public function getGoogleCalendarFeeds() { $startDate = JRequest::getVar('start', null); $endDate = JRequest::getVar('end', null); $calendarids = ''; if (JRequest::getVar('gcids', null) != null) { if (is_array(JRequest::getVar('gcids', null))) { $calendarids = JRequest::getVar('gcids', null); } else { $calendarids = explode(',', JRequest::getVar('gcids', null)); } } else { $calendarids = JRequest::getVar('gcid', null); } $results = GCalendarDBUtil::getCalendars($calendarids); if (empty($results)) { return null; } $calendars = array(); foreach ($results as $result) { if (empty($result->calendar_id)) { continue; } $events = GCalendarZendHelper::getEvents($result, $startDate, $endDate, 1000); if ($events == null) { continue; } $calendars[] = $events; } return $calendars; }
public function onContentPrepare($context, &$article, &$params, $page = 0) { if (!$article->text) { return; } $calendarids = $this->params->get('calendarids'); $results = GCalendarDBUtil::getCalendars($calendarids); if (empty($results)) { return; } $maxEvents = $this->params->get('max_events', 10); $filter = $this->params->get('find', ''); $values = array(); foreach ($results as $result) { $events = GCalendarZendHelper::getEvents($result, null, null, $maxEvents, $filter); if (!empty($events)) { foreach ($events as $event) { if (!$event instanceof GCalendar_Entry) { continue; } $values[] = $event; } } } usort($values, array("GCalendar_Entry", "compare")); $values = array_slice($values, 0, $maxEvents); $article->text = GCalendarUtil::renderEvents($values, $article->text, JComponentHelper::getParams('com_gcalendar')); }
public static function getCalendarItems($params) { $calendarids = $params->get('calendarids'); $results = GCalendarDBUtil::getCalendars($calendarids); if (empty($results)) { JError::raiseWarning(500, 'The selected calendar(s) were not found in the database.'); return array(); } $orderBy = $params->get('order', 1) == 1 ? GCalendarZendHelper::ORDER_BY_START_TIME : GCalendarZendHelper::ORDER_BY_LAST_MODIFIED; $maxEvents = $params->get('max_events', 10); $filter = $params->get('find', ''); $startDate = $params->get('start_date', null); $endDate = $params->get('end_date', null); if (!empty($startDate)) { $startDate = strtotime($startDate); } if (!empty($endDate)) { $endDate = strtotime($endDate); } $values = array(); foreach ($results as $result) { $events = GCalendarZendHelper::getEvents($result, $startDate, $endDate, $maxEvents, $filter, $orderBy); if (!empty($events)) { foreach ($events as $event) { if (!$event instanceof GCalendar_Entry) { continue; } $values[] = $event; } } } usort($values, array("GCalendar_Entry", "compare")); return array_slice($values, 0, $maxEvents); }
public static function getCalendarItems($params) { $calendarids = $params->get('calendarids'); $results = GCalendarDBUtil::getCalendars($calendarids); if (empty($results)) { JError::raiseWarning(500, 'The selected calendar(s) were not found in the database.'); return null; } $orderBy = $params->get('order', 1) == 1 ? GCalendarZendHelper::ORDER_BY_START_TIME : GCalendarZendHelper::ORDER_BY_LAST_MODIFIED; $maxEvents = $params->get('max_events', 10); $filter = $params->get('find', ''); $titleFilter = $params->get('title_filter', '.*'); $values = array(); foreach ($results as $result) { $events = GCalendarZendHelper::getEvents($result, null, null, $maxEvents, $filter, $orderBy); if (!empty($events)) { foreach ($events as $event) { if (!$event instanceof GCalendar_Entry) { continue; } $event->setParam('moduleFilter', $titleFilter); $values[] = $event; } } } usort($values, array("GCalendar_Entry", "compare")); $events = array_filter($values, array('ModGCalendarNextHelper', "filter")); $offset = $params->get('offset', 0); $numevents = $params->get('count', $maxEvents); return array_shift($values); }
function checkDB() { $tmp = array(); $results = GCalendarDBUtil::getAllCalendars(); if (empty($results)) { $tmp[] = array('name' => 'DB Entries Check', 'description' => 'No DB data found.', 'status' => 'ok', 'solution' => ''); } else { foreach ($results as $result) { $events = GCalendarZendHelper::getEvents($result, null, null, 5); if ($events == null) { $message = array_shift(JFactory::getApplication()->getMessageQueue()); if (key_exists('message', $message)) { $message = $message['message']; } else { $message = print_r($message, true); } $desc = "An error occurred when reading calendar " . $result->name . ":<br>" . $message; $solution = "<ul><li>If the error is the same as in the connection test use the solution described there.</li>"; $solution .= "<li>Please check your shared settings of the calendar and the events, "; $solution .= "if you do not share your calendar with the public the <a href=\"http://code.google.com/apis/calendar/docs/2.0/developers_guide_protocol.html#AuthMagicCookie\">magic cookie</a> field must be set.</li>"; $solution .= "<li><b>If the problem still exists check the forum at <a href=\"http://g4j.digital-peak.com\">g4j.digital-peak.com</a>.</b></li></ul>"; $status = 'failure'; } else { if (empty($events)) { $solution = 'Create events in the calendar.'; $status = 'warning'; $desc = 'GCalendar could check the events without any problems from calendar ' . $result->name . '. But the result was empty.'; } else { $solution = ''; $status = 'ok'; $desc = 'GCalendar could read the events without any problems from calendar ' . $result->name . '.'; } } // $desc .= $desc.'<br><a href="'.$feed->feed_url.'" target="_blank">Here</a> is the url of the generated google calendar feed.'; $tmp[] = array('name' => $result->name . ' Check', 'description' => $desc, 'status' => $status, 'solution' => $solution); } } return $tmp; }
public function onContentSearch($text, $phrase = '', $ordering = '', $areas = null) { $user = JFactory::getUser(); $text = trim($text); if ($text == '') { return array(); } if ($phrase == 'exact') { $text = "\"" . $text . "\""; } switch ($ordering) { case 'oldest': $orderasc = GCalendarZendHelper::SORT_ORDER_ASC; break; case 'newest': default: $orderasc = GCalendarZendHelper::SORT_ORDER_DESC; } if (is_array($areas)) { if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) { return array(); } } $pluginParams = $this->params; $limit = $pluginParams->def('search_limit', 50); $calendarids = $pluginParams->get('calendarids', NULL); $pastevents = $pluginParams->get('pastevents', 1) == 1; $results = GCalendarDBUtil::getCalendars($calendarids); if (empty($results)) { return array(); } $events = array(); foreach ($results as $result) { $tmp = GCalendarZendHelper::getEvents($result, null, null, $limit, $text, GCalendarZendHelper::ORDER_BY_START_TIME, $pastevents, $orderasc); foreach ($tmp as $event) { $events[] = $event; } } if ($orderasc == GCalendarZendHelper::SORT_ORDER_ASC) { usort($events, array("GCalendar_Entry", "compare")); } else { usort($events, array("GCalendar_Entry", "compareDesc")); } array_splice($events, $limit); $return = array(); foreach ($events as $event) { $params = clone JComponentHelper::getParams('com_gcalendar'); $title = GCalendarUtil::renderEvents(array($event), '{{#events}}{{date}} {{{title}}}{{/events}}', $params); $text = GCalendarUtil::renderEvents(array($event), '{{#events}}{{{description}}}{{/events}}', $params); $itemID = GCalendarUtil::getItemId($event->getParam('gcid')); if (!empty($itemID)) { $itemID = '&Itemid=' . $itemID; } $row->href = JRoute::_('index.php?option=com_gcalendar&view=event&eventID=' . $event->getGCalId() . '&gcid=' . $event->getParam('gcid') . $itemID); $row->title = $title; $row->text = $text; $row->section = JText::_('PLG_SEARCH_GCALENDAR_OUTPUT_CATEGORY'); $row->category = $event->getParam('gcid'); $row->created = $event->getStartDate()->format('U', true); $row->browsernav = ''; $return[] = $row; $row = null; } return $return; }