From f03791fe49d47d0c34de5e78a0d4144a53f14911 Mon Sep 17 00:00:00 2001 From: Dmi3yy Date: Sat, 3 Aug 2013 10:51:44 +0300 Subject: [PATCH] Refactor #10038 added sorting when viewing children documents --- manager/actions/document_data.static.php | 63 +++++++++++++++++-- manager/actions/mutate_content.dynamic.php | 32 ++++++++-- manager/actions/wait.static.php | 10 ++- .../processors/delete_content.processor.php | 20 +++++- .../processors/publish_content.processor.php | 21 ++++++- manager/processors/save_content.processor.php | 12 +++- .../processors/undelete_content.processor.php | 18 +++++- .../unpublish_content.processor.php | 21 ++++++- 8 files changed, 180 insertions(+), 17 deletions(-) diff --git a/manager/actions/document_data.static.php b/manager/actions/document_data.static.php index 5735a7ad7a..45e6dd5769 100644 --- a/manager/actions/document_data.static.php +++ b/manager/actions/document_data.static.php @@ -115,15 +115,33 @@ $rs = $modx->db->query($sql); $numRecords = $modx->db->getRecordCount($rs); +$sort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : 'createdon' ; +$dir = isset($_REQUEST['dir'])? $_REQUEST['dir']: 'DESC'; + // Get child documents (with paging) $sql = 'SELECT DISTINCT sc.* '. 'FROM '.$tbl_site_content.' AS sc '. 'LEFT JOIN '.$tbl_document_groups.' AS dg ON dg.document = sc.id '. 'WHERE sc.parent=\''.$content['id'].'\' '. 'AND ('.$access.') '. + 'ORDER BY '.$sort.' '.$dir. $childsTable->handlePaging(); // add limit clause - +$filter_sort=''; +$filter_dir=''; if ($numRecords > 0) { + $filter_sort='

'; + $filter_dir='

'; if (!$rs = $modx->db->query($sql)) { // sql error $e->setError(1); @@ -151,6 +169,8 @@ $listTableHeader = array( 'docid' => $_lang['id'], 'title' => $_lang['resource_title'], + 'createdon' => $_lang['createdon'], + 'pub_date' => $_lang['page_data_publishdate'], 'status' => $_lang['page_data_status'], 'edit' => $_lang['mgrlog_action'], ); @@ -159,17 +179,49 @@ $limitClause = $childsTable->handlePaging(); +$sd=isset($_REQUEST['dir'])?'&dir='.$_REQUEST['dir']:'&dir=DESC'; +$sb=isset($_REQUEST['sort'])?'&sort='.$_REQUEST['sort']:'&sort=createdon'; +$pg=isset($_REQUEST['page'])?'&page='.(int)$_REQUEST['page']:''; +$add_path=$sd.$sb.$pg; + + $listDocs = array(); foreach($resource as $k => $children){ + /* + $listDocs[] = array( + 'docid' => $children['id'], + 'title' => (($children['deleted'] ? (''.$children['pagetitle'].'') : ( ($modx->hasPermission('edit_document')) ? ('' . $children['pagetitle'] . '') : $children['pagetitle'] ))), + 'createdon' => ($modx->toDateFormat($children['createdon']+$server_offset_time,'dateOnly')), + 'pub_date' => ($children['pub_date']? ($modx->toDateFormat($children['pub_date']+$server_offset_time,'dateOnly')) : ''), + 'status' => ($children['published'] == 0) ? ''.$_lang['page_data_unpublished'].'' : ''.$_lang['page_data_published'].'', + 'edit' => (($modx->hasPermission('edit_document')) ? '    ' : '') . + (($modx->hasPermission('delete_document')) ? '  ' : ''), + ); + */ + + // дописываем в заголовок класс для неопубликованных плюс по всем ссылкам обратный путь + // для сохранения сортировки + $listDocs[] = array( 'docid' => $children['id'], - 'title' => $children['pagetitle'], + 'title' => (($children['deleted'] ? (''.$children['pagetitle'].'') : ( ($modx->hasPermission('edit_document')) ? ('' . ($children['published']?$children['pagetitle']:''.$children['pagetitle'].'') . '') : $children['pagetitle'] ))), + 'createdon' => ($modx->toDateFormat($children['createdon']+$server_offset_time,'dateOnly')), + 'pub_date' => ($children['pub_date']? ($modx->toDateFormat($children['pub_date']+$server_offset_time,'dateOnly')) : ''), 'status' => ($children['published'] == 0) ? ''.$_lang['page_data_unpublished'].'' : ''.$_lang['page_data_published'].'', - 'edit' => ''.$_lang['view'].''.(($modx->hasPermission('edit_document')) ? ' '.$_lang['edit'].' '.$_lang['move'].'' : ''), + 'edit' => (($modx->hasPermission('edit_document')) ? '    ' : '') . + (($modx->hasPermission('delete_document')) ? '  ' : ''), ); + + /****************/ } - $childsTable->createPagingNavigation($numRecords,'a=3&id='.$content['id']); + $childsTable->createPagingNavigation($numRecords,'a=3&id='.$content['id'].'&dir='.$dir.'&sort='.$sort); $children_output = $childsTable->create($listDocs,$listTableHeader,'index.php?a=3&id='.$content['id']); } } else { @@ -304,7 +356,7 @@ function movedocument() {

- + hasPermission('new_document')) { ?>
diff --git a/manager/actions/mutate_content.dynamic.php b/manager/actions/mutate_content.dynamic.php index c3a1b8e162..015e0408b6 100644 --- a/manager/actions/mutate_content.dynamic.php +++ b/manager/actions/mutate_content.dynamic.php @@ -1,6 +1,13 @@ INCLUDE_ORDERING_ERROR

Please use the MODx Content Manager instead of accessing this file directly.'); +/********************/ +$sd=isset($_REQUEST['dir'])?'&dir='.$_REQUEST['dir']:'&dir=DESC'; +$sb=isset($_REQUEST['sort'])?'&sort='.$_REQUEST['sort']:'&sort=createdon'; +$pg=isset($_REQUEST['page'])?'&page='.(int)$_REQUEST['page']:''; +$add_path=$sd.$sb.$pg; +/*******************/ + // check permissions switch ($_REQUEST['a']) { case 27: @@ -201,13 +208,13 @@ function changestate(element) { function deletedocument() { if (confirm("")==true) { - document.location.href="index.php?id=" + document.mutate.id.value + "&a=6"; + document.location.href="index.php?id=" + document.mutate.id.value + "&a=6"; } } function duplicatedocument(){ if(confirm("")==true) { - document.location.href="index.php?id=&a=94"; + document.location.href="index.php?id=&a=94"; } } @@ -230,7 +237,7 @@ function enableLinkSelection(b) { function setLink(lId) { if (!allowLinkSelection) { - window.location.href="index.php?a=3&id="+lId; + window.location.href="index.php?a=3&id="+lId+""; return; } else { @@ -255,7 +262,7 @@ function enableParentSelection(b) { function setParent(pId, pName) { if (!allowParentSelection) { - window.location.href="index.php?a=3&id="+pId; + window.location.href="index.php?a=3&id="+pId+""; return; } else { @@ -507,6 +514,13 @@ function decode(s) { )); if (is_array($evtOut)) echo implode('', $evtOut); + +/*************************/ +$dir=isset($_REQUEST['dir'])?$_REQUEST['dir']:''; +$sort=isset($_REQUEST['sort'])?$_REQUEST['sort']:'createdon'; +$page=isset($_REQUEST['page'])?(int)$_REQUEST['page']:''; +/*************************/ + ?> @@ -515,6 +529,14 @@ function decode(s) { + + + + + + + +

@@ -539,7 +561,7 @@ function decode(s) {
  • " alt="icons_resource_duplicate" />
  • " alt="icons_delete_document" />
  • -
  • ">icons_cancel" />
  • +
  • ">icons_cancel" />
  • icons_preview_resource" />
  • diff --git a/manager/actions/wait.static.php b/manager/actions/wait.static.php index f21b1c2acb..ebb0cd030e 100644 --- a/manager/actions/wait.static.php +++ b/manager/actions/wait.static.php @@ -1,5 +1,11 @@ INCLUDE_ORDERING_ERROR

    Please use the MODx Content Manager instead of accessing this file directly."); +/*********************/ +$sd=isset($_REQUEST['dir'])?'&dir='.$_REQUEST['dir']:'&dir=DESC'; +$sb=isset($_REQUEST['sort'])?'&sort='.$_REQUEST['sort']:'&sort=createdon'; +$pg=isset($_REQUEST['page'])?'&page='.(int)$_REQUEST['page']:''; +$add_path=$sd.$sb.$pg; +/**********************/ ?>

    @@ -12,7 +18,9 @@ function goHome() { top.mainMenu.startrefresh(10); - document.location.href="index.php?a=3&id="; +// document.location.href="index.php?a=3&id="; +//возвращаем куда нужно с учетом сортировки + document.location.href="index.php?a=3&id="; document.location.href="index.php?a=2"; diff --git a/manager/processors/delete_content.processor.php b/manager/processors/delete_content.processor.php index 0598a80d9b..15ac293d0a 100755 --- a/manager/processors/delete_content.processor.php +++ b/manager/processors/delete_content.processor.php @@ -9,6 +9,19 @@ db->getValue($modx->db->query("SELECT parent FROM ".$modx->getFullTableName('site_content')." WHERE id=".$id." LIMIT 0,1")); +$pid=($pid==0?$id:$pid); + +/************ а заодно и путь возврата (сам путь внизу файла) **********/ +$sd=isset($_REQUEST['dir'])?'&dir='.$_REQUEST['dir']:'&dir=DESC'; +$sb=isset($_REQUEST['sort'])?'&sort='.$_REQUEST['sort']:'&sort=createdon'; +$pg=isset($_REQUEST['page'])?'&page='.(int)$_REQUEST['page']:''; +$add_path=$sd.$sb.$pg; + +/*****************************/ + $deltime = time(); $children = array(); @@ -111,7 +124,12 @@ function getChildren($parent) { $sync->setReport(false); $sync->emptyCache(); // first empty the cache // finished emptying cache - redirect - $header="Location: index.php?r=1&a=7&id=$id&dv=1"; +// $header="Location: index.php?r=1&a=7&id=$id&dv=1"; + + //новый путь + $header="Location: index.php?r=1&a=7&id=$pid&dv=1".$add_path; + + header($header); } ?> \ No newline at end of file diff --git a/manager/processors/publish_content.processor.php b/manager/processors/publish_content.processor.php index b61dee06b7..2a827ae53b 100755 --- a/manager/processors/publish_content.processor.php +++ b/manager/processors/publish_content.processor.php @@ -7,6 +7,21 @@ $id = $_REQUEST['id']; + +/************webber ********/ +$pid=$modx->db->getValue($modx->db->query("SELECT parent FROM ".$modx->getFullTableName('site_content')." WHERE id=".$id." LIMIT 0,1")); +$pid=($pid==0?$id:$pid); + +/************** webber *************/ +$sd=isset($_REQUEST['dir'])?'&dir='.$_REQUEST['dir']:'&dir=DESC'; +$sb=isset($_REQUEST['sort'])?'&sort='.$_REQUEST['sort']:'&sort=createdon'; +$pg=isset($_REQUEST['page'])?'&page='.(int)$_REQUEST['page']:''; +$add_path=$sd.$sb.$pg; + +/***********************************/ + + + // check permissions on the document include_once "./processors/user_documents_permissions.class.php"; $udperms = new udperms(); @@ -41,6 +56,10 @@ $sync->setReport(false); $sync->emptyCache(); // first empty the cache -$header="Location: index.php?r=1&id=$id&a=7"; +//$header="Location: index.php?r=1&id=$id&a=7"; + +// webber +$header="Location: index.php?r=1&id=$pid&a=7&dv=1".$add_path; + header($header); ?> \ No newline at end of file diff --git a/manager/processors/save_content.processor.php b/manager/processors/save_content.processor.php index a82eab9ecf..757ffe832e 100755 --- a/manager/processors/save_content.processor.php +++ b/manager/processors/save_content.processor.php @@ -37,6 +37,14 @@ $menutitle = $modx->db->escape($_POST['menutitle']); $hidemenu = intval($_POST['hidemenu']); +/************* webber ********/ +$sd=isset($_POST['dir'])?'&dir='.$_POST['dir']:'&dir=DESC'; +$sb=isset($_POST['sort'])?'&sort='.$_POST['sort']:'&sort=pub_date'; +$pg=isset($_POST['page'])?'&page='.(int)$_POST['page']:''; +$add_path=$sd.$sb.$pg; + + + if (trim($pagetitle == "")) { if ($type == "reference") { $pagetitle = $_lang['untitled_weblink']; @@ -673,9 +681,9 @@ // document $a = ($_POST['stay'] == '2') ? "27&id=$id" : "4&pid=$parent"; } - $header = "Location: index.php?a=" . $a . "&r=1&stay=" . $_POST['stay']; + $header = "Location: index.php?a=" . $a . "&r=1&stay=" . $_POST['stay'].$add_path; } else { - $header = "Location: index.php?r=1&id=$id&a=7&dv=1"; + $header = "Location: index.php?r=1&id=$id&a=7&dv=1".$add_path; } } header($header); diff --git a/manager/processors/undelete_content.processor.php b/manager/processors/undelete_content.processor.php index db90a7b82b..c18701894e 100755 --- a/manager/processors/undelete_content.processor.php +++ b/manager/processors/undelete_content.processor.php @@ -7,6 +7,19 @@ $id=$_REQUEST['id']; +/************ webber ********/ +$pid=$modx->db->getValue($modx->db->query("SELECT parent FROM ".$modx->getFullTableName('site_content')." WHERE id=".$id." LIMIT 0,1")); +$pid=($pid==0?$id:$pid); + +/************** webber *************/ +$sd=isset($_REQUEST['dir'])?'&dir='.$_REQUEST['dir']:'&dir=DESC'; +$sb=isset($_REQUEST['sort'])?'&sort='.$_REQUEST['sort']:'&sort=createdon'; +$pg=isset($_REQUEST['page'])?'&page='.(int)$_REQUEST['page']:''; +$add_path=$sd.$sb.$pg; + +/***********************************/ + + // check permissions on the document include_once "./processors/user_documents_permissions.class.php"; $udperms = new udperms(); @@ -86,7 +99,10 @@ function getChildren($parent) { $sync->setReport(false); $sync->emptyCache(); // first empty the cache // finished emptying cache - redirect - $header="Location: index.php?r=1&a=7&id=$id&dv=1"; + //$header="Location: index.php?r=1&a=7&id=$id&dv=1"; + +// webber + $header="Location: index.php?r=1&a=7&id=$pid&dv=1".$add_path; header($header); } ?> \ No newline at end of file diff --git a/manager/processors/unpublish_content.processor.php b/manager/processors/unpublish_content.processor.php index 0f8e263f7c..3dcb79fc02 100755 --- a/manager/processors/unpublish_content.processor.php +++ b/manager/processors/unpublish_content.processor.php @@ -7,6 +7,20 @@ $id = $_REQUEST['id']; +/************ Webber ********/ +$pid=$modx->db->getValue($modx->db->query("SELECT parent FROM ".$modx->getFullTableName('site_content')." WHERE id=".$id." LIMIT 0,1")); +$pid=($pid==0?$id:$pid); + +/************** Webber *************/ +$sd=isset($_REQUEST['dir'])?'&dir='.$_REQUEST['dir']:'&dir=DESC'; +$sb=isset($_REQUEST['sort'])?'&sort='.$_REQUEST['sort']:'&sort=createdon'; +$pg=isset($_REQUEST['page'])?'&page='.(int)$_REQUEST['page']:''; +$add_path=$sd.$sb.$pg; + +/***********************************/ + + + // check permissions on the document include_once "./processors/user_documents_permissions.class.php"; $udperms = new udperms(); @@ -41,6 +55,11 @@ $sync->setReport(false); $sync->emptyCache(); // first empty the cache -$header="Location: index.php?r=1&id=$id&a=7"; +//$header="Location: index.php?r=1&id=$id&a=7"; + + +// Webber +$header="Location: index.php?r=1&id=$pid&a=7&dv=1".$add_path; + header($header); ?> \ No newline at end of file