/**
  * Triggered if a user edits a Draft subpage of a template.
  * It adds an editintro message with help and links.
  *
  * @param Array $preloads
  * @param Title $title
  * @return bool
  */
 public static function onEditPageLayoutShowIntro(&$preloads, Title $title)
 {
     if ($title->getNamespace() == NS_TEMPLATE) {
         if (TemplateDraftHelper::isTitleDraft($title)) {
             $base = Title::newFromText($title->getBaseText(), NS_TEMPLATE);
             $baseHelp = Title::newFromText('Help:PortableInfoboxes');
             $preloads['EditPageIntro'] = ['content' => wfMessage('templatedraft-editintro')->rawParams(Xml::element('a', ['href' => $baseHelp->getFullURL(), 'target' => '_blank'], wfMessage('templatedraft-module-help')->plain()), Xml::element('a', ['href' => $base->getFullUrl(['action' => 'edit']), 'target' => '_blank'], wfMessage('templatedraft-module-view-parent')->plain()))->escaped()];
         } elseif (!TemplateDraftHelper::titleHasPortableInfobox($title)) {
             $base = Title::newFromText($title->getBaseText() . '/' . wfMessage('templatedraft-subpage'), NS_TEMPLATE);
             $draftUrl = $base->getFullUrl(['action' => 'edit', TemplateConverter::CONVERSION_MARKER => 1]);
             $preloads['EditPageIntro'] = ['content' => wfMessage('templatedraft-module-editintro-please-convert')->rawParams(Xml::element('a', ['href' => $draftUrl, 'target' => '_blank'], wfMessage('templatedraft-module-button-create')->plain()))->escaped()];
         }
     }
     return true;
 }
Esempio n. 2
0
 public function onView()
 {
     $title = $this->getTitle();
     $redirectParams = wfArrayToCGI(array_diff_key($this->getRequest()->getQueryValues(), ['title' => null, 'action' => null]));
     if (!$title->exists()) {
         $this->addBannerNotificationMessage('templatedraft-approval-no-page-error');
         $redirectTitle = $title;
     } elseif (!TemplateDraftHelper::isTitleDraft($title)) {
         $this->addBannerNotificationMessage('templatedraft-approval-no-templatedraft-error');
         $redirectTitle = $title;
     } else {
         $this->approveDraft($title);
         $redirectTitle = $title->getBaseText();
         $redirectTitle = Title::newFromText($redirectTitle, $title->getNamespace());
     }
     $this->getOutput()->redirect($redirectTitle->getFullUrl($redirectParams));
 }
 public static function isInfoboxTemplate(Title $title)
 {
     $namespace = $title->getNamespace();
     if ($namespace === NS_TEMPLATE && class_exists('TemplateClassificationController')) {
         $tc = new TemplateClassificationController($title);
         return $tc->isType($tc::TEMPLATE_INFOBOX) || TemplateDraftHelper::isTitleDraft($title);
     }
     return false;
 }