1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
15:
16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
17:
18: cInclude('includes', 'functions.upl.php');
19:
20: $isZipFile = isArchive($_REQUEST['file']);
21:
22: $page = new cGuiPage('upl_edit');
23:
24: $page->addStyle('jquery/plugins/timepicker.css');
25: $page->addScript('jquery/plugins/timepicker.js');
26: $page->addScript('include.upl_edit.js');
27:
28:
29: if (($lang_short = substr(strtolower($belang), 0, 2)) != 'en') {
30: $page->addScript('jquery/plugins/timepicker-' . $lang_short . '.js');
31: $page->addScript('jquery/plugins/datepicker-' . $lang_short . '.js');
32: }
33:
34: $form = new cGuiTableForm('properties');
35: $form->setVar('frame', $frame);
36: $form->setVar('area', 'upl');
37: $form->setVar('path', $_REQUEST['path']);
38: $form->setVar('file', $_REQUEST['file']);
39: $form->setVar('action', 'upl_modify_file');
40: $form->setVar('startpage', $_REQUEST['startpage']);
41: $form->setVar('sortby', $_REQUEST['sortby']);
42: $form->setVar('sortmode', $_REQUEST['sortmode']);
43: $form->setVar('thumbnailmode', $_REQUEST['thumbnailmode']);
44:
45: $form->addHeader(i18n('Edit'));
46:
47: if (isset($_REQUEST['zip'])) {
48: var_dump('zip');
49: }
50: $properties = new cApiPropertyCollection();
51: $uploads = new cApiUploadCollection();
52:
53: if (cApiDbfs::isDbfs($_REQUEST['path'])) {
54: $qpath = $_REQUEST['path'] . '/';
55: } else {
56: $qpath = $_REQUEST['path'];
57: }
58:
59: if ((is_writable($cfgClient[$client]['upl']['path'] . $path) || cApiDbfs::isDbfs($path)) && (int) $client > 0) {
60: $bDirectoryIsWritable = true;
61: } else {
62: $bDirectoryIsWritable = false;
63: }
64:
65: $uploads->select("idclient = '" . $client . "' AND dirname = '" . $qpath . "' AND filename='" . $_REQUEST['file'] . "'");
66:
67: if ($upload = $uploads->next()) {
68:
69:
70: $aListRows = array();
71: $aListRows['filename'] = i18n('File name');
72: $aListRows['path'] = i18n('Path');
73: $aListRows['replacefile'] = i18n('Replace file');
74: $aListRows['medianame'] = i18n('Media name');
75: $aListRows['description'] = i18n('Description');
76: $aListRows['keywords'] = i18n('Keywords');
77: $aListRows['medianotes'] = i18n('Internal notes');
78: $aListRows['copyright'] = i18n('Copyright');
79: $aListRows['protected'] = i18n('Protection');
80: $aListRows['timecontrol'] = i18n('Time control');
81: $aListRows['preview'] = i18n('Preview');
82: $aListRows['author'] = i18n('Author');
83: $aListRows['modified'] = i18n('Last modified by');
84:
85: if ($isZipFile) {
86: $id = $_GET['user_id'];
87:
88:
89: if (isset($_SESSION['zip']) && $_SESSION['zip'] === 'extract') {
90:
91: }
92:
93: $link = new cHTMLLink();
94: $link->appendContent(i18n('extract'));
95: $aListRows['zip'] = $link;
96: }
97: ($isZipFile) ? $aListRows['extractFolder'] = '<label class="ZipExtract">' . i18n('extractTo') . '</label>' : '';
98:
99:
100: if (!cApiDbfs::isDbfs($_REQUEST['path'])) {
101: unset($aListRows['protected']);
102: unset($aListRows['timecontrol']);
103: }
104:
105:
106: $_cecIterator = $_cecRegistry->getIterator('Contenido.Upl_edit.Rows');
107: if ($_cecIterator->count() > 0) {
108: while ($chainEntry = $_cecIterator->next()) {
109: $newRowList = $chainEntry->execute($aListRows);
110: if (is_array($newRowList)) {
111: $aListRows = $newRowList;
112: }
113: }
114: }
115:
116: $iIdupl = $upload->get('idupl');
117:
118: $uploadMeta = new cApiUploadMeta();
119: $uploadMeta->loadByUploadIdAndLanguageId($iIdupl, $lang);
120:
121:
122: foreach ($aListRows as $sListRow => $sTitle) {
123: $sCell = '';
124: switch ($sListRow) {
125: case 'filename':
126: $sCell = $_REQUEST['file'];
127: break;
128:
129: case 'zip':
130: $sCell = new cHTMLCheckbox('extractZip', '');
131: $sCell->setEvent('onclick', 'show();');
132:
133: break;
134:
135: case 'extractFolder':
136: $box = new cHTMLTextbox('efolder');
137: $box->setID('extractFolder');
138: $box->setValue(strstr($_REQUEST['file'], '.', TRUE));
139: $box->setClass('ZipExtract');
140: $sCell = $box;
141: $checkbox = new cHTMLCheckbox('overwrite', i18n('overwrite'));
142: $checkbox->setID('overwrite');
143: $checkbox->setLabelText(i18n('overwrite'));
144: $checkbox->setClass('ZipExtract');
145:
146: $sCell .= $checkbox;
147: break;
148:
149: case 'path':
150: $sCell = generateDisplayFilePath($qpath, 65);
151: break;
152:
153: case 'replacefile':
154: $uplelement = new cHTMLUpload('file', 40);
155: $uplelement->setDisabled(!$bDirectoryIsWritable);
156: $sCell = $uplelement->render();
157: break;
158:
159: case 'medianame':
160: if ($uploadMeta->get('medianame')) {
161: $medianame = cSecurity::unFilter($uploadMeta->get('medianame'));
162: } else {
163: $medianame = $properties->getValue('upload', $qpath . $_REQUEST['file'], 'file', 'medianame');
164: }
165:
166: $mnedit = new cHTMLTextbox('medianame', $medianame, 60);
167: $sCell = $mnedit->render();
168: break;
169:
170: case 'description':
171: if ($uploadMeta->get('description')) {
172: $description = cSecurity::unFilter($uploadMeta->get('description'));
173: } else {
174: $description = '';
175: }
176:
177: $dsedit = new cHTMLTextarea('description', $description);
178: $sCell = $dsedit->render();
179: break;
180:
181: case 'keywords':
182: if ($uploadMeta->get('keywords')) {
183: $keywords = cSecurity::unFilter($uploadMeta->get('keywords'));
184: } else {
185: $keywords = $properties->getValue('upload', $qpath . $_REQUEST['file'], 'file', 'keywords');
186: }
187:
188: $kwedit = new cHTMLTextarea('keywords', $keywords);
189: $sCell = $kwedit->render();
190: break;
191:
192: case 'medianotes':
193: if ($uploadMeta->get('internal_notice')) {
194: $medianotes = cSecurity::unFilter($uploadMeta->get('internal_notice'));
195: } else {
196: $medianotes = $properties->getValue('upload', $qpath . $_REQUEST['file'], 'file', 'medianotes');
197: }
198:
199: $moedit = new cHTMLTextarea('medianotes', $medianotes);
200: $sCell = $moedit->render();
201: break;
202:
203: case 'copyright':
204: if ($uploadMeta->get('copyright')) {
205: $copyright = cSecurity::unFilter($uploadMeta->get('copyright'));
206: } else {
207: $copyright = $properties->getValue('upload', $qpath . $_REQUEST['file'], 'file', 'copyright');
208: }
209:
210: $copyrightEdit = new cHTMLTextarea('copyright', $copyright);
211: $sCell = $copyrightEdit->render();
212: break;
213:
214: case 'protected':
215: $vprotected = $properties->getValue('upload', $qpath . $_REQUEST['file'], 'file', 'protected');
216: $protected = new cHTMLCheckbox('protected', '1');
217: $protected->setChecked($vprotected);
218: $protected->setLabelText(i18n('Protected for non-logged in users'));
219: $sCell = $protected->render();
220: break;
221:
222: case 'timecontrol':
223: $iTimeMng = (int) $properties->getValue('upload', $qpath . $_REQUEST['file'], 'file', 'timemgmt');
224: $sStartDate = $properties->getValue('upload', $qpath . $_REQUEST['file'], 'file', 'datestart');
225: $sEndDate = $properties->getValue('upload', $qpath . $_REQUEST['file'], 'file', 'dateend');
226:
227: $oTimeCheckbox = new cHTMLCheckbox('timemgmt', i18n('Use time control'));
228: $oTimeCheckbox->setChecked($iTimeMng);
229:
230: $sHtmlTimeMng = $oTimeCheckbox->render();
231: $sHtmlTimeMng .= "<table id='dbfsTimecontrol' class='borderless' border='0' cellpadding='0' cellspacing='0'>\n";
232: $sHtmlTimeMng .= "<tr><td><label for='datestart'>" . i18n('Start date') . "</label></td>\n";
233: $sHtmlTimeMng .= '<td><input type="text" name="datestart" id="datestart" value="' . $sStartDate . '" size="20" maxlength="40" class="text_medium">' .
234: '</td></tr>';
235: $sHtmlTimeMng .= "<tr><td><label for='dateend'>" . i18n('End date') . "</label></td>\n";
236: $sHtmlTimeMng .= '<td><input type="text" name="dateend" id="dateend" value="' . $sEndDate . '" size="20" maxlength="40" class="text_medium">' .
237: '</td></tr>';
238: $sHtmlTimeMng .= "</table>\n";
239:
240: $sCell = $sHtmlTimeMng;
241: break;
242:
243: case 'preview':
244: if (cApiDbfs::isDbfs($_REQUEST['path'])) {
245: $sCell = '<a target="_blank" href="' . $sess->url(cRegistry::getFrontendUrl() . "dbfs.php?file=" . $qpath . $_REQUEST['file']) . '"><img class="bordered" src="' . uplGetThumbnail($qpath . $_REQUEST['file'], 350) . '"></a>';
246: } else {
247: $sCell = '<a target="_blank" href="' . $cfgClient[$client]['upl']['htmlpath'] . $qpath . $_REQUEST['file'] . '"><img class="bordered" src="' . uplGetThumbnail($qpath . $_REQUEST['file'], 350) . '"></a>';
248: }
249: break;
250:
251: case 'author':
252: $oUser = new cApiUser($upload->get('author'));
253: $sCell = $oUser->get('username') . ' (' . displayDatetime($upload->get('created')) . ')';
254: break;
255:
256: case 'modified':
257: $oUser = new cApiUser($upload->get('modifiedby'));
258: $sCell = $oUser->get('username') . ' (' . displayDatetime($upload->get('lastmodified')) . ')';
259: break;
260:
261: default:
262:
263: $_cecIterator = $_cecRegistry->getIterator('Contenido.Upl_edit.RenderRows');
264:
265: if ($_cecIterator->count() > 0) {
266: $contents = array();
267: while ($chainEntry = $_cecIterator->next()) {
268: $contents[] = $chainEntry->execute($iIdupl, $qpath, $_REQUEST['file'], $sListRow);
269: }
270: }
271: $sCell = implode('', $contents);
272: }
273: $form->add($sTitle, $sCell);
274: }
275:
276: $sScript = '';
277: if (cApiDbfs::isDbfs($_REQUEST['path'])) {
278: $sScript = '
279:
280: <script type="text/javascript">
281: var startcal = new calendar1(document.properties.elements["datestart"]);
282: startcal.year_scroll = true;
283: startcal.time_comp = true;
284: var endcal = new calendar1(document.properties.elements["dateend"]);
285: endcal.year_scroll = true;
286: endcal.time_comp = true;
287:
288: </script>
289:
290: ';
291: }
292:
293: if ($bDirectoryIsWritable == false) {
294: $pager->displayError(i18n('Directory not writable') . ' (' . $cfgClient[$client]['upl']['path'] . $path . ')');
295: }
296:
297: $page->set('s', 'FORM', $form->render() . $sScript);
298: } else {
299: $page->displayCriticalError(sprintf(i18n('Could not load file %s'), $_REQUEST['file']));
300: }
301:
302: $page->render();
303:
304: function isArchive($fileName) {
305:
306: if (substr(strrchr($fileName, '.'), 1) === 'zip') {
307: return true;
308: } else {
309: return false;
310: }
311: }
312: