* @subpackage EventList Wide Module * @copyright (C) 2005 - 2007 Christoph Lukes * @license GNU/GPL, see LICENCE.php * EventList is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License 2 * as published by the Free Software Foundation. * EventList is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with EventList; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ // no direct access defined('_JEXEC') or die('Restricted access'); // get module helper require_once dirname(__FILE__) . DS . 'helper.php'; //require needed component classes require_once JPATH_SITE . DS . 'components' . DS . 'com_eventlist' . DS . 'helpers' . DS . 'helper.php'; require_once JPATH_SITE . DS . 'components' . DS . 'com_eventlist' . DS . 'helpers' . DS . 'route.php'; require_once JPATH_SITE . DS . 'components' . DS . 'com_eventlist' . DS . 'classes' . DS . 'image.class.php'; $list = modEventListwideHelper::getList($params); $document =& JFactory::getDocument(); $document->addStyleSheet(JURI::base(true) . '/modules/mod_eventlist_wide/tmpl/mod_eventlist_wide.css'); // check if any results returned $items = count($list); if (!$items) { return; } require JModuleHelper::getLayoutPath('mod_eventlist_wide');
/** * Method to get the events * * @access public * @return array */ function getList(&$params) { global $mainframe; $db =& JFactory::getDBO(); $user =& JFactory::getUser(); $user_gid = (int) $user->get('aid'); //all upcoming events if ($params->get('type') == 1) { $where = ' WHERE a.dates > CURDATE()'; // $where = ' WHERE a.published = 1'; $order = ' ORDER BY a.dates, a.times'; } //archived events only if ($params->get('type') == 2) { $where = ' WHERE a.published = -1'; $order = ' ORDER BY a.dates DESC, a.times DESC'; } //currently running events only if ($params->get('type') == 3) { $where = ' WHERE a.published = 1'; $where .= ' AND ( a.dates = CURDATE()'; $where .= ' OR ( a.enddates >= CURDATE() AND a.dates <= CURDATE() ))'; $order = ' ORDER BY a.dates, a.times'; } //clean parameter data $catid = trim($params->get('catid')); $venid = trim($params->get('venid')); $state = JString::strtolower(trim($params->get('stateloc'))); //Build category selection query statement if ($catid) { $ids = explode(',', $catid); JArrayHelper::toInteger($ids); $categories = ' AND (c.id=' . implode(' OR c.id=', $ids) . ')'; } //Build venue selection query statement if ($venid) { $ids = explode(',', $venid); JArrayHelper::toInteger($ids); $venues = ' AND (l.id=' . implode(' OR l.id=', $ids) . ')'; } //Build state selection query statement if ($state) { $rawstate = explode(',', $state); foreach ($rawstate as $val) { if ($val) { $states[] = '"' . trim($db->getEscaped($val)) . '"'; } } JArrayHelper::toString($states); $stat = ' AND (LOWER(l.state)=' . implode(' OR LOWER(l.state)=', $states) . ')'; } //perform select query $query = 'SELECT a.title, a.dates, a.enddates, a.times, a.endtimes, a.datdescription, a.datimage, l.venue, l.state, l.locimage, l.city, l.locdescription, c.catname,' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug,' . ' CASE WHEN CHAR_LENGTH(l.alias) THEN CONCAT_WS(\':\', l.id, l.alias) ELSE l.id END as venueslug,' . ' CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(\':\', c.id, c.alias) ELSE c.id END as categoryslug' . ' FROM #__eventlist_events AS a' . ' LEFT JOIN #__eventlist_venues AS l ON l.id = a.locid' . ' LEFT JOIN #__eventlist_categories AS c ON c.id = a.catsid' . $where . ' AND c.access <= ' . $user_gid . ($catid ? $categories : '') . ($venid ? $venues : '') . ($state ? $stat : '') . $order . ' LIMIT ' . (int) $params->get('count', '2'); $db->setQuery($query); $rows = $db->loadObjectList(); //assign datemethod value to jview jimport('joomla.application.component.view'); JView::assignRef('datemethod', $params->get('datemethod', 1)); JView::assignRef('use_modal', $params->get('use_modal', 0)); if ($params->get('use_modal', 0)) { JHTML::_('behavior.modal'); } //Loop through the result rows and prepare data $i = 0; $lists = array(); foreach ($rows as $row) { //create thumbnails if needed and receive imagedata $dimage = ELImage::flyercreator($row->datimage, 'event'); $limage = ELImage::flyercreator($row->locimage); //cut titel $length = strlen(htmlspecialchars($row->title)); if ($length > $params->get('cuttitle', '25')) { $row->title = substr($row->title, 0, $params->get('cuttitle', '18')); $row->title = $row->title . '...'; } $lists[$i]->title = htmlspecialchars($row->title, ENT_COMPAT, 'UTF-8'); $lists[$i]->venue = htmlspecialchars($row->venue, ENT_COMPAT, 'UTF-8'); $lists[$i]->catname = htmlspecialchars($row->catname, ENT_COMPAT, 'UTF-8'); $lists[$i]->state = htmlspecialchars($row->state, ENT_COMPAT, 'UTF-8'); $lists[$i]->eventlink = $params->get('linkevent', 1) ? JRoute::_(EventListHelperRoute::getRoute($row->slug)) : ''; $lists[$i]->venuelink = $params->get('linkvenue', 1) ? JRoute::_(EventListHelperRoute::getRoute($row->venueslug, 'venueevents')) : ''; $lists[$i]->categorylink = $params->get('linkcategory', 1) ? JRoute::_(EventListHelperRoute::getRoute($row->categoryslug, 'categoryevents')) : ''; $lists[$i]->date = modEventListwideHelper::_format_date($row, $params); $lists[$i]->time = $row->times ? modEventListwideHelper::_format_time($row->dates, $row->times, $params) : ''; $lists[$i]->eventimage = JURI::base(true) . '/' . $dimage['thumb']; $lists[$i]->eventimageorig = JURI::base(true) . '/' . $dimage['original']; $lists[$i]->venueimage = JURI::base(true) . '/' . $limage['thumb']; $lists[$i]->venueimageorig = JURI::base(true) . '/' . $limage['original']; $lists[$i]->eventdescription = strip_tags($row->datdescription); $lists[$i]->venuedescription = strip_tags($row->locdescription); $i++; } return $lists; }