Top  Branding  Banner 
blank.gif
blank.gif
triangle.gif Du er her: /  Forsiden  /  Kildekoden  /  Component  /  Imagerotator   Login nu   Login
blank.gif
««« Se kilde koden
blank.gif
tl.gif Cms tr.gif tls.gif     Component  trs.gif tl.gif Db tr.gif tl.gif Db-basket tr.gif tl.gif Db-login tr.gif tl.gif Db-customer tr.gif tl.gif Db-select tr.gif tl.gif Jquery tr.gif tl.gif Form-elements tr.gif tl.gif Menu-fisheye tr.gif tl.gif Template tr.gif tl.gif Tree-node tr.gif tl.gif Validator tr.gif
blank.gif
blank.gif
arrow-headline.gif Index
MenuLink  http://www.hvepseeksperten.dk (61)
MenuLeft  
Tilbage

Skjul: Navn

Imagerotator.php


Vis: Sample code, tutorial

Imagerotator, Sample code, tutorial

Sådan benyttes komponenten Imagerotator klassen

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

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

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

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

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

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

Skjul: Sådan vises komponenten

Imagerotator, Sådan vises komponenten

Sådan vises komponenten Imagerotator klassen

http://www.hvepseeksperten.dk (07)

Vis: PHP source code

Imagerotator, PHP source code

Den fulde PHP kildekode for Imagerotator klassen

<?php
/**
 * @package component
 * @filesource 
 * @see HTML_COMPONENT_PAGE_PATH.'/Imagerotator.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_COMMON_PATH.'/Html.php');
require_once(
HTML_BASE_UTIL_PATH.'/Image.php');
require_once(
HTML_BASE_UTIL_PATH.'/Link.php');


/**
 * Image Rotator. An image is shown in an round robin fasion in an interval
 * Note: At the moment of writing, only numbers between 00,01,02,...,99 are supported
 * <code>
 * Usage:
 *   $path  = "/w200";
 *   $image = "";   // NOT USED if empty
 *   $start = "10"; // Start with image no. 10
 *   $end   = "20"; // End   with image no. 20
 *   $imagerotator = new Imagerotator($path, $image, $start, $end);
 *   print $imagerotator->getHtml();
 * Or
 *   Imagerotator::display($path, $image, $start, $end);
 * </code>
 * @package component
 */

class Imagerotator extends Html {
    
/**
     * @var String $path The Path to the images to use
     */
    
protected $path  '';
    
/**
     * @var String $image NOT USED, The Image to use
     */
    
protected $image '';
    
/**
     * @var String $start The start name of picture to rotate
     */
    
protected $start '';
    
/**
     * @var String $end The end name of picture to rotate
     */
    
protected $end   '';

    
/**
     * Constructor
     * @param String $path  The path to the images
     * @param String $image The image to use for now
     * @param String $start The start of the image name to use for now
     * @param String $end   The end of the image name to use for now
     */
    
function __construct($path=''$image=''$start=''$end='') {
        
parent::__construct();
        
$this->path  $path  !== '' $path  IMAGE_ROTATOR_PATH;
        
$this->image $image !== '' $image IMAGE_ROTATOR_IMAGE;
        
$this->start $start !== '' $start IMAGE_ROTATOR_START;
        
$this->end   $end   !== '' $end   IMAGE_ROTATOR_END;
        if (
$this->end>IMAGE_ROTATOR_END) {
            die(
$this->getClassName()."(), The max rotator end:".$this->end." is greater than ".IMAGE_ROTATOR_END."<br />\r\n");
        }
    }

    
/**
     * Get the name of the image to rotate
     * The name is prepended with zero if the name is smaller than 10
     * so the images must be named i.e. 00,01,02,..99
     * @return String The name
     */
    
function getName() {
        
$name $this->image;
        if (
$name == "") {
            
$name rand($this->start$this->end);
            
$length strlen($this->end $this->start);
            
$start  strlen($name);
            for (
$i $start$i $length$i *= 10) {
                
$name '0'.$name;
            }
        }
        return 
$name;
    }

    
/**
     * Builds the html, and return it for an Image Rotator object
     * @return String The html
     */
    
function getHtml() {
        
$html  $this->html;
        if (
defined('COMPONENT_SHOW') && COMPONENT_SHOW COMPONENT_SHOW_IMAGEROTATOR && HTTP_USER_AGENT!=HTTP_USER_AGENT_P900) {
            if (
defined('CREATE_RUNTIME_KERNEL') && CREATE_RUNTIME_KERNEL) {
                
$html .= "require_once(HTML_COMPONENT_PAGE_PATH.'/Imagerotator.php');";
                
$html .= '<'.'?Imagerotator::display();?'.'>';
            } else {
                
$name $this->getName(); 
                
$text  '';
                
$title IMAGE_ROTATOR_LINK.' ('.$name.')';
                
$link  = new Link($textIMAGE_ROTATOR_LINK,CSS_LINK_COLOR$title,LINK_LAYOUT_BR);
                
$image = new Image($this->path.'/'.$name.'.'.IMAGE_SUFFIX_JPG,'',''$title,CSS_LINK_COLOR);
                
$link->add($image);
                
$html .= $link->getHtml();
            }
        } else {
            if (
defined('DEBUG_LEVEL_SHOW_INFO') && DEBUG_LEVEL DEBUG_LEVEL_SHOW_INFO) {
                
$html .= "<!-- No Image Rotator object -->\r\n";
            }
        }
        return 
$html;
    }

    
/**
     * Display html
     * <code>
     * Usage:
     *   $path      = "/w200";
     *   $image     = "";   // NOT USED if empty
     *   $start     = "10"; // Start with image no. 10
     *   $end       = "20"; // End   with image no. 20
     *   Imagerotator::display($path, $image, $start, $end);
     * </code>
     * @static
     * @param String $path  The path to the images to rotate
     * @param String $image The image to use for now
     * @param String $start The start of the image name to use for now
     * @param String $end   The end of the image name to use for now
     */
    
public static function display($path=''$image=''$start=''$end='') {
        
$html = new Imagerotator($path$image$start$end);
        
$html->addHtml();
    }
}
?>

Vis: HTML source code

Imagerotator, HTML source code

Den fulde HTML kildekode for Imagerotator klassen

<?
<!-- DEBUGImagerotator -->
<!-- 
DEBUGLink -->
<
class="baseLinkColor" href="http://www.hvepseeksperten.dk" title="http://www.hvepseeksperten.dk (07)"><!-- DEBUGImage -->
<
img src="http://finnrasmussen.dk/images/w200/07.jpg" alt="http://www.hvepseeksperten.dk (07)" class="baseLinkColor" />
</
a><br />

?>

Vis: Class methods

Imagerotator, Class methods

Her er 'klasse metoderne' for Imagerotator klassen:

  • __construct
  • getName
  • getHtml
  • display
  • 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

Imagerotator, Object vars

Her er 'objekt variable' for Imagerotator 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.3.3-7+squeeze3) 1.11
blank.gif