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.         
  30.             // this image has a link
  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.             
  39.         else {
  40.             // image is not linked
  41.             $href = null;
  42.         }
  43.         
  44.         // unset these so they don't show up as attributes
  45.         unset($options['attr']['link']);
  46.         
  47.         $attr '';
  48.         $alt = false;
  49.         foreach ($options['attr'as $key => $val{
  50.             if (strtolower($key== 'alt'{
  51.                 $alt = true;
  52.             }
  53.             $attr .= " $key=\"$val\"";
  54.         }
  55.         
  56.         // always add an "alt" attribute per Stephane Solliec
  57.         if ($alt{
  58.             $attr .= ' alt="' basename($options['src']'"';
  59.         }
  60.         
  61.         if ($href{
  62.             return "<a href=\"$href\"><img src=$src$attr/></a>";
  63.         else {
  64.             return "<img src=$src$attr/>";
  65.         }
  66.     }
  67. }
  68. ?>

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