Top  Branding 
triangle.gif Til forsiden
blank.gif
blank.gif
triangle.gif Du er her: /  Forsiden  /  Kildekoden  /  Base  /  Image   Login nu   Login
blank.gif
««« Se kilde koden
blank.gif
tls.gif     Base  trs.gif tl.gif Basic tr.gif tl.gif Dto tr.gif tl.gif Form tr.gif tl.gif Language tr.gif tl.gif Layout tr.gif tl.gif Menu tr.gif tl.gif Mvc tr.gif tl.gif Netbank.eksperter.dk tr.gif tl.gif Tab tr.gif tl.gif Table tr.gif tl.gif Util tr.gif
blank.gif
blank.gif
arrow-headline.gif Index
MenuLink  MenuLeft  
Tilbage

Skjul: Navn

Image.php


Vis: Sample code, tutorial

Image, 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();
    ?>

Skjul: Sådan vises komponenten

Image, Sådan vises komponenten

Sådan vises komponenten Image klassen

Sample demo

Vis: PHP source code

Image, PHP source code

Den fulde PHP kildekode for Image klassen

<?php
/**
 * @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.11
 * @since 27-nov-2009
 */

/**
 * 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 __construct($src=''$width=''$height=''$alt=''$class=''$border=''$aux='') {
        
$theSrc   $src;
        
$strHttp  'http:/'.'/';
        
$strHttps 'https:/'.'/';
        if (
strpos($src$strHttp) !==false || 
            
strpos($src$strHttps)!==false || 
            
strpos($srcCURRENT_MYPHP_VERSION )!==false ||
            
substr($src,0,1)==="." ) {
            
// remote server or './*' or '../*'
        
} else {
            
$domainname '';
            if (
defined('HTML_UTIL_COMPONENT_PATH')) {
                
$strHttp 'http:/'.'/';
                if (
strpos($src$strHttp)!==false) {
                    
// Skip
                
} else {
                    
$domainname Url::subdomain(DOMAIN_NAME); // Strip off subdomain names
                
}
            }
            
$theSrc $domainname.IMAGE_SKIN_URL.$src// Local server
        
}
        
parent::__construct($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)
     */
    
public static function display($src=''$width=''$height=''$alt=''$class=''$border=''$aux='') {
        
$html = new Image($src$width$height$alt$class$border$aux);
        
$html->addHtml();
    }
}
?>

Vis: HTML source code

Image, HTML source code

Den fulde HTML kildekode for Image klassen

<?
<!-- DEBUGImage -->
<
img src="http://finnrasmussen.dk/images/aniBee.gif" width="20" height="20" alt="Sample demo" />
?>

Vis: Class methods

Image, Class methods

Her er 'klasse metoderne' for Image klassen:

  • __construct
  • getSrcName
  • display
  • calculateWidthHeight
  • getHtml
  • setObject
  • set
  • get
  • getAttribute
  • getTag
  • add
  • getSizeof
  • getElement
  • getElements
  • getToogle
  • getMaximize
  • getMinimize
  • newTriangle
  • getStartHtml
  • getEndHtml
  • showsource
  • getClassName
  • getMsg
  • addHtml
  • __toString
  • getCacheFileName
  • save
  • content

Vis: Object vars

Image, Object vars

Her er 'objekt variable' for Image klassen:

  • html =>
  • sql =>

MenuRight 
triangle.gif

Dansk

Deutch

English (UK)

France

Italy

Norsk

Svensk

English (USA)


 
blank.gif
MenuBottom 
triangle.gif Copyright @ 1999-2010 www.Finn-Rasmussen.com Powered by myPHP Version (5.2.6-1+lenny9) 1.11
blank.gif