function checkDB()
{
    $tmp = array();
    $db =& JFactory::getDBO();
    $query = "SELECT id, calendar_id, name, color, magic_cookie  FROM #__gcalendar";
    $db->setQuery($query);
    $results = $db->loadObjectList();
    if (empty($results)) {
        $tmp[] = array('name' => 'DB Entries Check', 'description' => 'No DB data found.', 'status' => 'ok', 'solution' => '');
    } else {
        foreach ($results as $result) {
            $feed = new SimplePie_GCalendar();
            $feed->set_show_past_events(FALSE);
            $feed->set_sort_ascending(TRUE);
            $feed->set_orderby_by_start_date(TRUE);
            $feed->set_expand_single_events(TRUE);
            $feed->enable_order_by_date(FALSE);
            $feed->enable_cache(FALSE);
            $feed->set_cal_language(GCalendarUtil::getFrLanguage());
            $feed->set_timezone(GCalendarUtil::getComponentParameter('timezone'));
            $url = SimplePie_GCalendar::create_feed_url($result->calendar_id, $result->magic_cookie);
            $feed->set_feed_url($url);
            $feed->init();
            $feed->handle_content_type();
            $data = $feed->get_items();
            if ($feed->error()) {
                $desc = "The following Simplepie error occurred when reading calendar " . $result->name . ":<br>" . $feed->error();
                $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>Run the <a href=\"components/com_gcalendar/libraries/sp-gcalendar/sp_compatibility_test.php\">simplepie compatibility test</a> and check if your system does meet the minimum requirements of simplepie.</li>";
                $solution .= "<li><b>If the problem still exists check the forum at <a href=\"http://g4j.laoneo.net\">g4j.laoneo.net</a>.</b></li>";
                $status = 'failure';
            } else {
                if (empty($data)) {
                    $solution = 'Create events in the calendar.';
                    $status = 'warning';
                    $desc = 'Simplepie could check the events without any problems from calendar ' . $result->name . '. But the result was empty.';
                } else {
                    $solution = '';
                    $status = 'ok';
                    $desc = 'Simplepie 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;
}
Exemple #2
0
 function getGoogleCalendarFeeds($start, $end)
 {
     GCalendarUtil::ensureSPIsLoaded();
     $calendarids = null;
     $gcids = $this->getState('gcids');
     if (!empty($gcids)) {
         $calendarids = $gcids;
     }
     $results = GCalendarDBUtil::getCalendars($calendarids);
     if (empty($results)) {
         return array();
     }
     $calendars = array();
     foreach ($results as $result) {
         if (!empty($result->calendar_id)) {
             $feed = new SimplePie_GCalendar();
             $feed->set_show_past_events(FALSE);
             $feed->set_sort_ascending(TRUE);
             $feed->set_orderby_by_start_date(TRUE);
             $feed->set_expand_single_events(TRUE);
             $feed->enable_order_by_date(FALSE);
             $feed->enable_cache(FALSE);
             $feed->set_start_date($start);
             $feed->set_end_date($end);
             $feed->set_max_events(100);
             $feed->put('gcid', $result->id);
             $feed->put('gccolor', $result->color);
             $feed->set_cal_language(GCalendarUtil::getFrLanguage());
             $feed->set_timezone(GCalendarUtil::getComponentParameter('timezone'));
             $url = SimplePie_GCalendar::create_feed_url($result->calendar_id, $result->magic_cookie);
             $feed->set_feed_url($url);
             $feed->init();
             $feed->handle_content_type();
             $calendars[] = $feed;
         }
     }
     return $calendars;
 }
 /**
  * Gets the simplepie event
  * @return string event
  */
 function getGCalendar()
 {
     GCalendarUtil::ensureSPIsLoaded();
     $results = GCalendarDBUtil::getCalendars(JRequest::getVar('gcid', null));
     if (empty($results) || JRequest::getVar('eventID', null) == null) {
         return null;
     }
     $result = $results[0];
     $feed = new SimplePie_GCalendar();
     $feed->set_show_past_events(FALSE);
     $feed->set_sort_ascending(TRUE);
     $feed->set_orderby_by_start_date(TRUE);
     $feed->set_expand_single_events(TRUE);
     $feed->enable_order_by_date(FALSE);
     $feed->enable_cache(FALSE);
     $feed->set_start_date(JRequest::getVar('start', 0) - 86400);
     $feed->set_end_date(JRequest::getVar('end', 0) + 86400);
     $feed->put('gcid', $result->id);
     $feed->put('gccolor', $result->color);
     $feed->put('gcname', $result->name);
     $feed->set_cal_language(GCalendarUtil::getFrLanguage());
     $feed->set_timezone(GCalendarUtil::getComponentParameter('timezone'));
     $url = SimplePie_GCalendar::create_feed_url($result->calendar_id, $result->magic_cookie);
     $feed->set_feed_url($url);
     $feed->init();
     if ($feed->error()) {
         JError::raiseWarning(500, 'Simplepie detected an error for the calendar ' . $result->calendar_id . '. Please run the <a href="administrator/components/com_gcalendar/libraries/sp-gcalendar/sp_compatibility_test.php">compatibility utility</a>.<br>The following Simplepie error occurred:<br>' . $feed->error());
     }
     $feed->handle_content_type();
     $items = $feed->get_items();
     foreach ($items as $item) {
         if ($item->get_id() == JRequest::getVar('eventID', null)) {
             return $item;
         }
     }
     return null;
 }
 function getCalendarItems()
 {
     GCalendarUtil::ensureSPIsLoaded();
     $params = $this->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();
     }
     $values = array();
     $sortOrder = $params->get('order', 1) == 1;
     $maxEvents = $params->get('max_events', 10);
     foreach ($results as $result) {
         if (!empty($result->calendar_id)) {
             $feed = new SimplePie_GCalendar();
             $feed->set_show_past_events($params->get('past_events', TRUE));
             $startDate = $params->get('start_date', '');
             $endDate = $params->get('end_date', '');
             if (!empty($startDate) && !empty($endDate)) {
                 $feed->set_start_date(strtotime($startDate));
                 $feed->set_end_date(strtotime($endDate));
             }
             $feed->set_sort_ascending(TRUE);
             $feed->set_orderby_by_start_date($sortOrder);
             $feed->set_expand_single_events($params->get('expand_events', TRUE));
             $feed->enable_order_by_date(false);
             $conf =& JFactory::getConfig();
             if ($params != null && ($params->get('gc_cache', 0) == 2 || $params->get('gc_cache', 0) == 1 && $conf->getValue('config.caching'))) {
                 $cacheTime = $params->get('gccache_time', $conf->getValue('config.cachetime') * 60);
                 // check if cache directory exists and is writeable
                 $cacheDir = JPATH_BASE . DS . 'cache' . DS . $params->get('gc_cache_folder', '');
                 JFolder::create($cacheDir, 0755);
                 if (!is_writable($cacheDir)) {
                     JError::raiseWarning(500, "Created cache at " . $cacheDir . " is not writable, disabling cache.");
                     $cache_exists = false;
                 } else {
                     $cache_exists = true;
                 }
                 //check and set caching
                 $feed->enable_cache($cache_exists);
                 if ($cache_exists) {
                     $feed->set_cache_location($cacheDir);
                     $feed->set_cache_duration($cacheTime);
                 }
             } else {
                 $feed->enable_cache(false);
                 $feed->set_cache_duration(-1);
             }
             $feed->set_max_events($maxEvents);
             $feed->set_timezone(GCalendarUtil::getComponentParameter('timezone'));
             $feed->set_cal_language(GCalendarUtil::getFrLanguage());
             $feed->set_cal_query($params->get('find', ''));
             $feed->put('gcid', $result->id);
             $feed->put('gcname', $result->name);
             $feed->put('gccolor', $result->color);
             $url = SimplePie_GCalendar::create_feed_url($result->calendar_id, $result->magic_cookie);
             $feed->set_feed_url($url);
             // Initialize the feed so that we can use it.
             $feed->init();
             //				echo $feed->feed_url;
             if ($feed->error()) {
                 JError::raiseWarning(500, 'Simplepie detected an error. Please run the <a href="administrator/components/com_gcalendar/libraries/sp-gcalendar/sp_compatibility_test.php">compatibility utility</a>.', $feed->error());
             }
             // Make sure the content is being served out to the browser properly.
             $feed->handle_content_type();
             $values = array_merge($values, $feed->get_items());
         }
     }
     // we sort the array based on the event compare function
     usort($values, array("SimplePie_Item_GCalendar", "compare"));
     $events = array_filter($values, array($this, "filter"));
     $offset = $params->get('offset', 0);
     $numevents = $params->get('count', $maxEvents);
     $events = array_slice($values, $offset, $numevents);
     //return the feed data structure for the template
     return $events;
 }
<div class="contentpane<?php 
echo $params->get('pageclass_sfx');
?>
"><?php 
$variables = '';
$variables .= '?showTitle=' . $params->get('title');
$variables .= '&amp;showNav=' . $params->get('navigation');
$variables .= '&amp;showDate=' . $params->get('date');
$variables .= '&amp;showPrint=' . $params->get('print');
$variables .= '&amp;showTabs=' . $params->get('tabs');
$variables .= '&amp;showCalendars=0';
$variables .= '&amp;showTz=' . $params->get('tz');
$variables .= '&amp;mode=' . $params->get('view', 'MONTH');
$variables .= '&amp;wkst=' . $params->get('weekstart', 2);
$variables .= '&amp;bgcolor=%23' . $params->get('bgcolor', 'FFFFFF');
$variables .= '&amp;hl=' . GCalendarUtil::getFrLanguage();
$tz = $params->get('timezone');
if (!empty($tz)) {
    $tz = '&amp;ctz=' . $tz;
}
$variables .= $tz;
$variables .= '&amp;height=' . $params->get('height', 500);
$domain = 'http://www.google.com/calendar/embed';
$google_apps_domain = $params->get('google_apps_domain');
if (!empty($google_apps_domain)) {
    $domain = 'http://www.google.com/calendar/hosted/' . $google_apps_domain . '/embed';
}
$calendar_list = '<div id="gc_google_view_list"><table>';
$calendarids = array();
$tmp = $params->get('calendarids');
if (is_array($tmp)) {
 /**
  * Returns a Simplepie feed for the calendar according
  * to the parameter gcid.
  * If there is a menu available for this calendar the
  * cache is used and configured from the menu parameters.
  */
 function getGoogleCalendarFeeds()
 {
     GCalendarUtil::ensureSPIsLoaded();
     $startDate = JRequest::getVar('start', null);
     $endDate = JRequest::getVar('end', null);
     $browserTz = JRequest::getInt('browserTimezone', null);
     if (!empty($browserTz)) {
         $browserTz = $browserTz * 60;
     } else {
         $browserTz = 0;
     }
     $serverOffset = date('Z', $startDate);
     $startDate = $startDate - $browserTz - $serverOffset - GCalendarModelJSONFeed::getGCalendarTZOffset($startDate);
     $endDate = $endDate - $browserTz - $serverOffset - GCalendarModelJSONFeed::getGCalendarTZOffset($endDate);
     $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;
         }
         $feed = new SimplePie_GCalendar();
         if (JRequest::getCmd('layout', null) == 'module') {
             $cacheTime = JRequest::getInt('ctime', -1);
             if ($cacheTime > -1) {
                 // check if cache directory exists and is writeable
                 $cacheDir = JPATH_BASE . DS . 'cache' . DS . 'mod_gcalendar';
                 $cache_exists = true;
                 JFolder::create($cacheDir, 0755);
                 if (!is_writable($cacheDir)) {
                     JError::raiseWarning(500, "Created cache at " . $cacheDir . " is not writable, disabling cache.");
                     $cache_exists = false;
                 } else {
                     $cache_exists = true;
                 }
                 $feed->enable_cache($cache_exists);
                 if ($cache_exists) {
                     $feed->set_cache_location($cacheDir);
                     $feed->set_cache_duration($cacheTime);
                 }
             } else {
                 $feed->enable_cache(false);
                 $feed->set_cache_duration(-1);
             }
         } else {
             $linkID = GCalendarUtil::getItemId($result->id);
             $menus =& JSite::getMenu();
             $params = $menus->getParams($linkID);
             $conf =& JFactory::getConfig();
             if ($params != null && ($params->get('gccache', 0) == 2 || $params->get('gccache', 0) == 1 && $conf->getValue('config.caching'))) {
                 $cacheTime = $params->get('gccache_time', $conf->getValue('config.cachetime') * 60);
                 // check if cache directory exists and is writeable
                 $cacheDir = JPATH_BASE . DS . 'cache' . DS . 'com_gcalendar';
                 JFolder::create($cacheDir, 0755);
                 if (!is_writable($cacheDir)) {
                     JError::raiseWarning(500, "Created cache at " . $cacheDir . " is not writable, disabling cache.");
                     $cache_exists = false;
                 } else {
                     $cache_exists = true;
                 }
                 //check and set caching
                 $feed->enable_cache($cache_exists);
                 if ($cache_exists) {
                     $feed->set_cache_location($cacheDir);
                     $feed->set_cache_duration($cacheTime);
                 }
             } else {
                 $feed->enable_cache(false);
                 $feed->set_cache_duration(-1);
             }
         }
         $feed->set_show_past_events(FALSE);
         $feed->set_sort_ascending(TRUE);
         $feed->set_orderby_by_start_date(TRUE);
         $feed->set_expand_single_events(TRUE);
         $feed->enable_order_by_date(FALSE);
         $feed->set_start_date($startDate);
         $feed->set_end_date($endDate);
         $feed->set_max_events(1000);
         $feed->put('gcid', $result->id);
         $feed->put('gccolor', $result->color);
         $feed->put('gcname', $result->name);
         $feed->set_cal_language(GCalendarUtil::getFrLanguage());
         $feed->set_timezone(GCalendarUtil::getComponentParameter('timezone'));
         $url = SimplePie_GCalendar::create_feed_url($result->calendar_id, $result->magic_cookie);
         $feed->set_feed_url($url);
         $feed->init();
         //echo $feed->feed_url;
         if ($feed->error()) {
             JError::raiseWarning(500, 'Simplepie detected an error for the calendar ' . $result->calendar_id . '. Please run the <a href="administrator/components/com_gcalendar/libraries/sp-gcalendar/sp_compatibility_test.php">compatibility utility</a>.<br>The following Simplepie error occurred:<br>' . $feed->error());
         }
         $feed->handle_content_type();
         $calendars[] = $feed;
     }
     return $calendars;
 }
Exemple #7
0
 public static function renderEvents(array $events = null, $output, $params = null, $eventParams = array())
 {
     if ($events === null) {
         $events = array();
     }
     JFactory::getLanguage()->load('com_gcalendar', JPATH_ADMINISTRATOR . '/components/com_gcalendar');
     $lastHeading = '';
     $configuration = $eventParams;
     $configuration['events'] = array();
     foreach ($events as $event) {
         if (!is_object($event)) {
             continue;
         }
         $variables = array();
         $itemID = GCalendarUtil::getItemId($event->getParam('gcid', null));
         if (!empty($itemID) && JRequest::getVar('tmpl', null) != 'component' && $event != null) {
             $component = JComponentHelper::getComponent('com_gcalendar');
             $menu = JFactory::getApplication()->getMenu();
             $item = $menu->getItem($itemID);
             if ($item != null) {
                 $backLinkView = $item->query['view'];
                 $dateHash = '';
                 if ($backLinkView == 'gcalendar') {
                     $day = $event->getStartDate()->format('d', true);
                     $month = $event->getStartDate()->format('m', true);
                     $year = $event->getStartDate()->format('Y', true);
                     $dateHash = '#year=' . $year . '&month=' . $month . '&day=' . $day;
                 }
             }
             $variables['calendarLink'] = JRoute::_('index.php?option=com_gcalendar&Itemid=' . $itemID . $dateHash);
         }
         $itemID = GCalendarUtil::getItemId($event->getParam('gcid'));
         if (!empty($itemID)) {
             $itemID = '&Itemid=' . $itemID;
         } else {
             $menu = JFactory::getApplication()->getMenu();
             $activemenu = $menu->getActive();
             if ($activemenu != null) {
                 $itemID = '&Itemid=' . $activemenu->id;
             }
         }
         $variables['backlink'] = JRoute::_('index.php?option=com_gcalendar&view=event&eventID=' . $event->getGCalId() . '&gcid=' . $event->getParam('gcid') . $itemID);
         $variables['link'] = $event->getLink('alternate')->getHref();
         $variables['calendarcolor'] = $event->getParam('gccolor');
         // the date formats from http://php.net/date
         $dateformat = $params->get('event_date_format', 'm.d.Y');
         $timeformat = $params->get('event_time_format', 'g:i a');
         // These are the dates we'll display
         $startDate = $event->getStartDate()->format($dateformat, true);
         $startTime = $event->getStartDate()->format($timeformat, true);
         $endDate = $event->getEndDate()->format($dateformat, true);
         $endTime = $event->getEndDate()->format($timeformat, true);
         $dateSeparator = '-';
         $timeString = $startTime . ' ' . $startDate . ' ' . $dateSeparator . ' ' . $endTime . ' ' . $endDate;
         $copyDateTimeFormat = 'Ymd';
         switch ($event->getDayType()) {
             case GCalendar_Entry::SINGLE_WHOLE_DAY:
                 $timeString = $startDate;
                 $copyDateTimeFormat = 'Ymd';
                 $startTime = '';
                 $endTime = '';
                 $dateSeparator = '';
                 break;
             case GCalendar_Entry::SINGLE_PART_DAY:
                 $timeString = $startDate . ' ' . $startTime . ' ' . $dateSeparator . ' ' . $endTime;
                 $copyDateTimeFormat = 'Ymd\\THis';
                 break;
             case GCalendar_Entry::MULTIPLE_WHOLE_DAY:
                 $tmp = clone $event->getEndDate();
                 $tmp->modify('-1 day');
                 $endDate = $tmp->format($dateformat, true);
                 $timeString = $startDate . ' ' . $dateSeparator . ' ' . $endDate;
                 $copyDateTimeFormat = 'Ymd';
                 $startTime = '';
                 $endTime = '';
                 break;
             case GCalendar_Entry::MULTIPLE_PART_DAY:
                 $timeString = $startTime . ' ' . $startDate . ' ' . $dateSeparator . ' ' . $endTime . ' ' . $endDate;
                 $copyDateTimeFormat = 'Ymd\\THis';
                 break;
         }
         $variables['calendarName'] = $event->getParam('gcname');
         $variables['title'] = (string) $event->getTitle();
         if ($params->get('show_event_date', 1) == 1) {
             $variables['date'] = $timeString;
             $variables['startDate'] = $startDate;
             $variables['startTime'] = $startTime;
             $variables['endDate'] = $endDate;
             $variables['endTime'] = $endTime;
             $variables['dateseparator'] = $dateSeparator;
             $variables['month'] = strtoupper($event->getStartDate()->format('M', true));
             $variables['day'] = $event->getStartDate()->format('j', true);
         }
         $variables['modifieddate'] = $event->getModifiedDate()->format($timeformat, true) . ' ' . $event->getModifiedDate()->format($dateformat, true);
         if (count($event->getWho()) > 0) {
             $variables['hasAttendees'] = true;
             $variables['attendees'] = array();
             foreach ($event->getWho() as $a) {
                 $variables['attendees'][] = array('name' => (string) $a->getValueString(), 'email' => base64_encode(str_replace('@', '#', $a->getEmail())));
             }
         }
         $location = $event->getLocation();
         $variables['location'] = $location;
         if (!empty($location)) {
             $variables['maplink'] = (JBrowser::getInstance()->isSSLConnection() ? 'https' : 'http') . "://maps.google.com/?q=" . urlencode($location) . '&hl=' . substr(GCalendarUtil::getFrLanguage(), 0, 2) . '&output=embed';
         }
         $variables['description'] = (string) $event->getContent();
         if ($params->get('event_description_format', 1) == 1) {
             $variables['description'] = preg_replace("@(src|href)=\"https?://@i", '\\1="', $event->getContent());
             $variables['description'] = nl2br(preg_replace("@(((f|ht)tp:\\/\\/)[^\"\\'\\>\\s]+)@", '<a href="\\1" target="_blank">\\1</a>', $variables['description']));
         }
         $variables['hasAuthor'] = count($event->getAuthor()) > 0;
         $variables['author'] = array();
         foreach ($event->getAuthor() as $author) {
             $variables['author'][] = array('name' => (string) $author->getName(), 'email' => base64_encode(str_replace('@', '#', $author->getEmail())));
         }
         $variables['copyGoogleUrl'] = 'http://www.google.com/calendar/render?action=TEMPLATE&text=' . urlencode($event->getTitle());
         $variables['copyGoogleUrl'] .= '&dates=' . $event->getStartDate()->format($copyDateTimeFormat) . '%2F' . $event->getEndDate()->format($copyDateTimeFormat);
         $variables['copyGoogleUrl'] .= '&location=' . urlencode($event->getLocation());
         $variables['copyGoogleUrl'] .= '&details=' . urlencode($event->getContent());
         $variables['copyGoogleUrl'] .= '&hl=' . GCalendarUtil::getFrLanguage() . '&ctz=Etc/GMT';
         $variables['copyGoogleUrl'] .= '&sf=true&output=xml';
         $ical_timeString_start = $startTime . ' ' . $startDate;
         $ical_timeString_start = strtotime($ical_timeString_start);
         $ical_timeString_end = $endTime . ' ' . $endDate;
         $ical_timeString_end = strtotime($ical_timeString_end);
         $loc = $event->getLocation();
         $variables['copyOutlookUrl'] = JRoute::_("index.php?option=com_gcalendar&view=ical&format=raw&eventID=" . $event->getGCalId() . '&gcid=' . $event->getParam('gcid'));
         $groupHeading = $event->getStartDate()->format($params->get('grouping', ''), true);
         if ($groupHeading != $lastHeading) {
             $lastHeading = $groupHeading;
             $variables['header'] = $groupHeading;
         }
         $configuration['events'][] = $variables;
     }
     $configuration['eventLabel'] = JText::_('COM_GCALENDAR_FIELD_CONFIG_EVENT_LABEL');
     $configuration['calendarLinkLabel'] = JText::_('COM_GCALENDAR_FIELD_CONFIG_EVENT_LABEL_CALENDAR_BACK_LINK');
     $configuration['calendarNameLabel'] = JText::_('COM_GCALENDAR_FIELD_CONFIG_EVENT_LABEL_CALENDAR_NAME');
     $configuration['titleLabel'] = JText::_('COM_GCALENDAR_FIELD_CONFIG_EVENT_LABEL_EVENT_TITLE');
     $configuration['dateLabel'] = JText::_('COM_GCALENDAR_FIELD_CONFIG_EVENT_LABEL_WHEN');
     $configuration['attendeesLabel'] = JText::_('COM_GCALENDAR_FIELD_CONFIG_EVENT_LABEL_ATTENDEES');
     $configuration['locationLabel'] = JText::_('COM_GCALENDAR_FIELD_CONFIG_EVENT_LABEL_LOCATION');
     $configuration['descriptionLabel'] = JText::_('COM_GCALENDAR_FIELD_CONFIG_EVENT_LABEL_DESCRIPTION');
     $configuration['authorLabel'] = JText::_('COM_GCALENDAR_FIELD_CONFIG_EVENT_LABEL_AUTHOR');
     $configuration['copyLabel'] = JText::_('COM_GCALENDAR_FIELD_CONFIG_EVENT_LABEL_COPY');
     $configuration['copyGoogleLabel'] = JText::_('COM_GCALENDAR_FIELD_CONFIG_EVENT_LABEL_COPY_TO_MY_CALENDAR');
     $configuration['copyOutlookLabel'] = JText::_('COM_GCALENDAR_FIELD_CONFIG_EVENT_LABEL_COPY_TO_MY_CALENDAR_ICS');
     $configuration['language'] = substr(GCalendarUtil::getFrLanguage(), 0, 2);
     $configuration['emptyText'] = JText::_('COM_GCALENDAR_FIELD_CONFIG_EVENT_LABEL_NO_EVENT_TEXT');
     try {
         $m = new Mustache();
         return $m->render($output, $configuration);
     } catch (Exception $e) {
         echo $e->getMessage();
     }
 }
Exemple #8
0
 function getGoogleCalendarFeeds($startDate, $endDate, $projection = null)
 {
     GCalendarUtil::ensureSPIsLoaded();
     $results = $this->getDBCalendars();
     if (empty($results)) {
         return null;
     }
     $params = $this->getState('parameters.menu');
     $useCache = false;
     $calendarids = array();
     if ($params != null) {
         $useCache = $params->get('cache', 'no') == 'yes';
         $tmp = $params->get('calendarids');
         if (is_array($tmp)) {
             $calendarids = $tmp;
         } else {
             if (!empty($tmp)) {
                 $calendarids[] = $tmp;
             }
         }
     }
     $calendars = array();
     foreach ($results as $result) {
         if (empty($result->calendar_id)) {
             continue;
         }
         if (!empty($calendarids) && !in_array($result->id, $calendarids)) {
             continue;
         }
         $feed = new SimplePie_GCalendar();
         $feed->set_show_past_events(FALSE);
         $feed->set_sort_ascending(TRUE);
         $feed->set_orderby_by_start_date(TRUE);
         $feed->set_expand_single_events(TRUE);
         $feed->enable_order_by_date(FALSE);
         $feed->enable_cache($useCache);
         if ($useCache) {
             // check if cache directory exists and is writeable
             $cacheDir = JPATH_BASE . DS . 'cache' . DS . 'com_gcalendar';
             JFolder::create($cacheDir, 0755);
             if (!is_writable($cacheDir)) {
                 JError::raiseWarning(500, "Created cache at " . $cacheDir . " is not writable, disabling cache.");
                 $cache_exists = false;
             } else {
                 $cache_exists = true;
             }
             //check and set caching
             $feed->enable_cache($cache_exists);
             if ($cache_exists) {
                 $feed->set_cache_location($cacheDir);
                 $cache_time = intval($params->get('cache_time', 3600));
                 $feed->set_cache_duration($cache_time);
             }
         }
         $feed->set_projection($projection);
         $feed->set_start_date($startDate);
         $feed->set_end_date($endDate);
         $feed->set_max_events(100);
         $feed->put('gcid', $result->id);
         $feed->put('gccolor', $result->color);
         $feed->put('gcname', $result->name);
         $feed->set_cal_language(GCalendarUtil::getFrLanguage());
         $feed->set_timezone(GCalendarUtil::getComponentParameter('timezone'));
         $url = SimplePie_GCalendar::create_feed_url($result->calendar_id, $result->magic_cookie);
         $feed->set_feed_url($url);
         $feed->init();
         $feed->handle_content_type();
         $calendars[] = $feed;
     }
     return $calendars;
 }
Exemple #9
0
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with GCalendar.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @author Allon Moritz
 * @copyright 2007-2009 Allon Moritz
 * @version $Revision: 2.1.2 $
 */
defined('_JEXEC') or die('Restricted access');
require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_gcalendar' . DS . 'util.php';
$tz = GCalendarUtil::getComponentParameter('timezone');
if (!empty($tz)) {
    $tz = '&ctz=' . $tz;
}
$lg = '&hl=' . GCalendarUtil::getFrLanguage();
$url = 'http://www.google.com/calendar/event?eid=' . $this->eventID . $tz . $lg;
$domain = GCalendarUtil::getComponentParameter('google_apps_domain');
if (!empty($domain)) {
    $url = 'http://www.google.com/calendar/hosted/' . $domain . '/event?eid=' . $this->eventID . $tz . $lg;
}
$itemID = GCalendarUtil::getItemId(JRequest::getVar('gcid', null));
if (!empty($itemID) && JRequest::getVar('tmpl', null) != 'component') {
    $component =& JComponentHelper::getComponent('com_gcalendar');
    $menu =& JSite::getMenu();
    $item = $menu->getItem($itemID);
    if ($item != null) {
        $backLinkView = $item->query['view'];
        echo "<table><tr><td valign=\"middle\">\n";
        echo '<a href="' . JRoute::_('index.php?option=com_gcalendar&view=' . $backLinkView . '&Itemid=' . $itemID) . "\">\n";
        echo "<img id=\"prevBtn_img\" height=\"16\" border=\"0\" width=\"16\" alt=\"backlink\" src=\"components/com_gcalendar/hiddenviews/event/tmpl/back.png\"/>\n";
 /**
  * @return Zend_Gdata_App_Entry|NULL
  */
 public static function internalGetEvent($calendar, $eventId)
 {
     try {
         $client = new Zend_Http_Client();
         if (!empty($calendar->username) && !empty($calendar->password)) {
             $client = Zend_Gdata_ClientLogin::getHttpClient($calendar->username, $calendar->password, Zend_Gdata_Calendar::AUTH_SERVICE_NAME);
         }
         $service = new Zend_Gdata_Calendar($client);
         $query = $service->newEventQuery();
         $query->setUser($calendar->calendar_id);
         if ($calendar->magic_cookie != null) {
             $query->setVisibility('private-' . $calendar->magic_cookie);
         }
         $query->setProjection('full');
         $query->setEvent($eventId);
         $query->setParam('ctz', 'Etc/GMT');
         $query->setParam('hl', GCalendarUtil::getFrLanguage());
         $event = $service->getEntry($query, 'GCalendar_Entry');
         $event->setParam('gcid', $calendar->id);
         $event->setParam('gccolor', $calendar->color);
         $event->setParam('gcname', $calendar->name);
         return $event;
     } catch (Zend_Gdata_App_Exception $e) {
         JError::raiseWarning(200, $e->getMessage());
         return null;
     }
 }
    }
    if (GCalendarUtil::getComponentParameter('show_event_location', 1) == 1) {
        $loc = $event->get_location();
        if (!empty($loc)) {
            echo "<tr><td class=\"event_content_key\">" . JText::_('LOCATION') . ": </td><td>" . $loc . "</td></tr>\n";
            echo "<tr><td colspan=\"2\"><iframe width=\"100%\" height=\"300px\" frameborder=\"0\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" src=\"http://maps.google.com/maps?q=" . urlencode($loc) . "&amp;output=embed\"></iframe></td></tr>\n";
        }
    }
    $desc = preg_replace("@(src|href)=\"https?://@i", '\\1="', $event->get_description());
    if (GCalendarUtil::getComponentParameter('show_event_description', 1) == 1 && !empty($desc)) {
        echo "<tr><td class=\"event_content_key\">" . JText::_('DESCRIPTION') . ": </td><td>" . htmlspecialchars_decode(nl2br(preg_replace("@(((f|ht)tp:\\/\\/)[^\"\\'\\>\\s]+)@", '<a href="\\1" target="_blank">\\1</a>', $desc))) . "</td></tr>\n";
    }
    if (GCalendarUtil::getComponentParameter('show_event_author', 2) == 1) {
        $authors = $event->get_authors();
        if (count($authors) > 0) {
            $document->addScript(JURI::base() . 'components/com_gcalendar/hiddenviews/event/tmpl/default.js');
            echo "<tr><td class=\"event_content_key\">" . JText::_('AUTHOR') . ": </td><td style=\"valign:top\">" . $authors[0]->get_name() . " <a href=\"javascript:sdafgkl437jeeee('" . base64_encode(str_replace('@', '#', $authors[0]->get_email())) . "')\"><img height=\"11\" border=\"0\" width=\"16\" alt=\"email\" src=\"components/com_gcalendar/images/mail.png\"/></a></td></tr>\n";
        }
    }
    if (GCalendarUtil::getComponentParameter('show_event_copy_info', 1) == 1) {
        $urlText = 'action=TEMPLATE&amp;text=' . urlencode($event->get_title());
        $urlText .= '&amp;dates=' . strftime($copyDateTimeFormat, $event->get_start_date()) . '%2F' . strftime($copyDateTimeFormat, $event->get_end_date());
        $urlText .= '&amp;location=' . urlencode($event->get_location());
        $urlText .= '&amp;details=' . urlencode($event->get_description());
        $urlText .= '&amp;hl=' . GCalendarUtil::getFrLanguage() . '&amp;ctz=' . GCalendarUtil::getComponentParameter('timezone');
        $urlText .= '&amp;sf=true&amp;output=xml';
        echo "<tr><td class=\"event_content_key\">" . JText::_('COPY') . ": </td><td><a target=\"_blank\" href=\"http://www.google.com/calendar/render?" . $urlText . "\">" . JText::_('COPY_TO_MY_CALENDAR') . "</a></td></tr>\n";
    }
    echo "</table></div>\n";
}
echo "<div style=\"text-align:center;margin-top:10px\" id=\"gcalendar_powered\"><a href=\"http://g4j.laoneo.net\">Powered by GCalendar</a></div>\n";