コード例 #1
0
ファイル: LanguageBehavior.php プロジェクト: yupe/yupe
 /**
  * @param \CWebApplication $owner
  */
 public function attach($owner)
 {
     $this->lm = $owner->getUrlManager();
     if (count($this->lm->getAvailableLanguages()) > 1) {
         $owner->attachEventHandler('onBeginRequest', [$this, 'handleLanguageBehavior']);
     }
 }
コード例 #2
0
ファイル: RestApplication.php プロジェクト: isuvorov/yiirest
 protected function registerCoreComponents()
 {
     parent::registerCoreComponents();
     require_once __DIR__ . '/components/Cipher.php';
     require_once __DIR__ . '/components/RestActiveRecord.php';
     require_once __DIR__ . '/components/RestController.php';
     require_once __DIR__ . '/components/RestUserIdentity.php';
     require_once __DIR__ . '/components/ServiceUserIdentity.php';
     require_once __DIR__ . '/controllers/RestAuthController.php';
     require_once __DIR__ . '/models/Userlink.php';
     //        $components=array(
     //            'ActiveRecord' => array(
     //                'class' => 'ActiveRecord',
     //            ),
     //            'Cipher'=>array(
     //                'class' =>'Cipher',
     //            ),
     //            'Controller' => array(
     //                'class' => 'Controller',
     //            ),
     //            'RecentComments' => array(
     //                'class' => 'RecentComments',
     //            ),
     //            'RestController' => array(
     //                'class' => 'RestController',
     //            ),
     //            'ServiceUserIdentity' => array(
     //                'class' => 'ServiceUserIdentity',
     //            ),
     //            'UserIdentity' => array(
     //                'class' => 'UserIdentity',
     //            ),
     //        );
     //        $this->setComponents($components);
 }
コード例 #3
0
 public function run()
 {
     if (YII_DEBUG) {
         $this->initErrorHandlers();
     }
     return parent::run();
 }
コード例 #4
0
ファイル: WebApplication.php プロジェクト: equa2k9/jazz
 /**
  * Workaround to fallback to `en` locale even if something unknown to us was requested.
  *
  * @param string $localeID
  * @return CLocale
  */
 public function getLocale($localeID = null)
 {
     try {
         return parent::getLocale($localeID);
     } catch (Exception $e) {
         return CLocale::getInstance('uk');
     }
 }
コード例 #5
0
 /**
  * Initiates the application
  *
  * @access public
  * @param array $config
  * @return void
  */
 public function __construct($config = null)
 {
     if (is_string($config) && !file_exists($config)) {
         $config = APPPATH . 'config/config-sample-mysql' . EXT;
     }
     if (is_string($config)) {
         $config = (require $config);
     }
     if ($config['config']['debug'] == 2) {
         // If debug = 2 we add firebug / console logging for all trace messages
         // If you want to var_dump $config you could do:
         //
         // Yii::trace(CVarDumper::dumpAsString($config), 'vardump');
         //
         // or shorter:
         //
         //traceVar($config);
         //
         // This statement won't cause any harm or output when debug is 1 or 0
         $config['preload'][] = 'log';
         if (array_key_exists('components', $config) && array_key_exists('log', $config['components'])) {
             // We already have some custom logging, only add our own
         } else {
             // No logging yet, set it up
             $config['components']['log'] = array('class' => 'CLogRouter');
         }
         // Add logging of trace
         $config['components']['log']['routes'][] = array('class' => 'CWebLogRoute', 'levels' => 'trace', 'categories' => 'vardump', 'showInFireBug' => true);
         // if debugsql = 1 we add sql logging to the output
         if (array_key_exists('debugsql', $config['config']) && $config['config']['debugsql'] == 1) {
             // Add logging of trace
             $config['components']['log']['routes'][] = array('class' => 'CWebLogRoute', 'levels' => 'trace', 'categories' => 'system.db.*', 'showInFireBug' => true);
             $config['components']['db']['enableProfiling'] = true;
             $config['components']['db']['enableParamLogging'] = true;
         }
     }
     if (!isset($config['components']['request'])) {
         $config['components']['request'] = array();
     }
     $config['components']['request'] = array_merge_recursive($config['components']['request'], array('class' => 'LSHttpRequest', 'noCsrfValidationRoutes' => array('getTokens_json', 'getSurveys_json', 'remotecontrol'), 'enableCsrfValidation' => false, 'enableCookieValidation' => false));
     parent::__construct($config);
     // Load the default and environmental settings from different files into self.
     $ls_config = (require APPPATH . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config-defaults.php');
     $email_config = (require APPPATH . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'email.php');
     $version_config = (require APPPATH . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'version.php');
     $settings = array_merge($ls_config, $version_config, $email_config);
     if (file_exists(APPPATH . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php')) {
         $ls_config = (require APPPATH . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php');
         if (is_array($ls_config['config'])) {
             $settings = array_merge($settings, $ls_config['config']);
         }
     }
     foreach ($settings as $key => $value) {
         $this->setConfig($key, $value);
     }
 }
コード例 #6
0
 /**
  * Because of our need to switch URLs in certain cases, we actually make all URLs absolute now
  */
 public function createUrl($route, $params = array(), $ampersand = '&', $schema = '')
 {
     // Get the URL without the host first.
     $url = parent::createUrl($route, $params, $ampersand);
     // Does this system support regular SSL or Common SSL?
     if (Yii::app()->params['ENABLE_SSL'] == false && Yii::app()->hasCommonSSL == false) {
         // For systems with no SSL, function normally
         return $url;
     }
     if (isset($route) && $route !== '') {
         $strController = $this->parseRouteGetController($route);
         $strAction = $this->parseRouteGetAction($route);
         $route = _xls_remove_leading_slash($route);
     } else {
         $strController = null;
     }
     if (Yii::app()->hasCommonSSL === true && Yii::app()->isCommonSSL === false) {
         // When SSL is available on the web store there are certain routes
         // which use CommonsslController to hand over from the HTTP to
         // HTTPS domain. The commonssl routes should be generated on the
         // same domain as this request, since they require access to the
         // user session for the handover.
         if ($route == "cart/checkout") {
             $route = "commonssl/cartcheckout";
             return $this->getUrlManager()->createUrl($route, $params, $ampersand);
         } elseif (in_array($route, $this->_arrNeverSecureRoutes) === false && in_array($strController, $this->_arrCommonSSLControllers) === true) {
             $route = 'commonssl/' . $strController;
             return $this->getUrlManager()->createUrl($route, $params + array('action' => $strAction), $ampersand);
         }
     }
     if (Yii::app()->HasCommonSSL) {
         $strCustomUrl = Yii::app()->params['LIGHTSPEED_HOSTING_CUSTOM_URL'];
         $strLightSpeedUrl = Yii::app()->params['LIGHTSPEED_HOSTING_LIGHTSPEED_URL'];
     } else {
         $strCustomUrl = '';
         $strLightSpeedUrl = '';
     }
     $httpHost = str_replace($strLightSpeedUrl, $strCustomUrl, $this->getRequest()->getHostInfo('http'));
     // For specific routes, we always use HTTP.
     if (in_array($route, $this->_arrNeverSecureRoutes)) {
         // Force a switch to original URL without SSL
         $host = $httpHost;
     } elseif (in_array($route, $this->_arrNeedToSecureRoutes) || in_array($strController, $this->_arrNeedToSecureControllers)) {
         //Force a switch to Common SSL
         $host = str_replace($strCustomUrl, $strLightSpeedUrl, $this->getRequest()->getHostInfo('https'));
     } elseif (in_array($strController, $this->_arrPassthroughControllers)) {
         //For specific controllers, pass these through (this is mostly AJAX)
         //This URL could be on either hostname so just pass through without schema
         return $url;
     } else {
         // Force a switch to original URL without SSL.
         $host = $httpHost;
     }
     Yii::log("URL built as " . $host . $url, 'trace', 'application.' . __CLASS__ . "." . __FUNCTION__);
     return $host . $url;
 }
コード例 #7
0
ファイル: WebApplication.php プロジェクト: alefernie/intranet
 /**
  * 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));
     }
 }
コード例 #8
0
ファイル: EWebApplication.php プロジェクト: a303/smart_lp2
 /**
  * We were getting tons of errors in the logs from OPTIONS requests for the URI "*"
  * As it turns out, the requests were from localhost (::1) and are apparently a way
  * that Apache polls its processes to see if they're alive. This function causes
  * Yii to respond without logging errors.
  */
 public function runController($route)
 {
     try {
         parent::runController($route);
     } catch (CHttpException $e) {
         if (@$_SERVER['REQUEST_METHOD'] == 'OPTIONS' && @$_SERVER['REQUEST_URI'] == '*') {
             Yii::app()->end('Hello, amigo!');
         } else {
             throw $e;
         }
     }
 }
コード例 #9
0
ファイル: WebApp.php プロジェクト: blrtromax/seobility
 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);
 }
コード例 #10
0
ファイル: WebApplication.php プロジェクト: youprofit/Zurmo
 /**
  * Override to handle when debug is turned on and the checksum fails on cached models.
  */
 public function run()
 {
     try {
         parent::run();
     } catch (ChecksumMismatchException $e) {
         echo 'A checksum mismatch has occurred while retrieving a cached model. ' . 'This is most likely caused by setting debug=true. The cache must be cleared.';
         // Not Coding Standard
         echo '<br/>';
         $url = Yii::app()->createUrl('zurmo/default/index/', array('clearCache' => true));
         echo ZurmoHtml::link('Click here to clear the cache', $url);
         Yii::app()->end(0, false);
     }
 }
コード例 #11
0
ファイル: Aweapp.php プロジェクト: awecode/awecms
 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();
 }
コード例 #12
0
 /**
  * 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();
 }
コード例 #13
0
ファイル: EWebApplication.php プロジェクト: 44n/myEYii
		}

		if($this->isExt){
			return 'ext';
		}

	}


	protected function registerCoreComponents(){
		parent::registerCoreComponents();

		$components = array(
			'request'=>array(
				'class'=>'EHttpRequest',
			),
			'image'=>array(
				'class'=>'eyii.extensions.image.CImageComponent',
				'driver'=>'GD',
				'params'=>array('directory'=>$this->runtimePath),
			),
			'errorHandler'=>array(
				'errorAction'=>'static/page/error',
			),
			'urlManager'=>array(
				'class'=>'EUrlManager',
				'urlFormat'=>'path',
				'showScriptName' => false,
				'caseSensitive' => false,
				'rules' => array(
					'' => 'page/static/showindex'
				),
			),
			'log'=>array(
				'class'=>'CLogRouter',
				'routes'=>array(
					array(
						'class'=>'CFileLogRoute',
						'levels'=>'error, warning',
					),
					// uncomment the following to show log messages on web pages
					/*
					array(
コード例 #14
0
 /**
  * Creates the controller and performs the specified action.
  * @param string the route of the current request. See {@link createController} for more details.
  * @throws CHttpException if the controller could not be created.
  */
 public function runController($route)
 {
     if (($ca = $this->createController($route)) !== null) {
         list($controller, $actionID) = $ca;
         $oldController = parent::getController();
         parent::setController($controller);
         $controller->init();
         // Check Access Control after controller is created so computed roles are available.
         if ($route && !$this->checkOpenAccess($route)) {
             $authRoute = $route[0] === '/' ? $route : '/' . $route;
             if (!$this->user->checkAccess($authRoute)) {
                 throw new CHttpException(401, Yii::t('auth', 'You do not have permission to perform this action.'));
             }
         }
         $controller->run($actionID);
         parent::setController($oldController);
     } else {
         throw new CHttpException(404, Yii::t('yii', 'Unable to resolve the request "{route}".', array('{route}' => $route === '' ? $this->defaultController : $route)));
     }
 }
コード例 #15
0
 /**
  * Creates the controller and performs the specified action.
  * @param string $route the route of the current request. See {@link createController} for more details.
  * @throws CHttpException if the controller could not be created.
  */
 public function runController($route)
 {
     try {
         parent::runController($route);
     } catch (CHttpException $x) {
         if (\Yii::app()->params['site']['logError404']) {
             \Yii::import('admin.models.BadUrlLog');
             if (!\BadUrlLog::saveLog()) {
                 throw $x;
             }
             // Si tout va bien, on enregistre l'erreur sans envoyer de mail à l'administrateur
             // On redirige le client vers la page d'erreur personnalisée
             \Yii::import('admin.*');
             /** @var \AdminModule $adminModule */
             $adminModule = \Yii::app()->getModule('admin');
             $this->runController($adminModule->routeFor404ErrorPage);
         } else {
             throw $x;
         }
     }
 }
コード例 #16
0
 /**
  * Initiates the application
  *
  * @access public
  * @param array $config
  * @return void
  */
 public function __construct($config = null)
 {
     if (!file_exists($config)) {
         $config = APPPATH . 'config/config-sample' . EXT;
     }
     parent::__construct($config);
     // Load the default and environmental settings from different files into self.
     $ls_config = (require APPPATH . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config-defaults.php');
     $email_config = (require APPPATH . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'email.php');
     $version_config = (require APPPATH . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'version.php');
     $settings = array_merge($ls_config, $version_config, $email_config);
     if (file_exists(APPPATH . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php')) {
         $ls_config = (require APPPATH . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php');
         if (is_array($ls_config['config'])) {
             $settings = array_merge($settings, $ls_config['config']);
         }
     }
     foreach ($settings as $key => $value) {
         $this->setConfig($key, $value);
     }
 }
コード例 #17
0
ファイル: X2WebApplication.php プロジェクト: dsyman2/X2CRM
 public function onEndRequest($event)
 {
     if (!empty(Yii::$translationLog)) {
         $username = '';
         if (isset(Yii::$systemuser)) {
             $username = Yii::$systemuser;
         }
         if (!is_dir(Yii::app()->basePath . '/messages/log_' . $username)) {
             mkdir(Yii::app()->basePath . '/messages/log_' . $username);
         }
         foreach (Yii::$translationLog as $category => $messages) {
             $fileName = Yii::app()->basePath . '/messages/log_' . $username . '/' . $category . '.php';
             if (!is_file($fileName)) {
                 file_put_contents($fileName, '<?php return ' . var_export(array(), true) . ";\n");
             }
             $messages = array_merge(require $fileName, $messages);
             file_put_contents($fileName, '<?php return ' . var_export($messages, true) . ";\n");
         }
     }
     parent::onEndRequest($event);
 }
コード例 #18
0
 /**
  * For future use, cache the language app wise as well.
  *
  * @access public
  * @return void
  */
 public function setLanguage($sLanguage)
 {
     $sLanguage = preg_replace('/[^a-z0-9-]/i', '', $sLanguage);
     $this->messages->catalog = $sLanguage;
     parent::setLanguage($sLanguage);
 }
コード例 #19
0
ファイル: ICApplication.php プロジェクト: AxelPanda/ibos
 protected function setBehaviors($behaviors)
 {
     parent::attachBehaviors($behaviors);
 }
コード例 #20
0
ファイル: Application.php プロジェクト: codemix/restyii
 /**
  * Registers the core application components.
  * This method overrides the parent implementation by registering additional core components.
  * @see setComponents
  */
 protected function registerCoreComponents()
 {
     parent::registerCoreComponents();
     $components = array('eventStream' => array('class' => 'Restyii\\Event\\LocalEventStream'), 'request' => array('class' => 'Restyii\\Web\\Request'), 'schema' => array('class' => 'Restyii\\Meta\\Schema'), 'urlManager' => array('class' => 'Restyii\\Web\\UrlManager'));
     $this->setComponents($components);
 }
コード例 #21
0
 /**
  * Initialize component
  */
 public function init()
 {
     $this->setSystemModules();
     parent::init();
 }
コード例 #22
0
 /**
  * The pre-filter for controller actions.
  * This method is invoked before the currently requested controller action and all its filters
  * are executed. You may override this method with logic that needs to be done
  * before all controller actions.
  * @param CController $controller the controller
  * @param CAction $action the action
  * @return boolean whether the action should be executed.
  */
 public function beforeControllerAction($controller, $action)
 {
     /**
      * Plugin event done before all web controller action
      * Can set run to false to deactivate action
      */
     $event = new PluginEvent('beforeControllerAction');
     $event->set('controller', $controller->getId());
     $event->set('action', $action->getId());
     App()->getPluginManager()->dispatchEvent($event);
     return $event->get("run", parent::beforeControllerAction($controller, $action));
 }
コード例 #23
0
ファイル: WebApplication.php プロジェクト: Wiedzal/araucano
 public function init()
 {
     parent::init();
 }
コード例 #24
0
 public function end($status = 0, $exit = true)
 {
     parent::end(0, false);
     throw new YiiExitException();
 }
コード例 #25
0
 /**
  * For future use, cache the language app wise as well.
  *
  * @access public
  * @return void
  */
 public function setLanguage($sLanguage)
 {
     $this->messages->catalog = $sLanguage;
     parent::setLanguage($sLanguage);
 }
コード例 #26
0
 public function init()
 {
     parent::init();
     Yii::import('application.helpers.ClassFactory');
     ClassFactory::registerClass('Token_', 'Token');
     ClassFactory::registerClass('Response_', 'Response');
 }
コード例 #27
0
ファイル: WebApp.php プロジェクト: amite/arc-va
 /**
  * @todo Remove for Craft 3.
  *
  * @param int    $code The level of the error raised.
  * @param string $message The error message.
  * @param string $file The filename that the error was raised in.
  * @param int    $line The line number the error was raised at.
  */
 public function handleError($code, $message, $file, $line)
 {
     // PHP 7 turned some E_STRICT messages to E_WARNINGs. Code 2 is for all warnings
     // and since there are no messages specific codes we have to parse the string for what
     // we're looking for. Lame, but it works since all PHP error messages are always in English.
     // https://stackoverflow.com/questions/11556375/is-there-a-way-to-localize-phps-error-output
     if (version_compare(PHP_VERSION, '7', '>=') && $code === 2 && strpos($message, 'should be compatible with') !== false) {
         return;
     }
     parent::handleError($code, $message, $file, $line);
 }
コード例 #28
0
 public function saveGlobalState()
 {
     parent::saveGlobalState();
 }
コード例 #29
0
ファイル: WebApp.php プロジェクト: kentonquatman/portfolio
 /**
  * Override setComponent so we can attach any pending events.
  *
  * @param string $id
  * @param mixed  $component
  * @param bool   $merge
  */
 public function setComponent($id, $component, $merge = true)
 {
     parent::setComponent($id, $component, $merge);
     $this->_attachEventListeners($id);
 }
コード例 #30
0
ファイル: Schema.php プロジェクト: codemix/restyii
 /**
  * Gets the unique id for a given module
  *
  * @param \CWebApplication|\CWebModule $module the parent module or application
  *
  * @return string the unique id for the module
  */
 public function getModuleUniqueId($module)
 {
     $parts = array();
     $parent = $module->getParentModule();
     if (is_object($parent)) {
         $parts[] = $this->getModuleUniqueId($parent);
     }
     return implode('/', $parts);
 }