Remove unused code

1.10.x
Julio Montoya 9 years ago
parent 57f99efbdc
commit 31d0069d7f
  1. 2
      main/exercice/export/scorm/scorm_classes.php
  2. 2
      main/exercice/question.class.php
  3. 40
      main/inc/latex.php
  4. 2
      main/inc/lib/link.lib.php
  5. 132
      main/inc/lib/text.lib.php
  6. 1
      main/newscorm/learnpath.class.php
  7. 41
      tests/main/inc/lib/text.lib.test.php

@ -733,14 +733,12 @@ class ScormAnswerHotspot extends Answer
{
$s="<tr>
<td valign='top' colspan='2'>&nbsp;";
$questionName=text_filter($questionName);
$s.=$questionName;
$s.="</td>
</tr>
<tr>
<td valign='top' colspan='2'>
<i>";
$questionDescription=text_filter($questionDescription);
$s.=$questionDescription;
$s.="</i>
</td>

@ -204,7 +204,7 @@ abstract class Question
*/
public function selectDescription()
{
$this->description = text_filter($this->description);
$this->description = $this->description;
return $this->description;
}

@ -1,40 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>LaTeX Code</title>
</head>
<body>
<?php // $Id: latex.php,v 1.1 2006/04/05 07:18:46 pcool Exp $
/* For licensing terms, see /license.txt */
/* INIT SECTION */
include '../inc/global.inc.php';
/* FUNCTIONS */
// put your functions here
// if the list gets large, divide them into different sections:
// display functions, tool logic functions, database functions
// try to place your functions into an API library or separate functions file - it helps reuse
/* MAIN CODE */
$code = Security::remove_XSS($_GET['code']);
echo '<div id="latex_code">';
echo '<h3>'.get_lang('LatexCode').'</h3>';
echo stripslashes($code);
echo '</div>';
echo '<div id="latex_image">';
echo '<h3>'.get_lang('LatexFormula').'</h3>';
echo '<img src="'.api_get_path(WEB_COURSE_PATH).$_course['path'].'/temp/'.$code.'" alt="'.get_lang('LatexCode').'"/>';
echo '</div>';
/* FOOTER */
?>
</body>
</html>

@ -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;

@ -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.
* <code>[tex]\sqrt(2)[/tex]</code>
* @param $input string. some text
* @return $output string. some text that contains the parsed elements.
* @author Patrick Cool <patrick.cool@UGent.be>
* @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 <patrick.cool@UGent.be>
* @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: <embed type="application/x-techexplorer" texdata="'.stripslashes($value).'" autosize="true" pluginspage="http://www.integretechpub.com/techexplorer/"><br />';
}
}
$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 <patrick.cool@UGent.be>
*/
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 <patrick.cool@UGent.be>
*/
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 <patrick.cool@UGent.be> 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:<br /><pre>'.$mimetex_command.'</pre><hr>';
}
$return = "<a href=\"\" onclick=\"javascript: newWindow=window.open('".api_get_path(WEB_CODE_PATH)."inc/latex.php?code=".urlencode($latex_code)."&amp;filename=$latex_filename','latexCode','toolbar=no,location=no,scrollbars=yes,resizable=yes,status=yes,width=375,height=250,left=200,top=100');\">";
$return .= '<img src="'.api_get_path(WEB_COURSE_PATH).$_course['path'].'/temp/'.$latex_filename.'" alt="'.$latex_code.'" border="0" /></a>';
return $return;
}
/**
* This functions cuts a paragraph
* i.e cut('Merry Xmas from Lima',13) = "Merry Xmas fr..."

@ -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.

@ -1,8 +1,8 @@
<?php
require_once(api_get_path(LIBRARY_PATH).'text.lib.php');
class TestText extends UnitTestCase {
class TestText extends UnitTestCase
{
public function test_api_html_to_text() {
$filename = api_get_path(SYS_PATH).'documentation/installation_guide.html';
$res = @file_get_contents($filename);
@ -37,26 +37,6 @@ class TestText extends UnitTestCase {
//var_dump($results2);
}
function test_text_parse_glossary() {
$input='';
$res=_text_parse_glossary($input);
$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 test_text_parse_tool() {
$input='';
$res=_text_parse_tool($input);
$this->assertTrue(is_null($res));
//var_dump($res);
}
function testcut() {
$text='';
@ -82,27 +62,10 @@ class TestText extends UnitTestCase {
//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);
}
}

Loading…
Cancel
Save