From b625487d2258a6f1f875813206adc9a5857dab24 Mon Sep 17 00:00:00 2001 From: andi Date: Fri, 15 Apr 2005 22:47:35 +0200 Subject: new parser: more hacking, RSS readded darcs-hash:20050415204735-9977f-613d9b007452d538dcb8fce4ade5cbec389c4415.gz --- inc/parser/xhtml.php | 95 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 66 insertions(+), 29 deletions(-) (limited to 'inc/parser/xhtml.php') diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index 377b514be..83d498b47 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -1,4 +1,11 @@ + * @author Andreas Gohr + */ + if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); if ( !defined('DOKU_LF') ) { @@ -14,8 +21,8 @@ if ( !defined('DOKU_TAB') ) { require_once DOKU_INC . 'inc/parser/renderer.php'; /** -* @TODO Probably useful for have constant for linefeed formatting -*/ + * The Renderer + */ class Doku_Renderer_XHTML extends Doku_Renderer { var $doc = ''; @@ -381,10 +388,6 @@ class Doku_Renderer_XHTML extends Doku_Renderer { $this->internallink($link,$link); } - /** - * @TODO Support media - * @TODO correct attributes - */ function internallink($id, $name = NULL) { global $conf; @@ -416,37 +419,38 @@ class Doku_Renderer_XHTML extends Doku_Renderer { echo $this->__formatLink($link); } - - /** - * @TODO Should list assume blacklist check already made? - * @TODO External link icon - * @TODO correct attributes - */ - function externallink($link, $title = NULL) { - - echo '__getLinkTitle($title, $link, $isImage); + function externallink($url, $name = NULL) { + global $conf; + + $name = $this->__getLinkTitle($name, $url, $isImage); if ( !$isImage ) { - echo ' class="urlextern"'; + $class='urlextern'; } else { - echo ' class="media"'; + $class='media'; } - echo ' target="_blank" href="'.$this->__xmlEntities($link).'"'; - - echo ' onclick="return svchk()" onkeypress="return svchk()">'; - - echo $title; - - echo ''; + //prepare for formating + $link['target'] = $conf['target']['extern']; + $link['style'] = ''; + $link['pre'] = ''; + $link['suf'] = ''; + $link['more'] = 'onclick="return svchk()" onkeypress="return svchk()"'; + $link['class'] = $class; + $link['url'] = $url; + $link['name'] = $name; + $link['title'] = $this->__xmlEntities($url); + if($conf['relnofollow']) $link['more'] .= ' rel="nofollow"'; + + //output formatted + echo $this->__formatLink($link); } /** * @TODO Remove hard coded link to splitbrain.org on style */ function interwikilink($link, $title = NULL, $wikiName, $wikiUri) { + global $conf; // RESOLVE THE URL if ( isset($this->interwiki[$wikiName]) ) { @@ -614,11 +618,45 @@ class Doku_Renderer_XHTML extends Doku_Renderer { 'link' => $link )); } + /** + * Renders an RSS feed using magpie + * + * @author Andreas Gohr + */ + function rss ($url){ + global $lang; + define('MAGPIE_CACHE_ON', false); //we do our own caching + define('MAGPIE_DIR', DOKU_INC.'inc/magpie/'); + define('MAGPIE_OUTPUT_ENCODING','UTF-8'); //return all feeds as UTF-8 + require_once(MAGPIE_DIR.'/rss_fetch.inc'); + + //disable warning while fetching + $elvl = error_reporting(E_ERROR); + $rss = fetch_rss($url); + error_reporting($elvl); + + print '
    '; + if($rss){ + foreach ($rss->items as $item ) { + print '
  • '; + $this->externallink($item['link'],$item['title']); + print '
  • '; + } + }else{ + print '
  • '; + print ''.$lang['rssfailed'].''; + $this->externallink($url); + print '
  • '; + } + print '
'; + } + /** * Renders internal and external media * * @author Andreas Gohr * @todo handle center align + * @todo move to bottom */ function __media ($src, $title=NULL, $align=NULL, $width=NULL, $height=NULL, $cache=NULL) { @@ -629,9 +667,8 @@ class Doku_Renderer_XHTML extends Doku_Renderer { if(substr($mime,0,5) == 'image'){ //add image tag $ret .= '__xmlEntities($title).'"'; -- cgit v1.2.3