Top  Branding  Banner 
blank.gif
blank.gif
triangle.gif Du er her: /  Forsiden  /  Kildekoden  /  Basic  /  Rowcolor   Login nu   Login
blank.gif
««« Se kilde koden
blank.gif
tl.gif Base tr.gif tls.gif     Basic  trs.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

Rowcolor.php


Vis: Sample code, tutorial

Rowcolor, Sample code, tutorial

Sådan benyttes komponenten Rowcolor klassen

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

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

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

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

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

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

Skjul: Sådan vises komponenten

Rowcolor, Sådan vises komponenten

Sådan vises komponenten Rowcolor klassen

baseColorLight

Vis: PHP source code

Rowcolor, PHP source code

Den fulde PHP kildekode for Rowcolor klassen

<?php
/**
 * @package basic
 * @see HTML_BASIC_UTIL_PATH.'/Rowcolor.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
 */

/**
 * Generates a new Row Color
 * <code>
 * Usage:
 *   $html = new Rowcolor($count++,, $light, $dark);
 *   print $html->getHtml();
 * Or
 *   $rowcolor = Rowcolor::get($count++, $light, $dark);
 * Or
 *   $imgcolor = Rowcolor::img($color);
 * </code>
 * @package basic
 */

class Rowcolor {
    
/**
    * @var int $count The row counter
    */
    
protected $count 0;

    
/**
    * @var String $light The light row
    */
    
protected $light 0;

    
/**
    * @var String $dark The dark row
    */
    
protected $dark 0;

    
/**
     * Constructor
     * @param int    $count The next row
     * @param String $light The light row
     * @param String $dark  The dark  row
     */
    
function __construct($count$light=''$dark='') {
        
$this->count $count;
        
$this->light $light != ''?$light:CSS_COLOR_LIGHT;
        
$this->dark  $dark  != ''?$dark :CSS_COLOR_DARK;
    }

    
/**
     * Get the complete html for a Row Color
     * @see CSS_COLOR_LIGHT The css color Light
     * @see CSS_COLOR_DARK  The css color Dark
     * @return String the html
     */
    
function getHtml() {
        return 
$this->count%2?$this->light:$this->dark;
    }

    
/**
     * Returns 6 digits css color code from the supplied 3 digits hex color
     * The color is hex I.e. 1F3 => 11FF34 (where the last color digit is counted one up)
     * This function ia a bugfix for xhtml 1.0 strict compliant validator
     * where <img border="0" ... /> is not allowed, however we must have it
     * <code>
     * Usage:
     *    $imgcolor = Rowcolor::img($color);
     * </code> 
     * @static
     * @param  int $hexcolor The css hex color, i.e. a2b
     * @return String the img css color (6 digits) i.e. 'aa22bc' (c=b+1)
     */
    
public static function img($hexcolor) {
        
$html '';
        
$len strlen($hexcolor);
        if (
$len != 3) {
            
//die('File: '.__FILE__."<br />\r\nLine: ".__LINE__."<br />\r\n".' Rowcolor::img($hexcolor), The color MUST be 3 digits, like 2fc, found length='.$len.' in $hexcolor='.$hexcolor);
        
}
        for (
$i 0$i $len$i++) {
            
$digit hexdec(substr($hexcolor$i1));
            if (!
is_numeric($digit)) {
                die(
'File: '.__FILE__."<br />\r\nLine: ".__LINE__."<br />\r\n".' Rowcolor::img($hexcolor), The color is not a numeric, found $digit='.$digit.' in $hexcolor='.$hexcolor);
            }
            switch (
$i) {
                case 
0:
                case 
1:
                    
$html .= ''.dechex($digit).dechex($digit);
                    break;
                case 
4:
                case 
3:
                case 
2:
                    
$html .= ''.dechex($digit);
                    if (
$digit 0xF) {
                        
$html .= dechex($digit 1);
                    } else {
                        
$html .= dechex($digit 1);
                    }
                    break;
                default:
                    
//die('File: '.__FILE__."<br />\r\nLine: ".__LINE__."<br />\r\n".', Rowcolor::img($hexcolor), Should never end up here!');
                    
break;
            }
        }
        return 
$html;
    }

    
/**
     * Get the rowcolor for the odd/even count
     * <code>
     * Usage:
     *    Rowcolor::get($count++, $light, $dark);
     * </code> 
     * @static
     * @param  int    $count The next row
     * @param  String $light The light row
     * @param  String $dark  The dark  row
     * @return String the html
     */
    
public static function get($count$light=''$dark='') {
        
$html = new Rowcolor($count$light$dark);
        return 
$html->getHtml();
    }
}
?>

Vis: HTML source code

Rowcolor, HTML source code

Den fulde HTML kildekode for Rowcolor klassen

<?
baseColorLight
?>

Vis: Class methods

Rowcolor, Class methods

Her er 'klasse metoderne' for Rowcolor klassen:

  • __construct
  • getHtml
  • img
  • get

Vis: Object vars

Rowcolor, Object vars

Her er 'objekt variable' for Rowcolor klassen:


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