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