/** * Logic to trash events * * @access public * @return void */ function trash() { // Check for request forgeries JSession::checkToken() or jexit('Invalid Token'); $app = JFactory::getApplication(); $input = $app->input; $cid = $input->get('cid', array(0), 'post', 'array'); $false = array_search('0', $cid); if ($false === 0) { JError::raiseNotice(100, JText::_('COM_JEM_SELECT_ITEM_TO_TRASH')); $this->setRedirect(JEMHelperRoute::getMyEventsRoute()); return; } $model = $this->getModel('myevents'); if (!$model->publish($cid, -2)) { echo "<script> alert('" . $model->getError() . "'); window.history.go(-1); </script>\n"; } $total = count($cid); $msg = $total . ' ' . JText::_('COM_JEM_EVENT_TRASHED'); $this->setRedirect(JEMHelperRoute::getMyEventsRoute(), $msg); }
/** * Determines the Itemid * * searches if a menuitem for this item exists * if not the active menuitem will be returned * * @param array The id and view * * * @return int Itemid */ protected static function _findItem($needles = null) { $app = JFactory::getApplication(); $menus = $app->getMenu('site'); if (!isset(self::$FixedItemid)) { $settings = JEMHelper::globalattribs(); $defaultItemid = $settings->get('default_Itemid'); } else { if (isset(self::$FixedItemid)) { $defaultItemid = self::$FixedItemid; } } // Prepare the reverse lookup array. if (!isset(self::$lookup2)) { self::$lookup2 = array(); $component = JComponentHelper::getComponent('com_jem'); $items = $menus->getItems('component_id', $component->id); // loop trough the menu-items of the component if ($items) { foreach ($items as $item) { if (isset($item->query) && isset($item->query['view'])) { // skip Calendar-layout if (isset($item->query['layout']) && $item->query['layout'] == 'calendar') { continue; } // define $view variable $view = $item->query['view']; // skip several views if (isset($item->query['view'])) { if ($view == 'calendar' || $view == 'search' || $view == 'venues') { continue; } } if (!isset(self::$lookup2[$view])) { self::$lookup2[$view] = array(); } } // check for Id's if (isset($item->query['id'])) { if (!isset(self::$lookup2[$view][$item->query['id']])) { self::$lookup2[$view][$item->query['id']] = $item->id; } } else { // Some views have no ID, but we have to set one self::$lookup2[$view][self::ARTIFICALID] = $item->id; } } } } // at this point we collected itemid's linking to the component if ($needles) { foreach ($needles as $view => $ids) { if (isset(self::$lookup2[$view])) { foreach ($ids as $id) { if (isset(self::$lookup2[$view][(int) $id])) { return self::$lookup2[$view][(int) $id]; } } } } } if ($defaultItemid) { return $defaultItemid; } else { $active = $menus->getActive(); if ($active && $active->component == 'com_jem') { return $active->id; } $component = JComponentHelper::getComponent('com_jem'); $items = $menus->getItems(array('component_id', 'link'), array($component->id, 'index.php?option=com_jem&view=eventslist'), false); $default = reset($items); return !empty($default->id) ? $default->id : null; } }
/** * Method to get the events * * @access public * @return array */ public static function getList(&$params) { mb_internal_encoding('UTF-8'); $db = JFactory::getDBO(); $user = JemFactory::getUser(); $levels = $user->getAuthorisedViewLevels(); # Retrieve Eventslist model for the data $model = JModelLegacy::getInstance('Eventslist', 'JemModel', array('ignore_request' => true)); # Set params for the model # has to go before the getItems function $model->setState('params', $params); # filter published # 0: unpublished # 1: published # 2: archived # -2: trashed # type: # 0: upcoming (not started) - dates,times > now+offset # 1: unfinished (not ended) - enddates,endtimes > now+offset # 2: archived - no limit, but from now back to the past # 3: running (today) - enddates,endtimes > today+offset AND dates,times < tomorrow+offset # 4: featured - ? (same as upcoming yet) $type = (int)$params->get('type'); $offset_hours = (int)$params->get('offset_hours', 0); $max_title_length = (int)$params->get('cuttitle', '25'); # clean parameter data $catids = JemHelper::getValidIds($params->get('catid')); $venids = JemHelper::getValidIds($params->get('venid')); $eventids = JemHelper::getValidIds($params->get('eventid')); $stateloc = $params->get('stateloc'); $stateloc_mode = $params->get('stateloc_mode', 0); # Open date support $opendates = empty($eventids) ? 0 : 1; // allow open dates if limited to specific events $model->setState('filter.opendates', $opendates); # all upcoming or unfinished events if (($type == 0) || ($type == 1)) { $offset_minutes = $offset_hours * 60; $model->setState('filter.published',1); $model->setState('filter.orderby',array('a.dates ASC','a.times ASC')); $cal_from = "(a.dates IS NULL OR (TIMESTAMPDIFF(MINUTE, NOW(), CONCAT(a.dates,' ',IFNULL(a.times,'00:00:00'))) > $offset_minutes) "; $cal_from .= ($type == 1) ? " OR (TIMESTAMPDIFF(MINUTE, NOW(), CONCAT(IFNULL(a.enddates,a.dates),' ',IFNULL(a.endtimes,'23:59:59'))) > $offset_minutes)) " : ") "; } # archived events only elseif ($type == 2) { $model->setState('filter.published',2); $model->setState('filter.orderby',array('a.dates DESC','a.times DESC')); $cal_from = ""; } # currently running events only (today + offset is inbetween start and end date of event) elseif ($type == 3) { $offset_days = (int)round($offset_hours / 24); $model->setState('filter.published',1); $model->setState('filter.orderby',array('a.dates ASC','a.times ASC')); $cal_from = " ((DATEDIFF(a.dates, CURDATE()) <= $offset_days) AND (DATEDIFF(IFNULL(a.enddates,a.dates), CURDATE()) >= $offset_days))"; } # featured elseif ($type == 4) { $offset_minutes = $offset_hours * 60; $model->setState('filter.featured',1); $model->setState('filter.orderby',array('a.dates ASC','a.times ASC')); $cal_from = "((TIMESTAMPDIFF(MINUTE, NOW(), CONCAT(a.dates,' ',IFNULL(a.times,'00:00:00'))) > $offset_minutes) "; $cal_from .= " OR (TIMESTAMPDIFF(MINUTE, NOW(), CONCAT(IFNULL(a.enddates,a.dates),' ',IFNULL(a.endtimes,'23:59:59'))) > $offset_minutes)) "; } $model->setState('filter.calendar_from',$cal_from); $model->setState('filter.groupby','a.id'); # filter category's if ($catids) { $model->setState('filter.category_id', $catids); $model->setState('filter.category_id.include', true); } # filter venue's if ($venids) { $model->setState('filter.venue_id', $venids); $model->setState('filter.venue_id.include', true); } # filter event id's if ($eventids) { $model->setState('filter.event_id', $eventids); $model->setState('filter.event_id.include', true); } # filter venue's state/province if ($stateloc) { $model->setState('filter.venue_state', $stateloc); $model->setState('filter.venue_state.mode', $stateloc_mode); // 0: exact, 1: partial } # count $count = $params->get('count', '2'); $model->setState('list.limit', $count); if ($params->get('use_modal', 0)) { JHtml::_('behavior.modal', 'a.flyermodal'); } # date/time $dateFormat = $params->get('formatdate', ''); $timeFormat = $params->get('formattime', ''); $addSuffix = empty($timeFormat); // if we use component's default time format we can also add corresponding suffix # Retrieve the available Events $events = $model->getItems(); $color = $params->get('color'); $fallback_color = $params->get('fallbackcolor', '#EEEEEE'); # Loop through the result rows and prepare data $lists = array(); $i = 0; foreach ($events as $row) { # create thumbnails if needed and receive imagedata $dimage = $row->datimage ? JEMImage::flyercreator($row->datimage, 'event') : null; $limage = $row->locimage ? JEMImage::flyercreator($row->locimage, 'venue') : null; ################# ## DEFINE LIST ## ################# $lists[$i] = new stdClass(); # check view access if (in_array($row->access, $levels)) { # We know that user has the privilege to view the event $lists[$i]->link = JRoute::_(JEMHelperRoute::getEventRoute($row->slug)); $lists[$i]->linkText = JText::_('MOD_JEM_TEASER_READMORE'); } else { $lists[$i]->link = JRoute::_('index.php?option=com_users&view=login'); $lists[$i]->linkText = JText::_('MOD_JEM_TEASER_READMORE_REGISTER'); } # cut titel $fulltitle = htmlspecialchars($row->title, ENT_COMPAT, 'UTF-8'); if (mb_strlen($fulltitle) > $max_title_length) { $title = mb_substr($fulltitle, 0, $max_title_length) . '...'; } else { $title = $fulltitle; } $lists[$i]->title = $title; $lists[$i]->fulltitle = $fulltitle; $lists[$i]->venue = htmlspecialchars($row->venue, ENT_COMPAT, 'UTF-8'); $lists[$i]->catname = implode(", ", JemOutput::getCategoryList($row->categories, $params->get('linkcategory', 1))); $lists[$i]->state = htmlspecialchars($row->state, ENT_COMPAT, 'UTF-8'); $lists[$i]->city = htmlspecialchars($row->city, ENT_COMPAT, 'UTF-8'); $lists[$i]->eventlink = $params->get('linkevent', 1) ? JRoute::_(JEMHelperRoute::getEventRoute($row->slug)) : ''; $lists[$i]->venuelink = $params->get('linkvenue', 1) ? JRoute::_(JEMHelperRoute::getVenueRoute($row->venueslug)) : ''; # time/date static $formats = array('year' => 'Y', 'month' => 'F', 'day' => 'j', 'weekday' => 'l'); static $defaults = array('year' => ' ', 'month' => '', 'day' => '?', 'weekday' => ''); $lists[$i]->day = modJEMteaserHelper::_format_day($row, $params); $tmpdate = empty($row->dates) ? $defaults : self::_format_date_fields($row->dates, $formats); $lists[$i]->dayname = $tmpdate['weekday']; // keep them for backward compatibility $lists[$i]->daynum = $tmpdate['day']; $lists[$i]->month = $tmpdate['month']; $lists[$i]->year = $tmpdate['year']; $lists[$i]->startdate = $tmpdate; $lists[$i]->enddate = empty($row->enddates) ? $defaults : self::_format_date_fields($row->enddates, $formats); list($lists[$i]->date, $lists[$i]->time) = self::_format_date_time($row, $params->get('datemethod', 1), $dateFormat, $timeFormat, $addSuffix); $lists[$i]->dateinfo = JEMOutput::formatDateTime($row->dates, $row->times, $row->enddates, $row->endtimes, $dateFormat, $timeFormat, $addSuffix); if ($dimage == null) { $lists[$i]->eventimage = JUri::base(true).'/media/system/images/blank.png'; $lists[$i]->eventimageorig = JUri::base(true).'/media/system/images/blank.png'; } else { $lists[$i]->eventimage = JUri::base(true).'/'.$dimage['thumb']; $lists[$i]->eventimageorig = JUri::base(true).'/'.$dimage['original']; } if ($limage == null) { $lists[$i]->venueimage = JUri::base(true).'/media/system/images/blank.png'; $lists[$i]->venueimageorig = JUri::base(true).'/media/system/images/blank.png'; } else { $lists[$i]->venueimage = JUri::base(true).'/'.$limage['thumb']; $lists[$i]->venueimageorig = JUri::base(true).'/'.$limage['original']; } $length = $params->get('descriptionlength'); $length2 = 1; $etc = '...'; $etc2 = JText::_('MOD_JEM_TEASER_NO_DESCRIPTION'); //append <br /> tags on line breaking tags so they can be stripped below $description = preg_replace("'<(hr[^/>]*?/|/(div|h[1-6]|li|p|tr))>'si", "$0<br />", $row->introtext); //strip html tags but leave <br /> tags $description = strip_tags($description, "<br>"); //switch <br /> tags to space character if ($params->get('br') == 0) { $description = str_replace('<br />',' ', $description); } // if (strlen($description) > $length) { $length -= strlen($etc); $description = preg_replace('/\s+?(\S+)?$/', '', substr($description, 0, $length+1)); $lists[$i]->eventdescription = substr($description, 0, $length).$etc; } elseif (strlen($description) < $length2) { $length -= strlen($etc2); $description = preg_replace('/\s+?(\S+)?$/', '', substr($description, 0, $length+1)); $lists[$i]->eventdescription = substr($description, 0, $length).$etc2; } else { $lists[$i]->eventdescription = $description; } $lists[$i]->readmore = strlen(trim($row->fulltext)); $lists[$i]->colorclass = $color; if (($color == 'category') && !empty($row->categories)) { $colors = array(); foreach ($row->categories as $category) { if (!empty($category->color)) { $colors[$category->color] = $category->color; } } $lists[$i]->color = (count($colors) == 1) ? array_pop($colors) : $fallback_color; } $i++; } // foreach ($events as $row) return $lists; }
/** * Creates the Venue View */ function display($tpl = null) { if ($this->getLayout() == 'calendar') { ### Venue Calendar view ### $app = JFactory::getApplication(); // Load tooltips behavior JHtml::_('behavior.tooltip'); // initialize variables $document = JFactory::getDocument(); $menu = $app->getMenu(); $menuitem = $menu->getActive(); $jemsettings = JEMHelper::config(); $params = $app->getParams(); $uri = JFactory::getURI(); $pathway = $app->getPathWay(); $jinput = $app->input; $print = $jinput->getBool('print', false); $user = JemFactory::getUser(); // Load css JemHelper::loadCss('jem'); JemHelper::loadCss('calendar'); JemHelper::loadCustomCss(); JemHelper::loadCustomTag(); if ($print) { JemHelper::loadCss('print'); $document->setMetaData('robots', 'noindex, nofollow'); } $evlinkcolor = $params->get('eventlinkcolor'); $evbackgroundcolor = $params->get('eventbackgroundcolor'); $currentdaycolor = $params->get('currentdaycolor'); $eventandmorecolor = $params->get('eventandmorecolor'); $style = ' div#jem .eventcontentinner a, div#jem .eventandmore a {color:' . $evlinkcolor . ';} .eventcontentinner {background-color:'.$evbackgroundcolor .';} .eventandmore {background-color:' . $eventandmorecolor . ';} .today .daynum {background-color:' . $currentdaycolor . ';}'; $document->addStyleDeclaration ($style); // add javascript (using full path - see issue #590) JHtml::_('script', 'media/com_jem/js/calendar.js'); // Retrieve year/month variables $year = $jinput->get('yearID', strftime("%Y"),'int'); $month = $jinput->get('monthID', strftime("%m"),'int'); // get data from model and set the month $model = $this->getModel('VenueCal'); $model->setDate(mktime(0, 0, 1, $month, 1, $year)); $rows = $this->get('Items','VenueCal'); // Set Page title $pagetitle = $params->def('page_title', $menuitem->title); $params->def('page_heading', $params->get('page_title')); $pageclass_sfx = $params->get('pageclass_sfx'); // Add site name to title if param is set if ($app->getCfg('sitename_pagetitles', 0) == 1) { $pagetitle = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $pagetitle); } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) { $pagetitle = JText::sprintf('JPAGETITLE', $pagetitle, $app->getCfg('sitename')); } $document->setTitle($pagetitle); $document->setMetaData('title', $pagetitle); // Check if the user has permission to add things $permissions = new stdClass(); $permissions->canAddEvent = $user->can('add', 'event'); $permissions->canAddVenue = $user->can('add', 'venue'); $itemid = $jinput->getInt('Itemid', 0); $venueID = $jinput->getInt('id', $params->get('id')); $partItemid = ($itemid > 0) ? '&Itemid=' . $itemid : ''; $partVenid = ($venueID > 0) ? '&id=' . $venueID : ''; $partLocid = ($venueID > 0) ? '&locid=' . $venueID : ''; $partDate = ($year ? ('&yearID=' . $year) : '') . ($month ? ('&monthID=' . $month) : ''); $url_base = 'index.php?option=com_jem&view=venue&layout=calendar' . $partVenid . $partItemid; $print_link = JRoute::_($url_base . $partDate . '&print=1&tmpl=component'); // init calendar $cal = new JEMCalendar($year, $month, 0); $cal->enableMonthNav($url_base . ($print ? '&print=1&tmpl=component' : '')); $cal->setFirstWeekDay($params->get('firstweekday',1)); $cal->enableDayLinks('index.php?option=com_jem&view=day'.$partLocid); // map variables $this->rows = $rows; $this->locid = $venueID; $this->params = $params; $this->jemsettings = $jemsettings; $this->permissions = $permissions; $this->cal = $cal; $this->pageclass_sfx = htmlspecialchars($pageclass_sfx); $this->print_link = $print_link; } else { ### Venue List view ### // initialize variables $app = JFactory::getApplication(); $document = JFactory::getDocument(); $menu = $app->getMenu(); $menuitem = $menu->getActive(); $jemsettings = JemHelper::config(); $settings = JemHelper::globalattribs(); $params = $app->getParams('com_jem'); $pathway = $app->getPathWay (); $uri = JFactory::getURI(); $jinput = $app->input; $task = $jinput->getCmd('task', ''); $print = $jinput->getBool('print', false); $user = JemFactory::getUser(); $itemid = $app->input->getInt('id', 0) . ':' . $app->input->getInt('Itemid', 0); // Load css JemHelper::loadCss('jem'); JemHelper::loadCustomCss(); JemHelper::loadCustomTag(); if ($print) { JemHelper::loadCss('print'); $document->setMetaData('robots', 'noindex, nofollow'); } // get data from model $rows = $this->get('Items'); $venue = $this->get('Venue'); // check for data error if (empty($venue)) { $app->enqueueMessage(JText::_('COM_JEM_VENUE_ERROR_VENUE_NOT_FOUND'), 'error'); return false; } // are events available? $noevents = (!$rows) ? 1 : 0; // Decide which parameters should take priority $useMenuItemParams = ($menuitem && $menuitem->query['option'] == 'com_jem' && $menuitem->query['view'] == 'venue' && (!isset($menuitem->query['layout']) || $menuitem->query['layout'] == 'default') && $menuitem->query['id'] == $venue->id); // get search & user-state variables $filter_order = $app->getUserStateFromRequest('com_jem.venue.'.$itemid.'.filter_order', 'filter_order', 'a.dates', 'cmd'); $filter_order_DirDefault = 'ASC'; // Reverse default order for dates in archive mode if($task == 'archive' && $filter_order == 'a.dates') { $filter_order_DirDefault = 'DESC'; } $filter_order_Dir = $app->getUserStateFromRequest('com_jem.venue.'.$itemid.'.filter_order_Dir', 'filter_order_Dir', $filter_order_DirDefault, 'word'); $filter_type = $app->getUserStateFromRequest('com_jem.venue.'.$itemid.'.filter_type', 'filter_type', '', 'int'); $search = $app->getUserStateFromRequest('com_jem.venue.'.$itemid.'.filter_search', 'filter_search', '', 'string'); // table ordering $lists['order_Dir'] = $filter_order_Dir; $lists['order'] = $filter_order; // Get image $limage = JemImage::flyercreator($venue->locimage,'venue'); // Add feed links $link = '&format=feed&id='.$venue->id.'&limitstart='; $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'); $this->document->addHeadLink(JRoute::_($link . '&type=rss'), 'alternate', 'rel', $attribs); $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'); $this->document->addHeadLink(JRoute::_($link . '&type=atom'), 'alternate', 'rel', $attribs); // pathway, page title, page heading if ($useMenuItemParams) { $pagetitle = $params->get('page_title', $menuitem->title ? $menuitem->title : $venue->venue); $pageheading = $params->get('page_heading', $pagetitle); $pathway->setItemName(1, $menuitem->title); } else { $pagetitle = $venue->venue; $pageheading = $pagetitle; $params->set('show_page_heading', 1); // ensure page heading is shown $pathway->addItem($pagetitle, JRoute::_(JemHelperRoute::getVenueRoute($venue->slug))); } $pageclass_sfx = $params->get('pageclass_sfx'); // create the pathway if ($task == 'archive') { $pathway->addItem (JText::_('COM_JEM_ARCHIVE'), JRoute::_(JemHelperRoute::getVenueRoute($venue->slug).'&task=archive')); $print_link = JRoute::_(JEMHelperRoute::getVenueRoute($venue->slug).'&task=archive&print=1&tmpl=component'); $pagetitle .= ' - ' . JText::_('COM_JEM_ARCHIVE'); $pageheading .= ' - ' . JText::_('COM_JEM_ARCHIVE'); } else { //$pathway->addItem($venue->venue, JRoute::_(JEMHelperRoute::getVenueRoute($venue->slug))); $print_link = JRoute::_(JemHelperRoute::getVenueRoute($venue->slug).'&print=1&tmpl=component'); } $params->set('page_heading', $pageheading); // Add site name to title if param is set if ($app->getCfg('sitename_pagetitles', 0) == 1) { $pagetitle = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $pagetitle); } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) { $pagetitle = JText::sprintf('JPAGETITLE', $pagetitle, $app->getCfg('sitename')); } // set Page title & Meta data $document->setTitle($pagetitle); $document->setMetaData('title', $pagetitle); $document->setMetadata('keywords', $venue->meta_keywords); $document->setDescription(strip_tags($venue->meta_description)); // Check if the user has permission to add things $permissions = new stdClass(); $permissions->canAddEvent = $user->can('add', 'event'); $permissions->canAddVenue = $user->can('add', 'venue'); // Check if the user has permission to edit-this venue $permissions->canEditVenue = $user->can('edit', 'venue', $venue->id, $venue->created_by); $permissions->canEditPublishVenue = $user->can(array('edit', 'publish'), 'venue', $venue->id, $venue->created_by); // Generate Venuedescription if (!$venue->locdescription == '' || !$venue->locdescription == '<br />') { // execute plugins $venue->text = $venue->locdescription; $venue->title = $venue->venue; JPluginHelper::importPlugin ('content'); $app->triggerEvent ('onContentPrepare', array ( 'com_jem.venue', &$venue, &$params, 0 )); $venuedescription = $venue->text; } // build the url if (!empty($venue->url) && !preg_match('%^http(s)?://%', $venue->url)) { $venue->url = 'http://' . $venue->url; } // prepare the url for output if (strlen($venue->url) > 35) { $venue->urlclean = $this->escape(substr($venue->url, 0, 35 )) . '...'; } else { $venue->urlclean = $this->escape($venue->url); } // create flag if ($venue->country) { $venue->countryimg = JemHelperCountries::getCountryFlag($venue->country); } // Create the pagination object $pagination = $this->get('Pagination'); // filters $filters = array (); // ALL events have the same venue - so hide this from filter and list $jemsettings->showlocate = 0; if ($jemsettings->showtitle == 1) { $filters[] = JHtml::_('select.option', '1', JText::_('COM_JEM_TITLE')); } if ($jemsettings->showlocate == 1) { $filters[] = JHtml::_('select.option', '2', JText::_('COM_JEM_VENUE')); } if ($jemsettings->showcity == 1) { $filters[] = JHtml::_('select.option', '3', JText::_('COM_JEM_CITY')); } if ($jemsettings->showcat == 1) { $filters[] = JHtml::_('select.option', '4', JText::_('COM_JEM_CATEGORY')); } if ($jemsettings->showstate == 1) { $filters[] = JHtml::_('select.option', '5', JText::_('COM_JEM_STATE')); } $lists['filter'] = JHtml::_('select.genericlist', $filters, 'filter_type', array('size'=>'1','class'=>'inputbox'), 'value', 'text', $filter_type); $lists['search'] = $search; // mapping variables $this->lists = $lists; $this->action = $uri->toString(); $this->rows = $rows; $this->noevents = $noevents; $this->venue = $venue; $this->print_link = $print_link; $this->params = $params; $this->limage = $limage; $this->venuedescription = $venuedescription; $this->pagination = $pagination; $this->jemsettings = $jemsettings; $this->settings = $settings; $this->permissions = $permissions; $this->show_status = $permissions->canEditPublishVenue; $this->item = $menuitem; $this->pagetitle = $pagetitle; $this->task = $task; $this->pageclass_sfx = htmlspecialchars($pageclass_sfx); } parent::display($tpl); }
/** * Deletes a registered user */ function delreguser() { // Check for request forgeries JSession::checkToken() or jexit('Invalid Token'); $id = JFactory::getApplication()->input->getInt('rdid', 0); // Get/Create the model $model = $this->getModel('Event', 'JEMModel'); $model->setId($id); $model->delreguser(); JEMHelper::updateWaitingList($id); JPluginHelper::importPlugin('jem'); $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onEventUserUnregistered', array($id)); $cache = JFactory::getCache('com_jem'); $cache->clean(); $msg = JText::_('COM_JEM_UNREGISTERED_SUCCESSFULL'); $this->setRedirect(JRoute::_(JEMHelperRoute::getEventRoute($id), false), $msg); }
/** * Method to get the events * * @access public * @return array */ public static function getList(&$params) { mb_internal_encoding('UTF-8'); // Retrieve Eventslist model for the data $model = JModelLegacy::getInstance('Eventslist', 'JemModel', array('ignore_request' => true)); // Set params for the model // has to go before the getItems function $model->setState('params', $params); $model->setState('filter.access', true); // filter published // 0: unpublished // 1: published // 2: archived // -2: trashed $type = $params->get('type'); $offset_hourss = $params->get('offset_hours', 0); // all upcoming or unfinished events if ($type == 0 || $type == 1) { $offset_minutes = $offset_hourss * 60; $model->setState('filter.published', 1); $model->setState('filter.orderby', array('a.dates ASC', 'a.times ASC')); $cal_from = "((TIMESTAMPDIFF(MINUTE, NOW(), CONCAT(a.dates,' ',IFNULL(a.times,'00:00:00'))) > {$offset_minutes}) "; $cal_from .= $type == 1 ? " OR (TIMESTAMPDIFF(MINUTE, NOW(), CONCAT(IFNULL(a.enddates,a.dates),' ',IFNULL(a.endtimes,'23:59:59'))) > {$offset_minutes})) " : ") "; } elseif ($type == 2) { $model->setState('filter.published', 2); $model->setState('filter.orderby', array('a.dates DESC', 'a.times DESC')); $cal_from = ""; } elseif ($type == 3) { $offset_days = (int) round($offset_hourss / 24); $model->setState('filter.published', 1); $model->setState('filter.orderby', array('a.dates ASC', 'a.times ASC')); $cal_from = " ((DATEDIFF(a.dates, CURDATE()) <= {$offset_days}) AND (DATEDIFF(IFNULL(a.enddates,a.dates), CURDATE()) >= {$offset_days}))"; } $model->setState('filter.calendar_from', $cal_from); $model->setState('filter.groupby', 'a.id'); // clean parameter data $catids = $params->get('catid'); $venids = $params->get('venid'); $eventids = $params->get('eventid'); // filter category's if ($catids) { $model->setState('filter.category_id', $catids); $model->setState('filter.category_id.include', true); } // filter venue's if ($venids) { $model->setState('filter.venue_id', $venids); $model->setState('filter.venue_id.include', true); } // filter event id's if ($eventids) { $model->setState('filter.event_id', $eventids); $model->setState('filter.event_id.include', true); } // count $count = $params->get('count', '2'); $model->setState('list.limit', $count); if ($params->get('use_modal', 0)) { JHtml::_('behavior.modal', 'a.flyermodal'); } // Retrieve the available Events $events = $model->getItems(); if (!$events) { return array(); } // define list-array // in here we collect the row information $lists = array(); $i = 0; $FixItemID = $params->get('FixItemID', ''); $eventimg = $params->get('eventimg', 1); $venueimg = $params->get('venueimg', 1); /** * DEFINE FOREACH */ foreach ($events as $row) { // create thumbnails if needed and receive imagedata if ($row->datimage) { $dimage = JEMImage::flyercreator($row->datimage, 'event'); } else { $dimage = null; } if ($row->locimage) { $limage = JEMImage::flyercreator($row->locimage, 'venue'); } else { $limage = null; } // cut titel $length = mb_strlen($row->title); $maxlength = $params->get('cuttitle', '18'); if ($length > $maxlength && $maxlength > 0) { $row->title = mb_substr($row->title, 0, $maxlength); $row->title = $row->title . '...'; } $lists[$i] = new stdClass(); $lists[$i]->title = htmlspecialchars($row->title, ENT_COMPAT, 'UTF-8'); $lists[$i]->venue = htmlspecialchars($row->venue, ENT_COMPAT, 'UTF-8'); $lists[$i]->state = htmlspecialchars($row->state, ENT_COMPAT, 'UTF-8'); list($lists[$i]->date, $lists[$i]->time) = modJEMwideHelper::_format_date_time($row, $params); if ($FixItemID) { $lists[$i]->eventlink = $params->get('linkevent', 1) ? JRoute::_('index.php?option=com_jem&view=event&id=' . $row->slug . '&Itemid=' . $FixItemID) : ''; $lists[$i]->venuelink = $params->get('linkvenue', 1) ? JRoute::_('index.php?option=com_jem&view=venue&id=' . $row->venueslug . '&Itemid=' . $FixItemID) : ''; } else { $lists[$i]->eventlink = $params->get('linkevent', 1) ? JRoute::_(JEMHelperRoute::getEventRoute($row->slug)) : ''; $lists[$i]->venuelink = $params->get('linkvenue', 1) ? JRoute::_(JEMHelperRoute::getVenueRoute($row->venueslug)) : ''; } $lists[$i]->catname = implode(", ", JemOutput::getCategoryList($row->categories, $params->get('linkcategory', 1), false, $FixItemID)); // images if ($eventimg) { if ($dimage == null) { $lists[$i]->eventimage = ''; $lists[$i]->eventimageorig = ''; } else { $lists[$i]->eventimage = JURI::base(true) . '/' . $dimage['thumb']; $lists[$i]->eventimageorig = JURI::base(true) . '/' . $dimage['original']; } } else { $lists[$i]->eventimage = ''; $lists[$i]->eventimageorig = ''; } if ($venueimg) { if ($limage == null) { $lists[$i]->venueimage = ''; $lists[$i]->venueimageorig = ''; } else { $lists[$i]->venueimage = JURI::base(true) . '/' . $limage['thumb']; $lists[$i]->venueimageorig = JURI::base(true) . '/' . $limage['original']; } } else { $lists[$i]->venueimage = ''; $lists[$i]->venueimageorig = ''; } $lists[$i]->eventdescription = strip_tags($row->fulltext); $lists[$i]->venuedescription = strip_tags($row->locdescription); $i++; } return $lists; }
/** * Method to get a list of venues. */ public function getItems() { $query = $this->_getListQuery(); $items = $this->_getList($query, $this->getStart(), $this->getState('list.limit')); $app = JFactory::getApplication(); $params = clone $this->getState('params'); // Lets load the content if it doesn't already exist if ($items) { foreach ($items as $item) { //create target link $item->linkEventsArchived = JRoute::_(JEMHelperRoute::getVenueRoute($item->venueslug . '&task=archive')); $item->linkEventsPublished = JRoute::_(JEMHelperRoute::getVenueRoute($item->venueslug)); $item->EventsPublished = $this->AssignedEvents($item->locid, '1'); $item->EventsArchived = $this->AssignedEvents($item->locid, '2'); } return $items; } return array(); }
/** * Method to get the events * * @access public * @return array */ public static function getList(&$params) { mb_internal_encoding('UTF-8'); $db = JFactory::getDBO(); $user = JFactory::getUser(); $levels = $user->getAuthorisedViewLevels(); # Retrieve Eventslist model for the data $model = JModelLegacy::getInstance('Eventslist', 'JemModel', array('ignore_request' => true)); # Set params for the model # has to go before the getItems function $model->setState('params', $params); # filter published # 0: unpublished # 1: published # 2: archived # -2: trashed $type = (int) $params->get('type'); $offset_hours = (int) $params->get('offset_hours', 0); $max_title_length = (int) $params->get('cuttitle', '25'); # clean parameter data $catids = JemHelper::getValidIds($params->get('catid')); $venids = JemHelper::getValidIds($params->get('venid')); # all upcoming or unfinished events if ($type == 0 || $type == 1) { $offset_minutes = $offset_hours * 60; $model->setState('filter.published', 1); $model->setState('filter.orderby', array('a.dates ASC', 'a.times ASC')); $cal_from = "((TIMESTAMPDIFF(MINUTE, NOW(), CONCAT(a.dates,' ',IFNULL(a.times,'23:59:59'))) > {$offset_minutes}) "; $cal_from .= $type == 1 ? " OR (TIMESTAMPDIFF(MINUTE, NOW(), CONCAT(IFNULL(a.enddates,a.dates),' ',IFNULL(a.endtimes,'23:59:59'))) > {$offset_minutes})) " : ") "; } elseif ($type == 2) { $model->setState('filter.published', 2); $model->setState('filter.orderby', array('a.dates DESC', 'a.times DESC')); $cal_from = ""; } elseif ($type == 3) { $offset_days = (int) round($offset_hours / 24); $model->setState('filter.published', 1); $model->setState('filter.orderby', array('a.dates ASC', 'a.times ASC')); $cal_from = " ((DATEDIFF(a.dates, CURDATE()) <= {$offset_days}) AND (DATEDIFF(IFNULL(a.enddates,a.dates), CURDATE()) >= {$offset_days}))"; } $model->setState('filter.calendar_from', $cal_from); $model->setState('filter.groupby', 'a.id'); # filter category's if ($catids) { $model->setState('filter.category_id', $catids); $model->setState('filter.category_id.include', true); } # filter venue's if ($venids) { $model->setState('filter.venue_id', $venids); $model->setState('filter.venue_id.include', true); } # count $count = $params->get('count', '2'); $model->setState('list.limit', $count); if ($params->get('use_modal', 0)) { JHtml::_('behavior.modal', 'a.flyermodal'); } # date/time $dateFormat = $params->get('formatdate', ''); $timeFormat = $params->get('formattime', ''); $addSuffix = empty($timeFormat); // if we use component's default time format we can also add corresponding suffix # Retrieve the available Events $events = $model->getItems(); # Loop through the result rows and prepare data $lists = array(); $i = 0; foreach ($events as $row) { # create thumbnails if needed and receive imagedata $dimage = $row->datimage ? JEMImage::flyercreator($row->datimage, 'event') : null; $limage = $row->locimage ? JEMImage::flyercreator($row->locimage, 'venue') : null; ################# ## DEFINE LIST ## ################# $lists[$i] = new stdClass(); # cut titel $fulltitle = htmlspecialchars($row->title, ENT_COMPAT, 'UTF-8'); if (mb_strlen($fulltitle) > $max_title_length) { $title = mb_substr($fulltitle, 0, $max_title_length) . '...'; } else { $title = $fulltitle; } ## Also trim venue name to same as title $fullvenuename = htmlspecialchars($row->venue, ENT_COMPAT, 'UTF-8'); if (mb_strlen($fullvenuename) > $max_title_length) { $venue = mb_substr($fullvenuename, 0, $max_title_length) . '...'; } else { $venue = $fullvenuename; } $lists[$i]->title = $title; $lists[$i]->fulltitle = $fulltitle; $lists[$i]->venue = $venue; $lists[$i]->fullvenue = $fullvenuename; $lists[$i]->catname = implode(", ", JemOutput::getCategoryList($row->categories, $params->get('linkcategory', 1))); $lists[$i]->state = htmlspecialchars($row->state, ENT_COMPAT, 'UTF-8'); $lists[$i]->city = htmlspecialchars($row->city, ENT_COMPAT, 'UTF-8'); $lists[$i]->eventlink = $params->get('linkevent', 1) ? JRoute::_(JEMHelperRoute::getEventRoute($row->slug)) : ''; $lists[$i]->venuelink = $params->get('linkvenue', 1) ? JRoute::_(JEMHelperRoute::getVenueRoute($row->venueslug)) : ''; # time/date list($lists[$i]->date, $lists[$i]->time) = self::_format_date_time($row, $params->get('datemethod', 1), $dateFormat, $timeFormat, $addSuffix); $lists[$i]->dateinfo = JEMOutput::formatDateTime($row->dates, $row->times, $row->enddates, $row->endtimes, $dateFormat, $timeFormat, $addSuffix); if ($dimage == null) { $lists[$i]->eventimage = JUri::base(true) . '/media/system/images/blank.png'; $lists[$i]->eventimageorig = JUri::base(true) . '/media/system/images/blank.png'; } else { $lists[$i]->eventimage = JUri::base(true) . '/' . $dimage['thumb']; $lists[$i]->eventimageorig = JUri::base(true) . '/' . $dimage['original']; } if ($limage == null) { $lists[$i]->venueimage = JUri::base(true) . '/media/system/images/blank.png'; $lists[$i]->venueimageorig = JUri::base(true) . '/media/system/images/blank.png'; } else { $lists[$i]->venueimage = JUri::base(true) . '/' . $limage['thumb']; $lists[$i]->venueimageorig = JUri::base(true) . '/' . $limage['original']; } $lists[$i]->eventdescription = strip_tags($row->fulltext); $lists[$i]->venuedescription = strip_tags($row->locdescription); $i++; } // foreach ($events as $row) return $lists; }
<?php // Note: We don't skip empty subcategories if they have at least one non-empty subsubcategory. if (!$this->params->get('showemptychilds', 1) && ($child->getNumItems(true) <= 0)) : continue; // skip this subcat endif; if ($id == $lastid) : $class = ' class="last"'; endif; ?> <li<?php echo $class; ?>> <?php $class = ''; ?> <span class="item-title"> <a href="<?php echo JRoute::_(JEMHelperRoute::getCategoryRoute($child->id, $this->task)); ?>"> <?php echo $this->escape($child->catname); ?> </a> </span> <?php if ($this->params->get('show_subcat_desc') == 1) : ?> <?php if ($child->description) : ?> <div class="category-desc"> <?php echo JHtml::_('content.prepare', $child->description, '', 'com_content.category'); ?> </div> <?php endif; ?> <?php if ( $this->params->get('show_cat_num_articles', 1)) : ?> <dl> <dt> <?php echo JText::_('COM_JEM_EVENTS') . ':' ; ?> </dt> <dd>
public static function getdays ($greq_year, $greq_month, &$params) { $db = JFactory::getDBO(); # Retrieve Eventslist model for the data $model = JModelLegacy::getInstance('Eventslist', 'JemModel', array('ignore_request' => true)); # Set params for the model //$app = JFactory::getApplication(); //$appParams = $app->getParams('com_jem'); $model->setState('params', $params); $user = JemFactory::getUser(); $levels = $user->getAuthorisedViewLevels(); $settings = JemHelper::globalattribs(); $catids = JemHelper::getValidIds($params->get('catid')); $venids = JemHelper::getValidIds($params->get('venid')); $StraightToDetails = $params->get('StraightToDetails', '1'); $DisplayCat = $params->get('DisplayCat', '0'); $DisplayVenue = $params->get('DisplayVenue', '0'); $ArchivedEvents = $params->get('ArchivedEvents', '0'); $CurrentEvents = $params->get('CurrentEvents', '1'); $FixItemID = $params->get('FixItemID', '0'); $defaultItemid = $settings->get('default_Itemid',''); $daylinkparams = ''; // collects additional params for link to day view # filter category's if ($catids) { $model->setState('filter.category_id',$catids); $model->setState('filter.category_id.include',true); $daylinkparams .= '&catids=' . implode(',', $catids); } # filter venue's if ($venids) { $model->setState('filter.venue_id',$venids); $model->setState('filter.venue_id.include',true); $daylinkparams .= '&locids=' . implode(',', $venids); } # filter published # 0: unpublished # 1: published # 2: archived # -2: trashed if ($CurrentEvents && $ArchivedEvents) { $model->setState('filter.published',array(1,2)); $daylinkparams .= '&pub=1,2'; } else { if ($CurrentEvents == 1) { $model->setState('filter.published',1); $daylinkparams .= '&pub=1'; } # filter archived if ($ArchivedEvents == 1) { $model->setState('filter.published',2); $daylinkparams .= '&pub=2'; } } $model->setState('filter.groupby','a.id'); # Retrieve the available Items $events = $model->getItems(); # create an array to catch days $days = array(); foreach ($events as $index => $event) { # adding categories $nr = count($event->categories); $catname = ''; $ix = 0; # walk through categories assigned to an event foreach($event->categories AS $category) { $catname .= htmlspecialchars($category->catname); $ix++; if ($ix != $nr) { $catname .= ', '; } } // Cope with no end date set i.e. set it to same as start date if (is_null($event->enddates)) { $eyear = $event->created_year; $emonth = $event->created_month; $eday = $event->created_day; } else { list($eyear, $emonth, $eday) = explode('-', $event->enddates); } // The two cases for roll over the year end with an event that goes across the year boundary. if ($greq_year < $eyear) { $emonth = $emonth + 12; } if ($event->created_year < $greq_year) { $event->created_month = $event->created_month - 12; } if (($greq_year >= $event->created_year) && ($greq_year <= $eyear) && ($greq_month >= $event->created_month) && ($greq_month <= $emonth)) { // Set end day for current month if ($emonth > $greq_month) { $emonth = $greq_month; // $eday = cal_days_in_month(CAL_GREGORIAN, $greq_month,$greq_year); $eday = date('t', mktime(0, 0, 0, $greq_month, 1, $greq_year)); } // Set start day for current month if ($event->created_month < $greq_month) { $event->created_month = $greq_month; $event->created_day = 1; } $stod = 1; for ($count = $event->created_day; $count <= $eday; $count++) { $uxdate = mktime(0, 0, 0, $greq_month, $count, $greq_year); $tdate = strftime('%Y%m%d',$uxdate);// Toni change Joomla 1.5 // $created_day = $count; // $tt = $days[$count][1]; // if (strlen($tt) == 0) if (empty($days[$count][1])) { $title = htmlspecialchars($event->title); if ($DisplayCat == 1) { $title = $title . ' (' . $catname . ')'; } if ($DisplayVenue == 1) { if (isset($event->venue)) { $title = $title . ' @' . htmlspecialchars($event->venue); } } $stod = 1; } else { $tt = $days[$count][1]; $title = $tt . '+%+%+' . htmlspecialchars($event->title); if ($DisplayCat == 1) { $title = $title . ' (' . $catname . ')'; } if ($DisplayVenue == 1) { if (isset($event->venue)) { $title = $title . ' @' . htmlspecialchars($event->venue); } } $stod = 0; } if (($StraightToDetails == 1) and ($stod == 1)) { if ($FixItemID == 0) { $link = JRoute::_(JEMHelperRoute::getEventRoute($event->slug)); } else { //Create the link - copied from Jroute $evlink = JEMHelperRoute::getEventRoute($event->slug).'&Itemid='.$FixItemID; $link = JRoute::_($evlink); } } else { // @todo fix the getroute link if ($FixItemID == 0) { if ($defaultItemid) { $evlink = 'index.php?option=com_jem&view=day&id='. $tdate . $daylinkparams . '&Itemid='.$defaultItemid; } else { $evlink = 'index.php?option=com_jem&view=day&id='. $tdate . $daylinkparams; } $link = JRoute::_($evlink); //$link = JEMHelperRoute::getRoute($tdate, 'day'); } else { //Create the link - copied from Jroute $evlink = 'index.php?option=com_jem&view=day&id='. $tdate . $daylinkparams .'&Itemid='.$FixItemID; $link = JRoute::_($evlink); } } $days[$count] = array($link,$title); } } // End of Toni modification # check if the item-categories is empty, if so the user has no access to that event at all. if (empty($event->categories)) { unset ($events[$index]); } } // end foreach return $days; }
/** * Creates the Venue View */ function display($tpl = null) { // initialize variables $app = JFactory::getApplication(); $jinput = $app->input; $document = JFactory::getDocument(); $menu = $app->getMenu(); $menuitem = $menu->getActive(); $jemsettings = JemHelper::config(); $settings = JemHelper::globalattribs(); $vsettings = JemHelper::viewSettings('vvenue'); $db = JFactory::getDBO(); $state = $this->get('State'); $params = $state->params; $pathway = $app->getPathWay(); $uri = JFactory::getURI(); $task = $jinput->getCmd('task'); $user = JFactory::getUser(); $itemid = $jinput->getInt('id', 0) . ':' . $jinput->getInt('Itemid', 0); $print = $jinput->getBool('print'); $this->state = $this->get('State'); // Load css JemHelper::loadCss('jem'); JemHelper::loadCustomCss(); JemHelper::loadCustomTag(); if ($print) { JemHelper::loadCss('print'); $document->setMetaData('robots', 'noindex, nofollow'); } // get data from model $rows = $this->get('Items'); $venue = $this->get('Venue'); // are events available? if (!$rows) { $noevents = 1; } else { $noevents = 0; } // Decide which parameters should take priority $useMenuItemParams = $menuitem && $menuitem->query['option'] == 'com_jem' && $menuitem->query['view'] == 'venue' && (!isset($menuitem->query['layout']) || $menuitem->query['layout'] == 'default') && $menuitem->query['id'] == $venue->id; // get search & user-state variables $filter_order = $app->getUserStateFromRequest('com_jem.venue.' . $itemid . '.filter_order', 'filter_order', 'a.dates', 'cmd'); $filter_order_DirDefault = 'ASC'; // Reverse default order for dates in archive mode if ($task == 'archive' && $filter_order == 'a.dates') { $filter_order_DirDefault = 'DESC'; } $filter_order_Dir = $app->getUserStateFromRequest('com_jem.venue.' . $itemid . '.filter_order_Dir', 'filter_order_Dir', $filter_order_DirDefault, 'word'); $filter_type = $app->getUserStateFromRequest('com_jem.venue.' . $itemid . '.filter_type', 'filter_type', '', 'int'); $search = $app->getUserStateFromRequest('com_jem.venue.' . $itemid . '.filter_search', 'filter_search', '', 'string'); $search = $db->escape(trim(JString::strtolower($search))); // table ordering $lists['order_Dir'] = $filter_order_Dir; $lists['order'] = $filter_order; // Get image $limage = JemImage::flyercreator($venue->locimage, 'venue'); // Add feed links $link = '&format=feed&limitstart='; $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'); $this->document->addHeadLink(JRoute::_($link . '&type=rss'), 'alternate', 'rel', $attribs); $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'); $this->document->addHeadLink(JRoute::_($link . '&type=atom'), 'alternate', 'rel', $attribs); // pathway, page title, page heading if ($useMenuItemParams) { $pagetitle = $params->get('page_title', $menuitem->title ? $menuitem->title : $venue->venue); $pageheading = $params->get('page_heading', $pagetitle); $pathway->setItemName(1, $menuitem->title); } else { $pagetitle = $venue->venue; $pageheading = $pagetitle; $params->set('show_page_heading', 1); // ensure page heading is shown $pathway->addItem($pagetitle, JRoute::_(JemHelperRoute::getVenueRoute($venue->slug))); } $pageclass_sfx = $params->get('pageclass_sfx'); // create the pathway if ($task == 'archive') { $pathway->addItem(JText::_('COM_JEM_ARCHIVE'), JRoute::_(JemHelperRoute::getVenueRoute($venue->slug) . '&task=archive')); $print_link = JRoute::_(JEMHelperRoute::getVenueRoute($venue->slug) . '&task=archive&print=1&tmpl=component'); $pagetitle .= ' - ' . JText::_('COM_JEM_ARCHIVE'); $pageheading .= ' - ' . JText::_('COM_JEM_ARCHIVE'); } else { //$pathway->addItem($venue->venue, JRoute::_(JEMHelperRoute::getVenueRoute($venue->slug))); $print_link = JRoute::_(JemHelperRoute::getVenueRoute($venue->slug) . '&print=1&tmpl=component'); } $params->set('page_heading', $pageheading); // Add site name to title if param is set if ($app->getCfg('sitename_pagetitles', 0) == 1) { $pagetitle = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $pagetitle); } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) { $pagetitle = JText::sprintf('JPAGETITLE', $pagetitle, $app->getCfg('sitename')); } // set Page title & Meta data $document->setTitle($pagetitle); $document->setMetaData('title', $pagetitle); $document->setMetadata('keywords', $venue->meta_keywords); $document->setDescription(strip_tags($venue->meta_description)); // Check if the user has access to the add-eventform $maintainer = JemUser::ismaintainer('add'); $genaccess = JemUser::validate_user($jemsettings->evdelrec, $jemsettings->delivereventsyes); if ($maintainer || $genaccess || $user->authorise('core.create', 'com_jem')) { $addeventlink = 1; } else { $addeventlink = 0; } // Check if the user has access to the add-venueform $maintainer2 = JemUser::venuegroups('add'); $genaccess2 = JemUser::validate_user($jemsettings->locdelrec, $jemsettings->deliverlocsyes); if ($maintainer2 || $genaccess2) { $addvenuelink = 1; } else { $addvenuelink = 0; } // Check if the user has access to the edit-venueform $maintainer3 = JemUser::venuegroups('edit'); $genaccess3 = JemUser::editaccess($jemsettings->venueowner, $venue->created, $jemsettings->venueeditrec, $jemsettings->venueedit); if ($maintainer3 || $genaccess3) { $allowedtoeditvenue = 1; } else { $allowedtoeditvenue = 0; } // Generate Venuedescription if (!$venue->locdescription == '' || !$venue->locdescription == '<br />') { // execute plugins $venue->text = $venue->locdescription; $venue->title = $venue->venue; JPluginHelper::importPlugin('content'); $app->triggerEvent('onContentPrepare', array('com_jem.venue', &$venue, &$params, 0)); $venuedescription = $venue->text; } // prepare the url for output if (strlen($venue->url) > 35) { $venue->urlclean = $this->escape(substr($venue->url, 0, 35)) . '...'; } else { $venue->urlclean = $this->escape($venue->url); } // create flag if ($venue->country) { $venue->countryimg = JemHelperCountries::getCountryFlag($venue->country); } # retrieve mapType setting $settings = JemHelper::globalattribs(); $mapType = $settings->get('mapType', '0'); switch ($mapType) { case '0': $type = 'ROADMAP'; break; case '1': $type = 'SATELLITE'; break; case '2': $type = 'HYBRID'; break; case '3': $type = 'TERRAIN'; break; } $this->mapType = $type; // Create the pagination object $pagination = $this->get('Pagination'); // filters $filters = array(); $filters[] = JHtml::_('select.option', '0', '— ' . JText::_('COM_JEM_GLOBAL_SELECT_FILTER') . ' —'); if ($jemsettings->showtitle == 1) { $filters[] = JHtml::_('select.option', '1', JText::_('COM_JEM_TITLE')); } if ($jemsettings->showcat == 1) { $filters[] = JHtml::_('select.option', '4', JText::_('COM_JEM_CATEGORY')); } $lists['filter'] = JHtml::_('select.genericlist', $filters, 'filter_type', array('size' => '1', 'class' => 'inputbox input-medium'), 'value', 'text', $filter_type); $lists['search'] = $search; // mapping variables $this->lists = $lists; $this->action = $uri->toString(); $this->rows = $rows; $this->noevents = $noevents; $this->venue = $venue; $this->print_link = $print_link; $this->params = $params; $this->addvenuelink = $addvenuelink; $this->addeventlink = $addeventlink; $this->limage = $limage; $this->venuedescription = $venuedescription; $this->pagination = $pagination; $this->jemsettings = $jemsettings; $this->settings = $settings; $this->vsettings = $vsettings; $this->item = $menuitem; $this->pagetitle = $pagetitle; $this->task = $task; $this->allowedtoeditvenue = $allowedtoeditvenue; $this->pageclass_sfx = htmlspecialchars($pageclass_sfx); $this->print = $print; parent::display($tpl); }
//if ($this->params->get('show_empty_categories') || $child->getNumItems(true) || count($child->getChildren())) : if (!isset($this->children[$this->category->id][$id + 1])) { $class = ' class="last"'; } ?> <li<?php echo $class; ?> > <?php $class = ''; ?> <span class="item-title"> <a href="<?php echo JRoute::_(JEMHelperRoute::getCategoryRoute($child->id)); ?> "> <?php echo $this->escape($child->catname); ?> </a> </span> <?php if ($this->params->get('show_subcat_desc') == 1) { ?> <?php if ($child->description) { ?> <div class="category-desc"> <?php
/** * Method to get the events * * @access public * @return array */ public static function getList(&$params) { mb_internal_encoding('UTF-8'); $db = JFactory::getDBO(); $user = JFactory::getUser(); $levels = $user->getAuthorisedViewLevels(); $settings = JemHelper::config(); // Use (short) format saved in module settings or in component settings or format in language file otherwise $dateFormat = $params->get('formatdate', ''); if (empty($dateFormat)) { // on empty format long format will be used but we need short format if (isset($settings->formatShortDate) && $settings->formatShortDate) { $dateFormat = $settings->formatShortDate; } else { $dateFormat = JText::_('COM_JEM_FORMAT_SHORT_DATE'); } } $timeFormat = $params->get('formattime', ''); $addSuffix = false; if (empty($timeFormat)) { // on empty format component's format will be used, so also use component's time suffix $addSuffix = true; } # Retrieve Eventslist model for the data $model = JModelLegacy::getInstance('Eventslist', 'JemModel', array('ignore_request' => true)); # Set params for the model # has to go before the getItems function $model->setState('params', $params); # filter published # 0: unpublished # 1: published # 2: archived # -2: trashed $type = $params->get('type'); # All events $cal_from = ""; // TODO: Add parameter to specify start and end dates for showing events // (used for schools league) // All events, default order if ($type == 3) { $cal_from = ""; } elseif ($type == 2) { $model->setState('filter.published', 2); $model->setState('filter.orderby', array('a.dates DESC', 'a.times DESC')); $cal_from = ""; } else { $model->setState('filter.published', 1); $model->setState('filter.orderby', array('a.dates ASC', 'a.times ASC')); $offset_minutes = 60 * $params->get('offset_hours', 0); $cal_from = "((TIMESTAMPDIFF(MINUTE, NOW(), CONCAT(a.dates,' ',IFNULL(a.times,'00:00:00'))) > {$offset_minutes}) "; $cal_from .= $type == 1 ? " OR (TIMESTAMPDIFF(MINUTE, NOW(), CONCAT(IFNULL(a.enddates,a.dates),' ',IFNULL(a.endtimes,'23:59:59'))) > {$offset_minutes})) " : ") "; } $model->setState('filter.calendar_from', $cal_from); $model->setState('filter.groupby', 'a.id'); # filter category's $catids = JemHelper::getValidIds($params->get('catid')); if ($catids) { $model->setState('filter.category_id', $catids); $model->setState('filter.category_id.include', true); } # filter venue's $venids = JemHelper::getValidIds($params->get('venid')); if ($venids) { $model->setState('filter.venue_id', $venids); $model->setState('filter.venue_id.include', true); } # count $count = $params->get('count', '2'); $model->setState('list.limit', $count); # Retrieve the available Events $events = $model->getItems(); # Loop through the result rows and prepare data $i = 0; $lists = array(); foreach ($events as $row) { //cut titel $length = mb_strlen($row->title); if ($length > $params->get('cuttitle', '18')) { $row->title = mb_substr($row->title, 0, $params->get('cuttitle', '18')); $row->title = $row->title . '...'; } $lists[$i] = new stdClass(); $lists[$i]->link = JRoute::_(JemHelperRoute::getEventRoute($row->slug)); # time/date list($lists[$i]->date, $lists[$i]->time) = self::_format_date_time($row, $params->get('datemethod', 1), $dateFormat, $timeFormat, $addSuffix); $lists[$i]->dateinfo = JEMOutput::formatDateTime($row->dates, $row->times, $row->enddates, $row->endtimes, $dateFormat, $timeFormat, $addSuffix); $lists[$i]->dateinfo = JemOutput::formatDateTime($row->dates, $row->times, $row->enddates, $row->endtimes, $dateFormat, $timeFormat, $addSuffix); $lists[$i]->text = $params->get('showtitloc', 0) ? $row->title : htmlspecialchars($row->venue, ENT_COMPAT, 'UTF-8'); $lists[$i]->city = htmlspecialchars($row->city, ENT_COMPAT, 'UTF-8'); $lists[$i]->venueurl = !empty($row->venueslug) ? JRoute::_(JEMHelperRoute::getVenueRoute($row->venueslug)) : null; $i++; } return $lists; }
/** * This method handles any mailings triggered by an venue store action * * @access public * @param int $venue_id Integer Venue identifier * @param int $is_new Integer Venue new or edited * @return boolean * */ public function onVenueEdited($venue_id, $is_new) { // Sendto $send_to = array( 'user' => $is_new ? $this->params->get('newvenue_mail_user', '1') : $this->params->get('editvenue_mail_user', '0'), 'admin' => $is_new ? $this->params->get('newvenue_mail_admin', '1') : $this->params->get('editvenue_mail_admin', '0'), ); // Skip if processing not needed if (!array_filter($send_to)) return true; $user = JFactory::getUser(); $username = empty($this->_UseLoginName) ? $user->name : $user->username; // get data $db = JFactory::getDBO(); $query = $db->getQuery(true); $case_when = ' CASE WHEN '; $case_when .= $query->charLength('alias'); $case_when .= ' THEN '; $id = $query->castAsChar('id'); $case_when .= $query->concatenate(array($id, 'alias'), ':'); $case_when .= ' ELSE '; $case_when .= $id.' END as slug'; $query->select(array('id','published','venue','city','street','postalCode','url','country','locdescription','created','modified',$case_when)); $query->from('#__jem_venues'); $query->where(array('id= '.$db->quote($venue_id))); $db->setQuery($query); if (is_null($venue = $db->loadObject())) return false; # at this point we do have a result // Define link for venue $link = JRoute::_(JUri::base().JEMHelperRoute::getVenueRoute($venue->slug), false); // Define published-state message $adminstate = $venue->published ? JText::sprintf('PLG_JEM_MAILER_VENUE_PUBLISHED', $link) : JText::_('PLG_JEM_MAILER_VENUE_UNPUBLISHED'); $userstate = $venue->published ? JText::sprintf('PLG_JEM_MAILER_USER_MAIL_VENUE_PUBLISHED', $link) : JText::_('PLG_JEM_MAILER_USER_MAIL_VENUE_UNPUBLISHED'); // Strip tags/scripts,etc from description $text_description = JFilterOutput::cleanText($venue->locdescription); ####################### ## RECEIVERS - ADMIN ## ####################### # in here we selected the option to send to admin. # we selected admin so we can use the adminDBList. # if the adminDBList is empty mailing should stop! if ($send_to['admin']) { $admin_receivers = $this->_AdminDBList; if ($admin_receivers) { $data = new stdClass(); # is the venue new or edited? if ($is_new) { # the venue is new and we send a mail to adminDBList $created = JHtml::Date($venue->created, JText::_('DATE_FORMAT_LC2')); $data->subject = JText::sprintf('PLG_JEM_MAILER_NEW_VENUE_MAIL', $this->_SiteName, $venue->venue); $data->body = JText::sprintf('PLG_JEM_MAILER_NEW_VENUE_A', $username, $created, $venue->venue, $venue->url, $venue->street, $venue->postalCode, $venue->city, $venue->country, $text_description, $adminstate); } else { # the venue is edited and we send a mail to adminDBList $modified = JHtml::Date($venue->modified, JText::_('DATE_FORMAT_LC2')); $data->subject = JText::sprintf('PLG_JEM_MAILER_EDIT_VENUE_MAIL', $this->_SiteName, $venue->venue); $data->body = JText::sprintf('PLG_JEM_MAILER_EDIT_VENUE_A', $username, $modified, $venue->venue, $venue->url, $venue->street, $venue->postalCode, $venue->city, $venue->country, $text_description, $adminstate); } $data->receivers = $admin_receivers; $this->_mailer($data); } else { return false; } } ###################### ## RECEIVERS - USER ## ###################### # here we selected the option to send to a logged in user # we make a selection between added/edited venue # -> here we don't specify an extra variable if ($send_to['user']) { $data = new stdClass(); if ($is_new) { $created = JHtml::Date($venue->created, JText::_('DATE_FORMAT_LC2')); $data->subject = JText::sprintf('PLG_JEM_MAILER_NEW_USER_VENUE_MAIL', $this->_SiteName, $venue->venue); $data->body = JText::sprintf('PLG_JEM_MAILER_USER_MAIL_NEW_VENUE_A', $username, $created, $venue->venue, $venue->url, $venue->street, $venue->postalCode, $venue->city, $venue->country, $text_description, $userstate); } else { $modified = JHtml::Date($venue->modified, JText::_('DATE_FORMAT_LC2')); $data->subject = JText::sprintf('PLG_JEM_MAILER_EDIT_USER_VENUE_MAIL', $this->_SiteName, $venue->venue); $data->body = JText::sprintf('PLG_JEM_MAILER_USER_MAIL_EDIT_VENUE_A', $username, $modified, $venue->venue, $venue->url, $venue->street, $venue->postalCode, $venue->city, $venue->country, $text_description, $userstate); } $data->receivers = $user->email; $this->_mailer($data); } return true; }
/** * Determines the Itemid * * searches if a menuitem for this item exists * if not the active menuitem will be returned * * @param array The id and view * * * @return int Itemid */ protected static function _findItem($needles = null) { $app = JFactory::getApplication(); $menus = $app->getMenu('site'); // Prepare the reverse lookup array. if (self::$lookup === null) { self::$lookup = array(); $component = JComponentHelper::getComponent('com_jem'); $items = $menus->getItems('component_id', $component->id); if ($items) { foreach ($items as $item) { if (isset($item->query) && isset($item->query['view'])) { if (isset($item->query['layout']) && ($item->query['layout'] == 'calendar')) { continue; // skip calendars } $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; } // Some views have no ID, but we have to set one else { self::$lookup[$view][self::ARTIFICALID] = $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])) { // TODO: Check on access. See commented code below return self::$lookup[$view][(int)$id]; } } } } } else { $active = $menus->getActive(); if ($active) { return $active->id; } } return null; // $user = JemFactory::getUser(); // //false if there exists no menu item at all // if (!$items) { // return false; // } else { // //Not needed currently but kept because of a possible hierarchic link structure in future // foreach($needles as $needle => $id) // { // foreach($items as $item) // { // if (($item->query['view'] == $needle) && ($item->query['id'] == $id)) { // return $item; // } // } // /* // //no menuitem exists -> return first possible match // foreach($items as $item) // { // if ($item->published == 1 && $item->access <= $gid) { // return $item; // } // } // */ // } // } // return false; }
/** * Categories Search method * * The sql must return the following fields that are * used in a common display routine: href, title, section, created, text, * browsernav * @param string Target search string * @param string mathcing option, exact|any|all * @param string ordering option, newest|oldest|popular|alpha|category * @param mixed An array if restricted to areas, null if search all */ function onContentSearch($text, $phrase='', $ordering='', $areas=null) { $db = JFactory::getDBO(); $app = JFactory::getApplication(); $user = JFactory::getUser(); $groups = implode(',', $user->getAuthorisedViewLevels()); $tag = JFactory::getLanguage()->getTag(); require_once(JPATH_SITE.'/components/com_jem/helpers/route.php'); if (is_array($areas)) { if (!array_intersect($areas, array_keys(self::$_areas))) { return array(); } } else { $areas = array_keys(self::$_areas); } // load plugin params info $plugin = JPluginHelper::getPlugin('search', 'jem'); $pluginParams = new JRegistry($plugin->params); $limit = $pluginParams->def('search_limit', 50); $text = trim($text); if ($text == '') { return array(); } $searchJEM = $db->Quote(JText::_('PLG_JEM_SEARCH_JEM')); $rows = array(); $query = $db->getQuery(true); if (in_array('jemevents', $areas) && $limit > 0) { $areaName = JText::_(self::$_areas['jemevents']); switch ($phrase) { case 'exact': $text_q = $db->Quote('%'.$db->escape($text, true).'%', false); $wheres2 = array(); $wheres2[] = 'LOWER(a.title) LIKE '.$text_q; $wheres2[] = 'LOWER(a.introtext) LIKE '.$text_q; $wheres2[] = 'LOWER(a.fulltext) LIKE '.$text_q; $wheres2[] = 'LOWER(a.meta_keywords) LIKE '.$text_q; $wheres2[] = 'LOWER(a.meta_description) LIKE '.$text_q; $where = '(' . implode(') OR (', $wheres2) . ')'; break; case 'all': case 'any': default: $words = explode(' ', $text); $wheres = array(); foreach ($words as $word) { $word = $db->Quote('%'.$db->escape( $word, true ).'%', false); $wheres2 = array(); $wheres2[] = 'LOWER(a.title) LIKE '.$word; $wheres2[] = 'LOWER(a.introtext) LIKE '.$word; $wheres2[] = 'LOWER(a.fulltext) LIKE '.$word; $wheres2[] = 'LOWER(a.meta_keywords) LIKE '.$word; $wheres2[] = 'LOWER(a.meta_description) LIKE '.$word; $wheres[] = implode(' OR ', $wheres2); } $where = '(' . implode(($phrase == 'all' ? ') AND (' : ') OR ('), $wheres) . ')'; break; } switch ($ordering) { case 'oldest': $order = 'a.dates ASC, a.times ASC'; break; case 'alpha': $order = 'a.title ASC'; break; case 'category': $order = 'c.catname ASC, a.title ASC'; break; case 'newest': default: $order = 'a.dates DESC, a.times DESC'; } $query->clear(); //sqlsrv changes $case_when = ' CASE WHEN '; $case_when .= $query->charLength('a.alias'); $case_when .= ' THEN '; $a_id = $query->castAsChar('a.id'); $case_when .= $query->concatenate(array($a_id, 'a.alias'), ':'); $case_when .= ' ELSE '; $case_when .= $a_id.' END as slug'; $case_when1 = ' CASE WHEN '; $case_when1 .= $query->charLength('c.alias'); $case_when1 .= ' THEN '; $c_id = $query->castAsChar('c.id'); $case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':'); $case_when1 .= ' ELSE '; $case_when1 .= $c_id.' END as catslug'; $query->select('a.title AS title, a.meta_description, a.meta_keywords, a.created AS created'); $query->select($query->concatenate(array('a.introtext', 'a.fulltext')).' AS text'); $query->select($query->concatenate(array($db->quote($areaName), 'c.catname'), ' / ').' AS section'); $query->select($case_when.','.$case_when1.', '.'\'2\' AS browsernav'); $query->select('rel.catid'); $query->from('#__jem_events AS a'); $query->join('LEFT', '#__jem_cats_event_relations AS rel ON rel.itemid = a.id'); $query->join('LEFT', '#__jem_categories AS c ON c.id = rel.catid'); $query->where('('. $where .')' . ' AND a.published=1 AND c.published = 1 AND a.access IN ('.$groups.') ' .'AND c.access IN ('.$groups.') ' ); $query->group('a.id'); $query->order($order); $db->setQuery($query, 0, $limit); $list = $db->loadObjectList(); $limit -= count($list); if (isset($list)) { foreach($list as $key => $row) { $list[$key]->href = JEMHelperRoute::getEventRoute($row->slug); // todo: list ALL accessable categories // todo: show date/time somewhere because this is very useful information } } $rows[] = $list; } if (in_array('jemvenues', $areas) && $limit > 0) { $areaName = JText::_(self::$_areas['jemvenues']); switch ($phrase) { case 'exact': $text_q = $db->Quote('%'.$db->escape($text, true).'%', false); $wheres2 = array(); $wheres2[] = 'LOWER(venue) LIKE '.$text_q; $wheres2[] = 'LOWER(locdescription) LIKE '.$text_q; $wheres2[] = 'LOWER(city) LIKE '.$text_q; $wheres2[] = 'LOWER(meta_keywords) LIKE '.$text_q; $wheres2[] = 'LOWER(meta_description) LIKE '.$text_q; $where = '(' . implode(') OR (', $wheres2) . ')'; break; case 'all': case 'any': default: $words = explode(' ', $text); $wheres = array(); foreach ($words as $word) { $word = $db->Quote('%'.$db->escape( $word, true ).'%', false); $wheres2 = array(); $wheres2[] = 'LOWER(venue) LIKE '.$word; $wheres2[] = 'LOWER(locdescription) LIKE '.$word; $wheres2[] = 'LOWER(city) LIKE '.$word; $wheres2[] = 'LOWER(meta_keywords) LIKE '.$word; $wheres2[] = 'LOWER(meta_description) LIKE '.$word; $wheres[] = implode(' OR ', $wheres2); } $where = '(' . implode(($phrase == 'all' ? ') AND (' : ') OR ('), $wheres) . ')'; break; } switch ($ordering) { case 'oldest': $order = 'created DESC'; break; case 'alpha': $order = 'venue ASC'; break; case 'newest': $order = 'created ASC'; break; default: $order = 'venue ASC'; } $query = 'SELECT venue AS title,' . ' locdescription AS text,' . ' created,' . ' "2" AS browsernav,' . ' CASE WHEN CHAR_LENGTH(alias) THEN CONCAT_WS(\':\', id, alias) ELSE id END as slug, ' . ' '.$db->quote($areaName).' AS section' . ' FROM #__jem_venues' . ' WHERE ( '.$where.')' . ' AND published = 1' . ' ORDER BY '. $order ; $db->setQuery($query, 0, $limit); $list2 = $db->loadObjectList(); foreach((array) $list2 as $key => $row) { $list2[$key]->href = JEMHelperRoute::getVenueRoute($row->slug); } $rows[] = $list2; } if (in_array('jemcategories', $areas) && $limit > 0) { $areaName = JText::_(self::$_areas['jemcategories']); switch ($phrase) { case 'exact': $text_q = $db->Quote('%'.$db->escape($text, true).'%', false); $wheres2 = array(); $wheres2[] = 'LOWER(catname) LIKE '.$text_q; $wheres2[] = 'LOWER(description) LIKE '.$text_q; $wheres2[] = 'LOWER(meta_keywords) LIKE '.$text_q; $wheres2[] = 'LOWER(meta_description) LIKE '.$text_q; $where = '(' . implode(') OR (', $wheres2) . ')'; break; case 'all': case 'any': default: $words = explode(' ', $text); $wheres = array(); foreach ($words as $word) { $word = $db->Quote('%'.$db->escape($word, true).'%', false); $wheres2 = array(); $wheres2[] = 'LOWER(catname) LIKE '.$word; $wheres2[] = 'LOWER(description) LIKE '.$word; $wheres2[] = 'LOWER(meta_keywords) LIKE '.$word; $wheres2[] = 'LOWER(meta_description) LIKE '.$word; $wheres[] = implode(' OR ', $wheres2); } $where = '(' . implode(($phrase == 'all' ? ') AND (' : ') OR ('), $wheres) . ')'; break; } $query = 'SELECT catname AS title,' . ' description AS text,' . ' "" AS created,' . ' "2" AS browsernav,' . ' CASE WHEN CHAR_LENGTH(alias) THEN CONCAT_WS(\':\', id, alias) ELSE id END as slug, ' . ' '.$db->quote($areaName).' AS section' . ' FROM #__jem_categories' . ' WHERE ( '.$where.' )' . ' AND published = 1' . ' AND access IN ('.$groups.') ' . ' ORDER BY catname' ; $db->setQuery($query, 0, $limit); $list3 = $db->loadObjectList(); foreach((array)$list3 as $key => $row) { $list3[$key]->href = JEMHelperRoute::getCategoryRoute($row->slug); } $rows[] = $list3; } $count = count($rows); if ($count > 1) { switch ($count) { case 2: $results = array_merge((array)$rows[0], (array)$rows[1]); break; case 3: $results = array_merge((array)$rows[0], (array)$rows[1], (array)$rows[2]); break; case 4: default: $results = array_merge((array)$rows[0], (array)$rows[1], (array)$rows[2], (array)$rows[3]); break; } return $results; } else if ($count == 1) { return $rows[0]; } }
/** * Method to get the Categories * * @access public * @return array */ function &getData() { $app = JFactory::getApplication(); $params = $app->getParams(); // Lets load the content if it doesn't already exist if (empty($this->_categories)) { // include category itself but not if it's the root category $parentCategory = ($this->_id > 1) ? $this->_getList($this->_buildQueryParentCategory(true)) : array(); $query = $this->_buildQuerySubCategories($this->_showemptycats); $pagination = $this->getPagination(); $this->_categories = $this->_getList($query, $pagination->limitstart, $pagination->limit); // Include parent category itself $this->_categories = array_merge($parentCategory, $this->_categories); foreach($this->_categories as $category) { if ($this->_showsubcats) { //child categories // ensure parent shows at least all categories also shown in list $showempty = $this->_showemptysubcats | ($category->id == $this->_id ? $this->_showemptycats : false); $query = $this->_buildQuerySubCategories($showempty, $category->id); $this->_db->setQuery($query); $category->subcats = $this->_db->loadObjectList(); } else { $category->subcats = array(); } //Generate description if (empty ($category->description)) { $category->description = JText::_('COM_JEM_NO_DESCRIPTION'); } else { //execute plugins $category->text = $category->description; $category->title = $category->catname; JPluginHelper::importPlugin('content'); $app->triggerEvent('onContentPrepare', array('com_jem.categories', &$category, &$params, 0)); $category->description = $category->text; } //create target link // TODO: Move to view? $task = $app->input->get('task', ''); if ($task == 'archive') { $category->linktext = JText::_('COM_JEM_SHOW_ARCHIVE'); $category->linktarget = JRoute::_(JEMHelperRoute::getCategoryRoute($category->slug.'&task=archive')); } else { $category->linktext = JText::_('COM_JEM_SHOW_EVENTS'); $category->linktarget = JRoute::_(JEMHelperRoute::getCategoryRoute($category->slug)); } } } return $this->_categories; }
<?php echo $this->escape($row->title) . JemOutput::recurrenceicon($row); ?> </a> </td> <?php endif; ?> <?php if (($this->jemsettings->showtitle == 1) && ($this->jemsettings->showdetails == 0)) : ?> <td headers="jem_title" align="left" valign="top"> <?php echo $this->escape($row->title) . JemOutput::recurrenceicon($row); ?> </td> <?php endif; ?> <?php if ($this->jemsettings->showlocate == 1) : ?> <td headers="jem_location" align="left" valign="top"> <?php if ($this->jemsettings->showlinkvenue == 1) : echo $row->locid != 0 ? "<a href='".JRoute::_(JEMHelperRoute::getVenueRoute($row->venueslug))."'>".$this->escape($row->venue)."</a>" : '-'; else : echo $row->locid ? $this->escape($row->venue) : '-'; endif; ?> </td> <?php endif; ?> <?php if ($this->jemsettings->showcity == 1) : ?> <td headers="jem_city" align="left" valign="top"> <?php echo $row->city ? $this->escape($row->city) : '-'; ?> </td> <?php endif; ?> <?php if ($this->jemsettings->showstate == 1) : ?> <td headers="jem_state" align="left" valign="top">
</td> <?php } ?> <?php } ?> <?php if ($this->jemsettings->showtitle == 1 && $this->jemsettings->showdetails == 1) { ?> <td class="jem_title jem_title_cat<?php echo $this->catrow->id; ?> "> <a href="<?php echo JRoute::_(JEMHelperRoute::getEventRoute($row->slug)); ?> " itemprop="url"> <span itemprop="name"><?php echo $this->escape($row->title); ?> </span> </a> </td> <?php } ?> <?php if ($this->jemsettings->showtitle == 1 && $this->jemsettings->showdetails == 0) { ?>
/** * Logic to trash events * * @access public * @return void */ function trash() { $cid = $input->get('cid', array(), 'post', 'array'); JArrayHelper::toInteger($cid); if (empty($cid)) { $this->setRedirect(JEMHelperRoute::getMyEventsRoute(), JText::_('COM_JEM_SELECT_ITEM_TO_TRASH'), 'warning'); return; } $model = $this->getModel('myevents'); if (!$model->publish($cid, -2)) { $msg = $model->getError(); $this->setRedirect(JEMHelperRoute::getMyEventsRoute(), $msg); return; } $total = count($cid); $msg = $total . ' ' . JText::_('COM_JEM_EVENT_TRASHED'); $this->setRedirect(JEMHelperRoute::getMyEventsRoute(), $msg); }
/** * Method to get the events * * @access public * @return array */ public static function getList(&$params) { mb_internal_encoding('UTF-8'); // Retrieve Eventslist model for the data $model = JModelLegacy::getInstance('Eventslist', 'JemModel', array('ignore_request' => true)); // Set params for the model // has to go before the getItems function $model->setState('params', $params); $model->setState('filter.access', true); // filter published // 0: unpublished // 1: published // 2: archived // -2: trashed $type = $params->get('type'); $offset_hourss = $params->get('offset_hours', 0); // all upcoming events if ($type == 0 || $type == 1) { $offset_minutes = $offset_hourss * 60; $model->setState('filter.published', 1); $model->setState('filter.orderby', array('a.dates ASC', 'a.times ASC')); $cal_from = "((TIMESTAMPDIFF(MINUTE, NOW(), CONCAT(a.dates,' ',IFNULL(a.times,'00:00:00'))) > {$offset_minutes}) "; $cal_from .= $type == 1 ? " OR (TIMESTAMPDIFF(MINUTE, NOW(), CONCAT(IFNULL(a.enddates,a.dates),' ',IFNULL(a.endtimes,'23:59:59'))) > {$offset_minutes})) " : ") "; } elseif ($type == 2) { $model->setState('filter.published', 2); $model->setState('filter.orderby', array('a.dates DESC', 'a.times DESC')); $cal_from = ""; } elseif ($type == 3) { $offset_days = (int) round($offset_hourss / 24); $model->setState('filter.published', 1); $model->setState('filter.orderby', array('a.dates ASC', 'a.times ASC')); $cal_from = " ((DATEDIFF(a.dates, CURDATE()) <= {$offset_days}) AND (DATEDIFF(IFNULL(a.enddates,a.dates), CURDATE()) >= {$offset_days}))"; } elseif ($type == 4) { $offset_minutes = $offset_hourss * 60; $model->setState('filter.featured', 1); $model->setState('filter.orderby', array('a.dates ASC', 'a.times ASC')); $cal_from = "((TIMESTAMPDIFF(MINUTE, NOW(), CONCAT(a.dates,' ',IFNULL(a.times,'00:00:00'))) > {$offset_minutes}) "; $cal_from .= " OR (TIMESTAMPDIFF(MINUTE, NOW(), CONCAT(IFNULL(a.enddates,a.dates),' ',IFNULL(a.endtimes,'23:59:59'))) > {$offset_minutes})) "; } $model->setState('filter.calendar_from', $cal_from); $model->setState('filter.groupby', 'a.id'); // clean parameter data $catids = $params->get('catid'); $venids = $params->get('venid'); $eventids = $params->get('eventid'); // filter category's if ($catids) { $model->setState('filter.category_id', $catids); $model->setState('filter.category_id.include', true); } // filter venue's if ($venids) { $model->setState('filter.venue_id', $venids); $model->setState('filter.venue_id.include', true); } // filter event id's if ($eventids) { $model->setState('filter.event_id', $eventids); $model->setState('filter.event_id.include', true); } // count $count = $params->get('count', '2'); if ($params->get('use_modal', 0)) { JHtml::_('behavior.modal', 'a.flyermodal'); } $model->setState('list.limit', $count); // Retrieve the available Events $events = $model->getItems(); if (!$events) { return array(); } // Loop through the result rows and prepare data $i = 0; $lists = array(); $FixItemID = $params->get('FixItemID', ''); $eventimg = $params->get('eventimg', 1); $venueimg = $params->get('venueimg', 1); foreach ($events as $row) { // create thumbnails if needed and receive imagedata if ($row->datimage) { $dimage = JEMImage::flyercreator($row->datimage, 'event'); } else { $dimage = null; } if ($row->locimage) { $limage = JEMImage::flyercreator($row->locimage, 'venue'); } else { $limage = null; } // cut titel $length = mb_strlen($row->title); $maxlength = $params->get('cuttitle', '18'); if ($length > $maxlength && $maxlength > 0) { $row->title = mb_substr($row->title, 0, $maxlength); $row->title = $row->title . '...'; } /** * DEFINE LIST **/ $settings = JEMHelper::globalattribs(); $access = !$settings->get('show_noauth', '0'); $authorised = JAccess::getAuthorisedViewLevels(JFactory::getUser()->get('id')); $lists[$i] = new stdClass(); $lists[$i]->title = htmlspecialchars($row->title, ENT_COMPAT, 'UTF-8'); $lists[$i]->venue = htmlspecialchars($row->venue, ENT_COMPAT, 'UTF-8'); $lists[$i]->state = htmlspecialchars($row->state, ENT_COMPAT, 'UTF-8'); $lists[$i]->city = htmlspecialchars($row->city, ENT_COMPAT, 'UTF-8'); // time/date $lists[$i]->date = modJEMteaserHelper::_format_date($row, $params); $lists[$i]->day = modJEMteaserHelper::_format_day($row, $params); $lists[$i]->dayname = modJEMteaserHelper::_format_dayname($row); $lists[$i]->daynum = modJEMteaserHelper::_format_daynum($row); $lists[$i]->month = modJEMteaserHelper::_format_month($row); $lists[$i]->year = modJEMteaserHelper::_format_year($row); $lists[$i]->time = $row->times ? modJEMteaserHelper::_format_time($row->dates, $row->times, $params) : ''; if ($access || in_array($row->access, $authorised)) { // We know that user has the privilege to view the event if ($FixItemID) { $lists[$i]->link = JRoute::_('index.php?option=com_jem&view=event&id=' . $row->slug . '&Itemid=' . $FixItemID); } else { $lists[$i]->link = JRoute::_(JEMHelperRoute::getEventRoute($row->slug)); } $lists[$i]->linkText = JText::_('MOD_JEM_TEASER_READMORE'); } else { $lists[$i]->link = JRoute::_('index.php?option=com_users&view=login'); $lists[$i]->linkText = JText::_('MOD_JEM_TEASER_READMORE_REGISTER'); } if ($FixItemID) { $lists[$i]->eventlink = $params->get('linkevent', 1) ? JRoute::_('index.php?option=com_jem&view=event&id=' . $row->slug . '&Itemid=' . $FixItemID) : ''; $lists[$i]->venuelink = $params->get('linkvenue', 1) ? JRoute::_('index.php?option=com_jem&view=venue&id=' . $row->venueslug . '&Itemid=' . $FixItemID) : ''; } else { $lists[$i]->eventlink = $params->get('linkevent', 1) ? JRoute::_(JEMHelperRoute::getEventRoute($row->slug)) : ''; $lists[$i]->venuelink = $params->get('linkvenue', 1) ? JRoute::_(JEMHelperRoute::getVenueRoute($row->venueslug)) : ''; } $lists[$i]->catname = implode(", ", JemOutput::getCategoryList($row->categories, $params->get('linkcategory', 1), false, $FixItemID)); // images if ($eventimg) { if ($dimage == null) { $lists[$i]->eventimage = ''; $lists[$i]->eventimageorig = ''; } else { $lists[$i]->eventimage = JURI::base(true) . '/' . $dimage['thumb']; $lists[$i]->eventimageorig = JURI::base(true) . '/' . $dimage['original']; } } else { $lists[$i]->eventimage = ''; $lists[$i]->eventimageorig = ''; } if ($venueimg) { if ($limage == null) { $lists[$i]->venueimage = ''; $lists[$i]->venueimageorig = ''; } else { $lists[$i]->venueimage = JURI::base(true) . '/' . $limage['thumb']; $lists[$i]->venueimageorig = JURI::base(true) . '/' . $limage['original']; } } else { $lists[$i]->venueimage = ''; $lists[$i]->venueimageorig = ''; } $length = $params->get('descriptionlength'); $length2 = 1; $etc = '...'; $etc2 = JText::_('MOD_JEM_TEASER_NO_DESCRIPTION'); //strip html tags but leave <br /> tags $description = strip_tags($row->introtext, "<br>"); //switch <br /> tags to space character if ($params->get('br') == 0) { $description = str_replace('<br />', ' ', $description); } // if (strlen($description) > $length) { $length -= strlen($etc); $description = preg_replace('/\\s+?(\\S+)?$/', '', substr($description, 0, $length + 1)); $lists[$i]->eventdescription = substr($description, 0, $length) . $etc; } else { if (strlen($description) < $length2) { $length -= strlen($etc2); $description = preg_replace('/\\s+?(\\S+)?$/', '', substr($description, 0, $length + 1)); $lists[$i]->eventdescription = substr($description, 0, $length) . $etc2; } else { $lists[$i]->eventdescription = $description; } } $lists[$i]->readmore = strlen(trim($row->fulltext)); $i++; } return $lists; }
/** * Method to get a list of events. */ public function getItems() { // Get a storage key. $store = $this->getStoreId(); $query = $this->_getListQuery(); $items = $this->_getList($query, $this->getStart(), $this->getState('list.limit')); $app = JFactory::getApplication(); $params = clone $this->getState('params'); // Lets load the content if it doesn't already exist if ($items) { foreach ($items as $item) { // Create image information $item->limage = JEMImage::flyercreator($item->locimage, 'venue'); //Generate Venuedescription if (!$item->locdescription == '' || !$item->locdescription == '<br />') { //execute plugins $item->text = $item->locdescription; $item->title = $item->venue; JPluginHelper::importPlugin('content'); $app->triggerEvent('onContentPrepare', array('com_jem.venue', &$item, &$params, 0)); $item->locdescription = $item->text; } //build the url if (!empty($item->url) && !preg_match('%^http(s)?://%', $item->url)) { $item->url = 'http://'.$item->url; } //prepare the url for output // TODO: Should be part of view! Then use $this->escape() if (strlen($item->url) > 35) { $item->urlclean = htmlspecialchars(substr($item->url, 0 , 35)).'...'; } else { $item->urlclean = htmlspecialchars($item->url); } //create flag if ($item->country) { $item->countryimg = JemHelperCountries::getCountryFlag($item->country); } //create target link $item->linkEventsArchived = JRoute::_(JEMHelperRoute::getVenueRoute($item->venueslug.'&task=archive')); $item->linkEventsPublished = JRoute::_(JEMHelperRoute::getVenueRoute($item->venueslug)); $item->EventsPublished = $this->AssignedEvents($item->locid,'1'); $item->EventsArchived = $this->AssignedEvents($item->locid,'2'); } // Add the items to the internal cache. $this->cache[$store] = $items; return $this->cache[$store]; } return array(); }
/** * redirect to events page */ function back() { $this->setRedirect(JRoute::_(JEMHelperRoute::getMyEventsRoute(), false)); $this->redirect(); }
/** * Method to get the events * * @access public * @return array */ public static function getList(&$params) { mb_internal_encoding('UTF-8'); // Retrieve Eventslist model for the data $model = JModelLegacy::getInstance('Eventslist', 'JemModel', array('ignore_request' => true)); // Set params for the model // has to go before the getItems function $model->setState('params', $params); $model->setState('filter.access', true); # filter published # 0: unpublished # 1: published # 2: archived # -2: trashed $type = $params->get('type'); # archived events if ($type == 2) { $model->setState('filter.published', 2); $model->setState('filter.orderby', array('a.dates DESC', 'a.times DESC')); $cal_from = ""; } else { $model->setState('filter.published', 1); $model->setState('filter.orderby', array('a.dates ASC', 'a.times ASC')); $offset_minutes = 60 * $params->get('offset_hours', 0); $cal_from = "((TIMESTAMPDIFF(MINUTE, NOW(), CONCAT(a.dates,' ',IFNULL(a.times,'00:00:00'))) > {$offset_minutes}) "; $cal_from .= $type == 1 ? " OR (TIMESTAMPDIFF(MINUTE, NOW(), CONCAT(IFNULL(a.enddates,a.dates),' ',IFNULL(a.endtimes,'23:59:59'))) > {$offset_minutes})) " : ") "; } $model->setState('filter.calendar_from', $cal_from); $model->setState('filter.groupby', 'a.id'); # clean parameter data $catids = $params->get('catid'); $venids = $params->get('venid'); $eventids = $params->get('eventid'); # filter category's if ($catids) { $model->setState('filter.category_id', $catids); $model->setState('filter.category_id.include', true); } # filter venue's if ($venids) { $model->setState('filter.venue_id', $venids); $model->setState('filter.venue_id.include', true); } # filter event id's if ($eventids) { $model->setState('filter.event_id', $eventids); $model->setState('filter.event_id.include', true); } # count $count = $params->get('count', '2'); $model->setState('list.limit', $count); # Retrieve the available Events $events = $model->getItems(); # do we have $events? if (!$events) { return array(); } # Loop through the result rows and prepare data $i = 0; $lists = array(); $maxlength = $params->get('cuttitle', '18'); $settings = JemHelper::config(); $dateformat = $params->get('formatdate', $settings->formatShortDate); foreach ($events as $row) { //cut titel $length = mb_strlen($row->title); if ($length > $maxlength && $maxlength > 0) { $row->title = mb_substr($row->title, 0, $maxlength); $row->title = $row->title . '...'; } $lists[$i] = new stdClass(); $lists[$i]->link = JRoute::_(JEMHelperRoute::getEventRoute($row->slug)); $lists[$i]->dateinfo = JEMOutput::formatDateTime($row->dates, $row->times, $row->enddates, $row->endtimes, $dateformat); $lists[$i]->text = $params->get('showtitloc', 0) ? $row->title : htmlspecialchars($row->venue, ENT_COMPAT, 'UTF-8'); $lists[$i]->venue = htmlspecialchars($row->venue, ENT_COMPAT, 'UTF-8'); $lists[$i]->city = htmlspecialchars($row->city, ENT_COMPAT, 'UTF-8'); $lists[$i]->venueurl = !empty($row->venueslug) ? JRoute::_(JEMHelperRoute::getVenueRoute($row->venueslug)) : null; $i++; } return $lists; }
/** * Logic to publish/unpublish/trash venues * * @access protected * @return void * */ protected function setStatus($status, $message) { // Check for request forgeries JSession::checkToken() or jexit('Invalid Token'); $app = JFactory::getApplication(); $input = $app->input; $cid = $input->get('cid', array(), 'array'); if (empty($cid)) { JError::raiseNotice(100, JText::_('COM_JEM_SELECT_ITEM_TO_PUBLISH')); $this->setRedirect(JEMHelperRoute::getMyVenuesRoute()); return; } $model = $this->getModel('myvenues'); if (!$model->publish($cid, $status)) { echo "<script> alert('" . $model->getError() . "'); window.history.go(-1); </script>\n"; } $total = count($cid); $msg = $total . ' ' . JText::_($message); $this->setRedirect(JEMHelperRoute::getMyVenuesRoute(), $msg); }
/** * Method to index an item. The item must be a FinderIndexerResult object. * * @param FinderIndexerResult $item The item to index as an FinderIndexerResult object. * @param string $format The item format * * @return void * * @throws Exception on database error. */ protected function index(FinderIndexerResult $item, $format = 'html') { // Check if the extension is enabled if (JComponentHelper::isEnabled($this->extension) == false) { return; } if ($this->jVer == 3) { $item->setLanguage(); } // Initialize the item parameters. $registry = new JRegistry; $registry->loadString($item->params); $item->params = JComponentHelper::getParams('com_jem', true); $item->params->merge($registry); $registry = new JRegistry; $registry->loadString($item->metadata); $item->metadata = $registry; // Trigger the onContentPrepare event. $item->summary = FinderIndexerHelper::prepareContent($item->summary, $item->params); $item->body = FinderIndexerHelper::prepareContent($item->fulltext, $item->params); // Build the necessary route and path information. $item->url = $this->getURL($item->id, $this->extension, $this->layout); $item->route = JEMHelperRoute::getEventRoute($item->slug, $item->catslug); $item->path = FinderIndexerHelper::getContentPath($item->route); // Get the menu title if it exists. $title = $this->getItemMenuTitle($item->url); // Adjust the title if necessary. if (!empty($title) && $this->params->get('use_menu_title', true)) { $item->title = $title; } // Add the meta-author. $item->metaauthor = $item->metadata->get('author'); // Add the meta-data processing instructions. // TODO: // $item->addInstruction(FinderIndexer::META_CONTEXT, 'meta_description'); // Translate the state. Articles should only be published if the category is published. $item->state = $this->translateState($item->state, $item->cat_state); // Add the type taxonomy data. $item->addTaxonomy('Type', 'Event'); // Add the author taxonomy data. if (!empty($item->author) || !empty($item->created_by_alias)) { $item->addTaxonomy('Author', !empty($item->created_by_alias) ? $item->created_by_alias : $item->author); } // Add the category taxonomy data. $item->addTaxonomy('Category', $item->category, $item->cat_state, $item->cat_access); // Add the language taxonomy data. $item->addTaxonomy('Language', $item->language); // Add the venue taxonomy data. if(!empty($item->venue)) { $item->addTaxonomy('Venue', $item->venue, $item->loc_published); } // Get content extras. FinderIndexerHelper::getContentExtras($item); // Index the item. // On J! 3.x we must use indexer member which doesn't exist on J! 2.5 if ($this->jVer == 3) { $this->indexer->index($item); } else { FinderIndexer::index($item); } }
protected function _display($rows, $parameters, $listevents_id) { if (!$rows) { return $parameters["eventsmsgnone"]; } $html_list = '<div class="listevents" id="listevents-' . $listevents_id . '">'; $html_list .= '<ul>'; $n_event = 0; foreach ($rows as $event) { require_once JPATH_BASE . "/components/com_jem/helpers/route.php"; $linkdetails = JRoute::_(JEMHelperRoute::getEventRoute($event->slug)); $linkdate = JRoute::_(JEMHelperRoute::getRoute(str_replace('-', '', $event->dates), 'day')); $linkvenue = JRoute::_(JEMHelperRoute::getVenueRoute($event->venueslug)); $jemsettings = JemHelper::config(); if ($parameters["eventstype"] == 'regprev' || $parameters["eventstype"] == 'regnext') { require_once JPATH_BASE . "/components/com_jem/models/eventlist.php"; $eventsmodel = new EventListModelEventList(); $query = 'SELECT COUNT(uid) as attendees from #__eventlist_register WHERE event = ' . $event->eventid; $eventsmodel->_db->setQuery($query); $_event = $eventsmodel->_db->loadObject(); $attendees = $_event->attendees; if ($attendees == 0) { continue; } } $html_list .= '<li id="listevent' . ($n_event + 1) . '">'; if ($parameters["eventstitle"] != 'off') { $html_list .= '<span id="eventtitle">'; $html_list .= $parameters["eventstitle"] == 'link' ? '<a href="' . $linkdetails . '">' : ''; $html_list .= $event->title; $html_list .= $parameters["eventstitle"] == 'link' ? '</a>' : ''; $html_list .= '</span>'; } if ($parameters["eventsdate"] != 'off' && $event->dates) { # display startdate require_once JPATH_BASE . "/components/com_jem/helpers/helper.php"; require_once JPATH_BASE . "/components/com_jem/classes/output.class.php"; $html_list .= ' : ' . '<span id="eventdate">'; $html_list .= $parameters["eventsdate"] == 'link' ? '<a href="' . $linkdate . '">' : ''; $html_list .= JEMOutput::formatdate($event->dates); $html_list .= $parameters["eventsdate"] == 'link' ? '</a>' : ''; $html_list .= '</span>'; } if ($parameters["eventstime"] != 'off' && $event->times) { # display starttime require_once JPATH_BASE . "/components/com_jem/helpers/helper.php"; require_once JPATH_BASE . "/components/com_jem/classes/output.class.php"; $html_list .= ' ' . '<span id="eventtime">'; $html_list .= JEMOutput::formattime($event->times); $html_list .= '</span>'; } if ($parameters["eventsvenue"] != 'off' && $event->venue) { $html_list .= ' : ' . '<span id="eventvenue">'; $html_list .= $parameters["eventsvenue"] == 'link' ? '<a href="' . $linkvenue . '">' : ''; $html_list .= $event->venue; $html_list .= $parameters["eventsvenue"] == 'link' ? '</a>' : ''; $html_list .= '</span>'; } if ($parameters["eventscategory"] != 'off' && $event->categories) { if ($parameters["eventscategory"] == 'link') { $catlink = 1; } else { $catlink = false; } $html_list .= " "; $html_list .= implode(", ", JemOutput::getCategoryList($event->categories, $catlink)); } $html_list .= '</li>'; $n_event++; if ($parameters["eventsmax"] && $n_event >= $parameters["eventsmax"]) { break; } } if ($n_event == 0) { $html_list .= $parameters["eventsmsgnone"]; } $html_list .= '</ul>'; $html_list .= '</div>'; return $html_list; }