public function __construct() { $this->feed = new XMLight('rss', array('version' => '2.0')); $this->feed->registerNamespaces(['atom' => 'http://www.w3.org/2005/Atom', 'media' => 'http://search.yahoo.com/mrss/']); $this->channel = $this->feed->appendNode('channel'); $now = Rss::formatDate(time()); $website_description = getSetting('website_description', true); $website_doctitle = getSetting('website_doctitle', true); $website_url = G\get_base_url(); $website_logo = get_system_image_url(getSetting('favicon_image')); /* Add generic RSS 2.0 channel head with feed logo */ $this->channel->importArray(array('title' => $website_doctitle, 'link' => $website_url, 'description' => $website_description, 'pubDate' => $now, 'lastBuildDate' => $now, 'generator' => 'Chevereto Feeds::MRSS v' . Rss::getVersion() . '(with XMLight v' . XMLight::getVersion() . ')', 'ttl' => 60, 'image' => array('url' => $website_logo, 'title' => $website_doctitle, 'link' => $website_url))); /* Add self atom link */ $this->channel->appendNode('link', '', array('href' => G\get_current_url(), 'rel' => 'self', 'type' => 'application/rss+xml'), 'atom'); }
public function addImage(array $image) { $entry = $this->feed->appendNode('entry'); $entry->appendNode('title', $image['name']); $entry->appendNode('link', '', array('rel' => 'alternate', 'type' => 'text/html', 'href' => $image['url_viewer'])); $entry->appendNode('id', 'tag:' . $_SERVER['SERVER_NAME'] . ',2005:' . G\url_to_relative($image['url_viewer'])); $uploader = $image['user'] ?: array('name' => _s('Guest'), 'url' => G\get_base_url()); $author = $entry->appendNode('author'); $author->appendNode('name', $uploader['name']); $author->appendNode('uri', $uploader['url']); $entry->appendNode('updated', Atom::formatDate($image['date_gmt'])); /* if ( isset($image['original_exifdata']) ) { $exif = json_decode( html_entity_decode($image['original_exifdata']) ); if( isset($exif->DateTimeOriginal) ) { $entry->appendNode('date.Taken', Atom::formatDate( $exif->DateTimeOriginal ), array(), 'dc' ); } } */ if (isset($image['category'])) { $entry->appendNode('category', array('term' => $image['category_id'], 'label' => $image['category'])); } if ((bool) ($image['chain'] & 1)) { // mask 0001 check for thumbnail $html = strtr(Atom::$contentTemplate, array('%p' => $uploader['url'], '%u' => $uploader['name'], '%d' => $image['description'], '%v' => $image['url_viewer'], '%t' => $image['thumb']['url'])); $entry->appendNode('content', $html, ['type' => 'html']); } /* if ( (bool)($image['chain'] & 2) ) { // mask 0010 check for medium $entry->appendNode('link', '', array( 'rel' => 'enclosure', 'type' => $image['medium']['mime'], 'href' => $image['medium']['url'] )); } */ if ((bool) ($image['chain'] & 12)) { // mask 1100 check for large and original $entry->appendNode('link', '', array('rel' => 'enclosure', 'type' => $image['mime'], 'href' => $image['url'])); } }
public function addImage(array $image) { $entry = $this->feed->appendNode('image'); $entry->appendNode('id', $image['id_encoded']); $entry->appendNode('title', $image['name']); $entry->appendNode('description', $image['description']); $entry->appendNode('url', $image['url_viewer']); $entry->appendNode('updated', Xapi::formatDate($image['date_gmt'])); /* Check for available image sizes by utilizing a chain property. see https://chevereto.com/src/img/misc/image-chain.png */ if ((bool) ($image['chain'] & 1)) { // 1 is 0001 in binary :/, so we get only last bit to check for thumbnail. $entry->appendNode('thumb', $image['thumb']['url'], array('width' => $image['thumb']['width'], 'height' => $image['thumb']['height'], 'type' => $image['thumb']['mime'], 'bytesize' => $image['thumb']['size'])); } if ((bool) ($image['chain'] & 2)) { // 2 is 0010 in binary, so we get only second bit to check for medium. $entry->appendNode('medium', $image['medium']['url'], array('width' => $image['medium']['width'], 'height' => $image['medium']['height'], 'type' => $image['medium']['mime'], 'bytesize' => $image['medium']['size'])); } if ((bool) ($image['chain'] & 12)) { // 12 is 1100 in binary, so we get third and fourth bits to check for large and original. $entry->appendNode('large', $image['url'], array('width' => $image['width'], 'height' => $image['height'], 'type' => $image['mime'], 'bytesize' => $image['size'])); } /* Check if uploader is registred user. */ $by = $image['user'] ?: array('name' => _s('Guest'), 'url' => G\get_base_url()); $uploader = $entry->appendNode('uploader'); $uploader->appendNode('name', $by['name']); $uploader->appendNode('url', $by['url']); if (isset($image['category'])) { $entry->appendNode('category', array('id' => $image['category_id'], 'name' => $image['category'])); } }