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

Source for file Wikilink.php

Documentation is available at Wikilink.php

  1. <?php
  2.  
  3. class Text_Wiki_Render_Xhtml_Wikilink extends Text_Wiki_Render {
  4.     
  5.     
  6.     var $conf = array(
  7.         'pages' => array(),
  8.         'view_url' => 'http://example.com/index.php?page=%s',
  9.         'new_url'  => 'http://example.com/new.php?page=%s',
  10.         'new_text' => '?'
  11.     );
  12.     
  13.     /**
  14.     * 
  15.     * Renders a token into XHTML.
  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.         // make nice variable names (page, anchor, text)
  29.         extract($options);
  30.         
  31.         // does the page exist?
  32.         if (in_array($page$this->getConf('pages'array()))) {
  33.         
  34.             // yes, link to the page view, but we have to build
  35.             // the HREF.  we support both the old form where
  36.             // the page always comes at the end, and the new
  37.             // form that uses %s for sprintf()
  38.             $href $this->getConf('view_url');
  39.             
  40.             if (strpos($href'%s'=== false{
  41.                 // use the old form
  42.                 $href $href $page $anchor;
  43.             else {
  44.                 // use the new form
  45.                 $href sprintf($href$page $anchor);
  46.             }
  47.             
  48.             return "<a href=\"$href\">$text</a>";
  49.             
  50.         }
  51.         
  52.         // no, link to a create-page url, but only if new_url is set
  53.         $href $this->getConf('new_url'null);
  54.         
  55.         if ($href || trim($href== ''{
  56.             // no useful href, return the text as it is
  57.             return $text;
  58.         else {
  59.         
  60.             // yes, link to the page view, but we have to build
  61.             // the HREF.  we support both the old form where
  62.             // the page always comes at the end, and the new
  63.             // form that uses sprintf()
  64.             if (strpos($href'%s'=== false{
  65.                 // use the old form
  66.                 $href $href $page;
  67.             else {
  68.                 // use the new form
  69.                 $href sprintf($href$page);
  70.             }
  71.             
  72.             return $text . "<a href=\"$href\">" . $this->getConf('new_text'"</a>";
  73.         }
  74.     }
  75. }
  76. ?>

Documentation generated on Mon, 11 Mar 2019 13:51:30 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.