From a01e9933e4ea0cbb40c66b29b553cf32026996c4 Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 26 Feb 2013 16:08:08 -0800 Subject: [PATCH] Admin-ui - Support for link-targets (modal, dialog or blank) and batch site-link creation. ( Issue #8 ) --- e107_admin/cpage.php | 21 ++--- e107_admin/links.php | 10 ++- e107_admin/newspost.php | 7 +- e107_handlers/admin_ui.php | 46 +++++++++-- e107_handlers/form_handler.php | 24 ++++-- e107_handlers/model_class.php | 94 ++++++++++++++++++++++ e107_languages/English/admin/lan_admin.php | 85 +++++++++---------- 7 files changed, 218 insertions(+), 69 deletions(-) diff --git a/e107_admin/cpage.php b/e107_admin/cpage.php index 3b147c4c2..ae690b8ff 100644 --- a/e107_admin/cpage.php +++ b/e107_admin/cpage.php @@ -182,12 +182,12 @@ class menu_admin_ui extends e_admin_ui protected $batchCopy = true; // protected $sortField = 'page_order'; protected $orderStep = 10; - protected $itemRoute = 'page/view?page_id=page_id&page_sef=page_sef'; + protected $url = 'page/view'; protected $fields = array( 'checkboxes' => array('title'=> '', 'type' => null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center'), - 'page_id' => array('title'=> 'ID', 'tab' => 0, 'width'=>'5%', 'forced'=> TRUE), + 'page_id' => array('title'=> 'ID', 'type'=>'text', 'tab' => 0, 'width'=>'5%', 'readParms'=>'link=sef&dialog=1','forced'=> TRUE), 'page_theme' => array('title'=> "Menu Name", 'tab' => 0, 'type' => 'text', 'width' => 'auto','nolist'=>true), 'page_title' => array('title'=> LAN_TITLE, 'tab' => 0, 'type' => 'text', 'width'=>'25%','readParms'=>'link={e_BASE}page.php?[id]&dialog=1'), @@ -229,11 +229,11 @@ class menu_form_ui extends e_admin_form_ui // MAIN Pages. class page_admin_ui extends e_admin_ui { - protected $pluginTitle = ADLAN_42; - protected $pluginName = 'core'; - protected $table = "page"; + protected $pluginTitle = ADLAN_42; + protected $pluginName = 'core'; + protected $table = "page"; - protected $listQry = "SELECT p.*,u.user_id,u.user_name FROM #page AS p LEFT JOIN #user AS u ON p.page_author = u.user_id WHERE p.page_theme = '' "; // without any Order or Limit. + protected $listQry = "SELECT p.*,u.user_id,u.user_name FROM #page AS p LEFT JOIN #user AS u ON p.page_author = u.user_id WHERE p.page_theme = '' "; // without any Order or Limit. //protected $editQry = "SELECT * FROM #comments WHERE comment_id = {ID}"; protected $pid = "page_id"; @@ -241,18 +241,19 @@ class page_admin_ui extends e_admin_ui protected $perPage = 10; protected $batchDelete = true; protected $batchCopy = true; + protected $batchLink = true; protected $sortField = 'page_order'; protected $orderStep = 10; - protected $itemRoute = 'page/view?page_id=page_id&page_sef=page_sef'; + protected $url = array('profile'=>'page/view', 'name' => 'page_title', 'description' => '', 'link'=>'{e_BASE}page.php?id=[id]'); // 'link' only needed if profile not provided. protected $tabs = array("Main","Advanced"); // protected $listSorting = true; protected $fields = array( 'checkboxes' => array('title'=> '', 'type' => null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center'), - 'page_id' => array('title'=> LAN_ID, 'tab' => 0, 'width'=>'5%', 'forced'=> TRUE), + 'page_id' => array('title'=> LAN_ID, 'type' => 'text', 'tab' => 0, 'width'=>'5%', 'forced'=> TRUE, 'readParms'=>'link=sef&target=dialog'), 'page_chapter' => array('title'=> 'Book/Chapter', 'tab' => 0, 'type' => 'dropdown', 'width' => '20%', 'filter' => true, 'batch'=>true, 'inline'=>true), - 'page_title' => array('title'=> LAN_TITLE, 'tab' => 0, 'type' => 'text', 'width'=>'25%','readParms'=>'link={e_BASE}page.php?[id]&dialog=1'), + 'page_title' => array('title'=> LAN_TITLE, 'tab' => 0, 'type' => 'text', 'inline'=>true, 'width'=>'25%'), 'page_theme' => array('title'=> LAN_TYPE, 'tab' => 0, 'type' => 'text', 'width' => 'auto','nolist'=>true, 'noedit'=>true), 'page_template' => array('title'=> LAN_TEMPLATE, 'tab' => 0, 'type' => 'dropdown', 'width' => 'auto','filter' => true, 'batch'=>true, 'inline'=>true, 'writeParms'=>''), @@ -260,7 +261,7 @@ class page_admin_ui extends e_admin_ui 'page_text' => array('title'=> CUSLAN_9, 'tab' => 0, 'type' => 'bbarea', 'data'=>'str', 'width' => '30%', 'readParms' => 'expand=...&truncate=50&bb=1', 'writeParms'=>'media=page'), 'page_datestamp' => array('title'=> LAN_DATE, 'tab' => 1, 'type' => 'datestamp', 'data'=>'int', 'width' => 'auto','writeParms'=>'auto=1'), - 'page_class' => array('title'=> LAN_USERCLASS, 'tab' => 1, 'type' => 'userclass', 'data'=>'int', 'width' => 'auto', 'filter' => true, 'batch' => true), + 'page_class' => array('title'=> LAN_USERCLASS, 'tab' => 1, 'type' => 'userclass', 'data'=>'int', 'inline'=>true, 'width' => 'auto', 'filter' => true, 'batch' => true), 'page_rating_flag' => array('title'=> LAN_RATING, 'tab' => 1, 'type' => 'boolean', 'data'=>'int', 'width' => '5%', 'thclass' => 'center', 'class' => 'center' ), 'page_comment_flag' => array('title'=> ADLAN_114, 'tab' => 1, 'type' => 'boolean', 'data'=>'int', 'width' => '5%', 'thclass' => 'center', 'class' => 'center' ), // 'page_password' => array('title'=> LXAN_USER_05, 'type' => 'text', 'width' => 'auto'), diff --git a/e107_admin/links.php b/e107_admin/links.php index 6e77aa2ca..6eb396ee0 100644 --- a/e107_admin/links.php +++ b/e107_admin/links.php @@ -80,12 +80,13 @@ class links_admin_ui extends e_admin_ui 'link_button' => array('title'=> LAN_ICON, 'type'=>'icon', 'width'=>'5%', 'thclass' => 'center', 'class'=>'center'), 'link_id' => array('title'=> LAN_ID, 'noedit'=>TRUE), 'link_name' => array('title'=> LCLAN_15, 'width'=>'auto','type'=>'text', 'inline'=>true, 'required' => true, 'validate' => true), - 'link_parent' => array('title'=> 'Sublink of', 'type' => 'method', 'width' => 'auto', 'batch'=>true, 'filter'=>true, 'thclass' => 'left first'), + 'link_category' => array('title'=> LAN_TEMPLATE, 'type' => 'dropdown', 'inline'=>true, 'batch'=>true, 'filter'=>true, 'width' => 'auto'), + + 'link_parent' => array('title'=> 'Sublink of', 'type' => 'method', 'width' => 'auto', 'batch'=>true, 'filter'=>true, 'thclass' => 'left first'), 'link_url' => array('title'=> LAN_URL, 'width'=>'auto', 'type'=>'text', 'inline'=>true, 'required'=>true,'validate' => true), - 'link_sefurl' => array('title'=> LAN_SEFURL, 'type' => 'text', 'inline'=>true, 'width' => 'auto'), + // 'link_sefurl' => array('title'=> LAN_SEFURL, 'type' => 'text', 'inline'=>true, 'width' => 'auto'), 'link_class' => array('title'=> LAN_USERCLASS, 'type' => 'userclass','inline'=>true, 'writeParms' => 'classlist=public,guest,nobody,member,classes,admin,main', 'batch'=>true, 'filter'=>true, 'width' => 'auto'), 'link_description' => array('title'=> LAN_DESCRIPTION, 'type' => 'textarea', 'width' => 'auto'), // 'method'=>'tinymce_plugins', ? - 'link_category' => array('title'=> LAN_TEMPLATE, 'type' => 'dropdown', 'inline'=>true, 'batch'=>true, 'filter'=>true, 'width' => 'auto'), 'link_order' => array('title'=> LAN_ORDER, 'type' => 'number', 'width' => 'auto', 'nolist'=>true), 'link_open' => array('title'=> LCLAN_19, 'type' => 'dropdown', 'inline'=>true, 'width' => 'auto', 'batch'=>true, 'filter'=>true, 'thclass' => 'left first'), 'link_function' => array('title'=> 'Function', 'type' => 'method', 'data'=>'str', 'width' => 'auto', 'thclass' => 'left first'), @@ -115,11 +116,12 @@ class links_admin_ui extends e_admin_ui 3 => "3 - Footer", 4 => "4 - Alt", 5 => "5 - Alt", - // 6 => "6 - Alt", // If more than 5 are required, then something is not right with the themeing method. + 6 => "6 - Alt", // If more than 6 are required, then something is not right with the themeing method. // 7 => "7 - Alt", // 8 => "8 - Alt", // 9 => "9 - Alt", // 10 => "10 - Alt" + 255 => "(Unassigned)", ); $this->fields['link_open']['writeParms'] = array( diff --git a/e107_admin/newspost.php b/e107_admin/newspost.php index 8bfe04883..bc3d4c6d2 100644 --- a/e107_admin/newspost.php +++ b/e107_admin/newspost.php @@ -349,16 +349,19 @@ class news_admin_ui extends e_admin_ui protected $perPage = 10; //no limit protected $batchDelete = true; protected $batchCopy = true; + protected $batchLink = true; protected $listOrder = "news_id desc"; + protected $url = array('profile'=>'news/view/item', 'name' => 'news_title', 'description' => 'news_summary', 'link'=>'{e_BASE}news.php?extend.[id]'); // 'link' only needed if profile not provided. + protected $listQry = "SELECT n.*,u.user_id,u.user_name FROM #news AS n LEFT JOIN #user AS u ON n.news_author = u.user_id "; // without any Order or Limit. protected $fields = array( 'checkboxes' => array('title' => '', 'type' => null, 'width' => '3%', 'thclass' => 'center first', 'class' => 'center', 'nosort' => true, 'toggle' => 'news_selected', 'forced' => TRUE), - 'news_id' => array('title' => LAN_NEWS_45, 'type' => 'number', 'width' => '5%', 'thclass' => 'center', 'class' => 'center', 'nosort' => false), + 'news_id' => array('title' => LAN_NEWS_45, 'type' => 'text', 'width' => '5%', 'thclass' => 'center', 'class' => 'center', 'nosort' => false, 'readParms'=>'link=sef&target=blank'), 'news_thumbnail' => array('title' => NWSLAN_67, 'type' => 'method', 'width' => '110px', 'thclass' => 'center', 'class' => "center", 'nosort' => false, 'readParms'=>'thumb=60&thumb_urlraw=0&thumb_aw=60','readonly'=>false), - 'news_title' => array('title' => LAN_TITLE, 'type' => 'method', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'readParms'=>'link={e_BASE}news.php?extend.[id]&dialog=1'), + 'news_title' => array('title' => LAN_TITLE, 'type' => 'text', 'inline'=>true, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false), 'news_summary' => array('title' => LAN_NEWS_27, 'type' => 'text', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false), 'news_meta_keywords' => array('title' => LAN_KEYWORDS, 'type' => 'text', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false), diff --git a/e107_handlers/admin_ui.php b/e107_handlers/admin_ui.php index c51f392d0..d2e636039 100644 --- a/e107_handlers/admin_ui.php +++ b/e107_handlers/admin_ui.php @@ -2285,7 +2285,10 @@ class e_admin_controller_ui extends e_admin_controller */ protected $batchCopy = false; - + /** + * @var boolean + */ + protected $batchLink = false; /** * Could be LAN constant (mulit-language support) * @@ -2339,6 +2342,12 @@ class e_admin_controller_ui extends e_admin_controller { return $this->batchCopy; } + + + public function getBatchLink() + { + return $this->batchLink; + } /** * @return string @@ -2365,6 +2374,16 @@ class e_admin_controller_ui extends e_admin_controller { return $this->tabs; } + + + /** + * Get URL profile + * @return array + */ + public function getUrl() + { + return $this->url; + } /** @@ -3905,7 +3924,19 @@ class e_admin_ui extends e_admin_controller_ui $this->redirect(); } - + /** TODO + * Batch copy trigger + * @param array $selected + * @return void + */ + protected function handleListUrlBatch($selected) + { + // Batch Copy + $set_messages = true; + $this->getTreeModel()->url($selected); + if($set_messages) $this->getTreeModel()->setMessages(); + $this->redirect(); + } /** * Batch boolean trigger * @param array $selected @@ -4646,6 +4677,7 @@ class e_admin_ui extends e_admin_controller_ui $this->_model = new e_admin_model(); $this->_model->setModelTable($this->table) ->setFieldIdName($this->pid) + ->setUrl($this->url) ->setValidationRules($this->validationRules) ->setDbTypes($this->fieldTypes) ->setDataFields($this->dataFields) @@ -4665,6 +4697,7 @@ class e_admin_ui extends e_admin_controller_ui $this->_tree_model = new e_admin_tree_model(); $this->_tree_model->setModelTable($this->table) ->setFieldIdName($this->pid) + ->setUrl($this->url) ->setMessageStackName('admin_ui_tree_'.$this->table) ->setParams(array('model_class' => 'e_admin_model', 'model_message_stack' => 'admin_ui_model_'.$this->table ,'db_query' => $this->listQry)); @@ -4828,7 +4861,7 @@ class e_admin_form_ui extends e_form public function getModal($caption = '', $type='') { return ' -