'/') {
$folder = $path.'/';
} else {
$folder = '/';
}
$sys_course_path = api_get_path(SYS_COURSE_PATH);
// including the functions for the slideshow
include ('slideshow.inc.php');
// breadcrumb navigation
$url = "document.php?curdirpath=".$pathurl;
$originaltoolname = get_lang('Documents');
$interbreadcrumb[] = array ("url" => Security::remove_XSS($url), "name" => $originaltoolname);
// because $nametools uses $_SERVER['PHP_SELF'] for the breadcrumbs instead of $_SERVER['REQUEST_URI'], I had to
// bypass the $nametools thing and use tags in the $interbreadcrump array
//$url = "slideshow.php?curdirpath=".$pathurl;
$originaltoolname = get_lang('SlideShow');
//$interbreadcrumb[]= array ("url"=>$url, "name"=>$originaltoolname );
Display :: display_header($originaltoolname, "Doc");
// loading the slides from the session
if (isset($_SESSION["image_files_only"])) {
$image_files_only = $_SESSION["image_files_only"];
}
// calculating the current slide, next slide, previous slide and the number of slides
if ($slide_id <> "all") {
if ($slide_id) {
$slide = $slide_id;
} else {
$slide = 0;
}
$previous_slide = $slide -1;
$next_slide = $slide +1;
} // if ($slide_id<>"all")
$total_slides = count($image_files_only);
?>
';
// =======================================================================
// TREATING THE POST DATA FROM SLIDESHOW OPTIONS
// =======================================================================
// if we come from slideshowoptions.php we sessionize (new word !!! ;-) the options
if (isset ($_POST['Submit'])) {
// we come from slideshowoptions.php
$_SESSION["image_resizing"] = Security::remove_XSS($_POST['radio_resizing']);
if ($_POST['radio_resizing'] == "resizing" && $_POST['width'] != '' && $_POST['height'] != '') {
//echo "resizing";
$_SESSION["image_resizing_width"] = Security::remove_XSS($_POST['width']);
$_SESSION["image_resizing_height"] = Security::remove_XSS($_POST['height']);
} else {
//echo "unsetting the session heighte and width";
$_SESSION["image_resizing_width"] = null;
$_SESSION["image_resizing_height"] = null;
}
} // if ($submit)
// The target height and width depends if we choose resizing or no resizing
if ($_SESSION["image_resizing"] == "resizing") {
$target_width = $_SESSION["image_resizing_width"];
$target_height = $_SESSION["image_resizing_height"];
} else {
$image_width = $source_width;
$image_height = $source_height;
}
// =======================================================================
// THUMBNAIL VIEW
// =======================================================================
// this is for viewing all the images in the slideshow as thumbnails.
$image_tag = array ();
if ($slide_id == "all") {
$thumbnail_width = 100;
$thumbnail_height = 100;
$row_items = 4;
if (is_array($image_files_only)) {
foreach ($image_files_only as $one_image_file) {
$image = $sys_course_path.$_course['path']."/document".$folder.$one_image_file;
if (file_exists($image)) {
$image_height_width = resize_image($image, $thumbnail_width, $thumbnail_height, 1);
$image_height = $image_height_width[0];
$image_width = $image_height_width[1];
if ($path and $path !== "/") {
$doc_url = $path."/".$one_image_file;
} else {
$doc_url = $path.$one_image_file;
}
$image_tag[] = "
";
}
} // foreach ($image_files_only as $one_image_file)
}
} // if ($slide_id=="all")
// creating the table
$html_table='';
echo '';
$i = 0;
$count_image=count($image_tag);
$number_image=6;
$number_iteration=ceil($count_image/$number_image);
$p=0;
for ($k=0;$k<$number_iteration;$k++) {
echo '';
for ($i=0;$i<$number_image;$i++) {
if (!is_null($image_tag[$p])) {
echo '';
echo ' | ';
}
$p++;
}
echo '
';
}
echo '
';
// =======================================================================
// ONE AT A TIME VIEW
// =======================================================================
// this is for viewing all the images in the slideshow one at a time.
if ($slide_id !== "all") {
$image = $sys_course_path.$_course['path']."/document".$folder.$image_files_only[$slide];
if (file_exists($image)) {
$image_height_width = resize_image($image, $target_width, $target_height);
$image_height = $image_height_width[0];
$image_width = $image_height_width[1];
if ($_SESSION["image_resizing"] == "resizing") {
$height_width_tags = 'width="'.$image_width.'" height="'.$image_height.'"';
/* // Removed by Ivan Tcholakov, 04-MAY-2009. After some changes this fragment of code is not needed anymore.
//adjust proportions. Juan Carlos Raсa Trabado TODO: replace resize_image function ?
$size = @ getimagesize($image);
$height_width_tags = (($size[1] > $image_width) ? 'width="'.$image_width.'"' : '');
$height_width_tags = (($size[1] > $image_height) ? 'height="'.$image_height.'"' : '');
*/
}
// showing the comment of the image, Patrick Cool, 8 april 2005
// this is done really quickly and should be cleaned up a little bit using the API functions
$tbl_documents = Database::get_course_table(TABLE_DOCUMENT);
if ($path=='/') {
$pathpart='/';
} else {
$pathpart=$path.'/';
}
$sql = "SELECT * FROM $tbl_documents WHERE path='".Database::escape_string($pathpart.$image_files_only[$slide])."'";
$result = api_sql_query($sql,__FILE__,__LINE__);
$row = Database::fetch_array($result);
// back forward buttons
echo '';
echo '
';
echo '';
echo '';
echo '';
echo " ";
echo ' | ';
echo '
';
echo '';
echo '';
$aux= explode(".", htmlspecialchars($image_files_only[$slide]));
$ext= $aux[count($aux)-1];
echo ''.basename(htmlspecialchars($image_files_only[$slide]), '.'.$ext).'';
echo ' '.$row['comment'].' ';
list($width, $high) = getimagesize($image);
echo $width.' x '.$high.' ';
echo round((filesize($image)/1024),2).' KB';
echo ' - '.$ext;
echo ' | ';
echo '
';
echo '
';
} else {
Display::display_warning_message(get_lang('FileNotExist'));
}
} // if ($slide_id!=="all")
Display :: display_footer();
?>