Index: mathfilter.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mathfilter/mathfilter.module,v
retrieving revision 1.3
diff -r1.3 mathfilter.module
18c18
< 		'description' => t('Set the URL to your Mimetex binary.'),
---
> 		'description' => t('Set the URL to the Mimetex binary.'),
40c40
< 		'#default_value' => variable_get('mathfilter_cgi', ''),
---
> 		'#default_value' => variable_get('mathfilter_cgi', '/cgi-bin/mimetex.cgi'),
42c42
< 		'#description' => t('Entering the full URL here allows admin users to define the location of their Mimetex binary (which could be a CGI or a .exe file.  Note that you will have to visit <a href="http://www.forkosh.com/mimetex.html">this website</a> to download and install the binary.)')
---
> 		'#description' => t('Entering the full URL here allows admin users to define the location of their Mimetex binary (which could be a CGI or a .exe file.  You can visit <a href="http://www.forkosh.com/mimetex.html">this website</a> to download and install the binary.)')
44c44
< 	/*$form['mathfilter_width'] = array(
---
> 	$form['mathfilter_width'] = array(
46,47c46,47
< 		'#default_value' => variable_get('mathfilter_width', 260),
< 		'#title' => t('Enter the default width of the graphs'),
---
> 		'#default_value' => variable_get('mathfilter_width', '260'),
> 		'#title' => t('Enter the default width of the graphs in px'),
51,54c51,61
< 		'#default_value' => variable_get('mathfilter_height', 260),
< 		'#title' => t('Enter the default width of the graphs'),
< 	);*/
<   return system_settings_form($form);
---
> 		'#default_value' => variable_get('mathfilter_height', '260'),
> 		'#title' => t('Enter the default height of the graphs in px'),
> 	);
> 
> 	$form['mathfilter_caching'] = array(
> 		'#type' => 'checkbox',
> 		'#title' => 'Cache',
> 		'#default_value' => variable_get('mathfilter_caching', FALSE),
> 		'#description' => t('Select to save images instead of referencing mimeTex.'),
> 	);
> 	return system_settings_form($form);
63c70
<       return array(0 => t('Mathematics')); 
---
>       return array(0 => t('Mathfilter')); 
68,70d74
<     case 'prepare': 
<     
< 	
74,75c78
< 		$request = $_SERVER['HTTP_HOST'];
< 		$mimetex_cgi_path_http = variable_get('mathfilter_cgi', ''); // http://www.unitorganizer.com/cgi-bin/mimetex.cgi
---
> 		$mimetex_cgi_path_http = variable_get('mathfilter_cgi', '/cgi-bin/mimetex.cgi'); // http://www.unitorganizer.com/cgi-bin/mimetex.cgi
76a80,114
> 
> 		/* Get the defined width/height. */
> 		$graph_width  = variable_get('mathfilter_width', '260');
> 		$graph_height = variable_get('mathfilter_height', '260');
> 
> 		/* Find out if caching is enabled. */
> 		$mathfilter_caching = variable_get('mathfilter_caching', FALSE);
> 
> 		if ($mathfilter_caching) {
> 			/* We make sure that the directory exists and is writable. */
> 			/* We do this here in case something happens so we can     */
> 			/* deal with it on the fly if necessary.                   */
> 			$file_directory_path = file_directory_path()."/mathfilter";
> 			if (!file_check_directory($file_directory_path)) {
> 				if (!is_dir($file_directory_path)) {
> 					mkdir($file_directory_path);
> 				}
> 				chmod($file_directory_path, 0777);
> 			}
> 
> 			/* If we are going with caching, we need an /absolute/ url */
> 			/* for cURL which may have not been entered by the user.   */
> 			if (preg_match('/^http/i', $mimetex_cgi_path_http)) {
> 				$absolute_url = $mimetex_cgi_path_http;
> 			} else {
> 				/* We will respect secure transactions. */
> 				if ($_SERVER['HTTPS']) {
> 					$absolute_url = 'https://';
> 				} else {
> 					$absolute_url = 'http://';
> 				}
> 				$absolute_url .= $_SERVER['HTTP_HOST'] . $mimetex_cgi_path_http . '?';
> 			}
> 
> 		}
87c125,147
< 			$text = substr_replace($text, "<img src='".$mimetex_cgi_path_http."?" . rawurlencode($mimetex_formula) . "' title='".$alt_mimetex_formula."' alt='".$alt_mimetex_formula."' style=\"vertical-align: middle;\" >",$pos,strlen($tex_matches[0][$i]));
---
> 
> 			if (!$mathfilter_caching) {
> 				$text = substr_replace($text, "<img src='".$mimetex_cgi_path_http."?" . rawurlencode($mimetex_formula) . "' title='".$alt_mimetex_formula."' alt='".$alt_mimetex_formula."' style=\"vertical-align: middle;\" >",$pos,strlen($tex_matches[0][$i]));
> 			} else {
> 				/* mathfilter_caching */
> 				/* Get the image with curl, save it using sha1    */
> 				/* as the file name and reference the saved image */ 
> 				/* in the img tag.  We use sha1 to prevent file   */
> 				/* name collisions which is *much* better for     */
> 				/* this purpose than md5 which is used by mimetex */
> 				/* if caching is enabled at compile time.         */
> 				$formula_image_file = $file_directory_path . '/' . sha1($mimetex_formula) . '.gif';
> 				$ch = curl_init($absolute_url . rawurlencode($mimetex_formula));
> 				$fp = fopen($formula_image_file, 'w');
> 
> 				curl_setopt($ch, CURLOPT_FILE, $fp);
> 
> 				curl_exec($ch);
> 				curl_close($ch);
> 				fclose($fp);
> 
> 				$text = substr_replace($text, "<img src='".file_create_url($formula_image_file)."' title='".$alt_mimetex_formula."' alt='".$alt_mimetex_formula."' style=\"vertical-align: middle;\" >",$pos,strlen($tex_matches[0][$i]));
> 			}
95c155,156
< 			$text = substr_replace($text, '<iframe frameborder="0" src="'.$graph_path.'f='.urlencode($function).'" style="display: block; width: 260px; height: 260px; border: 0px;" scrolling="no" ></iframe>',$pos,strlen($graph_matches[0][$i]));
---
> 
> 			$text = substr_replace($text, '<iframe frameborder="0" src="'.$graph_path.'f='.urlencode($function).'" style="display: block; width: '.$graph_width.'px; height: '.$graph_height.'px; border: 0px;" scrolling="no" ></iframe>',$pos,strlen($graph_matches[0][$i]));
103c164,165
< 			$text = substr_replace($text, '<iframe frameborder="0" src="'.$graph_path.'f='.urlencode($function).'&xmin='.$matches[1][$i].'&xmax='.$matches[2][$i].'&ymin='.$matches[3][$i].'&ymax='.$matches[4][$i].'" style="display: block; width: 260px; height: 260px; border: 0px;" scrolling="no" ></iframe>',$pos,strlen($matches[0][$i]));
---
> 
> 			$text = substr_replace($text, '<iframe frameborder="0" src="'.$graph_path.'f='.urlencode($function).'&xmin='.$matches[1][$i].'&xmax='.$matches[2][$i].'&ymin='.$matches[3][$i].'&ymax='.$matches[4][$i].'" style="display: block; width: '.$graph_width.'px; height: '.$graph_height.'px; border: 0px;" scrolling="no" ></iframe>',$pos,strlen($matches[0][$i]));
114c176
< ?>
\ No newline at end of file
---
> ?>
Index: includes/graphframe.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mathfilter/includes/graphframe.php,v
retrieving revision 1.1
diff -r1.1 graphframe.php
10c10,25
< 	<div id="fakegraphframe" style="position: relative; display: block; width: 245px; height: 242px; margin: 0px; padding: 0px;"></div>
---
> 	<?php
> 	/* We need to chdir to the root of the Drupal */
> 	/* install so includes, etc work properly     */
> 	/* when we bootstrap to work in a Drupal      */
> 	/* envronment.                                */
> 	chdir("../../..");
> 	include('includes/bootstrap.inc');
> 
> 	drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
> 
> 	/* graph size user defined */
> 	$width  = variable_get('mathfilter_width', '260');
> 	$height = variable_get('mathfilter_height', '260');
> 
> 	echo '<div id="fakegraphframe" style="position: relative; display: block; width: '.$width.'px; height: '.$height.'px; margin: 0px; padding: 0px;"></div>';
> 	?>
13c28
< 			if ($_GET['f']) {
---
> 			if (array_key_exists('f', $_GET)) {
18c33
< 			if ($_GET['xmin']) {
---
> 			if (array_key_exists('xmin', $_GET) && is_numeric($_GET['xmin'])) {
23c38
< 			if ($_GET['xmax']) {
---
> 			if (array_key_exists('xmax', $_GET) && is_numeric($_GET['xmax'])) {
28c43
< 			if ($_GET['ymax']) {
---
> 			if (array_key_exists('ymax', $_GET) && is_numeric($_GET['ymax'])) {
33c48
< 			if ($_GET['ymin']) {
---
> 			if (array_key_exists('ymin', $_GET) && is_numeric($_GET['ymin'])) {
45a61,88
> 
> 			/* Height/width must fit in the iframe    */
> 			/* so we take the smaller of the two      */
> 			/* because the graph is hardcoded square. */
> 			$size = ($width < $height) ? $width : $height;
> 
> 			/* But WZ put in some hard coded numbers  */
> 			/* so we account for them here. These are */
> 			/* not adjusted because the font size is  */
> 			/* hardcoded as well.                     */
> 			$right    = 4;
> 			$left_top = 10;
> 			$bottom   = 22;
> 
> 			/* This is the area where the curve will */
> 			/* be drawn.  So, we use the ratio that  */
> 			/* is the defaults in the js to start.   */
> 			$defw     = intval($size*(220/260));
> 
> 			/* Now we make sure that these values */
> 			/* won't exceed our max size.  This   */
> 			/* equation is the pertinent one used */
> 			/* in WZ's js.                           */
> 			if (($defw + 1 + $right + 20) > $size) {
> 				/* If it does, we take the excess off the */
> 				/* largest part.                          */
> 				$defw = $defw - ($defw + 1 + $right + 20 - $size);
> 			}
46a90,95
> 			var DEFW   = <?php echo $defw; ?>;
> 			var LEFT   = <?php echo $left_top; ?>;
> 			var TOP    = <?php echo $left_top; ?>;
> 			var RIGHT  = <?php echo $right; ?>;
> 			var BOTTOM = <?php echo $bottom; ?>;
> 
Index: js/wz_grapher.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mathfilter/js/wz_grapher.js,v
retrieving revision 1.1
diff -r1.1 wz_grapher.js
729c729
< window.onload = init;
\ No newline at end of file
---
> window.onload = init;
