function testRSSFeed()
 {
     $list = new DataObjectSet();
     $list->push(new RSSFeedTest_ItemA());
     $list->push(new RSSFeedTest_ItemB());
     $list->push(new RSSFeedTest_ItemC());
     $origServer = $_SERVER;
     $_SERVER['HTTP_HOST'] = 'www.example.org';
     Director::setBaseURL('/');
     $rssFeed = new RSSFeed($list, "http://www.example.com", "Test RSS Feed", "Test RSS Feed Description");
     $content = $rssFeed->feedContent();
     //Debug::message($content);
     $this->assertContains('<link>http://www.example.org/item-a/</link>', $content);
     $this->assertContains('<link>http://www.example.com/item-b.html</link>', $content);
     $this->assertContains('<link>http://www.example.com/item-c.html</link>', $content);
     $this->assertContains('<title>ItemA</title>', $content);
     $this->assertContains('<title>ItemB</title>', $content);
     $this->assertContains('<title>ItemC</title>', $content);
     $this->assertContains('<description>ItemA Content</description>', $content);
     $this->assertContains('<description>ItemB Content</description>', $content);
     $this->assertContains('<description>ItemC Content</description>', $content);
     // Feed #2 - put Content() into <title> and AltContent() into <description>
     $rssFeed = new RSSFeed($list, "http://www.example.com", "Test RSS Feed", "Test RSS Feed Description", "Content", "AltContent");
     $content = $rssFeed->feedContent();
     $this->assertContains('<title>ItemA Content</title>', $content);
     $this->assertContains('<title>ItemB Content</title>', $content);
     $this->assertContains('<title>ItemC Content</title>', $content);
     $this->assertContains('<description>ItemA AltContent</description>', $content);
     $this->assertContains('<description>ItemB AltContent</description>', $content);
     $this->assertContains('<description>ItemC AltContent</description>', $content);
     Director::setBaseURL(null);
     $_SERVER = $origServer;
 }
 /**
  * Return an RSS feed of comments for a given set of comments or all 
  * comments on the website.
  *
  * To maintain backwards compatibility with 2.4 this supports mapping
  * of PageComment/rss?pageid= as well as the new RSS format for comments
  * of CommentingController/rss/{classname}/{id}
  *
  * @return RSS
  */
 public function rss()
 {
     $link = $this->Link('rss');
     $class = $this->urlParams['ID'];
     $id = $this->urlParams['OtherID'];
     if (isset($_GET['pageid'])) {
         $id = Convert::raw2sql($_GET['pageid']);
         $comments = Comment::get()->where(sprintf("BaseClass = 'SiteTree' AND ParentID = '%s' AND Moderated = 1 AND IsSpam = 0", $id));
         $link = $this->Link('rss', 'SiteTree', $id);
     } else {
         if ($class && $id) {
             if (Commenting::has_commenting($class)) {
                 $comments = Comment::get()->where(sprintf("BaseClass = '%s' AND ParentID = '%s' AND Moderated = 1 AND IsSpam = 0", Convert::raw2sql($class), Convert::raw2sql($id)));
                 $link = $this->Link('rss', Convert::raw2xml($class), (int) $id);
             } else {
                 return $this->httpError(404);
             }
         } else {
             if ($class) {
                 if (Commenting::has_commenting($class)) {
                     $comments = Comment::get()->where(sprintf("BaseClass = '%s' AND Moderated = 1 AND IsSpam = 0", Convert::raw2sql($class)));
                 } else {
                     return $this->httpError(404);
                 }
             } else {
                 $comments = Comment::get();
             }
         }
     }
     $title = _t('CommentingController.RSSTITLE', "Comments RSS Feed");
     $feed = new RSSFeed($comments, $link, $title, $link, 'Title', 'Comment', 'AuthorName');
     $feed->outputToBrowser();
 }
Ejemplo n.º 3
0
 function testRSSFeed()
 {
     $list = new ArrayList();
     $list->push(new RSSFeedTest_ItemA());
     $list->push(new RSSFeedTest_ItemB());
     $list->push(new RSSFeedTest_ItemC());
     $rssFeed = new RSSFeed($list, "http://www.example.com", "Test RSS Feed", "Test RSS Feed Description");
     $content = $rssFeed->feedContent();
     //Debug::message($content);
     $this->assertContains('<link>http://www.example.org/item-a/</link>', $content);
     $this->assertContains('<link>http://www.example.com/item-b.html</link>', $content);
     $this->assertContains('<link>http://www.example.com/item-c.html</link>', $content);
     $this->assertContains('<title>ItemA</title>', $content);
     $this->assertContains('<title>ItemB</title>', $content);
     $this->assertContains('<title>ItemC</title>', $content);
     $this->assertContains('<description>ItemA Content</description>', $content);
     $this->assertContains('<description>ItemB Content</description>', $content);
     $this->assertContains('<description>ItemC Content</description>', $content);
     // Feed #2 - put Content() into <title> and AltContent() into <description>
     $rssFeed = new RSSFeed($list, "http://www.example.com", "Test RSS Feed", "Test RSS Feed Description", "Content", "AltContent");
     $content = $rssFeed->feedContent();
     $this->assertContains('<title>ItemA Content</title>', $content);
     $this->assertContains('<title>ItemB Content</title>', $content);
     $this->assertContains('<title>ItemC Content</title>', $content);
     $this->assertContains('<description>ItemA AltContent</description>', $content);
     $this->assertContains('<description>ItemB AltContent</description>', $content);
     $this->assertContains('<description>ItemC AltContent</description>', $content);
 }
Ejemplo n.º 4
0
 function rss()
 {
     $request = Controller::curr()->getRequest();
     $foundation = $request->requestVar('foundation');
     $jobs = $this->repository->getDateSortedJobs($foundation);
     $rss = new RSSFeed($jobs, $this->Link(), "OpenStack Jobs Feed");
     $rss->outputToBrowser();
 }
 public function rss()
 {
     $config = SiteConfig::current_site_config();
     // Creates a new RSS Feed list
     $rss = new RSSFeed($list = NewsArticle::get(), $link = $this->Link("rss"), $title = $config->Title . " News", $description = "All the latest news from " . $config->Title . ".");
     // Outputs the RSS feed to the user.
     return $rss->outputToBrowser();
 }
 public function testRenderWithTemplate()
 {
     $rssFeed = new RSSFeed(new ArrayList(), "", "", "");
     $rssFeed->setTemplate('RSSFeedTest');
     $content = $rssFeed->outputToBrowser();
     $this->assertContains('<title>Test Custom Template</title>', $content);
     $rssFeed->setTemplate('RSSFeed');
     $content = $rssFeed->outputToBrowser();
     $this->assertNotContains('<title>Test Custom Template</title>', $content);
 }
Ejemplo n.º 7
0
 /**
  * Возвращает RSS комментариев.
  * @route GET//comments.rss
  */
 public static function on_get_rss(Context $ctx)
 {
     if (!class_exists('RSSFeed')) {
         throw new PageNotFoundException(t('Модуль rss не установлен.'));
     }
     $filter = array('class' => 'comment', 'deleted' => 0, 'published' => 1, '#limit' => 20, '#sort' => '-id');
     $title = t('Комментарии на %host', array('%host' => MCMS_HOST_NAME));
     $feed = new RSSFeed($filter);
     return $feed->render($ctx, array('title' => $title, 'description' => $title . '.', 'xsl' => os::path('lib', 'modules', 'comment', 'rss.xsl')));
 }
 function tag()
 {
     $blogName = $this->owner->Title . " - " . ucwords($this->owner->request->latestParam('ID'));
     if ($this->owner->request->param('Action') == 'tag' && $this->owner->request->param('OtherID') == "rss") {
         $entries = $this->owner->Entries(20, Convert::raw2xml($this->owner->request->latestParam('ID')));
         if ($entries) {
             $rss = new RSSFeed($entries, $this->owner->Link('rss'), $blogName, "", "Title", "RSSContent");
             return $rss->outputToBrowser();
         }
     } else {
         return $this->owner;
     }
 }
Ejemplo n.º 9
0
 public static function on_get_custom(Context $ctx)
 {
     $filter = array();
     if (!($filter['class'] = $ctx->get('type'))) {
         $filter['class'] = $ctx->db->getResultsV("name", "SELECT name FROM node WHERE class = 'type' AND deleted = 0 AND published = 1");
     }
     if ($tmp = $ctx->get('tags')) {
         $filter['tags'] = explode('+', $tmp);
     }
     if ($tmp = $ctx->get('author')) {
         $filter['uid'] = $tmp;
     }
     $feed = new RSSFeed($filter);
     return $feed->render($ctx);
 }
 /**
  *
  */
 function init()
 {
     RSSFeed::linkToFeed(Director::baseURL() . $this->URLSegment . "/episodesRSS");
     if (Director::is_ajax()) {
         $this->isAjax = true;
     } else {
         $this->isAjax = false;
     }
     parent::init();
 }
 public function init()
 {
     // Adds the requirements for the Podcast and Episode Page in the correct order
     Requirements::javascript('framework/thirdparty/jquery/jquery.js');
     Requirements::javascript('podcast/thirdparty/mediaelement/mediaelement-and-player.min.js');
     Requirements::javascript('podcast/javascript/podcast-page.js');
     Requirements::css('podcast/thirdparty/mediaelement/mediaelementplayer.min.css');
     Requirements::css('podcast/css/podcast-page.css');
     // Provides a link to the Podcast RSS in the HTML head
     RSSFeed::linkToFeed($this->Link('rss'));
     parent::init();
 }
Ejemplo n.º 12
0
 public static function importString($string)
 {
     $xml = simplexml_load_string($string);
     if ($xml === false) {
         return;
     }
     if (isset($xml->channel)) {
         // RSS
         return RSSFeed::import($xml->channel[0]);
     }
     if (isset($xml->entry)) {
         // Atom
         return AtomFeed::import($xml);
     }
 }
 public function rss()
 {
     $SiteConfig = SiteConfig::current_site_config();
     $rss = new RSSFeed(NewsArticle::get(), $this->Link(), $SiteConfig->Title);
     return $rss->outputToBrowser();
 }
Ejemplo n.º 14
0
$xssDomain = $tmp[2];
$tmp = "";
//$getData = XML_unserialize($test);
//print_r($getData);
/*******************************************************
* 开始存储数据到xml文件
********************************************************/
$fpath = "../slave/slave.xml";
$slaveData = new OpXML('slaveData', $fpath);
//增加一条记录
$arr = array('requestDate' => $requestDate, 'slaveWatermark' => $slaveWatermark, 'slaveIP' => $slaveIP, 'slaveUA' => $slaveUA, 'slaveLang' => $slaveLang, 'slaveProxy' => $slaveProxy, 'slaveLocation' => $slaveLocation, 'xssGot' => $qstr);
$slaveData->insert($arr);
/*******************************************************
* 生成rss feed
********************************************************/
$myFeed = new RSSFeed();
$myFeed->addChannel("Anehta!", "http://anehta.googlecode.com", "Anehta Slave Events!", "zh-cn");
// 下面去掉$qstr 里的 "<![CDATA["和 "]]>"
$qstr = str_replace("\r\n<![CDATA[\r\n", "", $qstr);
$qstr = str_replace("\r\n]]>\r\n", "", $qstr);
/**
 * Encodes HTML safely for UTF-8. Use instead of htmlentities.
 *
 * @param string $var
 * @return string
 */
function html_encode($var)
{
    return htmlentities($var, ENT_QUOTES, 'UTF-8');
}
$qstr = html_encode($qstr);
Ejemplo n.º 15
0
 public function setProtectString($protectString)
 {
     if (is_bool($protectString)) {
         self::$_protectString = $protectString;
     }
 }
 public function init()
 {
     RSSFeed::linkToFeed($this->Parent()->Link() . "rss", _t("CalendarEvent.RSSFEED", "RSS Feed of this calendar"));
     parent::init();
     Requirements::css('event_calendar/css/calendar.css');
     Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
     Requirements::javascript('event_calendar/javascript/calendar_core.js');
 }
Ejemplo n.º 17
0
 public function display($part = 'all')
 {
     switch ($part) {
         case 'page-menu-only':
             if (file_exists('theme/' . $this->get_config('es_theme') . '/page_menu.php')) {
                 $page_menu_file = 'theme/' . $this->get_config('es_theme') . '/page_menu.php';
             } else {
                 $page_menu_file = 'includes/layout/theme//page_menu.php';
             }
             ob_start();
             include $page_menu_file;
             $page_menu = ob_get_contents();
             ob_end_clean();
             echo $page_menu;
             break;
         case 'posts-only':
             echo '<div id="new-post"></div>';
             $this->get_posts();
             break;
         case 'topbar-only':
             ob_start();
             include 'includes/layout/topbar.php';
             $this->topbar = ob_get_contents();
             ob_end_clean();
             echo $this->topbar;
             break;
         case 'sidebar-only':
             if (file_exists('theme/' . $this->get_config('es_theme') . '/sidebar.php')) {
                 $sidebar_file = 'theme/' . $this->get_config('es_theme') . '/sidebar.php';
             } else {
                 $sidebar_file = 'includes/layout/theme/sidebar.php';
             }
             ob_start();
             include $sidebar_file;
             $sidebar = ob_get_contents();
             ob_end_clean();
             echo $sidebar;
             break;
         case 'first-load':
             if ($this->configFileExists()) {
                 ob_start();
                 include 'includes/layout/topbar.php';
                 $this->topbar = ob_get_contents();
                 ob_end_clean();
                 $script_uri = 'http://' . str_replace('www.', '', $_SERVER['HTTP_HOST']) . $_SERVER['REQUEST_URI'];
                 if (substr($script_uri, -1) != '/') {
                     $script_uri .= '/';
                 }
                 $editsee_request = str_replace(str_replace('www.', '', $this->get_config('es_main_url')), '', $script_uri);
                 if (substr($editsee_request, 0, 5) == 'feed/') {
                     include "includes/RSSFeed.class.php";
                     header("Content-type: text/xml; charset=UTF-8");
                     $myfeed = new RSSFeed();
                     $myfeed->SetChannel($this->get_config('es_main_url'), $this->get_config('es_title'), $this->get_config('es_description'), 'en-us', date(Y) . ' ' . $_SERVER['HTTP_HOST'], 'webmaster@' . $_SERVER['HTTP_HOST'], $this->get_config('es_title'));
                     $myfeed->SetImage('');
                     $query = $this->db->_query("select id,title,urltag,content,date_entered from " . $this->db->get_table_prefix() . "post \n\t\t\t\t\t\t\t\t\t\t\t\t\twhere type='post' and deleted='0' and (date_entered <= NOW())\n\t\t\t\t\t\t\t\t\t\t\t\t\torder by date_entered desc");
                     while ($post = $query->_fetch_assoc()) {
                         $post['content'] = strip_tags($post['content'], '<br/><br>');
                         if (strpos($post['content'], '!--full-post--!')) {
                             $post['content'] = substr($post['content'], 0, strpos($post['content'], '!--full-post--!'));
                             $add_dots = true;
                         } else {
                             if (strlen($post['content']) > 280) {
                                 $post['content'] = substr(substr($post['content'], 0, 280), 0, strrpos(substr($post['content'], 0, 280), ' '));
                                 $add_dots = true;
                             }
                         }
                         $post['content'] = htmlentities(stripslashes($post['content']));
                         if ($add_dots) {
                             $post['content'] .= ' [...]';
                         }
                         $myfeed->SetItem($this->get_config('es_main_url') . 'post/' . $post['id'], $this->get_config('es_main_url') . 'post/' . $post['urltag'], $post['title'], $post['date_entered'], $post['content']);
                     }
                     echo $myfeed->output();
                     exit;
                 }
                 $editsee_index = '';
                 if ($editsee_request == '' || $editsee_request == $this->get_config('es_postpage') . '/' || $editsee_request == 'index.php/') {
                     $post_start = 0;
                     $page_number = 1;
                     if ($this->get_config('es_homepage') == '!posts!' || $editsee_request == $this->get_config('es_postpage') . '/') {
                         $this->is_posts = true;
                     } else {
                         $editsee_request = $this->get_config('es_homepage') . '/';
                     }
                 }
                 if (substr($editsee_request, 0, 5) == 'page/') {
                     $page_number = substr(substr($editsee_request, 5), 0, strpos(substr($editsee_request, 5), '/'));
                     $post_start = ($page_number - 1) * $this->get_config('es_posts_per_page');
                     $this->is_posts = true;
                 }
                 if ($this->is_posts) {
                     ob_start();
                     $this->get_posts($post_start);
                     $editsee_index .= ob_get_contents();
                     ob_end_clean();
                 } else {
                     $query = $this->db->_query("select id,title from " . $this->db->get_table_prefix() . "post where urltag='" . substr($editsee_request, 0, -1) . "'");
                     if ($query->_num_rows() == 1) {
                         $this->is_page = true;
                         $page = $query->_fetch_assoc();
                         $this->title .= ' - ' . $page['title'];
                         $editsee_index .= $this->get_single_post($page['id'], 'full', 'page');
                     } else {
                         if (substr($editsee_request, 0, 5) == 'post/') {
                             if (!$this->loggedIn()) {
                                 $if_notloggedin = ' and draft=0 and (date_entered <= NOW())';
                             }
                             $query = $this->db->_query("select id,title from " . $this->db->get_table_prefix() . "post \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twhere (urltag='" . substr($editsee_request, 5, -1) . "' or id='" . substr($editsee_request, 5, -1) . "') \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tand deleted=0" . $if_notloggedin);
                             if ($query->_num_rows() == 1) {
                                 $this->is_post = true;
                                 $post = $query->_fetch_assoc();
                                 $this->title .= ' - ' . $post['title'];
                                 $editsee_index .= $this->get_single_post($post['id'], 'full', 'post');
                                 $post_id = $post['id'];
                                 ob_start();
                                 include "includes/layout/comment_form.php";
                                 $comment_form = ob_get_contents();
                                 ob_end_clean();
                                 $editsee_index .= $comment_form;
                             } else {
                                 $this->is_404 = true;
                                 $editsee_index .= '404 not found';
                             }
                         } else {
                             if (substr($editsee_request, 0, 9) == 'category/') {
                                 $this->is_category = true;
                                 $category = substr(substr($editsee_request, 9), 0, strpos(substr($editsee_request, 9), '/'));
                                 ob_start();
                                 $this->get_posts(0, $category);
                                 $editsee_index = ob_get_contents();
                                 ob_end_clean();
                             } else {
                                 $this->is_404 = true;
                                 $editsee_index .= '404 not found';
                             }
                         }
                     }
                 }
                 if (file_exists('theme/' . $this->get_config('es_theme') . '/header.php')) {
                     require_once 'theme/' . $this->get_config('es_theme') . '/header.php';
                     echo $editsee_index;
                 }
                 if (file_exists('theme/' . $this->get_config('es_theme') . '/index.php')) {
                     require_once 'theme/' . $this->get_config('es_theme') . '/index.php';
                 }
                 if (file_exists('theme/' . $this->get_config('es_theme') . '/footer.php')) {
                     require_once 'theme/' . $this->get_config('es_theme') . '/footer.php';
                 }
             } else {
                 ob_start();
                 include "includes/layout/install.php";
                 $install_page = ob_get_contents();
                 ob_end_clean();
                 echo $install_page;
             }
     }
 }
    function index($request)
    {
        // For 2.3 and 2.4 compatibility
        $bt = defined('DB::USE_ANSI_SQL') ? "\"" : "`";
        BasicAuth::enable();
        BasicAuth::requireLogin("CMS RSS feed access.  Use your CMS login", "CMS_ACCESS_CMSMain");
        $member = $this->getBasicAuthMember();
        // Due to a bug in 2.3.0 we can't get the information that we need from $request
        $params = Director::urlParams();
        // Default value
        if (!isset($params['Data']) || !$params['Data']) {
            $params['Data'] = 'all';
        }
        switch ($params['Data']) {
            case 'all':
                $changes = $this->changes();
                break;
            case 'page':
                if ((int) $params['PageID']) {
                    $changes = $this->changes("{$bt}SiteTree{$bt}.{$bt}ID{$bt} = " . (int) $params['PageID']);
                } else {
                    return new HTTPResponse("<h1>Bad Page ID</h1><p>Bad page ID when getting RSS feed of changes to a page.</p>", 400);
                }
                break;
            default:
                user_error("CMSChangeTracker Data param value '{$params['Data']}' not implemented; this is probably due to a bad URL rule.", E_USER_ERROR);
        }
        $processedChanges = new DataObjectSet();
        foreach ($changes as $change) {
            if ($change->canEdit($member)) {
                $author = DataObject::get_by_id("Member", $change->AuthorID);
                $verbed = $change->Version == 1 ? "created" : "edited";
                if ($author) {
                    $changeTitle = "'{$change->Title}' {$verbed} by {$author->FirstName} {$author->Surname}";
                    $changeAuthor = "{$author->FirstName} {$author->Surname}";
                    $firstParagraph = "{$author->FirstName} {$author->Surname} (<a href=\"mailto:{$author->Email}\">{$author->Email}</a>) has {$verbed} the '{$change->Title}' page.";
                } else {
                    $changeTitle = "'{$change->Title}' {$verbed}";
                    $changeAuthor = "";
                    $firstParagraph = "The '{$change->Title}' page has been {$verbed}.";
                }
                $actionLinks = "";
                $cmsLink = Director::absoluteURL("admin/show/{$change->ID}");
                $actionLinks .= "<li><a href=\"{$cmsLink}\">Edit in CMS</a></li>\n";
                $page = DataObject::get_by_id('SiteTree', $change->ID);
                if ($page) {
                    $link = $page->AbsoluteLink();
                    $actionLinks .= "<li><a href=\"{$link}\">See the page on site</a></li>\n";
                }
                if ($change->Version > 1) {
                    $prevVersion = $change->Version - 1;
                    $diffLink = Director::absoluteURL("admin/compareversions/{$change->ID}/?From={$prevVersion}&To={$change->Version}");
                    $actionLinks .= "<li><a href=\"{$diffLink}\">See the changes in CMS</a></li>\n";
                }
                $changeDescription = <<<HTML
<p>{$firstParagraph}</p>

<h3>Actions and links</h3>

<ul>
\t{$actionLinks}
</ul>
HTML;
                $processedChange = new CMSChangeTracker_Change(array("ChangeTitle" => $changeTitle, "Author" => $changeAuthor, "Content" => $changeDescription, "Link" => $change->Link() . "version/{$change->Version}"));
                $processedChanges->push($processedChange);
            }
        }
        $feed = new RSSFeed($processedChanges, Director::absoluteURL("admin/"), "SilverStripe Content Changes", "", "ChangeTitle");
        return $feed->outputToBrowser();
    }
Ejemplo n.º 19
0
 function doModel()
 {
     osc_run_hook('before_search');
     $mCategories = new Category();
     ////////////////////////////////
     //GETTING AND FIXING SENT DATA//
     ////////////////////////////////
     $p_sCategory = Params::getParam('sCategory');
     if (!is_array($p_sCategory)) {
         if ($p_sCategory == '') {
             $p_sCategory = array();
         } else {
             $p_sCategory = explode(",", $p_sCategory);
         }
     }
     $p_sCityArea = Params::getParam('sCityArea');
     if (!is_array($p_sCityArea)) {
         if ($p_sCityArea == '') {
             $p_sCityArea = array();
         } else {
             $p_sCityArea = explode(",", $p_sCityArea);
         }
     }
     $p_sCity = Params::getParam('sCity');
     if (!is_array($p_sCity)) {
         if ($p_sCity == '') {
             $p_sCity = array();
         } else {
             $p_sCity = explode(",", $p_sCity);
         }
     }
     $p_sRegion = Params::getParam('sRegion');
     if (!is_array($p_sRegion)) {
         if ($p_sRegion == '') {
             $p_sRegion = array();
         } else {
             $p_sRegion = explode(",", $p_sRegion);
         }
     }
     $p_sCountry = Params::getParam('sCountry');
     if (!is_array($p_sCountry)) {
         if ($p_sCountry == '') {
             $p_sCountry = array();
         } else {
             $p_sCountry = explode(",", $p_sCountry);
         }
     }
     $p_sPattern = strip_tags(Params::getParam('sPattern'));
     $p_sUser = strip_tags(Params::getParam('sUser'));
     // ADD TO THE LIST OF LAST SEARCHES
     if (osc_save_latest_searches()) {
         if (trim($p_sPattern) != '') {
             LatestSearches::newInstance()->insert(array('s_search' => trim($p_sPattern), 'd_date' => date('Y-m-d H:i:s')));
         }
     }
     $p_bPic = Params::getParam('bPic');
     $p_bPic == 1 ? $p_bPic = 1 : ($p_bPic = 0);
     $p_sPriceMin = Params::getParam('sPriceMin');
     $p_sPriceMax = Params::getParam('sPriceMax');
     //WE CAN ONLY USE THE FIELDS RETURNED BY Search::getAllowedColumnsForSorting()
     $p_sOrder = Params::getParam('sOrder');
     if (!in_array($p_sOrder, Search::getAllowedColumnsForSorting())) {
         $p_sOrder = osc_default_order_field_at_search();
     }
     //ONLY 0 ( => 'asc' ), 1 ( => 'desc' ) AS ALLOWED VALUES
     $p_iOrderType = Params::getParam('iOrderType');
     $allowedTypesForSorting = Search::getAllowedTypesForSorting();
     $orderType = osc_default_order_type_at_search();
     foreach ($allowedTypesForSorting as $k => $v) {
         if ($p_iOrderType == $v) {
             $orderType = $k;
             break;
         }
     }
     $p_iOrderType = $orderType;
     $p_sFeed = Params::getParam('sFeed');
     $p_iPage = intval(Params::getParam('iPage'));
     if ($p_sFeed != '') {
         $p_sPageSize = 1000;
     }
     $p_sShowAs = Params::getParam('sShowAs');
     $aValidShowAsValues = array('list', 'gallery');
     if (!in_array($p_sShowAs, $aValidShowAsValues)) {
         $p_sShowAs = osc_default_show_as_at_search();
     }
     // search results: it's blocked with the maxResultsPerPage@search defined in t_preferences
     $p_iPageSize = intval(Params::getParam('iPagesize'));
     if ($p_iPageSize > 0) {
         if ($p_iPageSize > osc_max_results_per_page_at_search()) {
             $p_iPageSize = osc_max_results_per_page_at_search();
         }
     } else {
         $p_iPageSize = osc_default_results_per_page_at_search();
     }
     //FILTERING CATEGORY
     $bAllCategoriesChecked = false;
     if (count($p_sCategory) > 0) {
         foreach ($p_sCategory as $category) {
             $this->mSearch->addCategory($category);
         }
     } else {
         $bAllCategoriesChecked = true;
     }
     //FILTERING CITY_AREA
     foreach ($p_sCityArea as $city_area) {
         $this->mSearch->addCityArea($city_area);
     }
     $p_sCityArea = implode(", ", $p_sCityArea);
     //FILTERING CITY
     foreach ($p_sCity as $city) {
         $this->mSearch->addCity($city);
     }
     $p_sCity = implode(", ", $p_sCity);
     //FILTERING REGION
     foreach ($p_sRegion as $region) {
         $this->mSearch->addRegion($region);
     }
     $p_sRegion = implode(", ", $p_sRegion);
     //FILTERING COUNTRY
     foreach ($p_sCountry as $country) {
         $this->mSearch->addCountry($country);
     }
     $p_sCountry = implode(", ", $p_sCountry);
     // FILTERING PATTERN
     if ($p_sPattern != '') {
         $this->mSearch->addConditions(sprintf("MATCH(d.s_title, d.s_description) AGAINST('%s' IN BOOLEAN MODE)", $p_sPattern));
         $osc_request['sPattern'] = $p_sPattern;
     }
     // FILTERING USER
     if ($p_sUser != '') {
         $this->mSearch->fromUser(explode(",", $p_sUser));
     }
     // FILTERING IF WE ONLY WANT ITEMS WITH PICS
     if ($p_bPic) {
         $this->mSearch->withPicture(true);
     }
     //FILTERING BY RANGE PRICE
     $this->mSearch->priceRange($p_sPriceMin, $p_sPriceMax);
     //ORDERING THE SEARCH RESULTS
     $this->mSearch->order($p_sOrder, $allowedTypesForSorting[$p_iOrderType]);
     //SET PAGE
     $this->mSearch->page($p_iPage, $p_iPageSize);
     osc_run_hook('search_conditions', Params::getParamsAsArray());
     if (!Params::existParam('sFeed')) {
         // RETRIEVE ITEMS AND TOTAL
         $aItems = $this->mSearch->doSearch();
         $iTotalItems = $this->mSearch->count();
         $iStart = $p_iPage * $p_iPageSize;
         $iEnd = min(($p_iPage + 1) * $p_iPageSize, $iTotalItems);
         $iNumPages = ceil($iTotalItems / $p_iPageSize);
         osc_run_hook('search', $this->mSearch);
         //preparing variables...
         //$this->_exportVariableToView('non_empty_categories', $aCategories) ;
         $this->_exportVariableToView('search_start', $iStart);
         $this->_exportVariableToView('search_end', $iEnd);
         $this->_exportVariableToView('search_category', $p_sCategory);
         $this->_exportVariableToView('search_order_type', $p_iOrderType);
         $this->_exportVariableToView('search_order', $p_sOrder);
         $this->_exportVariableToView('search_pattern', $p_sPattern);
         $this->_exportVariableToView('search_from_user', $p_sUser);
         $this->_exportVariableToView('search_total_pages', $iNumPages);
         $this->_exportVariableToView('search_page', $p_iPage);
         $this->_exportVariableToView('search_has_pic', $p_bPic);
         $this->_exportVariableToView('search_region', $p_sRegion);
         $this->_exportVariableToView('search_city', $p_sCity);
         $this->_exportVariableToView('search_price_min', $p_sPriceMin);
         $this->_exportVariableToView('search_price_max', $p_sPriceMax);
         $this->_exportVariableToView('search_total_items', $iTotalItems);
         $this->_exportVariableToView('items', $aItems);
         $this->_exportVariableToView('search_show_as', $p_sShowAs);
         $this->_exportVariableToView('search', $this->mSearch);
         $this->_exportVariableToView('search_alert', base64_encode(serialize($this->mSearch)));
         //calling the view...
         $this->doView('search.php');
     } else {
         $this->mSearch->page(0, osc_num_rss_items());
         // RETRIEVE ITEMS AND TOTAL
         $iTotalItems = $this->mSearch->count();
         $aItems = $this->mSearch->doSearch();
         $this->_exportVariableToView('items', $aItems);
         if ($p_sFeed == '' || $p_sFeed == 'rss') {
             // FEED REQUESTED!
             header('Content-type: text/xml; charset=utf-8');
             $feed = new RSSFeed();
             $feed->setTitle(__('Latest items added') . ' - ' . osc_page_title());
             $feed->setLink(osc_base_url());
             $feed->setDescription(__('Latest items added in') . ' ' . osc_page_title());
             if (osc_count_items() > 0) {
                 while (osc_has_items()) {
                     if (osc_count_item_resources() > 0) {
                         osc_has_item_resources();
                         $feed->addItem(array('title' => osc_item_title(), 'link' => htmlentities(osc_item_url()), 'description' => osc_item_description(), 'dt_pub_date' => osc_item_pub_date(), 'image' => array('url' => htmlentities(osc_resource_thumbnail_url()), 'title' => osc_item_title(), 'link' => htmlentities(osc_item_url()))));
                     } else {
                         $feed->addItem(array('title' => osc_item_title(), 'link' => htmlentities(osc_item_url()), 'description' => osc_item_description(), 'dt_pub_date' => osc_item_pub_date()));
                     }
                 }
             }
             osc_run_hook('feed', $feed);
             $feed->dumpXML();
         } else {
             osc_run_hook('feed_' . $p_sFeed, $aItems);
         }
     }
 }
Ejemplo n.º 20
0
                                        $params_ranks = array();
                                        $params_ranks['alexa_rank'] = number_format((double) $objSettings->CheckAlexaRank($http_host));
                                        $params_ranks['google_rank'] = (int) $objSettings->CheckGoogleRank($http_host);
                                        if ($objSettings->UpdateFields($params_ranks) == true) {
                                            $msg = draw_success_message(_CHANGES_WERE_SAVED, false);
                                        } else {
                                            $msg = draw_important_message($objSettings->error, false);
                                        }
                                    } else {
                                        if ($submition_type == 'cron_settings') {
                                            if ($objSettings->UpdateFields($params_cron) == true) {
                                                $msg = draw_success_message(_CHANGES_WERE_SAVED, false);
                                            } else {
                                                $msg = draw_important_message($objSettings->error, false);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    $template = $objSettings->GetTemplate();
    if (strtolower(SITE_MODE) != 'demo' && $submition_type == 'general' || $submition_type == 'visual_settings' || $submition_type == 'meta_tags') {
        $objSiteDescription->LoadData();
        RSSFeed::UpdateFeeds();
    }
}
 public function rss()
 {
     $rss = new RSSFeed($this->Updates()->sort('Created DESC')->limit(20), $this->Link(), $this->getSubscriptionTitle());
     $rss->setTemplate('NewsHolder_rss');
     return $rss->outputToBrowser();
 }
Ejemplo n.º 22
0
 /**
  * Generic Function to add Default left join to a request
  *
  * @param $itemtype                    reference ID
  * @param $ref_table                   reference table
  * @param &$already_link_tables  array of tables already joined
  *
  * @return Left join string
  **/
 static function addDefaultJoin($itemtype, $ref_table, array &$already_link_tables)
 {
     switch ($itemtype) {
         // No link
         case 'User':
             return self::addLeftJoin($itemtype, $ref_table, $already_link_tables, "glpi_profiles_users", "profiles_users_id", 0, 0, array('jointype' => 'child'));
         case 'Reminder':
             return Reminder::addVisibilityJoins();
         case 'RSSFeed':
             return RSSFeed::addVisibilityJoins();
         case 'ProjectTask':
             // Same structure in addDefaultWhere
             $out = '';
             $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, "glpi_projecttaskteams", "projecttaskteams_id", 0, 0, array('jointype' => 'child'));
             return $out;
         case 'Project':
             // Same structure in addDefaultWhere
             $out = '';
             if (!Session::haveRight("project", Project::READALL)) {
                 $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, "glpi_projectteams", "projectteams_id", 0, 0, array('jointype' => 'child'));
             }
             return $out;
         case 'Ticket':
             // Same structure in addDefaultWhere
             $out = '';
             if (!Session::haveRight("ticket", Ticket::READALL)) {
                 $searchopt =& self::getOptions($itemtype);
                 // show mine : requester
                 $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, "glpi_tickets_users", "tickets_users_id", 0, 0, $searchopt[4]['joinparams']['beforejoin']['joinparams']);
                 if (Session::haveRight("ticket", Ticket::READGROUP)) {
                     if (count($_SESSION['glpigroups'])) {
                         $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, "glpi_groups_tickets", "groups_tickets_id", 0, 0, $searchopt[71]['joinparams']['beforejoin']['joinparams']);
                     }
                 }
                 // show mine : observer
                 $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, "glpi_tickets_users", "tickets_users_id", 0, 0, $searchopt[66]['joinparams']['beforejoin']['joinparams']);
                 if (count($_SESSION['glpigroups'])) {
                     $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, "glpi_groups_tickets", "groups_tickets_id", 0, 0, $searchopt[65]['joinparams']['beforejoin']['joinparams']);
                 }
                 if (Session::haveRight("ticket", Ticket::OWN)) {
                     // Can own ticket : show assign to me
                     $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, "glpi_tickets_users", "tickets_users_id", 0, 0, $searchopt[5]['joinparams']['beforejoin']['joinparams']);
                 }
                 if (Session::haveRightsOr("ticket", array(Ticket::READMY, Ticket::READASSIGN))) {
                     // show mine + assign to me
                     $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, "glpi_tickets_users", "tickets_users_id", 0, 0, $searchopt[5]['joinparams']['beforejoin']['joinparams']);
                     if (count($_SESSION['glpigroups'])) {
                         $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, "glpi_groups_tickets", "groups_tickets_id", 0, 0, $searchopt[8]['joinparams']['beforejoin']['joinparams']);
                     }
                 }
                 if (Session::haveRightsOr('ticketvalidation', array(TicketValidation::VALIDATEINCIDENT, TicketValidation::VALIDATEREQUEST))) {
                     $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, "glpi_ticketvalidations", "ticketvalidations_id", 0, 0, $searchopt[58]['joinparams']['beforejoin']['joinparams']);
                 }
             }
             return $out;
         case 'Change':
         case 'Problem':
             if ($itemtype == 'Change') {
                 $right = 'change';
                 $table = 'changes';
                 $groupetable = "glpi_changes_groups";
                 $linkfield = "changes_groups_id";
             } else {
                 if ($itemtype == 'Problem') {
                     $right = 'problem';
                     $table = 'problems';
                     $groupetable = "glpi_groups_problems";
                     $linkfield = "groups_problems_id";
                 }
             }
             // Same structure in addDefaultWhere
             $out = '';
             if (!Session::haveRight("{$right}", $itemtype::READALL)) {
                 $searchopt =& self::getOptions($itemtype);
                 if (Session::haveRight("{$right}", $itemtype::READMY)) {
                     // show mine : requester
                     $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, "glpi_" . $table . "_users", $table . "_users_id", 0, 0, $searchopt[4]['joinparams']['beforejoin']['joinparams']);
                     if (count($_SESSION['glpigroups'])) {
                         $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, $groupetable, $linkfield, 0, 0, $searchopt[71]['joinparams']['beforejoin']['joinparams']);
                     }
                     // show mine : observer
                     $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, "glpi_" . $table . "_users", $table . "_users_id", 0, 0, $searchopt[66]['joinparams']['beforejoin']['joinparams']);
                     if (count($_SESSION['glpigroups'])) {
                         $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, $groupetable, $linkfield, 0, 0, $searchopt[65]['joinparams']['beforejoin']['joinparams']);
                     }
                     // show mine : assign
                     $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, "glpi_" . $table . "_users", $table . "_users_id", 0, 0, $searchopt[5]['joinparams']['beforejoin']['joinparams']);
                     if (count($_SESSION['glpigroups'])) {
                         $out .= self::addLeftJoin($itemtype, $ref_table, $already_link_tables, $groupetable, $linkfield, 0, 0, $searchopt[8]['joinparams']['beforejoin']['joinparams']);
                     }
                 }
             }
             return $out;
         default:
             // Plugin can override core definition for its type
             if ($plug = isPluginItemType($itemtype)) {
                 $function = 'plugin_' . $plug['plugin'] . '_addDefaultJoin';
                 if (function_exists($function)) {
                     $out = $function($itemtype, $ref_table, $already_link_tables);
                     if (!empty($out)) {
                         return $out;
                     }
                 }
             }
             return "";
     }
 }
 public function init()
 {
     RSSFeed::linkToFeed("add-ons/rss", "New modules on addons.silverstripe.org");
     parent::init();
 }
 public function rss()
 {
     $rss = new RSSFeed($this->GetNewsPages(), $this->Link(), $this->SiteConfig->Title . " News", "RSS feed for the news from " . $this->SiteConfig->Title);
     return $rss->outputToBrowser();
 }
Ejemplo n.º 25
0
 public function rss()
 {
     $rss = new RSSFeed($this->Children(), $this->Link, SiteConfig::current_site_config()->Title . ' news');
     return $rss->outputToBrowser();
 }
Ejemplo n.º 26
0
Archivo: index.php Proyecto: high/cgeek
        $rss .= '
			</channel>
		</rss>';
        return $rss;
    }
}
$newsData = array('title' => 'GIT repository for the source', 'content' => 'The source code for my site is now on GitHub, so if you are interested on how my site is build the URL is:
<a href="http://github.com/high/cgeek">http://github.com/high/cgeek</a>.', 'created' => mktime(0, 0, 0, 3, 14, 2009));
$newsItem = new NewsItem();
$newsItem->loadData($newsData);
$newsItems[] = $newsItem;
$newsData = array('title' => 'New site is up', 'content' => 'Well, here is the new site. My goal is to make it as simple as possible and just display the things that are essential to me', 'created' => mktime(0, 0, 0, 3, 12, 2010));
$newsItem = new NewsItem();
$newsItem->loadData($newsData);
$newsItems[] = $newsItem;
$rss = new RSSFeed();
$rss->setNewsItems($newsItems);
$rssText = $rss->compile();
file_put_contents("rss.xml", $rssText);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		
		<title>High's page</title>
		<link rel="stylesheet" type="text/css" href="site.css"></link>
	</head>
	
	<body>
 public function rss()
 {
     $this->setDefaultView();
     $events = $this->Events();
     foreach ($events as $event) {
         $event->Title = strip_tags($event->DateRange()) . " : " . $event->getTitle();
         $event->Description = $event->getContent();
     }
     $rss_title = $this->RSSTitle ? $this->RSSTitle : sprintf(_t("Calendar.UPCOMINGEVENTSFOR", "Upcoming Events for %s"), $this->Title);
     $rss = new RSSFeed($events, $this->Link(), $rss_title, "", "Title", "Description");
     if (is_int($rss->lastModified)) {
         HTTP::register_modification_timestamp($rss->lastModified);
         header('Last-Modified: ' . gmdate("D, d M Y H:i:s", $rss->lastModified) . ' GMT');
     }
     if (!empty($rss->etag)) {
         HTTP::register_etag($rss->etag);
     }
     $xml = str_replace('&nbsp;', '&#160;', $rss->renderWith('RSSFeed'));
     $xml = preg_replace('/<!--(.|\\s)*?-->/', '', $xml);
     $xml = trim($xml);
     HTTP::add_cache_headers();
     $this->getResponse()->addHeader('Content-Type', 'application/rss+xml');
     echo $xml;
 }
Ejemplo n.º 28
0
http://indepnet.net/   http://glpi-project.org
-------------------------------------------------------------------------

LICENSE

This file is part of GLPI.

GLPI is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

GLPI is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
* @since version 0.84
*/
include '../inc/includes.php';
Session::checkCentralAccess();
Html::header(RSSFeed::getTypeName(2), $_SERVER['PHP_SELF'], "utils", "rssfeed");
Search::show('RSSFeed');
Html::footer();
Ejemplo n.º 29
0
 function doModel()
 {
     osc_run_hook('before_search');
     $mCategories = Category::newInstance();
     if (osc_rewrite_enabled()) {
         // IF rewrite is not enabled, skip this part, preg_match is always time&resources consuming task
         $p_sParams = "/" . Params::getParam('sParams', false, false);
         if (preg_match_all('|\\/([^,]+),([^\\/]*)|', $p_sParams, $m)) {
             $l = count($m[0]);
             for ($k = 0; $k < $l; $k++) {
                 switch ($m[1][$k]) {
                     case osc_get_preference('rewrite_search_country'):
                         $m[1][$k] = 'sCountry';
                         break;
                     case osc_get_preference('rewrite_search_region'):
                         $m[1][$k] = 'sRegion';
                         break;
                     case osc_get_preference('rewrite_search_city'):
                         $m[1][$k] = 'sCity';
                         break;
                     case osc_get_preference('rewrite_search_city_area'):
                         $m[1][$k] = 'sCityArea';
                         break;
                     case osc_get_preference('rewrite_search_category'):
                         $m[1][$k] = 'sCategory';
                         break;
                     case osc_get_preference('rewrite_search_user'):
                         $m[1][$k] = 'sUser';
                         break;
                     case osc_get_preference('rewrite_search_pattern'):
                         $m[1][$k] = 'sPattern';
                         break;
                     default:
                         break;
                 }
                 $_REQUEST[$m[1][$k]] = $m[2][$k];
                 $_GET[$m[1][$k]] = $m[2][$k];
                 unset($_REQUEST['sParams']);
                 unset($_GET['sParams']);
                 unset($_POST['sParams']);
             }
         }
     }
     ////////////////////////////////
     //GETTING AND FIXING SENT DATA//
     ////////////////////////////////
     $p_sCategory = Params::getParam('sCategory');
     if (!is_array($p_sCategory)) {
         if ($p_sCategory == '') {
             $p_sCategory = array();
         } else {
             $p_sCategory = explode(",", $p_sCategory);
         }
     }
     $p_sCityArea = Params::getParam('sCityArea');
     if (!is_array($p_sCityArea)) {
         if ($p_sCityArea == '') {
             $p_sCityArea = array();
         } else {
             $p_sCityArea = explode(",", $p_sCityArea);
         }
     }
     $p_sCity = Params::getParam('sCity');
     if (!is_array($p_sCity)) {
         if ($p_sCity == '') {
             $p_sCity = array();
         } else {
             $p_sCity = explode(",", $p_sCity);
         }
     }
     $p_sRegion = Params::getParam('sRegion');
     if (!is_array($p_sRegion)) {
         if ($p_sRegion == '') {
             $p_sRegion = array();
         } else {
             $p_sRegion = explode(",", $p_sRegion);
         }
     }
     $p_sCountry = Params::getParam('sCountry');
     if (!is_array($p_sCountry)) {
         if ($p_sCountry == '') {
             $p_sCountry = array();
         } else {
             $p_sCountry = explode(",", $p_sCountry);
         }
     }
     $p_sUser = Params::getParam('sUser');
     if (!is_array($p_sUser)) {
         if ($p_sUser == '') {
             $p_sUser = '';
         } else {
             $p_sUser = explode(",", $p_sUser);
         }
     }
     $p_sPattern = strip_tags(Params::getParam('sPattern'));
     // ADD TO THE LIST OF LAST SEARCHES
     if (osc_save_latest_searches()) {
         if (trim($p_sPattern) != '') {
             LatestSearches::newInstance()->insert(array('s_search' => trim($p_sPattern), 'd_date' => date('Y-m-d H:i:s')));
         }
     }
     $p_bPic = Params::getParam('bPic');
     $p_bPic == 1 ? $p_bPic = 1 : ($p_bPic = 0);
     $p_sPriceMin = Params::getParam('sPriceMin');
     $p_sPriceMax = Params::getParam('sPriceMax');
     //WE CAN ONLY USE THE FIELDS RETURNED BY Search::getAllowedColumnsForSorting()
     $p_sOrder = Params::getParam('sOrder');
     if (!in_array($p_sOrder, Search::getAllowedColumnsForSorting())) {
         $p_sOrder = osc_default_order_field_at_search();
     }
     $old_order = $p_sOrder;
     //ONLY 0 ( => 'asc' ), 1 ( => 'desc' ) AS ALLOWED VALUES
     $p_iOrderType = Params::getParam('iOrderType');
     $allowedTypesForSorting = Search::getAllowedTypesForSorting();
     $orderType = osc_default_order_type_at_search();
     foreach ($allowedTypesForSorting as $k => $v) {
         if ($p_iOrderType == $v) {
             $orderType = $k;
             break;
         }
     }
     $p_iOrderType = $orderType;
     $p_sFeed = Params::getParam('sFeed');
     $p_iPage = 0;
     if (is_numeric(Params::getParam('iPage')) && Params::getParam('iPage') > 0) {
         $p_iPage = intval(Params::getParam('iPage')) - 1;
     }
     if ($p_sFeed != '') {
         $p_sPageSize = 1000;
     }
     $p_sShowAs = Params::getParam('sShowAs');
     $aValidShowAsValues = array('list', 'gallery');
     if (!in_array($p_sShowAs, $aValidShowAsValues)) {
         $p_sShowAs = osc_default_show_as_at_search();
     }
     // search results: it's blocked with the maxResultsPerPage@search defined in t_preferences
     $p_iPageSize = intval(Params::getParam('iPagesize'));
     if ($p_iPageSize > 0) {
         if ($p_iPageSize > osc_max_results_per_page_at_search()) {
             $p_iPageSize = osc_max_results_per_page_at_search();
         }
     } else {
         $p_iPageSize = osc_default_results_per_page_at_search();
     }
     //FILTERING CATEGORY
     $bAllCategoriesChecked = false;
     if (count($p_sCategory) > 0) {
         foreach ($p_sCategory as $category) {
             $this->mSearch->addCategory($category);
         }
     } else {
         $bAllCategoriesChecked = true;
     }
     //FILTERING CITY_AREA
     foreach ($p_sCityArea as $city_area) {
         $this->mSearch->addCityArea($city_area);
     }
     $p_sCityArea = implode(", ", $p_sCityArea);
     //FILTERING CITY
     foreach ($p_sCity as $city) {
         $this->mSearch->addCity($city);
     }
     $p_sCity = implode(", ", $p_sCity);
     //FILTERING REGION
     foreach ($p_sRegion as $region) {
         $this->mSearch->addRegion($region);
     }
     $p_sRegion = implode(", ", $p_sRegion);
     //FILTERING COUNTRY
     foreach ($p_sCountry as $country) {
         $this->mSearch->addCountry($country);
     }
     $p_sCountry = implode(", ", $p_sCountry);
     // FILTERING PATTERN
     if ($p_sPattern != '') {
         $this->mSearch->addPattern($p_sPattern);
         $osc_request['sPattern'] = $p_sPattern;
     } else {
         // hardcoded - if there isn't a search pattern, order by dt_pub_date desc
         if ($p_sOrder == 'relevance') {
             $p_sOrder = 'dt_pub_date';
             foreach ($allowedTypesForSorting as $k => $v) {
                 if ($p_iOrderType == 'desc') {
                     $orderType = $k;
                     break;
                 }
             }
             $p_iOrderType = $orderType;
         }
     }
     // FILTERING USER
     if ($p_sUser != '') {
         $this->mSearch->fromUser($p_sUser);
     }
     // FILTERING IF WE ONLY WANT ITEMS WITH PICS
     if ($p_bPic) {
         $this->mSearch->withPicture(true);
     }
     //FILTERING BY RANGE PRICE
     $this->mSearch->priceRange($p_sPriceMin, $p_sPriceMax);
     //ORDERING THE SEARCH RESULTS
     $this->mSearch->order($p_sOrder, $allowedTypesForSorting[$p_iOrderType]);
     //SET PAGE
     $this->mSearch->page($p_iPage, $p_iPageSize);
     osc_run_hook('search_conditions', Params::getParamsAsArray());
     if (!Params::existParam('sFeed')) {
         // RETRIEVE ITEMS AND TOTAL
         $aItems = $this->mSearch->doSearch();
         $iTotalItems = $this->mSearch->count();
         $iStart = $p_iPage * $p_iPageSize;
         $iEnd = min(($p_iPage + 1) * $p_iPageSize, $iTotalItems);
         $iNumPages = ceil($iTotalItems / $p_iPageSize);
         osc_run_hook('search', $this->mSearch);
         //preparing variables...
         $regionName = $p_sRegion;
         if (is_numeric($p_sRegion)) {
             $r = Region::newInstance()->findByPrimaryKey($p_sRegion);
             if ($r) {
                 $regionName = $r['s_name'];
             }
         }
         $cityName = $p_sCity;
         if (is_numeric($p_sCity)) {
             $c = City::newInstance()->findByPrimaryKey($p_sCity);
             if ($c) {
                 $cityName = $c['s_name'];
             }
         }
         //$this->_exportVariableToView('non_empty_categories', $aCategories) ;
         $this->_exportVariableToView('search_start', $iStart);
         $this->_exportVariableToView('search_end', $iEnd);
         $this->_exportVariableToView('search_category', $p_sCategory);
         // hardcoded - non pattern and order by relevance
         $p_sOrder = $old_order;
         $this->_exportVariableToView('search_order_type', $p_iOrderType);
         $this->_exportVariableToView('search_order', $p_sOrder);
         $this->_exportVariableToView('search_pattern', $p_sPattern);
         $this->_exportVariableToView('search_from_user', $p_sUser);
         $this->_exportVariableToView('search_total_pages', $iNumPages);
         $this->_exportVariableToView('search_page', $p_iPage);
         $this->_exportVariableToView('search_has_pic', $p_bPic);
         $this->_exportVariableToView('search_region', $regionName);
         $this->_exportVariableToView('search_city', $cityName);
         $this->_exportVariableToView('search_price_min', $p_sPriceMin);
         $this->_exportVariableToView('search_price_max', $p_sPriceMax);
         $this->_exportVariableToView('search_total_items', $iTotalItems);
         $this->_exportVariableToView('items', $aItems);
         $this->_exportVariableToView('search_show_as', $p_sShowAs);
         $this->_exportVariableToView('search', $this->mSearch);
         // json
         $json = $this->mSearch->toJson();
         $this->_exportVariableToView('search_alert', base64_encode($json));
         //calling the view...
         $this->doView('search.php');
     } else {
         $this->mSearch->page(0, osc_num_rss_items());
         // RETRIEVE ITEMS AND TOTAL
         $iTotalItems = $this->mSearch->count();
         $aItems = $this->mSearch->doSearch();
         $this->_exportVariableToView('items', $aItems);
         if ($p_sFeed == '' || $p_sFeed == 'rss') {
             // FEED REQUESTED!
             header('Content-type: text/xml; charset=utf-8');
             $feed = new RSSFeed();
             $feed->setTitle(__('Latest listings added') . ' - ' . osc_page_title());
             $feed->setLink(osc_base_url());
             $feed->setDescription(__('Latest listings added in') . ' ' . osc_page_title());
             if (osc_count_items() > 0) {
                 while (osc_has_items()) {
                     if (osc_count_item_resources() > 0) {
                         osc_has_item_resources();
                         $feed->addItem(array('title' => osc_item_title(), 'link' => htmlentities(osc_item_url(), ENT_COMPAT, "UTF-8"), 'description' => osc_item_description(), 'dt_pub_date' => osc_item_pub_date(), 'image' => array('url' => htmlentities(osc_resource_thumbnail_url(), ENT_COMPAT, "UTF-8"), 'title' => osc_item_title(), 'link' => htmlentities(osc_item_url(), ENT_COMPAT, "UTF-8"))));
                     } else {
                         $feed->addItem(array('title' => osc_item_title(), 'link' => htmlentities(osc_item_url(), ENT_COMPAT, "UTF-8"), 'description' => osc_item_description(), 'dt_pub_date' => osc_item_pub_date()));
                     }
                 }
             }
             osc_run_hook('feed', $feed);
             $feed->dumpXML();
         } else {
             osc_run_hook('feed_' . $p_sFeed, $aItems);
         }
     }
 }
Ejemplo n.º 30
0
 function doModel()
 {
     osc_run_hook('before_search');
     if (osc_rewrite_enabled()) {
         // IF rewrite is not enabled, skip this part, preg_match is always time&resources consuming task
         $p_sParams = "/" . Params::getParam('sParams', false, false);
         if (preg_match_all('|\\/([^,]+),([^\\/]*)|', $p_sParams, $m)) {
             $l = count($m[0]);
             for ($k = 0; $k < $l; $k++) {
                 switch ($m[1][$k]) {
                     case osc_get_preference('rewrite_search_country'):
                         $m[1][$k] = 'sCountry';
                         break;
                     case osc_get_preference('rewrite_search_region'):
                         $m[1][$k] = 'sRegion';
                         break;
                     case osc_get_preference('rewrite_search_city'):
                         $m[1][$k] = 'sCity';
                         break;
                     case osc_get_preference('rewrite_search_city_area'):
                         $m[1][$k] = 'sCityArea';
                         break;
                     case osc_get_preference('rewrite_search_category'):
                         $m[1][$k] = 'sCategory';
                         break;
                     case osc_get_preference('rewrite_search_user'):
                         $m[1][$k] = 'sUser';
                         break;
                     case osc_get_preference('rewrite_search_pattern'):
                         $m[1][$k] = 'sPattern';
                         break;
                     default:
                         // custom fields
                         if (preg_match("/meta(\\d+)-?(.*)?/", $m[1][$k], $results)) {
                             $meta_key = $m[1][$k];
                             $meta_value = $m[2][$k];
                             $array_r = array();
                             if (Params::existParam('meta')) {
                                 $array_r = Params::getParam('meta');
                             }
                             if ($results[2] == '') {
                                 // meta[meta_id] = meta_value
                                 $meta_key = $results[1];
                                 $array_r[$meta_key] = $meta_value;
                             } else {
                                 // meta[meta_id][meta_key] = meta_value
                                 $meta_key = $results[1];
                                 $meta_key2 = $results[2];
                                 $array_r[$meta_key][$meta_key2] = $meta_value;
                             }
                             $m[1][$k] = 'meta';
                             $m[2][$k] = $array_r;
                         }
                         break;
                 }
                 Params::setParam($m[1][$k], $m[2][$k]);
             }
             Params::unsetParam('sParams');
         }
     }
     $uriParams = Params::getParamsAsArray();
     $searchUri = osc_search_url($uriParams);
     if ($this->uri != 'feed') {
         if (str_replace("%20", '+', $searchUri) != str_replace("%20", '+', WEB_PATH . $this->uri)) {
             $this->redirectTo($searchUri, 301);
         }
     }
     ////////////////////////////////
     //GETTING AND FIXING SENT DATA//
     ////////////////////////////////
     $p_sCategory = Params::getParam('sCategory');
     if (!is_array($p_sCategory)) {
         if ($p_sCategory == '') {
             $p_sCategory = array();
         } else {
             $p_sCategory = explode(",", $p_sCategory);
         }
     }
     $p_sCityArea = Params::getParam('sCityArea');
     if (!is_array($p_sCityArea)) {
         if ($p_sCityArea == '') {
             $p_sCityArea = array();
         } else {
             $p_sCityArea = explode(",", $p_sCityArea);
         }
     }
     $p_sCity = Params::getParam('sCity');
     if (!is_array($p_sCity)) {
         if ($p_sCity == '') {
             $p_sCity = array();
         } else {
             $p_sCity = explode(",", $p_sCity);
         }
     }
     $p_sRegion = Params::getParam('sRegion');
     if (!is_array($p_sRegion)) {
         if ($p_sRegion == '') {
             $p_sRegion = array();
         } else {
             $p_sRegion = explode(",", $p_sRegion);
         }
     }
     $p_sCountry = Params::getParam('sCountry');
     if (!is_array($p_sCountry)) {
         if ($p_sCountry == '') {
             $p_sCountry = array();
         } else {
             $p_sCountry = explode(",", $p_sCountry);
         }
     }
     $p_sUser = Params::getParam('sUser');
     if (!is_array($p_sUser)) {
         if ($p_sUser == '') {
             $p_sUser = '';
         } else {
             $p_sUser = explode(",", $p_sUser);
         }
     }
     $p_sLocale = Params::getParam('sLocale');
     if (!is_array($p_sLocale)) {
         if ($p_sLocale == '') {
             $p_sLocale = '';
         } else {
             $p_sLocale = explode(",", $p_sLocale);
         }
     }
     $p_sPattern = trim(strip_tags(Params::getParam('sPattern')));
     // ADD TO THE LIST OF LAST SEARCHES
     if (osc_save_latest_searches() && (!Params::existParam('iPage') || Params::getParam('iPage') == 1)) {
         $savePattern = osc_apply_filter('save_latest_searches_pattern', $p_sPattern);
         if ($savePattern != '') {
             LatestSearches::newInstance()->insert(array('s_search' => $savePattern, 'd_date' => date('Y-m-d H:i:s')));
         }
     }
     $p_bPic = Params::getParam('bPic');
     $p_bPic = $p_bPic == 1 ? 1 : 0;
     $p_bPremium = Params::getParam('bPremium');
     $p_bPremium = $p_bPremium == 1 ? 1 : 0;
     $p_sPriceMin = Params::getParam('sPriceMin');
     $p_sPriceMax = Params::getParam('sPriceMax');
     //WE CAN ONLY USE THE FIELDS RETURNED BY Search::getAllowedColumnsForSorting()
     $p_sOrder = Params::getParam('sOrder');
     if (!in_array($p_sOrder, Search::getAllowedColumnsForSorting())) {
         $p_sOrder = osc_default_order_field_at_search();
     }
     $old_order = $p_sOrder;
     //ONLY 0 ( => 'asc' ), 1 ( => 'desc' ) AS ALLOWED VALUES
     $p_iOrderType = Params::getParam('iOrderType');
     $allowedTypesForSorting = Search::getAllowedTypesForSorting();
     $orderType = osc_default_order_type_at_search();
     foreach ($allowedTypesForSorting as $k => $v) {
         if ($p_iOrderType == $v) {
             $orderType = $k;
             break;
         }
     }
     $p_iOrderType = $orderType;
     $p_sFeed = Params::getParam('sFeed');
     $p_iPage = 0;
     if (is_numeric(Params::getParam('iPage')) && Params::getParam('iPage') > 0) {
         $p_iPage = intval(Params::getParam('iPage')) - 1;
     }
     if ($p_sFeed != '') {
         $p_sPageSize = 1000;
     }
     $p_sShowAs = Params::getParam('sShowAs');
     $aValidShowAsValues = array('list', 'gallery');
     if (!in_array($p_sShowAs, $aValidShowAsValues)) {
         $p_sShowAs = osc_default_show_as_at_search();
     }
     // search results: it's blocked with the maxResultsPerPage@search defined in t_preferences
     $p_iPageSize = intval(Params::getParam('iPagesize'));
     if ($p_iPageSize > 0) {
         if ($p_iPageSize > osc_max_results_per_page_at_search()) {
             $p_iPageSize = osc_max_results_per_page_at_search();
         }
     } else {
         $p_iPageSize = osc_default_results_per_page_at_search();
     }
     //FILTERING CATEGORY
     $bAllCategoriesChecked = false;
     $successCat = false;
     if (count($p_sCategory) > 0) {
         foreach ($p_sCategory as $category) {
             $successCat = $this->mSearch->addCategory($category) || $successCat;
         }
     } else {
         $bAllCategoriesChecked = true;
     }
     //FILTERING CITY_AREA
     foreach ($p_sCityArea as $city_area) {
         $this->mSearch->addCityArea($city_area);
     }
     $p_sCityArea = implode(", ", $p_sCityArea);
     //FILTERING CITY
     foreach ($p_sCity as $city) {
         $this->mSearch->addCity($city);
     }
     $p_sCity = implode(", ", $p_sCity);
     //FILTERING REGION
     foreach ($p_sRegion as $region) {
         $this->mSearch->addRegion($region);
     }
     $p_sRegion = implode(", ", $p_sRegion);
     //FILTERING COUNTRY
     foreach ($p_sCountry as $country) {
         $this->mSearch->addCountry($country);
     }
     $p_sCountry = implode(", ", $p_sCountry);
     // FILTERING PATTERN
     if ($p_sPattern != '') {
         $this->mSearch->addPattern($p_sPattern);
         $osc_request['sPattern'] = $p_sPattern;
     } else {
         // hardcoded - if there isn't a search pattern, order by dt_pub_date desc
         if ($p_sOrder == 'relevance') {
             $p_sOrder = 'dt_pub_date';
             foreach ($allowedTypesForSorting as $k => $v) {
                 if ($p_iOrderType == 'desc') {
                     $orderType = $k;
                     break;
                 }
             }
             $p_iOrderType = $orderType;
         }
     }
     // FILTERING USER
     if ($p_sUser != '') {
         $this->mSearch->fromUser($p_sUser);
     }
     // FILTERING LOCALE
     $this->mSearch->addLocale($p_sLocale);
     // FILTERING IF WE ONLY WANT ITEMS WITH PICS
     if ($p_bPic) {
         $this->mSearch->withPicture(true);
     }
     // FILTERING IF WE ONLY WANT PREMIUM ITEMS
     if ($p_bPremium) {
         $this->mSearch->onlyPremium(true);
     }
     //FILTERING BY RANGE PRICE
     $this->mSearch->priceRange($p_sPriceMin, $p_sPriceMax);
     //ORDERING THE SEARCH RESULTS
     $this->mSearch->order($p_sOrder, $allowedTypesForSorting[$p_iOrderType]);
     //SET PAGE
     if ($p_sFeed == 'rss') {
         // If param sFeed=rss, just output last 'osc_num_rss_items()'
         $this->mSearch->page(0, osc_num_rss_items());
     } else {
         $this->mSearch->page($p_iPage, $p_iPageSize);
     }
     // CUSTOM FIELDS
     $custom_fields = Params::getParam('meta');
     $fields = Field::newInstance()->findIDSearchableByCategories($p_sCategory);
     $table = DB_TABLE_PREFIX . 't_item_meta';
     if (is_array($custom_fields)) {
         foreach ($custom_fields as $key => $aux) {
             if (in_array($key, $fields)) {
                 $field = Field::newInstance()->findByPrimaryKey($key);
                 switch ($field['e_type']) {
                     case 'TEXTAREA':
                     case 'TEXT':
                     case 'URL':
                         if ($aux != '') {
                             $aux = "%{$aux}%";
                             $sql = "SELECT fk_i_item_id FROM {$table} WHERE ";
                             $str_escaped = Search::newInstance()->dao->escape($aux);
                             $sql .= $table . '.fk_i_field_id = ' . $key . ' AND ';
                             $sql .= $table . ".s_value LIKE " . $str_escaped;
                             $this->mSearch->addConditions(DB_TABLE_PREFIX . 't_item.pk_i_id IN (' . $sql . ')');
                         }
                         break;
                     case 'DROPDOWN':
                     case 'RADIO':
                         if ($aux != '') {
                             $sql = "SELECT fk_i_item_id FROM {$table} WHERE ";
                             $str_escaped = Search::newInstance()->dao->escape($aux);
                             $sql .= $table . '.fk_i_field_id = ' . $key . ' AND ';
                             $sql .= $table . ".s_value = " . $str_escaped;
                             $this->mSearch->addConditions(DB_TABLE_PREFIX . 't_item.pk_i_id IN (' . $sql . ')');
                         }
                         break;
                     case 'CHECKBOX':
                         if ($aux != '') {
                             $sql = "SELECT fk_i_item_id FROM {$table} WHERE ";
                             $sql .= $table . '.fk_i_field_id = ' . $key . ' AND ';
                             $sql .= $table . ".s_value = 1";
                             $this->mSearch->addConditions(DB_TABLE_PREFIX . 't_item.pk_i_id IN (' . $sql . ')');
                         }
                         break;
                     case 'DATE':
                         if ($aux != '') {
                             $y = (int) date('Y', $aux);
                             $m = (int) date('n', $aux);
                             $d = (int) date('j', $aux);
                             $start = mktime('0', '0', '0', $m, $d, $y);
                             $end = mktime('23', '59', '59', $m, $d, $y);
                             $sql = "SELECT fk_i_item_id FROM {$table} WHERE ";
                             $sql .= $table . '.fk_i_field_id = ' . $key . ' AND ';
                             $sql .= $table . ".s_value >= " . $start . " AND ";
                             $sql .= $table . ".s_value <= " . $end;
                             $this->mSearch->addConditions(DB_TABLE_PREFIX . 't_item.pk_i_id IN (' . $sql . ')');
                         }
                         break;
                     case 'DATEINTERVAL':
                         if (is_array($aux) && (!empty($aux['from']) && !empty($aux['to']))) {
                             $from = $aux['from'];
                             $to = $aux['to'];
                             $start = $from;
                             $end = $to;
                             $sql = "SELECT fk_i_item_id FROM {$table} WHERE ";
                             $sql .= $table . '.fk_i_field_id = ' . $key . ' AND ';
                             $sql .= $start . " >= " . $table . ".s_value AND s_multi = 'from'";
                             $sql1 = "SELECT fk_i_item_id FROM {$table} WHERE ";
                             $sql1 .= $table . ".fk_i_field_id = " . $key . " AND ";
                             $sql1 .= $end . " <= " . $table . ".s_value AND s_multi = 'to'";
                             $sql_interval = "select a.fk_i_item_id from (" . $sql . ") a where a.fk_i_item_id IN (" . $sql1 . ")";
                             $this->mSearch->addConditions(DB_TABLE_PREFIX . 't_item.pk_i_id IN (' . $sql_interval . ')');
                         }
                         break;
                     default:
                         break;
                 }
             }
         }
     }
     osc_run_hook('search_conditions', Params::getParamsAsArray());
     // RETRIEVE ITEMS AND TOTAL
     $key = md5(osc_base_url() . $this->mSearch->toJson());
     $found = null;
     $cache = osc_cache_get($key, $found);
     $aItems = null;
     $iTotalItems = null;
     if ($cache) {
         $aItems = $cache['aItems'];
         $iTotalItems = $cache['iTotalItems'];
     } else {
         $aItems = $this->mSearch->doSearch();
         $iTotalItems = $this->mSearch->count();
         $_cache['aItems'] = $aItems;
         $_cache['iTotalItems'] = $iTotalItems;
         osc_cache_set($key, $_cache, OSC_CACHE_TTL);
     }
     $iStart = $p_iPage * $p_iPageSize;
     $iEnd = min(($p_iPage + 1) * $p_iPageSize, $iTotalItems);
     $iNumPages = ceil($iTotalItems / $p_iPageSize);
     // works with cache enabled ?
     osc_run_hook('search', $this->mSearch);
     //preparing variables...
     $countryName = $p_sCountry;
     if (strlen($p_sCountry) == 2) {
         $c = Country::newInstance()->findByCode($p_sCountry);
         if ($c) {
             $countryName = $c['s_name'];
         }
     }
     $regionName = $p_sRegion;
     if (is_numeric($p_sRegion)) {
         $r = Region::newInstance()->findByPrimaryKey($p_sRegion);
         if ($r) {
             $regionName = $r['s_name'];
         }
     }
     $cityName = $p_sCity;
     if (is_numeric($p_sCity)) {
         $c = City::newInstance()->findByPrimaryKey($p_sCity);
         if ($c) {
             $cityName = $c['s_name'];
         }
     }
     $this->_exportVariableToView('search_start', $iStart);
     $this->_exportVariableToView('search_end', $iEnd);
     $this->_exportVariableToView('search_category', $p_sCategory);
     // hardcoded - non pattern and order by relevance
     $p_sOrder = $old_order;
     $this->_exportVariableToView('search_order_type', $p_iOrderType);
     $this->_exportVariableToView('search_order', $p_sOrder);
     $this->_exportVariableToView('search_pattern', $p_sPattern);
     $this->_exportVariableToView('search_from_user', $p_sUser);
     $this->_exportVariableToView('search_total_pages', $iNumPages);
     $this->_exportVariableToView('search_page', $p_iPage);
     $this->_exportVariableToView('search_has_pic', $p_bPic);
     $this->_exportVariableToView('search_only_premium', $p_bPremium);
     $this->_exportVariableToView('search_country', $countryName);
     $this->_exportVariableToView('search_region', $regionName);
     $this->_exportVariableToView('search_city', $cityName);
     $this->_exportVariableToView('search_price_min', $p_sPriceMin);
     $this->_exportVariableToView('search_price_max', $p_sPriceMax);
     $this->_exportVariableToView('search_total_items', $iTotalItems);
     $this->_exportVariableToView('items', $aItems);
     $this->_exportVariableToView('search_show_as', $p_sShowAs);
     $this->_exportVariableToView('search', $this->mSearch);
     // json
     $json = $this->mSearch->toJson();
     $encoded_alert = base64_encode(osc_encrypt_alert($json));
     // Create the HMAC signature and convert the resulting hex hash into base64
     $stringToSign = osc_get_alert_public_key() . $encoded_alert;
     $signature = hex2b64(hmacsha1(osc_get_alert_private_key(), $stringToSign));
     $server_signature = Session::newInstance()->_set('alert_signature', $signature);
     $this->_exportVariableToView('search_alert', $encoded_alert);
     // calling the view...
     if (count($aItems) === 0) {
         header('HTTP/1.1 404 Not Found');
     }
     osc_run_hook("after_search");
     if (!Params::existParam('sFeed')) {
         $this->doView('search.php');
     } else {
         if ($p_sFeed == '' || $p_sFeed == 'rss') {
             // FEED REQUESTED!
             header('Content-type: text/xml; charset=utf-8');
             $feed = new RSSFeed();
             $feed->setTitle(__('Latest listings added') . ' - ' . osc_page_title());
             $feed->setLink(osc_base_url());
             $feed->setDescription(__('Latest listings added in') . ' ' . osc_page_title());
             if (osc_count_items() > 0) {
                 while (osc_has_items()) {
                     if (osc_count_item_resources() > 0) {
                         osc_has_item_resources();
                         $feed->addItem(array('title' => osc_item_title(), 'link' => htmlentities(osc_item_url(), ENT_COMPAT, "UTF-8"), 'description' => osc_item_description(), 'country' => osc_item_country(), 'region' => osc_item_region(), 'city' => osc_item_city(), 'city_area' => osc_item_city_area(), 'category' => osc_item_category(), 'dt_pub_date' => osc_item_pub_date(), 'image' => array('url' => htmlentities(osc_resource_thumbnail_url(), ENT_COMPAT, "UTF-8"), 'title' => osc_item_title(), 'link' => htmlentities(osc_item_url(), ENT_COMPAT, "UTF-8"))));
                     } else {
                         $feed->addItem(array('title' => osc_item_title(), 'link' => htmlentities(osc_item_url(), ENT_COMPAT, "UTF-8"), 'description' => osc_item_description(), 'country' => osc_item_country(), 'region' => osc_item_region(), 'city' => osc_item_city(), 'city_area' => osc_item_city_area(), 'category' => osc_item_category(), 'dt_pub_date' => osc_item_pub_date()));
                     }
                 }
             }
             osc_run_hook('feed', $feed);
             $feed->dumpXML();
         } else {
             osc_run_hook('feed_' . $p_sFeed, $aItems);
         }
     }
 }