return $this->_error( 'math_image_error' );
}
+ if( filesize( "$wgTmpDirectory/{$this->hash}.png" ) == 0 ) {
+ return $this->_error( 'math_image_error' );
+ }
+
$hashpath = $this->_getHashPath();
if( !file_exists( $hashpath ) ) {
if( !@wfMkdirParents( $hashpath, 0755 ) ) {
), $fname
);
}
-
+
+ // If we're replacing an older version of the image, make sure it's current.
+ global $wgUseSquid;
+ if ( $wgUseSquid ) {
+ $urls = array( $this->_mathImageUrl() );
+ $u = new SquidUpdate( $urls );
+ $u->doUpdate();
+ }
}
return $this->_doRender();
}
function _linkToMathImage() {
- global $wgMathPath;
- $url = "$wgMathPath/" . substr($this->hash, 0, 1)
- .'/'. substr($this->hash, 1, 1) .'/'. substr($this->hash, 2, 1)
- . "/{$this->hash}.png";
+ $url = $this->_mathImageUrl();
return Xml::element( 'img',
$this->_attribs(
'src' => $url ) ) );
}
+ function _mathImageUrl() {
+ global $wgMathPath;
+ $dir = $this->_getHashSubPath();
+ return "$wgMathPath/$dir/$this->hash";
+ }
+
function _getHashPath() {
global $wgMathDirectory;
- $path = $wgMathDirectory .'/'. substr($this->hash, 0, 1)
- .'/'. substr($this->hash, 1, 1)
- .'/'. substr($this->hash, 2, 1);
+ $path = $wgMathDirectory .'/' . $this->_getHashSubPath();
wfDebug( "TeX: getHashPath, hash is: $this->hash, path is: $path\n" );
return $path;
}
+
+ function _getHashSubPath() {
+ return substr($this->hash, 0, 1)
+ .'/'. substr($this->hash, 1, 1)
+ .'/'. substr($this->hash, 2, 1);
+ }
public static function renderMath( $tex, $params=array() ) {
global $wgUser;