Feature #272 - The "Documents" tool, part 3: Revision, code conventions and cleaning.
parent
3412f6e28d
commit
ccdbbbb36f
@ -1,18 +1,61 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
/** |
||||
============================================================================== |
||||
* @package dokeos.document |
||||
============================================================================== |
||||
*/ |
||||
* @package chamilo.document |
||||
* TODO: There is no indication that this file us used for something. |
||||
*/ |
||||
|
||||
require_once '../inc/global.inc.php'; |
||||
?> |
||||
|
||||
<html> |
||||
$platform_theme = api_get_setting('stylesheets'); // plataform's css |
||||
$my_style = $platform_theme; |
||||
|
||||
if (api_get_setting('user_selected_theme') == 'true') { |
||||
$useri = api_get_user_info(); |
||||
$user_theme = $useri['theme']; |
||||
if (!empty($user_theme) && $user_theme != $my_style) { |
||||
$my_style = $user_theme; // user's css |
||||
} |
||||
} |
||||
$mycourseid = api_get_course_id(); |
||||
if (!empty($mycourseid) && $mycourseid != -1) { |
||||
if (api_get_setting('allow_course_theme') == 'true') { |
||||
$mycoursetheme=api_get_course_setting('course_theme'); |
||||
|
||||
if (!empty($mycoursetheme) && $mycoursetheme != -1) { |
||||
if (!empty($mycoursetheme) && $mycoursetheme != $my_style) { |
||||
$my_style = $mycoursetheme; // course's css |
||||
} |
||||
} |
||||
|
||||
$mycourselptheme = api_get_course_setting('allow_learning_path_theme'); |
||||
if (!empty($mycourselptheme) && $mycourselptheme != -1 && $mycourselptheme == 1) { |
||||
|
||||
global $lp_theme_css; // it comes from the lp_controller.php |
||||
global $lp_theme_config; // it comes from the lp_controller.php |
||||
|
||||
if (!$lp_theme_config) { |
||||
if ($lp_theme_css != '') { |
||||
$theme = $lp_theme_css; |
||||
if (!empty($theme) && $theme != $my_style) { |
||||
$my_style = $theme; // LP's css |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
?><!DOCTYPE html |
||||
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo api_get_language_isocode(); ?>" lang="<?php echo api_get_language_isocode(); ?>">
|
||||
<head> |
||||
<link rel="stylesheet" href="<?php echo $clarolineRepositoryWeb ?>css/default.css" type="text/css">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo api_get_system_encoding(); ?>" />
|
||||
<link rel="stylesheet" href="<?php echo api_get_path(WEB_CSS_PATH).$my_style; ?>/default.css" type="text/css">
|
||||
</head> |
||||
</html> |
||||
|
||||
<body dir="<?php echo api_get_text_direction(); ?>">
|
||||
<?php |
||||
|
||||
Display::display_footer(); |
||||
?> |
||||
@ -1,32 +1,34 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
/** |
||||
============================================================================== |
||||
* @package dokeos.document |
||||
============================================================================== |
||||
*/ |
||||
// name of the language file that needs to be included |
||||
* @package chamilo.document |
||||
*/ |
||||
|
||||
// Name of the language file that needs to be included |
||||
$language_file = 'document'; |
||||
|
||||
require_once '../inc/global.inc.php'; |
||||
$noPHP_SELF=true; |
||||
$header_file= Security::remove_XSS($_GET['file']); |
||||
$path_array=explode('/',str_replace('\\','/',$header_file)); |
||||
$path_array = array_map('urldecode',$path_array); |
||||
$header_file=implode('/',$path_array); |
||||
|
||||
$noPHP_SELF = true; |
||||
$header_file = Security::remove_XSS($_GET['file']); |
||||
$path_array = explode('/', str_replace('\\', '/', $header_file)); |
||||
$path_array = array_map('urldecode', $path_array); |
||||
$header_file = implode('/', $path_array); |
||||
$nameTools = $header_file; |
||||
|
||||
if(isset($_SESSION['_gid']) && $_SESSION['_gid']!='') { |
||||
if (isset($_SESSION['_gid']) && $_SESSION['_gid'] != '') { |
||||
$req_gid = '&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')); |
||||
} |
||||
|
||||
$interbreadcrumb[]= array ("url"=>"./document.php?curdirpath=".dirname($header_file).$req_gid, "name"=> get_lang('Documents')); |
||||
$interbreadcrumb[]= array ("url"=>"showinframes.php?file=".$header_file, "name"=>$header_file); |
||||
$file_url_sys=api_get_path(SYS_COURSE_PATH).'document'.$header_file; |
||||
$path_info= pathinfo($file_url_sys); |
||||
$interbreadcrumb[] = array('url' => './document.php?curdirpath='.dirname($header_file).$req_gid, 'name' => get_lang('Documents')); |
||||
$interbreadcrumb[] = array('url' => 'showinframes.php?file='.$header_file, 'name' => $header_file); |
||||
$file_url_sys = api_get_path(SYS_COURSE_PATH).'document'.$header_file; |
||||
$path_info = pathinfo($file_url_sys); |
||||
$this_section = SECTION_COURSES; |
||||
|
||||
Display::display_header(null,"Doc"); |
||||
echo "<div align=\"center\">"; |
||||
$file_url_web=api_get_path('WEB_COURSE_PATH').$_course['path'].'/document'.$header_file."?".api_get_cidreq(); |
||||
echo "<a href='".$file_url_web."' target='blank'>".get_lang('_cut_paste_link')."</a></div>"; |
||||
?> |
||||
Display::display_header(null, 'Doc'); |
||||
echo '<div align="center">'; |
||||
$file_url_web = api_get_path('WEB_COURSE_PATH').$_course['path'].'/document'.$header_file.'?'.api_get_cidreq(); |
||||
echo '<a href="'.$file_url_web.'" target="blank">'.get_lang('_cut_paste_link').'</a></div>'; |
||||
|
||||
@ -1,131 +1,103 @@ |
||||
<?php // $Id: quota.php 21106 2009-05-30 16:25:16Z iflorespaz $
|
||||
/* |
||||
============================================================================== |
||||
Dokeos - elearning and course management software |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
Copyright (c) 2004 Dokeos S.A. |
||||
Copyright (c) 2005 Roan Embrechts, Vrije Universiteit Brussel |
||||
|
||||
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: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com |
||||
============================================================================== |
||||
*/ |
||||
/** |
||||
============================================================================== |
||||
* This script displays info about the course disk use and quota: |
||||
* how large (in megabytes) is the documents area of the course, |
||||
* what is the maximum allowed for this course... |
||||
* |
||||
* @author Roan Embrechts |
||||
* @package dokeos.document |
||||
============================================================================== |
||||
*/ |
||||
|
||||
// name of the language file that needs to be included |
||||
* This script displays info about the course disk use and quota: |
||||
* how large (in megabytes) is the documents area of the course, |
||||
* what is the maximum allowed for this course... |
||||
* |
||||
* @author Roan Embrechts |
||||
* @package chamilo.document |
||||
*/ |
||||
|
||||
// Name of the language file that needs to be included |
||||
$language_file = 'document'; |
||||
|
||||
// including the global dokeos file |
||||
require_once "../inc/global.inc.php"; |
||||
// Including the global dokeos file |
||||
require_once '../inc/global.inc.php'; |
||||
|
||||
// including additional libraries |
||||
require_once api_get_path(LIBRARY_PATH) . 'fileUpload.lib.php'; |
||||
require_once api_get_path(LIBRARY_PATH) . 'document.lib.php'; |
||||
// Including additional libraries |
||||
require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php'; |
||||
require_once api_get_path(LIBRARY_PATH).'document.lib.php'; |
||||
|
||||
// some constants and variables |
||||
$courseDir = $_course['path']."/document"; |
||||
// Some constants and variables |
||||
$courseDir = $_course['path'].'/document'; |
||||
$maxFilledSpace = DEFAULT_DOCUMENT_QUOTA; |
||||
|
||||
// breadcrumbs |
||||
$interbreadcrumb[]=array("url" => "document.php","name" => get_lang('ToolDocument')); |
||||
|
||||
// title of the page |
||||
$nameTools = get_lang("DocumentQuota"); |
||||
// Breadcrumbs |
||||
$interbreadcrumb[] = array('url' => 'document.php','name' => get_lang('ToolDocument')); |
||||
|
||||
// display the header |
||||
Display::display_header($nameTools,"Doc"); |
||||
// Title of the page |
||||
$nameTools = get_lang('DocumentQuota'); |
||||
|
||||
// Display the header |
||||
Display::display_header($nameTools,'Doc'); |
||||
|
||||
|
||||
/* |
||||
============================================================================== |
||||
FUNCTIONS |
||||
============================================================================== |
||||
*/ |
||||
/* FUNCTIONS */ |
||||
|
||||
/** |
||||
* Here we count 1 kilobyte = 1000 byte, 12 megabyte = 1000 kilobyte. |
||||
*/ |
||||
function display_quota($course_quota, $already_consumed_space) |
||||
{ |
||||
* Here we count 1 kilobyte = 1000 byte, 12 megabyte = 1000 kilobyte. |
||||
*/ |
||||
function display_quota($course_quota, $already_consumed_space) { |
||||
$course_quota_m = round($course_quota / 1000000); |
||||
$already_consumed_space_m = round($already_consumed_space / 1000000); |
||||
$message = get_lang("CourseCurrentlyUses") . " <strong>" . $already_consumed_space_m . " megabyte</strong>.<br/>". get_lang("MaximumAllowedQuota") . " <strong>$course_quota_m megabyte</strong>.<br/>"; |
||||
$message = get_lang('CourseCurrentlyUses') . ' <strong>' . $already_consumed_space_m . ' megabyte</strong>.<br />'. get_lang('MaximumAllowedQuota') . ' <strong>'.$course_quota_m.' megabyte</strong>.<br />'; |
||||
|
||||
$percentage = $already_consumed_space / $course_quota * 100; |
||||
$percentage = round($percentage); |
||||
|
||||
if ($percentage < 100) $other_percentage = 100 - $percentage; |
||||
else $other_percentage = 0; |
||||
$other_percentage = $percentage < 100 ? 100 - $percentage : 0; |
||||
|
||||
//decide where to place percentage in graph |
||||
if ($percentage >= 50) |
||||
{ |
||||
$text_in_filled = " $other_percentage%". |
||||
$text_in_unfilled = ""; |
||||
} |
||||
else |
||||
{ |
||||
$text_in_unfilled = " $other_percentage%". |
||||
$text_in_filled = ""; |
||||
// Decide where to place percentage in graph |
||||
if ($percentage >= 50) { |
||||
$text_in_filled = ' '.$other_percentage.'%'; |
||||
$text_in_unfilled = ''; |
||||
} else { |
||||
$text_in_unfilled = ' '.$other_percentage.'%'; |
||||
$text_in_filled = ''; |
||||
} |
||||
|
||||
//decide the background colour of the graph |
||||
if ($percentage < 65) $colour = "#00BB00"; //safe - green |
||||
else if ($percentage < 90) $colour = "#ffd400"; //filling up - yelloworange |
||||
else $colour = "#DD0000"; //full - red |
||||
// Decide the background colour of the graph |
||||
if ($percentage < 65) { |
||||
$colour = '#00BB00'; // Safe - green |
||||
} elseif ($percentage < 90) { |
||||
$colour = '#ffd400'; // Filling up - yelloworange |
||||
} else { |
||||
$colour = '#DD0000'; // Full - red |
||||
} |
||||
|
||||
//this is used for the table width: a table of only 100 pixels looks too small |
||||
// This is used for the table width: a table of only 100 pixels looks too small |
||||
$visual_percentage = 4 * $percentage; |
||||
$visual_other_percentage = 4 * $other_percentage; |
||||
|
||||
$message .= get_lang("PercentageQuotaInUse") . ": <strong>$percentage%</strong>.<br/>" . |
||||
get_lang("PercentageQuotaFree") . ": <strong>$other_percentage%</strong>.<br>"; |
||||
|
||||
$message .= "<br/><table cellpadding=\"\" cellspacing=\"0\" height=\"40\"><tr> |
||||
<td bgcolor=\"$colour\" width=\"$visual_percentage\"></td> |
||||
<td bgcolor=\"Silver\" width=\"$visual_other_percentage\"> $other_percentage%</td> |
||||
</tr></table>"; |
||||
$message .= get_lang('PercentageQuotaInUse') . ': <strong>'.$percentage.'%</strong>.<br />' . |
||||
get_lang('PercentageQuotaFree') . ': <strong>'.$other_percentage.'%</strong>.<br />'; |
||||
|
||||
$show_percentage = $percentage >= 10 ? ' '.$percentage.'%' : ''; |
||||
$message .= '<br /><table cellpadding="" cellspacing="0" height="40"><tr> |
||||
<td bgcolor="'.$colour.'" width="'.$visual_percentage.'">'.$show_percentage.'</td> |
||||
<td bgcolor="Silver" width="'.$visual_other_percentage.'"> '.$other_percentage.'%</td> |
||||
</tr></table>'; |
||||
echo $message; |
||||
} |
||||
|
||||
// actions |
||||
// Actions |
||||
echo '<div class="actions">'; |
||||
// link back to the documents overview |
||||
echo '<a href="document.php">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('DocumentsOverview')).get_lang('BackTo').' '.get_lang('DocumentsOverview').'</a>'; |
||||
echo '<a href="document.php">'.Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview')).get_lang('BackTo').' '.get_lang('DocumentsOverview').'</a>'; |
||||
echo '</div>'; |
||||
|
||||
// getting the course quota |
||||
// Getting the course quota |
||||
$course_quota = DocumentManager::get_course_quota(); |
||||
|
||||
// setting the full path |
||||
$full_path = $baseWorkDir . $courseDir; |
||||
// Setting the full path |
||||
$full_path = $baseWorkDir.$courseDir; |
||||
|
||||
// calculating the total space |
||||
// Calculating the total space |
||||
$already_consumed_space = documents_total_space($_course); |
||||
|
||||
// displaying the quota |
||||
// Displaying the quota |
||||
display_quota($course_quota, $already_consumed_space); |
||||
|
||||
// display the footer |
||||
// Display the footer |
||||
Display::display_footer(); |
||||
?> |
||||
Loading…
Reference in new issue