Skip to content

Commit

Permalink
Fixed the problem where CP bullet list cannot have duplicate items
Browse files Browse the repository at this point in the history
  • Loading branch information
slackero committed Jan 29, 2017
1 parent 58005cb commit f5d0aa4
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
3 changes: 1 addition & 2 deletions include/inc_front/content/cnt4.article.inc.php
Expand Up @@ -42,8 +42,7 @@
$crow["acontent_template"] = render_cnt_template($crow["acontent_template"], 'TITLE', html($crow['acontent_title']));
$crow["acontent_template"] = render_cnt_template($crow["acontent_template"], 'SUBTITLE', html($crow['acontent_subtitle']));

$crow['bullets'] = convertStringToArray($crow["acontent_text"], LF);

$crow['bullets'] = convertStringToArray($crow["acontent_text"], LF, false);

if(count($crow['bullets'])) {

Expand Down
1 change: 1 addition & 0 deletions include/inc_lang/backend/de/lang.inc.php
Expand Up @@ -1465,3 +1465,4 @@
$BL['be_suppress_render_caption'] = 'Ausgabe der Bildunterschrift unterdrücken';
$BL['be_cnt_attribute_class'] = 'CSS Klasse [class]';
$BL['be_cnt_attribute_id'] = 'CSS ID [id]';
$BL['be_cnt_avoid_duplicates'] = 'allow unique values only';
1 change: 1 addition & 0 deletions include/inc_lang/backend/en/lang.inc.php
Expand Up @@ -1474,3 +1474,4 @@
$BL['be_suppress_render_caption'] = 'suppress rendering of the caption';
$BL['be_cnt_attribute_class'] = 'CSS class';
$BL['be_cnt_attribute_id'] = 'CSS id';
$BL['be_cnt_avoid_duplicates'] = 'Nur eindeutige Werte zulassen';
2 changes: 1 addition & 1 deletion include/inc_lib/content/cnt4.readform.inc.php
Expand Up @@ -17,7 +17,7 @@
// ----------------------------------------------------------------

// Content Type Bullet List Table
$content["text"] = html_specialchars(slweg($_POST["ctext"], 65500));
$content["text"] = html(slweg($_POST["ctext"], 65500));
$cbullet = explode(LF, $content["text"]);
if(count($cbullet)) {
foreach($cbullet as $key => $value) {
Expand Down
12 changes: 8 additions & 4 deletions include/inc_lib/general.inc.php
Expand Up @@ -1053,13 +1053,17 @@ function getJavaScriptSourceLink($src, $prefix=' ') {

function convertStringToArray($string='', $seperator=',', $mode='UNIQUE', $rmvDblWSp=true) {
// clean up a seperator seperated string and return as array
if(trim($string) == '') return array();
if(trim($string) === '') {
return array();
}
// replace all duplicate white chars by single space
if($rmvDblWSp) $string = preg_replace('/\s\s+/', ' ', $string);
if($rmvDblWSp) {
$string = preg_replace('/\s\s+/', ' ', $string);
}
$string = explode($seperator, $string);
$string = array_map('trim', $string);
$string = array_diff($string, array('',NULL,false));
if($mode=='UNIQUE') {
$string = array_diff($string, array('', NULL, false));
if($mode === 'UNIQUE') {
$string = array_unique($string);
}
return $string;
Expand Down

0 comments on commit f5d0aa4

Please sign in to comment.