|
18 | 18 | $tplRow = $modx->getOption('tplRow', $scriptProperties, 'tpl.FileMan.Row'); |
19 | 19 | $wrapIfEmpty = $modx->getOption('wrapIfEmpty', $scriptProperties, false); |
20 | 20 |
|
21 | | -$usePdoTools = $fileMan->pdoToolsAvailable() |
22 | | - ? $modx->getOption('fileman_pdotools', $scriptProperties, true) |
23 | | - : false; |
| 21 | +$usePdoTools = $fileMan->pdoToolsAvailable() && $modx->getOption('fileman_pdotools', $scriptProperties, true); |
24 | 22 |
|
25 | | -$sortby = $modx->getOption('sortBy', $scriptProperties, 'sort_order'); |
26 | | -$sortdir = $modx->getOption('sortDir', $scriptProperties, 'ASC'); |
| 23 | +$sortBy = $modx->getOption('sortBy', $scriptProperties, 'sort_order'); |
| 24 | +$sortDir = $modx->getOption('sortDir', $scriptProperties, 'ASC'); |
27 | 25 | $limit = $modx->getOption('limit', $scriptProperties, 0); |
28 | 26 | $offset = $modx->getOption('offset', $scriptProperties, 0); |
29 | 27 | $totalVar = $modx->getOption('totalVar', $scriptProperties, 'total'); |
|
32 | 30 |
|
33 | 31 | $ids = $modx->getOption('ids', $scriptProperties, ''); |
34 | 32 | $resource = $modx->getOption('resource', $scriptProperties, 0); |
| 33 | +$showUnpublished = $modx->getOption('showUnpublished', $scriptProperties, false); |
35 | 34 | $showGroups = $modx->getOption('showGroups', $scriptProperties, true); |
36 | 35 | $makeUrl = $modx->getOption('makeUrl', $scriptProperties, true); |
37 | 36 | $private = $modx->getOption('private', $scriptProperties, false); |
|
50 | 49 | // Build query |
51 | 50 | $c = $modx->newQuery(File::class); |
52 | 51 |
|
| 52 | +if (!$showUnpublished) { |
| 53 | + $c->where([ |
| 54 | + 'published' => true |
| 55 | + ]); |
| 56 | +} |
53 | 57 | // resource |
54 | 58 | $c->where([ |
55 | 59 | 'resource_id' => ($resource > 0) ? $resource : $modx->resource->get('id') |
|
71 | 75 | } |
72 | 76 |
|
73 | 77 | // sort |
74 | | -$c->sortby($modx->escape($sortby), $sortdir); |
| 78 | +$c->sortby($modx->escape($sortBy), $sortDir); |
75 | 79 |
|
76 | 80 | $items = $modx->getIterator(File::class, $c); |
77 | 81 |
|
|
83 | 87 |
|
84 | 88 | /** @var File $item */ |
85 | 89 | foreach ($items as $item) { |
86 | | - $item->source = $mediaSource; |
| 90 | + $item->setMediaSource($mediaSource); |
87 | 91 | $itemArr = $item->toArray(); |
88 | 92 |
|
89 | 93 | if ($makeUrl) { |
|
0 commit comments