1
0
mirror of https://github.com/e107inc/e107.git synced 2025-04-21 05:02:02 +02:00

Batch-Copy added to admin-ui. Adding missing core shortcodes. Media-Category NewsThumbs added (legacy support)

This commit is contained in:
CaMer0n 2011-07-25 02:41:49 +00:00
parent a6613cb515
commit 7a9ae43aad
8 changed files with 102 additions and 6 deletions

View File

@ -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

View File

@ -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');

View File

@ -0,0 +1,2 @@
//<?
return SITECONTACTINFO;

View File

@ -0,0 +1,4 @@
//<?php
$tp = e107::getParser();
return $tp->toHtml(SITEDISCLAIMER,TRUE,"constants defs");

View File

@ -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
<img src='".e_IMAGE_ABS."generic/branchbottom.gif' alt='' class='icon action' />
".$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))."

View File

@ -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;
}
}

View File

@ -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)
{

View File

@ -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)");