コード例 #1
0
ファイル: Parser.php プロジェクト: rrameshs/mediawiki
 /**
  * Set's up the PHP implementation of OOUI for use in this request
  * and instructs OutputPage to enable OOUI for itself.
  *
  * @since 1.26
  */
 public function enableOOUI()
 {
     OutputPage::setupOOUI();
     $this->mOutput->setEnableOOUI(true);
 }
 /**
  * Helper function for getParsedcontent for making subpage section headers
  * @param $contentItem array of data for the content item we're generating the header for
  * @return string html (NOTE THIS IS AN OPEN DIV)
  */
 protected function makeHeader(Title $title, array $contentItem)
 {
     global $wgParser;
     static $tocLinks = [];
     // All used ids for the sections for the toc
     $linkRenderer = $wgParser->getLinkRenderer();
     $spTitle = Title::newFromText($contentItem['title']);
     $spRev = Revision::newFromTitle($spTitle);
     // Get display name
     if (isset($contentItem['displayTitle'])) {
         $spPage = $contentItem['displayTitle'];
     } else {
         $spPage = $spTitle->getSubpageText();
     }
     // Generate an id for the section for anchors
     // Make sure this matches the ToC anchor generation
     $spPageLink = Sanitizer::escapeId(htmlspecialchars($spPage));
     $spPageLink2 = $spPageLink;
     $spPageLinkCounter = 1;
     while (in_array($spPageLink2, $tocLinks)) {
         $spPageLink2 = $spPageLink . $spPageLinkCounter;
         $spPageLinkCounter++;
     }
     $tocLinks[] = $spPageLink2;
     // Get editsection-style links for the subpage
     $sectionLinks = [];
     $sectionLinksText = '';
     if (isset($spRev)) {
         $sectionLinks['viewLink'] = $linkRenderer->makeLink($spTitle, wfMessage('collaborationkit-hub-subpage-view')->inContentLanguage()->text());
     }
     if ($spTitle->userCan('edit')) {
         if (isset($spRev)) {
             $linkString = 'edit';
             // TODO get appropriate edit link if it's something weird
             $sectionLinks['edit'] = $linkRenderer->makeLink($spTitle, wfMessage($linkString)->inContentLanguage()->text(), [], ['action' => 'edit']);
         } else {
             $linkString = 'create';
             $sectionLinks['edit'] = $linkRenderer->makeLink(SpecialPage::getTitleFor('CreateHubFeature'), wfMessage($linkString)->inContentLanguage()->text(), [], ['collaborationhub' => $title->getPrefixedDBKey(), 'feature' => $spTitle->getSubpageText()]);
         }
     }
     if ($title->userCan('edit')) {
         $sectionLinks['removeLink'] = $linkRenderer->makeLink($title, wfMessage('collaborationkit-hub-subpage-remove')->inContentLanguage()->text(), [], ['action' => 'edit']);
     }
     foreach ($sectionLinks as $sectionLink) {
         $sectionLinksText .= $this->makeEditSectionLink($sectionLink);
     }
     $sectionLinksText = Html::rawElement('span', ['class' => 'mw-editsection'], $sectionLinksText);
     // Assemble header
     // Open general section here since we have the id here
     $html = Html::openElement('div', ['class' => 'mw-ck-hub-section', 'id' => $spPageLink2]);
     $html .= Html::rawElement('h2', [], Html::element('span', ['class' => 'mw-headline'], $spPage) . $sectionLinksText);
     OutputPage::setupOOUI();
     return $html;
 }