Example #1
0
 *     'plugins' => array('/full/path/to/plugins/', '/next/full/path/to/plugins/'),
 *     'models' =>  array('/full/path/to/models/', '/next/full/path/to/models/'),
 *     'views' => array('/full/path/to/views/', '/next/full/path/to/views/'),
 *     'controllers' => array('/full/path/to/controllers/', '/next/full/path/to/controllers/'),
 *     'datasources' => array('/full/path/to/datasources/', '/next/full/path/to/datasources/'),
 *     'behaviors' => array('/full/path/to/behaviors/', '/next/full/path/to/behaviors/'),
 *     'components' => array('/full/path/to/components/', '/next/full/path/to/components/'),
 *     'helpers' => array('/full/path/to/helpers/', '/next/full/path/to/helpers/'),
 *     'vendors' => array('/full/path/to/vendors/', '/next/full/path/to/vendors/'),
 *     'shells' => array('/full/path/to/shells/', '/next/full/path/to/shells/'),
 *     'locales' => array('/full/path/to/locale/', '/next/full/path/to/locale/')
 * ));
 *
 */
App::build(array('plugins' => array(APP . 'extensions/')));
/**
 * As of 1.3, additional rules for the inflector are added below
 *
 * Inflector::rules('singular', array('rules' => array(), 'irregular' => array(), 'uninflected' => array()));
 * Inflector::rules('plural', array('rules' => array(), 'irregular' => array(), 'uninflected' => array()));
 *
 */
Cache::config('sl', array('engine' => 'File', 'prefix' => 'sl_', 'duration' => Configure::read() ? '+10 seconds' : '+999 days'));
Cache::config('models', array('engine' => 'File', 'prefix' => 'sl_', 'path' => CACHE . 'models' . DS, 'duration' => '+7 days'));
App::import('lib', 'sl');
App::import('lib', 'sl_configure');
App::import('lib', 'sl_extensions');
App::import('lib', 'sl_session');
App::import('lib', 'sl_cookie');
SlExtensions::trigger('bootstrap');
Configure::write('Routing.prefixes', array_keys(SlConfigure::read('Routing.prefixes')));
Example #2
0
 /**
  * Loads Components and prepares them for initialization.
  * Models will be lazy loaded by default
  *
  * @return mixed true if models found and instance created, or cakeError if models not found.
  * @access public
  * @see Controller::loadModel()
  * @link http://book.cakephp.org/view/977/Controller-Methods#constructClasses-986
  */
 function constructClasses()
 {
     if (SlExtensions::getInstance()->dependencyError) {
         $params = SlExtensions::getInstance()->dependencyError;
         SlExtensions::getInstance()->dependencyError = false;
         $this->cakeError('missingDependence', $params);
     }
     SlExtensions::trigger('constructClasses', $this);
     $this->__mergeVars();
     // Component class sets components by reference, hence triggering an uneeded read operation
     // Avoid magic __get() method calls by setting null values
     $this->components = Set::normalize($this->components);
     foreach ($this->components as $component => $settings) {
         if (strpos($component, '.') !== false) {
             list($plugin, $component) = explode('.', $component);
         }
         $this->{$component} = null;
     }
     if (!SlConfigure::read('Sl.options.lazyLoadModels')) {
         return parent::constructClasses();
     }
     $this->Component->init($this);
     if ($this->uses !== null || $this->uses !== array()) {
         if ($this->uses) {
             $uses = is_array($this->uses) ? $this->uses : array($this->uses);
             $modelClassName = $uses[0];
             if (strpos($uses[0], '.') !== false) {
                 list($plugin, $modelClassName) = explode('.', $uses[0]);
             }
             $this->modelClass = $modelClassName;
         }
     }
     return true;
 }
Example #3
0
 /**
  * Set the list of active collections
  *
  * @param array $collections names
  * @param bool $setDefault
  *
  * @return string Key to be used in restoreColections(...)
  */
 public static function setCollections($collections = array(), $setDefault = true)
 {
     if ($setDefault) {
         if (self::$_collections && SlExtensions::loaded('Auth')) {
             $user = SlAuth::user();
             if (isset($user['id'])) {
                 $groups = SlSession::read('Auth.groups');
                 $collections["users"] = 200;
                 if ($groups) {
                     foreach ($groups as $i => $group) {
                         $collections["Group{$group['id']}"] = 201 + $i;
                         $collections[$group['name']] = 201 + $i;
                     }
                 }
                 $collections["User{$user['id']}"] = 299;
             } else {
                 $collections["guest"] = 299;
             }
         }
         $controller = Sl::getInstance()->controller;
         if ($controller) {
             $collections["{$controller->name}Controller"] = 50;
             if (!empty($controller->params['home'])) {
                 $collections['home'] = 70;
             }
             if (!empty($controller->params['plugin'])) {
                 $plugin = Inflector::camelize($controller->params['plugin']);
                 $collections["{$plugin}Plugin"] = 60;
                 //                    $collections["{$plugin}{$controller->name}"] = 61;
             }
         }
         $collections = am(array('important' => 1000, 'cookie' => 10, 'session' => 20, 'global' => 0), $collections);
     }
     $collections = Set::normalize($collections);
     arsort($collections);
     self::$_collectionsNoLocale = $collections;
     $localizedCollections = array();
     foreach ($collections as $collection => $priority) {
         if (self::$_locale) {
             $localizedCollections[] = $collection . "." . self::$_locale;
         }
         $localizedCollections[] = $collection;
     }
     $key = self::rememberCollections();
     self::$_collections = $localizedCollections;
     self::_refresh();
     return $key;
 }
Example #4
0
 public static function trigger($hook, $params = null, $options = array())
 {
     return SlExtensions::getInstance()->_trigger($hook, $params, $options);
 }
Example #5
0
 /**
  * Registers a parser to handle a block in current layout
  *
  * @param string $blockName
  * @param PhemeParser $parser
  * @param string $skin Default (html) skin
  * @param bool $globalContext If true, the registered block could be triggered from layout's {body},
  *      if set to a string the block will be considered a child of the registered block with
  *      that name.
  * @return bool Success or null on error
  */
 public static function register($blockName, $parser = null, $skin = null, $globalContext = true)
 {
     $options = compact('blockName', 'parser', 'skin', 'globalContext');
     $options = SlExtensions::trigger('phemeRegister', $options);
     extract($options);
     // check if not already registered
     if (empty(self::$_registered[$blockName])) {
         // set default skin
         $skin = self::getSkin($skin);
         self::$_core->skins[$blockName] = $skin;
         // register parser
         if (is_string($parser)) {
             $parser = self::get($parser);
         }
         if (!is_object($parser)) {
             return;
         }
         self::$_registered[$blockName] = $parser;
         $parser->options['skinnable'] = true;
         // make block callable from layout's {body}
         if (is_string($globalContext)) {
             $parent = self::get($globalContext);
             $parent->blocks[$blockName] = $parser;
         } elseif ($globalContext) {
             self::$body->blocks[$blockName] = $parser;
         }
         return true;
     }
     return false;
 }
 public function auth()
 {
     $this->helpers[] = 'JsValidate.Validation';
     $this->set('title', __t('StarLight installation: Administrator profile'));
     if (!SlExtensions::loaded('Auth')) {
         $this->Session->setFlash(__t('Auth extension is disabled. All security settings will be ignored.'));
         $this->redirect(array('action' => 'done'));
     }
     //        $this->loadModel('Auth.AuthUser');
     $user = $this->AuthUser->read(null, 1);
     if ($user) {
         $this->Session->setFlash(__t('Administrator profile step skipped. A root user (<b>{$username}</b>) is already registered.', array('username' => $user['AuthUser']['username'])), array('class' => 'message'));
         $this->redirect(array('action' => 'done'));
     }
     if ($this->data) {
         $success = $this->data['AuthUser']['password'] == $this->data['AuthUser']['confirm_password'];
         if (!$success) {
             $this->AuthUser->invalidate('password', __t('Passwords do not match'));
             return;
         }
         $password = $this->data['AuthUser']['password'];
         $this->data['AuthGroup']['AuthGroup'] = array(1, 2);
         $this->data['AuthUser']['password'] = SlAuth::password($this->data['AuthUser']['password']);
         $this->data['AuthUser']['active'] = true;
         // force loading of associated model
         $this->AuthUser->AuthGroup;
         if ($this->AuthUser->saveAll($this->data)) {
             SlAuth::login($this->data['AuthUser']['username'], $password);
             $this->redirect(array('action' => 'done'));
         }
     }
 }