mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-07 02:31:40 +09:00
issue 70 list count modified in content admin
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@8854 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
b87aedbd2b
commit
ac9bf88af4
13 changed files with 355 additions and 183 deletions
|
|
@ -39,93 +39,136 @@ class trashAdminController extends trash
|
|||
{
|
||||
global $lang;
|
||||
$isAll = Context::get('is_all');
|
||||
$tmpTrashSrls = Context::get('trash_srls');
|
||||
$tmpTrashSrls = Context::get('cart');
|
||||
if(is_array($tmpTrashSrls)) $trashSrls = $tmpTrashSrls;
|
||||
else $trashSrls = explode('|@|', $tmpTrashSrls);
|
||||
|
||||
$oTrashModel = &getModel('trash');
|
||||
if($isAll == 'true')
|
||||
{
|
||||
$trashSrls = array();
|
||||
//module relation data delete...
|
||||
$output = $this->_relationDataDelete($isAll, $trashSrls);
|
||||
if(!$output->toBool()) return new Object(-1, $output->message);
|
||||
|
||||
//module relation data delete...
|
||||
$output = $oTrashModel->getTrashList($args);
|
||||
if(!$output->toBool()) return new Object(-1, $output->message);
|
||||
|
||||
if(is_array($output->data))
|
||||
{
|
||||
foreach($output->data AS $key=>$oTrashVO)
|
||||
{
|
||||
//class file check
|
||||
$classPath = ModuleHandler::getModulePath($oTrashVO->getOriginModule());
|
||||
if(!is_dir(FileHandler::getRealPath($classPath))) return new Object(-1, 'not exist restore module directory');
|
||||
|
||||
$classFile = sprintf('%s%s.admin.controller.php', $classPath, $oTrashVO->getOriginModule());
|
||||
$classFile = FileHandler::getRealPath($classFile);
|
||||
if(!file_exists($classFile)) return new Object(-1, 'not exist restore module class file');
|
||||
|
||||
$oAdminController = &getAdminController($oTrashVO->getOriginModule());
|
||||
if(!method_exists($oAdminController, 'emptyTrash')) return new Object(-1, 'not exist restore method in module class file');
|
||||
|
||||
$output = $oAdminController->emptyTrash($oTrashVO->getSerializedObject());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!$this->_emptyTrash($trashSrls))
|
||||
return new Object(-1, $lang->fail_empty);
|
||||
if(!$this->_emptyTrash($trashSrls)) return new Object(-1, $lang->fail_empty);
|
||||
|
||||
$this->setMessage('success_deleted', 'info');
|
||||
if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) {
|
||||
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispTrashAdminList');
|
||||
header('location:'.$returnUrl);
|
||||
$this->setRedirectUrl($returnUrl);
|
||||
return;
|
||||
}
|
||||
return new Object(0, $lang->success_empty);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief empty trash - private method
|
||||
**/
|
||||
function _relationDataDelete($isAll, &$trashSrls)
|
||||
{
|
||||
if($isAll == 'true') $trashSrls = array();
|
||||
$oTrashModel = &getModel('trash');
|
||||
if(count($trashSrls) > 0) $args->trashSrl = $trashSrls;
|
||||
$output = $oTrashModel->getTrashList($args);
|
||||
if(!$output->toBool()) return new Object(-1, $output->message);
|
||||
|
||||
if(is_array($output->data))
|
||||
{
|
||||
foreach($output->data AS $key=>$oTrashVO)
|
||||
{
|
||||
if($isAll == 'true') array_push($trashSrls, $oTrashVO->getTrashSrl());
|
||||
|
||||
//class file check
|
||||
$classPath = ModuleHandler::getModulePath($oTrashVO->getOriginModule());
|
||||
if(!is_dir(FileHandler::getRealPath($classPath))) return new Object(-1, 'not exist restore module directory');
|
||||
|
||||
$classFile = sprintf('%s%s.admin.controller.php', $classPath, $oTrashVO->getOriginModule());
|
||||
$classFile = FileHandler::getRealPath($classFile);
|
||||
if(!file_exists($classFile)) return new Object(-1, 'not exist restore module class file');
|
||||
|
||||
$oAdminController = &getAdminController($oTrashVO->getOriginModule());
|
||||
if(!method_exists($oAdminController, 'emptyTrash')) return new Object(-1, 'not exist restore method in module class file');
|
||||
|
||||
$output = $oAdminController->emptyTrash($oTrashVO->getSerializedObject());
|
||||
if(!$output->toBool()) return new Object(-1, $output->message);
|
||||
}
|
||||
}
|
||||
return new Object(0, $lang->success_deleted);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief restore content object
|
||||
**/
|
||||
function procTrashAdminRestore()
|
||||
{
|
||||
global $lang;
|
||||
$trashSrl = Context::get('trash_srl');
|
||||
$trashSrlList = Context::get('cart');
|
||||
|
||||
$oTrashModel = &getModel('trash');
|
||||
$output = $oTrashModel->getTrash($trashSrl);
|
||||
if(!$output->toBool()) return new Object(-1, $output->message);
|
||||
if(is_array($trashSrlList))
|
||||
{
|
||||
// begin transaction
|
||||
$oDB = &DB::getInstance();
|
||||
$oDB->begin();
|
||||
// eache restore method call in each classfile
|
||||
foreach($trashSrlList AS $key=>$value)
|
||||
{
|
||||
$oTrashModel = &getModel('trash');
|
||||
$output = $oTrashModel->getTrash($value);
|
||||
if(!$output->toBool()) return new Object(-1, $output->message);
|
||||
|
||||
//class file check
|
||||
$classPath = ModuleHandler::getModulePath($output->data->getOriginModule());
|
||||
if(!is_dir(FileHandler::getRealPath($classPath))) return new Object(-1, 'not exist restore module directory');
|
||||
//class file check
|
||||
$classPath = ModuleHandler::getModulePath($output->data->getOriginModule());
|
||||
if(!is_dir(FileHandler::getRealPath($classPath))) return new Object(-1, 'not exist restore module directory');
|
||||
|
||||
$classFile = sprintf('%s%s.admin.controller.php', $classPath, $output->data->getOriginModule());
|
||||
$classFile = FileHandler::getRealPath($classFile);
|
||||
if(!file_exists($classFile)) return new Object(-1, 'not exist restore module class file');
|
||||
$classFile = sprintf('%s%s.admin.controller.php', $classPath, $output->data->getOriginModule());
|
||||
$classFile = FileHandler::getRealPath($classFile);
|
||||
if(!file_exists($classFile)) return new Object(-1, 'not exist restore module class file');
|
||||
|
||||
$oAdminController = &getAdminController($output->data->getOriginModule());
|
||||
if(!method_exists($oAdminController, 'restoreTrash')) return new Object(-1, 'not exist restore method in module class file');
|
||||
$oAdminController = &getAdminController($output->data->getOriginModule());
|
||||
if(!method_exists($oAdminController, 'restoreTrash')) return new Object(-1, 'not exist restore method in module class file');
|
||||
|
||||
// begin transaction
|
||||
$oDB = &DB::getInstance();
|
||||
$oDB->begin();
|
||||
$originObject = unserialize($output->data->getSerializedObject());
|
||||
$output = $oAdminController->restoreTrash($originObject);
|
||||
|
||||
$originObject = unserialize($output->data->getSerializedObject());
|
||||
$output = $oAdminController->restoreTrash($originObject);
|
||||
if(!$output->toBool()) {
|
||||
$oDB->rollback();
|
||||
return new Object(-1, $output->message);
|
||||
}
|
||||
}
|
||||
|
||||
if(!$output->toBool()) {
|
||||
$oDB->rollback();
|
||||
return new Object(-1, $output->message);
|
||||
// restore object delete in trash box
|
||||
if(!$this->_emptyTrash($trashSrlList)) {
|
||||
$oDB->rollback();
|
||||
return new Object(-1, $lang->fail_empty);
|
||||
}
|
||||
$oDB->commit();
|
||||
}
|
||||
|
||||
$this->setMessage('success_restore', 'info');
|
||||
if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) {
|
||||
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispTrashAdminList');
|
||||
$this->setRedirectUrl($returnUrl);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function procTrashAdminGetList()
|
||||
{
|
||||
if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted');
|
||||
$trashSrls = Context::get('trash_srls');
|
||||
if($trashSrls) $trashSrlList = explode(',', $trashSrls);
|
||||
|
||||
if(count($trashSrlList) > 0) {
|
||||
$oTrashModel = &getModel('trash');
|
||||
$args->trashSrl = $trashSrlList;
|
||||
$output = $oTrashModel->getTrashList($args);
|
||||
$trashList = $output->data;
|
||||
}
|
||||
else
|
||||
{
|
||||
Context::set('is_all', 'false');
|
||||
Context::set('trash_srls', $trashSrl);
|
||||
$output = $this->procTrashAdminEmptyTrash();
|
||||
if(!$output->toBool()) {
|
||||
$oDB->rollback();
|
||||
return new Object(-1, $output->message);
|
||||
}
|
||||
global $lang;
|
||||
$trashList = array();
|
||||
$this->setMessage($lang->no_documents);
|
||||
}
|
||||
$oDB->commit();
|
||||
return new Object(0, $lang->success_restore);
|
||||
|
||||
$this->add('trash_list', $trashList);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue