Ejemplo n.º 1
0
 /**
  * Perform a book information request and output the result
  * if available, or an error if appropriate
  *
  * @param string $isbn ISBN to be queried
  * @param OutputPage $output OutputPage object to use
  */
 public static function show($isbn, $output)
 {
     if (self::isValidISBN($isbn)) {
         $result = BookInformationCache::get($isbn);
         if ($result === false) {
             $driver = self::getDriver();
             if ($driver !== false) {
                 $result = $driver->submitRequest($isbn);
                 if ($result->isCacheable()) {
                     BookInformationCache::set($isbn, $result);
                 }
             } else {
                 $output->addHTML(self::makeError('nodriver'));
                 return;
             }
         }
         if ($result->getResponseCode() == BookInformationResult::RESPONSE_OK) {
             $output->addHTML(self::makeResult($result));
         } elseif ($result->getResponseCode() == BookInformationResult::RESPONSE_NOSUCHITEM) {
             $output->addHTML(self::makeError('nosuchitem'));
         } else {
             $output->addHTML(self::makeError('noresponse'));
         }
     } else {
         $output->addHTML(self::makeError('invalidisbn'));
     }
 }
Ejemplo n.º 2
0
 /**
  * @param $group MessageGroup
  */
 public function doModLangs($group)
 {
     global $wgLang;
     $languages = array_keys(Language::getLanguageNames(false));
     $modified = $codes = array();
     foreach ($languages as $code) {
         if ($code === 'en') {
             continue;
         }
         $cache = new MessageGroupCache($group, $code);
         if ($cache->isValid()) {
             continue;
         }
         $link = $this->skin->link($this->getTitle(), htmlspecialchars(TranslateUtils::getLanguageName($code, false, $wgLang->getCode()) . " ({$code})"), array(), array('group' => $group->getId(), 'language' => $code));
         if (!$cache->exists()) {
             $modified[] = wfMsgHtml('translate-manage-modlang-new', $link);
         } else {
             $modified[] = $link;
         }
         $codes[] = $code;
     }
     if (count($modified)) {
         $this->out->addWikiMsg('translate-manage-modlangs', $wgLang->formatNum(count($modified)));
         if ($this->user->isAllowed('translate-manage')) {
             $this->out->addHTML($this->rebuildButton($group, $codes, 'import'));
         }
         $this->out->addHTML('<ul><li>' . implode("</li>\n<li>", $modified) . '</li></ul>');
     }
 }
Ejemplo n.º 3
0
 /**
  * Show error message for missing or incorrect captcha on EditPage.
  * @param EditPage $editPage
  * @param OutputPage $out
  */
 function showEditFormFields(&$editPage, &$out)
 {
     $page = $editPage->getArticle()->getPage();
     if (!isset($page->ConfirmEdit_ActivateCaptcha)) {
         return;
     }
     unset($page->ConfirmEdit_ActivateCaptcha);
     $out->addHTML(Html::openElement('div', array('id' => 'mw-confirmedit-error-area', 'class' => 'errorbox')) . Html::element('strong', array(), $out->msg('errorpagetitle')->text()) . Html::element('div', array('id' => 'errorbox-body'), $out->msg('captcha-sendemail-fail')->text()) . Html::closeElement('div'));
     $this->showEditCaptcha = true;
 }
Ejemplo n.º 4
0
 /**
  * Show error message for missing or incorrect captcha on EditPage.
  * @param EditPage $editPage
  * @param OutputPage $out
  */
 function showEditFormFields(&$editPage, &$out)
 {
     $page = $editPage->getArticle()->getPage();
     if (!isset($page->ConfirmEdit_ActivateCaptcha)) {
         return;
     }
     if ($this->action !== 'edit') {
         unset($page->ConfirmEdit_ActivateCaptcha);
         $out->addWikiText($this->getMessage($this->action));
         $out->addHTML($this->getForm($out));
     }
 }
Ejemplo n.º 5
0
 /**
  * Format and output report results using the given information plus
  * OutputPage
  *
  * @param OutputPage $out OutputPage to print to
  * @param Skin $skin User skin to use [unused]
  * @param DatabaseBase $dbr (read) connection to use
  * @param int $res Result pointer
  * @param int $num Number of available result rows
  * @param int $offset Paging offset
  */
 protected function outputResults($out, $skin, $dbr, $res, $num, $offset)
 {
     if ($num > 0) {
         $gallery = new ImageGallery();
         # $res might contain the whole 1,000 rows, so we read up to
         # $num [should update this to use a Pager]
         for ($i = 0; $i < $num && ($row = $dbr->fetchObject($res)); $i++) {
             $namespace = isset($row->namespace) ? $row->namespace : NS_FILE;
             $title = Title::makeTitleSafe($namespace, $row->title);
             if ($title instanceof Title && $title->getNamespace() == NS_FILE) {
                 $gallery->add($title, $this->getCellHtml($row));
             }
         }
         $out->addHTML($gallery->toHtml());
     }
 }
Ejemplo n.º 6
0
 /**
  * Format and output report results using the given information plus
  * OutputPage
  *
  * @param OutputPage $out OutputPage to print to
  * @param Skin $skin User skin to use
  * @param Database $dbr Database (read) connection to use
  * @param int $res Result pointer
  * @param int $num Number of available result rows
  * @param int $offset Paging offset
  */
 protected function outputResults($out, $skin, $dbr, $res, $num, $offset)
 {
     if ($num > 0) {
         $gallery = new ImageGallery();
         $gallery->useSkin($skin);
         # $res might contain the whole 1,000 rows, so we read up to
         # $num [should update this to use a Pager]
         for ($i = 0; $i < $num && ($row = $dbr->fetchObject($res)); $i++) {
             $image = $this->prepareImage($row);
             if ($image) {
                 $gallery->add($image->getTitle(), $this->getCellHtml($row));
             }
         }
         $out->addHTML($gallery->toHtml());
     }
 }
Ejemplo n.º 7
0
 /**
  * Format and output report results using the given information plus
  * OutputPage
  *
  * @param OutputPage $out OutputPage to print to
  * @param Skin $skin User skin to use [unused]
  * @param DatabaseBase $dbr (read) connection to use
  * @param ResultWrapper $res Result pointer
  * @param int $num Number of available result rows
  * @param int $offset Paging offset
  */
 protected function outputResults($out, $skin, $dbr, $res, $num, $offset)
 {
     if ($num > 0) {
         $gallery = ImageGalleryBase::factory(false, $this->getContext());
         # $res might contain the whole 1,000 rows, so we read up to
         # $num [should update this to use a Pager]
         $i = 0;
         foreach ($res as $row) {
             $i++;
             $namespace = isset($row->namespace) ? $row->namespace : NS_FILE;
             $title = Title::makeTitleSafe($namespace, $row->title);
             if ($title instanceof Title && $title->getNamespace() == NS_FILE) {
                 $gallery->add($title, $this->getCellHtml($row));
             }
             if ($i === $num) {
                 break;
             }
         }
         $out->addHTML($gallery->toHtml());
     }
 }
Ejemplo n.º 8
0
 /**
  * Show options for the log list
  *
  * @param $types string or Array
  * @param $user String
  * @param $page String
  * @param $pattern String
  * @param $year Integer: year
  * @param $month Integer: month
  * @param $filter: array
  * @param $tagFilter: array?
  */
 public function showOptions($types = array(), $user = '', $page = '', $pattern = '', $year = '', $month = '', $filter = null, $tagFilter = '')
 {
     global $wgScript, $wgMiserMode;
     $action = $wgScript;
     $title = SpecialPage::getTitleFor('Log');
     $special = $title->getPrefixedDBkey();
     // For B/C, we take strings, but make sure they are converted...
     $types = $types === '' ? array() : (array) $types;
     $tagSelector = ChangeTags::buildTagFilterSelector($tagFilter);
     $html = Html::hidden('title', $special);
     // Basic selectors
     $html .= $this->getTypeMenu($types) . "\n";
     $html .= $this->getUserInput($user) . "\n";
     $html .= $this->getTitleInput($page) . "\n";
     $html .= $this->getExtraInputs($types) . "\n";
     // Title pattern, if allowed
     if (!$wgMiserMode) {
         $html .= $this->getTitlePattern($pattern) . "\n";
     }
     // date menu
     $html .= Xml::tags('p', null, Xml::dateMenu($year, $month));
     // Tag filter
     if ($tagSelector) {
         $html .= Xml::tags('p', null, implode('&#160;', $tagSelector));
     }
     // Filter links
     if ($filter) {
         $html .= Xml::tags('p', null, $this->getFilterLinks($filter));
     }
     // Submit button
     $html .= Xml::submitButton(wfMsg('allpagessubmit'));
     // Fieldset
     $html = Xml::fieldset(wfMsg('log'), $html);
     // Form wrapping
     $html = Xml::tags('form', array('action' => $action, 'method' => 'get'), $html);
     $this->out->addHTML($html);
 }
Ejemplo n.º 9
0
 /**
  * Show protection long extracts for this page
  *
  * @param OutputPage $out
  * @access private
  */
 function showLogExtract(&$out)
 {
     # Show relevant lines from the protection log:
     $protectLogPage = new LogPage('protect');
     $out->addHTML(Xml::element('h2', null, $protectLogPage->getName()->text()));
     LogEventsList::showLogExtract($out, 'protect', $this->mTitle);
     # Let extensions add other relevant log extracts
     Hooks::run('ProtectionForm::showLogExtract', [$this->mArticle, $out]);
 }
 /**
  * Wraps the provided html code in a div and outputs it to the page
  *
  * @param Title $title
  * @param ParserOutput $pout
  * @param OutputPage $out
  */
 private function showHtmlPreview(Title $title, ParserOutput $pout, OutputPage $out)
 {
     $lang = $title->getPageViewLanguage();
     $out->addHTML("<h2>" . $this->msg('expand_templates_preview')->escaped() . "</h2>\n");
     $out->addHTML(Html::openElement('div', array('class' => 'mw-content-' . $lang->getDir(), 'dir' => $lang->getDir(), 'lang' => $lang->getHtmlCode())));
     $out->addParserOutputContent($pout);
     $out->addHTML(Html::closeElement('div'));
 }
Ejemplo n.º 11
0
 /**
  * Render the supplied wiki text and append to the page as a preview
  *
  * @param Title $title
  * @param string $text
  * @param OutputPage $out
  */
 private function showHtmlPreview($title, $text, $out)
 {
     global $wgParser;
     $pout = $wgParser->parse($text, $title, new ParserOptions());
     $out->addHTML("<h2>" . wfMsgHtml('expand_templates_preview') . "</h2>\n");
     global $wgRawHtml, $wgRequest, $wgUser;
     if ($wgRawHtml) {
         // To prevent cross-site scripting attacks, don't show the preview if raw HTML is
         // allowed and a valid edit token is not provided (bug 71111). However, MediaWiki
         // does not currently provide logged-out users with CSRF protection; in that case,
         // do not show the preview unless anonymous editing is allowed.
         if ($wgUser->isAnon() && !$wgUser->isAllowed('edit')) {
             $error = array('expand_templates_preview_fail_html_anon');
         } elseif (!$wgUser->matchEditToken($wgRequest->getVal('wpEditToken'))) {
             $error = array('expand_templates_preview_fail_html');
         } else {
             $error = false;
         }
         if ($error) {
             $out->wrapWikiMsg("<div class='previewnote'>\n\$1\n</div>", $error);
             return;
         }
     }
     $out->addHTML($pout->getText());
 }
 /**
  * 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;
 }
 /**
  * Hook into Article::view() to provide syntax highlighting for
  * custom CSS and JavaScript pages
  *
  * @param string $text
  * @param Title $title
  * @param OutputPage $output
  * @return bool
  */
 public static function viewHook($text, $title, $output)
 {
     // Determine the language
     preg_match('!\\.(css|js)$!u', $title->getText(), $matches);
     $lang = $matches[1] == 'css' ? 'css' : 'javascript';
     // Attempt to format
     $geshi = self::prepare($text, $lang);
     if ($geshi instanceof GeSHi) {
         $out = $geshi->parse_code();
         if (!$geshi->error()) {
             // Done
             $output->addHeadItem("source-{$lang}", self::buildHeadItem($geshi));
             $output->addHTML("<div dir=\"ltr\">{$out}</div>");
             return false;
         }
     }
     // Bottle out
     return true;
 }
 /**
  * Wraps the provided html code in a div and outputs it to the page
  *
  * @param Title $title
  * @param string $html
  * @param OutputPage $out
  */
 private function showHtmlPreview(Title $title, $html, OutputPage $out)
 {
     $lang = $title->getPageViewLanguage();
     $out->addHTML("<h2>" . $this->msg('expand_templates_preview')->escaped() . "</h2>\n");
     global $wgRawHtml;
     if ($wgRawHtml) {
         $request = $this->getRequest();
         $user = $this->getUser();
         // To prevent cross-site scripting attacks, don't show the preview if raw HTML is
         // allowed and a valid edit token is not provided (bug 71111). However, MediaWiki
         // does not currently provide logged-out users with CSRF protection; in that case,
         // do not show the preview unless anonymous editing is allowed.
         if ($user->isAnon() && !$user->isAllowed('edit')) {
             $error = array('expand_templates_preview_fail_html_anon');
         } elseif (!$user->matchEditToken($request->getVal('wpEditToken'), '', $request)) {
             $error = array('expand_templates_preview_fail_html');
         } else {
             $error = false;
         }
         if ($error) {
             $out->wrapWikiMsg("<div class='previewnote'>\n\$1\n</div>", $error);
             return;
         }
     }
     $out->addHTML(Html::openElement('div', array('class' => 'mw-content-' . $lang->getDir(), 'dir' => $lang->getDir(), 'lang' => $lang->getHtmlCode())));
     $out->addHTML($html);
     $out->addHTML(Html::closeElement('div'));
 }
Ejemplo n.º 15
0
 /**
  * Called when the normal wikitext editor is shown.
  * Inserts a 'veswitched' hidden field if requested by the client
  *
  * @param $editPage EditPage
  * @param $output OutputPage
  * @return boolean true
  */
 public static function onEditPageShowEditFormFields(EditPage $editPage, OutputPage $output)
 {
     $request = $output->getRequest();
     if ($request->getBool('veswitched')) {
         $output->addHTML(Xml::input('veswitched', false, '1', array('type' => 'hidden')));
     }
     return true;
 }
Ejemplo n.º 16
0
 /**
  * Format and output report results using the given information plus
  * OutputPage
  *
  * @param OutputPage $out OutputPage to print to
  * @param Skin $skin User skin to use
  * @param IDatabase $dbr Database (read) connection to use
  * @param ResultWrapper $res Result pointer
  * @param int $num Number of available result rows
  * @param int $offset Paging offset
  */
 protected function outputResults($out, $skin, $dbr, $res, $num, $offset)
 {
     global $wgContLang;
     if ($num > 0) {
         $html = array();
         if (!$this->listoutput) {
             $html[] = $this->openList($offset);
         }
         # $res might contain the whole 1,000 rows, so we read up to
         # $num [should update this to use a Pager]
         // @codingStandardsIgnoreStart Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed
         for ($i = 0; $i < $num && ($row = $res->fetchObject()); $i++) {
             // @codingStandardsIgnoreEnd
             $line = $this->formatResult($skin, $row);
             if ($line) {
                 $attr = isset($row->usepatrol) && $row->usepatrol && $row->patrolled == 0 ? ' class="not-patrolled"' : '';
                 $html[] = $this->listoutput ? $line : "<li{$attr}>{$line}</li>\n";
             }
         }
         # Flush the final result
         if ($this->tryLastResult()) {
             $row = null;
             $line = $this->formatResult($skin, $row);
             if ($line) {
                 $attr = isset($row->usepatrol) && $row->usepatrol && $row->patrolled == 0 ? ' class="not-patrolled"' : '';
                 $html[] = $this->listoutput ? $line : "<li{$attr}>{$line}</li>\n";
             }
         }
         if (!$this->listoutput) {
             $html[] = $this->closeList();
         }
         $html = $this->listoutput ? $wgContLang->listToText($html) : implode('', $html);
         $out->addHTML($html);
     }
 }
Ejemplo n.º 17
0
 /**
  * @param OutputPage $out
  * @access private
  */
 function showLogExtract(&$out)
 {
     # Show relevant lines from the deletion log:
     $out->addHTML("<h2>" . htmlspecialchars(LogPage::logName('protect')) . "</h2>\n");
     require_once 'SpecialLog.php';
     $logViewer = new LogViewer(new LogReader(new FauxRequest(array('page' => $this->mTitle->getPrefixedText(), 'type' => 'protect'))));
     $logViewer->showList($out);
 }
	/**
	 * Hook into Article::view() to provide syntax highlighting for
	 * custom CSS and JavaScript pages.
	 *
	 * B/C for MW 1.20 and before. 1.21 and later use renderHook() instead.
	 *
	 * @param string $text
	 * @param Title $title
	 * @param OutputPage $output
	 * @return bool
	 */
	public static function viewHook( $text, $title, $output ) {
		global $wgUseSiteCss;
		// Determine the language
		$matches = array();
		preg_match( '!\.(css|js)$!u', $title->getText(), $matches );
		$lang = isset( $matches[1] ) && $matches[1] == 'css' ? 'css' : 'javascript';
		// Attempt to format
		$geshi = self::prepare( $text, $lang );
		if( $geshi instanceof GeSHi ) {
			$out = $geshi->parse_code();
			if( !$geshi->error() ) {
				// Done
				$output->addHeadItem( "source-$lang", self::buildHeadItem( $geshi ) );
				$output->addHTML( "<div dir=\"ltr\">{$out}</div>" );
				if( $wgUseSiteCss ) {
					$output->addModuleStyles( 'ext.geshi.local' );
				}
				return false;
			}
		}
		// Bottle out
		return true;
	}
 /**
  * Add hidden field with category metadata
  *
  * @param EditPage $editPage
  * @param OutputPage $out
  *
  * @return Boolean because it's a hook
  */
 public static function onEditPageShowEditFormFields($editPage, $out)
 {
     $out->addHTML(F::app()->renderView('CategorySelect', 'editPageMetadata'));
     return true;
 }
Ejemplo n.º 20
0
 /**
  * Print extra field for 'title'
  *
  * @param OutputPage $wgOut
  */
 public function renderFormHeader($wgOut)
 {
     global $wgRequest;
     $oTmpl = new EasyTemplate(dirname(__FILE__) . "/templates/");
     $oTmpl->set_vars(array("formErrors" => $this->mFormErrors, "formData" => $this->mFormData, "isReload" => $wgRequest->getVal('wpIsReload', 0) == 1, "editIntro" => $wgOut->parse($this->mEditIntro)));
     $wgOut->setPageTitle(wfMsg("createpage"));
     $wgOut->addScriptFile('edit.js');
     if ($this->mPreviewTitle == null) {
         $wgOut->addHTML('<div id="custom_createpagetext">');
         $wgOut->addWikiText(wfMsgForContent('newarticletext'));
         $wgOut->addHTML('</div>');
     }
     $wgOut->addHTML($oTmpl->render("createFormHeader"));
 }
 /**
  * Handles new pages to show error message and print message, that page does not exist.
  * @param OutputPage $out
  */
 protected function handleNewPages(OutputPage $out)
 {
     # Show error message
     $title = $this->getTitle();
     if (!$title->exists() && !$title->isSpecialPage() && $title->userCan('create', $this->getUser()) && $title->getNamespace() !== NS_FILE) {
         $out->clearHTML();
         $out->addHTML(Html::openElement('div', array('id' => 'mw-mf-newpage')) . wfMessage('mobile-frontend-editor-newpage-prompt')->parse() . Html::closeElement('div'));
     }
 }
Ejemplo n.º 22
0
/**
 * Add hidden field with category metadata
 *
 * @param EditPage $editPage
 * @param OutputPage $out
 *
 * @author Maciej Błaszkowski <marooned at wikia-inc.com>
 */
function CategorySelectAddFormFields($editPage, $out)
{
    global $wgCategorySelectMetaData;
    $categories = '';
    if (!empty($wgCategorySelectMetaData)) {
        $categories = htmlspecialchars(CategorySelectChangeFormat($wgCategorySelectMetaData['categories'], 'array', 'json'));
    }
    $out->addHTML("<input type=\"hidden\" value=\"{$categories}\" name=\"wpCategorySelectWikitext\" id=\"wpCategorySelectWikitext\" />");
    $out->addHTML('<input type="hidden" value="wiki" id="wpCategorySelectSourceType" name="wpCategorySelectSourceType" />');
    return true;
}
	public function execute( $messages ) {
		global $wgOut, $wgLang;

		$this->out = $wgOut;

		// Set up diff engine
		$diff = new DifferenceEngine;
		$diff->showDiffStyle();
		$diff->setReducedLineNumbers();

		// Check whether we do processing
		$process = $this->allowProcess();

		// Initialise collection
		$group = $this->getGroup();
		$code = $this->getCode();
		$collection = $group->initCollection( $code );
		$collection->loadTranslations();

		$this->out->addHTML( $this->doHeader() );

		// Determine changes
		$alldone = $process;
		$changed = array();

		foreach ( $messages as $key => $value ) {
			$fuzzy = $old = false;

			if ( isset( $collection[$key] ) ) {
				$old = $collection[$key]->translation();
			}

			// No changes at all, ignore
			if ( strval( $old ) === strval( $value ) ) {
				continue;
			}

			if ( $old === false ) {
				$name = wfMsgHtml( 'translate-manage-import-new',
					'<code style="font-weight:normal;">' . htmlspecialchars( $key ) . '</code>'
				);
				$text = TranslateUtils::convertWhiteSpaceToHTML( $value );
				$changed[] = self::makeSectionElement( $name, 'new', $text );
			} else {
				$diff->setText( $old, $value );
				$text = $diff->getDiff( '', '' );
				$type = 'changed';

				global $wgRequest;
				$action = $wgRequest->getVal( self::escapeNameForPHP( "action-$type-$key" ) );

				if ( $process ) {
					if ( !count( $changed ) ) {
						$changed[] = '<ul>';
					}

					if ( $action === null ) {
						$message = wfMsgExt( 'translate-manage-inconsistent', 'parseinline', wfEscapeWikiText( "action-$type-$key" ) );
						$changed[] = "<li>$message</li></ul>";
						$process = false;
					} else {
						// Check processing time
						if ( !isset( $this->time ) ) {
							$this->time = wfTimestamp();
						}

						$message = self::doAction(
							$action,
							$group,
							$key,
							$code,
							$value
						);

						$key = array_shift( $message );
						$params = $message;
						$message = wfMsgExt( $key, 'parseinline', $params );
						$changed[] = "<li>$message</li>";

						if ( $this->checkProcessTime() ) {
							$process = false;
							$duration = $wgLang->formatNum( $this->processingTime );
							$message = wfMsgExt( 'translate-manage-toolong', 'parseinline', $duration );
							$changed[] = "<li>$message</li></ul>";
						}
						continue;
					}
				}

				$alldone = false;

				$actions = $this->getActions();
				$defaction = $this->getDefaultAction( $fuzzy, $action );

				$act = array();

				foreach ( $actions as $action ) {
					$label = wfMsg( "translate-manage-action-$action" );
					$name = self::escapeNameForPHP( "action-$type-$key" );
					$id = Sanitizer::escapeId( "action-$key-$action" );
					$act[] = Xml::radioLabel( $label, $name, $action, $id, $action === $defaction );
				}

				$name = wfMsg( 'translate-manage-import-diff',
					'<code style="font-weight:normal;">' . htmlspecialchars( $key ) . '</code>',
					implode( ' ', $act )
				);

				$changed[] = self::makeSectionElement( $name, $type, $text );
			}
		}

		if ( !$process ) {
			$collection->filter( 'hastranslation', false );
			$keys = $collection->getMessageKeys();

			$diff = array_diff( $keys, array_keys( $messages ) );

			foreach ( $diff as $s ) {
				// @todo FIXME: Use CSS file.
				$name = wfMsgHtml( 'translate-manage-import-deleted',
					'<code style="font-weight:normal;">' . htmlspecialchars( $s ) . '</code>'
				);
				$text = TranslateUtils::convertWhiteSpaceToHTML(  $collection[$s]->translation() );
				$changed[] = self::makeSectionElement( $name, 'deleted', $text );
			}
		}

		if ( $process || ( !count( $changed ) && $code !== 'en' ) ) {
			if ( !count( $changed ) ) {
				$this->out->addWikiMsg( 'translate-manage-nochanges-other' );
			}

			if ( !count( $changed ) || strpos( $changed[count( $changed ) - 1], '<li>' ) !== 0 ) {
				$changed[] = '<ul>';
			}

			$message = wfMsgExt( 'translate-manage-import-done', 'parseinline' );
			$changed[] = "<li>$message</li></ul>";
			$this->out->addHTML( implode( "\n", $changed ) );
		} else {
			// END
			if ( count( $changed ) ) {
				if ( $code === 'en' ) {
					$this->out->addWikiMsg( 'translate-manage-intro-en' );
				} else {
					$lang = TranslateUtils::getLanguageName( $code, false, $wgLang->getCode() );
					$this->out->addWikiMsg( 'translate-manage-intro-other', $lang );
				}
				$this->out->addHTML( Html::hidden( 'language', $code ) );
				$this->out->addHTML( implode( "\n", $changed ) );
				$this->out->addHTML( Xml::submitButton( wfMsg( 'translate-manage-submit' ) ) );
			} else {
				$this->out->addWikiMsg( 'translate-manage-nochanges' );
			}
		}

		$this->out->addHTML( $this->doFooter() );
		return $alldone;
	}
 /**
  * Render the supplied wiki text and append to the page as a preview
  *
  * @param Title $title
  * @param string $text
  * @param OutputPage $out
  */
 private function showHtmlPreview($title, $text, $out)
 {
     global $wgParser;
     $pout = $wgParser->parse($text, $title, new ParserOptions());
     $out->addHTML("<h2>" . wfMsgHtml('expand_templates_preview') . "</h2>\n");
     $out->addHTML($pout->getText());
 }
Ejemplo n.º 25
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.º 26
0
 /**
  * If there are rows in the deletion log for this page, show them,
  * along with a nice little note for the user
  *
  * @param OutputPage $out
  */
 protected function showDeletionLog($out)
 {
     global $wgUser;
     $loglist = new LogEventsList($wgUser->getSkin(), $out);
     $pager = new LogPager($loglist, 'delete', false, $this->mTitle->getPrefixedText());
     $count = $pager->getNumRows();
     if ($count > 0) {
         $pager->mLimit = 10;
         $out->addHTML('<div class="mw-warning-with-logexcerpt">');
         $out->addWikiMsg('recreate-deleted-warn');
         $out->addHTML($loglist->beginLogEventsList() . $pager->getBody() . $loglist->endLogEventsList());
         if ($count > 10) {
             $out->addHTML($wgUser->getSkin()->link(SpecialPage::getTitleFor('Log'), wfMsgHtml('deletelog-fulllog'), array(), array('type' => 'delete', 'page' => $this->mTitle->getPrefixedText())));
         }
         $out->addHTML('</div>');
         return true;
     }
     return false;
 }
 /**
  * (a) Add a hidden field that has the rev ID the text is based off.
  * (b) If an edit was undone, add a hidden field that has the rev ID of that edit.
  * Needed for autoreview and user stats (for autopromote).
  * Note: baseRevId trusted for Reviewers - text checked for others.
  */
 public function addRevisionIDField(EditPage $editPage, OutputPage $out)
 {
     $revId = self::getBaseRevId($editPage, $this->getRequest());
     $out->addHTML("\n" . Html::hidden('baseRevId', $revId));
     $out->addHTML("\n" . Html::hidden('undidRev', empty($editPage->undidRev) ? 0 : $editPage->undidRev));
 }
Ejemplo n.º 28
0
 /**
  * Show a rights log fragment for the specified user
  *
  * @param User $user User to show log for
  * @param OutputPage $output OutputPage to use
  */
 protected function showLogFragment($user, $output)
 {
     $rightsLogPage = new LogPage('rights');
     $output->addHTML(Xml::element('h2', null, $rightsLogPage->getName()->text()));
     LogEventsList::showLogExtract($output, 'rights', $user->getUserPage());
 }
Ejemplo n.º 29
0
 /**
  * Insert the captcha prompt into an edit form.
  * @param OutputPage $out
  */
 function editCallback(&$out)
 {
     $out->addWikiText($this->getMessage($this->action));
     $out->addHTML($this->getForm());
     $this->addCSS(&$out);
 }
Ejemplo n.º 30
0
 /**
  * @param OutputPage $out
  * @access private
  */
 function showLogExtract(&$out)
 {
     # Show relevant lines from the protection log:
     $out->addHTML(Xml::element('h2', null, LogPage::logName('protect')));
     LogEventsList::showLogExtract($out, 'protect', $this->mTitle->getPrefixedText());
 }