/**
  * Show a nice form for the user to request a confirmation mail
  */
 function showRequestForm()
 {
     global $wgOut, $wgUser, $wgLang, $wgRequest;
     if ($wgRequest->wasPosted() && $wgUser->matchEditToken($wgRequest->getText('token'))) {
         $ok = $wgUser->sendConfirmationMail();
         if (WikiError::isError($ok)) {
             $wgOut->addWikiMsg('confirmemail_sendfailed', $ok->toString());
         } else {
             $wgOut->addWikiMsg('confirmemail_sent');
         }
     } else {
         if ($wgUser->isEmailConfirmed()) {
             $time = $wgLang->timeAndDate($wgUser->mEmailAuthenticated, true);
             $wgOut->addWikiMsg('emailauthenticated', $time);
         }
         if ($wgUser->isEmailConfirmationPending()) {
             $wgOut->addWikiMsg('confirmemail_pending');
         }
         $wgOut->addWikiMsg('confirmemail_text');
         $self = SpecialPage::getTitleFor('Confirmemail');
         $form = wfOpenElement('form', array('method' => 'post', 'action' => $self->getLocalUrl()));
         $form .= wfHidden('token', $wgUser->editToken());
         $form .= wfSubmitButton(wfMsgHtml('confirmemail_send'));
         $form .= wfCloseElement('form');
         $wgOut->addHtml($form);
     }
 }
Example #2
0
 function showForm()
 {
     global $wgOut, $wgUser, $wgLang, $wgRequest;
     $self = SpecialPage::getTitleFor('Resetpass');
     $form = '<div id="userloginForm">' . wfOpenElement('form', array('method' => 'post', 'action' => $self->getLocalUrl())) . '<h2>' . wfMsgHtml('resetpass_header') . '</h2>' . '<div id="userloginprompt">' . wfMsgExt('resetpass_text', array('parse')) . '</div>' . '<table>' . wfHidden('token', $wgUser->editToken()) . wfHidden('wpName', $this->mName) . wfHidden('wpPassword', $this->mTemporaryPassword) . wfHidden('returnto', $wgRequest->getVal('returnto')) . $this->pretty(array(array('wpName', 'username', 'text', $this->mName), array('wpNewPassword', 'newpassword', 'password', ''), array('wpRetype', 'yourpasswordagain', 'password', ''))) . '<tr>' . '<td></td>' . '<td>' . Xml::checkLabel(wfMsg('remembermypassword'), 'wpRemember', 'wpRemember', $wgRequest->getCheck('wpRemember')) . '</td>' . '</tr>' . '<tr>' . '<td></td>' . '<td>' . wfSubmitButton(wfMsgHtml('resetpass_submit')) . '</td>' . '</tr>' . '</table>' . wfCloseElement('form') . '</div>';
     $wgOut->addHtml($form);
 }
Example #3
0
 /**
  * Show a drop down list to select a group as well as a user name
  * search box.
  * @todo localize
  */
 function getPageHeader()
 {
     $self = $this->getTitle();
     # Form tag
     $out = wfOpenElement('form', array('method' => 'post', 'action' => $self->getLocalUrl()));
     # Group drop-down list
     $out .= wfElement('label', array('for' => 'group'), wfMsg('group')) . ' ';
     $out .= wfOpenElement('select', array('name' => 'group'));
     $out .= wfElement('option', array('value' => ''), wfMsg('group-all'));
     # Item for "all groups"
     $groups = User::getAllGroups();
     foreach ($groups as $group) {
         $attribs = array('value' => $group);
         if ($group == $this->requestedGroup) {
             $attribs['selected'] = 'selected';
         }
         $out .= wfElement('option', $attribs, User::getGroupName($group));
     }
     $out .= wfCloseElement('select') . ' ';
     # . wfElement( 'br' );
     # Username field
     $out .= wfElement('label', array('for' => 'username'), wfMsg('specialloguserlabel')) . ' ';
     $out .= wfElement('input', array('type' => 'text', 'id' => 'username', 'name' => 'username', 'value' => $this->requestedUser)) . ' ';
     # Preserve offset and limit
     if ($this->offset) {
         $out .= wfElement('input', array('type' => 'hidden', 'name' => 'offset', 'value' => $this->offset));
     }
     if ($this->limit) {
         $out .= wfElement('input', array('type' => 'hidden', 'name' => 'limit', 'value' => $this->limit));
     }
     # Submit button and form bottom
     $out .= wfElement('input', array('type' => 'submit', 'value' => wfMsg('allpagessubmit')));
     $out .= wfCloseElement('form');
     return $out;
 }
Example #4
0
function PoemExtension($in, $param = array(), $parser = null)
{
    /* using newlines in the text will cause the parser to add <p> tags,
     * which may not be desired in some cases
     */
    $nl = $param['compact'] ? '' : "\n";
    if (method_exists($parser, 'recursiveTagParse')) {
        //new methods in 1.8 allow nesting <nowiki> in <poem>.
        $tag = $parser->insertStripItem("<br />", $parser->mStripState);
        $text = preg_replace(array("/^\n/", "/\n\$/D", "/\n/", "/^( +)/me"), array("", "", "{$tag}{$nl}", "str_replace(' ','&nbsp;','\\1')"), $in);
        $text = $parser->recursiveTagParse($text);
    } else {
        $text = preg_replace(array("/^\n/", "/\n\$/D", "/\n/", "/^( +)/me"), array("", "", "<br />{$nl}", "str_replace(' ','&nbsp;','\\1')"), $in);
        $ret = $parser->parse($text, $parser->getTitle(), $parser->getOptions(), true, false);
        $text = $ret->getText();
    }
    global $wgVersion;
    if (version_compare($wgVersion, "1.7alpha") >= 0) {
        // Pass HTML attributes through to the output.
        $attribs = Sanitizer::validateTagAttributes($param, 'div');
    } else {
        // Can't guarantee safety on 1.6 or older.
        $attribs = array();
    }
    // Wrap output in a <div> with "poem" class.
    if (isset($attribs['class'])) {
        $attribs['class'] = 'poem ' . $attribs['class'];
    } else {
        $attribs['class'] = 'poem';
    }
    return wfOpenElement('div', $attribs) . $nl . trim($text) . "{$nl}</div>";
}
Example #5
0
/**
 * constructor
 */
function wfSpecialMIMEsearch($par = null)
{
    global $wgRequest, $wgTitle, $wgOut;
    $mime = isset($par) ? $par : $wgRequest->getText('mime');
    $wgOut->addHTML(wfElement('form', array('id' => 'specialmimesearch', 'method' => 'get', 'action' => $wgTitle->escapeLocalUrl()), null) . wfOpenElement('label') . wfMsgHtml('mimetype') . wfElement('input', array('type' => 'text', 'size' => 20, 'name' => 'mime', 'value' => $mime), '') . ' ' . wfElement('input', array('type' => 'submit', 'value' => wfMsg('ilsubmit')), '') . wfCloseElement('label') . wfCloseElement('form'));
    list($major, $minor) = wfSpecialMIMEsearchParse($mime);
    if ($major == '' or $minor == '' or !wfSpecialMIMEsearchValidType($major)) {
        return;
    }
    $wpp = new MIMEsearchPage($major, $minor);
    list($limit, $offset) = wfCheckLimits();
    $wpp->doQuery($offset, $limit);
}
Example #6
0
 /**
  * Show a nice form for the user to request a confirmation mail
  */
 function showRequestForm()
 {
     global $wgOut, $wgUser, $wgLang, $wgRequest;
     if ($wgRequest->wasPosted() && $wgUser->matchEditToken($wgRequest->getText('token'))) {
         $ok = $wgUser->sendConfirmationMail();
         $message = WikiError::isError($ok) ? 'confirmemail_sendfailed' : 'confirmemail_sent';
         $wgOut->addWikiText(wfMsg($message));
     } else {
         if ($wgUser->isEmailConfirmed()) {
             $time = $wgLang->timeAndDate($wgUser->mEmailAuthenticated, true);
             $wgOut->addWikiText(wfMsg('emailauthenticated', $time));
         }
         $wgOut->addWikiText(wfMsg('confirmemail_text'));
         $self = Title::makeTitle(NS_SPECIAL, 'Confirmemail');
         $form = wfOpenElement('form', array('method' => 'post', 'action' => $self->getLocalUrl()));
         $form .= wfHidden('token', $wgUser->editToken());
         $form .= wfSubmitButton(wfMsgHtml('confirmemail_send'));
         $form .= wfCloseElement('form');
         $wgOut->addHtml($form);
     }
 }
 /**
  * Returns a string with a HTML represenation of the given page.
  * $title must be a Title object
  */
 function renderNode(&$title, $mode = NULL, $children = false, $loadchildren = false, $depth = 1)
 {
     global $wgCategoryTreeOmitNamespace, $wgCategoryTreeDefaultMode;
     static $uniq = 0;
     if ($mode === NULL) {
         $wgCategoryTreeDefaultMode;
     }
     $load = false;
     if ($children && $loadchildren) {
         $uniq += 1;
         $load = 'ct-' . $uniq . '-' . mt_rand(1, 100000);
         $children = false;
     }
     $ns = $title->getNamespace();
     $key = $title->getDBkey();
     #$trans = $title->getLocalizedText();
     $trans = '';
     #place holder for when translated titles are available
     #when showing only categories, omit namespace in label unless we explicitely defined the configuration setting
     #patch contributed by Manuel Schneider <*****@*****.**>, Bug 8011
     if ($wgCategoryTreeOmitNamespace || $mode == CT_MODE_CATEGORIES) {
         $label = htmlspecialchars($title->getText());
     } else {
         $label = htmlspecialchars($title->getPrefixedText());
     }
     if ($trans && $trans != $label) {
         $label .= ' ' . wfElement('i', array('class' => 'translation'), $trans);
     }
     $wikiLink = $title->getLocalURL();
     $labelClass = 'CategoryTreeLabel ' . ' CategoryTreeLabelNs' . $ns;
     if ($ns == NS_CATEGORY) {
         $labelClass .= ' CategoryTreeLabelCategory';
     } else {
         $labelClass .= ' CategoryTreeLabelPage';
     }
     if ($ns % 2 > 0) {
         $labelClass .= ' CategoryTreeLabelTalk';
     }
     $linkattr = array('href' => '#');
     if ($load) {
         $linkattr['id'] = $load;
     }
     if (!$children) {
         $txt = '+';
         $linkattr['onclick'] = "this.href='javascript:void(0)'; categoryTreeExpandNode('" . Xml::escapeJsString($key) . "','" . $mode . "',this);";
         # Don't load this message for ajax requests, so that we don't have to initialise $wgLang
         $linkattr['title'] = $this->mIsAjaxRequest ? '##LOAD##' : self::msg('expand');
     } else {
         $txt = '–';
         #NOTE: that's not a minus but a unicode ndash!
         $linkattr['onclick'] = "this.href='javascript:void(0)'; categoryTreeCollapseNode('" . Xml::escapeJsString($key) . "','" . $mode . "',this);";
         $linkattr['title'] = self::msg('collapse');
         $linkattr['class'] = 'CategoryTreeLoaded';
     }
     $s = '';
     #NOTE: things in CategoryTree.js rely on the exact order of tags!
     #      Specifically, the CategoryTreeChildren div must be the first
     #      sibling with nodeName = DIV of the grandparent of the expland link.
     $s .= wfOpenElement('div', array('class' => 'CategoryTreeSection'));
     $s .= wfOpenElement('div', array('class' => 'CategoryTreeItem'));
     if ($ns == NS_CATEGORY) {
         $s .= wfOpenElement('span', array('class' => 'CategoryTreeBullet'));
         $s .= '[' . wfElement('a', $linkattr, $txt) . '] ';
         $s .= wfCloseElement('span');
     } else {
         $s .= ' ';
     }
     $s .= wfOpenElement('a', array('class' => $labelClass, 'href' => $wikiLink)) . $label . wfCloseElement('a');
     $s .= wfCloseElement('div');
     $s .= "\n\t\t";
     $s .= wfOpenElement('div', array('class' => 'CategoryTreeChildren', 'style' => $children ? "display:block" : "display:none"));
     //HACK here?
     if ($children) {
         $s .= $this->renderChildren($title, $mode, $depth);
     }
     $s .= wfCloseElement('div');
     $s .= wfCloseElement('div');
     if ($load) {
         $s .= "\n\t\t";
         $s .= wfOpenElement('script', array('type' => 'text/javascript'));
         $s .= 'categoryTreeExpandNode("' . Xml::escapeJsString($key) . '", "' . $mode . '", document.getElementById("' . $load . '") );';
         $s .= wfCloseElement('script');
     }
     $s .= "\n\t\t";
     return $s;
 }
Example #8
0
 /**
  * Show a namespace selection form for filtering
  *
  * @return string
  */
 function getPageHeader()
 {
     $thisTitle = Title::makeTitle(NS_SPECIAL, $this->getName());
     $form = wfOpenElement('form', array('method' => 'post', 'action' => $thisTitle->getLocalUrl()));
     $form .= wfElement('label', array('for' => 'namespace'), wfMsg('namespace')) . ' ';
     $form .= HtmlNamespaceSelector($this->namespace);
     # Preserve the offset and limit
     $form .= wfElement('input', array('type' => 'hidden', 'name' => 'offset', 'value' => $this->offset));
     $form .= wfElement('input', array('type' => 'hidden', 'name' => 'limit', 'value' => $this->limit));
     $form .= wfElement('input', array('type' => 'submit', 'name' => 'submit', 'id' => 'submit', 'value' => wfMsg('allpagessubmit')));
     $form .= wfCloseElement('form');
     return $form;
 }
Example #9
0
 /**
  * Tag hook handler for 'pre'.
  */
 function renderPreTag($text, $attribs)
 {
     // Backwards-compatibility hack
     $content = StringUtils::delimiterReplace('<nowiki>', '</nowiki>', '$1', $text, 'i');
     $attribs = Sanitizer::validateTagAttributes($attribs, 'pre');
     return wfOpenElement('pre', $attribs) . Xml::escapeTagsOnly($content) . '</pre>';
 }
Example #10
0
 /**
  * Show a form for filtering namespace and username
  *
  * @return string
  */
 function getPageHeader()
 {
     $self = Title::makeTitle(NS_SPECIAL, $this->getName());
     $form = wfOpenElement('form', array('method' => 'post', 'action' => $self->getLocalUrl()));
     $form .= '<table><tr><td align="right">' . wfMsgHtml('namespace') . '</td>';
     $form .= '<td>' . HtmlNamespaceSelector($this->namespace) . '</td><tr>';
     $form .= '<tr><td align="right">' . wfMsgHtml('newpages-username') . '</td>';
     $form .= '<td>' . wfInput('username', 30, $this->username) . '</td></tr>';
     $form .= '<tr><td></td><td>' . wfSubmitButton(wfMsg('allpagessubmit')) . '</td></tr></table>';
     $form .= wfHidden('offset', $this->offset) . wfHidden('limit', $this->limit) . '</form>';
     return $form;
 }
 /**
  * Display a page stating that the Wiki is in read-only mode,
  * and optionally show the source of the page that the user
  * was trying to edit.  Should only be called (for this
  * purpose) after wfReadOnly() has returned true.
  *
  * For historical reasons, this function is _also_ used to
  * show the error message when a user tries to edit a page
  * they are not allowed to edit.  (Unless it's because they're
  * blocked, then we show blockedPage() instead.)  In this
  * case, the second parameter should be set to true and a list
  * of reasons supplied as the third parameter.
  *
  * @todo Needs to be split into multiple functions.
  *
  * @param string $source    Source code to show (or null).
  * @param bool   $protected Is this a permissions error?
  * @param array  $reasons   List of reasons for this error, as returned by Title::getUserPermissionsErrors().
  */
 public function readOnlyPage($source = null, $protected = false, $reasons = array())
 {
     global $wgUser, $wgReadOnlyFile, $wgReadOnly, $wgTitle;
     $skin = $wgUser->getSkin();
     $this->setRobotpolicy('noindex,nofollow');
     $this->setArticleRelated(false);
     // If no reason is given, just supply a default "I can't let you do
     // that, Dave" message.  Should only occur if called by legacy code.
     if ($protected && empty($reasons)) {
         $reasons[] = array('badaccess-group0');
     }
     if (!empty($reasons)) {
         // Permissions error
         if ($source) {
             $this->setPageTitle(wfMsg('viewsource'));
             $this->setSubtitle(wfMsg('viewsourcefor', $skin->makeKnownLinkObj($wgTitle)));
         } else {
             $this->setPageTitle(wfMsg('badaccess'));
         }
         $this->addWikiText($this->formatPermissionsErrorMessage($reasons));
     } else {
         // Wiki is read only
         $this->setPageTitle(wfMsg('readonly'));
         if ($wgReadOnly) {
             $reason = $wgReadOnly;
         } else {
             // Should not happen, user should have called wfReadOnly() first
             $reason = file_get_contents($wgReadOnlyFile);
         }
         $this->addWikiMsg('readonlytext', $reason);
     }
     // Show source, if supplied
     if (is_string($source)) {
         $this->addWikiMsg('viewsourcetext');
         $text = wfOpenElement('textarea', array('id' => 'wpTextbox1', 'name' => 'wpTextbox1', 'cols' => $wgUser->getOption('cols'), 'rows' => $wgUser->getOption('rows'), 'readonly' => 'readonly'));
         $text .= htmlspecialchars($source);
         $text .= wfCloseElement('textarea');
         $this->addHTML($text);
         // Show templates used by this article
         $skin = $wgUser->getSkin();
         $article = new Article($wgTitle);
         $this->addHTML($skin->formatTemplates($article->getUsedTemplates()));
     }
     # If the title doesn't exist, it's fairly pointless to print a return
     # link to it.  After all, you just tried editing it and couldn't, so
     # what's there to do there?
     if ($wgTitle->exists()) {
         $this->returnToMain(false, $wgTitle);
     }
 }
 function showRevision($timestamp)
 {
     global $wgLang, $wgUser, $wgOut;
     $self = SpecialPage::getTitleFor('Undelete');
     $skin = $wgUser->getSkin();
     if (!preg_match("/[0-9]{14}/", $timestamp)) {
         return 0;
     }
     $archive = new PageArchive($this->mTargetObj);
     $rev = $archive->getRevision($timestamp);
     if (!$rev) {
         $wgOut->addWikiMsg('undeleterevision-missing');
         return;
     }
     $wgOut->setPageTitle(wfMsg('undeletepage'));
     $link = $skin->makeKnownLinkObj(SpecialPage::getTitleFor('Undelete', $this->mTargetObj->getPrefixedDBkey()), htmlspecialchars($this->mTargetObj->getPrefixedText()));
     $time = htmlspecialchars($wgLang->timeAndDate($timestamp, true));
     $user = $skin->userLink($rev->getUser(), $rev->getUserText()) . $skin->userToolLinks($rev->getUser(), $rev->getUserText());
     if ($this->mDiff) {
         $previousRev = $archive->getPreviousRevision($timestamp);
         if ($previousRev) {
             $this->showDiff($previousRev, $rev);
             if ($wgUser->getOption('diffonly')) {
                 return;
             } else {
                 $wgOut->addHtml('<hr />');
             }
         } else {
             $wgOut->addHtml(wfMsgHtml('undelete-nodiff'));
         }
     }
     $wgOut->addHtml('<p>' . wfMsgHtml('undelete-revision', $link, $time, $user) . '</p>');
     wfRunHooks('UndeleteShowRevision', array($this->mTargetObj, $rev));
     if ($this->mPreview) {
         $wgOut->addHtml("<hr />\n");
         $wgOut->addWikiTextTitleTidy($rev->getText(), $this->mTargetObj, false);
     }
     $wgOut->addHtml(wfElement('textarea', array('readonly' => 'readonly', 'cols' => intval($wgUser->getOption('cols')), 'rows' => intval($wgUser->getOption('rows'))), $rev->getText() . "\n") . wfOpenElement('div') . wfOpenElement('form', array('method' => 'post', 'action' => $self->getLocalURL("action=submit"))) . wfElement('input', array('type' => 'hidden', 'name' => 'target', 'value' => $this->mTargetObj->getPrefixedDbKey())) . wfElement('input', array('type' => 'hidden', 'name' => 'timestamp', 'value' => $timestamp)) . wfElement('input', array('type' => 'hidden', 'name' => 'wpEditToken', 'value' => $wgUser->editToken())) . wfElement('input', array('type' => 'submit', 'name' => 'preview', 'value' => wfMsg('showpreview'))) . wfElement('input', array('name' => 'diff', 'type' => 'submit', 'value' => wfMsg('showdiff'))) . wfCloseElement('form') . wfCloseElement('div'));
 }
Example #13
0
 function showHistory()
 {
     global $wgLang, $wgUser, $wgOut;
     $sk = $wgUser->getSkin();
     if ($this->mAllowed) {
         $wgOut->setPagetitle(wfMsg("undeletepage"));
     } else {
         $wgOut->setPagetitle(wfMsg('viewdeletedpage'));
     }
     $archive = new PageArchive($this->mTargetObj);
     $text = $archive->getLastRevisionText();
     /*
     if( is_null( $text ) ) {
     	$wgOut->addWikiText( wfMsg( "nohistory" ) );
     	return;
     }
     */
     if ($this->mAllowed) {
         $wgOut->addWikiText(wfMsg("undeletehistory"));
     } else {
         $wgOut->addWikiText(wfMsg("undeletehistorynoadmin"));
     }
     # List all stored revisions
     $revisions = $archive->listRevisions();
     $files = $archive->listFiles();
     $haveRevisions = $revisions && $revisions->numRows() > 0;
     $haveFiles = $files && $files->numRows() > 0;
     # Batch existence check on user and talk pages
     if ($haveRevisions) {
         $batch = new LinkBatch();
         while ($row = $revisions->fetchObject()) {
             $batch->addObj(Title::makeTitleSafe(NS_USER, $row->ar_user_text));
             $batch->addObj(Title::makeTitleSafe(NS_USER_TALK, $row->ar_user_text));
         }
         $batch->execute();
         $revisions->seek(0);
     }
     if ($haveFiles) {
         $batch = new LinkBatch();
         while ($row = $files->fetchObject()) {
             $batch->addObj(Title::makeTitleSafe(NS_USER, $row->fa_user_text));
             $batch->addObj(Title::makeTitleSafe(NS_USER_TALK, $row->fa_user_text));
         }
         $batch->execute();
         $files->seek(0);
     }
     if ($this->mAllowed) {
         $titleObj = Title::makeTitle(NS_SPECIAL, "Undelete");
         $action = $titleObj->getLocalURL("action=submit");
         # Start the form here
         $top = wfOpenElement('form', array('method' => 'post', 'action' => $action, 'id' => 'undelete'));
         $wgOut->addHtml($top);
     }
     # Show relevant lines from the deletion log:
     $wgOut->addHTML("<h2>" . htmlspecialchars(LogPage::logName('delete')) . "</h2>\n");
     $logViewer = new LogViewer(new LogReader(new FauxRequest(array('page' => $this->mTargetObj->getPrefixedText(), 'type' => 'delete'))));
     $logViewer->showList($wgOut);
     if ($this->mAllowed && ($haveRevisions || $haveFiles)) {
         # Format the user-visible controls (comment field, submission button)
         # in a nice little table
         $table = '<fieldset><table><tr>';
         $table .= '<td colspan="2">' . wfMsgWikiHtml('undeleteextrahelp') . '</td></tr><tr>';
         $table .= '<td align="right"><strong>' . wfMsgHtml('undeletecomment') . '</strong></td>';
         $table .= '<td>' . wfInput('wpComment', 50, $this->mComment) . '</td>';
         $table .= '</tr><tr><td>&nbsp;</td><td>';
         $table .= wfSubmitButton(wfMsg('undeletebtn'), array('name' => 'restore'));
         $table .= wfElement('input', array('type' => 'reset', 'value' => wfMsg('undeletereset')));
         $table .= '</td></tr></table></fieldset>';
         $wgOut->addHtml($table);
     }
     $wgOut->addHTML("<h2>" . htmlspecialchars(wfMsg("history")) . "</h2>\n");
     if ($haveRevisions) {
         # The page's stored (deleted) history:
         $wgOut->addHTML("<ul>");
         $target = urlencode($this->mTarget);
         while ($row = $revisions->fetchObject()) {
             $ts = wfTimestamp(TS_MW, $row->ar_timestamp);
             if ($this->mAllowed) {
                 $checkBox = wfCheck("ts{$ts}");
                 $pageLink = $sk->makeKnownLinkObj($titleObj, $wgLang->timeanddate($ts, true), "target={$target}&timestamp={$ts}");
             } else {
                 $checkBox = '';
                 $pageLink = $wgLang->timeanddate($ts, true);
             }
             $userLink = $sk->userLink($row->ar_user, $row->ar_user_text) . $sk->userToolLinks($row->ar_user, $row->ar_user_text);
             $comment = $sk->commentBlock($row->ar_comment);
             $wgOut->addHTML("<li>{$checkBox} {$pageLink} . . {$userLink} {$comment}</li>\n");
         }
         $revisions->free();
         $wgOut->addHTML("</ul>");
     } else {
         $wgOut->addWikiText(wfMsg("nohistory"));
     }
     if ($haveFiles) {
         $wgOut->addHtml("<h2>" . wfMsgHtml('imghistory') . "</h2>\n");
         $wgOut->addHtml("<ul>");
         while ($row = $files->fetchObject()) {
             $ts = wfTimestamp(TS_MW, $row->fa_timestamp);
             if ($this->mAllowed && $row->fa_storage_key) {
                 $checkBox = wfCheck("fileid" . $row->fa_id);
                 $key = urlencode($row->fa_storage_key);
                 $target = urlencode($this->mTarget);
                 $pageLink = $sk->makeKnownLinkObj($titleObj, $wgLang->timeanddate($ts, true), "target={$target}&file={$key}");
             } else {
                 $checkBox = '';
                 $pageLink = $wgLang->timeanddate($ts, true);
             }
             $userLink = $sk->userLink($row->fa_user, $row->fa_user_text) . $sk->userToolLinks($row->fa_user, $row->fa_user_text);
             $data = wfMsgHtml('widthheight', $wgLang->formatNum($row->fa_width), $wgLang->formatNum($row->fa_height)) . ' (' . wfMsgHtml('nbytes', $wgLang->formatNum($row->fa_size)) . ')';
             $comment = $sk->commentBlock($row->fa_description);
             $wgOut->addHTML("<li>{$checkBox} {$pageLink} . . {$userLink} {$data} {$comment}</li>\n");
         }
         $files->free();
         $wgOut->addHTML("</ul>");
     }
     if ($this->mAllowed) {
         # Slip in the hidden controls here
         $misc = wfHidden('target', $this->mTarget);
         $misc .= wfHidden('wpEditToken', $wgUser->editToken());
         $wgOut->addHtml($misc . '</form>');
     }
     return true;
 }
 /**
  * Make the big table of radio buttons and permissions
  * @param form the form that it is adding the radio buttons to.
  * @param getcurrentvalues is used for determining if it should set the radio buttons at the current permissions
  */
 function createCheckboxes(&$form, $getcurrentvalues)
 {
     global $wgGroupPermissions;
     if ($getcurrentvalues) {
         //let's extract the appropriate array of values from GroupPermissions once so we don't have to put it in the foreach
         foreach ($wgGroupPermissions as $group => $permissions) {
             if ($group == $this->target) {
                 $evGroupPermissions = $permissions;
                 break;
             }
         }
     }
     foreach ($this->permissionslist as $right) {
         if ($getcurrentvalues) {
             foreach ($evGroupPermissions as $permission => $value) {
                 $bool = in_array($right, array_keys($evGroupPermissions));
                 if ($right == $permission || !$bool) {
                     $form .= wfOpenElement('tr') . wfOpenElement('td') . "{$right}: " . wfCloseElement('td');
                     $form .= wfOpenElement('td') . wfElement('label', array('for' => "{$right}-true"), wfMsg('grouppermissions-true')) . ' ';
                     if ($value == 1 && $bool) {
                         //right is set to true
                         $form .= $this->makeRadio($right, 'true', true) . wfCloseElement('td');
                     } else {
                         $form .= $this->makeRadio($right, 'true') . wfCloseElement('td');
                     }
                     $form .= wfOpenElement('td') . wfElement('label', array('for' => "{$right}-false"), wfMsg('grouppermissions-false')) . ' ';
                     if ($value == 0 && $bool) {
                         //right is set to false
                         $form .= $this->makeRadio($right, 'false', true) . wfCloseElement('td');
                     } else {
                         $form .= $this->makeRadio($right, 'false') . wfCloseElement('td');
                     }
                     $form .= wfOpenElement('td') . wfElement('label', array('for' => "{$right}-inherit"), wfMsg('grouppermissions-inherit')) . ' ';
                     if (!$bool) {
                         //right isn't set, which means that it is inherited from other groups
                         $form .= $this->makeRadio($right, 'inherit', true) . wfCloseElement('td');
                     } else {
                         $form .= $this->makeRadio($right, 'inherit') . wfCloseElement('td');
                     }
                     $form .= wfCloseElement('tr');
                     break;
                 }
             }
         } else {
             //just set it at inherit
             $form .= wfOpenElement('tr') . wfOpenElement('td') . "{$right}: " . wfCloseElement('td');
             $form .= wfOpenElement('td') . wfElement('label', array('for' => "{$right}-true"), wfMsg('grouppermissions-true')) . ' ';
             $form .= $this->makeRadio($right, 'true') . wfCloseElement('td');
             $form .= wfOpenElement('td') . wfElement('label', array('for' => "{$right}-false"), wfMsg('grouppermissions-false')) . ' ';
             $form .= $this->makeRadio($right, 'false') . wfCloseElement('td');
             $form .= wfOpenElement('td') . wfElement('label', array('for' => "{$right}-inherit"), wfMsg('grouppermissions-inherit')) . ' ';
             $form .= $this->makeRadio($right, 'inherit', true);
             $form .= wfCloseElement('td') . wfCloseElement('tr');
         }
     }
 }
 function makeNamespaceForm()
 {
     $self = Title::makeTitle(NS_SPECIAL, $this->getName());
     $form = wfOpenElement('form', array('method' => 'post', 'action' => $self->getLocalUrl()));
     $form .= wfLabel(wfMsg('newestpages-namespace'), 'namespace') . '&nbsp;';
     $form .= htmlNamespaceSelector($this->namespace, 'all');
     $form .= wfHidden('limit', $this->limit);
     $form .= wfHidden('redirects', $this->redirects);
     $form .= wfSubmitButton(wfMsg('newestpages-submit')) . '</form>';
     return $form;
 }
 /**
  * Input form for entering a category
  */
 function makeInputForm()
 {
     global $wgScript;
     $thisTitle = Title::makeTitle(NS_SPECIAL, $this->getName());
     $form = '';
     $form .= wfOpenElement('form', array('name' => 'categorytree', 'method' => 'get', 'action' => $wgScript));
     $form .= wfElement('input', array('type' => 'hidden', 'name' => 'title', 'value' => $thisTitle->getPrefixedDbKey()));
     $form .= wfElement('label', array('for' => 'target'), wfMsg('categorytree-category')) . ' ';
     $form .= wfElement('input', array('type' => 'text', 'name' => 'target', 'id' => 'target', 'value' => $this->target)) . ' ';
     $form .= wfOpenElement('select', array('name' => 'mode'));
     $form .= wfElement('option', array('value' => 'categories') + ($this->mode == CT_MODE_CATEGORIES ? array('selected' => 'selected') : array()), wfMsg('categorytree-mode-categories'));
     $form .= wfElement('option', array('value' => 'pages') + ($this->mode == CT_MODE_PAGES ? array('selected' => 'selected') : array()), wfMsg('categorytree-mode-pages'));
     $form .= wfElement('option', array('value' => 'all') + ($this->mode == CT_MODE_ALL ? array('selected' => 'selected') : array()), wfMsg('categorytree-mode-all'));
     $form .= wfCloseElement('select');
     $form .= wfElement('input', array('type' => 'submit', 'name' => 'dotree', 'value' => wfMsg('categorytree-go')));
     $form .= wfCloseElement('form');
     return $form;
 }
Example #17
0
 /**
  * Show a namespace selection form for filtering
  *
  * @return string
  */
 function getPageHeader()
 {
     $thisTitle = Title::makeTitle(NS_SPECIAL, $this->getName());
     $form = wfOpenElement('form', array('method' => 'get', 'action' => $thisTitle->getLocalUrl()));
     $form .= wfElement('label', array('for' => 'status'), 'Status') . ' ';
     $form .= StructuredData::addSelectToHtml(0, 'status', self::$STATUS_OPTIONS, $this->status, '', false);
     # Preserve the offset and limit
     $form .= wfElement('input', array('type' => 'hidden', 'name' => 'offset', 'value' => $this->offset));
     $form .= wfElement('input', array('type' => 'hidden', 'name' => 'limit', 'value' => $this->limit));
     $form .= wfElement('input', array('type' => 'submit', 'name' => 'submit', 'id' => 'submit', 'value' => wfMsg('allpagessubmit')));
     $form .= wfCloseElement('form');
     return $form;
 }
Example #18
0
 /**
  * @return string
  */
 function wgHooks()
 {
     global $wgHooks;
     if (count($wgHooks)) {
         $myWgHooks = $wgHooks;
         ksort($myWgHooks);
         $ret = "<h2>Hooks</h2>\n" . wfOpenElement('table', array('id' => 'sv-hooks')) . "<tr><th>Hook name</th><th>Subscribed by</th></tr>\n";
         foreach ($myWgHooks as $hook => $hooks) {
             $ret .= "<tr><td>{$hook}</td><td>" . $this->listToText($hooks) . "</td></tr>\n";
         }
         $ret .= '</table>';
         return $ret;
     } else {
         return '';
     }
 }
 function execute()
 {
     global $wgOut, $wgTitle, $wgScript;
     $wgOut->addHTML(wfElement('form', array('id' => 'specialfilepath', 'method' => 'get', 'action' => $wgScript), null) . wfHidden('title', $wgTitle->getPrefixedText()) . wfOpenElement('label') . wfMsgHtml('filepath-page') . ' ' . wfElement('input', array('type' => 'text', 'size' => 25, 'name' => 'file', 'value' => is_object($this->mTitle) ? $this->mTitle->getText() : ''), '') . ' ' . wfElement('input', array('type' => 'submit', 'value' => wfMsgHtml('filepath-submit')), '') . wfCloseElement('label') . wfCloseElement('form'));
 }
Example #20
0
 /**
  * Call the stock "user is blocked" page
  */
 function blockedPage()
 {
     global $wgOut, $wgUser;
     $wgOut->blockedPage(false);
     # Standard block notice on the top, don't 'return'
     # If the user made changes, preserve them when showing the markup
     # (This happens when a user is blocked during edit, for instance)
     $first = $this->firsttime || !$this->save && $this->textbox1 == '';
     if ($first) {
         $source = $this->mTitle->exists() ? $this->getContent() : false;
     } else {
         $source = $this->textbox1;
     }
     # Spit out the source or the user's modified version
     if ($source !== false) {
         $rows = $wgUser->getOption('rows');
         $cols = $wgUser->getOption('cols');
         $attribs = array('id' => 'wpTextbox1', 'name' => 'wpTextbox1', 'cols' => $cols, 'rows' => $rows, 'readonly' => 'readonly');
         $wgOut->addHtml('<hr />');
         $wgOut->addWikiText(wfMsg($first ? 'blockedoriginalsource' : 'blockededitsource', $this->mTitle->getPrefixedText()));
         $wgOut->addHtml(wfOpenElement('textarea', $attribs) . htmlspecialchars($source) . wfCloseElement('textarea'));
     }
 }
 function execute($par)
 {
     global $wgRequest, $wgOut, $wgTitle, $wgLocalDatabases, $wgUser;
     global $wgConf, $wgCanonicalNamespaceNames, $wgLang;
     $this->setHeaders();
     # Check permissions
     if (!$wgUser->isAllowed('lookupcontribs')) {
         $wgOut->permissionRequired('lookupcontribs');
         return;
     }
     $user = $wgRequest->getText('user');
     #		$userName =  $user->getName();
     # Show form
     $self = Title::makeTitle(NS_SPECIAL, 'LookupContribs');
     $form = '<span>' . wfMsgHtml('lookupcontribs-summary') . '</span>';
     $form .= wfOpenElement('form', array('method' => 'get', 'action' => $self->getLocalUrl()));
     //original was method=post
     $form .= '<table><tr><td align="right">' . wfMsgHtml('lookupcontribs-user') . '</td>';
     $form .= '<td>' . wfInput('user', 50, $user) . '</td></tr>';
     $form .= '<tr><td></td><td>' . wfSubmitButton(wfMsg('go')) . '</td></tr></table></form>';
     $wgOut->addHtml($form);
     if ($user) {
         $dbr = wfGetDB(DB_SLAVE);
         $s = '';
         foreach ($wgLocalDatabases as $db) {
             $sql = "SELECT rc_namespace,rc_title,rc_timestamp,rc_user_text,rc_last_oldid FROM {$db}.recentchanges WHERE rc_user_text='" . $dbr->strencode($user) . "' AND rc_this_oldid=0";
             //TODO: use page & revision tables, alá Special:Contributions
             $res = $dbr->query($sql, "findspam.php");
             //this seems to be a wikimedia-specific hack that needs a total rewrite
             $arr = explode('.', strtolower($_SERVER['SERVER_NAME']));
             $subdomain = $arr[0];
             //list( $site, $lang ) = $wgConf->siteFromDB( $db );
             //if ( $lang == 'en' ) {
             //	$baseUrl = "http://internal.jackphoenix.com"; //ugly!
             //} else {
             $baseUrl = "http://{$subdomain}.jackphoenix.com";
             //}
             if ($dbr->numRows($res)) {
                 $s .= "\n{$db}\n";
                 while ($row = $dbr->fetchObject($res)) {
                     if ($row->rc_namespace == 0) {
                         $title = $row->rc_title;
                     } else {
                         $title = $wgCanonicalNamespaceNames[$row->rc_namespace] . ':' . $row->rc_title;
                     }
                     $encTitle = urlencode($title);
                     $url = "{$baseUrl}/wiki/{$encTitle}";
                     $user = urlencode($row->rc_user_text);
                     $rollbackText = wfMsg('rollback');
                     $diffText = wfMsg('diff');
                     $rollbackUrl = "{$baseUrl}/w/wiki.phtml?title={$encTitle}&action=rollback&from={$user}";
                     $diffUrl = "{$baseUrl}/w/wiki.phtml?title={$encTitle}&diff=0&oldid=0";
                     if ($row->rc_last_oldid) {
                         $lastLink = "[{$baseUrl}/w/wiki.phtml?title={$encTitle}&oldid={$row->rc_last_oldid}&action=edit last]";
                     }
                     $date = $wgLang->timeanddate($row->rc_timestamp);
                     $s .= "* {$date} [{$url} {$title}] ([{$rollbackUrl} {$rollbackText}] | [{$diffUrl} {$diffText}])\n";
                     $s .= "* {$date} [{$url} {$title}] ({$lastLink} | [{$diffUrl} {$diffText}])\n";
                 }
             }
         }
         if ($s == '') {
             $s = wfMsg('lookupcontribs-notextfound');
         }
         /* TODO: fixme 
         			if (!$userName->exists) {
         			wfMsg('nosuchusershort');
         			}*/
         $wgOut->addWikiText($s . "<br />");
     }
 }
 function execute()
 {
     global $wgOut, $wgTitle;
     $wgOut->addHTML(wfElement('form', array('id' => 'specialcite', 'method' => 'get', 'action' => $wgTitle->escapeLocalUrl()), null) . wfOpenElement('label') . wfMsgHtml('cite_page') . ' ' . wfElement('input', array('type' => 'text', 'size' => 20, 'name' => 'page', 'value' => is_object($this->mTitle) ? $this->mTitle->getPrefixedText() : ''), '') . ' ' . wfElement('input', array('type' => 'submit', 'value' => wfMsgHtml('cite_submit')), '') . wfCloseElement('label') . wfCloseElement('form'));
 }
Example #23
0
 /**
  * Tag hook handler for 'pre'.
  */
 function renderPreTag($text, $attribs, $parser)
 {
     // Backwards-compatibility hack
     $content = preg_replace('!<nowiki>(.*?)</nowiki>!is', '\\1', $text);
     $attribs = Sanitizer::validateTagAttributes($attribs, 'pre');
     return wfOpenElement('pre', $attribs) . wfEscapeHTMLTagsOnly($content) . '</pre>';
 }
Example #24
0
/**
 *
 */
function wfSpecialExport($page = '')
{
    global $wgOut, $wgRequest, $wgExportAllowListContributors;
    global $wgExportAllowHistory, $wgExportMaxHistory;
    $curonly = true;
    if ($wgRequest->getVal('action') == 'submit') {
        $page = $wgRequest->getText('pages');
        $curonly = $wgRequest->getCheck('curonly');
    }
    if ($wgRequest->getCheck('history')) {
        $curonly = false;
    }
    if (!$wgExportAllowHistory) {
        // Override
        $curonly = true;
    }
    $list_authors = $wgRequest->getCheck('listauthors');
    if (!$curonly || !$wgExportAllowListContributors) {
        $list_authors = false;
    }
    if ($page != '') {
        $wgOut->disable();
        // Cancel output buffering and gzipping if set
        // This should provide safer streaming for pages with history
        while ($status = ob_get_status()) {
            ob_end_clean();
            if ($status['name'] == 'ob_gzhandler') {
                header('Content-Encoding:');
            }
        }
        header("Content-type: application/xml; charset=utf-8");
        $pages = explode("\n", $page);
        $db =& wfGetDB(DB_SLAVE);
        $history = $curonly ? MW_EXPORT_CURRENT : MW_EXPORT_FULL;
        $exporter = new WikiExporter($db, $history);
        $exporter->list_authors = $list_authors;
        $exporter->openStream();
        foreach ($pages as $page) {
            if ($wgExportMaxHistory && !$curonly) {
                $title = Title::newFromText($page);
                if ($title) {
                    $count = Revision::countByTitle($db, $title);
                    if ($count > $wgExportMaxHistory) {
                        wfDebug(__FUNCTION__ . ": Skipped {$page}, {$count} revisions too big\n");
                        continue;
                    }
                }
            }
            $exporter->pageByName($page);
        }
        $exporter->closeStream();
        return;
    }
    $wgOut->addWikiText(wfMsg("exporttext"));
    $titleObj = Title::makeTitle(NS_SPECIAL, "Export");
    $form = wfOpenElement('form', array('method' => 'post', 'action' => $titleObj->getLocalUrl()));
    $form .= wfOpenElement('textarea', array('name' => 'pages', 'cols' => 40, 'rows' => 10)) . '</textarea><br />';
    if ($wgExportAllowHistory) {
        $form .= wfCheck('curonly', true, array('value' => 'true', 'id' => 'curonly'));
        $form .= wfLabel(wfMsg('exportcuronly'), 'curonly') . '<br />';
    } else {
        $wgOut->addWikiText(wfMsg('exportnohistory'));
    }
    $form .= wfHidden('action', 'submit');
    $form .= wfSubmitButton(wfMsg('export-submit')) . '</form>';
    $wgOut->addHtml($form);
}
Example #25
0
/**
 *
 */
function wfSpecialExport($page = '')
{
    global $wgOut, $wgRequest, $wgExportAllowListContributors;
    global $wgExportAllowHistory, $wgExportMaxHistory;
    $curonly = true;
    $fullHistory = array('dir' => 'asc', 'offset' => false, 'limit' => $wgExportMaxHistory);
    if ($wgRequest->wasPosted()) {
        $page = $wgRequest->getText('pages');
        $curonly = $wgRequest->getCheck('curonly');
        $rawOffset = $wgRequest->getVal('offset');
        if ($rawOffset) {
            $offset = wfTimestamp(TS_MW, $rawOffset);
        } else {
            $offset = null;
        }
        $limit = $wgRequest->getInt('limit');
        $dir = $wgRequest->getVal('dir');
        $history = array('dir' => 'asc', 'offset' => false, 'limit' => $wgExportMaxHistory);
        $historyCheck = $wgRequest->getCheck('history');
        if ($curonly) {
            $history = WikiExporter::CURRENT;
        } elseif (!$historyCheck) {
            if ($limit > 0 && $limit < $wgExportMaxHistory) {
                $history['limit'] = $limit;
            }
            if (!is_null($offset)) {
                $history['offset'] = $offset;
            }
            if (strtolower($dir) == 'desc') {
                $history['dir'] = 'desc';
            }
        }
    } else {
        // Default to current-only for GET requests
        $page = $wgRequest->getText('pages', $page);
        $historyCheck = $wgRequest->getCheck('history');
        if ($historyCheck) {
            $history = WikiExporter::FULL;
        } else {
            $history = WikiExporter::CURRENT;
        }
    }
    if (!$wgExportAllowHistory) {
        // Override
        $history = WikiExporter::CURRENT;
    }
    $list_authors = $wgRequest->getCheck('listauthors');
    if (!$curonly || !$wgExportAllowListContributors) {
        $list_authors = false;
    }
    if ($page != '') {
        $wgOut->disable();
        // Cancel output buffering and gzipping if set
        // This should provide safer streaming for pages with history
        while ($status = ob_get_status()) {
            ob_end_clean();
            if ($status['name'] == 'ob_gzhandler') {
                header('Content-Encoding:');
            }
        }
        header("Content-type: application/xml; charset=utf-8");
        $pages = explode("\n", $page);
        $db =& wfGetDB(DB_SLAVE);
        $exporter = new WikiExporter($db, $history);
        $exporter->list_authors = $list_authors;
        $exporter->openStream();
        foreach ($pages as $page) {
            /*
            			if( $wgExportMaxHistory && !$curonly ) {
            				$title = Title::newFromText( $page );
            				if( $title ) {
            					$count = Revision::countByTitle( $db, $title );
            					if( $count > $wgExportMaxHistory ) {
            						wfDebug( __FUNCTION__ .
            							": Skipped $page, $count revisions too big\n" );
            						continue;
            					}
            				}
            			}*/
            $exporter->pageByName($page);
        }
        $exporter->closeStream();
        return;
    }
    $wgOut->addWikiText(wfMsg("exporttext"));
    $titleObj = Title::makeTitle(NS_SPECIAL, "Export");
    $form = wfOpenElement('form', array('method' => 'post', 'action' => $titleObj->getLocalUrl()));
    $form .= wfOpenElement('textarea', array('name' => 'pages', 'cols' => 40, 'rows' => 10)) . '</textarea><br />';
    if ($wgExportAllowHistory) {
        $form .= wfCheck('curonly', true, array('value' => 'true', 'id' => 'curonly'));
        $form .= wfLabel(wfMsg('exportcuronly'), 'curonly') . '<br />';
    } else {
        $wgOut->addWikiText(wfMsg('exportnohistory'));
    }
    $form .= wfHidden('action', 'submit');
    $form .= wfSubmitButton(wfMsg('export-submit')) . '</form>';
    $wgOut->addHtml($form);
}
Example #26
0
 function buildSelector($action, $selected)
 {
     global $wgRestrictionLevels;
     $id = 'mwProtect-level-' . $action;
     $attribs = array('id' => $id, 'name' => $id, 'size' => count($wgRestrictionLevels), 'onchange' => 'protectLevelsUpdate(this)') + $this->disabledAttrib;
     $out = wfOpenElement('select', $attribs);
     foreach ($wgRestrictionLevels as $key) {
         $out .= $this->buildOption($key, $selected);
     }
     $out .= "</select>\n";
     return $out;
 }
Example #27
0
 /**
  * Really do the upload
  * Checks are made in SpecialUpload::execute()
  * @access private
  */
 function processUpload()
 {
     global $wgUser, $wgOut;
     /* Check for PHP error if any, requires php 4.2 or newer */
     if ($this->mUploadError == 1) {
         $this->mainUploadForm(wfMsgHtml('largefileserver'));
         return;
     }
     /**
      * If there was no filename or a zero size given, give up quick.
      */
     if (trim($this->mOname) == '' || empty($this->mUploadSize)) {
         $this->mainUploadForm(wfMsgHtml('emptyfile'));
         return;
     }
     # Chop off any directories in the given filename
     if ($this->mDestFile) {
         $basename = wfBaseName($this->mDestFile);
     } else {
         $basename = wfBaseName($this->mOname);
     }
     /**
      * We'll want to blacklist against *any* 'extension', and use
      * only the final one for the whitelist.
      */
     list($partname, $ext) = $this->splitExtensions($basename);
     if (count($ext)) {
         $finalExt = $ext[count($ext) - 1];
     } else {
         $finalExt = '';
     }
     $fullExt = implode('.', $ext);
     # If there was more than one "extension", reassemble the base
     # filename to prevent bogus complaints about length
     if (count($ext) > 1) {
         for ($i = 0; $i < count($ext) - 1; $i++) {
             $partname .= '.' . $ext[$i];
         }
     }
     if (strlen($partname) < 3) {
         $this->mainUploadForm(wfMsgHtml('minlength'));
         return;
     }
     /**
      * Filter out illegal characters, and try to make a legible name
      * out of it. We'll strip some silently that Title would die on.
      */
     $filtered = preg_replace("/[^" . Title::legalChars() . "]|:/", '-', $basename);
     $nt = Title::newFromText($filtered);
     if (is_null($nt)) {
         $this->uploadError(wfMsgWikiHtml('illegalfilename', htmlspecialchars($filtered)));
         return;
     }
     $nt =& Title::makeTitle(NS_IMAGE, $nt->getDBkey());
     $this->mUploadSaveName = $nt->getDBkey();
     /**
      * If the image is protected, non-sysop users won't be able
      * to modify it by uploading a new revision.
      */
     if (!$nt->userCanEdit()) {
         return $this->uploadError(wfMsgWikiHtml('protectedpage'));
     }
     /**
      * In some cases we may forbid overwriting of existing files.
      */
     $overwrite = $this->checkOverwrite($this->mUploadSaveName);
     if (WikiError::isError($overwrite)) {
         return $this->uploadError($overwrite->toString());
     }
     /* Don't allow users to override the blacklist (check file extension) */
     global $wgStrictFileExtensions;
     global $wgFileExtensions, $wgFileBlacklist;
     if ($this->checkFileExtensionList($ext, $wgFileBlacklist) || $wgStrictFileExtensions && !$this->checkFileExtension($finalExt, $wgFileExtensions)) {
         return $this->uploadError(wfMsgHtml('badfiletype', htmlspecialchars($fullExt)));
     }
     /**
      * Look at the contents of the file; if we can recognize the
      * type but it's corrupt or data of the wrong type, we should
      * probably not accept it.
      */
     if (!$this->mStashed) {
         $this->checkMacBinary();
         $veri = $this->verify($this->mUploadTempName, $finalExt);
         if ($veri !== true) {
             //it's a wiki error...
             return $this->uploadError($veri->toString());
         }
     }
     /**
      * Provide an opportunity for extensions to add futher checks
      */
     $error = '';
     if (!wfRunHooks('UploadVerification', array($this->mUploadSaveName, $this->mUploadTempName, &$error))) {
         return $this->uploadError($error);
     }
     /**
      * Check for non-fatal conditions
      */
     if (!$this->mIgnoreWarning) {
         $warning = '';
         global $wgCapitalLinks;
         if ($wgCapitalLinks) {
             $filtered = ucfirst($filtered);
         }
         if ($this->mUploadSaveName != $filtered) {
             $warning .= '<li>' . wfMsgHtml('badfilename', htmlspecialchars($this->mUploadSaveName)) . '</li>';
         }
         global $wgCheckFileExtensions;
         if ($wgCheckFileExtensions) {
             if (!$this->checkFileExtension($finalExt, $wgFileExtensions)) {
                 $warning .= '<li>' . wfMsgHtml('badfiletype', htmlspecialchars($fullExt)) . '</li>';
             }
         }
         global $wgUploadSizeWarning;
         if ($wgUploadSizeWarning && $this->mUploadSize > $wgUploadSizeWarning) {
             # TODO: Format $wgUploadSizeWarning to something that looks better than the raw byte
             # value, perhaps add GB,MB and KB suffixes?
             $warning .= '<li>' . wfMsgHtml('largefile', $wgUploadSizeWarning, $this->mUploadSize) . '</li>';
         }
         if ($this->mUploadSize == 0) {
             $warning .= '<li>' . wfMsgHtml('emptyfile') . '</li>';
         }
         if ($nt->getArticleID()) {
             global $wgUser;
             $sk = $wgUser->getSkin();
             $dlink = $sk->makeKnownLinkObj($nt);
             $warning .= '<li>' . wfMsgHtml('fileexists', $dlink) . '</li>';
         } else {
             # If the file existed before and was deleted, warn the user of this
             # Don't bother doing so if the image exists now, however
             $image = new Image($nt);
             if ($image->wasDeleted()) {
                 $skin = $wgUser->getSkin();
                 $ltitle = Title::makeTitle(NS_SPECIAL, 'Log');
                 $llink = $skin->makeKnownLinkObj($ltitle, wfMsgHtml('deletionlog'), 'type=delete&page=' . $nt->getPrefixedUrl());
                 $warning .= wfOpenElement('li') . wfMsgWikiHtml('filewasdeleted', $llink) . wfCloseElement('li');
             }
         }
         if ($warning != '') {
             /**
              * Stash the file in a temporary location; the user can choose
              * to let it through and we'll complete the upload then.
              */
             return $this->uploadWarning($warning);
         }
     }
     /**
      * Try actually saving the thing...
      * It will show an error form on failure.
      */
     $hasBeenMunged = !empty($this->mSessionKey) || $this->mRemoveTempFile;
     if ($this->saveUploadedFile($this->mUploadSaveName, $this->mUploadTempName, $hasBeenMunged)) {
         /**
          * Update the upload log and create the description page
          * if it's a new file.
          */
         $img = Image::newFromName($this->mUploadSaveName);
         $success = $img->recordUpload($this->mUploadOldVersion, $this->mUploadDescription, $this->mLicense, $this->mUploadCopyStatus, $this->mUploadSource, $this->mWatchthis);
         if ($success) {
             $this->showSuccess();
             wfRunHooks('UploadComplete', array(&$img));
         } else {
             // Image::recordUpload() fails if the image went missing, which is
             // unlikely, hence the lack of a specialised message
             $wgOut->showFileNotFoundError($this->mUploadSaveName);
         }
     }
 }