Example #1
0
 /**
  * Displays the application output in the canvas.
  *
  * @since	1.0
  * @access	public
  * @param	int		The user id that is currently being viewed.
  */
 public function display($groupId = null, $docType = null)
 {
     $group = FD::group($groupId);
     // Render the rss model
     $model = FD::model('RSS');
     $result = $model->getItems($group->id, SOCIAL_TYPE_GROUP);
     // If there are tasks, we need to bind them with the table.
     $feeds = array();
     if ($result) {
         foreach ($result as $row) {
             // Bind the result back to the note object.
             $rss = FD::table('Rss');
             $rss->bind($row);
             // Initialize the parser.
             $parser = @JFactory::getFeedParser($rss->url);
             $rss->parser = $parser;
             $rss->total = @$parser->get_item_quantity();
             $rss->items = @$parser->get_items();
             $feeds[] = $rss;
         }
     }
     // Get the app params
     $params = $this->app->getParams();
     $limit = $params->get('total', 5);
     $this->set('totalDisplayed', $limit);
     $this->set('appId', $this->app->id);
     $this->set('group', $group);
     $this->set('feeds', $feeds);
     echo parent::display('views/default');
 }
Example #2
0
 static function getFeed($params)
 {
     // module params
     $rssurl = $params->get('rssurl', '');
     // get RSS parsed object
     $cache_time = 0;
     if ($params->get('cache')) {
         $cache_time = $params->get('cache_time', 15) * 60;
     }
     $rssDoc = JFactory::getFeedParser($rssurl, $cache_time);
     $feed = new stdclass();
     if ($rssDoc != false) {
         // channel header and link
         $feed->title = $rssDoc->get_title();
         $feed->link = $rssDoc->get_link();
         $feed->description = $rssDoc->get_description();
         // channel image if exists
         $feed->image->url = $rssDoc->get_image_url();
         $feed->image->title = $rssDoc->get_image_title();
         // items
         $items = $rssDoc->get_items();
         // feed elements
         $feed->items = array_slice($items, 0, $params->get('rssitems', 5));
     } else {
         $feed = false;
     }
     return $feed;
 }
Example #3
0
 function getFeed()
 {
     $sefConfig =& SEFConfig::getConfig();
     if (!$sefConfig->artioFeedDisplay) {
         return '';
     }
     $rssDoc = JFactory::getFeedParser($sefConfig->artioFeedUrl);
     if ($rssDoc === false) {
         return JText::_('COM_SEF_ERROR_CONNECTING_TO_RSS_FEED');
     }
     $items = $rssDoc->get_items();
     if (count($items) == 0) {
         return JText::_('COM_SEF_NO_ITEMS_TO_DISPLAY');
     }
     $txt = '';
     for ($i = 0, $n = count($items); $i < $n; $i++) {
         $item =& $items[$i];
         $title = $item->get_title();
         $link = $item->get_link();
         $desc = $item->get_description();
         $date = $item->get_date('j. F Y');
         $author = $item->get_author();
         $txt .= '<div class="feed-item">';
         $txt .= '<div class="feed-title"><a href="' . $link . '" target="_blank">' . $title . '</a></div>';
         $txt .= '<div class="feed-text">' . $desc . '</div>';
         $txt .= '</div>';
     }
     return $txt;
 }
Example #4
0
 public function fetchFeeds($url = '', $max = 3)
 {
     if (method_exists('JFactory', 'getFeedParser')) {
         $rss = JFactory::getFeedParser($url);
     } else {
         $rss = JFactory::getXMLParser('rss', array('rssUrl' => $url));
     }
     if ($rss == null) {
         return false;
     }
     $result = $rss->get_items();
     $feeds = array();
     $i = 0;
     foreach ($result as $r) {
         if ($i == $max) {
             break;
         }
         $feed = array();
         $feed['link'] = $r->get_link();
         $feed['title'] = $r->get_title();
         $feed['description'] = preg_replace('/<img([^>]+)>/', '', $r->get_description());
         $feeds[] = $feed;
         $i++;
     }
     return $feeds;
 }
Example #5
0
 /**
  * Stores a new feed item
  *
  * @since	1.0
  * @access	public
  */
 public function save()
 {
     // Check for request forgeries.
     FD::checkToken();
     // Ensure that the user is logged in.
     FD::requireLogin();
     // Get the ajax object.
     $ajax = FD::ajax();
     // Get current logged in user
     $my = FD::user();
     // Get app's id.
     $id = JRequest::getInt('id');
     // Get feed table
     $feed = $this->getTable('Feed');
     // Set the feed props
     $feed->user_id = $my->id;
     $feed->title = JRequest::getVar('title');
     $feed->url = JRequest::getVar('url');
     $feed->state = SOCIAL_STATE_PUBLISHED;
     // $parser 	= new JFeedFactory;
     // $rss 		= $parser->getFeed( $feed->url );
     $rss = @JFactory::getFeedParser($feed->url);
     if ($rss) {
         // $feed->description	= $rss->description;
         $feed->description = @$rss->get_description();
     }
     $state = $feed->store();
     if (!$state) {
         return $ajax->reject($feed->getError());
     }
     // Get the application params
     $params = $this->getParams();
     // Create new stream item when a new feed is created
     if ($params->get('stream_create', true)) {
         $feed->createStream('create');
     }
     $theme = FD::themes();
     $theme->set('feed', $feed);
     $output = $theme->output('apps/user/feeds/dashboard/default.item');
     return $ajax->resolve($output);
 }
Example #6
0
 public function isValid()
 {
     // Connect and get the remote video
     if (!parent::isValid()) {
         return false;
     }
     if (class_exists('JFeedFactory')) {
         $feed = new JFeedFactory();
         $rssDoc = $feed->getFeed($this->getFeedUrl());
         $this->title = $rssDoc[0]->title;
         $this->data = $rssDoc[0]->content;
     } else {
         $rssDoc = JFactory::getFeedParser($this->getFeedUrl(), 0);
         foreach ($rssDoc->get_items() as $item) {
             $enclosures = $item->get_enclosures();
             $this->duration = $enclosures[0]->get_duration();
             $this->title = $item->get_title();
             $this->data = $item->get_description();
         }
     }
     return true;
 }
Example #7
0
 static function getFeed($params)
 {
     // module params
     $rssurl = $params->get('rssurl', '');
     // get RSS parsed object
     $cache_time = 0;
     if ($params->get('cache')) {
         /*
          * The cache_time will get fed into JCache to initiate the feed_parser cache group and eventually
          * JCacheStorage will multiply the value by 60 and use that for its lifetime. The only way to sync
          * the feed_parser cache (which caches with an empty dataset anyway) with the module cache is to
          * first divide the module's cache time by 60 then inject that forward, which once stored into the
          * JCacheStorage object, will be the correct value in minutes.
          */
         $cache_time = $params->get('cache_time', 15) / 60;
     }
     $rssDoc = JFactory::getFeedParser($rssurl, $cache_time);
     $feed = new stdClass();
     if ($rssDoc != false) {
         // channel header and link
         $feed->title = $rssDoc->get_title();
         $feed->link = $rssDoc->get_link();
         $feed->description = $rssDoc->get_description();
         // channel image if exists
         $feed->image = new stdClass();
         $feed->image->url = $rssDoc->get_image_url();
         $feed->image->title = $rssDoc->get_image_title();
         // items
         $items = $rssDoc->get_items();
         // feed elements
         $feed->items = array_slice($items, 0, $params->get('rssitems', 5));
     } else {
         $feed = false;
     }
     return $feed;
 }
    public static function render($params)
    {
        // module params
        $rssurl = $params->get('feedurl', '');
        $rssitems = $params->get('feeditems', 5);
        $rssdesc = $params->get('rssdesc', 1);
        $rssimage = $params->get('rssimage', 1);
        $rssitemdesc = $params->get('rssitemdesc', 1);
        $words = $params->get('word_count', 40);
        $rsstitle = $params->get('rsstitle', 1);
        $rssrtl = $params->get('rssrtl', 0);
        $moduleclass_sfx = $params->get('moduleclass_sfx', '');
        $filter = JFilterInput::getInstance();
        //  get RSS parsed object
        $rssDoc = JFactory::getFeedParser($rssurl);
        //	    var_dump($rssDoc);
        // echo "feed " + $rssurl;
        if ($rssDoc != false) {
            // channel header and link
            $channel['title'] = $filter->clean($rssDoc->get_title());
            $channel['link'] = $filter->clean($rssDoc->get_link());
            $channel['description'] = $filter->clean($rssDoc->get_description());
            // channel image if exists
            $image['url'] = $rssDoc->get_image_url();
            $image['title'] = $rssDoc->get_image_title();
            //image handling
            $iUrl = isset($image['url']) ? $image['url'] : null;
            $iTitle = isset($image['title']) ? $image['title'] : null;
            // items
            $items = $rssDoc->get_items();
            // feed elements
            $items = array_slice($items, 0, $rssitems);
            ?>
        <table cellpadding="0" cellspacing="0" class="moduletable<?php 
            echo htmlspecialchars($params->get('moduleclass_sfx'));
            ?>
">
            <?php 
            // feed description
            if (!is_null($channel['title']) && $rsstitle) {
                ?>
                <tr>
                    <td>
                        <strong>
                            <a href="<?php 
                echo htmlspecialchars(str_replace('&', '&amp;', $channel['link']));
                ?>
" target="_blank">
                                <?php 
                echo htmlspecialchars($channel['title']);
                ?>
</a>
                        </strong>
                    </td>
                </tr>
                <?php 
            }
            // feed description
            if ($rssdesc) {
                ?>
                <tr>
                    <td>
                        <?php 
                echo $channel['description'];
                ?>
                    </td>
                </tr>
                <?php 
            }
            // feed image
            if ($rssimage && $iUrl) {
                ?>
                <tr>
                    <td align="center">
                        <img src="<?php 
                echo htmlspecialchars($iUrl);
                ?>
" alt="<?php 
                echo htmlspecialchars(@$iTitle);
                ?>
"/>
                    </td>
                </tr>
                <?php 
            }
            $actualItems = count($items);
            $setItems = $rssitems;
            if ($setItems > $actualItems) {
                $totalItems = $actualItems;
            } else {
                $totalItems = $setItems;
            }
            ?>
            <tr>
                <td>
                    <ul class="newsfeed<?php 
            echo htmlspecialchars($moduleclass_sfx);
            ?>
"  >
                        <?php 
            for ($j = 0; $j < $totalItems; $j++) {
                $currItem =& $items[$j];
                // item title
                ?>
                            <li>
                                <?php 
                if (!is_null($currItem->get_link())) {
                    ?>
                                    <a href="<?php 
                    echo htmlspecialchars($currItem->get_link());
                    ?>
" target="_child">
                                        <?php 
                    echo htmlspecialchars($currItem->get_title());
                    ?>
</a>
                                    <?php 
                }
                // item description
                if ($rssitemdesc) {
                    // item description
                    $text = $filter->clean(html_entity_decode($currItem->get_description(), ENT_COMPAT, 'UTF-8'));
                    $text = str_replace('&apos;', "'", $text);
                    // Word limit check
                    if ($words) {
                        $texts = explode(' ', $text);
                        $count = count($texts);
                        if ($count > $words) {
                            $text = '';
                            for ($i = 0; $i < $words; $i++) {
                                $text .= ' ' . $texts[$i];
                            }
                            $text .= '...';
                        }
                    }
                    ?>
                                    <div style="text-align: <?php 
                    echo $rssrtl ? 'right' : 'left';
                    ?>
 !important">
                                        <?php 
                    echo $text;
                    ?>
                                    </div>
                                    <?php 
                }
                ?>
                            </li>
                            <?php 
            }
            ?>
                    </ul>
                </td>
            </tr>
        </table>
        <?php 
        }
    }
Example #9
0
 /**
  * Stores a new feed item
  *
  * @since	1.0
  * @access	public
  */
 public function save()
 {
     // Check for request forgeries.
     FD::checkToken();
     // Ensure that the user is logged in.
     FD::requireLogin();
     // Get the ajax object.
     $ajax = FD::ajax();
     // Get current logged in user
     $my = FD::user();
     // Get the group object
     $groupId = $this->input->get('groupId', 0, 'int');
     $group = FD::group($groupId);
     // Ensure that this is the owner or the group admin
     if (!$group->isMember()) {
         return $ajax->reject(JText::_('APP_FEEDS_NOT_ALLOWED_TO_CREATE'));
     }
     // Get app's id.
     $id = $this->input->get('appId', '', 'int');
     // Get feed table
     $rss = FD::table('Rss');
     // Set the feed owner
     $rss->uid = $group->id;
     $rss->type = SOCIAL_TYPE_GROUP;
     $rss->user_id = $my->id;
     // Get the feed title
     $rss->title = $this->input->get('title', '', 'default');
     $rss->url = $this->input->get('url', '', 'default');
     $rss->state = true;
     // Load up the feed parser
     $parser = @JFactory::getFeedParser($rss->url);
     if ($parser) {
         // $feed->description	= $rss->description;
         $rss->description = @$parser->get_description();
     }
     // Try to save the feed now
     $state = $rss->store();
     if (!$state) {
         return $ajax->reject($rss->getError());
     }
     // Get the application params
     $params = $this->getParams();
     // Create new stream item when a new feed is created
     if ($params->get('stream_create', true)) {
         $rss->createStream('create');
     }
     // Initialize the parser.
     $parser = @JFactory::getFeedParser($rss->url);
     // If that is invalid feed url
     if ($parser === false) {
         return $ajax->resolve();
     }
     $rss->parser = $parser;
     $rss->total = @$parser->get_item_quantity();
     $rss->items = @$parser->get_items();
     $theme = FD::themes();
     // @TODO
     $theme->set('totalDisplayed', 5);
     $theme->set('rss', $rss);
     $output = $theme->output('apps/group/feeds/views/default.item');
     return $ajax->resolve($output);
 }
Example #10
0
 /**
  * Get an XML document
  *
  * @param string The type of xml parser needed 'DOM', 'RSS' or 'Simple'
  * @param array:
  * 		string  ['rssUrl'] the rss url to parse when using "RSS"
  * 		string	['cache_time'] with 'RSS' - feed cache time. If not defined defaults to 3600 sec
  * @return object Parsed XML document object
  * @deprecated
  */
 public static function getXMLParser($type = '', $options = array())
 {
     $doc = null;
     switch (strtolower($type)) {
         case 'rss':
         case 'atom':
             $cache_time = isset($options['cache_time']) ? $options['cache_time'] : 0;
             $doc = JFactory::getFeedParser($options['rssUrl'], $cache_time);
             break;
         case 'simple':
             // JError::raiseWarning('SOME_ERROR_CODE', 'JSimpleXML is deprecated. Use JFactory::getXML instead');
             jimport('joomla.utilities.simplexml');
             $doc = new JSimpleXML();
             break;
         case 'dom':
             JError::raiseWarning('SOME_ERROR_CODE', 'DommitDocument is deprecated.  Use DomDocument instead');
             $doc = null;
             break;
             throw new JException('DommitDocument is deprecated.  Use DomDocument instead');
         default:
             $doc = null;
     }
     return $doc;
 }
Example #11
0
    /**
     * Renders a feed
     *
     * @param   string  $url  - the feed url
     *
     * @return void
     */
    public static function renderFeed($url)
    {
        $rssitems = 5;
        $rssitemdesc = 1;
        // Aaach, Joomla 2.5 please die faster...
        if (JVERSION < '3') {
            $rssDoc = JFactory::getFeedParser($url, 900);
            if (!$rssDoc) {
                return JText::_('LIB_COMPOJOOM_FEED_COULDNT_BE_FETCHED');
            }
        } else {
            // Get RSS parsed object
            try {
                jimport('joomla.feed.factory');
                $feed = new JFeedFactory();
                $rssDoc = $feed->getFeed($url);
            } catch (Exception $e) {
                return JText::_('LIB_COMPOJOOM_FEED_COULDNT_BE_FETCHED');
            }
        }
        $feed = $rssDoc;
        if (JVERSION < 3) {
            if ($rssDoc != false) {
                $filter = JFilterInput::getInstance();
                // Channel header and link
                $channel['title'] = $filter->clean($rssDoc->get_title());
                $channel['link'] = $filter->clean($rssDoc->get_link());
                $channel['description'] = $filter->clean($rssDoc->get_description());
                // Items
                $items = $rssDoc->get_items();
                // Feed elements
                $items = array_slice($items, 0, $rssitems);
                ?>
				<div class="newsfeed">
					<?php 
                if (!is_null($channel['title'])) {
                    ?>
						<h2>
							<a href="<?php 
                    echo htmlspecialchars(str_replace('&', '&amp;', $channel['link']));
                    ?>
" target="_blank">
								<?php 
                    echo htmlspecialchars($channel['title']);
                    ?>
</a>
						</h2>
					<?php 
                }
                ?>

					<?php 
                echo $channel['description'];
                ?>

					<?php 
                $actualItems = count($items);
                $setItems = $rssitems;
                if ($setItems > $actualItems) {
                    $totalItems = $actualItems;
                } else {
                    $totalItems = $setItems;
                }
                ?>

						<ul class="newsfeed">
							<?php 
                for ($j = 0; $j < $totalItems; $j++) {
                    $currItem = $items[$j];
                    ?>
								<li>
									<?php 
                    if (!is_null($currItem->get_link())) {
                        ?>
										<a href="<?php 
                        echo htmlspecialchars($currItem->get_link());
                        ?>
" target="_child">
											<?php 
                        echo htmlspecialchars($currItem->get_title());
                        ?>
</a>
									<?php 
                    }
                    ?>

									<?php 
                    // Item description
                    if ($rssitemdesc) {
                        // Item description
                        $text = $filter->clean(html_entity_decode($currItem->get_description(), ENT_COMPAT, 'UTF-8'));
                        $text = str_replace('&apos;', "'", $text);
                        $texts = explode(' ', $text);
                        $count = count($texts);
                        if ($count > 50) {
                            $text = '';
                            for ($i = 0; $i < 50; $i++) {
                                $text .= ' ' . $texts[$i];
                            }
                            $text .= '...';
                        }
                        ?>
										<div>
											<?php 
                        echo $text;
                        ?>
										</div>
									<?php 
                    }
                    ?>
								</li>
							<?php 
                }
                ?>
						</ul>
					</div>
			<?php 
            }
        } else {
            if ($rssDoc != false) {
                ?>
				<div class="feed">
					<?php 
                if (!is_null($feed->title)) {
                    ?>
						<h2>
							<a href="<?php 
                    echo str_replace('&', '&amp;', $url);
                    ?>
" target="_blank">
								<?php 
                    echo $feed->title;
                    ?>
</a>
						</h2>
					<?php 
                }
                ?>

					<?php 
                echo $feed->description;
                ?>


					<ul class="newsfeed">
						<?php 
                for ($i = 0; $i < $rssitems; $i++) {
                    if (!$feed->offsetExists($i)) {
                        break;
                    }
                    ?>
							<?php 
                    $uri = !empty($feed[$i]->uri) || !is_null($feed[$i]->uri) ? $feed[$i]->uri : $feed[$i]->guid;
                    $text = !empty($feed[$i]->content) || !is_null($feed[$i]->content) ? $feed[$i]->content : $feed[$i]->description;
                    ?>
							<li>
								<?php 
                    if (!empty($uri)) {
                        ?>
									<h5 class="feed-link">
										<a href="<?php 
                        echo $uri;
                        ?>
" target="_blank">
											<?php 
                        echo $feed[$i]->title;
                        ?>
</a></h5>
								<?php 
                    } else {
                        ?>
									<h5 class="feed-link"><?php 
                        echo $feed[$i]->title;
                        ?>
</h5>
								<?php 
                    }
                    ?>

								<?php 
                    if ($rssitemdesc && !empty($text)) {
                        ?>
									<div class="feed-item-description">
										<?php 
                        // Strip the images.
                        $text = JFilterOutput::stripImages($text);
                        $text = JHtml::_('string.truncate', $text, 250);
                        echo str_replace('&apos;', "'", $text);
                        ?>
									</div>
								<?php 
                    }
                    ?>
							</li>
						<?php 
                }
                ?>
					</ul>
				</div>
			<?php 
            }
        }
    }
Example #12
0
    public static function render($params)
    {
        // module params
        $rssurl = $params->get('rssurl', '');
        $rssitems = $params->get('rssitems', 5);
        $rssdesc = $params->get('rssdesc', 1);
        $rssimage = $params->get('rssimage', 1);
        $rssitemdesc = $params->get('rssitemdesc', 1);
        $words = $params->def('word_count', 0);
        $rsstitle = $params->get('rsstitle', 1);
        $rssrtl = $params->get('rssrtl', 0);
        $moduleclass_sfx = $params->get('moduleclass_sfx', '');
        $filter = JFilterInput::getInstance();
        // get RSS parsed object
        $cache_time = 0;
        if ($params->get('cache')) {
            /*
             * The cache_time will get fed into JCache to initiate the feed_parser cache group and eventually
             * JCacheStorage will multiply the value by 60 and use that for its lifetime. The only way to sync
             * the feed_parser cache (which caches with an empty dataset anyway) with the module cache is to
             * first divide the module's cache time by 60 then inject that forward, which once stored into the
             * JCacheStorage object, will be the correct value in minutes.
             */
            $cache_time = $params->get('cache_time', 15) / 60;
        }
        $rssDoc = JFactory::getFeedParser($rssurl, $cache_time);
        if ($rssDoc != false) {
            // channel header and link
            $channel['title'] = $filter->clean($rssDoc->get_title());
            $channel['link'] = $filter->clean($rssDoc->get_link());
            $channel['description'] = $filter->clean($rssDoc->get_description());
            // channel image if exists
            $image['url'] = $rssDoc->get_image_url();
            $image['title'] = $rssDoc->get_image_title();
            //image handling
            $iUrl = isset($image['url']) ? $image['url'] : null;
            $iTitle = isset($image['title']) ? $image['title'] : null;
            // items
            $items = $rssDoc->get_items();
            // feed elements
            $items = array_slice($items, 0, $rssitems);
            ?>
			<table cellpadding="0" cellspacing="0" class="moduletable<?php 
            echo htmlspecialchars($params->get('moduleclass_sfx'));
            ?>
">
			<?php 
            // feed description
            if (!is_null($channel['title']) && $rsstitle) {
                ?>
				<tr>
				<td>
					<strong>
						<a href="<?php 
                echo htmlspecialchars(str_replace('&', '&amp;', $channel['link']));
                ?>
" target="_blank">
						<?php 
                echo htmlspecialchars($channel['title']);
                ?>
</a>
					</strong>
				</td>
				</tr>
			<?php 
            }
            // feed description
            if ($rssdesc) {
                ?>
				<tr>
					<td>
						<?php 
                echo $channel['description'];
                ?>
					</td>
				</tr>
			<?php 
            }
            // feed image
            if ($rssimage && $iUrl) {
                ?>
				<tr>
					<td align="center">
						<img src="<?php 
                echo htmlspecialchars($iUrl);
                ?>
" alt="<?php 
                echo htmlspecialchars(@$iTitle);
                ?>
"/>
					</td>
				</tr>
			<?php 
            }
            $actualItems = count($items);
            $setItems = $rssitems;
            if ($setItems > $actualItems) {
                $totalItems = $actualItems;
            } else {
                $totalItems = $setItems;
            }
            ?>
			<tr>
			<td>
				<ul class="newsfeed<?php 
            echo htmlspecialchars($moduleclass_sfx);
            ?>
"  >
				<?php 
            for ($j = 0; $j < $totalItems; $j++) {
                $currItem =& $items[$j];
                // item title
                ?>
					<li>
					<?php 
                if (!is_null($currItem->get_link())) {
                    ?>
						<a href="<?php 
                    echo htmlspecialchars($currItem->get_link());
                    ?>
" target="_child">
						<?php 
                    echo htmlspecialchars($currItem->get_title());
                    ?>
</a>
					<?php 
                }
                // item description
                if ($rssitemdesc) {
                    // item description
                    $text = $filter->clean(html_entity_decode($currItem->get_description(), ENT_COMPAT, 'UTF-8'));
                    $text = str_replace('&apos;', "'", $text);
                    // word limit check
                    if ($words) {
                        $texts = explode(' ', $text);
                        $count = count($texts);
                        if ($count > $words) {
                            $text = '';
                            for ($i = 0; $i < $words; $i++) {
                                $text .= ' ' . $texts[$i];
                            }
                            $text .= '...';
                        }
                    }
                    ?>
						<div style="text-align: <?php 
                    echo $rssrtl ? 'right' : 'left';
                    ?>
 !important">
							<?php 
                    echo $text;
                    ?>
						</div>
						<?php 
                }
                ?>
					</li>
					<?php 
            }
            ?>
				</ul>
			</td>
			</tr>
		</table>
		<?php 
        }
    }
Example #13
0
 function renderJEventsNewsCached25()
 {
     $output = '';
     //  get RSS parsed object
     $options = array();
     $options['rssUrl'] = 'https://www.jevents.net/jevnews?format=feed&type=rss';
     $options['cache_time'] = 0;
     error_reporting(0);
     ini_set('display_errors', 0);
     $rssDoc = JFactory::getFeedParser($options['rssUrl'], $options['cache_time']);
     //$rssDoc =  JFactory::getXMLparser('RSS', $options);
     if ($rssDoc == false) {
         $output = JText::_('Error: Feed not retrieved');
     } else {
         // channel header and link
         $title = str_replace(" ", "_", $rssDoc->get_title());
         $link = $rssDoc->get_link();
         $output = '<table class="adminlist   table table-striped">';
         $output .= '<tr><th><a href="' . $link . '" target="_blank">' . JText::_($title) . '</th></tr>';
         $items = array_slice($rssDoc->get_items(), 0, 3);
         $numItems = count($items);
         if ($numItems == 0) {
             $output .= '<tr><th>' . JText::_('JEV_No_news') . '</th></tr>';
         } else {
             $k = 0;
             for ($j = 0; $j < $numItems; $j++) {
                 $item = $items[$j];
                 $output .= '<tr><td class="row' . $k . '">';
                 $output .= '<a href="' . $item->get_link() . '" target="_blank">' . $item->get_title() . '</a>';
                 if ($item->get_description()) {
                     $description = $this->limitText($item->get_description(), 50);
                     $output .= '<br />' . $description;
                 }
                 $output .= '</td></tr>';
                 $k = 1 - $k;
             }
         }
         $output .= '</table>';
     }
     // do not return the output because of differences between J15 and J17
     echo $output;
 }
 public static function getFeedParser($url)
 {
     return JFactory::getFeedParser($url);
 }
Example #15
0
 /**
  * get  list of items from rss list and process caching.
  *
  * @param JParameter $params.
  * @return array list of articles
  */
 public static function dataFromRSS($params)
 {
     $data = array();
     if (trim($params->get('rss_link')) == '') {
         return $data;
     }
     $rssUrl = $params->get('rss_link');
     //  get RSS parsed object
     $options = array();
     $options['rssUrl'] = $rssUrl;
     if ($params->get('enable_cache')) {
         $options['cache_time'] = $params->get('cache_time', '30');
         $options['cache_time'] *= 60;
     } else {
         $options['cache_time'] = null;
     }
     if (version_compare(JVERSION, '3.0', 'ge')) {
         $rssDoc = JFactory::getFeedParser($rssUrl, $options['cache_time']);
     } else {
         if (version_compare(JVERSION, '2.5', 'ge')) {
             $rssDoc = JFactory::getXMLparser('RSS', $options);
         } else {
             $rssDoc = JFactory::getXMLparser('RSS', $options);
         }
     }
     if ($rssDoc != false) {
         $items = $rssDoc->get_items();
         if ($items != null) {
             $tmp = array();
             foreach ($items as $item) {
                 $obj = new stdClass();
                 $obj->title = $item->get_title();
                 $obj->link = $item->get_link();
                 $obj->introtext = $item->get_description();
                 $tmp[] = $obj;
             }
             $data = $tmp;
         }
     }
     return $data;
 }
Example #16
0
 public function display()
 {
     $this->feed = JFactory::getFeedParser($this->module->params->get('rssurl'), $this->module->params->get('cache_time', 15) * 60);
     return parent::display();
 }
Example #17
0
 /**
  * @since	1.6
  */
 function display($tpl = null)
 {
     // Initialise variables.
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $dispatcher = JDispatcher::getInstance();
     // Get view related request variables.
     $print = JRequest::getBool('print');
     // Get model data.
     $state = $this->get('State');
     $item = $this->get('Item');
     if ($item) {
         // Get Category Model data
         $categoryModel = JModel::getInstance('Category', 'NewsfeedsModel', array('ignore_request' => true));
         $categoryModel->setState('category.id', $item->catid);
         $categoryModel->setState('list.ordering', 'a.name');
         $categoryModel->setState('list.direction', 'asc');
         $items = $categoryModel->getItems();
     }
     // Check for errors.
     // @TODO Maybe this could go into JComponentHelper::raiseErrors($this->get('Errors'))
     if (count($errors = $this->get('Errors'))) {
         JError::raiseWarning(500, implode("\n", $errors));
         return false;
     }
     // Add router helpers.
     $item->slug = $item->alias ? $item->id . ':' . $item->alias : $item->id;
     $item->catslug = $item->category_alias ? $item->catid . ':' . $item->category_alias : $item->catid;
     $item->parent_slug = $item->category_alias ? $item->parent_id . ':' . $item->parent_alias : $item->parent_id;
     // check if cache directory is writeable
     $cacheDir = JPATH_CACHE . '/';
     if (!is_writable($cacheDir)) {
         JError::raiseNotice('0', JText::_('COM_NEWSFEEDS_CACHE_DIRECTORY_UNWRITABLE'));
         return;
     }
     // Merge newsfeed params. If this is single-newsfeed view, menu params override newsfeed params
     // Otherwise, newsfeed params override menu item params
     $params = $state->get('params');
     $newsfeed_params = clone $item->params;
     $active = $app->getMenu()->getActive();
     $temp = clone $params;
     // Check to see which parameters should take priority
     if ($active) {
         $currentLink = $active->link;
         // If the current view is the active item and an newsfeed view for this feed, then the menu item params take priority
         if (strpos($currentLink, 'view=newsfeed') && strpos($currentLink, '&id=' . (string) $item->id)) {
             // $item->params are the newsfeed params, $temp are the menu item params
             // Merge so that the menu item params take priority
             $newsfeed_params->merge($temp);
             $item->params = $newsfeed_params;
             // Load layout from active query (in case it is an alternative menu item)
             if (isset($active->query['layout'])) {
                 $this->setLayout($active->query['layout']);
             }
         } else {
             // Current view is not a single newsfeed, so the newsfeed params take priority here
             // Merge the menu item params with the newsfeed params so that the newsfeed params take priority
             $temp->merge($newsfeed_params);
             $item->params = $temp;
             // Check for alternative layouts (since we are not in a single-newsfeed menu item)
             if ($layout = $item->params->get('newsfeed_layout')) {
                 $this->setLayout($layout);
             }
         }
     } else {
         // Merge so that newsfeed params take priority
         $temp->merge($newsfeed_params);
         $item->params = $temp;
         // Check for alternative layouts (since we are not in a single-newsfeed menu item)
         if ($layout = $item->params->get('newsfeed_layout')) {
             $this->setLayout($layout);
         }
     }
     $offset = $state->get('list.offset');
     // Check the access to the newsfeed
     $levels = $user->getAuthorisedViewLevels();
     if (!in_array($item->access, $levels) or in_array($item->access, $levels) and !in_array($item->category_access, $levels)) {
         JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR'));
         return;
     }
     // Get the current menu item
     $menus = $app->getMenu();
     $menu = $menus->getActive();
     $params = $app->getParams();
     // Get the newsfeed
     $newsfeed = $item;
     $temp = new JRegistry();
     $temp->loadString($item->params);
     $params->merge($temp);
     //  get RSS parsed object
     $rssDoc = JFactory::getFeedParser($newsfeed->link, $newsfeed->cache_time);
     if ($rssDoc == false) {
         $msg = JText::_('COM_NEWSFEEDS_ERRORS_FEED_NOT_RETRIEVED');
         $app->redirect(NewsFeedsHelperRoute::getCategoryRoute($newsfeed->catslug), $msg);
         return;
     }
     $lists = array();
     // channel header and link
     $newsfeed->channel['title'] = $rssDoc->get_title();
     $newsfeed->channel['link'] = $rssDoc->get_link();
     $newsfeed->channel['description'] = $rssDoc->get_description();
     $newsfeed->channel['language'] = $rssDoc->get_language();
     // channel image if exists
     $newsfeed->image['url'] = $rssDoc->get_image_url();
     $newsfeed->image['title'] = $rssDoc->get_image_title();
     $newsfeed->image['link'] = $rssDoc->get_image_link();
     $newsfeed->image['height'] = $rssDoc->get_image_height();
     $newsfeed->image['width'] = $rssDoc->get_image_width();
     // items
     $newsfeed->items = $rssDoc->get_items();
     // feed elements
     $newsfeed->items = array_slice($newsfeed->items, 0, $newsfeed->numarticles);
     // feed display order
     $feed_display_order = $params->get('feed_display_order', 'des');
     if ($feed_display_order == 'asc') {
         $newsfeed->items = array_reverse($newsfeed->items);
     }
     //Escape strings for HTML output
     $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
     $this->assignRef('params', $params);
     $this->assignRef('newsfeed', $newsfeed);
     $this->assignRef('state', $state);
     $this->assignRef('item', $item);
     $this->assignRef('user', $user);
     $this->assign('print', $print);
     $this->_prepareDocument();
     parent::display($tpl);
 }
Example #18
0
 public function getRSS($url)
 {
     $rssDoc = JFactory::getFeedParser($url);
     $feed = new stdclass();
     if ($rssDoc != false) {
         // channel header and link
         $feed->title = $rssDoc->get_title();
         $feed->link = $rssDoc->get_link();
         $feed->description = $rssDoc->get_description();
         // channel image if exists
         $feed->image->url = $rssDoc->get_image_url();
         $feed->image->title = $rssDoc->get_image_title();
         // items
         $items = $rssDoc->get_items();
         // feed elements
         $feed->items = array_slice($items, 0, 5);
     } else {
         $feed = false;
     }
     return $feed;
 }
Example #19
0
 public static function getRssFeed($rssURL, $max)
 {
     // prevent Strict Standards errors in simplepie
     error_reporting(E_ALL ^ E_STRICT);
     $rssFeed = JFactory::getFeedParser($rssURL);
     if (empty($rssFeed) or !is_object($rssFeed)) {
         return false;
     }
     $count = $rssFeed->get_item_quantity();
     $limit = min($max, $count);
     for ($i = 0; $i < $limit; $i++) {
         $feed = new StdClass();
         $item = $rssFeed->get_item($i);
         $feed->link = $item->get_link();
         $feed->title = $item->get_title();
         $feed->description = $item->get_description();
         $feeds[] = $feed;
     }
     return $feeds;
 }
Example #20
0
    public static function getCanalRss($rssurl, $urlsep, $params)
    {
        $rssdesc = $params->get('rssdesc', 1);
        $rssimage = $params->get('rssimage', 1);
        $rssitemdesc = $params->get('rssitemdesc', 1);
        $words = $params->def('word_count', 0);
        $rsstitle = $params->get('rsstitle', 1);
        $moduleclass_sfx = $params->get('moduleclass_sfx', '');
        $rssitems = $params->get('rssitems', 5);
        $filter = JFilterInput::getInstance();
        // get RSS parsed object
        $cache_time = 0;
        if ($params->get('cache')) {
            $cache_time = $params->get('cache_time', 15) * 60;
        }
        $rssDoc = JFactory::getFeedParser($rssurl, $cache_time);
        if ($rssDoc != false) {
            // Cabecera de canal
            $canal['title'] = $filter->clean($rssDoc->get_title());
            $canal['link'] = $filter->clean($rssDoc->get_link());
            $canal['description'] = $filter->clean($rssDoc->get_description());
            // Imagen si existe
            $image['url'] = $rssDoc->get_image_url();
            $image['title'] = $rssDoc->get_image_title();
            //Manipulación de la imagen
            $iUrl = isset($image['url']) ? $image['url'] : null;
            $iTitle = isset($image['title']) ? $image['title'] : null;
            // Items
            $items = $rssDoc->get_items();
            // Elementos de los hilos
            $items = array_slice($items, 0, $rssitems);
            $filter = JFilterInput::getInstance();
            $html = '';
            $html .= '<div class="moduletable' . htmlspecialchars($params->get('moduleclass_sfx')) . '">';
            // Enlace y título si se optó
            if (!is_null($canal['title']) && $rsstitle) {
                $html .= '<div class="jh-feed">
							<div class="jh-sep">' . $urlsep . '</div>
							<div class="jh-title">
								<a href="' . htmlspecialchars(str_replace('&', '&amp;', $canal['link'])) . '" target="_blank">' . htmlspecialchars($canal['title']) . '</a>
							 </div>';
            }
            // Descripción
            if ($rssdesc) {
                $html .= '<div class="jh-desc">' . $canal['description'] . '</div';
            }
            // Imagen
            if ($rssimage && $iUrl) {
                $html .= ' <div class="jh-image"><img src="' . htmlspecialchars($iUrl) . '" alt="' . htmlspecialchars(@$iTitle) . '"/></div>';
            }
            $actualItems = count($items);
            $setItems = $rssitems;
            if ($setItems > $actualItems) {
                $totalItems = $actualItems;
            } else {
                $totalItems = $setItems;
            }
            $html .= ' <div class="jh-items">
							<ul class="newsfeed' . htmlspecialchars($moduleclass_sfx) . '"  >';
            for ($j = 0; $j < $totalItems; $j++) {
                $currItem =& $items[$j];
                // Comienzo de un item
                $html .= '	<li>';
                if (!is_null($currItem->get_link())) {
                    // Titulo enlazable de la noticia
                    $html .= '<a href="' . htmlspecialchars($currItem->get_link()) . '" target="_child">' . htmlspecialchars($currItem->get_title()) . '</a>';
                }
                // Descripción de la noticia
                if ($rssitemdesc) {
                    $text = $filter->clean(html_entity_decode($currItem->get_description(), ENT_COMPAT, 'UTF-8'));
                    $text = str_replace('&apos;', "'", $text);
                    // limite de palabras
                    if ($words) {
                        $texts = explode(' ', $text);
                        $count = count($texts);
                        if ($count > $words) {
                            $text = '';
                            for ($i = 0; $i < $words; $i++) {
                                $text .= ' ' . $texts[$i];
                            }
                            $text .= '...';
                        }
                    }
                    $html .= '<p class="jh-text">' . $text . '</p>';
                }
                // Fin de un item
                $html .= '</li>';
            }
            // Fin de noticias
            $html .= '	</ul></div>';
            // Cierres del cuerpo
            $html .= '	</div>';
            return $html;
        }
    }