Permalink
Browse files

Cleaned up config.php, moved ext > uuid and added float validator

  • Loading branch information...
1 parent cabc1ee commit 2065da49edc4dc0e58981b56b2731c01038bb588 @mjpearson committed Apr 18, 2010
Showing with 51 additions and 41 deletions.
  1. +2 −35 config.php
  2. +0 −5 lib/Core.class.php
  3. +4 −1 lib/Validator.class.php
  4. +45 −0 lib/loader.php
  5. 0 lib/{ext → uuid}/UUID.class.php
View
@@ -10,51 +10,18 @@
*/
//error_reporting(E_ALL);
$GLOBALS['THRIFT_ROOT'] = dirname(__FILE__).'/thrift-php/';
-
require_once $GLOBALS['THRIFT_ROOT'].'/packages/cassandra/Cassandra.php';
require_once $GLOBALS['THRIFT_ROOT'].'/transport/TSocket.php';
require_once $GLOBALS['THRIFT_ROOT'].'/protocol/TBinaryProtocol.php';
require_once $GLOBALS['THRIFT_ROOT'].'/transport/TFramedTransport.php';
require_once $GLOBALS['THRIFT_ROOT'].'/transport/TBufferedTransport.php';
-// Config xml path for Cassandra
-define('CASSANDRA_CONF_PATH', '/usr/local/src/apache-cassandra-incubating-0.5.0/conf/storage-conf.xml');
+require_once dirname(__FILE__).'/lib/loader.php';
define('MODEL_OUT_DIR', dirname(__FILE__).'/models/');
define('SCHEMA_PATH', dirname(__FILE__).'/schemas/');
define('THRIFT_PORT_DEFAULT', 9160);
define('DEFAULT_ROW_LIMIT', 10);
define('PERSIST_CONNECTIONS', FALSE); // TSocket Persistence
-
-function _pandraAutoLoad($className) {
-
- // seperate classes and interfaces for clarity
- $fExt = array('.class.php', '.interface.php');
-
- // strip prefix
- $className = preg_replace('/^pandra/i', '', $className);
-
- // class path relative to config
- $classPath = dirname(__FILE__)."/lib/";
-
- if (preg_match('/^(Query|Clause)/', $className)) {
- $classPath .= 'query/';
- } elseif (preg_match('/^Log/', $className)) {
- $classPath .= 'logging/';
- }
-
- foreach ($fExt as $ext) {
- $classFile = $classPath.$className.$ext;
- if (file_exists($classFile)) {
- require_once($classFile);
- break;
- // Check if it's an external class we might know about
- } else if (file_exists($classPath.'/ext/'.$className.$ext)) {
- require_once($classPath.'/ext/'.$className.$ext);
- break;
- }
- }
-}
-spl_autoload_register('_pandraAutoLoad');
-define('PANDRA_64', PHP_INT_SIZE == 8);
+define('CASSANDRA_CONF_PATH', '/usr/local/src/apache-cassandra-0.6.0/conf/storage-conf.xml');
?>
View
@@ -786,9 +786,4 @@ static public function getRangeKeys($keySpace,
}
}
}
-
-// Setup our capabilities
-PandraCore::setMemcachedAvailable(class_exists('Memcached'));
-
-PandraCore::setAPCAvailable(function_exists('apc_sma_info') && apc_sma_info() !== FALSE);
?>
@@ -132,8 +132,11 @@ static public function check($value, $label, $typeDefs, &$errors) {
if ($error) $errorMsg[] = "Invalid URL";
break;
- case 'int' :
case 'float' :
+ $error = !is_float($value);
+ if ($error) $errorMsg[] = "Field error, expected ".$type;
+ break;
+ case 'int' :
case 'numeric' :
$error = !is_numeric($value);
if ($error) $errorMsg[] = "Field error, expected ".$type;
View
@@ -0,0 +1,45 @@
+<?php
+/**
+ * Loader
+ *
+ * Handles autoloading for the Pandra package and calls Core static construction methods
+ *
+ * @author Michael Pearson <pandra-support@phpgrease.net>
+ * @copyright 2010 phpgrease.net
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
+ * @version 0.2
+ * @package pandra
+ */
+define('PANDRA_64', PHP_INT_SIZE == 8);
+function _pandraAutoLoad($className) {
+ // seperate classes and interfaces for clarity
+ $fExt = array('.class.php', '.interface.php');
+
+ // strip prefix
+ $className = preg_replace('/^pandra/i', '', $className);
+
+ // class path relative to config
+ $classPath = dirname(__FILE__)."/";
+
+ if (preg_match('/^(Query|Clause)/', $className)) {
+ $classPath .= 'query/';
+ } elseif (preg_match('/^Log/', $className)) {
+ $classPath .= 'logging/';
+ } elseif (preg_match('/^UUID/', $className)) {
+ $classPath .= 'uuid/';
+ }
+
+ foreach ($fExt as $ext) {
+ $classFile = $classPath.$className.$ext;
+ if (file_exists($classFile)) {
+ require_once($classFile);
+ break;
+ }
+ }
+}
+spl_autoload_register('_pandraAutoLoad');
+
+// Setup our capabilities
+PandraCore::setMemcachedAvailable(class_exists('Memcached'));
+PandraCore::setAPCAvailable(function_exists('apc_sma_info') && apc_sma_info() !== FALSE);
+?>
File renamed without changes.

0 comments on commit 2065da4

Please sign in to comment.