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

Source for file Freelink.php

Documentation is available at Freelink.php

  1. <?php
  2.  
  3. class Text_Wiki_Render_Xhtml_Freelink extends Text_Wiki_Render {
  4.     
  5.     var $conf = array(
  6.         'pages' => array(),
  7.         'view_url' => 'http://example.com/index.php?page=%s',
  8.         'new_url'  => 'http://example.com/new.php?page=%s',
  9.         'new_text' => '?'
  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.         // get nice variable names (page, text, anchor)
  29.         extract($options);
  30.         
  31.         if (in_array($page$this->getConf('pages'))){
  32.         
  33.             // the page exists, show a link to the page
  34.             $href $this->getConf('view_url');
  35.             if (strpos($href'%s'=== false{
  36.                 // use the old form
  37.                 $href $href urlencode($page'#' $anchor;
  38.             else {
  39.                 // use the new form
  40.                 $href sprintf($hrefurlencode($page'#' $anchor);
  41.             }
  42.             
  43.             $text htmlspecialchars($text);
  44.             return "<a href=\"$href\">$text</a>";
  45.             
  46.         else {
  47.         
  48.             // the page does not exist, show the page name and
  49.             // the "new page" text
  50.             $href $this->getConf('new_url');
  51.             if (strpos($href'%s'=== false{
  52.                 // use the old form
  53.                 $href $href urlencode($page);
  54.             else {
  55.                 // use the new form
  56.                 $href sprintf($hrefurlencode($page));
  57.             }
  58.             
  59.             return $text . "<a href=\"$href\">" . $this->getConf('new_text'"</a>";
  60.             
  61.         }
  62.     }
  63. }
  64. ?>

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