Пример #1
0
 function displayCalendarLegend($style = "list")
 {
     // do not display normal legend if dynamic legend is visible on this page
     $registry = JRegistry::getInstance("jevents");
     if ($registry->get("jevents.dynamiclegend", 0)) {
         return;
     }
     // since this is meant to be a comprehensive legend look for catids from menu first:
     $cfg = JEVConfig::getInstance();
     $Itemid = $this->myItemid;
     $user = JFactory::getUser();
     $db = JFactory::getDBO();
     // Parameters - This module should only be displayed alongside a com_jevents calendar component!!!
     $cfg = JEVConfig::getInstance();
     $option = JRequest::getCmd('option');
     if ($this->disable && $option != JEV_COM_COMPONENT) {
         return;
     }
     $catidList = "";
     include_once JPATH_ADMINISTRATOR . "/components/" . JEV_COM_COMPONENT . "/libraries/colorMap.php";
     $menu = JFactory::getApplication()->getMenu();
     $active = $menu->getActive();
     if (!is_null($active) && $active->component == JEV_COM_COMPONENT || !isset($Itemid)) {
         $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
     } else {
         // If accessing this function from outside the component then I must load suitable parameters
         $params = $menu->getParams($Itemid);
     }
     $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
     $c = 0;
     $catids = array();
     // New system
     $newcats = $params->get("catidnew", false);
     if ($newcats && is_array($newcats)) {
         foreach ($newcats as $newcat) {
             if (!in_array($newcat, $catids)) {
                 $catids[] = $newcat;
                 $catidList .= (JString::strlen($catidList) > 0 ? "," : "") . $newcat;
             }
         }
     } else {
         while ($nextCatId = $params->get("catid{$c}", null)) {
             if (!in_array($nextCatId, $catids)) {
                 $catids[] = $nextCatId;
                 $catidList .= (JString::strlen($catidList) > 0 ? "," : "") . $nextCatId;
             }
             $c++;
         }
     }
     $jevleghelper = new modJeventsLegendHelper();
     if ($catidList == "" && $params->get("catid0", "xxx") == "xxx") {
         modJeventsLegendHelper::getAllCats($this->_params, $catids, $catidList);
     }
     $separator = $params->get("catseparator", "|");
     $catidsOut = str_replace(",", $separator, $catidList);
     // I should only show legend for items that **can** be shown in calendar so must filter based on GET/POST
     $catidsIn = JRequest::getVar('catids', "NONE");
     if ($catidsIn != "NONE" && $catidsIn != "0") {
         $catidsGP = explode($separator, $catidsIn);
     } else {
         $catidsGP = array();
     }
     $catidsGPList = implode(",", $catidsGP);
     // This produces a full tree of categories
     $allrows = $this->getCategoryHierarchy($catidList, $catidsGPList);
     // This is the full set of top level catids
     $availableCatsIds = "";
     foreach ($allrows as $row) {
         $availableCatsIds .= (JString::strlen($availableCatsIds) > 0 ? $separator : "") . $row->id;
     }
     $allcats = new catLegend("0", JText::_('JEV_LEGEND_ALL_CATEGORIES'), "#d3d3d3", JText::_('JEV_LEGEND_ALL_CATEGORIES_DESC'));
     $allcats->activeBranch = true;
     array_push($allrows, $allcats);
     if (count($allrows) == 0) {
         return "";
     } else {
         if ($Itemid < 999999) {
             $itm = "&Itemid={$Itemid}";
         }
         $task = JRequest::getVar('jevcmd', $cfg->get('com_startview'));
         list($year, $month, $day) = JEVHelper::getYMD();
         $tsk = "";
         if ($task == "month.calendar" || $task == "year.listeventsevents" || $task == "week.listevents" || $task == "year.listevents" || $task == "day.listevents" || $task == "cat.listevents") {
             $tsk = "&task={$task}&year={$year}&month={$month}&day={$day}";
         } else {
             $tsk = "&task={$this->myTask}&year={$year}&month={$month}&day={$day}";
         }
         switch ($style) {
             case 'list':
                 $content = '<div class="event_legend_container">';
                 $content .= '<table border="0" cellpadding="0" cellspacing="5" width="100%">';
                 foreach ($allrows as $row) {
                     if (isset($row->activeBranch)) {
                         $content .= $this->listKids($row, $itm, $tsk, $availableCatsIds);
                     }
                 }
                 $content .= "</table>\n";
                 $content .= "</div>";
                 break;
             case 'block':
             default:
                 $content = '<div class="event_legend_container">';
                 foreach ($allrows as $row) {
                     if (isset($row->activeBranch)) {
                         $content .= $this->blockKids($row, $itm, $tsk, $availableCatsIds);
                     }
                 }
                 // stop floating legend items
                 $content .= '<br style="clear:both" />' . "</div>\n";
         }
         // only if called from module
         if (isset($this->_params)) {
             if ($this->_params->get('show_admin', 0) && isset($year) && isset($month) && isset($day) && isset($Itemid)) {
                 // This is only displayed when JEvents is the component so I can get the component view
                 $component = JComponentHelper::getComponent(JEV_COM_COMPONENT);
                 $registry = JRegistry::getInstance("jevents");
                 $controller =& $registry->get("jevents.controller", null);
                 if (!$controller) {
                     return $content;
                 }
                 $view = $controller->view;
                 //include_once(JPATH_SITE."/components/$option/events.html.php");
                 ob_start();
                 if (method_exists($view, "_viewNavAdminPanel")) {
                     echo $view->_viewNavAdminPanel();
                 }
                 $content .= ob_get_contents();
                 ob_end_clean();
             }
         }
         return $content;
     }
 }
Пример #2
0
<?php

/**
 * JEvents Component for Joomla 1.5.x
 *
 * @version     $Id: mod_jevents_legend.php 3141 2011-12-29 10:13:17Z geraintedwards $
 * @package     JEvents
 * @subpackage  Module JEvents Calendar
 * @copyright   Copyright (C) 2006-2008 JEvents Project Group
 * @license     GNU/GPLv2, see http://www.gnu.org/licenses/gpl-2.0.html
 * @link        http://joomlacode.org/gf/project/jevents
 */
defined('_JEXEC') or die('Restricted access');
// record what is running - used by the filters
$registry = JRegistry::getInstance("jevents");
$registry->set("jevents.activeprocess", "mod_jevents_legend");
$registry->set("jevents.moduleid", $module->id);
$registry->set("jevents.moduleparams", $params);
require_once dirname(__FILE__) . '/' . 'helper.php';
$jevhelper = new modJeventsLegendHelper();
$theme = JEV_CommonFunctions::getJEventsViewName();
$modtheme = $params->get("com_calViewName", $theme);
if ($modtheme == "" || $modtheme == "global") {
    $modtheme = $theme;
}
$theme = $modtheme;
$viewclass = $jevhelper->getViewClass($theme, 'mod_jevents_legend', $theme . '/' . "legend", $params);
$modview = new $viewclass($params, $module->id);
$modview->jevlayout = $theme;
echo $modview->displayCalendarLegend();