cvs: pear /Text_Wiki/Text/Wiki/Render/Docbook Interwiki.php

From: Date: Sat, 25 Feb 2006 05:20:51 +0000
Subject: cvs: pear /Text_Wiki/Text/Wiki/Render/Docbook Interwiki.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-38581@lists.php.net to get a copy of this message
toggg Sat Feb 25 05:20:51 2006 UTC Modified files: /pear/Text_Wiki/Text/Wiki/Render/Docbook Interwiki.php Log: Allow parsers to give the full url in token options instead of the site + wiki page http://cvs.php.net/viewcvs.cgi/pear/Text_Wiki/Text/Wiki/Render/Docbook/Interwiki.php?r1=1.3&r2=1.4&diff_format=u Index: pear/Text_Wiki/Text/Wiki/Render/Docbook/Interwiki.php diff -u pear/Text_Wiki/Text/Wiki/Render/Docbook/Interwiki.php:1.3 pear/Text_Wiki/Text/Wiki/Render/Docbook/Interwiki.php:1.4 --- pear/Text_Wiki/Text/Wiki/Render/Docbook/Interwiki.php:1.3 Fri Feb 10 18:31:15 2006 +++ pear/Text_Wiki/Text/Wiki/Render/Docbook/Interwiki.php Sat Feb 25 05:20:51 2006 @@ -9,7 +9,7 @@ * @package Text_Wiki_Docbook * @author bertrand Gugger <bertrand@toggg.com> * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 - * @version CVS: $Id: Interwiki.php,v 1.3 2006/02/10 18:31:15 toggg Exp $ + * @version CVS: $Id: Interwiki.php,v 1.4 2006/02/25 05:20:51 toggg Exp $ * @link http://pear.php.net/package/Text_Wiki_Docbook */ @@ -49,24 +49,30 @@ function token($options) { - $site = $options['site']; - $page = $this->urlEncode($options['page']); $text = $options['text']; - - if (isset($this->conf['sites'][$site])) { - $href = $this->conf['sites'][$site]; - } else { - return $text; - } - - // old form where page is at end, - // or new form with %s placeholder for sprintf()? - if (strpos($href, '%s') === false) { - // use the old form - $href = $href . $page; + if (isset($options['url'])) { + // calculated by the parser (e.g. Mediawiki) + $href = $options['url']; } else { - // use the new form - $href = sprintf($href, $page); + $site = $options['site']; + // toggg 2006/02/05 page name must be url encoded (e.g. may contain spaces) + $page = $this->urlEncode($options['page']); + + if (isset($this->conf['sites'][$site])) { + $href = $this->conf['sites'][$site]; + } else { + return $text; + } + + // old form where page is at end, + // or new form with %s placeholder for sprintf()? + if (strpos($href, '%s') === false) { + // use the old form + $href = $href . $page; + } else { + // use the new form + $href = sprintf($href, $page); + } } return '<link xlink:href="' . $href . '">' . $text . '</link>'; }

« previous php.pear.cvs (#38581) next »