static function getInstance() { if (!isset(self::$instance)) { self::$instance = new self(); } return self::$instance; }
public static function getEPLAssets($combine) { $files = []; if (class_exists('EditPageLayoutHelper')) { $files = EditPageLayoutHelper::getAssets(); } return $files; }
public static function getEPLAssets($combine) { // This class always exists at the moment, this is just in case it goes away at some point if (class_exists('EditPageLayoutHelper')) { return EditPageLayoutHelper::getAssets(); } else { return array(); } }
/** * 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'); } }
/** * Show a read-only error * Parameters are the same as OutputPage:readOnlyPage() * Redirect to the article page if redlink=1 */ function readOnlyPage($source = null, $protected = false, $reasons = array(), $action = null) { $this->mIsReadOnlyPage = true; $this->helper->addJsVariable('wgEditPageIsReadOnly', true); $bridge = F::build('EditPageOutputBridge', array($this, $this->mCoreEditNotices)); /* @var $bridge EditPageOutputBridge */ parent::readOnlyPage($source, $protected, $reasons, $action); $bridge->close(); //$this->mCoreEditNotices->get( ??? )->setSummary( $this->app->wf->msgExt( 'editpagelayout-blocked-user' ) ); $this->mCoreEditNotices->remove('templatesUsed'); $this->mCoreEditNotices->remove('viewsourcetext'); $this->mCoreEditNotices->remove(false); $this->textbox1 = $source; $this->out->clearHTML(); $this->out->addHtml('<div id="myedit">'); $this->showTextbox1(array('readonly')); $this->out->addHtml('</div>'); }
/** * 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; }
/** * Initialise a GeSHi object to format some code, performing * common setup for all our uses of it * * @param string $text * @param string $lang * @return GeSHi */ public static function prepare($text, $lang) { global $wgTitle, $wgOut; self::initialise(); $geshi = new GeSHi($text, $lang); if ($geshi->error() == GESHI_ERROR_NO_SUCH_LANG) { return null; } $geshi->set_encoding('UTF-8'); $geshi->enable_classes(); $geshi->set_overall_class("source-{$lang}"); $geshi->enable_keyword_links(false); // Wikia change start if ($wgTitle instanceof Title && EditPageLayoutHelper::isCodeSyntaxHighlightingEnabled($wgTitle)) { $theme = 'solarized-light'; if (SassUtil::isThemeDark()) { $theme = 'solarized-dark'; } $geshi->set_language_path(GESHI_ROOT . $theme . DIRECTORY_SEPARATOR); $geshi->set_overall_id('theme-' . $theme); $wgOut->addStyle(AssetsManager::getInstance()->getSassCommonURL('extensions/SyntaxHighlight_GeSHi/styles/solarized.scss')); } // Wikia change end return $geshi; }
/** * Add global variables for Javascript * @param array $aVars * @return bool */ public static function onEditPageMakeGlobalVariablesScript(array &$aVars) { $aVars['enableWikitextSyntaxHighlighting'] = \EditPageLayoutHelper::isWikitextSyntaxHighlightingEnabled(); 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__); }