enclosure() public method

public enclosure ( $url, $length, $type = 'audio/mpeg' )
    $blogPostItem->category($blogPost['category'], $categoryUrl);
    $pubDate = new DateTime($blogPost['date']);
    $blogPostItem->pubDate($pubDate->getTimestamp());
    if (preg_match('@{{photo="([^\\/]+)/([^\\.]+).([^"]+)"}}@', $blogPost['body'], $match) == 1) {
        $photoPath = "/photo/{$match[1]}/{$match[2]}-size-large.{$match[3]}";
        $photoInternalPath = __DIR__ . '/../../web/public' . $photoPath;
        $photoSize = filesize($photoInternalPath);
        /**
         * ugh, remote host does not have pecl fileinfo
         *
         * $fInfo = new finfo(FILEINFO_MIME_TYPE);
         * $photoType = $fInfo->file($photoInternalPath);
         * unset($fInfo);
         **/
        $photoType = 'image/jpeg';
        $blogPostItem->enclosure("https://blog.jacobemerick.com{$photoPath}", $photoSize, $photoType);
    }
    $blogPostItem->appendTo($blogPostChannel);
}
$buildFeed($blogPostFeed, 'blog');
/*********************************************
 * Then the blog comments
 *********************************************/
$blogCommentFeed = new Feed();
$blogCommentChannel = new Channel();
$blogCommentChannel->title('Jacob Emerick | Blog Comment Feed');
$blogCommentChannel->description('Most recent comments on blog posts of Jacob Emerick');
$blogCommentChannel->url('https://blog.jacobemerick.com');
// todo depends on env
$blogCommentChannel->appendTo($blogCommentFeed);
$query = "\n    SELECT `comment_meta`.`id`, `comment_meta`.`date`, `comment`.`body`, `commenter`.`name`,\n           `post`.`title`, `post`.`category`, `post`.`path`\n    FROM `jpemeric_comment`.`comment_meta`\n    INNER JOIN `jpemeric_comment`.`comment` ON `comment`.`id` = `comment_meta`.`comment`\n    INNER JOIN `jpemeric_comment`.`commenter` ON `commenter`.`id` = `comment_meta`.`commenter` AND\n                                                 `commenter`.`trusted` = :trusted_commenter\n    INNER JOIN `jpemeric_comment`.`comment_page` ON `comment_page`.`id` = `comment_meta`.`comment_page` AND\n                                                    `comment_page`.`site` = :comment_site\n    INNER JOIN `jpemeric_blog`.`post` ON `post`.`path` = `comment_page`.`path` AND\n                                         `post`.`display` = :display_post\n    WHERE `comment_meta`.`display` = :active_comment\n    ORDER BY `comment_meta`.`date` DESC";
Exemplo n.º 2
0
 /**
  * Display rss feeds from content category
  * @return string
  * @throws ForbiddenException
  */
 public function actionRss()
 {
     $path = $this->request->getPathWithoutControllerAction();
     $configs = $this->getConfigs();
     // build model data
     $model = new EntityCategoryList($path, $configs, 0);
     // remove global layout
     $this->layout = null;
     // check if rss display allowed for this category
     if ((int) $model->category['configs']['showRss'] !== 1) {
         throw new ForbiddenException(__('Rss feed is disabled for this category'));
     }
     // initialize rss feed objects
     $feed = new Feed();
     $channel = new Channel();
     // set channel data
     $channel->title($model->category['title'])->description($model->category['description'])->url(App::$Alias->baseUrl . '/content/list/' . $model->category['path'])->appendTo($feed);
     // add content data
     if ($model->getContentCount() > 0) {
         foreach ($model->items as $row) {
             $item = new Item();
             // add title, short text, url
             $item->title($row['title'])->description($row['text'])->url(App::$Alias->baseUrl . $row['uri']);
             // add poster
             if ($row['thumb'] !== null) {
                 $item->enclosure(App::$Alias->scriptUrl . $row['thumb'], $row['thumbSize'], 'image/jpeg');
             }
             // append response to channel
             $item->appendTo($channel);
         }
     }
     // define rss read event
     App::$Event->run(static::EVENT_RSS_READ, ['model' => $model, 'feed' => $feed, 'channel' => $channel]);
     // render response from feed object
     return $feed->render();
 }