/** * Draws the html form element * * @param array $data To pre-populate element with * @param int $repeatCounter Repeat group counter * * @return string Elements html */ public function render($data, $repeatCounter = 0) { $name = $this->getHTMLName($repeatCounter); $id = $this->getHTMLId($repeatCounter); $element = $this->getElement(); if ($element->hidden == '1') { return $this->getHiddenField($name, $this->getValue($data, $repeatCounter), $id); } $params = $this->getParams(); $cols = $params->get('width', $element->width); $rows = $params->get('height', $element->height); $value = $this->getValue($data, $repeatCounter); $bits = array(); $bits['class'] = "fabrikinput inputbox " . $params->get('bootstrap_class'); $wysiwyg = $this->useWysiwyg(); if (!$this->isEditable()) { if ($params->get('textarea-tagify') == true) { $value = $this->tagify($value); } else { if (!$wysiwyg) { $value = nl2br($value); } if ($value !== '' && ((int) $params->get('textarea-truncate-where', 0) === 2 || (int) $params->get('textarea-truncate-where', 0) === 3)) { $opts = $this->truncateOpts(); $value = fabrikString::truncate($value, $opts); } } return $value; } if ($params->get('textarea_placeholder', '') !== '') { $bits['placeholder'] = $params->get('textarea_placeholder'); } if ($this->elementError != '') { $bits['class'] .= ' elementErrorHighlight'; } $layoutData = new stdClass(); $this->charsLeft($value, $layoutData); if ($wysiwyg) { $editor = JEditor::getInstance($this->config->get('editor')); $buttons = (bool) $params->get('wysiwyg_extra_buttons', true); $layoutData->editor = $editor->display($name, $value, $cols * 10, $rows * 15, $cols, $rows, $buttons, $id); $layout = $this->getLayout('wysiwyg'); } else { if ($params->get('disable')) { $bits['class'] .= " disabled"; $bits['disabled'] = 'disabled'; } if ($params->get('textarea-showmax') && $params->get('textarea_limit_type', 'char') === 'char') { $bits['maxlength'] = $params->get('textarea-maxlength'); } $bits['name'] = $name; $bits['id'] = $id; $bits['cols'] = $cols; $bits['rows'] = $rows; $layoutData->attributes = $bits; $layoutData->value = $value; $layout = $this->getLayout('form'); } return $layout->render($layoutData); }
function truncate($text, $opts = array()) { return fabrikString::truncate($data, $opts); }
/** * shows the data formatted for the table view * @param string data * @param object all the data in the tables current row * @return string formatted value */ function renderListData($data, $oAllRowsData) { $data = parent::renderListData($data, $oAllRowsData); $params = $this->getParams(); if ($params->get('textarea-tagify') == true) { $data = $this->tagify($data); } //$$$rob dont strip slashes here - this is done when saving to db now if ($params->get('use_wysiwyg', 0) == 0) { if (is_array($data)) { for ($i = 0; $i < count($data); $i++) { $data[$i] = nl2br($data[$i]); } } else { if (is_object($data)) { $this->convertDataToString($data); } $data = nl2br($data); } } if (!$params->get('textarea-tagify') && $data !== '' && (int) $params->get('textarea-truncate', 0) !== 0) { $opts = array(); $opts['wordcount'] = (int) $params->get('textarea-truncate', 0); $opts['tip'] = $params->get('textarea-hover'); $opts['position'] = $params->get('textarea_hover_location', 'top'); $data = fabrikString::truncate($data, $opts); } return $data; }