当前位置: 首页>>代码示例>>PHP>>正文


PHP Gadget::loadStructuredList方法代码示例

本文整理汇总了PHP中Gadget::loadStructuredList方法的典型用法代码示例。如果您正苦于以下问题:PHP Gadget::loadStructuredList方法的具体用法?PHP Gadget::loadStructuredList怎么用?PHP Gadget::loadStructuredList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Gadget的用法示例。


在下文中一共展示了Gadget::loadStructuredList方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getList

 private function getList()
 {
     $data = array();
     $result = $this->getResult();
     $gadgets = Gadget::loadStructuredList();
     foreach ($gadgets as $category => $list) {
         if (!$this->neededNames || isset($this->neededNames[$category])) {
             $row = array();
             if (isset($this->props['name'])) {
                 $row['name'] = $category;
             }
             if ($category !== "") {
                 if (isset($this->props['title'])) {
                     $row['desc'] = wfMessage("gadget-section-{$category}")->parse();
                 }
             }
             if (isset($this->props['members'])) {
                 $row['members'] = count($list);
             }
             $data[] = $row;
         }
     }
     $result->setIndexedTagName($data, 'category');
     $result->addValue('query', $this->getModuleName(), $data);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:25,代码来源:ApiQueryGadgetCategories.php

示例2: testPreferences

    function testPreferences()
    {
        global $wgUser, $wgOut, $wgTitle;
        // This test makes call to the parser which requires valids Outputpage
        // and Title objects. Set them up there, they will be released at the
        // end of the test.
        $old_wgOut = $wgOut;
        $old_wgTitle = $wgTitle;
        $wgTitle = Title::newFromText('Parser test for Gadgets extension');
        // Proceed with test setup:
        $prefs = array();
        $context = new RequestContext();
        $wgOut = $context->getOutput();
        $wgOut->setTitle(Title::newFromText('test'));
        Gadget::loadStructuredList('* foo | foo.js
==keep-section1==
* bar| bar.js
==remove-section==
* baz [rights=embezzle] |baz.js
==keep-section2==
* quux [rights=read] | quux.js');
        $this->assertTrue(GadgetHooks::getPreferences($wgUser, $prefs), 'GetPrefences hook should return true');
        $options = $prefs['gadgets']['options'];
        $this->assertFalse(isset($options['<gadget-section-remove-section>']), 'Must not show empty sections');
        $this->assertTrue(isset($options['<gadget-section-keep-section1>']));
        $this->assertTrue(isset($options['<gadget-section-keep-section2>']));
        // Restore globals
        $wgOut = $old_wgOut;
        $wgTitle = $old_wgTitle;
    }
开发者ID:Tarendai,项目名称:spring-website,代码行数:30,代码来源:GadgetTest.php

示例3: getPreferences

 /**
  * GetPreferences hook handler.
  * @param $user User
  * @param $preferences Array: Preference descriptions
  */
 public static function getPreferences($user, &$preferences)
 {
     $gadgets = Gadget::loadStructuredList();
     if (!$gadgets) {
         return true;
     }
     $options = array();
     $default = array();
     foreach ($gadgets as $section => $thisSection) {
         $available = array();
         foreach ($thisSection as $gadget) {
             if ($gadget->isAllowed($user)) {
                 $gname = $gadget->getName();
                 # bug 30182: dir="auto" because it's often not translated
                 $desc = '<span dir="auto">' . $gadget->getDescription() . '</span>';
                 $available[$desc] = $gname;
                 if ($gadget->isEnabled($user)) {
                     $default[] = $gname;
                 }
             }
         }
         if ($section !== '') {
             $section = wfMsgExt("gadget-section-{$section}", 'parseinline');
             if (count($available)) {
                 $options[$section] = $available;
             }
         } else {
             $options = array_merge($options, $available);
         }
     }
     $preferences['gadgets-intro'] = array('type' => 'info', 'label' => '&#160;', 'default' => Xml::tags('tr', array(), Xml::tags('td', array('colspan' => 2), wfMsgExt('gadgets-prefstext', 'parse'))), 'section' => 'gadgets', 'raw' => 1, 'rawrow' => 1);
     $preferences['gadgets'] = array('type' => 'multiselect', 'options' => $options, 'section' => 'gadgets', 'label' => '&#160;', 'prefix' => 'gadget-', 'default' => $default);
     return true;
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:39,代码来源:Gadgets_body.php

示例4: getList

 /**
  * @return array
  */
 private function getList()
 {
     $gadgets = Gadget::loadStructuredList();
     $result = array();
     foreach ($gadgets as $category => $list) {
         if ($this->categories && !isset($this->categories[$category])) {
             continue;
         }
         foreach ($list as $g) {
             if ($this->isNeeded($g)) {
                 $result[] = $g;
             }
         }
     }
     return $result;
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:19,代码来源:ApiQueryGadgets.php

示例5: testPreferences

    function testPreferences()
    {
        $prefs = array();
        Gadget::loadStructuredList('* foo | foo.js
==keep-section1==
* bar| bar.js
==remove-section==
* baz [rights=embezzle] |baz.js
==keep-section2==
* quux [rights=read] | quux.js');
        $this->assertTrue(GadgetHooks::getPreferences(new User(), $prefs), 'GetPrefences hook should return true');
        $options = $prefs['gadgets']['options'];
        $this->assertFalse(isset($options['&lt;gadget-section-remove-section&gt;']), 'Must not show empty sections');
        $this->assertTrue(isset($options['&lt;gadget-section-keep-section1&gt;']));
        $this->assertTrue(isset($options['&lt;gadget-section-keep-section2&gt;']));
    }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:16,代码来源:GadgetTest.php

示例6: showMainForm

 /**
  * Displays form showing the list of installed gadgets
  */
 public function showMainForm()
 {
     global $wgOut, $wgUser, $wgLang, $wgContLang;
     $skin = $wgUser->getSkin();
     $this->setHeaders();
     $wgOut->setPagetitle(wfMsg("gadgets-title"));
     $wgOut->addWikiMsg('gadgets-pagetext');
     $gadgets = Gadget::loadStructuredList();
     if (!$gadgets) {
         return;
     }
     $lang = "";
     if ($wgLang->getCode() != $wgContLang->getCode()) {
         $lang = "/" . $wgLang->getCode();
     }
     $listOpen = false;
     $msgOpt = array('parseinline', 'parsemag');
     $editInterfaceAllowed = $wgUser->isAllowed('editinterface');
     foreach ($gadgets as $section => $entries) {
         if ($section !== false && $section !== '') {
             $t = Title::makeTitleSafe(NS_MEDIAWIKI, "Gadget-section-{$section}{$lang}");
             if ($editInterfaceAllowed) {
                 $lnkTarget = $t ? $skin->link($t, wfMsgHTML('edit'), array(), array('action' => 'edit')) : htmlspecialchars($section);
                 $lnk = "&#160; &#160; [{$lnkTarget}]";
             } else {
                 $lnk = '';
             }
             $ttext = wfMsgExt("gadget-section-{$section}", $msgOpt);
             if ($listOpen) {
                 $wgOut->addHTML(Xml::closeElement('ul') . "\n");
                 $listOpen = false;
             }
             $wgOut->addHTML(Html::rawElement('h2', array(), $ttext . $lnk) . "\n");
         }
         foreach ($entries as $gadget) {
             $t = Title::makeTitleSafe(NS_MEDIAWIKI, "Gadget-{$gadget->getName()}{$lang}");
             if (!$t) {
                 continue;
             }
             $links = array();
             if ($editInterfaceAllowed) {
                 $links[] = $skin->link($t, wfMsgHTML('edit'), array(), array('action' => 'edit'));
             }
             $links[] = $skin->link($this->getTitle("export/{$gadget->getName()}"), wfMsgHtml('gadgets-export'));
             $ttext = wfMsgExt("gadget-{$gadget->getName()}", $msgOpt);
             if (!$listOpen) {
                 $listOpen = true;
                 $wgOut->addHTML(Xml::openElement('ul'));
             }
             $lnk = '&#160;&#160;' . wfMsg('parentheses', $wgLang->pipeList($links));
             $wgOut->addHTML(Xml::openElement('li') . $ttext . $lnk . "<br />" . wfMsgHTML('gadgets-uses') . wfMsg('colon-separator'));
             $lnk = array();
             foreach ($gadget->getScriptsAndStyles() as $codePage) {
                 $t = Title::makeTitleSafe(NS_MEDIAWIKI, $codePage);
                 if (!$t) {
                     continue;
                 }
                 $lnk[] = $skin->link($t, htmlspecialchars($t->getText()));
             }
             $wgOut->addHTML($wgLang->commaList($lnk));
             $rights = array();
             foreach ($gadget->getRequiredRights() as $right) {
                 $rights[] = '* ' . wfMessage("right-{$right}")->plain();
             }
             if (count($rights)) {
                 $wgOut->addHTML('<br />' . wfMessage('gadgets-required-rights', implode("\n", $rights), count($rights))->parse());
             }
             $skins = array();
             $validskins = Skin::getSkinNames();
             foreach ($gadget->getRequiredSkins() as $skinid) {
                 if (isset($validskins[$skinid])) {
                     $skins[] = wfMessage("skinname-{$skinid}")->plain();
                 } else {
                     $skins[] = $skinid;
                 }
             }
             if (count($skins)) {
                 $wgOut->addHTML('<br />' . wfMessage('gadgets-required-skins', $wgLang->commaList($skins), count($skins))->parse());
             }
             if ($gadget->isOnByDefault()) {
                 $wgOut->addHTML('<br />' . wfMessage('gadgets-default')->parse());
             }
             $wgOut->addHTML(Xml::closeElement('li') . "\n");
         }
     }
     if ($listOpen) {
         $wgOut->addHTML(Xml::closeElement('ul') . "\n");
     }
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:92,代码来源:SpecialGadgets.php

示例7: showMainForm

 /**
  * Displays form showing the list of installed gadgets
  */
 public function showMainForm()
 {
     global $wgContLang;
     $output = $this->getOutput();
     $this->setHeaders();
     $output->setPagetitle($this->msg('gadgets-title'));
     $output->addWikiMsg('gadgets-pagetext');
     $gadgets = Gadget::loadStructuredList();
     if (!$gadgets) {
         return;
     }
     $lang = $this->getLanguage();
     $langSuffix = "";
     if ($lang->getCode() != $wgContLang->getCode()) {
         $langSuffix = "/" . $lang->getCode();
     }
     $listOpen = false;
     $editInterfaceMessage = $this->getUser()->isAllowed('editinterface') ? 'edit' : 'viewsource';
     foreach ($gadgets as $section => $entries) {
         if ($section !== false && $section !== '') {
             $t = Title::makeTitleSafe(NS_MEDIAWIKI, "Gadget-section-{$section}{$langSuffix}");
             $lnkTarget = $t ? Linker::link($t, $this->msg($editInterfaceMessage)->escaped(), array(), array('action' => 'edit')) : htmlspecialchars($section);
             $lnk = "&#160; &#160; [{$lnkTarget}]";
             $ttext = $this->msg("gadget-section-{$section}")->parse();
             if ($listOpen) {
                 $output->addHTML(Xml::closeElement('ul') . "\n");
                 $listOpen = false;
             }
             $output->addHTML(Html::rawElement('h2', array(), $ttext . $lnk) . "\n");
         }
         /**
          * @var $gadget Gadget
          */
         foreach ($entries as $gadget) {
             $t = Title::makeTitleSafe(NS_MEDIAWIKI, "Gadget-{$gadget->getName()}{$langSuffix}");
             if (!$t) {
                 continue;
             }
             $links = array();
             $links[] = Linker::link($t, $this->msg($editInterfaceMessage)->escaped(), array(), array('action' => 'edit'));
             $links[] = Linker::link($this->getPageTitle("export/{$gadget->getName()}"), $this->msg('gadgets-export')->escaped());
             $ttext = $this->msg("gadget-{$gadget->getName()}")->parse();
             if (!$listOpen) {
                 $listOpen = true;
                 $output->addHTML(Xml::openElement('ul'));
             }
             $lnk = '&#160;&#160;' . $this->msg('parentheses')->rawParams($lang->pipeList($links))->escaped();
             $output->addHTML(Xml::openElement('li') . $ttext . $lnk . "<br />" . $this->msg('gadgets-uses')->escaped() . $this->msg('colon-separator')->escaped());
             $lnk = array();
             foreach ($gadget->getScriptsAndStyles() as $codePage) {
                 $t = Title::makeTitleSafe(NS_MEDIAWIKI, $codePage);
                 if (!$t) {
                     continue;
                 }
                 $lnk[] = Linker::link($t, htmlspecialchars($t->getText()));
             }
             $output->addHTML($lang->commaList($lnk));
             $rights = array();
             foreach ($gadget->getRequiredRights() as $right) {
                 $rights[] = '* ' . $this->msg("right-{$right}")->plain();
             }
             if (count($rights)) {
                 $output->addHTML('<br />' . $this->msg('gadgets-required-rights', implode("\n", $rights), count($rights))->parse());
             }
             $skins = array();
             $validskins = Skin::getSkinNames();
             foreach ($gadget->getRequiredSkins() as $skinid) {
                 if (isset($validskins[$skinid])) {
                     $skins[] = $this->msg("skinname-{$skinid}")->plain();
                 } else {
                     $skins[] = $skinid;
                 }
             }
             if (count($skins)) {
                 $output->addHTML('<br />' . $this->msg('gadgets-required-skins', $lang->commaList($skins))->numParams(count($skins))->parse());
             }
             if ($gadget->isOnByDefault()) {
                 $output->addHTML('<br />' . $this->msg('gadgets-default')->parse());
             }
             $output->addHTML(Xml::closeElement('li') . "\n");
         }
     }
     if ($listOpen) {
         $output->addHTML(Xml::closeElement('ul') . "\n");
     }
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:89,代码来源:SpecialGadgets.php


注:本文中的Gadget::loadStructuredList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。