Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/filter/algebra/pix.php
Go to the documentation of this file.
00001 <?PHP
00002       // This function fetches math. images from the data directory
00003       // If not, it obtains the corresponding TeX expression from the cache_tex db table
00004       // and uses mimeTeX to create the image file
00005 
00006 // disable moodle specific debug messages and any errors in output
00007 define('NO_DEBUG_DISPLAY', true);
00008 define('NO_MOODLE_COOKIES', true); // Because it interferes with caching
00009 
00010     require_once('../../config.php');
00011 
00012     if (!filter_is_enabled('filter/algebra')) {
00013         print_error('filternotenabled');
00014     }
00015 
00016     require_once($CFG->libdir.'/filelib.php');
00017     require_once($CFG->dirroot.'/filter/tex/lib.php');
00018 
00019     $cmd    = '';               // Initialise these variables
00020     $status = '';
00021 
00022     $relativepath = get_file_argument();
00023 
00024     $args = explode('/', trim($relativepath, '/'));
00025 
00026     if (count($args) == 1) {
00027         $image    = $args[0];
00028         $pathname = $CFG->dataroot.'/filter/algebra/'.$image;
00029     } else {
00030         print_error('invalidarguments', 'error');
00031     }
00032 
00033     if (!file_exists($pathname)) {
00034         $md5 = str_replace('.gif','',$image);
00035         if ($texcache = $DB->get_record('cache_filters', array('filter'=>'algebra', 'md5key'=>$md5))) {
00036             if (!file_exists($CFG->dataroot.'/filter/algebra')) {
00037                 make_upload_directory('filter/algebra');
00038             }
00039 
00040             $texexp = $texcache->rawtext;
00041             $texexp = str_replace('&lt;','<',$texexp);
00042             $texexp = str_replace('&gt;','>',$texexp);
00043             $texexp = preg_replace('!\r\n?!',' ',$texexp);
00044             $texexp = '\Large ' . $texexp;
00045             $cmd = filter_tex_get_cmd($pathname, $texexp);
00046             system($cmd, $status);
00047         }
00048     }
00049 
00050     if (file_exists($pathname)) {
00051         send_file($pathname, $image);
00052     } else {
00053         if (debugging()) {
00054             echo "The shell command<br />$cmd<br />returned status = $status<br />\n";
00055             echo "Image not found!<br />";
00056             echo "Please try the <a href=\"$CFG->wwwroot/filter/algebra/algebradebug.php\">debugging script</a>";
00057         } else {
00058             echo "Image not found!<br />";
00059             echo "Please try the <a href=\"$CFG->wwwroot/filter/algebra/algebradebug.php\">debugging script</a><br />";
00060             echo "Please turn on debug mode in site configuration to see more info here.";
00061         }
00062     }
00063 
 All Data Structures Namespaces Files Functions Variables Enumerations