Example #1
0
File: router.php Project: nemis/Fm
 static function route_controller($applicationName)
 {
     $url = parse_url($_SERVER['REQUEST_URI']);
     $path = explode('/', trim($url['path'], '/'));
     if (!isset($path[1])) {
         self::$controller = 'index';
         self::$action = 'index';
     } else {
         array_shift($path);
         $dir = $applicationName . '/controllers/';
         foreach ($path as $p) {
             if (!is_dir($dir . $p . '/')) {
                 break;
             } else {
                 $dir .= $p . '/';
                 array_shift($path);
             }
         }
         self::$dir = $dir;
         //if (isset($path[0]) and $path[0] == 'index.php')
         self::$controller = array_shift($path);
         self::$action = array_shift($path);
         if (empty(self::$action)) {
             self::$action = 'index';
         }
     }
     foreach ($path as $k => $v) {
         self::$params[$k] = $v;
     }
     return array(self::$controller, self::$action, self::$params);
 }
Example #2
0
 public function isAdmin()
 {
     if (self::$segments[0] == 'admin') {
         array_shift(self::$segments);
         self::$dir = 'admin';
     } elseif (self::$segments[0] == '') {
         array_shift(self::$segments);
         self::$dir = 'frontend';
     } else {
         self::$dir = 'frontend';
     }
 }