From: <ni...@us...> - 2008-04-29 20:14:12
|
Revision: 9340 http://jmol.svn.sourceforge.net/jmol/?rev=9340&view=rev Author: nicove Date: 2008-04-29 13:14:09 -0700 (Tue, 29 Apr 2008) Log Message: ----------- Fix for MediaWiki 1.12 Modified Paths: -------------- trunk/Jmol-extensions/wiki/MediaWiki/Jmol.body.php trunk/Jmol-extensions/wiki/MediaWiki/Jmol.php Modified: trunk/Jmol-extensions/wiki/MediaWiki/Jmol.body.php =================================================================== --- trunk/Jmol-extensions/wiki/MediaWiki/Jmol.body.php 2008-04-29 14:18:45 UTC (rev 9339) +++ trunk/Jmol-extensions/wiki/MediaWiki/Jmol.body.php 2008-04-29 20:14:09 UTC (rev 9340) @@ -10,6 +10,7 @@ require_once("Title.php"); +/* Global configuration parameters */ global $wgJmolAuthorizeChoosingSignedApplet; global $wgJmolAuthorizeUploadedFile; global $wgJmolAuthorizeUrl; @@ -20,24 +21,11 @@ global $wgJmolShowWarnings; global $wgJmolUsingSignedAppletByDefault; -/* Global configuration parameters */ -$wgJmolAuthorizeChoosingSignedApplet = false; -$wgJmolAuthorizeUploadedFile = true; -$wgJmolAuthorizeUrl = false; -$wgJmolDefaultAppletSize = "400"; -$wgJmolDefaultScript = ""; -$wgJmolExtensionPath = "$IP/extensions/Jmol"; -$wgJmolForceNameSpace = ""; -$wgJmolShowWarnings = true; -$wgJmolUsingSignedAppletByDefault = false; - class Jmol { var $mOutput, $mDepth; var $mCurrentObject, $mCurrentTag, $mCurrentSubTag; - var $mJmolTagPresent; - var $mValChecked; var $mValColor; var $mValInlineContents; @@ -63,7 +51,6 @@ function __construct() { $this->mOutput = ""; $this->mDepth = 0; - $this->mJmolTagPresent = false; $this->resetValues(); } @@ -73,9 +60,8 @@ // Render Jmol tag private function renderJmol($input) { - $this->mOutput = ""; + $this->mOutput = "<!-- Jmol -->"; $this->mDepth = 0; - $this->mJmolTagPresent = true; $xmlParser = xml_parser_create(); xml_set_object($xmlParser, $this); xml_set_element_handler($xmlParser, "startElement", "endElement"); @@ -566,30 +552,41 @@ // DIRECTING THE EXTENSION // // *********************** // - private function beginParsing() { - $this->mJmolTagPresent = false; - } - private function parseJmolTag(&$text, &$params, &$parser) { $parser->disableCache(); - $parser->mOutput->mJmolTag = true; return $this->renderJmol($text); } - private function endParsing() { - global $wgJmolExtensionPath,$wgOut; - if ($this->mJmolTagPresent == true) { - $this->includeScript($wgOut, $wgJmolExtensionPath."/Jmol.js"); - $this->includeScript($wgOut, $wgJmolExtensionPath."/JmolMediaWiki.js"); - if ($this->mValSigned) { - $this->addScript($wgOut, "jmolInitialize('".$wgJmolExtensionPath."', true);"); - } else { - $this->addScript($wgOut, "jmolInitialize('".$wgJmolExtensionPath."', false);"); - } + private function beforeHMTLOutput(&$outputPage, &$text) { + global $wgJmolExtensionPath; + //if (preg_match_all('/<!-- Jmol -->/m', $text, $matches) === false) { + // return true; + //} + $this->includeScript($outputPage, $wgJmolExtensionPath."/Jmol.js"); + $this->includeScript($outputPage, $wgJmolExtensionPath."/JmolMediaWiki.js"); + if ($this->mValSigned) { + $this->addScript($outputPage, "jmolInitialize('".$wgJmolExtensionPath."', true);"); + } else { + $this->addScript($outputPage, "jmolInitialize('".$wgJmolExtensionPath."', false);"); } - $this->mJmolTagPresent = false; + return true; } + private function toto(&$outputPage, &$text) { + global $wgJmolExtensionPath; + if (preg_match_all('/<!-- Jmol -->/m', $text, $matches) === false) { + return true; + } + $this->includeScript($outputPage, $wgJmolExtensionPath."/Jmol.js"); + $this->includeScript($outputPage, $wgJmolExtensionPath."/JmolMediaWiki.js"); + if ($this->mValSigned) { + $this->addScript($outputPage, "jmolInitialize('".$wgJmolExtensionPath."', true);"); + } else { + $this->addScript($outputPage, "jmolInitialize('".$wgJmolExtensionPath."', false);"); + } + return true; + } + // ******************* // // MEDIAWIKI CALLBACKS // // ******************* // @@ -603,15 +600,18 @@ // MEDIAWIKI HOOKS // // *************** // + // OutputPageBeforeHTML + function hOutputPageBeforeHTML(&$out, &$text) { + return $this->toto($out, $text); //$this->beforeHTMLOutput($out, $text); + } + // ParserBeforeStrip hook function hParserBeforeStrip(&$parser, &$text, &$strip_state) { - $this->beginParsing(); return true; } // ParserAfterStrip hook function hParserAfterStrip(&$parser, &$text, &$strip_state) { - $this->endParsing(); return true; } Modified: trunk/Jmol-extensions/wiki/MediaWiki/Jmol.php =================================================================== --- trunk/Jmol-extensions/wiki/MediaWiki/Jmol.php 2008-04-29 14:18:45 UTC (rev 9339) +++ trunk/Jmol-extensions/wiki/MediaWiki/Jmol.php 2008-04-29 20:14:09 UTC (rev 9340) @@ -15,11 +15,33 @@ 'version' => StubManager::getRevisionId( '$Id$' ) ); +/* Global configuration parameters */ +global $wgJmolAuthorizeChoosingSignedApplet; +global $wgJmolAuthorizeUploadedFile; +global $wgJmolAuthorizeUrl; +global $wgJmolDefaultAppletSize; +global $wgJmolDefaultScript; +global $wgJmolExtensionPath; +global $wgJmolForceNameSpace; +global $wgJmolShowWarnings; +global $wgJmolUsingSignedAppletByDefault; + +$wgJmolAuthorizeChoosingSignedApplet = false; +$wgJmolAuthorizeUploadedFile = true; +$wgJmolAuthorizeUrl = false; +$wgJmolDefaultAppletSize = "400"; +$wgJmolDefaultScript = ""; +$wgJmolExtensionPath = "/extensions/Jmol"; +$wgJmolForceNameSpace = ""; +$wgJmolShowWarnings = true; +$wgJmolUsingSignedAppletByDefault = false; + StubManager::createStub( 'Jmol', dirname(__FILE__).'/Jmol.body.php', null, //dirname(__FILE__).'/Jmol.i18n.php', - array( 'ParserBeforeStrip', + array( 'OutputPageBeforeHTML', + 'ParserBeforeStrip', 'ParserAfterStrip' ), false, // no need for logging support array( 'jmol' ), // tags This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |