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

Div.php


Vis: Sample code, tutorial

Div, Sample code, tutorial

Sådan benyttes komponenten Div klassen

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

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

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

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

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

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

Skjul: Sådan vises komponenten

Div, Sådan vises komponenten

Sådan vises komponenten Div klassen

Demo

Vis: PHP source code

Div, PHP source code

Den fulde PHP kildekode for Div klassen

<?php
/**
 * @package base
 * @filesource
 * @see HTML_BASE_UTIL_PATH.'/Div.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');

/**
 * Generates a <div class="$class" align="$align" id="$id">$text</div>
 * <code>
 * Usage:
 *   $text  = "some text";
 *   $class = CSS_ALIGN_RIGHT;
 *   $align = "";
 *   $id    = "";
 *   $html  = new Div($text, $class, $align, $id);
 *   print $html->getHtml();
 * Or
 *   Div::display($text , $class, $align, $id);
 * Or
 *   Div::start($text, $class, $align, $id);
 *   Link::display();
 *   Div::end();
 * </code>
 * @package base
 */

class Div extends Html {
    
/**
     * @var String $text The Text or an object
     */
    
protected $text  '';

    
/**
     * @var String $class The CSS class name for an object
     */
    
protected $class '';

    
/**
     * @var String $align The align attribute
     */
    
protected $align '';

    
/**
     * @var String $id The ID attribute
     */
    
protected $id '';

    
/**
     * Constructor
     * @param String $text   The text for the Div tag or an object
     * @param String $class  The css class name
     * @param String $align  The align attribute
     * @param String $id     The ID attribute
     */
    
function __construct($text=''$class=''$align=''$id='') {
        
parent::__construct();
        
$this->text  $text;
        
$this->class $class;
        
$this->align $align;
        
$this->id    $id;
    }

    
/**
     * Returns the start for the div html element
     * @return String the complete html
     */
    
function getStart() {
        
$html  '';
        
$html .= '<div';
        
$html .= $this->getAttribute('id');
        
$html .= $this->getAttribute('class');
        
$html .= $this->getAttribute('align');
        
$html .= '>';
        if (
is_object($this->text)) {
            
$html .= $this->text->getHtml();
        } else {
            
$html .= $this->text;
        }
        
$html .= $this->getElements();
        return 
$html;
    }

    
/**
     * Returns the end for the div html element
     * @return String the complete html
     */
    
function getEnd() {
        return 
"</div>\r\n";
    }

    
/**
     * Returns the html for the div html element
     * @return String the complete html
     */
    
function getHtml() {
        
$html  '';
        
$html .= $this->getStart();
        
$html .= $this->getEnd();
        return 
$html;
    }

    
/**
     * Display start
     * <code>
     * Usage:
     *    Div::start($text, $class, $align, $id);
     * </code>
     * @static
     * @param String $text  The text for the div or an object
     * @param String $class The css class of the div
     * @param String $align The align attribute
     * @param String $id    The ID attribute
     */
    
public static function start($text=''$class=''$align=''$id='') {
        
$html = new Div($text$class$align$id);
        
$html->addHtml($html->getStart());
    }

    
/**
     * Display end
     * <code>
     * Usage:
     *    Div::end();
     * </code>
     * @static
     */
    
public static function end() {
        
$html = new Div();
        
$html->addHtml($html->getEnd());
    }

    
/**
     * Display html
     * <code>
     * Usage:
     *    $text  = "some text";
     *    $class = CSS_ALIGN_RIGHT;
     *    $align = "";
     *    $id    = "";
     *    Div::display($text, $class, $align, $id);
     * </code>
     * @static
     * @param String $text  The text for the div or an object
     * @param String $class The css class of the div
     * @param String $align The align attribute
     * @param String $id    The ID attribute
     */
    
public static function display($text=''$class=''$align=''$id='') {
        
$html = new Div($text$class$align$id);
        
$html->addHtml();
    }
}
?>

Vis: HTML source code

Div, HTML source code

Den fulde HTML kildekode for Div klassen

<?
<div class="baseColorLight baseAlignRight">Demo</div>

?>

Vis: Class methods

Div, Class methods

Her er 'klasse metoderne' for Div klassen:

  • __construct
  • getStart
  • getEnd
  • getHtml
  • start
  • end
  • 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

Div, Object vars

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