/
SetList.php
50 lines (43 loc) · 1.24 KB
/
SetList.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
namespace Concrete\Core\File\Set;
use Concrete\Core\Support\Facade\Application;
use Concrete\Core\Legacy\DatabaseItemList;
use FileSet;
use Loader;
use Concrete\Core\User\User;
class SetList extends DatabaseItemList
{
protected $itemsPerPage = 10;
public function __construct()
{
$this->setQuery("SELECT FileSets.fsID FROM FileSets");
$this->sortBy('fsName', 'asc');
}
public function filterByKeywords($kw)
{
$db = Loader::db();
$this->filter(false, "(FileSets.fsName like " . $db->qstr('%' . $kw . '%') . ")");
}
public function filterByType($fsType)
{
switch ($fsType) {
case FileSet::TYPE_PRIVATE:
$u = Application::getFacadeApplication()->make(User::class);
$this->filter('FileSets.uID', $u->getUserID());
break;
}
$this->filter('FileSets.fsType', $fsType);
}
public function get($itemsToGet = 0, $offset = 0)
{
$sets = array();
$r = parent::get($itemsToGet, $offset);
foreach ($r as $row) {
$fs = FileSet::getByID($row['fsID']);
if (is_object($fs)) {
$sets[] = $fs;
}
}
return $sets;
}
}