Support Joomla!

Joomla! 1.5 Documentation

Packages

Package: patTemplate

Developer Network License

The Joomla! Developer Network content is © copyright 2006 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution- NonCommercial- ShareAlike 2.5
Source code for file /pattemplate/patTemplate/Function/Img.php

Documentation is available at Img.php

  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 47 2005-09-15 02:55:27Z rhuk $
  7.  *
  8.  * @package        patTemplate
  9.  * @subpackage    Functions
  10.  * @author        Jens Strobel <[email protected]>
  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 47 2005-09-15 02:55:27Z rhuk $
  21.  *
  22.  * @package        patTemplate
  23.  * @subpackage    Functions
  24.  * @author        Jens Strobel <[email protected]>
  25.  */
  26.    /**
  27.     * name of the function
  28.     * @access    private
  29.     * @var        string 
  30.     */
  31.     var $_name      =    'Img';
  32.  
  33.    /**
  34.     * defaults for some tags
  35.     *
  36.     * @access    protected
  37.     * @var    array 
  38.     */
  39.     var $_defaults = array();
  40.  
  41.    /**
  42.     * call the function
  43.     *
  44.     * @access    public
  45.     * @param    array    parameters of the function (= attributes of the tag)
  46.     * @param    string    content of the tag
  47.     * @return    string    content to insert into the template
  48.     */
  49.     function call ($params$content)
  50.     {
  51.         $src$params['src'$params['src'$content;
  52.         list($width$height$type$attr)getimagesize($src);
  53.  
  54.         $this->_defaultsarray(
  55.           'border' => 0,
  56.           'title'  => '',
  57.           'alt'    => '',
  58.           'width'  => $width,
  59.           'height' => $height
  60.         );
  61.  
  62.         $params array_merge($this->_defaults$params);
  63.         $tags'';
  64.         foreach ($params as $key => $value){
  65.           $tags.= sprintf('%s="%s" '$keyhtmlentities($value));
  66.         }
  67.         $imgstrsprintf('<img %s/>'$tags);
  68.  
  69.         return $imgstr;
  70.     }
  71. }
  72. ?>

Documentation generated on Mon, 05 Mar 2007 21:07:40 +0000 by phpDocumentor 1.3.1