예제 #1
13
    function showDiffPage($diffOnly = false)
    {
        global $wgUser, $wgOut, $wgUseExternalEditor, $wgUseRCPatrol, $wgRequest, $wgTitle, $wgLanguageCode;
        $fname = 'DifferenceEngine::showDiffPage';
        wfProfileIn($fname);
        # If external diffs are enabled both globally and for the user,
        # we'll use the application/x-external-editor interface to call
        # an external diff tool like kompare, kdiff3, etc.
        if ($wgUseExternalEditor && $wgUser->getOption('externaldiff')) {
            global $wgInputEncoding, $wgServer, $wgScript, $wgLang;
            $wgOut->disable();
            header("Content-type: application/x-external-editor; charset=" . $wgInputEncoding);
            $url1 = $this->mTitle->getFullURL("action=raw&oldid=" . $this->mOldid);
            $url2 = $this->mTitle->getFullURL("action=raw&oldid=" . $this->mNewid);
            $special = $wgLang->getNsText(NS_SPECIAL);
            $control = <<<CONTROL
[Process]
Type=Diff text
Engine=MediaWiki
Script={$wgServer}{$wgScript}
Special namespace={$special}

[File]
Extension=wiki
URL={$url1}

[File 2]
Extension=wiki
URL={$url2}
CONTROL;
            echo $control;
            return;
        }
        $wgOut->setArticleFlag(false);
        if (!$this->loadRevisionData()) {
            $t = $this->mTitle->getPrefixedText() . " (Diff: {$this->mOldid}, {$this->mNewid})";
            $wgOut->setPagetitle(wfMsg('errorpagetitle'));
            $wgOut->addWikiMsg('missingarticle', "<nowiki>{$t}</nowiki>");
            wfProfileOut($fname);
            return;
        }
        wfRunHooks('DiffViewHeader', array($this, $this->mOldRev, $this->mNewRev));
        if ($this->mNewRev->isCurrent()) {
            $wgOut->setArticleFlag(true);
        }
        # mOldid is false if the difference engine is called with a "vague" query for
        # a diff between a version V and its previous version V' AND the version V
        # is the first version of that article. In that case, V' does not exist.
        if ($this->mOldid === false && false) {
            $this->showFirstRevision();
            $this->renderNewRevision();
            // should we respect $diffOnly here or not?
            wfProfileOut($fname);
            return;
        }
        $wgOut->suppressQuickbar();
        if (!$this->mOldPage) {
            $this->mOldPage = $this->mNewPage;
        }
        $oldTitle = $this->mOldPage->getPrefixedText();
        $newTitle = $this->mNewPage->getPrefixedText();
        if ($oldTitle == $newTitle) {
            $wgOut->setPageTitle($newTitle);
        } else {
            $wgOut->setPageTitle($oldTitle . ', ' . $newTitle);
        }
        $wgOut->setSubtitle(wfMsg('difference'));
        $wgOut->setRobotpolicy('noindex,nofollow');
        if (!($this->mOldPage->userCanRead() && $this->mNewPage->userCanRead())) {
            $wgOut->loginToUse();
            $wgOut->output();
            wfProfileOut($fname);
            exit;
        }
        $sk = $wgUser->getSkin();
        if ($this->mNewRev->isCurrent() && $wgUser->isAllowed('rollback') && $this->mTitle->userCanEdit()) {
            $rollback = $sk->generateRollback($this->mNewRev);
        } else {
            $rollback = '';
        }
        // Prepare a change patrol link, if applicable
        if ($wgUseRCPatrol && $wgUser->isAllowed('patrol')) {
            // If we've been given an explicit change identifier, use it; saves time
            if ($this->mRcidMarkPatrolled) {
                $rcid = $this->mRcidMarkPatrolled;
            } else {
                // Look for an unpatrolled change corresponding to this diff
                $db = wfGetDB(DB_SLAVE);
                $change = RecentChange::newFromConds(array('rc_user_text' => $this->mNewRev->getRawUserText(), 'rc_timestamp' => $db->timestamp($this->mNewRev->getTimestamp()), 'rc_this_oldid' => $this->mNewid, 'rc_last_oldid' => $this->mOldid, 'rc_patrolled' => 0), __METHOD__);
                if ($change instanceof RecentChange) {
                    $rcid = $change->mAttribs['rc_id'];
                } else {
                    // None found
                    $rcid = 0;
                }
            }
            // Build the link
            if ($rcid) {
                //XXCHANGED for recent changes patrolling
                $show_namespace = $wgRequest->getVal('show_namespace');
                $invert = $wgRequest->getVal('invert');
                $featured = $wgRequest->getVal('featured');
                $reverse = $wgRequest->getVal('reverse');
                //XXCHANGED
                $fromrc = "";
                if ($wgRequest->getVal('fromrc', null) != null) {
                    $fromrc = "&fromrc=1";
                }
                if ($this->mRcidMarkPatrolledCount > 1) {
                    $msg = wfMsg('markaspatrolleddiff_multiple', $this->mRcidMarkPatrolledCount);
                    $patrol = '[' . $sk->makeKnownLinkObj($this->mTitle, $msg, "action=markpatrolled&rcid={$this->mRcidMarkPatrolled}&show_namespace={$show_namespace}" . "&invert={$invert}&reverse={$reverse}&featured={$featured}" . "&rchi={$this->mRcidMarkPatrolledMax}&rclow={$this->mRcidMarkPatrolledMin}{$fromrc}", '', '', "accesskey='p'") . ']';
                    $patrol .= '[' . $sk->makeKnownLinkObj($this->mTitle, wfMsg('skip'), "action=markpatrolled&rcid={$this->mRcidMarkPatrolled}&show_namespace={$show_namespace}" . "&invert={$invert}&reverse={$reverse}&featured={$featured}" . "&rchi={$this->mRcidMarkPatrolledMax}&rclow={$this->mRcidMarkPatrolledMin}{$fromrc}&skip=1", '', '', "") . ']';
                } else {
                    $patrol = '[' . $sk->makeKnownLinkObj($this->mTitle, wfMsg('markaspatrolleddiff'), "action=markpatrolled&rcid={$rcid}&show_namespace={$show_namespace}&invert={$invert}&reverse={$reverse}&featured={$featured}{$fromrc}", '', '', "accesskey='p'") . ']';
                    $patrol .= ' [' . $sk->makeKnownLinkObj($this->mTitle, wfMsg('skip'), "action=markpatrolled&rcid={$this->mRcidMarkPatrolled}&show_namespace={$show_namespace}&invert={$invert}&reverse={$reverse}&featured={$featured}&skip=1{$fromrc}") . ']';
                }
                $patrol = "<span id='markaspatrolledlinks'>{$patrol}</span>";
                //XXADDED
            } else {
                $patrol = '';
            }
        } else {
            $patrol = '';
        }
        //XXADDED
        if ($wgUser->isAllowed('rollback') && $this->mTitle->userCanEdit()) {
            //$rollback .= '<br/>&nbsp;&nbsp;&nbsp;<strong>' . SpamDiffTool::getDiffLink($this->mTitle) . '</strong>';
        }
        $prevlink = $sk->makeKnownLinkObj($this->mTitle, wfMsgHtml('previousdiff'), 'diff=prev&oldid=' . $this->mOldid, '', '', 'id="differences-prevlink"');
        if ($this->mNewRev->isCurrent()) {
            $nextlink = '';
        } else {
            $nextlink = $sk->makeKnownLinkObj($this->mTitle, wfMsgHtml('nextdiff'), 'diff=next&oldid=' . $this->mNewid, '', '', 'id="differences-nextlink"');
        }
        $oldminor = '';
        $newminor = '';
        if ($this->mOldRev->mMinorEdit == 1) {
            $oldminor = wfElement('span', array('class' => 'minor'), wfMsg('minoreditletter')) . ' ';
        }
        if ($this->mNewRev->mMinorEdit == 1) {
            $newminor = wfElement('span', array('class' => 'minor'), wfMsg('minoreditletter')) . ' ';
        }
        $rdel = '';
        $ldel = '';
        if ($wgUser->isAllowed('deleterevision')) {
            $revdel = SpecialPage::getTitleFor('Revisiondelete');
            if (!$this->mOldRev->userCan(Revision::DELETED_RESTRICTED)) {
                // If revision was hidden from sysops
                $ldel = wfMsgHtml('rev-delundel');
            } else {
                $ldel = $sk->makeKnownLinkObj($revdel, wfMsgHtml('rev-delundel'), 'target=' . urlencode($this->mOldRev->mTitle->getPrefixedDbkey()) . '&oldid=' . urlencode($this->mOldRev->getId()));
                // Bolden oversighted content
                if ($this->mOldRev->isDeleted(Revision::DELETED_RESTRICTED)) {
                    $ldel = "<strong>{$ldel}</strong>";
                }
            }
            $ldel = "&nbsp;&nbsp;&nbsp;<tt>(<small>{$ldel}</small>)</tt> ";
            // We don't currently handle well changing the top revision's settings
            if ($this->mNewRev->isCurrent()) {
                // If revision was hidden from sysops
                $rdel = wfMsgHtml('rev-delundel');
            } else {
                if (!$this->mNewRev->userCan(Revision::DELETED_RESTRICTED)) {
                    // If revision was hidden from sysops
                    $rdel = wfMsgHtml('rev-delundel');
                } else {
                    $rdel = $sk->makeKnownLinkObj($revdel, wfMsgHtml('rev-delundel'), 'target=' . urlencode($this->mNewRev->mTitle->getPrefixedDbkey()) . '&oldid=' . urlencode($this->mNewRev->getId()));
                    // Bolden oversighted content
                    if ($this->mNewRev->isDeleted(Revision::DELETED_RESTRICTED)) {
                        $rdel = "<strong>{$rdel}</strong>";
                    }
                }
            }
            $rdel = "&nbsp;&nbsp;&nbsp;<tt>(<small>{$rdel}</small>)</tt> ";
        }
        if ($this->mOldRev) {
            /*$oldHeader = '<div id="mw-diff-otitle1"><strong>'.$this->mOldtitle.'</strong></div>' .
            		'<div id="mw-diff-otitle2">' . $sk->revUserTools( $this->mOldRev, true ) . "</div>" .
            		'<div id="mw-diff-otitle3">' . $oldminor . $sk->revComment( $this->mOldRev, !$diffOnly, true ) . $ldel . "</div>" .
            		'<div id="mw-diff-otitle4">' . $prevlink .'</div>';*/
            $comment = $oldminor . $sk->revComment($this->mOldRev, !$diffOnly, true) . $ldel;
            //INTL: Avatar database data doesn't exist for sites other than English
            if ($wgLanguageCode == 'en') {
                $av = '<img src="' . Avatar::getAvatarURL($this->mOldRev->mUserText) . '" class="diff_avatar" />';
            }
            //$userToolsString = $sk->revUserTools( $this->mOldRev, true );
            //$userParts = explode("(", $userToolsString, 2);
            //$userName = $userParts[0];
            //$userTools = "(" . $userParts[1];
            $userName = $sk->userLink($this->mOldRev->getUser(), $this->mOldRev->getUserText());
            $userTools = $sk->userToolLinks($this->mOldRev->getUser(), $this->mOldRev->getUserText());
            $oldHeader = '<div id="mw-diff-otitle1"><h4>' . $prevlink . $this->mOldtitle . '</h4></div>' . '<div class="diff_details">' . $av . '<div id="mw-diff-otitle1a">' . wfMsg('diff_by') . ' ' . $userName . '</div>' . '<div id="mw-diff-otitle2">' . $this->mOldDate . "</div>" . '<div id="mw-diff-otitle2b">' . $userTools . "</div>";
            if ($comment != "") {
                $oldHeader .= '<div id="mw-diff-otitle3" class="rccomment"><div class="">' . $comment . '</div></div>';
            }
            $oldHeader .= '</div>';
        } else {
            $oldHeader = wfMsg('diff_noprev');
        }
        /*$newHeader = '<div id="mw-diff-ntitle1"><strong>'.$this->mNewtitle.'</strong></div>' .
        		'<div id="mw-diff-ntitle2">' . $sk->revUserTools( $this->mNewRev, true ) . "</div>" .
        		'<div id="mw-diff-ntitle2a">' . $rollback . "</div>" .
        		'<div id="mw-diff-ntitle3">' . $newminor . $sk->revComment( $this->mNewRev, !$diffOnly, true ) . $rdel . "</div>" .
        		'<div id="mw-diff-ntitle4">' . $nextlink . $patrol . '</div>';*/
        $comment = $newminor . $sk->revComment($this->mNewRev, !$diffOnly, true) . $rdel;
        //INTL: Avatar database data doesn't exist for sites other than English
        if ($wgLanguageCode == 'en') {
            $av = '<img src="' . Avatar::getAvatarURL($this->mNewRev->mUserText) . '" class="diff_avatar" />';
        }
        //$userToolsString = $sk->revUserTools( $this->mNewRev, true );
        //$userParts = explode("(", $userToolsString, 2);
        //$userName = $userParts[0];
        //$userTools = "(" . $userParts[1];
        $userName = $sk->userLink($this->mNewRev->getUser(), $this->mNewRev->getUserText());
        $userTools = $sk->userToolLinks($this->mNewRev->getUser(), $this->mNewRev->getUserText());
        $thumbsHtml = "";
        $thumbHeader = "";
        $th_diff_div = "";
        if ($wgUser->getId() != 0 && $wgTitle->getText() != "RCPatrol" && $wgTitle->getText() != "RCPatrolGuts" && $this->mNewRev->getTitle()->getNamespace() == NS_MAIN) {
            $oldId = $this->mNewRev->getPrevious();
            $oldId = $oldId ? $oldId->getId() : -1;
            // Only show thumbs up for diffs that look back one revision
            if (class_exists('ThumbsUp')) {
                if ($oldId == -1 || $this->mOldRev && $oldId == $this->mOldRev->getId()) {
                    $params = array('title' => $this->mNewRev->getTitle(), 'new' => $this->mNewid, 'old' => $oldId, 'vandal' => 0);
                    $thumbsHtml = ThumbsUp::getThumbsUpButton($params, true);
                    //$thumbHeader = 'class="th_diff_h4"';
                    $th_diff_div = 'class="th_diff_div"';
                }
            }
        }
        $newHeader = '<div id="mw-diff-ntitle1" ' . $th_diff_div . '><h4 ' . $thumbHeader . '>' . $this->mNewtitle . ' ' . $nextlink . '</h4></div>' . '<div class="diff_details">' . $av . $thumbsHtml . '<div id="mw-diff-ntitle1a">' . wfMsg('diff_by') . ' ' . $userName . '</div>' . '<div id="mw-diff-ntitle2">' . $this->mNewDate . "</div>" . '<div id="mw-diff-ntitle2b">' . $userTools . "</div>" . '<div id="mw-diff-ntitle4" style="text-align:left">' . $rollback . $nextlink . $patrol . '</div>';
        if ($comment != "") {
            $newHeader .= '<div id="mw-diff-ntitle3" class="rccomment"><div class="">' . $comment . '</div></div>';
        }
        $newHeader .= '</div>';
        $this->showDiff($oldHeader, $newHeader);
        if (!$diffOnly) {
            $this->renderNewRevision();
        }
        wfProfileOut($fname);
    }
 /**
  * Show a drop down list to select a group as well as a user name
  * search box.
  * @todo localize
  */
 function getPageHeader()
 {
     global $wgScript;
     // Various variables used for the form
     $action = htmlspecialchars($wgScript);
     $title = Title::makeTitle(NS_SPECIAL, 'Listusers');
     $special = htmlspecialchars($title->getPrefixedDBkey());
     // form header
     $out = '<form method="get" action="' . $action . '">' . '<input type="hidden" name="title" value="' . $special . '" />' . wfMsgHtml('groups-editgroup-name') . '<select name="group">';
     // get all group names and IDs
     $groups = User::getAllGroups();
     // we want a default empty group
     $out .= '<option value=""></option>';
     // build the dropdown list menu using datas from the database
     foreach ($groups as $group) {
         $selected = $group == $this->requestedGroup;
         $out .= wfElement('option', array_merge(array('value' => $group), $selected ? array('selected' => 'selected') : array()), User::getGroupName($group));
     }
     $out .= '</select> ';
     $out .= wfMsgHtml('specialloguserlabel') . '<input type="text" name="username" /> ';
     // OK button, end of form.
     $out .= '<input type="submit" /></form>';
     // congratulations the form is now build
     return $out;
 }
예제 #3
0
 /**
  * @param WebRequest $request
  */
 function show($request)
 {
     global $wgOut, $wgUser;
     $first = $this->revisions[0];
     $wgOut->addWikiText(wfMsg('revdelete-selected', $this->page->getPrefixedText()));
     $wgOut->addHtml("<ul>");
     foreach ($this->revisions as $revid) {
         $rev = Revision::newFromTitle($this->page, $revid);
         $wgOut->addHtml($this->historyLine($rev));
         $bitfields[] = $rev->mDeleted;
         // FIXME
     }
     $wgOut->addHtml("</ul>");
     $wgOut->addWikiText(wfMsg('revdelete-text'));
     $items = array(wfInputLabel(wfMsg('revdelete-log'), 'wpReason', 'wpReason', 60), wfSubmitButton(wfMsg('revdelete-submit')));
     $hidden = array(wfHidden('wpEditToken', $wgUser->editToken()), wfHidden('target', $this->page->getPrefixedText()));
     foreach ($this->revisions as $revid) {
         $hidden[] = wfHidden('oldid[]', $revid);
     }
     $special = Title::makeTitle(NS_SPECIAL, 'Revisiondelete');
     $wgOut->addHtml(wfElement('form', array('method' => 'post', 'action' => $special->getLocalUrl('action=submit'))));
     $wgOut->addHtml('<fieldset><legend>' . wfMsgHtml('revdelete-legend') . '</legend>');
     foreach ($this->checks as $item) {
         list($message, $name, $field) = $item;
         $wgOut->addHtml('<div>' . wfCheckLabel(wfMsg($message), $name, $name, $rev->isDeleted($field)) . '</div>');
     }
     $wgOut->addHtml('</fieldset>');
     foreach ($items as $item) {
         $wgOut->addHtml('<p>' . $item . '</p>');
     }
     foreach ($hidden as $item) {
         $wgOut->addHtml($item);
     }
     $wgOut->addHtml('</form>');
 }
예제 #4
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);
}
 /**
  * Insert the captcha prompt into the edit form.
  */
 function getForm()
 {
     $info = $this->pickImage();
     if (!$info) {
         die("out of captcha images; this shouldn't happen");
     }
     // Generate a random key for use of this captcha image in this session.
     // This is needed so multiple edits in separate tabs or windows can
     // go through without extra pain.
     $index = $this->storeCaptcha($info);
     wfDebug("Captcha id {$index} using hash {$info['hash']}, salt {$info['salt']}.\n");
     $title = Title::makeTitle(NS_SPECIAL, 'Captcha/image');
     return "<p>" . wfElement('img', array('src' => $title->getLocalUrl('wpCaptchaId=' . urlencode($index)), 'width' => $info['width'], 'height' => $info['height'], 'alt' => '')) . "</p>\n" . wfElement('input', array('type' => 'hidden', 'name' => 'wpCaptchaId', 'id' => 'wpCaptchaId', 'value' => $index)) . "<p>" . wfElement('input', array('name' => 'wpCaptchaWord', 'id' => 'wpCaptchaWord', 'tabindex' => 1)) . "</p>\n";
 }
예제 #6
0
function charInsertChar($start, $end = '', $title = null)
{
    $estart = charInsertJsString($start);
    $eend = charInsertJsString($end);
    if ($eend == '') {
        $inline = charInsertDisplay($start);
    } else {
        $inline = charInsertDisplay($start . $end);
    }
    if ($title) {
        $extra = ' title="' . htmlspecialchars($title) . '"';
    } else {
        $extra = '';
    }
    return wfElement('a', array('onclick' => "insertTags('{$estart}','{$eend}','');return false", 'href' => '#'), $inline);
}
 function listForm($username, $reason)
 {
     global $wgUser, $wgOut, $wgLang;
     $pages = $this->getNewPages($username);
     $escapedName = wfEscapeWikiText($username);
     if (count($pages) == 0) {
         $wgOut->addWikiText(wfMsg('nuke-nopages', $escapedName));
         return $this->promptForm();
     }
     $wgOut->addWikiText(wfMsg('nuke-list', $escapedName));
     $nuke = Title::makeTitle(NS_SPECIAL, 'Nuke');
     $submit = wfElement('input', array('type' => 'submit', 'value' => wfMsgHtml('nuke-submit-delete')));
     $wgOut->addHTML(wfElement('form', array('action' => $nuke->getLocalURL('action=delete'), 'method' => 'post'), null) . "\n<div>" . wfMsgHtml('deletecomment') . ': ' . wfElement('input', array('name' => 'wpReason', 'value' => $reason, 'size' => 60)) . "</div><br />" . $submit . wfElement('input', array('type' => 'hidden', 'name' => 'wpEditToken', 'value' => $wgUser->editToken())) . "\n<ul>\n");
     $sk =& $wgUser->getSkin();
     foreach ($pages as $info) {
         list($title, $edits) = $info;
         $wgOut->addHTML('<li>' . wfElement('input', array('type' => 'checkbox', 'name' => "pages[]", 'value' => $title->getPrefixedDbKey(), 'checked' => 'checked')) . '&nbsp;' . $sk->makeKnownLinkObj($title) . '&nbsp;(' . $sk->makeKnownLinkObj($title, wfMsgExt('nchanges', array('parsemag'), $wgLang->formatNum($edits)), 'action=history') . ")</li>\n");
     }
     $wgOut->addHTML("</ul>\n{$submit}</form>");
 }
예제 #8
0
 /**
  * Recursivelly go through the object and output its data in WDDX format.
  */
 function slowWddxPrinter($elemValue)
 {
     switch (gettype($elemValue)) {
         case 'array':
             $this->printText('<struct>');
             foreach ($elemValue as $subElemName => $subElemValue) {
                 $this->printText(wfElement('var', array('name' => $subElemName), null));
                 $this->slowWddxPrinter($subElemValue);
                 $this->printText('</var>');
             }
             $this->printText('</struct>');
             break;
         case 'integer':
         case 'double':
             $this->printText(wfElement('number', null, $elemValue));
             break;
         case 'string':
             $this->printText(wfElement('string', null, $elemValue));
             break;
         default:
             ApiBase::dieDebug(__METHOD__, 'Unknown type ' . gettype($elemValue));
     }
 }
 /**
  * Insert a captcha prompt into the edit form.
  * This sample implementation generates a simple arithmetic operation;
  * it would be easy to defeat by machine.
  *
  * Override this!
  *
  * @return string HTML
  */
 function getForm()
 {
     $a = mt_rand(0, 100);
     $b = mt_rand(0, 10);
     $op = mt_rand(0, 1) ? '+' : '-';
     $test = "{$a} {$op} {$b}";
     $answer = $op == '+' ? $a + $b : $a - $b;
     $index = $this->storeCaptcha(array('answer' => $answer));
     return "<p><label for=\"wpCaptchaWord\">{$test}</label> = " . wfElement('input', array('name' => 'wpCaptchaWord', 'id' => 'wpCaptchaWord', 'tabindex' => 1)) . "</p>\n" . wfElement('input', array('type' => 'hidden', 'name' => 'wpCaptchaId', 'id' => 'wpCaptchaId', 'value' => $index));
 }
 /**
  * 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;
 }
예제 #11
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;
 }
예제 #12
0
 /**
  * This method takes an array and converts it into an xml.
  * There are several noteworthy cases:
  *
  *  If array contains a key '_element', then the code assumes that ALL other keys are not important and replaces them with the value['_element'].
  *	Example:	name='root',  value = array( '_element'=>'page', 'x', 'y', 'z') creates <root>  <page>x</page>  <page>y</page>  <page>z</page> </root>
  *
  *  If any of the array's element key is '*', then the code treats all other key->value pairs as attributes, and the value['*'] as the element's content.
  *	Example:	name='root',  value = array( '*'=>'text', 'lang'=>'en', 'id'=>10)   creates  <root lang='en' id='10'>text</root>
  *
  * If neither key is found, all keys become element names, and values become element content.
  * The method is recursive, so the same rules apply to any sub-arrays.
  */
 function recXmlPrint($elemName, $elemValue, $indent)
 {
     if (!is_null($indent)) {
         $indent += 2;
         $indstr = "\n" . str_repeat(" ", $indent);
     } else {
         $indstr = '';
     }
     switch (gettype($elemValue)) {
         case 'array':
             if (isset($elemValue['*'])) {
                 $subElemContent = $elemValue['*'];
                 unset($elemValue['*']);
             } else {
                 $subElemContent = null;
             }
             if (isset($elemValue['_element'])) {
                 $subElemIndName = $elemValue['_element'];
                 unset($elemValue['_element']);
             } else {
                 $subElemIndName = null;
             }
             $indElements = array();
             $subElements = array();
             foreach ($elemValue as $subElemId => &$subElemValue) {
                 if (gettype($subElemId) === 'integer') {
                     $indElements[] = $subElemValue;
                     unset($elemValue[$subElemId]);
                 } elseif (is_array($subElemValue)) {
                     $subElements[$subElemId] = $subElemValue;
                     unset($elemValue[$subElemId]);
                 }
             }
             if (is_null($subElemIndName) && !empty($indElements)) {
                 ApiBase::dieDebug(__METHOD__, "({$elemName}, ...) has integer keys without _element value. Use ApiResult::setIndexedTagName().");
             }
             if (!empty($subElements) && !empty($indElements) && !is_null($subElemContent)) {
                 ApiBase::dieDebug(__METHOD__, "({$elemName}, ...) has content and subelements");
             }
             if (!is_null($subElemContent)) {
                 $this->printText($indstr . wfElement($elemName, $elemValue, $subElemContent));
             } elseif (empty($indElements) && empty($subElements)) {
                 $this->printText($indstr . wfElement($elemName, $elemValue));
             } else {
                 $this->printText($indstr . wfElement($elemName, $elemValue, null));
                 foreach ($subElements as $subElemId => &$subElemValue) {
                     $this->recXmlPrint($subElemId, $subElemValue, $indent);
                 }
                 foreach ($indElements as $subElemId => &$subElemValue) {
                     $this->recXmlPrint($subElemIndName, $subElemValue, $indent);
                 }
                 $this->printText($indstr . wfCloseElement($elemName));
             }
             break;
         case 'object':
             // ignore
             break;
         default:
             $this->printText($indstr . wfElement($elemName, null, $elemValue));
             break;
     }
 }
예제 #13
0
 /** @todo document */
 function diffButtons($rev, $firstInList, $counter)
 {
     if ($this->linesonpage > 1) {
         $radio = array('type' => 'radio', 'value' => $rev->getId());
         if (!$rev->userCan(Revision::DELETED_TEXT)) {
             $radio['disabled'] = 'disabled';
         }
         /** @todo: move title texts to javascript */
         if ($firstInList) {
             $first = wfElement('input', array_merge($radio, array('style' => 'visibility:hidden', 'name' => 'oldid')));
             $checkmark = array('checked' => 'checked');
         } else {
             if ($counter == 2) {
                 $checkmark = array('checked' => 'checked');
             } else {
                 $checkmark = array();
             }
             $first = wfElement('input', array_merge($radio, $checkmark, array('name' => 'oldid')));
             $checkmark = array();
         }
         $second = wfElement('input', array_merge($radio, $checkmark, array('name' => 'diff')));
         return $first . $second;
     } else {
         return '';
     }
 }
/**
 * Create a list of messages, formatted in HTML as a list of messages and values and showing differences between the default language file message and the message in MediaWiki: namespace.
 * @param $messages Messages array.
 * @return The HTML list of messages.
 */
function makeHTMLText($messages)
{
    global $wgLang, $wgContLang, $wgUser;
    wfProfileIn(__METHOD__);
    $sk = $wgUser->getSkin();
    $talk = wfMsg('talkpagelinktext');
    $input = wfElement('input', array('type' => 'text', 'id' => 'allmessagesinput', 'onkeyup' => 'allmessagesfilter()'), '');
    $checkbox = wfElement('input', array('type' => 'button', 'value' => wfMsgHtml('allmessagesmodified'), 'id' => 'allmessagescheckbox', 'onclick' => 'allmessagesmodified()'), '');
    $txt = '<span id="allmessagesfilter" style="display: none;">' . wfMsgHtml('allmessagesfilter') . " {$input}{$checkbox} " . '</span>';
    $txt .= '
<table border="1" cellspacing="0" width="100%" id="allmessagestable">
	<tr>
		<th rowspan="2">' . wfMsgHtml('allmessagesname') . '</th>
		<th>' . wfMsgHtml('allmessagesdefault') . '</th>
	</tr>
	<tr>
		<th>' . wfMsgHtml('allmessagescurrent') . '</th>
	</tr>';
    wfProfileIn(__METHOD__ . "-check");
    # This is a nasty hack to avoid doing independent existence checks
    # without sending the links and table through the slow wiki parser.
    $pageExists = array(NS_MEDIAWIKI => array(), NS_MEDIAWIKI_TALK => array());
    $dbr = wfGetDB(DB_SLAVE);
    $page = $dbr->tableName('page');
    $sql = "SELECT page_namespace,page_title FROM {$page} WHERE page_namespace IN (" . NS_MEDIAWIKI . ", " . NS_MEDIAWIKI_TALK . ")";
    $res = $dbr->query($sql);
    while ($s = $dbr->fetchObject($res)) {
        $pageExists[$s->page_namespace][$s->page_title] = true;
    }
    $dbr->freeResult($res);
    wfProfileOut(__METHOD__ . "-check");
    wfProfileIn(__METHOD__ . "-output");
    $i = 0;
    foreach ($messages as $key => $m) {
        $title = $wgLang->ucfirst($key);
        if ($wgLang->getCode() != $wgContLang->getCode()) {
            $title .= '/' . $wgLang->getCode();
        }
        $titleObj =& Title::makeTitle(NS_MEDIAWIKI, $title);
        $talkPage =& Title::makeTitle(NS_MEDIAWIKI_TALK, $title);
        $changed = $m['statmsg'] != $m['msg'];
        $message = htmlspecialchars($m['statmsg']);
        $mw = htmlspecialchars($m['msg']);
        if (isset($pageExists[NS_MEDIAWIKI][$title])) {
            $pageLink = $sk->makeKnownLinkObj($titleObj, "<span id=\"sp-allmessages-i-{$i}\">" . htmlspecialchars($key) . '</span>');
        } else {
            $pageLink = $sk->makeBrokenLinkObj($titleObj, "<span id=\"sp-allmessages-i-{$i}\">" . htmlspecialchars($key) . '</span>');
        }
        if (isset($pageExists[NS_MEDIAWIKI_TALK][$title])) {
            $talkLink = $sk->makeKnownLinkObj($talkPage, htmlspecialchars($talk));
        } else {
            $talkLink = $sk->makeBrokenLinkObj($talkPage, htmlspecialchars($talk));
        }
        $anchor = 'msg_' . htmlspecialchars(strtolower($title));
        $anchor = "<a id=\"{$anchor}\" name=\"{$anchor}\"></a>";
        if ($changed) {
            $txt .= "\r\n\t<tr class=\"orig\" id=\"sp-allmessages-r1-{$i}\">\r\n\t\t<td rowspan=\"2\">\r\n\t\t\t{$anchor}{$pageLink}<br />{$talkLink}\r\n\t\t</td><td>\r\n{$message}\r\n\t\t</td>\r\n\t</tr><tr class=\"new\" id=\"sp-allmessages-r2-{$i}\">\r\n\t\t<td>\r\n{$mw}\r\n\t\t</td>\r\n\t</tr>";
        } else {
            $txt .= "\r\n\t<tr class=\"def\" id=\"sp-allmessages-r1-{$i}\">\r\n\t\t<td>\r\n\t\t\t{$anchor}{$pageLink}<br />{$talkLink}\r\n\t\t</td><td>\r\n{$mw}\r\n\t\t</td>\r\n\t</tr>";
        }
        $i++;
    }
    $txt .= '</table>';
    wfProfileOut(__METHOD__ . '-output');
    wfProfileOut(__METHOD__);
    return $txt;
}
예제 #15
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);
    }
예제 #16
0
 function searchForm()
 {
     global $wgTitle;
     return wfElement('form', array('action' => $wgTitle->getLocalUrl()), null) . wfElement('input', array('type' => 'hidden', 'name' => 'action', 'value' => 'search')) . wfElement('input', array('type' => 'hidden', 'name' => 'limit', 'value' => $this->limit)) . wfElement('input', array('name' => 'ip', 'value' => $this->ip)) . wfElement('input', array('type' => 'submit', 'value' => wfMsg('search'))) . '</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;
 }
예제 #18
0
 function showLogFragment(&$out, &$title)
 {
     $out->addHtml(wfElement('h2', NULL, LogPage::logName('block')));
     $request = new FauxRequest(array('page' => $title->getPrefixedText(), 'type' => 'block'));
     $viewer = new LogViewer(new LogReader($request));
     $viewer->showList($out);
 }
예제 #19
0
 function getEditButtons($tabindex)
 {
     global $wgLivePreview, $wgUser;
     $buttons = array();
     $temp = array('id' => 'wpSave', 'name' => 'wpSave', 'type' => 'submit', 'tabindex' => ++$tabindex, 'value' => wfMsg('savearticle'), 'accesskey' => wfMsg('accesskey-save'), 'title' => wfMsg('tooltip-save') . ' [' . wfMsg('accesskey-save') . ']', 'onclick' => 'needToConfirm = false', 'class' => 'button primary submit_button');
     $buttons['save'] = wfElement('input', $temp, '');
     $temp = array('id' => 'wpPreview', 'name' => 'wpPreview', 'type' => 'submit', 'tabindex' => ++$tabindex, 'value' => wfMsg('showpreview'), 'accesskey' => wfMsg('accesskey-preview'), 'title' => wfMsg('tooltip-preview') . ' [' . wfMsg('accesskey-preview') . ']', 'onclick' => 'needToConfirm = false; checkMinLength = false; checkSummary();', 'class' => 'button secondary submit_button');
     $buttons['preview'] = wfElement('input', $temp, '');
     $buttons['live'] = '';
     $temp = array('id' => 'wpDiff', 'name' => 'wpDiff', 'type' => 'submit', 'tabindex' => ++$tabindex, 'value' => wfMsg('showdiff'), 'accesskey' => wfMsg('accesskey-diff'), 'title' => wfMsg('tooltip-diff') . ' [' . wfMsg('accesskey-diff') . ']', 'onclick' => 'needToConfirm = false; checkMinLength = false; checkSummary();', 'class' => 'button secondary submit_button');
     $buttons['diff'] = wfElement('input', $temp, '');
     wfRunHooks('EditPageBeforeEditButtons', array(&$this, &$buttons));
     return $buttons;
 }
 /**
  * Dumps a <revision> section on the output stream, with
  * data filled in from the given database row.
  *
  * @param object $row
  * @access private
  */
 function dumpRev($row)
 {
     $fname = 'WikiExporter::dumpRev';
     wfProfileIn($fname);
     print "    <revision>\n";
     print "      " . wfElement('id', null, $row->rev_id) . "\n";
     $ts = wfTimestamp2ISO8601($row->rev_timestamp);
     print "      " . wfElement('timestamp', null, $ts) . "\n";
     print "      <contributor>";
     if ($row->rev_user) {
         print wfElementClean('username', null, $row->rev_user_text);
         print wfElement('id', null, $row->rev_user);
     } else {
         print wfElementClean('ip', null, $row->rev_user_text);
     }
     print "</contributor>\n";
     if ($row->rev_minor_edit) {
         print "      <minor/>\n";
     }
     if ($row->rev_comment != '') {
         print "      " . wfElementClean('comment', null, $row->rev_comment) . "\n";
     }
     $text = Revision::getRevisionText($row);
     print "      " . wfElementClean('text', array('xml:space' => 'preserve'), $text) . "\n";
     print "    </revision>\n";
     wfProfileOut($fname);
     if (isset($this->revCallback)) {
         call_user_func($this->revCallback, $row);
     }
 }
예제 #21
0
 function newtalk()
 {
     global $wgUser, $wgDBname;
     $newtalks = $wgUser->getNewMessageLinks();
     if (count($newtalks) == 1 && $newtalks[0]["wiki"] === $wgDBname) {
         $usertitle = $this->getUserPageTitle();
         $usertalktitle = $usertitle->getTalkPage();
         if (!$usertalktitle->equals($this->mTitle)) {
             $ntl = wfMsg('youhavenewmessages', $this->makeKnownLinkObj($usertalktitle, wfMsgHtml('newmessageslink'), 'redirect=no'), $this->makeKnownLinkObj($usertalktitle, wfMsgHtml('newmessagesdifflink'), 'diff=cur'));
             # Disable Cache
             $this->mOut->setSquidMaxage(0);
         }
     } else {
         if (count($newtalks)) {
             $sep = str_replace("_", " ", wfMsgHtml("newtalkseperator"));
             $msgs = array();
             foreach ($newtalks as $newtalk) {
                 $msgs[] = wfElement("a", array('href' => $newtalk["link"]), $newtalk["wiki"]);
             }
             $parts = implode($sep, $msgs);
             $ntl = wfMsgHtml('youhavenewmessagesmulti', $parts);
             $this->mOut->setSquidMaxage(0);
         } else {
             $ntl = '';
         }
     }
     return cbt_value($ntl, 'dynamic');
 }
/**
 * Special page "user contributions".
 * Shows a list of the contributions of a user.
 *
 * @return	none
 * @param	string	$par	(optional) user name of the user for which to show the contributions
 */
function wfSpecialContributions($par = null)
{
    global $wgUser, $wgOut, $wgLang, $wgContLang, $wgRequest, $wgTitle, $wgScript;
    $fname = 'wfSpecialContributions';
    $target = isset($par) ? $par : $wgRequest->getVal('target');
    if (!strlen($target)) {
        $wgOut->errorpage('notargettitle', 'notargettext');
        return;
    }
    $nt = Title::newFromURL($target);
    if (!$nt) {
        $wgOut->errorpage('notargettitle', 'notargettext');
        return;
    }
    $nt =& Title::makeTitle(NS_USER, $nt->getDBkey());
    list($limit, $offset) = wfCheckLimits();
    $offset = $wgRequest->getVal('offset');
    /* Offset must be an integral. */
    if (!strlen($offset) || !preg_match("/^[0-9]+\$/", $offset)) {
        $offset = 0;
    }
    $title = Title::makeTitle(NS_SPECIAL, "Contributions");
    $urlbits = "target=" . wfUrlEncode($target);
    $myurl = $title->escapeLocalURL($urlbits);
    $finder = new contribs_finder($target == 'newbies' ? 'newbies' : $nt->getText());
    $finder->set_limit($limit);
    $finder->set_offset($offset);
    $nsurl = $xnsurl = "";
    if (($ns = $wgRequest->getVal('namespace', null)) !== null) {
        $nsurl = "&namespace={$ns}";
        $xnsurl = htmlspecialchars($nsurl);
        $finder->set_namespace($ns);
    }
    if ($wgRequest->getText('go') == "prev") {
        $prevts = $finder->get_previous_offset_for_paging();
        $prevurl = $title->getLocalURL($urlbits . "&offset={$prevts}&limit={$limit}{$nsurl}");
        $wgOut->redirect($prevurl);
        return;
    }
    if ($wgRequest->getText('go') == "first") {
        $prevts = $finder->get_first_offset_for_paging();
        $prevurl = $title->getLocalURL($urlbits . "&offset={$prevts}&limit={$limit}{$nsurl}");
        $wgOut->redirect($prevurl);
        return;
    }
    $sk = $wgUser->getSkin();
    $id = User::idFromName($nt->getText());
    if (0 == $id) {
        $ul = $nt->getText();
    } else {
        $ul = $sk->makeLinkObj($nt, htmlspecialchars($nt->getText()));
        $userCond = '=' . $id;
    }
    $talk = $nt->getTalkPage();
    if ($talk) {
        $ul .= ' (' . $sk->makeLinkObj($talk, $wgLang->getNsText(NS_TALK)) . ')';
    }
    if ($target == 'newbies') {
        $ul = wfMsg('newbies');
    }
    $wgOut->setSubtitle(wfMsgHtml('contribsub', $ul));
    wfRunHooks('SpecialContributionsBeforeMainOutput', $id);
    $arr = $wgContLang->getFormattedNamespaces();
    $nsform = "<form method='get' action=\"{$wgScript}\">\n";
    $nsform .= wfElement("input", array("name" => "title", "type" => "hidden", "value" => $wgTitle->getPrefixedText()));
    $nsform .= wfElement("input", array("name" => "offset", "type" => "hidden", "value" => $offset));
    $nsform .= wfElement("input", array("name" => "limit", "type" => "hidden", "value" => $limit));
    $nsform .= wfElement("input", array("name" => "target", "type" => "hidden", "value" => $target));
    $nsform .= "<p>";
    $nsform .= wfMsgHtml('namespace');
    $nsform .= HTMLnamespaceselector($ns, '');
    $nsform .= wfElement("input", array("type" => "submit", "value" => wfMsg('allpagessubmit')));
    $nsform .= "</p></form>\n";
    $wgOut->addHTML($nsform);
    $contribsPage = Title::makeTitle(NS_SPECIAL, 'Contributions');
    $contribs = $finder->find();
    if (count($contribs) == 0) {
        $wgOut->addWikiText(wfMsg("nocontribs"));
        return;
    }
    list($early, $late) = $finder->get_edit_limits();
    $lastts = count($contribs) ? $contribs[count($contribs) - 1]->rev_timestamp : 0;
    $atstart = !count($contribs) || $late == $contribs[0]->rev_timestamp;
    $atend = !count($contribs) || $early == $lastts;
    $lasturl = $wgTitle->escapeLocalURL("action=history&limit={$limit}");
    $firsttext = wfMsgHtml("histfirst");
    $lasttext = wfMsgHtml("histlast");
    $prevtext = wfMsg("prevn", $limit);
    if ($atstart) {
        $lastlink = $lasttext;
        $prevlink = $prevtext;
    } else {
        $lastlink = "<a href=\"{$myurl}&amp;limit={$limit}{$xnsurl}\">{$lasttext}</a>";
        $prevlink = "<a href=\"{$myurl}&amp;offset={$offset}&amp;limit={$limit}{$xnsurl}&amp;go=prev\">{$prevtext}</a>";
    }
    $nexttext = wfMsg("nextn", $limit);
    if ($atend) {
        $firstlink = $firsttext;
        $nextlink = $nexttext;
    } else {
        $firstlink = "<a href=\"{$myurl}&amp;limit={$limit}{$xnsurl}&amp;go=first\">{$firsttext}</a>";
        $nextlink = "<a href=\"{$myurl}&amp;offset={$lastts}&amp;limit={$limit}{$xnsurl}\">{$nexttext}</a>";
    }
    $firstlast = "({$lastlink} | {$firstlink})";
    $urls = array();
    foreach (array(20, 50, 100, 250, 500) as $num) {
        $urls[] = "<a href=\"{$myurl}&amp;offset={$offset}&amp;limit={$num}{$xnsurl}\">" . $wgLang->formatNum($num) . "</a>";
    }
    $bits = implode($urls, ' | ');
    $prevnextbits = "{$firstlast} " . wfMsgHtml("viewprevnext", $prevlink, $nextlink, $bits);
    $wgOut->addHTML("<p>{$prevnextbits}</p>\n");
    $wgOut->addHTML("<ul>\n");
    foreach ($contribs as $contrib) {
        $wgOut->addHTML(ucListEdit($sk, $contrib));
    }
    $wgOut->addHTML("</ul>\n");
    $wgOut->addHTML("<p>{$prevnextbits}</p>\n");
}
예제 #23
0
 function buildSubmit()
 {
     return wfElement('input', array('type' => 'submit', 'value' => wfMsg('confirm')));
 }
 /** @todo document */
 function diffButtons($row, $latest, $counter)
 {
     global $wgUser;
     if ($this->linesonpage > 1) {
         $radio = array('type' => 'radio', 'value' => $row->rev_id, 'title' => wfMsg('selectolderversionfordiff'));
         if ($row->rev_deleted && !$wgUser->isAllowed('undelete')) {
             $radio['disabled'] = 'disabled';
         }
         # XXX: move title texts to javascript
         if ($latest) {
             $first = wfElement('input', array_merge($radio, array('style' => 'visibility:hidden', 'name' => 'oldid')));
             $checkmark = array('checked' => 'checked');
         } else {
             if ($counter == 2) {
                 $checkmark = array('checked' => 'checked');
             } else {
                 $checkmark = array();
             }
             $first = wfElement('input', array_merge($radio, $checkmark, array('name' => 'oldid')));
             $checkmark = array();
         }
         $second = wfElement('input', array_merge($radio, $checkmark, array('name' => 'diff')));
         return $first . $second;
     } else {
         return '';
     }
 }
 function clearOpenElement($style)
 {
     if ($this->openElement) {
         $this->buffer .= wfElement($this->openElement[0], $this->openElement[1], $style);
         $this->openElement = false;
     }
 }
 function execute($param)
 {
     global $wgOut, $wgRequest, $wgTitle, $wgUser, $wgMessageCache;
     $this->setHeaders();
     $title = Title::makeTitle(NS_SPECIAL, 'EasyGallery');
     $par = 8;
     # The $param is the number of text inputs to be replicated in the form
     if (isset($param)) {
         $par = $param;
     } else {
         if ($wgRequest->getText('wpParam', "")) {
             $par = $wgRequest->getText('wpParam', "");
         } else {
             $par = 8;
         }
     }
     # Extract any posted data
     $posted = $wgRequest->getText('wpSubmit', false);
     # Extract any contents of fields
     $gtitle = $wgRequest->getText('wpGtitle', "");
     $width = $wgRequest->getText('wpWidth', "");
     $column = $wgRequest->getText('wpColumn', "");
     # Render the form
     $wgOut->addWikiText(wfMsg('easygalleryMessage', 'easygalleryParameter'));
     $wgOut->addHTML(wfElement('form', array('action' => $title->getLocalURL('action=submit'), 'method' => 'post'), null) . "<br /><p><b>Usage</b></p>\n\t\t<p>This form creates a gallery in the page you enter below, whether the page exists or not.</p>\n\t\t<p>If there is already text in the page it will be retained but an existing gallery will be replaced by this one. You can have one gallery per page.</p>\n\t\t<p>This extension defaults to 8 pictures (plus captions), unless the number of pictures in your intended gallery is added to the address bar title, for example for five images:\n\t\thttp://localhost/wiki/index.php/Special:EasyGallery/5</p>\n\t\t<p>Here is the expected form of the picture and the caption:\n\t\tImage:Example.jpg\n                Example Caption</p>\n\t\t<p>You can upload your pictures by clicking <a href='" . $wgServer . $wgScript . "/Special:Upload' target='_blank'>Special:Upload</a>.</p>\n\t\t<p>You can access the names of images already uploaded by clicking <a href='" . $wgServer . $wgScript . "/Special:ImageList' target='_blank'>Special:ImageList</a>.</p>\n\t\t<p>Press the Submit Query button, then you can go to the page and edit it normally if you want.</p>\n\t\t<br/ >\n\t\t<p><b>Page Setup</b></p>\n\t\t<p>What is the title of the page your gallery will be in? This is a compulsory field.</p>\n\t\t<input name='wpGtitle' size = '35' />\n\t\t<p>How many columns do you want the easygallery to have? If you leave the field empty it is 2.</p>\n\t\t<input name='wpColumn' size = '10' />\n\t\t<p>How wide do you want each thumbnail to be (in pixels)? Empty field is 150.</p>\n\t\t<input name='wpWidth' size = '10' />\n\t\t<input type='hidden' name='wpParam' value={$par}><br /><br />");
     # Render multiple inputs using the /$par from the url
     for ($ctr = 1; $ctr <= $par; $ctr++) {
         $wgOut->addHTML("<p><b>Gallery " . $ctr . "</b></p>\n\t\t\t<p>The image you want for the thumbnail.</p>\n\t\t\t<input name='wpUrl" . $ctr . "' size = '50' />\n\t\t\t<p>The caption for this image.</p>\n\t\t\t<input name='wpCaption" . $ctr . "' size = '50' />");
     }
     # Post
     $wgOut->addHTML("<br /><br />" . wfElement('input', array('name' => 'wpSubmit', 'type' => 'submit')) . "<br /><br />");
     # Process results if data posted
     if ($posted) {
         # Defaults for posted style elements
         if ($width == "") {
             $width = 200;
         }
         if ($column == "") {
             $column = 2;
         }
         # Build tag
         $tag = "<\ngallery widths='" . $width . "px' perrow='" . $column . "'>\n";
         # Some arrays to populate with loops
         $url[] = array();
         $caption[] = array();
         # Make some variables out of the posted fields
         for ($n = 1; $n <= $par; $n++) {
             $url[$n] = $wgRequest->getText('wpUrl' . $n, "");
             $caption[$n] = $wgRequest->getText('wpCaption' . $n, "");
         }
         for ($n = 1; $n <= $par; $n++) {
             if ($url[$n] != "") {
                 $tag .= $url[$n] . "|<center>" . $caption[$n] . "</center>\n";
             }
         }
         $tag .= "</gallery>";
         if ($wgUser->isAllowed('edit')) {
             $title = Title::newFromText($gtitle);
             if (trim($wgRequest->getText('wpGtitle')) == '') {
                 $wgTitle = Title::newFromText(wfMsgForContent('badtitle'));
                 $wgOut->errorpage('badtitle', 'badtitletext');
             }
             # Make the new page if no page exists.
             if (isset($title) && $title->getArticleID() == 0) {
                 $article = new Article($title);
                 $article->doEdit($tag, "", EDIT_NEW);
                 $wgOut->addHTML(wfMsg('easygallerySuccessMessage'));
             } elseif (isset($title) && $title->getArticleID() != 0) {
                 $article = new Article($title, 0);
                 $original = $article->fetchContent(0);
                 $intro = preg_replace("%<gallery.*%is", "", $original);
                 $outro = preg_replace("%.*</gallery>%is", "", $original);
                 $tag = $intro . $tag . $outro;
                 $article->doEdit($tag, "", EDIT_UPDATE);
                 $wgOut->addHTML(wfMsg('easygallerySuccessMessage'));
             } else {
                 $wgTitle = Title::newFromText(wfMsgForContent('badtitle'));
                 $wgOut->errorpage('error', 'badtitletext');
             }
         } else {
             $wgTitle = Title::newFromText(wfMsgForContent('badtitle'));
             $wgOut->errorpage('error', 'badarticleerror');
         }
     }
 }
/**
 * Creates the choose namespace selection
 *
 * @private
 *
 * @param $namespace Mixed: the key of the currently selected namespace, empty string
 *              if there is none
 * @param $invert Bool: whether to invert the namespace selection
 * @param $nondefaults Array: an array of non default options to be remembered
 * @param $categories_any Bool: Default value for the checkbox
 *
 * @return string
 */
function rcNamespaceForm($namespace, $invert, $nondefaults, $categories_any)
{
    global $wgScript, $wgAllowCategorizedRecentChanges, $wgRequest;
    $t = SpecialPage::getTitleFor('Recentchanges');
    $namespaceselect = HTMLnamespaceselector($namespace, '');
    $submitbutton = '<input type="submit" value="' . wfMsgHtml('allpagessubmit') . "\" />\n";
    $invertbox = "<input type='checkbox' name='invert' value='1' id='nsinvert'" . ($invert ? ' checked="checked"' : '') . ' />';
    if ($wgAllowCategorizedRecentChanges) {
        $categories = trim($wgRequest->getVal('categories', ""));
        $cb_arr = array('type' => 'checkbox', 'name' => 'categories_any', 'value' => "1");
        if ($categories_any) {
            $cb_arr['checked'] = "checked";
        }
        $catbox = "<br />";
        $catbox .= wfMsgExt('rc_categories', array('parseinline')) . " ";
        $catbox .= wfElement('input', array('type' => 'text', 'name' => 'categories', 'value' => $categories));
        $catbox .= " &nbsp;";
        $catbox .= wfElement('input', $cb_arr);
        $catbox .= wfMsgExt('rc_categories_any', array('parseinline'));
    } else {
        $catbox = "";
    }
    $out = "<div class='namespacesettings'><form method='get' action='{$wgScript}'>\n";
    foreach ($nondefaults as $key => $value) {
        if ($key != 'namespace' && $key != 'invert') {
            $out .= wfElement('input', array('type' => 'hidden', 'name' => $key, 'value' => $value));
        }
    }
    $out .= '<input type="hidden" name="title" value="' . $t->getPrefixedText() . '" />';
    $out .= "\r\n<div id='nsselect' class='recentchanges'>\r\n\t<label for='namespace'>" . wfMsgHtml('namespace') . "</label>\r\n\t{$namespaceselect}{$submitbutton}{$invertbox} <label for='nsinvert'>" . wfMsgHtml('invert') . "</label>{$catbox}\n</div>";
    $out .= '</form></div>';
    return $out;
}
예제 #28
0
/**
 * Allow the user to clear their watchlist
 *
 * @param $out Output object
 * @param $request Request object
 * @param $par Parameters passed to the watchlist page
 * @return bool True if it's been taken care of; false indicates the watchlist
 * 				code needs to do something further
 */
function wlHandleClear(&$out, &$request, $par)
{
    # Check this function has something to do
    if ($request->getText('action') == 'clear' || $par == 'clear') {
        global $wgUser;
        $out->setPageTitle(wfMsgHtml('clearwatchlist'));
        $count = wlCountItems($wgUser);
        if ($count > 0) {
            # See if we're clearing or confirming
            if ($request->wasPosted() && $wgUser->matchEditToken($request->getText('token'), 'clearwatchlist')) {
                # Clearing, so do it and report the result
                $dbw =& wfGetDB(DB_MASTER);
                // WERELATE - don't remove pages in your trees; call WatchedItem::removeWatch
                // $dbw->delete( 'watchlist', array( 'wl_user' => $wgUser->mId ), 'wlHandleClear' );
                $sql = 'SELECT wl_namespace, wl_title FROM watchlist where wl_user='******' AND NOT EXISTS (SELECT fp_tree_id FROM familytree_page WHERE fp_namespace=(wl_namespace & ~1) AND fp_title=wl_title AND fp_user_id=wl_user)';
                $rows = $dbw->query($sql, 'wlHandleClear');
                while ($row = $dbw->fetchObject($rows)) {
                    $title = Title::makeTitle($row->wl_namespace, $row->wl_title);
                    if ($title) {
                        $wl = WatchedItem::fromUserTitle($wgUser, $title);
                        $wl->removeWatch();
                    }
                }
                $dbw->freeResult($rows);
                $out->addWikiText(wfMsg('watchlistcleardone', $count));
                $out->returnToMain();
            } else {
                # Confirming, so show a form
                $wlTitle = Title::makeTitle(NS_SPECIAL, 'Watchlist');
                $out->addHTML(wfElement('form', array('method' => 'post', 'action' => $wlTitle->getLocalUrl('action=clear')), NULL));
                $out->addWikiText(wfMsg('watchlistcount', $count));
                $out->addWikiText(wfMsg('watchlistcleartext'));
                $out->addHTML(wfElement('input', array('type' => 'hidden', 'name' => 'token', 'value' => $wgUser->editToken('clearwatchlist')), ''));
                $out->addHTML(wfElement('input', array('type' => 'submit', 'name' => 'submit', 'value' => wfMsgHtml('watchlistclearbutton')), ''));
                $out->addHTML(wfCloseElement('form'));
            }
            return true;
        } else {
            # Nothing on the watchlist; nothing to do here
            $out->addWikiText(wfMsg('nowatchlist'));
            $out->returnToMain();
            return true;
        }
    } else {
        return false;
    }
}
예제 #29
0
/** Build a select with all defined groups
 * @param $selectname String: name of this element. Name of form is automaticly prefixed.
 * @param $selectmsg String: FIXME
 * @param $selected Array: array of element selected when posted. Only multiples will show them.
 * @param $multiple Boolean: A multiple elements select.
 * @param $size Integer: number of elements to be shown ignored for non-multiple (default 6).
 * @param $reverse Boolean: if true, multiple select will hide selected elements (default false).
 * @todo Document $selectmsg
*/
function HTMLSelectGroups($selectname, $selectmsg, $selected = array(), $multiple = false, $size = 6, $reverse = false)
{
    $groups = User::getAllGroups();
    $out = htmlspecialchars(wfMsg($selectmsg));
    if ($multiple) {
        $attribs = array('name' => $selectname . '[]', 'multiple' => 'multiple', 'size' => $size);
    } else {
        $attribs = array('name' => $selectname);
    }
    $out .= wfElement('select', $attribs, null);
    foreach ($groups as $group) {
        $attribs = array('value' => $group);
        if ($multiple) {
            // for multiple will only show the things we want
            if (!in_array($group, $selected) xor $reverse) {
                continue;
            }
        } else {
            if (in_array($group, $selected)) {
                $attribs['selected'] = 'selected';
            }
        }
        $out .= wfElement('option', $attribs, User::getGroupName($group)) . "\n";
    }
    $out .= "</select>\n";
    return $out;
}
예제 #30
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;
 }