1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15:
16:
17: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
18:
19: 20: 21: 22: 23:
24: class cGuiFileOverview extends cGuiPage {
25:
26: 27: 28: 29:
30: protected $directory;
31:
32: 33: 34: 35:
36: protected $markedFile;
37:
38: 39: 40: 41:
42: protected $fileInfoType;
43:
44: 45: 46: 47:
48: protected $fileExtension;
49:
50: 51: 52: 53: 54: 55:
56: public function __construct($dir, $markedFile = '', $fileInfoType = '') {
57: parent::__construct('generic_file_overview');
58:
59:
60: $this->directory = $dir;
61: $this->markedFile = $markedFile;
62: $this->fileInfoType = $fileInfoType;
63: }
64:
65: 66: 67: 68: 69: 70:
71: public function setFileExtension($extension) {
72: if (cSecurity::isString($extension)) {
73: $extension = array($extension);
74: }
75: $this->fileExtension = $extension;
76: }
77:
78: 79: 80: 81:
82: public function render() {
83: global $area, $cfg, $perm;
84:
85:
86: $files = array();
87: foreach (new DirectoryIterator($this->directory) as $file) {
88: if ($file->isDir()) {
89: continue;
90: }
91: if (!empty($this->fileExtension) && !in_array($file->getExtension(), $this->fileExtension)) {
92: continue;
93: }
94: $files[] = $file->getBasename();
95: }
96:
97:
98: sort($files);
99:
100:
101: $this->set('s', 'JS_AREA', $area);
102: $this->set('s', 'JS_ACTION_DELETE', $area . '_delete');
103:
104:
105: $fileInfos = new cApiFileInformationCollection();
106: foreach($files as $file) {
107: if($this->fileInfoType != '') {
108: $fileInfo = $fileInfos->getFileInformation($file, $this->fileInfoTyp);
109: $this->set('d', 'DESCRIPTION', $fileInfo['description']);
110: } else {
111: $this->set('d', 'DESCRIPTION', '');
112: }
113: $this->set('d', 'AREA', $area);
114: $this->set('d', 'ACTION', $area . '_edit');
115: $this->set('d', 'FILENAME', $file);
116: if($file == $this->markedFile) {
117: $this->set('d', 'MARKED', 'marked');
118: } else {
119: $this->set('d', 'MARKED', '');
120: }
121: if(getEffectiveSetting("client", "readonly", "false") == "true" || (!$perm->have_perm_area_action($area, $area . "_delete"))) {
122: $this->set('d', 'DELETE_IMAGE', $cfg['path']['images'] . 'delete_inact.gif');
123: } else {
124: $this->set('d', 'DELETE_IMAGE', $cfg['path']['images'] . 'delete.gif');
125: }
126:
127: $this->next();
128: }
129:
130:
131: parent::render();
132: }
133:
134: }
135: