protected function formatStory($story, $mode) { $item = array('GUID' => $story->getGUID(), 'link' => $story->getLink(), 'title' => Sanitizer::htmlStripTags2UTF8($story->getTitle()), 'description' => Sanitizer::htmlStripTags2UTF8($story->getDescription()), 'pubDate' => $story->getPubTimestamp()); if ($story->getContent()) { if ($mode == 'full') { $item['body'] = $story->getContent(); } $item['hasBody'] = TRUE; } else { $item['hasBody'] = FALSE; } $thumbnail = $story->getThumbnail(); if ($thumbnail && $thumbnail->getURL()) { $key = $this->requestedVersion < 2 ? 'image' : 'thumbnail'; $item[$key] = array('src' => $thumbnail->getURL(), 'width' => $thumbnail->getWidth(), 'height' => $thumbnail->getHeight()); } if ($this->requestedVersion >= 2) { $image = $story->getImage(); if ($image && $image->getURL()) { $item['image'] = array('src' => $image->getURL(), 'width' => $image->getWidth(), 'height' => $image->getHeight()); } } $author = $story->getAuthor(); $item['author'] = $author ? $author : ""; return $item; }
protected function arrayFromVideo($video, $section) { $videoArray = array("id" => $video->getID(), "type" => $video->getType(), "title" => $video->getTitle(), "description" => Sanitizer::htmlStripTags2UTF8($video->getDescription()), "author" => $video->getAuthor(), "published" => array('date' => $video->getPublished()->format('Y-m-d H:i:s'), 'timezone_type' => 1, 'timezone' => $video->getPublished()->format('P')), "date" => $video->getPublished()->format('M n, Y'), "url" => $video->getURL(), "image" => $video->getImage(), "width" => $video->getWidth(), "height" => $video->getHeight(), "aspect" => $video->getAspectRatio(), "duration" => $video->getDuration(), "tags" => $video->getTags(), "mobileURL" => $video->getMobileURL(), "streamingURL" => $video->getStreamingURL(), "stillFrameImage" => $video->getStillFrameImage(), "playerURL" => FULL_URL_BASE . $this->configModule . '/player?' . http_build_query(array('section' => $section, 'videoid' => $video->getID()))); if ($this->requestedVersion >= 2) { $videoArray['published']['timestamp'] = $video->getPublished()->format('U'); $videoArray['playerURL'] = $video->getPlayerURL(); } return $videoArray; }
protected function initializeForCommand() { switch ($this->command) { case 'notice': if ($noticeConfig = $this->getOptionalModuleSection('notice', 'feeds')) { $modelClass = isset($noticeConfig['MODEL_CLASS']) ? $noticeConfig['MODEL_CLASS'] : 'EmergencyNoticeDataModel'; $emergencyNoticeController = EmergencyNoticeDataModel::factory($modelClass, $noticeConfig); $emergencyNotice = $emergencyNoticeController->getFeaturedEmergencyNotice(); if (isset($emergencyNotice['text'])) { $emergencyNotice['text'] = Sanitizer::htmlStripTags2UTF8($emergencyNotice['text']); } if (isset($emergencyNotice['body'])) { $emergencyNotice['body'] = Sanitizer::htmlStripTags2UTF8($emergencyNotice['body']); } // if there is no emergency notice and a no-notice section // is set, use it as a feed if (!isset($emergencyNotice) && ($noEmergencyConfig = $this->getOptionalModuleSection('no-notice', 'feeds'))) { $modelClass = isset($noEmergencyConfig['MODEL_CLASS']) ? $noEmergencyConfig['MODEL_CLASS'] : 'EmergencyNoticeDataModel'; if (!isset($noEmergencyConfig['NOTICE_EXPIRATION'])) { $noEmergencyConfig['NOTICE_EXPIRATION'] = 0; } $noEmergencyNoticeController = EmergencyNoticeDataModel::factory($modelClass, $noEmergencyConfig); $emergencyNotice = $noEmergencyNoticeController->getFeaturedEmergencyNotice(); } else { if (!isset($emergencyNotice)) { // if there is not a no emergency feed, there may be a no emergency string if ($noEmergencyString = $this->getOptionalModuleVar('NO_EMERGENCY', null, 'strings')) { $emergencyNotice['text'] = $noEmergencyString; $emergencyNotice['unixtime'] = time(); } } } $noticeEnabled = true; } else { // Config section 'notice' not set, there is not notice $emergencyNotice = null; $noticeEnabled = false; } $response = array('notice' => $emergencyNotice, 'noticeEnabled' => $noticeEnabled); $this->setResponse($response); $this->setResponseVersion(2); break; case 'contacts': if ($contactsConfig = $this->getOptionalModuleSection('contacts', 'feeds')) { $modelClass = isset($contactsConfig['MODEL_CLASS']) ? $contactsConfig['MODEL_CLASS'] : 'EmergencyContactsDataModel'; $contactsController = EmergencyContactsDataModel::factory($modelClass, $contactsConfig); $response = array('primary' => self::formatContacts($contactsController->getPrimaryContacts()), 'secondary' => self::formatContacts($contactsController->getSecondaryContacts())); } else { $response = new stdClass(); } $this->setResponse($response); $this->setResponseVersion(2); break; } }
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' => Sanitizer::htmlStripTags2UTF8($item->getDescription()), 'body' => $item->getContent(false), 'link' => $item->getLink(), 'date' => $item->getPubDate() ? 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; }
private function arrayForPhoto($albumId, $photoData) { $photo = array('id' => strval($photoData->getID()), 'title' => $photoData->getTitle(), 'albumId' => strval($albumId), 'thumbnailUrl' => $photoData->getThumbnailUrl(), 'imgUrl' => $photoData->getUrl(), 'description' => Sanitizer::htmlStripTags2UTF8($photoData->getDescription()), 'author' => $photoData->getAuthor(), 'published' => $photoData->getPublished()->getTimestamp()); return $photo; }