Task #2560 - Fixing some indentations that I broke in the previous transaction.

skala
Ivan Tcholakov 14 years ago
parent 81eb7fe847
commit b69e884026
  1. 70
      main/exercice/hotpotatoes.lib.php
  2. 8
      main/exercice/hotpotatoes.php
  3. 78
      main/inc/lib/text.lib.php

@ -2,9 +2,9 @@
/* For licensing terms, see /license.txt */
/**
* Code library for HotPotatoes integration.
* @package chamilo.exercise
* @author Istvan Mandak (original author)
* Code library for HotPotatoes integration.
* @package chamilo.exercise
* @author Istvan Mandak (original author)
*/
$dbTable = Database::get_course_table(TABLE_DOCUMENT); // TODO: This is a global variable with too simple name, conflicts are possible. Better eliminate it. Correct the test unit too.
@ -13,8 +13,8 @@ $dbTable = Database::get_course_table(TABLE_DOCUMENT); // TODO: This is a global
* Creates a hotpotato directory.
*
* If a directory of that name already exists, don't create any. If a file of that name exists, remove it and create a directory.
* @param string Wanted path
* @return boolean Always true so far
* @param string Wanted path
* @return boolean Always true so far
*/
function hotpotatoes_init($base_work_dir) {
//global $_course, $_user;
@ -40,9 +40,9 @@ function hotpotatoes_init($base_work_dir) {
/**
* Gets the title of the quizz file given as parameter.
* @param string File name
* @param string File path
* @return string The exercise title
* @param string File name
* @param string File path
* @return string The exercise title
*/
function GetQuizName($fname, $fpath) {
@ -69,8 +69,8 @@ function GetQuizName($fname, $fpath) {
/**
* Gets the comment about a file from the corresponding database record.
* @param string File path
* @return string Comment from the database record
* @param string File path
* @return string Comment from the database record
* Added conditional to the table if is empty.
*/
function GetComment($path, $course_code = '') {
@ -94,7 +94,7 @@ function GetComment($path, $course_code = '') {
* Sets the comment in the database for a particular path.
* @param string File path
* @param string Comment to set
* @return string Result of the database operation (Database::query will output some message directly on error anyway)
* @return string Result of the database operation (Database::query will output some message directly on error anyway)
*/
function SetComment($path, $comment) {
global $dbTable;
@ -108,7 +108,7 @@ function SetComment($path, $comment) {
/**
* Reads the file contents into a string.
* @param string Urlencoded path
* @return string The file contents or false on security error
* @return string The file contents or false on security error
*/
function ReadFileCont($full_file_path) {
if (Security::check_abs_path(dirname($full_file_path).'/', api_get_path(SYS_COURSE_PATH))) {
@ -127,8 +127,8 @@ function ReadFileCont($full_file_path) {
/**
* Writes the file contents into the given filepath.
* @param string Urlencoded path
* @param string The file contents
* @return boolean True on success, false on security error
* @param string The file contents
* @return boolean True on success, false on security error
*/
function WriteFileCont($full_file_path, $content) {
// Check if this is not an attack, trying to get into other directories or something like that.
@ -149,7 +149,7 @@ function WriteFileCont($full_file_path, $content) {
/**
* Gets the name of an img whose path is given (without directories or extensions).
* @param string An image tag (<img src="...." ...>)
* @return string The image file name or an empty string
* @return string The image file name or an empty string
*/
function GetImgName($imgtag) {
// Select src tag from img tag.
@ -180,7 +180,7 @@ function GetImgName($imgtag) {
/**
* Gets the source path of an image tag.
* @param string An image tag
* @return string The image source or ""
* @return string The image source or ""
*/
function GetSrcName($imgtag) {
// Select src tag from img tag.
@ -198,9 +198,9 @@ function GetSrcName($imgtag) {
/**
* Gets the image parameters from an image path.
* @param string File name
* @param string File path
* @param reference Reference to a list of image parameters (emptied, then used to return results)
* @param string File name
* @param string File path
* @param reference Reference to a list of image parameters (emptied, then used to return results)
* @param reference Reference to a counter of images (emptied, then used to return results)
*/
function GetImgParams($fname, $fpath, &$imgparams, &$imgcount) {
@ -226,7 +226,7 @@ function GetImgParams($fname, $fpath, &$imgparams, &$imgcount) {
/**
* Generates a list of hidden fields with the image params given as parameter to this function.
* @param array List of image parameters
* @return string String containing the hidden parameters built from the list given
* @return string String containing the hidden parameters built from the list given
*/
function GenerateHiddenList($imgparams) {
$list = '';
@ -241,8 +241,8 @@ function GenerateHiddenList($imgparams) {
/**
* Searches for a node in the given array.
* @param reference Reference to the array to search
* @param string Node we are looking for in the array
* @return mixed Node name or false if not found
* @param string Node we are looking for in the array
* @return mixed Node name or false if not found
*/
function myarraysearch(&$array, $node) {
$match = false;
@ -260,10 +260,10 @@ function myarraysearch(&$array, $node) {
/**
* Searches an image name into an array.
* @param reference Reference to an array to search
* @param string String to look for
* @return mixed String given if found, false otherwise
* @uses myarraysearch This function is just an additional layer on the myarraysearch() function
* @param reference Reference to an array to search
* @param string String to look for
* @return mixed String given if found, false otherwise
* @uses myarraysearch This function is just an additional layer on the myarraysearch() function
*/
function CheckImageName(&$imgparams, $string) {
$checked = myarraysearch($imgparams, $string);
@ -273,7 +273,7 @@ function CheckImageName(&$imgparams, $string) {
/**
* Replaces an image tag by ???
* @param string The content to replace
* @return string The modified content
* @return string The modified content
*/
function ReplaceImgTag($content) {
$newcontent = $content;
@ -298,8 +298,8 @@ function ReplaceImgTag($content) {
/**
* Fills the folder name up to a certain length with "0".
* @param string Original folder name
* @param integer Length to reach
* @return string Modified folder name
* @param integer Length to reach
* @return string Modified folder name
*/
function FillFolderName($name, $nsize) {
$str = '';
@ -313,7 +313,7 @@ function FillFolderName($name, $nsize) {
/**
* Generates the HotPotato folder tree.
* @param string Folder path
* @return string Folder name (modified)
* @return string Folder name (modified)
*/
function GenerateHpFolder($folder) {
$filelist = array();
@ -344,7 +344,7 @@ function GenerateHpFolder($folder) {
/**
* Gets the folder name (strips down path).
* @param string Path
* @return string Folder name stripped down
* @return string Folder name stripped down
*/
function GetFolderName($fname) {
$name = explode('/', $fname);
@ -355,7 +355,7 @@ function GetFolderName($fname) {
/**
* Gets the folder path (withouth the name of the folder itself) ?
* @param string Path
* @return string Path stripped down
* @return string Path stripped down
*/
function GetFolderPath($fname) {
$str = '';
@ -369,7 +369,7 @@ function GetFolderPath($fname) {
/**
* Checks if there are subfolders.
* @param string Path
* @return integer 1 if a subfolder was found, 0 otherwise
* @return integer 1 if a subfolder was found, 0 otherwise
*/
function CheckSubFolder($path) {
$folder = GetFolderPath($path);
@ -391,10 +391,10 @@ function CheckSubFolder($path) {
/**
* Hotpotato Garbage Collector
* @param string Path
* @param string Path
* @param integer Flag
* @param integer User id
* @return void No return value, but echoes results
* @return void No return value, but echoes results
*/
function HotPotGCt($folder, $flag, $user_id) {
// Garbage Collector

@ -2,9 +2,9 @@
/* For licensing terms, see /license.txt */
/**
* Code for HotPotatoes integration.
* @package chamilo.exercise
* @author Istvan Mandak (original author)
* Code for HotPotatoes integration.
* @package chamilo.exercise
* @author Istvan Mandak (original author)
*/
@ -51,7 +51,7 @@ $dbTable = Database::get_course_table(TABLE_DOCUMENT);
$document_sys_path = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
$uploadPath = '/HotPotatoes_files';
$finish = (!empty($_POST['finish']) ? $_POST['finish'] : 0);
$imgcount = (!empty($_POST['imgcount']) ? $_POST['imgcount'] : null);
$imgcount = (!empty($_POST['imgcount']) ? $_POST['imgcount'] : null);
$fld = (!empty($_POST['fld']) ? $_POST['fld'] : null);
// If user is allowed to edit...

@ -15,7 +15,7 @@
/**
* This function strips all html-tags found in the input string and outputs a pure text.
* Mostly, the function is to be used before language or encoding detection of the input string.
* @param string $string The input string with html-tags to be converted to plain text.
* @param string $string The input string with html-tags to be converted to plain text.
* @return string The returned plain text as a result.
*/
function api_html_to_text($string) {
@ -37,7 +37,7 @@ function api_html_to_text($string) {
/**
* Detects encoding of html-formatted text.
* @param string $string The input html-formatted text.
* @param string $string The input html-formatted text.
* @return string Returns the detected encoding.
*/
function api_detect_encoding_html($string) {
@ -75,8 +75,8 @@ function api_set_encoding_html(&$string, $encoding) {
* Returns the title of a html document.
* @param string $string The contents of the input document.
* @param string $input_encoding The encoding of the input document. If the value is not set, it is detected.
* @param string $$output_encoding The encoding of the retrieved title. If the value is not set, the system encoding is assumend.
* @return string The retrieved title, html-entities and extra-whitespace between the words are cleaned.
* @param string $$output_encoding The encoding of the retrieved title. If the value is not set, the system encoding is assumend.
* @return string The retrieved title, html-entities and extra-whitespace between the words are cleaned.
*/
function api_get_title_html(&$string, $output_encoding = null, $input_encoding = null) {
if (@preg_match('/<head.+<title[^>]*>(.*)<\/title>/msi', $string, $matches)) {
@ -102,8 +102,8 @@ define('_PCRE_XML_ENCODING', '/<\?xml.*encoding=[\'"](.*?)[\'"].*\?>/m');
/**
* Detects encoding of xml-formatted text.
* @param string $string The input xml-formatted text.
* @param string $default_encoding This is the default encoding to be returned if there is no way the xml-text's encoding to be detected. If it not spesified, the system encoding is assumed then.
* @return string Returns the detected encoding.
* @param string $default_encoding This is the default encoding to be returned if there is no way the xml-text's encoding to be detected. If it not spesified, the system encoding is assumed then.
* @return string Returns the detected encoding.
* @todo The second parameter is to be eliminated. See api_detect_encoding_html().
*/
function api_detect_encoding_xml($string, $default_encoding = null) {
@ -198,11 +198,11 @@ function _api_convert_encoding_xml_callback($matches) {
/**
* Parses CSV data (one line) into an array. This function is not affected by the OS-locale settings.
* @param string $string The input string.
* @param string $string The input string.
* @param string $delimiter (optional) The field delimiter, one character only. The default delimiter character is comma {,).
* @param string $enclosure (optional) The field enclosure, one character only. The default enclosure character is quote (").
* @param string $escape (optional) The escape character, one character only. The default escape character is backslash (\).
* @return array Returns an array containing the fields read.
* @param string $escape (optional) The escape character, one character only. The default escape character is backslash (\).
* @return array Returns an array containing the fields read.
* Note: In order this function to work correctly with UTF-8, limitation for the parameters $delimiter, $enclosure and $escape
* should be kept. These parameters should be single ASCII characters only. Thus the implementation of this function is faster.
* @link http://php.net/manual/en/function.str-getcsv.php (exists as of PHP 5 >= 5.3.0)
@ -262,12 +262,12 @@ function & api_str_getcsv(& $string, $delimiter = ',', $enclosure = '"', $escape
/**
* Reads a line from a file pointer and parses it for CSV fields. This function is not affected by the OS-locale settings.
* @param resource $handle The file pointer, it must be valid and must point to a file successfully opened by fopen().
* @param int $length (optional) Reading ends when length - 1 bytes have been read, on a newline (which is included in the return value), or on EOF (whichever comes first).
* If no length is specified, it will keep reading from the stream until it reaches the end of the line.
* @param int $length (optional) Reading ends when length - 1 bytes have been read, on a newline (which is included in the return value), or on EOF (whichever comes first).
* If no length is specified, it will keep reading from the stream until it reaches the end of the line.
* @param string $delimiter (optional) The field delimiter, one character only. The default delimiter character is comma {,).
* @param string $enclosure (optional) The field enclosure, one character only. The default enclosure character is quote (").
* @param string $escape (optional) The escape character, one character only. The default escape character is backslash (\).
* @return array Returns an array containing the fields read.
* @param string $escape (optional) The escape character, one character only. The default escape character is backslash (\).
* @return array Returns an array containing the fields read.
* Note: In order this function to work correctly with UTF-8, limitation for the parameters $delimiter, $enclosure and $escape
* should be kept. These parameters should be single ASCII characters only.
* @link http://php.net/manual/en/function.fgetcsv.php
@ -325,7 +325,7 @@ function api_contains_asciisvg($html) {
* Convers a string from camel case into underscore.
* Works correctly with ASCII strings only, implementation for human-language strings is not necessary.
* @param string $string The input string (ASCII)
* @return string The converted result string
* @return string The converted result string
*/
function api_camel_case_to_underscore($string) {
return strtolower(preg_replace('/([a-z])([A-Z])/', "$1_$2", $string));
@ -336,7 +336,7 @@ function api_camel_case_to_underscore($string) {
* Works correctly with ASCII strings only, implementation for human-language strings is not necessary.
* @param string $string The input string (ASCII)
* @param bool $capitalise_first_char (optional) If true (default), the function capitalises the first char in the result string.
* @return string The converted result string
* @return string The converted result string
*/
function api_underscore_to_camel_case($string, $capitalise_first_char = true) {
if ($capitalise_first_char) {
@ -354,11 +354,11 @@ function _api_camelize($match) {
* Truncates a string.
*
* @author Brouckaert Olivier
* @param string $text The text to truncate.
* @param integer $length The approximate desired length. The length of the suffix below is to be added to have the total length of the result string.
* @param string $text The text to truncate.
* @param integer $length The approximate desired length. The length of the suffix below is to be added to have the total length of the result string.
* @param string $suffix A suffix to be added as a replacement.
* @param string $encoding (optional) The encoding to be used. If it is omitted, the platform character set will be used by default.
* @param boolean $middle If this parameter is true, truncation is done in the middle of the string.
* @param boolean $middle If this parameter is true, truncation is done in the middle of the string.
* @return string Truncated string, decorated with the given suffix (replacement).
*/
function api_trunc_str($text, $length = 30, $suffix = '...', $middle = false, $encoding = null) {
@ -423,8 +423,8 @@ function make_clickable($string) {
/**
* @desc This function does some parsing on the text that gets inputted. This parsing can be of any kind
* LaTeX notation, Word Censoring, Glossary Terminology (extension will available soon), Musical Notations, ...
* The inspiration for this filter function came from Moodle an phpBB who both use a similar approach
* LaTeX notation, Word Censoring, Glossary Terminology (extension will available soon), Musical Notations, ...
* The inspiration for this filter function came from Moodle an phpBB who both use a similar approach.
* @param $input string. some text
* @return $output string. some text that contains the parsed elements.
* @example [tex]\sqrt(2)[/tex]
@ -480,8 +480,8 @@ function text_filter($input, $filter = true) {
* Applies parsing for tex commands that are separated by [tex]
* [/tex] to make it readable for techexplorer plugin.
* This function should not be accessed directly but should be accesse through the text_filter function
* @param string $text The text to parse
* @return string The text after parsing.
* @param string $text The text to parse
* @return string The text after parsing.
* @author Patrick Cool <patrick.cool@UGent.be>
* @version June 2004
*/
@ -513,8 +513,8 @@ function _text_parse_glossary($input) {
}
/**
* @desc this function makes a valid link to a different tool
* This function should not be accessed directly but should be accesse through the text_filter function
* @desc This function makes a valid link to a different tool.
* This function should not be accessed directly but should be accesse through the text_filter function
* @author Patrick Cool <patrick.cool@UGent.be>
*/
function _text_parse_tool($input) {
@ -526,7 +526,7 @@ function _text_parse_tool($input) {
}
/**
* render LaTeX code into a gif or retrieve a cached version of the gif
* Renders LaTeX code into a gif or retrieve a cached version of the gif.
* @author Patrick Cool <patrick.cool@UGent.be> Ghent University
*/
function latex_gif_renderer($latex_code) {
@ -555,9 +555,9 @@ function latex_gif_renderer($latex_code) {
/**
* This functions cuts a paragraph
* i.e cut('Merry Xmas from Lima',13) = "Merry Xmas fr..."
* @param string the text to "cut"
* @param int count of chars
* @param bool Whether to embed in a <span title="...">...</span>
* @param string The text to "cut"
* @param int Count of chars
* @param bool Whether to embed in a <span title="...">...</span>
* @return string
* */
function cut($text, $maxchar, $embed = false) {
@ -565,7 +565,7 @@ function cut($text, $maxchar, $embed = false) {
if ($embed) {
return '<span title="'.$text.'">'.api_substr($text, 0, $maxchar).'...</span>';
}
return api_substr($text, 0, $maxchar).'...' ;
return api_substr($text, 0, $maxchar).'...';
}
return $text;
}
@ -573,9 +573,9 @@ function cut($text, $maxchar, $embed = false) {
/**
* Show a number as only integers if no decimals, but will show 2 decimals if exist.
*
* @param mixed number to convert
* @param int decimal points 0=never, 1=if needed, 2=always
* @return mixed an integer or a float depends on the parameter
* @param mixed Number to convert
* @param int Decimal points 0=never, 1=if needed, 2=always
* @return mixed An integer or a float depends on the parameter
*/
function float_format($number, $flag = 1) {
if (is_numeric($number)) {
@ -595,7 +595,7 @@ function float_format($number, $flag = 1) {
// TODO: To be checked for correct timezone management.
/**
* Function to obtain last week timestamps
* @return array times for every day inside week
* @return array Times for every day inside week
*/
function get_last_week() {
$week = date('W');
@ -616,8 +616,8 @@ function get_last_week() {
/**
* Gets the week from a day
* @param string date in UTC (2010-01-01 12:12:12)
* @return int int with the week number of the year
* @param string Date in UTC (2010-01-01 12:12:12)
* @return int Returns an integer with the week number of the year
*/
function get_week_from_day($date) {
if (!empty($date)) {
@ -636,8 +636,8 @@ function get_week_from_day($date) {
/**
* Applies parsing the content for tex commands that are separated by [tex]
* [/tex] to make it readable for techexplorer plugin.
* @param string $text The text to parse
* @return string The text after parsing.
* @param string $text The text to parse
* @return string The text after parsing.
* @author Patrick Cool <patrick.cool@UGent.be>
* @version June 2004
*/
@ -655,8 +655,8 @@ function api_parse_tex($textext) {
* Applies parsing for tex commandos that are seperated by [tex]
* [/tex] to make it readable for techexplorer plugin.
* This function should not be accessed directly but should be accesse through the text_filter function
* @param string $text The text to parse
* @return string The text after parsing.
* @param string $text The text to parse
* @return string The text after parsing.
* @author Patrick Cool <patrick.cool@UGent.be>
* @version June 2004
*/

Loading…
Cancel
Save