/** * 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; }
/** * Returns value of the row * * @param Varien_Object $row * @return mixed|string */ protected function _getValue(Varien_Object $row) { $data = parent::_getValue($row); if (!is_null($data)) { $value = $data * 1; $sign = (bool) (int) $this->getColumn()->getShowNumberSign() && $value > 0 ? '+' : ''; if ($sign) { $value = $sign . $value; } return $value ? $value : '0'; // fixed for showing zero in grid } return $this->getColumn()->getDefault(); }
/** * 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; }
/** * 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); } }