Changeset 16352

Show
Ignore:
Timestamp:
05/09/08 10:33:24 (2 months ago)
Author:
xfade
Message:

Add RSS feed for latest items.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/MidCOM_2_8/org.maemo.socialnews/config/manifest.inc

    r16331 r16352  
    11'name' => 'org.maemo.socialnews', 
    22'purecode' => false, 
    3 'version' => '1.1.3', 
     3'version' => '1.1.4', 
    44'state' => 'stable', 
    55'privileges' => array(), 
  • branches/MidCOM_2_8/org.maemo.socialnews/documentation/CHANGES

    r14821 r16352  
    77  which might even break existing functionality. 
    88- All items marked with "+" represent completely new features. 
     9 
     102008-05-09 xfade 
     11  + RSS feed for latest items 
    912 
    10132007-08-29 bergie 
  • branches/MidCOM_2_8/org.maemo.socialnews/handler/latest.php

    r15501 r16352  
    1818{ 
    1919    private $nodes = array(); 
     20    private $articles = array(); 
    2021 
    2122    /** 
     
    6465        $_MIDCOM->componentloader->load_graceful('net.nemein.favourites'); 
    6566 
     67        $data['node_title'] = $this->_config->get('socialnews_title'); 
     68        if (empty($data['node_title'])) 
     69        { 
     70            $data['node_title'] = $this->_topic->extra; 
     71        } 
     72 
     73        if ($handler_id == 'rss20_latest') 
     74        { 
     75            $_MIDCOM->load_library('de.bitfolge.feedcreator'); 
     76            $_MIDCOM->cache->content->content_type('text/xml; charset=UTF-8'); 
     77            $_MIDCOM->header('Content-type: text/xml; charset=UTF-8'); 
     78            $_MIDCOM->skip_page_style = true; 
     79            $data['feedcreator'] = new UniversalFeedCreator(); 
     80            $data['feedcreator']->title = $data['node_title']; 
     81            $data['feedcreator']->link = substr($_MIDCOM->get_host_prefix(), 0, -1) . $_MIDCOM->get_context_data(MIDCOM_CONTEXT_ANCHORPREFIX); 
     82            $data['feedcreator']->cssStyleSheet = false; 
     83            $data['feedcreator']->syndicationURL = "{$data['feedcreator']->link}rss.xml"; 
     84        } 
     85 
    6686        return true; 
    6787    } 
     
    80100            $data['node_title'] = $this->_topic->extra; 
    81101        } 
    82         midcom_show_style('index_latest_header'); 
    83102        $qb = midcom_db_article::new_query_builder(); 
    84103        $qb->add_constraint('topic.component', '=', 'net.nehmer.blog'); 
     
    87106        $articles = $qb->execute(); 
    88107        $date = ''; 
     108 
     109        if ($handler_id == 'rss20_latest') 
     110 
     111        { 
     112            $this->articles = $articles; 
     113            $this->_show_rss_items($handler_id, &$data); 
     114            return; 
     115        } 
     116 
     117        midcom_show_style('index_latest_header'); 
    89118        foreach ($articles as $article) 
    90119        { 
     
    111140        midcom_show_style('index_latest_footer'); 
    112141    } 
     142 
     143    /** 
     144     * Displays the feed 
     145     * 
     146     * @param mixed $handler_id The ID of the handler. 
     147     * @param mixed &$data The local request data. 
     148     */ 
     149    function _show_rss_items($handler_id, &$data) 
     150    { 
     151        // Add each article now. 
     152 
     153        if ($this->articles) 
     154        { 
     155            foreach ($this->articles as $article) 
     156            { 
     157                $data['article'] =& $article; 
     158 
     159                //FIXME! We need to do this the proper way. 
     160 
     161                /*$data['score'] = $this->articles_scores[$article->guid]; 
     162                $data['score_initial'] = $this->articles_scores_initial[$article->guid]; 
     163 
     164                if (isset($this->articles_attention[$article->guid])) 
     165                { 
     166                    $data['attention'] = $this->articles_attention[$article->guid]; 
     167                }*/ 
     168 
     169                $data['score'] = 0; 
     170 
     171                midcom_show_style('feed-item'); 
     172            } 
     173        } 
     174        echo $data['feedcreator']->createFeed('RSS2.0'); 
     175    } 
     176 
    113177} 
    114178?> 
  • branches/MidCOM_2_8/org.maemo.socialnews/viewer.php

    r15990 r16352  
    8888            'fixed_args' => Array('my_items.xml'), 
    8989        );        
     90        // Handle /latest.xml 
     91        $this->_request_switch['rss20_latest'] = array 
     92        ( 
     93            'handler' => Array('org_maemo_socialnews_handler_latest', 'latest'), 
     94            'fixed_args' => Array('latest.xml'), 
     95        ); 
    9096         
    9197        // The Archive