You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
108 lines
3.4 KiB
108 lines
3.4 KiB
15 years ago
|
<?php
|
||
|
/* For licensing terms, see /license.txt */
|
||
7 years ago
|
|
||
18 years ago
|
/**
|
||
7 years ago
|
* This is a plugin for the documents tool. It looks for .jpg, .jpeg, .gif, .png
|
||
|
* files (since these are the files that can be viewed in a browser) and creates
|
||
|
* a slideshow with it by allowing to go to the next/previous image.
|
||
|
* You can also have a quick overview (thumbnail view) of all the images in
|
||
|
* that particular folder.
|
||
15 years ago
|
*
|
||
7 years ago
|
* Each slideshow is folder based. Only
|
||
|
* the images of the chosen folder are shown.
|
||
15 years ago
|
*
|
||
7 years ago
|
* This file has two large sections.
|
||
|
* 1. code that belongs in document.php, but to avoid clutter I put the code here
|
||
|
* (not present) 2. the function resize_image that handles the image resizing
|
||
15 years ago
|
*
|
||
7 years ago
|
* @author Patrick Cool, responsible author
|
||
|
* @author Roan Embrechts, minor cleanup
|
||
7 years ago
|
*
|
||
7 years ago
|
* @package chamilo.document
|
||
15 years ago
|
*/
|
||
14 years ago
|
/**
|
||
7 years ago
|
* General code that belongs in document.php.
|
||
14 years ago
|
*
|
||
7 years ago
|
* This code should indeed go in documents.php but since document.php is already a really ugly file with
|
||
|
* too much things in one file , I decided to put the code for document.php here and to include this
|
||
|
* file into document.php
|
||
14 years ago
|
*/
|
||
7 years ago
|
|
||
6 years ago
|
// We check if there are images in this folder by searching the extensions for .jpg, .gif, .png
|
||
18 years ago
|
// grabbing the list of all the documents of this folder
|
||
7 years ago
|
$array_to_search = !empty($documentAndFolders) && is_array($documentAndFolders) ? $documentAndFolders : [];
|
||
18 years ago
|
|
||
16 years ago
|
if (count($array_to_search) > 0) {
|
||
7 years ago
|
foreach ($array_to_search as $file) {
|
||
|
$all_files[] = basename($file['path']);
|
||
7 years ago
|
}
|
||
18 years ago
|
}
|
||
|
|
||
10 years ago
|
// Always show gallery.
|
||
|
$image_present = 1;
|
||
|
/*
|
||
13 years ago
|
if (isset($all_files) && is_array($all_files) && count($all_files) > 0) {
|
||
7 years ago
|
foreach ($all_files as & $file) {
|
||
|
$slideshow_extension = strrchr($file, '.');
|
||
|
$slideshow_extension = strtolower($slideshow_extension);
|
||
|
if (in_array($slideshow_extension, $accepted_extensions)) {
|
||
|
$image_present = 1;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
10 years ago
|
}*/
|
||
|
|
||
15 years ago
|
$tablename_column = isset($_GET['tablename_column']) ? Security::remove_XSS($_GET['tablename_column']) : 0;
|
||
16 years ago
|
if ($tablename_column == 0) {
|
||
7 years ago
|
$tablename_column = 1;
|
||
16 years ago
|
} else {
|
||
7 years ago
|
$tablename_column = intval($tablename_column) - 1;
|
||
18 years ago
|
}
|
||
|
|
||
18 years ago
|
$image_files_only = sort_files($array_to_search);
|
||
18 years ago
|
|
||
10 years ago
|
function sort_files($table)
|
||
|
{
|
||
8 years ago
|
$tablename_direction = isset($_GET['tablename_direction']) ? Security::remove_XSS($_GET['tablename_direction']) : 'ASC';
|
||
7 years ago
|
$accepted_extensions = ['.jpg', '.jpeg', '.gif', '.png', '.bmp', '.svg'];
|
||
|
$temp = [];
|
||
16 years ago
|
|
||
7 years ago
|
foreach ($table as &$file_array) {
|
||
10 years ago
|
if ($file_array['filetype'] == 'file') {
|
||
|
$slideshow_extension = strrchr($file_array['path'], '.');
|
||
16 years ago
|
$slideshow_extension = strtolower($slideshow_extension);
|
||
10 years ago
|
if (in_array($slideshow_extension, $accepted_extensions)) {
|
||
|
$start_date = isset($file_array['insert_date']) ? $file_array['insert_date'] : null;
|
||
7 years ago
|
$temp[] = ['file', basename($file_array['path']), $file_array['size'], $start_date];
|
||
10 years ago
|
}
|
||
|
}
|
||
|
}
|
||
16 years ago
|
|
||
10 years ago
|
if ($tablename_direction == 'DESC') {
|
||
|
usort($temp, 'rsort_table');
|
||
|
} else {
|
||
|
usort($temp, 'sort_table');
|
||
|
}
|
||
16 years ago
|
|
||
7 years ago
|
$final_array = [];
|
||
7 years ago
|
foreach ($temp as &$file_array) {
|
||
10 years ago
|
$final_array[] = $file_array[1];
|
||
|
}
|
||
16 years ago
|
|
||
7 years ago
|
return $final_array;
|
||
18 years ago
|
}
|
||
|
|
||
7 years ago
|
function sort_table($a, $b)
|
||
|
{
|
||
|
global $tablename_column;
|
||
|
|
||
|
return strnatcmp($a[$tablename_column], $b[$tablename_column]);
|
||
18 years ago
|
}
|
||
|
|
||
7 years ago
|
function rsort_table($a, $b)
|
||
|
{
|
||
|
global $tablename_column;
|
||
|
|
||
|
return strnatcmp($b[$tablename_column], $a[$tablename_column]);
|
||
16 years ago
|
}
|