Skip to content

Commit

Permalink
Added option of the allowed HTML tags during the HTML clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
dziudek committed May 20, 2013
1 parent b31869b commit 53fd6fd
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
17 changes: 15 additions & 2 deletions mod_news_pro_gk5/helpers/gk.utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,21 @@ static function cutText($text, $config, $field, $at_end = FALSE) {
}
}
if($config['clean_xhtml'] == 1) {
$allowed_html = '';

if(strlen(trim($config['allowed_tags'])) > 0) {
$allowed_html = explode(',', $config['allowed_tags']);
$allowed_len = count($allowed_html);

for($i = 0; $i < $allowed_len; $i++) {
$allowed_html[$i] = '<' . $allowed_html[$i] . '>';
}

$allowed_html = implode('', $allowed_html);
}

if($limit_type == 'words' && $limit_value > 0){
$temp = explode(' ', strip_tags($text));
$temp = explode(' ', strip_tags($text, $allowed_html));

if(count($temp) > $limit_value){
for($i=0; $i<$limit_value; $i++) $cutted[$i] = $temp[$i];
Expand All @@ -44,7 +57,7 @@ static function cutText($text, $config, $field, $at_end = FALSE) {
return '';
} else {
if(JString::strlen($text) > $limit_value){
$text = JString::substr(strip_tags($text), 0, $limit_value) . $at_end;
$text = JString::substr(strip_tags($text, $allowed_html), 0, $limit_value) . $at_end;
}
}
} else {
Expand Down
2 changes: 2 additions & 0 deletions mod_news_pro_gk5/language/en-GB.mod_news_pro_gk5.ini
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,8 @@ MOD_NEWS_PRO_GK5_PAGINATION="Pagination"
MOD_NEWS_PRO_GK5_ARROWS_WITH_PAGINATION="Arrows with pagination"
MOD_NEWS_PRO_GK5_CLEANXHTML="Clean HTML code in the text"
MOD_NEWS_PRO_GK5_CLEANXHTML_DESC="Clean xhtml code from articles text. If this option is disabled then the engine used to clean HTML code will be used to avoid problems with the unclosed tags"
MOD_NEWS_PRO_GK5_ALLOWED_TAGS="Allowed HTML tags"
MOD_NEWS_PRO_GK5_ALLOWED_TAGS_DESC="You can specify the list of allowed HTML tags separated by comma (i.e. a,p,abbr) when the XHTML clean up is enabled"
MOD_NEWS_PRO_GK5_MORE_TEXT_VALUE="End of text"
MOD_NEWS_PRO_GK5_MORE_TEXT_VALUE_DESC="Value of end of the text added at the end of every text longer than limit"
MOD_NEWS_PRO_GK5_PARSE="Parse plugins"
Expand Down
2 changes: 2 additions & 0 deletions mod_news_pro_gk5/language/pl-PL.mod_news_pro_gk5.ini
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,8 @@ MOD_NEWS_PRO_GK5_PAGINATION="Paginacja"
MOD_NEWS_PRO_GK5_ARROWS_WITH_PAGINATION="Strzałki z paginacją"
MOD_NEWS_PRO_GK5_CLEANXHTML="Czyść kod HTML w tekście"
MOD_NEWS_PRO_GK5_CLEANXHTML_DESC="Usuwa kod HTML z tekstu artykułu. Jeżeli opcja ta jest wyłączona, wtedy zostanie użyty specjalny mechanizm do unikania problemów z niedomkniętymi tagami."
MOD_NEWS_PRO_GK5_ALLOWED_TAGS="Dozwolone tagi HTML"
MOD_NEWS_PRO_GK5_ALLOWED_TAGS_DESC="Pozwala określić listę dozwolonych tagów HTML rozdzielonych przecinkami (np. a,p,abbr) gdy czyszczenie tagów HTML jest włączone"
MOD_NEWS_PRO_GK5_MORE_TEXT_VALUE="Zakończenie tekstu"
MOD_NEWS_PRO_GK5_MORE_TEXT_VALUE_DESC="Określa ciąg znaków dodawany na końcu każdego tekstu dłuższego niż określony limit."
MOD_NEWS_PRO_GK5_PARSE="Parsuj pluginy"
Expand Down
1 change: 1 addition & 0 deletions mod_news_pro_gk5/mod_news_pro_gk5.xml
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@
<option value="0">MOD_NEWS_PRO_GK5_DISABLED</option>
<option value="1">MOD_NEWS_PRO_GK5_ENABLED</option>
</field>
<field name="allowed_tags" type="text" default="" size="20" label="MOD_NEWS_PRO_GK5_ALLOWED_TAGS" description="MOD_NEWS_PRO_GK5_ALLOWED_TAGS_DESC" class="gk-group-text" />
<field name="more_text_value" type="text" default="..." size="5" label="MOD_NEWS_PRO_GK5_MORE_TEXT_VALUE" description="MOD_NEWS_PRO_GK5_MORE_TEXT_VALUE_DESC" class="gk-group-text" />
<field name="parse_plugins" type="list" class="gk_switch gk-group-text" default="0" label="MOD_NEWS_PRO_GK5_PARSE" description="MOD_NEWS_PRO_GK5_PARSE_DESC">
<option value="1">MOD_NEWS_PRO_GK5_ENABLED</option>
Expand Down

0 comments on commit 53fd6fd

Please sign in to comment.