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