protected static function findItem($needles = null)
 {
     $app = JFactory::getApplication();
     $menus = $app->getMenu('site');
     // Prepare the reverse lookup array.
     // Collect all menu items and creat an array that contains
     // the ID from the query string of the menu item as a key,
     // and the menu item id (Itemid) as a value
     // Example:
     // array( "category" =>
     //     1(id) => 100 (Itemid),
     //     2(id) => 101 (Itemid)
     // );
     if (self::$lookup === null) {
         self::$lookup = array();
         $component = JComponentHelper::getComponent('com_gamification');
         $items = $menus->getItems('component_id', $component->id);
         if ($items) {
             foreach ($items as $item) {
                 if (isset($item->query) && isset($item->query['view'])) {
                     $view = $item->query['view'];
                     if (!isset(self::$lookup[$view])) {
                         self::$lookup[$view] = array();
                     }
                     if (isset($item->query['id'])) {
                         self::$lookup[$view][$item->query['id']] = $item->id;
                     } else {
                         // If it is a root element that have no a request parameter ID ( categories, authors ), we set 0 for an key
                         self::$lookup[$view][0] = $item->id;
                     }
                 }
             }
         }
     }
     if ($needles) {
         foreach ($needles as $view => $ids) {
             if (isset(self::$lookup[$view])) {
                 foreach ($ids as $id) {
                     if (isset(self::$lookup[$view][(int) $id])) {
                         return self::$lookup[$view][(int) $id];
                     }
                 }
             }
         }
     } else {
         $active = $menus->getActive();
         if ($active) {
             return $active->id;
         }
     }
     return null;
 }
Example #2
0
 */
// no direct access
defined('_JEXEC') or die;
foreach ($this->items as $item) {
    $notReadClass = "";
    if (!$item->status) {
        $notReadClass = "gfy-note-notread";
    }
    ?>
    <div class="row gfy-note-tiny <?php 
    echo $notReadClass;
    ?>
">
        <div class="col-xs-10">
            <a href="<?php 
    echo JRoute::_(GamificationHelperRoute::getNotificationRoute($item->id));
    ?>
">
                <?php 
    echo $this->escape($item->content);
    ?>
            </a>
        </div>
        <div class="col-xs-2">
            <img src="<?php 
    echo !$item->status ? "media/com_gamification/images/status_active.png" : "media/com_gamification/images/status_inactive.png";
    ?>
"/>
        </div>
    </div>
<?php