-
Notifications
You must be signed in to change notification settings - Fork 452
/
FolderSet.php
78 lines (69 loc) · 2.41 KB
/
FolderSet.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
namespace Concrete\Core\File\Search\ColumnSet;
use Concrete\Core\File\Search\ColumnSet\Column\FolderItemModifiedColumn;
use Concrete\Core\File\Search\ColumnSet\Column\FolderItemSizeColumn;
use Concrete\Core\File\Search\ColumnSet\Column\FolderItemTypeColumn;
use Concrete\Core\File\Type\Type;
use Concrete\Core\File\Search\ColumnSet\Column\FolderItemNameColumn;
use Concrete\Core\Search\Column\Column;
use Concrete\Core\Search\Column\Set;
use Concrete\Core\Support\Facade\Application;
class FolderSet extends Set
{
public static function getType($node)
{
switch ($node->getTreeNodeTypeHandle()) {
case 'file_folder':
return t('Folder');
case 'search_preset':
return t('Saved Search');
case 'file':
$file = $node->getTreeNodeFileObject();
if (is_object($file)) {
$type = $file->getTypeObject();
if (is_object($type)) {
return $type->getGenericDisplayType();
} else {
return t('Unknown');
}
}
break;
}
}
public static function getDateModified($node)
{
$app = Application::getFacadeApplication();
return $app->make('date')->formatDateTime($node->getDateLastModified());
}
public static function getName($node)
{
return $node->getTreeNodeDisplayName();
}
public static function getSize($node)
{
if ($node->getTreeNodeTypeHandle() == 'file_folder') {
return '';
}
if ($node->getTreeNodeTypeHandle() == 'file') {
$file = $node->getTreeNodeFileObject();
if (is_object($file)) {
return $file->getSize();
}
}
}
public static function getFileDateActivated($f)
{
$fv = $f->getVersion();
$app = Application::getFacadeApplication();
return $app->make('date')->formatDateTime($f->getDateAdded()->getTimestamp());
}
public function __construct()
{
$this->addColumn(new FolderItemNameColumn());
$this->addColumn(new FolderItemTypeColumn());
$this->addColumn(new FolderItemModifiedColumn());
$this->addColumn(new FolderItemSizeColumn());
$type = $this->getColumnByKey('folderItemType');
$this->setDefaultSortColumn($type, 'asc');
}
}