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

Design.php


Vis: Sample code, tutorial

Design, Sample code, tutorial

Sådan benyttes komponenten Design klassen

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

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

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

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

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

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

Skjul: Sådan vises komponenten

Design, Sådan vises komponenten

Sådan vises komponenten Design klassen


DEFINE_LAYOUT_SHOW











Vis: PHP source code

Design, PHP source code

Den fulde PHP kildekode for Design klassen

<?php
/**
 * @package layout
 * @see HTML_LAYOUT_UTIL_PATH.'/Design.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
 */

// KNOWN BUG, radio deault 'checked' is not working

/**
 * The required files
 */
require_once(HTML_BASE_COMMON_PATH.'/Html.php');
require_once(
HTML_BASE_UTIL_PATH.'/Fieldset.php');
require_once(
HTML_BASE_UTIL_PATH.'/Legend.php');
require_once(
HTML_FORM_COMPONENT_PATH.'/Form.php');
require_once(
HTML_FORM_COMPONENT_PATH.'/ElementFactory.php');
require_once(
HTML_FORM_COMPONENT_PATH.'/Hiddens.php');
require_once(
HTML_FORM_COMPONENT_PATH.'/Hidden.php');
require_once(
HTML_FORM_COMPONENT_PATH.'/SubmitButton.php');
require_once(
HTML_UTIL_COMPONENT_PATH.'/Request.php');
require_once(
HTML_UTIL_COMPONENT_PATH.'/Format.php');
require_once(
HTML_BASE_UTIL_PATH.'/Tag.php');

/**
 * Design the system constants as checkbox, radio box or input fields
 * <code>
 * Usage:
 *    $components = $DEFINE_LAYOUT_SHOW;  // The array of possible defines
 *    $type       = DESIGN_TYPE_CHECKBOX; // Which look and feel to use
 *    $component  = Request::get(REQUEST_LAYOUT_SHOW,LAYOUT_SHOW);
 *    $show       = REQUEST_LAYOUT_SHOW;  // The name of the request parameter
 *    
 *    $html = new Design($components, $type, $component, $show);
 *    print $html->getHtml();
 * Or
 *    Dump::display($components, $type, $component, $show);
 * </code>
 * @package layout
 */

class Design extends Html {
    protected 
$components '';
    protected 
$type       '';
    protected 
$component  '';
    protected 
$show       '';

    
/**
     * Constructor
     * @param String $components  The system components to display
     * @param String $type        The display type (field, checkbox, radio)
     * @param String $component   The requested parameters
     * @param String $show        The display type to show
     */
    
function __construct($components=''$type=''$component=''$show='') {
        
parent::__construct();
        
$this->components $components != '' $components DEFINE_SETUP_PATH;
        
$this->type       $type       != '' $type       DESIGN_TYPE_TEXT;
        
$this->component  $component  != '' $component  '';
        
$this->show       $show       != '' $show       '';
    }
    
    
/**
     * Get the javascript onclick event code for a Checkbox.
     * If not a checkbox, just return an empty string
     * @param  String $type  The element type to use
     * @param  String $value The value for the element
     * @return String The onClick javascript, if a Checkbox else ''
     */
    
function getOnClick($type$value) {
        
$onclick ''// Pure Javascript
        
switch ($type) {
            case 
DESIGN_TYPE_CHECKBOX// Special case
                
$onclick .= "if(this.checked){";
                
$onclick .= "this.form.elements['".$this->show."'].value";
                
$onclick .= is_bool($value) ? '=false' '|='.$value;
                
$onclick .= ';';
                
$onclick .= '}else{';
                
$onclick .= "this.form.elements['".$this->show."'].value";
                
$onclick .= is_bool($value) ? '=true' '&='.(~$value);
                
$onclick .= ';';
                
$onclick .= '}';
                break;
            default: 
// Ignore
                
break;
        }
        return 
$onclick;
    }

    
/**
     * Get the checked value for a Checkbox or Radio.
     * If not a checkbox or radio, just return an empty string
     * @param  String $type       The element type to use
     * @param  String $component  The element component to use
     * @param  String $value      The value for the element
     * @return String The $checked value else ''
     */
    
function getChecked($type$component$value) {
        
$checked ''// Pure Javascript
        
switch ($type) {
            case 
DESIGN_TYPE_CHECKBOX// Special case
                
if ($value $component) {
                    
$checked 'checked';
                } else {
                    
// Do nothing
                
}
                break;
            case 
DESIGN_TYPE_RADIO:
                if (
$value $component) {
                    
$checked 'checked';
                }
                break;
            default: 
// Ignore
                
break;
        }
        return 
$checked;
    }
    
    
/**
     * Return the element for a Label and Input as an object
     * checkbox and radio buttons are also supported
     * @param  String $type     The type to use
     * @param  String $key      The Key to use
     * @param  String $name     The name to use
     * @param  String $value    The value to use
     * @param  String $len      The maxsize to use OR $onclick if Checkbox
     * @param  String $required The required text to use, if any
     * @param  String $debug    The debug text to use, if any
     * @param  String $checked  The checked attribute if ticked off for radio/checkbox
     * @return Object The html as an Object 
     */
    
function newElement($type$key$name$value$onclick=''$required=''$debug=''$checked='') {
        
$required ''// Not used
        
return ElementFactory::newElement($type$key$name$value$onclick$required$debug$checked);
    }

    
/**
    * Get the html, and return it as a Form page
    * @return String The html
     */
    
function getFormHtml() {
        
$html   '';
        if (
is_array($this->components)) {
            
$hr     = new Tag('','hr');
            
$html  .= $hr->getHtml();
            
$form   = new Form();
            
$legend = new Legend('Unknown Array Name');
            
$hexvalue 1// NONE
            
foreach ($this->components as $key=>$value) {
                if (
$key=='ARRAY_NAME') {
                    
$legend = new Legend($value);
                } else {
                    
$onclick $this->getOnClick($this->type$value);
                    
$checked $this->getChecked($this->type$this->component$value);
                    switch (
$this->type) {
                        case 
DESIGN_TYPE_CHECKBOX// Special case
                            
if ($value $this->component) {
                                
$hexvalue |= $value;
                            }
                            else {
                                
// Do nothing
                            
}
                            
$form->add($this->newElement('checkbox'$key''$value$onclick''''$checked));
                            break;
                        case 
DESIGN_TYPE_RADIO// Special case
                            
$form->add($this->newElement('radio'$key$this->show$value$onclick''''$checked));
                            break;
                        case 
DESIGN_TYPE_DEC2BIN:
                            
$format = new Format($value,FORMAT_STYLE_BIN);
                            
$debug  = new Format($value,FORMAT_STYLE_HEX);
                            
$form->add($this->newElement('text'$key$key$format->convert(), $onclick''$debug->getHtml(), $checked));
                            break;
                        case 
DESIGN_TYPE_DEC2HEX:
                            
$format = new Format($value,FORMAT_STYLE_HEX);
                            
$debug  = new Format($value,FORMAT_STYLE_BIN);
                            
$form->add($this->newElement('text'$key$key$format->convert(), $onclick''$debug->getHtml(), $checked));
                            break;
                        case 
DESIGN_TYPE_TEXT:
                            
$debug  = new Format($value,FORMAT_STYLE_HEX);
                            
$form->add($this->newElement('text'$key$key$value$onclick''$debug->getHtml(), $checked));
                            break;
                        default:
                            
$msg $this->getClassName().'.php, Unknown type='.$this->type.'<br />';
                            
Log::error($msg__FILE____LINE__);
                            die(
'File: '.__FILE__."<br />\r\nLine: ".__LINE__."<br />\r\n".$msg);
                            break;
                    }
                }
            }
            
// Special case
            
if ($this->type==DESIGN_TYPE_CHECKBOX) {
                
$form->add(new Hidden($this->show$hexvalue));
                foreach (
$_GET as $key=>$value) {
                    if (
$key!=$this->show) {
                        
$form->add(new Hidden($key$value));
                    }
                }
                
// SubmitButton($name='', $value='', $class='', $disabled='', $onclick='', $title='', $tabindex='', $accesskey='')
                
$form->add(new SubmitButton('',BUTTON_SET_ALL''''"this.form.".$this->show.".value=".'0xffff;'));
                
$form->add(new SubmitButton('',BUTTON_CLEAR_ALL''''"this.form.".$this->show.".value=".'1;'));
            }
            
$form->add(new Hiddens());
            
$form->add(new SubmitButton('',BUTTON_CHANGE));
            
$fieldset = new Fieldset($legend);
            
$fieldset->add($form);
            
$html .= $fieldset->getHtml();
        }
        else {
            
$html .= 'Undefined '.$this->components;
        }
        return 
$html;
    }

    
/**
     * Builds the html for a dump parameter form 
     * @return String The result as html
     */
    
function getHtml() {
        
$html  '';
        
$html .= $this->getFormHtml(); // Popup the form
        
return $html;
    }

    
/**
     * Display html
     * <code>
     * Usage:
     *    Design::display($components, $type, $component, $show);
     * </code>
     * @static
     * @param String $components  The system components to display
     * @param String $type        The display type (field, checkbox, radio(
     * @param String $component   The system components to display
     * @param String $show        The display type to show
     */
    
public static function display($components=''$type=''$component=''$show='') {
        
$html = new Design($components$type$component$show);
        
$html->addHtml();
    }
}
?>

Vis: HTML source code

Design, HTML source code

Den fulde HTML kildekode for Design klassen

<?
<hr />
<!-- 
DEBUGFieldset -->
<
fieldset class="baseFieldset"><!-- DEBUGLegend -->
<
legend>DEFINE_LAYOUT_SHOW
</legend>

<!-- 
DEBUGForm -->
<
form action="/source-code/layout/Design/index.php" method="get" name="Form1" id="Form1">
<!-- 
DEBUGCheckbox -->
<
input type="checkbox" id="Checkbox2" onclick="if(this.checked){this.form.elements['layoutLAYOUT_SHOW'].value|=2;}else{this.form.elements['layoutLAYOUT_SHOW'].value&=-3;}" class="baseBody" value="2" tabindex="1" />

<!-- 
DEBUGLabel -->
<
label for="Checkbox2" accesskey="L" title="Accelerator key, use (Alt + L)">
    <
b><span class="baseColorDark">L</span>AYOUT&nbsp;SHOW&nbsp;BANNER</b>&nbsp; (Alt L) </label><br />


<!-- 
DEBUGCheckbox -->
<
input type="checkbox" id="Checkbox3" onclick="if(this.checked){this.form.elements['layoutLAYOUT_SHOW'].value|=4;}else{this.form.elements['layoutLAYOUT_SHOW'].value&=-5;}" class="baseBody" checked="checked" value="4" tabindex="2" />

<!-- 
DEBUGLabel -->
<
label for="Checkbox3" accesskey="A" title="Accelerator key, use (Alt + A)">
    <
b>L<span class="baseColorDark">A</span>YOUT&nbsp;SHOW&nbsp;LOCATOR</b>&nbsp; (Alt A) </label><br />


<!-- 
DEBUGCheckbox -->
<
input type="checkbox" id="Checkbox4" onclick="if(this.checked){this.form.elements['layoutLAYOUT_SHOW'].value|=32;}else{this.form.elements['layoutLAYOUT_SHOW'].value&=-33;}" class="baseBody" value="32" tabindex="3" />

<!-- 
DEBUGLabel -->
<
label for="Checkbox4" accesskey="Y" title="Accelerator key, use (Alt + Y)">
    <
b>LA<span class="baseColorDark">Y</span>OUT&nbsp;SHOW&nbsp;COMPANY</b>&nbsp; (Alt Y) </label><br />


<!-- 
DEBUGCheckbox -->
<
input type="checkbox" id="Checkbox5" onclick="if(this.checked){this.form.elements['layoutLAYOUT_SHOW'].value|=128;}else{this.form.elements['layoutLAYOUT_SHOW'].value&=-129;}" class="baseBody" checked="checked" value="128" tabindex="4" />

<!-- 
DEBUGLabel -->
<
label for="Checkbox5" accesskey="O" title="Accelerator key, use (Alt + O)">
    <
b>LAY<span class="baseColorDark">O</span>UT&nbsp;SHOW&nbsp;COPYRIGHT</b>&nbsp; (Alt O) </label><br />


<!-- 
DEBUGCheckbox -->
<
input type="checkbox" id="Checkbox6" onclick="if(this.checked){this.form.elements['layoutLAYOUT_SHOW'].value|=512;}else{this.form.elements['layoutLAYOUT_SHOW'].value&=-513;}" class="baseBody" checked="checked" value="512" tabindex="5" />

<!-- 
DEBUGLabel -->
<
label for="Checkbox6" accesskey="T" title="Accelerator key, use (Alt + T)">
    <
b>LAYOU<span class="baseColorDark">T</span>&nbsp;SHOW&nbsp;LINE</b>&nbsp; (Alt T) </label><br />


<!-- 
DEBUGCheckbox -->
<
input type="checkbox" id="Checkbox7" onclick="if(this.checked){this.form.elements['layoutLAYOUT_SHOW'].value|=2048;}else{this.form.elements['layoutLAYOUT_SHOW'].value&=-2049;}" class="baseBody" value="2048" tabindex="6" />

<!-- 
DEBUGLabel -->
<
label for="Checkbox7" accesskey="S" title="Accelerator key, use (Alt + S)">
    <
b>LAYOUT&nbsp;<span class="baseColorDark">S</span>HOW&nbsp;TOP</b>&nbsp; (Alt S) </label><br />


<!-- 
DEBUGCheckbox -->
<
input type="checkbox" id="Checkbox8" onclick="if(this.checked){this.form.elements['layoutLAYOUT_SHOW'].value|=4096;}else{this.form.elements['layoutLAYOUT_SHOW'].value&=-4097;}" class="baseBody" value="4096" tabindex="7" />

<!-- 
DEBUGLabel -->
<
label for="Checkbox8" accesskey="W" title="Accelerator key, use (Alt + W)">
    <
b>LAYOUT&nbsp;SHO<span class="baseColorDark">W</span>&nbsp;BRANDING</b>&nbsp; (Alt W) </label><br />


<!-- 
DEBUGCheckbox -->
<
input type="checkbox" id="Checkbox9" onclick="if(this.checked){this.form.elements['layoutLAYOUT_SHOW'].value|=8192;}else{this.form.elements['layoutLAYOUT_SHOW'].value&=-8193;}" class="baseBody" value="8192" tabindex="8" />

<!-- 
DEBUGLabel -->
<
label for="Checkbox9" accesskey="G" title="Accelerator key, use (Alt + G)">
    <
b>LAYOUT&nbsp;SHOW&nbsp;LO<span class="baseColorDark">G</span>O</b>&nbsp; (Alt G) </label><br />


<!-- 
DEBUGCheckbox -->
<
input type="checkbox" id="Checkbox10" onclick="if(this.checked){this.form.elements['layoutLAYOUT_SHOW'].value|=16384;}else{this.form.elements['layoutLAYOUT_SHOW'].value&=-16385;}" class="baseBody" value="16384" tabindex="9" />

<!-- 
DEBUGLabel -->
<
label for="Checkbox10" accesskey="I" title="Accelerator key, use (Alt + I)">
    <
b>LAYOUT&nbsp;SHOW&nbsp;VAL<span class="baseColorDark">I</span>DATOR</b>&nbsp; (Alt I) </label><br />


<!-- 
DEBUGHidden -->
<
input type="hidden" name="layoutLAYOUT_SHOW" value="645" />

<!-- 
DEBUGSubmitButton -->
<
input type="submit" class="formButton baseBorder baseBody formXXSmall"
     
onclick="this.form.layoutLAYOUT_SHOW.value=0xffff;" value="Set alt" title="Set alt (Alt + E)" tabindex="10" accesskey="E" />

<!-- 
DEBUGSubmitButton -->
<
input type="submit" class="formButton baseBorder baseBody formXXSmall"
     
onclick="this.form.layoutLAYOUT_SHOW.value=1;" value="Nulstil alt" title="Nulstil alt (Alt + N)" tabindex="11" accesskey="N" />

<!-- 
DEBUGHiddens -->

<!-- 
DEBUGSubmitButton -->
<
input type="submit" class="formButton baseBorder baseBody formXXSmall"
     
value="Ret" title="Ret (Alt + B)" tabindex="12" accesskey="B" />

</
form>

</
fieldset><br />

?>

Vis: Class methods

Design, Class methods

Her er 'klasse metoderne' for Design klassen:

  • __construct
  • getOnClick
  • getChecked
  • newElement
  • getFormHtml
  • 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

Design, Object vars

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