Exemple #1
0
 /**
  * Renders grid column
  *
  * @param Varien_Object $row
  * @return string
  */
 public function render(Varien_Object $row)
 {
     $line = parent::_getValue($row);
     $wrappedLine = '';
     $lineLength = $this->getColumn()->getData('lineLength') ? $this->getColumn()->getData('lineLength') : $this->_defaultMaxLineLength;
     for ($i = 0, $n = floor(Mage::helper('Mage_Core_Helper_String')->strlen($line) / $lineLength); $i <= $n; $i++) {
         $wrappedLine .= Mage::helper('Mage_Core_Helper_String')->substr($line, $lineLength * $i, $lineLength) . "<br />";
     }
     return $wrappedLine;
 }
Exemple #2
0
 /**
  * Render contents as a long text
  *
  * Text will be truncated as specified in string_limit, truncate or 250 by default
  * Also it can be html-escaped and nl2br()
  *
  * @param Varien_Object $row
  * @return string
  */
 public function render(Varien_Object $row)
 {
     $truncateLength = 250;
     // stringLength() is for legacy purposes
     if ($this->getColumn()->getStringLimit()) {
         $truncateLength = $this->getColumn()->getStringLimit();
     }
     if ($this->getColumn()->getTruncate()) {
         $truncateLength = $this->getColumn()->getTruncate();
     }
     $text = Mage::helper('Mage_Core_Helper_String')->truncate(parent::_getValue($row), $truncateLength);
     if ($this->getColumn()->getEscape()) {
         $text = $this->escapeHtml($text);
     }
     if ($this->getColumn()->getNl2br()) {
         $text = nl2br($text);
     }
     return $text;
 }
Exemple #3
0
 /**
  * Renders grid column
  *
  * @param Varien_Object $row
  * @return mixed
  */
 public function _getValue(Varien_Object $row)
 {
     $format = $this->getColumn()->getFormat() ? $this->getColumn()->getFormat() : null;
     $defaultValue = $this->getColumn()->getDefault();
     if (is_null($format)) {
         // If no format and it column not filtered specified return data as is.
         $data = parent::_getValue($row);
         $string = is_null($data) ? $defaultValue : $data;
         return $this->escapeHtml($string);
     } elseif (preg_match_all($this->_variablePattern, $format, $matches)) {
         // Parsing of format string
         $formattedString = $format;
         foreach ($matches[0] as $matchIndex => $match) {
             $value = $row->getData($matches[1][$matchIndex]);
             $formattedString = str_replace($match, $value, $formattedString);
         }
         return $formattedString;
     } else {
         return $this->escapeHtml($format);
     }
 }
Exemple #4
0
 /**
  * Renders CSS
  *
  * @return string
  */
 public function renderCss()
 {
     return parent::renderCss() . ' a-right';
 }
Exemple #5
0
 /**
  * Renders header of the column
  *
  * @return string
  */
 public function renderHeader()
 {
     if ($this->getColumn()->getHeader()) {
         return parent::renderHeader();
     }
     $checked = '';
     if ($filter = $this->getColumn()->getFilter()) {
         $checked = $filter->getValue() ? ' checked="checked"' : '';
     }
     $disabled = '';
     if ($this->getColumn()->getDisabled()) {
         $disabled = ' disabled="disabled"';
     }
     $html = '<input type="checkbox" ';
     $html .= 'name="' . $this->getColumn()->getFieldName() . '" ';
     $html .= 'onclick="' . $this->getColumn()->getGrid()->getJsObjectName() . '.checkCheckboxes(this)" ';
     $html .= 'class="checkbox"' . $checked . $disabled . ' ';
     $html .= 'title="' . Mage::helper('Mage_Backend_Helper_Data')->__('Select All') . '"/>';
     return $html;
 }