From 71fff6e8d26333e63813d4e968c7335ee8a9a94e Mon Sep 17 00:00:00 2001 From: Cameron Date: Sat, 16 Jan 2016 11:56:26 -0800 Subject: [PATCH] AdminUI: Simple SEF generation option added. Usage: writeParms='sef=sourceField'. eg. writeParms='sef=news_title'. --- e107_admin/cpage.php | 2 +- e107_admin/newspost.php | 6 +----- e107_handlers/form_handler.php | 25 +++++++++++++++++++----- e107_plugins/download/includes/admin.php | 8 ++++---- 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/e107_admin/cpage.php b/e107_admin/cpage.php index ae6159744..9d894e904 100644 --- a/e107_admin/cpage.php +++ b/e107_admin/cpage.php @@ -488,7 +488,7 @@ class page_admin_ui extends e_admin_ui 'page_rating_flag' => array('title'=> LAN_RATING, 'tab' => 1, 'type' => 'boolean', 'data'=>'int', 'width' => '5%', 'thclass' => 'center', 'class' => 'center' ), 'page_comment_flag' => array('title'=> LAN_COMMENTS, 'tab' => 1, 'type' => 'boolean', 'data'=>'int', 'width' => '5%', 'thclass' => 'center', 'class' => 'center' ), 'page_password' => array('title'=> LAN_PASSWORD, 'tab' => 1, 'type' => 'text', 'data'=>'str', 'width' => 'auto', 'writeParms'=>array('password'=>1, 'nomask'=>1, 'size' => 40, 'class' => 'tbox e-password', 'generate' => 1, 'strength' => 1, 'required'=>0)), - 'page_sef' => array('title'=> LAN_SEFURL, 'tab' => 1, 'type' => 'text', 'inline'=>true, 'width' => 'auto', 'writeParms'=>'size=xxlarge'), + 'page_sef' => array('title'=> LAN_SEFURL, 'tab' => 1, 'type' => 'text', 'inline'=>true, 'width' => 'auto', 'writeParms'=>'size=xxlarge&sef=page_title'), 'page_metakeys' => array('title'=> LAN_KEYWORDS, 'tab' => 1, 'type' => 'tags', 'width' => 'auto'), 'page_metadscr' => array('title'=> CUSLAN_11, 'tab' => 1, 'type' => 'text', 'width' => 'auto', 'writeParms'=>'size=xxlarge'), diff --git a/e107_admin/newspost.php b/e107_admin/newspost.php index 850736164..7488277ec 100644 --- a/e107_admin/newspost.php +++ b/e107_admin/newspost.php @@ -403,7 +403,7 @@ class news_admin_ui extends e_admin_ui '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, 'writeParms'=>array('size'=>'xxlarge')), - 'news_sef' => array('title' => LAN_SEFURL, 'type' => 'text', 'tab'=>1, 'inline'=>true, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'writeParms'=>array('size'=>'xxlarge', 'show'=>1, 'tdClassRight'=>'form-inline')), + 'news_sef' => array('title' => LAN_SEFURL, 'type' => 'text', 'tab'=>1, 'inline'=>true, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'writeParms'=>array('size'=>'xxlarge', 'show'=>1, 'sef'=>'news_title')), 'news_ping' => array('title' => LAN_PING, 'type' => 'checkbox', 'tab'=>1, 'data'=>false, 'writeParms'=>'value=0', 'inline'=>true, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false), 'news_author' => array('title' => LAN_AUTHOR, 'type' => 'method', 'tab'=>0, 'readParms'=>'idField=user_id&nameField=user_name', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false), @@ -689,11 +689,7 @@ class news_admin_ui extends e_admin_ui } - - $this->fields['news_email_notify']['writeParms']['post'] = "".LAN_CONFIGURE.""; - $this->fields['news_sef']['writeParms']['post'] = "".LAN_GENERATE.""; - // e107::getMessage()->addDebug(print_a($_POST,true)); diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index 4f3770062..26f1b60f8 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -1263,7 +1263,7 @@ class e_form { if(is_string($options)) parse_str($options, $options); // auto-height support - + if(vartrue($options['size']) && !is_numeric($options['size'])) { $options['class'] .= " form-control input-".$options['size']; @@ -4040,7 +4040,7 @@ class e_form case 'number': $maxlength = vartrue($parms['maxlength'], 255); unset($parms['maxlength']); - if(!vartrue($parms['size'])) $parms['size'] = 'mini'; + if(!vartrue($parms['size'])) $parms['size'] = 'small'; if(!vartrue($parms['class'])) $parms['class'] = 'tbox number e-spinner '; if(!$value) $value = '0'; $ret = vartrue($parms['pre']).$this->number($key, $value, $maxlength, $parms).vartrue($parms['post']); @@ -4070,21 +4070,31 @@ class e_form $ret = vartrue($parms['pre']).$this->password($key, $value, $maxlength, $parms).vartrue($parms['post']); // vartrue($parms['__options']) is limited. See 'required'=>true break; - + case 'text': $maxlength = vartrue($parms['maxlength'], 255); unset($parms['maxlength']); + if(!empty($parms['sef'])) + { + $sefSource = $this->name2id($parms['sef']); + $sefTarget = $this->name2id($key); + $parms['tdClassRight'] .= 'input-group'; + $parms['post'] = "".LAN_GENERATE.""; + } + if(!empty($parms['password'])) // password mechanism without the md5 storage. { $ret = vartrue($parms['pre']).$this->password($key, $value, $maxlength, $parms).vartrue($parms['post']); } + else { $ret = vartrue($parms['pre']).$this->text($key, $value, $maxlength, $parms).vartrue($parms['post']); // vartrue($parms['__options']) is limited. See 'required'=>true } + if(!empty($attributes['multilan'])) { $ret = "".$ret.""; @@ -4717,6 +4727,8 @@ class e_form $label = vartrue($att['note']) ? '
'.deftrue($att['note'], $att['note']).'
' : ''; $help = vartrue($att['help']) ? '
'.deftrue($att['help'], $att['help']).'
' : ''; + + $valPath = trim(vartrue($att['dataPath'], $key), '/'); $keyName = $key; if(strpos($valPath, '/')) //not TRUE, cause string doesn't start with / @@ -4737,8 +4749,11 @@ class e_form { $writeParms = varset($att['writeParms']); } - - + + if(!empty($writeParms['sef'])) // group sef generate button with input element. + { + $writeParms['tdClassRight'] .= 'input-group'; + } if('hidden' === $att['type']) { diff --git a/e107_plugins/download/includes/admin.php b/e107_plugins/download/includes/admin.php index a5d02cd4e..0a6ec7396 100644 --- a/e107_plugins/download/includes/admin.php +++ b/e107_plugins/download/includes/admin.php @@ -236,7 +236,7 @@ class download_main_admin_ui extends e_admin_ui 'download_id' => array('title'=> ID, 'type' => 'number', 'data' => 'int', 'width'=>'5%', 'thclass' => '', 'forced'=> TRUE, 'primary'=>TRUE/*, 'noedit'=>TRUE*/), //Primary ID is not editable 'download_name' => array('title'=> LAN_TITLE, 'type' => 'text', 'data' => 'str', 'inline'=>true, 'width' => 'auto', 'thclass' => ''), 'download_url' => array('title'=> DOWLAN_13, 'type' => 'url', 'data' => 'str', 'width'=>'auto', 'thclass' => '', 'batch' => TRUE, 'filter'=>TRUE), - 'download_sef' => array('title'=> LAN_SEFURL, 'type' => 'text', 'inline'=>true, 'data' => 'str', 'width'=>'auto', 'thclass' => '', 'batch' => TRUE, 'filter'=>TRUE), + 'download_sef' => array('title'=> LAN_SEFURL, 'type' => 'text', 'inline'=>true, 'data' => 'str', 'width'=>'auto', 'thclass' => '', 'batch' => TRUE, 'filter'=>TRUE, 'writeParms'=>'sef=download_name'), 'download_keywords' => array('title'=> LAN_KEYWORDS, 'type' => 'tags', 'inline'=>true, 'data' => 'str', 'width'=>'auto', 'thclass' => ''), 'download_author' => array('title'=> LAN_AUTHOR, 'type' => 'user', 'data' => 'str', 'width' => 'auto', 'thclass' => 'left'), @@ -1342,7 +1342,7 @@ $columnInfo = array( ".DOWLAN_12." - toForm($download_name)."\" maxlength='200'/> + toForm($download_name)."\" maxlength='200'/> @@ -1447,8 +1447,8 @@ $columnInfo = array( ".LAN_SEFURL." - - toForm($download_sef)."\" maxlength='250'/> + + ".$frm->renderElement('download_sef',$download_sef, array('type'=>'text', 'writeParms'=>array('sef'=>'download_name','size'=>'xxlarge')))."