/** * 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); } }
/** * 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; }
/** * 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; }
/** * 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 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; }
</tr> </thead> <tbody> <?php if (count((array)$this->attending) == 0) : ?> <tr align="center"><td colspan="20"><?php echo JText::_('COM_JEM_NO_EVENTS'); ?></td></tr> <?php else : ?> <?php foreach ($this->attending as $i => $row) : ?> <tr class="row<?php echo $i % 2; ?>"> <td headers="jem_date" align="left"> <?php echo JEMOutput::formatShortDateTime($row->dates, $row->times, $row->enddates, $row->endtimes); ?> </td> <?php if (($this->jemsettings->showtitle == 1) && ($this->jemsettings->showdetails == 1)) : ?> <td headers="jem_title" align="left" valign="top"> <a href="<?php echo JRoute::_(JEMHelperRoute::getEventRoute($row->slug)); ?>"> <?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) :
/** * This method handles any mailings triggered by an event store action * * @access public * @param int $event_id Event identifier * @param int $is_new Event new or edited * @return boolean * */ public function onEventEdited($event_id, $is_new) { #################### ## DEFINING ARRAY ## #################### $send_to = array( 'user' => $is_new ? $this->params->get('newevent_mail_user', '1') : $this->params->get('editevent_mail_user', '1'), 'admin' => $is_new ? $this->params->get('newevent_mail_admin', '0') : $this->params->get('editevent_mail_admin', '0'), 'registered' => !$is_new && $this->params->get('editevent_mail_registered', '0'), 'category' => $is_new ? $this->params->get('newevent_mail_category', '0') : $this->params->get('editevent_mail_category', '0'), 'group' => $is_new ? $this->params->get('newevent_mail_group', '0') : $this->params->get('editevent_mail_group', '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('a.alias'); $case_when .= ' THEN '; $id = $query->castAsChar('a.id'); $case_when .= $query->concatenate(array($id, 'a.alias'), ':'); $case_when .= ' ELSE '; $case_when .= $id.' END as slug'; $query->select(array('a.id','a.title','a.dates','a.times','a.locid','a.published','a.created','a.modified')); $query->select($query->concatenate(array('a.introtext', 'a.fulltext')).' AS text'); $query->select(array('v.venue','v.city')); $query->select($case_when); $query->from($db->quoteName('#__jem_events').' AS a'); $query->join('LEFT', '#__jem_venues AS v ON v.id = a.locid'); $query->where(array('a.id= '.$db->quote($event_id))); $db->setQuery($query); if (is_null($event = $db->loadObject())) return false; // Link for event $link = JRoute::_(JUri::base().JEMHelperRoute::getEventRoute($event->slug), false); // Strip tags/scripts, etc. from description $text_description = JFilterOutput::cleanText($event->text); // Define published-state message switch ($event->published) { case 1: $adminstate = JText::sprintf('PLG_JEM_MAILER_EVENT_PUBLISHED', $link); $userstate = JText::sprintf('PLG_JEM_MAILER_USER_MAIL_EVENT_PUBLISHED', $link); break; case -2: $adminstate = JText::_('PLG_JEM_MAILER_EVENT_TRASHED'); $userstate = JText::_('PLG_JEM_MAILER_USER_MAIL_EVENT_TRASHED'); break; case 0: $adminstate = JText::_('PLG_JEM_MAILER_EVENT_UNPUBLISHED'); $userstate = JText::_('PLG_JEM_MAILER_USER_MAIL_EVENT_UNPUBLISHED'); break; case 2: $adminstate = JText::_('PLG_JEM_MAILER_EVENT_ARCHIVED'); $userstate = JText::_('PLG_JEM_MAILER_USER_MAIL_EVENT_ARCHIVED'); break; default: /* TODO: fallback unknown / undefined */ $adminstate = JText::_('PLG_JEM_MAILER_EVENT_UNKNOWN'); $userstate = JText::_('PLG_JEM_MAILER_USER_MAIL_EVENT_UNKNOWN'); break; } ####################### ## RECEIVERS - ADMIN ## ####################### # in here we selected the option to send to admin. # we selected admin so we can use the adminDBList. if ($send_to['admin']) { $admin_receivers = $this->_AdminDBList; } else { $admin_receivers = false; } ############################ ## RECEIVERS - REGISTERED ## ############################ # in here we selected the option to send an email to all people registered to the event. # there is no check for the waitinglist # $registered_receivers is defined in here if ($send_to['registered']) { // get data $query = $db->getQuery(true); $query->select(array('u.email')); $query->from($db->quoteName('#__users').' AS u'); $query->join('INNER', '#__jem_register AS reg ON reg.uid = u.id'); $query->where(array('reg.event= '.$db->quote($event_id))); $db->setQuery($query); if (is_null($registered_receivers = $db->loadColumn(0))) return false; } else { $registered_receivers = false; } ############################ ## RECEIVERS - CATEGORY ## ############################ # in here we selected the option to send an email to the email-address # that's filled in the category-view. # the data within categoryDBList needs to be validated. # if the categoryDBList is empty we shoudln't send an email # $category_receivers is defined in here if ($send_to['category']) { // get data $query = $db->getQuery(true); $query->select(array('c.email')); $query->from($db->quoteName('#__jem_categories').' AS c'); $query->join('INNER', '#__jem_cats_event_relations AS rel ON rel.catid = c.id'); $query->where(array('rel.itemid= '.$db->quote($event_id))); $db->setQuery($query); if (is_null($category_receivers = $db->loadColumn(0))) { return false; } else { $category_receivers = self::categoryDBList($category_receivers); } } else { $category_receivers = false; } ####################### ## RECEIVERS - GROUP ## ####################### # in here we selected the option to send an email to the email-address # of the users within the maintainer-group of the category where # the event is assigned too. # $group_receivers is defined in here if ($send_to['group']) { // get data $query = $db->getQuery(true); $query->select(array('u.email')); $query->from($db->quoteName('#__users').' AS u'); $query->join('INNER', '#__jem_groupmembers AS gm ON gm.member = u.id'); $query->join('INNER', '#__jem_categories AS c ON c.groupid = gm.group_id'); $query->join('INNER', '#__jem_cats_event_relations AS rel ON rel.catid = c.id'); $query->where(array('rel.itemid= '.$db->quote($event_id))); $db->setQuery($query); if (is_null($group_receivers = $db->loadColumn(0))) return false; } else { $group_receivers = false; } ###################### ## RECEIVERS - USER ## ###################### # in here we selected the option to send an email to the logged-in user # $user_receiver is defined in here if ($send_to['user']) { $user_receiver = $user->email; } else { $user_receiver = false; } ############################## ## SENDMAIL: $user_receiver ## ############################## if ($user_receiver) { $data = new stdClass(); if ($is_new) { $created = JHtml::Date($event->created, JText::_('DATE_FORMAT_LC2')); $data->subject = JText::sprintf('PLG_JEM_MAILER_NEW_USER_EVENT_MAIL', $this->_SiteName, $event->title); $data->body = JText::sprintf('PLG_JEM_MAILER_USER_MAIL_NEW_EVENT_9', $username, $created, $event->title, $event->dates, $event->times, $event->venue, $event->city, $text_description, $userstate); } else { $modified = JHtml::Date($event->modified, JText::_('DATE_FORMAT_LC2')); $data->subject = JText::sprintf('PLG_JEM_MAILER_EDIT_USER_EVENT_MAIL', $this->_SiteName, $event->title); $data->body = JText::sprintf('PLG_JEM_MAILER_USER_MAIL_EDIT_EVENT_9', $username, $modified, $event->title, $event->dates, $event->times, $event->venue, $event->city, $text_description, $userstate); } $data->receivers = $user_receiver; $this->_mailer($data); } ################################ ## SENDMAIL: $admin_receivers ## ################################ if ($admin_receivers) { $data = new stdClass(); if ($is_new) { $created = JHtml::Date($event->created, JText::_('DATE_FORMAT_LC2')); $data->subject = JText::sprintf('PLG_JEM_MAILER_NEW_EVENT_MAIL', $this->_SiteName, $event->title); $data->body = JText::sprintf('PLG_JEM_MAILER_NEW_EVENT_9', $username, $created, $event->title, $event->dates, $event->times, $event->venue, $event->city, $text_description, $adminstate); } else { $modified = JHtml::Date($event->modified, JText::_('DATE_FORMAT_LC2')); $data->subject = JText::sprintf('PLG_JEM_MAILER_EDIT_EVENT_MAIL', $this->_SiteName, $event->title); $data->body = JText::sprintf('PLG_JEM_MAILER_EDIT_EVENT_9', $username, $modified, $event->title, $event->dates, $event->times, $event->venue, $event->city, $text_description, $adminstate); } $data->receivers = $admin_receivers; $this->_mailer($data); } ################################ ## SENDMAIL: $group_receivers ## ################################ if ($group_receivers) { $data = new stdClass(); if ($is_new) { $created = JHtml::Date($event->created, JText::_('DATE_FORMAT_LC2')); $data->subject = JText::sprintf('PLG_JEM_MAILER_NEW_EVENT_MAIL', $this->_SiteName, $event->title); $data->body = JText::sprintf('PLG_JEM_MAILER_NEW_EVENT_9', $username, $created, $event->title, $event->dates, $event->times, $event->venue, $event->city, $text_description, $adminstate); } else { $modified = JHtml::Date($event->modified, JText::_('DATE_FORMAT_LC2')); $data->subject = JText::sprintf('PLG_JEM_MAILER_EDIT_EVENT_MAIL', $this->_SiteName, $event->title); $data->body = JText::sprintf('PLG_JEM_MAILER_EDIT_EVENT_9', $username, $modified, $event->title, $event->dates, $event->times, $event->venue, $event->city, $text_description, $adminstate); } $data->receivers = array_unique($group_receivers); $this->_mailer($data); } ##################################### ## SENDMAIL: $registered_receivers ## ##################################### if ($registered_receivers) { $data = new stdClass(); if ($is_new) { $created = JHtml::Date($event->created, JText::_('DATE_FORMAT_LC2')); $data->subject = JText::sprintf('PLG_JEM_MAILER_NEW_EVENT_MAIL', $this->_SiteName, $event->title); $data->body = JText::sprintf('PLG_JEM_MAILER_NEW_EVENT_CAT_NOTIFY_9', $username, $created, $event->title, $event->dates, $event->times, $event->venue, $event->city, $text_description, $adminstate); } else { $modified = JHtml::Date($event->modified, JText::_('DATE_FORMAT_LC2')); $data->subject = JText::sprintf('PLG_JEM_MAILER_EDIT_EVENT_MAIL', $this->_SiteName, $event->title); $data->body = JText::sprintf('PLG_JEM_MAILER_EDIT_EVENT_CAT_NOTIFY_9', $username, $modified, $event->title, $event->dates, $event->times, $event->venue, $event->city, $text_description, $adminstate); } $data->receivers = array_unique($registered_receivers); $this->_mailer($data); } ################################### ## SENDMAIL: $category_receivers ## ################################### if ($category_receivers) { $data = new stdClass(); if ($is_new) { $created = JHtml::Date($event->created, JText::_('DATE_FORMAT_LC2')); $data->subject = JText::sprintf('PLG_JEM_MAILER_NEW_EVENT_MAIL', $this->_SiteName, $event->title); $data->body = JText::sprintf('PLG_JEM_MAILER_NEW_EVENT_CAT_NOTIFY_9', $username, $created, $event->title, $event->dates, $event->times, $event->venue, $event->city, $text_description, $adminstate); } else { $modified = JHtml::Date($event->modified, JText::_('DATE_FORMAT_LC2')); $data->subject = JText::sprintf('PLG_JEM_MAILER_EDIT_EVENT_MAIL', $this->_SiteName, $event->title); $data->body = JText::sprintf('PLG_JEM_MAILER_EDIT_EVENT_CAT_NOTIFY_9', $username, $modified, $event->title, $event->dates, $event->times, $event->venue, $event->city, $text_description, $adminstate); } $data->receivers = $category_receivers; $this->_mailer($data); } return true; }
/** * 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 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; }
</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) { ?>
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; }
<?php foreach ($this->catrow->events as $row) : ?> <tr class="sectiontableentry<?php echo ($odd + 1) . $this->params->get( 'pageclass_sfx' ); ?>" itemscope="itemscope" itemtype="http://schema.org/Event"> <td headers="jem_date_cat<?php echo $this->catrow->id; ?>" align="left"> <?php echo JEMOutput::formatShortDateTime($row->dates, $row->times, $row->enddates, $row->endtimes); echo JEMOutput::formatSchemaOrgDateTime($row->dates, $row->times, $row->enddates, $row->endtimes); ?> </td> <?php if (($this->jemsettings->showtitle == 1) && ($this->jemsettings->showdetails == 1)) : ?> <td headers="jem_title_cat<?php echo $this->catrow->id; ?>" align="left" valign="top"> <a href="<?php echo JRoute::_( JEMHelperRoute::getEventRoute($row->slug)); ?>" itemprop="url"> <span itemprop="name"><?php echo $this->escape($row->title) . JemOutput::recurrenceicon($row); ?></span> </a><?php JemOutput::publishstateicon($row); ?> </td> <?php endif; ?> <?php if (($this->jemsettings->showtitle == 1) && ($this->jemsettings->showdetails == 0)) : ?> <td headers="jem_title_cat<?php echo $this->catrow->id; ?>" align="left" valign="top" itemprop="name"> <?php echo $this->escape($row->title) . JemOutput::recurrenceicon($row) . JemOutput::publishstateicon($row); ?> </td> <?php endif; ?> <?php if ($this->jemsettings->showlocate == 1) : ?> <td headers="jem_location_cat<?php echo $this->catrow->id; ?>" align="left" valign="top"> <?php if ($this->jemsettings->showlinkvenue == 1 ) : ?> <?php echo $row->locid != 0 ? "<a href='".JRoute::_(JEMHelperRoute::getVenueRoute($row->venueslug))."'>".$this->escape($row->venue)."</a>" : '-'; ?>
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; }