|
3 | 3 | namespace FileMan\Processors\File; |
4 | 4 |
|
5 | 5 | use FileMan\Model\File; |
| 6 | +use MODX\Revolution\modResource; |
6 | 7 | use MODX\Revolution\modUser; |
7 | 8 | use MODX\Revolution\Processors\Model\GetListProcessor; |
| 9 | +use xPDO\Om\xPDOObject; |
8 | 10 | use xPDO\Om\xPDOQuery; |
9 | 11 |
|
10 | 12 | class GetList extends GetListProcessor |
@@ -54,36 +56,50 @@ public function beforeQuery() |
54 | 56 | public function prepareQueryBeforeCount(xPDOQuery $c) |
55 | 57 | { |
56 | 58 | $resourceId = (int) $this->getProperty('resource_id'); |
57 | | - $user = trim($this->getProperty('user')); |
58 | | - $query = trim($this->getProperty('query')); |
| 59 | + $user = trim($this->getProperty('user')); |
| 60 | + $query = trim($this->getProperty('query')); |
59 | 61 |
|
60 | 62 | $c->select($this->modx->getSelectColumns(File::class, 'File')); |
61 | 63 |
|
62 | | - if ($query){ |
63 | | - $c->where(array( |
| 64 | + if ($query){ |
| 65 | + $c->where(array( |
64 | 66 | 'name:LIKE' => "%{$query}%", |
65 | 67 | 'OR:title:LIKE' => "%{$query}%", |
66 | 68 | 'OR:description:LIKE' => "%{$query}%", |
67 | 69 | 'OR:group:LIKE' => "%{$query}%" |
68 | 70 | )); |
69 | 71 | } |
70 | 72 |
|
71 | | - if ($user || ($resourceId == 0)) { |
72 | | - $c->select('User.username'); |
73 | | - $c->leftJoin(modUser::class, 'User', 'User.id=File.user_id'); |
74 | | - } |
| 73 | + if ($user || ($resourceId == 0)) { |
| 74 | + $c->select('User.username'); |
| 75 | + $c->leftJoin(modUser::class, 'User', 'User.id=File.user_id'); |
| 76 | + } |
75 | 77 |
|
76 | | - if ($user) |
77 | | - $c->where(array('User.username:LIKE' => "%$user%")); |
| 78 | + if ($user) |
| 79 | + $c->where(array('User.username:LIKE' => "%$user%")); |
78 | 80 |
|
79 | | - if ($resourceId > 0) |
80 | | - $c->where(array('resource_id' => $resourceId)); |
81 | | - else { |
82 | | - $c->select('Resource.pagetitle'); |
83 | | - $c->leftJoin('modResource', 'Resource', 'Resource.id=File.resource_id'); |
84 | | - } |
| 81 | + if ($resourceId > 0) |
| 82 | + $c->where(array('resource_id' => $resourceId)); |
| 83 | + else { |
| 84 | + $c->leftJoin('modResource', 'Resource', 'Resource.id=File.resource_id'); |
| 85 | + $c->select($this->modx->getSelectColumns(modResource::class, 'Resource', 'resource_', ['pagetitle'])); |
| 86 | + } |
85 | 87 |
|
86 | 88 | return $c; |
87 | 89 | } |
88 | 90 |
|
| 91 | + /** |
| 92 | + * Prepare the row for iteration |
| 93 | + * |
| 94 | + * @param xPDOObject $object |
| 95 | + * |
| 96 | + * @return array |
| 97 | + */ |
| 98 | + public function prepareRow(xPDOObject $object) |
| 99 | + { |
| 100 | + $array = $object->toArray(); |
| 101 | + $array['resource_pagetitle'] = strip_tags($array['resource_pagetitle']); |
| 102 | + return $array; |
| 103 | + } |
| 104 | + |
89 | 105 | } |
0 commit comments