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

Navn : Image.php


Sample code, tutorial

Sådan benyttes komponenten Image klassen

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

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

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

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

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

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

Parent html

Sådan vises komponenten Image klassen

Sample demo

PHP source code

Den fulde PHP kildekode for Image klassen

<?
/**
* @package base
* @see HTML_BASE_UTIL_PATH.'/Image.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.'/Img.php');
if (
defined('HTML_UTIL_COMPONENT_PATH')) {
    require_once(
HTML_UTIL_COMPONENT_PATH.'/Url.php');
}
if (
defined('HTML_LOG_UTIL_PATH')) {
    require_once(
HTML_LOG_UTIL_PATH.'/Log.php');
}

/**
* Returns a complete Image as HTML
* The images are expected to be located here: /images/*.gif
* Note: If you specify "\r\n" in the alt tag, then a break is automatically added
* <code>
*      <img name="$name" src="$src" width="$width" height="$height"
*      alt="$alt" class="$class" border="$border" />
* Usage:
*   $image = new Image($src,$width,$height,$alt,$class,$border,$aux);
*   print $image->getHtml();
* Or
*   Image::display($src,$width,$height,$alt,$class,$border,$aux);
* </code>
* @package base
*/

class Image extends Img {
    
/**
     * Constructor
     * @param String $src    The source path for the image i.e. /logo.gif
     * @param String $width  The width or null or ''
     * @param String $height The height or null or ''
     * @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)
     *
     * @global String IMAGE_SKIN_URL Defines the relative sub url from docroot
     * @global String PROJECT_PATH   Defines the full path on the disk to the Project docroot
     */
    
function Image($src='',$width='',$height='',$alt='',$class='',$border='',$aux='') {
        
$theSrc = $src;
        
$strHttp  = 'http:/'.'/';
        
$strHttps = 'https:/'.'/';
        if (
strpos($src, $strHttp) !==false ||
            
strpos($src, $strHttps)!==false ||
            
strpos($src, CURRENT_MYPHP_VERSION )!==false ||
            
substr($src,0,1)==="." ) {
            
// remote server or './*' or '../*'
        
} else {
            
$domainname = '';
            if (
defined('HTML_UTIL_COMPONENT_PATH')) {
                
$domainname = Url::subdomain(DOMAIN_NAME); // Strip off subdomain names
            
}
            
$theSrc = $domainname.IMAGE_SKIN_URL.$src; // Local server
        
}
        
$this->Img($theSrc,$width,$height,$alt,$class,$border,$aux);
    }
    
    
/**
     * Get the name of the src file, where the IMAGE_SKIN_URL is stripped off
     * Except if the domain name is part of the src
     * @return String The name of the gif file
     */
    
function getSrcName() {
        return
$this->get('src'); //str_replace(IMAGE_SKIN_URL,'',$this->get('src'));
    
}

    
/**
     * Display html
     * <code>
     * Usage:
     *    Image::display($src,$width,$height,$alt,$class,$border,$aux);
     * </code>
     * @static
     * @param String $src    The source path for the image
     * @param String $width  The width or null or ''
     * @param String $height The height or null or ''
     * @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($src='',$width='',$height='',$alt='',$class='',$border='',$aux='') {
        
$html = new Image($src,$width,$height,$alt,$class,$border,$aux);
        
$html->addHtml();
    }
}
?>

HTML source code

Den fulde HTML kildekode for Image klassen

<?
<img src="/images/aniBee.gif" width="20" height="20" alt="Sample demo" />
?>

Class methods

Her er 'klasse metoderne' for Image klassen:

  • image
  • getsrcname
  • display
  • 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 Image klassen:

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

Image

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


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