/** * 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'); if ($params->get('type', '0') == -1) { // upcoming events $where = ' WHERE a.published = 1 and a.dates >= CURDATE()'; $order = ' ORDER BY a.dates ASC, a.times ASC'; } else { if ($params->get('type', '0') == 1) { // archived events $where = ' WHERE a.published = -1'; $order = ' ORDER BY a.dates DESC, a.times DESC'; } else { // published events (default) $where = ' WHERE a.published = 1'; $order = ' ORDER BY a.dates ASC, a.times ASC'; } } $catid = trim($params->get('catid')); $venid = trim($params->get('venid')); if ($catid) { $ids = explode(',', $catid); JArrayHelper::toInteger($ids); $categories = ' AND (c.id=' . implode(' OR c.id=', $ids) . ')'; } if ($venid) { $ids = explode(',', $venid); JArrayHelper::toInteger($ids); $venues = ' AND (l.id=' . implode(' OR l.id=', $ids) . ')'; } //get $params->get( 'count', '2' ) nr of datasets $query = 'SELECT a.*, l.venue, l.city, l.url,' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug' . ' 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 : '') . $order . ' LIMIT ' . (int) $params->get('count', '2'); $db->setQuery($query); $rows = $db->loadObjectList(); $i = 0; $lists = array(); foreach ($rows as $row) { //cut titel $length = strlen(htmlspecialchars($row->title)); if ($length > $params->get('cuttitle', '18')) { $row->title = substr($row->title, 0, $params->get('cuttitle', '18')); $row->title = htmlspecialchars($row->title . '...', ENT_COMPAT, 'UTF-8'); } $lists[$i]->link = JRoute::_(EventListHelperRoute::getRoute($row->slug)); $lists[$i]->dateinfo = modEventListHelper::_builddateinfo($row, $params); $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->url) ? modEventListHelper::_format_url($row->url) : null; $i++; } return $lists; }
/** * 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'); if ($params->get('type', '0') == 0) { $where = ' WHERE a.published = 1'; if ($params->get('event_after', '0')) { $limit_date = strftime('%Y-%m-%d', time() + $params->get('event_after', '0') * 86400); $where .= ' AND a.dates >= ' . $db->Quote($limit_date); } $order = ' ORDER BY a.dates, a.times'; } else { $where = ' WHERE a.published = -1'; $order = ' ORDER BY a.dates DESC, a.times DESC'; } $catid = trim($params->get('catid')); $venid = trim($params->get('venid')); if ($catid) { $ids = explode(',', $catid); JArrayHelper::toInteger($ids); $categories = ' AND (c.id=' . implode(' OR c.id=', $ids) . ')'; } if ($venid) { $ids = explode(',', $venid); JArrayHelper::toInteger($ids); $venues = ' AND (l.id=' . implode(' OR l.id=', $ids) . ')'; } //get $params->get( 'count', '2' ) nr of datasets $query = 'SELECT DISTINCT a.*, l.venue, l.city, l.url,' . ' 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' . ' FROM #__eventlist_events AS a' . ' INNER JOIN #__eventlist_cats_event_relations AS rel ON rel.itemid = a.id' . ' INNER JOIN #__eventlist_categories AS c ON c.id = rel.catid' . ' LEFT JOIN #__eventlist_venues AS l ON l.id = a.locid' . $where . ' AND c.access <= ' . $user_gid . ($catid ? $categories : '') . ($venid ? $venues : '') . $order . ' LIMIT ' . (int) $params->get('count', '2'); $db->setQuery($query); $rows = $db->loadObjectList(); $i = 0; $lists = array(); foreach ($rows as $row) { //cut titel $length = strlen(htmlspecialchars($row->title)); if ($length > $params->get('cuttitle', '18')) { $row->title = substr($row->title, 0, $params->get('cuttitle', '18')); $row->title = htmlspecialchars($row->title . '...', ENT_COMPAT, 'UTF-8'); } $lists[$i]->link = JRoute::_(EventListHelperRoute::getRoute($row->slug)); $lists[$i]->dateinfo = modEventListHelper::_builddateinfo($row, $params); $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::_(EventListHelperRoute::getRoute($row->venueslug, 'venueevents')) : null; $i++; } return $lists; }