addAttributesToRender() protected method

By default, the method will render 'id', 'accesskey', 'disabled', 'tabindex', 'title' and all custom attributes. The method can be overriden to provide customized attribute rendering.
protected addAttributesToRender ( $writer )
示例#1
0
 /**
  * Adds attributes to renderer.
  * @param THtmlWriter the renderer
  * @throws TInvalidDataValueException if associated control cannot be found using the ID
  */
 protected function addAttributesToRender($writer)
 {
     if ($this->_forControl !== '') {
         $writer->addAttribute('for', $this->_forControl);
     }
     parent::addAttributesToRender($writer);
 }
示例#2
0
 /**
  * Adds attributes to renderer.
  * @param THtmlWriter the renderer
  * @throws TInvalidDataValueException if default button is not right.
  */
 protected function addAttributesToRender($writer)
 {
     parent::addAttributesToRender($writer);
     if (($butt = $this->getDefaultButton()) !== '') {
         $writer->addAttribute('id', $this->getClientID());
     }
 }
示例#3
0
 /**
  * Adds attributes to renderer.
  * @param THtmlWriter the renderer
  */
 protected function addAttributesToRender($writer)
 {
     if (!$this->getActive() && $this->getPage()->getClientSupportsJavaScript()) {
         $this->getStyle()->setStyleField('display', 'none');
     }
     $this->getStyle()->mergeWith($this->getParent()->getViewStyle());
     parent::addAttributesToRender($writer);
     $writer->addAttribute('id', $this->getClientID());
 }
示例#4
0
 /**
  * Adds attributes related to an HTML image element to renderer.
  * @param THtmlWriter the writer used for the rendering purpose
  */
 protected function addAttributesToRender($writer)
 {
     $writer->addAttribute('src', $this->getImageUrl());
     $writer->addAttribute('alt', $this->getAlternateText());
     if (($desc = $this->getDescriptionUrl()) !== '') {
         $writer->addAttribute('longdesc', $desc);
     }
     if (($align = $this->getImageAlign()) !== '') {
         $writer->addAttribute('align', $align);
     }
     parent::addAttributesToRender($writer);
 }
示例#5
0
 /**
  * Sets name attribute to the unique ID of the control.
  * This method overrides the parent implementation with additional file update control specific attributes.
  * @param THtmlWriter the writer used for the rendering purpose
  */
 protected function addAttributesToRender($writer)
 {
     $this->getPage()->ensureRenderInForm($this);
     parent::addAttributesToRender($writer);
     $writer->addAttribute('type', 'file');
     $writer->addAttribute('name', $this->getUniqueID());
     $isEnabled = $this->getEnabled(true);
     if (!$isEnabled && $this->getEnabled()) {
         // in this case parent will not render 'disabled'
         $writer->addAttribute('disabled', 'disabled');
     }
 }
示例#6
0
 /**
  * Adds attributes related to a hyperlink element to renderer.
  * @param THtmlWriter the writer used for the rendering purpose
  */
 protected function addAttributesToRender($writer)
 {
     $isEnabled = $this->getEnabled(true);
     if ($this->getEnabled() && !$isEnabled) {
         $writer->addAttribute('disabled', 'disabled');
     }
     parent::addAttributesToRender($writer);
     if (($url = $this->getNavigateUrl()) !== '' && $isEnabled) {
         $writer->addAttribute('href', $url);
     }
     if (($target = $this->getTarget()) !== '') {
         $writer->addAttribute('target', $target);
     }
 }
示例#7
0
 /**
  * Adds attribute name-value pairs to renderer.
  * This overrides the parent implementation with additional button specific attributes.
  * @param THtmlWriter the writer used for the rendering purpose
  */
 protected function addAttributesToRender($writer)
 {
     if ($this->getID() !== '') {
         $writer->addAttribute('name', $this->getUniqueID());
     }
     if (($src = $this->getFrameUrl()) !== '') {
         $writer->addAttribute('src', $src);
     }
     if (($align = strtolower($this->getAlign())) !== 'notset') {
         $writer->addAttribute('align', $align);
     }
     $scrollBars = $this->getScrollBars();
     if ($scrollBars === TInlineFrameScrollBars::None) {
         $writer->addAttribute('scrolling', 'no');
     } else {
         if ($scrollBars === TInlineFrameScrollBars::Both) {
             $writer->addAttribute('scrolling', 'yes');
         }
     }
     if (!$this->getShowBorder()) {
         $writer->addAttribute('frameborder', '0');
     }
     if (($longdesc = $this->getDescriptionUrl()) !== '') {
         $writer->addAttribute('longdesc', $longdesc);
     }
     if (($width = $this->getWidth()) !== -1) {
         $writer->addAttribute('width', $width);
     }
     if (($height = $this->getHeight()) !== -1) {
         $writer->addAttribute('height', $height);
     }
     if (($marginheight = $this->getMarginHeight()) !== -1) {
         $writer->addAttribute('marginheight', $marginheight);
     }
     if (($marginwidth = $this->getMarginWidth()) !== -1) {
         $writer->addAttribute('marginwidth', $marginwidth);
     }
     parent::addAttributesToRender($writer);
 }
示例#8
0
 /**
  * Adds attribute name-value pairs to renderer.
  * This overrides the parent implementation with additional button specific attributes.
  * @param THtmlWriter the writer used for the rendering purpose
  */
 protected function addAttributesToRender($writer)
 {
     $page = $this->getPage();
     $page->ensureRenderInForm($this);
     $writer->addAttribute('type', strtolower($this->getButtonType()));
     if (($uniqueID = $this->getUniqueID()) !== '') {
         $writer->addAttribute('name', $uniqueID);
     }
     if ($this->getButtonTag() === TButtonTag::Button) {
         $this->addParsedObject($this->getText());
     } else {
         $writer->addAttribute('value', $this->getText());
     }
     if ($this->getEnabled(true)) {
         if ($this->getEnableClientScript() && $this->needPostBackScript()) {
             $this->renderClientControlScript($writer);
         }
     } else {
         if ($this->getEnabled()) {
             // in this case, parent will not render 'disabled'
             $writer->addAttribute('disabled', 'disabled');
         }
     }
     parent::addAttributesToRender($writer);
 }
示例#9
0
 /**
  * Adds attributes to renderer.
  * @param THtmlWriter the renderer
  */
 protected function addAttributesToRender($writer)
 {
     parent::addAttributesToRender($writer);
     $border = 0;
     if ($this->getHasStyle()) {
         if ($this->getGridLines() !== TTableGridLines::None) {
             if (($border = $this->getBorderWidth()) === '') {
                 $border = 1;
             } else {
                 $border = (int) $border;
             }
         }
     }
     $writer->addAttribute('border', "{$border}");
 }
示例#10
0
 /**
  * Adds attributes to renderer.
  * @param THtmlWriter the renderer
  */
 protected function addAttributesToRender($writer)
 {
     parent::addAttributesToRender($writer);
     if (($colspan = $this->getColumnSpan()) > 0) {
         $writer->addAttribute('colspan', "{$colspan}");
     }
     if (($rowspan = $this->getRowSpan()) > 0) {
         $writer->addAttribute('rowspan', "{$rowspan}");
     }
 }
示例#11
0
 /**
  * Adds attributes to renderer.
  * @param THtmlWriter the renderer
  */
 protected function addAttributesToRender($writer)
 {
     $writer->addAttribute('id', $this->getClientID());
     $this->setCssClass($this->getCssClass());
     parent::addAttributesToRender($writer);
 }
示例#12
0
 /**
  * Add the specified css classes to the track
  * @param THtmlWriter writer
  */
 protected function addAttributesToRender($writer)
 {
     parent::addAttributesToRender($writer);
     $writer->addAttribute('id', $this->getClientID());
     if ($this->getCssClass() === '') {
         $class = $this->getDirection() == TSliderDirection::Horizontal ? 'HorizontalSlider' : 'VerticalSlider';
         $writer->addAttribute('class', 'Slider ' . $class);
     }
 }
示例#13
0
 /**
  * Adds attribute name-value pairs to renderer.
  * This method overrides the parent implementation with additional TKeyboard specific attributes.
  * @param THtmlWriter the writer used for the rendering purpose
  */
 protected function addAttributesToRender($writer)
 {
     parent::addAttributesToRender($writer);
     if ($this->getPage()->getClientSupportsJavaScript()) {
         $writer->addAttribute('id', $this->getClientID());
     }
 }
示例#14
0
 protected function addAttributesToRender($writer)
 {
     $display = $this->getDisplay();
     $visible = $this->getEnabled(true) && count($this->getErrorMessages()) > 0;
     if (!$visible) {
         if ($display === TValidationSummaryDisplayStyle::None || $display === TValidationSummaryDisplayStyle::Dynamic) {
             $writer->addStyleAttribute('display', 'none');
         } else {
             $writer->addStyleAttribute('visibility', 'hidden');
         }
     }
     $writer->addAttribute('id', $this->getClientID());
     parent::addAttributesToRender($writer);
 }
示例#15
0
 /**
  * Ensure that the ID attribute is rendered and registers the javascript code
  * for initializing the active control.
  */
 protected function addAttributesToRender($writer)
 {
     //calls the TWebControl to avoid rendering other attribute normally render for a textbox.
     TWebControl::addAttributesToRender($writer);
     $writer->addAttribute('id', $this->getLabelClientID());
     $this->getActiveControl()->registerCallbackClientScript($this->getClientClassName(), $this->getPostBackOptions());
 }
示例#16
0
 /**
  * Adds attribute name-value pairs to renderer.
  * This method overrides the parent implementation with additional textbox specific attributes.
  * @param THtmlWriter the writer used for the rendering purpose
  */
 protected function addAttributesToRender($writer)
 {
     $page = $this->getPage();
     $page->ensureRenderInForm($this);
     if (($uid = $this->getUniqueID()) !== '') {
         $writer->addAttribute('name', $uid);
     }
     if (($textMode = $this->getTextMode()) === TTextBoxMode::MultiLine) {
         if (($rows = $this->getRows()) <= 0) {
             $rows = self::DEFAULT_ROWS;
         }
         if (($cols = $this->getColumns()) <= 0) {
             $cols = self::DEFAULT_COLUMNS;
         }
         $writer->addAttribute('rows', "{$rows}");
         $writer->addAttribute('cols', "{$cols}");
         if (!$this->getWrap()) {
             $writer->addAttribute('wrap', 'off');
         }
     } else {
         switch ($textMode) {
             case TTextBoxMode::Password:
                 $writer->addAttribute('type', 'password');
                 break;
             case TTextBoxMode::Color:
                 $writer->addAttribute('type', 'color');
                 break;
             case TTextBoxMode::Date:
                 $writer->addAttribute('type', 'date');
                 break;
             case TTextBoxMode::Datetime:
                 $writer->addAttribute('type', 'datetime');
                 break;
             case TTextBoxMode::DatetimeLocal:
                 $writer->addAttribute('type', 'datetime-local');
                 break;
             case TTextBoxMode::Email:
                 $writer->addAttribute('type', 'email');
                 break;
             case TTextBoxMode::Month:
                 $writer->addAttribute('type', 'month');
                 break;
             case TTextBoxMode::Number:
                 $writer->addAttribute('type', 'number');
                 break;
             case TTextBoxMode::Range:
                 $writer->addAttribute('type', 'range');
                 break;
             case TTextBoxMode::Search:
                 $writer->addAttribute('type', 'search');
                 break;
             case TTextBoxMode::Tel:
                 $writer->addAttribute('type', 'tel');
                 break;
             case TTextBoxMode::Time:
                 $writer->addAttribute('type', 'time');
                 break;
             case TTextBoxMode::Url:
                 $writer->addAttribute('type', 'url');
                 break;
             case TTextBoxMode::Week:
                 $writer->addAttribute('type', 'week');
                 break;
             case TTextBoxMode::SingleLine:
             default:
                 $writer->addAttribute('type', 'text');
                 break;
         }
         if (($text = $this->getText()) !== '' && ($textMode !== TTextBoxMode::Password || $this->getPersistPassword())) {
             $writer->addAttribute('value', $text);
         }
         if (($act = $this->getAutoCompleteType()) !== 'None') {
             if ($act === 'Disabled') {
                 $writer->addAttribute('autocomplete', 'off');
             } else {
                 if ($act === 'Search') {
                     $writer->addAttribute('vcard_name', 'search');
                 } else {
                     if ($act === 'HomeCountryRegion') {
                         $writer->addAttribute('vcard_name', 'HomeCountry');
                     } else {
                         if ($act === 'BusinessCountryRegion') {
                             $writer->addAttribute('vcard_name', 'BusinessCountry');
                         } else {
                             if (strpos($act, 'Business') === 0) {
                                 $act = 'Business' . '.' . substr($act, 8);
                             } else {
                                 if (strpos($act, 'Home') === 0) {
                                     $act = 'Home' . '.' . substr($act, 4);
                                 }
                             }
                             $writer->addAttribute('vcard_name', 'vCard.' . $act);
                         }
                     }
                 }
             }
         }
         if (($cols = $this->getColumns()) > 0) {
             $writer->addAttribute('size', "{$cols}");
         }
         if (($maxLength = $this->getMaxLength()) > 0) {
             $writer->addAttribute('maxlength', "{$maxLength}");
         }
     }
     if ($this->getReadOnly()) {
         $writer->addAttribute('readonly', 'readonly');
     }
     $isEnabled = $this->getEnabled(true);
     if (!$isEnabled && $this->getEnabled()) {
         // in this case parent will not render 'disabled'
         $writer->addAttribute('disabled', 'disabled');
     }
     if ($isEnabled && $this->getEnableClientScript() && ($this->getAutoPostBack() || $textMode === TTextBoxMode::SingleLine) && $page->getClientSupportsJavaScript()) {
         $this->renderClientControlScript($writer);
     }
     parent::addAttributesToRender($writer);
 }
示例#17
0
 /**
  * Adds attribute name-value pairs to renderer.
  * This overrides the parent implementation with additional button specific attributes.
  * @param THtmlWriter the writer used for the rendering purpose
  */
 protected function addAttributesToRender($writer)
 {
     $page = $this->getPage();
     $page->ensureRenderInForm($this);
     $writer->addAttribute('id', $this->getClientID());
     // We call parent implementation here because some attributes
     // may be overwritten in the following
     parent::addAttributesToRender($writer);
     if ($this->getEnabled(true) && $this->getEnableClientScript()) {
         $this->renderLinkButtonHref($writer);
         $this->renderClientControlScript($writer);
     } else {
         if ($this->getEnabled()) {
             // in this case, parent will not render 'disabled'
             $writer->addAttribute('disabled', 'disabled');
         }
     }
 }