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