Beispiel #1
0
 /**
  * Return list of messages matching given pattern
  *
  * Example: 'feature-foo-*'
  *
  * @param string $pattern - pattern to match against ALL messages in the system
  * @return array - key/value list of matching messages
  */
 private static function resolveMessagesPattern($pattern)
 {
     $fname = __METHOD__ . "::{$pattern}";
     wfProfileIn($fname);
     self::log(__METHOD__, $pattern);
     $pattern = substr($pattern, 0, -1);
     $patternLen = strlen($pattern);
     // get list of all messages loaded by MW
     $lang = wfGetLangObj(false);
     $langCode = $lang->getCode();
     if ($lang instanceof StubUserLang) {
         $lang = $lang->_newObject();
     }
     $messageKeys = self::getAllMessageKeys($lang);
     $ret = array();
     foreach ($messageKeys as $msg) {
         if (is_array($msg)) {
             var_dump($msg);
         }
         if (substr($msg, 0, $patternLen) === $pattern) {
             $ret[$msg] = wfmsgExt($msg, array('language' => $langCode));
         }
     }
     wfProfileOut($fname);
     return $ret;
 }
 /**
  * Show all applicable editing introductions
  *
  * - new article intro
  * - custom intro (editintro=Foo in URL)
  * - talk page intro
  * - main page educational note (BugId:51755)
  *
  * Handle preloads (BugId:5652)
  */
 protected function showIntro()
 {
     // Code based on EditPage.php
     if (!$this->mTitle->exists()) {
         if ($this->app->wg->User->isLoggedIn()) {
             $msgName = 'newarticletext';
             $class = 'mw-newarticletext';
         } else {
             $msgName = 'newarticletextanon';
             $class = 'mw-newarticletextanon';
         }
         // Give a notice if the user is editing a deleted/moved page...
         $titleText = $this->mTitle->getPrefixedText();
         if (!empty($titleText)) {
             $out = new OutputPage();
             $resultRowsNum = LogEventsList::showLogExtract($out, array('delete', 'move'), $titleText, '', array('lim' => 10, 'conds' => array("log_action != 'revision'"), 'showIfEmpty' => false, 'msgKey' => array('recreate-moveddeleted-warn')));
         }
         $msgParams = [];
         // check for empty message (BugId:6923)
         if (!empty($msgName)) {
             $message = wfMessage($msgName, $msgParams);
             $messageParsed = $message->parse();
             if (!$message->isBlank() && trim(strip_tags($messageParsed)) != '') {
                 $this->mEditPagePreloads['EditPageIntro'] = ['content' => $messageParsed, 'class' => $class];
             }
         }
     }
     wfRunHooks('EditPageLayoutShowIntro', [&$this->mEditPagePreloads, $this->mTitle]);
     // custom intro
     $this->showCustomIntro();
     // Intro text for talk pages (BugId:7092)
     if ($this->mTitle->isTalkPage()) {
         $this->mEditPagePreloads['EditPageTalkPageIntro'] = array('content' => wfmsgExt('talkpagetext', array('parse')), 'class' => 'mw-talkpagetext');
     } elseif ($this->mTitle->isMainPage() && !$this->mTitle->isProtected() && !$this->userDismissedEduNote()) {
         //if this is an unprotected main page and user hasn't seen the main page educational notice -- show it :)
         /** @var $notice EditPageNotice */
         $msg = wfMsgExt('mainpagewarning-notice', array('parse'));
         $notice = new EditPageNotice($msg, 'MainPageEduNote');
         $this->helper->addJsVariable('mainPageEduNoteHash', $notice->getHash());
         $this->addEditNotice($notice);
     }
     // Edit notice (BugId:7616)
     $editnotice_ns_key = 'editnotice-' . $this->mTitle->getNamespace();
     $editnotice_ns_msg = new Message($editnotice_ns_key);
     if (!$editnotice_ns_msg->isDisabled()) {
         $this->mEditPagePreloads['EditPageEditNotice'] = array('content' => $editnotice_ns_msg->parse(), 'class' => 'mw-editnotice');
     }
 }