Ejemplo n.º 1
0
 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())));
             if ($this->browser == 'native') {
                 $links[] = array('title' => 'AppQ Dialogs', 'url' => $this->buildBreadcrumbURL('dialogs', array()));
                 $links[] = array('title' => 'Truncation Form Post', 'url' => $this->buildBreadcrumbURL('truncate', array()));
             }
             $this->assign('links', $links);
             break;
         case 'text':
             break;
         case 'search':
             $formFields = $this->loadPageConfigFile($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 '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->loadPageConfigFile('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->loadPageConfigFile($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 '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;
     }
 }
Ejemplo n.º 2
0
 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(array('id', 'storyID'), false);
             $storyPage = $this->getArg('storyPage', '0');
             $story = $this->feed->getItem($storyID);
             $ajax = $this->getArg('ajax', false);
             if (!$story) {
                 throw new KurogoUserException($this->getLocalizedString('ERROR_STORY_NOT_FOUND', $storyID));
             }
             $this->setLogData($storyID, $story->getTitle());
             if (!($content = $this->cleanContent($story->getContent()))) {
                 if ($ajax) {
                     $content = $story->getDescription();
                     if ($url = $story->getLink()) {
                         $content .= $this->getLocalizedString('READ_MORE_LINK', $url);
                     }
                 } else {
                     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)) {
                 $truncated = false;
                 $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::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('link', $story->getLink());
             $this->assign('showLink', $this->showLink);
             $this->assign('showBodyImage', $this->showBodyImage);
             $this->assign('showBodyThumbnail', $this->showBodyThumbnail);
             $this->assign('showBodyPubDate', $this->showBodyPubDate);
             $this->assign('showBodyAuthor', $this->showBodyAuthor);
             if ($this->showImages) {
                 if ($image = $story->getImage()) {
                     $this->assign('image', array('src' => $image->getURL(), 'width' => $image->getWidth(), 'height' => $image->getHeight()));
                 } elseif ($thumbnail = $story->getThumbnail()) {
                     $this->assign('thumbnail', array('src' => $thumbnail->getURL(), 'width' => $thumbnail->getWidth(), 'height' => $thumbnail->getHeight()));
                 }
             }
             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, 'feed' => $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('feed' => $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;
                 $this->feed->setStart(0);
                 $this->feed->setLimit($this->maxPerPane);
                 $items = $this->feed->items();
                 $stories = array();
                 $options = array('noBreadcrumbs' => true, 'feed' => $this->feedIndex);
                 foreach ($items as $story) {
                     $link = $this->linkForItem($story, $options);
                     $link['url'] = $this->buildURL('index') . '#' . urlencode(FULL_URL_PREFIX . ltrim($link['url'], '/'));
                     $stories[] = $link;
                 }
                 $this->assign('showImages', $this->showImages);
                 $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);
             $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('feed' => $this->feedIndex);
             $stories = array();
             foreach ($items as $story) {
                 $stories[] = $this->linkForItem($story, $options);
             }
             $sections = array();
             foreach ($this->feeds as $index => $feedData) {
                 $sections[$index] = array('value' => $index, 'title' => $feedData['TITLE'], 'selected' => $this->feedIndex == $index, 'url' => $this->feedURL($index, false));
             }
             $this->addInternalJavascript('/common/javascript/lib/ellipsizer.js');
             $this->addOnLoad('setupNewsListing();');
             $this->assign('maxPerPage', $this->maxPerPage);
             $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);
             $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;
     }
 }