/**
  * @Route("/", methods="GET")
  * @Request({"menu"})
  */
 public function indexAction($menu = false)
 {
     $query = Node::query();
     if (is_string($menu)) {
         $query->where(['menu' => $menu]);
     }
     return array_values($query->get());
 }
 /**
  * Adds cache breaker to router.
  * Sets profiles routes
  */
 public function onAppRequest()
 {
     App::router()->setOption('userprofile.profilelink', '{slug}');
     $this->nodes = Node::query()->where("link LIKE '@userprofile/profiles/%'")->get();
     foreach ($this->nodes as $node) {
         App::routes()->add(['name' => '@userprofile/profiles/' . $node->slug, 'controller' => 'Bixie\\Userprofile\\Controller\\ProfilesController::indexAction', 'label' => $node->title, 'defaults' => ['_node' => $node->id, 'roles' => $node->get('show_roles')], 'path' => $node->path]);
         App::routes()->add(['name' => '@userprofile/profiles/' . $node->slug . '/page', 'controller' => 'Bixie\\Userprofile\\Controller\\ProfilesController::indexAction', 'label' => $node->title, 'defaults' => ['_node' => $node->id, 'roles' => $node->get('show_roles')], 'path' => $node->path . '/page/{page}']);
         App::routes()->add(['name' => '@userprofile/profiles/' . $node->slug . '/id', 'controller' => 'Bixie\\Userprofile\\Controller\\ProfilesController::detailsAction', 'label' => __('Details'), 'defaults' => ['_node' => $node->id], 'path' => $node->path . '/{slug}']);
     }
 }
Esempio n. 3
0
 /**
  * @Request({"id": "int", "type": "string"})
  */
 public function editAction($id = 0, $type = null)
 {
     if (!$id) {
         $widget = Widget::create(['type' => $type]);
     } else {
         if (!($widget = Widget::find($id))) {
             App::abort(404, 'Widget not found.');
         }
     }
     return ['$view' => ['title' => __('Widgets'), 'name' => 'system/widget/edit.php'], '$data' => ['widget' => $widget, 'config' => ['menus' => App::menu(), 'nodes' => array_values(Node::query()->get()), 'roles' => array_values(Role::findAll()), 'types' => array_values(App::widget()->all()), 'positions' => array_values(App::position()->all())]]];
 }
 /**
  * Registers category routes
  */
 public function onRequest()
 {
     $categories = Category::findAll(true);
     uasort($categories, function ($a, $b) {
         return strcmp(substr_count($a->path, '/'), substr_count($b->path, '/')) * -1;
     });
     $node = Node::query()->where(['link' => '@download'])->first();
     foreach ($categories as $category) {
         if ($category->status !== 1) {
             continue;
         }
         $route = ['label' => $category->title, 'defaults' => ['_node' => $node->id, 'id' => $category->id], 'path' => $node->path . $category->path];
         //category views
         App::routes()->add(array_merge(['name' => '@download/category/' . $category->id, 'controller' => 'Bixie\\Download\\Controller\\SiteController::categoryAction'], $route));
         //file view
         App::routes()->add(array_merge(['name' => '@download/category/file/' . $category->id, 'controller' => 'Bixie\\Download\\Controller\\SiteController::fileAction'], $route));
     }
 }