Feature #272 - fileManage.lib.php and text.lib.php: Revision, coding conventions, cleaning.

skala
Ivan Tcholakov 16 years ago
parent 589e5e7d51
commit be4fd4c1eb
  1. 2
      main/inc/header.inc.php
  2. 693
      main/inc/lib/fileManage.lib.php
  3. 36
      main/inc/lib/text.lib.php

@ -75,7 +75,7 @@ if (!empty($mycourseid) && $mycourseid != -1) {
if (!empty($mycoursetheme) && $mycoursetheme != -1) { if (!empty($mycoursetheme) && $mycoursetheme != -1) {
if (!empty($mycoursetheme) && $mycoursetheme != $my_style) { if (!empty($mycoursetheme) && $mycoursetheme != $my_style) {
$my_style = $mycoursetheme; // course's css $my_style = $mycoursetheme; // course's css
} }
} }

File diff suppressed because it is too large Load Diff

@ -13,7 +13,7 @@
/** /**
* function make_clickable($string) * function make_clickable($string)
* *
* @desc completes url contained in the text with "<a href ...". * @desc Completes url contained in the text with "<a href ...".
* However the function simply returns the submitted text without any * However the function simply returns the submitted text without any
* transformation if it already contains some "<a href:" or "<img src=". * transformation if it already contains some "<a href:" or "<img src=".
* @param string $text text to be converted * @param string $text text to be converted
@ -109,7 +109,7 @@ function text_filter($input, $filter = true) {
*/ */
function _text_parse_tex($textext) { function _text_parse_tex($textext) {
//$textext = str_replace(array ("[tex]", "[/tex]"), array ('[*****]', '[/*****]'), $textext); //$textext = str_replace(array ("[tex]", "[/tex]"), array ('[*****]', '[/*****]'), $textext);
//$textext=stripslashes($texttext); //$textext = stripslashes($texttext);
$input_array = preg_split("/(\[tex]|\[\/tex])/", $textext, -1, PREG_SPLIT_DELIM_CAPTURE); $input_array = preg_split("/(\[tex]|\[\/tex])/", $textext, -1, PREG_SPLIT_DELIM_CAPTURE);
@ -122,7 +122,7 @@ function _text_parse_tex($textext) {
} }
} }
$output=implode('',$input_array); $output = implode('',$input_array);
return $output; return $output;
} }
@ -142,7 +142,6 @@ function _text_parse_texexplorer($textext) {
$textext = str_replace(array("[texexplorer]", "[/texexplorer]"), array("<embed type=\"application/x-techexplorer\" texdata=\"", "\" autosize=\"true\" pluginspage=\"http://www.integretechpub.com/techexplorer/\">"), $textext); $textext = str_replace(array("[texexplorer]", "[/texexplorer]"), array("<embed type=\"application/x-techexplorer\" texdata=\"", "\" autosize=\"true\" pluginspage=\"http://www.integretechpub.com/techexplorer/\">"), $textext);
} }
return $textext; return $textext;
} }
/** /**
@ -159,11 +158,11 @@ function _text_parse_glossary($input) {
* @author Patrick Cool <patrick.cool@UGent.be> * @author Patrick Cool <patrick.cool@UGent.be>
*/ */
function _text_parse_tool($input) { function _text_parse_tool($input) {
// an array with all the valid tools // An array with all the valid tools
$tools[] = array(TOOL_ANNOUNCEMENT, 'announcements/announcements.php'); $tools[] = array(TOOL_ANNOUNCEMENT, 'announcements/announcements.php');
$tools[] = array(TOOL_CALENDAR_EVENT, 'calendar/agenda.php'); $tools[] = array(TOOL_CALENDAR_EVENT, 'calendar/agenda.php');
// check if the name between the [tool] [/tool] tags is a valid one // Check if the name between the [tool] [/tool] tags is a valid one
} }
/** /**
@ -173,7 +172,7 @@ function _text_parse_tool($input) {
function latex_gif_renderer($latex_code) { function latex_gif_renderer($latex_code) {
global $_course; global $_course;
// setting the paths and filenames // Setting the paths and filenames
$mimetex_path = api_get_path(LIBRARY_PATH).'mimetex/'; $mimetex_path = api_get_path(LIBRARY_PATH).'mimetex/';
$temp_path = api_get_path(SYS_COURSE_PATH).$_course['path'].'/temp/'; $temp_path = api_get_path(SYS_COURSE_PATH).$_course['path'].'/temp/';
$latex_filename = md5($latex_code).'.gif'; $latex_filename = md5($latex_code).'.gif';
@ -219,20 +218,21 @@ function cut($text, $maxchar, $embed = false) {
* @return mixed an integer or a float depends on the parameter * @return mixed an integer or a float depends on the parameter
*/ */
function float_format($number, $flag = 1) { function float_format($number, $flag = 1) {
if (is_numeric($number)) { // a number if (is_numeric($number)) {
if (!$number) { // zero if (!$number) {
$result = ($flag == 2 ? '0.00' : '0'); // output zero $result = ($flag == 2 ? '0.00' : '0');
} else { // value } else {
if (floor($number) == $number) { // whole number if (floor($number) == $number) {
$result = number_format($number, ($flag == 2 ? 2 : 0)); // format $result = number_format($number, ($flag == 2 ? 2 : 0));
} else { // cents } else {
$result = number_format(round($number, 2), ($flag == 0 ? 0 : 2)); // format $result = number_format(round($number, 2), ($flag == 0 ? 0 : 2));
} // integer or decimal }
} // value }
return $result; return $result;
} }
} }
// TODO: To be checked for timezones management and to be moved in the internationalization library.
/** /**
* Function to obtain last week timestamps * Function to obtain last week timestamps
* @return array times for every day inside week * @return array times for every day inside week
@ -248,7 +248,7 @@ function get_last_week() {
} }
$lastweek = sprintf("%02d", $lastweek); $lastweek = sprintf("%02d", $lastweek);
for ($i=1; $i<=7; $i++) { for ($i = 1; $i <= 7; $i++) {
$arrdays[] = strtotime("$year"."W$lastweek"."$i"); $arrdays[] = strtotime("$year"."W$lastweek"."$i");
} }
return $arrdays; return $arrdays;

Loading…
Cancel
Save