/** * Triggered if a user edits a Draft subpage of a template. * It pre-fills the content of the Draft with a converted markup. * @param $text * @param Title $title * @return bool */ public static function onEditFormPreloadText(&$text, Title $title) { $helper = new TemplateDraftHelper(); if ($helper->isTitleNewDraft($title) && TemplateConverter::isConversion()) { $parentTitleId = $helper->getParentTitle($title)->getArticleID(); if ($parentTitleId > 0) { $parentContent = WikiPage::newFromID($parentTitleId)->getText(); /** * TODO: Introduce a parameter to modify conversion flags * If you want to perform different conversions, not only the infobox one, * you can introduce a URL parameter to control the binary sum of flags. */ $controller = new TemplateDraftController(); $text = $controller->createDraftContent($title, $parentContent, TemplateClassificationController::TEMPLATE_INFOBOX); } } return true; }