Top  Branding  Banner 
blank.gif
blank.gif
triangle.gif Du er her: /  Forsiden  /  Kildekoden  /  Base  /  Picture   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

Picture.php


Vis: Sample code, tutorial

Picture, Sample code, tutorial

Sådan benyttes komponenten Picture klassen

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

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

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

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

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

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

Skjul: Sådan vises komponenten

Picture, Sådan vises komponenten

Sådan vises komponenten Picture klassen

Røde skov Myrer

Vis: PHP source code

Picture, PHP source code

Den fulde PHP kildekode for Picture klassen

<?php
/**
 * @package base
 * @see HTML_BASE_UTIL_PATH/Picture.php
 * @copyright 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.'/Link.php');
require_once(
HTML_BASE_UTIL_PATH.'/Image.php');

/**
 * Create the link and image for one of the pictures in the path /images/w200/
 * The picture names are from "00" to "60" with the extension of ".jpg"
 * <code>
 * Usage:
 *   $name     = "21"; // Assume ".jpg" extension
 *   $pictures = array(
 *          :
 *        21=>array('text'=>'', 'href'=>, 'title'=>'', 'src'=>'', 'width'=>'', 'height'=>'', 'alt'=>'', 'class'=>'', ),
 *          :
 *   );
 *   $path     = "/images/w200";
 *   $start    = '';
 *   $end      = '';
 *   $view     = new Picture($name, $pictures, $path, $start, $end);
 *   print $view->getHtml();
 * Or
 *   Picture::display($name, $pictures, $path, $start, $end);
 * </code>
 * @see HTML_BASE_RESOURCE_PATH/ConfigurationPictures.php
 * @package base
 */

class Picture extends Html {
    
/**
     * @var String $name The name of the picture to show
     */
    
protected $name '';

    
/**
     * @var array $pictures The rows of the pictures to show
     */
    
protected $pictures '';

    
/**
     * @var String $path The path to the the picture to show
     */
    
protected $path '';
    
/**
     * @var String $start The start name of picture to show
     */
    
protected $start '';
    
/**
     * @var String $end The end name of picture to show
     */
    
protected $end   '';

    
/**
     * Constructor
     * @param integer $name     The picture to display
     * @param array   $pictures The rows of pictures to display
     * @param String  $path     The path to the picture to display
     * @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($name=''$pictures=''$path=''$start=''$end='') {
        
parent::__construct();
        
$picture     array_key_exists(DEFINE_PICTURES$GLOBALS) ? $GLOBALS[DEFINE_PICTURES] : array("PictureIsMissing");
        
$this->name  $name  != '' $name '';
        
$this->pictures $pictures !== '' $pictures $picture;
        
$this->path  $path  != '' $path  IMAGE_PATH;
        
$this->start $start != '' $start '0';  // TODO PICTURE_START
        
$this->end   $end   != '' $end   '70'// TODO PICTURE_END
    
}

    
/**
     * 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->name;
        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 Picture for the Image and the Link to use as an object
     * @param  String $name    The name of the picture
     * @param  array  $picture The array data for the picture
     * @return Object The html as an Link and/or Image object
     */
    
function newObject($name$picture='') {
        
$text   '';
        
$href   LINK_HREF_URL.'/';
        
$title  BRANDING_TEXT."\r\n".MOBILE_PHONE."\r\n".LINK_TITLE_FREE_ADVICE." ($name)";
        
$src    '';
        
$width  '';
        
$height '';
        
$alt    '';
        
$class  CSS_BODY;
        if (
$picture != '' && is_array($picture)) {
            foreach(
$picture as $key=>$value) {
                if (
$value != '') {
                    $
$key $value;
                }
            }
        }
        
$object  = new Raw();
        if (
$href != '') {
            
$object = new Link($text$href$class$title); 
        }
        if (
$src == '') {
            
$name = (strlen($name)==1?'0' '').$name;             
            
$src $this->path.'/'.$name.'.'.IMAGE_SUFFIX_JPG;
        }
        if (
$class == CSS_BODY) {
            
$class .= ' '.CSS_FLOAT_RIGHT;
        }
        if (
$src != '') {
            
$object->add(new Image($src$width$height$alt$class));
        }
        return 
$object;
    }

    
/**
     * Return the content for the Image and the Link to use as an object
     * @return Object The picture object
     */
    
function newContent() {
        
$object  = new Raw();
        
$name $this->getName();
        if (
is_array($this->pictures) && array_key_exists($name$this->pictures)) {
            
$object $this->newObject($name$this->pictures[$name]);
        } else {
            
$object $this->newObject($name);
            if (
defined('DEBUG_LEVEL_SHOW_INFO') && DEBUG_LEVEL DEBUG_LEVEL_SHOW_INFO) {
                
$object  = new Raw($this->getClassName().'->newContent(), Unknown picture found, name='.$name."<br />\r\n");
            }
        }
        return 
$object;
    }

    
/**
     * Return the html for the Image and the Link to use
     * @return String The html
     */
    
function getHtml() {
        
$html  '';
        
$content $this->newContent();
        
$html .= $content->getHtml();
        return 
$html;
    }

    
/**
     * Display html
     * <code>
     * Usage: 
     *   $name     = "21"; // Assume 'jpg' extension
     *   $pictures = array("20", "21", "22", "23",);
     *   $path     = "/images/w200";
     *   $start    = '';
     *   $end      = '';
     *   Picture::display($name, $pictures, $path, $start, $end);
     * </code>
     * @static
     * @param integer $name     The image to display
     * @param array   $pictures The rows of pictures to display
     * @param String  $path     The path to the picture to display
     * @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($name=''$pictures=''$path=''$start=''$end='') {
        
$html = new Picture($name$pictures$path$start$end);
        
$html->addHtml();
    }
}
?>

Vis: HTML source code

Picture, HTML source code

Den fulde HTML kildekode for Picture klassen

<?
<!-- DEBUGLink -->
<
class="baseBody" href="http://www.hvepseeksperten.dk/skadedyrsguide/seek/havemyrer.shtml" title="HvepseEksperten.dk ApS&#013;(+45) 40 50 60 69&#013;Ring for Gratis rådgivning ...  (54)"><!-- DEBUGImage -->
<
img src="http://finnrasmussen.dk/images/w200/54.jpg" alt="Røde skov Myrer" class="baseBody baseFloatRight" />
</
a>
?>

Vis: Class methods

Picture, Class methods

Her er 'klasse metoderne' for Picture klassen:

  • __construct
  • getName
  • newObject
  • newContent
  • 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

Picture, Object vars

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