From 31d0069d7fbcd86c403fba2ee406810e998edabc Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Fri, 11 Sep 2015 14:27:10 +0200 Subject: [PATCH] Remove unused code --- main/exercice/export/scorm/scorm_classes.php | 2 - main/exercice/question.class.php | 2 +- main/inc/latex.php | 40 ----- main/inc/lib/link.lib.php | 2 +- main/inc/lib/text.lib.php | 132 ---------------- main/newscorm/learnpath.class.php | 1 - tests/main/inc/lib/text.lib.test.php | 157 +++++++------------ 7 files changed, 62 insertions(+), 274 deletions(-) delete mode 100755 main/inc/latex.php diff --git a/main/exercice/export/scorm/scorm_classes.php b/main/exercice/export/scorm/scorm_classes.php index 248d58e475..46b6855f2c 100755 --- a/main/exercice/export/scorm/scorm_classes.php +++ b/main/exercice/export/scorm/scorm_classes.php @@ -733,14 +733,12 @@ class ScormAnswerHotspot extends Answer { $s="  "; - $questionName=text_filter($questionName); $s.=$questionName; $s.=" "; - $questionDescription=text_filter($questionDescription); $s.=$questionDescription; $s.=" diff --git a/main/exercice/question.class.php b/main/exercice/question.class.php index bf7c88b5d0..d4cc14b0e2 100755 --- a/main/exercice/question.class.php +++ b/main/exercice/question.class.php @@ -204,7 +204,7 @@ abstract class Question */ public function selectDescription() { - $this->description = text_filter($this->description); + $this->description = $this->description; return $this->description; } diff --git a/main/inc/latex.php b/main/inc/latex.php deleted file mode 100755 index e329e77e17..0000000000 --- a/main/inc/latex.php +++ /dev/null @@ -1,40 +0,0 @@ - - - -LaTeX Code - - - -'; -echo '

'.get_lang('LatexCode').'

'; -echo stripslashes($code); -echo ''; - -echo '
'; -echo '

'.get_lang('LatexFormula').'

'; -echo ''.get_lang('LatexCode').''; -echo '
'; - -/* FOOTER */ - -?> - - \ No newline at end of file diff --git a/main/inc/lib/link.lib.php b/main/inc/lib/link.lib.php index 424beba727..5d690a04a8 100755 --- a/main/inc/lib/link.lib.php +++ b/main/inc/lib/link.lib.php @@ -1547,7 +1547,7 @@ class Link extends Model // Validation when belongs to a session $showChildren = $categoryId == $myrow['id'] || $show == 'all'; $session_img = api_get_session_image($myrow['session_id'], $_user['status']); - $myrow['description'] = text_filter($myrow['description']); + $myrow['description'] = $myrow['description']; $strVisibility = ''; $visibilityClass = null; diff --git a/main/inc/lib/text.lib.php b/main/inc/lib/text.lib.php index 1b1e956693..83610f480b 100755 --- a/main/inc/lib/text.lib.php +++ b/main/inc/lib/text.lib.php @@ -622,138 +622,6 @@ function _split_str_by_whitespace( $string, $goal ) { return $chunks; } - -/** - * @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. - * [tex]\sqrt(2)[/tex] - * @param $input string. some text - * @return $output string. some text that contains the parsed elements. - * @author Patrick Cool - * @version March 2OO6 - */ -function text_filter($input, $filter = true) { - - //$input = stripslashes($input); - - if ($filter) { - // *** parse [tex]...[/tex] tags *** // - // which will return techexplorer or image html depending on the capabilities of the - // browser of the user (using some javascript that checks if the browser has the TechExplorer plugin installed or not) - //$input = _text_parse_tex($input); - - // *** parse [teximage]...[/teximage] tags *** // - // these force the gif rendering of LaTeX using the mimetex gif renderer - //$input=_text_parse_tex_image($input); - - // *** parse [texexplorer]...[/texexplorer] tags *** // - // these force the texeplorer LaTeX notation - //$input = _text_parse_texexplorer($input); - - // *** Censor Words *** // - // censor words. This function removes certain words by [censored] - // this can be usefull when the campus is open to the world. - // $input=text_censor_words($input); - - // *** parse [?]...[/?] tags *** // - // for the glossary tool - //$input = _text_parse_glossary($input); - - // parse [wiki]...[/wiki] tags - // this is for the coolwiki plugin. - // $input=text_parse_wiki($input); - - // parse [tool]...[/tool] tags - // this parse function adds a link to a certain tool - // $input=text_parse_tool($input); - - // parse [user]...[/user] tags - - // parse [email]...[/email] tags - - // parse [code]...[/code] tags - } - - return $input; -} - -/** - * 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. - * @author Patrick Cool - * @version June 2004 - */ -function _text_parse_tex($textext) { - //$textext = str_replace(array ("[tex]", "[/tex]"), array ('[*****]', '[/*****]'), $textext); - //$textext = stripslashes($texttext); - - $input_array = preg_split("/(\[tex]|\[\/tex])/", $textext, -1, PREG_SPLIT_DELIM_CAPTURE); - - foreach ($input_array as $key => $value) { - if ($key > 0 && $input_array[$key - 1] == '[tex]' AND $input_array[$key + 1] == '[/tex]') { - $input_array[$key] = latex_gif_renderer($value); - unset($input_array[$key - 1]); - unset($input_array[$key + 1]); - //echo 'LaTeX:
'; - } - } - - $output = implode('',$input_array); - return $output; -} - -/** - * This function should not be accessed directly but should be accesse through the text_filter function - * @author Patrick Cool - */ -function _text_parse_glossary($input) { - return $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 - * @author Patrick Cool - */ -function _text_parse_tool($input) { - // An array with all the valid tools - $tools[] = array(TOOL_ANNOUNCEMENT, 'announcements/announcements.php'); - $tools[] = array(TOOL_CALENDAR_EVENT, 'calendar/agenda.php'); - - // Check if the name between the [tool] [/tool] tags is a valid one -} - -/** - * Renders LaTeX code into a gif or retrieve a cached version of the gif. - * @author Patrick Cool Ghent University - */ -function latex_gif_renderer($latex_code) { - $_course = api_get_course_info(); - - // Setting the paths and filenames - $mimetex_path = api_get_path(LIBRARY_PATH).'mimetex/'; - $temp_path = api_get_path(SYS_COURSE_PATH).$_course['path'].'/temp/'; - $latex_filename = md5($latex_code).'.gif'; - - if (!file_exists($temp_path.$latex_filename) OR isset($_GET['render'])) { - if (IS_WINDOWS_OS) { - $mimetex_command = $mimetex_path.'mimetex.exe -e "'.$temp_path.md5($latex_code).'.gif" '.escapeshellarg($latex_code).''; - } else { - $mimetex_command = $mimetex_path.'mimetex.cgi -e "'.$temp_path.md5($latex_code).'.gif" '.escapeshellarg($latex_code); - } - exec($mimetex_command); - //echo 'volgende shell commando werd uitgevoerd:
'.$mimetex_command.'

'; - } - - $return = ""; - $return .= ''.$latex_code.''; - return $return; -} - /** * This functions cuts a paragraph * i.e cut('Merry Xmas from Lima',13) = "Merry Xmas fr..." diff --git a/main/newscorm/learnpath.class.php b/main/newscorm/learnpath.class.php index 58fc5069b5..a5aa127e55 100755 --- a/main/newscorm/learnpath.class.php +++ b/main/newscorm/learnpath.class.php @@ -6030,7 +6030,6 @@ class learnpath $file = $filepath . $row['path']; if ($fp = @ fopen($file, '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. diff --git a/tests/main/inc/lib/text.lib.test.php b/tests/main/inc/lib/text.lib.test.php index ddfd34be56..e330a65df2 100755 --- a/tests/main/inc/lib/text.lib.test.php +++ b/tests/main/inc/lib/text.lib.test.php @@ -1,108 +1,71 @@ assertTrue(is_string($res)); + } else { + $this->assertTrue(true); // The file is missing, skip this test. + } + //var_dump('
'.$res.'
'); + } - public function test_api_html_to_text() { - $filename = api_get_path(SYS_PATH).'documentation/installation_guide.html'; - $res = @file_get_contents($filename); - if ($res !== false) { - $res = api_html_to_text($res); - $this->assertTrue(is_string($res)); - } else { - $this->assertTrue(true); // The file is missing, skip this test. - } - //var_dump('
'.$res.'
'); - } + public function test_api_camel_case_to_underscore() { + $input_strings = array('myDocuments', 'MyProfile', 'CreateNewCourse', 'Create_New_course'); + $expected_results = array('my_documents', 'my_profile', 'create_new_course', 'create_new_course'); + $results = array_map('api_camel_case_to_underscore', $input_strings); + $this->assertTrue($results == $expected_results); + //var_dump($results); + } - public function test_api_camel_case_to_underscore() { - $input_strings = array('myDocuments', 'MyProfile', 'CreateNewCourse', 'Create_New_course'); - $expected_results = array('my_documents', 'my_profile', 'create_new_course', 'create_new_course'); - $results = array_map('api_camel_case_to_underscore', $input_strings); - $this->assertTrue($results == $expected_results); - //var_dump($results); - } + function test_api_underscore_to_camel_case() { + $input_strings = array('my_documents', 'My_profile', 'create_new_course'); + $expected_results1 = array('MyDocuments', 'MyProfile', 'CreateNewCourse'); + $expected_results2 = array('myDocuments', 'MyProfile', 'createNewCourse'); + $func = create_function('$param', 'return api_underscore_to_camel_case($param, false);'); + $results1 = array('MyDocuments', 'MyProfile', 'CreateNewCourse'); + $results2 = array('myDocuments', 'MyProfile', 'createNewCourse'); + $results1 = array_map('api_underscore_to_camel_case', $input_strings); + $results2 = array_map($func, $input_strings); + $this->assertTrue($results1 == $expected_results1 && $results2 == $expected_results2); + //var_dump($results1); + //var_dump($results2); + } - function test_api_underscore_to_camel_case() { - $input_strings = array('my_documents', 'My_profile', 'create_new_course'); - $expected_results1 = array('MyDocuments', 'MyProfile', 'CreateNewCourse'); - $expected_results2 = array('myDocuments', 'MyProfile', 'createNewCourse'); - $func = create_function('$param', 'return api_underscore_to_camel_case($param, false);'); - $results1 = array('MyDocuments', 'MyProfile', 'CreateNewCourse'); - $results2 = array('myDocuments', 'MyProfile', 'createNewCourse'); - $results1 = array_map('api_underscore_to_camel_case', $input_strings); - $results2 = array_map($func, $input_strings); - $this->assertTrue($results1 == $expected_results1 && $results2 == $expected_results2); - //var_dump($results1); - //var_dump($results2); - } - function test_text_parse_glossary() { - $input=''; - $res=_text_parse_glossary($input); - $this->assertTrue(is_string($res)); - //var_dump($res); - } + function testcut() { + $text=''; + $maxchar=''; + $res=cut($text,$maxchar,$embed=false); + $this->assertTrue(is_string($res)); + //var_dump($res); + } - function test_text_parse_tex() { - $textext=''; - $res=_text_parse_tex($textext); - $this->assertTrue(is_string($res)); - //var_dump($res); - } + function testdate_to_str_ago() { + $date=''; + $res=date_to_str_ago($date); + $this->assertTrue(is_string($res)); + //var_dump($res); + } - function test_text_parse_tool() { - $input=''; - $res=_text_parse_tool($input); - $this->assertTrue(is_null($res)); - //var_dump($res); - } + function testfloat_format() { + $number=''; + $res=float_format($number, $flag = 1); + if(!is_numeric($res) or !is_float($res)) { + $this->assertTrue(is_null($res)); + } + //var_dump($res); + } - function testcut() { - $text=''; - $maxchar=''; - $res=cut($text,$maxchar,$embed=false); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - function testdate_to_str_ago() { - $date=''; - $res=date_to_str_ago($date); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - function testfloat_format() { - $number=''; - $res=float_format($number, $flag = 1); - if(!is_numeric($res) or !is_float($res)) { - $this->assertTrue(is_null($res)); - } - //var_dump($res); - } - - function testlatex_gif_renderer() { - ob_start(); - $latex_code=""; - global $_course; - $res=latex_gif_renderer($latex_code); - ob_end_clean(); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - function testmake_clickable() { - $string=''; - $res=make_clickable($string); - $this->assertTrue(is_string($res)); - //var_dump($res); - } - - function testtext_filter() { - $input=''; - $res=text_filter($input, $filter=true); - $this->assertTrue(is_string($res)); - //var_dump($res); - } + function testmake_clickable() { + $string=''; + $res=make_clickable($string); + $this->assertTrue(is_string($res)); + //var_dump($res); + } }