- <?
- /**
- * @package form
- * @filesource
- * @see HTML_FORM_COMPONENT_PATH.'/Option.php'
- * @copyright (c) http://Finn-Rasmussen.com
- * @license http://Finn-Rasmussen.com/license/ myPHP License conditions
- * @author http://Finn-Rasmussen.com
- * @version 1.9
- * @since 21-oct-2005
- */
-
- /**
- * The required files
- */
- require_once(HTML_PATH.'/Html.php');
-
- /**
- * Generates an OPTION form element
- * <code>
- * Usage:
- * $option = new Option($text,$value,$selected,$title);
- * print $option->getHtml();
- * Or
- * Option::display($text,$value,$selected,$title);
- * </code>
- * @package form
- */
-
- class Option extends Html {
- var $text = ''; // The text to show
-
- var $value = ''; // The value of the element
-
- var $selected = ''; // The selcted state of the option
-
- var $title = ''; // The title
-
-
-
- /**
- * Constructor
- * @param String $text The text to show
- * @param String $value The value, if any
- * @param String $selected The option is selected
- * @param String $title The tooltip
- */
- function Option($text,$value='',$selected='',$title='') {
- $this->Html();
- $this->text = $text;
- $this->value = $value;
- $this->selected = $selected;
- $this->title = $title;
- }
-
- /**
- * Returns the html for the option control
- * @return String the complete html
- */
- function getHtml() {
- $html = $this->html;
- $html .= ' <option';
- $html .= $this->getAttribute('value');
- $html .= $this->getAttribute('selected');
- $html .= $this->getAttribute('title');
- $html .= '>';
- $html .= htmlspecialchars(stripslashes($this->text)); // Translate html special chars
- $html .= "</option>\r\n";
- return $html;
- }
-
- /**
- * Display html
- * <code>
- * Usage:
- * Option::display($text,$value,$selected,$title);
- * </code>
- * @param String $text The text to show
- * @param String $value The value, if any
- * @param String $selected The option is selected
- * @param String $title The tooltip
- */
- function display($text,$value='',$selected='',$title='') {
- $html = new Option($text,$value,$selected,$title);
- $html->addHtml();
- }
- }
- ?>