pietschy avatar pietschy committed 49168db

Added new DateNavItem to handle date specific text information (instead of the template) and renamed date_nav template to the more general folding_nav

Comments (0)

Files changed (7)

elements/navigation_builder/date_nav/menu.php

-<?php defined('C5_EXECUTE') or die("Access Denied.");
-/** @var NavRoot $navRoot */
-if (!isset($navRoot)) {
-    throw new Exception('Required parameter $navRoot is missing');
-}
-?>
-<ul class="<?=$navRoot->getRenderOption('class','date-nav')?>">
-    <?= $navRoot->renderChildItems() ?>
-</ul>

elements/navigation_builder/date_nav/nav_item.php

-<?php defined('C5_EXECUTE') or die("Access Denied.");
-/** @var NavItem $navItem */
-if (!isset($navItem)) {
-    throw new Exception('Required parameter $navItem is missing');
-}
-$liClassNames = $navItem->getClassNames();
-$anchorClassNames = array();
-$ulClassNames= array();
-
-if ($navItem->isFirstChild()) {
-    $liClassNames[] = 'first-child';
-}
-if ($navItem->isLastChild()) {
-    $liClassNames[] = 'last-child';
-}
-if ($navItem->isCurrent()) {
-    $liClassNames[] = 'nav-selected';
-    $liClassNames[] = 'nav-path-selected';
-}
-if ($navItem->isInPath()) {
-    $liClassNames[] = 'nav-path-selected';
-}
-if (!$navItem->isInPath() && !$navItem->isCurrent())
-{
-    $liClassNames[]= 'closed';
-}
-if ($navItem->hasChildren()) {
-    $liClassNames[] = 'has-children';
-}
-if ($navItem->depth() < 2) {
-    $liClassNames[] = 'level-1';
-}
-if ($navItem->depth() > 1) {
-    $liClassNames[] = 'level-' . $navItem->depth();
-}
-
-$text = $navItem->getName();
-if ($navItem->hasChildren())
-{
-    $text .= " ({$navItem->childCount()})";
-}
-
-?>
-<li class="<?= join(' ', $liClassNames)?>">
-    <a href="<?=$navItem->getURL()?>" class="<?= join(' ', $anchorClassNames)?>" target="<?=$navItem->getTarget()?>"><?=$text?></a>
-    <? if ($navItem->hasChildren()) { ?>
-    <a href="#" class="open-toggle"><span> </span></a>
-    <ul>
-        <? $navItem->renderChildItems() ?>
-    </ul>
-    <? } ?>
-</li>

elements/navigation_builder/default/nav_item.php

 <li class="<?= join(' ', $classNames)?>">
     <a href="<?=$navItem->getURL()?>" class="<?= join(' ', $anchorClassNames)?>" target="<?=$navItem->getTarget()?>"><?=$navItem->getName()?></a>
     <? if ($navItem->hasChildren()) { ?>
-    <a href="#" class="-flyout-toggle"><span> </span></a>
-    <ul class="-flyout">
+    <ul>
         <? $navItem->renderChildren() ?>
     </ul>
     <? } ?>

elements/navigation_builder/folding_nav/menu.php

+<?php defined('C5_EXECUTE') or die("Access Denied.");
+/** @var NavRoot $navRoot */
+if (!isset($navRoot)) {
+    throw new Exception('Required parameter $navRoot is missing');
+}
+?>
+<ul class="<?=$navRoot->getRenderOption('class','date-nav')?>">
+    <?= $navRoot->renderChildItems() ?>
+</ul>

elements/navigation_builder/folding_nav/nav_item.php

+<?php defined('C5_EXECUTE') or die("Access Denied.");
+/** @var NavItem $navItem */
+if (!isset($navItem)) {
+    throw new Exception('Required parameter $navItem is missing');
+}
+$liClassNames = $navItem->getClassNames();
+$anchorClassNames = array();
+$ulClassNames= array();
+
+if ($navItem->isFirstChild()) {
+    $liClassNames[] = 'first-child';
+}
+if ($navItem->isLastChild()) {
+    $liClassNames[] = 'last-child';
+}
+if ($navItem->isCurrent()) {
+    $liClassNames[] = 'nav-selected';
+    $liClassNames[] = 'nav-path-selected';
+}
+if ($navItem->isInPath()) {
+    $liClassNames[] = 'nav-path-selected';
+}
+if (!$navItem->isInPath() && !$navItem->isCurrent())
+{
+    $liClassNames[]= 'closed';
+}
+if ($navItem->hasChildren()) {
+    $liClassNames[] = 'has-children';
+}
+if ($navItem->depth() < 2) {
+    $liClassNames[] = 'level-1';
+}
+if ($navItem->depth() > 1) {
+    $liClassNames[] = 'level-' . $navItem->depth();
+}
+$text = $navItem->getName();
+?>
+<li class="<?= join(' ', $liClassNames)?>">
+    <a href="<?=$navItem->getURL()?>" class="<?= join(' ', $anchorClassNames)?>" target="<?=$navItem->getTarget()?>"><?=$text?></a>
+    <? if ($navItem->hasChildren()) { ?>
+    <a href="#" class="open-toggle"><span> </span></a>
+    <ul>
+        <? $navItem->renderChildItems() ?>
+    </ul>
+    <? } ?>
+</li>

models/DateNavItem.php

+<?php
+/**
+ * Created by JetBrains PhpStorm.
+ * User: andrew
+ * Date: 20/09/12
+ * Time: 4:53 PM
+ * To change this template use File | Settings | File Templates.
+ */
+class DateNavItem extends NavItem
+{
+    /** @var Page $page */
+    private $page;
+    /** @var String $format */
+    private $format;
+
+    public function __construct($page, $format)
+    {
+        // do an empty name since we override the getName() method.
+        parent::__construct("");
+
+        $this->page = $page;
+        $this->format = $format;
+    }
+
+    public function getName()
+    {
+        return $this->page->getCollectionDatePublic($this->format);
+    }
+
+
+}

models/DateNavigationBuilder.php

         }
 
         $navRoot->configureActivePathFrom(Page::getCurrentPage());
-        $navRoot->setRenderTemplate('date_nav');
+        $navRoot->setRenderTemplate('folding_nav');
 
         return $navRoot;
     }
 
         if (!isset($monthItem))
         {
-            $monthItem = new NavItem($page->getCollectionDatePublic('F'));
+            $monthItem = new DateNavItem($page, "F");
             $this->monthItems[$monthKey] = $monthItem;
             $this->getYearItem($page)->add($monthItem);
         }
 
         if (!isset($yearItem))
         {
-            $yearItem = new NavItem($yearKey);
+            $yearItem = new DateNavItem($page, "Y");
             $this->yearItems[$yearKey] = $yearItem;
         }
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.