Ejemplo n.º 1
0
 /**
  * Build all my parameters for the view
  * @todo Pull as much as possible into the model, including the column names
  */
 public function onRender()
 {
     // Set the parentNode for the component output
     $topNode = menuModel::find($this->getIdFromProperty($this->property('start')));
     $this->page['parentNode'] = $topNode;
     // What page is active?
     $this->page['activeLeft'] = 0;
     $this->page['activeRight'] = 0;
     $activeNode = $this->getIdFromProperty($this->property('activeNode'));
     if ($activeNode) {
         // It's been set by the user, so use what they've set it as
         $activeNode = menuModel::find($activeNode);
     } elseif ($topNode) {
         // Go and find the page we're on
         $baseFileName = $this->page->page->getBaseFileName();
         // Get extra URL parameters
         $params = $this->page->controller->getRouter()->getParameters();
         // And make sure the active page is a child of the parentNode
         $activeNode = menuModel::where('url', $baseFileName)->where('nest_left', '>', $topNode->nest_left)->where('nest_right', '<', $topNode->nest_right);
         $activeNode = $activeNode->first();
     }
     // If I've got a result that is a node
     if ($activeNode && menuModel::getClassName() === get_class($activeNode)) {
         $this->page['activeLeft'] = (int) $activeNode->nest_left;
         $this->page['activeRight'] = (int) $activeNode->nest_right;
     }
     // How deep do we want to go?
     $this->page['numberOfLevels'] = (int) $this->property('numberOfLevels');
     // Add the classes to the view
     $this->page['primaryClasses'] = $this->property('primaryClasses');
     $this->page['secondaryClasses'] = $this->property('secondaryClasses');
     $this->page['tertiaryClasses'] = $this->property('tertiaryClasses');
     $this->page['listItemClasses'] = $this->property('listItemClasses');
 }
 public function run()
 {
     // This is a root node
     $mainMenu = Menu::create(['title' => 'Main Menu', 'description' => 'The main menu items', 'url' => '']);
     // The top, or primary level of navigation
     $homePage = $mainMenu->children()->create(['title' => 'Home Page', 'description' => 'The primary navigation level', 'url' => 'home']);
     // Secondary navigation
     $ajaxDemo = $homePage->children()->create(['title' => 'Ajax Framework', 'description' => 'Secondary item 1', 'url' => 'ajax']);
     $homePage->children()->create(['title' => 'Plugin Components', 'description' => 'Secondary item 2', 'url' => 'plugins']);
     $ajaxDemo->children()->create(['title' => 'Menu titles do not', 'description' => 'Tertiary item 1', 'url' => '']);
     $ajaxDemo->children()->create(['title' => 'Have to match page titles!', 'description' => 'Tertiary item 2', 'url' => '']);
 }
Ejemplo n.º 3
0
 /**
  * Update the menu item position
  */
 public function reorder_onMove()
 {
     $sourceNode = Menu::find(post('sourceNode'));
     $targetNode = post('targetNode') ? Menu::find(post('targetNode')) : null;
     if ($sourceNode == $targetNode) {
         return;
     }
     switch (post('position')) {
         case 'before':
             $sourceNode->moveBefore($targetNode);
             break;
         case 'after':
             $sourceNode->moveAfter($targetNode);
             break;
         case 'child':
             $sourceNode->makeChildOf($targetNode);
             break;
         default:
             $sourceNode->makeRoot();
             break;
     }
 }