Text_Wiki
[ class tree: Text_Wiki ] [ index: Text_Wiki ] [ all elements ]

Source for file Interwiki.php

Documentation is available at Interwiki.php

  1. <?php
  2.  
  3.     
  4.     var $conf = array(
  5.         'sites' => array(
  6.             'MeatBall' => 'http://www.usemod.com/cgi-bin/mb.pl?%s',
  7.             'Advogato' => 'http://advogato.org/%s',
  8.             'Wiki'       => 'http://c2.com/cgi/wiki?%s'
  9.         )
  10.     );
  11.     
  12.     
  13.     /**
  14.     * 
  15.     * Renders a token into text matching the requested format.
  16.     * 
  17.     * @access public
  18.     * 
  19.     * @param array $options The "options" portion of the token (second
  20.     *  element).
  21.     * 
  22.     * @return string The text rendered from the token options.
  23.     * 
  24.     */
  25.     
  26.     function token($options)
  27.     {
  28.         $text $options['text'];
  29.         if (isset($options['url'])) {
  30.             // calculated by the parser (e.g. Mediawiki)
  31.             $href $options['url'];
  32.         else {
  33.             $site $options['site'];
  34.             // toggg 2006/02/05 page name must be url encoded (e.g. may contain spaces)
  35.             $page $this->urlEncode($options['page']);
  36.  
  37.             if (isset($this->conf['sites'][$site])) {
  38.                 $href $this->conf['sites'][$site];
  39.             else {
  40.                 return $text;
  41.             }
  42.  
  43.             // old form where page is at end,
  44.             // or new form with %s placeholder for sprintf()?
  45.             if (strpos($href'%s'=== false{
  46.                 // use the old form
  47.                 $href $href $page;
  48.             else {
  49.                 // use the new form
  50.                 $href sprintf($href$page);
  51.             }
  52.         }
  53.         
  54.         return $text '\footnote{' $href '}';
  55.     }
  56. }
  57. ?>

Documentation generated on Tue, 12 Mar 2019 21:49:19 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.