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