本文整理汇总了PHP中OutputPage::addScript方法的典型用法代码示例。如果您正苦于以下问题:PHP OutputPage::addScript方法的具体用法?PHP OutputPage::addScript怎么用?PHP OutputPage::addScript使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OutputPage
的用法示例。
在下文中一共展示了OutputPage::addScript方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onBeforePageDisplay
/**
* Add JS and CSS to File Page (except mobile skin - see onWikiaMobileAssetsPackages)
*
* @param OutputPage $out
* @param $skin
* @return bool
*/
public static function onBeforePageDisplay(OutputPage $out, $skin)
{
global $wgEnableVideoPageRedesign;
$app = F::app();
wfProfileIn(__METHOD__);
if ($app->wg->Title->getNamespace() == NS_FILE) {
$assetsManager = AssetsManager::getInstance();
$wikiaFilePageJs = 'wikia_file_page_js';
foreach ($assetsManager->getURL($wikiaFilePageJs) as $url) {
$out->addScript("<script src=\"{$url}\"></script>");
}
// load assets when File Page redesign is enabled
if ($app->checkSkin('oasis') && !empty($wgEnableVideoPageRedesign)) {
$filePageTabbedCss = 'file_page_tabbed_css';
$filePageTabbedJs = 'file_page_tabbed_js';
foreach ($assetsManager->getURL($filePageTabbedCss) as $url) {
$out->addStyle($url);
}
foreach ($assetsManager->getURL($filePageTabbedJs) as $url) {
$out->addScript("<script src=\"{$url}\"></script>");
}
}
}
wfProfileOut(__METHOD__);
return true;
}
示例2: onBeforePageDisplay
public static function onBeforePageDisplay(OutputPage &$out, Skin &$skin)
{
global $wgScriptPath;
$dir = $wgScriptPath . '/extensions/MediawikiHighlight/highlight';
$out->addScript('<script src="' . $dir . '/highlight.pack.js"></script>');
$out->addScript('<link rel="stylesheet" href="' . $dir . '/styles/github.css" />');
$out->addScript("<script type='text/javascript'>\$(document).ready(function() {\n \$('pre').each(function(i, block) {\n hljs.highlightBlock(block);\n });\n });</script>");
return true;
}
示例3: onBeforePageDisplay
public function onBeforePageDisplay(OutputPage $out, $skin)
{
global $wgExtensionsPath;
wfProfileIn(__METHOD__);
$out->addScript('<script src="' . $wgExtensionsPath . '/wikia/ScavengerHunt/js/scavenger-game.js"></script>');
$out->addScript('<script src="' . $wgExtensionsPath . '/wikia/ScavengerHunt/js/sprite.js"></script>');
$out->addStyle(AssetsManager::getInstance()->getSassCommonURL('extensions/wikia/ScavengerHunt/css/scavenger-game.scss'));
wfProfileOut(__METHOD__);
return true;
}
示例4: setHeaders
/**
* Set the script tags in an OutputPage object
* @param OutputPage $outputPage
*/
static function setHeaders(&$outputPage)
{
global $wgJsMimeType, $wgScriptPath, $wgContLang, $wgCategoryTreeExtPath, $wgCategoryTreeVersion;
wfLoadExtensionMessages('CategoryTree');
# Register css file for CategoryTree
$outputPage->addLink(array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => "{$wgScriptPath}{$wgCategoryTreeExtPath}/CategoryTree.css?{$wgCategoryTreeVersion}"));
# Register css RTL file for CategoryTree
if ($wgContLang->isRTL()) {
$outputPage->addLink(array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => "{$wgScriptPath}{$wgCategoryTreeExtPath}/CategoryTree.rtl.css?{$wgCategoryTreeVersion}"));
}
# Register main js file for CategoryTree
$outputPage->addScript("<script type=\"{$wgJsMimeType}\" src=\"{$wgScriptPath}{$wgCategoryTreeExtPath}/CategoryTree.js?{$wgCategoryTreeVersion}\">" . "</script>\n");
# Add messages
$outputPage->addScript("\t<script type=\"{$wgJsMimeType}\">\n\t\t\tvar categoryTreeCollapseMsg = \"" . Xml::escapeJsString(self::msg('collapse')) . "\";\n\t\t\tvar categoryTreeExpandMsg = \"" . Xml::escapeJsString(self::msg('expand')) . "\";\n\t\t\tvar categoryTreeLoadMsg = \"" . Xml::escapeJsString(self::msg('load')) . "\";\n\t\t\tvar categoryTreeLoadingMsg = \"" . Xml::escapeJsString(self::msg('loading')) . "\";\n\t\t\tvar categoryTreeNothingFoundMsg = \"" . Xml::escapeJsString(self::msg('nothing-found')) . "\";\n\t\t\tvar categoryTreeNoSubcategoriesMsg = \"" . Xml::escapeJsString(self::msg('no-subcategories')) . "\";\n\t\t\tvar categoryTreeNoPagesMsg = \"" . Xml::escapeJsString(self::msg('no-pages')) . "\";\n\t\t\tvar categoryTreeErrorMsg = \"" . Xml::escapeJsString(self::msg('error')) . "\";\n\t\t\tvar categoryTreeRetryMsg = \"" . Xml::escapeJsString(self::msg('retry')) . "\";\n\t\t\t</script>\n");
}
示例5: Inject_JS
public static function Inject_JS(OutputPage $out)
{
global $wgMathJaxJS, $wgMathJaxProcConf, $wgMathJaxLocConf;
if (self::$jsInserted === true) {
return true;
}
$userConfig = $wgMathJaxLocConf ?: self::$defaultCustomConfig;
$configContents = file_get_contents(__DIR__ . '/../../public' . $userConfig);
$out->addScript(\Html::rawElement('script', ['type' => 'text/x-mathjax-config'], "\n" . $configContents . "\n"));
$file = $wgMathJaxJS ?: self::$defaultMathJaxPath;
$config = $wgMathJaxProcConf ?: self::$defaultMathJaxConfig;
$url = $file . '?' . http_build_query(['config' => $config], NULL, '&');
$out->addScript(Html::linkedScript($url));
self::$jsInserted = true;
return true;
}
示例6: interstitialAddJs
/**
* If interstitials are enabled, add the JS for them.
*/
function interstitialAddJs(OutputPage $out, Skin $sk)
{
global $wgAdsInterstitialsEnabled;
if (!empty($wgAdsInterstitialsEnabled)) {
global $wgJsMimeType, $wgExtensionsPath;
$out->addScript("<script type=\"{$wgJsMimeType}\" src=\"{$wgExtensionsPath}/wikia/Interstitial/Interstitial.js\" ></script>\n");
}
return true;
}
示例7: elmEasyRefOutput
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;
}
示例8: onBeforePageDisplay
public function onBeforePageDisplay(OutputPage $out, $skin)
{
wfProfileIn(__METHOD__);
// don't load it on edit pages (perf improvement)
if (F::app()->checkSkin('oasis', $skin) && !BodyController::isEditPage()) {
$assetsManager = F::build('AssetsManager', array(), 'getInstance');
$scssPackage = 'relatedvideos_scss';
$jsPackage = 'relatedvideos_js';
foreach ($assetsManager->getURL($scssPackage) as $url) {
$out->addStyle($url);
}
foreach ($assetsManager->getURL($jsPackage) as $url) {
$out->addScript("<script src=\"{$url}\"></script>");
}
}
wfProfileOut(__METHOD__);
return true;
}
示例9: onBeforePageDisplay
public static function onBeforePageDisplay(OutputPage $out, Skin $sk)
{
wfProfileIn(__METHOD__);
$title = $out->getTitle();
if ($title instanceof Title && $title->isContentPage()) {
$storage = PlaceStorage::newFromTitle($out->getTitle());
$model = $storage->getModel();
/* @var $model PlaceModel */
if ($model instanceof PlaceModel && !$model->isEmpty()) {
$out->addMeta('geo.position', implode(',', $model->getLatLon()));
}
}
if ($title instanceof Title && $title->getNamespace() == NS_CATEGORY) {
$out->addScript('<script src="' . F::app()->wg->extensionsPath . '/wikia/Places/js/GeoEnableButton.js"></script>');
$out->addStyle(AssetsManager::getInstance()->getSassCommonURL('extensions/wikia/Places/css/GeoEnableButton.scss'));
}
wfProfileOut(__METHOD__);
return true;
}
示例10: onBeforePageDisplay
/**
* Adds CSS to Page
* @param OutputPage $out
* @param Skin $skin
* @return boolean
*/
public function onBeforePageDisplay(&$out, &$skin)
{
$out->addModuleStyles('ext.bluespice.review.styles');
if ($out->getTitle()->isContentPage() == false) {
return true;
}
if ($out->getTitle()->exists() == false) {
return true;
}
//if( $out->getTitle()->userCan('workflowread') == false ) return true;
$out->addModules('ext.bluespice.review');
//PW TODO: find better way
//this always was loaded too late, no matter what dependency or position
$out->addScript('<script>' . "\$(document).on( 'BsStateBarRegisterToggleClickElements', function(event, aRegisteredToggleClickElements) {" . "aRegisteredToggleClickElements.push(\$('#sb-Review'));" . "});" . '</script>');
$bUserCanEdit = $out->getTitle()->userCan('workflowedit');
$out->addJsConfigVars('bsReviewUserCanEdit', $bUserCanEdit);
$oRev = BsReviewProcess::newFromPid($out->getTitle()->getArticleID());
$out->addJsConfigVars('bsReview', $this->makeJSDataObject($oRev));
return true;
}
示例11: onBeforePageDisplay
/**
* add resources needed by chat
* as chat entry points or links can appear on any page,
* we really need them everywhere
*/
public static function onBeforePageDisplay(OutputPage &$out, Skin &$skin)
{
global $wgExtensionsPath, $wgTitle, $wgResourceBasePath;
wfProfileIn(__METHOD__);
$sp = array('Contributions', 'Log', 'Recentchanges');
foreach ($sp as $value) {
if ($wgTitle->isSpecial($value)) {
// For Chat2 (doesn't exist in Chat(1))
$srcs = AssetsManager::getInstance()->getGroupCommonURL('chat_ban_js', array());
foreach ($srcs as $val) {
$out->addScript('<script src="' . $val . '"></script>');
}
JSMessages::enqueuePackage('ChatBanModal', JSMessages::EXTERNAL);
$out->addStyle(AssetsManager::getInstance()->getSassCommonURL('extensions/wikia/Chat2/css/ChatModal.scss'));
break;
}
}
JSMessages::enqueuePackage('ChatEntryPoint', JSMessages::INLINE);
wfProfileOut(__METHOD__);
return true;
}
示例12: devBoxPanelAdditionalScripts
function devBoxPanelAdditionalScripts(OutputPage &$out, &$sk)
{
global $wgExtensionsPath;
$out->addStyle("{$wgExtensionsPath}/wikia/Development/SpecialDevBoxPanel/DevBoxPanel.css");
$out->addScript("<script type='text/javascript' src='{$wgExtensionsPath}/wikia/Development/SpecialDevBoxPanel/DevBoxPanel.js'></script>");
return true;
}
示例13: setHeaders
/**
* Set the script tags in an OutputPage object
* @param OutputPage $outputPage
*/
static function setHeaders(&$outputPage)
{
global $wgJsMimeType, $wgPlayerExtensionPath, $wgContLang;
# Register css file for Player
/*$outputPage->addLink(
array(
'rel' => 'stylesheet',
'type' => 'text/css',
'href' => $wgPlayerExtensionPath . '/Player.css'
)
);*/
# Register css RTL file for Player
/*if( $wgContLang->isRTL() ) {
$outputPage->addLink(
array(
'rel' => 'stylesheet',
'type' => 'text/css',
'href' => $wgPlayerExtensionPath . '/Player.rtl.css'
)
);
}*/
# Register main js file for Player
$outputPage->addScript("<script type=\"{$wgJsMimeType}\" src=\"{$wgPlayerExtensionPath}/Player.js\">" . "</script>\n");
//var playerLoadingMsg = \"".Xml::escapeJsString(wfMsg('player-loading'))."\";
//var playerErrorMsg = \"".Xml::escapeJsString(wfMsg('player-error'))."\";
# Add messages
$outputPage->addScript("\t<script type=\"{$wgJsMimeType}\">\n\t\t\tvar wgPlayerExtensionPath = \"" . $wgPlayerExtensionPath . "\";\n\t\t\t</script>\n");
}
示例14: gracenoteLyricsTagCss
function gracenoteLyricsTagCss(OutputPage $out)
{
$css = <<<DOC
.lyricbox
{
\tpadding: 1em;
\tborder: 1px solid silver;
\tcolor: black;
\tbackground-color: #ffffcc;
}
DOC;
$out->addScript("<style type='text/css'>/*<![CDATA[*/\n" . $css . "\n/*]]>*/</style>");
return true;
}
示例15: commitToOutputPage
/**
* Acutally commit the collected requirements to a given OutputPage object that
* will later generate the HTML output. This makes sure that HTML output contains
* all required output items. Note that there is no parser caching at this level of
* processing. In particular, data should not be committed to $wgOut in methods
* that run during page parsing, since these would not run next time when the page
* is produced from parser cache.
*
* @param OutputPage $output
*/
public static function commitToOutputPage(OutputPage $output)
{
foreach (self::$scripts as $script) {
$output->addScript($script);
}
foreach (self::$headItems as $key => $item) {
$output->addHeadItem($key, "\t\t" . $item . "\n");
}
$output->addModules(array_values(self::$resourceModules));
self::$resourceModules = array();
self::$headItems = array();
}