Images
Images Du er her: /  Forsiden  /  Kildekoden  /  Base  /  Images   Login nu   Login
Images
 ««« Se kilde koden
Images
Images Basic Base  Component Db Db-basket Dto Form Form-elements Jquery Layout Menu Menu-fisheye Mvc Tab Table Template Util
Images
Images
Images Index
 
Tilbage

Navn : Images.php


Sample code, tutorial

Sådan benyttes komponenten Images klassen

Først skal du inkludere den fil der beskriver komponenten, som en klasse fil

  • <?
    require_once(HTML_PACKAGE_PATH.'/Images.php');
    ?>

Dernæst kan du enten benytte komponenten som et taglib (statiske metoder):

  • <?
    Images
    ::display($param1, $param2, $param3, ...);
    ?>

eller du kan lave en instance af komponenten og benytte metoderne direkte:

  • <?
    $object
    = new Images($param1, $param2, $param3, ...);
    print
    $object->getHtml();
    ?>

Parent html

Sådan vises komponenten Images klassen

Images

PHP source code

Den fulde PHP kildekode for Images klassen

<?
/**
* @package base
* @see HTML_BASE_UTIL_PATH.'/Images.php'
* @copyright (c) http://Finn-Rasmussen.com
* @license http://Finn-Rasmussen.com/license/ myPHP License conditions
* @author http://Finn-Rasmussen.com
* @version 1.10
* @since 22-feb-2007
*/

/**
* The required files
*/
require_once(HTML_BASE_UTIL_PATH.'/Image.php');
if (
defined('HTML_LOG_UTIL_PATH')) {
    require_once(
HTML_LOG_UTIL_PATH.'/Log.php');
}

/**
* Returns a complete Image as HTML
* The Src, Width, Height and Alt attributes are fetched from global storage, if defined
* @see $GLOBALS[IMAGE_NAME_ALT][IMAGE_PRINT] = LINK_TITLE_PRINT;
* <code>
* Usage:
*   $name = IMAGE_PRINT;
*   $images = new Images($name,$width,$height,$alt,$class,$border,$aux);
*   print $images->getHtml();
* Or
*   Images::display($name,$width,$height,$alt,$class,$border,$aux);
* </code>
* @package base
*/

class Images extends Image {
    
/**
    * Constructor
    * @param String $name   The name of the image i.e. IMAGE_PRINT
    * @param String $width  The width
    * @param String $height The height
    * @param String $alt    The alt text
    * @param String $class  The css class for the image
    * @param String $border The border of an image
    * @param String $aux    The new line indicator (nl)
    */
    
function Images($name='',$width='',$height='',$alt='',$class='',$border='',$aux='') {
        
$src = ''; // Assume default /images/*.gif
        
$theSrc    = $this->getSrc($src,$name);
        
$theWidth  = $this->getWidth($width,$name);
        
$theHeight = $this->getHeight($height,$name);
        
$theAlt    = $this->getAlt($alt,$name);
        
$theClass  = $this->getClass($class,$name);
        
$this->Image($theSrc,$theWidth,$theHeight,$theAlt,$theClass,$border,$aux);
    }

    
/**
     * Get the image attribute for the specified key or use the default value
     * <code>
     * Usage:
     *    $value = '';
     *    $text = $this->getImageName($value, IMAGE_PRINT, IMAGE_NAME_SRC);
     * </code>
     * @see $GLOBALS[IMAGE_NAME_ALT][IMAGE_PRINT] = LINK_TITLE_PRINT;
     * @param  String $value The value to use, if supplied
     * @param  String $name  The name of the image to use
     * @param  String $key   The key attribute for the image to use
     * @return String The attribute of the image for the specified key
     */
    
function getImageName($value, $name, $key) {
        
$attribute = $value;
// 2008-05-19 removed        
//        if ($value == '') {
            
$imagename = $GLOBALS[$key];
            if (
is_array($imagename)) {
                if (
array_key_exists($name,$imagename)) {
                    
$attribute = $GLOBALS[$key][$name];
                } else {
                    
// TODO what
                
}
            } else {
                
// TODO what
            
}
//        } else {
               // TODO what
//        }
        
return $attribute;
    }

    
/**
     * Get the image attribute for the Src or use the name of the image
     * @param  String $src  The Src to use, if supplied
     * @param  String $name The name of the image to use
     * @return String The value of the image Src attribute
     */
    
function getSrc($src, $name) {
        
$value = $src;
        switch (
$name) {
            case
IMAGE_DENMARK:
            case
IMAGE_GERMANY:
            case
IMAGE_ENGLAND:
            case
IMAGE_FRANCE:
            case
IMAGE_ITALY:
            case
IMAGE_NORWAY:
            case
IMAGE_SWEDEN:
            case
IMAGE_USA:
                
$value .= IMAGE_FLAG_PATH;
                break;
            default:
                break;
        }
        
$value .= '/'.$name.'.gif';
        return
$this->getImageName($value,$name,IMAGE_NAME_SRC);
    }

    
/**
     * Get the image attribute for the Width or use the name of the image
     * @param  String $width The Width to use, if supplied
     * @param  String $name  The name of the image to use
     * @return String The value of the image Width attribute
     */
    
function getWidth($width, $name) {
        return
$this->getImageName($width,$name,IMAGE_NAME_WIDTH);
    }

    
/**
     * Get the image attribute for the Height or use the name of the image
     * @param  String $height The Height to use, if supplied
     * @param  String $name   The name of the image to use
     * @return String The value of the image Height attribute
     */
    
function getHeight($height, $name) {
        return
$this->getImageName($height,$name,IMAGE_NAME_HEIGHT);
    }

    
/**
     * Get the image attribute for the Alt or use the name of the image
     * @param  String $alt  The Alt to use, if supplied
     * @param  String $name The name of the image to use
     * @return String The value of the image Alt attribute
     */
    
function getAlt($alt, $name) {
        return
$this->getImageName($alt,$name,IMAGE_NAME_ALT);
    }

    
/**
     * Get the image attribute for the Class or use the name of the image
     * @param  String $class The Class to use, if supplied
     * @param  String $name  The name of the image to use
     * @return String The value of the image Alt attribute
     */
    
function getClass($class, $name) {
        return
$this->getImageName($class,$name,IMAGE_NAME_CLASS);
    }

    
/**
     * Get a new Images object from the specified Image name
     * <code>
     * Usage:
     *    $image = Images::newImage($name,$width,$height,$alt,$class,$border,$aux);
     * </code>
     * @static
     * @param  String $name   The name of the image i.e. IMAGE_PRINT
     * @param  String $width  The width
     * @param  String $height The height
     * @param  String $alt    The alt text
     * @param  String $class  The css class for the image
     * @param  String $border The border of an image
     * @param  String $aux    The new line indicator (nl)
     * @return Images Return a new instance of the Images object
     */
     
function newImage($name='',$width='',$height='',$alt='',$class='',$border='',$aux='') {
        return new
Images($name,$width,$height,$alt,$class,$border,$aux);         
     }

    
/**
     * Display html
     * <code>
     * Usage:
     *    $name = IMAGE_PRINT;
     *    Images::display($name,$width,$height,$alt,$class,$border,$aux);
     * </code>
     * @static
     * @param String $name   The name of the image i.e. IMAGE_PRINT
     * @param String $width  The width
     * @param String $height The height
     * @param String $alt    The alt text
     * @param String $class  The css class for the image
     * @param String $border The border of an image
     * @param String $aux    The new line indicator (nl)
     */
    
function display($name='',$width='',$height='',$alt='',$class='',$border='',$aux='') {
        
$html = new Images($name,$width,$height,$alt,$class,$border,$aux);
        
$html->addHtml();
    }
}
?>

HTML source code

Den fulde HTML kildekode for Images klassen

<?
<img src="/images/aniBee.gif" alt="Images" />
?>

Class methods

Her er 'klasse metoderne' for Images klassen:

  • images
  • getimagename
  • getsrc
  • getwidth
  • getheight
  • getalt
  • getclass
  • newimage
  • display
  • image
  • getsrcname
  • object
  • getclassname
  • getmsg
  • addhtml
  • gethtml
  • tostring
  • getcachefilename
  • save
  • content
  • stop
  • html
  • setobject
  • set
  • get
  • getattribute
  • gettag
  • add
  • getsizeof
  • getelement
  • getelements
  • gettoogle
  • getmaximize
  • getminimize
  • newtriangle
  • showsource
  • img
  • calculatewidthheight

Object vars

Her er 'objekt variable' for Images klassen:

  • html =>
  • sql =>
  • elements => Array
  • sizeof => 0
  • src => /images/aniBee.gif
  • width =>
  • height =>
  • alt => Images
  • class =>
  • border =>
  • aux =>
  • name =>

Images

Vis denne side på danmark

Vis denne side på Germany

Vis denne side på England

Vis denne side på France

Vis denne side på Italy

Vis denne side på Norge

Vis denne side på Sverige

Vis denne side på USA


 
Images
Images Copyright @ 1999-2009 www.Finn-Rasmussen.com Powered by myPHP Version 1.10
Images