Example #1
0
 public static function submenu(Context $ctx, $query, array $pathinfo)
 {
     AdminPage::checkperm($ctx, $pathinfo);
     $router = new Router();
     $router->poll($ctx);
     $menu = new AdminMenu($router->getStatic());
     if (false === ($submenu = $menu->getSubMenu($ctx))) {
         throw new PageNotFoundException();
     }
     if (false === ($content = $submenu->getXML($ctx, 'content', array('type' => 'submenu')))) {
         throw new PageNotFoundException();
     }
     $page = new AdminPage($content);
     return $page->getResponse($ctx);
 }
Example #2
0
 public static function run()
 {
     try {
         self::setup();
         $ctx = Context::last();
         if ('admin/install' != $ctx->query() and !$ctx->config->isOk()) {
             $ctx->redirect('admin/install');
         }
         $router = new Router();
         $result = $router->poll($ctx)->dispatch($ctx);
         if ($result instanceof Response) {
             $result->send();
         } elseif (false === $result) {
             header('HTTP/1.1 404 Not Found');
             header('Content-Type: text/plain; charset=utf-8');
             die('Route Not Found.');
         } else {
             list($handler, $args) = $router->find($ctx);
             if (false === $handler) {
                 $method = '?unknown?';
             } elseif (is_array($handler['call'])) {
                 $method = implode('::', $handler['call']);
             } else {
                 $method = $handler['call'];
             }
             $message = t('<h1>Внутренняя ошибка</h1><p>Обработчик пути <tt>%path</tt> (<tt>%func</tt>) должен был вернуть объект класса <a href="@class">Response</a>, а вернул %type.</p><hr/><a href="@home">Molinos CMS v%version</a>', array('%path' => $ctx->query(), '%type' => gettype($result), '%func' => $method, '@class' => 'http://code.google.com/p/molinos-cms/wiki/Response_Class', '%version' => MCMS_VERSION, '@home' => 'http://molinos-cms.googlecode.com/'));
             header('HTTP/1.1 500 Internal Server Error');
             header('Content-Type: text/html; charset=utf-8');
             die($message);
         }
     } catch (Exception $e) {
         Logger::trace($e);
         header('HTTP/1.1 500 FUBAR');
         header('Content-Type: text/plain; charset=utf-8');
         die(sprintf('%s: %s.', get_class($e), rtrim($e->getMessage(), '.')));
     }
 }
Example #3
0
 /**
  * Добавление маршрутов.
  * @route GET//api/admin/menu.xml
  */
 public static function on_get_menu(Context $ctx)
 {
     $router = new Router();
     $router->poll($ctx);
     $menu = new AdminMenu($router->getStatic());
     return new Response($menu->getXML($ctx), 'text/xml');
 }