function __construct() { parent::__construct(); // Carga local de modelos if (isset($this->components) and is_array($this->components)) { foreach ($this->components as $component) { $local = APP::path('Controllers', array('Components')) . ucfirst(strtolower($component)) . 'Component.php'; if (file_exists($local)) { $this->load($component, 'Controllers', array('Components'), 'Component'); } else { $this->load($component, 'Lib', array('Controller', 'Components'), 'Component'); } } } }
/** * Constructor * * Carga los modelos y plugins de un controlador. * * @author Adrián Méndez <*****@*****.**> * @version 2.0 * */ public function __construct() { // Carga local de sesión $this->load('Session', 'Lib'); // Carga local de modelos if (isset($this->models) and is_array($this->models)) { foreach ($this->models as $model) { $local = APP::path('Models') . ucfirst(strtolower($model)) . 'Model.php'; if (file_exists($local)) { $this->load($model, 'Models', array(), 'Model'); } else { $this->load($model, 'Lib', array('Model'), 'Model'); } } } // Carga local de plugins if (is_array($this->plugins) and !empty($this->plugins)) { foreach ($this->plugins as $plugin) { $local = APP::path('Plugins', ucfirst(strtolower($plugin))) . ucfirst(strtolower($plugin)) . 'Plugin.php'; $this->load(ucfirst(strtolower($plugin)), 'Plugins', array(ucfirst(strtolower($plugin))), 'Plugin'); } } }
/** * Load * * Crea un objeto y clase definidas. * * El primer parámetro es obligatorio y debe ser el nombre del archivo Inc, y * coincidir * con el nombre de la clase, por ejemplo "Session.inc.php" y la clase "Session". * * El segundo parámetro es opcional y corresponde a la ubicación, por defecto * será raíz, done * se estima que deban ir todos los plugins que puedan ser accedidos por * controlador, modelos y vistas, como * el caso de sesion. * * @author Adrián Méndez <*****@*****.**> * @version 1.0 * */ public function load($class_name, $class_loc = null, $subs = null, $prefix = '.inc') { $object_name = ucfirst(strtolower($class_name)); $filename = APP::path($class_loc, $subs) . $class_name . $prefix . ".php"; if (file_exists($filename)) { include_once $filename; if ($prefix != '.inc') { $class_name .= ucfirst(strtolower($prefix)); } if (class_exists($class_name)) { $this->{$object_name} = new $class_name(); } else { die(sprintf('Library Found but Class names is missmatch! [%s]', $class_name)); } } else { die(sprintf('Library Not Found! [%s]', $filename)); } }
<?php /** * The url of the persona script tag. * It must be included on every page which uses navigator.id functions. * Because Persona is still in development, it shouldn't be localy cached. */ if (!Configure::read('Persona.scriptUrl')) { Configure::write('Persona.scriptUrl', 'https://login.persona.org/include.js'); } /** * URL of the service that's going to verify the indentity assertion */ if (!Configure::read('Persona.endpointUrl')) { Configure::write('Persona.endpointUrl', 'https://verifier.login.persona.org/verify'); } /** * Bundle of CA Root Certificates from Mozilla for usage with cURL * * @link http://curl.haxx.se/docs/caextract.html */ if (!Configure::read('Persona.sslCertPath')) { Configure::write('Persona.sslCertPath', false); $vendorPaths = APP::path('Vendor', 'Persona'); foreach ($vendorPaths as $path) { if (file_exists($path . 'cacert.pem')) { Configure::write('Persona.sslCertPath', $path . 'cacert.pem'); } } }
public static function build_element($element, $aParams = array()) { foreach ($aParams as $name => $data) { ${$name} = $data; } include APP::path('Views') . 'Elements/' . $element . ".ctp"; }
/** * Load Behaviors * * Carga los comportamientos incluidos en un modelo en especìfico. * * Ahora carga directamente desde los behaviors locales. * * @author Adrián Méndez <*****@*****.**> * @Version 1.1 */ protected function loadBehaviors() { if (isset($this->behaviors) and is_array($this->behaviors)) { foreach ($this->behaviors as $behaviors) { $local = APP::path('Models', array('Behaviors')) . ucfirst(strtolower($behaviors)) . 'Behavior.php'; if (file_exists($local)) { $this->load($behaviors, 'Models', array('Behaviors'), 'Behavior'); } else { $this->load($behaviors, 'Lib', array('Model', 'Behaviors'), 'Behavior'); } } } }
private function _controller_enviroment() { // Carga de controlador primario $this->{$this->controller}->data = $this->data; $this->{$this->controller}->template = self::$defaults['template']; $this->{$this->controller}->view = $this->action; $this->{$this->controller}->action = $this->action; $this->{$this->controller}->controller = $this->controller; $this->{$this->controller}->request = $this->request; $this->{$this->controller}->get = $this->getAttrs; // Revisa si hay que cargar componentes if (isset($this->{$this->controller}->components)) { if (!is_array($this->{$this->controller}->components)) { die('$components debe ser un array'); } foreach ($this->{$this->controller}->components as $c) { if (!is_null(self::$context)) { $local = APP::path('Controllers', array(ucfirst(strtolower(self::$context)), 'Components')) . ucfirst(strtolower($c)) . 'Component.php'; } else { $local = APP::path('Controllers', array('Components')) . ucfirst(strtolower($c)) . 'Component.php'; } if (file_exists($local)) { if (!is_null(self::$context)) { $this->{$this->controller}->load($c, 'Controllers', array(ucfirst(strtolower(self::$context)), 'Components'), 'Component'); } else { $this->{$this->controller}->load($c, 'Controllers', array('Components'), 'Component'); } } else { $this->{$this->controller}->load($c, 'Lib', array('Controller', 'Components'), 'Component'); } // PASA A LOS COMPONENTES EL CONTEXTO COMUN DE UN CONTROLADOR $this->{$this->controller}->{$c}->data = $this->data; $this->{$this->controller}->{$c}->template = self::$defaults['template']; $this->{$this->controller}->{$c}->view = $this->action; $this->{$this->controller}->{$c}->action = $this->action; $this->{$this->controller}->{$c}->controller = $this->controller; $this->{$this->controller}->{$c}->request = $this->request; $this->{$this->controller}->{$c}->get = $this->getAttrs; } } }