예제 #1
0
    public function PageLoad()
    {
        ob_clean();
        $this->presenter->PageLoad();
        $config = Configuration::Instance();
        $feed = new FeedWriter(ATOM);
        $title = $config->GetKey(ConfigKeys::APP_TITLE);
        $feed->setTitle("{$title} Reservations");
        $url = $config->GetScriptUrl();
        $feed->setLink($url);
        $feed->setChannelElement('updated', date(DATE_ATOM, time()));
        $feed->setChannelElement('author', array('name' => $title));
        foreach ($this->reservations as $reservation) {
            /** @var FeedItem $item */
            $item = $feed->createNewItem();
            $item->setTitle($reservation->Summary);
            $item->setLink($reservation->ReservationUrl);
            $item->setDate($reservation->DateCreated->Timestamp());
            $item->setDescription(sprintf('<div><span>Start</span> %s</div>
										  <div><span>End</span> %s</div>
										  <div><span>Organizer</span> %s</div>
										  <div><span>Description</span> %s</div>', $reservation->DateStart->ToString(), $reservation->DateEnd->ToString(), $reservation->Organizer, $reservation->Description));
            $feed->addItem($item);
        }
        $feed->genarateFeed();
    }
예제 #2
0
 public function setItemLink($link)
 {
     if ($this->version == RSS2 || $this->version == RSS1) {
         $this->addElement('link', $link);
     } else {
         $this->addElement('link', '', array('href' => $link));
         $this->addElement('id', FeedWriter::uuid($link, 'urn:uuid:'));
     }
 }
예제 #3
0
파일: FeedView.php 프로젝트: yiuked/tmcart
 public function displayMain()
 {
     $postFeed = new FeedWriter(RSS2);
     $postFeed->setTitle(Configuration::get('TM_SHOP_NAME'));
     $postFeed->setLink(Configuration::get('TM_SHOP_URL'));
     $postFeed->setDescription('This is test of creating a RSS 2.0 feed Universal Feed Writer');
     $postFeed->setImage('Testing the RSS writer class', 'http://www.ajaxray.com/projects/rss', 'http://www.rightbrainsolution.com/images/logo.gif');
     $posts = CMSHelper::getNewCMS(50);
     foreach ($posts as $row) {
         $newItem = $postFeed->createNewItem();
         $newItem->setTitle($row['title']);
         $newItem->setLink($row['link']);
         $newItem->setDate($row['add_date']);
         $newItem->setDescription($row['content']);
         $postFeed->addItem($newItem);
     }
     $postFeed->genarateFeed();
 }
예제 #4
0
 function rss()
 {
     global $REQUEST_ASSOC, $TPA;
     if ($node = $this->_tree->getNodeInfo($REQUEST_ASSOC['id'])) {
         Common::inc_module_factory('feedWriter', true);
         //Creating an instance of FeedWriter class.
         //The constant RSS2 is passed to mention the version
         $feed = new FeedWriter();
         //Setting the channel elements
         //Use wrapper functions for common channel elements
         $feed->setTitle(CHOST . ' - ' . $node['basic']);
         $feed->setLink(CHOST);
         $feed->setDescription(CHOST);
         //Image title and link must match with the 'title' and 'link' channel elements for RSS 2.0
         //$TestFeed->setImage('Testing the RSS writer class','http://www.ajaxray.com/projects/rss','http://www.rightbrainsolution.com/images/logo.gif');
         //Use core setChannelElement() function for other optional channels
         $node['params']['lang'] = 'ru';
         $feed->setChannelElement('language', $node['params']['lang']);
         if ($interval = $this->_common_obj->select_news_interval($node_id, 0, 10, '', '', false, $active = 1)) {
             foreach ($interval as $news) {
                 //Create an empty FeedItem
                 $newItem = $feed->createNewItem();
                 //Add elements to the feed item
                 //Use wrapper functions to add common feed elements
                 $newItem->setTitle($news['header']);
                 $newItem->setLink($TPA->page_link . '/~shownews/' . $news['id']);
                 //The parameter is a timestamp for setDate() function
                 $date = strtotime($news['sortdate']);
                 $newItem->setDate($date);
                 $newItem->setDescription($news['news_short']);
                 $newItem->addElement('author', '*****@*****.**');
                 //Attributes have to passed as array in 3rd parameter
                 $newItem->addElement('guid', 'http://www.ajaxray.com', array('isPermaLink' => 'true'));
                 //Now add the feed item
                 $feed->addItem($newItem);
             }
             $feed->genarateFeed();
             die;
         }
     }
 }
예제 #5
0
 /**
  * Generates a RSS feed from an external RSS feed
  *
  * @param $url string The URL of the external feed
  * @return void
  */
 public function rssProxy($url)
 {
     $this->_remoteRSS = array();
     $this->_feed = new FeedWriter();
     $this->loadRSSFeed($url);
     $version = $this->_remoteRSS["version"];
     $version = floatval($version);
     if ($version <= 1.0) {
         $version = RSS1;
     } else {
         $version = RSS2;
     }
     $this->_feed->setVersion($version);
     $this->_feed->setTitle($this->_remoteRSS["title"]);
     $this->_feed->setDescription($this->_remoteRSS["description"]);
     $this->_feed->setLink($this->_remoteRSS["link"]);
     $this->_feed->setImage($this->_remoteRSS["image"]["title"], $this->_remoteRSS["image"]["url"], $this->_remoteRSS["image"]["link"]);
     $this->_feed->setChannelElement("language", $this->_remoteRSS["language"]);
     $this->_feed->setChannelElement('pubDate', $this->_remoteRSS["pubDate"]);
     if (isset($this->_remoteRSS["items"]) && count($this->_remoteRSS["items"]) > 0) {
         foreach ($this->_remoteRSS["items"] as $item) {
             $title = $this->_filter->encodeHTML($item["title"]);
             $link = $item["link"];
             $pubDate = $item["pubDate"];
             $description = $item["description"];
             if (isset($item["enclosure"])) {
                 $enclosure = array("url" => $item["enclosure"]["url"], "length" => $item["enclosure"]["length"], "type" => $item["enclosure"]["type"]);
                 $this->addEnclosureContent($title, $link, $pubDate, $description, $enclosure);
             } else {
                 $this->addContent($title, $link, $pubDate, $description);
             }
         }
     }
     header('Content-type: text/xml');
     $this->_feed->genarateFeed();
 }
예제 #6
0
<?php

require_once 'FeedWriter.php';
require_once '../Spyc.php';
require_once '../functions.php';
$TestFeed = new FeedWriter(ATOM);
$TestFeed->setTitle('F**k-Huff-Duff. Very Private Sonar Feed.');
$TestFeed->setLink('http://' . $_SERVER['HTTP_HOST'] . '/' . get_subdir($_SERVER[PHP_SELF]) . '/');
#print_r(get_subdir($_SERVER[PHP_SELF]));
$TestFeed->setChannelElement('updated', date(DATE_ATOM, time()));
$TestFeed->setChannelElement('author', array('name' => 'Juicy Cocktail (http://juicycocktail.com/)'));
$items = Spyc::YAMLLoad('../urls.yaml');
foreach ($items as $item) {
    $newItem = $TestFeed->createNewItem();
    $newItem->setTitle($item['title']);
    $newItem->setLink($item['link']);
    $newItem->setDate($item['date']);
    $newItem->setDescription($item['description']);
    $newItem->setEncloser($item['enc_link'], $item['enc_length'], 'audio/mpeg');
    $TestFeed->addItem($newItem);
}
# Please don’t mastarbate.
$TestFeed->genarateFeed();
예제 #7
0
} else {
    $clan_name = "";
}
if (isset($_GET['limit'])) {
    $limit = escape_string($_GET['limit']);
} else {
    $limit = $toplist_max;
}
$current_time = time();
$timelimit = $maxdays * 60 * 60 * 24;
$statslink = httplink() . "?config=" . $currentconfignumber;
$feeddescription = "These are the top players of " . $statstitle . " (ordered by " . $sortby . "). Connect (with your " . $game . " gameclient) to: " . $public_ip . " and compete with them!";
$feeddescriptionshort = "XLRstats Top Players Feed";
$feedlogo = "http://www.bigbrotherbot.com/images/b3_power_88_2.gif";
//Creating an instance of FeedWriter class.
$XLRfeed = new FeedWriter(RSS2);
//Setting the channel elements
//Use wrapper functions for common channel elements
$XLRfeed->setTitle($statstitle);
$XLRfeed->setLink($statslink);
$XLRfeed->setDescription($feeddescription);
//Image title and link must match with the 'title' and 'link' channel elements for valid RSS 2.0
$XLRfeed->setImage($feeddescriptionshort, $statslink, $feedlogo);
// DATABASE
$coddb = new sql_db($db_host, $db_user, $db_pass, $db_db, false);
if (!$coddb->db_connect_id) {
    die("Could not connect to the database");
}
//Detriving informations from database addin feeds
$query = "SELECT {$t['b3_clients']}.name, {$t['b3_clients']}.time_edit, {$t['players']}.id, kills, deaths, ratio, skill, winstreak, losestreak, rounds, fixed_name, ip\n    FROM {$t['b3_clients']}, {$t['players']}\n    WHERE ({$t['b3_clients']}.id = {$t['players']}.client_id)\n    AND (({$t['players']}.kills > {$minkills})\n      OR ({$t['players']}.rounds > {$minrounds}))\n    AND ({$t['players']}.hide = 0)\n    AND ({$current_time} - {$t['b3_clients']}.time_edit  < {$timelimit})";
if ($clan_name != "") {
예제 #8
0
 /**
  * Generate RSS feeds for current user
  *
  * @param $token
  * @param $user_id
  * @param $tag_id if $type is 'tag', the id of the tag to generate feed for
  * @param string $type the type of feed to generate
  * @param int $limit the maximum number of items (0 means all)
  */
 public function generateFeeds($token, $user_id, $tag_id, $type = 'home', $limit = 0)
 {
     $allowed_types = array('home', 'fav', 'archive', 'tag');
     $config = $this->store->getConfigUser($user_id);
     if ($config == null) {
         die(sprintf(_('User with this id (%d) does not exist.'), $user_id));
     }
     if (!in_array($type, $allowed_types) || !isset($config['token']) || $token != $config['token']) {
         die(_('Uh, there is a problem while generating feed. Wrong token used?'));
     }
     $feed = new FeedWriter(RSS2);
     $feed->setTitle('wallabag — ' . $type . ' feed');
     $feed->setLink(Tools::getPocheUrl());
     $feed->setChannelElement('pubDate', date(DATE_RSS, time()));
     $feed->setChannelElement('generator', 'wallabag');
     $feed->setDescription('wallabag ' . $type . ' elements');
     if ($type == 'tag') {
         $entries = $this->store->retrieveEntriesByTag($tag_id, $user_id);
     } else {
         $entries = $this->store->getEntriesByView($type, $user_id);
     }
     // if $limit is set to zero, use all entries
     if (0 == $limit) {
         $limit = count($entries);
     }
     if (count($entries) > 0) {
         for ($i = 0; $i < min(count($entries), $limit); $i++) {
             $entry = $entries[$i];
             $newItem = $feed->createNewItem();
             $newItem->setTitle($entry['title']);
             $newItem->setSource(Tools::getPocheUrl() . '?view=view&amp;id=' . $entry['id']);
             $newItem->setLink($entry['url']);
             $newItem->setDate(time());
             $newItem->setDescription($entry['content']);
             $feed->addItem($newItem);
         }
     }
     $feed->genarateFeed();
     exit;
 }
 private function controlNodeContent($name, $value)
 {
     if (FeedValidator::isNull($value) == FALSE) {
         switch (strtolower($name)) {
             case 'start':
             case 'published':
             case 'updated':
                 return FeedValidator::isValidDate(FeedWriter::getISODate($value));
                 break;
             case 'name':
                 return FeedValidator::isNull($value) == FALSE ? TRUE : FALSE;
                 break;
             case 'email':
                 return FeedValidator::isValidEmail($value);
                 break;
             case 'logo':
             case 'icon':
             case 'uri':
                 return FeedValidator::isValidURL($value);
                 break;
             case 'latitude':
                 return FeedValidator::isValidLatitude($value);
                 break;
             case 'longitude':
                 return FeedValidator::isValidLongitude($value);
                 break;
             case 'country_code':
                 return FeedValidator::isValidCountryCode($value);
                 break;
             case 'currency':
                 return FeedValidator::isValidCurrency($value);
                 break;
             default:
                 return TRUE;
                 break;
         }
     }
     return TRUE;
 }
예제 #10
0
<?php

/**
 * Create a rss of the recorded programs.
 *
 * @license     GPL
 *
 * @package     MythWeb
 * @subpackage  TV
 *
 **/
$Feed = new FeedWriter(RSS2);
$Feed->setTitle('MythWeb - ' . t('Recorded Programs'));
$Feed->setLink(root_url);
$Feed->setDescription('MythWeb - ' . t('Recorded Programs'));
foreach ($All_Shows as $show) {
    $item = $Feed->createNewItem();
    $item->setTitle($show->title . (strlen($show->subtitle) > 0 ? ' - ' . $show->subtitle : ''));
    $item->setLink(root_url . 'tv/detail/' . $show->chanid . '/' . $show->recstartts);
    $item->setDate($show->starttime);
    $item->setDescription($show->description);
    $Feed->addItem($item);
}
$Feed->generateFeed();
예제 #11
0
<?php

include "FeedWriter.php";
// IMPORTANT : No need to add id for feed or channel. It will be automatically created from link.
//Creating an instance of FeedWriter class.
//The constant ATOM is passed to mention the version
$TestFeed = new FeedWriter(ATOM);
//Setting the channel elements
//Use wrapper functions for common elements
$TestFeed->setTitle('Testing the RSS writer class');
$TestFeed->setLink('http://www.ajaxray.com/rss2/channel/about');
//For other channel elements, use setChannelElement() function
$TestFeed->setChannelElement('updated', date(DATE_ATOM, time()));
$TestFeed->setChannelElement('author', array('name' => 'Anis uddin Ahmad'));
//Adding a feed. Genarally this protion will be in a loop and add all feeds.
//Create an empty FeedItem
$newItem = $TestFeed->createNewItem();
//Add elements to the feed item
//Use wrapper functions to add common feed elements
$newItem->setTitle('The first feed');
$newItem->setLink('http://www.yahoo.com');
$newItem->setDate(time());
//Internally changed to "summary" tag for ATOM feed
$newItem->setDescription('This is test of adding CDATA Encoded description by the php <b>Universal Feed Writer</b> class');
//Now add the feed item
$TestFeed->addItem($newItem);
//OK. Everything is done. Now genarate the feed.
$TestFeed->genarateFeed();
예제 #12
0
<?php

include "FeedWriter.php";
//Creating an instance of FeedWriter class.
//The constant RSS2 is passed to mention the version
$TestFeed = new FeedWriter(RSS2);
//Setting the channel elements
//Use wrapper functions for common channel elements
$TestFeed->setTitle('Testing & Checking the RSS writer class');
$TestFeed->setLink('http://www.ajaxray.com/projects/rss');
$TestFeed->setDescription('This is test of creating a RSS 2.0 feed Universal Feed Writer');
//Image title and link must match with the 'title' and 'link' channel elements for RSS 2.0
$TestFeed->setImage('Testing the RSS writer class', 'http://www.ajaxray.com/projects/rss', 'http://www.rightbrainsolution.com/images/logo.gif');
//Use core setChannelElement() function for other optional channels
$TestFeed->setChannelElement('language', 'en-us');
$TestFeed->setChannelElement('pubDate', date(DATE_RSS, time()));
//Adding a feed. Genarally this portion will be in a loop and add all feeds.
//Create an empty FeedItem
$newItem = $TestFeed->createNewItem();
//Add elements to the feed item
//Use wrapper functions to add common feed elements
$newItem->setTitle('The first feed');
$newItem->setLink('http://www.yahoo.com');
//The parameter is a timestamp for setDate() function
$newItem->setDate(time());
$newItem->setDescription('This is test of adding CDATA Encoded description by the php <b>Universal Feed Writer</b> class');
$newItem->setEncloser('http://www.attrtest.com', '1283629', 'audio/mpeg');
//Use core addElement() function for other supported optional elements
$newItem->addElement('author', 'admin@ajaxray.com (Anis uddin Ahmad)');
//Attributes have to passed as array in 3rd parameter
$newItem->addElement('guid', 'http://www.ajaxray.com', array('isPermaLink' => 'true'));
예제 #13
0
         $content = ob_get_contents();
         //Flush the buffer so that we dont get the page 2x times
         ob_end_clean();
     }
     ob_start();
     // Get the index template file.
     include_once $index_file;
     //Now that we have the whole index page generated, put it in cache folder
     if ($index_cache != 'off') {
         $fp = fopen($cachefile, 'w');
         fwrite($fp, ob_get_contents());
         fclose($fp);
     }
 } else {
     if ($filename == 'rss' || $filename == 'atom') {
         $filename == 'rss' ? $feed = new FeedWriter(RSS2) : ($feed = new FeedWriter(ATOM));
         $feed->setTitle($blog_title);
         $feed->setLink($blog_url);
         if ($filename == 'rss') {
             $feed->setDescription($meta_description);
             $feed->setChannelElement('language', $language);
             $feed->setChannelElement('pubDate', date(DATE_RSS, time()));
         } else {
             $feed->setChannelElement('author', $blog_title . ' - ' . $blog_email);
             $feed->setChannelElement('updated', date(DATE_RSS, time()));
         }
         $posts = get_all_posts();
         if ($posts) {
             $c = 0;
             foreach ($posts as $post) {
                 if ($c < $feed_max_items) {
예제 #14
0
function projects_rss()
{
    global $clerk, $project;
    $feed = new FeedWriter(RSS2);
    $title = $clerk->getSetting("site", 1);
    $feed->setTitle($title . ' / Projects Feed');
    $feed->setLink(linkToSite());
    $feed->setDescription('Live feed of projects on ' . $title);
    $feed->setChannelElement('pubDate', date(DATE_RSS, time()));
    $projects = $clerk->query_select("projects", "", "WHERE publish= 1 ORDER BY id DESC");
    while ($project = $clerk->query_fetchArray($projects)) {
        $newItem = $feed->createNewItem();
        $newItem->setTitle($project['title']);
        $newItem->setLink(html_entity_decode(linkToProject($project['id'])));
        $newItem->setDate($project['date']);
        $desc = projectThumbnail();
        $desc = call_anchor("projectsRssDescription", $desc);
        $newItem->setDescription('' . $desc . '');
        $newItem->addElement('guid', linkToProject($project['id']), array('isPermaLink' => 'true'));
        $feed->addItem($newItem);
        $count = 0;
        $desc = "";
    }
    $feed->genarateFeed();
}
예제 #15
0
파일: rss.php 프로젝트: anvnguyen/Goteo
 public static function get($config, $data, $gformat = null)
 {
     $feed = new \FeedWriter($config['title'], $config['description'], $config['link'], $config['indent'], true, null, true);
     // debug
     $feed->debug = true;
     //format
     $format = \RSS_2_0;
     if (isset($gformat)) {
         foreach ($feed->getFeedFormats() as $cFormat) {
             if ($cFormat[0] == $gformat) {
                 $format = $cFormat[1];
             }
         }
     }
     //channel
     //            $feed->set_image('Goteo.org', SITE_URL . '/images/logo.jpg');
     $feed->set_language('ES-ES');
     // segun \LANG
     $feed->set_date(\date('Y-m-d\\TH:i:s') . 'Z', DATE_UPDATED);
     $feed->set_author(null, 'Goteo');
     $feed->set_selfLink(SITE_URL . '/rss');
     foreach ($data['tags'] as $tagId => $tagName) {
         $feed->add_category($tagName);
     }
     date_default_timezone_set('UTC');
     foreach ($data['posts'] as $postId => $post) {
         // fecha
         $postDate = explode('-', $post->date);
         $date = \mktime(0, 0, 0, $postDate[1], $postDate[0], $postDate[2]);
         //item $postId
         $feed->add_item($post->title, $post->text, SITE_URL . '/blog/' . $post->id);
         $feed->set_date(\date(DATE_ATOM, $date), DATE_PUBLISHED);
         foreach ($post->tags as $tagId => $tagName) {
             $feed->add_category($tagName);
         }
         // html output
         $feed->set_feedConstruct($format);
         $feed->feed_construct->construct['itemTitle']['type'] = 'html';
         $feed->feed_construct->construct['itemContent']['type'] = 'html';
     }
     return $feed->getXML($format);
 }
예제 #16
0
파일: Vk2rss.php 프로젝트: woxcab/vk2rss
 /**
  * Generate RSS feed
  */
 public function generateRSS()
 {
     include 'FeedWriter.php';
     include 'FeedItem.php';
     $feed = new FeedWriter(RSS2);
     $wall = $this->getContent();
     $title = !empty($this->domain) ? $this->domain : $this->owner_id;
     $feed->setTitle('vk.com/' . $title);
     $feed->setLink('http://vk.com/' . $title);
     $feed->setDescription('wall from vk.com/' . $title);
     $feed->setChannelElement('language', 'ru-ru');
     $feed->setChannelElement('pubDate', date(DATE_RSS, time()));
     foreach (array_slice($wall->response, 1) as $post) {
         $newItem = $feed->createNewItem();
         $newItem->setLink("http://vk.com/wall{$post->to_id}_{$post->id}");
         $newItem->setDate($post->date);
         $description = $post->text;
         if (isset($post->copy_text)) {
             # additional content in re-posts
             $description .= (empty($description) ? '' : self::VERTICAL_DELIMITER) . $post->copy_text;
         }
         if (isset($post->attachment->photo->text) and !empty($post->attachment->photo->text)) {
             $description .= (empty($description) ? '' : self::VERTICAL_DELIMITER) . $post->attachment->photo->text;
         }
         if (isset($post->attachment->video->text) and !empty($post->attachment->video->text)) {
             $description .= (empty($description) ? '' : self::VERTICAL_DELIMITER) . $post->attachment->video->text;
         }
         if (isset($post->attachment->link)) {
             $description .= (empty($description) ? '' : self::VERTICAL_DELIMITER) . $post->attachment->link->title . '<br/>' . $post->attachment->link->description;
         }
         if (!is_null($this->include) && preg_match('/' . $this->include . '/iu', $description) !== 1) {
             continue;
         }
         if (!is_null($this->exclude) && preg_match('/' . $this->exclude . '/iu', $description) !== 0) {
             continue;
         }
         $hashTags = array();
         $description = preg_replace('/\\[[^|]+\\|([^\\]]+)\\]/u', '$1', $description);
         // remove internal vk links
         preg_match_all('/#([\\d\\w_]+)/u', $description, $hashTags);
         if (isset($post->attachments)) {
             foreach ($post->attachments as $attachment) {
                 switch ($attachment->type) {
                     case 'photo':
                         $description .= "<br><img src='{$attachment->photo->src_big}'/>";
                         break;
                         /*case 'audio': {
                             $description .= "<br><a href='http://vk.com/wall{$owner_id}_{$post->id}'>{$attachment->audio->performer} &ndash; {$attachment->audio->title}</a>";
                             break;
                           }*/
                     /*case 'audio': {
                         $description .= "<br><a href='http://vk.com/wall{$owner_id}_{$post->id}'>{$attachment->audio->performer} &ndash; {$attachment->audio->title}</a>";
                         break;
                       }*/
                     case 'doc':
                         $description .= "<br><a href='{$attachment->doc->url}'>{$attachment->doc->title}</a>";
                         break;
                     case 'link':
                         $description .= "<br><a href='{$attachment->link->url}'>{$attachment->link->title}</a>";
                         break;
                         /*case 'video': {
                             $description .= "<br><a href='http://vk.com/video{$attachment->video->owner_id}_{$attachment->video->vid}'><img src='{$attachment->video->image_big}'/></a>";
                             break;
                           }*/
                 }
             }
         }
         $newItem->setDescription($description);
         $newItem->addElement('title', $this->getTitle($description));
         $newItem->addElement('guid', $post->id);
         foreach ($hashTags[1] as $hashTag) {
             $newItem->addElement('category', $hashTag);
         }
         $feed->addItem($newItem);
     }
     $feed->generateFeed();
 }
예제 #17
0
파일: atom.php 프로젝트: ASDAFF/myprofile
$user_hash = trim($_REQUEST['id']);
// Get the corresponding webid for the hash
if ($_REQUEST['id'] != 'local') {
    $webid = get_webid_by_hash($user_hash);
    // complain if the feed ID is not valid
    if (!$webid) {
        echo "<font style=\"font-size: 1.3em;\">There is no feed associated to this ID!</font>\n";
        exit;
    }
} else {
    $webid = $user_hash;
}
// IMPORTANT : No need to add id for feed or channel. It will be automatically created from link.
//Creating an instance of FeedWriter class.
//The constant ATOM is passed to mention the version
$Feed = new FeedWriter(ATOM);
//Setting the channel elements
if ($user_hash != 'local') {
    $Feed->setTitle('MyProfile Pingbacks/Notifications Feed');
} else {
    $Feed->setTitle('MyProfile Wall Feed');
}
$Feed->setLink($base_uri . '/feed.php?id=' . $user_hash);
//For other channel elements, use setChannelElement() function
$Feed->setChannelElement('updated', date(DATE_ATOM, time()));
$Feed->setChannelElement('author', array('name' => 'WebID Test Suite'));
// fetch messages for the selected webid
// Limited to Wall posts until we can secure the private messages better
$query = "SELECT * FROM pingback_messages WHERE to_hash='" . mysql_real_escape_string($user_hash) . "' AND wall='1' ORDER BY date DESC LIMIT 10";
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result)) {
        }
        public function get_enclosures()
        {
            return null;
        }
        public function get_categories()
        {
            return null;
        }
    }
    $feed = new DummySingleItemFeed($url);
}
////////////////////////////////////////////
// Create full-text feed
////////////////////////////////////////////
$output = new FeedWriter();
if (_FF_FTR_MODE === 'simple') {
    $output->enableSimpleJson();
}
//$feed_title = $feed->get_title();
//echo $feed_title; exit;
$output->setTitle(strip_tags($feed->get_title()));
$output->setDescription(strip_tags($feed->get_description()));
$output->setXsl('css/feed.xsl');
// Chrome uses this, most browsers ignore it
$ttl = $feed->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'ttl');
if ($ttl !== null) {
    $ttl = (int) $ttl[0]['data'];
    $output->setTtl($ttl);
}
$output->setSelf(get_self_url());
예제 #19
0
<?php

// This is a minimum example of using the class
include "FeedWriter.php";
//Creating an instance of FeedWriter class.
$TestFeed = new FeedWriter(RSS2);
//Setting the channel elements
//Use wrapper functions for common channel elements
$TestFeed->setTitle('Testing & Checking the RSS writer class');
$TestFeed->setLink('http://www.ajaxray.com/projects/rss');
$TestFeed->setDescription('This is test of creating a RSS 2.0 feed Universal Feed Writer');
//Image title and link must match with the 'title' and 'link' channel elements for valid RSS 2.0
$TestFeed->setImage('Testing the RSS writer class', 'http://www.ajaxray.com/projects/rss', 'http://www.rightbrainsolution.com/images/logo.gif');
//Detriving informations from database addin feeds
$db->query($query);
$result = $db->result;
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
    //Create an empty FeedItem
    $newItem = $TestFeed->createNewItem();
    //Add elements to the feed item
    $newItem->setTitle($row['title']);
    $newItem->setLink($row['link']);
    $newItem->setDate($row['create_date']);
    $newItem->setDescription($row['description']);
    //Now add the feed item
    $TestFeed->addItem($newItem);
}
//OK. Everything is done. Now genarate the feed.
$TestFeed->genarateFeed();
예제 #20
0
 /**
  * @desc     Print channels
  * @access   private
  * @return   void
  */
 private function printChannels()
 {
     //Start channel tag
     switch ($this->version) {
         case RSS2:
             echo '<channel>' . PHP_EOL;
             break;
         case RSS1:
             echo isset($this->data['ChannelAbout']) ? "<channel rdf:about=\"{$this->data['ChannelAbout']}\">" : "<channel rdf:about=\"{$this->channels['link']}\">";
             break;
     }
     //Print Items of channel
     foreach ($this->channels as $key => $value) {
         if ($this->version == ATOM && $key == 'link') {
             // ATOM prints link element as href attribute
             echo $this->makeNode($key, '', array('href' => $value));
             //Add the id for ATOM
             echo $this->makeNode('id', FeedWriter::uuid($value, 'urn:uuid:'));
         } else {
             echo $this->makeNode($key, $value);
         }
     }
     //RSS 1.0 have special tag <rdf:Seq> with channel
     if ($this->version == RSS1) {
         echo "<items>" . PHP_EOL . "<rdf:Seq>" . PHP_EOL;
         foreach ($this->items as $item) {
             $thisItems = $item->getElements();
             echo "<rdf:li resource=\"{$thisItems['link']['content']}\"/>" . PHP_EOL;
         }
         echo "</rdf:Seq>" . PHP_EOL . "</items>" . PHP_EOL . "</channel>" . PHP_EOL;
     }
 }
예제 #21
0
파일: index.php 프로젝트: dollavon/tipi
$book_pages = BookPage::getFlatPagesArray();
/** Merge the pages **/
$pages = array_merge($news, $book_pages);
/** Sort Desc **/
function _sort_pages($page1, $page2)
{
    if ($page1->getLastUpdatedAt() == $page2->getLastUpdatedAt()) {
        return 0;
    }
    // Desc
    return $page1->getLastUpdatedAt() > $page2->getLastUpdatedAt() ? -1 : 1;
}
usort($pages, '_sort_pages');
/** Start Feed Output **/
$last_updated_at = null;
$feed = new FeedWriter(RSS2);
$feed->setTitle(SITE_NAME);
$feed->setLink(url_for("/", IS_ABSOLUTE_URL));
$feed->setDescription(SITE_DESC);
$feed->setChannelElement('language', 'zh-cn');
// get flat pages
foreach ($pages as $page) {
    $page_updated_at = $page->getLastUpdatedAt();
    if (!$last_updated_at || $page_updated_at > $last_updated_at) {
        $last_updated_at = $page_updated_at;
    }
    $render = new SimpieView($page->getPageFilePath(), '../templates/layout/feed.php');
    $feed_item = $feed->createNewItem();
    $feed_item->setTitle($page->getAbsTitle());
    $feed_item->setLink($page->getUrl(IS_ABSOLUTE_URL));
    $feed_item->setDescription($page->getPageContent($render));
예제 #22
0
<?php

include "FeedWriter.php";
//Creating an instance of FeedWriter class.
//The constant RSS1 is passed to mention the version
$TestFeed = new FeedWriter(RSS1);
//Setting the channel elements
//Use wrapper functions for common elements
//For other optional channel elements, use setChannelElement() function
$TestFeed->setTitle('Testing the RSS writer class');
$TestFeed->setLink('http://www.ajaxray.com/rss2/channel/about');
$TestFeed->setDescription('This is test of creating a RSS 1.0 feed by Universal Feed Writer');
//It's important for RSS 1.0
$TestFeed->setChannelAbout('http://www.ajaxray.com/rss2/channel/about');
//Adding a feed. Genarally this protion will be in a loop and add all feeds.
//Create an empty FeedItem
$newItem = $TestFeed->createNewItem();
//Add elements to the feed item
//Use wrapper functions to add common feed elements
$newItem->setTitle('The first feed');
$newItem->setLink('http://www.yahoo.com');
//The parameter is a timestamp for setDate() function
$newItem->setDate(time());
$newItem->setDescription('This is test of adding CDATA Encoded description by the php <b>Universal Feed Writer</b> class');
//Use core addElement() function for other supported optional elements
$newItem->addElement('dc:subject', 'Nothing but test');
//Now add the feed item
$TestFeed->addItem($newItem);
//Adding multiple elements from array
//Elements which have an attribute cannot be added by this way
$newItem = $TestFeed->createNewItem();
예제 #23
0
 /**
  * Set the unique identifier of the feed item
  * 
  * @access   public
  * @param    string  The unique identifier of this item
  * @return   void
  */
 public function setId($id)
 {
     if ($this->version == RSS2) {
         $this->addElement('guid', $id, array('isPermaLink' => 'false'));
     } else {
         if ($this->version == ATOM) {
             $this->addElement('id', FeedWriter::uuid($id, 'urn:uuid:'), NULL, TRUE);
         }
     }
 }
예제 #24
0
<?php

$arrAllArticles = $ogArticleManager->pullTokens(0, "", "id", "DESC");
$oFeedWriter = new FeedWriter(RSS2);
$oFeedWriter->setTitle($ogContentManager->getContent("RSSTitle", "Site RSS Feed"));
$oFeedWriter->setLink($ogContentManager->getContent("RSSLink", $fusebox['urlBase']));
$oFeedWriter->setDescription("RSSDescription", "Site RSS Feed Description");
$oFeedWriter->setImage($ogContentManager->getContent("RSSTitle", "Site RSS Feed"), $ogContentManager->getContent("RSSLink", "Site RSS Link"), $fusebox['urlAssets'] . 'images/rss.png');
foreach ($arrAllArticles as $a) {
    $oItem = $oFeedWriter->createNewItem();
    $oItem->setTitle($ogArticleManager->getTitle($a['token']));
    $oItem->setLink($fusebox['urlBase'] . $a['token'] . ".page");
    $oItem->setDate($ogArticleManager->getCreatedDate($a['token']));
    $oItem->setDescription($ogArticleManager->getContent($a['token']));
    $oFeedWriter->addItem($oItem);
}
$oFeedWriter->genarateFeed();
예제 #25
0
 /**
  * Filter tickets by certain condition
  *
  */
 public function actionFilterIssues($type, $id, $alias, $rss = null)
 {
     // Initiate Criteria
     $criteria = new CDbCriteria();
     $pages = new CPagination();
     $pages->route = '/issues/' . $type . '/' . $id . '/' . $alias;
     switch ($type) {
         case 'status':
             $criteria->condition = 't.ticketstatus=:status';
             $criteria->params = array(':status' => $id);
             break;
         case 'type':
             $criteria->condition = 't.tickettype=:type';
             $criteria->params = array(':type' => $id);
             break;
         case 'priority':
             $criteria->condition = 't.priority=:priority';
             $criteria->params = array(':priority' => $id);
             break;
         case 'category':
             $criteria->condition = 't.ticketcategory=:category';
             $criteria->params = array(':category' => $id);
             break;
         case 'version':
             $criteria->condition = 't.ticketversion=:version';
             $criteria->params = array(':version' => $id);
             break;
         case 'fixedin':
             $criteria->condition = 't.fixedin=:fixedin';
             $criteria->params = array(':fixedin' => $id);
             break;
         case 'milestone':
             $criteria->condition = 't.milestone=:milestone';
             $criteria->params = array(':milestone' => $id);
             break;
         default:
             $this->redirect(array('/tickets'));
             break;
     }
     // Initiate Pager
     $count = Tickets::model()->count($criteria);
     $pages->pageSize = Yii::app()->params['ticketsPerPage'];
     $pages->applyLimit($criteria);
     // Load them
     $tickets = Tickets::model()->with(array('reporter', 'assigned', 'status', 'type', 'category', 'ticketpriority', 'version', 'fixed', 'ticketmilestone'))->byDate()->findAll($criteria);
     // Did we wanted to see the rss
     if ($rss && in_array($rss, array('rss', 'atom'))) {
         // Load the feed writer
         Yii::import('ext.FeedWriter.FeedWriter');
         $feedWriter = new FeedWriter($rss == 'atom' ? ATOM : RSS2);
         $channelElems = array('title' => Yii::t('tickets', 'Tickets Feed'), 'link' => Yii::app()->createAbsoluteUrl('/tickets'), 'charset' => Yii::app()->charset, 'description' => Yii::t('tickets', 'Tickets Feed'), 'author' => Yii::app()->name, 'generator' => Yii::app()->name, 'language' => Yii::app()->language, 'ttl' => 10);
         // Set channel elements
         $feedWriter->setChannelElementsFromArray($channelElems);
         if ($tickets) {
             foreach ($tickets as $r) {
                 $newItem = $feedWriter->createNewItem();
                 $itemElems = array('title' => htmlspecialchars($r->title), 'link' => Yii::app()->createAbsoluteUrl('/issue/' . $r->id . '/' . $r->alias), 'charset' => Yii::app()->charset, 'description' => htmlspecialchars(substr(strip_tags($r->content), 0, 100)), 'author' => $r->reporter ? $r->reporter->username : Yii::app()->name, 'generator' => Yii::app()->name, 'language' => Yii::app()->language, 'guid' => $r->id, 'content' => htmlspecialchars($r->content));
                 $newItem->addElementArray($itemElems);
                 //Now add the feed item
                 $feedWriter->addItem($newItem);
             }
         }
         // Display & end
         echo $feedWriter->genarateFeed();
         exit;
     }
     // Load the quick moderation form
     $moderation = new TicketsQuickModeration();
     // Title
     $this->pageTitle[] = Yii::t('tickets', 'Viewing Issues');
     // Render
     $this->render('ticketslist', array('total' => $count, 'tickets' => $tickets, 'pages' => $pages, 'moderation' => $moderation));
 }
예제 #26
0
            $thread_name = '';
        }
    } else {
        $feed = $rssC->get_section($section, $uinfo);
        $title = $rssC->get_title($section, $subsection, $tid);
        $section_name = ' - ' . $title['section_name'];
        $subsection_name = '';
        $thread_name = '';
    }
} else {
    $feed = $rssC->get_all($uinfo);
    $section_name = '';
    $subsection_name = '';
    $thread_name = '';
}
$TestFeed = new FeedWriter(RSS2);
$site_name = $_SERVER["HTTP_HOST"];
$title = $site_name . $section_name . $subsection_name . $thread_name;
$TestFeed->setTitle($title);
$TestFeed->setImage($title, 'http://' . $site_name . '/', 'http://' . $site_name . '/rss_icon.png');
if (!empty($feed)) {
    for ($i = 0; $i < count($feed); $i++) {
        $newItem = $TestFeed->createNewItem();
        $newItem->setTitle($feed[$i]['title']);
        $newItem->setLink($feed[$i]['link']);
        $newItem->setDate($feed[$i]['time']);
        $newItem->setDescription($feed[$i]['description']);
        $TestFeed->addItem($newItem);
    }
}
$TestFeed->genarateFeed();
/**
 * Universal Feed Loader
 * hooked function
 * supports custom settings
 * NOTE uses just-in-time initialization
 * @see     functions.php, feed-links include module
 * @uses    Universal Feed Writer class
 */
function tLoadFeed()
{
    global $tFeeds, $tCurrentFeed, $wp_query, $post;
    $tCurrentFeed = get_query_var('feed');
    // FB::trace($tCurrentFeed);
    if (empty($tCurrentFeed) || $tCurrentFeed == 'feed') {
        $tCurrentFeed = get_default_feed();
        # rss2
    }
    $args =& $tFeeds[$tCurrentFeed];
    $defaults = array('num_entries' => get_option('posts_per_rss'), 'do_images' => true, 'size_image' => 'large', 'feed_type' => defined('TFEED') ? TFEED : 'atom', 'feed_title' => 'Recent Posts', 'feed_description' => 'An unfiltered list limited to ' . $num_entries . ' posts');
    $args = apply_filters('t_load_feed_args', $args);
    $args = wp_parse_args($args, $defaults);
    # customizing default info
    if (is_category()) {
        $category = t_get_term_name(get_query_var('cat'), 'category');
        $args['feed_title'] = 'Feed for ' . $category;
        $args['feed_description'] = 'A list limited to ' . $args['num_entries'] . ' posts categorized under ' . $category;
    }
    if ($wp_query->is_comment_feed) {
        # comment feed
        if (is_singular()) {
            $args['feed_title'] = 'Recent comments on ' . get_the_title_rss();
        } elseif (is_search()) {
            $args['feed_title'] = 'Comments for search on ' . attribute_escape($wp_query->query_vars['s']);
        } else {
            $args['feed_title'] = 'Recent comments for ' . get_wp_title_rss();
        }
        $args['feed_title'] = ent2ncr($args['feed_title']);
        $args['feed_description'] = 'A list limited to ' . $args['num_entries'] . ' comments';
    }
    $args['query'] = tGetFeedQuery();
    if (is_array($args['query'])) {
        $args['query']['showposts'] =& $args['num_entries'];
    }
    if ($tCurrentFeed == 'rss' || $tCurrentFeed == 'rss2' || $tCurrentFeed == 'atom') {
        $args['feed_type'] = $tCurrentFeed;
    } else {
        $args['feed_title'] = ucwords(str_replace('_', ' ', $tCurrentFeed));
    }
    extract($args);
    # namespacing
    switch ($feed_type) {
        case 'rss2':
            $namespace = '
                 xmlns:dc="http://purl.org/dc/elements/1.1/"
                 xmlns:atom="http://www.w3.org/2005/Atom"
                 xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
                ';
            $feedType = RSS2;
            break;
        case 'rss':
            $namespace = '
                 xmlns:dc="http://purl.org/dc/elements/1.1/"
                 xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
                 xmlns:admin="http://webns.net/mvcb/"
                 xmlns:content="http://purl.org/rss/1.0/modules/content/"
                ';
            $feedType = RSS1;
            break;
        case 'atom':
        default:
            $namespace = '
                 xmlns:thr="http://purl.org/syndication/thread/1.0"
                 xml:lang="' . get_option('rss_language') . '"
                 xml:base="' . get_bloginfo_rss('url') . '"
                 ';
            $feedType = ATOM;
            break;
    }
    $GLOBALS['t_feed_ns'] = $namespace;
    # for use in FeedWriter
    add_filter('t_feed_ns', create_function('$default', 'return $default . $GLOBALS["t_feed_ns"];'));
    # start
    $feedWriter = new FeedWriter($feedType);
    require TDIR . TMODINC . 'feed-head.php';
    require TDIR . TMODINC . 'feed-body.php';
    # output
    $out = ob_get_contents();
    $out = str_replace(array("\n", "\r", "\t", ' '), '', $input);
    ob_end_clean();
    $feedWriter->generateFeed();
    // lifestream_rss_feed();
    // FB::info($args);
}
예제 #28
0
<?php

require __DIR__ . '/../inc/core.php';
require __DIR__ . '/../inc/feedwriter.php';
$id = trim($_GET['id'], '\'');
$version = null;
if (!empty($_GET['version'])) {
    $version = trim($_GET['version'], '\'');
}
$results = DB::findByID($id, $version);
$feed = new FeedWriter('FindPackagesById');
$feed->writeToOutput($results);
예제 #29
0
        }
        public function get_enclosures()
        {
            return null;
        }
        public function get_categories()
        {
            return null;
        }
    }
    $feed = new DummySingleItemFeed($url);
}
////////////////////////////////////////////
// Create full-text feed
////////////////////////////////////////////
$output = new FeedWriter();
$output->setTitle(strip_tags($feed->get_title()));
$output->setDescription(strip_tags($feed->get_description()));
$output->setXsl('css/feed.xsl');
// Chrome uses this, most browsers ignore it
if ($valid_key && isset($_GET['pubsub'])) {
    // used only on fivefilters.org at the moment
    $output->addHub('http://fivefilters.superfeedr.com/');
    $output->addHub('http://pubsubhubbub.appspot.com/');
    $output->setSelf('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
}
$output->setLink($feed->get_link());
// Google Reader uses this for pulling in favicons
if ($img_url = $feed->get_image_url()) {
    $output->setImage($feed->get_title(), $feed->get_link(), $img_url);
}
 public static function output($event_id = NULL, $event_cat = NULL, $page = 1, $is_download = FALSE, $is_push = FALSE)
 {
     //ob_clean();
     //ini_set('zlib.output_handler','');
     $EM_Events = !empty($event_id) ? array(em_get_event($event_id)) : EM_Events::get(apply_filters('em_calendar_template_args', array('limit' => get_option('ess_feed_limit'), 'category' => $event_cat, 'page' => $page, 'owner' => FALSE, 'orderby' => 'event_start_date')));
     $limit = 0;
     //no limit for now, but this shall be eventually set in the wP settings page, option name dbem_ess_limit
     //var_dump( $EM_Events );die;
     //echo "count: ".count($EM_Events);
     //echo "limit: " . get_option('ess_feed_limit', $limit );
     //echo "event_id: ". $event_id;
     //die;
     $essFeed = new FeedWriter(strlen(get_option('ess_feed_language')) == 2 ? get_option('ess_feed_language', ESS_Database::DEFAULT_LANGUAGE) : ESS_Database::DEFAULT_LANGUAGE);
     $essFeed->DEBUG = FALSE;
     // ###  DEBUG  MODE
     $essFeed->setTitle(self::_g('ess_feed_title', __('ESS Feed generated by Wordpress', 'dbem')));
     $essFeed->setLink(str_replace('&push=1', '', str_replace('&download=1', '', FeedWriter::getCurrentURL())));
     $essFeed->setPublished(ESS_Timezone::get_date_GMT(get_option('em_last_modified', current_time('timestamp', TRUE))));
     $essFeed->setUpdated(ESS_Timezone::get_date_GMT(current_time('timestamp', TRUE)));
     $essFeed->setRights(self::_g('ess_feed_rights', 'Rights'));
     $count = 0;
     while (count($EM_Events) > 0) {
         foreach ($EM_Events as $ie => $EM_Event) {
             if (intval($EM_Event->event_id) <= 0) {
                 // event empty
                 break;
             }
             if (get_option('ess_feed_limit', $limit) != 0 && $count > get_option('ess_feed_limit', $limit)) {
                 //we've reached the max event per feed
                 break;
             }
             //dd( $EM_Event );
             $event_url = self::unhtmlentities(esc_html(urldecode($EM_Event->guid)));
             // --- Create a new event to the feed: <feed>
             $newEvent = $essFeed->newEventFeed();
             $newEvent->setTitle($EM_Event->output(get_option('dbem_rss_title_format', sprintf(__('Event Nb: %d', 'dbem'), $ie)), "rss"));
             $newEvent->setUri($event_url);
             $newEvent->setPublished(ESS_Timezone::get_date_GMT(strtotime($EM_Event->post_date)));
             $newEvent->setUpdated(ESS_Timezone::get_date_GMT(strtotime($EM_Event->post_modified)));
             $newEvent->setAccess(intval($EM_Event->event_private) === 1 ? EssDTD::ACCESS_PRIVATE : EssDTD::ACCESS_PUBLIC);
             // -- encode a unic ID base on the host name + event_id (e.g. www.sample.com:123)
             $newEvent->setId((strlen(@$_SERVER['SERVER_NAME']) > 0 ? $_SERVER['SERVER_NAME'] : @$_SERVER['HTTP_HOST']) . ":" . $EM_Event->event_id);
             $description = wpautop($EM_Event->post_content, TRUE);
             if (get_option('ess_backlink_enabled')) {
                 $feed_uri_host = parse_url($event_url, PHP_URL_HOST);
                 $description = "<h6>" . __("Source:", 'dbem') . " <a target=\"_blank\" title=\"" . __("Source:", 'dbem') . " " . $feed_uri_host . "\" href=\"" . $event_url . "\">" . $feed_uri_host . "</a></h6>" . $description;
             }
             //dd( $description );
             // Add custom attributes json encoded in HTML comments <!--||ATTR||xx{xx:'xx',xx...}||ATTR||-->
             if (@count(@$EM_Event->event_attributes) > 0 && @$EM_Event->event_attributes != NULL) {
                 $custom_att = $EM_Event->event_attributes;
                 //dd( $custom_att );
                 $description .= "<!--" . self::CUSTOM_ATTRIBUTE_SEPARATOR . json_encode(iconv(mb_detect_encoding($custom_att, mb_detect_order(), TRUE), "UTF-8", $custom_att), JSON_UNESCAPED_SLASHES) . self::CUSTOM_ATTRIBUTE_SEPARATOR . "-->";
             }
             $newEvent->setDescription($description);
             //dd( $description );
             // ====== TAGS ========
             $tags = get_the_terms($EM_Event->post_id, EM_TAXONOMY_TAG);
             //var_dump( $tags );
             if (count($tags) > 0 && $tags != NULL) {
                 $arr_ = array();
                 foreach ($tags as $tag) {
                     if (strlen($tag->name) > 1 && is_numeric($tag->name) == FALSE) {
                         array_push($arr_, $tag->name);
                     }
                 }
                 if (count($arr_) > 0) {
                     $newEvent->setTags($arr_);
                 }
             }
             // ====== CATEGORIES ========
             //dd( $EM_Event );
             // $categories_ = EM_Categories::get( $EM_Event->get_categories()->get_ids() ); // enumerate all the categories
             if (@count(@$EM_Event->categories) > 0 && @$EM_Event->categories != NULL) {
                 $cat_duplicates_ = array();
                 foreach ($EM_Event->categories as $cat) {
                     $category_type = get_option('ess_feed_category_type');
                     if (strlen($cat->name) > 0 && strlen($category_type) > 3) {
                         if (in_array(strtolower($cat->name), $cat_duplicates_) == FALSE) {
                             $newEvent->addCategory($category_type, array('name' => $cat->name, 'id' => $cat->id));
                         }
                         $cat_duplicates_[] = strtolower($cat->name);
                     }
                 }
             }
             // ====== DATES =========
             $event_start = NULL;
             if (isset($EM_Event->event_start_date) && isset($EM_Event->event_end_date)) {
                 $event_start = ESS_Timezone::get_date_GMT(strtotime($EM_Event->event_start_date . " " . $EM_Event->event_start_time));
                 $event_stop = ESS_Timezone::get_date_GMT(strtotime($EM_Event->event_end_date . " " . $EM_Event->event_end_time));
                 // -- STANDALONE -----
                 if ($EM_Event->recurrence <= 0) {
                     $duration_s = FeedValidator::getDateDiff('s', $event_start, $event_stop);
                     // number of seconds between two dates
                     $newEvent->addDate('standalone', 'hour', NULL, NULL, NULL, NULL, array('name' => __('Date', 'dbem'), 'start' => $event_start, 'duration' => $duration_s > 0 ? $duration_s / 60 / 60 : 0));
                 } else {
                     $interval = intval($EM_Event->recurrence_interval);
                     $u = $EM_Event->recurrence_freq;
                     $event_unit = $u == 'daily' ? 'day' : ($u == 'weekly' ? 'week' : ($u == 'monthly' ? 'month' : ($u == 'yearly' ? 'year' : 'hour')));
                     switch ($event_unit) {
                         default:
                         case 'day':
                             $limit = FeedValidator::getDateDiff('d', $event_start, $event_stop);
                             break;
                             // number of days
                         // number of days
                         case 'hour':
                             $limit = FeedValidator::getDateDiff('h', $event_start, $event_stop);
                             break;
                             // number of hours
                         // number of hours
                         case 'week':
                             $limit = FeedValidator::getDateDiff('ww', $event_start, $event_stop);
                             break;
                             // number of weeks
                         // number of weeks
                         case 'month':
                             $limit = FeedValidator::getDateDiff('m', $event_start, $event_stop);
                             break;
                             // number of months
                         // number of months
                         case 'year':
                             $limit = FeedValidator::getDateDiff('yyyy', $event_start, $event_stop);
                             break;
                             // number of years
                     }
                     $d = intval($EM_Event->recurrence_byday);
                     $selected_day = $event_unit == 'year' || $event_unit == 'month' || $event_unit == 'week' ? $d == 0 ? 'sunday' : ($d == 1 ? 'monday' : ($d == 2 ? 'tuesday' : ($d == 3 ? 'wednesday' : ($d == 4 ? 'thursday' : ($d == 5 ? 'friday' : ($d == 6 ? 'saturday' : '')))))) : '';
                     $w = intval($EM_Event->recurrence_byweekno);
                     $selected_week = $event_unit == 'month' ? $w == -1 ? 'last' : ($w == 1 ? 'first' : ($w == 2 ? 'second' : ($w == 3 ? 'third' : ($w == 4 ? 'fourth' : '')))) : '';
                     $newEvent->addDate('recurrent', $event_unit, $limit, $interval, $selected_day, $selected_week, array('name' => sprintf(__('Date: %s', 'dbem'), $event_start), 'start' => $event_start, 'duration' => 0));
                 }
             }
             // end date
             // ====== PLACES ========
             $places_ = $EM_Event->get_location();
             //var_dump( $places_ );
             if (is_object($places_) && strlen($places_->location_name) > 0) {
                 $newEvent->addPlace('fixed', null, array('name' => $places_->location_name == $places_->location_address ? sprintf(__('Place: %s', 'dbem'), $places_->location_name) : $places_->location_name, 'latitude' => isset($places_->location_latitude) ? round($places_->location_latitude * 10000) / 10000 : '', 'longitude' => isset($places_->location_longitude) ? round($places_->location_longitude * 10000) / 10000 : '', 'address' => strlen($places_->location_address) > 0 ? $places_->location_address : $places_->location_name, 'city' => $places_->location_town, 'zip' => $places_->location_postcode, 'state' => $places_->location_region, 'state_code' => $places_->location_state, 'country' => FeedValidator::$COUNTRIES_[strtoupper($places_->location_country)], 'country_code' => strtolower($places_->location_country) == 'xe' ? '' : $places_->location_country));
             }
             // end place
             // ====== PRICES =========
             if ($EM_Event->is_free() == TRUE) {
                 $newEvent->addPrice('standalone', 'free', NULL, NULL, NULL, NULL, NULL, array('name' => __('Free', 'dbem'), 'currency' => get_option('ess_feed_currency', ESS_Database::DEFAULT_CURRENCY), 'value' => 0));
             } else {
                 $prices_ = $EM_Event->get_bookings();
                 //dd($prices_);
                 if ($prices_) {
                     if (count($prices_->tickets->tickets) > 0 && $event_start != NULL && $prices_->tickets->tickets != NULL) {
                         if (isset($prices_->tickets)) {
                             if (is_array($prices_->tickets->tickets)) {
                                 foreach ($prices_->tickets->tickets as $i => $price) {
                                     if (is_object($price)) {
                                         $duration_s = $price->ticket_start && $price->ticket_end ? FeedValidator::getDateDiff('s', $price->ticket_start, $price->ticket_end) : 0;
                                         $ticket_start = isset($price->ticket_start) ? ESS_Timezone::get_date_GMT(strtotime($price->ticket_start)) : 0;
                                         $ticket_end = isset($price->ticket_end) ? ESS_Timezone::get_date_GMT(strtotime($price->ticket_end)) : 0;
                                         $p = intval($price->ticket_price);
                                         $e_start = strtotime($event_start);
                                         $t_end = strtotime($ticket_end);
                                         $t_mode = $p > 0 ? $e_start < $t_end || $ticket_end == 0 ? 'fixed' : 'prepaid' : 'free';
                                         $newEvent->addPrice('standalone', $t_mode, "hour", NULL, NULL, NULL, NULL, array('name' => strlen($price->ticket_name) > 0 ? $price->ticket_name : sprintf(__("Ticket Nb %s", 'dbem'), $i), 'currency' => get_option('ess_feed_currency', ESS_Database::DEFAULT_CURRENCY), 'value' => intval($price->ticket_price) > 0 ? $price->ticket_price : 0, 'start' => isset($price->ticket_start) ? $ticket_start : '', 'duration' => intval($duration_s) > 0 ? $duration_s / 60 / 60 : 0, 'uri' => $event_url . "#em-booking"));
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             // end prices
             // ====== PEOPLE ===========
             $people_ = $EM_Event->get_contact();
             //var_dump( $people_ );
             if ($people_ instanceof EM_Person) {
                 $owner_name = strlen(self::_g('ess_owner_firstname')) > 0 && strlen(self::_g('ess_owner_lastname')) > 0 ? trim(self::_g('ess_owner_firstname') . " " . self::_g('ess_owner_lastname')) : $people_->data->display_name;
                 if (strlen($owner_name) > 0 && get_option('ess_owner_activate')) {
                     $newEvent->addPeople('organizer', array('name' => $owner_name, 'firstname' => self::_g('ess_owner_firstname'), 'lastname' => self::_g('ess_owner_lastname'), 'organization' => self::_g('ess_owner_company'), 'logo' => '', 'icon' => '', 'uri' => self::_g('ess_owner_website'), 'address' => self::_g('ess_owner_address'), 'city' => self::_g('ess_owner_city'), 'zip' => self::_g('ess_owner_zip'), 'state' => self::_g('ess_owner_state'), 'state_code' => '', 'country' => FeedValidator::$COUNTRIES_[strtoupper(self::_g('ess_owner_country'))], 'country_code' => strtolower(self::_g('ess_owner_country')) == 'xe' ? 'GB' : self::_g('ess_owner_country'), 'email' => self::_g('ess_owner_email'), 'phone' => self::_g('ess_owner_phone')));
                 }
                 foreach (ESS_Database::$SOCIAL_PLATFORMS as $type => $socials_) {
                     foreach ($socials_ as $social) {
                         if (FeedValidator::isValidURL(get_option('ess_social_' . $social))) {
                             $newEvent->addPeople('social', array('name' => __(ucfirst($social), 'dbem'), 'uri' => self::_g('ess_social_' . $social)));
                         }
                     }
                 }
                 if (strlen(self::_g('ess_feed_title')) > 0 && FeedValidator::isValidURL(self::_g('ess_feed_website'))) {
                     $newEvent->addPeople('author', array('name' => self::_g('ess_feed_title'), 'uri' => self::_g('ess_feed_website')));
                 }
                 if (strlen($EM_Event->post_excerpt) > 0) {
                     $newEvent->addPeople('attendee', array('name' => __('Required'), 'minpeople' => 0, 'maxpeople' => 0, 'minage' => 0, 'restriction' => esc_html($EM_Event->post_excerpt)));
                 }
             }
             // ====== MEDIA ============
             // -- IMAGES -----
             if (get_option('ess_feed_export_images')) {
                 $IMG_ = array();
                 $media_url = $EM_Event->get_image_url();
                 if (FeedValidator::isValidURL($media_url)) {
                     array_push($IMG_, array('name' => __('Main Image', 'dbem'), 'uri' => $media_url));
                 }
                 $images_ = ESS_Images::get($EM_Event->post_id);
                 if (count($images_) > 0 && $images_ != NULL) {
                     foreach ($images_ as $i => $img_) {
                         array_push($IMG_, array('name' => strlen($img_['name']) > 0 ? $img_['name'] : sprintf(__('Image %d', 'dbem'), $i), 'uri' => $img_['uri']));
                     }
                 }
                 if (count($IMG_) > 0 && $IMG_ != NULL) {
                     $IMG_ = array_map("unserialize", array_unique(array_map("serialize", $IMG_)));
                     $duplicates_ = array();
                     foreach ($IMG_ as $i => $img_) {
                         if (!in_array($img_['uri'], $duplicates_)) {
                             $newEvent->addMedia('image', array('name' => strlen($img_['name']) > 0 ? sprintf(__('Image %d', 'dbem'), $i) : $img_['name'], 'uri' => $img_['uri']));
                         }
                         array_push($duplicates_, $img_['uri']);
                     }
                 }
             }
             // -- SOUNDS -----
             if (get_option('ess_feed_export_sounds')) {
                 // TODO:...
             }
             // -- VIDEOS -----
             if (get_option('ess_feed_export_videos')) {
                 // TODO:...
             }
             // -- WEBSITES -----
             if (FeedValidator::isValidURL(self::_g('ess_feed_website'))) {
                 $newEvent->addMedia('website', array('name' => __('The website', 'dbem'), 'uri' => self::_g('ess_feed_website')));
             }
             $essFeed->addItem($newEvent);
             $count++;
         }
         // -- We've reached the limit of event per feed, or showing one event only
         if (!empty($event_id) || intval($event_id) <= 0 || get_option('ess_feed_limit', $limit) != 0 && $count > get_option('ess_feed_limit', $limit) || $count <= get_option('ess_feed_limit', $limit) && intval($page) <= 1) {
             break;
         } else {
             //-- Go to the next page of results
             $page++;
             self::output($event_id, $page, $is_download, $is_push);
         }
     }
     $essFeed->IS_DOWNLOAD = $is_download === TRUE ? TRUE : FALSE;
     $essFeed->AUTO_PUSH = get_option('ess_feed_push', TRUE) && $is_push === TRUE ? TRUE : FALSE;
     //var_dump( $essFeed );
     $essFeed->genarateFeed();
 }