protected function timeText($event, $timeOnly = false) { if ($timeOnly) { if ($event->get_end() - $event->get_start() == -1) { return DateFormatter::formatDate($event->get_start(), DateFormatter::NO_STYLE, DateFormatter::SHORT_STYLE); } else { return DateFormatter::formatDateRange($event->get_range(), DateFormatter::NO_STYLE, DateFormatter::SHORT_STYLE); } } else { return DateFormatter::formatDateRange($event->get_range(), DateFormatter::SHORT_STYLE, DateFormatter::SHORT_STYLE); } }
public static function timeText($event, $timeOnly = false) { if ($timeOnly) { if ($event->getEnd() - $event->getStart() == -1) { return DateFormatter::formatDate($event->getStart(), DateFormatter::NO_STYLE, DateFormatter::SHORT_STYLE); } else { return DateFormatter::formatDateRange($event->getRange(), DateFormatter::NO_STYLE, DateFormatter::SHORT_STYLE); } } else { return DateFormatter::formatDateRange($event->getRange(), DateFormatter::SHORT_STYLE, DateFormatter::SHORT_STYLE); } }
protected function linkForSchedule(KurogoObject $event, $data = null) { $subtitle = DateFormatter::formatDateRange($event->getRange(), DateFormatter::NO_STYLE, DateFormatter::SHORT_STYLE); $current = $this->getArg('time', time(), FILTER_VALIDATE_INT); $beginningOfDay = mktime(0, 0, 0, date('n', $current), date('j', $current)); $endOfDay = mktime(23, 59, 59, date('n', $current), date('j', $current)); $eventStart = $event->getStart(); $eventEnd = $event->getEnd(); if ($eventStart < $beginningOfDay) { // if starts more than one day before, put the date if ($eventStart < strtotime('-1 day', $beginningOfDay)) { $startDate = DateFormatter::formatDate($eventStart, DateFormatter::SHORT_STYLE, DateFormatter::NO_STYLE); } else { $startDate = $this->getLocalizedString('THE_PREVIOUS_DAY'); //'the previous day' } $subtitle = $this->getLocalizedString('IF_STARTS_EARLIER_DATE', $startDate) . $subtitle; } if ($eventEnd > $endOfDay) { // if ends more than one day after, put the date if ($eventEnd > strtotime('+1 day', $endOfDay)) { $endDate = DateFormatter::formatDate($eventEnd, DateFormatter::SHORT_STYLE, DateFormatter::NO_STYLE); } else { $endDate = $this->getLocalizedString('THE_FOLLOWING_DAY'); //'the following day' } $subtitle .= $this->getLocalizedString('IF_ENDS_LATER_DATE', $endDate); } $options = array('id' => $event->getID(), 'time' => $event->getStart()); if (isset($data['section'])) { $options['section'] = $data['section']; } if (isset($data['groupID'])) { $options['groupID'] = $data['groupID']; } $class = ''; if ($this->SHOW_EVENT_DETAILS) { $url = $this->buildBreadcrumbURL('schedule', $options, true); } else { $url = false; } if ($event->getRange()->contains(new TimeRange(time()))) { $class = 'open'; } else { $class = 'closed'; } return array('title' => $event->getTitle(), 'subtitle' => $subtitle, 'url' => $url, 'listclass' => $this->SHOW_HOURS_STATUS ? $class : null); }
public function getAllEmergencyNotices() { if ($this->emergencyNotices === NULL) { $now = time(); $this->emergencyNotices = array(); $items = $this->getData(); foreach ($items as $item) { if ($this->NOTICE_EXPIRATION && $now - $item->getPubTimestamp() > $this->NOTICE_EXPIRATION) { break; // items too old } $this->emergencyNotices[] = array('title' => $item->getTitle(), 'text' => $item->getDescription(), 'date' => DateFormatter::formatDate($item->getPubDate(), DateFormatter::MEDIUM_STYLE, DateFormatter::MEDIUM_STYLE), 'unixtime' => $item->getPubTimestamp()); if (isset($this->NOTICE_MAX_COUNT) && count($this->emergencyNotices) >= $this->NOTICE_MAX_COUNT) { break; // hit max count } } } return $this->emergencyNotices; }
protected function initializeForPage() { if (!Kurogo::getOptionalSiteVar('STATS_ENABLED', true)) { throw new KurogoException($this->getLocalizedString('STATS_DISABLED')); } if ($this->page == 'updateStats') { KurogoStats::exportStatsData(); $this->redirectTo('index'); } if ($this->getOptionalModuleVar('AUTO_UPDATE_STATS')) { KurogoStats::exportStatsData(); } $serviceTypes = $this->getServiceTypes(); $service = $this->getArg('service', 'web'); if (!array_key_exists($service, $serviceTypes)) { $service = 'web'; } $interval_types = $this->getIntervalTypes(); $interval = $this->getArg('interval', 'day'); if (!array_key_exists($interval, $interval_types)) { $interval = 'day'; } if ($interval == 'custom') { $start = $this->getArg('start'); $startTime = $start ? mktime(0, 0, 0, $start['Month'], $start['Day'], $start['Year']) : mktime(0, 0, 0); $end = $this->getArg('end', array()); $endTime = $end ? mktime(23, 59, 59, $end['Month'], $end['Day'], $end['Year']) : mktime(23, 59, 59); if ($endTime < $startTime) { $endTime = $startTime; } } else { $times = $this->getTimesForInterval($interval, $interval_types[$interval]['duration']); $startTime = $times['start']; $endTime = $times['end']; } $intervalOptions = array(); $args = $this->args; $args['service'] = $service; $args['interval'] = $interval; foreach ($interval_types as $interval_type => $type) { $args['interval'] = $interval_type; $intervalOptions[$interval_type] = array('title' => $type['title'], 'selected' => $interval_type == $interval, 'url' => $this->buildbreadcrumbURL($this->page, $args, false)); } $args = $this->args; $args['service'] = $service; $args['interval'] = $interval; foreach ($serviceTypes as $serviceType => $serviceTypeTitle) { $args['service'] = $serviceType; $serviceOptions[$serviceType] = array('title' => $serviceTypeTitle, 'selected' => $service == $serviceType, 'url' => $this->buildbreadcrumbURL($this->page, $args, false)); } $this->assign('starttime', $startTime); $this->assign('endtime', $endTime); $this->assign('statsService', $service); $this->assign('interval', $interval); $this->assign('intervalOptions', $intervalOptions); $this->assign('serviceOptions', $serviceOptions); $this->assign('intervalTabclass', count($interval_types) == 4 ? 'fourtabs' : 'threetabs'); $this->assign('serviceTabclass', 'twotabs'); $commonData = array('service' => $service, 'start' => $startTime, 'end' => $endTime); if ($date = KurogoStats::getLastDateFromSummary()) { includePackage('DateTime'); $date = new DateTime($date); $this->assign('lastUpdated', DateFormatter::formatDate($date, DateFormatter::LONG_STYLE, DateFormatter::NO_STYLE)); } switch ($this->page) { case 'index': //get config $chartsConfig = $this->getModuleSections('stats-index'); $charts = array(); foreach ($chartsConfig as $chartIndex => $chartData) { try { $charts[] = $this->prepareChart(array_merge($chartData, $commonData), $interval); } catch (KurogoStatsConfigurationException $e) { $this->redirectTo('statsconfigerror', array('chart' => $chartData['title'])); } } $this->assign('charts', $charts); break; case 'detail': if (!($group = $this->getArg('group'))) { $this->redirectTo('index'); } if (!(${$group} = $this->getArg($group))) { $this->redirectTo('index'); } if (!($chartsConfig = $this->getChartsConfig($group, ${$group}))) { $this->redirectTo('index'); } $charts = array(); $commonData[$group] = ${$group}; foreach ($chartsConfig as $chartIndex => $chartData) { try { $charts[] = $this->prepareChart(array_merge($chartData, $commonData), $interval); } catch (KurogoStatsConfigurationException $e) { $this->redirectTo('statsconfigerror', array('chart' => $chartData['title'])); } } $this->setPageTitle(sprintf("Stats for %s", ${$group})); $this->assign('charts', $charts); break; case 'statsconfigerror': $this->assign('chart', $this->getArg('chart')); break; } }
protected function timeText($photo, $timeOnly = false) { includePackage('Calendar'); return DateFormatter::formatDate($photo->getPublished(), DateFormatter::SHORT_STYLE, DateFormatter::SHORT_STYLE); }
protected function elapsedTime($timestamp) { $now = time(); $diff = $now - $timestamp; $today = mktime(0, 0, 0); $today_timestamp = mktime(0, 0, 0, date('m', $timestamp), date('d', $timestamp), date('Y', $timestamp)); $date = new DateTime("@" . $timestamp); Kurogo::includePackage('DateTime'); if ($diff > 0) { // more than 6 days if ($today - $today_timestamp > 518400) { return DateFormatter::formatDate($date, DateFormatter::MEDIUM_STYLE, DateFormatter::NO_STYLE); } elseif ($today - $today_timestamp > 86400) { // up to 6 days // @TODO localize return sprintf("%d days ago", $diff / 86400); } elseif ($today - $today_timestamp > 0) { // yesterday // @TODO localize return strftime('Yesterday @ %l:%M %p', $timestamp); } elseif ($diff > 3600) { // @TODO localize return sprintf("%d hour%s ago", $diff / 3600, intval($diff / 3600) > 1 ? 's' : ''); } elseif ($diff > 60) { // @TODO localize return sprintf("%d minute%s ago", $diff / 60, intval($diff / 60) > 1 ? 's' : ''); } else { // @TODO localize return sprintf("%d second%s ago", $diff, $diff > 1 ? 's' : ''); } } else { return DateFormatter::formatDate($date, DateFormatter::MEDIUM_STYLE, DateFormatter::MEDIUM_STYLE); } }
protected function initializeForPage() { if (!$this->feed) { throw new KurogoConfigurationException($this->getLocalizedString('ERROR_NOT_CONFIGURED')); } switch ($this->page) { case 'story': $searchTerms = $this->getArg('filter', false); if ($searchTerms) { $this->feed->setOption('search', $searchTerms); } $storyID = $this->getArg('storyID', false); $storyPage = $this->getArg('storyPage', '0'); $story = $this->feed->getItem($storyID); if (!$story) { throw new KurogoUserException($this->getLocalizedString('ERROR_STORY_NOT_FOUND', $storyID)); } $this->setLogData($storyID, $story->getTitle()); if (!($content = $this->cleanContent($story->getContent()))) { if ($url = $story->getLink()) { Kurogo::redirectToURL($url); } // no content or link. Attempt to get description if (!($content = $story->getDescription())) { throw new KurogoDataException($this->getLocalizedString('ERROR_CONTENT_NOT_FOUND', $storyID)); } } if ($this->getOptionalModuleVar('SHARING_ENABLED', 1)) { $body = $story->getDescription() . "\n\n" . $story->getLink(); $shareEmailURL = $this->buildMailToLink("", $story->getTitle(), $body); $this->assign('shareTitle', $this->getLocalizedString('SHARE_THIS_STORY')); $this->assign('shareEmailURL', $shareEmailURL); $this->assign('shareRemark', $story->getTitle()); $this->assign('storyURL', $story->getLink()); } if ($pubDate = $story->getPubDate()) { $date = DateFormatter::formatDate($pubDate, DateFormatter::LONG_STYLE, DateFormatter::NO_STYLE); } else { $date = ""; } $this->enablePager($content, $this->feed->getEncoding(), $storyPage); $this->assign('date', $date); $this->assign('title', $this->htmlEncodeFeedString($story->getTitle())); $this->assign('author', $this->htmlEncodeFeedString($story->getAuthor())); $this->assign('image', $this->getImageForStory($story)); $this->assign('link', $story->getLink()); $this->assign('ajax', $this->getArg('ajax')); $this->assign('showLink', $this->showLink); $this->assign('showBodyThumbnail', $this->showBodyThumbnail); break; case 'search': $searchTerms = $this->getArg('filter'); $start = $this->getArg('start', 0); if ($searchTerms) { $options = array('start' => $start); $items = $this->searchItems($searchTerms, $this->maxPerPage, $options); $this->setLogData($searchTerms); $totalItems = $this->feed->getTotalItems(); $stories = array(); $options = array('filter' => $searchTerms, 'section' => $this->feedIndex); foreach ($items as $story) { $stories[] = $this->linkForItem($story, $options); } $previousURL = ''; $nextURL = ''; if ($totalItems > $this->maxPerPage) { $args = $this->args; if ($start > 0) { $args['start'] = $start - $this->maxPerPage; $previousURL = $this->buildBreadcrumbURL($this->page, $args, false); } if ($totalItems - $start > $this->maxPerPage) { $args['start'] = $start + $this->maxPerPage; $nextURL = $this->buildBreadcrumbURL($this->page, $args, false); } } $extraArgs = array('section' => $this->feedIndex); $this->addInternalJavascript('/common/javascript/lib/ellipsizer.js'); $this->addOnLoad('setupNewsListing();'); $this->assign('maxPerPage', $this->maxPerPage); $this->assign('extraArgs', $extraArgs); $this->assign('searchTerms', $searchTerms); $this->assign('stories', $stories); $this->assign('previousURL', $previousURL); $this->assign('nextURL', $nextURL); $this->assign('showImages', $this->showImages); $this->assign('showPubDate', $this->showPubDate); $this->assign('showAuthor', $this->showAuthor); } else { $this->redirectTo('index'); // search was blank } break; case 'pane': if ($this->ajaxContentLoad) { $start = 0; if ($this->legacyController) { $items = $this->feed->items($start, $this->maxPerPane); } else { $this->feed->setStart(0); $this->feed->setLimit($this->maxPerPane); $items = $this->feed->items(); } $stories = array(); $options = array('noBreadcrumbs' => true, 'section' => $this->feedIndex); foreach ($items as $story) { $stories[] = $this->linkForItem($story, $options); } foreach ($stories as $i => $story) { $stories[$i]['url'] = $this->buildURL('index') . '#' . urlencode(FULL_URL_PREFIX . ltrim($story['url'], '/')); } $this->assign('stories', $stories); } $this->addInternalJavascript('/common/javascript/lib/ellipsizer.js'); $this->addInternalJavascript('/common/javascript/lib/paneStories.js'); break; case 'index': $start = $this->getArg('start', 0); if ($this->legacyController) { $items = $this->feed->items($start, $this->maxPerPage); } else { $this->feed->setStart($start); $this->feed->setLimit($this->maxPerPage); $items = $this->feed->items(); } $totalItems = $this->feed->getTotalItems(); $this->setLogData($this->feedIndex, $this->feed->getTitle()); $previousURL = null; $nextURL = null; if ($totalItems > $this->maxPerPage) { $args = $this->args; if ($start > 0) { $args['start'] = $start - $this->maxPerPage; $previousURL = $this->buildBreadcrumbURL($this->page, $args, false); } if ($totalItems - $start > $this->maxPerPage) { $args['start'] = $start + $this->maxPerPage; $nextURL = $this->buildBreadcrumbURL($this->page, $args, false); } } $options = array('section' => $this->feedIndex); $stories = array(); foreach ($items as $story) { $stories[] = $this->linkForItem($story, $options); } $sections = array(); foreach ($this->feeds as $index => $feedData) { $sections[] = array('value' => $index, 'title' => $feedData['TITLE'], 'selected' => $this->feedIndex == $index, 'url' => $this->feedURL($index, false)); } $hiddenArgs = array('section' => $this->feedIndex); $this->addInternalJavascript('/common/javascript/lib/ellipsizer.js'); $this->addOnLoad('setupNewsListing();'); $this->assign('maxPerPage', $this->maxPerPage); $this->assign('hiddenArgs', $hiddenArgs); $this->assign('sections', $sections); $this->assign('currentSection', $sections[$this->feedIndex]); $this->assign('placeholder', $this->getLocalizedString('SEARCH_MODULE', $this->getModuleName())); $this->assign('stories', $stories); $this->assign('isHome', true); $this->assign('previousURL', $previousURL); $this->assign('nextURL', $nextURL); $this->assign('showImages', $this->showImages); $this->assign('showPubDate', $this->showPubDate); $this->assign('showAuthor', $this->showAuthor); break; } }
protected function initializeForPage() { switch ($this->page) { case 'index': $links = array(array('title' => 'Text', 'url' => $this->buildBreadcrumbURL('text', array())), array('title' => 'Navigation Lists', 'url' => $this->buildBreadcrumbURL('nav', array())), array('title' => 'Results Lists', 'url' => $this->buildBreadcrumbURL('results', array())), array('title' => 'Search', 'url' => $this->buildBreadcrumbURL('search', array())), array('title' => 'Detail', 'url' => $this->buildBreadcrumbURL('detail', array())), array('title' => 'Geolocation', 'url' => $this->buildBreadcrumbURL('location', array())), array('title' => 'HTML Truncation Form', 'url' => $this->buildBreadcrumbURL('truncate', array())), array('title' => 'Javascript API Call Test', 'url' => $this->buildBreadcrumbURL('apicall', array()))); if ($this->browser == 'native') { $appQLinks = array(array('title' => 'Dialogs', 'url' => $this->buildBreadcrumbURL('dialogs', array())), array('title' => 'Refresh Button', 'url' => $this->buildBreadcrumbURL('refresh', array())), array('title' => 'Auto Refresh', 'url' => $this->buildBreadcrumbURL('autorefresh', array()))); $this->assign('appQLinks', $appQLinks); } $this->assign('links', $links); break; case 'text': break; case 'apicall': break; case 'search': $formFields = $this->loadPageConfigArea($this->page, false); foreach ($formFields as $i => $formField) { if (isset($formField['option_keys'])) { $options = array(); foreach ($formField['option_keys'] as $j => $optionKey) { $options[$optionKey] = $formField['option_values'][$j]; } $formFields[$i]['options'] = $options; unset($formFields[$i]['option_keys']); unset($formFields[$i]['option_values']); } } $this->assign('formFields', $formFields); break; case 'results': if ($title = $this->getArg('title')) { $this->setPageTitles($title); } $this->assign('next', 'Next'); $this->assign('prev', 'Prev'); $this->assign('nextURL', $this->buildBreadcrumbURL($this->page, $this->args, false)); $this->assign('prevURL', $this->buildBreadcrumbURL($this->page, $this->args, false)); $this->assign('lists', $this->getListsForPage($this->page)); break; case 'nav': if ($title = $this->getArg('title')) { $this->setPageTitles($title); } $this->assign('lists', $this->getListsForPage($this->page)); break; case 'pane': $this->assign('lists', $this->getListsForPage($this->page)); break; case 'articles': $this->setWebBridgePageRefresh(true); $this->addInternalJavascript('/common/javascript/lib/ellipsizer.js'); $this->addOnLoad('setupListing();'); $this->assign('articles', $this->getListsForPage($this->page)); break; case 'detail': $detailConfig = $this->loadPageConfigArea('detail', 'detailConfig'); if ($this->getOptionalModuleVar('SHARING_ENABLED', 1)) { $this->assign('shareTitle', $this->getLocalizedString('SHARE_THIS_ITEM')); $this->assign('shareEmailURL', '*****@*****.**'); $this->assign('shareRemark', 'This is a share remark'); $this->assign('shareURL', 'This is a share URL'); } if ($this->getOptionalModuleVar('BOOKMARKS_ENABLED', 1)) { $this->generateBookmarkOptions('fakeid'); } $this->enableTabs(array_keys($detailConfig['tabs'])); break; case 'dialogs': $buttons = array(); $configs = $this->loadPageConfigArea($this->page, false); foreach ($configs as $config) { if (!isset($config['title'], $config['description'], $config['api'], $config['arguments'])) { continue; } $buttons[] = array('title' => $config['title'], 'description' => $config['description'], 'javascript' => "kgoBridge.{$config['api']}(" . implode(', ', $config['arguments']) . ", null, function (error, params) { alert('You clicked button type \\''+params['button']+'\\''); }); return false;"); } $this->assign('buttons', $buttons); break; case 'location': $links = array(array('title' => 'Watch Position Map Test', 'url' => $this->buildBreadcrumbURL('location_full', array()))); $this->assign('links', $links); break; case 'location_full': $this->addExternalJavascript('http://maps.googleapis.com/maps/api/js?sensor=true'); $this->addOnLoad('initMap();'); $this->addInlineJavascript('var locationMarkerURL = "' . FULL_URL_PREFIX . 'common/images/map-location.png";'); break; case 'truncate': $this->assign('action', $this->buildBreadcrumbURL('truncated', array())); break; case 'truncated': $length = $this->getArg('length', 0); $margin = $this->getArg('margin', 0); $minLineLength = $this->getArg('minLineLength', 40); $html = $this->getArg('html', ''); if ($length && $margin && $html) { $html = Sanitizer::sanitizeAndTruncateHTML($html, $truncated, $length, $margin, $minLineLength); } $this->assign('html', $html); break; case 'autorefresh': $links = array(array('title' => 'Detail', 'url' => $this->buildBreadcrumbURL('detail', array()))); $this->assign('links', $links); // fallthrough // fallthrough case 'refresh': $now = new DateTime(); $this->assign('lastUpdated', DateFormatter::formatDate($now, DateFormatter::MEDIUM_STYLE, DateFormatter::MEDIUM_STYLE)); break; } }
protected function initializeForPage() { switch ($this->page) { case 'news': $start = $this->getArg('start', 0); $section = $this->getArg('section'); $newsFeed = $this->getNewsFeed($section); $newsFeed->setStart($start); $newsFeed->setLimit($this->maxPerPage); $items = $newsFeed->items(); $totalItems = $newsFeed->getTotalItems(); $this->setLogData($section, $newsFeed->getTitle()); $previousURL = null; $nextURL = null; if ($totalItems > $this->maxPerPage) { $args = $this->args; if ($start > 0) { $args['start'] = $start - $this->maxPerPage; $previousURL = $this->buildBreadcrumbURL($this->page, $args, false); } if ($totalItems - $start > $this->maxPerPage) { $args['start'] = $start + $this->maxPerPage; $nextURL = $this->buildBreadcrumbURL($this->page, $args, false); } } $options = array('section' => $section); $stories = array(); foreach ($items as $story) { $stories[] = $this->linkForNewsItem($story, $options); } $this->addInternalJavascript('/common/javascript/lib/ellipsizer.js'); $this->addOnLoad('setupNewsListing();'); $this->assign('maxPerPage', $this->maxPerPage); $this->assign('stories', $stories); $this->assign('previousURL', $previousURL); $this->assign('nextURL', $nextURL); $this->assign('showImages', $this->showImages); $this->assign('showPubDate', $this->showPubDate); $this->assign('showAuthor', $this->showAuthor); break; case 'news_detail': $section = $this->getArg('section'); $gender = $this->getArg('gender'); $storyID = $this->getArg('storyID', false); $storyPage = $this->getArg('storyPage', '0'); $feed = $this->getNewsFeed($section, $gender); if (!($story = $feed->getItem($storyID))) { throw new KurogoUserException($this->getLocalizedString('ERROR_STORY_NOT_FOUND', $storyID)); } $this->setLogData($storyID, $story->getTitle()); if (!($content = $this->cleanContent($story->getContent()))) { if ($url = $story->getLink()) { Kurogo::redirectToURL($url); } else { throw new KurogoDataException($this->getLocalizedString('ERROR_CONTENT_NOT_FOUND', $storyID)); } } if ($this->getOptionalModuleVar('SHARING_ENABLED', 1)) { $body = $story->getDescription() . "\n\n" . $story->getLink(); $shareEmailURL = $this->buildMailToLink("", $story->getTitle(), $body); $this->assign('shareTitle', $this->getLocalizedString('SHARE_THIS_STORY')); $this->assign('shareEmailURL', $shareEmailURL); $this->assign('shareRemark', $story->getTitle()); $this->assign('storyURL', $story->getLink()); } if ($pubDate = $story->getPubDate()) { $date = DateFormatter::formatDate($pubDate, DateFormatter::MEDIUM_STYLE, DateFormatter::NO_STYLE); } else { $date = ""; } $this->enablePager($content, $this->newsFeed->getEncoding(), $storyPage); $this->assign('date', $date); $this->assign('title', $this->htmlEncodeFeedString($story->getTitle())); $this->assign('author', $this->htmlEncodeFeedString($story->getAuthor())); $this->assign('image', $this->getImageForStory($story)); $this->assign('link', $story->getLink()); $this->assign('showLink', $this->showLink); break; case 'search': $searchTerms = $this->getArg('filter'); $start = $this->getArg('start', 0); $section = $this->getArg('section'); if ($searchTerms) { $newsFeed = $this->getNewsFeed($section); $newsFeed->setStart($start); $newsFeed->setLimit($this->maxPerPage); $items = $newsFeed->search($searchTerms); $this->setLogData($searchTerms); $totalItems = $newsFeed->getTotalItems(); $stories = array(); $options = array('start' => $start, 'filter' => $searchTerms, 'section' => $section); foreach ($items as $story) { $stories[] = $this->linkForNewsItem($story, $options); } $previousURL = ''; $nextURL = ''; if ($totalItems > $this->maxPerPage) { $args = $this->args; if ($start > 0) { $args['start'] = $start - $this->maxPerPage; $previousURL = $this->buildBreadcrumbURL($this->page, $args, false); } if ($totalItems - $start > $this->maxPerPage) { $args['start'] = $start + $this->maxPerPage; $nextURL = $this->buildBreadcrumbURL($this->page, $args, false); } } $extraArgs = array('section' => $section); $this->addInternalJavascript('/common/javascript/lib/ellipsizer.js'); $this->addOnLoad('setupNewsListing();'); $this->assign('maxPerPage', $this->maxPerPage); $this->assign('extraArgs', $extraArgs); $this->assign('searchTerms', $searchTerms); $this->assign('stories', $stories); $this->assign('previousURL', $previousURL); $this->assign('nextURL', $nextURL); $this->assign('showImages', $this->showImages); $this->assign('showPubDate', $this->showPubDate); $this->assign('showAuthor', $this->showAuthor); } else { $this->redirectTo('index'); // search was blank } break; case 'schedule': $sport = $this->getArg('sport', ''); $sportData = $this->getSportData($sport); if ($scheduleFeed = $this->getScheduleFeed($sport)) { $scheduleItems = array(); $options = array('sport' => $sport); if ($events = $scheduleFeed->items()) { foreach ($events as $event) { $scheduleItems[] = $this->linkForScheduleItem($event, $options); } } $this->assign('scheduleItems', $scheduleItems); } break; case 'schedule_detail': $sport = $this->getArg('sport', ''); $id = $this->getArg('id', ''); $sportData = $this->getSportData($sport); $scheduleFeed = $this->getScheduleFeed($sport); if ($schedule = $scheduleFeed->getItem($id)) { $this->assign('schedule', $schedule); } else { throw new KurogoDataException($this->getLocalizedString('ERROR_EVENT_NOT_FOUND')); } $this->setLogData($sport . ':' . $schedule->getID(), $schedule->getSport()); $fields = $this->formatScheduleDetail($schedule); $schedule = $this->getFieldsForSechedule($schedule); $this->assign('schedule', $schedule); $this->assign('fields', $fields); break; case 'sport': $sport = $this->getArg('sport', ''); $previous = array(); $next = array(); $sportData = $this->getSportData($sport); $this->assign('sportTitle', $sportData['GENDER_TITLE']); $this->setPageTitles($sportData['GENDER_TITLE']); if ($scheduleFeed = $this->getScheduleFeed($sport)) { $scheduleItems = array(); if ($previousEvent = $scheduleFeed->getPreviousEvent()) { $previous = $this->linkForScheduleItem($previousEvent, array('sport' => $sport)); $scheduleItems[] = $previous; } if ($nextEvent = $scheduleFeed->getNextEvent()) { $next = $this->linkForScheduleItem($nextEvent, array('sport' => $sport)); $this->assign('next', $next); $scheduleItems[] = $next; } $scheduleItems[] = array('title' => $this->getLocalizedString('FULL_SCHEDULE_TEXT'), 'url' => $this->buildBreadcrumbURL('schedule', array('sport' => $sport), true)); $this->assign('scheduleItems', $scheduleItems); } if ($newsFeed = $this->getNewsFeed($sport)) { $start = $this->getArg('start', 0); $newsFeed->setStart($start); $newsFeed->setLimit($this->maxPerPage); $items = $newsFeed->items(); $totalItems = $newsFeed->getTotalItems(); $this->setLogData($sport, $newsFeed->getTitle()); $previousURL = null; $nextURL = null; if ($totalItems > $this->maxPerPage) { $args = $this->args; if ($start > 0) { $args['start'] = $start - $this->maxPerPage; $previousURL = $this->buildBreadcrumbURL($this->page, $args, false); } if ($totalItems - $start > $this->maxPerPage) { $args['start'] = $start + $this->maxPerPage; $nextURL = $this->buildBreadcrumbURL($this->page, $args, false); } } $options = array('section' => $sport); $newsItems = array(); foreach ($items as $story) { $newsItems[] = $this->linkForNewsItem($story, $options); } $this->addInternalJavascript('/common/javascript/lib/ellipsizer.js'); $this->addOnLoad('setupNewsListing();'); $this->assign('newsItems', $newsItems); $this->assign('maxPerPage', $this->maxPerPage); $this->assign('previousURL', $previousURL); $this->assign('nextURL', $nextURL); $this->assign('showImages', $this->showImages); $this->assign('showPubDate', $this->showPubDate); $this->assign('showAuthor', $this->showAuthor); } // Bookmark if ($this->getOptionalModuleVar('BOOKMARKS_ENABLED', 1)) { $cookieParams = array('sport' => $sport); $cookieID = http_build_query($cookieParams); $this->generateBookmarkOptions($cookieID); } break; case "index": $tabs = array(); //get top news if ($newsFeedData = $this->getNavData('topnews')) { $start = $this->getArg('start', 0); $newsFeed = $this->getNewsFeed('topnews'); $newsFeed->setStart($start); $newsFeed->setLimit($this->maxPerPage); $items = $newsFeed->items(); $totalItems = $newsFeed->getTotalItems(); $this->setLogData('topnews', $newsFeed->getTitle()); $previousURL = null; $nextURL = null; if ($totalItems > $this->maxPerPage) { //$args = $this->args; $args = array(); if ($start > 0) { $args['start'] = $start - $this->maxPerPage; $previousURL = $this->buildURL('index', $args); } if ($totalItems - $start > $this->maxPerPage) { $args['start'] = $start + $this->maxPerPage; $nextURL = $this->buildURL('index', $args); } } $topNews = array(); $options = array('section' => 'topnews'); foreach ($items as $story) { $topNews[] = $this->linkForNewsItem($story, $options); } $extraArgs = array('section' => 'topnews'); $this->addInternalJavascript('/common/javascript/lib/ellipsizer.js'); $this->addOnLoad('setupNewsListing();'); $tabs[] = 'topnews'; $this->assign('topNewsTitle', $newsFeedData['TITLE']); $this->assign('topNews', $topNews); $this->assign('extraArgs', $extraArgs); $this->assign('maxPerPage', $this->maxPerPage); $this->assign('previousURL', $previousURL); $this->assign('nextURL', $nextURL); $this->assign('showImages', $this->showImages); $this->assign('showPubDate', $this->showPubDate); $this->assign('showAuthor', $this->showAuthor); } //get sports for each gender foreach (array('men', 'women', 'coed') as $gender) { $sportsData = $this->getNavData($gender); if ($sportsData) { if ($sportsConfig = $this->getSportsForGender($gender)) { $sports = array(); foreach ($sportsConfig as $key => $sportData) { $image = "modules/{$this->configModule}/images/" . (isset($sportData['ICON']) ? $sportData['ICON'] : strtolower($sportData['TITLE'])) . $this->imageExt; $sport = array('title' => $sportData['TITLE'], 'img' => $image, 'url' => $this->buildURL('sport', array('sport' => $key))); $sports[] = $sport; } $tabs[] = $gender; $this->assign($gender . 'SportsTitle', $sportsData['TITLE']); $this->assign($gender . 'Sports', $sports); } } } $bookmarkData = $this->getNavData('bookmarks'); //get bookmarks $bookmarks = array(); if ($this->getOptionalModuleVar('BOOKMARKS_ENABLED', 1)) { $bookmarksData = $this->getBookmarks(); foreach ($bookmarksData as $bookmark) { parse_str(stripslashes($bookmark), $params); if (isset($params['sport']) && ($sportData = $this->getSportData($params['sport']))) { $bookmarks[] = array('title' => $sportData['GENDER_TITLE'], 'url' => $this->buildURL('sport', array('sport' => $params['sport']))); } } $tabs[] = 'bookmarks'; } $this->assign('placeholder', $this->getLocalizedString('SEARCH_TEXT')); $this->assign('bookmarksTitle', $bookmarkData['TITLE']); $this->assign('bookmarks', $bookmarks); $this->assign('tabs', $tabs); $this->enableTabs($tabs); break; case 'pane': if ($this->ajaxContentLoad) { $section = 'topnews'; $newsFeed = $this->getNewsFeed($section); $newsFeed->setStart(0); $newsFeed->setLimit($this->maxPerPage); $items = $newsFeed->items(); $this->setLogData($section, $newsFeed->getTitle()); $stories = array(); foreach ($items as $item) { $stories[] = $this->linkForNewsItem($item, array('section' => $section)); } $this->assign('stories', $stories); } $this->addInternalJavascript('/common/javascript/lib/ellipsizer.js'); $this->addInternalJavascript('/common/javascript/lib/paneStories.js'); break; } }
protected function initializeForPage() { switch ($this->page) { case 'news': $start = $this->getArg('start', 0); $section = $this->getArg('section'); $newsFeed = $this->getNewsFeed($section); $newsFeed->setStart($start); $newsFeed->setLimit($this->maxPerPage); $items = $newsFeed->items(); $totalItems = $newsFeed->getTotalItems(); $this->setLogData($section, $newsFeed->getTitle()); $previousURL = null; $nextURL = null; if ($totalItems > $this->maxPerPage) { $args = $this->args; if ($start > 0) { $args['start'] = $start - $this->maxPerPage; $previousURL = $this->buildBreadcrumbURL($this->page, $args, false); } if ($totalItems - $start > $this->maxPerPage) { $args['start'] = $start + $this->maxPerPage; $nextURL = $this->buildBreadcrumbURL($this->page, $args, false); } } $options = array('section' => $section); $stories = array(); foreach ($items as $story) { $stories[] = $this->linkForNewsItem($story, $options); } $this->addInternalJavascript('/common/javascript/lib/ellipsizer.js'); $this->addOnLoad('setupNewsListing();'); $this->assign('maxPerPage', $this->maxPerPage); $this->assign('stories', $stories); $this->assign('previousURL', $previousURL); $this->assign('nextURL', $nextURL); $this->assign('showImages', $this->showImages); $this->assign('showPubDate', $this->showPubDate); $this->assign('showAuthor', $this->showAuthor); break; case 'news_detail': $section = $this->getArg('section'); $gender = $this->getArg('gender'); $storyID = $this->getArg('storyID', false); $storyPage = $this->getArg('storyPage', '0'); $feed = $this->getNewsFeed($section, $gender); $showBodyThumbnail = $this->getOptionalModuleVar('SHOW_BODY_THUMBNAIL', $this->showBodyThumbnail, $section, 'feeds'); if (!($story = $feed->getItem($storyID))) { throw new KurogoUserException($this->getLocalizedString('ERROR_STORY_NOT_FOUND', $storyID)); } $this->setLogData($storyID, $story->getTitle()); if (!($content = $this->cleanContent($story->getContent()))) { if ($url = $story->getLink()) { Kurogo::redirectToURL($url); } else { throw new KurogoDataException($this->getLocalizedString('ERROR_CONTENT_NOT_FOUND', $storyID)); } } if ($this->getOptionalModuleVar('SHARING_ENABLED', 1)) { $body = Sanitizer::sanitizeAndTruncateHTML($story->getDescription(), $truncated, $this->getOptionalModuleVar('SHARE_EMAIL_DESC_MAX_LENGTH', 500), $this->getOptionalModuleVar('SHARE_EMAIL_DESC_MAX_LENGTH_MARGIN', 50), $this->getOptionalModuleVar('SHARE_EMAIL_DESC_MIN_LINE_LENGTH', 50), '') . "\n\n" . $story->getLink(); $shareEmailURL = $this->buildMailToLink("", $story->getTitle(), $body); $this->assign('shareTitle', $this->getLocalizedString('SHARE_THIS_STORY')); $this->assign('shareEmailURL', $shareEmailURL); $this->assign('shareRemark', $story->getTitle()); $this->assign('storyURL', $story->getLink()); } if ($pubDate = $story->getPubDate()) { $date = DateFormatter::formatDate($pubDate, DateFormatter::MEDIUM_STYLE, DateFormatter::NO_STYLE); } else { $date = ""; } $this->enablePager($content, $this->newsFeed->getEncoding(), $storyPage); $this->assign('date', $date); $this->assign('title', $this->htmlEncodeFeedString($story->getTitle())); $this->assign('author', $this->htmlEncodeFeedString($story->getAuthor())); $this->assign('image', $this->getImageForStory($story)); $this->assign('thumbnail', $this->getThumbnailForStory($story)); $this->assign('showBodyThumbnail', $showBodyThumbnail); $this->assign('link', $story->getLink()); $this->assign('showLink', $this->showLink); break; case 'search': $searchTerms = $this->getArg('filter'); $start = $this->getArg('start', 0); $section = $this->getArg('section', 'topnews'); if ($searchTerms) { $newsFeed = $this->getNewsFeed($section); $newsFeed->setStart($start); $newsFeed->setLimit($this->maxPerPage); $items = $newsFeed->search($searchTerms); $this->setLogData($searchTerms); $totalItems = $newsFeed->getTotalItems(); $stories = array(); $options = array('start' => $start, 'filter' => $searchTerms, 'section' => $section); foreach ($items as $story) { $stories[] = $this->linkForNewsItem($story, $options); } $previousURL = ''; $nextURL = ''; if ($totalItems > $this->maxPerPage) { $args = $this->args; if ($start > 0) { $args['start'] = $start - $this->maxPerPage; $previousURL = $this->buildBreadcrumbURL($this->page, $args, false); } if ($totalItems - $start > $this->maxPerPage) { $args['start'] = $start + $this->maxPerPage; $nextURL = $this->buildBreadcrumbURL($this->page, $args, false); } } $extraArgs = array('section' => $section); $this->addInternalJavascript('/common/javascript/lib/ellipsizer.js'); $this->addOnLoad('setupNewsListing();'); $this->assign('maxPerPage', $this->maxPerPage); $this->assign('extraArgs', $extraArgs); $this->assign('searchTerms', $searchTerms); $this->assign('stories', $stories); $this->assign('previousURL', $previousURL); $this->assign('nextURL', $nextURL); $this->assign('showImages', $this->showImages); $this->assign('showPubDate', $this->showPubDate); $this->assign('showAuthor', $this->showAuthor); } else { $this->redirectTo('index'); // search was blank } break; case 'schedule': $sport = $this->getArg('sport', ''); $sportData = $this->getSportData($sport); if ($scheduleFeed = $this->getScheduleFeed($sport)) { $scheduleItems = array(); $options = array('sport' => $sport); if ($events = $scheduleFeed->items()) { foreach ($events as $event) { $scheduleItems[] = $this->linkForScheduleItem($event, $options); } } $this->assign('scheduleItems', $scheduleItems); } break; case 'schedule_detail': $sport = $this->getArg('sport', ''); if ($sport == '') { $sport = 'allschedule'; } $id = $this->getArg('id', ''); // $sportData = $this->getSportData($sport); $scheduleFeed = $this->getScheduleFeed($sport); if ($schedule = $scheduleFeed->getItem($id)) { $this->assign('schedule', $schedule); } else { throw new KurogoDataException($this->getLocalizedString('ERROR_EVENT_NOT_FOUND')); } $this->setLogData($sport . ':' . $schedule->getID(), $schedule->getSport()); $fields = $this->formatScheduleDetail($schedule); $schedule = $this->getFieldsForSchedule($schedule); $this->assign('schedule', $schedule); $this->assign('fields', $fields); break; case 'sport': $sport = $this->getArg('sport', ''); $previous = array(); $next = array(); $sportData = $this->getSportData($sport); $this->assign('sportTitle', $sportData['GENDER_TITLE']); $this->setPageTitles($sportData['GENDER_TITLE']); if ($scheduleFeed = $this->getScheduleFeed($sport)) { $scheduleItems = array(); if ($previousEvent = $scheduleFeed->getPreviousEvent()) { $previous = $this->linkForScheduleItem($previousEvent, array('sport' => $sport)); $scheduleItems[] = $previous; } if ($nextEvent = $scheduleFeed->getNextEvent()) { $next = $this->linkForScheduleItem($nextEvent, array('sport' => $sport)); $this->assign('next', $next); $scheduleItems[] = $next; } $scheduleItems[] = array('title' => $this->getLocalizedString('FULL_SCHEDULE_TEXT'), 'url' => $this->buildBreadcrumbURL('schedule', array('sport' => $sport), true)); $this->assign('scheduleItems', $scheduleItems); } if ($newsFeed = $this->getNewsFeed($sport)) { $start = $this->getArg('start', 0); $newsFeed->setStart($start); $newsFeed->setLimit($this->maxPerPage); $items = $newsFeed->items(); $totalItems = $newsFeed->getTotalItems(); $this->setLogData($sport, $newsFeed->getTitle()); $previousURL = null; $nextURL = null; if ($totalItems > $this->maxPerPage) { $args = $this->args; if ($start > 0) { $args['start'] = $start - $this->maxPerPage; $previousURL = $this->buildBreadcrumbURL($this->page, $args, false); } if ($totalItems - $start > $this->maxPerPage) { $args['start'] = $start + $this->maxPerPage; $nextURL = $this->buildBreadcrumbURL($this->page, $args, false); } } $options = array('section' => $sport); $newsItems = array(); foreach ($items as $story) { $newsItems[] = $this->linkForNewsItem($story, $options); } $this->addInternalJavascript('/common/javascript/lib/ellipsizer.js'); $this->addOnLoad('setupNewsListing();'); $this->assign('newsItems', $newsItems); $this->assign('maxPerPage', $this->maxPerPage); $this->assign('previousURL', $previousURL); $this->assign('nextURL', $nextURL); $this->assign('showImages', $this->showImages); $this->assign('showPubDate', $this->showPubDate); $this->assign('showAuthor', $this->showAuthor); } // Bookmark if ($this->getOptionalModuleVar('BOOKMARKS_ENABLED', 1)) { $cookieParams = array('sport' => $sport); $cookieID = http_build_query($cookieParams); $this->generateBookmarkOptions($cookieID); } break; case "index": $tabs = array(); $latestSubTab = $this->getArg('newsTab', 'topnews'); // used to distinguish between top news and schedule $latestSubTabLinks = array(); // will add 'Latest' subTab items to this array //get top news if ($newsFeedData = $this->getNavData('topnews')) { $start = $this->getArg('start', 0); $newsFeed = $this->getNewsFeed('topnews'); $newsFeed->setStart($start); $newsFeed->setLimit($this->maxPerPage); $newsTab = array('id' => 'topnews', 'title' => $this->getLocalizedString('TOP_NEWS'), 'url' => $this->buildBreadcrumbURL('index', array('newsTab' => 'topnews'), false), 'ajaxUrl' => $this->buildAjaxBreadcrumbURL('index', array('newsTab' => 'topnews'), false)); $latestSubTabLinks[] = $newsTab; $newsItems = $newsFeed->items(); $totalItems = $newsFeed->getTotalItems(); $this->setLogData('topnews', $newsFeed->getTitle()); $previousURL = null; $nextURL = null; if ($totalItems > $this->maxPerPage) { //$args = $this->args; $args = array(); if ($start > 0) { $args['start'] = $start - $this->maxPerPage; $previousURL = $this->buildURL('index', $args); } if ($totalItems - $start > $this->maxPerPage) { $args['start'] = $start + $this->maxPerPage; $nextURL = $this->buildURL('index', $args); } } $topNews = array(); $options = array('section' => 'topnews'); foreach ($newsItems as $story) { $topNews[] = $this->linkForNewsItem($story, $options); } $extraArgs = array('section' => 'topnews'); $this->addInternalJavascript('/common/javascript/lib/ellipsizer.js'); $this->addOnLoad('setupNewsListing();'); // KurogoDebug::debug($newsFeedData['TITLE'], true); $this->assign('topNewsTitle', $newsFeedData['TITLE']); $this->assign('topNews', $topNews); $this->assign('extraArgs', $extraArgs); $this->assign('maxPerPage', $this->maxPerPage); $this->assign('previousURL', $previousURL); $this->assign('nextURL', $nextURL); $this->assign('showImages', $this->showImages); $this->assign('showPubDate', $this->showPubDate); $this->assign('showAuthor', $this->showAuthor); } // get all sports schedule if ($scheduleFeedData = $this->getNavData('allschedule')) { // KurogoDebug::debug($scheduleFeed, true); $scheduleFeed = $this->getScheduleFeed('allschedule'); $athleticEvents = $scheduleFeed->items(); $scheduleItems = array(); foreach ($athleticEvents as $event) { $scheduleItems[] = $this->linkForScheduleItem($event); } if ($limit = Kurogo::arrayVal($scheduleFeedData, 'LIMIT')) { $scheduleItems = array_slice($scheduleItems, 0, $limit); } $scheduleTab = array('id' => 'allschedule', 'title' => $this->getLocalizedString('ALL_SCHEDULE'), 'url' => $this->buildBreadcrumbURL('index', array('newsTab' => 'allschedule'), false), 'ajaxUrl' => $this->buildAjaxBreadcrumbURL('index', array('newsTab' => 'allschedule'), false)); $latestSubTabLinks[] = $scheduleTab; $this->assign('scheduleItems', $scheduleItems); } // make sure we are displaying tabs correctly if (count($latestSubTabLinks) > 0) { // if we have topnews to show $tabs[] = 'topnews'; if (count($latestSubTabLinks) == 1) { $latestSubTab = $latestSubTabLinks[0]['id']; } } $this->assign('latestSubTabLinks', $latestSubTabLinks); $this->assign('latestSubTab', $latestSubTab); //get sports for each gender foreach (array('men', 'women', 'coed') as $gender) { $sportsData = $this->getNavData($gender); if ($sportsData) { if ($sportsConfig = $this->getSportsForGender($gender)) { $sports = array(); foreach ($sportsConfig as $key => $sportData) { $image = "modules/{$this->id}/images/" . (isset($sportData['ICON']) ? $sportData['ICON'] : strtolower($sportData['TITLE'])) . $this->imageExt; $sport = array('title' => $sportData['TITLE'], 'img' => $image, 'url' => $this->buildURL('sport', array('sport' => $key))); $sports[] = $sport; } $tabs[] = $gender; $this->assign($gender . 'SportsTitle', $sportsData['TITLE']); $this->assign($gender . 'Sports', $sports); } } } $bookmarkData = $this->getNavData('bookmarks'); //get bookmarks $bookmarks = array(); if ($this->getOptionalModuleVar('BOOKMARKS_ENABLED', 1)) { $bookmarksData = $this->getBookmarks(); foreach ($bookmarksData as $bookmark) { parse_str(stripslashes($bookmark), $params); if (isset($params['sport']) && ($sportData = $this->getSportData($params['sport']))) { $image = "modules/{$this->id}/images/" . (isset($sportData['ICON']) ? $sportData['ICON'] : strtolower($sportData['TITLE'])) . $this->imageExt; $bookmarks[] = array('title' => $sportData['GENDER_TITLE'], 'img' => $image, 'url' => $this->buildURL('sport', array('sport' => $params['sport']))); } } $tabs[] = 'bookmarks'; } $this->assign('placeholder', $this->getLocalizedString('SEARCH_TEXT')); $this->assign('bookmarksTitle', $bookmarkData['TITLE']); $this->assign('bookmarks', $bookmarks); $this->assign('tabs', $tabs); $this->enableTabs($tabs); break; case 'pane': if ($this->ajaxContentLoad) { $section = 'topnews'; $newsFeed = $this->getNewsFeed($section); $newsFeed->setStart(0); $newsFeed->setLimit($this->maxPerPane); $items = $newsFeed->items(); $this->setLogData($section, $newsFeed->getTitle()); $stories = array(); $options = array('section' => $section, 'addBreadcrumb' => false); foreach ($items as $story) { $stories[] = $this->linkForItem($story, $options); } $this->assign('showImages', $this->showImages); $this->assign('stories', $stories); } $this->addInternalJavascript('/common/javascript/lib/ellipsizer.js'); $this->addInternalJavascript('/common/javascript/lib/paneStories.js'); break; } }