Overview

Packages

  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Datatype
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationMain
    • NavigationTop
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • cHTML
  • cHTMLAlignmentTable
  • cHTMLArticle
  • cHTMLAside
  • cHTMLAudio
  • cHTMLButton
  • cHTMLCanvas
  • cHTMLCheckbox
  • cHTMLContentElement
  • cHTMLDiv
  • cHTMLFieldset
  • cHTMLFooter
  • cHTMLForm
  • cHTMLFormElement
  • cHTMLHeader
  • cHTMLHgroup
  • cHTMLHiddenField
  • cHTMLIFrame
  • cHTMLImage
  • cHTMLLabel
  • cHTMLLegend
  • cHTMLLink
  • cHTMLList
  • cHTMLListItem
  • cHTMLNav
  • cHTMLOptgroup
  • cHTMLOptionElement
  • cHTMLParagraph
  • cHTMLPasswordbox
  • cHTMLRadiobutton
  • cHTMLScript
  • cHTMLSection
  • cHTMLSelectElement
  • cHTMLSpan
  • cHTMLTable
  • cHTMLTableBody
  • cHTMLTableData
  • cHTMLTableHead
  • cHTMLTableHeader
  • cHTMLTableRow
  • cHTMLTextarea
  • cHTMLTextbox
  • cHTMLTime
  • cHTMLUpload
  • cHTMLVideo
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: /**
  3:  * This file contains the cHTMLOptionElement class.
  4:  *
  5:  * @package Core
  6:  * @subpackage GUI_HTML
  7:  * @version SVN Revision $Rev:$
  8:  *
  9:  * @author Simon Sprankel
 10:  * @copyright four for business AG <www.4fb.de>
 11:  * @license http://www.contenido.org/license/LIZENZ.txt
 12:  * @link http://www.4fb.de
 13:  * @link http://www.contenido.org
 14:  */
 15: 
 16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 17: 
 18: /**
 19:  * cHTMLOptionElement class represents a select option element.
 20:  *
 21:  * @package Core
 22:  * @subpackage GUI_HTML
 23:  */
 24: class cHTMLOptionElement extends cHTMLFormElement {
 25: 
 26:     /**
 27:      * Title to display
 28:      *
 29:      * @var string
 30:      */
 31:     protected $_title;
 32: 
 33:     /**
 34:      * Constructor.
 35:      * Creates an HTML option element.
 36:      *
 37:      * @param string $title Displayed title of the element
 38:      * @param string $value Value of the option
 39:      * @param bool $selected If true, element is selected
 40:      * @param bool $disabled If true, element is disabled
 41:      * @param string $class the class of this element
 42:      * @return void
 43:      */
 44:     public function __construct($title, $value, $selected = false, $disabled = false, $class = '') {
 45:         cHTML::__construct();
 46:         $this->_tag = 'option';
 47:         $this->_title = $title;
 48: 
 49:         $this->updateAttribute('value', $value);
 50:         $this->_contentlessTag = false;
 51: 
 52:         $this->setSelected($selected);
 53:         $this->setDisabled($disabled);
 54:         $this->setClass($class);
 55:     }
 56: 
 57:     /**
 58:      * Sets the selected flag
 59:      *
 60:      * @param bool $selected If true, adds the "selected" attribute
 61:      * @return cHTMLOptionElement $this
 62:      */
 63:     public function setSelected($selected) {
 64:         if ($selected == true) {
 65:             return $this->updateAttribute('selected', 'selected');
 66:         } else {
 67:             return $this->removeAttribute('selected');
 68:         }
 69:     }
 70: 
 71:     /**
 72:      * Checks whether this option element is selected.
 73:      *
 74:      * @return bool whether this option element is selected
 75:      */
 76:     public function isSelected() {
 77:         return $this->getAttribute('selected') === 'selected';
 78:     }
 79: 
 80:     /**
 81:      * Sets the disabled flag
 82:      *
 83:      * @param bool $disabled If true, adds the "disabled" attribute
 84:      * @return cHTMLOptionElement $this
 85:      */
 86:     public function setDisabled($disabled) {
 87:         if ($disabled == true) {
 88:             return $this->updateAttribute('disabled', 'disabled');
 89:         } else {
 90:             return $this->removeAttribute('disabled');
 91:         }
 92:     }
 93: 
 94:     /**
 95:      * Renders the option element.
 96:      * Note:
 97:      * the cHTMLSelectElement renders the options by itself.
 98:      *
 99:      * @return string Rendered HTML
100:      */
101:     public function toHtml() {
102:         $this->_setContent($this->_title);
103: 
104:         return parent::toHTML();
105:     }
106: 
107: }
108: 
CMS CONTENIDO 4.9.0 API documentation generated by ApiGen 2.8.0