/**
  * Returns HTML of terms of use link or null if it shouldn't be displayed
  * Note: This is called by a hook in the WikimediaMessages extension.
  *
  * @param Skin $sk
  * @param string $urlMsgKey Key of i18n message containing terms of use URL (optional)
  * @return null|string
  */
 public static function getTermsLink($sk, $urlMsgKey = 'mobile-frontend-terms-url')
 {
     $urlMsg = $sk->msg($urlMsgKey)->inContentLanguage();
     if ($urlMsg->isDisabled()) {
         return null;
     }
     $url = $urlMsg->plain();
     return Html::element('a', array('href' => Skin::makeInternalOrExternalUrl($url)), $sk->msg('mobile-frontend-terms-text')->text());
 }
Ejemplo n.º 2
0
 protected function showStandardInputs(&$tabindex = 2)
 {
     global $wgOut;
     $wgOut->addHTML("<div class='editOptions'>\n");
     if ($this->section != 'new') {
         $this->showSummaryInput(false, $this->summary);
         $wgOut->addHTML($this->getSummaryPreview(false, $this->summary));
     }
     $checkboxes = $this->getCheckboxes($tabindex, array('minor' => $this->minoredit, 'watch' => $this->watchthis));
     // wikia change begin, @author eloy
     wfRunHooks('EditPage::showEditForm:checkboxes', array(&$this, &$checkboxes));
     // wikia change end
     $wgOut->addHTML("<div class='editCheckboxes'>" . implode($checkboxes, "\n") . "</div>\n");
     $wgOut->addHTML("<div class='editButtons'>\n");
     $wgOut->addHTML(implode($this->getEditButtons($tabindex), "\n") . "\n");
     $cancel = $this->getCancelLink();
     if ($cancel !== '') {
         $cancel .= wfMsgExt('pipe-separator', 'escapenoentities');
     }
     $edithelpurl = Skin::makeInternalOrExternalUrl(wfMsgForContent('edithelppage'));
     $edithelp = '<a target="helpwindow" href="' . $edithelpurl . '">' . htmlspecialchars(wfMsg('edithelp')) . '</a> ' . htmlspecialchars(wfMsg('newwindow'));
     $wgOut->addHTML("\t<span class='editHelp'>{$cancel}{$edithelp}</span>\n");
     $wgOut->addHTML("</div><!-- editButtons -->\n</div><!-- editOptions -->\n");
 }
Ejemplo n.º 3
0
 protected function showStandardInputs(&$tabindex = 2)
 {
     global $wgOut, $wgUseMediaWikiUIEverywhere;
     $wgOut->addHTML("<div class='editOptions'>\n");
     if ($this->section != 'new') {
         $this->showSummaryInput(false, $this->summary);
         $wgOut->addHTML($this->getSummaryPreview(false, $this->summary));
     }
     $checkboxes = $this->getCheckboxes($tabindex, array('minor' => $this->minoredit, 'watch' => $this->watchthis));
     $wgOut->addHTML("<div class='editCheckboxes'>" . implode($checkboxes, "\n") . "</div>\n");
     // Show copyright warning.
     $wgOut->addWikiText($this->getCopywarn());
     $wgOut->addHTML($this->editFormTextAfterWarn);
     $wgOut->addHTML("<div class='editButtons'>\n");
     $wgOut->addHTML(implode($this->getEditButtons($tabindex), "\n") . "\n");
     $cancel = $this->getCancelLink();
     if ($cancel !== '') {
         $cancel .= Html::element('span', array('class' => 'mw-editButtons-pipe-separator'), wfMessage('pipe-separator')->text());
     }
     $message = wfMessage('edithelppage')->inContentLanguage()->text();
     $edithelpurl = Skin::makeInternalOrExternalUrl($message);
     $attrs = array('target' => 'helpwindow', 'href' => $edithelpurl);
     if ($wgUseMediaWikiUIEverywhere) {
         $attrs['class'] = 'mw-ui-button mw-ui-quiet';
     }
     $edithelp = Html::element('a', $attrs, wfMessage('edithelp')->text()) . wfMessage('word-separator')->escaped() . wfMessage('newwindow')->parse();
     $wgOut->addHTML("\t<span class='cancelLink'>{$cancel}</span>\n");
     $wgOut->addHTML("\t<span class='editHelp'>{$edithelp}</span>\n");
     $wgOut->addHTML("</div><!-- editButtons -->\n");
     wfRunHooks('EditPage::showStandardInputs:options', array($this, $wgOut, &$tabindex));
     $wgOut->addHTML("</div><!-- editOptions -->\n");
 }
Ejemplo n.º 4
0
	function execute() {
		global $wgCookieExpiration;
		$expirationDays = ceil( $wgCookieExpiration / ( 3600 * 24 ) );
?>
<div class="mw-ui-container">
	<?php if ( $this->haveData( 'languages' ) ) { ?>
		<div id="languagelinks">
			<p><?php $this->html( 'languages' ); ?></p>
		</div>
	<?php } ?>
	<div id="userloginForm">
		<form name="userlogin" class="mw-ui-vform" method="post" action="<?php $this->text( 'action' ); ?>">
			<?php if ( $this->data['loggedin'] ) { ?>
				<div class="warningbox">
					<?php echo $this->getMsg( 'userlogin-loggedin' )->params( $this->data['loggedinuser'] )->parse(); ?>
				</div>
			<?php } ?>
			<section class="mw-form-header">
				<?php $this->html( 'header' ); /* extensions such as ConfirmEdit add form HTML here */ ?>
			</section>

			<?php if ( $this->data['message'] ) { ?>
				<div class="<?php $this->text( 'messagetype' ); ?>box">
					<?php if ( $this->data['messagetype'] == 'error' ) { ?>
						<strong><?php $this->msg( 'loginerror' ); ?></strong>
						<br />
					<?php } ?>
					<?php $this->html( 'message' ); ?>
				</div>
			<?php } ?>

			<div>
				<label for='wpName1'>
					<?php
					$this->msg( 'userlogin-yourname' );

					if ( $this->data['secureLoginUrl'] ) {
						echo Html::element( 'a', array(
							'href' => $this->data['secureLoginUrl'],
							'class' => 'mw-ui-flush-right mw-secure',
						), $this->getMsg( 'userlogin-signwithsecure' )->text() );
					}
					?>
				</label>
				<?php
				$extraAttrs = array();
				echo Html::input( 'wpName', $this->data['name'], 'text', array(
					'class' => 'loginText',
					'id' => 'wpName1',
					'tabindex' => '1',
					'size' => '20',
					// 'required' is blacklisted for now in Html.php due to browser issues.
					// Keeping here in case that changes.
					'required' => true,
					// Set focus to this field if it's blank.
					'autofocus' => !$this->data['name'],
					'placeholder' => $this->getMsg( 'userlogin-yourname-ph' )->text()
				) );
				?>
			</div>

			<div>
				<label for='wpPassword1'>
					<?php
					$this->msg( 'userlogin-yourpassword' );

					if ( $this->data['useemail'] && $this->data['canreset'] && $this->data['resetlink'] === true ) {
						echo ' ' . Linker::link(
							SpecialPage::getTitleFor( 'PasswordReset' ),
							$this->getMsg( 'userlogin-resetpassword-link' )->parse(),
							array( 'class' => 'mw-ui-flush-right' )
						);
					}
					?>
				</label>
				<?php
				echo Html::input( 'wpPassword', null, 'password', array(
					'class' => 'loginPassword',
					'id' => 'wpPassword1',
					'tabindex' => '2',
					'size' => '20',
					// Set focus to this field if username is filled in.
					'autofocus' => (bool)$this->data['name'],
					'placeholder' => $this->getMsg( 'userlogin-yourpassword-ph' )->text()
				) );
				?>
			</div>

			<?php
			if ( isset( $this->data['usedomain'] ) && $this->data['usedomain'] ) {
				$doms = "";
				foreach ( $this->data['domainnames'] as $dom ) {
					$doms .= "<option>" . htmlspecialchars( $dom ) . "</option>";
				}
			?>
				<div id="mw-user-domain-section">
					<label for='wpDomain'><?php $this->msg( 'yourdomainname' ); ?></label>
					<select name="wpDomain" value="<?php $this->text( 'domain' ); ?>" tabindex="3">
						<?php echo $doms; ?>
					</select>
				</div>
			<?php } ?>

			<?php
			if ( $this->haveData( 'extrafields' ) ) {
				echo $this->data['extrafields'];
			}
			?>

			<div>
				<?php if ( $this->data['canremember'] ) { ?>
					<label class="mw-ui-checkbox-label">
						<input name="wpRemember" type="checkbox" value="1" id="wpRemember" tabindex="4"
							<?php if ( $this->data['remember'] ) {
								echo 'checked="checked"';
							} ?>
						>
						<?php echo $this->getMsg( 'userlogin-remembermypassword' )->numParams( $expirationDays )->escaped(); ?>
					</label>
				<?php } ?>
			</div>

			<div>
				<?php
				echo Html::input( 'wpLoginAttempt', $this->getMsg( 'login' )->text(), 'submit', array(
					'id' => 'wpLoginAttempt',
					'tabindex' => '6',
					'class' => 'mw-ui-button mw-ui-big mw-ui-block mw-ui-primary'
				) );
				?>
			</div>
			<div id="mw-userlogin-help">
				<?php
				echo Html::element(
					'a',
					array(
						'href' => Skin::makeInternalOrExternalUrl(
							wfMessage( 'helplogin-url' )->inContentLanguage()->text()
						),
					),
					$this->getMsg( 'userlogin-helplink2' )->text()
				);
				?>
			</div>
			<?php if ( $this->haveData( 'createOrLoginHref' ) ) { ?>
				<?php if ( $this->data['loggedin'] ) { ?>
					<div id="mw-createaccount-another">
						<h3 id="mw-userloginlink"><a href="<?php $this->text( 'createOrLoginHref' ); ?>" id="mw-createaccount-join" tabindex="7"  class="mw-ui-button"><?php $this->msg( 'userlogin-createanother' ); ?></a></h3>
					</div>
				<?php } else { ?>
					<div id="mw-createaccount-cta">
						<h3 id="mw-userloginlink"><?php $this->msg( 'userlogin-noaccount' ); ?><a href="<?php $this->text( 'createOrLoginHref' ); ?>" id="mw-createaccount-join" tabindex="7"  class="mw-ui-button mw-ui-constructive"><?php $this->msg( 'userlogin-joinproject' ); ?></a></h3>
					</div>
				<?php } ?>
			<?php } ?>
			<?php if ( $this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
			<?php if ( $this->haveData( 'token' ) ) { ?><input type="hidden" name="wpLoginToken" value="<?php $this->text( 'token' ); ?>" /><?php } ?>
			<?php if ( $this->data['cansecurelogin'] ) {?><input type="hidden" name="wpForceHttps" value="<?php $this->text( 'stickhttps' ); ?>" /><?php } ?>
		</form>
	</div>
</div>
<?php

	}
Ejemplo n.º 5
0
 protected function showStandardInputs(&$tabindex = 2)
 {
     global $wgOut;
     $wgOut->addHTML("<div class='editOptions'>\n");
     if ($this->section != 'new') {
         $this->showSummaryInput(false, $this->summary);
         $wgOut->addHTML($this->getSummaryPreview(false, $this->summary));
     }
     $checkboxes = $this->getCheckboxes($tabindex, array('minor' => $this->minoredit, 'watch' => $this->watchthis));
     $wgOut->addHTML("<div class='editCheckboxes'>" . implode($checkboxes, "\n") . "</div>\n");
     // Show copyright warning.
     $wgOut->addWikiText($this->getCopywarn());
     $wgOut->addHTML($this->editFormTextAfterWarn);
     $wgOut->addHTML("<div class='editButtons'>\n");
     $wgOut->addHTML(implode($this->getEditButtons($tabindex), "\n") . "\n");
     $cancel = $this->getCancelLink();
     if ($cancel !== '') {
         $cancel .= wfMessage('pipe-separator')->text();
     }
     $edithelpurl = Skin::makeInternalOrExternalUrl(wfMessage('edithelppage')->inContentLanguage()->text());
     $edithelp = '<a target="helpwindow" href="' . $edithelpurl . '">' . wfMessage('edithelp')->escaped() . '</a> ' . wfMessage('newwindow')->parse();
     $wgOut->addHTML("\t<span class='cancelLink'>{$cancel}</span>\n");
     $wgOut->addHTML("\t<span class='editHelp'>{$edithelp}</span>\n");
     $wgOut->addHTML("</div><!-- editButtons -->\n");
     wfRunHooks('EditPage::showStandardInputs:options', array($this, $wgOut, &$tabindex));
     $wgOut->addHTML("</div><!-- editOptions -->\n");
 }
Ejemplo n.º 6
0
    /**
     * Send the edit form and related headers to $wgOut
     * @param $formCallback Optional callable that takes an OutputPage
     *                      parameter; will be called during form output
     *                      near the top, for captchas and the like.
     */
    function showEditForm($formCallback = null)
    {
        global $wgOut, $wgUser, $wgLang, $wgContLang, $wgMaxArticleSize, $wgTitle;
        $fname = 'EditPage::showEditForm';
        wfProfileIn($fname);
        $sk = $wgUser->getSkin();
        wfRunHooks('EditPage::showEditForm:initial', array(&$this));
        $wgOut->setRobotpolicy('noindex,nofollow');
        # Enabled article-related sidebar, toplinks, etc.
        $wgOut->setArticleRelated(true);
        if ($this->formtype == 'preview') {
            $wgOut->setPageTitleActionText(wfMsg('preview'));
        }
        if ($this->isConflict) {
            $s = wfMsg('editconflict', $wgTitle->getPrefixedText());
            $wgOut->setPageTitle($s);
            $wgOut->addWikiMsg('explainconflict');
            $this->textbox2 = $this->textbox1;
            $this->textbox1 = $this->getContent();
            $this->edittime = $this->mArticle->getTimestamp();
        } else {
            if ($this->section != '') {
                if ($this->section == 'new') {
                    $s = wfMsg('editingcomment', $wgTitle->getPrefixedText());
                } else {
                    $s = wfMsg('editingsection', $wgTitle->getPrefixedText());
                    $matches = array();
                    if (!$this->summary && !$this->preview && !$this->diff) {
                        preg_match("/^(=+)(.+)\\1/mi", $this->textbox1, $matches);
                        if (!empty($matches[2])) {
                            global $wgParser;
                            $this->summary = "/* " . $wgParser->stripSectionName(trim($matches[2])) . " */ ";
                        }
                    }
                }
            } else {
                $s = wfMsg('editing', $wgTitle->getPrefixedText());
            }
            $wgOut->setPageTitle($s);
            if ($this->missingComment) {
                $wgOut->wrapWikiMsg('<div id="mw-missingcommenttext">$1</div>', 'missingcommenttext');
            }
            if ($this->missingSummary && $this->section != 'new') {
                $wgOut->wrapWikiMsg('<div id="mw-missingsummary">$1</div>', 'missingsummary');
            }
            if ($this->missingSummary && $this->section == 'new') {
                $wgOut->wrapWikiMsg('<div id="mw-missingcommentheader">$1</div>', 'missingcommentheader');
            }
            if ($this->hookError !== '') {
                $wgOut->addWikiText($this->hookError);
            }
            if (!$this->checkUnicodeCompliantBrowser()) {
                $wgOut->addWikiMsg('nonunicodebrowser');
            }
            if (isset($this->mArticle) && isset($this->mArticle->mRevision)) {
                // Let sysop know that this will make private content public if saved
                if (!$this->mArticle->mRevision->userCan(Revision::DELETED_TEXT)) {
                    $wgOut->addWikiMsg('rev-deleted-text-permission');
                } else {
                    if ($this->mArticle->mRevision->isDeleted(Revision::DELETED_TEXT)) {
                        $wgOut->addWikiMsg('rev-deleted-text-view');
                    }
                }
                if (!$this->mArticle->mRevision->isCurrent()) {
                    $this->mArticle->setOldSubtitle($this->mArticle->mRevision->getId());
                    $wgOut->addWikiMsg('editingold');
                }
            }
        }
        if (wfReadOnly()) {
            $wgOut->addHTML('<div id="mw-read-only-warning">' . wfMsgWikiHTML('readonlywarning') . '</div>');
        } elseif ($wgUser->isAnon() && $this->formtype != 'preview') {
            $wgOut->addHTML('<div id="mw-anon-edit-warning">' . wfMsgWikiHTML('anoneditwarning') . '</div>');
        } else {
            if ($this->isCssJsSubpage && $this->formtype != 'preview') {
                # Check the skin exists
                if ($this->isValidCssJsSubpage) {
                    $wgOut->addWikiMsg('usercssjsyoucanpreview');
                } else {
                    $wgOut->addWikiMsg('userinvalidcssjstitle', $wgTitle->getSkinFromCssJsSubpage());
                }
            }
        }
        if ($this->mTitle->getNamespace() == NS_MEDIAWIKI) {
            # Show a warning if editing an interface message
            $wgOut->addWikiMsg('editinginterface');
        } elseif ($this->mTitle->isProtected('edit')) {
            # Is the title semi-protected?
            if ($this->mTitle->isSemiProtected()) {
                $noticeMsg = 'semiprotectedpagewarning';
            } else {
                # Then it must be protected based on static groups (regular)
                $noticeMsg = 'protectedpagewarning';
            }
            $wgOut->addWikiMsg($noticeMsg);
        }
        if ($this->mTitle->isCascadeProtected()) {
            # Is this page under cascading protection from some source pages?
            list($cascadeSources, ) = $this->mTitle->getCascadeProtectionSources();
            $notice = "\$1\n";
            if (count($cascadeSources) > 0) {
                # Explain, and list the titles responsible
                foreach ($cascadeSources as $page) {
                    $notice .= '* [[:' . $page->getPrefixedText() . "]]\n";
                }
            }
            $wgOut->wrapWikiMsg($notice, array('cascadeprotectedwarning', count($cascadeSources)));
        }
        if (!$this->mTitle->exists() && $this->mTitle->getRestrictions('create') != array()) {
            $wgOut->addWikiMsg('titleprotectedwarning');
        }
        if ($this->kblength === false) {
            $this->kblength = (int) (strlen($this->textbox1) / 1024);
        }
        if ($this->tooBig || $this->kblength > $wgMaxArticleSize) {
            $wgOut->addWikiMsg('longpageerror', $wgLang->formatNum($this->kblength), $wgMaxArticleSize);
        } elseif ($this->kblength > 29) {
            $wgOut->addWikiMsg('longpagewarning', $wgLang->formatNum($this->kblength));
        }
        #need to parse the preview early so that we know which templates are used,
        #otherwise users with "show preview after edit box" will get a blank list
        if ($this->formtype == 'preview') {
            $previewOutput = $this->getPreviewText();
        }
        $rows = $wgUser->getIntOption('rows');
        $cols = $wgUser->getIntOption('cols');
        $ew = $wgUser->getOption('editwidth');
        if ($ew) {
            $ew = " style=\"width:100%\"";
        } else {
            $ew = '';
        }
        $q = 'action=submit';
        #if ( "no" == $redirect ) { $q .= "&redirect=no"; }
        $action = $wgTitle->escapeLocalURL($q);
        $summary = wfMsg('summary');
        $subject = wfMsg('subject');
        $cancel = $sk->makeKnownLink($wgTitle->getPrefixedText(), wfMsgExt('cancel', array('parseinline')));
        $edithelpurl = Skin::makeInternalOrExternalUrl(wfMsgForContent('edithelppage'));
        $edithelp = '<a target="helpwindow" href="' . $edithelpurl . '">' . htmlspecialchars(wfMsg('edithelp')) . '</a> ' . htmlspecialchars(wfMsg('newwindow'));
        global $wgRightsText;
        if ($wgRightsText) {
            $copywarnMsg = array('copyrightwarning', '[[' . wfMsgForContent('copyrightpage') . ']]', $wgRightsText);
        } else {
            $copywarnMsg = array('copyrightwarning2', '[[' . wfMsgForContent('copyrightpage') . ']]');
        }
        if ($wgUser->getOption('showtoolbar') and !$this->isCssJsSubpage) {
            # prepare toolbar for edit buttons
            $toolbar = $this->getEditToolbar();
        } else {
            $toolbar = '';
        }
        // activate checkboxes if user wants them to be always active
        if (!$this->preview && !$this->diff) {
            # Sort out the "watch" checkbox
            if ($wgUser->getOption('watchdefault')) {
                # Watch all edits
                $this->watchthis = true;
            } elseif ($wgUser->getOption('watchcreations') && !$this->mTitle->exists()) {
                # Watch creations
                $this->watchthis = true;
            } elseif ($this->mTitle->userIsWatching()) {
                # Already watched
                $this->watchthis = true;
            }
            if ($wgUser->getOption('minordefault')) {
                $this->minoredit = true;
            }
        }
        $wgOut->addHTML($this->editFormPageTop);
        if ($wgUser->getOption('previewontop')) {
            if ('preview' == $this->formtype) {
                $this->showPreview($previewOutput);
            } else {
                $wgOut->addHTML('<div id="wikiPreview"></div>');
            }
            if ('diff' == $this->formtype) {
                $this->showDiff();
            }
        }
        $wgOut->addHTML($this->editFormTextTop);
        # if this is a comment, show a subject line at the top, which is also the edit summary.
        # Otherwise, show a summary field at the bottom
        $summarytext = htmlspecialchars($wgContLang->recodeForEdit($this->summary));
        # FIXME
        if ($this->section == 'new') {
            $commentsubject = "<span id='wpSummaryLabel'><label for='wpSummary'>{$subject}:</label></span>\n<div class='editOptions'>\n<input tabindex='1' type='text' value=\"{$summarytext}\" name='wpSummary' id='wpSummary' maxlength='200' size='60' /><br />";
            $editsummary = '';
            $subjectpreview = $summarytext && $this->preview ? "<div class=\"mw-summary-preview\">" . wfMsg('subject-preview') . ':' . $sk->commentBlock($this->summary, $this->mTitle) . "</div>\n" : '';
            $summarypreview = '';
        } else {
            $commentsubject = '';
            $editsummary = "<span id='wpSummaryLabel'><label for='wpSummary'>{$summary}:</label></span>\n<div class='editOptions'>\n<input tabindex='2' type='text' value=\"{$summarytext}\" name='wpSummary' id='wpSummary' maxlength='200' size='60' /><br />";
            $summarypreview = $summarytext && $this->preview ? "<div class=\"mw-summary-preview\">" . wfMsg('summary-preview') . ':' . $sk->commentBlock($this->summary, $this->mTitle) . "</div>\n" : '';
            $subjectpreview = '';
        }
        # Set focus to the edit box on load, except on preview or diff, where it would interfere with the display
        if (!$this->preview && !$this->diff) {
            $wgOut->setOnloadHandler('document.editform.wpTextbox1.focus()');
        }
        $templates = $this->preview || $this->section != '' ? $this->mPreviewTemplates : $this->mArticle->getUsedTemplates();
        $formattedtemplates = $sk->formatTemplates($templates, $this->preview, $this->section != '');
        global $wgUseMetadataEdit;
        if ($wgUseMetadataEdit) {
            $metadata = $this->mMetaData;
            $metadata = htmlspecialchars($wgContLang->recodeForEdit($metadata));
            $top = wfMsgWikiHtml('metadata_help');
            $metadata = $top . "<textarea name='metadata' rows='3' cols='{$cols}'{$ew}>{$metadata}</textarea>";
        } else {
            $metadata = "";
        }
        $hidden = '';
        $recreate = '';
        if ($this->deletedSinceEdit) {
            if ('save' != $this->formtype) {
                $wgOut->addWikiMsg('deletedwhileediting');
            } else {
                // Hide the toolbar and edit area, use can click preview to get it back
                // Add an confirmation checkbox and explanation.
                $toolbar = '';
                $hidden = 'type="hidden" style="display:none;"';
                $recreate = $wgOut->parse(wfMsg('confirmrecreate', $this->lastDelete->user_name, $this->lastDelete->log_comment));
                $recreate .= "<br /><input tabindex='1' type='checkbox' value='1' name='wpRecreate' id='wpRecreate' />" . "<label for='wpRecreate' title='" . wfMsg('tooltip-recreate') . "'>" . wfMsg('recreate') . "</label>";
            }
        }
        $tabindex = 2;
        $checkboxes = self::getCheckboxes($tabindex, $sk, array('minor' => $this->minoredit, 'watch' => $this->watchthis));
        $checkboxhtml = implode($checkboxes, "\n");
        $buttons = $this->getEditButtons($tabindex);
        $buttonshtml = implode($buttons, "\n");
        $safemodehtml = $this->checkUnicodeCompliantBrowser() ? '' : Xml::hidden('safemode', '1');
        $wgOut->addHTML(<<<END
{$toolbar}
<form id="editform" name="editform" method="post" action="{$action}" enctype="multipart/form-data">
END
);
        if (is_callable($formCallback)) {
            call_user_func_array($formCallback, array(&$wgOut));
        }
        wfRunHooks('EditPage::showEditForm:fields', array(&$this, &$wgOut));
        // Put these up at the top to ensure they aren't lost on early form submission
        $wgOut->addHTML("\n<input type='hidden' value=\"" . htmlspecialchars($this->section) . "\" name=\"wpSection\" />\n<input type='hidden' value=\"{$this->starttime}\" name=\"wpStarttime\" />\n\n<input type='hidden' value=\"{$this->edittime}\" name=\"wpEdittime\" />\n\n<input type='hidden' value=\"{$this->scrolltop}\" name=\"wpScrolltop\" id=\"wpScrolltop\" />\n");
        $wgOut->addHTML(<<<END
{$recreate}
{$commentsubject}
{$subjectpreview}
{$this->editFormTextBeforeContent}
<textarea tabindex='1' accesskey="," name="wpTextbox1" id="wpTextbox1" rows='{$rows}'
cols='{$cols}'{$ew} {$hidden}>
END
 . htmlspecialchars($this->safeUnicodeOutput($this->textbox1)) . "\n</textarea>\n\t\t");
        $wgOut->wrapWikiMsg("<div id=\"editpage-copywarn\">\n\$1\n</div>", $copywarnMsg);
        $wgOut->addHTML($this->editFormTextAfterWarn);
        $wgOut->addHTML("\n{$metadata}\n{$editsummary}\n{$summarypreview}\n{$checkboxhtml}\n{$safemodehtml}\n");
        $wgOut->addHTML("<div class='editButtons'>\n{$buttonshtml}\n\t<span class='editHelp'>{$cancel} | {$edithelp}</span>\n</div><!-- editButtons -->\n</div><!-- editOptions -->");
        $wgOut->addHtml('<div class="mw-editTools">');
        $wgOut->addWikiMsgArray('edittools', array(), array('content'));
        $wgOut->addHtml('</div>');
        $wgOut->addHTML($this->editFormTextAfterTools);
        $wgOut->addHTML("\n<div class='templatesUsed'>\n{$formattedtemplates}\n</div>\n");
        /**
         * To make it harder for someone to slip a user a page
         * which submits an edit form to the wiki without their
         * knowledge, a random token is associated with the login
         * session. If it's not passed back with the submission,
         * we won't save the page, or render user JavaScript and
         * CSS previews.
         *
         * For anon editors, who may not have a session, we just
         * include the constant suffix to prevent editing from
         * broken text-mangling proxies.
         */
        $token = htmlspecialchars($wgUser->editToken());
        $wgOut->addHTML("\n<input type='hidden' value=\"{$token}\" name=\"wpEditToken\" />\n");
        # If a blank edit summary was previously provided, and the appropriate
        # user preference is active, pass a hidden tag here. This will stop the
        # user being bounced back more than once in the event that a summary
        # is not required.
        if ($this->missingSummary) {
            $wgOut->addHTML("<input type=\"hidden\" name=\"wpIgnoreBlankSummary\" value=\"1\" />\n");
        }
        # For a bit more sophisticated detection of blank summaries, hash the
        # automatic one and pass that in a hidden field.
        $autosumm = $this->autoSumm ? $this->autoSumm : md5($this->summary);
        $wgOut->addHtml(wfHidden('wpAutoSummary', $autosumm));
        if ($this->isConflict) {
            $wgOut->wrapWikiMsg('==$1==', "yourdiff");
            $de = new DifferenceEngine($this->mTitle);
            $de->setText($this->textbox2, $this->textbox1);
            $de->showDiff(wfMsg("yourtext"), wfMsg("storedversion"));
            $wgOut->wrapWikiMsg('==$1==', "yourtext");
            $wgOut->addHTML("<textarea tabindex='6' id='wpTextbox2' name=\"wpTextbox2\" rows='{$rows}' cols='{$cols}'>" . htmlspecialchars($this->safeUnicodeOutput($this->textbox2)) . "\n</textarea>");
        }
        $wgOut->addHTML($this->editFormTextBottom);
        $wgOut->addHTML("</form>\n");
        if (!$wgUser->getOption('previewontop')) {
            if ($this->formtype == 'preview') {
                $this->showPreview($previewOutput);
            } else {
                $wgOut->addHTML('<div id="wikiPreview"></div>');
            }
            if ($this->formtype == 'diff') {
                $this->showDiff();
            }
        }
        wfProfileOut($fname);
    }
Ejemplo n.º 7
0
function efIcon_Render(&$parser, $img, $alt = null, $width = null, $page = null)
{
    $ititle = Title::newFromText($img);
    // this really shouldn't happen... not much we can do here.
    if (!is_object($ititle)) {
        return '';
    }
    // add to parser image collection so it this shows up on the image's links/what links here voodoo
    $parser->mOutput->addImage($ititle->getDBkey());
    // check if we are dealing with an InterWiki link
    if ($ititle->isLocal()) {
        $image = wfFindFile($img);
        if (!$image) {
            return '[[Image:' . $img . ']]';
        }
        $iURL = $image->getURL();
    } else {
        $iURL = $ititle->getFullURL();
    }
    // Optional parameters
    if (empty($alt)) {
        $alt = '';
    } else {
        $alt = htmlspecialchars($alt);
    }
    if (!empty($width)) {
        $width = intval($width);
        if ($width > 0) {
            $thumb = $image->transform(array('width' => $width));
            if ($thumb->isError()) {
                $imageString = wfMsgHtml('icon-badimage');
            } else {
                $imageString = $thumb->toHtml(array('alt' => $alt, 'title' => $alt));
            }
        } else {
            $imageString = wfMsgHtml('icon-badwidth');
        }
    } else {
        $imageString = "<img class='iconimg' style=\"vertical-align: middle;\" src='{$iURL}' alt=\"{$alt}\" title=\"{$alt}\" />";
    }
    $output = $imageString;
    if (!empty($page)) {
        if (preg_match('/^(?:' . wfUrlProtocols() . ')/', $page)) {
            $tURL = Skin::makeInternalOrExternalUrl($page);
            $aClass = 'class="plainlinks iconlink"';
            $output = "<a " . $aClass . " href='{$tURL}'>{$imageString}</a>";
        } else {
            $ptitle = Title::newFromText($page);
            // this might happen in templates...
            if (is_object($ptitle)) {
                if ($ptitle->isLocal()) {
                    $tURL = $ptitle->getLocalUrl();
                    $aClass = 'class="iconlink"';
                } else {
                    $tURL = $ptitle->getFullURL();
                    $aClass = 'class="extiw iconlink"';
                }
                $output = "<a " . $aClass . " href='{$tURL}'>{$imageString}</a>";
            }
        }
    }
    return $parser->insertStripItem($output, $parser->mStripState);
}
Ejemplo n.º 8
0
 public function execute()
 {
     global $wgVisualEditorNamespaces, $wgVisualEditorParsoidURL, $wgVisualEditorParsoidTimeout, $wgDevelEnvironment;
     $user = $this->getUser();
     $params = $this->extractRequestParams();
     $page = Title::newFromText($params['page']);
     if (!$page) {
         $this->dieUsageMsg('invalidtitle', $params['page']);
     }
     if (!in_array($page->getNamespace(), $wgVisualEditorNamespaces)) {
         $this->dieUsage("VisualEditor is not enabled in namespace " . $page->getNamespace(), 'novenamespace');
     }
     $parserParams = array();
     if (isset($params['oldwt'])) {
         $parserParams['oldwt'] = $params['oldwt'];
     } else {
         if (isset($params['oldid'])) {
             $parserParams['oldid'] = $params['oldid'];
         }
     }
     switch ($params['paction']) {
         case 'parsewt':
             // FIXME: Perhaps requestParsoid method should be used here
             $postData = array('wt' => $params['wikitext']);
             $content = Http::post($wgVisualEditorParsoidURL . '/' . urlencode($this->getApiSource()) . '/' . urlencode($page->getPrefixedDBkey()), array('postData' => $postData, 'timeout' => $wgVisualEditorParsoidTimeout, 'noProxy' => !empty($wgDevelEnvironment)));
             $result = array('result' => 'success', 'content' => $content);
             break;
         case 'parse':
             $parsed = $this->getHTML($page, $parserParams);
             // Dirty hack to provide the correct context for edit notices
             global $wgTitle;
             // FIXME NOOOOOOOOES
             $wgTitle = $page;
             RequestContext::getMain()->setTitle($page);
             // TODO: In MW 1.19.7 method getEditNotices does not exist so for now fallback to just an empty
             // but in future figure out what's the proper backward compatibility solution.
             // #back-compat
             // $notices = $page->getEditNotices();
             $notices = array();
             $anoneditwarning = false;
             $anoneditwarningMessage = $this->msg('VisualEditor-anoneditwarning');
             if ($user->isAnon() && $anoneditwarningMessage->exists()) {
                 $notices[] = $anoneditwarningMessage->parseAsBlock();
                 $anoneditwarning = true;
             }
             if ($parsed && $parsed['restoring']) {
                 $notices[] = $this->msg('editingold')->parseAsBlock();
             }
             // Creating new page
             if (!$page->exists()) {
                 $notices[] = $this->msg($user->isLoggedIn() ? 'newarticletext' : 'newarticletextanon', Skin::makeInternalOrExternalUrl($this->msg('helppage')->inContentLanguage()->text()))->parseAsBlock();
                 // Page protected from creation
                 if ($page->getRestrictions('create')) {
                     $notices[] = $this->msg('titleprotectedwarning')->parseAsBlock();
                 }
             }
             // Look at protection status to set up notices + surface class(es)
             $protectedClasses = array();
             if (MWNamespace::getRestrictionLevels($page->getNamespace()) !== array('')) {
                 // Page protected from editing
                 if ($page->isProtected('edit')) {
                     # Is the title semi-protected?
                     if ($page->isSemiProtected()) {
                         $protectedClasses[] = 'mw-textarea-sprotected';
                         $noticeMsg = 'semiprotectedpagewarning';
                     } else {
                         $protectedClasses[] = 'mw-textarea-protected';
                         # Then it must be protected based on static groups (regular)
                         $noticeMsg = 'protectedpagewarning';
                     }
                     $notices[] = $this->msg($noticeMsg)->parseAsBlock();
                 }
                 // Deal with cascading edit protection
                 list($sources, $restrictions) = $page->getCascadeProtectionSources();
                 if (isset($restrictions['edit'])) {
                     $protectedClasses[] = ' mw-textarea-cprotected';
                     $notice = $this->msg('cascadeprotectedwarning')->parseAsBlock() . '<ul>';
                     // Unfortunately there's no nice way to get only the pages which cause
                     // editing to be restricted
                     foreach ($sources as $source) {
                         $notice .= "<li>" . Linker::link($source) . "</li>";
                     }
                     $notice .= '</ul>';
                     $notices[] = $notice;
                 }
             }
             // Show notice when editing user / user talk page of a user that doesn't exist
             // or who is blocked
             // HACK of course this code is partly duplicated from EditPage.php :(
             if ($page->getNamespace() == NS_USER || $page->getNamespace() == NS_USER_TALK) {
                 $parts = explode('/', $page->getText(), 2);
                 $targetUsername = $parts[0];
                 $targetUser = User::newFromName($targetUsername, false);
                 if (!($targetUser && $targetUser->isLoggedIn()) && !User::isIP($targetUsername)) {
                     // User does not exist
                     $notices[] = "<div class=\"mw-userpage-userdoesnotexist error\">\n" . $this->msg('userpage-userdoesnotexist', wfEscapeWikiText($targetUsername)) . "\n</div>";
                 }
                 // Some upstream code is deleted from here, more information:
                 // https://github.com/Wikia/app/commit/d54b481d3f6e5b092b212a2c98b2cb5452bee26c
                 // https://github.com/Wikia/app/commit/681e7437078206460f7c0cb1837095e656d8ba85
             }
             if (class_exists('GlobalBlocking')) {
                 $error = GlobalBlocking::getUserBlockErrors($user, $this->getRequest()->getIP());
                 if (count($error)) {
                     $notices[] = call_user_func_array(array($this, 'msg'), $error)->parseAsBlock();
                 }
             }
             // HACK: Build a fake EditPage so we can get checkboxes from it
             $article = new Article($page);
             // Deliberately omitting ,0 so oldid comes from request
             $ep = new EditPage($article);
             $req = $this->getRequest();
             $req->setVal('format', 'text/x-wiki');
             $ep->importFormData($req);
             // By reference for some reason (bug 52466)
             $tabindex = 0;
             $states = array('minor' => false, 'watch' => false);
             $checkboxes = $ep->getCheckboxes($tabindex, $states);
             // HACK: Find out which red links are on the page
             // We do the lookup for the current version. This might not be entirely complete
             // if we're loading an oldid, but it'll probably be close enough, and LinkCache
             // will automatically request any additional data it needs.
             $links = array();
             $wikipage = WikiPage::factory($page);
             $popts = $wikipage->makeParserOptions('canonical');
             $cached = ParserCache::singleton()->get($article, $popts, true);
             if ($cached) {
                 foreach ($cached->getLinks() as $ns => $dbks) {
                     foreach ($dbks as $dbk => $id) {
                         $links[Title::makeTitle($ns, $dbk)->getPrefixedText()] = array('missing' => $id == 0);
                     }
                 }
             }
             // On parser cache miss, just don't bother populating red link data
             if ($parsed === false) {
                 $this->dieUsage('Error contacting the Parsoid server', 'parsoidserver');
             } else {
                 $result = array_merge(array('result' => 'success', 'notices' => $notices, 'checkboxes' => $checkboxes, 'links' => $links, 'protectedClasses' => implode(' ', $protectedClasses), 'anoneditwarning' => $anoneditwarning), $parsed['result']);
             }
             break;
         case 'parsefragment':
             $content = $this->parseWikitextFragment($page, $params['wikitext']);
             if ($content === false) {
                 $this->dieUsage('Error contacting the Parsoid server', 'parsoidserver');
             } else {
                 $result = array('result' => 'success', 'content' => $content);
             }
             break;
         case 'serialize':
             if ($params['cachekey'] !== null) {
                 $content = $this->trySerializationCache($params['cachekey']);
                 if (!is_string($content)) {
                     $this->dieUsage('No cached serialization found with that key', 'badcachekey');
                 }
             } else {
                 if ($params['html'] === null) {
                     $this->dieUsageMsg('missingparam', 'html');
                 }
                 $html = $params['html'];
                 $content = $this->postHTML($page, $html, $parserParams);
                 if ($content === false) {
                     $this->dieUsage('Error contacting the Parsoid server', 'parsoidserver');
                 }
             }
             $result = array('result' => 'success', 'content' => $content);
             break;
         case 'diff':
             if ($params['cachekey'] !== null) {
                 $wikitext = $this->trySerializationCache($params['cachekey']);
                 if (!is_string($wikitext)) {
                     $this->dieUsage('No cached serialization found with that key', 'badcachekey');
                 }
             } else {
                 $wikitext = $this->postHTML($page, $params['html'], $parserParams);
                 if ($wikitext === false) {
                     $this->dieUsage('Error contacting the Parsoid server', 'parsoidserver');
                 }
             }
             $diff = $this->diffWikitext($page, $wikitext);
             if ($diff['result'] === 'fail') {
                 $this->dieUsage('Diff failed', 'difffailed');
             }
             $result = $diff;
             break;
         case 'serializeforcache':
             $key = $this->storeInSerializationCache($page, $parserParams['oldid'], $params['html']);
             $result = array('result' => 'success', 'cachekey' => $key);
             break;
         case 'getlanglinks':
             $langlinks = $this->getLangLinks($page);
             if ($langlinks === false) {
                 $this->dieUsage('Error querying MediaWiki API', 'parsoidserver');
             } else {
                 $result = array('result' => 'success', 'langlinks' => $langlinks);
             }
             break;
     }
     $this->getResult()->addValue(null, $this->getModuleName(), $result);
 }
Ejemplo n.º 9
0
    public function execute()
    {
        global $wgUser;
        global $wgForegroundFeatures;
        wfSuppressWarnings();
        $this->html('headelement');
        switch ($wgForegroundFeatures['NavWrapperType']) {
            case '0':
                break;
            case 'divonly':
                echo "<div id='navwrapper'>";
                break;
            default:
                echo "<div id='navwrapper' class='" . $wgForegroundFeatures['NavWrapperType'] . "'>";
                break;
        }
        // Set default variables for footer and switch them if 'showFooterIcons' => true
        $footerLeftClass = 'small-8 large-centered columns text-center';
        $footerRightClass = 'large-12 small-12 columns';
        $poweredbyType = "nocopyright";
        $poweredbyMakeType = 'withoutImage';
        switch ($wgForegroundFeatures['showFooterIcons']) {
            case true:
                $footerLeftClass = 'large-8 small-12 columns';
                $footerRightClass = 'large-4 small-12 columns';
                $poweredbyType = "icononly";
                $poweredbyMakeType = 'withImage';
                break;
            default:
                break;
        }
        ?>
<!-- START FOREGROUNDTEMPLATE -->
		<nav class="top-bar" data-topbar role="navigation">
			<ul class="title-area">
				<li class="name">
					<h1 class="title-name">
					<a href="<?php 
        echo $this->data['nav_urls']['mainpage']['href'];
        ?>
">
					<?php 
        if ($wgForegroundFeatures['navbarIcon'] != '0') {
            ?>
						<img alt="<?php 
            echo $this->text('sitename');
            ?>
" class="top-bar-logo" src="<?php 
            echo $this->text('logopath');
            ?>
">
					<?php 
        }
        ?>
					
					<div class="title-name" style="display: inline-block;"><?php 
        echo $wgForegroundFeatures['wikiName'];
        ?>
</div>
					</a>
					</h1>
				</li>
				<li class="toggle-topbar menu-icon">
					<a href="#"><span><?php 
        echo wfMessage('foreground-menutitle')->text();
        ?>
</span></a>
				</li>
			</ul>

		<section class="top-bar-section">

			<ul id="top-bar-left" class="left">
				<li class="divider show-for-small"></li>
					<?php 
        foreach ($this->getSidebar() as $boxName => $box) {
            if ($box['header'] != wfMessage('toolbox')->text()) {
                ?>
				<li class="has-dropdown active"  id='<?php 
                echo Sanitizer::escapeId($box['id']);
                ?>
'<?php 
                echo Linker::tooltip($box['id']);
                ?>
>
					<a href="#"><?php 
                echo htmlspecialchars($box['header']);
                ?>
</a>
						<?php 
                if (is_array($box['content'])) {
                    ?>
							<ul class="dropdown">
								<?php 
                    foreach ($box['content'] as $key => $item) {
                        echo $this->makeListItem($key, $item);
                    }
                    ?>
							</ul>
								<?php 
                }
            }
            ?>
						<?php 
        }
        ?>
			</ul>

			<ul id="top-bar-right" class="right">
<!-- _vp_ 20160106 begin -->
<li>
              <a href="http://wasya.co/#services" class="services">Services</a>
            </li>
            <li class="has-dropdown not-click">
              <a href="javascript:void(0);">Knowledge Base</a>
              <ul class="dropdown"><li class="title back js-generated"><h5><a href="#">Back</a></h5></li>
                <li><a href="http://blog.wasya.co">Blog</a></li>
                <li><a href="http://wiki.computationalartscorp.com">Wiki</a></li>
              </ul>
            </li>
            <li>
              <a href="http://wasya.co/#about" class="about">About</a>
            </li>
            <li>
              <a href="mailto:admin@wasya.co?subject=Potential Work Opportunity">Contact</a>
            </li>
<!-- _vp_ 20160106 end -->
				<li class="has-form">
					<form action="<?php 
        $this->text('wgScript');
        ?>
" id="searchform" class="mw-search">
						<div class="row collapse">
						<div class="small-12 columns">
							<?php 
        echo $this->makeSearchInput(array('placeholder' => wfMessage('searchsuggest-search')->text(), 'id' => 'searchInput'));
        ?>
							<button type="submit" class="button search"><?php 
        echo wfMessage('search')->text();
        ?>
</button>
						</div>
						</div>
					</form>
				</li>
				<li class="divider show-for-small"></li>

				<li class="has-dropdown active"><a href="#"><i class="fa fa-cogs"></i></a>
					<ul id="toolbox-dropdown" class="dropdown">
						<?php 
        foreach ($this->getToolbox() as $key => $item) {
            echo $this->makeListItem($key, $item);
        }
        ?>
						<?php 
        if ($wgForegroundFeatures['showRecentChangesUnderTools']) {
            ?>
<li id="n-recentchanges"><?php 
            echo Linker::specialLink('Recentchanges');
            ?>
</li><?php 
        }
        ?>
						<?php 
        if ($wgForegroundFeatures['showHelpUnderTools']) {
            ?>
<li id="n-help" <?php 
            echo Linker::tooltip('help');
            ?>
><a href="<?php 
            echo Skin::makeInternalOrExternalUrl(wfMessage('helppage')->inContentLanguage()->text());
            ?>
"><?php 
            echo wfMessage('help')->text();
            ?>
</a></li><?php 
        }
        ?>
					</ul>
				</li>

				<li id="personal-tools-dropdown" class="has-dropdown active"><a href="#"><i class="fa fa-user"></i></a>
					<ul class="dropdown">
						<?php 
        foreach ($this->getPersonalTools() as $key => $item) {
            echo $this->makeListItem($key, $item);
        }
        ?>
					</ul>
				</li>

			</ul>
		</section>
		</nav>
		
		<?php 
        if ($wgForegroundFeatures['NavWrapperType'] != '0') {
            echo "</div>";
        }
        ?>
		
		<div id="page-content">
		<div class="row">
				<div class="large-12 columns">
				<!--[if lt IE 9]>
				<div id="siteNotice" class="sitenotice panel radius"><?php 
        echo $this->text('sitename') . ' ' . wfMessage('foreground-browsermsg')->text();
        ?>
</div>
				<![endif]-->

				<?php 
        if ($this->data['sitenotice']) {
            ?>
<div id="siteNotice" class="sitenotice"><?php 
            $this->html('sitenotice');
            ?>
</div><?php 
        }
        ?>
				<?php 
        if ($this->data['newtalk']) {
            ?>
<div id="usermessage" class="newtalk panel radius"><?php 
            $this->html('newtalk');
            ?>
</div><?php 
        }
        ?>
				</div>
		</div>

		<div id="mw-js-message" style="display:none;"></div>

		<div class="row">
				<div id="p-cactions" class="large-12 columns">
					<?php 
        if ($wgUser->isLoggedIn() || $wgForegroundFeatures['showActionsForAnon']) {
            ?>
						<a id="actions-button" href="#" data-dropdown="actions" data-options="align:left; is_hover: true; hover_timeout:700" class="button small secondary radius"><i class="fa fa-cog"><span class="show-for-medium-up">&nbsp;<?php 
            echo wfMessage('actions')->text();
            ?>
</span></i></a>
						<!--RTL -->
						<ul id="actions" class="f-dropdown" data-dropdown-content>
							<?php 
            foreach ($this->data['content_actions'] as $key => $item) {
                echo preg_replace(array('/\\sprimary="1"/', '/\\scontext="[a-z]+"/', '/\\srel="archives"/'), '', $this->makeListItem($key, $item));
            }
            ?>
							<?php 
            wfRunHooks('SkinTemplateToolboxEnd', array(&$this, true));
            ?>
						</ul>
						<!--RTL -->
						<?php 
            if ($wgUser->isLoggedIn()) {
                ?>
							<div id="echo-notifications">
							<div id="echo-notifications-alerts"></div>
							<div id="echo-notifications-messages"></div>
							</div>
						<?php 
            }
            ?>
					<?php 
        }
        $namespace = str_replace('_', ' ', $this->getSkin()->getTitle()->getNsText());
        $displaytitle = $this->data['title'];
        if (!empty($namespace)) {
            $pagetitle = $this->getSkin()->getTitle();
            $newtitle = str_replace($namespace . ':', '', $pagetitle);
            $displaytitle = str_replace($pagetitle, $newtitle, $displaytitle);
            ?>
<h4 class="namespace label"><?php 
            print $namespace;
            ?>
</h4><?php 
        }
        ?>
					<div id="content">
					<h2  id="firstHeading" class="title"><?php 
        print $displaytitle;
        ?>
</h2>
					<?php 
        if ($this->data['isarticle']) {
            ?>
<h3 id="tagline"><?php 
            $this->msg('tagline');
            ?>
</h3><?php 
        }
        ?>
					<h5 id="siteSub" class="subtitle"><?php 
        $this->html('subtitle');
        ?>
</h5>
					<div id="contentSub" class="clear_both"></div>
					<div id="bodyContent" class="mw-bodytext">
						<?php 
        $this->html('bodytext');
        ?>
						<div class="clear_both"></div>
					</div>
		    	<div class="group"><?php 
        $this->html('catlinks');
        ?>
</div>
		    	<?php 
        $this->html('dataAfterContent');
        ?>
				</div>
		    </div>
		</div>

			<footer class="row">
				<div id="footer">
					<?php 
        if ($wgForegroundFeatures['addThisFollowPUBID'] != '') {
            ?>
						<div class="social-footer large-12 small-12 columns">
							<div class="social-links">
							<!-- Go to www.addthis.com/dashboard to customize your tools -->
							<div class="addthis_horizontal_follow_toolbox"></div>
							<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=<?php 
            echo $wgForegroundFeatures['addThisFollowPUBID'];
            ?>
"></script>
							</div>
						</div>
					<?php 
        }
        ?>
					<div id="footer-left" class="<?php 
        echo $footerLeftClass;
        ?>
">
					<ul id="footer-left">
						<?php 
        foreach ($this->getFooterLinks("flat") as $key) {
            ?>
							<li id="footer-<?php 
            echo $key;
            ?>
"><?php 
            $this->html($key);
            ?>
</li>
						<?php 
        }
        ?>
									
					</ul>
					</div>	
					<div id="footer-right-icons" class="<?php 
        echo $footerRightClass;
        ?>
">
					<ul id="poweredby">
						<?php 
        foreach ($this->getFooterIcons($poweredbyType) as $blockName => $footerIcons) {
            ?>
							<li class="<?php 
            echo $blockName;
            ?>
"><?php 
            foreach ($footerIcons as $icon) {
                ?>
								<?php 
                echo $this->getSkin()->makeFooterIcon($icon, $poweredbyMakeType);
                ?>
								<?php 
            }
            ?>
							</li>
						<?php 
        }
        ?>
					</ul>
					</div>								
				</div>
			</footer>

		</div>
		
		<?php 
        $this->printTrail();
        ?>

		</body>
		</html>

<?php 
        wfRestoreWarnings();
    }
    function showEditForm($formCallback = null)
    {
        global $wgOut, $wgUser, $wgLang, $wgContLang, $wgMaxArticleSize;
        // print "call SHOW EDIT FORM";
        if (!isset($this->stripped_edit_text)) {
            $this->stripped_edit_text = '';
        }
        $fname = 'EditPageAjax::showEditForm';
        wfProfileIn($fname);
        $closeFormHtml = '';
        // check if we are in the MVD namespace (and need to use templates for edits:)
        if ($this->mTitle->getNamespace() == MV_NS_MVD) {
            // get display type get mvTitle if not set
            if (!isset($this->article->mvTitle)) {
                $this->mvTitle = new MV_Title($this->mTitle->getDBkey());
            }
            $editFormType = strtolower($this->mvTitle->getMvdTypeKey());
        } else {
            // check if its seq type:
            if ($this->mvd_id == 'seq') {
                $editFormType = 'seq';
            } else {
                $editFormType = 'default';
            }
        }
        switch ($editFormType) {
            case 'ht_en':
                $this->do_pre_htEdit();
                $closeFormHtml = $this->do_post_HtEdit();
                break;
            case 'anno_en':
                $this->loadEditText();
                // set the default action so save page:
                $wgOut->addHTML($this->getAjaxForm());
                // add in adjust html if present:
                $wgOut->addHTML($this->adj_html);
                break;
            case 'seq':
                $wgOut->addHTML(wfMsg('mv_edit_sequence_desc_help'));
                if ($this->mArticle->mTitle->exists()) {
                    $this->stripped_edit_text = $this->mArticle->getPageContent();
                } else {
                    $this->stripped_edit_text = '';
                }
                $wgOut->addHTML($this->getAjaxForm());
                break;
            default:
                $this->loadEditText();
                // set the default action so save page:
                $wgOut->addHTML($this->getAjaxForm());
                break;
        }
        $sk = $wgUser->getSkin();
        // wfRunHooks( 'EditPage::showEditForm:initial', array( &$this ) ) ;
        // $wgOut->setRobotpolicy( 'noindex,nofollow' );
        # Enabled article-related sidebar, top links, etc.
        $wgOut->setArticleRelated(true);
        if ($this->isConflict) {
            $s = wfMsg('editconflict', $this->mTitle->getPrefixedText());
            $wgOut->setPageTitle($s);
            $wgOut->addWikiText(wfMsg('explainconflict'));
            $this->textbox2 = $this->textbox1;
            $this->textbox1 = $this->stripped_edit_text;
            $this->edittime = $this->mArticle->getTimestamp();
        } else {
            if ($this->section != '') {
                if ($this->section == 'new') {
                    $s = wfMsg('editingcomment', $this->mTitle->getPrefixedText());
                } else {
                    $s = wfMsg('editingsection', $this->mTitle->getPrefixedText());
                    $matches = array();
                    if (!$this->summary && !$this->preview && !$this->diff) {
                        preg_match("/^(=+)(.+)\\1/mi", $this->stripped_edit_text, $matches);
                        if (!empty($matches[2])) {
                            $this->summary = "/* " . trim($matches[2]) . " */ ";
                        }
                    }
                }
            } else {
                $s = wfMsg('editing', $this->mTitle->getPrefixedText());
            }
            // $wgOut->addHTML($s);
            // $wgOut->setPageTitle( $s );
            if ($this->missingComment) {
                $wgOut->addWikiText(wfMsg('missingcommenttext'));
            }
            if ($this->missingSummary && $this->section != 'new') {
                $wgOut->addWikiText(wfMsg('missingsummary'));
            }
            if ($this->missingSummary && $this->section == 'new') {
                $wgOut->addWikiText(wfMsg('missingcommentheader'));
            }
            if (!$this->hookError == '') {
                $wgOut->addWikiText($this->hookError);
            }
            if (!$this->checkUnicodeCompliantBrowser()) {
                $wgOut->addWikiText(wfMsg('nonunicodebrowser'));
            }
            if (isset($this->mArticle) && isset($this->mArticle->mRevision)) {
                // Let sysop know that this will make private content public if saved
                if ($this->mArticle->mRevision->isDeleted(Revision::DELETED_TEXT)) {
                    $wgOut->wrapWikiMsg("<div class='mw-warning plainlinks'>\n\$1</div>\n", 'rev-deleted-text-view');
                }
                if (!$this->mArticle->mRevision->isCurrent()) {
                    $this->mArticle->setOldSubtitle($this->mArticle->mRevision->getId());
                    $wgOut->addWikiText(wfMsg('editingold'));
                }
            }
        }
        if (wfReadOnly()) {
            $wgOut->addWikiText(wfMsg('readonlywarning'));
        } elseif ($wgUser->isAnon() && $this->formtype != 'preview') {
            $wgOut->addWikiText(wfMsg('anoneditwarning'));
        } else {
            if ($this->isCssJsSubpage && $this->formtype != 'preview') {
                # Check the skin exists
                if (!$this->isWrongCaseCssJsPage) {
                    $wgOut->addWikiText(wfMsg('usercssjsyoucanpreview'));
                } else {
                    $wgOut->addWikiText(wfMsg('userinvalidcssjstitle', $this->mTitle->getSkinFromCssJsSubpage()));
                }
            }
        }
        if ($this->mTitle->getNamespace() == NS_MEDIAWIKI) {
            # Show a warning if editing an interface message
            $wgOut->addWikiText(wfMsg('editinginterface'));
        } elseif ($this->mTitle->isProtected('edit')) {
            # Is the title semi-protected?
            if ($this->mTitle->isSemiProtected()) {
                $notice = wfMsg('semiprotectedpagewarning');
                if (wfEmptyMsg('semiprotectedpagewarning', $notice) || $notice == '-') {
                    $notice = '';
                }
            } else {
                # Then it must be protected based on static groups (regular)
                $notice = wfMsg('protectedpagewarning');
            }
            $wgOut->addWikiText($notice);
        }
        if ($this->mTitle->isCascadeProtected()) {
            # Is this page under cascading protection from some source pages?
            list($cascadeSources, ) = $this->mTitle->getCascadeProtectionSources();
            if (count($cascadeSources) > 0) {
                # Explain, and list the titles responsible
                $notice = wfMsgExt('cascadeprotectedwarning', array('parsemag'), count($cascadeSources)) . "\n";
                foreach ($cascadeSources as $id => $page) {
                    $notice .= '* [[:' . $page->getPrefixedText() . "]]\n";
                }
            }
            $wgOut->addWikiText($notice);
        }
        if ($this->kblength === false) {
            $this->kblength = (int) (strlen($this->stripped_edit_text) / 1024);
        }
        if ($this->tooBig || $this->kblength > $wgMaxArticleSize) {
            $wgOut->addWikiText(wfMsg('longpageerror', $wgLang->formatNum($this->kblength), $wgMaxArticleSize));
        } elseif ($this->kblength > 29) {
            $wgOut->addWikiText(wfMsg('longpagewarning', $wgLang->formatNum($this->kblength)));
        }
        # need to parse the preview early so that we know which templates are used,
        # otherwise users with "show preview after edit box" will get a blank list
        if ($this->formtype == 'preview') {
            $previewOutput = $this->getPreviewText();
        }
        if ($wgUser->getOption('previewontop')) {
            if ('preview' == $this->formtype) {
                $this->showPreview($previewOutput);
            } else {
                $wgOut->addHTML('<div id="wikiPreview_' . htmlspecialchars($this->mvd_id) . '"></div>');
            }
            if ('diff' == $this->formtype) {
                $this->showDiff();
            }
        }
        $wgOut->addHTML($this->basic_html);
        $wgOut->addHTML('<div style="display:inline" class="mv_advanced_edit"><br>');
        // $rows = $wgUser->getIntOption( 'rows' );
        // $cols = $wgUser->getIntOption( 'cols' );
        // for ajax short edit area:
        $rows = 3;
        $cols = 40;
        $ew = $wgUser->getOption('editwidth');
        if ($ew) {
            $ew = " style=\"width:100%\"";
        } else {
            $ew = '';
        }
        // do ajax action:
        // $q = 'action=ajax';
        # if ( "no" == $redirect ) { $q .= "&redirect=no"; }
        // $action = $this->mTitle->escapeLocalURL( $q );
        if ($editFormType == 'seq') {
            $summary = wfMsg('mv_seq_summary');
        } else {
            $summary = wfMsg('summary');
        }
        $subject = wfMsg('subject');
        if ($this->mvd_id == 'seq') {
            $cancel = $sk->makeKnownLinkObj($this->mTitle, wfMsgExt('cancel', array('parseinline')));
            $edithelpurl = Skin::makeInternalOrExternalUrl(wfMsgForContent('mv_edithelpsequence'));
        } else {
            $cancel = '<a href="javascript:mv_disp_mvd(\'' . $this->mTitle->getDBkey() . '\',\'' . $this->mvd_id . '\');">' . wfMsgExt('cancel', array('parseinline')) . '</a>';
            $edithelpurl = Skin::makeInternalOrExternalUrl(wfMsgForContent('edithelppage'));
        }
        $edithelp = '<a target="helpwindow" href="' . $edithelpurl . '">' . htmlspecialchars(wfMsg('edithelp')) . '</a> ' . htmlspecialchars(wfMsg('newwindow'));
        global $wgRightsText;
        // copy right here is too verbose for a ajax window
        /*$copywarn = "<div id=\"editpage-copywarn\">\n" .
        			wfMsg( $wgRightsText ? 'copyrightwarning' : 'copyrightwarning2',
        				'[[' . wfMsgForContent( 'copyrightpage' ) . ']]',
        				$wgRightsText ) . "\n</div>";
        		*/
        if ($wgUser->getOption('showtoolbar') and !$this->isCssJsSubpage) {
            # prepare toolbar for edit buttons
            $toolbar = EditPage::getEditToolbar();
        } else {
            $toolbar = '';
        }
        // activate checkboxes if user wants them to be always active
        if (!$this->preview && !$this->diff) {
            # Sort out the "watch" checkbox
            if ($wgUser->getOption('watchdefault')) {
                # Watch all edits
                $this->watchthis = true;
            } elseif ($wgUser->getOption('watchcreations') && !$this->mTitle->exists()) {
                # Watch creations
                $this->watchthis = true;
            } elseif ($this->mTitle->userIsWatching()) {
                # Already watched
                $this->watchthis = true;
            }
            if ($wgUser->getOption('minordefault')) {
                $this->minoredit = true;
            }
        }
        $wgOut->addHTML($this->editFormPageTop);
        $wgOut->addHTML($this->editFormTextTop);
        # if this is a comment, show a subject line at the top, which is also the edit summary.
        # Otherwise, show a summary field at the bottom
        $summarytext = htmlspecialchars($wgContLang->recodeForEdit($this->summary));
        # FIXME
        if ($this->section == 'new') {
            $commentsubject = "<br /><span id='wpSummaryLabel'><label for='wpSummary'>{$subject}:</label></span>\n<div class='editOptions'>\n<input tabindex='1' type='text' value=\"{$summarytext}\" name='wpSummary' id='wpSummary' maxlength='200' size='40' /><br />";
            $editsummary = '';
            $subjectpreview = $summarytext && $this->preview ? "<div class=\"mw-summary-preview\">" . wfMsg('subject-preview') . ':' . $sk->commentBlock($this->summary, $this->mTitle) . "</div>\n" : '';
            $summarypreview = '';
        } else {
            $commentsubject = '';
            $editsummary = "<br /><span id='wpSummaryLabel'><label for='wpSummary'>{$summary}:</label></span>\n<div class='editOptions'>\n<input tabindex='2' type='text' value=\"{$summarytext}\" name='wpSummary' id='wpSummary' maxlength='200' size='40' /><br />";
            $summarypreview = $summarytext && $this->preview ? "<div class=\"mw-summary-preview\">" . wfMsg('summary-preview') . ':' . $sk->commentBlock($this->summary, $this->mTitle) . "</div>\n" : '';
            $subjectpreview = '';
        }
        $templates = $this->preview || $this->section != '' ? $this->mPreviewTemplates : $this->mArticle->getUsedTemplates();
        $formattedtemplates = $sk->formatTemplates($templates, $this->preview, $this->section != '');
        global $wgUseMetadataEdit;
        if ($wgUseMetadataEdit) {
            $metadata = $this->mMetaData;
            $metadata = htmlspecialchars($wgContLang->recodeForEdit($metadata));
            $top = wfMsgWikiHtml('metadata_help');
            $metadata = $top . "<textarea name='metadata' rows='3' cols='{$cols}'{$ew}>{$metadata}</textarea>";
        } else {
            $metadata = "";
        }
        $hidden = '';
        $recreate = '';
        if ($this->deletedSinceEdit) {
            if ('save' != $this->formtype) {
                $wgOut->addWikiText(wfMsg('deletedwhileediting'));
            } else {
                // Hide the toolbar and edit area, use can click preview to get it back
                // Add an confirmation checkbox and explanation.
                $toolbar = '';
                $hidden = 'type="hidden" style="display:none;"';
                $recreate = $wgOut->parse(wfMsg('confirmrecreate', $this->lastDelete->user_name, $this->lastDelete->log_comment));
                $recreate .= "<br /><input tabindex='1' type='checkbox' value='1' name='wpRecreate' id='wpRecreate' />" . "<label for='wpRecreate' title='" . wfMsg('tooltip-recreate') . "'>" . wfMsg('recreate') . "</label>";
            }
        }
        $tabindex = 2;
        $checkboxes = self::getCheckboxes($tabindex, $sk, array('minor' => $this->minoredit, 'watch' => $this->watchthis));
        $checkboxhtml = implode($checkboxes, "\n");
        $button_action = 'mv_do_ajax_form_submit(\'' . $this->mvd_id . '\', \'%s\');';
        $buttons = $this->getEditButtons($tabindex, $button_action);
        $buttonshtml = implode($buttons, "\n");
        $safemodehtml = $this->checkUnicodeCompliantBrowser() ? '' : Html::Hidden('safemode', '1');
        $wgOut->addHTML(<<<END
{$toolbar}
END
);
        // remove form because set earlier
        // <form id="editform" name="editform" method="post" action="$action" enctype="multipart/form-data">
        if (is_callable($formCallback)) {
            call_user_func_array($formCallback, array(&$wgOut));
        }
        wfRunHooks('EditPage::showEditForm:fields', array(&$this, &$wgOut));
        // Put these up at the top to ensure they aren't lost on early form submission
        $wgOut->addHTML("\n<input type='hidden' value=\"" . htmlspecialchars($this->section) . "\" name=\"wpSection\" />\n<input type='hidden' value=\"{$this->starttime}\" name=\"wpStarttime\" />\n\n<input type='hidden' value=\"{$this->edittime}\" name=\"wpEdittime\" />\n\n<input type='hidden' value=\"{$this->scrolltop}\" name=\"wpScrolltop\" id=\"wpScrolltop\" />\n");
        $wgOut->addHTML(<<<END
{$recreate}
{$commentsubject}
{$subjectpreview}
<textarea class="mv_ajax_textarea" tabindex='1' accesskey="," name="wpTextbox1" id="wpTextbox1" rows='{$rows}'
cols='{$cols}' {$ew} {$hidden}>
END
 . htmlspecialchars($this->safeUnicodeOutput($this->stripped_edit_text)) . "\n</textarea>\n\t\t");
        // close advanced display_edit div
        $wgOut->addHTML("</div>");
        // $wgOut->addWikiText( $copywarn );
        $wgOut->addHTML($this->editFormTextAfterWarn);
        $separator = wfMsgExt('pipe-separator', 'escapenoentities');
        $wgOut->addHTML("\n{$metadata}\n{$editsummary}\n{$summarypreview}\n{$checkboxhtml}\n{$safemodehtml}\n");
        $wgOut->addHTML("<div class='editButtons'>\n{$buttonshtml}\n\t<span class='editHelp'>{$cancel}{$separator}{$edithelp}</span>\n</div><!-- editButtons -->\n</div><!-- editOptions -->");
        $wgOut->addHTML('<div class="mw-editTools">');
        $wgOut->addWikiText(wfMsgForContent('edittools'));
        $wgOut->addHTML('</div>');
        $wgOut->addHTML($this->editFormTextAfterTools);
        $wgOut->addHTML("\n<div class='templatesUsed'>\n{$formattedtemplates}\n</div>\n");
        /**
         * To make it harder for someone to slip a user a page
         * which submits an edit form to the wiki without their
         * knowledge, a random token is associated with the login
         * session. If it's not passed back with the submission,
         * we won't save the page, or render user JavaScript and
         * CSS previews.
         *
         * For anon editors, who may not have a session, we just
         * include the constant suffix to prevent editing from
         * broken text-mangling proxies.
         */
        $token = htmlspecialchars($wgUser->editToken());
        $wgOut->addHTML("\n<input type='hidden' value=\"{$token}\" name=\"wpEditToken\" />\n");
        # If a blank edit summary was previously provided, and the appropriate
        # user preference is active, pass a hidden tag here. This will stop the
        # user being bounced back more than once in the event that a summary
        # is not required.
        if ($this->missingSummary) {
            $wgOut->addHTML("<input type=\"hidden\" name=\"wpIgnoreBlankSummary\" value=\"1\" />\n");
        }
        # For a bit more sophisticated detection of blank summaries, hash the
        # automatic one and pass that in a hidden field.
        $autosumm = $this->autoSumm ? $this->autoSumm : md5($this->summary);
        $wgOut->addHTML(Html::Hidden('wpAutoSummary', $autosumm));
        if ($this->isConflict) {
            $wgOut->addWikiText('==' . wfMsg("yourdiff") . '==');
            $de = new DifferenceEngine($this->mTitle);
            $de->setText($this->textbox2, $this->stripped_edit_text);
            $de->showDiff(wfMsg("yourtext"), wfMsg("storedversion"));
            $wgOut->addWikiText('==' . wfMsg("yourtext") . '==');
            $wgOut->addHTML("<textarea tabindex=6 id='wpTextbox2' name=\"wpTextbox2\" rows='{$rows}' cols='{$cols}' wrap='virtual'>" . htmlspecialchars($this->safeUnicodeOutput($this->textbox2)) . "\n</textarea>");
        }
        $wgOut->addHTML($this->editFormTextBottom);
        $wgOut->addHTML("</form>\n");
        if (!$wgUser->getOption('previewontop')) {
            if ($this->formtype == 'preview') {
                $this->showPreview($previewOutput);
            } else {
                $wgOut->addHTML('<div id="wikiPreview"></div>');
            }
            if ($this->formtype == 'diff') {
                $this->showDiff();
            }
        }
        $wgOut->addHTML($closeFormHtml);
        wfProfileOut($fname);
    }
Ejemplo n.º 11
0
 /**
  * Return array of links (href, text, id) for this wiki box
  * Author: Inez Korczynski (inez at wikia.com)
  * @return array
  */
 public static final function GetThisWiki()
 {
     wfProfileIn(__METHOD__);
     global $wgWikiaUsePHPBB;
     $data = array();
     $data['header'] = self::Translate('this_wiki');
     $data['home']['url'] = Skin::makeMainPageUrl();
     $data['home']['text'] = self::Translate('home');
     if (!empty($wgWikiaUsePHPBB)) {
         $data['forum']['url'] = '/forum/';
         $data['forum']['text'] = self::Translate('forum');
     } else {
         $data['forum']['url'] = Skin::makeInternalOrExternalUrl(wfMsgForContent('forum-url'));
         $data['forum']['text'] = self::Translate('forum');
     }
     $data['randompage']['url'] = Skin::makeSpecialUrl('Randompage');
     $data['randompage']['text'] = self::Translate('randompage');
     $data['help']['url'] = 'http://www.wikia.com/wiki/Help:Tutorial_1';
     $data['help']['text'] = self::Translate('helpfaq');
     $data['joinnow']['url'] = Skin::makeSpecialUrl('Userlogin', "type=signup");
     $data['joinnow']['text'] = self::Translate('joinnow');
     wfProfileOut(__METHOD__);
     return $data;
 }
Ejemplo n.º 12
0
    function execute()
    {
        global $wgCookieExpiration;
        $expirationDays = ceil($wgCookieExpiration / (3600 * 24));
        ?>
<div class="mw-ui-container">
	<div id="userloginprompt"><?php 
        $this->msgWiki('loginprompt');
        ?>
</div>
	<?php 
        if ($this->haveData('languages')) {
            ?>
		<div id="languagelinks">
			<p><?php 
            $this->html('languages');
            ?>
</p>
		</div>
	<?php 
        }
        ?>
	<div id="userloginForm">
		<form name="userlogin" class="mw-ui-vform" method="post" action="<?php 
        $this->text('action');
        ?>
">
			<?php 
        if ($this->data['loggedin']) {
            ?>
				<div class="warningbox">
					<?php 
            echo $this->getMsg('userlogin-loggedin')->params($this->data['loggedinuser'])->parse();
            ?>
				</div>
			<?php 
        }
        ?>
			<section class="mw-form-header">
				<?php 
        $this->html('header');
        /* extensions such as ConfirmEdit add form HTML here */
        ?>
			</section>

			<?php 
        if ($this->data['message']) {
            ?>
				<div class="<?php 
            $this->text('messagetype');
            ?>
box">
					<?php 
            if ($this->data['messagetype'] == 'error') {
                ?>
						<strong><?php 
                $this->msg('loginerror');
                ?>
</strong>
						<br />
					<?php 
            }
            ?>
					<?php 
            $this->html('message');
            ?>
				</div>
			<?php 
        }
        ?>

			<?php 
        if ($this->data['formheader']) {
            ?>
				<div class="mw-form-formheader">
					<?php 
            $this->html('formheader');
            /* extensions such as MobileFrontend add HTML here */
            ?>
				</div>
			<?php 
        }
        ?>
			<div class="mw-ui-vform-field">
				<label for="wpName1">
					<?php 
        $this->msg('userlogin-yourname');
        if ($this->data['secureLoginUrl']) {
            echo Html::element('a', ['href' => $this->data['secureLoginUrl'], 'class' => 'mw-ui-flush-right mw-secure'], $this->getMsg('userlogin-signwithsecure')->text());
        }
        ?>
				</label>
				<?php 
        echo Html::input('wpName', $this->data['name'], 'text', ['class' => 'loginText mw-ui-input', 'id' => 'wpName1', 'tabindex' => '1', 'required' => true, 'autofocus' => !$this->data['name'], 'placeholder' => $this->getMsg('userlogin-yourname-ph')->text()]);
        ?>
			</div>

			<div class="mw-ui-vform-field">
				<label for="wpPassword1">
					<?php 
        $this->msg('userlogin-yourpassword');
        ?>
				</label>
				<?php 
        echo Html::input('wpPassword', null, 'password', ['class' => 'loginPassword mw-ui-input', 'id' => 'wpPassword1', 'tabindex' => '2', 'autofocus' => (bool) $this->data['name'], 'placeholder' => $this->getMsg('userlogin-yourpassword-ph')->text()]);
        ?>
			</div>

			<?php 
        if (isset($this->data['usedomain']) && $this->data['usedomain']) {
            $select = new XmlSelect('wpDomain', false, $this->data['domain']);
            $select->setAttribute('tabindex', 3);
            foreach ($this->data['domainnames'] as $dom) {
                $select->addOption($dom);
            }
            ?>
				<div class="mw-ui-vform-field" id="mw-user-domain-section">
					<label for="wpDomain"><?php 
            $this->msg('yourdomainname');
            ?>
</label>
					<?php 
            echo $select->getHTML();
            ?>
				</div>
			<?php 
        }
        ?>

			<?php 
        if ($this->haveData('extrafields')) {
            echo $this->data['extrafields'];
        }
        ?>

			<div class="mw-ui-vform-field">
				<?php 
        if ($this->data['canremember']) {
            ?>
					<div class="mw-ui-checkbox">
						<input name="wpRemember" type="checkbox" value="1" id="wpRemember" tabindex="4"
							<?php 
            if ($this->data['remember']) {
                echo 'checked="checked"';
            }
            ?>
						><label for="wpRemember">
							<?php 
            echo $this->getMsg('userlogin-remembermypassword')->numParams($expirationDays)->escaped();
            ?>
</label>
					</div>
				<?php 
        }
        ?>
			</div>

			<div class="mw-ui-vform-field">
				<?php 
        $attrs = ['id' => 'wpLoginAttempt', 'name' => 'wpLoginAttempt', 'tabindex' => '6'];
        $modifiers = ['mw-ui-progressive'];
        echo Html::submitButton($this->getMsg('pt-login-button')->text(), $attrs, $modifiers);
        ?>
			</div>

			<div class="mw-ui-vform-field mw-form-related-link-container" id="mw-userlogin-help">
				<?php 
        echo Html::element('a', ['href' => Skin::makeInternalOrExternalUrl(wfMessage('helplogin-url')->inContentLanguage()->text())], $this->getMsg('userlogin-helplink2')->text());
        ?>
			</div>
			<?php 
        if ($this->data['useemail'] && $this->data['canreset'] && $this->data['resetlink'] === true) {
            echo Html::rawElement('div', ['class' => 'mw-ui-vform-field mw-form-related-link-container'], Linker::link(SpecialPage::getTitleFor('PasswordReset'), $this->getMsg('userlogin-resetpassword-link')->escaped()));
        }
        if ($this->haveData('createOrLoginHref')) {
            if ($this->data['loggedin']) {
                ?>
					<div class="mw-form-related-link-container mw-ui-vform-field">
						<a href="<?php 
                $this->text('createOrLoginHref');
                ?>
" id="mw-createaccount-join" tabindex="7"><?php 
                $this->msg('userlogin-createanother');
                ?>
</a>
					</div>
				<?php 
            } else {
                ?>
					<div id="mw-createaccount-cta" class="mw-ui-vform-field">
						<?php 
                $this->msg('userlogin-noaccount');
                ?>
<a href="<?php 
                $this->text('createOrLoginHref');
                ?>
" id="mw-createaccount-join" tabindex="7" class="mw-ui-button"><?php 
                $this->msg('userlogin-joinproject');
                ?>
</a>
					</div>
				<?php 
            }
        }
        // Hidden fields
        $fields = '';
        if ($this->haveData('uselang')) {
            $fields .= Html::hidden('uselang', $this->data['uselang']);
        }
        if ($this->haveData('token')) {
            $fields .= Html::hidden('wpLoginToken', $this->data['token']);
        }
        if ($this->data['cansecurelogin']) {
            $fields .= Html::hidden('wpForceHttps', $this->data['stickhttps']);
        }
        if ($this->data['cansecurelogin'] && $this->haveData('fromhttp')) {
            $fields .= Html::hidden('wpFromhttp', $this->data['fromhttp']);
        }
        echo $fields;
        ?>
		</form>
	</div>
</div>
<?php 
    }
Ejemplo n.º 13
0
 function showEditForm($formCallback = null)
 {
     global $wgOut, $wgLanguageCode, $wgRequest, $wgTitle, $wgUser, $wgLang;
     $whow = null;
     // conflict resolution
     if (!$wgRequest->wasPosted()) {
         EditPage::showEditForm();
     }
     $wgOut->clearHTML();
     //echo $this->textbox1; exit;
     wfRunHooks('EditPage::showEditForm:initial', array(&$this));
     // are we called with just action=edit and no title?
     $newArticle = false;
     if (($wgRequest->getVal("title") == "" || $wgTitle->getArticleID() == 0) && !$this->preview) {
         $newArticle = true;
     }
     $sk = $wgUser->getSkin();
     if (!$this->mTitle->getArticleID() && !$this->preview) {
         # new article
         $wgOut->addHTML(wfMsg("newarticletext"));
     }
     // do we have a new article? if so, format the title if it's English
     $wgRequest->getVal("new_article");
     if ($new_article && $wgLanguageCode == "en") {
         $title = $this->mTitle->getText();
         $old_title = $title;
         $title = $this->formatTitle($title);
         $titleObj = Title::newFromText($title);
         $this->mTitle = $titleObj;
         $this->mArticle = new Article($titleObj);
     }
     $conflictWikiHow = null;
     $conflictTitle = false;
     if ($this->isConflict) {
         $s = wfMsg("editconflict", $this->mTitle->getPrefixedText());
         $wgOut->setPageTitle($s);
         if ($new_article) {
             $wgOut->addHTML("<b><font color=red>" . wfMsg('page-name-exists') . "</b></font><br/><br/>");
             $conflictTitle = true;
         } else {
             $this->edittime = $this->mArticle->getTimestamp();
             $wgOut->addHTML(wfMsg("explainconflict"));
             // let the advanced editor handle the situation
             if ($this->isConflict) {
                 EditPage::showEditForm();
                 return;
             }
         }
         $this->textbox2 = $this->textbox1;
         $conflictWikiHow = WikihowArticleEditor::newFromText($this->textbox1);
         $this->textbox1 = $this->mArticle->getContent(true, true);
         $this->edittime = $this->mArticle->getTimestamp();
     } else {
         if ($this->mTitle->getArticleID() == 0) {
             $s = wfMsg('creating', "\"" . wfMsg('howto', $this->mTitle->getPrefixedText()) . "\"");
         } else {
             $s = wfMsg('editing', "\"" . wfMsg('howto', $this->mTitle->getPrefixedText()) . "\"");
         }
         if ($this->section != "") {
             if ($this->section == "new") {
                 $s .= wfMsg("commentedit");
             } else {
                 $s .= wfMsg("sectionedit");
             }
             if (!$this->preview) {
                 $sectitle = preg_match("/^=+(.*?)=+/mi", $this->textbox1, $matches);
                 if (!empty($matches[1])) {
                     $this->summary = "/* " . trim($matches[1]) . " */ ";
                 }
             }
         }
         $wgOut->setPageTitle($s);
         if ($this->oldid) {
             $this->mArticle->setOldSubtitle($this->oldid);
             $wgOut->addHTML(wfMsg("editingold"));
         }
     }
     if (wfReadOnly()) {
         $wgOut->addHTML("<strong>" . wfMsg("readonlywarning") . "</strong>");
     } elseif ($isCssJsSubpage and "preview" != $formtype) {
         $wgOut->addHTML(wfMsg("usercssjsyoucanpreview"));
     }
     if (!$newArticle && $this->mTitle->isProtected('edit')) {
         if ($this->mTitle->isSemiProtected()) {
             $notice = wfMsg('semiprotectedpagewarning');
             if (wfEmptyMsg('semiprotectedpagewarning', $notice) || $notice == '-') {
                 $notice = '';
             }
         } else {
             $notice = wfMsg('protectedpagewarning');
         }
         $wgOut->addHTML("<div class='article_inner'>\n ");
         $wgOut->addWikiText($notice);
         $wgOut->addHTML("</div>\n");
     }
     $q = "action=submit2&override=yes";
     #if ( "no" == $redirect ) { $q .= "&redirect=no"; }
     $action = $this->mTitle->escapeLocalURL($q);
     if ($newArticle) {
         $main = str_replace(' ', '-', wfMsg('mainpage'));
         $action = str_replace("&title=" . $main, "", $action);
     }
     $summary = wfMsg("summary");
     $subject = wfMsg("subject");
     $minor = wfMsg("minoredit");
     $watchthis = wfMsg("watchthis");
     $save = wfMsg("savearticle");
     $prev = wfMsg("showpreview");
     $cancel = $sk->makeKnownLink($this->mTitle->getPrefixedText(), wfMsg("cancel"));
     $edithelpurl = Skin::makeInternalOrExternalUrl(wfMsgForContent('edithelppage'));
     $edithelp = '<a target="helpwindow" href="' . $edithelpurl . '">' . htmlspecialchars(wfMsg('edithelp')) . '</a> ' . htmlspecialchars(wfMsg('newwindow'));
     $copywarn = wfMsg("copyrightwarning", $sk->makeKnownLink(wfMsg("copyrightpage")));
     $minoredithtml = '';
     if ($wgUser->isAllowed('minoredit')) {
         $minoredithtml = "<input tabindex='11' type='checkbox' value='1' name='wpMinoredit'" . ($this->minoredit ? " checked='checked'" : "") . " accesskey='" . wfMsg('accesskey-minoredit') . "' id='wpMinoredit' />\n" . "<label for='wpMinoredit' title='" . wfMsg('tooltip-minoredit') . "'>{$minor}</label>\n";
     }
     $watchhtml = '';
     if ($wgUser->isLoggedIn()) {
         $watchhtml = "<input tabindex='12' type='checkbox' name='wpWatchthis'" . ($this->watchthis ? " checked='checked'" : "") . " accesskey=\"" . htmlspecialchars(wfMsg('accesskey-watch')) . "\" id='wpWatchthis'  />\n" . "<label for='wpWatchthis' title=\"" . htmlspecialchars(wfMsg('tooltip-watch')) . "\">{$watchthis}</label>\n";
     }
     $checkboxhtml = $minoredithtml . $watchhtml;
     $tabindex = 14;
     $buttons = $this->getEditButtons($tabindex);
     $footerbuttons = "";
     $buttons['preview'] = "<span id='gatGuidedPreview'>{$buttons['preview']}</span>";
     if ($wgUser->getOption('hidepersistantsavebar', 0) == 0) {
         $footerbuttons .= "<span id='gatPSBSave'>{$buttons['save']}</span>";
         $footerbuttons .= "<span id='gatPSBPreview'>{$buttons['preview']}</span>";
     }
     $saveBtn = str_replace('accesskey="s"', "", $buttons['save']);
     $buttons['save'] = "<span id='gatGuidedSave'>{$saveBtn}</span>";
     $buttonshtml = implode($buttons, "\n");
     # if this is a comment, show a subject line at the top, which is also the edit summary.
     # Otherwise, show a summary field at the bottom
     $summarytext = htmlspecialchars($wgLang->recodeForEdit($this->summary));
     # FIXME
     $editsummary1 = "";
     if ($wgRequest->getVal('suggestion')) {
         $summarytext .= ($summarytext == "" ? "" : ", ") . wfMsg('suggestion_edit_summary');
     }
     if ($this->section == "new") {
         $commentsubject = "{$subject}: <input tabindex='1' type='text' value=\"{$summarytext}\" name=\"wpSummary\" id='wpSummary' maxlength='200' size='60' />";
         $editsummary = "";
     } else {
         $commentsubject = "";
         if ($wgTitle->getArticleID() == 0 && $wgTitle->getNamespace() == NS_MAIN && $summarytext == "") {
             $summarytext = wfMsg('creating_new_article');
         }
         $editsummary = "<input tabindex='10' type='text' value=\"{$summarytext}\" name=\"wpSummary\" id='wpSummary' maxlength='200' size='60' /><br />";
         $editsummary1 = "<input tabindex='10' type='text' value=\"{$summarytext}\" name=\"wpSummary1\" id='wpSummary1' maxlength='200' size='60' /><br />";
     }
     // create the wikiHow
     if ($conflictWikiHow == null) {
         if ($this->textbox1 != "") {
             $whow = WikihowArticleEditor::newFromText($this->textbox1);
         } else {
             $whow = WikihowArticleEditor::newFromArticle($this->mArticle);
         }
     } else {
         $whow = $conflictWikiHow;
     }
     //********** SETTING UP THE FORM
     //
     //
     //
     //
     $confirm = "window.onbeforeunload = confirmExit;";
     if ($wgUser->getOption('disablewarning') == '1') {
         $confirm = "";
     }
     $wgOut->addHTML("<script language=\"JavaScript\">\n\t\t\t\tvar isGuided = true;\n\t\t\t\tvar needToConfirm = false;\n\t\t\t\tvar checkMinLength = true;\n\t\t\t\t{$confirm}\n\t\t\t\tfunction confirmExit() {\n\t\t\t\t\tif (needToConfirm)\n\t\t\t\t\t\treturn \"" . wfMsg('all-changes-lost') . "\";\n\t\t\t\t}\n\t\t\t\tfunction addrows(element) {\n\t\t\t\t\tif (element.rows < 32)  {\n\t\t\t\t\t\telement.rows += 4;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfunction removerows(element) {\n\t\t\t\t\tif (element.rows > 4)  {\n\t\t\t\t\t\telement.rows -= 4;\n\t\t\t\t\t} else {\n\t\t\t\t\t\telement.rows = 4;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfunction saveandpublish() {\n\t\t\t\t\twindow.onbeforeunload = null;\n\t\t\t\t\tdocument.editform.submit();\n\t\t\t\t}\n\t\t\t\t(function (\$) {\n\t\t\t\t\t\$(document).ready(function() {\n\t\t\t\t\t\t\$('.button').click(function () {\n\t\t\t\t\t\t\tvar button = \$(this).not('.submit_button');\n\t\t\t\t\t\t\tif (button.length) {\n\t\t\t\t\t\t\t\tneedToConfirm = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\$('textarea').focus(function () {\n\t\t\t\t\t\t\tneedToConfirm = true;\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t\t\$('#ep_cat').live('click', function(e) {\n\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\tvar title = 'Categorize ' + wgTitle;\n\t\t\t\t\t\tif (title.length > 54) {\n\t\t\t\t\t\t\ttitle = title.substr(0, 54) + '...';\n\t\t\t\t\t\t}\n\t\t\t\t\t\tjQuery('#dialog-box').html('');\n\t\t\t\t\t\t\n\t\t\t\t\t\tjQuery('#dialog-box').load('/Special:Categorizer?a=editpage&id=' + wgArticleId, function() {\n\t\t\t\t\t\t\tjQuery('#dialog-box').dialog({\n\t\t\t\t\t\t\t\twidth: 673,\n\t\t\t\t\t\t\t\theight: 600,\n\t\t\t\t\t\t\t\tmodal: true,\n\t\t\t\t\t\t\t\ttitle: title,\n\t\t\t\t\t\t\t\tcloseText: 'Close',\t\n\t\t\t\t\t\t\t\tdialogClass: 'modal2',\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\treCenter = function() {\n\t\t\t\t\t\t\t\tjQuery('#dialog-box').dialog('option', 'position', 'center');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsetTimeout('reCenter()', 100);\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\$.getScript('/extensions/wikihow/cattool/categorizer.js');\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t})(jQuery);\n\t\t\t</script>\n\t\t\t<script type=\"text/javascript\" src=\"" . wfGetPad('/extensions/min/f/skins/common/clientscript.js,/skins/common/ac.js,/extensions/wikihow/video/importvideo.js&rev=') . WH_SITEREV . "\"></script>\n\n\t\t");
     if (!$this->preview) {
         # Don't select the edit box on preview; this interferes with seeing what's going on.
         $wgOut->setOnloadHandler("document.editform.title.focus(); load_cats();");
     }
     $title = "";
     //$wgOut->setOnloadHandler( "' onbeforeunload='return confirm(\"Are you sure you want to navigate away from this page? All changes will be lost!\");" );
     $suggested_title = "";
     if (isset($_GET["requested"])) {
         $t = Title::makeTitle(NS_MAIN, $_GET["requested"]);
         $suggested_title = $t->getText();
     }
     if ($wgRequest->getVal('title', null) == null || $conflictTitle || $suggested_title != "") {
         $title = "<div id='title'><h3>" . wfMsg('title') . "</h3><br/>" . wfMsg('howto', '') . " &nbsp;&nbsp;&nbsp;\n\t\t\t<input autocomplete=\"off\" size=60 type=\"text\" name=\"title\" id=category tabindex=\"1\" value=\"{$suggested_title}\"></div>";
     }
     $steps = htmlspecialchars($wgLang->recodeForEdit($whow->getSteps(true)), ENT_QUOTES);
     $video = htmlspecialchars($wgLang->recodeForEdit($whow->getSection(wfMsg('video'))));
     $tips = htmlspecialchars($wgLang->recodeForEdit($whow->getSection(wfMsg('tips'))));
     $warns = htmlspecialchars($wgLang->recodeForEdit($whow->getSection(wfMsg('warnings'))));
     $related_text = htmlspecialchars($wgLang->recodeForEdit($whow->getSection(wfMsg('relatedwikihows'))));
     $summary = htmlspecialchars($wgLang->recodeForEdit($whow->getSummary()));
     if ($newArticle || $whow->mIsNew) {
         if ($steps == "") {
             $steps = "#  ";
         }
         if ($tips == "") {
             $tips = "*  ";
         }
         if ($warns == "") {
             $warns = "*  ";
         }
         if ($ingredients == "") {
             $ingredients = "*  ";
         }
     }
     $cat = $whow->getCategoryString();
     $advanced = "";
     $cat_array = explode("|", $whow->getCategoryString());
     $i = 0;
     $cat_string = "";
     foreach ($cat_array as $cat) {
         if ($cat == "") {
             continue;
         }
         if ($i != 0) {
             $cat_string .= "," . $cat;
         } else {
             $cat_string = $cat;
         }
         $i++;
     }
     $removeButton = "";
     $cat_advisory = "";
     if ($cat_string != "") {
         $removeButton = "<input type=\"button\" name=\"change_cats\" onclick=\"removeCategories();\" value=\"" . wfMsg('remove-categories') . "\">";
     } else {
         $cat_advisory = wfMsg('categorization-optional');
     }
     //$cat_string = str_replace("|", ", ", $whow->getCategoryString());
     //$cat_string = implode(", ", $raa);
     if (!$newArticle && !$whow->mIsNew && !$conflictTitle) {
         $oldparameters = "";
         if ($wgRequest->getVal("oldid") != "") {
             $oldparameters = "&oldid=" . $wgRequest->getVal("oldid");
         }
         if (!$this->preview) {
             $advanced = "<a class='' href='{$wgScript}?title=" . $wgTitle->getPrefixedURL() . "&action=edit&advanced=true{$oldparameters}'>" . wfMsg('advanced-editing') . "</a>";
         }
     } elseif ($newArticle && $wgRequest->getVal('title', null) != null) {
         $t = Title::newFromText("CreatePage", NS_SPECIAL);
         //$advanced = str_replace("href=", "class='guided-button' href=", $sk->makeLinkObj($t, wfMsg('advanced-editing'))) . " |";
         //$advanced = "<a href='{$wgScript}?title=" . $wgTitle->getPrefixedURL() . "&action=edit&advanced=true$oldparameters';\">".wfMsg('advanced-editing')."</a>";
         $advanced = "<a class='button secondary' style='float:left;' href='{$wgScript}?title=" . $wgTitle->getPrefixedURL() . "&action=edit&advanced=true{$oldparameters}'>" . wfMsg('advanced-editing') . "</a>";
     }
     $section_class = 'minor_section';
     // MODIFIED FOR POPUP
     $categoryHTML = "";
     if ($wgUser->getID() > 0) {
         $ctitle = $this->mTitle->getText();
         $css = HtmlSnips::makeUrlTags('css', array('categoriespopup.css'), 'extensions/wikihow', false);
         if ($wgLanguageCode == 'en') {
             $editCatMore = "<a href=\"{$wgScriptPath}/Writer%27s-Guide?section=2#" . wfMsg('more-info-categorization') . "\" target=\"new\">" . wfMsg('moreinfo') . "</a>";
             $editCatHtml = "<a href='#' id='ep_cat'>[" . wfMsg('editcategory') . "]</a><strong>{$editCatLink}</strong>";
         }
         $categoryHTML = "\n\t\t\t\t{$css}\n\t\t\t\t<div id='categories'>\n\t\t\t\t\t<h5>" . wfMsg('add-optional-categories') . "{$editCatMore}</h5>\n\t\t\t\t\t<div id='option_cats'>\n\t\t\t\t\t{$editCatHtml}" . Categoryhelper::getCategoryOptionsForm2($cat_string, $whow->mCategories) . "\t</div>\n\t\t\t\t</div>";
     }
     $requested = "";
     if (isset($_GET['requested'])) {
         $requested = $_GET['requested'];
     }
     $related_vis = "hide";
     $related_checked = "";
     $relatedHTML = "";
     if ($whow->getSection(wfMsg('relatedwikihows')) != "") {
         $related_vis = "show";
         $relatedHTML = $whow->getSection(wfMsg('relatedwikihows'));
         $relatedHTML = str_replace("*", "", $relatedHTML);
         $relatedHTML = str_replace("[[", "", $relatedHTML);
         $relatedHTML = str_replace("]]", "", $relatedHTML);
         $lines = split("\n", $relatedHTML);
         $relatedHTML = "";
         foreach ($lines as $line) {
             $xx = strpos($line, "|");
             if ($xx !== false) {
                 $line = substr($line, 0, $xx);
             }
             // Google+ hack.  We don't normally allow + but will for the Goog
             if (false === stripos($line, 'Google+')) {
                 $line = trim(urldecode($line));
             }
             if ($line == "") {
                 continue;
             }
             $relatedHTML .= "<OPTION VALUE=\"" . htmlspecialchars($line) . "\">{$line}</OPTION>\n";
         }
         $related_checked = " CHECKED ";
     }
     $vidpreview_vis = "hide";
     $vidbtn_vis = "show";
     $vidpreview = "<img src='" . wfGetPad('/extensions/wikihow/rotate.gif') . "'/>";
     if ($whow->getSection(wfMsg('video')) != "") {
         $vidpreview_vis = "show";
         $vidbtn_vis = "hide";
         try {
             #$vt = Title::makeTitle(NS_VIDEO, $this->mTitle->getText());
             #$r = Revision::newFromTitle($vt);
             $vidtext = $whow->getSection(wfMsg('video'));
             $vidpreview = $wgOut->parse($vidtext);
         } catch (Exception $e) {
             $vidpreview = "Sorry, preview is currently not available.";
         }
     } else {
         $vidpreview = wfMsg('video_novideoyet');
     }
     $video_disabled = "";
     $vid_alt = "";
     $video_msg = "";
     $video_button = "<a id='gatVideoImportEdit' type='button' onclick=\"changeVideo('" . urlencode($wgTitle->getDBKey()) . "'); return false;\" href='#' id='show_preview_button' class='button secondary'  >" . wfMsg('video_change') . "</a>";
     if ($wgUser->getID() == 0) {
         $video_disabled = "disabled";
         $video_alt = "<input type='hidden' name='video' value=\"" . htmlspecialchars($video) . "\"/>";
         $video_msg = wfMsg('video_loggedin');
         $video_button = "";
     }
     $things_vis = "hide";
     $things = "*  ";
     $things_checked = "";
     $tyn = $whow->getSection(wfMsg("thingsyoullneed"));
     if ($tyn != '') {
         $things_vis = "show";
         $things = $tyn;
         $things_checked = " CHECKED ";
     }
     $ingredients_vis = "hide";
     $section = $whow->getSection(wfMsg("ingredients"));
     $ingredients_checked = "";
     if ($section != '') {
         $ingredients_vis = "show";
         $ingredients = $section;
         $ingredients_checked = " CHECKED ";
     }
     $sources_vis = "hide";
     $sources = "*  ";
     $sources_checked = "";
     $sources = $whow->getSection(wfMsg("sources"));
     $sources = str_replace('<div class="references-small"><references/></div>', '', $sources);
     $sources = str_replace('{{reflist}}', '', $sources);
     if ($sources != "") {
         $sources_vis = "show";
         $sources_checked = " CHECKED ";
     }
     $new_field = "";
     if ($newArticle || $new_article) {
         $new_field = "<input type=hidden name=new_article value=true>";
     }
     $lang_links = htmlspecialchars($whow->getLangLinks());
     $vt = Title::makeTitle(NS_VIDEO, $this->mTitle->getText());
     $vp = SpecialPage::getTitleFor("Previewvideo", $vt->getFullText());
     $newArticleWarn = '<script type="text/javascript" src="' . wfGetPad('/extensions/min/f/extensions/wikihow/winpop.js?') . WH_SITEREV . '"></script>';
     $popup = Title::newFromText("UploadPopup", NS_SPECIAL);
     if ($wgUser->isLoggedIn()) {
         $token = htmlspecialchars($wgUser->editToken());
     } else {
         $token = EDIT_TOKEN_SUFFIX;
     }
     if ('preview' == $this->formtype) {
         $previewOutput = $this->getPreviewText();
         $this->showPreview($previewOutput);
         $show_weave = true;
     } else {
         $wgOut->addHTML('<div id="wikiPreview"></div>');
     }
     if ('diff' == $this->formtype) {
         $this->showDiff();
         $show_weave = true;
     }
     if ($show_weave) {
         $relBtn = $wgLanguageCode == 'en' ? PopBox::getGuidedEditorButton() : '';
         $relHTML = PopBox::getPopBoxJSGuided() . PopBox::getPopBoxDiv() . PopBox::getPopBoxCSS();
         $weave_links = $relHTML . '<div class="wh_block editpage_sublinks">' . $relBtn . '</div>';
     }
     $undo = '';
     if ($wgRequest->getVal('undo', null) != null) {
         $undo_id = $wgRequest->getVal('undo', null);
         $undo = "\n<input type='hidden' value=\"{$undo_id}\" name=\"wpUndoEdit\" />\n";
     }
     $wgOut->addHTML(Easyimageupload::getUploadBoxJS());
     $wgOut->addHTML("\t\n{$newArticleWarn}\n\n<div id='editpage'>\n<form id=\"editform\" name=\"editform\" method=\"post\" action=\"{$action}\"\nenctype=\"application/x-www-form-urlencoded\"  onSubmit=\"return checkForm();\">\t\t");
     if (is_callable($formCallback)) {
         call_user_func_array($formCallback, array(&$wgOut));
     }
     $hidden_cats = "";
     if (!$wgUser->isLoggedIn()) {
         $hidden_cats = "<input type=\"hidden\" name=\"categories22\" value=\"{$cat_string}\">";
     }
     $token1 = md5($wgUser->getName() . $this->mTitle->getArticleID() . time());
     wfTrackEditToken($wgUser, $token1, $this->mTitle, $this instanceof EditPageWrapper);
     $wgOut->addHTML("\n\t\t{$new_field}\n\t\t{$hidden_cats}\n\t\t<input type='hidden' value=\"{$this->starttime}\" name=\"wpStarttime\" />\n\n\t\t<input type=\"hidden\" name=\"requested\" value=\"{$requested}\">\n\t\t<input type=\"hidden\" name=\"langlinks\" value=\"{$lang_links}\">\n\t\t<input type='hidden' value=\"{$this->edittime}\" name=\"wpEdittime\" />\n\n\n\t\t{$commentsubject}\n\t\t{$title}\n\t\t<br clear='all'/>\n<script language='javascript'>\n\tvar vp_URL = '{$vp->getLocalUrl()}';\n</script>\n<script language='javascript' src='" . wfGetPad('/extensions/min/f/extensions/wikihow/previewvideo.js?rev=') . "'></script>\n<style type='text/css' media='all'>/*<![CDATA[*/ @import '" . wfGetPad('/extensions/min/f/extensions/wikihow/editpagewrapper.css,/extensions/wikihow/winpop.css,/extensions/wikihow/video/importvideo.css,/extensions/wikihow/cattool/categorizer.css,/extensions/wikihow/cattool/categorizer_editpage.css&rev=') . WH_SITEREV . "'; /*]]>*/</style>\n\n\t{$weave_links}\n\n\t<div id='introduction' class='{$section_class}'>\n\t\t<h2>" . wfMsg('introduction') . "\n\t\t\t<div class='head_details'>" . wfMsg('summaryinfo') . "</div>\n\t\t\t<a href=\"{$wgScriptPath}/" . wfMsg('writers-guide-url') . "?section=2#" . wfMsg('introduction-url') . "\" target=\"new\">" . wfMsg('moreinfo') . "</a>\n\t\t</h2>\n\t\t<textarea rows='4' cols='100' name='summary' id='summary' tabindex=\"2\" wrap=virtual>{$summary}</textarea>\n\t\t<!--a href='#' class='button secondary add_image_button' onclick='easyImageUpload.doEIUModal(\"intro\"); return false;'>" . wfMsg('eiu-add-image-to-introduction') . "</a-->\n\t\t<div class='clearall'></div>\n\t</div>\n\n\n\t<div id='ingredients' class='{$ingredients_vis} {$section_class}'>\n\t\t<h2>" . wfMsg('ingredients') . "\n\t\t\t<div class='head_details'>" . wfMsg('ingredients_tooltip') . "</div>\n\t\t\t<a href=\"{$wgScriptPath}/" . wfMsg('writers-guide-url') . "?section=2#" . wfMsg('ingredients') . "\" target=\"new\">" . wfMsg('moreinfo') . "</a>\n\t\t</h2>\n\t\t<textarea name='ingredients' rows='4' cols='100' onKeyUp=\"addStars(event, document.editform.ingredients);\" tabindex='3' id='ingredients_text'>{$ingredients}</textarea>\n\t\t<a href='#' class='button secondary add_image_button'  onclick='easyImageUpload.doEIUModal(\"ingredients\"); return false;'>" . wfMsg('eiu-add-image-to-ingredients') . "</a>\n\t</div>\n\n\t<div id='steps' class='{$section_class}'>\n\t\t<h2>" . wfMsg('steps') . "\n\t\t\t<div class='head_details'>" . wfMsg('stepsinfo') . "</div>\n\t\t\t<a href=\"{$wgScriptPath}/" . wfMsg('writers-guide-url') . "?section=2#" . wfMsg('steps') . "\" target=\"new\">" . wfMsg('moreinfo') . "</a>\n\t\t</h2>\n\t\t<textarea name='steps' rows='{$wgRequest->getVal('txtarea_steps_text', 12)}' cols='100' wrap='virtual' onKeyUp=\"addNumToSteps(event);\" tabindex='4' id='steps_text'>{$steps}</textarea>\n\t\t<a href='#' class='button secondary add_image_button' onclick='easyImageUpload.doEIUModal(\"steps\", 0); return false;'>" . wfMsg('eiu-add-image-to-steps') . "</a>\n\t</div>");
     $wgOut->addHTML("<div id='video' class='{$section_class}'>\n\t\t<h2>" . wfMsg('video') . "\n\t\t\t<div class='head_details'>" . wfMsg('videoinfo') . "</div>\n\t\t\t<a href=\"{$wgScriptPath}/" . wfMsg('writers-guide-url') . "?section=2#" . wfMsg('video') . "\" target=\"new\">" . wfMsg('moreinfo') . "</a>\n\t\t</h2>\n\t\t{$video_alt}\n\t\t<input type='text' name='video{$video_disabled}' size='60' id='video_text' style='float:left;' value=\"{$video}\" {$video_disabled}/><br />\n\t\t{$video_button}\n\t\t<a href='javascript:showHideVideoPreview();' id='show_preview_button' class='button secondary {$vidbtn_vis}'>" . wfMsg('show_preview') . "</a>\n\t\t{$video_msg}\n\t</div>\n\t<div id='viewpreview' class='{$vidpreview_vis} {$section_class}' style='text-align: center; margin-top: 5px;'>\n\t\t<center><a onclick='showHideVideoPreview();'>" . wfMsg('ep_hide_preview') . "</a></center><br/>\n\t\t<div id='viewpreview_innards'>{$vidpreview}</div>\n\t</div>\n\n\t<div id='tips' class='{$section_class}'>\n\t\t<h2>" . wfMsg('tips') . "\n\t\t\t<div class='head_details'>" . wfMsg('listhints') . "</div>\n\t\t\t<a href=\"{$wgScriptPath}/" . wfMsg('writers-guide-url') . "?section=2#" . wfMsg('tips') . "\" target=\"new\">" . wfMsg('moreinfo') . "</a>\n\t\t</h2>\n\t\t<textarea name='tips' rows='{$wgRequest->getVal('txtarea_tips_text', 12)}' cols='100' wrap='virtual' onKeyUp='addStars(event, document.editform.tips);' tabindex='5' id='tips_text'>{$tips}</textarea>\n\t\t<a href='#' class='button secondary add_image_button' onclick='easyImageUpload.doEIUModal(\"tips\"); return false;'>" . wfMsg('eiu-add-image-to-tips') . "</a>\n\t</div>\n\n\t<div id='warnings' class='{$section_class}'>\n\t\t<h2>" . wfMsg('warnings') . "\n\t\t\t<div class='head_details'>" . wfMsg('optionallist') . "</div>\n\t\t\t<a href=\"{$wgScriptPath}/" . wfMsg('writers-guide-url') . "?section=3#" . wfMsg('warnings') . "\" target=\"new\">" . wfMsg('moreinfo') . "</a>\n\t\t</h2>\n\t\t<textarea name='warnings' rows='{$wgRequest->getVal('txtarea_warnings_text', 4)}' cols='100' wrap='virtual' onKeyUp='addStars(event, document.editform.warnings);' id='warnings_text' tabindex=\"6\" id='warnings_text'>{$warns}</textarea>\n\t\t<a href='#' class='button secondary add_image_button' onclick='easyImageUpload.doEIUModal(\"warnings\"); return false;'>" . wfMsg('eiu-add-image-to-warnings') . "</a>\n\t</div>\n\n\t<div id='thingsyoullneed' class='{$things_vis} {$section_class}'>\n\t\t<h2>" . wfMsg('thingsyoullneed') . "\n\t\t\t<div class='head_details'>" . wfMsg('items') . "</div>\n\t\t\t<a href=\"{$wgScriptPath}/" . wfMsg('writers-guide-url') . "?section=4#" . wfMsg('thingsyoullneed') . "\" target=\"new\">" . wfMsg('moreinfo') . "</a>\n\t\t</h2>\n\t\t<textarea name='thingsyoullneed' rows='4' cols='65' wrap='virtual' onKeyUp='addStars(event, document.editform.thingsyoullneed);' tabindex='7' id='thingsyoullneed_text'>{$things}</textarea>\n\t\t<a href='#' class='button secondary add_image_button' onclick='easyImageUpload.doEIUModal(\"thingsyoullneed\"); return false;'>" . wfMsg('eiu-add-image-to-thingsyoullneed') . "</a>\n\t</div>\n\n\t<div id='relatedwikihows' class='{$related_vis} {$section_class}'>\n\t\t<h2>" . wfMsg('relatedarticlestext') . "\n\t\t\t<div class='head_details'>" . wfMsg('relatedlist') . "</div>\n\t\t\t<a href=\"{$wgScriptPath}/" . wfMsg('writers-guide-url') . "?section=5#" . wfMsg('related-wikihows-url') . "\" target=\"new\">" . wfMsg('moreinfo') . "</a>\n\t\t</h2>\n\t\t<div id='related_buttons'>\n\t\t\t<a href='#'  class='button secondary' onclick='moveRelated(true);return false;' >" . wfMsg('epw_move_up') . "</a>\n\t\t\t<a href='#' class='button secondary' onclick='moveRelated(false);return false;'>" . wfMsg('epw_move_down') . "</a>\n\t\t\t<a href='#' class='button red' onclick='removeRelated(); return false;'>" . wfMsg('epw_remove') . "</a>\n\t\t\t<br />\n\t\t\t<br />\n\t\t</div>\n\t\t<input type=hidden value=\"\" name=\"related_list\">\n\t\t<select size='4' name='related' id='related_select' ondblclick='viewRelated();'>\n\t\t\t{$relatedHTML}\n\t\t</select>\n\t\t<br />\n\t\t<br />\n\t\t<br class='clearall'/>\n\t\t<div>\n\t\t\t<b>" . wfMsg('addtitle') . "</b><br />\n\t\t\t<input type='text' autocomplete=\"off\" maxLength='256' name='q' value='' onKeyPress=\"return keyxxx(event);\" tabindex='8'>\n\t\t</div>\n\t\t<a href='#' id='add_button' class='button secondary' onclick='add_related();return false;'>" . wfMsg('epw_add') . "</a>\n\t\t<br class='clearall'/>\n\t</div>\n\n<script language=\"JavaScript\">\n\tvar js_enabled = document.getElementById('related');\n\t\t if (js_enabled != null) {\n\t\t\t\t js_enabled.className = 'display';\n\t\t\t}\n\t</script>\n\t<noscript>\n\t\t<input type='hidden' name='no_js' value='true'>\n\t\t<div id='related'>\n\t\t\t<textarea name='related_no_js' rows='4' cols='65' wrap='virtual' onKeyUp='addStars(event, document.editform.related_no_js);' id='related_no_js' tabindex='8'>{$related_text}</textarea>\n\t\t</div>\n\t</noscript>\n\n\t<div id='sources' class='{$sources_vis} {$section_class}'>\n\t\t<h2>" . wfMsg('sources') . "\n\t\t\t<div class='head_details'>" . wfMsg('linkstosites') . "</div>\n\t\t\t<a href=\"{$wgScriptPath}/" . wfMsg('writers-guide-url') . "?section=2#" . wfMsg('sources-links-url') . "\" target=\"new\"> " . wfMsg('moreinfo') . "</a>\n\t\t</h2>\n\t\t<textarea name='sources' rows='3' cols='100' wrap='virtual' onKeyUp='addStars(event, document.editform.sources);' id='sources' tabindex='9'>{$sources}</textarea>\n\t</div>\n\n\t<div class='{$section_class}'>\n\t\t<h2>" . wfMsg('optional_options') . "</h2>\n\t\t{$categoryHTML}\n\n\t\t<div id='optional_sections'>\n\t\t\t<h5>" . wfMsg('optionalsections') . "</h5>\n\t\t\t<ul>\n\t\t\t\t<li><input type='checkbox' id='thingsyoullneed_checkbox' name='thingsyoullneed_checkbox' onclick='showhiderow(\"thingsyoullneed\", \"thingsyoullneed_checkbox\");' {$things_checked} /> <label for='thingsyoullneed_checkbox'>" . wfMsg('thingsyoullneed') . "</label></li>\n\t\t\t\t<li><input type='checkbox' id='related_checkbox' name='related_checkbox' onclick='showhiderow(\"relatedwikihows\", \"related_checkbox\");' {$related_checked} > <label for='related_checkbox'>" . wfMsg('relatedwikihows') . "</label></li>\n\t\t\t\t<li><input type='checkbox' id='sources_checkbox' name='sources_checkbox' onclick='showhiderow(\"sources\", \"sources_checkbox\");' {$sources_checked} > <label for='sources_checkbox'>" . wfMsg('sources') . "</label></li>\n\t\t\t\t<li><input type='checkbox' id='ingredients_checkbox' name='ingredients_checkbox' onclick='showhiderow(\"ingredients\", \"ingredients_checkbox\");' {$ingredients_checked} > <label for='ingredients_checkbox'>" . wfMsg('ingredients_checkbox') . "</label></li>\n\t\t\t</ul>\n\t\t</div>\n\t</div>\n\t\n\t<div class='{$section_class}'>\n\t\t<div class='editOptions'>\n\t\t\t<h2>" . wfMsg('editdetails') . "\n\t\t\t\t<div class='head_details'>" . wfMsg('summaryedit') . "</div>\n\t\t\t\t<a href=\"{$wgScriptPath}/" . wfMsg('writers-guide-url') . "?section=2#" . wfMsg('summary') . "\" target=\"new\"> " . wfMsg('moreinfo') . "</a>\n\t\t\t</h2>\n\t\t\t{$editsummary}\n\t\t\t{$checkboxhtml}\n\t\t\t{$undo}\n\t\t\t<input type='hidden' value=\"{$token}\" name=\"wpEditToken\" />\n\t\t\t<input type='hidden' value=\"{$token1}\" name=\"wpEditTokenTrack\" />\n\t\t\t<div class='editButtons'>\n\t\t\t\t<a href=\"javascript:history.back()\" id=\"wpCancel\" class=\"button secondary\">" . wfMsg('cancel') . "</a>\n\t\t\t\t{$buttonshtml}\n\t\t\t</div>\n\t\t\t{$copywarn}\n\t\t</div>\n\t</div>\n\t<input type='hidden' value=\"" . htmlspecialchars($this->section) . "\" name=\"wpSection\" />\n\t<input type='hidden' value=\"{$this->edittime}\" name=\"wpEdittime\" />\n");
     if ($this->isConflict) {
         require_once "DifferenceEngine.php";
         $wgOut->addHTML("<h2>" . wfMsg("yourdiff") . "</h2>\n");
         DifferenceEngine::showDiff($this->textbox2, $this->textbox1, wfMsg("yourtext"), wfMsg("storedversion"));
     }
     if ($wgUser->getOption('hidepersistantsavebar', 0) == 0) {
         $wgOut->addHTML(" <div id='edit_page_footer'>\n\t\t\t\t<table class='edit_footer'><tr><td class='summary'>\n\t\t\t\t" . wfMsg('editsummary') . ": &nbsp; {$editsummary1}</td>\n\t\t\t\t<td class='buttons'>{$footerbuttons}</td></tr></table>\n\t\t\t\t</div> ");
     }
     $wgOut->addHTML("</form></div>\n");
 }
Ejemplo n.º 14
0
    /**
     * Replace entire showEditForm, need to add our own textbox and stuff
     */
    function showEditForm($formCallback = null)
    {
        global $wgOut, $wgUser, $wgLang, $wgContLang, $wgMaxArticleSize, $wgTitle, $wgRequest;
        # If $wgTitle is null, that means we're in API mode.
        # Some hook probably called this function  without checking
        # for is_null($wgTitle) first. Bail out right here so we don't
        # do lots of work just to discard it right after.
        if (is_null($wgTitle)) {
            return;
        }
        $fname = 'EditPage::showEditForm';
        wfProfileIn($fname);
        $sk = $wgUser->getSkin();
        wfRunHooks('EditPage::showEditForm:initial', array(&$this));
        #need to parse the preview early so that we know which templates are used,
        #otherwise users with "show preview after edit box" will get a blank list
        #we parse this near the beginning so that setHeaders can do the title
        #setting work instead of leaving it in getPreviewText
        $previewOutput = '';
        if ($this->formtype == 'preview') {
            $previewOutput = $this->getPreviewText();
        }
        $this->setHeaders();
        # Enabled article-related sidebar, toplinks, etc.
        $wgOut->setArticleRelated(true);
        if ($this->isConflict) {
            $wgOut->wrapWikiMsg("<div class='mw-explainconflict'>\n\$1</div>", 'explainconflict');
            $this->textbox2 = $this->textbox1;
            $this->textbox1 = $this->getContent();
            $this->edittime = $this->mArticle->getTimestamp();
            # MeanEditor: too complicated for visual editing
            $this->noVisualEditor = false;
        } else {
            if ($this->section != '' && $this->section != 'new') {
                $matches = array();
                if (!$this->summary && !$this->preview && !$this->diff) {
                    preg_match("/^(=+)(.+)\\1/mi", $this->textbox1, $matches);
                    if (!empty($matches[2])) {
                        global $wgParser;
                        $this->summary = "/* " . $wgParser->stripSectionName(trim($matches[2])) . " */ ";
                    }
                }
            }
            if ($this->missingComment) {
                $wgOut->wrapWikiMsg('<div id="mw-missingcommenttext">$1</div>', 'missingcommenttext');
            }
            if ($this->missingSummary && $this->section != 'new') {
                $wgOut->wrapWikiMsg('<div id="mw-missingsummary">$1</div>', 'missingsummary');
            }
            if ($this->missingSummary && $this->section == 'new') {
                $wgOut->wrapWikiMsg('<div id="mw-missingcommentheader">$1</div>', 'missingcommentheader');
            }
            if ($this->hookError !== '') {
                $wgOut->addWikiText($this->hookError);
            }
            if (!$this->checkUnicodeCompliantBrowser()) {
                $wgOut->addWikiMsg('nonunicodebrowser');
            }
            if (isset($this->mArticle) && isset($this->mArticle->mRevision)) {
                // Let sysop know that this will make private content public if saved
                if (!$this->mArticle->mRevision->userCan(Revision::DELETED_TEXT)) {
                    $wgOut->wrapWikiMsg("<div class='mw-warning plainlinks'>\n\$1</div>\n", 'rev-deleted-text-permission');
                } else {
                    if ($this->mArticle->mRevision->isDeleted(Revision::DELETED_TEXT)) {
                        $wgOut->wrapWikiMsg("<div class='mw-warning plainlinks'>\n\$1</div>\n", 'rev-deleted-text-view');
                    }
                }
                if (!$this->mArticle->mRevision->isCurrent()) {
                    $this->mArticle->setOldSubtitle($this->mArticle->mRevision->getId());
                    $wgOut->addWikiMsg('editingold');
                }
            }
        }
        if (wfReadOnly()) {
            $wgOut->wrapWikiMsg("<div id=\"mw-read-only-warning\">\n\$1\n</div>", array('readonlywarning', wfReadOnlyReason()));
            # MeanEditor: visual editing makes no sense here
            $this->noVisualEditor = true;
        } elseif ($wgUser->isAnon() && $this->formtype != 'preview') {
            $wgOut->wrapWikiMsg('<div id="mw-anon-edit-warning">$1</div>', 'anoneditwarning');
        } else {
            if ($this->isCssJsSubpage) {
                # Check the skin exists
                if ($this->isValidCssJsSubpage) {
                    if ($this->formtype !== 'preview') {
                        $wgOut->addWikiMsg('usercssjsyoucanpreview');
                    }
                } else {
                    $wgOut->addWikiMsg('userinvalidcssjstitle', $wgTitle->getSkinFromCssJsSubpage());
                }
            }
        }
        $classes = array();
        // Textarea CSS
        if ($this->mTitle->getNamespace() == NS_MEDIAWIKI) {
        } elseif ($this->mTitle->isProtected('edit')) {
            # Is the title semi-protected?
            if ($this->mTitle->isSemiProtected()) {
                $noticeMsg = 'semiprotectedpagewarning';
                $classes[] = 'mw-textarea-sprotected';
            } else {
                # Then it must be protected based on static groups (regular)
                $noticeMsg = 'protectedpagewarning';
                $classes[] = 'mw-textarea-protected';
            }
            $wgOut->addHTML("<div class='mw-warning-with-logexcerpt'>\n");
            $wgOut->addWikiMsg($noticeMsg);
            LogEventsList::showLogExtract($wgOut, 'protect', $this->mTitle->getPrefixedText(), '', 1);
            $wgOut->addHTML("</div>\n");
        }
        if ($this->mTitle->isCascadeProtected()) {
            # Is this page under cascading protection from some source pages?
            list($cascadeSources, ) = $this->mTitle->getCascadeProtectionSources();
            $notice = "<div class='mw-cascadeprotectedwarning'>\$1\n";
            $cascadeSourcesCount = count($cascadeSources);
            if ($cascadeSourcesCount > 0) {
                # Explain, and list the titles responsible
                foreach ($cascadeSources as $page) {
                    $notice .= '* [[:' . $page->getPrefixedText() . "]]\n";
                }
            }
            $notice .= '</div>';
            $wgOut->wrapWikiMsg($notice, array('cascadeprotectedwarning', $cascadeSourcesCount));
        }
        if (!$this->mTitle->exists() && $this->mTitle->getRestrictions('create')) {
            $wgOut->wrapWikiMsg('<div class="mw-titleprotectedwarning">$1</div>', 'titleprotectedwarning');
        }
        if ($this->kblength === false) {
            # MeanEditor: the length will probably be different in HTML
            $this->kblength = (int) (strlen($this->textbox1) / 1024);
        }
        if ($this->tooBig || $this->kblength > $wgMaxArticleSize) {
            $wgOut->addHTML("<div class='error' id='mw-edit-longpageerror'>\n");
            $wgOut->addWikiMsg('longpageerror', $wgLang->formatNum($this->kblength), $wgLang->formatNum($wgMaxArticleSize));
            $wgOut->addHTML("</div>\n");
        } elseif ($this->kblength > 29) {
            $wgOut->addHTML("<div id='mw-edit-longpagewarning'>\n");
            $wgOut->addWikiMsg('longpagewarning', $wgLang->formatNum($this->kblength));
            $wgOut->addHTML("</div>\n");
        }
        $q = 'action=' . $this->action;
        #if ( "no" == $redirect ) { $q .= "&redirect=no"; }
        $action = $wgTitle->escapeLocalURL($q);
        $summary = wfMsg('summary');
        $subject = wfMsg('subject');
        $cancel = $sk->makeKnownLink($wgTitle->getPrefixedText(), wfMsgExt('cancel', array('parseinline')));
        $separator = wfMsgExt('pipe-separator', 'escapenoentities');
        $edithelpurl = Skin::makeInternalOrExternalUrl(wfMsgForContent('edithelppage'));
        $edithelp = '<a target="helpwindow" href="' . $edithelpurl . '">' . htmlspecialchars(wfMsg('edithelp')) . '</a> ' . htmlspecialchars(wfMsg('newwindow'));
        global $wgRightsText;
        if ($wgRightsText) {
            $copywarnMsg = array('copyrightwarning', '[[' . wfMsgForContent('copyrightpage') . ']]', $wgRightsText);
        } else {
            $copywarnMsg = array('copyrightwarning2', '[[' . wfMsgForContent('copyrightpage') . ']]');
        }
        /* MeanEditor: always disable the toolbar */
        if ($wgUser->getOption('showtoolbar') and !$this->isCssJsSubpage) {
            # prepare toolbar for edit buttons
            $toolbar = '';
        } else {
            $toolbar = '';
        }
        // activate checkboxes if user wants them to be always active
        if (!$this->preview && !$this->diff) {
            # Sort out the "watch" checkbox
            if ($wgUser->getOption('watchdefault')) {
                # Watch all edits
                $this->watchthis = true;
            } elseif ($wgUser->getOption('watchcreations') && !$this->mTitle->exists()) {
                # Watch creations
                $this->watchthis = true;
            } elseif ($this->mTitle->userIsWatching()) {
                # Already watched
                $this->watchthis = true;
            }
            # May be overriden by request parameters
            if ($wgRequest->getBool('watchthis')) {
                $this->watchthis = true;
            }
            if ($wgUser->getOption('minordefault')) {
                $this->minoredit = true;
            }
            # MeanEditor: User preference
            if ($wgUser->getOption('prefer_traditional_editor')) {
                $this->userWantsTraditionalEditor = true;
            }
        }
        $wgOut->addHTML($this->editFormPageTop);
        if ($wgUser->getOption('previewontop')) {
            $this->displayPreviewArea($previewOutput, true);
        }
        $wgOut->addHTML($this->editFormTextTop);
        # if this is a comment, show a subject line at the top, which is also the edit summary.
        # Otherwise, show a summary field at the bottom
        $summarytext = $wgContLang->recodeForEdit($this->summary);
        # If a blank edit summary was previously provided, and the appropriate
        # user preference is active, pass a hidden tag as wpIgnoreBlankSummary. This will stop the
        # user being bounced back more than once in the event that a summary
        # is not required.
        #####
        # For a bit more sophisticated detection of blank summaries, hash the
        # automatic one and pass that in the hidden field wpAutoSummary.
        $summaryhiddens = '';
        if ($this->missingSummary) {
            $summaryhiddens .= Xml::hidden('wpIgnoreBlankSummary', true);
        }
        $autosumm = $this->autoSumm ? $this->autoSumm : md5($this->summary);
        $summaryhiddens .= Xml::hidden('wpAutoSummary', $autosumm);
        if ($this->section == 'new') {
            $commentsubject = '';
            if (!$wgRequest->getBool('nosummary')) {
                # Add a class if 'missingsummary' is triggered to allow styling of the summary line
                $summaryClass = $this->missingSummary ? 'mw-summarymissed' : 'mw-summary';
                $commentsubject = Xml::tags('label', array('for' => 'wpSummary'), $subject);
                $commentsubject = Xml::tags('span', array('class' => $summaryClass, 'id' => "wpSummaryLabel"), $commentsubject);
                $commentsubject .= '&nbsp;';
                $commentsubject .= Xml::input('wpSummary', 60, $summarytext, array('id' => 'wpSummary', 'maxlength' => '200', 'tabindex' => '1'));
            }
            $editsummary = "<div class='editOptions'>\n";
            global $wgParser;
            $formattedSummary = wfMsgForContent('newsectionsummary', $wgParser->stripSectionName($this->summary));
            $subjectpreview = $summarytext && $this->preview ? "<div class=\"mw-summary-preview\">" . wfMsg('subject-preview') . $sk->commentBlock($formattedSummary, $this->mTitle, true) . "</div>\n" : '';
            $summarypreview = '';
        } else {
            $commentsubject = '';
            # Add a class if 'missingsummary' is triggered to allow styling of the summary line
            $summaryClass = $this->missingSummary ? 'mw-summarymissed' : 'mw-summary';
            $editsummary = Xml::tags('label', array('for' => 'wpSummary'), $summary);
            $editsummary = Xml::tags('span', array('class' => $summaryClass, 'id' => "wpSummaryLabel"), $editsummary) . ' ';
            $editsummary .= Xml::input('wpSummary', 60, $summarytext, array('id' => 'wpSummary', 'maxlength' => '200', 'tabindex' => '1'));
            // No idea where this is closed.
            $editsummary = Xml::openElement('div', array('class' => 'editOptions')) . $editsummary . '<br/>';
            $summarypreview = '';
            if ($summarytext && $this->preview) {
                $summarypreview = Xml::tags('div', array('class' => 'mw-summary-preview'), wfMsg('summary-preview') . $sk->commentBlock($this->summary, $this->mTitle));
            }
            $subjectpreview = '';
        }
        $commentsubject .= $summaryhiddens;
        # Set focus to the edit box on load, except on preview or diff, where it would interfere with the display
        if (!$this->preview && !$this->diff) {
            $wgOut->setOnloadHandler('document.editform.wpTextbox1.focus()');
        }
        $templates = $this->getTemplates();
        $formattedtemplates = $sk->formatTemplates($templates, $this->preview, $this->section != '');
        $hiddencats = $this->mArticle->getHiddenCategories();
        $formattedhiddencats = $sk->formatHiddenCategories($hiddencats);
        global $wgUseMetadataEdit;
        if ($wgUseMetadataEdit) {
            $metadata = $this->mMetaData;
            $metadata = htmlspecialchars($wgContLang->recodeForEdit($metadata));
            $top = wfMsgWikiHtml('metadata_help');
            /* ToDo: Replace with clean code */
            $ew = $wgUser->getOption('editwidth');
            if ($ew) {
                $ew = " style=\"width:100%\"";
            } else {
                $ew = '';
            }
            $cols = $wgUser->getIntOption('cols');
            /* /ToDo */
            $metadata = $top . "<textarea name='metadata' rows='3' cols='{$cols}'{$ew}>{$metadata}</textarea>";
        } else {
            $metadata = "";
        }
        $recreate = '';
        if ($this->wasDeletedSinceLastEdit()) {
            if ('save' != $this->formtype) {
                $wgOut->wrapWikiMsg("<div class='error mw-deleted-while-editing'>\n\$1</div>", 'deletedwhileediting');
            } else {
                // Hide the toolbar and edit area, user can click preview to get it back
                // Add an confirmation checkbox and explanation.
                $toolbar = '';
                $recreate = '<div class="mw-confirm-recreate">' . $wgOut->parse(wfMsg('confirmrecreate', $this->lastDelete->user_name, $this->lastDelete->log_comment)) . Xml::checkLabel(wfMsg('recreate'), 'wpRecreate', 'wpRecreate', false, array('title' => $sk->titleAttrib('recreate'), 'tabindex' => 1, 'id' => 'wpRecreate')) . '</div>';
            }
        }
        $tabindex = 2;
        $checkboxes = $this->getCheckboxes($tabindex, $sk, array('minor' => $this->minoredit, 'watch' => $this->watchthis, 'want_traditional_editor' => $this->userWantsTraditionalEditor));
        $checkboxhtml = implode($checkboxes, "\n");
        $buttons = $this->getEditButtons($tabindex);
        $buttonshtml = implode($buttons, "\n");
        $safemodehtml = $this->checkUnicodeCompliantBrowser() ? '' : Xml::hidden('safemode', '1');
        $wgOut->addHTML(<<<END
{$toolbar}
<form id="editform" name="editform" method="post" action="{$action}" enctype="multipart/form-data">
END
);
        if (is_callable($formCallback)) {
            call_user_func_array($formCallback, array(&$wgOut));
        }
        wfRunHooks('EditPage::showEditForm:fields', array(&$this, &$wgOut));
        // Put these up at the top to ensure they aren't lost on early form submission
        $this->showFormBeforeText();
        $wgOut->addHTML(<<<END
{$recreate}
{$commentsubject}
{$subjectpreview}
{$this->editFormTextBeforeContent}
END
);
        if ($this->isConflict || $this->diff) {
            # MeanEditor: should be redundant, but let's be sure
            $this->noVisualEditor = true;
        }
        # MeanEditor: also apply htmlspecialchars? See $encodedtext
        $html_text = $this->safeUnicodeOutput($this->textbox1);
        if (!($this->noVisualEditor || $this->userWantsTraditionalEditor)) {
            $this->noVisualEditor = wfRunHooks('EditPage::wiki2html', array($this->mArticle, $wgUser, &$this, &$html_text));
        }
        if (!$this->noVisualEditor && !$this->userWantsTraditionalEditor) {
            $this->noVisualEditor = wfRunHooks('EditPage::showBox', array(&$this, $html_text, $rows, $cols, $ew));
        }
        if (!$this->noVisualEditor && !$this->userWantsTraditionalEditor) {
            $wgOut->addHTML("<input type='hidden' value=\"0\" name=\"wpNoVisualEditor\" />\n");
        } else {
            $wgOut->addHTML("<input type='hidden' value=\"1\" name=\"wpNoVisualEditor\" />\n");
            $this->showTextbox1($classes);
        }
        $wgOut->wrapWikiMsg("<div id=\"editpage-copywarn\">\n\$1\n</div>", $copywarnMsg);
        $wgOut->addHTML(<<<END
{$this->editFormTextAfterWarn}
{$metadata}
{$editsummary}
{$summarypreview}
{$checkboxhtml}
{$safemodehtml}
END
);
        $wgOut->addHTML("<div class='editButtons'>\n{$buttonshtml}\n\t<span class='editHelp'>{$cancel}{$separator}{$edithelp}</span>\n</div><!-- editButtons -->\n</div><!-- editOptions -->");
        /**
         * To make it harder for someone to slip a user a page
         * which submits an edit form to the wiki without their
         * knowledge, a random token is associated with the login
         * session. If it's not passed back with the submission,
         * we won't save the page, or render user JavaScript and
         * CSS previews.
         *
         * For anon editors, who may not have a session, we just
         * include the constant suffix to prevent editing from
         * broken text-mangling proxies.
         */
        $token = htmlspecialchars($wgUser->editToken());
        $wgOut->addHTML("\n<input type='hidden' value=\"{$token}\" name=\"wpEditToken\" />\n");
        $this->showEditTools();
        $wgOut->addHTML(<<<END
{$this->editFormTextAfterTools}
<div class='templatesUsed'>
{$formattedtemplates}
</div>
<div class='hiddencats'>
{$formattedhiddencats}
</div>
END
);
        if ($this->isConflict && wfRunHooks('EditPageBeforeConflictDiff', array(&$this, &$wgOut))) {
            $wgOut->wrapWikiMsg('==$1==', "yourdiff");
            $de = new DifferenceEngine($this->mTitle);
            $de->setText($this->textbox2, $this->textbox1);
            $de->showDiff(wfMsg("yourtext"), wfMsg("storedversion"));
            $wgOut->wrapWikiMsg('==$1==', "yourtext");
            $this->showTextbox2();
        }
        $wgOut->addHTML($this->editFormTextBottom);
        $wgOut->addHTML("</form>\n");
        if (!$wgUser->getOption('previewontop')) {
            $this->displayPreviewArea($previewOutput, false);
        }
        wfProfileOut($fname);
    }
Ejemplo n.º 15
0
 /**
  * Create a HTMLForm descriptor for the core login fields.
  * @param FakeAuthTemplate $template B/C data (not used but needed by getBCFieldDefinitions)
  * @return array
  */
 protected function getFieldDefinitions($template)
 {
     global $wgEmailConfirmToEdit, $wgLoginLanguageSelector;
     $isLoggedIn = $this->getUser()->isLoggedIn();
     $continuePart = $this->isContinued() ? 'continue-' : '';
     $anotherPart = $isLoggedIn ? 'another-' : '';
     $expiration = $this->getRequest()->getSession()->getProvider()->getRememberUserDuration();
     $expirationDays = ceil($expiration / (3600 * 24));
     $secureLoginLink = '';
     if ($this->mSecureLoginUrl) {
         $secureLoginLink = Html::element('a', ['href' => $this->mSecureLoginUrl, 'class' => 'mw-ui-flush-right mw-secure'], $this->msg('userlogin-signwithsecure')->text());
     }
     $usernameHelpLink = '';
     if (!$this->msg('createacct-helpusername')->isDisabled()) {
         $usernameHelpLink = Html::rawElement('span', ['class' => 'mw-ui-flush-right'], $this->msg('createacct-helpusername')->parse());
     }
     if ($this->isSignup()) {
         $fieldDefinitions = ['statusarea' => ['type' => 'info', 'raw' => true, 'default' => Html::element('div', ['id' => 'mw-createacct-status-area']), 'weight' => -105], 'username' => ['label-raw' => $this->msg('userlogin-yourname')->escaped() . $usernameHelpLink, 'id' => 'wpName2', 'placeholder-message' => $isLoggedIn ? 'createacct-another-username-ph' : 'userlogin-yourname-ph'], 'mailpassword' => ['type' => 'check', 'label-message' => 'createaccountmail', 'name' => 'wpCreateaccountMail', 'id' => 'wpCreateaccountMail'], 'password' => ['id' => 'wpPassword2', 'placeholder-message' => 'createacct-yourpassword-ph', 'hide-if' => ['===', 'wpCreateaccountMail', '1']], 'domain' => [], 'retype' => ['baseField' => 'password', 'type' => 'password', 'label-message' => 'createacct-yourpasswordagain', 'id' => 'wpRetype', 'cssclass' => 'loginPassword', 'size' => 20, 'validation-callback' => function ($value, $alldata) {
             if (empty($alldata['mailpassword']) && !empty($alldata['password'])) {
                 if (!$value) {
                     return $this->msg('htmlform-required');
                 } elseif ($value !== $alldata['password']) {
                     return $this->msg('badretype');
                 }
             }
             return true;
         }, 'hide-if' => ['===', 'wpCreateaccountMail', '1'], 'placeholder-message' => 'createacct-yourpasswordagain-ph'], 'email' => ['type' => 'email', 'label-message' => $wgEmailConfirmToEdit ? 'createacct-emailrequired' : 'createacct-emailoptional', 'id' => 'wpEmail', 'cssclass' => 'loginText', 'size' => '20', 'required' => $wgEmailConfirmToEdit, 'validation-callback' => function ($value, $alldata) {
             global $wgEmailConfirmToEdit;
             // AuthManager will check most of these, but that will make the auth
             // session fail and this won't, so nicer to do it this way
             if (!$value && $wgEmailConfirmToEdit) {
                 // no point in allowing registration without email when email is
                 // required to edit
                 return $this->msg('noemailtitle');
             } elseif (!$value && !empty($alldata['mailpassword'])) {
                 // cannot send password via email when there is no email address
                 return $this->msg('noemailcreate');
             } elseif ($value && !Sanitizer::validateEmail($value)) {
                 return $this->msg('invalidemailaddress');
             }
             return true;
         }, 'placeholder-message' => 'createacct-' . $anotherPart . 'email-ph'], 'realname' => ['type' => 'text', 'help-message' => $isLoggedIn ? 'createacct-another-realname-tip' : 'prefs-help-realname', 'label-message' => 'createacct-realname', 'cssclass' => 'loginText', 'size' => 20, 'id' => 'wpRealName'], 'reason' => ['type' => 'text', 'label-message' => 'createacct-reason', 'cssclass' => 'loginText', 'id' => 'wpReason', 'size' => '20', 'placeholder-message' => 'createacct-reason-ph'], 'extrainput' => [], 'createaccount' => ['type' => 'submit', 'default' => $this->msg('createacct-' . $anotherPart . $continuePart . 'submit')->text(), 'name' => 'wpCreateaccount', 'id' => 'wpCreateaccount', 'weight' => 100]];
     } else {
         $fieldDefinitions = ['username' => ['label-raw' => $this->msg('userlogin-yourname')->escaped() . $secureLoginLink, 'id' => 'wpName1', 'placeholder-message' => 'userlogin-yourname-ph'], 'password' => ['id' => 'wpPassword1', 'placeholder-message' => 'userlogin-yourpassword-ph'], 'domain' => [], 'extrainput' => [], 'rememberMe' => ['type' => 'check', 'name' => 'wpRemember', 'label-message' => $this->msg('userlogin-remembermypassword')->numParams($expirationDays), 'id' => 'wpRemember'], 'loginattempt' => ['type' => 'submit', 'default' => $this->msg('pt-login-' . $continuePart . 'button')->text(), 'id' => 'wpLoginAttempt', 'weight' => 100], 'linkcontainer' => ['type' => 'info', 'cssclass' => 'mw-form-related-link-container mw-userlogin-help', 'raw' => true, 'default' => Html::element('a', ['href' => Skin::makeInternalOrExternalUrl(wfMessage('helplogin-url')->inContentLanguage()->text())], $this->msg('userlogin-helplink2')->text()), 'weight' => 200], 'skipReset' => ['weight' => 110, 'flags' => []]];
     }
     $fieldDefinitions['username'] += ['type' => 'text', 'name' => 'wpName', 'cssclass' => 'loginText', 'size' => 20];
     $fieldDefinitions['password'] += ['type' => 'password', 'name' => 'wpPassword', 'cssclass' => 'loginPassword', 'size' => 20];
     if ($template->get('header') || $template->get('formheader')) {
         // B/C for old extensions that haven't been converted to AuthManager (or have been
         // but somebody is using the old version) and still use templates via the
         // UserCreateForm/UserLoginForm hook.
         // 'header' used by ConfirmEdit, CondfirmAccount, Persona, WikimediaIncubator, SemanticSignup
         // 'formheader' used by MobileFrontend
         $fieldDefinitions['header'] = ['type' => 'info', 'raw' => true, 'default' => $template->get('header') ?: $template->get('formheader'), 'weight' => -110];
     }
     if ($this->mEntryError) {
         $fieldDefinitions['entryError'] = ['type' => 'info', 'default' => Html::rawElement('div', ['class' => $this->mEntryErrorType . 'box'], $this->mEntryError), 'raw' => true, 'rawrow' => true, 'weight' => -100];
     }
     if (!$this->showExtraInformation()) {
         unset($fieldDefinitions['linkcontainer'], $fieldDefinitions['signupend']);
     }
     if ($this->isSignup() && $this->showExtraInformation()) {
         // blank signup footer for site customization
         // uses signupend-https for HTTPS requests if it's not blank, signupend otherwise
         $signupendMsg = $this->msg('signupend');
         $signupendHttpsMsg = $this->msg('signupend-https');
         if (!$signupendMsg->isDisabled()) {
             $usingHTTPS = $this->getRequest()->getProtocol() === 'https';
             $signupendText = $usingHTTPS && !$signupendHttpsMsg->isBlank() ? $signupendHttpsMsg->parse() : $signupendMsg->parse();
             $fieldDefinitions['signupend'] = ['type' => 'info', 'raw' => true, 'default' => Html::rawElement('div', ['id' => 'signupend'], $signupendText), 'weight' => 225];
         }
     }
     if (!$this->isSignup() && $this->showExtraInformation()) {
         $passwordReset = new PasswordReset($this->getConfig(), AuthManager::singleton());
         if ($passwordReset->isAllowed($this->getUser())->isGood()) {
             $fieldDefinitions['passwordReset'] = ['type' => 'info', 'raw' => true, 'cssclass' => 'mw-form-related-link-container', 'default' => Linker::link(SpecialPage::getTitleFor('PasswordReset'), $this->msg('userlogin-resetpassword-link')->escaped()), 'weight' => 230];
         }
         // Don't show a "create account" link if the user can't.
         if ($this->showCreateAccountLink()) {
             // link to the other action
             $linkTitle = $this->getTitleFor($this->isSignup() ? 'Userlogin' : 'CreateAccount');
             $linkq = $this->getReturnToQueryStringFragment();
             // Pass any language selection on to the mode switch link
             if ($wgLoginLanguageSelector && $this->mLanguage) {
                 $linkq .= '&uselang=' . $this->mLanguage;
             }
             $loggedIn = $this->getUser()->isLoggedIn();
             $fieldDefinitions['createOrLogin'] = ['type' => 'info', 'raw' => true, 'linkQuery' => $linkq, 'default' => function ($params) use($loggedIn, $linkTitle) {
                 return Html::rawElement('div', ['id' => 'mw-createaccount' . (!$loggedIn ? '-cta' : ''), 'class' => $loggedIn ? 'mw-form-related-link-container' : 'mw-ui-vform-field'], ($loggedIn ? '' : $this->msg('userlogin-noaccount')->escaped()) . Html::element('a', ['id' => 'mw-createaccount-join' . ($loggedIn ? '-loggedin' : ''), 'href' => $linkTitle->getLocalURL($params['linkQuery']), 'class' => $loggedIn ? '' : 'mw-ui-button', 'tabindex' => 100], $this->msg($loggedIn ? 'userlogin-createanother' : 'userlogin-joinproject')->escaped()));
             }, 'weight' => 235];
         }
     }
     $fieldDefinitions = $this->getBCFieldDefinitions($fieldDefinitions, $template);
     $fieldDefinitions = array_filter($fieldDefinitions);
     return $fieldDefinitions;
 }
Ejemplo n.º 16
0
 /**
  * Generate the generic "this page has been changed" e-mail text.
  */
 private function composeCommonMailtext()
 {
     global $wgPasswordSender, $wgNoReplyAddress;
     global $wgEnotifFromEditor, $wgEnotifRevealEditorAddress;
     global $wgEnotifImpersonal, $wgEnotifUseRealName;
     $this->composed_common = true;
     # You as the WikiAdmin and Sysops can make use of plenty of
     # named variables when composing your notification emails while
     # simply editing the Meta pages
     $keys = array();
     $postTransformKeys = array();
     $pageTitleUrl = $this->title->getCanonicalURL();
     $pageTitle = $this->title->getPrefixedText();
     if ($this->oldid) {
         // Always show a link to the diff which triggered the mail. See bug 32210.
         $keys['$NEWPAGE'] = "\n\n" . wfMessage('enotif_lastdiff', $this->title->getCanonicalURL(array('diff' => 'next', 'oldid' => $this->oldid)))->inContentLanguage()->text();
         if (!$wgEnotifImpersonal) {
             // For personal mail, also show a link to the diff of all changes
             // since last visited.
             $keys['$NEWPAGE'] .= "\n\n" . wfMessage('enotif_lastvisited', $this->title->getCanonicalURL(array('diff' => '0', 'oldid' => $this->oldid)))->inContentLanguage()->text();
         }
         $keys['$OLDID'] = $this->oldid;
         // Deprecated since MediaWiki 1.21, not used by default. Kept for backwards-compatibility.
         $keys['$CHANGEDORCREATED'] = wfMessage('changed')->inContentLanguage()->text();
     } else {
         # clear $OLDID placeholder in the message template
         $keys['$OLDID'] = '';
         $keys['$NEWPAGE'] = '';
         // Deprecated since MediaWiki 1.21, not used by default. Kept for backwards-compatibility.
         $keys['$CHANGEDORCREATED'] = wfMessage('created')->inContentLanguage()->text();
     }
     $keys['$PAGETITLE'] = $this->title->getPrefixedText();
     $keys['$PAGETITLE_URL'] = $this->title->getCanonicalURL();
     $keys['$PAGEMINOREDIT'] = $this->minorEdit ? wfMessage('minoredit')->inContentLanguage()->text() : '';
     $keys['$UNWATCHURL'] = $this->title->getCanonicalURL('action=unwatch');
     if ($this->editor->isAnon()) {
         # real anon (user:xxx.xxx.xxx.xxx)
         $keys['$PAGEEDITOR'] = wfMessage('enotif_anon_editor', $this->editor->getName())->inContentLanguage()->text();
         $keys['$PAGEEDITOR_EMAIL'] = wfMessage('noemailtitle')->inContentLanguage()->text();
     } else {
         $keys['$PAGEEDITOR'] = $wgEnotifUseRealName && $this->editor->getRealName() !== '' ? $this->editor->getRealName() : $this->editor->getName();
         $emailPage = SpecialPage::getSafeTitleFor('Emailuser', $this->editor->getName());
         $keys['$PAGEEDITOR_EMAIL'] = $emailPage->getCanonicalURL();
     }
     $keys['$PAGEEDITOR_WIKI'] = $this->editor->getUserPage()->getCanonicalURL();
     $keys['$HELPPAGE'] = wfExpandUrl(Skin::makeInternalOrExternalUrl(wfMessage('helppage')->inContentLanguage()->text()));
     # Replace this after transforming the message, bug 35019
     $postTransformKeys['$PAGESUMMARY'] = $this->summary == '' ? ' - ' : $this->summary;
     // Now build message's subject and body
     // Messages:
     // enotif_subject_deleted, enotif_subject_created, enotif_subject_moved,
     // enotif_subject_restored, enotif_subject_changed
     $this->subject = wfMessage('enotif_subject_' . $this->pageStatus)->inContentLanguage()->params($pageTitle, $keys['$PAGEEDITOR'])->text();
     // Messages:
     // enotif_body_intro_deleted, enotif_body_intro_created, enotif_body_intro_moved,
     // enotif_body_intro_restored, enotif_body_intro_changed
     $keys['$PAGEINTRO'] = wfMessage('enotif_body_intro_' . $this->pageStatus)->inContentLanguage()->params($pageTitle, $keys['$PAGEEDITOR'], $pageTitleUrl)->text();
     $body = wfMessage('enotif_body')->inContentLanguage()->plain();
     $body = strtr($body, $keys);
     $body = MessageCache::singleton()->transform($body, false, null, $this->title);
     $this->body = wordwrap(strtr($body, $postTransformKeys), 72);
     # Reveal the page editor's address as REPLY-TO address only if
     # the user has not opted-out and the option is enabled at the
     # global configuration level.
     $adminAddress = new MailAddress($wgPasswordSender, wfMessage('emailsender')->inContentLanguage()->text());
     if ($wgEnotifRevealEditorAddress && $this->editor->getEmail() != '' && $this->editor->getOption('enotifrevealaddr')) {
         $editorAddress = MailAddress::newFromUser($this->editor);
         if ($wgEnotifFromEditor) {
             $this->from = $editorAddress;
         } else {
             $this->from = $adminAddress;
             $this->replyto = $editorAddress;
         }
     } else {
         $this->from = $adminAddress;
         $this->replyto = new MailAddress($wgNoReplyAddress);
     }
 }
Ejemplo n.º 17
0
 /**
  * Create a HTMLForm descriptor for the core login fields.
  * @param FakeAuthTemplate $template B/C data (not used but needed by getBCFieldDefinitions)
  * @return array
  */
 protected function getFieldDefinitions($template)
 {
     global $wgEmailConfirmToEdit;
     $isLoggedIn = $this->getUser()->isLoggedIn();
     $continuePart = $this->isContinued() ? 'continue-' : '';
     $anotherPart = $isLoggedIn ? 'another-' : '';
     $expiration = $this->getRequest()->getSession()->getProvider()->getRememberUserDuration();
     $expirationDays = ceil($expiration / (3600 * 24));
     $secureLoginLink = '';
     if ($this->mSecureLoginUrl) {
         $secureLoginLink = Html::element('a', ['href' => $this->mSecureLoginUrl, 'class' => 'mw-ui-flush-right mw-secure'], $this->msg('userlogin-signwithsecure')->text());
     }
     if ($this->isSignup()) {
         $fieldDefinitions = ['username' => ['label-message' => 'userlogin-yourname', 'help-message' => 'createacct-helpusername', 'id' => 'wpName2', 'placeholder-message' => $isLoggedIn ? 'createacct-another-username-ph' : 'userlogin-yourname-ph'], 'mailpassword' => ['type' => 'check', 'label-message' => 'createaccountmail', 'name' => 'wpCreateaccountMail', 'id' => 'wpCreateaccountMail'], 'password' => ['id' => 'wpPassword2', 'placeholder-message' => 'createacct-yourpassword-ph', 'hide-if' => ['===', 'wpCreateaccountMail', '1']], 'domain' => [], 'retype' => ['baseField' => 'password', 'type' => 'password', 'label-message' => 'createacct-yourpasswordagain', 'id' => 'wpRetype', 'cssclass' => 'loginPassword', 'size' => 20, 'validation-callback' => function ($value, $alldata) {
             if (empty($alldata['mailpassword']) && !empty($alldata['password'])) {
                 if (!$value) {
                     return $this->msg('htmlform-required');
                 } elseif ($value !== $alldata['password']) {
                     return $this->msg('badretype');
                 }
             }
             return true;
         }, 'hide-if' => ['===', 'wpCreateaccountMail', '1'], 'placeholder-message' => 'createacct-yourpasswordagain-ph'], 'email' => ['type' => 'email', 'label-message' => $wgEmailConfirmToEdit ? 'createacct-emailrequired' : 'createacct-emailoptional', 'id' => 'wpEmail', 'cssclass' => 'loginText', 'size' => '20', 'required' => $wgEmailConfirmToEdit, 'validation-callback' => function ($value, $alldata) {
             global $wgEmailConfirmToEdit;
             // AuthManager will check most of these, but that will make the auth
             // session fail and this won't, so nicer to do it this way
             if (!$value && $wgEmailConfirmToEdit) {
                 // no point in allowing registration without email when email is
                 // required to edit
                 return $this->msg('noemailtitle');
             } elseif (!$value && !empty($alldata['mailpassword'])) {
                 // cannot send password via email when there is no email address
                 return $this->msg('noemailcreate');
             } elseif ($value && !Sanitizer::validateEmail($value)) {
                 return $this->msg('invalidemailaddress');
             }
             return true;
         }, 'placeholder-message' => 'createacct-' . $anotherPart . 'email-ph'], 'realname' => ['type' => 'text', 'help-message' => $isLoggedIn ? 'createacct-another-realname-tip' : 'prefs-help-realname', 'label-message' => 'createacct-realname', 'cssclass' => 'loginText', 'size' => 20, 'id' => 'wpRealName'], 'reason' => ['type' => 'text', 'label-message' => 'createacct-reason', 'cssclass' => 'loginText', 'id' => 'wpReason', 'size' => '20', 'placeholder-message' => 'createacct-reason-ph'], 'extrainput' => [], 'createaccount' => ['type' => 'submit', 'default' => $this->msg('createacct-' . $anotherPart . $continuePart . 'submit')->text(), 'name' => 'wpCreateaccount', 'id' => 'wpCreateaccount', 'weight' => 100]];
     } else {
         $fieldDefinitions = ['username' => ['label-raw' => $this->msg('userlogin-yourname')->escaped() . $secureLoginLink, 'id' => 'wpName1', 'placeholder-message' => 'userlogin-yourname-ph'], 'password' => ['id' => 'wpPassword1', 'placeholder-message' => 'userlogin-yourpassword-ph'], 'domain' => [], 'extrainput' => [], 'rememberMe' => ['type' => 'check', 'label-message' => $this->msg('userlogin-remembermypassword')->numParams($expirationDays), 'id' => 'wpRemember'], 'loginattempt' => ['type' => 'submit', 'name' => 'wpRemember', 'default' => $this->msg('pt-login-' . $continuePart . 'button')->text(), 'id' => 'wpLoginAttempt', 'weight' => 100], 'linkcontainer' => ['type' => 'info', 'cssclass' => 'mw-form-related-link-container mw-userlogin-help', 'raw' => true, 'default' => Html::element('a', ['href' => Skin::makeInternalOrExternalUrl(wfMessage('helplogin-url')->inContentLanguage()->text())], $this->msg('userlogin-helplink2')->text()), 'weight' => 200]];
     }
     $fieldDefinitions['username'] += ['type' => 'text', 'name' => 'wpName', 'cssclass' => 'loginText', 'size' => 20];
     $fieldDefinitions['password'] += ['type' => 'password', 'name' => 'wpPassword', 'cssclass' => 'loginPassword', 'size' => 20];
     if ($this->mEntryError) {
         $fieldDefinitions['entryError'] = ['type' => 'info', 'default' => Html::rawElement('div', ['class' => $this->mEntryErrorType . 'box'], $this->mEntryError), 'raw' => true, 'rawrow' => true, 'weight' => -100];
     }
     if (!$this->showExtraInformation()) {
         unset($fieldDefinitions['linkcontainer']);
     }
     $fieldDefinitions = $this->getBCFieldDefinitions($fieldDefinitions, $template);
     $fieldDefinitions = array_filter($fieldDefinitions);
     return $fieldDefinitions;
 }
 function showStandardInputs(&$tabindex = 2)
 {
     global $wgOut, $wgUser;
     $wgOut->addHTML("<div class='editOptions'>\n");
     if ($this->section != 'new') {
         $this->showSummaryInput(false, $this->summary);
         $wgOut->addHTML($this->getSummaryPreview(false, $this->summary));
     }
     # MeanEditor: also set the value of our checkbox
     $checkboxes = $this->getCheckboxes($tabindex, array('minor' => $this->minoredit, 'watch' => $this->watchthis, 'want_traditional_editor' => $this->userWantsTraditionalEditor));
     $wgOut->addHTML("<div class='editCheckboxes'>" . implode($checkboxes, "\n") . "</div>\n");
     $wgOut->addHTML("<div class='editButtons'>\n");
     $wgOut->addHTML(implode($this->getEditButtons($tabindex), "\n") . "\n");
     $cancel = $this->getCancelLink();
     $separator = wfMsgExt('pipe-separator', 'escapenoentities');
     $edithelpurl = Skin::makeInternalOrExternalUrl(wfMsgForContent('edithelppage'));
     $edithelp = '<a target="helpwindow" href="' . $edithelpurl . '">' . htmlspecialchars(wfMsg('edithelp')) . '</a> ' . htmlspecialchars(wfMsg('newwindow'));
     $wgOut->addHTML("\t<span class='editHelp'>{$cancel}{$separator}{$edithelp}</span>\n");
     $wgOut->addHTML("</div><!-- editButtons -->\n</div><!-- editOptions -->\n");
 }
Ejemplo n.º 19
0
 public function execute()
 {
     $user = $this->getUser();
     $params = $this->extractRequestParams();
     $title = Title::newFromText($params['page']);
     if (!$title) {
         $this->dieUsageMsg('invalidtitle', $params['page']);
     }
     $isSafeAction = in_array($params['paction'], self::$SAFE_ACTIONS, true);
     $availableNamespaces = $this->veConfig->get('VisualEditorAvailableNamespaces');
     if (!$isSafeAction && (!isset($availableNamespaces[$title->getNamespace()]) || !$availableNamespaces[$title->getNamespace()])) {
         $this->dieUsage("VisualEditor is not enabled in namespace " . $title->getNamespace(), 'novenamespace');
     }
     $parserParams = array();
     if (isset($params['oldid'])) {
         $parserParams['oldid'] = $params['oldid'];
     }
     $html = $params['html'];
     if (substr($html, 0, 11) === 'rawdeflate,') {
         $deflated = base64_decode(substr($html, 11));
         wfSuppressWarnings();
         $html = gzinflate($deflated);
         wfRestoreWarnings();
         if ($deflated === $html || $html === false) {
             $this->dieUsage("HTML provided is not properly deflated", 'invaliddeflate');
         }
     }
     wfDebugLog('visualeditor', "called on '{$title}' with paction: '{$params['paction']}'");
     switch ($params['paction']) {
         case 'parse':
         case 'metadata':
             // Dirty hack to provide the correct context for edit notices
             global $wgTitle;
             // FIXME NOOOOOOOOES
             $wgTitle = $title;
             RequestContext::getMain()->setTitle($title);
             // Get information about current revision
             if ($title->exists()) {
                 $latestRevision = Revision::newFromTitle($title);
                 if ($latestRevision === null) {
                     $this->dieUsage('Could not find latest revision for title', 'latestnotfound');
                 }
                 $revision = null;
                 if (!isset($parserParams['oldid']) || $parserParams['oldid'] === 0) {
                     $parserParams['oldid'] = $latestRevision->getId();
                     $revision = $latestRevision;
                 } else {
                     $revision = Revision::newFromId($parserParams['oldid']);
                     if ($revision === null) {
                         $this->dieUsage('Could not find revision ID ' . $parserParams['oldid'], 'oldidnotfound');
                     }
                 }
                 $restoring = $revision && !$revision->isCurrent();
                 $baseTimestamp = $latestRevision->getTimestamp();
                 $oldid = intval($parserParams['oldid']);
                 // If requested, request HTML from Parsoid/RESTBase
                 if ($params['paction'] === 'parse') {
                     $content = $this->requestRestbase('GET', 'page/html/' . urlencode($title->getPrefixedDBkey()) . '/' . $oldid, array());
                     if ($content === false) {
                         $this->dieUsage('Error contacting the document server', 'docserver');
                     }
                 }
             } else {
                 $content = '';
                 $baseTimestamp = wfTimestampNow();
                 $oldid = 0;
                 $restoring = false;
             }
             // Get edit notices
             $notices = $title->getEditNotices();
             // Anonymous user notice
             if ($user->isAnon()) {
                 $notices[] = $this->msg('anoneditwarning', '{{fullurl:Special:UserLogin|returnto={{FULLPAGENAMEE}}}}', '{{fullurl:Special:UserLogin/signup|returnto={{FULLPAGENAMEE}}}}')->parseAsBlock();
             }
             // Old revision notice
             if ($restoring) {
                 $notices[] = $this->msg('editingold')->parseAsBlock();
             }
             // New page notices
             if (!$title->exists()) {
                 $notices[] = $this->msg($user->isLoggedIn() ? 'newarticletext' : 'newarticletextanon', wfExpandUrl(Skin::makeInternalOrExternalUrl($this->msg('helppage')->inContentLanguage()->text())))->parseAsBlock();
                 // Page protected from creation
                 if ($title->getRestrictions('create')) {
                     $notices[] = $this->msg('titleprotectedwarning')->parseAsBlock();
                 }
             }
             // Look at protection status to set up notices + surface class(es)
             $protectedClasses = array();
             if (MWNamespace::getRestrictionLevels($title->getNamespace()) !== array('')) {
                 // Page protected from editing
                 if ($title->isProtected('edit')) {
                     # Is the title semi-protected?
                     if ($title->isSemiProtected()) {
                         $protectedClasses[] = 'mw-textarea-sprotected';
                         $noticeMsg = 'semiprotectedpagewarning';
                     } else {
                         $protectedClasses[] = 'mw-textarea-protected';
                         # Then it must be protected based on static groups (regular)
                         $noticeMsg = 'protectedpagewarning';
                     }
                     $notices[] = $this->msg($noticeMsg)->parseAsBlock() . $this->getLastLogEntry($title, 'protect');
                 }
                 // Deal with cascading edit protection
                 list($sources, $restrictions) = $title->getCascadeProtectionSources();
                 if (isset($restrictions['edit'])) {
                     $protectedClasses[] = ' mw-textarea-cprotected';
                     $notice = $this->msg('cascadeprotectedwarning')->parseAsBlock() . '<ul>';
                     // Unfortunately there's no nice way to get only the pages which cause
                     // editing to be restricted
                     foreach ($sources as $source) {
                         $notice .= "<li>" . Linker::link($source) . "</li>";
                     }
                     $notice .= '</ul>';
                     $notices[] = $notice;
                 }
             }
             // Permission notice
             $permErrors = $title->getUserPermissionsErrors('create', $user);
             if ($permErrors && !$title->exists()) {
                 $notices[] = $this->msg('permissionserrorstext-withaction', 1, $this->msg('action-createpage')) . "<br>" . call_user_func_array(array($this, 'msg'), $permErrors[0])->parse();
             }
             // Show notice when editing user / user talk page of a user that doesn't exist
             // or who is blocked
             // HACK of course this code is partly duplicated from EditPage.php :(
             if ($title->getNamespace() == NS_USER || $title->getNamespace() == NS_USER_TALK) {
                 $parts = explode('/', $title->getText(), 2);
                 $targetUsername = $parts[0];
                 $targetUser = User::newFromName($targetUsername, false);
                 if (!($targetUser && $targetUser->isLoggedIn()) && !User::isIP($targetUsername)) {
                     // User does not exist
                     $notices[] = "<div class=\"mw-userpage-userdoesnotexist error\">\n" . $this->msg('userpage-userdoesnotexist', wfEscapeWikiText($targetUsername)) . "\n</div>";
                 } elseif ($targetUser->isBlocked()) {
                     // Show log extract if the user is currently blocked
                     $notices[] = $this->msg('blocked-notice-logextract', $targetUser->getName())->parseAsBlock() . $this->getLastLogEntry($targetUser->getUserPage(), 'block');
                 }
             }
             // Blocked user notice
             if ($user->isBlockedFrom($title) && $user->getBlock()->prevents('edit') !== false) {
                 $notices[] = call_user_func_array(array($this, 'msg'), $user->getBlock()->getPermissionsError($this->getContext()))->parseAsBlock();
             }
             // Blocked user notice for global blocks
             if (class_exists('GlobalBlocking')) {
                 $error = GlobalBlocking::getUserBlockErrors($user, $this->getRequest()->getIP());
                 if (count($error)) {
                     $notices[] = call_user_func_array(array($this, 'msg'), $error)->parseAsBlock();
                 }
             }
             // HACK: Build a fake EditPage so we can get checkboxes from it
             $article = new Article($title);
             // Deliberately omitting ,0 so oldid comes from request
             $ep = new EditPage($article);
             $req = $this->getRequest();
             $req->setVal('format', 'text/x-wiki');
             $ep->importFormData($req);
             // By reference for some reason (bug 52466)
             $tabindex = 0;
             $states = array('minor' => false, 'watch' => false);
             $checkboxes = $ep->getCheckboxes($tabindex, $states);
             // HACK: Find out which red links are on the page
             // We do the lookup for the current version. This might not be entirely complete
             // if we're loading an oldid, but it'll probably be close enough, and LinkCache
             // will automatically request any additional data it needs.
             $links = array();
             $wikipage = WikiPage::factory($title);
             $popts = $wikipage->makeParserOptions('canonical');
             $cached = ParserCache::singleton()->get($article, $popts, true);
             $links = array('missing' => array(), 'known' => $restoring || !$cached ? array() : 1);
             if ($cached) {
                 foreach ($cached->getLinks() as $namespace => $cachedTitles) {
                     foreach ($cachedTitles as $cachedTitleText => $exists) {
                         $cachedTitle = Title::makeTitle($namespace, $cachedTitleText);
                         if (!$cachedTitle->isKnown()) {
                             $links['missing'][] = $cachedTitle->getPrefixedText();
                         } elseif ($links['known'] !== 1) {
                             $links['known'][] = $cachedTitle->getPrefixedText();
                         }
                     }
                 }
             }
             // Add information about current page
             if (!$title->isKnown()) {
                 $links['missing'][] = $title->getPrefixedText();
             } elseif ($links['known'] !== 1) {
                 $links['known'][] = $title->getPrefixedText();
             }
             // On parser cache miss, just don't bother populating red link data
             $result = array('result' => 'success', 'notices' => $notices, 'checkboxes' => $checkboxes, 'links' => $links, 'protectedClasses' => implode(' ', $protectedClasses), 'watched' => $user->isWatched($title), 'basetimestamp' => $baseTimestamp, 'starttimestamp' => wfTimestampNow(), 'oldid' => $oldid);
             if ($params['paction'] === 'parse') {
                 $result['content'] = $content;
             }
             break;
         case 'parsefragment':
             $wikitext = $params['wikitext'];
             if ($params['pst']) {
                 $wikitext = $this->pstWikitext($title, $wikitext);
             }
             $content = $this->parseWikitextFragment($title, $wikitext);
             if ($content === false) {
                 $this->dieUsage('Error contacting the document server', 'docserver');
             } else {
                 $result = array('result' => 'success', 'content' => $content);
             }
             break;
         case 'serialize':
             if ($params['cachekey'] !== null) {
                 $content = $this->trySerializationCache($params['cachekey']);
                 if (!is_string($content)) {
                     $this->dieUsage('No cached serialization found with that key', 'badcachekey');
                 }
             } else {
                 if ($params['html'] === null) {
                     $this->dieUsageMsg('missingparam', 'html');
                 }
                 $content = $this->postHTML($title, $html, $parserParams, $params['etag']);
                 if ($content === false) {
                     $this->dieUsage('Error contacting the document server', 'docserver');
                 }
             }
             $result = array('result' => 'success', 'content' => $content);
             break;
         case 'diff':
             if ($params['cachekey'] !== null) {
                 $wikitext = $this->trySerializationCache($params['cachekey']);
                 if (!is_string($wikitext)) {
                     $this->dieUsage('No cached serialization found with that key', 'badcachekey');
                 }
             } else {
                 $wikitext = $this->postHTML($title, $html, $parserParams, $params['etag']);
                 if ($wikitext === false) {
                     $this->dieUsage('Error contacting the document server', 'docserver');
                 }
             }
             $diff = $this->diffWikitext($title, $wikitext);
             if ($diff['result'] === 'fail') {
                 $this->dieUsage('Diff failed', 'difffailed');
             }
             $result = $diff;
             break;
         case 'serializeforcache':
             if (!isset($parserParams['oldid'])) {
                 $parserParams['oldid'] = Revision::newFromTitle($title)->getId();
             }
             $key = $this->storeInSerializationCache($title, $parserParams['oldid'], $html, $params['etag']);
             $result = array('result' => 'success', 'cachekey' => $key);
             break;
         case 'getlanglinks':
             $langlinks = $this->getLangLinks($title);
             if ($langlinks === false) {
                 $this->dieUsage('Error querying MediaWiki API', 'api-langlinks-error');
             } else {
                 $result = array('result' => 'success', 'langlinks' => $langlinks);
             }
             break;
     }
     $this->getResult()->addValue(null, $this->getModuleName(), $result);
 }
Ejemplo n.º 20
0
    /**
     * Send the edit form and related headers to $wgOut
     * @param $formCallback Optional callable that takes an OutputPage
     *                      parameter; will be called during form output
     *                      near the top, for captchas and the like.
     */
    function showEditForm($formCallback = null)
    {
        global $wgOut, $wgUser, $wgLang, $wgContLang, $wgMaxArticleSize;
        $fname = 'EditPage::showEditForm';
        wfProfileIn($fname);
        $sk =& $wgUser->getSkin();
        wfRunHooks('EditPage::showEditForm:initial', array(&$this));
        $wgOut->setRobotpolicy('noindex,nofollow');
        # Enabled article-related sidebar, toplinks, etc.
        $wgOut->setArticleRelated(true);
        if ($this->isConflict) {
            $s = wfMsg('editconflict', $this->mTitle->getPrefixedText());
            $wgOut->setPageTitle($s);
            $wgOut->addWikiText(wfMsg('explainconflict'));
            $this->textbox2 = $this->textbox1;
            $this->textbox1 = $this->getContent();
            $this->edittime = $this->mArticle->getTimestamp();
        } else {
            if ($this->section != '') {
                if ($this->section == 'new') {
                    $s = wfMsg('editingcomment', $this->mTitle->getPrefixedText());
                } else {
                    $s = wfMsg('editingsection', $this->mTitle->getPrefixedText());
                    if (!$this->summary && !$this->preview && !$this->diff) {
                        preg_match("/^(=+)(.+)\\1/mi", $this->textbox1, $matches);
                        if (!empty($matches[2])) {
                            $this->summary = "/* " . trim($matches[2]) . " */ ";
                        }
                    }
                }
            } else {
                $s = wfMsg('editing', $this->mTitle->getPrefixedText());
            }
            $wgOut->setPageTitle($s);
            if ($this->missingComment) {
                $wgOut->addWikiText(wfMsg('missingcommenttext'));
            }
            if ($this->missingSummary) {
                $wgOut->addWikiText(wfMsg('missingsummary'));
            }
            if (!$this->hookError == '') {
                $wgOut->addWikiText($this->hookError);
            }
            if (!$this->checkUnicodeCompliantBrowser()) {
                $wgOut->addWikiText(wfMsg('nonunicodebrowser'));
            }
            if (isset($this->mArticle) && isset($this->mArticle->mRevision) && !$this->mArticle->mRevision->isCurrent()) {
                $this->mArticle->setOldSubtitle($this->mArticle->mRevision->getId());
                $wgOut->addWikiText(wfMsg('editingold'));
            }
        }
        if (wfReadOnly()) {
            $wgOut->addWikiText(wfMsg('readonlywarning'));
        } elseif ($wgUser->isAnon() && $this->formtype != 'preview') {
            $wgOut->addWikiText(wfMsg('anoneditwarning'));
        } else {
            if ($this->isCssJsSubpage && $this->formtype != 'preview') {
                # Check the skin exists
                if ($this->isValidCssJsSubpage) {
                    $wgOut->addWikiText(wfMsg('usercssjsyoucanpreview'));
                } else {
                    $wgOut->addWikiText(wfMsg('userinvalidcssjstitle', $this->mTitle->getSkinFromCssJsSubpage()));
                }
            }
        }
        if ($this->mTitle->isProtected('edit')) {
            # Is the protection due to the namespace, e.g. interface text?
            if ($this->mTitle->getNamespace() == NS_MEDIAWIKI) {
                # Yes; remind the user
                $notice = wfMsg('editinginterface');
            } elseif ($this->mTitle->isSemiProtected()) {
                # No; semi protected
                $notice = wfMsg('semiprotectedpagewarning');
                if (wfEmptyMsg('semiprotectedpagewarning', $notice) || $notice == '-') {
                    $notice = '';
                }
            } else {
                # No; regular protection
                $notice = wfMsg('protectedpagewarning');
            }
            $wgOut->addWikiText($notice);
        }
        if ($this->kblength === false) {
            $this->kblength = (int) (strlen($this->textbox1) / 1024);
        }
        if ($this->tooBig || $this->kblength > $wgMaxArticleSize) {
            $wgOut->addWikiText(wfMsg('longpageerror', $wgLang->formatNum($this->kblength), $wgMaxArticleSize));
        } elseif ($this->kblength > 29) {
            $wgOut->addWikiText(wfMsg('longpagewarning', $wgLang->formatNum($this->kblength)));
        }
        $rows = $wgUser->getIntOption('rows');
        $cols = $wgUser->getIntOption('cols');
        $ew = $wgUser->getOption('editwidth');
        if ($ew) {
            $ew = " style=\"width:100%\"";
        } else {
            $ew = '';
        }
        $q = 'action=submit';
        #if ( "no" == $redirect ) { $q .= "&redirect=no"; }
        $action = $this->mTitle->escapeLocalURL($q);
        $summary = wfMsg('summary');
        $subject = wfMsg('subject');
        $minor = wfMsgExt('minoredit', array('parseinline'));
        $watchthis = wfMsgExt('watchthis', array('parseinline'));
        $cancel = $sk->makeKnownLink($this->mTitle->getPrefixedText(), wfMsgExt('cancel', array('parseinline')));
        $edithelpurl = Skin::makeInternalOrExternalUrl(wfMsgForContent('edithelppage'));
        $edithelp = '<a target="helpwindow" href="' . $edithelpurl . '">' . htmlspecialchars(wfMsg('edithelp')) . '</a> ' . htmlspecialchars(wfMsg('newwindow'));
        global $wgRightsText;
        $copywarn = "<div id=\"editpage-copywarn\">\n" . wfMsg($wgRightsText ? 'copyrightwarning' : 'copyrightwarning2', '[[' . wfMsgForContent('copyrightpage') . ']]', $wgRightsText) . "\n</div>";
        if ($wgUser->getOption('showtoolbar') and !$this->isCssJsSubpage) {
            # prepare toolbar for edit buttons
            $toolbar = $this->getEditToolbar();
        } else {
            $toolbar = '';
        }
        // activate checkboxes if user wants them to be always active
        if (!$this->preview && !$this->diff) {
            # Sort out the "watch" checkbox
            if ($wgUser->getOption('watchdefault')) {
                # Watch all edits
                $this->watchthis = true;
            } elseif ($wgUser->getOption('watchcreations') && !$this->mTitle->exists()) {
                # Watch creations
                $this->watchthis = true;
            } elseif ($this->mTitle->userIsWatching()) {
                # Already watched
                $this->watchthis = true;
            }
            if ($wgUser->getOption('minordefault')) {
                $this->minoredit = true;
            }
        }
        $minoredithtml = '';
        if ($wgUser->isAllowed('minoredit')) {
            $minoredithtml = "<input tabindex='3' type='checkbox' value='1' name='wpMinoredit'" . ($this->minoredit ? " checked='checked'" : "") . " accesskey='" . wfMsg('accesskey-minoredit') . "' id='wpMinoredit' />\n" . "<label for='wpMinoredit' title='" . wfMsg('tooltip-minoredit') . "'>{$minor}</label>\n";
        }
        $watchhtml = '';
        if ($wgUser->isLoggedIn()) {
            $watchhtml = "<input tabindex='4' type='checkbox' name='wpWatchthis'" . ($this->watchthis ? " checked='checked'" : "") . " accesskey=\"" . htmlspecialchars(wfMsg('accesskey-watch')) . "\" id='wpWatchthis'  />\n" . "<label for='wpWatchthis' title=\"" . htmlspecialchars(wfMsg('tooltip-watch')) . "\">{$watchthis}</label>\n";
        }
        $checkboxhtml = $minoredithtml . $watchhtml;
        if ($wgUser->getOption('previewontop')) {
            if ('preview' == $this->formtype) {
                $this->showPreview();
            } else {
                $wgOut->addHTML('<div id="wikiPreview"></div>');
            }
            if ('diff' == $this->formtype) {
                $wgOut->addHTML($this->getDiff());
            }
        }
        # if this is a comment, show a subject line at the top, which is also the edit summary.
        # Otherwise, show a summary field at the bottom
        $summarytext = htmlspecialchars($wgContLang->recodeForEdit($this->summary));
        # FIXME
        if ($this->section == 'new') {
            $commentsubject = "<span id='wpSummaryLabel'><label for='wpSummary'>{$subject}:</label></span>\n<div class='editOptions'>\n<input tabindex='1' type='text' value=\"{$summarytext}\" name='wpSummary' id='wpSummary' maxlength='200' size='60' /><br />";
            $editsummary = '';
        } else {
            $commentsubject = '';
            $editsummary = "<span id='wpSummaryLabel'><label for='wpSummary'>{$summary}:</label></span>\n<div class='editOptions'>\n<input tabindex='2' type='text' value=\"{$summarytext}\" name='wpSummary' id='wpSummary' maxlength='200' size='60' /><br />";
        }
        # Set focus to the edit box on load, except on preview or diff, where it would interfere with the display
        if (!$this->preview && !$this->diff) {
            $wgOut->setOnloadHandler('document.editform.wpTextbox1.focus()');
        }
        $templates = $this->formatTemplates();
        global $wgUseMetadataEdit;
        if ($wgUseMetadataEdit) {
            $metadata = $this->mMetaData;
            $metadata = htmlspecialchars($wgContLang->recodeForEdit($metadata));
            $top = wfMsgWikiHtml('metadata_help');
            $metadata = $top . "<textarea name='metadata' rows='3' cols='{$cols}'{$ew}>{$metadata}</textarea>";
        } else {
            $metadata = "";
        }
        $hidden = '';
        $recreate = '';
        if ($this->deletedSinceEdit) {
            if ('save' != $this->formtype) {
                $wgOut->addWikiText(wfMsg('deletedwhileediting'));
            } else {
                // Hide the toolbar and edit area, use can click preview to get it back
                // Add an confirmation checkbox and explanation.
                $toolbar = '';
                $hidden = 'type="hidden" style="display:none;"';
                $recreate = $wgOut->parse(wfMsg('confirmrecreate', $this->lastDelete->user_name, $this->lastDelete->log_comment));
                $recreate .= "<br /><input tabindex='1' type='checkbox' value='1' name='wpRecreate' id='wpRecreate' />" . "<label for='wpRecreate' title='" . wfMsg('tooltip-recreate') . "'>" . wfMsg('recreate') . "</label>";
            }
        }
        $temp = array('id' => 'wpSave', 'name' => 'wpSave', 'type' => 'submit', 'tabindex' => '5', 'value' => wfMsg('savearticle'), 'accesskey' => wfMsg('accesskey-save'), 'title' => wfMsg('tooltip-save'));
        $buttons['save'] = wfElement('input', $temp, '');
        $temp = array('id' => 'wpDiff', 'name' => 'wpDiff', 'type' => 'submit', 'tabindex' => '7', 'value' => wfMsg('showdiff'), 'accesskey' => wfMsg('accesskey-diff'), 'title' => wfMsg('tooltip-diff'));
        $buttons['diff'] = wfElement('input', $temp, '');
        global $wgLivePreview;
        if ($wgLivePreview && $wgUser->getOption('uselivepreview')) {
            $temp = array('id' => 'wpPreview', 'name' => 'wpPreview', 'type' => 'submit', 'tabindex' => '6', 'value' => wfMsg('showpreview'), 'accesskey' => '', 'title' => wfMsg('tooltip-preview'), 'style' => 'display: none;');
            $buttons['preview'] = wfElement('input', $temp, '');
            $temp = array('id' => 'wpLivePreview', 'name' => 'wpLivePreview', 'type' => 'submit', 'tabindex' => '6', 'value' => wfMsg('showlivepreview'), 'accesskey' => wfMsg('accesskey-preview'), 'title' => '', 'onclick' => $this->doLivePreviewScript());
            $buttons['live'] = wfElement('input', $temp, '');
        } else {
            $temp = array('id' => 'wpPreview', 'name' => 'wpPreview', 'type' => 'submit', 'tabindex' => '6', 'value' => wfMsg('showpreview'), 'accesskey' => wfMsg('accesskey-preview'), 'title' => wfMsg('tooltip-preview'));
            $buttons['preview'] = wfElement('input', $temp, '');
            $buttons['live'] = '';
        }
        $safemodehtml = $this->checkUnicodeCompliantBrowser() ? "" : "<input type='hidden' name=\"safemode\" value='1' />\n";
        $wgOut->addHTML(<<<END
{$toolbar}
<form id="editform" name="editform" method="post" action="{$action}" enctype="multipart/form-data">
END
);
        if (is_callable($formCallback)) {
            call_user_func_array($formCallback, array(&$wgOut));
        }
        // Put these up at the top to ensure they aren't lost on early form submission
        $wgOut->addHTML("\n<input type='hidden' value=\"" . htmlspecialchars($this->section) . "\" name=\"wpSection\" />\n<input type='hidden' value=\"{$this->starttime}\" name=\"wpStarttime\" />\n\n<input type='hidden' value=\"{$this->edittime}\" name=\"wpEdittime\" />\n\n<input type='hidden' value=\"{$this->scrolltop}\" name=\"wpScrolltop\" id=\"wpScrolltop\" />\n");
        $wgOut->addHTML(<<<END
{$recreate}
{$commentsubject}
<textarea tabindex='1' accesskey="," name="wpTextbox1" id="wpTextbox1" rows='{$rows}'
cols='{$cols}'{$ew} {$hidden}>
END
 . htmlspecialchars($this->safeUnicodeOutput($this->textbox1)) . "\n</textarea>\n\t\t");
        $wgOut->addWikiText($copywarn);
        $wgOut->addHTML("\n{$metadata}\n{$editsummary}\n{$checkboxhtml}\n{$safemodehtml}\n");
        $wgOut->addHTML("<div class='editButtons'>\n\t{$buttons['save']}\n\t{$buttons['preview']}\n\t{$buttons['live']}\n\t{$buttons['diff']}\n\t<span class='editHelp'>{$cancel} | {$edithelp}</span>\n</div><!-- editButtons -->\n</div><!-- editOptions -->");
        $wgOut->addWikiText(wfMsgForContent('edittools'));
        $wgOut->addHTML("\n<div class='templatesUsed'>\n{$templates}\n</div>\n");
        if ($wgUser->isLoggedIn()) {
            /**
             * To make it harder for someone to slip a user a page
             * which submits an edit form to the wiki without their
             * knowledge, a random token is associated with the login
             * session. If it's not passed back with the submission,
             * we won't save the page, or render user JavaScript and
             * CSS previews.
             */
            $token = htmlspecialchars($wgUser->editToken());
            $wgOut->addHTML("\n<input type='hidden' value=\"{$token}\" name=\"wpEditToken\" />\n");
        }
        # If a blank edit summary was previously provided, and the appropriate
        # user preference is active, pass a hidden tag here. This will stop the
        # user being bounced back more than once in the event that a summary
        # is not required.
        if ($this->missingSummary) {
            $wgOut->addHTML("<input type=\"hidden\" name=\"wpIgnoreBlankSummary\" value=\"1\" />\n");
        }
        # For a bit more sophisticated detection of blank summaries, hash the
        # automatic one and pass that in a hidden field.
        $autosumm = $this->autoSumm ? $this->autoSumm : md5($this->summary);
        $wgOut->addHtml(wfHidden('wpAutoSummary', $autosumm));
        if ($this->isConflict) {
            $wgOut->addWikiText('==' . wfMsg("yourdiff") . '==');
            $de = new DifferenceEngine($this->mTitle);
            $de->setText($this->textbox2, $this->textbox1);
            $de->showDiff(wfMsg("yourtext"), wfMsg("storedversion"));
            $wgOut->addWikiText('==' . wfMsg("yourtext") . '==');
            $wgOut->addHTML("<textarea tabindex=6 id='wpTextbox2' name=\"wpTextbox2\" rows='{$rows}' cols='{$cols}' wrap='virtual'>" . htmlspecialchars($this->safeUnicodeOutput($this->textbox2)) . "\n</textarea>");
        }
        $wgOut->addHTML("</form>\n");
        if (!$wgUser->getOption('previewontop')) {
            if ($this->formtype == 'preview') {
                $this->showPreview();
            } else {
                $wgOut->addHTML('<div id="wikiPreview"></div>');
            }
            if ($this->formtype == 'diff') {
                $wgOut->addHTML($this->getDiff());
            }
        }
        wfProfileOut($fname);
    }
Ejemplo n.º 21
0
 /**
  * @return string
  */
 function sysLinks()
 {
     $s = array($this->getSkin()->mainPageLink(), Linker::linkKnown(Title::newFromText(wfMessage('aboutpage')->inContentLanguage()->text()), wfMessage('about')->text()), Linker::makeExternalLink(Skin::makeInternalOrExternalUrl(wfMessage('helppage')->inContentLanguage()->text()), wfMessage('help')->text(), false), Linker::linkKnown(Title::newFromText(wfMessage('faqpage')->inContentLanguage()->text()), wfMessage('faq')->text()));
     $personalUrls = $this->getPersonalTools();
     foreach (array('logout', 'createaccount', 'login') as $key) {
         if ($personalUrls[$key]) {
             $s[] = $this->makeListItem($key, $personalUrls[$key], array('tag' => 'span'));
         }
     }
     return $this->getSkin()->getLanguage()->pipeList($s);
 }
Ejemplo n.º 22
-1
 /**
  * Get the body of the ad, with all transformations applied.
  */
 public function renderHtml()
 {
     $adCaption = $this->getCaption();
     $adBody = wfMessage($this->getDbKey())->parse();
     $adMainLink = $this->getMainLink();
     $adMainLink = empty($adMainLink) ? null : Skin::makeInternalOrExternalUrl($this->getMainLink());
     $adHtml = HTML::openElement('div', array('class' => 'promotion', 'data-adname' => $this->getName()));
     $adHtml .= HTML::openElement('div', array('class' => 'header'));
     //$adHtml .= HTML::element( 'span', array( 'class' => 'icon pull-right' ) );
     if (empty($adMainLink)) {
         $adHtml .= HTML::element('span', array('class' => 'caption'), $adCaption);
     } else {
         $adHtml .= HTML::element('a', array('class' => 'caption', 'href' => $adMainLink), $adCaption);
     }
     $adHtml .= HTML::closeElement('div');
     $adHtml .= HTML::rawElement('div', array('class' => 'content'), $adBody);
     if ($adMainLink) {
         $adHtml .= HTML::openElement('div', array('class' => 'mainlink'));
         $adHtml .= HTML::element('a', array('href' => $adMainLink), 'לפרטים נוספים...');
         $adHtml .= HTML::closeElement('div');
     }
     $adHtml .= HTML::closeElement('div');
     return $adHtml;
 }