Skip to content

Commit

Permalink
Cleaned up config.php, moved ext > uuid and added float validator
Browse files Browse the repository at this point in the history
  • Loading branch information
mjpearson committed Apr 18, 2010
1 parent cabc1ee commit 2065da4
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 41 deletions.
37 changes: 2 additions & 35 deletions config.php
Expand Up @@ -10,51 +10,18 @@
*/ */
//error_reporting(E_ALL); //error_reporting(E_ALL);
$GLOBALS['THRIFT_ROOT'] = dirname(__FILE__).'/thrift-php/'; $GLOBALS['THRIFT_ROOT'] = dirname(__FILE__).'/thrift-php/';

require_once $GLOBALS['THRIFT_ROOT'].'/packages/cassandra/Cassandra.php'; require_once $GLOBALS['THRIFT_ROOT'].'/packages/cassandra/Cassandra.php';
require_once $GLOBALS['THRIFT_ROOT'].'/transport/TSocket.php'; require_once $GLOBALS['THRIFT_ROOT'].'/transport/TSocket.php';
require_once $GLOBALS['THRIFT_ROOT'].'/protocol/TBinaryProtocol.php'; require_once $GLOBALS['THRIFT_ROOT'].'/protocol/TBinaryProtocol.php';
require_once $GLOBALS['THRIFT_ROOT'].'/transport/TFramedTransport.php'; require_once $GLOBALS['THRIFT_ROOT'].'/transport/TFramedTransport.php';
require_once $GLOBALS['THRIFT_ROOT'].'/transport/TBufferedTransport.php'; require_once $GLOBALS['THRIFT_ROOT'].'/transport/TBufferedTransport.php';


// Config xml path for Cassandra require_once dirname(__FILE__).'/lib/loader.php';
define('CASSANDRA_CONF_PATH', '/usr/local/src/apache-cassandra-incubating-0.5.0/conf/storage-conf.xml');


define('MODEL_OUT_DIR', dirname(__FILE__).'/models/'); define('MODEL_OUT_DIR', dirname(__FILE__).'/models/');
define('SCHEMA_PATH', dirname(__FILE__).'/schemas/'); define('SCHEMA_PATH', dirname(__FILE__).'/schemas/');
define('THRIFT_PORT_DEFAULT', 9160); define('THRIFT_PORT_DEFAULT', 9160);
define('DEFAULT_ROW_LIMIT', 10); define('DEFAULT_ROW_LIMIT', 10);
define('PERSIST_CONNECTIONS', FALSE); // TSocket Persistence define('PERSIST_CONNECTIONS', FALSE); // TSocket Persistence

define('CASSANDRA_CONF_PATH', '/usr/local/src/apache-cassandra-0.6.0/conf/storage-conf.xml');
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);
?> ?>
5 changes: 0 additions & 5 deletions lib/Core.class.php
Expand Up @@ -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);
?> ?>
5 changes: 4 additions & 1 deletion lib/Validator.class.php
Expand Up @@ -132,8 +132,11 @@ static public function check($value, $label, $typeDefs, &$errors) {
if ($error) $errorMsg[] = "Invalid URL"; if ($error) $errorMsg[] = "Invalid URL";
break; break;


case 'int' :
case 'float' : case 'float' :
$error = !is_float($value);
if ($error) $errorMsg[] = "Field error, expected ".$type;
break;
case 'int' :
case 'numeric' : case 'numeric' :
$error = !is_numeric($value); $error = !is_numeric($value);
if ($error) $errorMsg[] = "Field error, expected ".$type; if ($error) $errorMsg[] = "Field error, expected ".$type;
Expand Down
45 changes: 45 additions & 0 deletions lib/loader.php
@@ -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.