/** * Displays the reCAPTCHA widget. * If $this->recaptcha_error is set, it will display an error in the widget. * */ function getForm() { global $wgReCaptchaPublicKey, $wgReCaptchaTheme; $useHttps = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on'; $js = 'var RecaptchaOptions = ' . Xml::encodeJsVar(array('theme' => $wgReCaptchaTheme, 'tabindex' => 1)); return Html::inlineScript($js) . recaptcha_get_html($wgReCaptchaPublicKey, $this->recaptcha_error, $useHttps); }
/** * Show the special page * * @param $par String: name of the user to sudo into */ public function execute($par) { global $wgOut, $wgExtensionAssetsPath; $this->mSkin = new ThemeDesignerDummySkin(); $this->setHeaders(); if (function_exists("OutputPage::includeJQuery")) { $wgOut->includeJQuery(); } $wgOut->addExtensionStyle("{$wgExtensionAssetsPath}/ThemeDesigner/frame/style/main.css"); // Yes, the following is ugly... though I still haven't decided if I want to become completely ResourceLoader dependant // While 1.16 is still stable. $varScript = array(); foreach (array('leavewarning', 'resizertext') as $msgName) { $varScript[] = 'msg' . ucfirst($msgName) . ' = ' . Xml::encodeJsVar((string) wfMsg("themedesigner-{$msgName}")); } $varScript = 'var ' . implode(", ", $varScript) . ';'; $wgOut->addInlineScript($varScript); $wgOut->addScriptFile("{$wgExtensionAssetsPath}/ThemeDesigner/frame/designer.js"); echo $wgOut->headElement($this->mSkin); $wgOut->sendCacheControl(); $wgOut->disable(); // We've collected our html building into a separate file for readability require dirname(__FILE__) . '/frame/layout.php'; echo $this->mSkin->bottomScripts($wgOut); echo Html::closeElement('body'); echo Html::closeElement('html'); }
function __construct($special) { $this->special = $special; $this->editable = $special->editable; parent::__construct(); // Override paging defaults list($this->mLimit, ) = $this->mRequest->getLimitOffset(20, ''); $this->mLimitsShown = array(20, 50, 100); $msg = Xml::encodeJsVar(wfMsg('centralnotice-confirm-delete')); $this->onRemoveChange = "if( this.checked ) { this.checked = confirm( {$msg} ) }"; $this->viewPage = SpecialPage::getTitleFor('NoticeTemplate', 'view'); }
function getRegisterJS() { $response = new AjaxResponse(); $response->addText(AjaxLoginForm::getRegisterJS()); $response->addText(file_get_contents(dirname(__FILE__) . '/AjaxLogin.js') . "\n\n"); $vars = array('prefs_help_birthmesg' => wfMsg('prefs-help-birthmesg'), 'prefs_help_birthinfo' => wfMsg('prefs-help-birthinfo'), 'prefs_help_mailmesg' => wfMsg('prefs-help-mailmesg'), 'prefs_help_email' => wfMsg('prefs-help-email'), 'prefs_help_blurmesg' => wfMsg('prefs-help-blurmesg'), 'prefs_help_blurinfo' => wfMsgExt('captchahelp-text', array('parse'))); foreach ($vars as $key => $value) { $response->addText("var " . $key . " = " . Xml::encodeJsVar($value) . ";\n"); } header("X-Pass-Cache-Control: s-maxage=315360000, max-age=315360000"); $response->setCacheDuration(3600 * 24 * 365); return $response; }
function getForm() { global $wgAsirraEnlargedPosition, $wgAsirraCellsPerRow, $wgOut, $wgLang; $wgOut->addModules('ext.confirmedit.asirra'); $js = Html::linkedScript($this->asirra_clientscript); $message = Xml::encodeJsVar(wfMessage('asirra-createaccount-fail')->plain()); $js .= Html::inlineScript(<<<JAVASCRIPT var asirra_js_failed = '{$message}'; JAVASCRIPT ); $js .= '<noscript>' . wfMessage('asirra-nojs')->parse() . '</noscript>'; return $js; }
function __construct($special, $filter = '') { $this->special = $special; $this->editable = $special->editable; $this->filter = $filter; parent::__construct(); // Override paging defaults list($this->mLimit, ) = $this->mRequest->getLimitOffset(20, ''); $this->mLimitsShown = array(20, 50, 100); $msg = Xml::encodeJsVar($this->msg('promoter-confirm-delete')->text()); $this->onRemoveChange = "if( this.checked ) { this.checked = confirm( {$msg} ) }"; $this->viewPage = SpecialPage::getTitleFor('CampaignAd', 'view'); }
function efAddPiwik( $title ) { global $wgPiwikIDSite, $wgPiwikURL, $wgPiwikIgnoreSysops, $wgPiwikIgnoreBots, $wgUser, $wgScriptPath, $wgPiwikCustomJS, $wgPiwikActionName, $wgPiwikUsePageTitle; if ( !$wgUser->isAllowed( 'bot' ) || !$wgPiwikIgnoreBots ) { if ( !$wgUser->isAllowed( 'protect' ) || !$wgPiwikIgnoreSysops ) { if ( !empty( $wgPiwikIDSite ) AND !empty( $wgPiwikURL ) ) { if ( $wgPiwikUsePageTitle ) { $wgPiwikPageTitle = $title->getPrefixedText(); $wgPiwikFinalActionName = $wgPiwikActionName; $wgPiwikFinalActionName .= $wgPiwikPageTitle; } else { $wgPiwikFinalActionName = $wgPiwikActionName; } // Stop xss since page title's can have " and stuff in them. $wgPiwikFinalActionName = Xml::encodeJsVar( $wgPiwikFinalActionName ); $funcOutput = <<<PIWIK <!-- Piwik --> <script type="text/javascript"> /* <![CDATA[ */ var pkBaseURL = (("https:" == document.location.protocol) ? "https://{$wgPiwikURL}" : "http://{$wgPiwikURL}"); document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E")); /* ]]> */ </script> <script type="text/javascript"> /* <![CDATA[ */ try { var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", {$wgPiwikIDSite}); piwikTracker.setDocumentTitle({$wgPiwikFinalActionName}); piwikTracker.setIgnoreClasses("image"); {$wgPiwikCustomJS} piwikTracker.trackPageView(); piwikTracker.enableLinkTracking(); } catch( err ) {} /* ]]> */ </script><noscript><p><img src="http://{$wgPiwikURL}piwik.php?idsite={$wgPiwikIDSite}" style="border:0" alt=""/></p></noscript> <!-- /Piwik --> PIWIK; } else { $funcOutput = "\n<!-- You need to set the settings for Piwik -->"; } } else { $funcOutput = "\n<!-- Piwik tracking is disabled for users with 'protect' rights (i.e., sysops) -->"; } } else { $funcOutput = "\n<!-- Piwik tracking is disabled for bots -->"; } return $funcOutput; }
function elmEasyRefOutput(OutputPage $outputPage, $skin) { global $wgScriptPath; // Options global $wgElmEasyRefAddCSS, $wgElmEasyRefDebugMode, $wgElmEasyRefBodyContentId, $wgElmEasyRefAnimation, $wgElmEasyRefMetrics, $wgElmEasyRefNum_rp, $wgElmEasyRefNum_mt; // Register css for popup field $outputPage->addLink(array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => $wgScriptPath . '/extensions/ElmEasyRef/css/referencefield.css')); // Additonal css if setted if ($wgElmEasyRefAddCSS) { $outputPage->addLink(array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => $wgElmEasyRefAddCSS)); } // Register js-script file $src = '/extensions/ElmEasyRef/js/elmEasyRef'; if (!$wgElmEasyRefDebugMode) { $src .= '-min'; } $outputPage->addScript(Html::linkedScript($wgScriptPath . $src . '.js')); // Settings $settings = ''; if ($wgElmEasyRefDebugMode) { $settings .= 'elmEasyRef.debug = true;'; } if ($wgElmEasyRefBodyContentId) { $settings .= 'elmEasyRef.bodyContentId = ' . Xml::encodeJsVar($wgElmEasyRefBodyContentId) . ';'; } if ($wgElmEasyRefNum_rp) { $settings .= 'elmEasyRef.regRefNum_rp = /' . $wgElmEasyRefNum_rp . '/;'; } if ($wgElmEasyRefNum_mt) { $settings .= 'elmEasyRef.regRefNum_mt = /' . $wgElmEasyRefNum_mt . '/;'; } if ($wgElmEasyRefAnimation) { foreach ($wgElmEasyRefAnimation as $prop => $val) { $settings .= 'elmEasyRef.animation.' . $prop . ' = ' . Xml::encodeJsVar($val) . ';'; } } if ($wgElmEasyRefMetrics) { foreach ($wgElmEasyRefMetrics as $prop => $val) { $settings .= 'elmEasyRef.fieldm.' . $prop . ' = ' . Xml::encodeJsVar($val) . ';'; } } $msg = wfMsgExt('elm-easyref-ref', 'parseinline'); $settings .= 'elmEasyRef.messages.elm_easyref_ref = ' . Xml::encodeJsVar($msg) . ';'; $msg = wfMsgExt('elm-easyref-close', 'parseinline'); $settings .= 'elmEasyRef.messages.elm_easyref_close = ' . Xml::encodeJsVar($msg) . ';'; $outputPage->addInlineScript('addOnloadHook( function() {' . $settings . 'elmEasyRef.prepare();' . '} );'); return true; }
function efFundraiserPortalLoader($out, $skin) { global $wgOut, $wgContLang; global $wgFundraiserPortalShow, $wgFundraiserPortalProject, $wgFundraiserPortalPath; // Only proceed if we are configured to show the portal if (!$wgFundraiserPortalShow) { return true; } // Pull in our loader $lang = $wgContLang->getCode(); // note: this is English-only for now $fundraiserLoader = "{$wgFundraiserPortalProject}/{$lang}/fundraiserportal.js"; $encFundraiserLoader = Xml::encodeJsVar("{$wgFundraiserPortalPath}/{$fundraiserLoader}"); $wgOut->addInlineScript("var wgFundraiserPortal='', wgFundraiserPortalCSS='';\n" . "mediaWiki.loader.load({$encFundraiserLoader});\n"); return true; }
function AddLinkSuggest($a, $b, $c, $d) { global $wgOut, $wgExtensionsPath, $wgUser, $wgHooks; wfProfileIn(__METHOD__); if ($wgUser->getOption('disablelinksuggest') != true) { $js = "{$wgExtensionsPath}/wikia/LinkSuggest/LinkSuggest.js"; // load YUI for Oasis - TODO: Refactor LinkSuggest.js to not use YUI. Look in /trunk/skins/oasis/js/Search.js for an example of using LinkSuggest with jQuery. if (F::app()->checkSkin('oasis')) { $wgOut->addHTML('<script type="text/javascript">$(function() {$.loadYUI(function() {$.getScript(' . Xml::encodeJsVar($js) . ')})})</script>'); } else { $wgOut->addScript('<script type="text/javascript" src="' . $js . '"></script>'); } // add global JS variables only when LinkSuggest is really loaded (BugId:20958) $wgHooks['MakeGlobalVariablesScript'][] = 'wfLinkSuggestSetupVars'; } wfProfileOut(__METHOD__); return true; }
/** * @see MapsLayer::getJavaScriptDefinition * * @since 0.7.2 * * @return string */ public function getJavaScriptDefinition() { foreach ($this->properties as $name => $value) { ${$name} = MapsMapper::encodeJsVar($value); } $options = array('extractStyles' => true, 'extractAttributes' => true, 'maxDepth' => $maxdepth); $options = Xml::encodeJsVar((object) $options); return <<<EOT \tnew OpenLayers.Layer.GML( \t\t{$label}, \t\t{$source}, \t\t{ \t\t\tformat: OpenLayers.Format.KML, \t\t\tformatOptions: {$options} \t\t} \t) EOT; }
public function execute() { // Pop up a dialog box, to make it difficult for the user to forget // to download the file $lsUrl = $this->getVar('wgServer') . $this->parent->getUrl(['localsettings' => 1]); if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) { // JS appears to be the only method that works consistently with IE7+ $this->addHTML("\n<script>jQuery( function () { location.href = " . Xml::encodeJsVar($lsUrl) . "; } );</script>\n"); } else { $this->parent->request->response()->header("Refresh: 0;url={$lsUrl}"); } $this->startForm(); $this->parent->disableLinkPopups(); $this->addHTML($this->parent->getInfoBox(wfMessage('config-install-done', $lsUrl, $this->getVar('wgServer') . $this->getVar('wgScriptPath') . '/index.php', '<downloadlink/>')->plain(), 'tick-32.png')); $this->addHTML($this->parent->getInfoBox(wfMessage('config-extension-link')->text())); $this->parent->restoreLinkPopups(); $this->endForm(false, false); }
function lfPiwikScript($skin, &$text = '') { global $wmgPiwikSiteID, $wgUser; if (!$wmgPiwikSiteID) { $text .= "<!-- Piwik not enabled -->\n"; return true; } // Disabled Piwik admin blacklisting below Kudu 12/11/13 /* if ( $wgUser->isAllowed('noanalytics') ) { $text .= "<!-- Piwik code omitted -->\n"; return true; } */ $id = strval($wmgPiwikSiteID); $title = $skin->getRelevantTitle(); $jstitle = Xml::encodeJsVar($title->getPrefixedText()); $urltitle = $title->getPrefixedURL(); $userType = $wgUser->isLoggedIn() ? "User" : "Anonymous"; $text .= <<<SCRIPT <!-- Piwik --> <script type="text/javascript"> \tvar _paq = _paq || []; \t_paq.push(["trackPageView"]); \t_paq.push(["enableLinkTracking"]); \t(function() { \t\tvar u=(("https:" == document.location.protocol) ? "https" : "http") + "://bits.orain.org/piwik/"; \t\t_paq.push(["setTrackerUrl", u+"piwik.php"]); \t\t_paq.push(['setDocumentTitle', {$jstitle}]); \t\t_paq.push(["setSiteId", "{$id}"]); \t\t_paq.push(["setCustomVariable", 1, "userType", "{$userType}", "visit"]); \t\tvar d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0]; g.type="text/javascript"; \t\tg.defer=true; g.async=true; g.src=u+"piwik.js"; s.parentNode.insertBefore(g,s); \t})(); </script> <!-- End Piwik Code --> <!-- Piwik Image Tracker --> <noscript> <img src="//bits.orain.org/piwik/piwik.php?idsite={$id}&rec=1&action_name={$urltitle}" style="border:0" alt="" /> </noscript> <!-- End Piwik --> SCRIPT; return true; }
/** * @see MapsLayer::getJavaScriptDefinition * * @since 0.7.2 * * @return string */ public function getJavaScriptDefinition() { foreach ($this->properties as $name => $value) { ${$name} = MapsMapper::encodeJsVar($value); } $options = array('isImage' => true); if ($zoomlevels !== false) { $options['numZoomLevels'] = $zoomlevels; } $options = Xml::encodeJsVar((object) $options); return <<<EOT \tnew OpenLayers.Layer.Image( \t\t{$label}, \t\t{$source}, \t\tnew OpenLayers.Bounds({$leftbound}, {$lowerbound}, {$rightbound}, {$upperbound}), \t\tnew OpenLayers.Size({$width}, {$height}), \t\t{$options} \t) EOT; }
function toHtml($options = array()) { global $wgOut, $wgPDBHandlerUseWebGL; if ($wgPDBHandlerUseWebGL && self::$serial == 0) { $wgOut->addModules('ext.PDBHandler'); } self::$serial++; $id = sprintf('glmol_%d', self::$serial); $ret = ''; // parameters if ($wgPDBHandlerUseWebGL) { $ret .= '<script type="text/javascript">'; $ret .= 'if (pdbHandlerParams == undefined) var pdbHandlerParams = {};'; $ret .= sprintf('pdbHandlerParams[\'%s\'] = %s;', $id, Xml::encodeJsVar($this->file->getUrl())); $ret .= '</script>'; } // canvas $ret .= sprintf('<div id="%s" style="width:%dpx;height:%dpx;display:inline-block;">%s</div>', $id, $this->width, $this->height, parent::toHTML($options)); return $ret; }
static function piwikScript($skin, &$text = '') { global $wmgPiwikSiteID, $wgUser; if (!$wmgPiwikSiteID) { $wmgPiwikSiteID = 1; } $id = strval($wmgPiwikSiteID); $title = $skin->getRelevantTitle(); $jstitle = Xml::encodeJsVar($title->getPrefixedText()); $urltitle = $title->getPrefixedURL(); $userType = $wgUser->isLoggedIn() ? "User" : "Anonymous"; $text .= <<<SCRIPT <!-- Piwik --> <script type="text/javascript"> \tvar _paq = _paq || []; \t_paq.push(["trackPageView"]); \t_paq.push(["enableLinkTracking"]); \t(function() { \t\tvar u = "//piwik.orain.org/"; \t\t_paq.push(["setTrackerUrl", u+"piwik.php"]); \t\t_paq.push(['setDocumentTitle', {$jstitle}]); \t\t_paq.push(["setSiteId", "{$id}"]); \t\t_paq.push(["setCustomVariable", 1, "userType", "{$userType}", "visit"]); \t\tvar d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0]; g.type="text/javascript"; \t\tg.defer=true; g.async=true; g.src=u+"piwik.js"; s.parentNode.insertBefore(g,s); \t})(); </script> <!-- End Piwik Code --> <!-- Piwik Image Tracker --> <noscript> <img src="//piwik.orain.org/piwik.php?idsite={$id}&rec=1&action_name={$urltitle}" style="border:0" alt="" /> </noscript> <!-- End Piwik --> SCRIPT; return true; }
/** * @return bool|string */ protected function stubDiffLoader() { global $wgOut; $encRepo = Xml::encodeJsVar($this->mRepo->getName()); $encRev = Xml::encodeJsVar($this->mRev->getId()); $wgOut->addModules('ext.codereview.loaddiff'); $wgOut->addInlineScript("\$(\n\t\t\t\tfunction() {\n\t\t\t\t\tCodeReview.loadDiff({$encRepo},{$encRev});\n\t\t\t\t}\n\t\t\t);"); return wfMsg('code-load-diff'); }
function wfSpecialImportFreeImages($par) { global $wgUser, $wgOut, $wgRequest, $wgIFI_FlickrAPIKey, $wgEnableUploads; global $wgIFI_ResultsPerPage, $wgIFI_FlickrSort, $wgIFI_FlickrLicense, $wgIFI_ResultsPerRow; global $wgIFI_PromptForFilename, $wgIFI_FlickrSearchBy, $wgIFI_ThumbType; require_once "phpFlickr-2.2.0/phpFlickr.php"; $importPage = Title::makeTitle(NS_SPECIAL, "ImportFreeImages"); if (empty($wgIFI_FlickrAPIKey)) { // error - need to set $wgIFI_FlickrAPIKey to use this extension $wgOut->errorpage('error', 'importfreeimages_noapikey'); return; } $f = new phpFlickr($wgIFI_FlickrAPIKey); # a lot of this code is duplicated from SpecialUpload, should be refactored # Check uploading enabled if (!$wgEnableUploads) { $wgOut->showErrorPage('uploaddisabled', 'uploaddisabledtext'); return; } if (!$wgUser->isAllowed('upload')) { if (!$wgUser->isLoggedIn()) { $wgOut->showErrorPage('uploadnologin', 'uploadnologintext'); } else { $wgOut->permissionRequired('upload'); } return; } # Check blocks if ($wgUser->isBlocked()) { $wgOut->blockedPage(); return; } if (wfReadOnly()) { $wgOut->readOnlyPage(); return; } $import = $wgRequest->getVal('url', ''); if ($wgRequest->wasPosted() && $import != '') { if (wfIFI_handleUpload($f, $import)) { return; } $wgOut->addHTML('<hr/>'); } $q = $wgRequest->getText('q'); $wgOut->addHTML(wfMsg('importfreeimages_description') . "<br/><br/>\n\t\t<form method=GET action='" . $importPage->escapeFullURL() . "'>" . wfMsg('search') . ": <input type=text name=q value='" . htmlspecialchars($q) . "'><input type=submit value=" . wfMsg('search') . "></form>"); if ($q != '') { $page = $wgRequest->getInt('p', 1); $q = $wgRequest->getVal('q'); // TODO: get the right licenses $photos = $f->photos_search(array($wgIFI_FlickrSearchBy => $q, "tag_mode" => "any", "page" => $page, "per_page" => $wgIFI_ResultsPerPage, "license" => $wgIFI_FlickrLicense, "sort" => $wgIFI_FlickrSort)); // $wgOut->addHTML('<pre>'.htmlspecialchars(print_r($photos, TRUE)).'</pre>'); if ($photos == null || !is_array($photos) || sizeof($photos) == 0 || !isset($photos['photo']) || !is_array($photos['photo']) || sizeof($photos['photo']) == 0) { $wgOut->addHTML(wfMsg("importfreeimages_nophotosfound", htmlspecialchars($q))); return; } $sk = $wgUser->getSkin(); $wgOut->addHTML("\n\t\t\t<table cellpadding=4>\n\t\t\t<form method='POST' name='uploadphotoform' action='" . $importPage->escapeFullURL() . "'>\n\t\t\t\t<input type=hidden name='url' value=''>\n\t\t\t\t<input type=hidden name='id' value=''>\n\t\t\t\t<input type=hidden name='action' value='submit'>\n\t\t\t\t<input type=hidden name='owner' value=''>\n\t\t\t\t<input type=hidden name='name' value=''>\n\t\t\t\t<input type=hidden name='ititle' value=''>\n\t\t\t\t<input type=hidden name='token' value='" . $wgUser->editToken() . "'>\n\t\t\t\t<input type=hidden name='q' value='" . htmlspecialchars($q) . "'>\n\t\t<script type='text/javascript'>\n\n\t\t\tfunction s2 (url, id, owner, name, ititle) {\n\t\t\t\tdocument.uploadphotoform.url.value = url;\n\t\t\t\tdocument.uploadphotoform.id.value = id;\n\t\t\t\tdocument.uploadphotoform.owner.value = owner;\n\t\t\t\tdocument.uploadphotoform.name.value = name;\n\t\t\t\tdocument.uploadphotoform.ititle.value = ititle;\n\t\t\t\tif (" . ($wgIFI_PromptForFilename ? "true" : "false") . ") {\n\t\t\t\t\tdocument.uploadphotoform.ititle.value = prompt(" . Xml::encodeJsVar(wfMsg('importfreeimages_promptuserforfilename')) . ", ititle);\n\t\t\t\t\tif (document.uploadphotoform.ititle.value == '') {\n\t\t\t\t\t\tdocument.uploadphotoform.ititle.value = ititle;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tdocument.uploadphotoform.submit();\n\t\t\t}\n\n\t\t</script>\n\n\t\t"); $ownermsg = wfMsg('importfreeimages_owner'); $importmsg = wfMsg('importfreeimages_importthis'); $i = 0; foreach ($photos['photo'] as $photo) { $owner = $f->people_getInfo($photo['owner']); $owner_esc = htmlspecialchars($photo['owner'], ENT_QUOTES); $id_esc = htmlspecialchars($photo['id'], ENT_QUOTES); $title_esc = htmlspecialchars($photo['title'], ENT_QUOTES); $username_esc = htmlspecialchars($owner['username'], ENT_QUOTES); $thumb_esc = htmlspecialchars("http://farm{$photo['farm']}.static.flickr.com/{$photo['server']}/{$photo['id']}_{$photo['secret']}_{$wgIFI_ThumbType}.jpg", ENT_QUOTES); $owner_js = Xml::encodeJsVar($photo['owner']); $id_js = Xml::encodeJsVar($photo['id']); $title_js = Xml::encodeJsVar($photo['title']); $username_js = Xml::encodeJsVar($owner['username']); $url_js = Xml::encodeJsVar("http://farm{$photo['farm']}.static.flickr.com/{$photo['server']}/{$photo['id']}_{$photo['secret']}.jpg"); if ($i % $wgIFI_ResultsPerRow == 0) { $wgOut->addHTML("<tr>"); } $wgOut->addHTML("\n\t\t\t\t<td align='center' style='padding-top: 15px; border-bottom: 1px solid #ccc;'>\n\t\t\t\t\t<font size=-2><a href='http://www.flickr.com/photos/{$owner_esc}/{$id_esc}/'>{$title_esc}</a>\n\t\t\t\t\t<br/>{$ownermsg}: <a href='http://www.flickr.com/people/{$owner_esc}/'>{$username_esc}</a>\n\t\t\t\t\t<br/><img src='{$thumb_esc}' />\n\t\t\t\t\t<br/>(<a href='#' onclick='s2({$url_js}, {$id_js}, {$owner_js}, {$username_js}, {$title_js});'>{$importmsg}</a>)</font>\n\t\t\t\t</td>\n\t\t\t"); if ($i % $wgIFI_ResultsPerRow == $wgIFI_ResultsPerRow - 1) { $wgOut->addHTML("</tr>"); } $i++; } $wgOut->addHTML("</form></table>"); if ($wgIFI_ResultsPerPage * $page < $photos['total']) { $page++; $wgOut->addHTML("<br/>" . $sk->makeLinkObj($importPage, wfMsg('importfreeimages_next', $wgIFI_ResultsPerPage), "p={$page}&q=" . urlencode($q))); } } }
/** * Create a call to a JavaScript function. The supplied arguments will be * encoded using Xml::encodeJsVar(). * * @param string $name The name of the function to call, or a JavaScript expression * which evaluates to a function object which is called. * @param array $args of arguments to pass to the function. * * @since 1.17 * * @return string */ public static function encodeJsCall($name, $args) { foreach ($args as &$arg) { $arg = Xml::encodeJsVar($arg); } return "{$name}(" . implode(', ', $args) . ");\n"; }
function WH_Table($table) { global $lang; $url = "wh_table.php?table=" . urlencode($table) . '&lang=' . urlencode($lang); $encUrl = htmlspecialchars(Xml::encodeJsVar($url)); echo "<a href=\"#\" onClick=\"MyWindow=window.open({$encUrl},'{$table}','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=400,height=300,left=20,top=20'); return false;\" title =\"" . WH_Text($table) . "\">{$table}</a>"; }
function buildCleanupScript() { global $wgRestrictionLevels, $wgGroupPermissions; $script = 'var wgCascadeableLevels='; $CascadeableLevels = array(); foreach ($wgRestrictionLevels as $key) { if (isset($wgGroupPermissions[$key]['protect']) && $wgGroupPermissions[$key]['protect'] || $key == 'protect') { $CascadeableLevels[] = "'" . Xml::escapeJsString($key) . "'"; } } $script .= "[" . implode(',', $CascadeableLevels) . "];\n"; $options = (object) array('tableId' => 'mwProtectSet', 'labelText' => wfMsg('protect-unchain-permissions'), 'numTypes' => count($this->mApplicableTypes), 'existingMatch' => 1 == count(array_unique($this->mExistingExpiry))); $encOptions = Xml::encodeJsVar($options); $script .= "ProtectionForm.init({$encOptions})"; return Html::inlineScript("if ( window.mediaWiki ) { {$script} }"); }
/** * Create a call to a JavaScript function. The supplied arguments will be * encoded using Xml::encodeJsVar(). * * @since 1.17 * @param string $name The name of the function to call, or a JavaScript expression * which evaluates to a function object which is called. * @param array $args The arguments to pass to the function. * @param bool $pretty If true, add non-significant whitespace to improve readability. * @return string|bool String if successful; false upon failure */ public static function encodeJsCall($name, $args, $pretty = false) { foreach ($args as &$arg) { $arg = Xml::encodeJsVar($arg, $pretty); if ($arg === false) { return false; } } return "{$name}(" . ($pretty ? ' ' . implode(', ', $args) . ' ' : implode(',', $args)) . ");"; }
/** * @param $id string * @return string */ public static function jQueryPathId($id) { return Xml::encodeJsVar("#{$id}"); }
static function makeInlineVariablesScript($data) { $wf = F::app()->wf; $wf->profileIn(__METHOD__); if ($data) { $r = array(); foreach ($data as $name => $value) { $encValue = Xml::encodeJsVar($value); $r[] = "{$name}={$encValue}"; } $js = Html::inlineScript("\nvar " . implode(",\n", $r) . ";\n"); $wf->profileOut(__METHOD__); return $js; } else { $wf->profileOut(__METHOD__); return ''; } }
/** * @param $context ResourceLoaderContext * @return string */ public function getScript(ResourceLoaderContext $context) { global $IP, $wgLoadScript, $wgLegacyJavaScriptGlobals; $out = file_get_contents("{$IP}/resources/startup.js"); if ($context->getOnly() === 'scripts') { // The core modules: $modules = array('jquery', 'mediawiki'); wfRunHooks('ResourceLoaderGetStartupModules', array(&$modules)); // Get the latest version $version = 0; foreach ($modules as $moduleName) { $version = max($version, $context->getResourceLoader()->getModule($moduleName)->getModifiedTime($context)); } // Build load query for StartupModules $query = array('modules' => ResourceLoader::makePackedModulesString($modules), 'only' => 'scripts', 'lang' => $context->getLanguage(), 'skin' => $context->getSkin(), 'debug' => $context->getDebug() ? 'true' : 'false', 'version' => wfTimestamp(TS_ISO_8601_BASIC, $version)); // Ensure uniform query order ksort($query); // Startup function $configuration = $this->getConfig($context); $registrations = self::getModuleRegistrations($context); $out .= "var startUp = function() {\n" . "\tmw.config = new " . Xml::encodeJsCall('mw.Map', array($wgLegacyJavaScriptGlobals)) . "\n" . "\t{$registrations}\n" . "\t" . Xml::encodeJsCall('mw.config.set', array($configuration)) . "\t" . Xml::encodeJsCall('mw.loader.state', array(array('jquery' => 'ready'))) . "};\n"; // Conditional script injection // Wikia change - begin - @author: wladek // $scriptTag = Html::linkedScript( $wgLoadScript . '?' . wfArrayToCGI( $query ) ); // get jquery from CDN if we have wsl and getJqueryUrl loaded $scriptTagJquery = Xml::encodeJsVar(Html::linkedScript(ResourceLoader::makeLoaderURL($modules, $query['lang'], $query['skin'], null, $query['version'], $context->getDebug(), 'scripts'))); $scriptTagNoJquery = Xml::encodeJsVar(Html::linkedScript(ResourceLoader::makeLoaderURL(array('mediawiki'), $query['lang'], $query['skin'], null, $query['version'], $context->getDebug(), 'scripts'))); $scriptTag = <<<ENDSCRIPT ( (window.wsl && window.getJqueryUrl && window.wgJqueryUrl) ? (wsl.buildScript(window.getJqueryUrl()) + {$scriptTagNoJquery}) : ({$scriptTagJquery}) ) ENDSCRIPT; $scriptTag = new XmlJsCode($scriptTag); // Wikia change - end $out .= "if ( isCompatible() ) {\n" . "\t" . Xml::encodeJsCall('document.write', array($scriptTag)) . "}\n" . "delete isCompatible;"; } return $out; }
</div> <div class="config-input"><?php aField($conf, "DBtempTS_ora", "Temporary tablespace:"); ?> </div> </fieldset> <div class="config-input" style="padding:2em 0 3em"> <label class='column'> </label> <input type="submit" value="Install MediaWiki!" class="btn-install" /> </div> </div> </form> <script type="text/javascript"> window.onload = toggleDBarea( <?php echo Xml::encodeJsVar($conf->DBtype); ?> , <?php ## If they passed in a root user name, don't populate it on page load echo strlen(importPost('RootUser', '')) ? 0 : 1; ?> ); </script> <?php } /* -------------------------------------------------------------------------------------- */ function writeSuccessMessage() { $script = defined('MW_INSTALL_PHP5_EXT') ? 'index.php5' : 'index.php'; if (wfIniGetBool('safe_mode') && !ini_get('open_basedir')) {
/** * Validate a given script file; if valid returns the original source. * If invalid, returns replacement JS source that throws an exception. * * @param string $fileName * @param string $contents * @return string JS with the original, or a replacement error */ protected function validateScriptFile($fileName, $contents) { global $wgResourceLoaderValidateJS; if ($wgResourceLoaderValidateJS) { // Try for cache hit // Use CACHE_ANYTHING since filtering is very slow compared to DB queries $key = wfMemcKey('resourceloader', 'jsparse', self::$parseCacheVersion, md5($contents)); $cache = wfGetCache(CACHE_ANYTHING); $cacheEntry = $cache->get($key); if (is_string($cacheEntry)) { return $cacheEntry; } $parser = self::javaScriptParser(); try { $parser->parse($contents, $fileName, 1); $result = $contents; } catch (Exception $e) { // We'll save this to cache to avoid having to validate broken JS over and over... $err = $e->getMessage(); $result = "throw new Error(" . Xml::encodeJsVar("JavaScript parse error: {$err}") . ");"; } $cache->set($key, $result); return $result; } else { return $contents; } }
static function makeVariablesScript($data) { global $wgJsMimeType; $r = array("<script type= \"{$wgJsMimeType}\">/*<![CDATA[*/"); foreach ($data as $name => $value) { $encValue = Xml::encodeJsVar($value); $r[] = "var {$name} = {$encValue};"; } $r[] = "/*]]>*/</script>\n"; return implode("\n\t\t", $r); }
/** * @covers Xml::encodeJsVar */ public function testEncodeJsVarFloatString() { $this->assertEquals('"1.23456"', Xml::encodeJsVar('1.23456'), 'encodeJsVar() with float-like string'); }
public function outputHeader() { $this->headerDone = true; $dbTypes = $this->parent->getDBTypes(); $this->parent->request->response()->header('Content-Type: text/html; charset=utf-8'); if (!$this->allowFrames) { $this->parent->request->response()->header('X-Frame-Options: DENY'); } if ($this->redirectTarget) { $this->parent->request->response()->header('Location: ' . $this->redirectTarget); return; } if ($this->useShortHeader) { $this->outputShortHeader(); return; } echo Html::htmlHeader($this->getHeadAttribs()); ?> <head> <meta name="robots" content="noindex, nofollow" /> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <title><?php $this->outputTitle(); ?> </title> <?php echo $this->getCssUrl() . "\n"; ?> <?php echo Html::inlineScript("var dbTypes = " . Xml::encodeJsVar($dbTypes)) . "\n"; ?> <?php echo $this->getJQuery() . "\n"; ?> <?php echo Html::linkedScript('../skins/common/config.js') . "\n"; ?> </head> <?php echo Html::openElement('body', array('class' => $this->getDir())) . "\n"; ?> <div id="mw-page-base"></div> <div id="mw-head-base"></div> <div id="content"> <div id="bodyContent"> <h1><?php $this->outputTitle(); ?> </h1> <?php }