PHP Method Yii::getCustomPath Code Examples

This page contains top rated real world PHP examples of method Yii::getCustomPath extracted from open source projects. You can rate examples to help us improve the quality of examples
Example #1
Show file File: X2FlowFormatter.php Project: tymiles003/X2CRM
0
 /**
  * Parses a "short code" as a part of variable replacement.
  *
  * Short codes are defined in the file protected/components/x2flow/shortcodes.php
  * and are a list of manually defined pieces of code to be run in variable replacement.
  * Because they are stored in a protected directory, validation on allowed
  * functions is not performed, as it is the user's responsibility to edit this file.
  *
  * @param String $key The key of the short code to be used
  * @param X2Model $model The model having variables replaced, some short codes
  * use a model
  * @return mixed Returns the result of code evaluation if a short code
  * existed for the index $key, otherwise null
  */
 private static function parseShortCode($key, array $params)
 {
     if (isset($params['model'])) {
         $model = $params['model'];
     }
     $path = implode(DIRECTORY_SEPARATOR, array(Yii::app()->basePath, 'components', 'x2flow', 'shortcodes.php'));
     if (file_exists($path)) {
         $shortCodes = (include Yii::getCustomPath($path));
         if (isset($shortCodes[$key])) {
             return eval($shortCodes[$key]);
         }
     }
     return null;
 }
Example #2
Show file File: X2Controller.php Project: keyeMyria/CRM
0
 /**
  * Finds a view file based on its name.
  * Overrides {@link CBaseController::resolveViewFile} to check if the requested view 
  * has a version in /custom, and uses that if it exists.
  *
  * @param string $viewName the view name
  * @param string $viewPath the directory that is used to search for a relative view name
  * @param string $basePath the directory that is used to search for an absolute view name under the application
  * @param string $moduleViewPath the directory that is used to search for an absolute view name under the current module.
  * If this is not set, the application base view path will be used.
  * @return mixed the view file path. False if the view file does not exist.
  */
 public function resolveViewFile($viewName, $viewPath, $basePath, $moduleViewPath = null)
 {
     if (empty($viewName)) {
         return false;
     }
     if ($moduleViewPath === null) {
         $moduleViewPath = $basePath;
     }
     if (($renderer = Yii::app()->getViewRenderer()) !== null) {
         $extension = $renderer->fileExtension;
     } else {
         $extension = '.php';
     }
     if ($viewName[0] === '/') {
         if (strncmp($viewName, '//', 2) === 0) {
             $viewFile = $basePath . $viewName;
         } else {
             $viewFile = $moduleViewPath . $viewName;
         }
     } else {
         if (strpos($viewName, '.')) {
             $viewFile = Yii::getPathOfAlias($viewName);
         } else {
             $viewFile = $viewPath . DIRECTORY_SEPARATOR . $viewName;
         }
     }
     // custom part
     $fileName = Yii::getCustomPath($viewFile . $extension);
     if (is_file($fileName)) {
         return Yii::app()->findLocalizedFile($fileName);
     } else {
         if ($extension !== '.php') {
             $fileName = Yii::getCustomPath($viewFile . '.php');
             if (is_file($fileName)) {
                 return Yii::app()->findLocalizedFile($fileName);
             }
         }
     }
     return false;
 }
Example #3
Show file File: X2Widget.php Project: dsyman2/X2CRM
0
 /**
  * Renders a view file.
  * Overrides {@link CBaseController::renderFile} to check if the requested view 
  * has a version in /custom, and uses that if it exists.
  *
  * @param string $viewFile view file path
  * @param array $data data to be extracted and made available to the view
  * @param boolean $return whether the rendering result should be returned instead of being 
  *  echoed
  * @return string the rendering result. Null if the rendering result is not required.
  * @throws CException if the view file does not exist
  */
 public function renderFile($viewFile, $data = null, $return = false)
 {
     $viewFile = Yii::getCustomPath($viewFile);
     return parent::renderFile($viewFile, $data, $return);
 }
Example #4
Show file File: X2WebApplication.php Project: dsyman2/X2CRM
0
 /**
  * Creates a controller instance based on a route.
  * Modified to check in /custom for controller files.
  * See {@link CWebApplication::createController()} for details.
  *
  * @param string $route the route of the request.
  * @param CWebModule $owner the module that the new controller will belong to. Defaults to null, meaning the application
  * instance is the owner.
  * @return array the controller instance and the action ID. Null if the controller class does not exist or the route is invalid.
  */
 public function createController($route, $owner = null)
 {
     if ($owner === null) {
         $owner = $this;
     }
     if (($route = trim($route, '/')) === '') {
         $route = $owner->defaultController;
     }
     $caseSensitive = $this->getUrlManager()->caseSensitive;
     $route .= '/';
     while (($pos = strpos($route, '/')) !== false) {
         $id = substr($route, 0, $pos);
         if (!preg_match('/^\\w+$/', $id)) {
             return null;
         }
         if (!$caseSensitive) {
             $id = strtolower($id);
         }
         $route = (string) substr($route, $pos + 1);
         if (!isset($basePath)) {
             if (isset($owner->controllerMap[$id])) {
                 return array(Yii::createComponent($owner->controllerMap[$id], $id, $owner === $this ? null : $owner), $this->parseActionParams($route));
             }
             if (($module = $owner->getModule($id)) !== null) {
                 // fix module's base paths in case module was loaded from /custom
                 $module->basePath = Yii::resetCustomPath($module->basePath);
                 $module->viewPath = Yii::resetCustomPath($module->viewPath);
                 Yii::setPathOfAlias($module->getId(), $module->basePath);
                 return $this->createController($route, $module);
             }
             $basePath = $owner->getControllerPath();
             $controllerID = '';
         } else {
             $controllerID .= '/';
         }
         $className = ucfirst($id) . 'Controller';
         $classFile = $basePath . DIRECTORY_SEPARATOR . $className . '.php';
         $extendedClassFile = Yii::getCustomPath($basePath . DIRECTORY_SEPARATOR . 'My' . $className . '.php');
         if (is_file($extendedClassFile)) {
             // see if there's an extended controller in /custom
             if (!class_exists($className, false)) {
                 require Yii::getCustomPath($classFile);
             }
             // import the 'real' controller
             $className = 'My' . $className;
             // add "My" to the class name
             $classFile = $extendedClassFile;
         } else {
             $classFile = Yii::getCustomPath($classFile);
             // look in /custom for controller file
         }
         if (is_file($classFile)) {
             if (!class_exists($className, false)) {
                 require $classFile;
             }
             if (class_exists($className, false) && is_subclass_of($className, 'CController')) {
                 $id[0] = strtolower($id[0]);
                 return array(new $className($controllerID . $id, $owner === $this ? null : $owner), $this->parseActionParams($route));
             }
             return null;
         }
         $controllerID .= $id;
         $basePath .= DIRECTORY_SEPARATOR . $id;
     }
 }