Best Atoum code snippet using parser.resetValues
Jmol.body.php
Source:Jmol.body.php
...68 */69 function __construct() {70 $this->mOutput = "";71 $this->mDepth = 0;72 $this->resetValues();73 $this->setHooks();74 }75 /**#@+ @access private */76 // *** //77 // XML //78 // *** //79 // Render Jmol tag80 private function renderJmol( $input ) {81 $this->mOutput = "<!-- Jmol -->";82 $this->mDepth = 0;83 $xmlParser = xml_parser_create();84 xml_set_object( $xmlParser, $this );85 xml_set_element_handler( $xmlParser, "startElement", "endElement" );86 xml_set_character_data_handler( $xmlParser, "characterData" );87 $input = "<jmol>$input<jmol>";88 if ( !xml_parse( $xmlParser, $input ) ) {89 die(sprintf(90 "XML error: %s at line %d",91 xml_error_string( xml_get_error_code( $xmlParser ) ),92 xml_get_current_line_number( $xmlParser ) ) );93 }94 xml_parser_free( $xmlParser );95 return $this->mOutput;96 }97 // Renders a Jmol applet directly in the Wiki page98 private function renderJmolApplet() {99 global $wgJmolExtensionPath;100 $prefix = "";101 $postfix = "";102 $this->mValInlineContents = trim( $this->mValInlineContents );103 $this->mValInlineContents = preg_replace( "/\t/", " ", $this->mValInlineContents );104 // $this->mValInlineContents = preg_replace( "/\n/", "\\n'+\n'", $this->mValInlineContents );105 $prefix .= "<script type='text/javascript'>";106 $postfix .= "</script>\n";107 $this->mOutput .= $this->renderInternalJmolApplet( $prefix, $postfix, "'" );108 }109 // Renders a button in the Wiki page that will open a new window containing a Jmol applet110 private function renderJmolAppletButton() {111 global $wgJmolExtensionPath;112 $prefix = "";113 $postfix = "";114 $prefix .= "<input type='button'";115 if ( $this->mValName != "" ) {116 $prefix .= " name='" . $this->escapeAttribute( $this->mValName ) . "'" .117 " id='" . $this->escapeAttribute( $this->mValName ) . "'";118 }119 if ( $this->mValText == "" ) {120 $this->mValText = $this->mValTitle;121 }122 if ( $this->mValText != "" ) {123 $prefix .= " value='" . $this->escapeAttribute( $this->mValText ) . "'";124 }125 $prefix .= " onclick=\"jmolWikiPopupWindow(" .126 "'" . $this->escapeScript( $this->mValTitle ) . "'," .127 "'" . $this->escapeScript( $this->mValSize ) . "'," .128 "'" . $this->escapeScript( $this->mValPositionX ) . "'," .129 "'" . $this->escapeScript( $this->mValPositionY ) . "'," .130 "'";131 $postfix = "');return true\" />";132 $this->mOutput .= $this->renderInternalJmolApplet( $prefix, $postfix, "\\'" );133 }134 // Renders a link in the Wiki page that will open a new window containing a Jmol applet135 private function renderJmolAppletLink() {136 global $wgJmolExtensionPath;137 $prefix = "";138 $postfix = "";139 $prefix .= "<a";140 if ( $this->mValName != "" ) {141 $prefix .= " name='" . $this->escapeAttribute( $this->mValName ) . "'" .142 " id='" . $this->escapeAttribute( $this->mValName ) . "'";143 }144 $prefix .= " href=\"javascript:void(0)\"" .145 " onclick=\"jmolWikiPopupWindow(" .146 "'" . $this->escapeScript( $this->mValTitle ) . "'," .147 "'" . $this->escapeScript( $this->mValSize ) . "'," .148 "'" . $this->escapeScript( $this->mValPositionX ) . "'," .149 "'" . $this->escapeScript( $this->mValPositionY ) . "'," .150 "'";151 $postfix .= "');\"";152 $postfix .= ">";153 if ( $this->mValText == "" ) {154 $this->mValText = $this->mValTitle;155 }156 if ( $this->mValText != "" ) {157 $postfix .= $this->mValText;158 }159 $postfix .= "</a>";160 $this->mOutput .= $this->renderInternalJmolApplet( $prefix, $postfix, "\\'" );161 }162 // Renders a link in the Wiki page that will insert a div containing a Jmol applet163 private function renderJmolAppletInlineLink() {164 global $wgJmolExtensionPath;165 $prefix = "";166 $postfix = "";167 $uniqueID = rand(10000,99999);168 $hidelink = "[<a href='javascript:void(0)' " .169 " title='hide the Jmol applet'" .170 " style='font-family:Verdana, Arial, Helvetica, sans-serif;'" .171 " onclick='jmolWikiPopInlineHide(\"" . $uniqueID . "\")'>x</a>]";172 $prefix .= "<div style='width:".$this->mValSize."px; text-align:center;'>";173 if ( $this->mValHeader != "" ) { 174 $prefix .= "<div style='font-weight:bold; position:relative; padding-right:2ex;'>" .175 $this->mValHeader .176 "<span id='JmolInlineHide" . $uniqueID . "'" .177 " style='display:none; position:absolute; right:0; bottom:0; font-weight:normal;'>" .178 $hidelink .179 "</span>" .180 "</div>";181 } else {182 $prefix .= "<div>" .183 "<span id='JmolInlineHide" . $uniqueID . "'" .184 " style='display:none; float:right;'>" .185 $hidelink .186 "</span>" .187 "</div>";188 }189 $prefix .= "<a id='JmolInlineLink" . $uniqueID . "'";190 if ( $this->mValName != "" ) {191 $prefix .= " name='" . $this->escapeAttribute( $this->mValName ) . "'" .192 " id='" . $this->escapeAttribute( $this->mValName ) . "'";193 }194 $prefix .= " href='javascript:void(0)' " .195 " title='" . wfMsg( 'jmol-loadwarning' ) ."'" .196 " onclick=\"jmolWikiPopInline('" . $uniqueID . "','";197 $postfix .= "');\"";198 $postfix .= ">";199 if ( $this->mValText == "" ) {200 $this->mValText = "Jmol";201 }202 $postfix .= $this->mValText;203 $postfix .= "</a>";204 $postfix .= "<div id='JmolInlineEnv" . $uniqueID . "'></div>";205 /* style='z-index:5;position:absolute;vertical-align:top;' */206 $postfix .= "<div style='font-size:0.85em; line-height:1.2; text-align:left; margin:0.3em 1ex;'>" .207 $this->mValCaption . "</div></div>";208 $this->mOutput .= $this->renderInternalJmolApplet( $prefix, $postfix, "\\'" );209 }210 // Renders a button to control a Jmol applet211 private function renderJmolButton() {212 $this->mOutput .= "<script type='text/javascript'>\n";213 if ( $this->mValTarget != "" ) {214 $this->mOutput .= "jmolSetTarget('" . $this->escapeScript( $this->mValTarget ) . "');\n";215 }216 $this->mOutput .= "jmolButton(" .217 "'" . $this->escapeScript( $this->mValScript ) . "'," .218 "'" . $this->escapeScript( $this->mValText ) . "'";219 if ( $this->mValName != "" ) {220 $this->mOutput .= ",'" . $this->escapeScript( $this->mValName ) . "'";221 }222 $this->mOutput .= ");\n" .223 "</script>\n";224 }225 // Renders a checkbox to control a Jmol applet226 private function renderJmolCheckbox() {227 $this->mOutput .= "<script type='text/javascript'>\n";228 if ( $this->mValTarget != "" ) {229 $this->mOutput .= "jmolSetTarget('" . $this->escapeScript( $this->mValTarget ) . "');\n";230 }231 $this->mOutput .= "jmolCheckbox(" .232 "'" . $this->escapeScript( $this->mValScriptWhenChecked ) . "'," .233 "'" . $this->escapeScript( $this->mValScriptWhenUnchecked ) . "'," .234 "'" . $this->escapeScript( $this->mValText ) . "'";235 if ( $this->mValChecked == "true" ) {236 $this->mOutput .= ",true";237 } else {238 $this->mOutput .= ",false";239 }240 if ( $this->mValName != "" ) {241 $this->mOutput .= ",'" . $this->escapeScript( $this->mValName ) . "'";242 }243 $this->mOutput .= ");\n" .244 "</script>\n";245 }246 // Renders a link to control a Jmol applet247 private function renderJmolLink() {248 $this->mOutput .= "<script type='text/javascript'>\n";249 if ( $this->mValTarget != "" ) {250 $this->mOutput .= "jmolSetTarget('" . $this->escapeScript( $this->mValTarget ) . "');\n";251 }252 $this->mOutput .= "jmolLink(" .253 "'" . $this->escapeScript( $this->mValScript ) . "'," .254 "'" . $this->escapeScript( $this->mValText ) . "'";255 if ( $this->mValName != "" ) {256 $this->mOutput .= ",'" . $this->escapeScript( $this->mValName ) . "'";257 }258 $this->mOutput .= ");\n" .259 "</script>\n";260 }261 // Renders a menu to control a Jmol applet262 private function renderJmolMenu() {263 $this->mOutput .= "<script type='text/javascript'>\n";264 if ( $this->mValTarget != "" ) {265 $this->mOutput .= "jmolSetTarget('" . $this->escapeScript( $this->mValTarget ) . "');\n";266 }267 $this->mOutput .= "jmolMenu(" .268 "[" . $this->mValItems . "]," .269 $this->escapeScript( $this->mValMenuHeight );270 if ( $this->mValName != "" ) {271 $this->mOutput .= ",'" . $this->escapeScript( $this->mValName ) . "'";272 }273 $this->mOutput .= ");\n" .274 "</script>\n";275 }276 // Renders a radio group to control a Jmol applet277 private function renderJmolRadioGroup() {278 $this->mOutput .= "<script type='text/javascript'>\n";279 if ( $this->mValTarget != "" ) {280 $this->mOutput .= "jmolSetTarget('" . $this->escapeScript( $this->mValTarget ) . "');\n";281 }282 $this->mOutput .= "jmolRadioGroup([" . $this->mValItems . "]";283 if ( $this->mValVertical == "true" ) {284 $this->mOutput .= ",jmolBr()";285 } else {286 $this->mOutput .= ",' '";287 }288 if ( $this->mValName != "" ) {289 $this->mOutput .= ",'" . $this->escapeScript( $this->mValName ) . "'";290 }291 $this->mOutput .= ");\n" .292 "</script>\n";293 }294 // Internal function to make a Jmol applet295 private function renderInternalJmolApplet( $prefix, $postfix, $sep ) {296 global $wgJmolAuthorizeUrl, $wgJmolAuthorizeUploadedFile;297 global $wgJmolForceNameSpace, $wgJmolExtensionPath, $wgScriptPath;298 $output = $prefix;299 // initialize now goes in the body, thus allowing signed applet:300 $output .= "jmolInitialize(" . $sep . $wgJmolExtensionPath . $sep . ", ";301 if ( $this->mValSigned == "true" ) {302 $output .= "true";303 } else { 304 $output .= "false";305 }306 $output .= "); " .307 "_jmol.noEval = true; ";308 $output .=309 "jmolCheckBrowser(" .310 $sep . "popup" . $sep . ", " .311 $sep . $wgJmolExtensionPath . "/browsercheck" . $sep . ", " .312 $sep . "onclick" . $sep . ");" .313 "jmolSetAppletColor(" .314 $sep . $this->escapeScript( $this->mValColor ) . $sep . ");";315 if ( $this->mValUploadedFileContents != "" ) {316 if ( $wgJmolAuthorizeUploadedFile == true ) {317 $title = Title::makeTitleSafe( NS_IMAGE, $this->mValUploadedFileContents );318 $article = new Article($title);319 if ( !is_null( $title ) && $article->exists() ) {320 $file = wfFindFile($title);321 $this->mValUrlContents = $file->getURL();322 }323 } else {324 return $this->showWarning( wfMsg( 'jmol-nouploadedfilecontents' ) );325 }326 }327 if ( $this->mValWikiPageContents != "" ) {328 if ( $wgJmolAuthorizeUrl == true ) {329 $this->mValUrlContents = $wgScriptPath."/index.php?title="; // AH - fix for non-root wikis330 if ( $wgJmolForceNameSpace != "" ) {331 $this->mValUrlContents .= $wgJmolForceNameSpace . ":";332 }333 $this->mValUrlContents .= $this->mValWikiPageContents . "&action=raw";334 } else {335 return $this->showWarning( wfMsg( 'jmol-nowikipagecontents' ) );336 }337 }338 if ( $this->mValUrlContents != "" ) {339 $output .= "jmolApplet(" .340 $this->escapeScript( $this->mValSize ) . ", " .341 $sep . "set echo p 50% 50%;set echo p center;echo " . wfMsg( 'jmol-loading' ) . ";refresh;" .342 "load " . $this->escapeScript( $this->mValUrlContents ) . "; " .343 $this->escapeScript( $this->mValScript ) . $sep;344 } else {345 $output .= "jmolAppletInline(" .346 $this->escapeScript( $this->mValSize ) . ", " .347 $sep . $this->escapeScript( $this->mValInlineContents ) . $sep . ", " .348 $sep . $this->escapeScript( $this->mValScript ) . $sep;349 }350 if ( $this->mValName != "" ) {351 $output .= "," . $sep . $this->escapeScript( $this->mValName ) . $sep;352 }353 $output .= ");";354 $output .= $postfix;355 return $output;356 }357 // Function called for outputing a warning358 private function showWarning( $message ) {359 global $wgJmolShowWarnings;360 $output = "";361 if ( $wgJmolShowWarnings == true ) {362 $output .= $message;363 }364 return $output;365 }366 // ************* //367 // XML CALLBACKS //368 // ************* //369 // Function called when an opening XML tag is found370 function startElement( $parser, $name, $attrs ) {371 $this->mDepth += 1;372 switch ( $this->mDepth ) {373 case 1:374 // JMOL tag itself375 $this->resetValues();376 break;377 case 2:378 // The interesting tags379 $this->resetValues();380 $this->mCurrentObject = $name;381 break;382 case 3:383 // Details of the interesting tags384 $this->mCurrentTag = $name;385 break;386 case 4:387 // Details of sub tags388 $this->mCurrentSubTag = $name;389 break;390 }391 }392 // Function called when a closing XML tag is found393 function endElement( $parser, $name ) {394 switch ( $this->mDepth ) {395 case 1:396 // JMOL tag itself397 $this->resetValues();398 break;399 case 2:400 // The interesting tags401 switch ( $this->mCurrentObject ) {402 case "JMOLAPPLET":403 $this->renderJmolApplet();404 break;405 case "JMOLAPPLETBUTTON":406 $this->renderJmolAppletButton();407 break;408 case "JMOLAPPLETLINK":409 $this->renderJmolAppletLink();410 break;411 case "JMOLAPPLETINLINELINK":412 $this->renderJmolAppletInlineLink();413 break;414 case "JMOLBUTTON":415 $this->renderJmolButton();416 break;417 case "JMOLCHECKBOX":418 $this->renderJmolCheckbox();419 break;420 case "JMOLLINK":421 $this->renderJmolLink();422 break;423 case "JMOLMENU":424 $this->renderJmolMenu();425 break;426 case "JMOLRADIOGROUP":427 $this->renderJmolRadioGroup();428 break;429 }430 $this->resetValues();431 break;432 case 3:433 // Details of the interesting tags434 switch ( $this->mCurrentTag ) {435 case "ITEM":436 if ( $this->mValItems != "" ) {437 $this->mValItems .= ",";438 }439 $this->mValItems .= "['" . $this->escapeScript( $this->mValScript ) . "'";440 $this->mValItems .= ",'" . $this->escapeScript( $this->mValText ) . "'";441 if ( $this->mValChecked == "true" ) {442 $this->mValItems .= ",true]";443 } else {444 $this->mValItems .= ",false]";445 }446 break;447 }448 $this->mCurrentTag = "";449 break;450 case 4:451 // Details of sub tags452 $this->mCurrentSubTag = "";453 break;454 }455 $this->mDepth -= 1;456 }457 // Function called for the content of a XML tag458 function characterData( $parser, $data ) {459 global $wgJmolAuthorizeChoosingSignedApplet;460 switch ( $this->mDepth ) {461 case 3:462 // Details of the interesting tags463 switch ( $this->mCurrentTag ) {464 case "CHECKED":465 $this->mValChecked = $data;466 break;467 case "COLOR":468 $this->mValColor = $data;469 break;470 case "INLINECONTENTS":471 case "ONLINECONTENTS":472 $data = trim( $data );473 if ( $data != "" ) {474 $this->mValInlineContents .= "\n" . $data;475 }476 break;477 case "MENUHEIGHT":478 $this->mValMenuHeight = $data;479 break;480 case "NAME":481 $this->mValName = $data;482 break;483 case "SCRIPT":484 $this->mValScript = str_replace( "%26", "&", $data );485 break;486 case "SCRIPTWHENCHECKED":487 $this->mValScriptWhenChecked = str_replace( "%26", "&", $data );488 break;489 case "SCRIPTWHENUNCHECKED":490 $this->mValScriptWhenUnchecked = str_replace( "%26", "&", $data );491 break;492 case "SIGNED":493 if ( $wgJmolAuthorizeChoosingSignedApplet ) {494 $this->mValSigned = $data;495 }496 break;497 case "SIZE":498 $this->mValSize = $data;499 break;500 case "TARGET":501 $this->mValTarget = $data;502 break;503 case "TEXT":504 $this->mValText = $data;505 break;506 case "TITLE":507 $this->mValTitle = $data;508 break;509 case "HEADER":510 $this->mValHeader = $data;511 break;512 case "CAPTION":513 $this->mValCaption = $data;514 break;515 case "UPLOADEDFILECONTENTS":516 $this->mValUploadedFileContents = $data;517 break;518 case "URLCONTENTS":519 $this->mValUrlContents = str_replace( "%26", "&", $data );520 break;521 case "VERTICAL":522 $this->mValVertical = $data;523 break;524 case "WIKIPAGECONTENTS":525 $this->mValWikiPageContents = $data;526 break;527 case "X":528 $this->mValPositionX = $data;529 break;530 case "Y":531 $this->mValPositionY = $data;532 break;533 }534 break;535 case 4:536 // Details of sub tags537 if ( $this->mCurrentTag == "ITEM" ) {538 switch ( $this->mCurrentSubTag ) {539 case "CHECKED":540 $this->mValChecked = $data;541 break;542 case "SCRIPT":543 $this->mValScript = str_replace( "%26", "&", $data );544 break;545 case "TEXT":546 $this->mValText = $data;547 break;548 }549 }550 break;551 }552 }553 // ********* //554 // UTILITIES //555 // ********* //556 // Resets internal variables to their default values557 private function resetValues() {558 global $wgJmolDefaultAppletSize;559 global $wgJmolDefaultScript;560 global $wgJmolUsingSignedAppletByDefault;561 $this->mCurrentObject = "";562 $this->mCurrentTag = "";563 $this->mCurrentSubTag = "";564 $this->mValChecked = false;565 $this->mValColor = "black";566 $this->mValInlineContents = "";567 $this->mValItems = "";568 $this->mValMenuHeight = "1";569 $this->mValName = "";570 $this->mValPositionX = "100";571 $this->mValPositionY = "100";572 $this->mValScript = $wgJmolDefaultScript;573 $this->mValScriptWhenChecked = "";574 $this->mValScriptWhenUnchecked = "";575 $this->mValSigned = $wgJmolUsingSignedAppletByDefault;576 $this->mValSize = $wgJmolDefaultAppletSize;577 $this->mValTarget = "";578 $this->mValText = "";579 $this->mValTitle = "Jmol";580 $this->mValHeader = "";581 $this->mValCaption = "";582 $this->mValUploadedFileContents = "";583 $this->mValUrlContents = "";584 $this->mValVertical = false;585 $this->mValWikiPageContents = "";586 }587 // Functions to escape characters588 private function escapeAttribute( $value ) {589 return Xml::escapeJsString( $value );590 }591 private function escapeScript( $value ) {592 return Xml::escapeJsString( $value );593 }594 // *********************** //595 // DIRECTING THE EXTENSION //596 // *********************** //597 private function parseJmolTag( $text, $params, &$parser ) {598 global $wgJmolExtensionPath, $wgJmolScriptVersion;599 $parser->disableCache();600 // Add scripts in the header if needed601 $parser->getOutput()->addHeadItem(602 Html::linkedScript( $wgJmolExtensionPath . "/Jmol.js?version=" . $wgJmolScriptVersion ),603 'JmolScript' );604 $parser->getOutput()->addHeadItem(605 Html::linkedScript( $wgJmolExtensionPath . "/JmolMediaWiki.js?version=" . $wgJmolScriptVersion ),606 'JmolMediaWikiScript' );607 // Add element to display file608 return $this->renderJmol( $text );609 }610 private function parseJmolFileTag( $text, $params, &$parser ) {611 global $wgJmolExtensionPath, $wgJmolScriptVersion, $wgJmolAuthorizeUploadedFile;612 // Add scripts in the header if needed613 $parser->getOutput()->addHeadItem(614 Html::linkedScript( $wgJmolExtensionPath . "/Jmol.js?version=" . $wgJmolScriptVersion ),615 'JmolScript' );616 $parser->getOutput()->addHeadItem(617 Html::linkedScript( $wgJmolExtensionPath . "/JmolMediaWiki.js?version=" . $wgJmolScriptVersion ),618 'JmolMediaWikiScript' );619 // Add element to display file620 $result =621 "<a href=\"javascript:void(0)\"" .622 " onclick=\"jmolWikiPopupWindow(" .623 "'" . $this->escapeScript( $text ) . "'," .624 "'" . $this->escapeScript( "800" ) . "'," .625 "'" . $this->escapeScript( "50" ) . "'," .626 "'" . $this->escapeScript( "50" ) . "'," .627 "'";628 $result .= "jmolInitialize(\\'" . $wgJmolExtensionPath . "\\', false); ";629 $result .= "_jmol.noEval = true; ";630 $result .= "jmolCheckBrowser(\\'popup\\', \\'" . $wgJmolExtensionPath . "/browsercheck\\', \\'onclick\\'); ";631 if ( $wgJmolAuthorizeUploadedFile != true ) {632 return $this->showWarning( wfMsg( 'jmol-nouploadedfilecontents' ) );633 }634 $title = Title::makeTitleSafe( NS_IMAGE, $text );635 $article = new Article($title);636 if ( !is_null( $title ) && $article->exists() ) {637 $file = new Image($title);638 $result .= "jmolApplet( 500, \\'" .639 "set echo p 50% 50%;" .640 "set echo p center;" .641 "echo " . wfMsg( 'jmol-loading' ) . ";" .642 "refresh;" .643 "load " . $file->getURL() . ";\\' ); ";644 }645 $result .= "');\">";646 if ( isset( $params[ "text" ] ) ) {647 $result .= $params[ "text" ];648 } else {649 $result .= $text;650 }651 $result .= "</a>";652 return $result;653 }654 private function parseJmolPdbTag( $text, $params, &$parser ) {655 global $wgJmolExtensionPath, $wgJmolScriptVersion;656 // Add scripts in the header if needed657 $parser->getOutput()->addHeadItem(658 Html::linkedScript( $wgJmolExtensionPath . "/Jmol.js?version=" . $wgJmolScriptVersion ),659 'JmolScript' );660 $parser->getOutput()->addHeadItem(661 Html::linkedScript( $wgJmolExtensionPath . "/JmolMediaWiki.js?version=" . $wgJmolScriptVersion ),662 'JmolMediaWikiScript' );663 // Add element to display file664 $result =665 "<a href=\"javascript:void(0)\"" .666 " onclick=\"jmolWikiPopupWindow(" .667 "'" . $this->escapeScript( $text ) . "'," .668 "'" . $this->escapeScript( "800" ) . "'," .669 "'" . $this->escapeScript( "50" ) . "'," .670 "'" . $this->escapeScript( "50" ) . "'," .671 "'";672 $result .= "jmolInitialize(\\'" . $wgJmolExtensionPath . "\\', true); ";673 $result .= "_jmol.noEval = true; ";674 $result .= "jmolCheckBrowser(\\'popup\\', \\'" . $wgJmolExtensionPath . "/browsercheck\\', \\'onclick\\'); ";675 $result .= "jmolApplet( 500, \\'" .676 "set echo p 50% 50%;" .677 "set echo p center;" .678 "echo " . wfMsg( 'jmol-loading' ) . ";" .679 "refresh;" .680 "load =" . $text . ";\\' ); ";681 $result .= "');\">";682 if ( isset( $params[ "text" ] ) ) {683 $result .= $params[ "text" ];684 } else {685 $result .= $text;686 }687 $result .= "</a>";688 return $result;689 }690 private function parseJmolSmilesTag( $text, $params, &$parser ) {691 global $wgJmolExtensionPath, $wgJmolScriptVersion;692 // Add scripts in the header if needed693 $parser->getOutput()->addHeadItem(694 Html::linkedScript( $wgJmolExtensionPath . "/Jmol.js?version=" . $wgJmolScriptVersion ),695 'JmolScript' );696 $parser->getOutput()->addHeadItem(697 Html::linkedScript( $wgJmolExtensionPath . "/JmolMediaWiki.js?version=" . $wgJmolScriptVersion ),698 'JmolMediaWikiScript' );699 // Add element to display file700 $result =701 "<a href=\"javascript:void(0)\"" .702 " onclick=\"jmolWikiPopupWindow(" .703 "'" . $this->escapeScript( $text ) . "'," .704 "'" . $this->escapeScript( "800" ) . "'," .705 "'" . $this->escapeScript( "50" ) . "'," .706 "'" . $this->escapeScript( "50" ) . "'," .707 "'";708 $result .= "jmolInitialize(\\'" . $wgJmolExtensionPath . "\\', true); ";709 $result .= "_jmol.noEval = true; ";710 $result .= "jmolCheckBrowser(\\'popup\\', \\'" . $wgJmolExtensionPath . "/browsercheck\\', \\'onclick\\'); ";711 $result .= "jmolApplet( 500, \\'" .712 "set echo p 50% 50%;" .713 "set echo p center;" .714 "echo " . wfMsg( 'jmol-loading' ) . ";" .715 "refresh;" .716 "load \$" . $text . ";\\' ); ";717 $result .= "');\">";718 if ( isset( $params[ "text" ] ) ) {719 $result .= $params[ "text" ];720 } else {721 $result .= $text;722 }723 $result .= "</a>";724 return $result;725 }726 /**727 * Initialize the parser hooks728 */729 function setHooks() {730 global $wgParser, $wgHooks;731 global $wgJmolAuthorizeJmolFileTag,732 $wgJmolAuthorizeJmolPdbTag,733 $wgJmolAuthorizeJmolSmilesTag,734 $wgJmolAuthorizeJmolTag;735 if ( $wgJmolAuthorizeJmolTag == true ) {736 $wgParser->setHook( 'jmol' , array( &$this, 'jmolTag' ) );737 }738 if ( $wgJmolAuthorizeJmolFileTag == true ) {739 $wgParser->setHook( 'jmolFile', array( &$this, 'jmolFileTag' ) );740 }741 if ( $wgJmolAuthorizeJmolPdbTag == true ) {742 $wgParser->setHook( 'jmolPdb', array( &$this, 'jmolPdbTag' ) );743 }744 if ( $wgJmolAuthorizeJmolSmilesTag == true ) {745 $wgParser->setHook( 'jmolSmiles', array( &$this, 'jmolSmilesTag' ) );746 }747 }748 // ******************* //749 // MEDIAWIKI CALLBACKS //750 // ******************* //751 /**752 * Callback function for <jmol>753 *754 * @param string $text Text inside <jmol> tag755 * @param array $param Arguments inside <jmol> tag756 * @param Parser &$parser Parser757 * @return string758 */759 public function jmolTag( $text, $params, $parser ) {760 if ( $this->mInJmol ) {761 return htmlspecialchars( "<jmol>$text</jmol>" );762 } else {763 $this->mInJmol = true;764 $ret = $this->parseJmolTag( $text, $params, $parser );765 $this->mInJmol = false;766 return $ret;767 }768 }769 /**770 * Callback function for <jmolFile>771 *772 * @param string $text Text inside <jmolFile> tag773 * @param array $param Arguments inside <jmolFile> tag774 * @param Parser &$parser Parser775 * @return string776 */777 public function jmolFileTag( $text, $params, $parser ) {778 if ( $this->mInJmol ) {779 return htmlspecialchars( "<jmolFile>$text</jmolFile>" );780 } else {781 $this->mInJmol = true;782 $ret = $this->parseJmolFileTag( $text, $params, $parser );783 $this->mInJmol = false;784 return $ret;785 }786 }787 /**788 * Callback function for <jmolPdb>789 *790 * @param string $text Text inside <jmolPdb> tag791 * @param array $param Arguments inside <jmolPdb> tag792 * @param Parser &$parser Parser793 * @return string794 */795 public function jmolPdbTag( $text, $params, $parser ) {796 if ( $this->mInJmol ) {797 return htmlspecialchars( "<jmolPdb>$text</jmolPdb>" );798 } else {799 $this->mInJmol = true;800 $ret = $this->parseJmolPdbTag( $text, $params, $parser );801 $this->mInJmol = false;802 return $ret;803 }804 }805 /**806 * Callback function for <jmolSmiles>807 *808 * @param string $text Text inside <jmolSmiles> tag809 * @param array $param Arguments inside <jmolSmiles> tag810 * @param Parser &$parser Parser811 * @return string812 */813 public function jmolSmilesTag( $text, $params, $parser ) {814 if ( $this->mInJmol ) {815 return htmlspecialchars( "<jmolSmiles>$text</jmolSmiles>" );816 } else {817 $this->mInJmol = true;818 $ret = $this->parseJmolSmilesTag( $text, $params, $parser );819 $this->mInJmol = false;820 return $ret;821 }822 }823 // *************** //824 // MEDIAWIKI HOOKS //825 // *************** //826 /**827 * Gets run when Parser::clearState() gets run828 */829 function hClearState() {830 # Don't clear state when we're in the middle of parsing831 # a <jmol> tag832 if ( $this->mInJmol ) {833 return true;834 }835 resetValues();836 837 return true;838 }839 /**#@-*/840} // END CLASS DEFINITION841//</source>...
resetValues
Using AI Code Generation
1$parser = new Parser();2$parser->resetValues();3$parser = new Parser();4$parser->resetValues();5$parser = new Parser();6$parser->resetValues();7$parser = new Parser();8$parser->resetValues();9$parser = new Parser();10$parser->resetValues();11$parser = new Parser();12$parser->resetValues();13$parser = new Parser();14$parser->resetValues();15$parser = new Parser();16$parser->resetValues();17$parser = new Parser();18$parser->resetValues();19$parser = new Parser();20$parser->resetValues();21$parser = new Parser();22$parser->resetValues();23$parser = new Parser();24$parser->resetValues();25$parser = new Parser();26$parser->resetValues();27$parser = new Parser();28$parser->resetValues();29$parser = new Parser();30$parser->resetValues();31$parser = new Parser();32$parser->resetValues();33$parser = new Parser();34$parser->resetValues();
resetValues
Using AI Code Generation
1require_once('Parser.php');2$parser = new Parser();3$parser->resetValues();4require_once('Parser.php');5$parser = new Parser();6$parser->resetValues();7require_once('Parser.php');8$parser = new Parser();9$parser->resetValues();10require_once('Parser.php');11$parser = new Parser();12$parser->resetValues();13require_once('Parser.php');14$parser = new Parser();15$parser->resetValues();16require_once('Parser.php');17$parser = new Parser();18$parser->resetValues();
resetValues
Using AI Code Generation
1require_once('Parser.php');2$parser = new Parser();3$parser->resetValues();4require_once('Parser.php');5$parser = new Parser();6$parser->resetValues();7class Parser {8 private static $instance = null;9 private $values = array();10 private function __construct() {11 }12 public static function getInstance() {13 if (self::$instance == null) {14 self::$instance = new Parser();15 }16 return self::$instance;17 }18 public function resetValues() {19 $this->values = array();20 }21 public function setValues($values) {22 $this->values = $values;23 }24 public function getValues() {25 return $this->values;26 }27}28require_once('Parser.php');29$parser = Parser::getInstance();30$parser->resetValues();31require_once('Parser.php');32$parser = Parser::getInstance();33$parser->resetValues();
resetValues
Using AI Code Generation
1$parser = new Parser();2$parser->resetValues();3$parser = new Parser();4$parser->resetValues();5Parser::resetValues();6Parser::resetValues();7Parser::resetValues();8Parser::resetValues();9Parser::resetValues();10Parser::resetValues();11In the above code, the resetValues() method is called from two different files. The resetValues() method
resetValues
Using AI Code Generation
1$parser = new Parser();2$parser->resetValues();3Parser::resetValues();4Parser::resetValues();5{6 public static function resetValues()7 {8 }9}10Parser::resetValues();11$parser = new Parser();12$parser->resetValues();13Parser::resetValues();
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Execute automation tests with resetValues on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.
Test now for FreeGet 100 minutes of automation test minutes FREE!!