From 7a9ae43aadb6bb2e0a59525ac10b8dd079f76fba Mon Sep 17 00:00:00 2001 From: CaMer0n Date: Mon, 25 Jul 2011 02:41:49 +0000 Subject: [PATCH] Batch-Copy added to admin-ui. Adding missing core shortcodes. Media-Category NewsThumbs added (legacy support) --- e107_admin/links.php | 3 +- e107_admin/update_routines.php | 7 ++-- .../shortcodes/single/sitecontactinfo.sc | 2 ++ e107_core/shortcodes/single/sitedisclaimer.sc | 4 +++ e107_handlers/admin_ui.php | 36 +++++++++++++++++-- e107_handlers/model_class.php | 28 +++++++++++++++ e107_handlers/mysql_class.php | 27 ++++++++++++++ e107_languages/English/admin/lan_admin.php | 1 + 8 files changed, 102 insertions(+), 6 deletions(-) create mode 100644 e107_core/shortcodes/single/sitecontactinfo.sc create mode 100644 e107_core/shortcodes/single/sitedisclaimer.sc diff --git a/e107_admin/links.php b/e107_admin/links.php index 602e16f4d..f4964cc64 100644 --- a/e107_admin/links.php +++ b/e107_admin/links.php @@ -65,6 +65,7 @@ class links_admin_ui extends e_admin_ui protected $pid = "link_id"; protected $perPage = 0; protected $batchDelete = true; + protected $batchCopy = true; protected $listOrder = 'link_order ASC'; public $current_parent = 0; @@ -664,7 +665,7 @@ class links_admin_form_ui extends e_admin_form_ui 'fields' => $controller->getFields(), // see e_admin_ui::$fields 'fieldpref' => $controller->getFieldPref(), // see e_admin_ui::$fieldpref 'table_pre' => '', // markup to be added before opening table element - 'table_post' => !$tree[$id]->isEmpty() ? $this->renderBatch($controller->getBatchDelete()) : '', + 'table_post' => !$tree[$id]->isEmpty() ? $this->renderBatch($controller->getBatchDelete(),$controller->getBatchCopy()) : '', 'fieldset_pre' => '', // markup to be added before opening fieldset element 'fieldset_post' => '', // markup to be added after closing fieldset element 'perPage' => $controller->getPerPage(), // if 0 - no next/prev navigation diff --git a/e107_admin/update_routines.php b/e107_admin/update_routines.php index a743cf7fa..7cfb1bb4c 100644 --- a/e107_admin/update_routines.php +++ b/e107_admin/update_routines.php @@ -980,16 +980,19 @@ function update_706_to_800($type='') $count = $sql->db_Select_gen("SELECT * FROM `#core_media_cat` WHERE `media_cat_nick` = '_common' "); if($count != 1) { - if ($just_check) return update_needed('Add Media-Manager Categories and Import existing images.'); + if ($just_check) return update_needed('Add Media-Manager Categories and Import existing images.'); + $query = "INSERT INTO `".MPREFIX."core_media_cat` (`media_cat_id`, `media_cat_nick`, `media_cat_title`, `media_cat_diz`, `media_cat_class`) VALUES (0, '_common', '(Common Area)', 'Media in this category will be available in all areas of admin. ', 253), (0, 'news', 'News', 'Will be available in the news area. ', 253), (0, 'page', 'Custom Pages', 'Will be available in the custom pages area of admin. ', 253), (0, 'download', 'Download Images', '', 253), - (0, 'downloadthumb', 'Download Thumbnails', '', 253);"; + (0, 'downloadthumb', 'Download Thumbnails (legacy)', '', 253), + (0, 'newsthumb', 'News Thumbnails (legacy)', '', 253);"; mysql_query($query); + $med->import('newsthumb',e_IMAGE.'newspost_images',"^thumb_"); $med->import('news',e_IMAGE.'newspost_images'); $med->import('page',e_IMAGE.'custom'); $med->import('download',e_FILE.'downloadimages'); diff --git a/e107_core/shortcodes/single/sitecontactinfo.sc b/e107_core/shortcodes/single/sitecontactinfo.sc new file mode 100644 index 000000000..a7cb0d509 --- /dev/null +++ b/e107_core/shortcodes/single/sitecontactinfo.sc @@ -0,0 +1,2 @@ +//toHtml(SITEDISCLAIMER,TRUE,"constants defs"); diff --git a/e107_handlers/admin_ui.php b/e107_handlers/admin_ui.php index 2ec0b8c23..902c2d042 100644 --- a/e107_handlers/admin_ui.php +++ b/e107_handlers/admin_ui.php @@ -2035,6 +2035,12 @@ class e_admin_controller_ui extends e_admin_controller * @var boolean */ protected $batchDelete = true; + + /** + * @var boolean + */ + protected $batchCopy = false; + /** * Could be LAN constant (mulit-language support) @@ -2073,6 +2079,11 @@ class e_admin_controller_ui extends e_admin_controller { return $this->batchDelete; } + + public function getBatchCopy() + { + return $this->batchCopy; + } /** * @return string @@ -3341,6 +3352,21 @@ class e_admin_ui extends e_admin_controller_ui $this->redirect(); } + /** TODO + * Batch copy trigger + * @param array $selected + * @return void + */ + protected function handleListCopyBatch($selected) + { + // Batch Copy + $set_messages = true; + $this->getTreeModel()->copy($selected); + if($set_messages) $this->getTreeModel()->setMessages(); + $this->redirect(); + } + + /** * Batch boolean trigger * @param array $selected @@ -4012,7 +4038,7 @@ class e_admin_form_ui extends e_form 'fields' => $controller->getFields(), // see e_admin_ui::$fields 'fieldpref' => $controller->getFieldPref(), // see e_admin_ui::$fieldpref 'table_pre' => '', // markup to be added before opening table element - 'table_post' => !$tree[$id]->isEmpty() ? $this->renderBatch($controller->getBatchDelete()) : '', + 'table_post' => !$tree[$id]->isEmpty() ? $this->renderBatch($controller->getBatchDelete(),$controller->getBatchCopy()) : '', 'fieldset_pre' => '', // markup to be added before opening fieldset element 'fieldset_post' => '', // markup to be added after closing fieldset element 'perPage' => $controller->getPerPage(), // if 0 - no next/prev navigation @@ -4148,8 +4174,11 @@ class e_admin_form_ui extends e_form } // FIXME - use e_form::batchoptions(), nice way of buildig batch dropdown - news administration show_batch_options() - function renderBatch($allow_delete = false) + function renderBatch($allow_delete = false,$allow_copy= false) { + + // $allow_copy = TRUE; + $fields = $this->getController()->getFields(); if(!varset($fields['checkboxes'])) { @@ -4161,7 +4190,8 @@ class e_admin_form_ui extends e_form ".$this->select_open('etrigger_batch', array('class' => 'tbox select batch e-autosubmit reset', 'id' => false))." ".$this->option(LAN_BATCH_LABEL_SELECTED, '')." - ".($allow_delete ? $this->option(LAN_DELETE, 'delete', false, array('class' => 'ui-batch-option class', 'other' => 'style="padding-left: 15px"')) : '')." + ".($allow_copy ? $this->option(LAN_COPY, 'copy', false, array('class' => 'ui-batch-option class', 'other' => 'style="padding-left: 15px"')) : '')." + ".($allow_delete ? $this->option(LAN_DELETE, 'delete', false, array('class' => 'ui-batch-option class', 'other' => 'style="padding-left: 15px"')) : '')." ".$this->renderBatchFilter('batch')." ".$this->select_close()." ".$this->admin_button('e__execute_batch', 'e__execute_batch', 'batch e-hide-if-js', 'Execute', array('id' => false))." diff --git a/e107_handlers/model_class.php b/e107_handlers/model_class.php index dd712601e..a77cfc46d 100644 --- a/e107_handlers/model_class.php +++ b/e107_handlers/model_class.php @@ -3314,4 +3314,32 @@ class e_admin_tree_model extends e_front_tree_model return $res; } + + /** + * Batch Copy Table Rows. + */ + public function copy($ids) + { + $ids = array_map('intval', $ids); + $idstr = implode(', ', $ids); + + $sql = e107::getDb(); + + if($res = $sql->db_CopyRow($this->getModelTable(), "*", $this->getFieldIdName().' IN ('.$idstr.')')) + { + $this->addMessageSuccess('Copied #'.$idstr); + } + else + { + if($sql->getLastErrorNumber()) + { + $this->addMessageError('SQL Delete Error', $session_messages); //TODO - Lan + $this->addMessageDebug('SQL Error #'.$sql->getLastErrorNumber().': '.$sql->getLastErrorText()); + } + } + $this->_db_errno = $sql->getLastErrorNumber(); + $this->_db_errmsg = $sql->getLastErrorText(); + return $res; + } + } \ No newline at end of file diff --git a/e107_handlers/mysql_class.php b/e107_handlers/mysql_class.php index 33641b3af..d2a0d7dad 100644 --- a/e107_handlers/mysql_class.php +++ b/e107_handlers/mysql_class.php @@ -1434,6 +1434,33 @@ class e_db_mysql } } + + /** + * Duplicate a Table Row in a table. + */ + function db_CopyRow($table,$fields = '*', $args='') + { + if(!$table || !$args ) + { + return; + } + + if($fields == '*') + { + $fields = $this->db_FieldList($table); + unset($fields[0]); // Remove primary_id. + $fieldList = implode(",",$fields); + } + else + { + $fieldList = $fields; + } + + return $this->db_Select_gen("INSERT INTO #".$table."(".$fieldList.") SELECT ".$fieldList." FROM #".$table." WHERE ".$args); + + } + + function db_CopyTable($oldtable, $newtable, $drop = FALSE, $data = FALSE) { diff --git a/e107_languages/English/admin/lan_admin.php b/e107_languages/English/admin/lan_admin.php index 778a81dd0..96528c3a6 100644 --- a/e107_languages/English/admin/lan_admin.php +++ b/e107_languages/English/admin/lan_admin.php @@ -320,6 +320,7 @@ define("LAN_LOADING", "Loading..."); define("LAN_FILE", "File"); define("LAN_EXECUTE","Execute"); define("LAN_SEFURL","SEF URL"); +define("LAN_COPY","Copy"); define("LAN_SECURITYL_0", "Looking for trouble (none)");