Example #1
0
 function run()
 {
     if ($this->running) {
         throw new \Exception(get_called_class() . '::run() was previously called!');
     }
     $this->running = true;
     $request = Request::getInstance();
     if ($request->exists(self::PATH_INFO_OVERRIDE_PARAM)) {
         $this->pathInfo = $request->get(self::PATH_INFO_OVERRIDE_PARAM, '/');
         $request->delete(self::PATH_INFO_OVERRIDE_PARAM);
     } else {
         $this->pathInfo = \ManiaLib\Utils\Arrays::getNotNull($_SERVER, 'PATH_INFO', '/');
     }
     list($this->controller, $this->action) = Route::getActionAndControllerFromRoute($this->pathInfo);
     $this->calledURL = $request->createLink();
     $viewsNS =& Config::getInstance()->viewsNS;
     $currentViewsNS = Config::getInstance()->namespace . '\\Views\\';
     if (!in_array($currentViewsNS, $viewsNS)) {
         array_unshift($viewsNS, $currentViewsNS);
     }
     try {
         Controller::factory($this->controller)->launch($this->action);
         Response::getInstance()->render();
     } catch (\Exception $e) {
         call_user_func(Bootstrapper::$errorHandlingCallback, $e);
         Response::getInstance()->render();
     }
 }
Example #2
0
 public static function findPage($uri, $sectionId = 0)
 {
     $db = Core::getDb();
     $uri = trim($uri, '/');
     if (strstr($uri, '/')) {
         return null;
     }
     if (!$uri) {
         $uri = 'index';
     }
     $q = $db->buildQuery("SELECT id FROM articles a LEFT JOIN objects o ON o.object_id=a.object_id WHERE cname='%s' AND section_id=%d", $uri, $sectionId);
     $pageId = $db->getSingleValue($q);
     Log::debug("lookup for section: {$sectionId}, cname: {$uri} --> pageId: {$pageId}");
     if (!$pageId) {
         return null;
     }
     $controller = Controller::factory('page');
     $controller->setInstanceId($pageId);
     // $controller->setObjectId( $remainder );
     Log::debug("matches {$uri} (type: page, id: {$pageId}), remainder: , q: ");
     return $controller;
 }
Example #3
0
         // This targets individual albums and events. For proper referencing,
         // Albums and Events container controllers should be written.  These
         // could then be inserted here as default locations within Kiki
         // without setup, but there's no reason these should eventually not be
         // part of the database in the sections table.  Kiki does support that
         // already, after all, just the CMS is lacking.
         $controller = Controller::factory($moduleMatches[1]);
         $controller->setObjectId($moduleMatches[2]);
     } else {
         // For all static files
         $controller = Controller::factory('Kiki');
         $controller->setObjectId($matches[1]);
     }
 } else {
     if (preg_match('#^/storage/([^\\.]+)\\.([^x]+)x([^\\.]+)\\.((c?))?#', $requestPath, $matches)) {
         $controller = Controller::factory('Thumbnails');
         $controller->setObjectId($matches);
     } else {
         if (!($controller = Router::findPage($requestPath)) && !($controller = Router::findSection($requestPath))) {
             // Nothing? 404.
             //
             // @todo Add an alias controller here, functioning quite like the
             // tinyURL controller but then with database stored URI aliases.
             //
             // The CMS module (and possibly the site itself when an administrator is
             // logged in) should then warn about aliases that conflict with
             // top-level pages (and vice versa), and possibly tinyURLs but those
             // might need a technical solution beyond risk management due to their
             // automatic generation.
             $controller = new Controller\NotFound404();
         }
Example #4
0
<?php

// Require Loader
if (file_exists("app/libraries/Autoload.php")) {
    require_once "app/libraries/Autoload.php";
}
// Initialize all requires classes
Autoload::init();
// To avoid triggering a PHP notice, we can't use array elements that do not exists
if (!isset($_GET['url'])) {
    $_GET['url'] = '/';
}
$router = new Router($_GET['url']);
$router->setDefaultController('HomeController');
$router->setDefaultAction('index');
$router->parse();
$controller = $router->getController();
$action = $router->getAction();
$arguments = $router->getArguments();
$controllerClass = Controller::factory($controller);
$actionName = $action;
// This is the key part, we call a method that has a name stored in $stored
$controllerClass->{$actionName}($arguments);
Example #5
0
<?php

namespace Xignify;

define("__ROOT__", __DIR__);
define("__DEBUG__", true);
$loader = (require "vendor/autoload.php");
switch ($args[0]) {
    case ".":
        $fa = Controller::factory("Xignify\\Example\\FrontPage");
        break;
    default:
        Error::page(404);
}
$fa->next($args);
exit;
Example #6
0
 public function renderMainContent()
 {
     $requestUri = ltrim(str_replace(ROOT_URI, '', $_SERVER['REDIRECT_URL']), '/');
     $controller = Controller::factory($requestUri);
     $controller->handle($requestUri);
 }