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

Source for file Url.php

Documentation is available at Url.php

  1. <?php
  2.  
  3.  
  4. class Text_Wiki_Render_Xhtml_Url extends Text_Wiki_Render {
  5.     
  6.     
  7.     var $conf = array(
  8.         'target' => '_blank',
  9.         'images' => true,
  10.         'img_ext' => array('jpg''jpeg''gif''png')
  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.         // create local variables from the options array (text,
  29.         // href, type)
  30.         extract($options);
  31.         
  32.         // find the rightmost dot and determine the filename
  33.         // extension.
  34.         $pos strrpos($href'.');
  35.         $ext strtolower(substr($href$pos + 1));
  36.         $href htmlspecialchars($href);
  37.         
  38.         // does the filename extension indicate an image file?
  39.         if ($this->getConf('images'&&
  40.             in_array($ext$this->getConf('img_ext'array()))) {
  41.             
  42.             // create alt text for the image
  43.             if (isset($text|| $text == ''{
  44.                 $text basename($href);
  45.                 $text htmlspecialchars($text);
  46.             }
  47.             
  48.             // generate an image tag
  49.             $output = "<img src=\"$href\" alt=\"$text\" />";
  50.             
  51.         else {
  52.             
  53.             // allow for alternative targets on non-anchor HREFs
  54.             if ($href{0== '#'{
  55.                 $target '';
  56.             else {
  57.                 $target $this->getConf('target''');
  58.             }
  59.             
  60.             if ($target{
  61.                    $target ' target="' htmlspecialchars($target'"';
  62.             }
  63.             
  64.             // generate a regular link (not an image)
  65.             $text htmlspecialchars($text);
  66.             $output = "<a$target href=\"$href\">$text</a>";
  67.             
  68.             // make numbered references look like footnotes
  69.             if ($type == 'footnote'{
  70.                 $output '<sup>' $output '</sup>';
  71.             }
  72.         }
  73.         
  74.         return $output;
  75.     }
  76. }
  77. ?>

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