Top  Branding  Banner 
blank.gif
blank.gif
triangle.gif Du er her: /  Forsiden  /  Kildekoden  /  Form-elements  /  Controlfactory   Login nu   Login
blank.gif
««« Se kilde koden
blank.gif
tl.gif Cms tr.gif tl.gif Component tr.gif tl.gif Db tr.gif tl.gif Db-basket tr.gif tl.gif Db-login tr.gif tl.gif Db-customer tr.gif tl.gif Db-select tr.gif tl.gif Jquery tr.gif tls.gif     Form-elements  trs.gif tl.gif Menu-fisheye tr.gif tl.gif Template tr.gif tl.gif Tree-node tr.gif tl.gif Validator tr.gif
blank.gif
blank.gif
arrow-headline.gif Index
MenuLink  MenuLeft  
Tilbage

Skjul: Navn

ControlFactory.php


Vis: Sample code, tutorial

ControlFactory, Sample code, tutorial

Sådan benyttes komponenten ControlFactory klassen

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

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

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

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

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

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

Skjul: Sådan vises komponenten

ControlFactory, Sådan vises komponenten

Sådan vises komponenten ControlFactory klassen

Der er ikke fundet noget

Vis: PHP source code

ControlFactory, PHP source code

Den fulde PHP kildekode for ControlFactory klassen

<?php
/**
 * @package form-element
 * @see HTML_FORM_ELEMENTS_COMPONENT_PATH.'/ControlFactory.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_BASIC_UTIL_PATH.'/Singleton.php');
require_once(
HTML_FORM_ELEMENTS_PAGE_PATH.'/ControlEmail.php');
require_once(
HTML_FORM_ELEMENTS_PAGE_PATH.'/ControlPassword.php');
require_once(
HTML_FORM_ELEMENTS_PAGE_PATH.'/ControlFileupload.php');
require_once(
HTML_FORM_ELEMENTS_PAGE_PATH.'/ControlAccept.php');
require_once(
HTML_FORM_COMPONENT_PATH.'/ElementFactory.php');
require_once(
HTML_LANGUAGE_UTIL_PATH.'/Translate.php');
if (
defined('HTML_LOG_UTIL_PATH')) {
    require_once(
HTML_LOG_UTIL_PATH.'/Log.php');
}

/**
 * The Control Factory is used to return a complete populated 
 * element object, consisting of a label object and a input object.
 * The element is returned as a singleton.
 * <code>
 * Usage:
 *   $factory = new ControlFactory();
 *   $element  = $factory->getInstance($label, $name, $classname, $useLabel);
 *   print $element->getHtml(); // Use the object
 * Or 
 *   $element  = ControlFactory::getInstance($label, $name, $classname, $useLabel);
 *   print $element->getHtml(); // Use the object
 * </code>
 * @package form-element
 */

class ControlFactory {
    
/**
     * Constructor
     */
    
function __construct() {
    }
    
    
/**
     * Return the control as an object
     * @static
     * @param  Label      $label     The Label object
     * @param  Text field $control   The Control object
     * @param  String     $classname The class name of the control
     * @return Object The html as an Object 
     */
    
public static function getSingleton($label$control$classname) {
        
$element = & Singleton::getInstance($classname);
        
$element->set(CLASS_VAR_LABEL$label);
         
$element->set(CLASS_VAR_CONTROL$control);
        return 
$element;
    }

    
/**
     * Return the control as an singleton instance object
     * @static
     * @param  Label   $label     The Label object
     * @param  String  $name      The name of the control
     * @param  String  $classname The class name of the control
     * @param  boolean $useLabel  The Control has a label (true) or not (false)
     * @return Object The html as an Object 
     */
    
public static function getInstance($label$name$classname$useLabel=true) {
        
$required ''// Debug
        
$type 'UNKNOWN';
        switch (
$classname) {
            case 
CLASS_NAME_CONTROL_EMAIL:
                
$type 'text';
                break;
            case 
CLASS_NAME_CONTROL_PASSWORD:
                
$type 'password';
                break;
            case 
CLASS_NAME_CONTROL_FILEUPLOAD:
                
$type 'fileupload';
                break;
            case 
CLASS_NAME_CONTROL_ACCEPT:
                
$type 'checkbox';
                break;
            default:
                die(
'File: '.__FILE__."<br />\r\nLine: ".__LINE__."<br />\r\n"."ControlFactory::getInstance(type,..), unknown classname, found classname=".$classname);
                break;
        }
        
        
/**
         * Checkbox and Label objects MUST be constructed in reverse order
         * because of the automatic id and label association
         * @see Element
         */
        
if ($useLabel && $type != 'checkbox') {
            
// Must be instanciated BEFORE the text field
            
$label ElementFactory::newLabel($type$label$required); 
        }
        
$value '';
        
$len   '';
        
$debug '';
        
$control ElementFactory::newInput($type$name$value$len$debug);
        if (!
$useLabel) {
            
$control->setId('');
        }
        
/**
         * Checkbox and Label objects MUST be constructed in reverse order
         * because of the automatic id and label association
         * @see Element
         */
        
if ($useLabel && $type == 'checkbox') {
            
// Must be instanciated BEFORE the text field
            
$label ElementFactory::newLabel($type$label$required); 
        }
        return 
ControlFactory::getSingleton($label$control$classname);
    }
}
?>

Vis: HTML source code

ControlFactory, HTML source code

Den fulde HTML kildekode for ControlFactory klassen

<?
Der er ikke fundet noget
?>

Vis: Class methods

ControlFactory, Class methods

Her er 'klasse metoderne' for ControlFactory klassen:

  • __construct
  • getSingleton
  • getInstance

Vis: Object vars

ControlFactory, Object vars

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