Prado\Web\UI\WebControls\TStyle::addAttributesToRender PHP Méthode

addAttributesToRender() public méthode

Adds attributes related to CSS styles to renderer.
public addAttributesToRender ( $writer )
    public function addAttributesToRender($writer)
    {
        if ($this->_customStyle !== null) {
            foreach (explode(';', $this->_customStyle) as $style) {
                $arr = explode(':', $style, 2);
                if (isset($arr[1]) && trim($arr[0]) !== '') {
                    $writer->addStyleAttribute(trim($arr[0]), trim($arr[1]));
                }
            }
        }
        $writer->addStyleAttributes($this->_fields);
        if ($this->_font !== null) {
            $this->_font->addAttributesToRender($writer);
        }
        if ($this->_class !== null) {
            $writer->addAttribute('class', $this->_class);
        }
    }

Usage Example

Exemple #1
0
 /**
  * Adds attributes related to CSS styles to renderer.
  * This method overrides the parent implementation.
  * @param THtmlWriter the writer used for the rendering purpose
  */
 public function addAttributesToRender($writer)
 {
     if (($url = trim($this->getBackImageUrl())) !== '') {
         $this->setStyleField('background-image', 'url(' . $url . ')');
     }
     switch ($this->getScrollBars()) {
         case TScrollBars::Horizontal:
             $this->setStyleField('overflow-x', 'scroll');
             break;
         case TScrollBars::Vertical:
             $this->setStyleField('overflow-y', 'scroll');
             break;
         case TScrollBars::Both:
             $this->setStyleField('overflow', 'scroll');
             break;
         case TScrollBars::Auto:
             $this->setStyleField('overflow', 'auto');
             break;
     }
     if (($align = $this->getHorizontalAlign()) !== THorizontalAlign::NotSet) {
         $this->setStyleField('text-align', strtolower($align));
     }
     if (!$this->getWrap()) {
         $this->setStyleField('white-space', 'nowrap');
     }
     if (($direction = $this->getDirection()) !== TContentDirection::NotSet) {
         if ($direction === TContentDirection::LeftToRight) {
             $this->setStyleField('direction', 'ltr');
         } else {
             $this->setStyleField('direction', 'rtl');
         }
     }
     parent::addAttributesToRender($writer);
 }
All Usage Examples Of Prado\Web\UI\WebControls\TStyle::addAttributesToRender