Top  Branding  Banner 
blank.gif
blank.gif
triangle.gif Du er her: /  Forsiden  /  Kildekoden  /  Form  /  Textarea   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 tls.gif     Form  trs.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

Textarea.php


Vis: Sample code, tutorial

Textarea, Sample code, tutorial

Sådan benyttes komponenten Textarea klassen

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

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

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

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

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

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

Skjul: Sådan vises komponenten

Textarea, Sådan vises komponenten

Sådan vises komponenten Textarea klassen



Vis: PHP source code

Textarea, PHP source code

Den fulde PHP kildekode for Textarea klassen

<?php
/**
 * @package form
 * @filesource
 * @see HTML_FORM_COMPONENT_PATH.'/Textarea.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_BASE_UTIL_PATH.'/Element.php');
require_once(
HTML_BASE_UTIL_PATH.'/Tabindex.php');
require_once(
HTML_BASE_UTIL_PATH.'/Accesskey.php');

/**
 * Generates a html form elements, TEXTAREA
 * <code>
 * Usage:
 *   $textarea = new Textarea($name, $text, $rows, $cols, $class, $title, $tabindex, $accesskey, $wrap);
 *   print $textarea->getHtml();
 * Or
 *   $textarea = new Textarea($name, $text, $rows, $cols, $class, $title, $tabindex, $accesskey, $wrap);
 *   print $textarea->getStart();
 *   print "Display some text";
 *   print $textarea->getEnd();
 * Or
 *   Textarea::display($name, $text, $rows, $cols, $class, $title, $tabindex, $accesskey, $wrap);
 * Or
 *   Textarea::start($name, $text, $rows, $cols, $class, $title, $tabindex, $accesskey, $wrap);
 *   Raw::display('Display some text');
 *   Textarea::end();
 * </code>
 * @package form
 */

class Textarea extends Element {
    
/**
     * @var String $rows The number of rows
     */
    
protected $rows '';
    
/**
     * @var String $cols The number of columns
     */
    
protected $cols ''
    
    
/**
     * The wrap attribute defines how the text is wrapped inside the text area.
     * If set to off, the user have to scroll to see long lines
     * If set to physical, the lines are broken and is sent as seen by the user
     * If set to virtual, the text is wrapped within the text area, however the text is sent unbroken to the server. 
     * @var String $wrap One of the following values '', off, physical or virtual
     */
    
protected $wrap '';
    
    
/**
     * Constructor
     * @param String $name      The name of the control
     * @param String $text      The text value, if any
     * @param String $rows      The number of rows
     * @param String $cols      The number of columns
     * @param String $class     The class name
     * @param String $title     The title
     * @param String $tabindex  The tabindex
     * @param String $accesskey The accesskey
     * @param String $wrap      The wrap (virtual,physical,off)
     */
    
function __construct($name$text=''$rows=''$cols=''$class=''$title=''$tabindex=''$accesskey=''$wrap='') {
        
$aClass         $class != '' $class CSS_TEXTAREA_CLASS;
        
$onclick        '';
        
$aTabindex      $tabindex != '' $tabindex Tabindex::next();
        
// Call the constructor
        
parent::__construct($name$text$aClass$title$aTabindex$onclick$accesskey);
        
$this->rows     $rows != '' $rows TEXTAREA_ROWS;
        
$this->cols     $cols != '' $cols TEXTAREA_COLS;
        
$this->wrap     $wrap != '' $wrap TEXTAREA_WRAP_NONE;
           switch(
$this->wrap) {
               case 
TEXTAREA_WRAP_NONE:
               case 
TEXTAREA_WRAP_OFF:
               case 
TEXTAREA_WRAP_VIRTUAL:
               case 
TEXTAREA_WRAP_PHYSICAL:
                   
// Ok
                   
break;
               default:
                   die(
$this->getClassName()." Unknown wrap attribute, expected TEXTAREA_WRAP_PHYSICAL etc., found: ".$this->wrap);
                   break;
        }
    }

    
/**
     * Returns the complete html for the start of a textarea control
     * @return String the complete html
     */
    
function getStart() {
        
$html  $this->html;
        
$html .= '<textarea';
        
$html .= $this->getAttribute('name');
        
$html .= $this->getAttribute('id');
        
$html .= $this->getAttribute('rows');
        
$html .= $this->getAttribute('cols');
        
$html .= $this->getAttribute('class');
        
$html .= $this->getAttribute('title');
        
$html .= $this->getAttribute('tabindex');
        
$html .= $this->getAttribute('accesskey');
        
$html .= $this->getAttribute('wrap');
        
$html .= ">";
        
// Special handling of the value attribute
        
$encode    false;
        
$stripHttp false;
        
$html .= $this->getValue($encode$stripHttp__FILE____LINE__);
        
//$html .= $this->value;
        
return $html;
    }

    
/**
     * Returns the complete html for the end of a textarea control
     * @return String the complete html
     */
    
function getEnd() {
        
$html  '';
        
$html .= "</textarea><br />\r\n";
        return 
$html;
    }

    
/**
     * Returns the complete html for a textarea control
     * @return String the complete html
     */
    
function getHtml() {
        
$html  '';
        
$html .= $this->getStart();
        
$html .= $this->getEnd();
        return 
$html;
    }

    
/**
     * Display start html
     * <code>
     * Usage:
     *    Textarea::start($name, $text, $rows, $cols, $class, $title, $tabindex, $accesskey, $wrap); 
     * </code> 
     * @static
     * @param String $name      The name of the control
     * @param String $text      The text value, if any
     * @param String $rows      The number of rows
     * @param String $cols      The number of columns
     * @param String $class     The class name
     * @param String $tabindex  The tabindex
     * @param String $accesskey The accesskey
     * @param String $wrap      The wrap (virtual,physical,off)
     */
    
public static function start($name$text=''$rows=''$cols=''$class=''$title=''$tabindex=''$accesskey=''$wrap='') {
        
$html = new Textarea($name$text$rows$cols$class$title$tabindex$accesskey$wrap);
        
$html->addHtml($html->getStart());
    }

    
/**
     * Display end html
     * <code>
     * Usage:
     *    Textarea::end(); 
     * </code> 
     * @static
     */
    
public static function end() {
        
$html = new Textarea();
        
$html->addHtml($html->getEnd());
    }

    
/**
     * Display html
     * <code>
     * Usage:
     *    Textarea::display($name, $text, $rows, $cols, $class, $title, $tabindex, $accesskey, $wrap); 
     * </code> 
     * @static
     * @param String $name      The name of the control
     * @param String $text      The text value, if any
     * @param String $rows      The number of rows
     * @param String $cols      The number of columns
     * @param String $class     The class name
     * @param String $title     The title
     * @param String $tabindex  The tabindex
     * @param String $accesskey The accesskey
     * @param String $wrap      The wrap (virtual,physical,off)
     */
    
public static function display($name$text=''$rows=''$cols=''$class=''$title=''$tabindex=''$accesskey=''$wrap='') {
        
$html = new Textarea($name$text$rows$cols$class$title$tabindex$accesskey$wrap);
        
$html->addHtml();
    }
}
?>

Vis: HTML source code

Textarea, HTML source code

Den fulde HTML kildekode for Textarea klassen

<?
<!-- DEBUGTextarea -->
<
textarea name="Test" rows="5" cols="35" class="formXLARGE baseBorder baseBody" tabindex="1"></textarea><br />

?>

Vis: Class methods

Textarea, Class methods

Her er 'klasse metoderne' for Textarea klassen:

  • __construct
  • getStart
  • getEnd
  • getHtml
  • start
  • end
  • display
  • getValue
  • setId
  • setOnfocus
  • setOnblur
  • id
  • 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

Textarea, Object vars

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