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); }
/** * 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); } }
/** * 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); }
/** * 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); } }
/** * 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); } } }
/** * 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')); } }
/** * 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; }
/** * 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; }
/** * 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; } }
/** * 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; } }
/** * 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; }
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')); }
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')); }
/** * 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; }
/** * 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; }
function showRevision($timestamp) { global $wgLang, $wgUser, $wgOut; if (!preg_match("/[0-9]{14}/", $timestamp)) { return 0; } $archive = new PageArchive($this->mTargetObj); $rev = $archive->getRevision($timestamp); $wgOut->setPagetitle(wfMsg("undeletepage")); $wgOut->addWikiText("(" . wfMsg("undeleterevision", $wgLang->timeAndDate($timestamp)) . ")\n"); if (!$rev) { $wgOut->addWikiText(wfMsg('undeleterevision-missing')); return; } wfRunHooks('UndeleteShowRevision', array($this->mTargetObj, $rev)); if ($this->mPreview) { $wgOut->addHtml("<hr />\n"); $article = new Article($archive->title); # OutputPage wants an Article obj $wgOut->addPrimaryWikiText($rev->getText(), $article, false); } $self = SpecialPage::getTitleFor("Undelete"); $wgOut->addHtml(wfElement('textarea', array('readonly' => true, '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' => 'hidden', 'name' => 'preview', 'value' => '1')) . wfElement('input', array('type' => 'submit', 'value' => wfMsg('showpreview'))) . wfCloseElement('form') . wfCloseElement('div')); }
/** Generate wikitext showing extensions name, URL, author and description */ function extensionCredits() { global $wgExtensionCredits, $wgExtensionFunctions, $wgParser, $wgSkinExtensionFunction; if (!count($wgExtensionCredits) && !count($wgExtensionFunctions) && !count($wgSkinExtensionFunction)) { return ''; } $extensionTypes = array('specialpage' => 'Special pages', 'parserhook' => 'Parser hooks', 'variable' => 'Variables', 'other' => 'Other'); wfRunHooks('SpecialVersionExtensionTypes', array(&$this, &$extensionTypes)); $out = "<h2>Extensions</h2>\n"; $out .= wfOpenElement('table', array('id' => 'sv-ext')); foreach ($extensionTypes as $type => $text) { if (count(@$wgExtensionCredits[$type])) { $out .= $this->openExtType($text); usort($wgExtensionCredits[$type], array($this, 'compare')); foreach ($wgExtensionCredits[$type] as $extension) { wfSuppressWarnings(); $out .= $this->formatCredits($extension['name'], $extension['version'], $extension['author'], $extension['url'], $extension['description']); wfRestoreWarnings(); } } } if (count($wgExtensionFunctions)) { $out .= $this->openExtType('Extension functions'); $out .= '<tr><td colspan="3">' . $this->listToText($wgExtensionFunctions) . "</td></tr>\n"; } if ($cnt = count($tags = $wgParser->getTags())) { for ($i = 0; $i < $cnt; ++$i) { $tags[$i] = "<{$tags[$i]}>"; } $out .= $this->openExtType('Parser extension tags'); $out .= '<tr><td colspan="3">' . $this->listToText($tags) . "</td></tr>\n"; } if ($cnt = count($fhooks = $wgParser->getFunctionHooks())) { $out .= $this->openExtType('Parser function hooks'); $out .= '<tr><td colspan="3">' . $this->listToText($fhooks) . "</td></tr>\n"; } if (count($wgSkinExtensionFunction)) { $out .= $this->openExtType('Skin extension functions'); $out .= '<tr><td colspan="3">' . $this->listToText($wgSkinExtensionFunction) . "</td></tr>\n"; } $out .= wfCloseElement('table'); return $out; }
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')); }
/** * 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; if (!preg_match("/[0-9]{14}/", $timestamp)) { return 0; } $archive = new PageArchive($this->mTargetObj); $text = $archive->getRevisionText($timestamp); $wgOut->setPagetitle(wfMsg("undeletepage")); $wgOut->addWikiText("(" . wfMsg("undeleterevision", $wgLang->date($timestamp)) . ")\n"); if ($this->mPreview) { $wgOut->addHtml("<hr />\n"); $wgOut->addWikiText($text); } $self = Title::makeTitle(NS_SPECIAL, "Undelete"); $wgOut->addHtml(wfElement('textarea', array('readonly' => true, 'cols' => intval($wgUser->getOption('cols')), 'rows' => intval($wgUser->getOption('rows'))), $text . "\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' => 'hidden', 'name' => 'preview', 'value' => '1')) . wfElement('input', array('type' => 'submit', 'value' => wfMsg('showpreview'))) . wfCloseElement('form') . wfCloseElement('div')); }
/** * 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'); } } }