Skip to content

Commit

Permalink
Merge pull request #1350 from zau4man/html_teaser_options
Browse files Browse the repository at this point in the history
Более гибкая обрезка текста в поле html
  • Loading branch information
fuzegit authored Sep 2, 2021
2 parents e66ab35 + 164a6a3 commit 491fcab
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
26 changes: 22 additions & 4 deletions system/fields/html.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function getOptions(){
)),
new fieldCheckbox('is_html_filter', array(
'title' => LANG_PARSER_HTML_FILTERING,
'extended_option' => true
'extended_option' => true
)),
new fieldCheckbox('parse_patterns', array(
'title' => LANG_PARSER_PARSE_PATTERNS,
Expand All @@ -79,13 +79,28 @@ public function getOptions(){
new fieldNumber('teaser_len', array(
'title' => LANG_PARSER_HTML_TEASER_LEN,
'hint' => LANG_PARSER_HTML_TEASER_LEN_HINT,
'extended_option' => true
'extended_option' => true
)),
new fieldString('teaser_postfix', array(
'title' => LANG_PARSER_HTML_TEASER_POSTFIX,
'visible_depend' => array('options:teaser_len' => array('hide' => array(''))),
'extended_option' => true
)),
new fieldList('teaser_type', array(
'title' => LANG_PARSER_HTML_TEASER_TYPE,
'items' => array(
'' => LANG_PARSER_HTML_TEASER_TYPE_NULL,
's' => LANG_PARSER_HTML_TEASER_TYPE_S,
'w' => LANG_PARSER_HTML_TEASER_TYPE_W
),
'visible_depend' => array('options:teaser_len' => array('hide' => array(''))),
'extended_option' => true
)),
new fieldCheckbox('show_show_more', array(
'title' => LANG_PARSER_SHOW_SHOW_MORE,
'default' => false,
'visible_depend' => array('options:teaser_len' => array('hide' => array(''))),
'extended_option' => true
'extended_option' => true
)),
new fieldCheckbox('in_fulltext_search', array(
'title' => LANG_PARSER_IN_FULLTEXT_SEARCH,
Expand Down Expand Up @@ -142,7 +157,10 @@ public function parseTeaser($value) {

if ($max_len){

$value = string_short($value, $max_len);
$teaser_postfix = $this->getOption('teaser_postfix', '');
$teaser_type = $this->getOption('teaser_type', 's');

$value = string_short($value, $max_len, $teaser_postfix, $teaser_type);

if($this->getOption('show_show_more') && !empty($this->item['ctype']['name']) && !empty($this->item['slug'])){
$value .= '<span class="d-block mt-2"><a class="read-more btn btn-outline-info btn-sm" href="'.href_to($this->item['ctype']['name'], $this->item['slug'].'.html').'">'.LANG_MORE.'</a></span>';
Expand Down
5 changes: 5 additions & 0 deletions system/languages/en/language.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@
define('LANG_PARSER_BUILD_REDIRECT_LINK', 'External links via a redirect if sanitize input');
define('LANG_PARSER_HTML_TEASER_LEN', 'Truncate text length in list view');
define('LANG_PARSER_HTML_TEASER_LEN_HINT','The text will be truncated to a specified length, the formatting will be removed');
define('LANG_PARSER_HTML_TEASER_POSTFIX', 'Add text to the received line');
define('LANG_PARSER_HTML_TEASER_TYPE', 'Trim type');
define('LANG_PARSER_HTML_TEASER_TYPE_NULL','Cut anywhere');
define('LANG_PARSER_HTML_TEASER_TYPE_S', 'The last sentence');
define('LANG_PARSER_HTML_TEASER_TYPE_W', 'The latest word');
define('LANG_PARSER_SHOW_SHOW_MORE', 'Show "More" button');
define('LANG_PARSER_BBCODE', 'Textarea with BB-code');
define('LANG_PARSER_LIST', 'List');
Expand Down
5 changes: 5 additions & 0 deletions system/languages/ru/language.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@
define('LANG_PARSER_HTML_TEASER_LEN', 'Обрезать текст при просмотре списка');
define('LANG_PARSER_SHOW_SHOW_MORE', 'Показывать кнопку "Подробнее"');
define('LANG_PARSER_HTML_TEASER_LEN_HINT','Текст будет обрезан до указанной длины, форматирование будет удалено');
define('LANG_PARSER_HTML_TEASER_POSTFIX', 'Добавлять текст к полученной строке');
define('LANG_PARSER_HTML_TEASER_TYPE', 'Тип обрезки');
define('LANG_PARSER_HTML_TEASER_TYPE_NULL','Обрезать в любом месте');
define('LANG_PARSER_HTML_TEASER_TYPE_S', 'По последнему предложению');
define('LANG_PARSER_HTML_TEASER_TYPE_W', 'По последнему слову');
define('LANG_PARSER_BBCODE', 'Текст: BB-code');
define('LANG_PARSER_LIST', 'Список');
define('LANG_PARSER_LIST_FILTER_HINT', 'Номер варианта');
Expand Down

0 comments on commit 491fcab

Please sign in to comment.