public function render()
 {
     $app = $this->app;
     if ($app->request->query->get('curry_context') == 'main') {
         return Response::create($this->mainContent);
     }
     $twig = $this->getTwig();
     $templateFile = 'backend.html';
     $htmlHead = $this->getHtmlHead();
     $htmlHead->addScript('shared/libs/build/all.min.js');
     $htmlHead->addStylesheet('shared/libs/build/all.css');
     // Globals
     $twig->addGlobal('BaseUrl', $app->request->getBasePath() . '/');
     $twig->addGlobal('ProjectName', $this->app['name']);
     $twig->addGlobal('Encoding', 'utf-8');
     $twig->addGlobal('Version', App::VERSION);
     if ($app['setup']) {
         $user = 1;
     } else {
         $user = \User::getUser();
     }
     if (!$user) {
         $loginRedirect = '';
         if (isset($_POST['login_redirect'])) {
             $loginRedirect = $_POST['login_redirect'];
         } else {
             if (!isset($_GET['logout']) && count($_GET)) {
                 $loginRedirect = (string) url('', $_GET);
             }
         }
         $twig->addGlobal('LoginRedirect', $loginRedirect);
         $this->addBodyClass('tpl-login');
         $templateFile = 'login.html';
         // Finalize HtmlHead and add global
         $twig->addGlobal('HtmlHead', $htmlHead->getContent());
         $twig->addGlobal('BodyClass', $this->getBodyClass());
         $template = $twig->loadTemplate($templateFile);
         return $template->render(array());
     }
     $backendGroups = array('Content' => array(), 'Appearance' => array(), 'Accounts' => array(), 'System' => array());
     foreach ($app->backend->getViews() as $viewName => $view) {
         //if(!$user->hasAccess(get_class($view)))
         //	continue;
         $active = StringHelper::startsWith($app->request->getPathInfo(), '/' . $view->url());
         $group = $view->getGroup();
         $moduleProperties = array('Module' => $viewName, 'Active' => $active, 'Url' => $view->url(), 'Name' => $view->getName(), 'Title' => $view->getMessage(), 'Notifications' => $view->getNotifications());
         if ($group) {
             if (!isset($backendGroups[$group])) {
                 $backendGroups[$group] = array();
             }
             if (!isset($backendGroups[$group]['modules'])) {
                 $backendGroups[$group]['modules'] = array();
             }
             $backendGroups[$group]['modules'][$viewName] = $moduleProperties;
             $backendGroups[$group]['Name'] = $group;
             $backendGroups[$group]['Active'] = $active;
         }
         if ($active) {
             $twig->addGlobal('module', $moduleProperties);
         }
     }
     $twig->addGlobal('moduleGroups', $backendGroups);
     // Finalize HtmlHead and add global
     $twig->addGlobal('HtmlHead', $htmlHead->getContent());
     $twig->addGlobal('BodyClass', $this->getBodyClass());
     // Render template
     $template = $twig->loadTemplate($templateFile);
     return $template->render(array('breadcrumbs' => $this->breadcrumbs, 'commands' => $this->commands, 'menuItems' => $this->menuItems, 'mainContent' => $this->mainContent, 'menuContent' => $this->menuContent));
 }
Beispiel #2
0
 /**
  * Check if physical path is writable based on FilebrowserAccess.
  *
  * @param string $physical
  * @return bool
  */
 public static function isPhysicalWritable($physical)
 {
     $roots = self::getRoots();
     foreach ($roots as $root) {
         if ($root['writable'] && StringHelper::startsWith($physical . '/', $root['realpath'] . '/')) {
             return true;
         }
     }
     return false;
 }
Beispiel #3
0
 /**
  * Handler for reverse-routing.
  *
  * @param string $path
  * @param string|array $query
  */
 public function reverseRoute(&$path, &$query)
 {
     // remove matching base path
     $baseUrl = URL::getDefaultBaseUrl();
     $basePath = $baseUrl['path'];
     $basePathRemoved = false;
     if (StringHelper::startsWith($path, $basePath) && $path !== '/') {
         $path = substr($path, strlen($basePath));
         $basePathRemoved = true;
     }
     //\Curry_Route_ModelRoute::reverse($path, $query);
     // re-add base path if it was removed
     if ($basePathRemoved) {
         $path = $basePath . $path;
     }
 }