Example #1
0
 function initialize()
 {
     # setup database configuration
     if (!$this->_table_name) {
         if (!$this->_base_class) {
             $class = get_class($this);
             while (get_parent_class($class) && !preg_match('/_Base$/i', get_parent_class($class))) {
                 $class = get_parent_class($class);
             }
             $this->_base_class = $class;
         }
         $this->_table_name = Inflector::tableize($this->_base_class);
     }
     $this->_type_name = get_class($this);
     $this->_columns = AdoDBRecord_Tools::get_columns();
     # dynamically overload current class in PHP4 because it doesn't
     # propagate through the class hierarchy
     if (version_compare(PHP_VERSION, "5.0.0") < 0) {
         $const = "OVERLOADED_" . $this->_type_name;
         if (!defined($const)) {
             define($const, $const);
             overload($this->_type_name);
         }
     }
     # call the setup hook
     $this->setup();
 }
Example #2
0
 function overload()
 {
     if (function_exists('overload')) {
         if (func_num_args() > 0) {
             foreach (func_get_args() as $class) {
                 if (is_object($class)) {
                     overload(get_class($class));
                 } elseif (is_string($class)) {
                     overload($class);
                 }
             }
         } else {
             overload(get_class($this));
         }
     }
 }
Example #3
0
    /**
     *	@short Adds an object to the object pool.
     *	@param classname Name of the class for the desired object.
     *	@param id Primary key value for the desired object.
     *	@param obj The object to add to the pool.
     */
    private static function _add_to_pool($classname, $id, $obj)
    {
        if (!isset(self::$object_pool[$classname])) {
            self::$object_pool[$classname] = array();
        }
        self::$object_pool[$classname][$id] = $obj;
    }
    /**
     *	@short Retrieves an object from the object pool.
     *	@param classname Name of the class for the desired object.
     *	@param id Primary key value for the desired object.
     */
    private static function _get_from_pool($classname, $id)
    {
        if (!isset(self::$object_pool[$classname]) || !isset(self::$object_pool[$classname][$id])) {
            return NULL;
        }
        return self::$object_pool[$classname][$id];
    }
}
if (version_compare(PHP_VERSION, '5') < 0) {
    if (function_exists("overload")) {
        overload('ActiveRecord');
    }
}
Example #4
0
    }
    /**
     * SOAP_Client::__call
     *
     * Overload extension support
     * if the overload extension is loaded, you can call the client class
     * with a soap method name
     * $soap = new SOAP_Client(....);
     * $value = $soap->getStockQuote('MSFT');
     *
     * @param string method
     * @param array  args
     * @param string retur_value
     *
     * @return boolean
     * @access public
     */
    function __call($method, $args, &$return_value)
    {
        if (!$this->wsdl) {
            return FALSE;
        }
        #$return_value = call_user_func_array(array(&$this, 'my_' . $method), $args);
        $this->wsdl->matchMethod($method);
        $return_value = $this->call($method, $args);
        return TRUE;
    }
}
if (extension_loaded('overload')) {
    overload('SOAP_Client');
}
Example #5
0
function make_object_extendable($classname)
{
    if (_PHP_ < 5) {
        overload($classname);
    }
}
        }
        return $siblingList;
    }
    /**
     * Associates the sibling object to this one
     * @return 
     */
    function AddSibling($sibling)
    {
        if (is_a($sibling, "sibling")) {
            foreach (array_keys($sibling->_objectList) as $key) {
                $otherObject =& $sibling->_objectList[$key];
                if ($otherObject === $this) {
                    return false;
                }
            }
            $found = false;
            foreach ($this->_siblingList as $sibling2) {
                if ($sibling->siblingId > 0 && $sibling->siblingId == $sibling2->siblingId) {
                    $found = true;
                    break;
                }
            }
            if (!$found) {
                $this->_siblingList[] =& $sibling;
            }
        }
    }
}
overload('object');
Example #7
0
                clearCache($assoc);
                return true;
            }
        } else {
            //Will use for query cache deleting
        }
    }
    /**
     * Called when serializing a model
     *
     * @return array
     * @access public
     */
    function __sleep()
    {
        $return = array_keys(get_object_vars($this));
        return $return;
    }
    /**
     * Called when unserializing a model
     *
     * @return void
     * @access public
     */
    function __wakeup()
    {
    }
}
// --- PHP4 Only
overload('Model');
// --- PHP4 Only
Example #8
0
 * CakePHP(tm) :  Rapid Development Framework <http://www.cakephp.org/>
 * Copyright 2005-2007, Cake Software Foundation, Inc.
 *								1785 E. Sahara Avenue, Suite 490-204
 *								Las Vegas, Nevada 89104
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @filesource
 * @copyright		Copyright 2005-2007, Cake Software Foundation, Inc.
 * @link				http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
 * @package			cake
 * @subpackage		cake.cake.libs.model
 * @since			CakePHP(tm) v 0.10.0.0
 * @version			$Revision: 4409 $
 * @modifiedby		$LastChangedBy: phpnut $
 * @lastmodified	$Date: 2007-02-02 07:20:59 -0600 (Fri, 02 Feb 2007) $
 * @license			http://www.opensource.org/licenses/mit-license.php The MIT License
 */
/**
 * Load the model class based on the version of PHP.
 *
 */
if (phpversion() < 5) {
    require LIBS . 'model' . DS . 'model_php4.php';
    if (function_exists("overload")) {
        overload("Model");
    }
} else {
    require LIBS . 'model' . DS . 'model_php5.php';
}
Example #9
0
    }
    function sub($part, $num = 1)
    {
        return $this->__dateOperation('-', $part, $num);
    }
    function substract($part, $num = 1)
    {
        return $this->__dateOperation('-', $part, $num);
    }
    function __toString()
    {
        return $this->getDateTime();
    }
}
if (function_exists('overload') && phpversion() < 5) {
    overload('HessDateTime');
}
/*
// Tests

$date1 = new DateTime('2004-09-06 8:00:00');
$date2 = new DateTime('2004-09-06 9:00:00');
$date3 = new DateTime('2004-09-06 8:00:00');


if($date1->isBefore($date2))
	echo 'si<br>';
if($date2->isAfter($date1))
	echo 'si<br>';
if($date1->equals($date3))
	echo 'si<br>';
    function SetObjectList($list)
    {
        $this->_objectList = array();
        $existingObjectList = $this->GetObjectList();
        foreach ($existingObjectList as $object) {
            $object->parent_Id = '';
            $object->Save(false);
        }
        $this->_objectList =& $list;
    }
    /**
     * Associates the object object to this one
     * @return 
     */
    function AddObject($object)
    {
        $object->parent_Id = $this->parent_Id;
        $found = false;
        foreach ($this->_objectList as $object2) {
            if ($object->objectId > 0 && $object->objectId == $object2->objectId) {
                $found = true;
                break;
            }
        }
        if (!$found) {
            $this->_objectList[] =& $object;
        }
    }
}
overload('parent_');
    /**
     * getCmdResult 
     *  returns the result returned by the command, or error in case the command failed. 
     * @access public
     * @return mixed string on sucess, false and error on faliure.
     */
    function getCmdResult()
    {
        $descriptorspec = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
        $proc = proc_open($this->getCmdForExec(), $descriptorspec, $pipes);
        //so long...
        fclose($pipes[0]);
        $stdout = NULL;
        $stderr = NULL;
        foreach (array('stdout' => $pipes[1], 'stderr' => $pipes[2]) as $pipename => $piperes) {
            while (!feof($piperes)) {
                ${$pipename} .= fgets($piperes);
            }
            fclose($piperes);
        }
        if (!empty($stderr)) {
            trigger_error(sprintf('Command %s failed : %s', htmlspecialchars($this->command), htmlspecialchars($stderr)));
            return false;
        }
        return $stdout;
    }
}
//PHP4 requires this non-sense
if (PHP_VERSION < 5) {
    overload('CommandExecution');
}
Example #12
0
    function __get_foo(&$value)
    {
        debug("Fetching foo...");
        $value = 'BAR';
    }
    function __set($propname, $value)
    {
        debug("Setting {$propname} to {$value}...");
        $this->props[$propname] = $value;
        return true;
    }
    function __call($methodname, $args, &$ret)
    {
        debug("Calling {$methodname}...");
        $func = $this->methods[$methodname];
        if (isset($func)) {
            $ret = call_user_func_array($func, $args);
        }
        return true;
    }
}
overload('OverloadMe');
$obj =& new OverloadMe();
// Property overloading
$obj->someprop = 'BAM BAM GO BAM';
print $obj->someprop;
// Print out property $foo which is a special case and
// directly handled
print $obj->foo;
// Method overloading
print $obj->convn2br("\n\nYABBADABBADOOOOO\n\n");
                    }
                    if (isset($this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes']) && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'SET') {
                        $pog_query = $pog_query . "`" . $fcv_array[$i][0] . "` " . $fcv_array[$i][1] . " '" . $this->Escape($fcv_array[$i][2]) . "'";
                    } else {
                        $pog_query = $pog_query . "`" . $fcv_array[$i][0] . "` " . $fcv_array[$i][1] . " '" . $fcv_array[$i][2] . "'";
                    }
                }
            }
            return Database::NonQuery($pog_query, $connection);
        }
    }
    /**
     * Associates the object object to this one
     * @return boolean
     */
    function GetObject()
    {
        $object = new object();
        return $object->Get($this->objectId);
    }
    /**
     * Associates the object object to this one
     * @return 
     */
    function SetObject(&$object)
    {
        $this->objectId = $object->objectId;
    }
}
overload('child');
Example #14
0
        if ($contextnode === NULL) {
            $result = $xpath->xpath_eval($expression);
        } else {
            $result = $xpath->xpath_eval($expression, DoceboDOMNode::getRef($contextnode));
        }
        return createDoceboDOMObject($result->nodeset, FALSE);
    }
}
overload("DoceboDOMNode");
overload("DoceboDOMText");
overload("DoceboDOMDocument");
overload("DoceboDOMDocumentType");
overload("DoceboDOMAttr");
overload("DoceboDOMElement");
overload("DoceboDOMNodeList");
overload("DoceboDOMNamedNodeMap");
function _doceboNodePropertyGet(&$obj, $param, &$value)
{
    $ret_bool = TRUE;
    $secondChoice = FALSE;
    switch ($param) {
        case "nodeName":
            $value = $obj->nodeRef->node_name();
            return $ret_bool;
        case "nodeValue":
            $value = $obj->nodeRef->node_value();
            return $ret_bool;
        case "nodeType":
            $value = $obj->nodeRef->node_type();
            return $ret_bool;
        case "parentNode":
Example #15
0
} else {
    if (phpversion() < 5) {
        $class = <<<TEXT
        class XML_FastCreate_Overload extends PEAR {
            function __call(\$method, \$args, &\$return)
            {
                if (\$method != __CLASS__) {
                    \$return = \$this->_call(\$method, \$args);
                }
                return true;
            }
        }
TEXT;
        eval($class);
        if (function_exists('overload')) {
            overload('XML_FastCreate_Overload');
        }
    } else {
        $class = <<<TEXT
        class XML_FastCreate_Overload extends PEAR {
            function __call(\$method, \$args) 
            {
                if (\$method != __CLASS__) {
                    return \$this->_call(\$method, \$args);
                }
            }
        }
TEXT;
        eval($class);
    }
}
Example #16
0
            $ident = isset($this) && is_a($this, __CLASS__) ? get_class($this) : __CLASS__;
        }
        NDebug::debug($message, $debug_type, $log_level, $ident);
    }
}
class NModelError extends PEAR_Error
{
    /**
     * NModelError constructor.
     *
     * @param mixed      NModel error code, or string with error message.
     * @param integer    what "error mode" to operate in
     * @param integer    what error level to use for $mode & PEAR_ERROR_TRIGGER
     * @param mixed      additional debug info, such as the last query
     *
     * @access public
     *
     * @see PEAR_Error
     */
    function Model_Error($code = N_DAO_ERROR, $mode = PEAR_ERROR_RETURN, $level = E_USER_NOTICE, $debuginfo = null)
    {
        if (is_int($code)) {
            $this->PEAR_Error('N_DAO Error: ' . NModel::errorMessage($code), $code, $mode, $level, $debuginfo);
        } else {
            $this->PEAR_Error("N_DAO Error: {$code}", N_DAO_ERROR, $mode, $level, $debuginfo);
        }
    }
}
if (version_compare(phpversion(), "5") < 0) {
    overload('NModel');
}
Example #17
0
 * Provides an interface to the System class of the CentovaCast XML API.
 */
class CCSystemAPIClient extends CCBaseAPIClient
{
    var $classname = 'system';
    function CCSystemAPIClient($ccurl)
    {
        $this->cc_initialize($ccurl);
    }
    function build_argument_payload($functionargs)
    {
        if (count($functionargs) < 2) {
            trigger_error(sprintf('Function %s requires a minimum of 2 arguments, %d given', $this->methodname, count($functionargs)), E_USER_WARNING);
        }
        $adminpassword = $functionargs[0];
        $arguments = $functionargs[1];
        if (!is_array($arguments)) {
            $arguments = array();
        }
        $arguments = array_merge(array('password' => $adminpassword), $arguments);
        return $this->build_argument_xml($arguments);
    }
}
if (!defined('CCAPI_NO_OVERLOAD')) {
    if (function_exists('overload')) {
        overload('CCSystemAPIClient');
        overload('CCServerAPIClient');
    } elseif (version_compare(PHP_VERSION, '5.0.0', '<')) {
        die('The CentovaCast PHP API client requires that object overloading support is built into PHP.');
    }
}
Example #18
0
    }
    function sub($part, $num = 1)
    {
        return $this->__dateOperation('-', $part, $num);
    }
    function substract($part, $num = 1)
    {
        return $this->__dateOperation('-', $part, $num);
    }
    function __toString()
    {
        return $this->getHessian_DateTime();
    }
}
if (function_exists('overload') && phpversion() < 5) {
    overload('Hessian_DateTime');
}
/*
// Tests

$date1 = new Hessian_DateTime('2004-09-06 8:00:00');
$date2 = new Hessian_DateTime('2004-09-06 9:00:00');
$date3 = new Hessian_DateTime('2004-09-06 8:00:00');


if($date1->isBefore($date2))
	echo 'si<br>';
if($date2->isAfter($date1))
	echo 'si<br>';
if($date1->equals($date3))
	echo 'si<br>';
Example #19
0
        $options = $_DB_DATAOBJECT['CONFIG'];
        $null_strings = !isset($options['disable_null_strings']) || $options['disable_null_strings'] === false;
        $crazy_null = isset($options['disable_null_strings']) && is_string($options['disable_null_strings']) && strtolower($options['disable_null_strings'] === 'full');
        if ($null_strings && $isset && is_string($value) && strtolower($value) === 'null') {
            return true;
        }
        if ($crazy_null && !$isset) {
            return true;
        }
        return false;
    }
    /* ---- LEGACY BC METHODS - NOT DOCUMENTED - See Documentation on New Methods. ---*/
    function _get_table()
    {
        return $this->table();
    }
    function _get_keys()
    {
        return $this->keys();
    }
}
// technially 4.3.2RC1 was broken!!
// looks like 4.3.3 may have problems too....
if (!defined('DB_DATAOBJECT_NO_OVERLOAD')) {
    if (phpversion() != '4.3.2-RC1' && version_compare(phpversion(), "4.3.1") > 0) {
        if (version_compare(phpversion(), "5") < 0) {
            overload('DB_DataObject');
        }
        $GLOBALS['_DB_DATAOBJECT']['OVERLOADED'] = true;
    }
}
 **/
class HessianClient
{
    /**
     * Constructor, requires the url of the remote Hessian service
     *  
     * @param string url Url of the remote service
     **/
    function HessianClient($url, $options = false)
    {
        $this->__hessian__proxy__ =& Hessian::getHessianProxy($url, $options);
    }
    /**
     * PHP magic function used to execute a remote call to a remote Hessian service.
     *  
     * @param string method Method name
     * @param array params Arguments
     * @param mixed return Returned value
     * @return mixed True if PHP 4, return value of the function otherwise
     * @access public 
     **/
    function __call($method, $params, &$return)
    {
        $return = $this->__hessian__proxy__->call($method, $params);
        return true;
    }
}
// Call the overload() function when appropriate
if (function_exists('overload')) {
    overload('HessianClient');
}
    // }}}
    // {{{ __call()
    /**
     * Overloaded object call handler, called each time an
     * undefined/aggregated method is invoked.  This method repeats
     * the call in the right aggregate object and passes on the return
     * value.
     *
     * @param string $method  which method that was called
     *
     * @param string $args    An array of the parameters passed in the
     *                        original call
     *
     * @return mixed  The return value from the aggregated method, or a PEAR
     *                error if the called method was unknown.
     */
    function __call($method, $args)
    {
        $method = strtolower($method);
        if (empty($this->_method_map[$method]) && isset($this->_autoload_map[$method])) {
            $this->addAggregateObject($this->_autoload_map[$method]);
        }
        if (isset($this->_method_map[$method])) {
            $retval = call_user_func_array(array($this->_method_map[$method], $method), $args);
            return true;
        }
        return false;
    }
}
overload("PEAR_Autoloader");
        }
        return $objectList;
    }
    /**
     * Associates the object object to this one
     * @return 
     */
    function AddObject($object)
    {
        if (is_a($object, "object")) {
            foreach (array_keys($object->_siblingList) as $key) {
                $otherSibling =& $object->_siblingList[$key];
                if ($otherSibling === $this) {
                    return false;
                }
            }
            $found = false;
            foreach ($this->_objectList as $object2) {
                if ($object->objectId > 0 && $object->objectId == $object2->objectId) {
                    $found = true;
                    break;
                }
            }
            if (!$found) {
                $this->_objectList[] =& $object;
            }
        }
    }
}
overload('sibling');
Example #23
0
/**
 * Loads a model by CamelCase name.
 */
function loadModel($name = null)
{
    if (!class_exists('Model')) {
        require LIBS . 'model' . DS . 'model.php';
    }
    if (!class_exists('AppModel')) {
        if (file_exists(APP . 'app_model.php')) {
            require APP . 'app_model.php';
        } else {
            require CAKE . 'app_model.php';
        }
        if (phpversion() < 5 && function_exists("overload")) {
            overload('AppModel');
        }
    }
    if (!is_null($name) && !class_exists($name)) {
        $className = $name;
        $name = Inflector::underscore($name);
        $paths = Configure::getInstance();
        foreach ($paths->modelPaths as $path) {
            if (file_exists($path . $name . '.php')) {
                require $path . $name . '.php';
                if (phpversion() < 5 && function_exists("overload")) {
                    overload($className);
                }
                return true;
            }
        }
        return false;
    } else {
        return true;
    }
}
Example #24
0
    var $classname;
    var $filepath;
    var $loaded;
    var $object;
    /**
     * Constructor
     *
     * @param string $classname
     * @param string $filepath
     */
    function LazyLoad($classname, $filepath)
    {
        $this->classname = $classname;
        $this->filepath = $filepath;
        $this->loaded = false;
        $this->object = null;
    }
    function __call($name, $args, &$ret)
    {
        if (!$this->loaded) {
            require_once $this->filepath;
            $this->object = new $this->classname();
            $this->loaded = true;
        }
        // proxy the call to the real object
        $ret = call_user_func_array(array(&$this->object, $name), $args);
        return true;
    }
}
overload('LazyLoad');