コード例 #1
0
                        overload(get_class($class));
                    } elseif (is_string($class)) {
                        overload($class);
                    }
                }
            } else {
                overload(get_class($this));
            }
        }
    }
    function __call($method, $params, &$return)
    {
        if (!method_exists($this, 'call__')) {
            trigger_error(sprintf(__('Magic method handler call__ not defined in %s', true), get_class($this)), E_USER_ERROR);
        }
        $return = $this->call__($method, $params);
        return true;
    }
    function __get($name, &$value)
    {
        $value = $this->get__($name);
        return true;
    }
    function __set($name, $value)
    {
        $this->set__($name, $value);
        return true;
    }
}
Overloadable::overload('Overloadable2');
コード例 #2
0
 /**
  * Constructor. Binds the model's database table to the object.
  *
  * @param integer $id Set this ID for this model on startup
  * @param string $table Name of database table to use.
  * @param object $ds DataSource connection object.
  */
 function __construct($id = false, $table = null, $ds = null)
 {
     parent::__construct();
     if (is_array($id)) {
         extract(array_merge(array('id' => $this->id, 'table' => $this->useTable, 'ds' => $this->useDbConfig, 'name' => $this->name, 'alias' => $this->alias), $id));
     }
     if ($this->name === null) {
         $this->name = isset($name) ? $name : get_class($this);
     }
     if ($this->alias === null) {
         $this->alias = isset($alias) ? $alias : $this->name;
     }
     if ($this->primaryKey === null) {
         $this->primaryKey = 'id';
     }
     ClassRegistry::addObject($this->alias, $this);
     $this->id = $id;
     unset($id);
     if ($table === false) {
         $this->useTable = false;
     } elseif ($table) {
         $this->useTable = $table;
     }
     if (is_subclass_of($this, 'AppModel')) {
         $appVars = get_class_vars('AppModel');
         $merge = array('_findMethods');
         if ($this->actsAs !== null || $this->actsAs !== false) {
             $merge[] = 'actsAs';
         }
         $parentClass = get_parent_class($this);
         if (strtolower($parentClass) !== 'appmodel') {
             $parentVars = get_class_vars($parentClass);
             foreach ($merge as $var) {
                 if (isset($parentVars[$var]) && !empty($parentVars[$var])) {
                     $appVars[$var] = Set::merge($appVars[$var], $parentVars[$var]);
                 }
             }
         }
         foreach ($merge as $var) {
             if (isset($appVars[$var]) && !empty($appVars[$var]) && is_array($this->{$var})) {
                 $this->{$var} = Set::merge($appVars[$var], $this->{$var});
             }
         }
     }
     $this->Behaviors = new BehaviorCollection();
     if ($this->useTable !== false) {
         $this->setDataSource($ds);
         if ($this->useTable === null) {
             $this->useTable = Inflector::tableize($this->name);
         }
         if (method_exists($this, 'setTablePrefix')) {
             $this->setTablePrefix();
         }
         $this->setSource($this->useTable);
         if ($this->displayField == null) {
             $this->displayField = $this->hasField(array('title', 'name', $this->primaryKey));
         }
     } elseif ($this->table === false) {
         $this->table = Inflector::tableize($this->name);
     }
     $this->__createLinks();
     $this->Behaviors->init($this->alias, $this->actsAs);
 }
コード例 #3
0
 /**
  * Used to overload objects as needed.
  *
  * @param string $type Model or Helper
  * @param string $name Class name to overload
  * @access private
  */
 function __overload($type, $name, $parent)
 {
     if (($type === 'Model' || $type === 'Helper') && $parent !== false) {
         Overloadable::overload($name);
     }
 }
コード例 #4
0
ファイル: configure.php プロジェクト: afzet/connectivo-crm
 /**
  * Used to overload objects as needed.
  *
  * @param string $type Model or Helper
  * @param string $name Class name to overload
  * @access private
  */
 function __overload($type, $name)
 {
     if (($type === 'Model' || $type === 'Helper') && strtolower($name) != 'schema') {
         Overloadable::overload($name);
     }
 }
コード例 #5
0
ファイル: model.php プロジェクト: BLisa90/cakecart
 /**
  * Constructor. Binds the Model's database table to the object.
  *
  * @param integer $id Set this ID for this model on startup
  * @param string $table Name of database table to use.
  * @param object $ds DataSource connection object.
  */
 function __construct($id = false, $table = null, $ds = null)
 {
     parent::__construct();
     if (is_array($id)) {
         extract(array_merge(array('id' => false, 'table' => null, 'ds' => null, 'name' => null, 'alias' => null), $id));
         $this->name = $name;
         $this->alias = $alias;
     }
     if ($this->name === null) {
         $this->name = get_class($this);
     }
     if ($this->alias === null) {
         $this->alias = $this->name;
     }
     if ($this->primaryKey === null) {
         $this->primaryKey = 'id';
     }
     ClassRegistry::addObject($this->alias, $this);
     $this->id = $id;
     unset($id);
     if ($table === false) {
         $this->useTable = false;
     } elseif ($table) {
         $this->useTable = $table;
     }
     if ($this->useTable !== false) {
         $this->setDataSource($ds);
         if ($this->useTable === null) {
             $this->useTable = Inflector::tableize($this->name);
         }
         if (in_array('settableprefix', get_class_methods($this))) {
             $this->setTablePrefix();
         }
         $this->setSource($this->useTable);
         $this->__createLinks();
         if ($this->displayField == null) {
             $this->displayField = $this->hasField(array('title', 'name', $this->primaryKey));
         }
     }
     if (is_subclass_of($this, 'AppModel')) {
         $appVars = get_class_vars('AppModel');
         $merge = array();
         if ($this->actsAs !== null || $this->actsAs !== false) {
             $merge[] = 'actsAs';
         }
         foreach ($merge as $var) {
             if (isset($appVars[$var]) && !empty($appVars[$var]) && is_array($this->{$var})) {
                 $this->{$var} = Set::merge($appVars[$var], $this->{$var});
             }
         }
     }
     $this->Behaviors = new BehaviorCollection();
     $this->Behaviors->init($this->alias, $this->actsAs);
 }
コード例 #6
0
ファイル: basics.php プロジェクト: kaz0636/openflp
/**
 * @deprecated
 * @see App::import('Model', 'PluginName.PluginModel');
 */
function loadPluginModels($plugin)
{
    if (!class_exists('AppModel')) {
        loadModel();
    }
    $plugin = Inflector::underscore($plugin);
    $pluginAppModel = Inflector::camelize($plugin . '_app_model');
    $pluginAppModelFile = APP . 'plugins' . DS . $plugin . DS . $plugin . '_app_model.php';
    if (!class_exists($pluginAppModel)) {
        if (file_exists($pluginAppModelFile)) {
            require $pluginAppModelFile;
            Overloadable::overload($pluginAppModel);
        }
    }
    $pluginModelDir = APP . 'plugins' . DS . $plugin . DS . 'models' . DS;
    if (is_dir($pluginModelDir)) {
        foreach (listClasses($pluginModelDir) as $modelFileName) {
            list($name) = explode('.', $modelFileName);
            $className = Inflector::camelize($name);
            if (!class_exists($className)) {
                require $pluginModelDir . $modelFileName;
                Overloadable::overload($className);
            }
        }
    }
    trigger_error('loadPluginModels is deprecated see App::import(\'Model\', \'PluginName.PluginModel\');', E_USER_WARNING);
}
コード例 #7
0
ファイル: configure.php プロジェクト: kaz0636/openflp
 /**
  * Used to overload Objects as needed
  *
  * @param string $type Model or Helper
  * @param string $name Class name to overload
  * @access private
  */
 function __overload($type, $name)
 {
     $overload = array('Model', 'Helper');
     if (in_array($type, $overload)) {
         Overloadable::overload($name);
     }
 }
コード例 #8
0
/**
 * Loads a helper
 *
 * @param string $name Name of helper
 * @return boolean Success
 */
function loadHelper($name)
{
    if (!class_exists('AppHelper')) {
        if (file_exists(APP . 'app_helper.php')) {
            require APP . 'app_helper.php';
        } else {
            require CAKE . 'app_helper.php';
        }
        Overloadable::overload('AppHelper');
    }
    if ($name === null) {
        return true;
    }
    if (strpos($name, '.') !== false) {
        list($plugin, $name) = explode('.', $name);
    }
    $className = $name . 'Helper';
    if (!class_exists($className)) {
        $name = Inflector::underscore($name);
        $helpers = Configure::read('Helpers');
        if (is_array($helpers)) {
            if (array_key_exists($className, $helpers)) {
                require $helpers[$className]['path'];
                return true;
            } elseif (isset($helpers['Core']) && array_key_exists($className, $helpers['Core'])) {
                require $helpers['Core'][$className]['path'];
                return true;
            }
        }
        $paths = Configure::getInstance();
        foreach ($paths->helperPaths as $path) {
            if (file_exists($path . $name . '.php')) {
                Configure::store('Helpers', 'class.paths', array($className => array('path' => $path . $name . '.php')));
                require $path . $name . '.php';
                return true;
            }
        }
        if ($helperFilename = fileExistsInPath(LIBS . 'view' . DS . 'helpers' . DS . $name . '.php')) {
            if (file_exists($helperFilename)) {
                Configure::store('Helpers\'][\'Core', 'class.paths', array($className => array('path' => $helperFilename)));
                require $helperFilename;
                return true;
            } else {
                return false;
            }
        }
        return false;
    }
    return true;
}
コード例 #9
0
ファイル: model.php プロジェクト: rhencke/mozilla-cvs-history
 /**
  * Constructor. Binds the Model's database table to the object.
  *
  * @param integer $id
  * @param string $table Name of database table to use.
  * @param DataSource $ds DataSource connection object.
  */
 function __construct($id = false, $table = null, $ds = null)
 {
     parent::__construct();
     if (is_array($id) && isset($id['name'])) {
         $options = am(array('id' => false, 'table' => null, 'ds' => null, 'alias' => null), $id);
         list($id, $table, $ds) = array($options['id'], $options['table'], $options['ds']);
         $this->name = $options['name'];
     }
     if ($this->name === null) {
         $this->name = get_class($this);
     }
     if ($this->primaryKey === null) {
         $this->primaryKey = 'id';
     }
     if (isset($options['alias']) || !empty($options['alias'])) {
         $this->currentModel = Inflector::underscore($options['alias']);
         unset($options);
     } else {
         $this->currentModel = Inflector::underscore($this->name);
     }
     ClassRegistry::addObject($this->currentModel, $this);
     ClassRegistry::map($this->currentModel, $this->currentModel);
     $this->id = $id;
     unset($id);
     if ($table === false) {
         $this->useTable = false;
     } elseif ($table) {
         $this->useTable = $table;
     }
     if ($this->useTable !== false) {
         $this->setDataSource($ds);
         if ($this->useTable === null) {
             $this->useTable = Inflector::tableize($this->name);
         }
         if (in_array('settableprefix', get_class_methods($this))) {
             $this->setTablePrefix();
         }
         $this->setSource($this->useTable);
         $this->__createLinks();
         if ($this->displayField == null) {
             if ($this->hasField('title')) {
                 $this->displayField = 'title';
             }
             if ($this->hasField('name')) {
                 $this->displayField = 'name';
             }
             if ($this->displayField == null) {
                 $this->displayField = $this->primaryKey;
             }
         }
     }
     if (is_subclass_of($this, 'AppModel')) {
         $appVars = get_class_vars('AppModel');
         $actsAs = $appVars['actsAs'];
         $merge = array('actsAs');
         if ($this->actsAs !== null || $this->actsAs !== false) {
             $merge[] = 'actsAs';
         }
         foreach ($merge as $var) {
             if (isset($appVars[$var]) && !empty($appVars[$var]) && is_array($this->{$var})) {
                 $this->{$var} = array_merge($this->{$var}, array_diff($appVars[$var], $this->{$var}));
             }
         }
     }
     if ($this->actsAs !== null && empty($this->behaviors)) {
         $callbacks = array('setup', 'beforeFind', 'afterFind', 'beforeSave', 'afterSave', 'beforeDelete', 'afterDelete', 'afterError');
         $this->actsAs = Set::normalize($this->actsAs);
         foreach ($this->actsAs as $behavior => $config) {
             $className = $behavior . 'Behavior';
             if (!loadBehavior($behavior)) {
                 // Raise an error
             } else {
                 if (ClassRegistry::isKeySet($className)) {
                     if (PHP5) {
                         $this->behaviors[$behavior] = ClassRegistry::getObject($className);
                     } else {
                         $this->behaviors[$behavior] =& ClassRegistry::getObject($className);
                     }
                 } else {
                     if (PHP5) {
                         $this->behaviors[$behavior] = new $className();
                     } else {
                         $this->behaviors[$behavior] =& new $className();
                     }
                     ClassRegistry::addObject($className, $this->behaviors[$behavior]);
                 }
                 $this->behaviors[$behavior]->setup($this, $config);
                 $methods = $this->behaviors[$behavior]->mapMethods;
                 foreach ($methods as $method => $alias) {
                     if (!array_key_exists($method, $this->__behaviorMethods)) {
                         $this->__behaviorMethods[$method] = array($alias, $behavior);
                     }
                 }
                 $methods = get_class_methods($this->behaviors[$behavior]);
                 $parentMethods = get_class_methods('ModelBehavior');
                 foreach ($methods as $m) {
                     if (!in_array($m, $parentMethods)) {
                         if (strpos($m, '_') !== 0 && !array_key_exists($m, $this->__behaviorMethods) && !in_array($m, $callbacks)) {
                             $this->__behaviorMethods[$m] = array($m, $behavior);
                         }
                     }
                 }
             }
         }
     }
 }