Skip to content

Commit

Permalink
Added truncating in details to textarea
Browse files Browse the repository at this point in the history
  • Loading branch information
cheesegrits committed Mar 18, 2014
1 parent f513ba3 commit 8c98d64
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
12 changes: 12 additions & 0 deletions plugins/fabrik_element/textarea/forms/fields.xml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,18 @@
<field type="helplink"
url="PLG_ELEMENT_TEXTAREA_HELP_SERVER" />

<field name="textarea-truncate-where"
type="radio"
default="0"
class="btn-group"
description="PLG_ELEMENT_TEXTAREA_TRUNCATE_WHERE_DESC"
label="PLG_ELEMENT_TEXTAREA_TRUNCATE_WHERE_LABEL">
<option value="0">JNO</option>
<option value="1">PLG_ELEMENT_TEXTAREA_TRUNCATE_WHERE_LIST</option>
<option value="2">PLG_ELEMENT_TEXTAREA_TRUNCATE_WHERE_DETAILS</option>
<option value="3">PLG_ELEMENT_TEXTAREA_TRUNCATE_WHERE_BOTH</option>
</field>

<field name="textarea-truncate"
type="text"
class="input-mini"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ PLG_ELEMENT_TEXTAREA_TAGIFY_LABEL="Tagify"
PLG_ELEMENT_TEXTAREA_TAGIFY_DESC="If yes selected then the data entered represents tags. Each tag entered should be separated with a comma. When rendered in the list view the tags are split into links which when click on will filter the list's data"
PLG_ELEMENT_TEXTAREA_TRUNCATE="Truncate"
PLG_ELEMENT_TEXTAREA_TRUNCATE_LABEL="Truncate size"
PLG_ELEMENT_TEXTAREA_TRUNCATE_DESC="The number of words to show from the text when in list view. Set as 0 to show all text. Note that HTML formatting is removed from the text when truncated"
PLG_ELEMENT_TEXTAREA_TRUNCATE_DESC="The number of words to show from the text when truncatng."
PLG_ELEMENT_TEXTAREA_TRUNCATE_WHERE_DESC="Truncate in either list view, detail view, both, or not at all. Note that HTML formatting is removed from the text when truncated"
PLG_ELEMENT_TEXTAREA_TRUNCATE_WHERE_LABEL="Truncate"
PLG_ELEMENT_TEXTAREA_TRUNCATE_WHERE_LIST="List"
PLG_ELEMENT_TEXTAREA_TRUNCATE_WHERE_DETAILS="Detail"
PLG_ELEMENT_TEXTAREA_TRUNCATE_WHERE_BOTH="Both"
PLG_ELEMENT_TEXTAREA_TAGIFY_URL_LABEL="Custom tagify URL"
PLG_ELEMENT_TEXTAREA_TAGIFY_URL_DESC="If left blank then the list's URL will be reloaded with the tag applied as a querystring (&foo=bar). If not blank, please enter a full URL including a '{tag}' placeholder. {tag} will be replaced with the element data's tag."
PLG_ELEMENT_TEXTAREA_WORDS="Words"
Expand Down
16 changes: 14 additions & 2 deletions plugins/fabrik_element/textarea/textarea.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@ public function renderListData($data, stdClass &$thisRow)
}
}

if (!$params->get('textarea-tagify') && $data !== '' && (int) $params->get('textarea-truncate', 0) !== 0)
if (!$params->get('textarea-tagify') && $data !== ''
&&
((int) $params->get('textarea-truncate-where', 0) === 1 || (int) $params->get('textarea-truncate-where', 0) === 3)
)
{
$opts = array();
$opts['wordcount'] = (int) $params->get('textarea-truncate', 0);
Expand Down Expand Up @@ -301,7 +304,16 @@ public function render($data, $repeatCounter = 0)
{
$value = $this->tagify($value);
}

if (!$params->get('textarea-tagify') && $value !== ''
&&
((int) $params->get('textarea-truncate-where', 0) === 2 || (int) $params->get('textarea-truncate-where', 0) === 3))
{
$opts = array();
$opts['wordcount'] = (int) $params->get('textarea-truncate', 0);
$opts['tip'] = $params->get('textarea-hover');
$opts['position'] = $params->get('textarea_hover_location', 'top');
$value = fabrikString::truncate($value, $opts);
}
return $value;
}

Expand Down

0 comments on commit 8c98d64

Please sign in to comment.