public function init() { parent::init(); $this->initLanguage(); // These take care of dynamically creating a class for each token / response table. Yii::import('application.helpers.ClassFactory'); ClassFactory::registerClass('Token_', 'Token'); ClassFactory::registerClass('Response_', 'Response'); }
/** * Inits the webapplication * * Also start interceptor to add event support */ protected function init() { parent::init(); $this->interceptor->start(); $this->moduleManager->start(); $this->interceptor->intercept($this); if ($this->hasEventHandler('onInit')) { $this->onInit(new CEvent($this)); } }
public function init() { parent::init(); if (Yii::app()->language == 'en_au') { $lang = 'en'; } else { $lang = Yii::app()->language; } $config = array('name' => Settings::getVal('site_name'), 'components' => array('widgetFactory' => array('widgets' => array('CLinkPager' => array('prevPageLabel' => Yii::t('admin', 'previous'), 'nextPageLabel' => Yii::t('admin', 'next')), 'CJuiDatePicker' => array('language' => $lang, 'options' => array('dateFormat' => strtolower(Yii::app()->locale->getDateFormat('short')))))))); //$config = $this->generateSocialAccess($config); $this->checkAvailable(); $this->configure($config); }
protected function init() { $modulesConfig = array(); //dynamically loading modules and their config foreach (glob(dirname(__FILE__) . '/protected/modules/*', GLOB_ONLYDIR) as $moduleDirectory) { $this->setModules(array(basename($moduleDirectory))); $configFile = $moduleDirectory . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'main.php'; if (file_exists($configFile)) { $modulesConfig = CMap::mergeArray($modulesConfig, require $configFile); } } $finalConfig = CMap::mergeArray($modulesConfig, require dirname(__FILE__) . '/protected/config/db.php'); $this->configure(CMap::mergeArray($finalConfig, require $this->config)); return parent::init(); }
protected function init() { $this->setLicence(); $this->_enabledModule = Module::model()->fetchAllEnabledModule(); foreach ($this->getEnabledModule() as $module) { $config = CJSON::decode($module["config"], true); if (isset($config["configure"]) && array_key_exists("modules", $config["configure"])) { if (isset($config["behaviors"])) { $this->setBehaviors($config["behaviors"]); } parent::configure($config["configure"]); } } parent::init(); }
/** * Init application */ public function init() { // Set default cache first Yii::app()->setComponent('cache', Yii::CreateComponent(array('class' => 'CFileCache', 'directoryLevel' => 2))); // Set cache options $this->setCacheOptions(); // Init settings Yii::app()->settings->init(); // IP Block $this->checkIPBlock(); // Set language Yii::app()->language = getParam('default_site_language', 'en'); // Set default time zone date_default_timezone_set(getParam('global_time_zone', 'America/Los_Angeles')); // Build editor component Yii::app()->setComponent('customEditor', Yii::CreateComponent(array('class' => 'CustomEditor', 'type' => getParam('global_editor_type', 'ckeditor')))); // Run parent now parent::init(); }
/** * Initialize component */ public function init() { $this->setSystemModules(); parent::init(); }
/** * Initializes the application. * * @return null */ public function init() { // NOTE: Nothing that triggers a database connection should be made here until *after* _processResourceRequest() // in processRequest() is called. // Set default timezone to UTC date_default_timezone_set('UTC'); // Import all the built-in components foreach ($this->componentAliases as $alias) { Craft::import($alias); } // Attach our Craft app behavior. $this->attachBehavior('AppBehavior', new AppBehavior()); // Initialize Cache, HttpRequestService and LogRouter right away (order is important) $this->getComponent('cache'); $this->getComponent('request'); // Attach our own custom Logger Craft::setLogger(new Logger()); $this->getComponent('log'); // So we can try to translate Yii framework strings $this->coreMessages->attachEventHandler('onMissingTranslation', array('Craft\\LocalizationHelper', 'findMissingTranslation')); // Set our own custom runtime path. $this->setRuntimePath($this->path->getRuntimePath()); // If there is a custom appId set, apply it here. if ($appId = $this->config->get('appId')) { $this->setId($appId); } parent::init(); }
/** * @return null */ public function init() { // Set default timezone to UTC date_default_timezone_set('UTC'); // Import all the built-in components foreach ($this->componentAliases as $alias) { Craft::import($alias); } // Attach our Craft app behavior. $this->attachBehavior('AppBehavior', new AppBehavior()); // Initialize Cache, HttpRequestService and LogRouter right away (order is important) $this->getComponent('cache'); $this->getComponent('request'); $this->getComponent('log'); // So we can try to translate Yii framework strings $this->coreMessages->attachEventHandler('onMissingTranslation', array('Craft\\LocalizationHelper', 'findMissingTranslation')); // Set our own custom runtime path. $this->setRuntimePath($this->path->getRuntimePath()); // Attach our own custom Logger Craft::setLogger(new Logger()); // If we're not in devMode, we're going to remove some logging routes. if (!$this->config->get('devMode')) { $this->log->removeRoute('WebLogRoute'); $this->log->removeRoute('ProfileLogRoute'); } // If there is a custom appId set, apply it here. if ($appId = $this->config->get('appId')) { $this->setId($appId); } parent::init(); }
/** * Initializes the application. * This method overrides the parent implementation by preloading the 'request' component. */ protected function init() { $isBadDatabase = false; if (isset($_GET) && isset($_GET['r']) && $_GET['r'] == 'site/baddatabase') { $isBadDatabase = true; } if (!$isBadDatabase && count($_GET) == 0 || isset($_GET['r']) && $_GET['r'] == 'site/index') { //just some tests to see if the database is working $connection = null; try { $connection = yii::app()->getDb(); //new CDbConnection($dsn,$username,$password); // establish connection. You may try...catch possible exceptions $connection->active = true; } catch (Exception $zz) { $isBadDatabase = true; } if (!$isBadDatabase) { try { $command = $connection->createCommand('select * from Company LIMIT 1'); $reader = $command->query(); } catch (Exception $zz) { //create the database $fileread = fopen(dirname(__FILE__) . DIRECTORY_SEPARATOR . '../controllers/lazy8web.sql', "r"); while (!feof($fileread)) { $sqlCommand = ""; $line = trim(fgets($fileread)); $sqlCommand .= $line; while (!feof($fileread) && substr($line, strlen($line) - 1, 1) != ";") { $line = fgets($fileread); $sqlCommand .= $line; } $command = $connection->createCommand($sqlCommand); $command->execute(); } fclose($fileread); //need to give the database time to reset itself. Otherwise it cant find the tables. yii::app()->getDb()->__sleep(false); sleep(3); yii::app()->getDb()->setActive(true); } $criteria = new CDbCriteria(); $pages = new CPagination(10); $pages->pageSize = 2; $pages->applyLimit($criteria); $models = Message::model()->findAll($criteria); if (!isset($models) || count($models) == 0) { include 'SourceMessageController.php'; include 'ReportController.php'; //the languages are not initialized yet SourceMessageController::importLanguage(dirname(__FILE__) . DIRECTORY_SEPARATOR . '../controllers/lazy8weblanguage.xml', false, true); //load the reports as well ReportController::importFile(dirname(__FILE__) . DIRECTORY_SEPARATOR . '../controllers/lazy8webreport.xml', false); } $models = User::model()->findAll(); if (!isset($models) || count($models) == 0) { //load an admin person. $model = new User(); $model->username = '******'; $model->displayname = 'Admin!ChangeName!'; $model->salt = hash('sha1', uniqid(rand(), true)); $model->password = hash('sha1', 'admin' . $model->salt); $model->confirmPassword = hash('sha1', 'admin' . $model->salt); $model->save(); $optionsUser = User::optionsUserTemplate(); //preset with the default value for the user options foreach ($optionsUser as $key => $option) { $_POST['option_' . $key] = $option[1]; } foreach ($optionsUser as $key => $option) { if ($option[6] == 'true') { $_POST['option_' . $key] = 1; } } User::updateOptionTemplate(User::optionsUserTemplate(), $model->id, 0); } } } if (!$isBadDatabase) { $this->mainMenu = array('Data Entry' => array("label" => Yii::t("lazy8", "Data Entry"), "visible" => Yii::app()->user->getState('allowTrans') || Yii::app()->user->getState('allowAccount') || Yii::app()->user->getState('allowCustomer'), array("url" => array("route" => "trans"), "label" => Yii::t("lazy8", "Transactions"), "visible" => Yii::app()->user->getState('allowTrans')), array("url" => array("route" => "account"), "label" => Yii::t("lazy8", "Accounts"), "visible" => Yii::app()->user->getState('allowAccount')), array("url" => array("route" => "customer"), "label" => Yii::t("lazy8", "Tags"), "visible" => Yii::app()->user->getState('allowCustomer')), array("url" => array("route" => "donor"), "label" => Yii::t("lazy8", "Donors"), "visible" => Yii::app()->user->getState('allowDonor'))), 'Reports' => array("label" => Yii::t("lazy8", "Reports"), "visible" => Yii::app()->user->getState('allowReports'), "url" => array("route" => "report/report")), 'Company' => array("label" => Yii::t("lazy8", "Company"), "visible" => Yii::app()->user->getState('allowCompanyCreation') || Yii::app()->user->getState('allowPeriod') || Yii::app()->user->getState('allowAccountTypes') || Yii::app()->user->getState('allowExport') || Yii::app()->user->getState('allowImport'), array("url" => array("route" => "company"), "label" => Yii::t("lazy8", "Company"), "visible" => Yii::app()->user->getState('allowCompanyCreation')), array("url" => array("route" => "period"), "label" => Yii::t("lazy8", "Period"), "visible" => Yii::app()->user->getState('allowPeriod') && Yii::app()->user->getState('selectedCompanyId') != 0), array("url" => array("route" => "accountType"), "label" => Yii::t("lazy8", "Account types"), "visible" => Yii::app()->user->getState('allowAccountTypes') && Yii::app()->user->getState('selectedCompanyId') != 0), array("url" => array("route" => "company/export&id=" . Yii::app()->user->getState('selectedCompanyId')), "label" => Yii::t("lazy8", "Export this company"), "visible" => !Yii::app()->user->getState('allowCompanyCreation') && Yii::app()->user->getState('allowCompanyExport') != 0)), 'Setup' => array("label" => Yii::t("lazy8", "Setup"), "visible" => Yii::app()->user->getState('allowSelf') || Yii::app()->user->getState('allowAdmin'), array("url" => array("route" => "user/update&id=" . Yii::app()->user->id), "label" => Yii::t("lazy8", "Your profile"), "visible" => Yii::app()->user->getState('allowSelf') || Yii::app()->user->getState('allowAdmin')), array("url" => array("route" => "options"), "label" => Yii::t("lazy8", "Website"), "visible" => Yii::app()->user->getState('allowAdmin')), array("url" => array("route" => "user"), "label" => Yii::t("lazy8", "Users"), "visible" => Yii::app()->user->getState('allowAdmin')), array("url" => array("route" => "report"), "label" => Yii::t("lazy8", "Reports"), "visible" => Yii::app()->user->getState('allowAdmin')), array("url" => array("route" => "sourceMessage"), "label" => Yii::t("lazy8", "Translations"), "visible" => Yii::app()->user->getState('allowAdmin')), array("url" => array("route" => "changeLog"), "label" => Yii::t("lazy8", "Logs"), "visible" => Yii::app()->user->getState('allowChangeLog')), 'Reports Cron' => array("label" => Yii::t("lazy8", "Run Reports"), "visible" => Yii::app()->user->getState('allowAdmin'), 'disabled' => false, 'icon' => 'protected/images/skull.png', 'url' => array('route' => '', 'link' => '#', 'htmlOptions' => array('class' => 'menulink')), array('url' => array('route' => 'account/cronbalance', 'htmlOptions' => array('target' => '_BLANK', 'id' => 'balanceCheck', 'onClick' => 'return confirm(\'WARNING: Please Read Carefully. You are about to tun the daily Balance Check. This will automatically run once a day even if you run it now. Are you sure you would like to continue?\');')), "label" => Yii::t("lazy8", "Balance Check"), "visible" => Yii::app()->user->getState('allowAdmin')), array('url' => array('route' => 'report/cronreports', 'htmlOptions' => array('target' => '_BLANK', 'id' => 'weekltReport', 'onClick' => 'return confirm(\'WARNING: Please Read Carefully. You are about to run the Weekly Report. This will generate reports for all accounts and send emails to anyone who might be associatted with each account. Are you sure you would like to continue?\');')), "label" => Yii::t("lazy8", "Weekly Report"), "visible" => Yii::app()->user->getState('allowAdmin')))), 'Logout' => array("url" => array("route" => "/site/logout"), "label" => Yii::t("lazy8", "Logout"))); //Load all the modules parent::init(); $mods = yii::app()->modules; foreach ($mods as $key => $mod) { if (is_file(YiiBase::getPathOfAlias($mod['class']) . '.php')) { $type = Yii::import($mod['class'], true); $cc = new $type($key, $this); $cc->RegisterEvents($this, $this->mainMenu); } } } }
public function init() { parent::init(); Yii::import('application.helpers.ClassFactory'); ClassFactory::registerClass('Token_', 'Token'); ClassFactory::registerClass('Response_', 'Response'); }
public function init() { return parent::init(); }
/** * Initialize component */ public function init() { Yii::setPathOfAlias('root', dirname(Yii::getPathOfAlias('webroot'))); $this->setModules(Yii::app()->user->plan['modules']); parent::init(); }
protected function init() { register_shutdown_function(array($this, 'onShutdownHandler')); parent::init(); }
public function init() { parent::init(); if ($this->isInit) { return; } $this->setImport(array('ygin.models.object.*', 'ygin.interface.*', 'ygin.models.*', 'ygin.widgets.*', 'ygin.widgets.linkPager.LinkPagerWidget', 'ygin.widgets.alert.AlertWidget', 'ygin.behaviors.*', 'ygin.controllers.*')); if (!isset($this->controllerMap['static'])) { $this->controllerMap['static'] = 'ygin.controllers.StaticController'; } mb_internal_encoding('UTF-8'); mb_regex_encoding('UTF-8'); // если ещё не был создан конфиг файл плагинов, то создаем его и перезагружаем страницу if ($this->isFrontend && !$this->pluginsCompile) { // сюда должны попадать в крайнем случае //throw new ErrorException('Системная ошибка, плагины системы не проинициализированы. Обратитесь к разработчикам.'); $this->compilePluginsConfig(); Yii::app()->getRequest()->redirect(Yii::app()->getRequest()->getUrl()); } // добавление маршрутов модулей $modules = $this->getModules(); $urlManager = $this->getUrlManager(); // print_r($modules);exit; $urlRules = array(); foreach ($modules as $moduleName => $params) { if ($moduleName == 'gii') { continue; } // перекрывает errorHandler/errorAction $module = Yii::app()->getModule($moduleName); if (isset($module->urlRules) && count($module->urlRules) > 0) { //HU::dump($module->urlRules); $urlRules = array_merge($urlRules, $module->urlRules); //HU::dump($urlRules); } // получилось только так сделать ининициализацию вложенного модуля if (!empty($module->modules)) { $module->setModules($module->modules); $childModules = $module->getModules(); foreach ($childModules as $id => $config) { if (is_int($id)) { $id = $config; } $childModule = $module->getModule($id); if (isset($childModule->urlRules)) { $urlRules = array_merge($urlRules, $childModule->urlRules); //$urlManager->addRules(array_reverse($childModule->urlRules), false); } } } } //HU::dump($urlRules);exit; $urlManager->addRules($urlRules, false); //print_r($urlManager);exit; $this->isInit = true; }
/** * Initializes the application. * * @return null */ public function init() { // NOTE: Nothing that triggers a database connection should be made here until *after* _processResourceRequest() // in processRequest() is called. // Import all the built-in components foreach ($this->componentAliases as $alias) { Craft::import($alias); } // Attach our Craft app behavior. $this->attachBehavior('AppBehavior', new AppBehavior()); // If there is a custom validationKey set, apply it here. if ($validationKey = $this->config->get('validationKey')) { $this->security->setValidationKey($validationKey); // Make sure any instances of Yii's CSecurityManager class are using the custom validation // key as well $this->getComponent('securityManager')->setValidationKey($validationKey); } // Attach our own custom Logger Craft::setLogger(new Logger()); // If there is a custom appId set, apply it here. if ($appId = $this->config->get('appId')) { $this->setId($appId); } // Initialize Cache, HttpRequestService and LogRouter right away (order is important) $this->getComponent('cache'); $this->getComponent('request'); $this->getComponent('log'); // So we can try to translate Yii framework strings $this->coreMessages->attachEventHandler('onMissingTranslation', array('Craft\\LocalizationHelper', 'findMissingTranslation')); // Set our own custom runtime path. $this->setRuntimePath($this->path->getRuntimePath()); // Set the edition components $this->_setEditionComponents(); parent::init(); }
public function init() { parent::init(); }
/** * Processes resource requests before anything else has a chance to initialize. */ public function init() { // Set default timezone to UTC date_default_timezone_set('UTC'); // Import all the built-in components foreach ($this->componentAliases as $alias) { Craft::import($alias); } // Initialize HttpRequestService and LogRouter right away $this->getComponent('request'); $this->getComponent('log'); // Set our own custom runtime path. $this->setRuntimePath($this->path->getRuntimePath()); // Attach our own custom Logger Craft::setLogger(new Logger()); // If we're not in devMode or this is a resource request, we're going to remove some logging routes. if (!$this->config->get('devMode') || ($resourceRequest = $this->request->isResourceRequest()) == true) { // If it's a resource request, we don't want any logging routes, including craft.log // If it's not a resource request, we'll keep the FileLogRoute around. if ($resourceRequest) { $this->log->removeRoute('FileLogRoute'); } // Don't need either of these if not in devMode or it's a resource request. $this->log->removeRoute('WebLogRoute'); $this->log->removeRoute('ProfileLogRoute'); } parent::init(); }
protected function init() { parent::init(); $this->initLanguage(); if (!YII_DEBUG) { $this->getClientScript()->scriptMap = array('jquery.min.js' => '//cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js', 'jquery-ui.min.js' => '//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js', 'bootstrap.min.js' => '//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.3.1/js/bootstrap.min.js', 'bootstrap.min.css' => '//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.3.1/css/bootstrap.min.css', 'bootstrap-combined.no-icons.min.css' => '//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.3.0/css/bootstrap.no-icons.min.css', 'font-awesome.min.css' => '//cdnjs.cloudflare.com/ajax/libs/font-awesome/3.1.0/css/font-awesome.min.css', 'bootstrap-responsive.min.css' => '//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.3.1/css/bootstrap-responsive.min.css', 'jquery.form.min.js' => '//cdnjs.cloudflare.com/ajax/libs/jquery.form/3.24/jquery.form.min.js', 'jquery.form.js' => '//cdnjs.cloudflare.com/ajax/libs/jquery.form/3.24/jquery.form.min.js', 'wysihtml5-0.3.0.js' => '//cdnjs.cloudflare.com/ajax/libs/wysihtml5/0.3.0/wysihtml5.min.js', 'date.js' => '//cdnjs.cloudflare.com/ajax/libs/datejs/1.0/date.min.js', 'bootstrap-datepicker.css' => '//cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.0.2/css/bootstrap-datepicker.min.css', 'bootstrap-datepicker.js' => '//cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.0.2/js/bootstrap-datepicker.min.js', 'bootstrap-datepicker.id.js' => '//cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.0.2/js/locales/bootstrap-datepicker.id.min.js'); } // TODO: remove debug specific options and add that to plugins if (YII_DEBUG) { //$this->messages->onMissingTranslation = array ('CPhpMessageTranslator', 'appendMessage'); $this->setModules(array('gii' => array('class' => 'system.gii.GiiModule', 'password' => 'gii'))); $this->cache->hashKey = false; } }