Skip to content

Instantly share code, notes, and snippets.

@diogoca
Forked from jeroenherczeg/bootstrap.php
Last active December 20, 2015 00:39

Revisions

  1. diogoca revised this gist Jul 20, 2013. 1 changed file with 17 additions and 15 deletions.
    32 changes: 17 additions & 15 deletions horizontal.phtml
    Original file line number Diff line number Diff line change
    @@ -3,23 +3,24 @@
    * @authors Kanstantsin A Kamkou (2ka.by); Jeroen Herczeg
    */
    $html = array();
    $html[] ='<div class="navbar navbar-fixed-top">';
    $html[] =' <div class="navbar-inner">';
    $html[] =' <div class="container">';
    $html[] =' <ul class="nav">';

    foreach ($this->container as $page) {
    // ACL - visibility of the page

    // visibility of the page
    if (!$page->isVisible() || !$this->navigation()->accept($page)) {
    continue;
    }

    // Gerando Href relativo
    $href = str_replace($this->baseUrl(), '', $page->getHref());

    // dropdown
    $dropdown = !empty($page->pages);

    // header
    $html[] = '<li' . ($dropdown ? ' class="dropdown"' : '') . '>';
    $html[] = '<a href="' . ($dropdown ? '#' : $page->getHref()) . '" '
    $html[] = '<a href="' . ($dropdown ? '#' : $href) . '" '
    . 'class="dropdown-toggle" data-toggle="dropdown">';
    $html[] = $page->getLabel();

    @@ -37,16 +38,16 @@ foreach ($this->container as $page) {
    $html[] = '<ul class="dropdown-menu">';

    foreach ($page->pages as $subpage) {
    // ACL visibility of the sub-page
    if ($page->isVisible() || !$this->navigation()->accept($subpage)) {
    // visibility of the sub-page
    if (!$subpage->isVisible() || !$this->navigation()->accept($subpage)) {
    continue;
    }
    if ($subpage->getLabel() == 'divider') {
    $html[] = '<li class="divider"></li>';
    continue;
    }

    // Gerando Href relativo
    $href = str_replace($this->baseUrl(), '', $subpage->getHref());

    $html[] = '<li' . ($subpage->isActive() ? ' class="active"' : '') . '>';
    $html[] = '<a href="' . $subpage->getHref() . '">';
    $html[] = '<a href="' . $href . '">';

    if ($subpage->get('icon')) {
    $html[] = '<i class="icon-' . $subpage->get('icon') . '"></i>';
    @@ -55,15 +56,16 @@ foreach ($this->container as $page) {
    $html[] = $subpage->getLabel();
    $html[] = "</a>";
    $html[] = "</li>";

    if ($subpage->get('divider')) {
    $html[] = '<li class="divider"></li> ';
    }
    }

    $html[] = "</ul>";
    $html[] = "</li>";
    }

    $html[] = '</ul>';
    $html[] = '</div>';
    $html[] = '</div>';
    $html[] = '</div>';

    echo join(PHP_EOL, $html);
  2. diogoca revised this gist Jul 20, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion horizontal.phtml
    Original file line number Diff line number Diff line change
    @@ -38,7 +38,7 @@ foreach ($this->container as $page) {

    foreach ($page->pages as $subpage) {
    // ACL visibility of the sub-page
    if (!$page->isVisible() || !$this->navigation()->accept($page)) {
    if ($page->isVisible() || !$this->navigation()->accept($subpage)) {
    continue;
    }
    if ($subpage->getLabel() == 'divider') {
  3. diogoca revised this gist Jul 20, 2013. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions horizontal.phtml
    Original file line number Diff line number Diff line change
    @@ -9,8 +9,8 @@ $html[] =' <div class="container">';
    $html[] =' <ul class="nav">';

    foreach ($this->container as $page) {
    // visibility of the page
    if (!$page->isVisible()) {
    // ACL - visibility of the page
    if (!$page->isVisible() || !$this->navigation()->accept($page)) {
    continue;
    }

    @@ -37,8 +37,8 @@ foreach ($this->container as $page) {
    $html[] = '<ul class="dropdown-menu">';

    foreach ($page->pages as $subpage) {
    // visibility of the sub-page
    if (!$subpage->isVisible()) {
    // ACL visibility of the sub-page
    if (!$page->isVisible() || !$this->navigation()->accept($page)) {
    continue;
    }
    if ($subpage->getLabel() == 'divider') {
  4. @jeroenherczeg jeroenherczeg revised this gist Jun 19, 2012. 1 changed file with 20 additions and 0 deletions.
    20 changes: 20 additions & 0 deletions bootstrap.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {

    protected function _initNavigation() {
    // make sure the layout is loaded
    $this->bootstrap('layout');

    // get the view of the layout
    $layout = $this->getResource('layout');
    $view = $layout->getView();

    //load the navigation xml
    $config = new Zend_Config_Xml(APPLICATION_PATH.'/configs/navigation.xml','nav');

    // pass the navigation xml to the zend_navigation component
    $nav = new Zend_Navigation($config);

    // pass the zend_navigation component to the view of the layout
    $view->navigation($nav);
    }
    }
  5. @jeroenherczeg jeroenherczeg revised this gist Jun 19, 2012. 1 changed file with 35 additions and 0 deletions.
    35 changes: 35 additions & 0 deletions navigation.xml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    <?xml version="1.0" encoding="UTF-8"?>
    <configdata>
    <nav>
    <dashboard>
    <label>Dashboard</label>
    <uri>/</uri>
    </dashboard>
    <myprofile>
    <label>My Profile</label>
    <uri></uri>
    <pages>
    <editprofile>
    <label>Edit my profile</label>
    <uri>/user/profile</uri>
    </editprofile>
    <changepassword>
    <label>Change my password</label>
    <uri>/user/password</uri>
    </changepassword>
    <divider>
    <label>divider</label>
    <uri></uri>
    </divider>
    <logout>
    <label>Log out</label>
    <uri>/index/logout</uri>
    </logout>
    </pages>
    </myprofile>
    <admin>
    <label>Administration</label>
    <uri>/admin</uri>
    </admin>
    </nav>
    </configdata>
  6. @jeroenherczeg jeroenherczeg revised this gist Jun 19, 2012. 3 changed files with 23 additions and 5 deletions.
    16 changes: 13 additions & 3 deletions horizontal.phtml
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,12 @@
    <?php
    /**
    * @author Kanstantsin A Kamkou (2ka.by)
    * @authors Kanstantsin A Kamkou (2ka.by); Jeroen Herczeg
    */
    $html = array('<ul class="nav">');
    $html = array();
    $html[] ='<div class="navbar navbar-fixed-top">';
    $html[] =' <div class="navbar-inner">';
    $html[] =' <div class="container">';
    $html[] =' <ul class="nav">';

    foreach ($this->container as $page) {
    // visibility of the page
    @@ -37,7 +41,10 @@ foreach ($this->container as $page) {
    if (!$subpage->isVisible()) {
    continue;
    }

    if ($subpage->getLabel() == 'divider') {
    $html[] = '<li class="divider"></li>';
    continue;
    }
    $html[] = '<li' . ($subpage->isActive() ? ' class="active"' : '') . '>';
    $html[] = '<a href="' . $subpage->getHref() . '">';

    @@ -55,5 +62,8 @@ foreach ($this->container as $page) {
    }

    $html[] = '</ul>';
    $html[] = '</div>';
    $html[] = '</div>';
    $html[] = '</div>';

    echo join(PHP_EOL, $html);
    2 changes: 2 additions & 0 deletions layout.phtml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    $this->navigation()->menu()->setPartial('partials/horizontal.phtml');
    echo $this->navigation()->menu()->render();
    10 changes: 8 additions & 2 deletions vertical.phtml
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    <?php
    /**
    * @author Kanstantsin A Kamkou (2ka.by)
    * @authors Kanstantsin A Kamkou (2ka.by); Jeroen Herczeg
    */

    $html = array('<ul class="nav nav-list">');
    @@ -23,7 +23,10 @@ foreach ($this->container as $page) {
    if (!$subpage->isVisible()) {
    continue;
    }

    if ($subpage->getLabel() == 'divider') {
    $html[] = '<li class="divider"></li>';
    continue;
    }
    $html[] = '<li' . ($subpage->isActive() ? ' class="active"' : '') . '>';
    $html[] = '<a href="' . $subpage->getHref() . '">';

    @@ -39,5 +42,8 @@ foreach ($this->container as $page) {
    }

    $html[] = '</ul>';
    $html[] = '</div>';
    $html[] = '</div>';
    $html[] = '</div>';

    echo join(PHP_EOL, $html);
  7. @kkamkou kkamkou revised this gist Feb 24, 2012. 2 changed files with 18 additions and 2 deletions.
    10 changes: 10 additions & 0 deletions horizontal.phtml
    Original file line number Diff line number Diff line change
    @@ -5,6 +5,11 @@
    $html = array('<ul class="nav">');

    foreach ($this->container as $page) {
    // visibility of the page
    if (!$page->isVisible()) {
    continue;
    }

    // dropdown
    $dropdown = !empty($page->pages);

    @@ -28,6 +33,11 @@ foreach ($this->container as $page) {
    $html[] = '<ul class="dropdown-menu">';

    foreach ($page->pages as $subpage) {
    // visibility of the sub-page
    if (!$subpage->isVisible()) {
    continue;
    }

    $html[] = '<li' . ($subpage->isActive() ? ' class="active"' : '') . '>';
    $html[] = '<a href="' . $subpage->getHref() . '">';

    10 changes: 8 additions & 2 deletions vertical.phtml
    Original file line number Diff line number Diff line change
    @@ -6,8 +6,9 @@
    $html = array('<ul class="nav nav-list">');

    foreach ($this->container as $page) {
    // show only the current branch
    if ($this->menu()->getOnlyActiveBranch() && !$page->isActive(true)) {
    // show only the current branch and the visible item
    if (!$page->isVisible()
    || ($this->menu()->getOnlyActiveBranch() && !$page->isActive(true))) {
    continue;
    }

    @@ -18,6 +19,11 @@ foreach ($this->container as $page) {

    if (!empty($page->pages)) {
    foreach ($page->pages as $subpage) {
    // visibility of the sub-page
    if (!$subpage->isVisible()) {
    continue;
    }

    $html[] = '<li' . ($subpage->isActive() ? ' class="active"' : '') . '>';
    $html[] = '<a href="' . $subpage->getHref() . '">';

  8. @kkamkou kkamkou revised this gist Feb 23, 2012. 2 changed files with 0 additions and 0 deletions.
    File renamed without changes.
    File renamed without changes.
  9. @kkamkou kkamkou revised this gist Feb 23, 2012. 2 changed files with 3 additions and 2 deletions.
    1 change: 1 addition & 0 deletions horizontal
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    <?php
    /**
    * @author Kanstantsin A Kamkou (2ka.by)
    */
    4 changes: 2 additions & 2 deletions vertical
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,8 @@
    <?php
    /**
    * @author Kanstantsin A Kamkou (2ka.by)
    */


    $html = array('<ul class="nav nav-list">');

    foreach ($this->container as $page) {
    @@ -34,4 +34,4 @@ foreach ($this->container as $page) {

    $html[] = '</ul>';

    echo join(PHP_EOL, $html);
    echo join(PHP_EOL, $html);
  10. @kkamkou kkamkou created this gist Feb 23, 2012.
    48 changes: 48 additions & 0 deletions horizontal
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,48 @@
    /**
    * @author Kanstantsin A Kamkou (2ka.by)
    */
    $html = array('<ul class="nav">');

    foreach ($this->container as $page) {
    // dropdown
    $dropdown = !empty($page->pages);

    // header
    $html[] = '<li' . ($dropdown ? ' class="dropdown"' : '') . '>';
    $html[] = '<a href="' . ($dropdown ? '#' : $page->getHref()) . '" '
    . 'class="dropdown-toggle" data-toggle="dropdown">';
    $html[] = $page->getLabel();

    if ($dropdown) {
    $html[] = '<b class="caret"></b>';
    }

    $html[] = '</a>';

    if (!$dropdown) {
    $html[] = '</li>';
    continue;
    }

    $html[] = '<ul class="dropdown-menu">';

    foreach ($page->pages as $subpage) {
    $html[] = '<li' . ($subpage->isActive() ? ' class="active"' : '') . '>';
    $html[] = '<a href="' . $subpage->getHref() . '">';

    if ($subpage->get('icon')) {
    $html[] = '<i class="icon-' . $subpage->get('icon') . '"></i>';
    }

    $html[] = $subpage->getLabel();
    $html[] = "</a>";
    $html[] = "</li>";
    }

    $html[] = "</ul>";
    $html[] = "</li>";
    }

    $html[] = '</ul>';

    echo join(PHP_EOL, $html);
    37 changes: 37 additions & 0 deletions vertical
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    /**
    * @author Kanstantsin A Kamkou (2ka.by)
    */


    $html = array('<ul class="nav nav-list">');

    foreach ($this->container as $page) {
    // show only the current branch
    if ($this->menu()->getOnlyActiveBranch() && !$page->isActive(true)) {
    continue;
    }

    // header
    $html[] = '<li class="nav-header">';
    $html[] = $page->getLabel();
    $html[] = "</li>";

    if (!empty($page->pages)) {
    foreach ($page->pages as $subpage) {
    $html[] = '<li' . ($subpage->isActive() ? ' class="active"' : '') . '>';
    $html[] = '<a href="' . $subpage->getHref() . '">';

    if ($subpage->get('icon')) {
    $html[] = '<i class="icon-' . $subpage->get('icon') . '"></i>';
    }

    $html[] = $subpage->getLabel();
    $html[] = "</a>";
    $html[] = "</li>";
    }
    }
    }

    $html[] = '</ul>';

    echo join(PHP_EOL, $html);