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

Source for file Image.php

Documentation is available at Image.php

  1. <?php
  2. class Text_Wiki_Render_Xhtml_Image extends Text_Wiki_Render {
  3.  
  4.     var $conf = array(
  5.         'base' => '/'
  6.     );
  7.     
  8.     
  9.     /**
  10.     * 
  11.     * Renders a token into text matching the requested format.
  12.     * 
  13.     * @access public
  14.     * 
  15.     * @param array $options The "options" portion of the token (second
  16.     *  element).
  17.     * 
  18.     * @return string The text rendered from the token options.
  19.     * 
  20.     */
  21.     
  22.     function token($options)
  23.     {
  24.         $src '"' .
  25.             $this->getConf('base''/'.
  26.             $options['src''"';
  27.         
  28.         if (isset($options['attr']['link'])) {
  29.         // this image has a link
  30.         
  31.         if (strpos($options['attr']['link']'://')) {
  32.             // it's a URL
  33.             $href $options['attr']['link'];
  34.         else {
  35.                 $href $this->wiki->getRenderConf('xhtml''wikilink''view_url'.
  36.                     $options['attr']['link'];
  37.         }
  38.         else {
  39.             // image is not linked
  40.             $href = null;
  41.         }
  42.         
  43.         // unset these so they don't show up as attributes
  44.         unset($options['attr']['link']);
  45.         
  46.         $attr '';
  47.         $alt = false;
  48.         foreach ($options['attr'as $key => $val{
  49.             if (strtolower($key== 'alt'{
  50.                 $alt = true;
  51.             }
  52.             $attr .= " $key=\"$val\"";
  53.         }
  54.         
  55.     // always add an "alt" attribute per Stephane Solliec
  56.     if ($alt{
  57.         $attr .= ' alt="' basename($options['src']'"';
  58.     }
  59.     
  60.         if ($href{
  61.             return "<a href=\"$href\"><img src=$src$attr/></a>";
  62.         else {
  63.             return "<img src=$src$attr/>";
  64.         }
  65.     }
  66. }
  67. ?>

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