Top  Branding  Banner 
blank.gif
blank.gif
triangle.gif Du er her: /  Forsiden  /  Kildekoden  /  Component  /  Cssrotator   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  MenuLeft  
Tilbage

Skjul: Navn

Cssrotator.php


Vis: Sample code, tutorial

Cssrotator, Sample code, tutorial

Sådan benyttes komponenten Cssrotator klassen

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

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

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

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

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

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

Skjul: Sådan vises komponenten

Cssrotator, Sådan vises komponenten

Sådan vises komponenten Cssrotator klassen


Vis: PHP source code

Cssrotator, PHP source code

Den fulde PHP kildekode for Cssrotator klassen

<?php
/**
 * @package component
 * @filesource 
 * @see HTML_COMPONENT_PAGE_PATH.'/Cssrotator.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_PAGE_PATH.'/Css.php');
require_once(
HTML_BASE_UTIL_PATH.'/Style.php');
require_once(
HTML_BASE_UTIL_PATH.'/Image.php');

/**
 * Css Rotator. An image is shown in an round robin fasion in an interval
 * with the selected CSS item name
 * Note: At the moment of writing, only numbers between 00,01,02,...,99 are supported
 * It is assumed that the files are located here: /images/w200/00.jpg - 76.jpg
 * <code>
 * Usage:
 *   $path      = "/w200";
 *   $image     = ""; // NOT USED if empty
 *   $start     = "10"; // Start with image no. 10
 *   $end       = "20"; // End   with image no. 20
 *   $classname = "body";
 *   $position  = "top right";
 *   $repeat    = "no-repeat";
 * 
 *   $rotator = new Cssrotator($path, $image, $start, $end, $classname, $position, $repeat);
 *   print $rotator->getHtml();
 * Or
 *   Cssrotator::display($path, $image, $start, $end, $classname, $position, $repeat);
 * </code>
 * @package component
 */

class Cssrotator extends Style {
    
/**
     * @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   ''
    
/**
     * @var String $classname The CSS class name to use
     */
    
protected $classname "";
    
/**
     * @var String $position The CSS position to use
     */
    
protected $position   "";
    
/**
     * @var String $repeat The CSS repeat to use
     */
    
protected $repeat    "";

    
/**
     * 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
     * @param String $classname The CSS class name to use, sample: [ body | .skeletonCenter ]
     * @param String $postion   The CSS position to use,   sample: [top | bottom | right | left]
     * @param String $repeat    The CSS repeat to use,     sample: [no-repeat | repeat-x | repaet-y]
     */
    
function __construct($path=''$image=''$start=''$end=''$classname=''$position=''$repeat='') {
        
parent::__construct();
        
$this->path      $path      != '' $path      CSS_ROTATOR_PATH;
        
$this->image     $image     != '' $image     CSS_ROTATOR_IMAGE;
        
$this->start     $start     != '' $start     CSS_ROTATOR_START;
        
$this->end       $end       != '' $end       CSS_ROTATOR_END;
        
$this->classname $classname != '' $classname CSS_ROTATOR_CLASS_NAME;
        
$this->position  $position  != '' $position  CSS_ROTATOR_POSITION;
        
$this->repeat    $repeat    != '' $repeat    CSS_ROTATOR_REPEAT;
        if (
$this->end CSS_ROTATOR_END) {
            die(
$this->getClassName()."(), The max rotator end:".$this->end." is greater than ".CSS_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
     * If $this->image is non empty, use this name instead
     * @return String The name of the image to use
     */
    
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;
    }

    
/**
     * Return the content as CSS class code
     * @return String The content as CSS code
     */
    
function getContent() {
        
$html  '';
        
$name  $this->getName();
        
$alt   $name;
        
$filename $this->path.'/'.$name.".";
        
$filepath PROJECT_DOCUMENT_ROOT;
        if (
strpos($this->pathCURRENT_MYPHP_VERSION) === false) {
            
$filepath .= IMAGE_SKIN_URL// Assume /images/w200
        
} else {
            
// Assume /myphp-1.11/myphp-project/html/images
        
}
        if (
file_exists($filepath.$filename.IMAGE_SUFFIX_GIF)) {
            
$filename .= IMAGE_SUFFIX_GIF;
        } else if (
file_exists($filepath.$filename.IMAGE_SUFFIX_JPG)) {
            
$filename .= IMAGE_SUFFIX_JPG;
        } else if (
file_exists($filepath.$filename.IMAGE_SUFFIX_PNG)) {
            
$filename .= IMAGE_SUFFIX_PNG;
        } else if (
file_exists($filepath.$filename.IMAGE_SUFFIX_JPEG)) {
            
$filename .= IMAGE_SUFFIX_JPEG;
        } else {
            
$msg $this->getClassName().'->getContent(), file not found, expected='.$filepath.$filename."suffix where suffix [gif | jpg | jpeg]";
            if (
defined('HTML_LOG_UTIL_PATH')) {
                
Log::error($msg__FILE____LINE__);
            }
            
Message::add($msg__FILE____LINE__);
        }
        
$image = new Image($filename,'',''$alt,CSS_LINK_COLOR);
        
$url   $image->getSrcName();
        
$css   = new Css();
        
$html .= $css->getImage($this->classname$url$this->repeat$this->position);
        return 
$html;
    }

    
/**
     * 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_CSS_ROTATOR && HTTP_USER_AGENT!=HTTP_USER_AGENT_P900) {
            if (
defined('CREATE_RUNTIME_KERNEL') && CREATE_RUNTIME_KERNEL) {
                
$html .= "<"."?require_once(HTML_COMPONENT_PAGE_PATH.'/Cssrotator.php');\r\n";
                
$html .= "Cssrotator::display();?".">\r\n";
            } else {
                
$html .= $this->getStart();
                
$html .= $this->getContent();
                
$html .= $this->getEnd();
            }
        } else {
            if (
defined('DEBUG_LEVEL_SHOW_INFO') && DEBUG_LEVEL DEBUG_LEVEL_SHOW_INFO) {
                
$html .= "<!-- No ".$this->getClassName()." object -->\r\n";
            }
        }
        return 
$html;
    }

    
/**
     * Display html
     * <code>
     * Usage:
     *   $path      = "/w200";
     *   $image     = ""; // NOT USED
     *   $start     = "10"; // Start with image no. 10
     *   $end       = "20"; // End   with image no. 20
     *   $classname = "body"; // Or '.skeletonRight'
     *   $position  = "top right";
     *   $repeat    = "no-repeat";
     * 
     *   Cssrotator::display($path, $image, $start, $end, $classname, $position, $repeat);
     * </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
     * @param String $classname The CSS class name to use
     * @param String $postion   The CSS position to use
     * @param String $repeat    The CSS repeat to use
     */
    
public static function display($path=''$image=''$start=''$end=''$classname=''$position=''$repeat='') {
        
$html = new Cssrotator($path$image$start$end$classname$position$repeat);
        
$html->addHtml();
    }
}
?>

Vis: HTML source code

Cssrotator, HTML source code

Den fulde HTML kildekode for Cssrotator klassen

<?
<!-- DEBUGCssrotator -->
<
style type="text/css">
body{
    
background-image    url('http://borebiller.info/images/w200/03.jpg');
    
background-repeat    no-repeat;
    
background-position    top left;
}
</
style>

?>

Vis: Class methods

Cssrotator, Class methods

Her er 'klasse metoderne' for Cssrotator klassen:

  • __construct
  • getName
  • getContent
  • getHtml
  • display
  • getStart
  • getCss
  • getEnd
  • start
  • end
  • 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

Cssrotator, Object vars

Her er 'objekt variable' for Cssrotator 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