/** * @param Article $article */ function __construct(Article $article) { $this->app = F::app(); $this->out = $this->app->wg->Out; $this->request = $this->app->wg->Request; wfProfileIn(__METHOD__); parent::__construct($article); $this->helper = EditPageLayoutHelper::getInstance(); // default setup of summary box $this->mSummaryBox = array('name' => 'wpSummary', 'placeholder' => wfMsg('editpagelayout-pageControls-summaryLabel')); $this->mCoreEditNotices = new EditPageNotices(); $this->mEditNotices = new EditPageNotices(); // add messages (fetch them using <script> tag) JSMessages::enqueuePackage('EditPageLayout', JSMessages::EXTERNAL); wfProfileOut(__METHOD__); }
/** * initialize article edit page */ protected function initializeEditPage() { $helper = EditPageLayoutHelper::getInstance(); $editPage = $helper->setupEditPage($this->mEditedArticle, $this->fullScreen, get_class($this)); //var used by onMakeGlobalVariablesScript in EditPageLayoutHelper if (!empty($this->titleNS)) { $helper->addJsVariable('wgEditedTitleNS', $this->contLang->getFormattedNsText($this->titleNS)); } else { $helper->addJsVariable('wgEditedTitleNS', ''); } $helper->addJsVariable('wgEditedTitlePrefix', $editPage->titlePrefix = $this->getTitlePrefix()); if ($this->mode == self::MODE_NEW_SETUP) { $helper->addJsVariable('wgEditPageIsNewArticle', true); } return $editPage; }
/** * Grab notices added by core via LogEventsList class * * @param $s String Notice to be emitted * @param $types String or Array * @param $page String The page title to show log entries for * @param $user String The user who made the log entries * @param $param array Associative Array with the following additional options: * - lim Integer Limit of items to show, default is 50 * - conds Array Extra conditions for the query (e.g. "log_action != 'revision'") * - showIfEmpty boolean Set to false if you don't want any output in case the loglist is empty * if set to true (default), "No matching items in log" is displayed if loglist is empty * - msgKey Array If you want a nice box with a message, set this to the key of the message. * First element is the message key, additional optional elements are parameters for the key * that are processed with wgMsgExt and option 'parse' * - offset Set to overwrite offset parameter in $wgRequest * set to '' to unset offset * - wrap String: Wrap the message in html (usually something like "<div ...>$1</div>"). * @return boolean return false, so notice will not be emitted by core, but by EditPageLayout code */ static function onLogEventsListShowLogExtract($s, $types, $page, $user, $param) { $helper = EditPageLayoutHelper::getInstance(); if ($helper->editPage instanceof EditPageLayout) { if (!empty($s)) { $helper->editPage->addEditNotice($s, $param['msgKey'][0]); } // don't emit notices on the screen - they will be handled by addEditNotice() return false; } // don't touch things outside the edit page (BugId:9379) return true; }
/** * Render template for <body> tag content */ public function executeEditPage() { wfProfileIn(__METHOD__); $helper = EditPageLayoutHelper::getInstance(); $editPage = $helper->getEditPage(); $this->showPreview = true; if ($helper->fullScreen) { $wgJsMimeType = $this->wg->JsMimeType; // add stylesheet $this->wg->Out->addStyle(AssetsManager::getInstance()->getSassCommonURL('extensions/wikia/EditPageLayout/css/EditPageLayout.scss')); if ($helper->isCodeSyntaxHighlightingEnabled($editPage->getTitle())) { $this->wg->Out->addScript("<script type=\"{$wgJsMimeType}\" src=\"/resources/Ace/ace.js\"></script>"); $srcs = AssetsManager::getInstance()->getGroupCommonURL('ace_editor_js'); OasisController::addBodyClass('codeeditor'); $this->showPreview = $helper->isCodePageWithPreview($editPage->getTitle()); } else { $packageName = 'epl'; if (class_exists('RTE') && RTE::isEnabled() && !$editPage->isReadOnlyPage()) { $packageName = 'eplrte'; } $srcs = AssetsManager::getInstance()->getGroupCommonURL($packageName); } foreach ($srcs as $src) { $this->wg->Out->addScript("<script type=\"{$wgJsMimeType}\" src=\"{$src}\"></script>"); } } // render WikiLogo $response = $this->app->sendRequest('WikiHeader', 'Wordmark'); // move wordmark data $this->wordmark = $response->getData(); // render global and user navigation $this->header = F::app()->renderView('GlobalNavigation', 'index'); // Editing [foo] $this->title = $editPage->getEditedTitle(); $section = $this->wg->Request->getVal('section'); // Is user logged in? $this->isLoggedIn = $this->wg->User->isLoggedIn(); // Can the user minor edit? $this->canMinorEdit = $this->title->exists() && $this->isLoggedIn && $this->wg->User->isAllowed('minoredit'); // Text for Edit summary label $wpSummaryLabelText = 'editpagelayout-edit-summary-label'; // Should show mobile preview icon $this->showMobilePreview = $helper->showMobilePreview($editPage->getTitle()); if ($section == 'new') { $msgKey = 'editingcomment'; // If adding new section to page, change label text (BugId: 7243) $wpSummaryLabelText = 'editpagelayout-subject-headline-label'; } else { if (is_numeric($section)) { $msgKey = 'editingsection'; } else { $msgKey = 'editing'; } } // title $this->titleText = $this->title->getPrefixedText(); if ($this->titleText == '') { $this->titleText = ' '; } // limit title length if (mb_strlen($this->titleText) > self::TITLE_MAX_LENGTH) { $this->titleShortText = htmlspecialchars(mb_substr($this->titleText, 0, self::TITLE_MAX_LENGTH)) . '…'; } else { $this->titleShortText = htmlspecialchars($this->titleText); } $this->editing = wfMessage($msgKey, '')->escaped(); $this->wpSummaryLabelText = wfMessage($wpSummaryLabelText)->escaped(); // render help link and point the link to new tab $this->helpLink = wfMessage('editpagelayout-helpLink')->parse(); $this->helpLink = str_replace('<a ', '<a target="_blank" ', $this->helpLink); // action for edit form $this->editFormAction = $editPage->getFormAction(); // preloads $this->editPagePreloads = $editPage->getEditPagePreloads(); // minor edit checkbox (BugId:6461) $this->minorEditCheckbox = !empty($editPage->minoredit); // summary box $this->summaryBox = $editPage->renderSummaryBox(); // extra checkboxes $this->customCheckboxes = $editPage->getCustomCheckboxes(); // dismissable notifications $this->notices = $editPage->getNotices(); $this->noticesHtml = $editPage->getNoticesHtml(); // notifications link (BugId:7951) $this->notificationsLink = count($this->notices) == 0 ? wfMessage('editpagelayout-notificationsLink-none')->escaped() : wfMessage('editpagelayout-notificationsLink', count($this->notices))->parse(); // check if we're in read only mode // disable edit form when in read-only mode if (wfReadOnly()) { $this->bodytext = '<div id="mw-read-only-warning" class="WikiaArticle">' . wfMessage('oasis-editpage-readonlywarning', wfReadOnlyReason())->escaped() . '</div>'; wfDebug(__METHOD__ . ": edit form disabled because read-only mode is on\n"); } $this->hideTitle = $editPage->hideTitle; wfRunHooks('EditPageLayoutExecute', array($this)); wfProfileOut(__METHOD__); }