From c88fbb5c9a21a60bf2a78759e06711867edaa889 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sun, 2 Apr 2017 11:32:32 -0700 Subject: [PATCH] Closes #2528 Batch SEF generation added. --- e107_admin/cpage.php | 4 +- e107_admin/newspost.php | 2 +- e107_handlers/admin_ui.php | 95 +++++++++++++++++++++++- e107_plugins/download/includes/admin.php | 2 +- e107_plugins/forum/forum_admin.php | 2 +- 5 files changed, 96 insertions(+), 9 deletions(-) diff --git a/e107_admin/cpage.php b/e107_admin/cpage.php index ef1f50fee..894457c52 100644 --- a/e107_admin/cpage.php +++ b/e107_admin/cpage.php @@ -188,7 +188,7 @@ class page_chapters_ui extends e_admin_ui 'chapter_meta_description' => array('title'=> LAN_DESCRIPTION, 'type' => 'textarea', 'width' => 'auto', 'thclass' => 'left','readParms' => 'expand=...&truncate=150&bb=1', 'writeParms'=>'size=xxlarge', 'readonly'=>FALSE), 'chapter_meta_keywords' => array('title'=> LAN_KEYWORDS, 'type' => 'tags', 'inline'=>true, 'width' => 'auto', 'thclass' => 'left', 'readonly'=>FALSE), - 'chapter_sef' => array('title'=> LAN_SEFURL, 'type' => 'text', 'width' => 'auto', 'readonly'=>FALSE, 'inline'=>true, 'writeParms'=>'size=xxlarge&inline-empty=1&sef=chapter_name', ), // Display name + 'chapter_sef' => array('title'=> LAN_SEFURL, 'type' => 'text', 'width' => 'auto', 'readonly'=>FALSE, 'batch'=>true, 'inline'=>true, 'writeParms'=>'size=xxlarge&inline-empty=1&sef=chapter_name', ), // Display name 'chapter_manager' => array('title'=> CUSLAN_55, 'type' => 'userclass', 'inline'=>true, 'width' => 'auto', 'data' => 'int','batch'=>TRUE, 'filter'=>TRUE), 'chapter_order' => array('title'=> LAN_ORDER, 'type' => 'text', 'width' => 'auto', 'thclass' => 'right', 'class'=> 'right' ), 'chapter_visibility' => array('title'=> LAN_VISIBILITY, 'type' => 'userclass', 'inline'=>true, 'width' => 'auto', 'data' => 'int','batch'=>TRUE, 'filter'=>TRUE), @@ -583,7 +583,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', 'data'=>'str', 'inline'=>true, 'width' => 'auto', 'writeParms'=>'size=xxlarge&sef=page_title'), + 'page_sef' => array('title'=> LAN_SEFURL, 'tab' => 1, 'type' => 'text', 'batch'=>true, 'data'=>'str', 'inline'=>true, 'width' => 'auto', 'writeParms'=>'size=xxlarge&sef=page_title'), 'page_metakeys' => array('title'=> LAN_KEYWORDS, 'tab' => 1, 'type' => 'tags', 'data'=>'str', 'width' => 'auto'), 'page_metadscr' => array('title'=> CUSLAN_11, 'tab' => 1, 'type' => 'text', 'data'=>'str', 'width' => 'auto', 'writeParms'=>'size=xxlarge'), diff --git a/e107_admin/newspost.php b/e107_admin/newspost.php index 070390bd2..a38f61b08 100644 --- a/e107_admin/newspost.php +++ b/e107_admin/newspost.php @@ -440,7 +440,7 @@ class news_admin_ui extends e_admin_ui 'news_meta_keywords' => array('title' => LAN_KEYWORDS, 'type' => 'tags', 'data'=>'str', 'tab'=>1, 'inline'=>true, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false), 'news_meta_description' => array('title' => LAN_DESCRIPTION,'type' => 'textarea', 'data'=>'str', 'tab'=>1, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'writeParms'=>array('size'=>'xxlarge')), - 'news_sef' => array('title' => LAN_SEFURL, 'type' => 'text', 'data'=>'str', 'tab'=>1, 'inline'=>true, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'writeParms'=>array('size'=>'xxlarge', 'show'=>1, 'sef'=>'news_title')), + 'news_sef' => array('title' => LAN_SEFURL, 'type' => 'text', 'batch'=>1, 'data'=>'str', '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), diff --git a/e107_handlers/admin_ui.php b/e107_handlers/admin_ui.php index 3e704bb9c..bfc7fea18 100644 --- a/e107_handlers/admin_ui.php +++ b/e107_handlers/admin_ui.php @@ -3174,7 +3174,22 @@ class e_admin_controller_ui extends e_admin_controller switch($trigger[0]) { + case 'sefgen': + $field = $trigger[1]; + $value = $trigger[2]; + + //handleListBatch(); for custom handling of all field names + if(empty($selected)) return $this; + $method = 'handle'.$this->getRequest()->getActionName().'SefgenBatch'; + if(method_exists($this, $method)) // callback handling + { + $this->$method($selected, $field, $value); + } + break; + + case 'export': + if(empty($selected)) return $this; $method = 'handle'.$this->getRequest()->getActionName().'ExportBatch'; if(method_exists($this, $method)) // callback handling { @@ -4756,6 +4771,59 @@ class e_admin_ui extends e_admin_controller_ui } + /** + * Batch Export trigger + * @param array $selected + * @return void + */ + protected function handleListSefgenBatch($selected, $field, $value) + { + + $tree = $this->getTreeModel(); + $c= 0; + foreach($selected as $id) + { + if(!$tree->hasNode($id)) + { + e107::getMessage()->addError('Item #ID '.htmlspecialchars($id).' not found.'); + continue; + } + + $model = $tree->getNode($id); + + $name = $model->get($value); + + $sef = eHelper::title2sef($name,'dashl'); + + + + + + $model->set($field, $sef); + + + $model->save(); + + $data = $model->getData(); + + if($model->isModified()) + { + $this->getModel()->setData($data)->save(false,true); + $c++; + } + } + + + + $caption = e107::getParser()->lanVars(LAN_UI_BATCH_BOOL_SUCCESS, $c, true); + e107::getMessage()->addSuccess($caption); + + // e107::getMessage()->moveToSession(); + // redirect + // $this->redirect(); + } + + /** * Batch URL trigger @@ -5138,7 +5206,10 @@ class e_admin_ui extends e_admin_controller_ui { return; } - + + + + $cnt = $this->getTreeModel()->update($field, $val, $selected, true, false); if($cnt) { @@ -6287,7 +6358,8 @@ class e_admin_form_ui extends e_form 'copy' => $controller->getBatchCopy(), 'url' => $controller->getBatchLink(), 'featurebox' => $controller->getBatchFeaturebox(), - 'export' => $controller->getBatchExport() + 'export' => $controller->getBatchExport(), + ); @@ -6646,8 +6718,8 @@ class e_admin_form_ui extends e_form
"; $selectStart = "
- -
+ ".ADMIN_CHILD_ICON." +
".$this->select_open('etrigger_batch', array('class' => 'tbox form-control input-large select batch e-autosubmit reset', 'id' => false))." ".$this->option(LAN_BATCH_LABEL_SELECTED, '', false); @@ -6661,6 +6733,10 @@ class e_admin_form_ui extends e_form $selectOpt .= !empty($options['url']) ? $this->option(LAN_UI_BATCH_CREATELINK, 'url', false, array('class' => 'ui-batch-option class', 'other' => 'style="padding-left: 15px"')) : ''; $selectOpt .= !empty($options['featurebox']) ? $this->option(LAN_PLUGIN_FEATUREBOX_BATCH, 'featurebox', false, array('class' => 'ui-batch-option class', 'other' => 'style="padding-left: 15px"')) : ''; + // if(!empty($parms['sef']) + + + if(!empty($customBatchOptions)) { foreach($customBatchOptions as $key=>$val) @@ -6746,6 +6822,17 @@ class e_admin_form_ui extends e_form switch($val['type']) { + + case 'text'; + + if(!empty($parms['sef'])) + { + $option['sefgen__'.$key.'__'.$parms['sef']] = LAN_GENERATE; + } + + break; + + case 'bool': case 'boolean': //TODO modify description based on $val['parm] if(vartrue($parms['reverse'])) // reverse true/false values; diff --git a/e107_plugins/download/includes/admin.php b/e107_plugins/download/includes/admin.php index 0bc15bd73..e51444e91 100644 --- a/e107_plugins/download/includes/admin.php +++ b/e107_plugins/download/includes/admin.php @@ -150,7 +150,7 @@ class download_cat_ui extends e_admin_ui 'download_category_icon' => array('title'=> LAN_ICON, 'type' => 'method', 'width' => '5%', 'thclass' => 'center','class'=>'center','writeParms'=>'glyphs=1' ), 'download_category_id' => array('title'=> LAN_ID, 'type' => 'number', 'width' =>'5%', 'forced'=> TRUE, 'readParms'=>'link=sef&target=blank'), 'download_category_name' => array('title'=> LAN_TITLE, 'type' => 'text', 'data'=>'str', 'inline' => true, 'width' => 'auto', 'thclass' => 'left', 'writeParms'=>'size=xxlarge'), - 'download_category_sef' => array('title'=> LAN_SEFURL, 'type' => 'text', 'data'=>'str', 'inline' => true, 'width' => 'auto', 'thclass' => 'left', 'writeParms'=>'size=xxlarge'), + 'download_category_sef' => array('title'=> LAN_SEFURL, 'type' => 'text', 'data'=>'str', 'batch'=>true, 'inline' => true, 'width' => 'auto', 'thclass' => 'left', 'writeParms'=>'sef=download_category_name&size=xxlarge'), 'download_category_description' => array('title'=> LAN_DESCRIPTION, 'type' => 'bbarea', 'data'=>'str', 'width' => '30%', 'readParms' => 'expand=...&truncate=50&bb=1'), // Display name 'download_category_parent' => array('title'=> LAN_PARENT, 'type' => 'method', 'width' => '5%', 'batch' => TRUE, 'filter'=>TRUE), diff --git a/e107_plugins/forum/forum_admin.php b/e107_plugins/forum/forum_admin.php index f8492aa35..c2f21f6be 100644 --- a/e107_plugins/forum/forum_admin.php +++ b/e107_plugins/forum/forum_admin.php @@ -138,7 +138,7 @@ if(!deftrue('OLD_FORUMADMIN')) 'checkboxes' => array ( 'title' => '', 'type' => null, 'data' => null, 'width' => '5%', 'thclass' => 'center', 'forced' => '1', 'class' => 'center', 'toggle' => 'e-multiselect', ), 'forum_id' => array ( 'title' => LAN_ID, 'data' => 'int', 'width' => '5%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), 'forum_name' => array ( 'title' => LAN_TITLE, 'type' => 'method', 'inline'=>true, 'data' => 'str', 'width' => '40%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), - 'forum_sef' => array ( 'title' => LAN_SEFURL, 'type' => 'text', 'inline'=>true, 'noedit'=>false, 'data' => 'str', 'width' => 'auto', 'help' => 'Leave blank to auto-generate it from the title above.', 'readParms' => '', 'writeParms' => 'size=xxlarge', 'class' => 'left', 'thclass' => 'left', ), + 'forum_sef' => array ( 'title' => LAN_SEFURL, 'type' => 'text', 'batch'=>true, 'inline'=>true, 'noedit'=>false, 'data' => 'str', 'width' => 'auto', 'help' => 'Leave blank to auto-generate it from the title above.', 'readParms' => '', 'writeParms' => 'sef=forum_name&size=xxlarge', 'class' => 'left', 'thclass' => 'left', ), 'forum_description' => array ( 'title' => LAN_DESCRIPTION, 'type' => 'textarea', 'data' => 'str', 'width' => '30%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), 'forum_parent' => array ( 'title' => FORLAN_75, 'type' => 'dropdown', 'data' => 'int', 'width' => '10%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), 'forum_sub' => array ( 'title' => LAN_FORUM_1002, 'type' => 'dropdown', 'data' => 'int', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', ),