[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

/libraries/pattemplate/patTemplate/Function/ -> Img.php (source)

   1  <?PHP
   2  /**
   3   * patTemplate function that returns a complete imagetag and
   4   * width and height are extracted from the image
   5   *
   6   * $Id: Img.php 10381 2008-06-01 03:35:53Z pasamio $
   7   *
   8   * @package        patTemplate
   9   * @subpackage    Functions
  10   * @author        Jens Strobel <strobel@pixeldreamz.com>
  11   */
  12  
  13  // Check to ensure this file is within the rest of the framework
  14  defined('JPATH_BASE') or die();
  15  
  16  /**
  17   * patTemplate function that returns a complete imagetag and
  18   * width and height are extracted from the image
  19   *
  20   * $Id: Img.php 10381 2008-06-01 03:35:53Z pasamio $
  21   *
  22   * @package        patTemplate
  23   * @subpackage    Functions
  24   * @author        Jens Strobel <strobel@pixeldreamz.com>
  25   */
  26  class patTemplate_Function_Img extends patTemplate_Function {
  27      /**
  28      * name of the function
  29      * @access    private
  30      * @var        string
  31      */
  32      var $_name      =    'Img';
  33  
  34      /**
  35      * defaults for some tags
  36      *
  37      * @access    protected
  38      * @var    array
  39      */
  40      var $_defaults = array();
  41  
  42      /**
  43      * call the function
  44      *
  45      * @access    public
  46      * @param    array    parameters of the function (= attributes of the tag)
  47      * @param    string    content of the tag
  48      * @return    string    content to insert into the template
  49      */
  50  	function call ($params, $content)
  51      {
  52          $src= $params['src'] ? $params['src'] : $content;
  53          list($width, $height, $type, $attr)= getimagesize($src);
  54  
  55          $this->_defaults= array(
  56            'border' => 0,
  57            'title'  => '',
  58            'alt'    => '',
  59            'width'  => $width,
  60            'height' => $height
  61          );
  62  
  63          $params = array_merge($this->_defaults, $params);
  64          $tags= '';
  65          foreach ($params as $key => $value){
  66            $tags.= sprintf('%s="%s" ', $key, htmlentities($value));
  67          }
  68          $imgstr= sprintf('<img %s/>', $tags);
  69  
  70          return $imgstr;
  71      }
  72  }
  73  ?>


Generated: Wed Mar 28 15:54:07 2012 Cross-referenced by PHPXref 0.7.1