Exemplo n.º 1
0
 public function redirect($p)
 {
     $path = FabriqModules::new_model('pathmap', 'Paths');
     $path->get_by_path($p);
     if (count($path)) {
         switch ($path->modpage) {
             case 'module':
                 if (FabriqModules::enabled($path->controller)) {
                     $extra = explode('/', $path->extra);
                     if (count($extra) == 1) {
                         if ($extra[0] == '') {
                             unset($extra[0]);
                         }
                     }
                     PathMap::arg(0, $path->controller);
                     PathMap::arg(1, $path->action);
                     for ($i = 0; $i < count($extra); $i++) {
                         PathMap::arg($i + 2, $extra[$i]);
                     }
                     FabriqStack::enqueue($path->controller, $path->action, 'module', $extra);
                     return true;
                 } else {
                     FabriqStack::error(404);
                 }
                 break;
             case 'page':
             default:
                 PathMap::arg(0, $path->controller);
                 PathMap::arg(1, $path->action);
                 FabriqStack::enqueue($path->controller, $path->action);
                 if ($path->extra != '') {
                     $extra = explode('/', $path->extra);
                     if ($path->wildcard) {
                         $p = explode('/', $_GET['q']);
                         array_unshift($extra, $p[$path->wildcard]);
                     }
                     for ($i = 0; $i < count($extra); $i++) {
                         PathMap::arg($i + 2, $extra[$i]);
                     }
                 } else {
                     if ($path->wildcard) {
                         $p = explode('/', $_GET['q']);
                         PathMap::arg(2, $p[$path->wildcard]);
                     }
                 }
                 return true;
                 break;
         }
     }
     return false;
 }
Exemplo n.º 2
0
 /**
  * Process everything the queue
  */
 public static function processQueue()
 {
     if (!count(self::$queue)) {
         return false;
     }
     $next = FabriqStack::dequeue();
     while ($next->controller == '') {
         if (!count(self::$queue)) {
             return false;
         }
         FabriqStack::processQueue();
     }
     self::$processing = $next;
     switch ($next->type) {
         case 'module':
             $module =& FabriqModules::module($next->controller);
             call_user_func_array(array($module, $next->action), $next->extra);
             if (Fabriq::render() != 'none' && FabriqModules::has_permission() && !FabriqModules::stopMappedRender()) {
                 FabriqTemplates::renderToBody($next);
             }
             break;
         case 'controller':
         default:
             PathMap::controller($next->controller);
             PathMap::action($next->action);
             $file = "app/controllers/{$next->controller}.controller.php";
             if (file_exists('sites/' . FabriqStack::site() . "/{$file}")) {
                 require_once 'sites/' . FabriqStack::site() . "/{$file}";
             } else {
                 require_once $file;
             }
             $c = "{$next->controller}_controller";
             $controller = new $c();
             $a = str_replace('.', '_', $next->action);
             if (!$controller->hasMethod($a)) {
                 FabriqStack::error(404);
             }
             call_user_func(array($controller, $a));
             FabriqTemplates::renderToBody($next);
             break;
     }
     if (count(self::$queue)) {
         FabriqStack::processQueue();
     }
 }