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

Navn : Hiddens.php


Sample code, tutorial

Sådan benyttes komponenten Hiddens klassen

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

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

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

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

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

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

Parent html

Sådan vises komponenten Hiddens klassen


PHP source code

Den fulde PHP kildekode for Hiddens klassen

<?
/**
* @package form
* @filesource
* @see HTML_FORM_COMPONENT_PATH.'/Hiddens.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
*/

/**
* The required files
*/
require_once(HTML_BASE_COMMON_PATH.'/Html.php');
require_once(
HTML_FORM_COMPONENT_PATH.'/Hidden.php');
require_once(
HTML_UTIL_COMPONENT_PATH.'/Params.php');

/**
* Create the hidden fields used in a form
* <code>
* Usage:
*   $keyValue = array();
*   $hiddens  = new Hiddens($keyValue,$title);
*   print $hiddens->getHtml();
* Or
*   Hiddens::display($keyValue,$title);
* </code>
* @package form
*/

class Hiddens extends Html {
    
/**
     * @var array $keyValue Optionally array of key value pairs, or empty
     */
    
var $keyValue = '';

    
/**
     * @var String $title The title for the next command to execute
     */
    
var $title = '';

    
/**
     * @var String $debug The debug text to use, if any
     */
    
var $debug = '';

    
/**
     * Constructor
     * @param array  $keyValue Optionally array of key value pairs, or empty
     * @param String $title    The title for the next command to execute
     * @param String $debug    The debug text to use, if any
     */
    
function Hiddens($keyValue=array(),$title='',$debug='') {
        
$this->Html();
        
$this->keyValue = $keyValue;
        
$this->title    = $title;
        
$this->debug    = $debug;
    }

    
/**
     * Get the html for the specified hidden field
     * @param  String $name  The name of the request key
     * @param  String $const The const string of the request key
     * @param  array  $keyValue Optionally array of key value pairs, or empty
     * @param  array  $vars  The request array send as a GET or POST
     * @param  String $title The title for the hidden field
     * @return String The html
     */
    
function getHidden($name,$const,$keyValue,$vars,$title='') {
        
$html  = '';
        if (
defined($name) && !empty($vars[$const])) {
            if (!
array_key_exists($const,$keyValue)) {
                if (
defined('DEBUG_LEVEL') && DEBUG_LEVEL & DEBUG_LEVEL_SHOW_INFO) {
                    
$title = $title!=''?$title." $name":$name;
                }
                if (
Params::validate($const,$vars[$const])) {
                    
$hidden = new Hidden($const,$vars[$const],$title);
                    
$html .= $hidden->getHtml();
                } else {
                    
$html .= "Params::validate($name) failed<br />\r\n";
                }
            } else {
                if (
defined('DEBUG_LEVEL') && DEBUG_LEVEL & DEBUG_LEVEL_SHOW_INFO) {
                    
$html = "<!-- DEBUG: $name already defined -->\r\n";
                }
            }
        } else {
            if (
defined('DEBUG_LEVEL') && DEBUG_LEVEL & DEBUG_LEVEL_SHOW_INFO) {
                
//$html = "<!-- DEBUG: $name -->\r\n";
            
}
        }
        return
$html;
    }

    
/**
     * Get the html for all the hidden fields
     * @see Params
     * @param  array $vars The request array send as a GET or POST
     * @return String The html
     */
    
function getHiddens($vars) {
        
$html  = '';
        
$keyValue = $this->keyValue;
        foreach(
$keyValue as $key=>$value) {
            if (
$value!='') {
                if (
Params::validate($key,$value)) {
                    
$title  = $this->title;
                    if (
$this->debug!='') {
                        
$title .= ' ('.$this->debug.')';
                    }
                    
$hidden = new Hidden($key,$value,$title);
                    
$html .= $hidden->getHtml();
                } else {
                    
$html .= "Params::validate($key) failed<br />\r\n";
                }
            }
        }
        
        
// REQUEST_COMMAND is Added in the form where the Buttons are defined etc.
        //$html .= $this->getHidden('REQUEST_COMMAND',REQUEST_COMMAND,$keyValue,$vars,$this->title);
        
$html .= $this->getHidden('REQUEST_NEXT',REQUEST_NEXT,$keyValue,$vars,$this->title);
        
// CMS
        
$html .= $this->getHidden('REQUEST_PAGE_DOMAINNAME',REQUEST_PAGE_DOMAINNAME,$keyValue,$vars);
        
        
$html .= $this->getHidden('REQUEST_BASE_PACKAGE_TEST',REQUEST_BASE_PACKAGE_TEST,$keyValue,$vars);
        
$html .= $this->getHidden('REQUEST_ORDER_BY_NAME',REQUEST_ORDER_BY_NAME,$keyValue,$vars);
        
$html .= $this->getHidden('REQUEST_SORT_BY_NAME',REQUEST_SORT_BY_NAME,$keyValue,$vars);
        
$html .= $this->getHidden('REQUEST_LANGUAGE',REQUEST_LANGUAGE,$keyValue,$vars);
        
$html .= $this->getHidden('REQUEST_SID',REQUEST_SID,$keyValue,$vars);
        
// ViewSearchColumns, problems with default init value
        //$html .= $this->getHidden('REQUEST_VIEW_COLUMN_NAME',REQUEST_VIEW_COLUMN_NAME,$keyValue,$vars);
        
$html .= $this->getHidden('REQUEST_LIMIT_NAME_SKIP',REQUEST_LIMIT_NAME_SKIP,$keyValue,$vars);
        
$html .= $this->getHidden('REQUEST_LIMIT_NAME_SHOW',REQUEST_LIMIT_NAME_SHOW,$keyValue,$vars);
        return
$html;
    }

    
/**
     * Returns the html for all the hidden fields for a form
     * @return String The html
     */
    
function getHiddenFields() {
        return
$this->getHiddens($_SERVER['REQUEST_METHOD']===REQUEST_METHOD_POST?$_POST:$_GET);
    }

    
/**
     * Get the complete html for the hidden fields in a form
     * @return String The html
     */
    
function getHtml() {
        
$html  = $this->html;
        if (
defined('DEBUG_LEVEL') && (DEBUG_LEVEL & DEBUG_LEVEL_SHOW_DECRYPT) && $this->debug!='') {
            
$html .= "<!-- ".$this->getClassName()." ".$this->debug." -->\r\n";
        }
        
$html .= $this->getHiddenFields();
        return
$html;
    }
    
    
/**
     * Display html
     * <code>
     * Usage:
     *    Hiddens::display($keyValue, $title, $debug);
     * </code>
     * @static
     * @param array  $keyValue Optionally array of key value pairs, or empty
     * @param String $title    The title for the next command to execute
     * @param String $debug    The debug text, if any
     */
    
function display($keyValue=array(), $title='', $debug='') {
        
$html = new Hiddens($keyValue, $title, $debug);
        
$html->addHtml();
    }
}
?>

HTML source code

Den fulde HTML kildekode for Hiddens klassen

<?

?>

Class methods

Her er 'klasse metoderne' for Hiddens 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
  • hiddens
  • gethidden
  • gethiddens
  • gethiddenfields

Object vars

Her er 'objekt variable' for Hiddens klassen:

  • html =>
  • sql =>
  • elements => Array
  • sizeof => 0
  • keyValue => Array
  • title =>
  • debug =>

Hiddens

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


 
Hiddens