public static function getFile($pageName, $file, $themable, $folder)
 {
     // Creating the empty resourcePath variable
     $filePath;
     // Creating the resource relative path
     $fileRelativePath = "/" . $pageName . "/" . $folder . "/" . $file;
     // If the page instance is themable and the current theme contains the resource
     if ($themable && file_exists(Paladin::getThemeLoader()->getFolder() . "/" . Paladin::getThemeLoader()->getCurrentTheme() . $fileRelativePath)) {
         // Setting the template path to the theme template path
         $filePath = Paladin::getThemeLoader()->getFolder() . "/" . Paladin::getThemeLoader()->getCurrentTheme() . $fileRelativePath;
     } else {
         // Setting the template path to the default path
         $filePath = Paladin::getPageLoader()->getFolder() . $fileRelativePath;
     }
     // Getting the current route
     $route = Paladin::getRouteLoader()->getCurrentRoute();
     // Returning the resource path from the root folder
     return $filePath;
 }
예제 #2
0
 /**
  * Load route from the given URL
  */
 public function loadRouteFromURL($url)
 {
     // Getting the route name and arguments for the given URL
     $route = $this->getCurrentRouteFromURL($url);
     // If there isn't name
     if ($route['name'] == "") {
         // Setting the route name as 'index'
         $route['name'] = "Index";
     }
     for ($i = 0; $i < sizeof($this->folders); $i++) {
         // Getting the route path
         $routePath = $this->folders[$i] . "/" . $route['name'] . ".php";
         // If the route directory doesn't exist
         if (!file_exists($routePath)) {
             // If this is the last folder of the list
             if ($i == sizeof($this->folders) - 1) {
                 // Displaying the 404 page
                 Paladin::getPageLoader()->displayPage("\\Paladin\\Pages", "ErrorPage", array("404 :(", "Sorry ! The page you requested cannot be found !"));
                 // Stopping the function
                 return;
             } else {
                 // Continuing the loop
                 continue;
             }
         } else {
             // Breaking the loop
             break;
         }
     }
     // Calling the route
     require $routePath;
     $routeClass = new $route['name']();
     $routeClass->onCalling($route['args']);
 }
예제 #3
0
 /**
  * Renders a page
  *
  * @param page
  *           The page relative path
  * @param pageInstance
  *           The page main class instance
  * @param args
  *           The arguments of the page
  */
 private function renderPage($pageInstance, $args)
 {
     // Sending the 'beforeDisplayed()' event to the page
     $pageInstance->beforeDisplayed();
     // Creating the template path
     $templatePath = "/" . $pageInstance->getName() . "/" . $pageInstance->getMainPage();
     // If the page instance is themable and the current theme contains the page
     if ($pageInstance->isThemable() && file_exists(Paladin::getThemeLoader()->getFolder() . "/" . Paladin::getThemeLoader()->getCurrentTheme() . $templatePath)) {
         // Setting the template path to the theme template path
         $templatePath = Paladin::getThemeLoader()->getFolder() . "/" . Paladin::getThemeLoader()->getCurrentTheme() . $templatePath;
     } else {
         // Setting the template path to the default path
         $templatePath = $this->folder . $templatePath;
     }
     // Rendering the page with Twig
     echo Paladin::getTwig()->render($templatePath, $pageInstance->constructTwigArray($args));
     // Sending the 'afterDisplayed()' event to the page
     $pageInstance->afterDisplayed();
 }