/** * Module initialization. * * @param array $params Initialization parameters collection * @return bool Initialization result */ public function init(array $params = array()) { //[PHPCOMPRESSOR(remove,start)] // Create SamsonPHP routing table from loaded modules $rg = new GenericRouteGenerator($this->system->module_stack); // Generate web-application routes $routes = $rg->generate(); $routes->add($this->findGenericDefaultAction()); // Create cache marker $this->cacheFile = $routes->hash() . '.php'; // If we need to refresh cache if ($this->cache_refresh($this->cacheFile)) { $generator = new Structure($routes, new \samsonphp\generator\Generator()); // Generate routing logic function $routerLogic = $generator->generate(); // Store router logic in cache file_put_contents($this->cacheFile, '<?php ' . "\n" . $routerLogic); } require $this->cacheFile; //[PHPCOMPRESSOR(remove,end)] // This should be change to receive path as a parameter on initialization $pathParts = explode(Route::DELIMITER, $_SERVER['REQUEST_URI']); SamsonLocale::parseURL($pathParts); $this->requestURI = implode(Route::DELIMITER, $pathParts); // Subscribe to samsonphp\core routing event \samsonphp\event\Event::subscribe('core.routing', array($this, 'router')); // Continue initialization return parent::init($params); }
/** * Module initialization * @param array $params Collection of parameters * @return bool|void */ public function init(array $params = array()) { // Store pointer to file system module $this->fs =& m('fs'); // Call parent initialization parent::init($params); }
public function init(array $params = array()) { $this->request = url(); // Old applications main page rendering Event::subscribe(\samsoncms\cms\Application::EVENT_IS_CMS, array($this, 'authorize')); // Call parent initialization return parent::init($params); }
public function init(array $params = array()) { $this->request = url(); // Old applications main page rendering Event::subscribe(\samsoncms\cms\Application::EVENT_IS_CMS, array($this, 'authorize')); Event::subscribe(Compressor::E_CREATE_MODULE_LIST, array($this, 'getModuleList')); // Call parent initialization return parent::init($params); }
/** * Initialize module * @param array $params Collection of module parameters * @return bool True if module successfully initialized */ public function init(array $params = array()) { // Init FileSystem and ServerHandler $this->initFileSystem(); // If no valid handlers are passed - use generic handlers if (!isset($this->uploadDirHandler) || !is_callable($this->uploadDirHandler)) { $this->uploadDirHandler = array($this, 'defaultDirHandler'); } // Call parent initialization parent::init($params); }
public function init(array $params = array()) { //trace('cmsInit'); // Old applications main page rendering Event::subscribe('template.main.rendered', array($this, 'oldMainRenderer')); // Old applications menu rendering Event::subscribe('template.menu.rendered', array($this, 'oldMenuRenderer')); Event::subscribe('samson.url.build', array($this, 'buildUrl')); Event::subscribe('samson.url.args.created', array($this, 'parseUrl')); Event::subscribe(Module::EVENT_ROUTE_FOUND, array($this, 'activeModuleHandler')); Event::subscribe('samsonphp.router.create.module.routes', array($this, 'updateCMSPrefix')); //[PHPCOMPRESSOR(remove,start)] $moduleList = $this->system->module_stack; foreach ($this->system->module_stack as $id => $module) { if (!$this->isModuleDependent($module) && $id != 'core' && !$this->ifModuleRelated($module)) { unset($moduleList[$id]); } } // Generate resources for new module $this->system->module('resourcer')->generateResources($moduleList, $this->path() . 'app/view/index.php'); //[PHPCOMPRESSOR(remove,end)] // Call parent initialization return parent::init($params); }
/** * Module initialization. * * @param array $params Initialization parameters collection * @return bool Initialization result */ public function init(array $params = array()) { //[PHPCOMPRESSOR(remove,start)] // Create SamsonPHP routing table from loaded modules $rg = new GenericRouteGenerator($this->system->module_stack); // Generate web-application routes $routes = $rg->generate(); $routes->add($this->findGenericDefaultAction()); // Create cache marker $this->cacheFile = $routes->hash() . '.php'; // If we need to refresh cache if ($this->cache_refresh($this->cacheFile)) { $generator = new Structure($routes, new \samsonphp\generator\Generator()); // Generate routing logic function $routerLogic = $generator->generate(); // Store router logic in cache file_put_contents($this->cacheFile, '<?php ' . "\n" . $routerLogic); } require $this->cacheFile; //[PHPCOMPRESSOR(remove,end)] // Set locale resolver mode SamsonLocale::$leaveDefaultLocale = $this->browserLocaleRedirect; // This should be change to receive path as a parameter on initialization $pathParts = array_values(array_filter(explode(Route::DELIMITER, $_SERVER['REQUEST_URI']))); // Parse URL and store locale found bug $localeFound = SamsonLocale::parseURL($pathParts, $this->browserLocaleRedirect); // Gather URL path parts with removed locale placeholder $this->requestURI = implode(Route::DELIMITER, $pathParts); // Get localization data $current = SamsonLocale::current(); $default = SamsonLocale::$defaultLocale; // Browser agent language detection logic if ($this->browserLocaleRedirect && !$localeFound) { // Redirect to browser language $lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); // Is browser language supported by application $langSupport = in_array($lang, SamsonLocale::get(), true); /** * If browser language header is supported by our web-application and we are already not on that locale * and current locale is not default. */ if ($current === $default && $current !== $lang && $langSupport) { header('Location: http://' . $_SERVER['HTTP_HOST'] . '/' . $lang . '/' . $this->requestURI); exit; } elseif (!$langSupport || $lang === $current) { SamsonLocale::$leaveDefaultLocale = false; } } // Subscribe to samsonphp\core routing event \samsonphp\event\Event::subscribe('core.routing', array($this, 'router')); // Continue initialization return parent::init($params); }
/** @see \samson\core\ExternalModule::init() */ public function init(array $params = array()) { parent::init($params); // Set table prefix dbMySQLConnector::$prefix = $this->prefix; db()->connect($this->name, $this->login, $this->pwd, $this->host, $this->port); //[PHPCOMPRESSOR(remove,start)] // Generate table relations $this->relations(); //[PHPCOMPRESSOR(remove,end)] }
/** @see \samson\core\ExternalModule::init() */ public function init(array $params = array()) { parent::init($params); // Set table prefix dbMySQLConnector::$prefix = $this->prefix; //db()->connect($this->name, $this->login, $this->pwd, $this->host, $this->port); }