Show
Ignore:
Timestamp:
06/24/06 23:19:23 (2 years ago)
Author:
mbonetti
Message:

OPML 2.0 will support categories, so let's export them. Not sure the feed
follows the standard, though. We'll also have to parse categories when we
import the OPML feed.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/gregarius/opml.php

    r1328 r1510  
    121121// Output should be valid xml. (*fingers crossed*) 
    122122if (array_key_exists('act',$_REQUEST)) { 
     123 
     124    $rs = rss_query( "select fid,tag from " .getTable('tag')  
     125        ." t, " .getTable('metatag') ." mt " 
     126        ." where mt.tid=t.id and ttype='channel'"); 
     127    $cats=array(); 
     128    while(list($cid,$tag) = rss_fetch_row($rs)) { 
     129        if (!isset($cats[$cid])) { 
     130            $cats[$cid]=array(); 
     131        } 
     132        $cats[$cid][]=$tag; 
     133    } 
     134     
     135 
    123136    $sql = "select " 
    124137      ." c.id, c.title, c.url, c.siteurl, d.name, c.parent, c.descr " 
     
    152165      ."<?xml-stylesheet type=\"text/xsl\" href=\"".getPath()."css/opml.xsl\"?>\n" 
    153166      ."<!-- Generated by "._TITLE_. " " . _VERSION_ ." -->\n"             
    154       ."<opml version=\"1.1\">\n"; 
     167      ."<opml version=\"2.0\">\n"; 
    155168     
    156169    echo "\t<head>\n" 
     
    191204            echo " htmlUrl=\"$siteurl_\""; 
    192205        } 
    193      
     206        if (isset($cats[$id]) && count($cats[$id])) { 
     207            echo " categories=\"" . implode(",",$cats[$id]) ."\""; 
     208        } 
    194209        echo " xmlUrl=\"$url_\" />\n"; 
    195210    }