The module contains an array of items. Each item can be one of the following types: link, group, or divider. When adding an item you provide an array of with the following keys.
Inheritance: extends Gdn_Module
 /**
  *
  *
  * @throws Exception
  */
 public function render()
 {
     $section_found = false;
     // The module contains different links depending on its section.
     foreach ($this->customSections as $section) {
         if (InSection($section)) {
             $this->fireEvent($section);
             $section_found = true;
             break;
         }
     }
     // If a section wasn't found then add the default nav.
     if (!$section_found) {
         $this->fireEvent('default');
     }
     // Fire an event for everything.
     $this->fireEvent('all');
     parent::render();
 }
Example #2
0
 /**
  * @param array $section
  */
 public function addSectionItems($section)
 {
     if ($groups = val(self::GROUPS_INDEX, $section)) {
         foreach ($groups as $group) {
             parent::addGroup($group['text'], $group['key'], $group['cssClass'], $group['sort'], $group['modifiers']);
         }
     }
     if ($links = val(self::LINKS_INDEX, $section)) {
         foreach ($links as $link) {
             parent::addLink($link['text'], $link['url'], $link['key'], $link['cssClass'], $link['sort'], $link['modifiers'], $link['disabled']);
         }
     }
 }
Example #3
0
 /**
  * @param NavModule $sender
  */
 public function siteNavModule_init_handler($sender)
 {
     // Grab the default route so that we don't add a link to it twice.
     $home = trim(val('Destination', Gdn::router()->getRoute('DefaultController')), '/');
     // Add the site discussion links.
     $sender->addLinkIf($home !== 'categories', t('All Categories', 'Categories'), '/categories', 'main.categories', '', 1, array('icon' => 'th-list'));
     $sender->addLinkIf($home !== 'discussions', t('Recent Discussions'), '/discussions', 'main.discussions', '', 1, array('icon' => 'discussion'));
     $sender->addGroup(t('Favorites'), 'favorites', '', 3);
     if (Gdn::session()->isValid()) {
         $sender->addLink(t('My Bookmarks'), '/discussions/bookmarked', 'favorites.bookmarks', '', array(), array('icon' => 'star', 'badge' => Gdn::session()->User->CountBookmarks));
         $sender->addLink(t('My Discussions'), '/discussions/mine', 'favorites.discussions', '', array(), array('icon' => 'discussion', 'badge' => Gdn::session()->User->CountDiscussions));
         $sender->addLink(t('Drafts'), '/drafts', 'favorites.drafts', '', array(), array('icon' => 'compose', 'badge' => Gdn::session()->User->CountDrafts));
     }
     $user = Gdn::controller()->data('Profile');
     if (!$user) {
         return;
     }
     $sender->addGroupToSection('Profile', t('Posts'), 'posts');
     $sender->addLinkToSection('Profile', t('Discussions'), userUrl($user, '', 'discussions'), 'posts.discussions', '', array(), array('icon' => 'discussion', 'badge' => val('CountDiscussions', $user)));
     $sender->addLinkToSection('Profile', t('Comments'), userUrl($user, '', 'comments'), 'posts.comments', '', array(), array('icon' => 'comment', 'badge' => val('CountComments', $user)));
 }
Example #4
0
 /**
  * Get the sort order of an item in the items array.
  * This function looks at the following keys:
  * - **sort (numeric)**: A specific numeric sort was provided.
  * - **sort array('before|after', 'key')**: You can specify that the item is before or after another item.
  * - **_sort**: The order the item was added is used.
  *
  * @param array $item The item to get the sort order from.
  * @param array $items The entire list of items.
  * @param int $depth The current recursive depth used to prevent inifinite recursion.
  * @return number
  */
 public static function sortItemsOrder($item, $items, $depth = 0)
 {
     $default_sort = val('_sort', $item, 100);
     // Check to see if a custom sort has been specified.
     if (isset($item['sort'])) {
         if (is_numeric($item['sort'])) {
             // This is a numeric sort
             return $item['sort'] * 10000 + $default_sort;
         } elseif (is_array($item['sort']) && $depth < 10) {
             // This sort is before or after another depth.
             list($op, $key) = $item['sort'];
             if (array_key_exists($key, $items)) {
                 switch ($op) {
                     case 'after':
                         return NavModule::sortItemsOrder($items[$key], $items, $depth + 1) + 1000;
                     case 'before':
                     default:
                         return NavModule::sortItemsOrder($items[$key], $items, $depth + 1) - 1000;
                 }
             }
         }
     }
     return $default_sort * 10000 + $default_sort;
 }
Example #5
0
<div class="row form-group">
    <div class="label-wrap-wide">
        <div class="label"><?php 
echo t('Embed My Forum');
?>
</div>
        <div class="label-description"><?php 
echo t('If you want to embed your forum or use Vanilla\'s comments in your blog then you need to enable embedding. If you aren\'t using embedding then we recommend leaving this setting off.');
?>
</div>
    </div>
    <div class="input-wrap-right">
    <span id="plaintext-toggle">
        <?php 
if (c('Garden.Embed.Allow', false)) {
    echo wrap(anchor('<div class="toggle-well"></div><div class="toggle-slider"></div>', 'embed/forum/disable/' . Gdn::session()->TransientKey()), 'span', array('class' => "toggle-wrap toggle-wrap-on"));
} else {
    echo wrap(anchor('<div class="toggle-well"></div><div class="toggle-slider"></div>', 'embed/forum/enable/' . Gdn::session()->TransientKey()), 'span', array('class' => "toggle-wrap toggle-wrap-off"));
}
?>
    </span>
    </div>
</div>
<?php 
$nav = new NavModule();
$nav->addLink(t('Vanilla Plugin for WordPress'), 'embed/wordpress', 'embed.wordpress', '', [], ['icon' => dashboardSymbol('plugin'), 'description' => t('Use Vanilla\'s Wordpress plugin if you want to embed in WordPress site.')]);
$nav->addLink(t('Universal Forum Embed Code'), 'embed/universal', 'embed.universal', '', [], ['icon' => dashboardSymbol('code'), 'description' => t('Use the forum embed code to embed the entire forum in a non-WordPress site.')]);
$nav->addLink(t('Universal Comment Embed Code'), 'embed/comments', 'embed.comments', '', [], ['icon' => dashboardSymbol('code-bubble'), 'description' => t('Use the comment embed code to embed Vanilla comments into a non-WordPress site.')]);
$nav->addLink(t('Embed Settings'), 'embed/settings', 'embed.settings', '', [], ['icon' => dashboardSymbol('settings'), 'description' => t('Use the comment embed code to embed Vanilla comments into a non-WordPress site.')]);
$nav->setView('nav-adventure');
echo $nav;