Changeset 143
- Timestamp:
- 11/20/07 19:45:27 (1 year ago)
- Files:
-
- latex/INSTALL (moved) (moved from latex/mod/latex/INSTALL) (5 diffs)
- latex/LICENSE (moved) (moved from latex/mod/latex/LICENSE)
- latex/README (deleted)
- latex/_tinymce (deleted)
- latex/class.latexrender.php (moved) (moved from latex/mod/latex/class.latexrender.php)
- latex/latex_pic.php (moved) (moved from latex/mod/latex/latex_pic.php)
- latex/latex_render.php (added)
- latex/lib.php (moved) (moved from latex/mod/latex/lib.php) (2 diffs)
- latex/tinymce (added)
- latex/tinymce/latex (copied) (copied from latex/_tinymce/jscripts/tiny_mce/plugins/latex)
- latex/tinymce/latex/langs/en.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
latex/INSTALL
r34 r143 1 01-13-2007 1 Originally written: 01-13-2007 2 Last updated: 11-20-2007 3 (tested against svn revision 1296) 2 4 3 Renato Mendes Coutinho 4 renato@cecm.usp.br 5 Author: Renato Mendes Coutinho 6 mailto: renato.coutinho@gmail.com 7 elgg.org username: renato 8 5 9 6 10 This plugin is an adaptation of the LaTeX Rendering Class written by Benjamin … … 12 16 the University of Sao Paulo (http://stoa.usp.br). 13 17 14 REQUIREMENTS: 15 You need to have installed latex, convert (ImageMagick), identify and dvips. You 16 may have to set the path to them in class.latexrender.php lines 36-39. 18 Thanks also to Rolando, for the auto-create folder function. 19 20 21 REQUIREMENTS: 22 23 You need to have installed latex, convert (ImageMagick), ghostscript, identify 24 and dvips. You may have to set the path to them in class.latexrender.php lines 25 36-39 if your install paths are "unusual". 26 17 27 18 28 TO INSTALL: … … 24 34 25 35 26 - create the following tree under the dataroot ($CFG->dataroot which you set in config.php):27 latex/, latex/tmp/ and latex/pictures/28 all with write permission (777).29 30 31 - modify elgg/units/weblogs_text_process.php:32 @@ -55,6 +55,9 @@33 $run_result = preg_replace('/<a\s+/i', '<a rel="nofollow" ', $run_result);34 }35 36 + // plugins can process text in weblogs37 + $run_result = plugin_hook("weblog_post","process",$run_result);38 +39 // Text cutting40 // Commented out for the moment as it seems to disproportionately increase41 // memory usage / load42 43 44 36 - In order to fix a bug that cuts the backslashes when editing a post, edit the files 45 37 46 38 elgg/lib/displaylib.php: 47 @@ -152,7 +152,7 @@ 39 40 @@ -228,7 +228,7 @@ 48 41 $run_result .= "<input type=\"text\" name=\"".$parameter[0]."\" value=\"".htmlspecialchars(stripslashes($parameter[1]), ENT_COMPAT, 'utf-8')."\" style=\"width: 95%\" id=\"".$cleanid."\" />"; 49 42 break; … … 52 45 + $run_result .= "<textarea name=\"".$parameter[0]."\" id=\"".$parameter[0]."\" style=\"width: 95%; height: 200px\">".htmlspecialchars($parameter[1], ENT_COMPAT, 'utf-8')."</textarea>"; 53 46 break; 54 } 47 default: 48 if (isset($CFG->display_field_module[$parameter[2]])) { 55 49 56 and elgg/units/weblogs/weblogs_posts_edit.php: 57 @@ -38,7 +38,7 @@ 50 51 and elgg/mod/blog/lib/weblogs_posts_edit.php: 52 53 @@ -85,7 +85,7 @@ 58 54 $body .= templates_draw(array( 59 55 'context' => 'databoxvertical', … … 65 61 66 62 67 - To add a button to the tinymce menu,copy the files in68 elgg/_tinymce/jscripts/tiny_mce/plugins/latex and add "latex" to69 elgg/units/tinymce/tinymce_js.php:63 - Optionally, you can add a button to the tinymce menu. Just copy the files in 64 the folder tinymce/latex to elgg/mod/tinymce/lib/jscripts/tiny_mce/plugins 65 and add "latex" to elgg/mod/tinymce/tinymce_js.php: 70 66 71 circa line 48: theme_advanced_buttons1 :72 circa line 58: plugins :67 circa line 36: $plugins = ... 68 circa line 73: theme_advanced_buttons1 : ... 73 69 74 Note that the button description is translated only to brazilian portuguese 75 (besides english, of course). 70 (this feature is not that much tested in all browsers, but ideally it should work) 76 71 77 72 latex/lib.php
r63 r143 2 2 3 3 function latex_init() { 4 global $CFG ;4 global $CFG, $function; 5 5 6 include_once($CFG->dirroot . "mod/latex/class.latexrender.php"); 6 latex_setup(); 7 8 // include_once($CFG->dirroot . "mod/latex/class.latexrender.php"); 9 $function['weblogs:text:process'][] = $CFG->dirroot . "mod/latex/latex_render.php"; 7 10 8 listen_for_event("weblog_post","process","latex_render");11 //listen_for_event("weblog_post","process","latex_render"); 9 12 } 10 13 … … 12 15 } 13 16 14 function latex_render($object_type,$event,$text) { 17 function latex_setup() { 18 $dirs = array('latex/tmp', 'latex/pictures'); 15 19 16 global $CFG; 17 18 $latexrender_path = $CFG->dataroot . "latex"; 19 $latexrender_path_http = $CFG->wwwroot . "_latex"; 20 21 preg_match_all("#\[tex\](.*?)\[/tex\]#si",$text,$tex_matches); 22 23 $latex = new LatexRender($latexrender_path."/pictures",$latexrender_path_http,$latexrender_path."/tmp"); 24 25 for ($i=0; $i < count($tex_matches[0]); $i++) { 26 $pos = strpos($text, $tex_matches[0][$i]); 27 28 // get formula and replace blank spaces 29 $latex_formula = str_replace(' ', ' ', $tex_matches[1][$i]); 30 31 // convert to new-line <p> and <br> 32 $latex_formula = preg_replace('#<p\\s*?/??>#i', '', $latex_formula); 33 $latex_formula = preg_replace('#</p\\s*?/??>#i', "\n", $latex_formula); 34 $latex_formula = preg_replace('#<br\\s*?/??>#i', "\n", $latex_formula); 35 36 // decode html entities 37 $latex_formula = html_entity_decode($latex_formula); 38 39 $url = $latex->getFormulaURL($latex_formula); 40 41 $alt_latex_formula = htmlentities($latex_formula, ENT_QUOTES); 42 $alt_latex_formula = str_replace("\r"," ",$alt_latex_formula); 43 $alt_latex_formula = str_replace("\n"," ",$alt_latex_formula); 44 45 if ($url != false) { 46 $text = substr_replace($text, "<img src='".$url."' title='".$alt_latex_formula."' alt='".$alt_latex_formula."' align='absmiddle'>",$pos,strlen($tex_matches[0][$i])); 47 } else { 48 // unparseable or potentially dangerous latex formula 49 //$text = substr_replace($text, $tex_matches[1][$i],$pos,strlen($tex_matches[0][$i])); 20 foreach ($dirs as $dir) { 21 if (!file_exists($dir)) { 22 make_upload_directory($dir); 50 23 } 51 24 } 52 return $text;53 25 } 54 26 latex/tinymce/latex/langs/en.js
r34 r143 4 4 5 5 tinyMCE.addToLang('',{ 6 template_desc : ' Insert LaTeX tags'6 template_desc : 'LaTeX' 7 7 });
