Ticket #214: 214.diff

File 214.diff, 3.5 kB (added by werner, 7 years ago)

block ShowRss?.php and ShowRss?.ini file and lang stuff

  • modules/export/blocks/ShowRss.ini

    old new  
     1[details] 
     2name        = "Show RSS" 
     3description = "Displays a RSS Feed in a block" 
     4author      = "Werner M. Krauss" 
     5created     = "2006-08-08" 
     6version     = "0.6" 
     7copyright   = 
     8 
     9[rssSource] 
     10type        = "text" 
     11value       = "http://seagullproject.org/export/rss/" 
     12label       = "RSS resource" 
     13description = "URI of RSS feed" 
     14 
     15[itemsToShow] 
     16type        = "text" 
     17value       = 5 
     18label       = "Items to show" 
     19description = "Number of Items to show" 
  • modules/export/blocks/ShowRss.php

    old new  
     1<?php 
     2/** 
     3 * A block to dislay an RSS feed. 
     4 * 
     5 * @package export 
     6 * @author  Demian Turner <demian@phpkitchen.com> 
     7 * @author  Werner M. Krauss <werner@seagullproject.org> 
     8 */ 
     9 
     10class Export_Block_ShowRss 
     11{ 
     12 
     13    function init(&$output, $block_id, &$aParams) 
     14    { 
     15        SGL::logMessage(null, PEAR_LOG_DEBUG); 
     16         
     17        return $this->getBlockContent($output, $block_id, $aParams); 
     18    } 
     19 
     20    function getBlockContent(&$output, $block_id, &$aParams) 
     21    { 
     22        if (ini_get('safe_mode') || !ini_get('allow_url_fopen')) { 
     23            return 'Cannot request remote feed with safe_mode on or allow_url_fopen off'; 
     24        } 
     25        $c = &SGL_Config::singleton(); 
     26        $conf = $c->getAll(); 
     27         
     28        //  set block params 
     29        if (array_key_exists('rssSource', $aParams)) { 
     30            $rssSource = $aParams['rssSource']; 
     31        } else { 
     32            return false; 
     33        } 
     34         
     35        $itemsToShow = (array_key_exists('itemsToShow', $aParams)) 
     36            ? $aParams['itemsToShow'] 
     37            : 5; 
     38 
     39 
     40        $cache = & SGL_Cache::singleton($force = true); 
     41        if ($data = $cache->get('sglSiteRss'.$block_id, 'blocks')) { 
     42            $html = unserialize($data); 
     43            SGL::logMessage('rss from cache', PEAR_LOG_DEBUG); 
     44        } else { 
     45            require_once "XML/RSS.php"; 
     46            $rss =& new XML_RSS($rssSource); 
     47            $rss->parse(); 
     48 
     49            $html = "<ul class='noindent'>\n"; 
     50            $x = 0; 
     51            foreach ($rss->getItems() as $item) { 
     52                $html .= "<li><a href=\"" . $item['link'] . "\">" . $item['title'] . "</a></li>\n"; 
     53                $x ++; 
     54                if ($x >= $itemsToShow) { 
     55                    break; 
     56                } 
     57            } 
     58            $html .= "</ul>\n"; 
     59            $cache->save(serialize($html), 'sglSiteRss'.$block_id, 'blocks'); 
     60            SGL::logMessage('rss from remote', PEAR_LOG_DEBUG); 
     61        } 
     62        return $html; 
     63    } 
     64} 
     65?> 
  • modules/block/lang/english-iso-8859-15.php

    old new  
    9090        // Login2 Block 
    9191        'Login template name' => 'Login template name', 
    9292        'Logout template name' => 'Logout template name', 
     93         
     94        // Show RSS Block 
     95        'RSS resource' => 'RSS resource', 
     96        'URI of RSS feed' => 'URI of RSS feed', 
     97        'Items to show' => 'Items to show', 
     98        'Number of Items to show' => 'Number of Items to show', 
    9399    ); 
    94100?>