home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / php / PEAR / Text / Wiki / Render / Latex / Interwiki.php < prev    next >
Encoding:
PHP Script  |  2008-07-02  |  1.6 KB  |  59 lines

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