本文整理汇总了PHP中Gadget::loadList方法的典型用法代码示例。如果您正苦于以下问题:PHP Gadget::loadList方法的具体用法?PHP Gadget::loadList怎么用?PHP Gadget::loadList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gadget
的用法示例。
在下文中一共展示了Gadget::loadList方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforePageDisplay
/**
* BeforePageDisplay hook handler.
* @param $out OutputPage
* @return bool
*/
public static function beforePageDisplay($out)
{
wfProfileIn(__METHOD__);
$gadgets = Gadget::loadList();
if (!$gadgets) {
wfProfileOut(__METHOD__);
return true;
}
$lb = new LinkBatch();
$lb->setCaller(__METHOD__);
$pages = array();
/**
* @var $gadget Gadget
*/
$user = $out->getUser();
foreach ($gadgets as $gadget) {
if ($gadget->isEnabled($user) && $gadget->isAllowed($user)) {
if ($gadget->hasModule()) {
$out->addModuleStyles($gadget->getModuleName());
$out->addModules($gadget->getModuleName());
}
foreach ($gadget->getLegacyScripts() as $page) {
$lb->add(NS_MEDIAWIKI, $page);
$pages[] = $page;
}
}
}
// Allow other extensions, e.g. MobileFrontend, to disallow legacy gadgets
if (wfRunHooks('Gadgets::allowLegacy', array($out->getContext()))) {
$lb->execute(__METHOD__);
$done = array();
foreach ($pages as $page) {
if (isset($done[$page])) {
continue;
}
$done[$page] = true;
self::applyScript($page, $out);
}
}
wfProfileOut(__METHOD__);
return true;
}
示例2: showExportForm
/**
* Exports a gadget with its dependencies in a serialized form
* @param $gadget String Name of gadget to export
*/
public function showExportForm($gadget)
{
global $wgOut, $wgScript;
$gadgets = Gadget::loadList();
if (!isset($gadgets[$gadget])) {
$wgOut->showErrorPage('error', 'gadgets-not-found', array($gadget));
return;
}
$g = $gadgets[$gadget];
$this->setHeaders();
$wgOut->setPagetitle(wfMsg("gadgets-export-title"));
$wgOut->addWikiMsg('gadgets-export-text', $gadget, $g->getDefinition());
$exportList = "MediaWiki:gadget-{$gadget}\n";
foreach ($g->getScriptsAndStyles() as $page) {
$exportList .= "MediaWiki:{$page}\n";
}
$wgOut->addHTML(Html::openElement('form', array('method' => 'get', 'action' => $wgScript)) . Html::hidden('title', SpecialPage::getTitleFor('Export')->getPrefixedDBKey()) . Html::hidden('pages', $exportList) . Html::hidden('wpDownload', '1') . Html::hidden('templates', '1') . Xml::submitButton(wfMsg('gadgets-export-download')) . Html::closeElement('form'));
}
示例3: beforePageDisplay
/**
* BeforePageDisplay hook handler.
* @param $out OutputPage
* @return bool
*/
public static function beforePageDisplay($out)
{
global $wgUser;
wfProfileIn(__METHOD__);
$gadgets = Gadget::loadList();
if (!$gadgets) {
wfProfileOut(__METHOD__);
return true;
}
$lb = new LinkBatch();
$lb->setCaller(__METHOD__);
$pages = array();
/**
* @var $gadget Gadget
*/
foreach ($gadgets as $gadget) {
if ($gadget->isEnabled($wgUser) && $gadget->isAllowed($wgUser)) {
if ($gadget->hasModule()) {
$out->addModuleStyles($gadget->getModuleName());
$out->addModules($gadget->getModuleName());
}
foreach ($gadget->getLegacyScripts() as $page) {
$lb->add(NS_MEDIAWIKI, $page);
$pages[] = $page;
}
}
}
$lb->execute(__METHOD__);
$done = array();
foreach ($pages as $page) {
if (isset($done[$page])) {
continue;
}
$done[$page] = true;
self::applyScript($page, $out);
}
wfProfileOut(__METHOD__);
return true;
}
示例4: beforePageDisplay
/**
* BeforePageDisplay hook handler.
* @param $out OutputPage
*/
public static function beforePageDisplay($out)
{
global $wgUser;
wfProfileIn(__METHOD__);
$gadgets = Gadget::loadList();
if (!$gadgets) {
wfProfileOut(__METHOD__);
return true;
}
$lb = new LinkBatch();
$lb->setCaller(__METHOD__);
$pages = array();
$stylesModules = array();
foreach ($gadgets as $gadget) {
if ($gadget->isEnabled($wgUser) && $gadget->isAllowed($wgUser)) {
if ($gadget->hasModule()) {
$out->addModules($gadget->getModuleName());
}
if ($gadget->hasStylesModule()) {
$stylesModules[] = $gadget->getStylesModuleName();
}
foreach ($gadget->getLegacyScripts() as $page) {
$lb->add(NS_MEDIAWIKI, $page);
$pages[] = $page;
}
}
}
if (count($stylesModules)) {
$out->addHeadItem('ext.gadget', $out->makeResourceLoaderLink($stylesModules, ResourceLoaderModule::TYPE_STYLES) . Html::inlineScript(ResourceLoader::makeLoaderConditionalScript(ResourceLoader::makeLoaderStateScript(array_fill_keys($stylesModules, 'ready')))));
}
$lb->execute(__METHOD__);
$done = array();
foreach ($pages as $page) {
if (isset($done[$page])) {
continue;
}
$done[$page] = true;
self::applyScript($page, $out);
}
wfProfileOut(__METHOD__);
return true;
}