From ff896c52a0ac86e05af53c0e551247ea372d51ae Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 9 Jun 2015 15:46:45 -0700 Subject: [PATCH] Inline editing of keywords enabled on admin newspost. Fixes empty space between tags in database (causing issues with 'related' SQL queries). --- e107_admin/newspost.php | 2 +- e107_admin/update_routines.php | 8 ++++++-- e107_handlers/form_handler.php | 16 +++++++++++++--- e107_web/js/bootstrap-tag/bootstrap-tag.js | 4 ++-- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/e107_admin/newspost.php b/e107_admin/newspost.php index 42f84dab0..1d4d954f6 100644 --- a/e107_admin/newspost.php +++ b/e107_admin/newspost.php @@ -391,7 +391,7 @@ class news_admin_ui extends e_admin_ui 'news_body' => array('title' => "", 'type' => 'method', 'tab'=>0, 'nolist'=>true, 'writeParms'=>'nolabel=1','data'=>'str', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false), 'news_extended' => array('title' => "", 'type' => null, 'tab'=>0, 'nolist'=>true, 'writeParms'=>'nolabel=1','data'=>'str', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false), - 'news_meta_keywords' => array('title' => LAN_KEYWORDS, 'type' => 'tags', 'tab'=>1, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false), + 'news_meta_keywords' => array('title' => LAN_KEYWORDS, 'type' => 'tags', 'tab'=>1, 'inline'=>true, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false), 'news_meta_description' => array('title' => LAN_DESCRIPTION,'type' => 'textarea', 'tab'=>1, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false), 'news_sef' => array('title' => LAN_SEFURL, 'type' => 'text', 'tab'=>1, 'writeParms'=>'size=xxlarge', 'inline'=>true, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false), 'news_ping' => array('title' => LAN_PING, 'type' => 'checkbox', 'tab'=>1, 'data'=>false, 'writeParms'=>'value=0', 'inline'=>true, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false), diff --git a/e107_admin/update_routines.php b/e107_admin/update_routines.php index a51fa17d6..67df93166 100644 --- a/e107_admin/update_routines.php +++ b/e107_admin/update_routines.php @@ -1603,8 +1603,12 @@ function update_706_to_800($type='') e107::getSingleton('e107plugin')->refresh('page'); } - - + // Clean up news keywords. - remove spaces between commas. + if($sql->select('news', 'news_id', "news_meta_keywords LIKE '%, %' LIMIT 1")) + { + if ($just_check) return update_needed('News keywords contain spaces between commas and needs to be updated. '); + $sql->update('news', "news_meta_keywords = REPLACE(news_meta_keywords, ', ', ',')"); + } diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index cf0712e9b..6ea253e25 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -2748,6 +2748,8 @@ class e_form { return; } + + $tags = str_replace(', ',',', $tags); //BC Fix, all tags should be comma separated without spaces ie. one,two NOT one, two if(!varset($parm['limit'])) { @@ -3245,18 +3247,26 @@ class e_form if(empty($value)) { $value = '-'; - $emptyValue = "data-value=''"; + $setValue = "data-value=''"; } else { - $emptyValue = ""; + $setValue = ""; + + if($attributes['type'] == 'tags' && !empty($value)) + { + $setValue = "data-value='".$value."'"; + $value = str_replace(",", ", ", $value); // add spaces so it wraps, but don't change the actual values. + } } + + if(!vartrue($attributes['noedit']) && vartrue($parms['editable']) && !vartrue($parms['link'])) // avoid bad markup, better solution coming up { $mode = preg_replace('/[^\w]/', '', vartrue($_GET['mode'], '')); - $value = "".$value.""; + $value = "".$value.""; } $value = vartrue($parms['pre']).$value.vartrue($parms['post']); diff --git a/e107_web/js/bootstrap-tag/bootstrap-tag.js b/e107_web/js/bootstrap-tag/bootstrap-tag.js index 89eecdf6f..a9f8fbac7 100644 --- a/e107_web/js/bootstrap-tag/bootstrap-tag.js +++ b/e107_web/js/bootstrap-tag/bootstrap-tag.js @@ -138,13 +138,13 @@ this.values.push(value) this.createBadge(value) - this.element.val(this.values.join(', ')) + this.element.val(this.values.join(',')) } , remove: function ( index ) { if ( index >= 0 ) { this.values.splice(index, 1) this.element.siblings('.tag:eq(' + index + ')').remove() - this.element.val(this.values.join(', ')) + this.element.val(this.values.join(',')) } } , process: function () {