Feature #272 - The "Documents" tool, part 1: Revision, code conventions and cleaning.

skala
Ivan Tcholakov 16 years ago
parent a3968311b2
commit 6ae24bc4a8
  1. 185
      main/document/create_document.php
  2. 522
      main/document/document.inc.php
  3. 657
      main/document/document.php
  4. 101
      main/document/document_slideshow.inc.php

@ -1,48 +1,19 @@
<?php // $Id: create_document.php 22259 2009-07-20 18:56:45Z ivantcholakov $
<?php
/* For licensing terms, see /license.txt */
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004-2008 Dokeos SPRL
Copyright (c) 2003 Ghent University (UGent)
Copyright (c) 2001 Universite catholique de Louvain (UCL)
Copyright (c) Olivier Brouckaert
Copyright (c) Bart Mollet, Hogeschool Gent
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
Mail: info@dokeos.com
==============================================================================
*/
/**
==============================================================================
* This file allows creating new html documents with an online WYSIWYG html380
* editor.
*
* @package dokeos.document
==============================================================================
*/
* This file allows creating new html documents with an online WYSIWYG html editor.
*
* @package chamilo.document
*/
/*
==============================================================================
INIT SECTION
==============================================================================
*/
/* INIT SECTION */
// name of the language file that needs to be included
// Name of the language file that needs to be included
$language_file = 'document';
require_once '../inc/global.inc.php';
$_SESSION['whereami'] = 'document/create';
$this_section = SECTION_COURSES;
@ -196,68 +167,52 @@ require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';
require_once api_get_path(LIBRARY_PATH).'document.lib.php';
require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
$nameTools = get_lang('CreateDocument');
/* Constants and variables */
/*
-----------------------------------------------------------
Constants and variables
-----------------------------------------------------------
*/
$dir = isset($_GET['dir']) ? Security::remove_XSS($_GET['dir']) : Security::remove_XSS($_POST['dir']); // please do not modify this dirname formatting
/*
==============================================================================
MAIN CODE
==============================================================================
*/
/* MAIN CODE */
if (api_is_in_group())
{
if (api_is_in_group()) {
$group_properties = GroupManager::get_group_properties($_SESSION['_gid']);
}
if (strstr($dir, '..'))
{
if (strstr($dir, '..')) {
$dir = '/';
}
if ($dir[0] == '.')
{
if ($dir[0] == '.') {
$dir = substr($dir, 1);
}
if ($dir[0] != '/')
{
if ($dir[0] != '/') {
$dir = '/'.$dir;
}
if ($dir[strlen($dir) - 1] != '/')
{
if ($dir[strlen($dir) - 1] != '/') {
$dir .= '/';
}
// Configuration for the FCKEDITOR
$doc_tree= explode('/', $dir);
$count_dir = count($doc_tree) -2; // "2" because at the begin and end there are 2 "/"
// Configuration for the online editor
$doc_tree = explode('/', $dir);
$count_dir = count($doc_tree) - 2; // "2" because at the begin and end there are 2 "/"
// Level correction for group documents.
if (!empty($group_properties['directory']))
{
if (!empty($group_properties['directory'])) {
$count_dir = $count_dir > 0 ? $count_dir - 1 : 0;
}
$relative_url='';
for($i=0;$i<($count_dir);$i++)
{
$relative_url.='../';
$relative_url = '';
for ($i = 0; $i < ($count_dir); $i++) {
$relative_url .= '../';
}
// we do this in order to avoid the condition in html_editor.php ==> if ($this -> fck_editor->Config['CreateDocumentWebDir']=='' || $this -> fck_editor->Config['CreateDocumentDir']== '')
// We do this in order to avoid the condition in html_editor.php ==> if ($this -> fck_editor->Config['CreateDocumentWebDir']=='' || $this -> fck_editor->Config['CreateDocumentDir']== '')
if ($relative_url== '') {
$relative_url = '/';
}
$is_allowed_to_edit = api_is_allowed_to_edit(null,true);
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
$html_editor_config = array(
'ToolbarSet' => ($is_allowed_to_edit ? 'Documents' :'DocumentsStudent'),
@ -279,15 +234,11 @@ if (!is_dir($filepath)) {
$dir = '/';
}
//------------
/**************************************************/
$to_group_id = 0;
if (isset ($_SESSION['_gid']) && $_SESSION['_gid'] != '') {
if (isset($_SESSION['_gid']) && $_SESSION['_gid'] != '') {
$req_gid = '&amp;gidReq='.$_SESSION['_gid'];
$interbreadcrumb[] = array ("url" => "../group/group_space.php?gidReq=".$_SESSION['_gid'], "name" => get_lang('GroupSpace'));
$interbreadcrumb[] = array('url' => '../group/group_space.php?gidReq='.$_SESSION['_gid'], 'name' => get_lang('GroupSpace'));
$noPHP_SELF = true;
$to_group_id = $_SESSION['_gid'];
$group = GroupManager :: get_group_properties($to_group_id);
@ -296,19 +247,16 @@ if (isset ($_SESSION['_gid']) && $_SESSION['_gid'] != '') {
api_not_allowed(true);
}
}
$interbreadcrumb[] = array ("url" => "./document.php?curdirpath=".urlencode($_GET['dir']).$req_gid, "name" => get_lang('Documents'));
$interbreadcrumb[] = array('url' => './document.php?curdirpath='.urlencode($_GET['dir']).$req_gid, 'name' => get_lang('Documents'));
if (!$is_allowed_in_course)
if (!$is_allowed_in_course) {
api_not_allowed(true);
}
if (!($is_allowed_to_edit || $_SESSION['group_member_with_upload_rights'])) {
api_not_allowed(true);
}
/*
-----------------------------------------------------------
Header
-----------------------------------------------------------
*/
/* Header */
event_access_tool(TOOL_DOCUMENT);
$display_dir = $dir;
@ -332,7 +280,7 @@ $form->addElement('hidden', 'dir');
$default['dir'] = $dir;
// Filename
$form->addElement('hidden','title_edited','false','id="title_edited"');
$form->addElement('hidden', 'title_edited', 'false', 'id="title_edited"');
/**
* Check if a document width the choosen filename allready exists
@ -351,10 +299,10 @@ function document_exists($filename) {
$renderer = & $form->defaultRenderer();
*/
//$filename_template = str_replace('{element}', "<tt>$display_dir</tt> {element} <tt>.html</tt>", $renderer->_elementTemplate);
$filename_template = str_replace('{element}', "{element}", $renderer->_elementTemplate);
$filename_template = str_replace('{element}', '{element}', $renderer->_elementTemplate); // TODO: What is the point of this statement?
$renderer->setElementTemplate($filename_template, 'filename');
// initialize group array
// Initialize group array
$group = array();
// If allowed, add element for document title
@ -369,9 +317,9 @@ if (api_get_setting('use_document_title') == 'true') {
$form->addElement('hidden', 'filename', '', array('id' => 'filename'));
//
} else {
//$form->add_textfield('filename', get_lang('FileName'),true,'class="input_titles" id="filename" onblur="check_if_still_empty()"');
//$form->add_textfield('filename', get_lang('FileName'),true,'class="input_titles" id="filename" onblur="javascript: check_if_still_empty();"');
// replace the add_textfield with this
$group[]=$form->createElement('text','filename',get_lang('FileName'),'class="input_titles" id="document_title" onblur="check_if_still_empty()"');
$group[]=$form->createElement('text', 'filename', get_lang('FileName'), 'class="input_titles" id="document_title" onblur="javascript: check_if_still_empty();"');
//$form->applyFilter('filename','trim');
//$form->addRule('filename', get_lang('ThisFieldIsRequired'), 'required');
//$form->addRule('filename', get_lang('FileExists'), 'callback', 'document_exists');
@ -381,12 +329,13 @@ if (api_get_setting('use_document_title') == 'true') {
//
}
/* Show read-only box only in groups */
if(!empty($_SESSION['_gid'])) {
// Show read-only box only in groups
if (!empty($_SESSION['_gid'])) {
//$renderer->setElementTemplate('<div class="row"><div class="label"></div><div class="formw">{element}{label}</div></div>', 'readonly');
$group[]= $form->createElement('checkbox','readonly','',get_lang('ReadOnly'));
$group[]= $form->createElement('checkbox', 'readonly', '', get_lang('ReadOnly'));
}
// add group to the form
// Add group to the form
$form->addGroup($group, 'filename_group', api_get_setting('use_document_title') == 'true' ? get_lang('Title') : get_lang('FileName') ,'&nbsp;&nbsp;&nbsp;', false);
$form->addRule('filename_group', get_lang('ThisFieldIsRequired'), 'required');
@ -429,7 +378,7 @@ if ($form->validate()) {
$values = $form->exportValues();
$readonly = isset($values['readonly']) ? 1 : 0;
$values['title']=addslashes(trim($values['title']));
$values['title'] = addslashes(trim($values['title']));
$values['title'] = Security::remove_XSS($values['title']);
$values['title'] = replace_dangerous_char($values['title']);
$values['title'] = disable_dangerous_file($values['title']);
@ -449,15 +398,14 @@ if ($form->validate()) {
$title = $values['title'];
$extension = 'html';
$texte = $values['content'];
$texte=Security::remove_XSS($texte,COURSEMANAGERLOWSECURITY);
$content = Security::remove_XSS($values['content'], COURSEMANAGERLOWSECURITY);
if (!strstr($texte, '/css/frames.css')) {
$texte = str_replace('</head>', '<style> body{margin:10px;}</style> <link rel="stylesheet" href="./css/frames.css" type="text/css" /></head>', $texte);
if (strpos($content, '/css/frames.css') === false) {
$content = str_replace('</head>', '<style> body{margin:10px;}</style> <link rel="stylesheet" href="./css/frames.css" type="text/css" /></head>', $content);
}
if ($fp = @ fopen($filepath.$filename.'.'.$extension, 'w')) {
$texte = text_filter($texte);
$content = str_replace(api_get_path('WEB_COURSE_PATH'), $_configuration['url_append'].'/courses/', $texte);
if ($fp = @fopen($filepath.$filename.'.'.$extension, 'w')) {
$content = text_filter($content);
$content = str_replace(api_get_path('WEB_COURSE_PATH'), $_configuration['url_append'].'/courses/', $content);
// change the path of mp3 to absolute
// first regexp deals with ../../../ urls
// Disabled by Ivan Tcholakov.
@ -471,28 +419,28 @@ if ($form->validate()) {
if (!is_dir($filepath.'css')) {
mkdir($filepath.'css', api_get_permissions_for_new_directories());
$doc_id = add_document($_course, $dir.'css', 'folder', 0, 'css');
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'FolderCreated', $_user['user_id'],null,null,null,null,$current_session_id);
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'invisible', $_user['user_id'],null,null,null,null,$current_session_id);
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'FolderCreated', $_user['user_id'], null, null, null, null, $current_session_id);
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'invisible', $_user['user_id'], null, null, null, null, $current_session_id);
}
if (!is_file($filepath.'css/frames.css')) {
//make a copy of the current css for the new document
// Make a copy of the current css for the new document
copy(api_get_path(SYS_CODE_PATH).'css/'.api_get_setting('stylesheets').'/frames.css', $filepath.'css/frames.css');
$doc_id = add_document($_course, $dir.'css/frames.css', 'file', filesize($filepath.'css/frames.css'), 'frames.css');
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', $_user['user_id'],null,null,null,null,$current_session_id);
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'invisible', $_user['user_id'],null,null,null,null,$current_session_id);
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', $_user['user_id'], null, null, null, null, $current_session_id);
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'invisible', $_user['user_id'], null, null, null, null, $current_session_id);
}
$file_size = filesize($filepath.$filename.'.'.$extension);
$save_file_path = $dir.$filename.'.'.$extension;
$document_id = add_document($_course, $save_file_path, 'file', $file_size, $filename,null,$readonly);
$document_id = add_document($_course, $save_file_path, 'file', $file_size, $filename, null, $readonly);
if ($document_id) {
api_item_property_update($_course, TOOL_DOCUMENT, $document_id, 'DocumentAdded', $_user['user_id'], $to_group_id,null,null,null,$current_session_id);
//update parent folders
api_item_property_update($_course, TOOL_DOCUMENT, $document_id, 'DocumentAdded', $_user['user_id'], $to_group_id, null, null, null, $current_session_id);
// Update parent folders
item_property_update_on_folder($_course, $_GET['dir'], $_user['user_id']);
$new_comment = isset ($_POST['comment']) ? trim($_POST['comment']) : '';
$new_title = isset ($_POST['title']) ? trim($_POST['title']) : '';
$new_comment = isset($_POST['comment']) ? trim($_POST['comment']) : '';
$new_title = isset($_POST['title']) ? trim($_POST['title']) : '';
if ($new_comment || $new_title) {
$TABLE_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT);
$ct = '';
@ -502,16 +450,16 @@ if ($form->validate()) {
$ct .= ", title='$new_title'";
Database::query("UPDATE $TABLE_DOCUMENT SET".substr($ct, 1)." WHERE id = '$document_id'");
}
$dir= substr($dir,0,-1);
$dir = substr($dir, 0, -1);
header('Location: document.php?curdirpath='.urlencode($dir));
exit ();
} else {
Display :: display_header($nameTools, "Doc");
Display :: display_header($nameTools, 'Doc');
Display :: display_error_message(get_lang('Impossible'));
Display :: display_footer();
}
} else {
Display :: display_header($nameTools, "Doc");
Display :: display_header($nameTools, 'Doc');
//api_display_tool_title($nameTools);
Display :: display_error_message(get_lang('Impossible'));
Display :: display_footer();
@ -521,10 +469,9 @@ if ($form->validate()) {
//api_display_tool_title($nameTools);
// actions
echo '<div class="actions">';
// link back to the documents overview
echo '<a href="document.php?curdirpath='.Security::remove_XSS($_GET['dir']).'">'.Display::return_icon('back.png',get_lang('Back').' '.get_lang('To').' '.get_lang('DocumentsOverview')).get_lang('BackTo').' '.get_lang('DocumentsOverview').'</a>';
// Link back to the documents overview
echo '<a href="document.php?curdirpath='.Security::remove_XSS($_GET['dir']).'">'.Display::return_icon('back.png', get_lang('Back').' '.get_lang('To').' '.get_lang('DocumentsOverview')).get_lang('BackTo').' '.get_lang('DocumentsOverview').'</a>';
echo '</div>';
$form->display();
Display :: display_footer();
}
?>

@ -1,38 +1,7 @@
<?php // $Id: document.inc.php 22074 2009-07-14 16:28:37Z jhp1411 $
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004-2008 Dokeos SPRL
Copyright (c) 2003 Ghent University (UGent)
Copyright (c) 2001 Universite catholique de Louvain (UCL)
Copyright (c) various contributors
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
Mail: info@dokeos.com
==============================================================================
*/
/*
==============================================================================
EXTRA FUNCTIONS FOR DOCUMENT.PHP/UPLOAD.PHP
==============================================================================
/////////////////////////////////////////////////
//--> leave these here or move them elsewhere? //
/////////////////////////////////////////////////
*/
<?php
/* For licensing terms, see /license.txt */
/* EXTRA FUNCTIONS FOR DOCUMENTS TOOL */
/**
* Builds the form thats enables the user to
@ -44,94 +13,81 @@
* @param boolean Whether to change the renderer (this will add a template <span> to the QuickForm object displaying the form)
* @return string html form
*/
function build_directory_selector($folders,$curdirpath,$group_dir='',$changeRenderer=false)
{
function build_directory_selector($folders, $curdirpath, $group_dir = '', $change_renderer = false) {
$folder_titles = array();
if(api_get_setting('use_document_title') == 'true')
{
if (is_array($folders))
{
if (api_get_setting('use_document_title') == 'true') {
if (is_array($folders)) {
$escaped_folders = array();
foreach($folders as $key=>$val){$escaped_folders[$key] = Database::escape_string($val);}
$folder_sql = implode("','",$escaped_folders);
foreach ($folders as $key => & $val) {
$escaped_folders[$key] = Database::escape_string($val);
}
$folder_sql = implode("','", $escaped_folders);
$doc_table = Database::get_course_table(TABLE_DOCUMENT);
$sql = "SELECT * FROM $doc_table WHERE filetype='folder' AND path IN ('".$folder_sql."')";
$res = Database::query($sql);
$folder_titles = array();
while($obj = Database::fetch_object($res))
{
while ($obj = Database::fetch_object($res)) {
$folder_titles[$obj->path] = $obj->title;
}
}
}
else
{
if (is_array($folders)){
foreach($folders as $folder)
{
} else {
if (is_array($folders)) {
foreach ($folders as & $folder) {
$folder_titles[$folder] = basename($folder);
}
}
}
require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
$form = new FormValidator('selector','POST',api_get_self());
require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
$form = new FormValidator('selector', 'POST', api_get_self());
$parent_select = $form->addElement('select', 'curdirpath', get_lang('CurrentDirectory'),'','onchange="javascript:document.selector.submit()"');
$parent_select = $form->addElement('select', 'curdirpath', get_lang('CurrentDirectory'), '', 'onchange="javascript: document.selector.submit();"');
if($changeRenderer==true){
if ($change_renderer) {
$renderer = $form->defaultRenderer();
$renderer->setElementTemplate('<span>{label} : {element}</span> ','curdirpath');
}
//group documents cannot be uploaded in the root
if(empty($group_dir))
{
$parent_select -> addOption(get_lang('HomeDirectory'),'/');
if(is_array($folders))
{
foreach ($folders as $folder)
{
$selected = ($curdirpath==$folder)?' selected="selected"':'';
$path_parts = explode('/',$folder);
if($folder_titles[$folder]=='shared_folder')
{
$folder_titles[$folder]=get_lang('SharedFolder');
}
elseif(strstr($folder_titles[$folder], 'sf_user_'))
{
$userinfo=Database::get_user_info_from_id(substr($folder_titles[$folder],8));
$folder_titles[$folder]=api_get_person_name($userinfo['firstname'], $userinfo['lastname']);
// Group documents cannot be uploaded in the root
if (empty($group_dir)) {
$parent_select -> addOption(get_lang('HomeDirectory'), '/');
if (is_array($folders)) {
foreach ($folders as & $folder) {
$selected = ($curdirpath == $folder) ? ' selected="selected"' : '';
$path_parts = explode('/', $folder);
if ($folder_titles[$folder] == 'shared_folder') {
$folder_titles[$folder] = get_lang('SharedFolder');
} elseif (strstr($folder_titles[$folder], 'sf_user_')) {
$userinfo = Database::get_user_info_from_id(substr($folder_titles[$folder], 8));
$folder_titles[$folder] = api_get_person_name($userinfo['firstname'], $userinfo['lastname']);
}
$label = str_repeat('&nbsp;&nbsp;&nbsp;',count($path_parts)-2).' &mdash; '.$folder_titles[$folder];
$parent_select -> addOption($label,$folder);
if($selected!='') $parent_select->setSelected($folder);
$label = str_repeat('&nbsp;&nbsp;&nbsp;', count($path_parts) - 2).' &mdash; '.$folder_titles[$folder];
$parent_select -> addOption($label, $folder);
if ($selected != '') {
$parent_select->setSelected($folder);
}
}
}
}
else
{
foreach ($folders as $folder)
{
$selected = ($curdirpath==$folder)?' selected="selected"':'';
} else {
foreach ($folders as & $folder) {
$selected = ($curdirpath==$folder) ? ' selected="selected"' : '';
$label = $folder_titles[$folder];
if( $folder == $group_dir)
{
if ($folder == $group_dir) {
$label = '/ ('.get_lang('HomeDirectory').')';
} else {
$path_parts = explode('/', str_replace($group_dir, '', $folder));
$label = str_repeat('&nbsp;&nbsp;&nbsp;', count($path_parts) - 2).' &mdash; '.$label;
}
else
{
$path_parts = explode('/',str_replace($group_dir,'',$folder));
$label = str_repeat('&nbsp;&nbsp;&nbsp;',count($path_parts)-2).' &mdash; '.$label;
$parent_select -> addOption($label, $folder);
if ($selected != '') {
$parent_select->setSelected($folder);
}
$parent_select -> addOption($label,$folder);
if($selected!='') $parent_select->setSelected($folder);
}
}
$form=$form->toHtml();
$form = $form->toHtml();
return $form;
}
@ -147,96 +103,71 @@ function build_directory_selector($folders,$curdirpath,$group_dir='',$changeRend
* @param int $show_as_icon - if it is true, only a clickable icon will be shown
* @return string url
*/
function create_document_link($www, $title, $path, $filetype, $size, $visibility, $show_as_icon = false)
{
function create_document_link($www, $title, $path, $filetype, $size, $visibility, $show_as_icon = false) {
global $dbl_click_id;
if(isset($_SESSION['_gid']))
{
if (isset($_SESSION['_gid'])) {
$req_gid = '&amp;gidReq='.$_SESSION['_gid'];
}
else
{
} else {
$req_gid = '';
}
$url_path = urlencode($path);
//add class="invisible" on invisible files
$visibility_class= ($visibility==0)?' class="invisible"':'';
if (!$show_as_icon)
{
//build download link (icon)
$forcedownload_link=($filetype=='folder')?api_get_self().'?'.api_get_cidreq().'&action=downloadfolder&amp;path='.$url_path.$req_gid:api_get_self().'?'.api_get_cidreq().'&amp;action=download&amp;id='.$url_path.$req_gid;
//folder download or file download?
$forcedownload_icon=($filetype=='folder')?'folder_zip.gif':'filesave.gif';
//prevent multiple clicks on zipped folder download
$prevent_multiple_click =($filetype=='folder')?" onclick=\"javascript:if(typeof clic_$dbl_click_id == 'undefined' || clic_$dbl_click_id == false) { clic_$dbl_click_id=true; window.setTimeout('clic_".($dbl_click_id++)."=false;',10000); } else { return false; }\"":'';
}
$target='_self';
if($filetype=='file') {
//check the extension
$ext=explode('.',$path);
$ext=strtolower($ext[sizeof($ext)-1]);
//"htmlfiles" are shown in a frameset
if($ext == 'htm' || $ext == 'html' || $ext == 'gif' || $ext == 'jpg' || $ext == 'jpeg' || $ext == 'png')
{
$url = "showinframes.php?".api_get_cidreq()."&amp;file=".$url_path.$req_gid;
}
else
{
//url-encode for problematic characters (we may not call them dangerous characters...)
// Add class="invisible" on invisible files
$visibility_class = ($visibility == 0) ? ' class="invisible"' : '';
if (!$show_as_icon) {
// Build download link (icon)
$forcedownload_link = ($filetype == 'folder') ? api_get_self().'?'.api_get_cidreq().'&action=downloadfolder&amp;path='.$url_path.$req_gid : api_get_self().'?'.api_get_cidreq().'&amp;action=download&amp;id='.$url_path.$req_gid;
// Folder download or file download?
$forcedownload_icon = ($filetype == 'folder') ? 'folder_zip.gif' : 'filesave.gif';
// Prevent multiple clicks on zipped folder download
$prevent_multiple_click = ($filetype == 'folder') ? " onclick=\"javascript: if(typeof clic_$dbl_click_id == 'undefined' || clic_$dbl_click_id == false) { clic_$dbl_click_id=true; window.setTimeout('clic_".($dbl_click_id++)."=false;',10000); } else { return false; }\"":'';
}
$target = '_self';
if ($filetype == 'file') {
// Check the extension
$ext = explode('.', $path);
$ext = strtolower($ext[sizeof($ext) - 1]);
// "htmlfiles" are shown in a frameset
if ($ext == 'htm' || $ext == 'html' || $ext == 'gif' || $ext == 'jpg' || $ext == 'jpeg' || $ext == 'png') {
$url = 'showinframes.php?'.api_get_cidreq().'&amp;file='.$url_path.$req_gid;
} else {
// url-encode for problematic characters (we may not call them dangerous characters...)
$path = str_replace('%2F', '/',$url_path).'?'.api_get_cidreq();
$url=$www.$path;
$url = $www.$path;
}
//files that we want opened in a new window
if($ext=='txt' || $ext=='log' || $ext=='css' || $ext=='js') //add here
{
$target='_blank';
// Files that we want opened in a new window
if ($ext == 'txt' || $ext == 'log' || $ext == 'css' || $ext == 'js') { // Add here
$target = '_blank';
}
}
else
{
$url=api_get_self().'?'.api_get_cidreq().'&amp;curdirpath='.$url_path.$req_gid;
} else {
$url = api_get_self().'?'.api_get_cidreq().'&amp;curdirpath='.$url_path.$req_gid;
}
//the little download icon
//$tooltip_title = str_replace('?cidReq='.$_GET['cidReq'],'',basename($path));
// The little download icon
//$tooltip_title = str_replace('?cidReq='.$_GET['cidReq'], '', basename($path));
$tooltip_title = explode('?', basename($path));
$tooltip_title = $tooltip_title[0];
if($tooltip_title=='shared_folder')
{
$tooltip_title_alt=get_lang('SharedFolder');
}
elseif(strstr($tooltip_title, 'sf_user_'))
{
$userinfo=Database::get_user_info_from_id(substr($tooltip_title,8));
$tooltip_title_alt=api_get_person_name($userinfo['firstname'], $userinfo['lastname']);
}
else
{
$tooltip_title_alt=$tooltip_title;
if ($tooltip_title == 'shared_folder') {
$tooltip_title_alt = get_lang('SharedFolder');
} elseif(strstr($tooltip_title, 'sf_user_')) {
$userinfo = Database::get_user_info_from_id(substr($tooltip_title, 8));
$tooltip_title_alt = api_get_person_name($userinfo['firstname'], $userinfo['lastname']);
} else {
$tooltip_title_alt = $tooltip_title;
}
if (!$show_as_icon)
{
if($filetype=="folder")
{
if(api_is_allowed_to_edit() || api_is_platform_admin() || api_get_setting('students_download_folders') == 'true')
{
$force_download_html = ($size==0)?'':'<a href="'.$forcedownload_link.'" style="float:right"'.$prevent_multiple_click.'>'.Display::return_icon($forcedownload_icon, get_lang('Download'),array('height'=>'16', 'width' => '16')).'</a>';
if (!$show_as_icon) {
if ($filetype == 'folder') {
if (api_is_allowed_to_edit() || api_is_platform_admin() || api_get_setting('students_download_folders') == 'true') {
$force_download_html = ($size == 0) ? '' : '<a href="'.$forcedownload_link.'" style="float:right"'.$prevent_multiple_click.'>'.Display::return_icon($forcedownload_icon, get_lang('Download'), array('height'=>'16', 'width' => '16')).'</a>';
}
} else {
$force_download_html = ($size==0)?'':'<a href="'.$forcedownload_link.'" style="float:right"'.$prevent_multiple_click.'>'.Display::return_icon($forcedownload_icon, get_lang('Download'), array('height'=>'16', 'width' => '16')).'</a>';
}
else
{
$force_download_html = ($size==0)?'':'<a href="'.$forcedownload_link.'" style="float:right"'.$prevent_multiple_click.'>'.Display::return_icon($forcedownload_icon, get_lang('Download'),array('height'=>'16', 'width' => '16')).'</a>';
}
return '<a href="'.$url.'" title="'.$tooltip_title_alt.'" target="'.$target.'"'.$visibility_class.' style="float:left">'.$title.'</a>'.$force_download_html;
}
else
{
} else {
return '<a href="'.$url.'" title="'.$tooltip_title_alt.'" target="'.$target.'"'.$visibility_class.' style="float:left">'.build_document_icon_tag($filetype, $tooltip_title).'</a>';
}
}
@ -248,59 +179,40 @@ function create_document_link($www, $title, $path, $filetype, $size, $visibility
* @param string $path
* @return string img html tag
*/
function build_document_icon_tag($type, $path)
{
function build_document_icon_tag($type, $path) {
$basename = basename($path);
$current_session_id = api_get_session_id();
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
$is_allowed_to_edit = api_is_allowed_to_edit(null,true);
if ($type == 'file')
{
if ($type == 'file') {
$icon = choose_image($basename);
}
else
{
if($basename =='shared_folder')
{
} else {
if ($basename == 'shared_folder') {
$icon = 'shared_folder.gif';
if ($is_allowed_to_edit)
{
if ($is_allowed_to_edit) {
$basename = get_lang('HelpSharedFolder');
}
else
{
} else {
$basename = get_lang('SharedFolder');
}
}
elseif(strstr($basename, 'sf_user_'))
{
$userinfo=Database::get_user_info_from_id(substr($basename,8));
$image_path = UserManager::get_user_picture_path_by_id(substr($basename,8),'web',false, true);
} elseif(strstr($basename, 'sf_user_')) {
$userinfo = Database::get_user_info_from_id(substr($basename, 8));
$image_path = UserManager::get_user_picture_path_by_id(substr($basename, 8), 'web', false, true);
if($image_path['file']=='unknown.jpg')
{
if ($image_path['file'] == 'unknown.jpg') {
$icon = $image_path['file'];
}
else
{
$icon = '../upload/users/'.substr($basename,8).'/'.$image_path['file'];
} else {
$icon = '../upload/users/'.substr($basename, 8).'/'.$image_path['file'];
}
$basename = api_get_person_name($userinfo['firstname'], $userinfo['lastname']);
}
else
{
if(($basename =='audio' || $basename =='flash' || $basename =='images' || $basename =='video') && api_is_allowed_to_edit()==true)
{
$basename = get_lang('HelpDefaultDirDocuments');
} else {
if (($basename =='audio' || $basename =='flash' || $basename =='images' || $basename =='video') && api_is_allowed_to_edit()) {
$basename = get_lang('HelpDefaultDirDocuments');
}
$icon = 'folder_document.gif';
}
}
return Display::return_icon($icon, $basename, array('hspace'=>'5', 'align' => 'middle', 'height'=> 22, 'width' => 22));
return Display::return_icon($icon, $basename, array('hspace' => '5', 'align' => 'middle', 'height' => 22, 'width' => 22));
}
/**
@ -313,132 +225,102 @@ function build_document_icon_tag($type, $path)
* @param int $id dbase id of the document
* @return string html img tags with hyperlinks
*/
function build_edit_icons($curdirpath,$type,$path,$visibility,$id,$is_template,$is_read_only=0, $session_id=0)
{
if(isset($_SESSION['_gid']))
{
function build_edit_icons($curdirpath, $type, $path, $visibility, $id, $is_template, $is_read_only = 0, $session_id = 0) {
if (isset($_SESSION['_gid'])) {
$req_gid = '&amp;gidReq='.$_SESSION['_gid'];
}
else
{
} else {
$req_gid = '';
}
//build URL-parameters for table-sorting
// Build URL-parameters for table-sorting
$sort_params = array();
if( isset($_GET['column']))
{
if (isset($_GET['column'])) {
$sort_params[] = 'column='.Security::remove_XSS($_GET['column']);
}
if( isset($_GET['page_nr']))
{
if (isset($_GET['page_nr'])) {
$sort_params[] = 'page_nr='.Security::remove_XSS($_GET['page_nr']);
}
if( isset($_GET['per_page']))
{
if (isset($_GET['per_page'])) {
$sort_params[] = 'per_page='.Security::remove_XSS($_GET['per_page']);
}
if( isset($_GET['direction']))
{
if (isset($_GET['direction'])) {
$sort_params[] = 'direction='.Security::remove_XSS($_GET['direction']);
}
$sort_params = implode('&amp;',$sort_params);
$visibility_icon = ($visibility==0)?'invisible':'visible';
$visibility_command = ($visibility==0)?'set_visible':'set_invisible';
$sort_params = implode('&amp;', $sort_params);
$visibility_icon = ($visibility == 0) ? 'invisible' : 'visible';
$visibility_command = ($visibility == 0) ? 'set_visible' : 'set_invisible';
$curdirpath = urlencode($curdirpath);
$modify_icons = '';
$cur_ses = api_get_session_id();
// if document is read only *or* we're in a session and the document
// If document is read only *or* we're in a session and the document
// is from a non-session context, hide the edition capabilities
if ($is_read_only /*or ($session_id!=$cur_ses)*/)
{
if ($is_read_only /*or ($session_id!=$cur_ses)*/) {
$modify_icons = Display::return_icon('edit_na.gif', get_lang('Modify'));
$modify_icons .= '&nbsp;'.Display::return_icon('delete_na.gif', get_lang('Delete'));
$modify_icons .= '&nbsp;'.Display::return_icon('deplacer_fichier_na.gif', get_lang('Move'));
$modify_icons .= '&nbsp;'.Display::return_icon($visibility_icon.'_na.gif', get_lang('VisibilityCannotBeChanged'));
}
else
{
$modify_icons .= '&nbsp;'.Display::return_icon('delete_na.gif', get_lang('Delete'));
$modify_icons .= '&nbsp;'.Display::return_icon('deplacer_fichier_na.gif', get_lang('Move'));
$modify_icons .= '&nbsp;'.Display::return_icon($visibility_icon.'_na.gif', get_lang('VisibilityCannotBeChanged'));
} else {
$modify_icons = '<a href="edit_document.php?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;file='.urlencode($path).$req_gid.'"><img src="../img/edit.gif" border="0" title="'.get_lang('Modify').'" alt="" /></a>';
if (strcmp($path,'/audio')===0 or strcmp($path,'/flash')===0 or strcmp($path,'/images')===0 or strcmp($path,'/shared_folder')===0 or strcmp($path,'/video')===0 or strcmp($path,'/chat_files')===0) {
$modify_icons .= '&nbsp;'.Display::return_icon('delete_na.gif',get_lang('ThisFolderCannotBeDeleted'));
} else {
$modify_icons .= '&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;delete='.urlencode($path).$req_gid.'&amp;'.$sort_params.'" onclick="return confirmation(\''.basename($path).'\');"><img src="../img/delete.gif" border="0" title="'.get_lang('Delete').'" alt="" /></a>';
}
$modify_icons .= '&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;move='.urlencode($path).$req_gid.'"><img src="../img/deplacer_fichier.gif" border="0" title="'.get_lang('Move').'" alt="" /></a>';
$modify_icons .= '&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;'.$visibility_command.'='.$id.$req_gid.'&amp;'.$sort_params.'"><img src="../img/'.$visibility_icon.'.gif" border="0" title="'.get_lang('Visible').'" alt="" /></a>';
if (in_array($path, array('/audio', '/flash', '/images', '/shared_folder', '/video', '/chat_files'))) {
$modify_icons .= '&nbsp;'.Display::return_icon('delete_na.gif', get_lang('ThisFolderCannotBeDeleted'));
} else {
$modify_icons .= '&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;delete='.urlencode($path).$req_gid.'&amp;'.$sort_params.'" onclick="javascript: return confirmation(\''.basename($path).'\');"><img src="../img/delete.gif" border="0" title="'.get_lang('Delete').'" alt="" /></a>';
}
$modify_icons .= '&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;move='.urlencode($path).$req_gid.'"><img src="../img/deplacer_fichier.gif" border="0" title="'.get_lang('Move').'" alt="" /></a>';
$modify_icons .= '&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;'.$visibility_command.'='.$id.$req_gid.'&amp;'.$sort_params.'"><img src="../img/'.$visibility_icon.'.gif" border="0" title="'.get_lang('Visible').'" alt="" /></a>';
}
if($type == 'file' && pathinfo($path,PATHINFO_EXTENSION)=='html')
{
if($is_template==0)
{
if ($type == 'file' && pathinfo($path, PATHINFO_EXTENSION) == 'html') {
if ($is_template == 0) {
$modify_icons .= '&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;add_as_template='.$id.$req_gid.'&amp;'.$sort_params.'"><img src="../img/wizard_small.gif" border="0" title="'.get_lang('AddAsTemplate').'" alt="'.get_lang('AddAsTemplate').'" /></a>';
}
else{
} else {
$modify_icons .= '&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;remove_as_template='.$id.$req_gid.'&amp;'.$sort_params.'"><img src="../img/wizard_gray_small.gif" border="0" title="'.get_lang('RemoveAsTemplate').'" alt=""'.get_lang('RemoveAsTemplate').'" /></a>';
}
}
return $modify_icons;
}
function build_move_to_selector($folders,$curdirpath,$move_file,$group_dir='')
{
function build_move_to_selector($folders, $curdirpath, $move_file, $group_dir = '') {
$form = '<form name="move_to" action="'.api_get_self().'" method="post">'."\n";
$form .= '<input type="hidden" name="move_file" value="'.$move_file.'" />'."\n";
$form .= '<div class="row">';
$form .= ' <div class="label">';
$form .= get_lang('MoveTo');
$form .= get_lang('MoveTo');
$form .= ' </div>';
$form .= ' <div class="formw">';
$form .= ' <select name="move_to">'."\n";
//group documents cannot be uploaded in the root
if($group_dir=='')
{
if($curdirpath!='/')
{
// Group documents cannot be uploaded in the root
if ($group_dir == '') {
if ($curdirpath != '/') {
$form .= '<option value="/">/ ('.get_lang('HomeDirectory').')</option>';
}
if(is_array($folders))
{
foreach ($folders AS $folder)
{
//you cannot move a file to:
//1. current directory
//2. inside the folder you want to move
//3. inside a subfolder of the folder you want to move
if(($curdirpath!=$folder) && ($folder!=$move_file) && (substr($folder,0,strlen($move_file)+1) != $move_file.'/'))
{
if (is_array($folders)) {
foreach ($folders as & $folder) {
// You cannot move a file to:
// 1. current directory
// 2. inside the folder you want to move
// 3. inside a subfolder of the folder you want to move
if (($curdirpath != $folder) && ($folder != $move_file) && (substr($folder, 0, strlen($move_file) + 1) != $move_file.'/')) {
$path_displayed = $folder;
// if document title is used, we have to display titles instead of real paths...
if(api_get_setting('use_document_title'))
{
// If document title is used, we have to display titles instead of real paths...
if (api_get_setting('use_document_title')) {
$path_displayed = get_titles_of_path($folder);
}
$form .= '<option value="'.$folder.'">'.$path_displayed.'</option>'."\n";
}
}
}
}
else
{
foreach ($folders AS $folder)
{
if(($curdirpath!=$folder) && ($folder!=$move_file) && (substr($folder,0,strlen($move_file)+1) != $move_file.'/'))//cannot copy dir into his own subdir
{
if(api_get_setting('use_document_title'))
{
} else {
foreach ($folders as $folder) {
if (($curdirpath != $folder) && ($folder != $move_file) && (substr($folder, 0, strlen($move_file) + 1) != $move_file.'/')) { // Cannot copy dir into his own subdir
if (api_get_setting('use_document_title')) {
$path_displayed = get_titles_of_path($folder);
}
$display_folder = substr($path_displayed,strlen($group_dir));
$display_folder = ($display_folder == '')?'/ ('.get_lang('HomeDirectory').')':$display_folder;
$display_folder = ($display_folder == '') ? '/ ('.get_lang('HomeDirectory').')' : $display_folder;
$form .= '<option value="'.$folder.'">'.$display_folder.'</option>'."\n";
}
}
@ -461,38 +343,36 @@ function build_move_to_selector($folders,$curdirpath,$move_file,$group_dir='')
return $form;
}
/**
* get the path translated with title of docs and folders
* Gets the path translated with title of docs and folders
* @param string the real path
* @return the path which should be displayed
*/
function get_titles_of_path($path)
{
function get_titles_of_path($path) {
global $tmp_folders_titles;
$nb_slashes = substr_count($path,'/');
$nb_slashes = substr_count($path, '/');
$tmp_path = '';
$current_slash_pos = 0;
$path_displayed = '';
for($i=0; $i<$nb_slashes; $i++)
{ // foreach folders of the path, retrieve title.
$current_slash_pos = strpos($path,'/',$current_slash_pos+1);
$tmp_path = substr($path,strpos($path,'/',0),$current_slash_pos);
for ($i = 0; $i < $nb_slashes; $i++) {
// For each folder of the path, retrieve title.
$current_slash_pos = strpos($path, '/', $current_slash_pos + 1);
$tmp_path = substr($path, strpos($path, '/', 0), $current_slash_pos);
if(empty($tmp_path)) // if empty, then we are in the final part of the path
if (empty($tmp_path)) {
// If empty, then we are in the final part of the path
$tmp_path = $path;
}
if(!empty($tmp_folders_titles[$tmp_path])) // if this path has soon been stored here we don't need a new query
{
if (!empty($tmp_folders_titles[$tmp_path])) {
// If this path has soon been stored here we don't need a new query
$path_displayed .= $tmp_folders_titles[$tmp_path];
}
else
{
} else {
$sql = 'SELECT title FROM '.Database::get_course_table(TABLE_DOCUMENT).' WHERE path LIKE BINARY "'.$tmp_path.'"';
$rs = Database::query($sql);
$tmp_title = '/'.Database::result($rs,0,0);
$tmp_title = '/'.Database::result($rs, 0, 0);
$path_displayed .= $tmp_title;
$tmp_folders_titles[$tmp_path] = $tmp_title;
}
@ -500,43 +380,41 @@ function get_titles_of_path($path)
return $path_displayed;
}
/**
* This function displays the name of the user and makes the link tothe user tool.
*
* @param $user_id
* @param $name
* @return a link to the userInfo.php
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version february 2006, dokeos 1.8
*/
function display_user_link_document($user_id, $name)
{
if ($user_id<>0)
{
* This function displays the name of the user and makes the link tothe user tool.
*
* @param $user_id
* @param $name
* @return a link to the userInfo.php
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version february 2006, dokeos 1.8
*/
function display_user_link_document($user_id, $name) {
if ($user_id != 0) {
return '<a href="../user/userInfo.php?uInfo='.$user_id.'">'.$name.'</a>';
}
else
{
} else {
return get_lang('Anonymous');
}
}
/**
* Creates form that asks for the directory name.
* @return string html-output text for the form
*/
function create_dir_form() {
function create_dir_form()
{
//create the form that asks for the directory name
$new_folder_text = '<form action="'.api_get_self().'" method="post">';
$new_folder_text .= '<input type="hidden" name="curdirpath" value="'.Security::remove_XSS($_GET['curdirpath']).'" />';
// form title
// Form title
$new_folder_text .= '<div class="row"><div class="form_header">'.get_lang('CreateDir').'</div></div>';
// folder field
// Folder field
$new_folder_text .= '<div class="row">';
$new_folder_text .= '<div class="label"><span class="form_required">*</span>'.get_lang('NewDir').'</div>';
$new_folder_text .= '<div class="formw"><input type="text" name="dirname" /></div>';
$new_folder_text .= '</div>';
// submit button
// Submit button
$new_folder_text .= '<div class="row">';
$new_folder_text .= '<div class="label">&nbsp;</div>';
$new_folder_text .= '<div class="formw"><button type="submit" class="add" name="create_dir">'.get_lang('CreateFolder').'</button></div>';
@ -548,17 +426,9 @@ function create_dir_form()
}
/**
* get if the user is in his shared folder
* Checks whether the user is in his/her shared folder
* @return return bool Return true when user is in his shared folder
*/
function is_my_shared_folder($user_id, $path)
{
if('/shared_folder/sf_user_'.$user_id==Security::remove_XSS($path))
{
return true;
}
return false;
function is_my_shared_folder($user_id, $path) {
return Security::remove_XSS($path) == '/shared_folder/sf_user_'.$user_id;
}
?>

File diff suppressed because it is too large Load Diff

@ -1,58 +1,36 @@
<?php // $Id: document_slideshow.inc.php 21529 2009-06-20 14:01:55Z ivantcholakov $
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004-2008 Dokeos SPRL
Copyright (c) 2003 Ghent University (UGent)
Copyright (c) 2001 Universite catholique de Louvain (UCL)
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
<?php
/* For licensing terms, see /license.txt */
Contact: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium, info@dokeos.com
==============================================================================
*/
/**
* 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.
*
* Each slideshow is folder based. Only
* the images of the chosen folder are shown.
*
* 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
*
* @author Patrick Cool, responsible author
* @author Roan Embrechts, minor cleanup
* @package dokeos.document
==============================================================================
*/
* 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.
*
* Each slideshow is folder based. Only
* the images of the chosen folder are shown.
*
* 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
*
* @author Patrick Cool, responsible author
* @author Roan Embrechts, minor cleanup
* @package chamilo.document
*/
/*
==============================================================================
general code that belongs in document.php
General code that belongs in document.php
this code should indeed go in documents.php but since document.php is already a really ugly file with
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
==============================================================================
*/
$accepted_extensions = array('.jpg','.jpeg','.gif','.png');
$accepted_extensions = array('.jpg', '.jpeg', '.gif', '.png');
// resetting the images of the slideshow = destroying the slideshow
// Resetting the images of the slideshow = destroying the slideshow
if (isset($_GET['action']) && $_GET['action'] == 'exit_slideshow') {
$_SESSION['image_files_only'] = null;
unset($image_files_only);
@ -60,37 +38,36 @@ if (isset($_GET['action']) && $_GET['action'] == 'exit_slideshow') {
// 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();
//$all_files = $fileList['name'];
$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)) {
while (list($key) = each($array_to_search)) {
$all_files[] = basename($array_to_search[$key]['path']);
//echo basename($array_to_search[$key]['path']).'<br>';
//echo basename($array_to_search[$key]['path']).'<br />';
}
}
$image_present = 0;
if (count($all_files) > 0) {
foreach ($all_files as $file) {
$slideshow_extension = strrchr($file,'.');
if (is_array($all_files) && 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)) {
if (in_array($slideshow_extension, $accepted_extensions)) {
$image_present = 1;
$image_files_only[] = $file;
break;
}
}
}
$tablename_column = (isset($_GET['tablename_column']) ? Security::remove_XSS($_GET['tablename_column']) : 0);
$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;
}
$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;
@ -100,11 +77,11 @@ function sort_files($table) {
global $tablename_direction, $accepted_extensions;
$temp = array();
foreach ($table as $file_array) {
foreach ($table as & $file_array) {
if ($file_array['filetype'] == 'file') {
$slideshow_extension = strrchr($file_array['path'],'.');
$slideshow_extension = strrchr($file_array['path'], '.');
$slideshow_extension = strtolower($slideshow_extension);
if (in_array($slideshow_extension,$accepted_extensions)) {
if (in_array($slideshow_extension, $accepted_extensions)) {
$temp[] = array('file', basename($file_array['path']), $file_array['size'], $file_array['insert_date']);
}
}
@ -117,7 +94,7 @@ function sort_files($table) {
}
$final_array = array();
foreach ($temp as $file_array) {
foreach ($temp as & $file_array) {
$final_array[] = $file_array[1];
}
@ -133,5 +110,3 @@ function rsort_table($a, $b) {
global $tablename_column;
return strnatcmp($b[$tablename_column], $a[$tablename_column]);
}
?>

Loading…
Cancel
Save