Example #1
0
 /**
  * Class autoload loader.
  * This method is provided to be invoked within an __autoload() magic method.
  * @param string class name
  * @return boolean whether the class has been loaded successfully
  */
 public static function autoload($className)
 {
     if (strstr($className, 'CAS_')) {
         return false;
     }
     // use include so that the error PHP file may appear
     if (isset(self::$_coreClasses[$className])) {
         include YII_PATH . self::$_coreClasses[$className];
     } else {
         if (isset(self::$_classes[$className])) {
             include self::$_classes[$className];
         } else {
             $classfile = GetSSModulePath("{$className}Model");
             if ($classfile) {
                 include $classfile;
                 return class_exists($className, false) || interface_exists($className, false);
             }
             include $className . '.php';
             return class_exists($className, false) || interface_exists($className, false);
         }
     }
     return true;
 }
Example #2
0
 /**
  * Creates a controller instance based on a route.
  * The route should contain the controller ID and the action ID.
  * It may also contain additional GET variables. All these must be concatenated together with slashes.
  *
  * This method will attempt to create a controller in the following order:
  * <ol>
  * <li>If the first segment is found in {@link controllerMap}, the corresponding
  * controller configuration will be used to create the controller;</li>
  * <li>If the first segment is found to be a module ID, the corresponding module
  * will be used to create the controller;</li>
  * <li>Otherwise, it will search under the {@link controllerPath} to create
  * the corresponding controller. For example, if the route is "admin/user/create",
  * then the controller will be created using the class file "protected/controllers/admin/UserController.php".</li>
  * </ol>
  * @param string the route of the request.
  * @param CWebModule 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) {
                 return $this->createController($route, $module);
             }
             $basePath = $owner->getControllerPath();
             $controllerID = '';
         } else {
             $controllerID .= '/';
         }
         $className = ucfirst($id) . 'Controller';
         //	$this->classFile=$basePath.DIRECTORY_SEPARATOR.$id.DIRECTORY_SEPARATOR.$className.'.php';
         $this->classFile = GetSSModulePath($className);
         if (is_file($this->classFile)) {
             if (!class_exists($className, false)) {
                 require $this->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;
     }
 }