protected function movePage(Title $oldPage, Title $newPage)
 {
     $mp = new MovePage($oldPage, $newPage);
     $valid = $mp->isValidMove();
     if (!$valid->isOK()) {
         wfDebugLog('CentralAuthRename', "Invalid page move: {$oldPage->getPrefixedText()} -> {$newPage->getPrefixedText()}");
         return;
     }
     $msg = wfMessage('centralauth-rename-movelog')->params($this->params['from'], $this->params['to'])->inContentLanguage()->text();
     $status = $mp->move($this->user, $msg, !$this->params['suppressredirects']);
     if (!$status->isOK()) {
         wfDebugLog('CentralAuthRename', "Page move failed: {$oldPage->getPrefixedText()} -> {$newPage->getPrefixedText()}");
     }
 }
 protected function getFooterMessages()
 {
     $parentUrl = $this->pageTitle->getFullURL('action=unwatch');
     $parentTitleText = $this->pageTitle->getPrefixedText();
     $footerMessages = [$this->getMessage('emailext-unfollow-text', $parentUrl, $parentTitleText)->parse()];
     return array_merge($footerMessages, parent::getFooterMessages());
 }
 protected function performAction()
 {
     $jobs = array();
     $target = $this->title;
     $base = $this->title->getPrefixedText();
     $translationPages = $this->getTranslationPages();
     $user = $this->getUser();
     foreach ($translationPages as $old) {
         $jobs[$old->getPrefixedText()] = TranslateDeleteJob::newJob($old, $base, !$this->singleLanguage(), $user);
     }
     $sectionPages = $this->getSectionPages();
     foreach ($sectionPages as $old) {
         $jobs[$old->getPrefixedText()] = TranslateDeleteJob::newJob($old, $base, !$this->singleLanguage(), $user);
     }
     if (!$this->doSubpages) {
         $subpages = $this->getSubpages();
         foreach ($subpages as $old) {
             if (TranslatablePage::isTranslationPage($old)) {
                 continue;
             }
             $jobs[$old->getPrefixedText()] = TranslateDeleteJob::newJob($old, $base, !$this->singleLanguage(), $user);
         }
     }
     JobQueueGroup::singleton()->push($jobs);
     $cache = wfGetCache(CACHE_DB);
     $cache->set(wfMemcKey('pt-base', $target->getPrefixedText()), array_keys($jobs), 60 * 60 * 6);
     if (!$this->singleLanguage()) {
         $this->page->unmarkTranslatablePage();
     }
     $this->clearMetadata();
     MessageGroups::singleton()->recache();
     MessageIndexRebuildJob::newJob()->insert();
     $this->getOutput()->addWikiMsg('pt-deletepage-started');
 }
 protected function performAction()
 {
     $jobs = array();
     $target = $this->title;
     $base = $this->title->getPrefixedText();
     $translationPages = $this->getTranslationPages();
     foreach ($translationPages as $old) {
         $jobs[$old->getPrefixedText()] = DeleteJob::newJob($old, $base, !$this->singleLanguage(), $this->user);
     }
     $sectionPages = $this->getSectionPages();
     foreach ($sectionPages as $old) {
         $jobs[$old->getPrefixedText()] = DeleteJob::newJob($old, $base, !$this->singleLanguage(), $this->user);
     }
     if (!$this->doSubpages) {
         $subpages = $this->getSubpages();
         foreach ($subpages as $old) {
             if (TranslatablePage::isTranslationPage($old)) {
                 continue;
             }
             $jobs[$old->getPrefixedText()] = DeleteJob::newJob($old, $base, !$this->singleLanguage(), $this->user);
         }
     }
     Job::batchInsert($jobs);
     $cache = wfGetCache(CACHE_DB);
     $cache->set(wfMemcKey('pt-base', $target->getPrefixedText()), array_keys($jobs), 60 * 60 * 6);
     if (!$this->singleLanguage()) {
         $this->page->removeTags();
     }
     MessageGroups::clearCache();
     MessageIndexRebuildJob::newJob()->insert();
     global $wgOut;
     $wgOut->addWikiMsg('pt-deletepage-started');
 }
 function whatlinkshereForm()
 {
     // We get nicer value from the title object
     $this->opts->consumeValue('target');
     // Reset these for new requests
     $this->opts->consumeValues(['back', 'from']);
     $target = $this->target ? $this->target->getPrefixedText() : '';
     $namespace = $this->opts->consumeValue('namespace');
     $nsinvert = $this->opts->consumeValue('invert');
     # Build up the form
     $f = Xml::openElement('form', ['action' => wfScript()]);
     # Values that should not be forgotten
     $f .= Html::hidden('title', $this->getPageTitle()->getPrefixedText());
     foreach ($this->opts->getUnconsumedValues() as $name => $value) {
         $f .= Html::hidden($name, $value);
     }
     $f .= Xml::fieldset($this->msg('whatlinkshere')->text());
     # Target input (.mw-searchInput enables suggestions)
     $f .= Xml::inputLabel($this->msg('whatlinkshere-page')->text(), 'target', 'mw-whatlinkshere-target', 40, $target, ['class' => 'mw-searchInput']);
     $f .= ' ';
     # Namespace selector
     $f .= Html::namespaceSelector(['selected' => $namespace, 'all' => '', 'label' => $this->msg('namespace')->text()], ['name' => 'namespace', 'id' => 'namespace', 'class' => 'namespaceselector']);
     $f .= ' ' . Xml::checkLabel($this->msg('invert')->text(), 'invert', 'nsinvert', $nsinvert, ['title' => $this->msg('tooltip-whatlinkshere-invert')->text()]);
     $f .= ' ';
     # Submit
     $f .= Xml::submitButton($this->msg('whatlinkshere-submit')->text());
     # Close
     $f .= Xml::closeElement('fieldset') . Xml::closeElement('form') . "\n";
     return $f;
 }
 public function doUpdate()
 {
     $job = new HTMLCacheUpdateJob($this->mTitle, array('table' => $this->mTable, 'recursive' => true) + Job::newRootJobParams("htmlCacheUpdate:{$this->mTable}:{$this->mTitle->getPrefixedText()}"));
     $count = $this->mTitle->getBacklinkCache()->getNumLinks($this->mTable, 100);
     if ($count >= 100) {
         // many backlinks
         JobQueueGroup::singleton()->lazyPush($job);
     } else {
         // few backlinks ($count might be off even if 0)
         $dbw = wfGetDB(DB_MASTER);
         $dbw->onTransactionIdle(function () use($job) {
             $job->run();
             // just do the purge query now
         });
     }
 }
Example #7
0
 /**
  * Get the appropriate HTML attributes to add to the "a" element of an in-
  * ternal link, given the Title object for the page we want to link to.
  *
  * @param Title  $nt     The Title object
  * @param string $unused Unused
  * @param string $class  The contents of the class attribute, default none
  * @param mixed  $title  Optional (unescaped) string to use in the title
  *   attribute; if false, default to the name of the page we're linking to
  */
 function getInternalLinkAttributesObj($nt, $unused = null, $class = '', $title = false)
 {
     if ($title === false) {
         $title = $nt->getPrefixedText();
     }
     return $this->getLinkAttributesInternal($title, $class);
 }
	/**
	 * @param Title $title
	 * @return array of SisterSiteLink
	 */
	function siblings( $title ) {
		$normal = self::normalize( $title->getPrefixedText() );
		$dbr = wfGetDB( DB_SLAVE );
		$result = $dbr->select(
			array( 'sistersites_page', 'sistersites_site' ),
			array(
				'ssp_url',
				'ssp_title',
				'sss_name',
				'sss_interwiki',
			),
			array(
				'ssp_normalized_title' => $normal,
				'ssp_site=sss_id',
			),
			__METHOD__ );
		
		$out = array();
		while( $row = $dbr->fetchObject( $result ) ) {
			$out[] = new SisterSitesLink( $row );
		}
		
		$dbr->freeResult( $result );
		return $out;
	}
 /**
  * Make a "what links here" link for a given title
  *
  * @param Title $title Title to make the link for
  * @param Skin $skin Skin to use
  * @param object $result Result row
  * @return string
  */
 private function makeWlhLink($title, $skin, $result)
 {
     global $wgLang;
     $wlh = SpecialPage::getTitleFor('Whatlinkshere');
     $label = wfMsgExt('nlinks', array('parsemag', 'escape'), $wgLang->formatNum($result->value));
     return $skin->link($wlh, $label, array(), array('target' => $title->getPrefixedText()));
 }
 function whatlinkshereForm()
 {
     global $wgScript;
     // We get nicer value from the title object
     $this->opts->consumeValue('target');
     // Reset these for new requests
     $this->opts->consumeValues(array('back', 'from'));
     $target = $this->target ? $this->target->getPrefixedText() : '';
     $namespace = $this->opts->consumeValue('namespace');
     # Build up the form
     $f = Xml::openElement('form', array('action' => $wgScript));
     # Values that should not be forgotten
     $f .= Html::hidden('title', $this->getTitle()->getPrefixedText());
     foreach ($this->opts->getUnconsumedValues() as $name => $value) {
         $f .= Html::hidden($name, $value);
     }
     $f .= Xml::fieldset(wfMsg('whatlinkshere'));
     # Target input
     $f .= Xml::inputLabel(wfMsg('whatlinkshere-page'), 'target', 'mw-whatlinkshere-target', 40, $target);
     $f .= ' ';
     # Namespace selector
     $f .= Xml::label(wfMsg('namespace'), 'namespace') . ' ' . Xml::namespaceSelector($namespace, '');
     $f .= ' ';
     # Submit
     $f .= Xml::submitButton(wfMsg('allpagessubmit'));
     # Close
     $f .= Xml::closeElement('fieldset') . Xml::closeElement('form') . "\n";
     return $f;
 }
Example #11
0
 private function watchTitle(Title $title, User $user, array $params, $compatibilityMode = false)
 {
     if (!$title->isWatchable()) {
         return array('title' => $title->getPrefixedText(), 'watchable' => 0);
     }
     $res = array('title' => $title->getPrefixedText());
     if ($params['unwatch']) {
         $status = UnwatchAction::doUnwatch($title, $user);
         $res['unwatched'] = $status->isOK();
         if ($status->isOK()) {
             $res['message'] = $this->msg('removedwatchtext', $title->getPrefixedText())->title($title)->parseAsBlock();
         }
     } else {
         $status = WatchAction::doWatch($title, $user);
         $res['watched'] = $status->isOK();
         if ($status->isOK()) {
             $res['message'] = $this->msg('addedwatchtext', $title->getPrefixedText())->title($title)->parseAsBlock();
         }
     }
     if (!$status->isOK()) {
         if ($compatibilityMode) {
             $this->dieStatus($status);
         }
         $res['error'] = $this->getErrorFromStatus($status);
     }
     return $res;
 }
	/**
	 * Delivers all ancestors of a given subpage.
	 * 
	 * @param Title $page The page to get the ancestors from.
	 * @param int   $depth Maximum depth back to the most distant ancestor relative from the given
	 *              subpage. If negative, that many elements from the top-level parent will be returend.
	 *              null means no limit.
	 * 
	 * @return Title[] All ancestor pages of the given subpage in order from the top-level ancestor
	 *                 to the direct parent.
	 */	 
	static function getAncestorPages( Title $page, $depth = null ) {
		$parts = preg_split( "/\//", $page->getPrefixedText(), 2 );	
		$rootPage = Title::newFromText( $parts[0] );
		$pageFamily = SubpageInfo::getSubpages( $rootPage );
		$pages = array();
		
		//A page can't be it's own parent AND only a existing page can be a parent:
		if( !( $rootPage->equals( $page ) ) && $rootPage->exists() ) {
			$pages[] = $rootPage;
		}
		
		if( ! empty( $pageFamily ) ) { // order is top-level parent to direct parent
			foreach( $pageFamily as &$relativePage ) {				
				if( SubpageInfo::isAncestorOf( $relativePage, $page ) ) {
					$pages[] = $relativePage;
				}
			}
		}
				
		if( $depth !== null ) {
			if( $depth <= 0 ) {
				$pages = array_slice( $pages, 0, -$depth );
			} else {
				$pages = array_slice( $pages, -$depth );
			}
		}
		
		return $pages;
	}	
 /**
  * Target URL for a link provided by a support button/aid.
  *
  * @param $title Title Title object for the translation message.
  * @since 2015.09
  */
 public static function getSupportUrl(Title $title)
 {
     global $wgTranslateSupportUrl, $wgTranslateSupportUrlNamespace;
     $namespace = $title->getNamespace();
     // Fetch the configuration for this namespace if possible, or the default.
     if (isset($wgTranslateSupportUrlNamespace[$namespace])) {
         $config = $wgTranslateSupportUrlNamespace[$namespace];
     } elseif ($wgTranslateSupportUrl) {
         $config = $wgTranslateSupportUrl;
     } else {
         throw new TranslationHelperException("Support page not configured");
     }
     // Preprocess params
     $params = array();
     if (isset($config['params'])) {
         foreach ($config['params'] as $key => $value) {
             $params[$key] = str_replace('%MESSAGE%', $title->getPrefixedText(), $value);
         }
     }
     // Return the URL or make one from the page
     if (isset($config['url'])) {
         return wfAppendQuery($config['url'], $params);
     } elseif (isset($config['page'])) {
         $page = Title::newFromText($config['page']);
         if (!$page) {
             throw new TranslationHelperException("Support page not configured properly");
         }
         return $page->getFullUrl($params);
     } else {
         throw new TranslationHelperException("Support page not configured properly");
     }
 }
 /**
  * @deprecated since 1.24
  * @param int $pageid
  * @param Title $title
  * @param Revision $rev
  * @return bool|string
  */
 public static function getRollbackToken($pageid, $title, $rev)
 {
     global $wgUser;
     if (!$wgUser->isAllowed('rollback')) {
         return false;
     }
     return $wgUser->getEditToken(array($title->getPrefixedText(), $rev->getUserText()));
 }
 /**
  * @covers LogFormatter::getIRCActionComment
  * @covers LogFormatter::getIRCActionText
  */
 public function testIrcMsgForLogTypeMove()
 {
     $move_params = array('4::target' => $this->target->getPrefixedText(), '5::noredir' => 0);
     $sep = $this->context->msg('colon-separator')->text();
     # move/move
     $this->assertIRCComment($this->context->msg('1movedto2', 'SomeTitle', 'TestTarget')->plain() . $sep . $this->user_comment, 'move', 'move', $move_params, $this->user_comment);
     # move/move_redir
     $this->assertIRCComment($this->context->msg('1movedto2_redir', 'SomeTitle', 'TestTarget')->plain() . $sep . $this->user_comment, 'move', 'move_redir', $move_params, $this->user_comment);
 }
Example #16
0
	/**
	 * @param $source Title
	 * @param $target Title
	 * @param $params array, should include base-source and base-target
	 * @param $performer
	 * @return MoveJob
	 */
	public static function newJob( Title $source, Title $target, array $params, /*User*/ $performer ) {
		$job = new self( $source );
		$job->setUser( FuzzyBot::getUser() );
		$job->setTarget( $target->getPrefixedText() );
		$job->setSummary( wfMsgForContent( 'pt-movepage-logreason', $params['base-source'] ) );
		$job->setParams( $params );
		$job->setPerformer( $performer );
		$job->lock();
		return $job;
	}
 public function doUpdate()
 {
     global $wgMaxBacklinksInvalidate;
     wfProfileIn(__METHOD__);
     $job = new HTMLCacheUpdateJob($this->mTitle, array('table' => $this->mTable) + Job::newRootJobParams("htmlCacheUpdate:{$this->mTable}:{$this->mTitle->getPrefixedText()}"));
     $count = $this->mTitle->getBacklinkCache()->getNumLinks($this->mTable, 200);
     if ($wgMaxBacklinksInvalidate !== false && $count > $wgMaxBacklinksInvalidate) {
         wfDebug("Skipped HTML cache invalidation of {$this->mTitle->getPrefixedText()}.");
     } elseif ($count >= 200) {
         // many backlinks
         JobQueueGroup::singleton()->push($job);
         JobQueueGroup::singleton()->deduplicateRootJob($job);
     } else {
         // few backlinks ($count might be off even if 0)
         $job->run();
         // just do the purge query now
     }
     wfProfileOut(__METHOD__);
 }
 /**
  * Generate an IRC line corresponding to user unification/creation
  * @param Title $userpage
  * @param string $wikiID
  * @return string
  */
 public function getLine($userpage, $wikiID)
 {
     $title = IRCColourfulRCFeedFormatter::cleanupForIRC($userpage->getPrefixedText());
     $wikiID = IRCColourfulRCFeedFormatter::cleanupForIRC($wikiID);
     $url = $userpage->getCanonicalURL();
     $user = IRCColourfulRCFeedFormatter::cleanupForIRC($userpage->getText());
     # see http://www.irssi.org/documentation/formats for some colour codes. prefix is \003,
     # no colour (\003) switches back to the term default
     return "14[[07{$title}14]]4@{$wikiID}10 " . "02{$url} 5* 03{$user} 5*\n";
 }
Example #19
0
 /**
  * @return bool
  */
 function importOldRevision()
 {
     $dbw = wfGetDB(DB_MASTER);
     # Sneak a single revision into place
     $user = $this->getUserObj() ?: User::newFromName($this->getUser());
     if ($user) {
         $userId = intval($user->getId());
         $userText = $user->getName();
     } else {
         $userId = 0;
         $userText = $this->getUser();
         $user = new User();
     }
     // avoid memory leak...?
     Title::clearCaches();
     $page = WikiPage::factory($this->title);
     $page->loadPageData('fromdbmaster');
     if (!$page->exists()) {
         // must create the page...
         $pageId = $page->insertOn($dbw);
         $created = true;
         $oldcountable = null;
     } else {
         $pageId = $page->getId();
         $created = false;
         $prior = $dbw->selectField('revision', '1', ['rev_page' => $pageId, 'rev_timestamp' => $dbw->timestamp($this->timestamp), 'rev_user_text' => $userText, 'rev_comment' => $this->getComment()], __METHOD__);
         if ($prior) {
             // @todo FIXME: This could fail slightly for multiple matches :P
             wfDebug(__METHOD__ . ": skipping existing revision for [[" . $this->title->getPrefixedText() . "]], timestamp " . $this->timestamp . "\n");
             return false;
         }
     }
     if (!$pageId) {
         // This seems to happen if two clients simultaneously try to import the
         // same page
         wfDebug(__METHOD__ . ': got invalid $pageId when importing revision of [[' . $this->title->getPrefixedText() . ']], timestamp ' . $this->timestamp . "\n");
         return false;
     }
     // Select previous version to make size diffs correct
     // @todo This assumes that multiple revisions of the same page are imported
     // in order from oldest to newest.
     $prevId = $dbw->selectField('revision', 'rev_id', ['rev_page' => $pageId, 'rev_timestamp <= ' . $dbw->addQuotes($dbw->timestamp($this->timestamp))], __METHOD__, ['ORDER BY' => ['rev_timestamp DESC', 'rev_id DESC']]);
     # @todo FIXME: Use original rev_id optionally (better for backups)
     # Insert the row
     $revision = new Revision(['title' => $this->title, 'page' => $pageId, 'content_model' => $this->getModel(), 'content_format' => $this->getFormat(), 'text' => $this->getContent()->serialize($this->getFormat()), 'comment' => $this->getComment(), 'user' => $userId, 'user_text' => $userText, 'timestamp' => $this->timestamp, 'minor_edit' => $this->minor, 'parent_id' => $prevId]);
     $revision->insertOn($dbw);
     $changed = $page->updateIfNewerOn($dbw, $revision);
     if ($changed !== false && !$this->mNoUpdates) {
         wfDebug(__METHOD__ . ": running updates\n");
         // countable/oldcountable stuff is handled in WikiImporter::finishImportPage
         $page->doEditUpdates($revision, $user, ['created' => $created, 'oldcountable' => 'no-change']);
     }
     return true;
 }
Example #20
0
 private function watchTitle(Title $title, User $user, array $params, $compatibilityMode = false)
 {
     if (!$title->isWatchable()) {
         return array('title' => $title->getPrefixedText(), 'watchable' => 0);
     }
     $res = array('title' => $title->getPrefixedText());
     // Currently unnecessary, code to act as a safeguard against any change
     // in current behavior of uselang.
     // Copy from ApiParse
     $oldLang = null;
     if (isset($params['uselang']) && $params['uselang'] != $this->getContext()->getLanguage()->getCode()) {
         $oldLang = $this->getContext()->getLanguage();
         // Backup language
         $this->getContext()->setLanguage(Language::factory($params['uselang']));
     }
     if ($params['unwatch']) {
         $status = UnwatchAction::doUnwatch($title, $user);
         if ($status->isOK()) {
             $res['unwatched'] = '';
             $res['message'] = $this->msg('removedwatchtext', $title->getPrefixedText())->title($title)->parseAsBlock();
         }
     } else {
         $status = WatchAction::doWatch($title, $user);
         if ($status->isOK()) {
             $res['watched'] = '';
             $res['message'] = $this->msg('addedwatchtext', $title->getPrefixedText())->title($title)->parseAsBlock();
         }
     }
     if (!is_null($oldLang)) {
         $this->getContext()->setLanguage($oldLang);
         // Reset language to $oldLang
     }
     if (!$status->isOK()) {
         if ($compatibilityMode) {
             $this->dieStatus($status);
         }
         $res['error'] = $this->getErrorFromStatus($status);
     }
     return $res;
 }
 /**
  * @param $source Title
  * @param $target Title
  * @param $params array, should include base-source and base-target
  * @param $performer
  * @return TranslateMoveJob
  */
 public static function newJob(Title $source, Title $target, array $params, $performer)
 {
     $job = new self($source);
     $job->setUser(FuzzyBot::getUser());
     $job->setTarget($target->getPrefixedText());
     $summary = wfMessage('pt-movepage-logreason', $params['base-source']);
     $summary = $summary->inContentLanguage()->text();
     $job->setSummary($summary);
     $job->setParams($params);
     $job->setPerformer($performer);
     $job->lock();
     return $job;
 }
 protected function insertSource(Title $context, $sourceLanguage, $text)
 {
     $row = array('tms_lang' => $sourceLanguage, 'tms_len' => mb_strlen($text), 'tms_text' => $text, 'tms_context' => $context->getPrefixedText());
     $dbw = $this->getDB(DB_MASTER);
     $dbw->insert('translate_tms', $row, __METHOD__);
     $sid = $dbw->insertId();
     $fulltext = $this->filterForFulltext($sourceLanguage, $text);
     if (count($fulltext)) {
         $row = array('tmf_sid' => $sid, 'tmf_text' => implode(' ', $fulltext));
         $dbw->insert('translate_tmf', $row, __METHOD__);
     }
     return $sid;
 }
Example #23
0
    private function showHistory()
    {
        $this->showMergeForm();
        # List all stored revisions
        $revisions = new MergeHistoryPager($this, [], $this->mTargetObj, $this->mDestObj);
        $haveRevisions = $revisions && $revisions->getNumRows() > 0;
        $out = $this->getOutput();
        $titleObj = $this->getPageTitle();
        $action = $titleObj->getLocalURL(['action' => 'submit']);
        # Start the form here
        $top = Xml::openElement('form', ['method' => 'post', 'action' => $action, 'id' => 'merge']);
        $out->addHTML($top);
        if ($haveRevisions) {
            # Format the user-visible controls (comment field, submission button)
            # in a nice little table
            $table = Xml::openElement('fieldset') . $this->msg('mergehistory-merge', $this->mTargetObj->getPrefixedText(), $this->mDestObj->getPrefixedText())->parse() . Xml::openElement('table', ['id' => 'mw-mergehistory-table']) . '<tr>
						<td class="mw-label">' . Xml::label($this->msg('mergehistory-reason')->text(), 'wpComment') . '</td>
					<td class="mw-input">' . Xml::input('wpComment', 50, $this->mComment, ['id' => 'wpComment']) . '</td>
					</tr>
					<tr>
						<td>&#160;</td>
						<td class="mw-submit">' . Xml::submitButton($this->msg('mergehistory-submit')->text(), ['name' => 'merge', 'id' => 'mw-merge-submit']) . '</td>
					</tr>' . Xml::closeElement('table') . Xml::closeElement('fieldset');
            $out->addHTML($table);
        }
        $out->addHTML('<h2 id="mw-mergehistory">' . $this->msg('mergehistory-list')->escaped() . "</h2>\n");
        if ($haveRevisions) {
            $out->addHTML($revisions->getNavigationBar());
            $out->addHTML('<ul>');
            $out->addHTML($revisions->getBody());
            $out->addHTML('</ul>');
            $out->addHTML($revisions->getNavigationBar());
        } else {
            $out->addWikiMsg('mergehistory-empty');
        }
        # Show relevant lines from the merge log:
        $mergeLogPage = new LogPage('merge');
        $out->addHTML('<h2>' . $mergeLogPage->getName()->escaped() . "</h2>\n");
        LogEventsList::showLogExtract($out, 'merge', $this->mTargetObj);
        # When we submit, go by page ID to avoid some nasty but unlikely collisions.
        # Such would happen if a page was renamed after the form loaded, but before submit
        $misc = Html::hidden('targetID', $this->mTargetObj->getArticleID());
        $misc .= Html::hidden('destID', $this->mDestObj->getArticleID());
        $misc .= Html::hidden('target', $this->mTarget);
        $misc .= Html::hidden('dest', $this->mDest);
        $misc .= Html::hidden('wpEditToken', $this->getUser()->getEditToken());
        $misc .= Xml::closeElement('form');
        $out->addHTML($misc);
        return true;
    }
	/**
	 * create whole list using makeListItem
	 * @param $titles Array all page titles
	 * @param $token string the token symbol:
	 *  - * for ul,
	 *  - # for ol
	 *  - ยท for horizontal lists
	 * @return string the whole list
	 * @see SubPageList::makeListItem
	 */
	function makeList( $titles ) {
		$c = 0;
		# add parent item
		if ($this->showparent) {
			$pn = '[[' . $this->ptitle->getPrefixedText() .'|'. $this->ptitle->getText() .']]';
			if( $this->mode != 'bar' ) {
				$pn = $this->token . $pn;
			}
			$ss = trim($pn);
			$list[] = $ss;
			$c++; // flag for bar token to be added on next item
		}
		# add descendents
		$parlv = substr_count($this->ptitle->getPrefixedText(), '/');
		$list = array();
		foreach( $titles as $title ) {
			$lv = substr_count($title, '/') - $parlv;
			if ( $this->kidsonly!=1 || $lv < 2 ) {
				if ($this->showparent) {
					$lv++;
				}
				$ss = "";
				if( $this->mode == 'bar' ) {
					if( $c>0) {
						$ss .= $this->token;
					}
				} else {
					for ( $i = 0; $i < $lv; $i++ ) {
						$ss .= $this->token;
					}
				}
				$ss .= $this->makeListItem( $title );
				$ss = trim( $ss );  // make sure we don't get any <pre></pre> tags
				$list[] = $ss;
			}
			$c++;
			if ( $c > 200 ) {
				break;
			}
		}
		$retval = '';
		if( count( $list ) > 0 ) {
			$retval = implode( "\n", $list );
			if ( $this->mode == 'bar' ) {
				$retval = implode( "", $list );
			}
		}

		return $retval;
	}
 /**
  * Render the page with a list of languages the page is available in
  * @param string $pagename The name of the page
  */
 public function executeWhenAvailable($pagename)
 {
     if (!is_string($pagename) || $pagename === '') {
         wfHttpError(404, $this->msg('mobile-frontend-languages-404-title')->text(), $this->msg('mobile-frontend-languages-404-desc')->text());
         return;
     }
     $this->title = Title::newFromText($pagename);
     $output = $this->getOutput();
     $html = '';
     if ($this->title && $this->title->exists()) {
         $titlename = $this->title->getPrefixedText();
         $pageTitle = $this->msg('mobile-frontend-languages-header-page', $titlename)->text();
         $languages = $this->getLanguages();
         $variants = $this->getLanguageVariants();
         $languagesCount = count($languages);
         $variantsCount = count($variants);
         $html .= Html::element('p', array(), $this->msg('mobile-frontend-languages-text')->params($titlename)->numParams($languagesCount)->text());
         $html .= Html::openElement('p');
         $html .= Html::element('a', array('href' => $this->title->getLocalUrl()), $this->msg('returnto', $titlename)->text());
         $html .= Html::closeElement('p');
         if ($languagesCount > 0 || $variantsCount > 1) {
             // Language variants first
             if ($variantsCount > 1) {
                 $variantHeader = $variantsCount > 1 ? $this->msg('mobile-frontend-languages-variant-header')->text() : '';
                 $html .= Html::element('h2', array('id' => 'mw-mf-language-variant-header'), $variantHeader);
                 $html .= Html::openElement('ul', array('id' => 'mw-mf-language-variant-selection'));
                 foreach ($variants as $val) {
                     $html .= $this->makeLangListItem($val);
                 }
                 $html .= Html::closeElement('ul');
             }
             // Then other languages
             if ($languagesCount > 0) {
                 $languageHeader = $this->msg('mobile-frontend-languages-header')->text();
                 $html .= Html::element('h2', array('id' => 'mw-mf-language-header'), $languageHeader) . Html::openElement('ul', array('id' => 'mw-mf-language-selection'));
                 foreach ($languages as $val) {
                     $html .= $this->makeLangListItem($val);
                 }
                 $html .= Html::closeElement('ul');
             }
         }
     } else {
         $pageTitle = $this->msg('mobile-frontend-languages-header')->text();
         $html .= Html::element('p', array(), $this->msg('mobile-frontend-languages-nonexistent-title')->params($pagename)->text());
     }
     $html = MobileUI::contentElement($html);
     $output->setPageTitle($pageTitle);
     $output->addHTML($html);
 }
 /**
  * @param Title $title
  * @param string $submodule
  * @param array $request
  * @param bool $requiredBlock
  * @return array
  * @throws MWException
  */
 public function flowApi(Title $title, $submodule, array $request, $requiredBlock = false)
 {
     $request = new FauxRequest($request + array('action' => 'flow', 'submodule' => $submodule, 'page' => $title->getPrefixedText()));
     $api = new ApiMain($request);
     $api->execute();
     $flowData = $api->getResult()->getResultData(array('flow', $submodule, 'result'));
     if ($flowData === null) {
         throw new MWException("API response has no Flow data");
     }
     $flowData = ApiResult::stripMetadata($flowData);
     if ($requiredBlock !== false && !isset($flowData[$requiredBlock])) {
         throw new MWException("No {$requiredBlock} block in API response");
     }
     return $flowData;
 }
 protected function makePageLink(Title $title = null, $parameters = array())
 {
     global $wgContLang, $wgUserrightsInterwikiDelimiter;
     if (!$this->plaintext) {
         $text = $wgContLang->ucfirst($title->getText());
         $parts = explode($wgUserrightsInterwikiDelimiter, $text, 2);
         if (count($parts) === 2) {
             $titleLink = WikiMap::foreignUserLink($parts[1], $parts[0], htmlspecialchars($title->getPrefixedText()));
             if ($titleLink !== false) {
                 return $titleLink;
             }
         }
     }
     return parent::makePageLink($title, $parameters);
 }
 /**
  * Gets the HTML fragment for a watched page.
  *
  * @param Title $title The title of the watched page
  * @param int $ts When the page was last touched
  * @param string $thumb An HTML fragment for the page's thumbnaiL
  * @return string
  */
 public static function getLineHtml(Title $title, $ts, $thumb)
 {
     $titleText = $title->getPrefixedText();
     if ($ts) {
         $ts = new MWTimestamp($ts);
         $lastModified = wfMessage('mobile-frontend-watchlist-modified', $ts->getHumanTimestamp())->text();
         $className = 'title';
     } else {
         $className = 'title new';
         $lastModified = '';
     }
     $html = Html::openElement('li', array('class' => 'page-summary', 'title' => $titleText, 'data-id' => $title->getArticleId())) . Html::openElement('a', array('href' => $title->getLocalUrl(), 'class' => $className));
     $html .= $thumb;
     $html .= Html::element('h3', array(), $titleText) . Html::element('div', array('class' => 'info'), $lastModified) . Html::closeElement('a') . Html::closeElement('li');
     return $html;
 }
	/**
	 * Displays current poll actions links.
	 */
	function showPollActionsList( $pid, $poll_id, Title $poll_title ) {
		global $wgContLang;
		return wfMsg(
			'qp_results_line_qpl',
			# pagename
			qp_Setup::specialchars( $wgContLang->convert( $poll_title->getPrefixedText() ) ),
			# polltitle
			qp_Setup::specialchars( $poll_id ),
			# goto link
			$this->qpLink( $poll_title, wfMsg( 'qp_source_link' ) ),
			# voices link
			$this->qpLink( $this->getTitle(), wfMsg( 'qp_stats_link' ), array(), array( "id" => intval( $pid ), "action" => "stats" ) ),
			# users link
			$this->qpLink( $this->getTitle(), wfMsg( 'qp_users_link' ), array(), array( "id" => intval( $pid ), "action" => "pulist" ) ),
			# not participated link
			$this->qpLink( $this->getTitle(), wfMsg( 'qp_not_participated_link' ), array(), array( "id" => intval( $pid ), "action" => "npulist" ) )
		);
	}
 /**
  * Call the stock "user is blocked" page
  */
 function blockedPage()
 {
     global $wgOut;
     $wgOut->blockedPage(false);
     # Standard block notice on the top, don't 'return'
     # If the user made changes, preserve them when showing the markup
     # (This happens when a user is blocked during edit, for instance)
     $first = $this->firsttime || !$this->save && $this->textbox1 == '';
     if ($first) {
         $source = $this->mTitle->exists() ? $this->getContent() : false;
     } else {
         $source = $this->textbox1;
     }
     # Spit out the source or the user's modified version
     if ($source !== false) {
         $wgOut->addHTML('<hr />');
         $wgOut->addWikiMsg($first ? 'blockedoriginalsource' : 'blockededitsource', $this->mTitle->getPrefixedText());
         $this->showTextbox1(array('readonly'), $source);
     }
 }