@ -1,4 +1,4 @@
<?php // $Id: document_slideshow.inc.php 21106 2009-05-30 16:25:16Z iflorespaz $
<?php // $Id: document_slideshow.inc.php 21529 2009-06-20 14:01:55Z ivantcholakov $
/*
==============================================================================
Dokeos - elearning and course management software
@ -53,95 +53,85 @@
$accepted_extensions = array('.jpg','.jpeg','.gif','.png');
// resetting the images of the slideshow = destroying the slideshow
if (isset($_GET['action']) & & $_GET['action']=="exit_slideshow")
{
$_SESSION["image_files_only"]=null;
if (isset($_GET['action']) & & $_GET['action'] == 'exit_slideshow') {
$_SESSION['image_files_only'] = null;
unset($image_files_only);
}
// We check if there are images in this folder by searching the extensions for .jpg, .gif, .png
// grabbing the list of all the documents of this folder
//$all_files=$fileList['name'];
$array_to_search = (is_array($docs_and_folders))?$docs_and_folders:array();
$array_to_search = (is_array($docs_and_folders)) ? $docs_and_folders : array();
if(count($array_to_search) > 0) {
while(list ($key) = each ($array_to_search))
{
if (count($array_to_search) > 0) {
while(list ($key) = each ($array_to_search)) {
$all_files[] = basename($array_to_search[$key]['path']);
//echo basename($array_to_search[$key]['path']).'< br > ';
}
}
$image_present=0;
$image_present = 0;
if ( count($all_files) > 0 )
{
foreach ($all_files as $file)
{
$slideshow_extension=strrchr($file,".");
$slideshow_extension=strtolower($slideshow_extension);
if (in_array($slideshow_extension,$accepted_extensions))
{
$image_present=1;
$image_files_only[]=$file;
if (count($all_files) > 0) {
foreach ($all_files as $file) {
$slideshow_extension = strrchr($file,'.');
$slideshow_extension = strtolower($slideshow_extension);
if (in_array($slideshow_extension,$accepted_extensions)) {
$image_present = 1;
$image_files_only[] = $file;
}
}
}
$tablename_column = (isset($_GET['tablename_column'])? Security::remove_XSS($_GET['tablename_column']):0);
if($tablename_column==0){
$tablename_column=1;
$tablename_column = (isset($_GET['tablename_column']) ? Security::remove_XSS($_GET['tablename_column']) : 0);
if ($tablename_column == 0) {
$tablename_column = 1;
} else {
$tablename_column = intval($tablename_column) - 1;
}
else{
$tablename_column= intval($tablename_column)-1;
}
$tablename_direction = (isset($_GET['tablename_direction'])? Security::remove_XSS($_GET['tablename_direction']):'ASC');
$tablename_direction = (isset($_GET['tablename_direction']) ? Security::remove_XSS($_GET['tablename_direction']) : 'ASC');
$image_files_only = sort_files($array_to_search);
$_SESSION["image_files_only" ] = $image_files_only;
$_SESSION['image_files_only'] = $image_files_only;
function sort_files($table){
global $tablename_direction,$accepted_extensions;
$temp=array();
function sort_files($table) {
foreach($table as $file_array){
if($file_array['filetype']=='file'){
$slideshow_extension=strrchr($file_array['path'],".");
$slideshow_extension=strtolower($slideshow_extension);
if (in_array($slideshow_extension,$accepted_extensions))
{
global $tablename_direction, $accepted_extensions;
$temp = array();
foreach ($table as $file_array) {
if ($file_array['filetype'] == 'file') {
$slideshow_extension = strrchr($file_array['path'],'.');
$slideshow_extension = strtolower($slideshow_extension);
if (in_array($slideshow_extension,$accepted_extensions)) {
$temp[] = array('file', basename($file_array['path']), $file_array['size'], $file_array['insert_date']);
}
}
}
usort($temp, 'sort_table');
if($tablename_direction == 'DESC'){
rsort($temp);
if ($tablename_direction == 'DESC') {
usort($temp, 'rsort_table');
} else {
usort($temp, 'sort_table');
}
$final_array=array();
foreach($temp as $file_array){
$final_array = array();
foreach ($temp as $file_array) {
$final_array[] = $file_array[1];
}
return $final_array;
}
function sort_table($a, $b)
{
function sort_table($a, $b) {
global $tablename_column;
if($a[$tablename_column] > $b[$tablename_column]){
return 1;
}
else{
return -1;
}
return strnatcmp($a[$tablename_column], $b[$tablename_column]);
}
function rsort_table($a, $b) {
global $tablename_column;
return strnatcmp($b[$tablename_column], $a[$tablename_column]);
}
?>