/**
  * @return null|string
  */
 public function getLazySuggestionBox()
 {
     $this->mustBeKnownMessage();
     if (!$this->handle->getCode()) {
         return null;
     }
     $url = SpecialPage::getTitleFor('Translate', 'editpage')->getLocalUrl(array('suggestions' => 'only', 'page' => $this->handle->getTitle()->getPrefixedDbKey(), 'loadgroup' => $this->group->getId()));
     $url = Xml::encodeJsVar($url);
     $id = Sanitizer::escapeId('tm-lazysug-' . $this->dialogID());
     $target = self::jQueryPathId($id);
     $script = Html::inlineScript("jQuery({$target}).load({$url})");
     $spinner = Html::element('div', array('class' => 'mw-ajax-loader'));
     return Html::rawElement('div', array('id' => $id), $script . $spinner);
 }
 public static function getLiftiumOptionsScript()
 {
     wfProfileIn(__METHOD__);
     global $wgDBname, $wgTitle, $wgLang, $wgDartCustomKeyValues, $wgCityId;
     // See Liftium.js for documentation on options
     $options = array();
     $options['pubid'] = 999;
     $options['baseUrl'] = '/__varnish_liftium/';
     $options['kv_wgDBname'] = $wgDBname;
     if (is_object($wgTitle)) {
         $options['kv_article_id'] = $wgTitle->getArticleID();
         $options['kv_wpage'] = $wgTitle->getPartialURL();
     }
     $hub = WikiFactoryHub::getInstance();
     $options['kv_Hub'] = $hub->getCategoryName($wgCityId);
     $options['kv_skin'] = RequestContext::getMain()->getSkin()->getSkinName();
     $options['kv_user_lang'] = $wgLang->getCode();
     $options['kv_cont_lang'] = $GLOBALS['wgLanguageCode'];
     $options['kv_isMainPage'] = WikiaPageType::isMainPage();
     $options['kv_page_type'] = WikiaPageType::getPageType();
     $options['geoUrl'] = "http://geoiplookup.wikia.com/";
     if (!empty($wgDartCustomKeyValues)) {
         $options['kv_dart'] = $wgDartCustomKeyValues;
     }
     $options['kv_domain'] = $_SERVER['HTTP_HOST'];
     $options['hasMoreCalls'] = true;
     $options['isCalledAfterOnload'] = true;
     $options['maxLoadDelay'] = 6000;
     $js = "LiftiumOptions = " . json_encode($options) . ";\n";
     $out = "\n<!-- Liftium options -->\n";
     $out .= Html::inlineScript($js) . "\n";
     wfProfileOut(__METHOD__);
     return $out;
 }
 private static function makeVariablesScript($data)
 {
     if ($data) {
         return \Html::inlineScript(ResourceLoader::makeLoaderConditionalScript(ResourceLoader::makeConfigSetScript($data)));
     }
     return '';
 }
 /**
  * Return serialised results in specified format.
  * Implemented by subclasses.
  */
 protected function getResultText(SMWQueryResult $res, $outputmode)
 {
     $html = '';
     $id = uniqid();
     // build an array of article IDs contained in the result set
     $objects = array();
     foreach ($res->getResults() as $key => $object) {
         $objects[] = array($object->getTitle()->getArticleId());
         $html .= $key . ': ' . $object->getSerialization() . "<br>\n";
     }
     // build an array of data about the printrequests
     $printrequests = array();
     foreach ($res->getPrintRequests() as $key => $printrequest) {
         $data = $printrequest->getData();
         if ($data instanceof SMWPropertyValue) {
             $name = $data->getDataItem()->getKey();
         } else {
             $name = null;
         }
         $printrequests[] = array($printrequest->getMode(), $printrequest->getLabel(), $name, $printrequest->getOutputFormat(), $printrequest->getParameters());
     }
     // write out results and query params into JS arrays
     // Define the srf_filtered_values array
     SMWOutputs::requireScript('srf_slideshow', Html::inlineScript('srf_slideshow = {};'));
     SMWOutputs::requireScript('srf_slideshow' . $id, Html::inlineScript('srf_slideshow["' . $id . '"] = ' . json_encode(array($objects, $this->params['template'], $this->params['delay'] * 1000, $this->params['height'], $this->params['width'], $this->params['nav controls'], $this->params['effect'], json_encode($printrequests))) . ';'));
     SMWOutputs::requireResource('ext.srf.slideshow');
     if ($this->params['nav controls']) {
         SMWOutputs::requireResource('jquery.ui.slider');
     }
     return Html::element('div', array('id' => $id, 'class' => 'srf-slideshow ' . $id . ' ' . $this->params['class']));
 }
 /**
  * Loads the needed JavaScript.
  * Takes care of non-RL compatibility.
  * 
  * @since 0.1
  */
 public static function loadJs()
 {
     global $wgOut;
     $wgOut->addScript(Html::inlineScript('var ltDebugMessages = ' . FormatJson::encode($GLOBALS['egLiveTranslateDebugJS']) . ';'));
     // For backward compatibility with MW < 1.17.
     if (is_callable(array($wgOut, 'addModules'))) {
         $modules = array('ext.livetranslate');
         switch ($GLOBALS['egLiveTranslateService']) {
             case LTS_GOOGLE:
                 $modules[] = 'ext.lt.google';
                 $wgOut->addHeadItem('ext.lt.google.jsapi', Html::linkedScript('https://www.google.com/jsapi?key=' . htmlspecialchars($GLOBALS['egGoogleApiKey'])));
                 break;
             case LTS_MS:
                 $modules[] = 'ext.lt.ms';
                 $wgOut->addScript(Html::inlineScript('var ltMsAppId = ' . FormatJson::encode($GLOBALS['egLiveTranslateMSAppId']) . ';'));
                 break;
         }
         $wgOut->addModules($modules);
     } else {
         global $egLiveTranslateScriptPath;
         self::addJSLocalisation();
         $wgOut->includeJQuery();
         $wgOut->addHeadItem('ext.livetranslate', Html::linkedScript($egLiveTranslateScriptPath . '/includes/ext.livetranslate.js') . Html::linkedScript($egLiveTranslateScriptPath . '/includes/ext.lt.tm.js') . Html::linkedScript($egLiveTranslateScriptPath . '/includes/jquery.replaceText.js') . Html::linkedScript($egLiveTranslateScriptPath . '/includes/jquery.liveTranslate.js'));
         switch ($GLOBALS['egLiveTranslateService']) {
             case LTS_GOOGLE:
                 $wgOut->addHeadItem('ext.lt.google.jsapi', Html::linkedScript('https://www.google.com/jsapi?key=' . htmlspecialchars($GLOBALS['egGoogleApiKey'])));
                 $wgOut->addHeadItem('ext.lt.google', Html::linkedScript($egLiveTranslateScriptPath . '/includes/ext.lt.google.js'));
                 break;
             case LTS_MS:
                 $wgOut->addScript(Html::inlineScript('var ltMsAppId = ' . FormatJson::encode($GLOBALS['egLiveTranslateMSAppId']) . ';'));
                 $wgOut->addHeadItem('ext.lt.ms', Html::linkedScript($egLiveTranslateScriptPath . '/includes/ext.lt.ms.js'));
                 break;
         }
     }
 }
 /**
  * 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);
 }
 public function addJSVars($data)
 {
     global $wgOut;
     $text = "";
     foreach ($data as $key => $val) {
         $text = $text . "var " . $key . " = " . json_encode($val) . ";";
     }
     $wgOut->addHTML(Html::inlineScript("\n{$text}\n") . "\n");
 }
Exemple #8
0
/**
 * @param array $vars JS variables to be added at the top of the page
 * @param array $scripts JS scripts to add to the top of the page
 * @return bool return true - it's a hook
 */
function wfJSVariablesTopScripts(array &$vars, &$scripts)
{
    $wg = F::app()->wg;
    $title = $wg->Title;
    $out = $wg->Out;
    // ads need it
    $vars['wgAfterContentAndJS'] = array();
    if (is_array($wg->WikiFactoryTags)) {
        $vars['wgWikiFactoryTagIds'] = array_keys($wg->WikiFactoryTags);
        $vars['wgWikiFactoryTagNames'] = array_values($wg->WikiFactoryTags);
    }
    $vars['wgCdnRootUrl'] = $wg->CdnRootUrl;
    $vars['wgCdnApiUrl'] = $wg->CdnApiUrl;
    // analytics needs it (from here till the end of the function)
    $vars['wgDBname'] = $wg->DBname;
    $vars['wgCityId'] = $wg->CityId;
    // c&p from OutputPage::getJSVars with an old 1.16 name
    $vars['wgContentLanguage'] = $title->getPageLanguage()->getCode();
    // c&p from OutputPage::getJSVars, it's needed earlier
    $user = $wg->User;
    /** @var $user User */
    if ($user->isAnon()) {
        $vars['wgUserName'] = null;
    } else {
        $vars['wgUserName'] = $user->getName();
        /*
         * Remove when SOC-217 ABTest is finished
         */
        $vars['wgNotConfirmedEmail'] = $user->getGlobalAttribute(UserLoginSpecialController::NOT_CONFIRMED_LOGIN_OPTION_NAME);
        /*
         * End remove
         */
    }
    if ($out->isArticle()) {
        $vars['wgArticleId'] = $out->getWikiPage()->getId();
    }
    $vars['wgCategories'] = $out->getCategories();
    $vars['wgPageName'] = $title->getPrefixedDBKey();
    $vars['wikiaPageType'] = WikiaPageType::getPageType();
    $vars['wikiaPageIsCorporate'] = WikiaPageType::isCorporatePage();
    $vars['wgArticleType'] = WikiaPageType::getArticleType();
    // missing in 1.19
    $skin = RequestContext::getMain()->getSkin();
    $vars['skin'] = $skin->getSkinName();
    // for Google Analytics
    $vars['_gaq'] = array();
    $vars['wgIsGASpecialWiki'] = $wg->IsGASpecialWiki;
    // PER-58: moved wgStyleVersion to <head>
    $vars['wgStyleVersion'] = (string) $wg->StyleVersion;
    $wg->NoExternals = $wg->Request->getBool('noexternals', $wg->NoExternals);
    if (!empty($wg->NoExternals)) {
        $vars["wgNoExternals"] = $wg->NoExternals;
    }
    $vars['wgTransactionContext'] = Transaction::getAttributes();
    $scripts .= Html::inlineScript("var wgNow = new Date();") . "\n";
    return true;
}
Exemple #9
0
 /**
  * Static setup method for input type "menuselect".
  * Adds the Javascript code and css used by all menuselects.
  */
 private static function setup()
 {
     global $wgOut, $wgLang;
     static $hasRun = false;
     if (!$hasRun) {
         $hasRun = true;
         // set localized messages (use MW i18n, not jQuery i18n)
         $jstext = "jQuery(function(){mw.loader.using('jquery.ui.datepicker', function(){\n" . "\tjQuery.datepicker.regional['wiki'] = {\n" . "\t\tcloseText: '" . Xml::escapeJsString(wfMsg('semanticformsinputs-close')) . "',\n" . "\t\tprevText: '" . Xml::escapeJsString(wfMsg('semanticformsinputs-prev')) . "',\n" . "\t\tnextText: '" . Xml::escapeJsString(wfMsg('semanticformsinputs-next')) . "',\n" . "\t\tcurrentText: '" . Xml::escapeJsString(wfMsg('semanticformsinputs-today')) . "',\n" . "\t\tmonthNames: ['" . Xml::escapeJsString(wfMsg('january')) . "','" . Xml::escapeJsString(wfMsg('february')) . "','" . Xml::escapeJsString(wfMsg('march')) . "','" . Xml::escapeJsString(wfMsg('april')) . "','" . Xml::escapeJsString(wfMsg('may_long')) . "','" . Xml::escapeJsString(wfMsg('june')) . "','" . Xml::escapeJsString(wfMsg('july')) . "','" . Xml::escapeJsString(wfMsg('august')) . "','" . Xml::escapeJsString(wfMsg('september')) . "','" . Xml::escapeJsString(wfMsg('october')) . "','" . Xml::escapeJsString(wfMsg('november')) . "','" . Xml::escapeJsString(wfMsg('december')) . "'],\n" . "\t\tmonthNamesShort: ['" . Xml::escapeJsString(wfMsg('jan')) . "','" . Xml::escapeJsString(wfMsg('feb')) . "','" . Xml::escapeJsString(wfMsg('mar')) . "','" . Xml::escapeJsString(wfMsg('apr')) . "','" . Xml::escapeJsString(wfMsg('may')) . "','" . Xml::escapeJsString(wfMsg('jun')) . "','" . Xml::escapeJsString(wfMsg('jul')) . "','" . Xml::escapeJsString(wfMsg('aug')) . "','" . Xml::escapeJsString(wfMsg('sep')) . "','" . Xml::escapeJsString(wfMsg('oct')) . "','" . Xml::escapeJsString(wfMsg('nov')) . "','" . Xml::escapeJsString(wfMsg('dec')) . "'],\n" . "\t\tdayNames: ['" . Xml::escapeJsString(wfMsg('sunday')) . "','" . Xml::escapeJsString(wfMsg('monday')) . "','" . Xml::escapeJsString(wfMsg('tuesday')) . "','" . Xml::escapeJsString(wfMsg('wednesday')) . "','" . Xml::escapeJsString(wfMsg('thursday')) . "','" . Xml::escapeJsString(wfMsg('friday')) . "','" . Xml::escapeJsString(wfMsg('saturday')) . "'],\n" . "\t\tdayNamesShort: ['" . Xml::escapeJsString(wfMsg('sun')) . "','" . Xml::escapeJsString(wfMsg('mon')) . "','" . Xml::escapeJsString(wfMsg('tue')) . "','" . Xml::escapeJsString(wfMsg('wed')) . "','" . Xml::escapeJsString(wfMsg('thu')) . "','" . Xml::escapeJsString(wfMsg('fri')) . "','" . Xml::escapeJsString(wfMsg('sat')) . "'],\n" . "\t\tdayNamesMin: ['" . Xml::escapeJsString($wgLang->firstChar(wfMsg('sun'))) . "','" . Xml::escapeJsString($wgLang->firstChar(wfMsg('mon'))) . "','" . Xml::escapeJsString($wgLang->firstChar(wfMsg('tue'))) . "','" . Xml::escapeJsString($wgLang->firstChar(wfMsg('wed'))) . "','" . Xml::escapeJsString($wgLang->firstChar(wfMsg('thu'))) . "','" . Xml::escapeJsString($wgLang->firstChar(wfMsg('fri'))) . "','" . Xml::escapeJsString($wgLang->firstChar(wfMsg('sat'))) . "'],\n" . "\t\tweekHeader: '',\n" . "\t\tdateFormat: '" . Xml::escapeJsString(wfMsg('semanticformsinputs-dateformatshort')) . "',\n" . "\t\tfirstDay: '" . Xml::escapeJsString(wfMsg('semanticformsinputs-firstdayofweek')) . "',\n" . "\t\tisRTL: " . ($wgLang->isRTL() ? "true" : "false") . ",\n" . "\t\tshowMonthAfterYear: false,\n" . "\t\tyearSuffix: ''};\n" . "\tjQuery.datepicker.setDefaults(jQuery.datepicker.regional['wiki']);\n" . "});});\n";
         $wgOut->addScript(Html::inlineScript($jstext));
     }
 }
Exemple #10
0
    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;
    }
    /**
     * Returns the HTML for a storysubmission form.
     * 
     * @param Parser $parser
     * @param array $args
     * 
     * @return HTML
     */
    private static function getFrom(Parser $parser, array $args)
    {
        global $wgUser, $wgStyleVersion, $wgScriptPath, $wgStylePath;
        global $egStoryboardScriptPath, $egStorysubmissionWidth, $egStoryboardMaxStoryLen, $egStoryboardMinStoryLen;
        $maxLen = array_key_exists('maxlength', $args) && is_int($args['maxlength']) ? $args['maxlength'] : $egStoryboardMaxStoryLen;
        $minLen = array_key_exists('minlength', $args) && is_int($args['minlength']) ? $args['minlength'] : $egStoryboardMinStoryLen;
        efStoryboardAddJSLocalisation($parser);
        // Loading a seperate JS file would be overkill for just these 3 lines, and be bad for performance.
        $parser->getOutput()->addHeadItem(Html::linkedStyle("{$egStoryboardScriptPath}/storyboard.css?{$wgStyleVersion}") . Html::linkedScript("{$egStoryboardScriptPath}/storyboard.js?{$wgStyleVersion}") . Html::linkedScript("{$wgStylePath}/common/jquery.min.js?{$wgStyleVersion}") . Html::linkedScript("{$egStoryboardScriptPath}/jquery/jquery.validate.js?{$wgStyleVersion}") . Html::inlineScript(<<<EOT
\$(function() {
\tdocument.getElementById( 'storysubmission-button' ).disabled = true;
\tstbValidateStory( document.getElementById('storytext'), {$minLen}, {$maxLen}, 'storysubmission-charlimitinfo', 'storysubmission-button' )
\t\$("#storyform").validate({
\t\tmessages: {
\t\t\tstorytitle: {
\t\t\t\tremote: jQuery.validator.format( stbMsg( 'storyboard-alreadyexistschange' ) )
\t\t\t}
\t\t}
\t});\t\t
});\t\t\t
EOT
));
        $fieldSize = 50;
        $width = StoryboardUtils::getDimension($args, 'width', $egStorysubmissionWidth);
        $formBody = "<table width='{$width}'>";
        $defaultName = '';
        $defaultEmail = '';
        if ($wgUser->isLoggedIn()) {
            $defaultName = $wgUser->getRealName() !== '' ? $wgUser->getRealName() : $wgUser->getName();
            $defaultEmail = $wgUser->getEmail();
        }
        $formBody .= '<tr>' . Html::element('td', array('width' => '100%'), wfMsg('storyboard-yourname')) . '<td>' . Html::input('name', $defaultName, 'text', array('size' => $fieldSize, 'class' => 'required', 'maxlength' => 255, 'minlength' => 2)) . '</td></tr>';
        $formBody .= '<tr>' . Html::element('td', array('width' => '100%'), wfMsg('storyboard-location')) . '<td>' . Html::input('location', '', 'text', array('size' => $fieldSize, 'maxlength' => 255, 'minlength' => 2)) . '</td></tr>';
        $formBody .= '<tr>' . Html::element('td', array('width' => '100%'), wfMsg('storyboard-occupation')) . '<td>' . Html::input('occupation', '', 'text', array('size' => $fieldSize, 'maxlength' => 255, 'minlength' => 4)) . '</td></tr>';
        $formBody .= '<tr>' . Html::element('td', array('width' => '100%'), wfMsg('storyboard-email')) . '<td>' . Html::input('email', $defaultEmail, 'text', array('size' => $fieldSize, 'class' => 'required email', 'size' => $fieldSize, 'maxlength' => 255)) . '</td></tr>';
        $formBody .= '<tr>' . Html::element('td', array('width' => '100%'), wfMsg('storyboard-storytitle')) . '<td>' . Html::input('storytitle', '', 'text', array('size' => $fieldSize, 'class' => 'required storytitle', 'maxlength' => 255, 'minlength' => 2, 'remote' => "{$wgScriptPath}/api.php?format=json&action=storyexists")) . '</td></tr>';
        $formBody .= '<tr><td colspan="2">' . wfMsg('storyboard-story') . Html::element('div', array('class' => 'storysubmission-charcount', 'id' => 'storysubmission-charlimitinfo'), wfMsgExt('storyboard-charsneeded', 'parsemag', $minLen)) . '<br />' . Html::element('textarea', array('id' => 'storytext', 'name' => 'storytext', 'rows' => 7, 'class' => 'required', 'onkeyup' => "stbValidateStory( this, {$minLen}, {$maxLen}, 'storysubmission-charlimitinfo', 'storysubmission-button' )"), null) . '</td></tr>';
        // TODO: add upload functionality
        $formBody .= '<tr><td colspan="2"><input type="checkbox" id="storyboard-agreement" />&#160;' . $parser->recursiveTagParse(htmlspecialchars(wfMsg('storyboard-agreement'))) . '</td></tr>';
        $formBody .= '<tr><td colspan="2">' . Html::input('storysubmission-button', wfMsg('htmlform-submit'), 'submit', array('id' => 'storysubmission-button')) . '</td></tr>';
        $formBody .= '</table>';
        $formBody .= Html::hidden('wpStoryEditToken', $wgUser->editToken());
        if (!array_key_exists('language', $args) || !array_key_exists($args['language'], Language::getLanguageNames())) {
            global $wgContLanguageCode;
            $args['language'] = $wgContLanguageCode;
        }
        $formBody .= Html::hidden('lang', $args['language']);
        return Html::rawElement('form', array('id' => 'storyform', 'name' => 'storyform', 'method' => 'post', 'action' => SpecialPage::getTitleFor('StorySubmission')->getFullURL(), 'onsubmit' => 'return stbValidateSubmission( "storyboard-agreement" );'), $formBody);
    }
function wfWikimediaMobileAddJs( &$outputPage, &$skin ) {
	global $wgOut, $wgExtensionAssetsPath, $wgWikimediaMobileVersion;

	global $wgTitle, $wgRequest, $wgWikimediaMobileUrl;
	$ns = $wgTitle->getNamespace();
	$action = FormatJson::encode( $wgRequest->getVal( 'action', 'view' ) );
	$page = FormatJson::encode( $wgTitle->getPrefixedDBkey() );
	$mainpage = Title::newMainPage();
	$mp = FormatJson::encode( $mainpage ? $mainpage->getPrefixedText() : null );
	$url = FormatJson::encode( $wgWikimediaMobileUrl );
	$wgOut->addHeadItem( 'mobileredirectvars', Html::inlineScript( "wgNamespaceNumber=$ns;wgAction=$action;wgPageName=$page;wgMainPageTitle=$mp;wgWikimediaMobileUrl=$url;" ) );
	$wgOut->addHeadItem( 'mobileredirect', Html::linkedScript(
		"$wgExtensionAssetsPath/WikimediaMobile/MobileRedirect.js?$wgWikimediaMobileVersion"
	) );
	return true;
}
 /**
  * Add inline JS in <head> section
  *
  * @param string $scripts inline JS scripts
  * @return boolean return true
  */
 public function onSkinGetHeadScripts(&$scripts)
 {
     // used for page load time tracking
     $scripts .= "\n\n<!-- Used for page load time tracking -->\n" . Html::inlineScript("var wgNow = new Date();") . "\n";
     // Create a small stub which will spool up any event calls that happen before the real code is loaded.
     $scripts .= "\n\n<!-- Spool any early event-tracking calls -->\n" . Html::inlineScript(self::getTrackerSpoolingJs()) . "\n";
     // debug
     /**
     		$scripts .= Html::inlineScript(<<<JS
     _wtq.push('/1_wikia/foo/bar');
     _wtq.push(['/1_wikia/foo/bar', 'profil1']);
     _wtq.push([['1_wikia', 'user', 'foo', 'bar'], 'profil1']);
     JS
     );
     		**/
     return true;
 }
Exemple #14
0
 /**
  * Renders the storyboard tag.
  * 
  * @param $input
  * @param array $args
  * @param Parser $parser
  * @param $frame
  * 
  * @return array
  */
 public static function render($input, array $args, Parser $parser, $frame)
 {
     global $wgScriptPath, $wgStylePath, $wgStyleVersion, $wgContLanguageCode;
     global $egStoryboardScriptPath, $egStoryboardWidth, $egStoryboardHeight;
     efStoryboardAddJSLocalisation($parser);
     // TODO: Combine+minfiy JS files, add switch to use combined+minified version
     $parser->getOutput()->addHeadItem(Html::linkedStyle("{$egStoryboardScriptPath}/storyboard.css?{$wgStyleVersion}") . Html::linkedScript("{$wgStylePath}/common/jquery.min.js?{$wgStyleVersion}") . Html::linkedScript("{$egStoryboardScriptPath}/jquery/jquery.ajaxscroll.js?{$wgStyleVersion}") . Html::linkedScript("{$egStoryboardScriptPath}/tags/Storyboard/storyboard.js?{$wgStyleVersion}") . Html::linkedScript("{$egStoryboardScriptPath}/storyboard.js?{$wgStyleVersion}"));
     $width = StoryboardUtils::getDimension($args, 'width', $egStoryboardWidth);
     $height = StoryboardUtils::getDimension($args, 'height', $egStoryboardHeight);
     $languages = Language::getLanguageNames();
     if (array_key_exists('language', $args) && array_key_exists($args['language'], $languages)) {
         $language = $args['language'];
     } else {
         $language = $wgContLanguageCode;
     }
     $parser->getOutput()->addHeadItem(Html::inlineScript("var storyboardLanguage = '{$language}';"));
     $output = Html::element('div', array('class' => 'storyboard', 'style' => "height: {$height}; width: {$width};"));
     return array($output, 'noparse' => true, 'isHTML' => true);
 }
Exemple #15
0
 /**
  * Test for WikiaSkin::getScriptsWithCombinedGroups
  */
 public function testGetScriptsWithCombinedGroups()
 {
     global $wgStyleVersion, $wgCdnRootUrl;
     $cb = $wgStyleVersion;
     $inlineScripts = ['var inlineScript = true;'];
     $groups = ['tracker_js', 'oasis_jquery'];
     $singleAssets = ['/extensions/wikia/Foo/js/bar.js'];
     $skin = new DummySkin();
     $out = $skin->getOutput();
     // add the stuff the output
     foreach ($inlineScripts as $item) {
         $out->addScript(\Html::inlineScript($item));
     }
     foreach ($groups as $item) {
         \Wikia::addAssetsToOutput($item);
     }
     foreach ($singleAssets as $item) {
         \Wikia::addAssetsToOutput($item);
     }
     $jsGroups = ['jquery'];
     $combinedScripts = $skin->getScriptsWithCombinedGroups($jsGroups);
     // assert that single AM groups are not requested
     foreach ($groups as $item) {
         $this->assertNotContains("/__am/{$cb}/group/-/{$item}", $combinedScripts, "'{$item}' group should not be loaded separately");
     }
     // assert that single static files are still requested
     foreach ($singleAssets as $item) {
         $this->assertContains("/{$item}", $combinedScripts, "'{$item}' asset should still be loaded separately");
     }
     // assert that inline scripts are still there
     foreach ($inlineScripts as $item) {
         $this->assertContains(\Html::inlineScript($item), $combinedScripts, "Inline scripts should be kept");
     }
     // assert that combined AM groups <script> tag is the first one
     $items = join(',', array_merge(['jquery'], $groups));
     $this->assertStringStartsWith("<script src='{$wgCdnRootUrl}/__am/{$cb}/groups/-/{$items}", $combinedScripts, "'{$items}' groups should be loaded in a single request");
     // $jsGroups should be updated with the full list of combined groups
     $this->assertEquals($jsGroups, array_merge(['jquery'], $groups), '$jsGroups should contain the list of combined groups');
 }
Exemple #16
0
 /**
  * More minimal version of getHeadScripts from OutputPage
  *
  * @param OutputPage $out
  * @return string
  */
 protected function getHeadScripts(OutputPage $out)
 {
     $scripts = $out->makeResourceLoaderLink('startup', ResourceLoaderModule::TYPE_SCRIPTS, true, array('mobile' => true));
     $scripts .= Html::inlineScript(ResourceLoader::makeLoaderConditionalScript(ResourceLoader::makeConfigSetScript($out->getJSVars())));
     return $scripts;
 }
 protected function searchFocus()
 {
     $id = $this->searchAdvanced ? 'powerSearchText' : 'searchText';
     return Html::inlineScript("hookEvent(\"load\", function() {" . "document.getElementById('{$id}').focus();" . "});");
 }
Exemple #18
0
 /**
  * Returns the HTML to add to the page for the toolbar
  *
  * @since 1.19
  * @param $context IContextSource
  * @return string
  */
 public static function getDebugHTML(IContextSource $context)
 {
     global $wgDebugComments;
     $html = '';
     if (self::$enabled) {
         MWDebug::log('MWDebug output complete');
         $debugInfo = self::getDebugInfo($context);
         // Cannot use OutputPage::addJsConfigVars because those are already outputted
         // by the time this method is called.
         $html = Html::inlineScript(ResourceLoader::makeLoaderConditionalScript(ResourceLoader::makeConfigSetScript(array('debugInfo' => $debugInfo))));
     }
     if ($wgDebugComments) {
         $html .= "<!-- Debug output:\n" . htmlspecialchars(implode("\n", self::$debug)) . "\n\n-->";
     }
     return $html;
 }
	/**
	 * Static setup method for input type "menuselect".
	 * Adds the Javascript code and css used by all menuselects.
	 */
	static private function setup() {

		global $wgOut, $wgLang;
		global $sfgScriptPath, $sfigSettings;

		static $hasRun = false;

		if ( !$hasRun ) {
			$hasRun = true;
			
			$wgOut->addExtensionStyle( $sfgScriptPath . '/skins/jquery-ui/base/jquery.ui.datepicker.css' );
			$wgOut->addExtensionStyle( $sfgScriptPath . '/skins/jquery-ui/base/jquery.ui.theme.css' );
			$wgOut->addScript( '<script type="text/javascript" src="' . $sfgScriptPath . '/libs/jquery-ui/jquery.ui.datepicker.min.js"></script> ' );
			$wgOut->addScript( '<script type="text/javascript" src="' . $sfigSettings->scriptPath . '/libs/datepicker.js"></script> ' );

			// set localized messages (use MW i18n, not jQuery i18n)
			$jstext =
				"jQuery(function(){\n"
				. "	jQuery.datepicker.regional['wiki'] = {\n"
				. "		closeText: '" . Xml::escapeJsString( wfMsg( 'semanticformsinputs-close' ) ) . "',\n"
				. "		prevText: '" . Xml::escapeJsString( wfMsg( 'semanticformsinputs-prev' ) ) . "',\n"
				. "		nextText: '" . Xml::escapeJsString( wfMsg( 'semanticformsinputs-next' ) ) . "',\n"
				. "		currentText: '" . Xml::escapeJsString( wfMsg( 'semanticformsinputs-today' ) ) . "',\n"
				. "		monthNames: ['"
				. Xml::escapeJsString( wfMsg( 'january' ) ) . "','"
				. Xml::escapeJsString( wfMsg( 'february' ) ) . "','"
				. Xml::escapeJsString( wfMsg( 'march' ) ) . "','"
				. Xml::escapeJsString( wfMsg( 'april' ) ) . "','"
				. Xml::escapeJsString( wfMsg( 'may_long' ) ) . "','"
				. Xml::escapeJsString( wfMsg( 'june' ) ) . "','"
				. Xml::escapeJsString( wfMsg( 'july' ) ) . "','"
				. Xml::escapeJsString( wfMsg( 'august' ) ) . "','"
				. Xml::escapeJsString( wfMsg( 'september' ) ) . "','"
				. Xml::escapeJsString( wfMsg( 'october' ) ) . "','"
				. Xml::escapeJsString( wfMsg( 'november' ) ) . "','"
				. Xml::escapeJsString( wfMsg( 'december' ) ) . "'],\n"
				. "		monthNamesShort: ['"
				. Xml::escapeJsString( wfMsg( 'jan' ) ) . "','"
				. Xml::escapeJsString( wfMsg( 'feb' ) ) . "','"
				. Xml::escapeJsString( wfMsg( 'mar' ) ) . "','"
				. Xml::escapeJsString( wfMsg( 'apr' ) ) . "','"
				. Xml::escapeJsString( wfMsg( 'may' ) ) . "','"
				. Xml::escapeJsString( wfMsg( 'jun' ) ) . "','"
				. Xml::escapeJsString( wfMsg( 'jul' ) ) . "','"
				. Xml::escapeJsString( wfMsg( 'aug' ) ) . "','"
				. Xml::escapeJsString( wfMsg( 'sep' ) ) . "','"
				. Xml::escapeJsString( wfMsg( 'oct' ) ) . "','"
				. Xml::escapeJsString( wfMsg( 'nov' ) ) . "','"
				. Xml::escapeJsString( wfMsg( 'dec' ) ) . "'],\n"
				. "		dayNames: ['"
				. Xml::escapeJsString( wfMsg( 'sunday' ) ) . "','"
				. Xml::escapeJsString( wfMsg( 'monday' ) ) . "','"
				. Xml::escapeJsString( wfMsg( 'tuesday' ) ) . "','"
				. Xml::escapeJsString( wfMsg( 'wednesday' ) ) . "','"
				. Xml::escapeJsString( wfMsg( 'thursday' ) ) . "','"
				. Xml::escapeJsString( wfMsg( 'friday' ) ) . "','"
				. Xml::escapeJsString( wfMsg( 'saturday' ) ) . "'],\n"
				. "		dayNamesShort: ['"
				. Xml::escapeJsString( wfMsg( 'sun' ) ) . "','"
				. Xml::escapeJsString( wfMsg( 'mon' ) ) . "','"
				. Xml::escapeJsString( wfMsg( 'tue' ) ) . "','"
				. Xml::escapeJsString( wfMsg( 'wed' ) ) . "','"
				. Xml::escapeJsString( wfMsg( 'thu' ) ) . "','"
				. Xml::escapeJsString( wfMsg( 'fri' ) ) . "','"
				. Xml::escapeJsString( wfMsg( 'sat' ) ) . "'],\n"
				. "		dayNamesMin: ['"
				. Xml::escapeJsString( $wgLang->firstChar( wfMsg( 'sun' ) ) ) . "','"
				. Xml::escapeJsString( $wgLang->firstChar( wfMsg( 'mon' ) ) ) . "','"
				. Xml::escapeJsString( $wgLang->firstChar( wfMsg( 'tue' ) ) ) . "','"
				. Xml::escapeJsString( $wgLang->firstChar( wfMsg( 'wed' ) ) ) . "','"
				. Xml::escapeJsString( $wgLang->firstChar( wfMsg( 'thu' ) ) ) . "','"
				. Xml::escapeJsString( $wgLang->firstChar( wfMsg( 'fri' ) ) ) . "','"
				. Xml::escapeJsString( $wgLang->firstChar( wfMsg( 'sat' ) ) ) . "'],\n"
				. "		weekHeader: '',\n"
				. "		dateFormat: '" . Xml::escapeJsString( wfMsg( 'semanticformsinputs-dateformatshort' ) ) . "',\n"
				. "		firstDay: '" . Xml::escapeJsString( wfMsg( 'semanticformsinputs-firstdayofweek' ) ) . "',\n"
				. "		isRTL: " . ( $wgLang->isRTL() ? "true" : "false" ) . ",\n"
				. "		showMonthAfterYear: false,\n"
				. "		yearSuffix: ''};\n"
				. "	jQuery.datepicker.setDefaults(jQuery.datepicker.regional['wiki']);\n"
				. "});\n";

			$wgOut->addScript( Html::inlineScript(  $jstext ) );
			
		}
	}
Exemple #20
0
 /**
  * JS stuff to put at the bottom of the <body>: modules marked with position 'bottom',
  * legacy scripts ($this->mScripts), user preferences, site JS and user JS
  *
  * @param $sk Skin
  *
  * @return string
  */
 function getBottomScripts(Skin $sk)
 {
     global $wgUseSiteJs, $wgAllowUserJs;
     // Script and Messages "only" requests marked for bottom inclusion
     // Messages should go first
     $scripts = $this->makeResourceLoaderLink($sk, $this->getModuleMessages(true, 'bottom'), ResourceLoaderModule::TYPE_MESSAGES);
     $scripts .= $this->makeResourceLoaderLink($sk, $this->getModuleScripts(true, 'bottom'), ResourceLoaderModule::TYPE_SCRIPTS);
     // Modules requests - let the client calculate dependencies and batch requests as it likes
     // Only load modules that have marked themselves for loading at the bottom
     $modules = $this->getModules(true, 'bottom');
     if ($modules) {
         $scripts .= Html::inlineScript(ResourceLoader::makeLoaderConditionalScript(Xml::encodeJsCall('mw.loader.load', array($modules))));
     }
     // Legacy Scripts
     $scripts .= "\n" . $this->mScripts;
     $userScripts = array('user.options', 'user.tokens');
     // Add site JS if enabled
     if ($wgUseSiteJs) {
         $scripts .= $this->makeResourceLoaderLink($sk, 'site', ResourceLoaderModule::TYPE_SCRIPTS);
         if ($this->getUser()->isLoggedIn()) {
             $userScripts[] = 'user.groups';
         }
     }
     // Add user JS if enabled
     if ($wgAllowUserJs && $this->getUser()->isLoggedIn()) {
         $action = $this->getRequest()->getVal('action', 'view');
         if ($this->getTitle() && $this->getTitle()->isJsSubpage() && $sk->userCanPreview($action)) {
             # XXX: additional security check/prompt?
             $scripts .= Html::inlineScript("\n" . $this->getRequest()->getText('wpTextbox1') . "\n") . "\n";
         } else {
             # @todo FIXME: This means that User:Me/Common.js doesn't load when previewing
             # User:Me/Vector.js, and vice versa (bug26283)
             $userScripts[] = 'user';
         }
     }
     $scripts .= $this->makeResourceLoaderLink($sk, $userScripts, ResourceLoaderModule::TYPE_SCRIPTS);
     return $scripts;
 }
	public static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) {

		global $wgOut;
		global $sfgTabIndex, $sfgFieldNum;

		// Use a special ID for the free text field, for FCK's needs.
		$input_id = $input_name == 'free_text' ? 'free_text' : "input_$sfgFieldNum";

		if ( array_key_exists( 'editor', $other_args ) &&
			$other_args['editor'] == 'wikieditor' &&

			method_exists( $wgOut, 'getResourceLoader' ) &&
			in_array( 'jquery.wikiEditor', $wgOut->getResourceLoader()->getModuleNames() ) &&

			class_exists( 'WikiEditorHooks' ) ) {

			// load modules for all enabled features
			WikiEditorHooks::editPageShowEditFormInitial( $this );

			$wgOut->addModules( 'ext.semanticforms.wikieditor' );

			$jstext = <<<JAVASCRIPT
			jQuery( jQuery('#$input_id').SemanticForms_registerInputInit( ext.wikieditor.init, null ) );
JAVASCRIPT;

			// write JS code directly to the page's code
			$wgOut->addScript( Html::inlineScript( $jstext ) );

			$className = "wikieditor ";
		} else {
			$className = "";
		}

		$className .= ( $is_mandatory ) ? 'mandatoryField' : 'createboxInput';
		if ( array_key_exists( 'class', $other_args ) ) {
			$className .= " " . $other_args['class'];
		}

		if ( array_key_exists( 'rows', $other_args ) ) {
			$rows = $other_args['rows'];
		} else {
			$rows = 5;
		}

		if ( array_key_exists( 'autogrow', $other_args ) ) {
			$className .= ' autoGrow';
		}

		$textarea_attrs = array(
			'tabindex' => $sfgTabIndex,
			'id' => $input_id,
			'name' => $input_name,
			'rows' => $rows,
			'class' => $className,
		);

		if ( array_key_exists( 'cols', $other_args ) ) {
			$textarea_attrs['cols'] = $other_args['cols'];
			// Needed to prevent CSS from overriding the manually-
			// set width.
			$textarea_attrs['style'] = 'width: auto';
		} elseif ( array_key_exists( 'autogrow', $other_args ) ) {
			// If 'autogrow' has been set, automatically set
			// the number of columns - otherwise, the Javascript
			// won't be able to know how many characters there
			// are per line, and thus won't work.
			$textarea_attrs['cols'] = 90;
			$textarea_attrs['style'] = 'width: auto';
		} else {
			$textarea_attrs['style'] = 'width: 100%';
		}

		if ( $is_disabled ) {
			$textarea_attrs['disabled'] = 'disabled';
		}
		if ( array_key_exists( 'maxlength', $other_args ) ) {
			$maxlength = $other_args['maxlength'];
			// For every actual character pressed (i.e., excluding
			// things like the Shift key), reduce the string to its
			// allowed length if it's exceeded that.
			// This JS code is complicated so that it'll work
			// correctly in IE - IE moves the cursor to the end
			// whenever this.value is reset, so we'll make sure to
			// do that only when we need to.
			$maxLengthJSCheck = "if (window.event && window.event.keyCode < 48 && window.event.keyCode != 13) return; if (this.value.length > $maxlength) { this.value = this.value.substring(0, $maxlength); }";
			$textarea_attrs['onKeyDown'] = $maxLengthJSCheck;
			$textarea_attrs['onKeyUp'] = $maxLengthJSCheck;
		}
		if ( array_key_exists( 'placeholder', $other_args ) ) {
			$textarea_attrs['placeholder'] = $other_args['placeholder'];
		}

		$text = Html::element( 'textarea', $textarea_attrs, $cur_value );
		$spanClass = 'inputSpan';
		if ( $is_mandatory ) {
			$spanClass .= ' mandatoryFieldSpan';
		}
		$text = Html::rawElement( 'span', array( 'class' => $spanClass ), $text );

		return $text;
	}
 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 '';
     }
 }
 /**
  * Shows a bulletin board style toolbar for common editing functions.
  * It can be disabled in the user preferences.
  * The necessary JavaScript code can be found in skins/common/edit.js.
  *
  * @return string
  */
 static function getEditToolbar()
 {
     global $wgStylePath, $wgContLang, $wgLang, $wgOut;
     global $wgUseTeX, $wgEnableUploads, $wgForeignFileRepos;
     $imagesAvailable = $wgEnableUploads || count($wgForeignFileRepos);
     /**
      * $toolarray is an array of arrays each of which includes the
      * filename of the button image (without path), the opening
      * tag, the closing tag, optionally a sample text that is
      * inserted between the two when no selection is highlighted
      * and.  The tip text is shown when the user moves the mouse
      * over the button.
      *
      * Also here: accesskeys (key), which are not used yet until
      * someone can figure out a way to make them work in
      * IE. However, we should make sure these keys are not defined
      * on the edit page.
      */
     $toolarray = array(array('image' => $wgLang->getImageFile('button-bold'), 'id' => 'mw-editbutton-bold', 'open' => '\'\'\'', 'close' => '\'\'\'', 'sample' => wfMsg('bold_sample'), 'tip' => wfMsg('bold_tip'), 'key' => 'B'), array('image' => $wgLang->getImageFile('button-italic'), 'id' => 'mw-editbutton-italic', 'open' => '\'\'', 'close' => '\'\'', 'sample' => wfMsg('italic_sample'), 'tip' => wfMsg('italic_tip'), 'key' => 'I'), array('image' => $wgLang->getImageFile('button-link'), 'id' => 'mw-editbutton-link', 'open' => '[[', 'close' => ']]', 'sample' => wfMsg('link_sample'), 'tip' => wfMsg('link_tip'), 'key' => 'L'), array('image' => $wgLang->getImageFile('button-extlink'), 'id' => 'mw-editbutton-extlink', 'open' => '[', 'close' => ']', 'sample' => wfMsg('extlink_sample'), 'tip' => wfMsg('extlink_tip'), 'key' => 'X'), array('image' => $wgLang->getImageFile('button-headline'), 'id' => 'mw-editbutton-headline', 'open' => "\n== ", 'close' => " ==\n", 'sample' => wfMsg('headline_sample'), 'tip' => wfMsg('headline_tip'), 'key' => 'H'), $imagesAvailable ? array('image' => $wgLang->getImageFile('button-image'), 'id' => 'mw-editbutton-image', 'open' => '[[' . $wgContLang->getNsText(NS_FILE) . ':', 'close' => ']]', 'sample' => wfMsg('image_sample'), 'tip' => wfMsg('image_tip'), 'key' => 'D') : false, $imagesAvailable ? array('image' => $wgLang->getImageFile('button-media'), 'id' => 'mw-editbutton-media', 'open' => '[[' . $wgContLang->getNsText(NS_MEDIA) . ':', 'close' => ']]', 'sample' => wfMsg('media_sample'), 'tip' => wfMsg('media_tip'), 'key' => 'M') : false, $wgUseTeX ? array('image' => $wgLang->getImageFile('button-math'), 'id' => 'mw-editbutton-math', 'open' => "<math>", 'close' => "</math>", 'sample' => wfMsg('math_sample'), 'tip' => wfMsg('math_tip'), 'key' => 'C') : false, array('image' => $wgLang->getImageFile('button-nowiki'), 'id' => 'mw-editbutton-nowiki', 'open' => "<nowiki>", 'close' => "</nowiki>", 'sample' => wfMsg('nowiki_sample'), 'tip' => wfMsg('nowiki_tip'), 'key' => 'N'), array('image' => $wgLang->getImageFile('button-sig'), 'id' => 'mw-editbutton-signature', 'open' => '--~~~~', 'close' => '', 'sample' => '', 'tip' => wfMsg('sig_tip'), 'key' => 'Y'), array('image' => $wgLang->getImageFile('button-hr'), 'id' => 'mw-editbutton-hr', 'open' => "\n----\n", 'close' => '', 'sample' => '', 'tip' => wfMsg('hr_tip'), 'key' => 'R'));
     $script = 'mw.loader.using("mediawiki.action.edit", function() {';
     foreach ($toolarray as $tool) {
         if (!$tool) {
             continue;
         }
         $params = array($image = $wgStylePath . '/common/images/' . $tool['image'], $tip = $tool['tip'], $open = $tool['open'], $close = $tool['close'], $sample = $tool['sample'], $cssId = $tool['id']);
         $script .= Xml::encodeJsCall('mw.toolbar.addButton', $params);
     }
     // This used to be called on DOMReady from mediawiki.action.edit, which
     // ended up causing race conditions with the setup code above.
     $script .= "\n" . "// Create button bar\n" . "\$(function() { mw.toolbar.init(); } );\n";
     $script .= '});';
     $wgOut->addScript(Html::inlineScript(ResourceLoader::makeLoaderConditionalScript($script)));
     $toolbar = '<div id="toolbar"></div>';
     wfRunHooks('EditPageBeforeEditToolbar', array(&$toolbar));
     return $toolbar;
 }
Exemple #24
0
 /**
  * JS stuff to put at the bottom of the "<body>"
  * @return string
  */
 function getBottomScripts()
 {
     global $wgResourceLoaderExperimentalAsyncLoading;
     // Optimise jQuery ready event cross-browser.
     // This also enforces $.isReady to be true at </body> which fixes the
     // mw.loader bug in Firefox with using document.write between </body>
     // and the DOMContentReady event (bug 47457).
     $html = Html::inlineScript('window.jQuery && jQuery.ready();');
     if (!$wgResourceLoaderExperimentalAsyncLoading) {
         $html .= $this->getScriptsForBottomQueue(false);
     }
     return $html;
 }
 /**
  * JS stuff to put at the bottom of the "<body>"
  * @return string
  */
 function getBottomScripts()
 {
     // In case the skin wants to add bottom CSS
     $this->getSkin()->setupSkinUserCss($this);
     // Optimise jQuery ready event cross-browser.
     // This also enforces $.isReady to be true at </body> which fixes the
     // mw.loader bug in Firefox with using document.write between </body>
     // and the DOMContentReady event (bug 47457).
     $html = Html::inlineScript('if(window.jQuery)jQuery.ready();');
     if (!$this->getConfig()->get('ResourceLoaderExperimentalAsyncLoading')) {
         $html .= $this->getScriptsForBottomQueue(false);
     }
     return $html;
 }
 /**
  * <script>...</script> tags to put in "<head>".
  *
  * @return string HTML fragment
  */
 function getInlineHeadScripts()
 {
     $links = array();
     // Client profile classes for <html>. Allows for easy hiding/showing of UI components.
     // Must be done synchronously on every page to avoid flashes of wrong content.
     // Note: This class distinguishes MediaWiki-supported JavaScript from the rest.
     // The "rest" includes browsers that support JavaScript but not supported by our runtime.
     // For the performance benefit of the majority, this is added unconditionally here and is
     // then fixed up by the startup module for unsupported browsers.
     $links[] = Html::inlineScript('document.documentElement.className = document.documentElement.className' . '.replace( /(^|\\s)client-nojs(\\s|$)/, "$1client-js$2" );');
     // Load config before anything else
     $links[] = ResourceLoader::makeInlineScript(ResourceLoader::makeConfigSetScript($this->getJSVars()));
     // Load embeddable private modules before any loader links
     // This needs to be TYPE_COMBINED so these modules are properly wrapped
     // in mw.loader.implement() calls and deferred until mw.user is available
     $embedScripts = array('user.options');
     $links[] = $this->makeResourceLoaderLink($embedScripts, ResourceLoaderModule::TYPE_COMBINED);
     // Separate user.tokens as otherwise caching will be allowed (T84960)
     $links[] = $this->makeResourceLoaderLink('user.tokens', ResourceLoaderModule::TYPE_COMBINED);
     // Modules requests - let the client calculate dependencies and batch requests as it likes
     // Only load modules that have marked themselves for loading at the top
     $modules = $this->getModules(true, 'top');
     if ($modules) {
         $links[] = ResourceLoader::makeInlineScript(Xml::encodeJsCall('mw.loader.load', array($modules)));
     }
     // "Scripts only" modules marked for top inclusion
     $links[] = $this->makeResourceLoaderLink($this->getModuleScripts(true, 'top'), ResourceLoaderModule::TYPE_SCRIPTS);
     return self::getHtmlFromLoaderLinks($links);
 }
Exemple #27
0
 /**
  * Construct an inline script tag with given JS code.
  *
  * The code will be wrapped in a closure, and it will be executed by ResourceLoader
  * only if the client has adequate support for MediaWiki JavaScript code.
  *
  * @param string $script JavaScript code
  * @return WrappedString HTML
  */
 public static function makeInlineScript($script)
 {
     $js = self::makeLoaderConditionalScript($script);
     return new WrappedString(Html::inlineScript($js), "<script>window.RLQ = window.RLQ || []; window.RLQ.push( function () {\n", "\n} );</script>");
 }
	/**
	 * Adds the needed JS messages to the page output.
	 * This is for backward compatibility with pre-RL MediaWiki.
	 * 
	 * @since 0.1
	 */
	protected function addJSLocalisation() {
		global $egRatingsStarsJSMessages;
		
		$data = array();
	
		foreach ( $egRatingsStarsJSMessages as $msg ) {
			$data[$msg] = wfMsgNoTrans( $msg );
		}

		$this->parser->getOutput()->addHeadItem( Html::inlineScript( 'var wgRatingsStarsMessages = ' . json_encode( $data ) . ';' ) );
	}
 function buildCleanupScript()
 {
     global $wgCascadingRestrictionLevels, $wgOut;
     $cascadeableLevels = $wgCascadingRestrictionLevels;
     $options = array('tableId' => 'mwProtectSet', 'labelText' => wfMessage('protect-unchain-permissions')->plain(), 'numTypes' => count($this->mApplicableTypes), 'existingMatch' => count(array_unique($this->mExistingExpiry)) === 1);
     $wgOut->addJsConfigVars('wgCascadeableLevels', $cascadeableLevels);
     $script = Xml::encodeJsCall('ProtectionForm.init', array($options));
     return Html::inlineScript(ResourceLoader::makeLoaderConditionalScript($script));
 }
    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 
    }