$size = format_file_size($thisFile['size']); $date = format_date($thisFile['date']); $urlFileName = claro_htmlspecialchars(claro_get_file_download_url($thisFile['path'])); //$urlFileName = "goto/?doc_url=".rawurlencode($cmdFileName); //format_url($baseServUrl.$courseDir.$curDirPath."/".$fileName)); $target = get_conf('openNewWindowForDoc') ? 'target="_blank"' : ''; } elseif ($thisFile['type'] == A_DIRECTORY) { $image = 'folder'; $size = ' '; $date = ' '; $urlFileName = claro_htmlspecialchars(Url::Contextualize($_SERVER['PHP_SELF'] . '?cmd=exChDir&file=' . $cmdFileName)); $target = ''; } $out .= '<tr align="center">' . "\n" . '<td align="left">'; if (is_image($thisFile['path'])) { $out .= '<a class="' . $style . ' item' . $classItem . '" href="' . claro_htmlspecialchars(Url::Contextualize($_SERVER['PHP_SELF'] . '?docView=image&file=' . download_url_encode($thisFile['path']) . '&cwd=' . $curDirPath . $searchCmdUrl)) . '">'; } else { $out .= '<a class="' . $style . ' item' . $classItem . '" href="' . $urlFileName . '" ' . $target . ' >'; } // end if is_image $out .= '<img src="' . get_icon_url($image) . '" alt="" /> ' . $dspFileName . '</a>' . '</td>' . "\n" . '<td><small>' . $size . '</small></td>' . "\n" . '<td><small>' . $date . '</small></td>' . "\n"; /* NB : Before tracking implementation the url above was simply * "<a href=\"",$urlFileName,"\"",$style,">" */ if ($is_allowedToEdit) { /* EDIT COMMAND */ $out .= '<td>' . '<a href="' . claro_htmlspecialchars(Url::Contextualize($_SERVER['PHP_SELF'] . '?cmd=rqEdit&file=' . $cmdFileName)) . '">' . '<img src="' . get_icon_url('edit') . '" alt="' . get_lang('Modify') . '" />' . '</a>' . '</td>' . "\n"; /* DELETE COMMAND */ $out .= '<td>' . '<a href="' . claro_htmlspecialchars(Url::Contextualize($_SERVER['PHP_SELF'] . '?cmd=exRm&file=' . $cmdFileName)) . '" ' . 'onclick="return CLDOC.confirmation(\'' . clean_str_for_javascript($dspFileName) . '\');">' . '<img src="' . get_icon_url('delete') . '" alt="' . get_lang('Delete') . '" />' . '</a>' . '</td>' . "\n"; /* MOVE COMMAND */ $out .= '<td>' . '<a href="' . claro_htmlspecialchars(Url::Contextualize($_SERVER['PHP_SELF'] . '?cmd=rqMv&file=' . $cmdFileName)) . '">' . '<img src="' . get_icon_url('move') . '" alt="' . get_lang('Move') . '" />' . '</a>' . '</td>' . "\n" . '<td>';
/** * display a page of thumbnails * * @copyright (c) 2001-2011, Universite catholique de Louvain (UCL) * @param imageList (array) list containing all image file names * @param fileList (array) file properties * @param page (int) current page number * @param thumbnailWidth (int) width of thumbnails * @param colWidth (int) width of columns * @param numberOfCols (int) number of columns * @param numberOfRows (int) number of rows * @global curDirPath */ function display_thumbnails($imageList, $fileList, $page, $thumbnailWidth, $colWidth, $numberOfCols, $numberOfRows) { global $curDirPath; global $searchCmdUrl; // get index of first thumbnail on the page $displayed = get_offset($page); $html = ''; // loop on rows for ($rows = 0; $rows < $numberOfRows; $rows++) { $html .= "<tr>\n"; // loop on columns for ($cols = 0; $cols < $numberOfCols; $cols++) { // get index of image $num = $imageList[$displayed]; // get file name $fileName = $fileList[$num]['path']; // visibility style if ($fileList[$num]['visibility'] == 'i') { $style = "style=\"font-style: italic; color: silver;\""; } else { $style = ''; } // display thumbnail /*echo "<td style=\"text-align: center;\" style=\"width:" . $colWidth . "%;\">\n" ;*/ // omit colwidth since already in th $html .= "<td style=\"text-align: center;\">\n"; $html .= "<a href=\"" . claro_htmlspecialchars(Url::Contextualize($_SERVER['PHP_SELF'] . "?docView=image&file=" . download_url_encode($fileName) . "&cwd=" . $curDirPath . $searchCmdUrl)) . "\">"; // display image description using title attribute $title = ""; if ($fileList[$num]['comment']) { $text = $fileList[$num]['comment']; $text = cutstring($text, 40, false, 5, "..."); $title = "title=\"" . $text . "\""; } $html .= create_thumbnail($fileName, $thumbnailWidth, $title); // unset title for the next pass in the loop unset($title); $html .= "</a>\n"; // display image name $imgName = strlen(basename($fileList[$num]['path'])) > 25 ? substr(basename($fileList[$num]['path']), 0, 25) . "..." : basename($fileList[$num]['path']); $html .= "<p " . $style . ">" . $imgName . "</p>"; $html .= "</td>\n"; // update image number $displayed++; // finished ? if ($displayed >= count($imageList)) { $html .= "</tr>\n"; return $html; } } // end loop on columns $html .= "</tr>\n"; } // end loop on rows return $html; }
/** * Get the url to download the file at the given file path * @param string $file path to the file * @param array $context * @param string $moduleLabel * @since Claroline 1.10.5 * @return string url to the file */ function claro_get_file_download_url($file, $context = null, $moduleLabel = null) { $file = download_url_encode($file); if ($GLOBALS['is_Apache'] && get_conf('usePrettyUrl', false)) { // slash argument method - only compatible with Apache $url = get_path('url') . '/claroline/backends/download.php' . str_replace('%2F', '/', $file); } else { // question mark argument method, for IIS ... $url = get_path('url') . '/claroline/backends/download.php?url=' . $file; } $urlObj = new Url($url); if (!empty($context)) { $urlObj->relayContext(Claro_Context::getUrlContext($context)); } else { $urlObj->relayCurrentContext(); } if ($moduleLabel) { $urlObj->addParam('moduleLabel', $moduleLabel); } return $urlObj->toUrl(); }