Design
Design Du er her: /  Forsiden  /  Kildekoden  /  Layout  /  Design   Login nu   Login
Design
 ««« Se kilde koden
Design
Design Basic Design Design Base Design Design Component Design Design Db Design Design Dto Design Design Form Design Design Form-elements Design Design Jquery Design Design Layout  Design Design Menu Design Design Menu-fisheye Design Design Mvc Design Design Tab Design Design Table Design Design Template Design Design Util Design
Design
Design
Design Index
 
Tilbage

Navn : Design.php


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();
    ?>

Parent html

Sådan vises komponenten Design klassen


  DEFINE LAYOUT SHOW   










PHP source code

Den fulde PHP kildekode for Design klassen

<?
/**
* @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.10
* @since 22-feb-2007
*/

// 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 {
    var
$components = '';
    var
$type       = '';
    var
$component  = '';
    var
$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 Design($components='',$type='',$component='',$show='') {
        
$this->Html();
        
$this->components = $components!=''?$components:DEFINE_SETUP_PATH;
        
$this->type       = $type!=''?$type:DESIGN_TYPE_TEXT;
        
$this->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.".$this->show.".value";
                
$onclick .= is_bool($value)?'=false':'|='.$value;
                
$onclick .= ';';
                
$onclick .= '}else{';
                
$onclick .= "this.form.".$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 = 0; // 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->getHtml(),$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->getHtml(),$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(__FILE__,__LINE__,$msg);
                            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);
     * </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
     */
    
function display($components='',$type='',$component='',$show='') {
        
$html = new Design($components,$type,$component,$show);
        
$html->addHtml();
    }
}
?>

HTML source code

Den fulde HTML kildekode for Design klassen

<?
<hr />
<
fieldset class="baseFieldset"><legend class="baseLegend">&nbsp;<b>&nbsp;DEFINE&nbsp;LAYOUT&nbsp;SHOW&nbsp;</b>&nbsp;&nbsp;</legend>

<
form action="/source-code/layout/Design/index.php" method="get" name="Form51" id="Form51">
<
input type="checkbox" id="Checkbox52" onclick="if(this.checked){this.form.layoutLAYOUT_SHOW.value|=2;}else{this.form.layoutLAYOUT_SHOW.value&=-3;}" class="baseBody" value="2" tabindex="12" />

<
label for="Checkbox52" accesskey="C" title="Accelerator key, use (Alt + C)">
    <
b>LAYOUT SHOW BANNER</b>&nbsp; (Alt + C) </label><br />

<
input type="checkbox" id="Checkbox53" onclick="if(this.checked){this.form.layoutLAYOUT_SHOW.value|=4;}else{this.form.layoutLAYOUT_SHOW.value&=-5;}" class="baseBody" checked="checked" value="4" tabindex="13" />

<
label for="Checkbox53" accesskey="I" title="Accelerator key, use (Alt + I)">
    <
b>LAYOUT SHOW LOCATOR</b>&nbsp; (Alt + I) </label><br />

<
input type="checkbox" id="Checkbox54" onclick="if(this.checked){this.form.layoutLAYOUT_SHOW.value|=32;}else{this.form.layoutLAYOUT_SHOW.value&=-33;}" class="baseBody" value="32" tabindex="14" />

<
label for="Checkbox54" accesskey="M" title="Accelerator key, use (Alt + M)">
    <
b>LAYOUT&nbsp;SHOW&nbsp;CO<span class="baseColorDark">M</span>PANY</b>&nbsp; (Alt + M) </label><br />

<
input type="checkbox" id="Checkbox55" onclick="if(this.checked){this.form.layoutLAYOUT_SHOW.value|=128;}else{this.form.layoutLAYOUT_SHOW.value&=-129;}" class="baseBody" value="128" tabindex="15" />

<
label for="Checkbox55" accesskey="P" title="Accelerator key, use (Alt + P)">
    <
b>LAYOUT&nbsp;SHOW&nbsp;CO<span class="baseColorDark">P</span>YRIGHT</b>&nbsp; (Alt + P) </label><br />

<
input type="checkbox" id="Checkbox56" onclick="if(this.checked){this.form.layoutLAYOUT_SHOW.value|=512;}else{this.form.layoutLAYOUT_SHOW.value&=-513;}" class="baseBody" checked="checked" value="512" tabindex="16" />

<
label for="Checkbox56" accesskey="J" title="Accelerator key, use (Alt + J)">
    <
b>LAYOUT SHOW LINE</b>&nbsp; (Alt + J) </label><br />

<
input type="checkbox" id="Checkbox57" onclick="if(this.checked){this.form.layoutLAYOUT_SHOW.value|=2048;}else{this.form.layoutLAYOUT_SHOW.value&=-2049;}" class="baseBody" value="2048" tabindex="17" />

<
label for="Checkbox57" accesskey="Q" title="Accelerator key, use (Alt + Q)">
    <
b>LAYOUT SHOW TOP</b>&nbsp; (Alt + Q) </label><br />

<
input type="checkbox" id="Checkbox58" onclick="if(this.checked){this.form.layoutLAYOUT_SHOW.value|=4096;}else{this.form.layoutLAYOUT_SHOW.value&=-4097;}" class="baseBody" value="4096" tabindex="18" />

<
label for="Checkbox58" accesskey="X" title="Accelerator key, use (Alt + X)">
    <
b>LAYOUT SHOW BRANDING</b>&nbsp; (Alt + X) </label><br />

<
input type="checkbox" id="Checkbox59" onclick="if(this.checked){this.form.layoutLAYOUT_SHOW.value|=8192;}else{this.form.layoutLAYOUT_SHOW.value&=-8193;}" class="baseBody" value="8192" tabindex="19" />

<
label for="Checkbox59" accesskey="Z" title="Accelerator key, use (Alt + Z)">
    <
b>LAYOUT SHOW LOGO</b>&nbsp; (Alt + Z) </label><br />

<
input type="hidden" name="layoutLAYOUT_SHOW" id="Hidden60" value="516" />

<
input type="submit" id="Submitbutton61" class="formButton baseBorder baseBody"
    
onclick="this.form.layoutLAYOUT_SHOW.value=0xffff;" value="Set alt" title="Set alt (Alt + 0)" tabindex="20" accesskey="0" />

<
input type="submit" id="Submitbutton62" class="formButton baseBorder baseBody"
    
onclick="this.form.layoutLAYOUT_SHOW.value=1;" value="Nulstil alt" title="Nulstil alt (Alt + 1)" tabindex="21" accesskey="1" />


<
input type="submit" id="Submitbutton63" class="formButton baseBorder baseBody"
    
value="Ret" title="Ret (Alt + 2)" tabindex="22" accesskey="2" />

</
form>

</
fieldset><br />

?>

Class methods

Her er 'klasse metoderne' for Design klassen:

  • object
  • getclassname
  • getmsg
  • addhtml
  • gethtml
  • tostring
  • getcachefilename
  • save
  • content
  • stop
  • html
  • setobject
  • set
  • get
  • getattribute
  • gettag
  • add
  • getsizeof
  • getelement
  • getelements
  • gettoogle
  • getmaximize
  • getminimize
  • newtriangle
  • display
  • showsource
  • design
  • getonclick
  • getchecked
  • newelement
  • getformhtml

Object vars

Her er 'objekt variable' for Design klassen:

  • html =>
  • sql =>
  • elements => Array
  • sizeof => 0
  • components => Array
  • type => 1
  • component => 517
  • show => layoutLAYOUT_SHOW

Design

Vis denne side på danmark

Vis denne side på Germany

Vis denne side på England

Vis denne side på France

Vis denne side på Italy

Vis denne side på Norge

Vis denne side på Sverige

Vis denne side på USA


 
Design