Skip to content

Commit

Permalink
Revert "Apply grid filtering persistence via URL parameters to most g…
Browse files Browse the repository at this point in the history
…rids in the manager (modxcms#16369)"

This reverts commit 73ae298, reversing
changes made to 7a54b6e.
  • Loading branch information
Mark-H committed Feb 10, 2024
1 parent d37e0a1 commit 5461b72
Show file tree
Hide file tree
Showing 71 changed files with 2,297 additions and 2,169 deletions.
14 changes: 1 addition & 13 deletions _build/templates/default/sass/_toolbars.scss
Original file line number Diff line number Diff line change
Expand Up @@ -187,25 +187,13 @@
/* top toolbars */
.x-panel-tbar {
overflow: visible; /* prevent cut off box-shadows in FF */
padding-bottom: 4px;
padding-bottom: 2px;

.x-toolbar {
/*background-color: #F5F5F5;*/
border: 0;
padding: 5px 0;
overflow: visible; /* prevent cut off box-shadows in FF */

td {
vertical-align: bottom;
}

input {
&.filter-query {
/* fix positioning issue with query field */
position: relative;
bottom: -1px;
}
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions core/lexicon/en/dashboards.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
$_lang['dashboards'] = 'Dashboards';
$_lang['dashboards.intro_msg'] = 'Here you can manage all the available Dashboards for this MODX manager.';
$_lang['rank'] = 'Rank';
$_lang['user_group_filter'] = 'Filter by User Group...';
$_lang['user_group_filter'] = 'By User Group';
$_lang['widget'] = 'Widget';
$_lang['widget_content'] = 'Widget Content';
$_lang['widget_err_ae_name'] = 'A widget with the name "[[+name]]" already exists! Please try another name.';
Expand Down Expand Up @@ -99,4 +99,4 @@
$_lang['w_whosonline'] = 'Who\'s Online';
$_lang['w_whosonline_desc'] = 'Shows a list of online users.';
$_lang['w_view_all'] = 'View all';
$_lang['w_no_data'] = 'No data to display';
$_lang['w_no_data'] = 'No data to display';
3 changes: 1 addition & 2 deletions core/lexicon/en/default.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@
$_lang['filter_clear'] = 'Clear Filter';
$_lang['filter_by_key'] = 'Filter by Key...';
$_lang['filter_by_name'] = 'Filter by name...';
$_lang['filter_by_event_group'] = 'Filter by event group...';
$_lang['filter_by_username'] = 'Filter by user name...';
$_lang['finish'] = 'Finish';
$_lang['folder'] = 'Folder';
Expand Down Expand Up @@ -315,7 +314,7 @@
$_lang['orm_container_rename'] = 'Rename Container';
$_lang['orm_container_remove'] = 'Delete Container';
$_lang['orm_container_remove_confirm'] = 'Are you sure you want to delete this container and all attributes below it? This is irreversible.';
$_lang['pagetitle'] = 'Resource‘s Title';
$_lang['pagetitle'] = 'Resource\'s title';
$_lang['page_title'] = 'Resource Title';
$_lang['parameter'] = 'Parameter';
$_lang['parameters'] = 'Parameters';
Expand Down
59 changes: 20 additions & 39 deletions core/src/Revolution/Processors/Context/GetList.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use MODX\Revolution\modContext;
use MODX\Revolution\modAccessContext;
use MODX\Revolution\modResource;
use MODX\Revolution\modUserGroup;
use MODX\Revolution\Processors\Model\GetListProcessor;
use xPDO\Om\xPDOObject;
Expand Down Expand Up @@ -54,7 +53,7 @@ public function initialize()
{
$initialized = parent::initialize();
$this->setDefaultProperties([
'query' => '',
'search' => '',
'exclude' => '',
]);
$this->canCreate = $this->modx->hasPermission('new_context');
Expand All @@ -72,11 +71,11 @@ public function initialize()
*/
public function prepareQueryBeforeCount(xPDOQuery $c)
{
$query = $this->getProperty('query');
if (!empty($query)) {
$search = $this->getProperty('search');
if (!empty($search)) {
$c->where([
'key:LIKE' => '%' . $query . '%',
'OR:description:LIKE' => '%' . $query . '%',
'key:LIKE' => '%' . $search . '%',
'OR:description:LIKE' => '%' . $search . '%',
]);
}
$exclude = $this->getProperty('exclude');
Expand All @@ -90,39 +89,21 @@ public function prepareQueryBeforeCount(xPDOQuery $c)
limit results to only those contexts present in the current grid.
*/
if ($this->isGridFilter) {
$targetGrid = $this->getProperty('targetGrid', '');
switch ($targetGrid) {
case 'MODx.grid.UserGroupContext':
if ($userGroup = $this->getProperty('usergroup', false)) {
$c->innerJoin(
modAccessContext::class,
'modAccessContext',
[
'`modAccessContext`.`target` = `modContext`.`key`',
'`modAccessContext`.`principal` = ' . (int)$userGroup,
'`modAccessContext`.`principal_class` = ' . $this->modx->quote(modUserGroup::class)
]
);
if ($policy = $this->getProperty('policy', false)) {
$c->where([
'`modAccessContext`.`policy`' => (int)$policy
]);
}
}
break;

case 'MODx.grid.Trash':
$c->innerJoin(
modResource::class,
'modResource',
[
'`modResource`.`context_key` = `modContext`.`key`',
'`modResource`.`deleted` = 1'
]
);
break;

// no default case
if ($userGroup = $this->getProperty('usergroup', false)) {
$c->innerJoin(
modAccessContext::class,
'modAccessContext',
[
'`modAccessContext`.`target` = `modContext`.`key`',
'`modAccessContext`.`principal` = ' . (int)$userGroup,
'`modAccessContext`.`principal_class` = ' . $this->modx->quote(modUserGroup::class)
]
);
if ($policy = $this->getProperty('policy', false)) {
$c->where([
'`modAccessContext`.`policy`' => (int)$policy
]);
}
}
}
return $c;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

/*
* This file is part of the MODX Revolution package.
*
Expand All @@ -11,6 +10,7 @@

namespace MODX\Revolution\Processors\Element\Plugin\Event;


use MODX\Revolution\modEvent;
use MODX\Revolution\Processors\ModelProcessor;
use MODX\Revolution\modPluginEvent;
Expand Down Expand Up @@ -49,6 +49,13 @@ public function process()
foreach ($data['results'] as $event) {
$eventArray = $event->toArray();
$eventArray['enabled'] = $event->get('enabled') ? 1 : 0;

$eventArray['menu'] = [
[
'text' => $this->modx->lexicon('edit'),
'handler' => 'this.updateEvent',
],
];
$list[] = $eventArray;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

/*
* This file is part of the MODX Revolution package.
*
Expand All @@ -11,11 +10,10 @@

namespace MODX\Revolution\Processors\Element\Template\TemplateVar;


use MODX\Revolution\Processors\Model\GetListProcessor;
use MODX\Revolution\modTemplate;
use MODX\Revolution\modTemplateVar;
use xPDO\Om\xPDOObject;
use xPDO\Om\xPDOQuery;

/**
* Gets a list of TVs, marking ones associated with the template.
Expand All @@ -38,41 +36,26 @@ class GetList extends GetListProcessor
public $permission = ['view_tv' => true, 'view_template' => true];
public $languageTopics = ['template'];

protected $category = 0;
protected $query = '';
protected $isFiltered = false;

/**
* {@inheritDoc}
*/
public function initialize()
{
$this->category = (int)$this->getProperty('category', 0);
$this->query = $this->getProperty('query', '');
$this->isFiltered = $this->category > 0 || $this->query;
return parent::initialize();
}

/**
* Prepare conditions for TV list
*
* @return array
*/
public function prepareConditions(): array
public function prepareConditions()
{
$conditions = [];

if (!$this->isFiltered) {
return $conditions;
}

if ($this->category) {
$conditions[] = ['category' => $this->category];
$category = (integer)$this->getProperty('category', 0);
if ($category) {
$conditions[] = ['category' => $category];
}

if (!empty($this->query)) {
$query = $this->getProperty('query', '');
if (!empty($query)) {
$conditions[] = [
'name:LIKE' => '%' . $this->query . '%',
'OR:caption:LIKE' => '%' . $this->query . '%',
'OR:description:LIKE' => '%' . $this->query . '%'
'name:LIKE' => '%' . $query . '%',
'OR:caption:LIKE' => '%' . $query . '%',
'OR:description:LIKE' => '%' . $query . '%',
];
}

Expand All @@ -96,71 +79,37 @@ public function loadTemplate()
}

/**
* {@inheritDoc}
* {@inheritdoc}
* @return array
*/
public function getData(): array
public function getData()
{
$sort = $this->getProperty('sort');
$dir = $this->getProperty('dir');
$limit = (int)$this->getProperty('limit');
$start = (int)$this->getProperty('start');
$limit = intval($this->getProperty('limit'));
$start = intval($this->getProperty('start'));
$conditions = $this->prepareConditions();

$template = $this->loadTemplate();
$tvList = $template->getTemplateVarList([$sort => $dir], $limit, $start, $conditions);

$data = [
'total' => $this->isFiltered ? $this->getFilteredCount() : $tvList['total'],
'total' => $tvList['total'],
'results' => $tvList['collection'],
];

return $data;
}

/**
* Workaround to get correct total count when list is filtered
*/
public function getFilteredCount(): int
{
$c = $this->modx->newQuery(modTemplateVar::class);
$c = $this->prepareQueryBeforeCount($c);
$filteredCount = $this->modx->getCount(modTemplateVar::class, $c);

return $filteredCount;
}

/**
* {@inheritDoc}
*/
public function prepareQueryBeforeCount(xPDOQuery $c)
{
if (!$this->isFiltered) {
return $c;
}

if ($this->category) {
$c->where(
['category' => $this->category]
);
}

if ($this->query) {
$c->where([
'name:LIKE' => '%' . $this->query . '%',
'OR:caption:LIKE' => '%' . $this->query . '%',
'OR:description:LIKE' => '%' . $this->query . '%',
]);
}
return $c;
}

/**
* {@inheritDoc}
* {@inheritdoc}
* @param xPDOObject $object
*
* @return array|mixed
*/
public function prepareRow(xPDOObject $object)
{
$tvArray = $object->get(['id', 'name', 'caption', 'tv_rank', 'category_name']);
$tvArray['access'] = (bool)$object->get('access');
$tvArray['access'] = (boolean)$object->get('access');

$tvArray['perm'] = [];
if ($this->modx->hasPermission('edit_tv')) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

/*
* This file is part of the MODX Revolution package.
*
Expand All @@ -11,6 +10,7 @@

namespace MODX\Revolution\Processors\Element\TemplateVar\Template;


use MODX\Revolution\modCategory;
use MODX\Revolution\Processors\Processor;
use MODX\Revolution\modTemplate;
Expand Down Expand Up @@ -82,11 +82,10 @@ public function getData()

/* query for templates */
$c = $this->modx->newQuery(modTemplate::class);
$query = $this->getProperty('query', '');
$query = $this->getProperty('query');
if (!empty($query)) {
$c->where([
'templatename:LIKE' => '%' . $query . '%',
'OR:description:LIKE' => '%' . $query . '%'
'templatename:LIKE' => "%$query%",
]);
}
$c->leftJoin(modCategory::class, 'Category');
Expand All @@ -108,12 +107,8 @@ public function getData()
$c->select([
'category_name' => 'Category.category',
]);
$c->select($this->modx->getSelectColumns(
modTemplateVarTemplate::class,
'TemplateVarTemplates',
'',
['tmplvarid']
));
$c->select($this->modx->getSelectColumns(modTemplateVarTemplate::class, 'TemplateVarTemplates', '',
['tmplvarid']));
$c->select(['access' => 'TemplateVarTemplates.tmplvarid']);
$c->sortby($this->getProperty('sort'), $this->getProperty('dir'));
if ($isLimit) {
Expand Down
10 changes: 0 additions & 10 deletions core/src/Revolution/Processors/Resource/Trash/GetList.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,6 @@ public function prepareQueryBeforeCount(xPDOQuery $c)
$c->leftJoin(modUser::class, 'User', 'modResource.deletedby = User.id');
$c->leftJoin(modContext::class, 'Context', 'modResource.context_key = Context.key');

// TODO add only resources if we have the save permission here (on the context!!)
// we need the following permissions:
// undelete_document - to restore the document
// delete_document - thats perhaps not necessary, because all documents are already deleted
// but we need the purge_deleted permission - for every single file
if ($deleted = $this->getDeleted()) {
$c->where(['modResource.id:IN' => $deleted]);
} else {
$c->where(['modResource.id:IN' => 0]);
}
if (!empty($query)) {
$c->where([
'modResource.pagetitle:LIKE' => '%' . $query . '%',
Expand Down
Loading

0 comments on commit 5461b72

Please sign in to comment.