Exemplo n.º 1
0
 public function preDispatch()
 {
     $this->cr = Core::$mode == 'cli' ? "\n" : '<br/>';
     // get active modules list
     // detect existing CronController()
     foreach (Module::getConfig() as $vendor => $modules) {
         foreach ($modules as $key => $module) {
             // ignore disabled module
             if ($module['enabled'] != true) {
                 continue;
             }
             // ignore module without controller (rare though)
             if (!isset($module['controller'])) {
                 continue;
             }
             $path = Core::$basePath . "application/modules/{$vendor}/{$key}/controllers/CronController.php";
             if (file_exists($path)) {
                 $this->_modules[$vendor . '/' . $key] = $module;
             }
         }
     }
 }
Exemplo n.º 2
0
 public function init()
 {
     // Just in cas something goes wrong before the end
     // @todo replace with a setTemplate() in t41\Exception
     View::setTemplate('default.html');
     // get page identifiers (module, controller and action)
     Layout::$module = $this->_getParam('module');
     Layout::$controller = $this->_getParam('controller');
     Layout::$action = $this->_getParam('action');
     // provide controller with basic information about the current module
     foreach (Module::getConfig() as $vendor => $modules) {
         foreach ($modules as $key => $module) {
             if (isset($module['controller']) && Layout::$module == $module['controller']['base']) {
                 $this->_module = 'app/' . $vendor . '/' . $key;
                 Layout::$vendor = $vendor;
                 Layout::$moduleKey = $key;
                 $resource = Layout::$controller;
                 if (Layout::$action) {
                     $resource .= '/' . Layout::$action;
                 }
                 if (isset($module['controller']['items'])) {
                     foreach ($module['controller']['items'] as $controller) {
                         if ($this->_getCurrentItem($resource, $controller) == true) {
                             break;
                         }
                     }
                 }
                 if (isset($module['controllers_extends'])) {
                     foreach ($module['controllers_extends'] as $controller) {
                         if ($this->_getCurrentItem($resource, $controller['items']) == true) {
                             break;
                         }
                     }
                 }
                 break;
             }
         }
     }
 }
Exemplo n.º 3
0
 /**
  * Detect all modules directories and try to get config for them
  * @param string $path
  */
 public static function init($path)
 {
     if (Core::getEnvData('cache_configs') !== false) {
         $ckey = 'configs_acl';
         if (($cached = Core::cacheGet($ckey)) !== false) {
             self::$_config = $cached;
             return;
         }
     }
     // load application acl configuration file
     $config = Config\Loader::loadConfig('acl.xml', Config::REALM_CONFIGS);
     $resources = array();
     // add all fragments coming from modules
     foreach (Core\Module::getConfig() as $vendorId => $vendorModules) {
         foreach ($vendorModules as $key => $module) {
             // module menus
             if (isset($module['controller']) && isset($module['controller']['items'])) {
                 // walk recursively through all module's items (menu elements)
                 $resources += self::_getAcl($module['controller']['base'], $module['controller']['items']);
             }
             // and optional menus extensions
             if (isset($module['controllers_extends'])) {
                 foreach ($module['controllers_extends'] as $controller => $data) {
                     $resources += self::_getAcl($module['controller']['base'], $data['items']);
                 }
             }
         }
     }
     if (!isset($config['acl']['resources'])) {
         $config['acl']['resources'] = array();
     }
     $config['acl']['resources'] += $resources;
     self::$_config = $config['acl'];
     if (isset($ckey)) {
         Core::cacheSet($config['acl'], $ckey, true, array('tags' => array('config', 'acl')));
     }
 }