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.     
  5.     
  6.     var $conf = array(
  7.         'target' => '_blank',
  8.         'images' => true,
  9.         'img_ext' => array('jpg''jpeg''gif''png'),
  10.         'css_inline' => null,
  11.         'css_footnote' => null,
  12.         'css_descr' => null,
  13.         'css_img' => null
  14.     );
  15.     
  16.     /**
  17.     * 
  18.     * Renders a token into text matching the requested format.
  19.     * 
  20.     * @access public
  21.     * 
  22.     * @param array $options The "options" portion of the token (second
  23.     *  element).
  24.     * 
  25.     * @return string The text rendered from the token options.
  26.     * 
  27.     */
  28.     
  29.     function token($options)
  30.     {
  31.         // create local variables from the options array (text,
  32.         // href, type)
  33.         extract($options);
  34.         
  35.         // find the rightmost dot and determine the filename
  36.         // extension.
  37.         $pos strrpos($href'.');
  38.         $ext strtolower(substr($href$pos + 1));
  39.         $href htmlspecialchars($href);
  40.         
  41.         // does the filename extension indicate an image file?
  42.         if ($this->getConf('images'&&
  43.             in_array($ext$this->getConf('img_ext'array()))) {
  44.             
  45.             // create alt text for the image
  46.             if (isset($text|| $text == ''{
  47.                 $text basename($href);
  48.                 $text htmlspecialchars($text);
  49.             }
  50.             
  51.             // generate an image tag
  52.             $css $this->formatConf(' class="%s"''css_img');
  53.             $output = "<img$css src=\"$href\" alt=\"$text\" />";
  54.             
  55.         else {
  56.             
  57.             // should we build a target clause?
  58.             if ($href{0== '#' ||
  59.                 strtolower(substr($href07)) == 'mailto:'{
  60.                 // targets not allowed for on-page anchors
  61.                 // and mailto: links.
  62.                 $target '';
  63.             else {
  64.                 // allow targets on non-anchor non-mailto links
  65.                 $target $this->getConf('target');
  66.             }
  67.             
  68.             // generate a regular link (not an image)
  69.             $text htmlspecialchars($text);
  70.             $css $this->formatConf(' class="%s"'"css_$type");
  71.             $output = "<a$css href=\"$href\"";
  72.             
  73.             if ($target{
  74.                 // use a "popup" window.  this is XHTML compliant, suggested by
  75.                 // Aaron Kalin.  uses the $target as the new window name.
  76.                 $target htmlspecialchars($target);
  77.                 $output .= " onclick=\"window.open(this.href, '$target');";
  78.                 $output .= " return false;\"";
  79.             }
  80.             
  81.             // finish up output
  82.             $output .= ">$text</a>";
  83.             
  84.             // make numbered references look like footnotes when no
  85.             // CSS class specified, make them superscript by default
  86.             if ($type == 'footnote' && $css{
  87.                 $output '<sup>' $output '</sup>';
  88.             }
  89.         }
  90.         
  91.         return $output;
  92.     }
  93. }
  94. ?>

Documentation generated on Mon, 11 Mar 2019 14:28:35 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.