Ejemplo n.º 1
0
 public function getContext()
 {
     if (!is_object($this->out)) {
         \Wikia\Logger\WikiaLogger::instance()->debug('LogEventsList getContext not an object', ['exception' => new Exception()]);
     }
     return $this->out->getContext();
 }
 /**
  * Hook: BeforePageDisplay
  */
 public static function addModules(OutputPage $out, Skin $skin)
 {
     global $wgContentTranslationEventLogging, $wgContentTranslationCampaigns;
     $title = $out->getTitle();
     $user = $out->getUser();
     // Check if CX is available for current user.
     if (!self::isEnabledForUser($user)) {
         if (!$title->exists() && $wgContentTranslationCampaigns['newarticle'] && !$out->getRequest()->getCookie('cx_campaign_newarticle_hide', '') && !$user->isAnon()) {
             $out->addModules('ext.cx.campaigns.newarticle.veloader');
             if ($wgContentTranslationEventLogging) {
                 $out->addModules('ext.cx.eventlogging');
             }
         }
         return;
     }
     // If EventLogging integration is enabled, load the event logging functions module
     if ($wgContentTranslationEventLogging) {
         $out->addModules('ext.cx.eventlogging');
     }
     if ($title->inNamespace(NS_MAIN) && Action::getActionName($out->getContext()) === 'view' && $title->exists()) {
         $out->addModules('ext.cx.interlanguagelink');
     }
     // Add a hover menu for the contributions link in personal toolbar
     $out->addModules('ext.cx.campaigns.contributionsmenu');
     // The current guided tours are only for the user namespace,
     // so load the module only there.
     // In the future there may be guided tours in other namespaces,
     // and then this condition should be changed.
     if (class_exists('GuidedTourHooks') && $title->inNamespace(NS_USER)) {
         $out->addModules('ext.guidedTour');
     }
 }
Ejemplo n.º 3
0
 /**
  * @static
  * @param OutputPage $out
  * @param $categories
  * @param $links
  * @return bool
  */
 public static function onOutputPageMakeCategoryLinks(&$out, $categories, &$links)
 {
     if (!F::app()->wg->WikiaHubsPages) {
         return true;
     }
     $dbkey = $out->getContext()->getTitle()->getDBKey();
     if (in_array($dbkey, F::app()->wg->WikiaHubsPages)) {
         $categories = null;
         return false;
     }
     return true;
 }
 /**
  * Add "x email-tmwed open account requests" notice
  * @param $notice
  * @return bool
  */
 public static function tmwAccountsNotice(OutputPage &$out, Skin &$skin)
 {
     global $wgTMWAccountNotice;
     $context = $out->getContext();
     if (!$wgTMWAccountNotice || !$context->getUser()->isAllowed('tmwaccount')) {
         return true;
     }
     # Only show on some special pages
     $title = $context->getTitle();
     if (!$title->isSpecial('Recentchanges') && !$title->isSpecial('Watchlist')) {
         return true;
     }
     $count = TMWAccount::getOpenEmailTMWedCount('*');
     if ($count > 0) {
         $out->prependHtml('<div id="mw-tmwaccount-msg" class="plainlinks mw-tmwaccount-bar">' . $out->parse(wfMsgExt('tmwaccount-newrequests', 'parsemag', $count), false) . '</div>');
     }
     return true;
 }
 /**
  * Add "x email-confirmed open account requests" notice
  * @param $notice
  * @return bool
  */
 public static function confirmAccountsNotice(OutputPage &$out, Skin &$skin)
 {
     global $wgConfirmAccountNotice;
     $context = $out->getContext();
     if (!$wgConfirmAccountNotice || !$context->getUser()->isAllowed('confirmaccount')) {
         return true;
     }
     # Only show on some special pages
     $title = $context->getTitle();
     if (!$title->isSpecial('Recentchanges') && !$title->isSpecial('Watchlist')) {
         return true;
     }
     $count = ConfirmAccount::getOpenEmailConfirmedCount('*');
     if ($count > 0) {
         $out->prependHtml('<div id="mw-confirmaccount-msg" class="plainlinks mw-confirmaccount-bar">' . $context->msg('confirmaccount-newrequests')->numParams($count)->parse() . '</div>');
         $out->addModules('ext.confirmAccount');
         // CSS
     }
     return true;
 }
Ejemplo n.º 6
0
 /**
  * Show log extract. Either with text and a box (set $msgKey) or without (don't set $msgKey)
  *
  * @param OutputPage|string $out By-reference
  * @param string|array $types Log types to show
  * @param string|Title $page The page title to show log entries for
  * @param string $user The user who made the log entries
  * @param array $param 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 wfMessage
  * - offset Set to overwrite offset parameter in WebRequest
  *   set to '' to unset offset
  * - wrap String Wrap the message in html (usually something like "<div ...>$1</div>").
  * - flags Integer display flags (NO_ACTION_LINK,NO_EXTRA_USER_LINKS)
  * - useRequestParams boolean Set true to use Pager-related parameters in the WebRequest
  * - useMaster boolean Use master DB
  * @return int Number of total log items (not limited by $lim)
  */
 public static function showLogExtract(&$out, $types = array(), $page = '', $user = '', $param = array())
 {
     $defaultParameters = array('lim' => 25, 'conds' => array(), 'showIfEmpty' => true, 'msgKey' => array(''), 'wrap' => "\$1", 'flags' => 0, 'useRequestParams' => false, 'useMaster' => false);
     # The + operator appends elements of remaining keys from the right
     # handed array to the left handed, whereas duplicated keys are NOT overwritten.
     $param += $defaultParameters;
     # Convert $param array to individual variables
     $lim = $param['lim'];
     $conds = $param['conds'];
     $showIfEmpty = $param['showIfEmpty'];
     $msgKey = $param['msgKey'];
     $wrap = $param['wrap'];
     $flags = $param['flags'];
     $useRequestParams = $param['useRequestParams'];
     if (!is_array($msgKey)) {
         $msgKey = array($msgKey);
     }
     if ($out instanceof OutputPage) {
         $context = $out->getContext();
     } else {
         $context = RequestContext::getMain();
     }
     # Insert list of top 50 (or top $lim) items
     $loglist = new LogEventsList($context, null, $flags);
     $pager = new LogPager($loglist, $types, $user, $page, '', $conds);
     if (!$useRequestParams) {
         # Reset vars that may have been taken from the request
         $pager->mLimit = 50;
         $pager->mDefaultLimit = 50;
         $pager->mOffset = "";
         $pager->mIsBackwards = false;
     }
     if ($param['useMaster']) {
         $pager->mDb = wfGetDB(DB_MASTER);
     }
     if (isset($param['offset'])) {
         # Tell pager to ignore WebRequest offset
         $pager->setOffset($param['offset']);
     }
     if ($lim > 0) {
         $pager->mLimit = $lim;
     }
     // Fetch the log rows and build the HTML if needed
     $logBody = $pager->getBody();
     $numRows = $pager->getNumRows();
     $s = '';
     if ($logBody) {
         if ($msgKey[0]) {
             $dir = $context->getLanguage()->getDir();
             $lang = $context->getLanguage()->getHtmlCode();
             $s = Xml::openElement('div', array('class' => "mw-warning-with-logexcerpt mw-content-{$dir}", 'dir' => $dir, 'lang' => $lang));
             if (count($msgKey) == 1) {
                 $s .= $context->msg($msgKey[0])->parseAsBlock();
             } else {
                 // Process additional arguments
                 $args = $msgKey;
                 array_shift($args);
                 $s .= $context->msg($msgKey[0], $args)->parseAsBlock();
             }
         }
         $s .= $loglist->beginLogEventsList() . $logBody . $loglist->endLogEventsList();
     } elseif ($showIfEmpty) {
         $s = Html::rawElement('div', array('class' => 'mw-warning-logempty'), $context->msg('logempty')->parse());
     }
     if ($numRows > $pager->mLimit) {
         # Show "Full log" link
         $urlParam = array();
         if ($page instanceof Title) {
             $urlParam['page'] = $page->getPrefixedDBkey();
         } elseif ($page != '') {
             $urlParam['page'] = $page;
         }
         if ($user != '') {
             $urlParam['user'] = $user;
         }
         if (!is_array($types)) {
             # Make it an array, if it isn't
             $types = array($types);
         }
         # If there is exactly one log type, we can link to Special:Log?type=foo
         if (count($types) == 1) {
             $urlParam['type'] = $types[0];
         }
         $s .= Linker::link(SpecialPage::getTitleFor('Log'), $context->msg('log-fulllog')->escaped(), array(), $urlParam);
     }
     if ($logBody && $msgKey[0]) {
         $s .= '</div>';
     }
     if ($wrap != '') {
         // Wrap message in html
         $s = str_replace('$1', $s, $wrap);
     }
     /* hook can return false, if we don't want the message to be emitted (Wikia BugId:7093) */
     if (Hooks::run('LogEventsListShowLogExtract', array(&$s, $types, $page, $user, $param))) {
         // $out can be either an OutputPage object or a String-by-reference
         if ($out instanceof OutputPage) {
             $out->addHTML($s);
         } else {
             $out = $s;
         }
     }
     return $numRows;
 }
Ejemplo n.º 7
0
 /**
  * initialize various variables and generate the template
  *
  * @param OutputPage $out
  */
 function outputPage(OutputPage $out = null)
 {
     Profiler::instance()->setTemplated(true);
     $oldContext = null;
     if ($out !== null) {
         // Deprecated since 1.20, note added in 1.25
         wfDeprecated(__METHOD__, '1.25');
         $oldContext = $this->getContext();
         $this->setContext($out->getContext());
     }
     $out = $this->getOutput();
     $this->initPage($out);
     $tpl = $this->prepareQuickTemplate($out);
     // execute template
     $res = $tpl->execute();
     // result may be an error
     $this->printOrError($res);
     if ($oldContext) {
         $this->setContext($oldContext);
     }
 }
Ejemplo n.º 8
0
 /**
  * initialize various variables and generate the template
  *
  * @param $out OutputPage
  */
 function outputPage(OutputPage $out = null)
 {
     global $wgContLang;
     global $wgScript, $wgStylePath;
     global $wgMimeType, $wgJsMimeType;
     global $wgXhtmlDefaultNamespace, $wgXhtmlNamespaces, $wgHtml5Version;
     global $wgDisableCounters, $wgSitename, $wgLogo, $wgHideInterlanguageLinks;
     global $wgMaxCredits, $wgShowCreditsIfMax;
     global $wgPageShowWatchingUsers;
     global $wgDebugComments;
     global $wgArticlePath, $wgScriptPath, $wgServer;
     wfProfileIn(__METHOD__);
     Profiler::instance()->setTemplated(true);
     $oldContext = null;
     if ($out !== null) {
         // @todo Add wfDeprecated in 1.20
         $oldContext = $this->getContext();
         $this->setContext($out->getContext());
     }
     $out = $this->getOutput();
     $request = $this->getRequest();
     $user = $this->getUser();
     $title = $this->getTitle();
     wfProfileIn(__METHOD__ . '-init');
     $this->initPage($out);
     $tpl = $this->setupTemplate($this->template, 'skins');
     wfProfileOut(__METHOD__ . '-init');
     wfProfileIn(__METHOD__ . '-stuff');
     $this->thispage = $title->getPrefixedDBkey();
     $this->titletxt = $title->getPrefixedText();
     $this->userpage = $user->getUserPage()->getPrefixedText();
     $query = array();
     if (!$request->wasPosted()) {
         $query = $request->getValues();
         unset($query['title']);
         unset($query['returnto']);
         unset($query['returntoquery']);
     }
     $this->thisquery = wfArrayToCGI($query);
     $this->loggedin = $user->isLoggedIn();
     $this->username = $user->getName();
     if ($this->loggedin || $this->showIPinHeader()) {
         $this->userpageUrlDetails = self::makeUrlDetails($this->userpage);
     } else {
         # This won't be used in the standard skins, but we define it to preserve the interface
         # To save time, we check for existence
         $this->userpageUrlDetails = self::makeKnownUrlDetails($this->userpage);
     }
     wfProfileOut(__METHOD__ . '-stuff');
     wfProfileIn(__METHOD__ . '-stuff-head');
     if (!$this->useHeadElement) {
         $tpl->set('pagecss', false);
         $tpl->set('usercss', false);
         $tpl->set('userjs', false);
         $tpl->set('userjsprev', false);
         $tpl->set('jsvarurl', false);
         $tpl->setRef('xhtmldefaultnamespace', $wgXhtmlDefaultNamespace);
         $tpl->set('xhtmlnamespaces', $wgXhtmlNamespaces);
         $tpl->set('html5version', $wgHtml5Version);
         $tpl->set('headlinks', $out->getHeadLinks());
         $tpl->set('csslinks', $out->buildCssLinks());
         $tpl->set('pageclass', $this->getPageClasses($title));
         $tpl->set('skinnameclass', 'skin-' . Sanitizer::escapeClass($this->getSkinName()));
     }
     wfProfileOut(__METHOD__ . '-stuff-head');
     wfProfileIn(__METHOD__ . '-stuff2');
     $tpl->set('title', $out->getPageTitle());
     $tpl->set('pagetitle', $out->getHTMLTitle());
     $tpl->set('displaytitle', $out->mPageLinkTitle);
     $tpl->setRef('thispage', $this->thispage);
     $tpl->setRef('titleprefixeddbkey', $this->thispage);
     $tpl->set('titletext', $title->getText());
     $tpl->set('articleid', $title->getArticleId());
     $tpl->set('isarticle', $out->isArticle());
     $subpagestr = $this->subPageSubtitle();
     if ($subpagestr !== '') {
         $subpagestr = '<span class="subpages">' . $subpagestr . '</span>';
     }
     $tpl->set('subtitle', $subpagestr . $out->getSubtitle());
     $undelete = $this->getUndeleteLink();
     if ($undelete === '') {
         $tpl->set('undelete', '');
     } else {
         $tpl->set('undelete', '<span class="subpages">' . $undelete . '</span>');
     }
     $tpl->set('catlinks', $this->getCategories());
     if ($out->isSyndicated()) {
         $feeds = array();
         foreach ($out->getSyndicationLinks() as $format => $link) {
             $feeds[$format] = array('text' => $this->msg("feed-{$format}")->text(), 'href' => $link);
         }
         $tpl->setRef('feeds', $feeds);
     } else {
         $tpl->set('feeds', false);
     }
     $tpl->setRef('mimetype', $wgMimeType);
     $tpl->setRef('jsmimetype', $wgJsMimeType);
     $tpl->set('charset', 'UTF-8');
     $tpl->setRef('wgScript', $wgScript);
     $tpl->setRef('skinname', $this->skinname);
     $tpl->set('skinclass', get_class($this));
     $tpl->setRef('skin', $this);
     $tpl->setRef('stylename', $this->stylename);
     $tpl->set('printable', $out->isPrintable());
     $tpl->set('handheld', $request->getBool('handheld'));
     $tpl->setRef('loggedin', $this->loggedin);
     $tpl->set('notspecialpage', !$title->isSpecialPage());
     /* XXX currently unused, might get useful later
     		$tpl->set( 'editable', ( !$title->isSpecialPage() ) );
     		$tpl->set( 'exists', $title->getArticleID() != 0 );
     		$tpl->set( 'watch', $title->userIsWatching() ? 'unwatch' : 'watch' );
     		$tpl->set( 'protect', count( $title->isProtected() ) ? 'unprotect' : 'protect' );
     		$tpl->set( 'helppage', $this->msg( 'helppage' )->text() );
     		*/
     $tpl->set('searchaction', $this->escapeSearchLink());
     $tpl->set('searchtitle', SpecialPage::getTitleFor('Search')->getPrefixedDBKey());
     $tpl->set('search', trim($request->getVal('search')));
     $tpl->setRef('stylepath', $wgStylePath);
     $tpl->setRef('articlepath', $wgArticlePath);
     $tpl->setRef('scriptpath', $wgScriptPath);
     $tpl->setRef('serverurl', $wgServer);
     $tpl->setRef('logopath', $wgLogo);
     $tpl->setRef('sitename', $wgSitename);
     $lang = $this->getLanguage();
     $userlang = $lang->getHtmlCode();
     $userdir = $lang->getDir();
     $tpl->set('lang', $userlang);
     $tpl->set('dir', $userdir);
     $tpl->set('rtl', $lang->isRTL());
     $tpl->set('capitalizeallnouns', $lang->capitalizeAllNouns() ? ' capitalize-all-nouns' : '');
     $tpl->set('showjumplinks', $user->getOption('showjumplinks'));
     $tpl->set('username', $this->loggedin ? $this->username : null);
     $tpl->setRef('userpage', $this->userpage);
     $tpl->setRef('userpageurl', $this->userpageUrlDetails['href']);
     $tpl->set('userlang', $userlang);
     // Users can have their language set differently than the
     // content of the wiki. For these users, tell the web browser
     // that interface elements are in a different language.
     $tpl->set('userlangattributes', '');
     $tpl->set('specialpageattributes', '');
     # obsolete
     if ($userlang !== $wgContLang->getHtmlCode() || $userdir !== $wgContLang->getDir()) {
         $escUserlang = htmlspecialchars($userlang);
         $escUserdir = htmlspecialchars($userdir);
         // Attributes must be in double quotes because htmlspecialchars() doesn't
         // escape single quotes
         $attrs = " lang=\"{$escUserlang}\" dir=\"{$escUserdir}\"";
         $tpl->set('userlangattributes', $attrs);
     }
     wfProfileOut(__METHOD__ . '-stuff2');
     wfProfileIn(__METHOD__ . '-stuff3');
     $tpl->set('newtalk', $this->getNewtalks());
     $tpl->set('logo', $this->logoText());
     $tpl->set('copyright', false);
     $tpl->set('viewcount', false);
     $tpl->set('lastmod', false);
     $tpl->set('credits', false);
     $tpl->set('numberofwatchingusers', false);
     if ($out->isArticle() && $title->exists()) {
         if ($this->isRevisionCurrent()) {
             if (!$wgDisableCounters) {
                 $viewcount = $this->getWikiPage()->getCount();
                 if ($viewcount) {
                     $tpl->set('viewcount', $this->msg('viewcount')->numParams($viewcount)->parse());
                 }
             }
             if ($wgPageShowWatchingUsers) {
                 $dbr = wfGetDB(DB_SLAVE);
                 $num = $dbr->selectField('watchlist', 'COUNT(*)', array('wl_title' => $title->getDBkey(), 'wl_namespace' => $title->getNamespace()), __METHOD__);
                 if ($num > 0) {
                     $tpl->set('numberofwatchingusers', $this->msg('number_of_watching_users_pageview')->numParams($num)->parse());
                 }
             }
             if ($wgMaxCredits != 0) {
                 $tpl->set('credits', Action::factory('credits', $this->getWikiPage(), $this->getContext())->getCredits($wgMaxCredits, $wgShowCreditsIfMax));
             } else {
                 $tpl->set('lastmod', $this->lastModified());
             }
         }
         $tpl->set('copyright', $this->getCopyright());
     }
     wfProfileOut(__METHOD__ . '-stuff3');
     wfProfileIn(__METHOD__ . '-stuff4');
     $tpl->set('copyrightico', $this->getCopyrightIcon());
     $tpl->set('poweredbyico', $this->getPoweredBy());
     $tpl->set('disclaimer', $this->disclaimerLink());
     $tpl->set('privacy', $this->privacyLink());
     $tpl->set('about', $this->aboutLink());
     $tpl->set('footerlinks', array('info' => array('lastmod', 'viewcount', 'numberofwatchingusers', 'credits', 'copyright'), 'places' => array('privacy', 'about', 'disclaimer')));
     global $wgFooterIcons;
     $tpl->set('footericons', $wgFooterIcons);
     foreach ($tpl->data['footericons'] as $footerIconsKey => &$footerIconsBlock) {
         if (count($footerIconsBlock) > 0) {
             foreach ($footerIconsBlock as &$footerIcon) {
                 if (isset($footerIcon['src'])) {
                     if (!isset($footerIcon['width'])) {
                         $footerIcon['width'] = 88;
                     }
                     if (!isset($footerIcon['height'])) {
                         $footerIcon['height'] = 31;
                     }
                 }
             }
         } else {
             unset($tpl->data['footericons'][$footerIconsKey]);
         }
     }
     if ($wgDebugComments) {
         $tpl->setRef('debug', $out->mDebugtext);
     } else {
         $tpl->set('debug', '');
     }
     $tpl->set('sitenotice', $this->getSiteNotice());
     $tpl->set('bottomscripts', $this->bottomScripts());
     $tpl->set('printfooter', $this->printSource());
     # An ID that includes the actual body text; without categories, contentSub, ...
     $realBodyAttribs = array('id' => 'mw-content-text');
     # Add a mw-content-ltr/rtl class to be able to style based on text direction
     # when the content is different from the UI language, i.e.:
     # not for special pages or file pages AND only when viewing AND if the page exists
     # (or is in MW namespace, because that has default content)
     if (!in_array($title->getNamespace(), array(NS_SPECIAL, NS_FILE)) && in_array($request->getVal('action', 'view'), array('view', 'historysubmit')) && ($title->exists() || $title->getNamespace() == NS_MEDIAWIKI)) {
         $pageLang = $title->getPageLanguage();
         $realBodyAttribs['lang'] = $pageLang->getHtmlCode();
         $realBodyAttribs['dir'] = $pageLang->getDir();
         $realBodyAttribs['class'] = 'mw-content-' . $pageLang->getDir();
     }
     $out->mBodytext = Html::rawElement('div', $realBodyAttribs, $out->mBodytext);
     $tpl->setRef('bodytext', $out->mBodytext);
     # Language links
     $language_urls = array();
     if (!$wgHideInterlanguageLinks) {
         foreach ($out->getLanguageLinks() as $l) {
             $tmp = explode(':', $l, 2);
             $class = 'interwiki-' . $tmp[0];
             unset($tmp);
             $nt = Title::newFromText($l);
             if ($nt) {
                 $language_urls[] = array('href' => $nt->getFullURL(), 'text' => $wgContLang->getLanguageName($nt->getInterwiki()) != '' ? $wgContLang->getLanguageName($nt->getInterwiki()) : $l, 'title' => $nt->getText(), 'class' => $class, 'lang' => $nt->getInterwiki(), 'hreflang' => $nt->getInterwiki());
             }
         }
     }
     if (count($language_urls)) {
         $tpl->setRef('language_urls', $language_urls);
     } else {
         $tpl->set('language_urls', false);
     }
     wfProfileOut(__METHOD__ . '-stuff4');
     wfProfileIn(__METHOD__ . '-stuff5');
     # Personal toolbar
     $tpl->set('personal_urls', $this->buildPersonalUrls());
     $content_navigation = $this->buildContentNavigationUrls();
     $content_actions = $this->buildContentActionUrls($content_navigation);
     $tpl->setRef('content_navigation', $content_navigation);
     $tpl->setRef('content_actions', $content_actions);
     $tpl->set('sidebar', $this->buildSidebar());
     $tpl->set('nav_urls', $this->buildNavUrls());
     // Set the head scripts near the end, in case the above actions resulted in added scripts
     if ($this->useHeadElement) {
         $tpl->set('headelement', $out->headElement($this));
     } else {
         $tpl->set('headscripts', $out->getHeadScripts() . $out->getHeadItems());
     }
     $tpl->set('debughtml', $this->generateDebugHTML());
     $tpl->set('reporttime', wfReportTime());
     // original version by hansm
     if (!wfRunHooks('SkinTemplateOutputPageBeforeExec', array(&$this, &$tpl))) {
         wfDebug(__METHOD__ . ": Hook SkinTemplateOutputPageBeforeExec broke outputPage execution!\n");
     }
     // Set the bodytext to another key so that skins can just output it on it's own
     // and output printfooter and debughtml separately
     $tpl->set('bodycontent', $tpl->data['bodytext']);
     // Append printfooter and debughtml onto bodytext so that skins that were already
     // using bodytext before they were split out don't suddenly start not outputting information
     $tpl->data['bodytext'] .= Html::rawElement('div', array('class' => 'printfooter'), "\n{$tpl->data['printfooter']}") . "\n";
     $tpl->data['bodytext'] .= $tpl->data['debughtml'];
     // allow extensions adding stuff after the page content.
     // See Skin::afterContentHook() for further documentation.
     $tpl->set('dataAfterContent', $this->afterContentHook());
     wfProfileOut(__METHOD__ . '-stuff5');
     // execute template
     wfProfileIn(__METHOD__ . '-execute');
     $res = $tpl->execute();
     wfProfileOut(__METHOD__ . '-execute');
     // result may be an error
     $this->printOrError($res);
     if ($oldContext) {
         $this->setContext($oldContext);
     }
     wfProfileOut(__METHOD__);
 }
 /**
  * EditPage::showEditForm:fields hook
  *
  * Adds the event fields to the edit form
  *
  * @param EditPage $editPage the current EditPage object.
  * @param OutputPage $outputPage object.
  * @return bool
  */
 public static function editPageShowEditFormFields($editPage, $outputPage)
 {
     if ($editPage->contentModel !== CONTENT_MODEL_WIKITEXT) {
         return true;
     }
     $req = $outputPage->getContext()->getRequest();
     $editingStatsId = $req->getVal('editingStatsId');
     if (!$editingStatsId || !$req->wasPosted()) {
         $editingStatsId = self::getEditingStatsId();
     }
     $outputPage->addHTML(Xml::element('input', array('type' => 'hidden', 'name' => 'editingStatsId', 'id' => 'editingStatsId', 'value' => $editingStatsId)));
     return true;
 }
 private function manuscriptIsInViewMode(OutputPage $out)
 {
     $context = $out->getContext();
     if (Action::getActionName($context) !== 'view') {
         return false;
     }
     return true;
 }
Ejemplo n.º 11
0
 public function getContext()
 {
     return $this->out->getContext();
 }
Ejemplo n.º 12
0
 /**
  * initialize various variables and generate the template
  *
  * @param OutputPage $out
  */
 function outputPage(OutputPage $out = null)
 {
     wfProfileIn(__METHOD__);
     Profiler::instance()->setTemplated(true);
     $oldContext = null;
     if ($out !== null) {
         // @todo Add wfDeprecated in 1.20
         $oldContext = $this->getContext();
         $this->setContext($out->getContext());
     }
     $out = $this->getOutput();
     wfProfileIn(__METHOD__ . '-init');
     $this->initPage($out);
     wfProfileOut(__METHOD__ . '-init');
     $tpl = $this->prepareQuickTemplate($out);
     // execute template
     wfProfileIn(__METHOD__ . '-execute');
     $res = $tpl->execute();
     wfProfileOut(__METHOD__ . '-execute');
     // result may be an error
     $this->printOrError($res);
     if ($oldContext) {
         $this->setContext($oldContext);
     }
     wfProfileOut(__METHOD__);
 }