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