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', 'api/functions.frontend.list.php');
20: cInclude('includes', 'functions.upl.php');
21: cInclude('includes', 'functions.file.php');
22:
23: $appendparameters = $_REQUEST["appendparameters"];
24:
25: 26: 27:
28: class UploadSearchResultList extends FrontendList {
29:
30: 31: 32: 33: 34:
35: private $dark;
36:
37: 38: 39: 40:
41: private $_pathdata;
42:
43: 44: 45: 46:
47: private $_fileType;
48:
49: 50: 51: 52:
53: public $size;
54:
55: 56: 57: 58: 59: 60: 61: 62: 63: 64:
65: function convert($field, $data) {
66: global $cfg, $sess, $client, $cfgClient, $appendparameters;
67:
68: if ($field == 5) {
69: if ($data == "") {
70: return i18n("None");
71: }
72: }
73: if ($field == 4) {
74: return humanReadableSize($data);
75: }
76:
77: if ($field == 3) {
78: if ($data == "") {
79: return " ";
80: } else {
81: return $data;
82: }
83: }
84:
85: if ($field == 2) {
86:
87:
88: $icon = "<img src=\"images/but_ok.gif\" alt=\"\" /> ";
89:
90: $vpath = str_replace($cfgClient[$client]["upl"]["path"], "", $this->_pathdata);
91: $slashpos = strrpos($vpath, "/");
92: if ($slashpos === false) {
93: $file = $vpath;
94: } else {
95: $path = substr($vpath, 0, $slashpos + 1);
96: $file = substr($vpath, $slashpos + 1);
97: }
98:
99: if ($appendparameters == "imagebrowser" || $appendparameters == "filebrowser") {
100: $mstr = '<a href="javascript://" onclick="javascript:Con.getFrame(\'left_top\').document.getElementById(\'selectedfile\').value= \'' . $cfgClient[$client]["upl"]["frontendpath"] . $path . $data . '\'; window.returnValue=\'' . $cfgClient[$client]["upl"]["frontendpath"] . $path . $data . '\'; window.close();">' . $icon . $data . '</a>';
101: } else if ('' !== $this->_fileType) {
102: $markLeftPane = "Con.getFrame('left_bottom').upl.click(Con.getFrame('left_bottom').document.getElementById('$path'));";
103:
104: $tmp_mstr = '<a onmouseover="this.style.cursor=\'pointer\'" href="javascript:Con.multiLink(\'%s\', \'%s\', \'%s\', \'%s\');' . $markLeftPane . '">%s</a>';
105: $mstr = sprintf($tmp_mstr, 'right_bottom', $sess->url("main.php?area=upl_edit&frame=4&path=$path&file=$file"), 'right_top', $sess->url("main.php?area=upl&frame=3&path=$path&file=$file"), $data);
106: } else {
107: $markLeftPane = "Con.getFrame('left_bottom').upl.click(Con.getFrame('left_bottom').document.getElementById('$path'));";
108:
109: $tmp_mstr = '<a onmouseover="this.style.cursor=\'pointer\'" href="javascript:Con.multiLink(\'%s\', \'%s\', \'%s\', \'%s\');' . $markLeftPane . '">%s</a>';
110:
111: $mstr = sprintf($tmp_mstr, 'right_bottom', $sess->url("main.php?area=upl&frame=4&path=$path$file/&file="), 'right_top', $sess->url("main.php?area=upl&frame=3&path=$path&file=$file"), $data);
112: }
113: return $mstr;
114: }
115:
116: if ($field == 1) {
117: $this->_pathdata = $data;
118:
119:
120: $this->_fileType = strtolower(cFileHandler::getExtension($data));
121: switch ($this->_fileType) {
122: case "png":
123: case "psd":
124: case "gif":
125: case "tiff":
126: case "bmp":
127: case "jpeg":
128: case "jpg":
129: case "iff":
130: case "xbm":
131: case "wbmp":
132: $frontendURL = cRegistry::getFrontendUrl();
133:
134: $sCacheThumbnail = uplGetThumbnail($data, 150);
135: $sCacheName = substr($sCacheThumbnail, strrpos($sCacheThumbnail, "/") + 1, strlen($sCacheThumbnail) - (strrchr($sCacheThumbnail, '/') + 1));
136: $sFullPath = $cfgClient[$client]['cache']['path'] . $sCacheName;
137: if (cFileHandler::exists($sFullPath)) {
138: $aDimensions = getimagesize($sFullPath);
139: $iWidth = $aDimensions[0];
140: $iHeight = $aDimensions[1];
141: } else {
142: $iWidth = 0;
143: $iHeight = 0;
144: }
145:
146: if (cApiDbfs::isDbfs($data)) {
147: $retValue = '<a href="JavaScript:iZoom(\'' . $sess->url($frontendURL . "dbfs.php?file=" . $data) . '\');">
148: <img class="hover" alt="" name="smallImage" src="' . $sCacheThumbnail . '">
149: <img class="preview" alt="" name="prevImage" src="' . $sCacheThumbnail . '">
150: </a>';
151: return $retValue;
152: } else {
153: $retValue = '<a href="JavaScript:iZoom(\'' . $frontendURL . $cfgClient[$client]["upload"] . $data . '\');">
154: <img class="hover" alt="" name="smallImage" onMouseOver="correctPosition(this, ' . $iWidth . ', ' . $iHeight . ');" onmouseout="if (typeof(previewHideIe6) == \'function\') {previewHideIe6(this)}" src="' . $sCacheThumbnail . '">
155: <img class="preview" alt="" name="prevImage" src="' . $sCacheThumbnail . '">
156: </a>';
157: $retValue .= '<a href="JavaScript:iZoom(\'' . $frontendURL . $cfgClient[$client]["upload"] . $data . '\');"><img class="preview" alt="" name="prevImage" src="' . $sCacheThumbnail . '"></a>';
158: return $retValue;
159: }
160: break;
161: case '':
162:
163: return '<img class="hover_none" name="smallImage" alt="" src="' . cRegistry::getBackendUrl() . 'images/grid_folder.gif' . '">';
164: default:
165: $sCacheThumbnail = uplGetThumbnail($data, 150);
166: return '<img class="hover_none" name="smallImage" alt="" src="' . $sCacheThumbnail . '">';
167: }
168: }
169:
170: return $data;
171: }
172:
173: }
174:
175: if ($sortby == "") {
176: $sortby = 7;
177: $sortmode = "DESC";
178: }
179:
180: if ($startpage == "") {
181: $startpage = 1;
182: }
183:
184: $thisfile = $sess->url("main.php?area=$area&frame=$frame&appendparameters=$appendparameters&searchfor=$searchfor&thumbnailmode=$thumbnailmode");
185: $scrollthisfile = $thisfile . "&sortmode=$sortmode&sortby=$sortby";
186:
187: if ($sortby == 2 && $sortmode == "DESC") {
188: $fnsort = '<a class="gray" href="' . $thisfile . '&sortby=2&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Filename / Description") . '<img src="images/sort_down.gif" alt="" border="0"></a>';
189: } else {
190: if ($sortby == 2) {
191: $fnsort = '<a class="gray" href="' . $thisfile . '&sortby=2&sortmode=DESC&startpage=' . $startpage . '">' . i18n("Filename / Description") . '<img src="images/sort_up.gif" alt="" border="0"></a>';
192: } else {
193: $fnsort = '<a class="gray" href="' . $thisfile . '&sortby=2&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Filename / Description") . '</a>';
194: }
195: }
196:
197: if ($sortby == 3 && $sortmode == "DESC") {
198: $pathsort = '<a class="gray" href="' . $thisfile . '&sortby=3&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Path") . '<img src="images/sort_down.gif" alt="" border="0"></a>';
199: } else {
200: if ($sortby == 3) {
201: $pathsort = '<a class="gray" href="' . $thisfile . '&sortby=3&sortmode=DESC&startpage=' . $startpage . '">' . i18n("Path") . '<img src="images/sort_up.gif" alt="" border="0"></a>';
202: } else {
203: $pathsort = '<a class="gray" href="' . $thisfile . '&sortby=3&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Path") . "</a>";
204: }
205: }
206:
207: if ($sortby == 4 && $sortmode == "DESC") {
208: $sizesort = '<a class="gray" href="' . $thisfile . '&sortby=4&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Size") . '<img src="images/sort_down.gif" alt="" border="0"></a>';
209: } else {
210: if ($sortby == 4) {
211: $sizesort = '<a class="gray" href="' . $thisfile . '&sortby=4&sortmode=DESC&startpage=' . $startpage . '">' . i18n("Size") . '<img src="images/sort_up.gif" alt="" border="0"></a>';
212: } else {
213: $sizesort = '<a class="gray" href="' . $thisfile . '&sortby=4&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Size") . "</a>";
214: }
215: }
216:
217: if ($sortby == 5 && $sortmode == "DESC") {
218: $typesort = '<a class="gray" href="' . $thisfile . '&sortby=5&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Type") . '<img src="images/sort_down.gif" alt="" border="0"></a>';
219: } else {
220: if ($sortby == 5) {
221: $typesort = '<a class="gray" href="' . $thisfile . '&sortby=5&sortmode=DESC&startpage=' . $startpage . '">' . i18n("Type") . '<img src="images/sort_up.gif" alt="" border="0"></a>';
222: } else {
223: $typesort = '<a class="gray" href="' . $thisfile . '&sortby=5&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Type") . "</a>";
224: }
225: }
226:
227: if ($sortby == 6 && $sortmode == "DESC") {
228: $srelevance = '<a class="gray" href="' . $thisfile . '&sortby=6&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Relevance") . '<img src="images/sort_down.gif" alt="" border="0"></a>';
229: } else {
230: if ($sortby == 6) {
231: $srelevance = '<a class="gray" href="' . $thisfile . '&sortby=6&sortmode=DESC&startpage=' . $startpage . '">' . i18n("Relevance") . '<img src="images/sort_up.gif" alt="" border="0"></a>';
232: } else {
233: $srelevance = '<a class="gray" href="' . $thisfile . '&sortby=6&sortmode=ASC&startpage=' . $startpage . '">' . i18n("Relevance") . "</a>";
234: }
235: }
236:
237: $sToolsRow = '<tr class="textg_medium">
238: <th colspan="6" id="cat_navbar">
239: <div class="toolsRight">' . i18n("Searched for:") . " " . $searchfor . '</div>
240: </th>
241: </tr>';
242:
243:
244:
245: $sSpacedRow = '<tr height="10">
246: <td colspan="6" class="emptyCell"></td>
247: </tr>';
248:
249: $pagerwrap = '<tr>
250: <th colspan="6" id="cat_navbar" class="vAlignMiddle">
251: <div class="toolsRight">
252: <div class="vAlignMiddle">-C-SCROLLLEFT-</div>
253: <div class="vAlignMiddle">-C-PAGE-</div>
254: <div class="vAlignMiddle">-C-SCROLLRIGHT-</div>
255: </div>
256: ' . i18n("Files per Page") . ' -C-FILESPERPAGE-
257: </th>
258: </tr>';
259:
260: $startwrap = '<table class="hoverbox generic" cellspacing="0" cellpadding="2" border="0">
261: ' . $pagerwrap . $sSpacedRow . $sToolsRow . $sSpacedRow . '
262: <tr>
263: <th>' . i18n("Preview") . '</th>
264: <th width="100%">' . $fnsort . '</th>
265: <th>' . $pathsort . '</th>
266: <th>' . $sizesort . '</th>
267: <th>' . $typesort . '</th>
268: <th>' . $srelevance . '</th>
269: </tr>';
270: $itemwrap = '<tr>
271: <td align="center">%s</td>
272: <td class="vAlignTop nowrap">%s</td>
273: <td class="vAlignTop nowrap">%s</td>
274: <td class="vAlignTop nowrap">%s</td>
275: <td class="vAlignTop nowrap">%s</td>
276: <td class="vAlignTop nowrap">%s</td>
277: </tr>';
278: $endwrap = $sSpacedRow . $sToolsRow . $sSpacedRow . $pagerwrap . '</table>';
279:
280:
281: $page = new cGuiPage("upl_search_results");
282: $list2 = new UploadSearchResultList($startwrap, $endwrap, $itemwrap);
283:
284: $uploads = new cApiUploadCollection();
285:
286:
287: $files = uplSearch($searchfor);
288:
289: if ($thumbnailmode == '') {
290: $current_mode = $currentuser->getUserProperty('upload_folder_thumbnailmode', md5('search_results_num_per_page'));
291: if ($current_mode != '') {
292: $thumbnailmode = $current_mode;
293: } else {
294: $thumbnailmode = getEffectiveSetting('backend', 'thumbnailmode', 100);
295: }
296: }
297:
298: switch ($thumbnailmode) {
299: case 25:
300: $numpics = 25;
301: break;
302: case 50:
303: $numpics = 50;
304: break;
305: case 100:
306: $numpics = 100;
307: break;
308: case 200:
309: $numpics = 200;
310: break;
311: default:
312: $thumbnailmode = 100;
313: $numpics = 15;
314: break;
315: }
316:
317: $currentuser->setUserProperty('upload_folder_thumbnailmode', md5('search_results_num_per_page'), $thumbnailmode);
318:
319: $list2->setResultsPerPage($numpics);
320:
321: $list2->size = $thumbnailmode;
322:
323: $rownum = 0;
324: if (!is_array($files)) {
325: $files = array();
326: }
327:
328: arsort($files, SORT_NUMERIC);
329:
330: foreach ($files as $idupl => $rating) {
331: $upl = new cApiUpload($idupl);
332:
333: $filename = $upl->get('filename');
334: $dirname = $upl->get('dirname');
335: $fullDirname = $cfgClient[$client]["upl"]["path"] . $upl->get('dirname');
336:
337: $filesize = $upl->get('size');
338: if ($filesize == 0 && cFileHandler::exists($fullDirname . $filename)) {
339: $filesize = filesize($fullDirname . $filename);
340: $upl->set('size', $filesize);
341: $upl->store();
342: }
343: $description = $upl->get('description');
344:
345: $fileType = strtolower(cFileHandler::getExtension($filename));
346: $list2->setData($rownum, $dirname . $filename, $filename, $dirname, $filesize, $fileType, $rating / 10, $dirname . $filename);
347:
348: $rownum++;
349: }
350:
351: if ($rownum == 0) {
352: $page->displayWarning(i18n("No files found"));
353: $page->abortRendering();
354: $page->render();
355: return;
356: }
357:
358: if ($sortmode == "ASC") {
359: $list2->sort($sortby, SORT_ASC);
360: } else {
361: $list2->sort($sortby, SORT_DESC);
362: }
363:
364: if ($startpage < 1) {
365: $startpage = 1;
366: }
367:
368: if ($startpage > $list2->getNumPages()) {
369: $startpage = $list2->getNumPages();
370: }
371:
372: $list2->setListStart($startpage);
373:
374:
375: if ($list2->getCurrentPage() > 1) {
376: $prevpage = '<a href="' . $scrollthisfile . '&startpage=' . ($list2->getCurrentPage() - 1) . '" class="invert_hover">' . i18n("Previous Page") . '</a>';
377: } else {
378: $nextpage = ' ';
379: }
380:
381: if ($list2->getCurrentPage() < $list2->getNumPages()) {
382: $nextpage = '<a href="' . $scrollthisfile . '&startpage=' . ($list2->getCurrentPage() + 1) . '" class="invert_hover">' . i18n("Next Page") . '</a>';
383: } else {
384: $nextpage = ' ';
385: }
386:
387: if ($list2->getNumPages() > 1) {
388: $num_pages = $list2->getNumPages();
389:
390: $paging_form .= "<script type=\"text/javascript\">
391: function jumpToPage(select) {
392: var pagenumber = select.selectedIndex + 1;
393: url = '" . $sess->url("main.php?area=$area&frame=$frame&appendparameters=$appendparameters&searchfor=$searchfor&thumbnailmode=$thumbnailmode") . "';
394: document.location.href = url + '&startpage=' + pagenumber;
395: }
396: </script>";
397: $paging_form .= "<select name=\"start_page\" class=\"text_medium\" onChange=\"jumpToPage(this);\">";
398: for ($i = 1; $i <= $num_pages; $i++) {
399: if ($i == $startpage) {
400: $selected = " selected";
401: } else {
402: $selected = "";
403: }
404: $paging_form .= "<option value=\"$i\"$selected>$i</option>";
405: }
406:
407: $paging_form .= "</select>";
408: } else {
409: $paging_form = "1";
410: }
411:
412: $curpage = $paging_form . " / " . $list2->getNumPages();
413:
414: $scroller = $prevpage . $nextpage;
415:
416: $output = $list2->output(true);
417:
418: $output = str_replace("-C-SCROLLLEFT-", $prevpage, $output);
419: $output = str_replace("-C-SCROLLRIGHT-", $nextpage, $output);
420: $output = str_replace("-C-PAGE-", i18n("Page") . " " . $curpage, $output);
421: $output = str_replace("-C-THUMBNAILMODE-", $thumbnailmode, $output);
422:
423: $form = new cHTMLForm("options");
424: $form->setVar("contenido", $sess->id);
425: $form->setVar("area", $area);
426: $form->setVar("frame", $frame);
427: $form->setVar("searchfor", $searchfor);
428: $form->setVar("sortmode", $sortmode);
429: $form->setVar("sortby", $sortby);
430: $form->setVar("startpage", $startpage);
431: $form->setVar("appendparameters", $appendparameters);
432:
433: $select = new cHTMLSelectElement("thumbnailmode");
434: $select->setClass("vAlignMiddle tableElement");
435: $values = array(
436: 25 => "25",
437: 50 => "50",
438: 100 => "100",
439: 200 => "200"
440: );
441:
442: $select->autoFill($values);
443:
444: $select->setDefault($thumbnailmode);
445: $select->setEvent('change', "if (document.options.thumbnailmode[0] != 'undefined') document.options.thumbnailmode[0].value = this.value; if (document.options.thumbnailmode[1] != 'undefined') document.options.thumbnailmode[1].value = this.value;");
446:
447: $topbar = $select->render() . '<input type="image" onmouseover="this.style.cursor=\'pointer\'" src="images/submit.gif" class="vAlignMiddle tableElement">';
448:
449: $output = str_replace("-C-FILESPERPAGE-", $topbar, $output);
450:
451: $page->addScript($sess->url("iZoom.js.php"));
452:
453: $form->appendContent($output);
454: $page->set("s", "FORM", $form->render());
455: $page->render();
456: