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