function addRequestWikiForm()
 {
     $localpage = $this->getPageTitle()->getLocalUrl();
     $form = Xml::openElement('form', array('action' => $localpage, 'method' => 'post'));
     $form .= '<fieldset><legend>' . $this->msg('requestwiki')->escaped() . '</legend>';
     $form .= Xml::openElement('table');
     $form .= '<tr><td>' . $this->msg('requestwiki-label-siteurl')->escaped() . '</td>';
     $form .= '<td>' . Xml::input('subdomain', 20, '') . '.miraheze.org' . '</td></tr>';
     $form .= '<tr><td>' . $this->msg('requestwiki-label-sitename')->escaped() . '</td>';
     $form .= '<td>' . Xml::input('sitename', 20, '', array('required' => '')) . '</td></tr>';
     $form .= '<tr><td>' . $this->msg('requestwiki-label-customdomain')->escaped() . '</td>';
     $form .= '<td>' . Xml::input('customdomain', 20, '') . '</td></tr>';
     $form .= '<tr><td>' . $this->msg('requestwiki-label-language')->escaped() . '</td>';
     $form .= '<td>' . Xml::languageSelector('en', true, null, array('name' => 'language'))[1] . '</td></tr>';
     $form .= '<tr><td>' . $this->msg('requestwiki-label-private')->escaped() . '</td>';
     $form .= '<td>' . Xml::check('private', false, array('value' => 0)) . '</td></tr>';
     $form .= '<tr><td>' . $this->msg('requestwiki-label-comments')->escaped() . '</td>';
     $form .= '<td>' . Xml::textarea('comments', '', 40, 5, array('required' => '')) . '</td></tr>';
     $form .= '<tr><td>' . Xml::submitButton($this->msg('requestwiki-submit')->plain()) . '</td></tr>';
     $form .= Xml::closeElement('table');
     $form .= '</fieldset>';
     $form .= Html::hidden('token', $this->getUser()->getEditToken());
     $form .= Xml::closeElement('form');
     $this->getOutput()->addHTML($form);
 }
Esempio n. 2
0
 function execute($subpage)
 {
     global $wgRequest, $wgOut;
     $wgOut->setPageTitle('Wikitext Preview');
     if ($wikitext = $wgRequest->getText('wikitext')) {
         $wgOut->addHTML(Xml::fieldset('Wikitext preview', $wgOut->parse($wikitext)));
     }
     $f = Xml::textarea('wikitext', $wikitext);
     $f .= Xml::submitButton('Preview wikitext');
     $f .= Html::Hidden('title', $this->getTitle()->getPrefixedText());
     $f = Xml::tags('form', array('method' => 'POST', 'action' => $this->getTitle()->getLocalURL()), $f);
     $wgOut->addHTML(Xml::fieldset('Preview wikitext', $f));
 }
 function show()
 {
     global $wgOut, $wgUser;
     if (!$wgUser->isAllowed('abusefilter-modify')) {
         $wgOut->addWikiMsg('abusefilter-edit-notallowed');
         return;
     }
     $wgOut->addWikiMsg('abusefilter-import-intro');
     $html = Xml::textarea('wpImportText', '', 40, 20);
     $html .= Xml::submitButton(wfMsg('abusefilter-import-submit'), array('accesskey' => 's'));
     $url = SpecialPage::getTitleFor('AbuseFilter', 'new')->getFullURL();
     $html = Xml::tags('form', array('method' => 'post', 'action' => $url), $html);
     $wgOut->addHTML($html);
 }
 /**
  * View or edit an individual banner
  */
 private function showView()
 {
     global $wgOut, $wgUser, $wgRequest, $wgLanguageCode, $wgExtensionAssetsPath, $wgLang, $wgNoticeEnableFundraising;
     $scriptPath = "{$wgExtensionAssetsPath}/CentralNotice";
     $sk = $this->getSkin();
     if ($this->editable) {
         $readonly = array();
         $disabled = array();
     } else {
         $readonly = array('readonly' => 'readonly');
         $disabled = array('disabled' => 'disabled');
     }
     // Get user's language
     $wpUserLang = $wgRequest->getVal('wpUserLanguage', $wgLanguageCode);
     // Get current banner
     $currentTemplate = $wgRequest->getText('template');
     $bannerSettings = CentralNoticeDB::getBannerSettings($currentTemplate);
     if (!$bannerSettings) {
         $this->showError('centralnotice-banner-doesnt-exist');
         return;
     } else {
         // Begin building HTML
         $htmlOut = '';
         // Begin View Banner fieldset
         $htmlOut .= Html::openElement('fieldset', array('class' => 'prefsection'));
         $htmlOut .= Html::element('h2', null, wfMsg('centralnotice-banner-heading', $currentTemplate));
         // Show preview of banner
         $render = new SpecialBannerLoader();
         $render->siteName = 'Wikipedia';
         $render->language = $wpUserLang;
         try {
             $preview = $render->getHtmlNotice($wgRequest->getText('template'));
         } catch (SpecialBannerLoaderException $e) {
             $preview = wfMsg('centralnotice-nopreview');
         }
         if ($render->language != '') {
             $htmlOut .= Xml::fieldset(wfMsg('centralnotice-preview') . " ({$render->language})", $preview);
         } else {
             $htmlOut .= Xml::fieldset(wfMsg('centralnotice-preview'), $preview);
         }
         // Pull banner text and respect any inc: markup
         $bodyPage = Title::newFromText("Centralnotice-template-{$currentTemplate}", NS_MEDIAWIKI);
         $curRev = Revision::newFromTitle($bodyPage);
         $body = $curRev ? $curRev->getText() : '';
         // Extract message fields from the banner body
         $fields = array();
         $allowedChars = Title::legalChars();
         preg_match_all("/\\{\\{\\{([{$allowedChars}]+)\\}\\}\\}/u", $body, $fields);
         // If there are any message fields in the banner, display translation tools.
         if (count($fields[0]) > 0) {
             if ($this->editable) {
                 $htmlOut .= Html::openElement('form', array('method' => 'post'));
             }
             $htmlOut .= Xml::fieldset(wfMsg('centralnotice-translate-heading', $currentTemplate), false, array('id' => 'mw-centralnotice-translations-for'));
             $htmlOut .= Html::openElement('table', array('cellpadding' => 9, 'width' => '100%'));
             // Table headers
             $htmlOut .= Html::element('th', array('width' => '15%'), wfMsg('centralnotice-message'));
             $htmlOut .= Html::element('th', array('width' => '5%'), wfMsg('centralnotice-number-uses'));
             $htmlOut .= Html::element('th', array('width' => '40%'), wfMsg('centralnotice-english'));
             $languages = Language::getLanguageNames();
             $htmlOut .= Html::element('th', array('width' => '40%'), $languages[$wpUserLang]);
             // Remove duplicate message fields
             $filteredFields = array();
             foreach ($fields[1] as $field) {
                 $filteredFields[$field] = array_key_exists($field, $filteredFields) ? $filteredFields[$field] + 1 : 1;
             }
             // Table rows
             foreach ($filteredFields as $field => $count) {
                 // Message
                 $message = $wpUserLang == 'en' ? "Centralnotice-{$currentTemplate}-{$field}" : "Centralnotice-{$currentTemplate}-{$field}/{$wpUserLang}";
                 // English value
                 $htmlOut .= Html::openElement('tr');
                 $title = Title::newFromText("MediaWiki:{$message}");
                 $htmlOut .= Xml::tags('td', null, $sk->makeLinkObj($title, htmlspecialchars($field)));
                 $htmlOut .= Html::element('td', null, $count);
                 // English text
                 $englishText = wfMsg('centralnotice-message-not-set');
                 $englishTextExists = false;
                 if (Title::newFromText("Centralnotice-{$currentTemplate}-{$field}", NS_MEDIAWIKI)->exists()) {
                     $englishText = wfMsgExt("Centralnotice-{$currentTemplate}-{$field}", array('language' => 'en'));
                     $englishTextExists = true;
                 }
                 $htmlOut .= Xml::tags('td', null, Html::element('span', array('style' => 'font-style:italic;' . (!$englishTextExists ? 'color:silver' : '')), $englishText));
                 // Foreign text input
                 $foreignText = '';
                 $foreignTextExists = false;
                 if (Title::newFromText($message, NS_MEDIAWIKI)->exists()) {
                     $foreignText = wfMsgExt("Centralnotice-{$currentTemplate}-{$field}", array('language' => $wpUserLang));
                     $foreignTextExists = true;
                 }
                 $htmlOut .= Xml::tags('td', null, Xml::input("updateText[{$wpUserLang}][{$currentTemplate}-{$field}]", '', $foreignText, wfArrayMerge($readonly, array('style' => 'width:100%;' . (!$foreignTextExists ? 'color:red' : '')))));
                 $htmlOut .= Html::closeElement('tr');
             }
             $htmlOut .= Html::closeElement('table');
             if ($this->editable) {
                 $htmlOut .= Html::hidden('wpUserLanguage', $wpUserLang);
                 $htmlOut .= Html::hidden('authtoken', $wgUser->editToken());
                 $htmlOut .= Xml::tags('div', array('class' => 'cn-buttons'), Xml::submitButton(wfMsg('centralnotice-modify'), array('name' => 'update')));
             }
             $htmlOut .= Html::closeElement('fieldset');
             if ($this->editable) {
                 $htmlOut .= Html::closeElement('form');
             }
             // Show language selection form
             $actionTitle = $this->getTitleFor('NoticeTemplate', 'view');
             $actionUrl = $actionTitle->getLocalURL();
             $htmlOut .= Html::openElement('form', array('method' => 'get', 'action' => $actionUrl));
             $htmlOut .= Xml::fieldset(wfMsg('centralnotice-change-lang'));
             $htmlOut .= Html::hidden('template', $currentTemplate);
             $htmlOut .= Html::openElement('table', array('cellpadding' => 9));
             // Retrieve the language list
             list($lsLabel, $lsSelect) = Xml::languageSelector($wpUserLang, true, $wgLang->getCode());
             $newPage = $this->getTitle('view');
             $htmlOut .= Xml::tags('tr', null, Xml::tags('td', null, $lsLabel) . Xml::tags('td', null, $lsSelect) . Xml::tags('td', array('colspan' => 2), Xml::submitButton(wfMsg('centralnotice-modify'))));
             $htmlOut .= Xml::tags('tr', null, Xml::tags('td', null, '') . Xml::tags('td', null, $sk->makeLinkObj($newPage, wfMsgHtml('centralnotice-preview-all-template-translations'), "template={$currentTemplate}&wpUserLanguage=all")));
             $htmlOut .= Html::closeElement('table');
             $htmlOut .= Html::closeElement('fieldset');
             $htmlOut .= Html::closeElement('form');
         }
         // Show edit form
         if ($this->editable) {
             $htmlOut .= Html::openElement('form', array('method' => 'post', 'onsubmit' => 'return validateBannerForm(this)'));
             $htmlOut .= Html::hidden('wpMethod', 'editTemplate');
         }
         // If there was an error, we'll need to restore the state of the form
         if ($wgRequest->wasPosted() && $wgRequest->getVal('mainform')) {
             $displayAnon = $wgRequest->getCheck('displayAnon');
             $displayAccount = $wgRequest->getCheck('displayAccount');
             $fundraising = $wgRequest->getCheck('fundraising');
             $autolink = $wgRequest->getCheck('autolink');
             $landingPages = $wgRequest->getVal('landingPages');
             $body = $wgRequest->getVal('templateBody', $body);
         } else {
             // Use previously stored values
             $displayAnon = $bannerSettings['anon'] == 1;
             $displayAccount = $bannerSettings['account'] == 1;
             $fundraising = $bannerSettings['fundraising'] == 1;
             $autolink = $bannerSettings['autolink'] == 1;
             $landingPages = $bannerSettings['landingpages'];
             // $body default is defined prior to message interface code
         }
         // Show banner settings
         $htmlOut .= Xml::fieldset(wfMsg('centralnotice-settings'));
         $htmlOut .= Html::openElement('p', null);
         $htmlOut .= wfMsg('centralnotice-banner-display');
         $htmlOut .= Xml::check('displayAnon', $displayAnon, wfArrayMerge($disabled, array('id' => 'displayAnon')));
         $htmlOut .= Xml::label(wfMsg('centralnotice-banner-anonymous'), 'displayAnon');
         $htmlOut .= Xml::check('displayAccount', $displayAccount, wfArrayMerge($disabled, array('id' => 'displayAccount')));
         $htmlOut .= Xml::label(wfMsg('centralnotice-banner-logged-in'), 'displayAccount');
         $htmlOut .= Html::closeElement('p');
         // Fundraising settings
         if ($wgNoticeEnableFundraising) {
             // Checkbox for indicating if it is a fundraising banner
             $htmlOut .= Html::openElement('p', null);
             $htmlOut .= Xml::check('fundraising', $fundraising, wfArrayMerge($disabled, array('id' => 'fundraising')));
             $htmlOut .= Xml::label(wfMsg('centralnotice-banner-fundraising'), 'fundraising');
             $htmlOut .= Html::closeElement('p');
             // Checkbox for whether or not to automatically create landing page link
             $htmlOut .= Html::openElement('p', null);
             $htmlOut .= Xml::check('autolink', $autolink, wfArrayMerge($disabled, array('id' => 'autolink')));
             $htmlOut .= Xml::label(wfMsg('centralnotice-banner-autolink'), 'autolink');
             $htmlOut .= Html::closeElement('p');
             // Interface for setting the landing pages
             if ($autolink) {
                 $htmlOut .= Html::openElement('div', array('id' => 'autolinkInterface'));
             } else {
                 $htmlOut .= Html::openElement('div', array('id' => 'autolinkInterface', 'style' => 'display:none;'));
             }
             $htmlOut .= Xml::tags('p', array(), wfMsg('centralnotice-banner-autolink-help', 'id="cn-landingpage-link"', 'JimmyAppeal01'));
             $htmlOut .= Xml::tags('p', array(), Xml::inputLabel(wfMsg('centralnotice-banner-landing-pages'), 'landingPages', 'landingPages', 40, $landingPages, array('maxlength' => 255)));
             $htmlOut .= Html::closeElement('div');
         }
         // Begin banner body section
         $htmlOut .= Html::closeElement('fieldset');
         if ($this->editable) {
             $htmlOut .= Xml::fieldset(wfMsg('centralnotice-edit-template'));
             $htmlOut .= wfMsg('centralnotice-edit-template-summary');
             $buttons = array();
             $buttons[] = '<a href="#" onclick="insertButton(\'close\');return false;">' . wfMsg('centralnotice-close-button') . '</a>';
             $htmlOut .= Xml::tags('div', array('style' => 'margin-bottom: 0.2em;'), '<img src="' . $scriptPath . '/down-arrow.png" ' . 'style="vertical-align:baseline;"/>' . wfMsg('centralnotice-insert', $wgLang->commaList($buttons)));
         } else {
             $htmlOut .= Xml::fieldset(wfMsg('centralnotice-banner'));
         }
         $htmlOut .= Xml::textarea('templateBody', $body, 60, 20, $readonly);
         $htmlOut .= Html::closeElement('fieldset');
         if ($this->editable) {
             // Indicate which form was submitted
             $htmlOut .= Html::hidden('mainform', 'true');
             $htmlOut .= Html::hidden('authtoken', $wgUser->editToken());
             $htmlOut .= Xml::tags('div', array('class' => 'cn-buttons'), Xml::submitButton(wfMsg('centralnotice-save-banner')));
             $htmlOut .= Html::closeElement('form');
         }
         // Show clone form
         if ($this->editable) {
             $htmlOut .= Html::openElement('form', array('method' => 'post', 'action' => $this->getTitle('clone')->getLocalUrl()));
             $htmlOut .= Xml::fieldset(wfMsg('centralnotice-clone-notice'));
             $htmlOut .= Html::openElement('table', array('cellpadding' => 9));
             $htmlOut .= Html::openElement('tr');
             $htmlOut .= Xml::inputLabel(wfMsg('centralnotice-clone-name'), 'newTemplate', 'newTemplate', '25');
             $htmlOut .= Xml::submitButton(wfMsg('centralnotice-clone'), array('id' => 'clone'));
             $htmlOut .= Html::hidden('oldTemplate', $currentTemplate);
             $htmlOut .= Html::closeElement('tr');
             $htmlOut .= Html::closeElement('table');
             $htmlOut .= Html::hidden('authtoken', $wgUser->editToken());
             $htmlOut .= Html::closeElement('fieldset');
             $htmlOut .= Html::closeElement('form');
         }
         // End View Banner fieldset
         $htmlOut .= Html::closeElement('fieldset');
         // Output HTML
         $wgOut->addHTML($htmlOut);
     }
 }
 /**
  * Show the form to add group memberships to one or more users at once.
  */
 protected function showEditUserGroupsForm()
 {
     global $wgOut, $wgUser, $wgLang;
     $wgOut->addHTML(Xml::openElement('form', array('method' => 'post', 'action' => $this->getTitle()->getLocalURL(), 'name' => 'editGroup', 'id' => 'mw-userrights-form2')) . Html::hidden('wpEditToken', $wgUser->getEditToken()) . Xml::openElement('fieldset') . Xml::element('legend', array(), wfMsg('userrights-editusergroup')) . wfMsgExt('batchuserrights-intro', array('parse')) . Xml::tags('p', null, $this->groupCheckboxes()) . Xml::openElement('table', array('border' => '0', 'id' => 'mw-userrights-table-outer')) . "<tr>\n\t\t\t\t\t<td class='mw-label'>" . Xml::label(wfMsg('batchuserrights-names'), 'wpUsernames') . "</td>\n\t\t\t\t\t<td class='mw-input'>" . Xml::textarea('wpUsernames', '') . "</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td class='mw-label'>" . Xml::label(wfMsg('userrights-reason'), 'wpReason') . "</td>\n\t\t\t\t\t<td class='mw-input'>" . Xml::input('user-reason', 60, false, array('id' => 'wpReason', 'maxlength' => 255)) . "</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td></td>\n\t\t\t\t\t<td class='mw-submit'>" . Xml::submitButton(wfMsg('saveusergroups'), array('name' => 'saveusergroups', 'accesskey' => 's')) . "</td>\n\t\t\t\t</tr>" . Xml::closeElement('table') . "\n" . Xml::closeElement('fieldset') . Xml::closeElement('form') . "\n");
 }
 /**
  * @param $rules String
  * @param $textName String
  * @param $addResultDiv Boolean
  * @param $canEdit Boolean
  * @return string
  */
 static function buildEditBox($rules, $textName = 'wpFilterRules', $addResultDiv = true, $canEdit = true)
 {
     global $wgOut;
     $textareaAttrib = array('dir' => 'ltr');
     # Rules are in English
     if (!$canEdit) {
         $textareaAttrib['readonly'] = 'readonly';
     }
     global $wgUser;
     $noTestAttrib = array();
     if (!$wgUser->isAllowed('abusefilter-modify')) {
         $noTestAttrib['disabled'] = 'disabled';
         $addResultDiv = false;
     }
     $rules = rtrim($rules) . "\n";
     $rules = Xml::textarea($textName, $rules, 40, 15, $textareaAttrib);
     if ($canEdit) {
         $dropDown = self::getBuilderValues();
         // Generate builder drop-down
         $builder = '';
         $builder .= Xml::option(wfMessage('abusefilter-edit-builder-select')->text());
         foreach ($dropDown as $group => $values) {
             // Give grep a chance to find the usages:
             // abusefilter-edit-builder-group-op-arithmetic, abusefilter-edit-builder-group-op-comparison,
             // abusefilter-edit-builder-group-op-bool, abusefilter-edit-builder-group-misc,
             // abusefilter-edit-builder-group-funcs, abusefilter-edit-builder-group-vars
             $builder .= Xml::openElement('optgroup', array('label' => wfMessage("abusefilter-edit-builder-group-{$group}")->text())) . "\n";
             foreach ($values as $content => $name) {
                 $builder .= Xml::option(wfMessage("abusefilter-edit-builder-{$group}-{$name}")->text(), $content) . "\n";
             }
             $builder .= Xml::closeElement('optgroup') . "\n";
         }
         $rules .= Xml::tags('select', array('id' => 'wpFilterBuilder'), $builder) . ' ';
         // Add syntax checking
         $rules .= Xml::element('input', array('type' => 'button', 'value' => wfMessage('abusefilter-edit-check')->text(), 'id' => 'mw-abusefilter-syntaxcheck') + $noTestAttrib);
     }
     if ($addResultDiv) {
         $rules .= Xml::element('div', array('id' => 'mw-abusefilter-syntaxresult', 'style' => 'display: none;'), '&#160;');
     }
     // Add script
     $wgOut->addModules('ext.abuseFilter.edit');
     self::$editboxName = $textName;
     return $rules;
 }
 /**
  * Displays form to create wiki
  */
 protected function _executeCreate($wgFarmer, $wiki)
 {
     global $wgOut, $wgUser, $wgRequest;
     if (!$wgFarmer->getActiveWiki()->isDefaultWiki()) {
         $wgOut->wrapWikiMsg('== $1 ==', 'farmer-notavailable');
         $wgOut->addWikiMsg('farmer-notavailable-text');
         return;
     }
     if (!MediaWikiFarmer::userCanCreateWiki($wgUser, $wiki)) {
         $wgOut->addWikiMsg('farmercantcreatewikis');
         return;
     }
     $name = MediaWikiFarmer_Wiki::sanitizeName($wgRequest->getVal('wpName', $wiki));
     $title = MediaWikiFarmer_Wiki::sanitizeTitle($wgRequest->getVal('wpTitle'));
     $description = $wgRequest->getVal('wpDescription', '');
     $reason = $wgRequest->getVal('wpReason');
     $action = $this->getTitle('create')->escapeLocalURL();
     // if something was POST'd
     if ($wgRequest->wasPosted()) {
         // we create the wiki if the user pressed 'Confirm'
         if ($wgRequest->getCheck('wpConfirm')) {
             $wikiObj = MediaWikiFarmer_Wiki::newFromParams($name, $title, $description, $wgUser->getName());
             $wikiObj->create();
             $log = new LogPage('farmer');
             $log->addEntry('create', $this->getTitle(), $reason, array($name));
             $wgOut->wrapWikiMsg('== $1 ==', 'farmer-wikicreated');
             $wgOut->addWikiMsg('farmer-wikicreated-text', $wikiObj->getUrl(wfUrlencode(wfMessage('mainpage')->inContentLanguage()->useDatabase(false)->plain())));
             $wgOut->addWikiMsg('farmer-default', '[[' . $title . ':Special:Farmer|Special:Farmer]]');
             return;
         }
         if ($name && $title && $description) {
             $wiki = new MediaWikiFarmer_Wiki($name);
             if ($wiki->exists() || $wiki->databaseExists()) {
                 $wgOut->wrapWikiMsg("== \$1 ==\n\n\$2", 'farmer-wikiexists', array('farmer-wikiexists-text', $name));
                 return;
             }
             $url = $wiki->getUrl('');
             $wgOut->wrapWikiMsg('== $1 ==', 'farmer-confirmsetting');
             $wgOut->addHtml(Xml::openElement('table', array('class' => 'wikitable')) . "\n" . Xml::tags('tr', array(), Xml::tags('th', array(), wfMsgExt('farmer-confirmsetting-name', 'parseinline')) . Xml::element('td', array(), $name)) . "\n" . Xml::tags('tr', array(), Xml::tags('th', array(), wfMsgExt('farmer-confirmsetting-title', 'parseinline')) . Xml::element('td', array(), $title)) . "\n" . Xml::tags('tr', array(), Xml::tags('th', array(), wfMsgExt('farmer-confirmsetting-description', 'parseinline')) . Xml::element('td', array(), $description)) . "\n" . Xml::tags('tr', array(), Xml::tags('th', array(), wfMsgExt('farmer-confirmsetting-reason', 'parseinline')) . Xml::element('td', array(), $reason)) . "\n" . Xml::closeElement('table'));
             $wgOut->addWikiMsg('farmer-confirmsetting-text', $name, $title, $url);
             $nameaccount = htmlspecialchars($name);
             $nametitle = htmlspecialchars($title);
             $namedescript = htmlspecialchars($description);
             $confirmaccount = wfMsgHtml('farmer-button-confirm');
             $wgOut->addHTML("\n\n<form id=\"farmercreate2\" method=\"post\" action=\"{$action}\">\n<input type=\"hidden\" name=\"wpName\" value=\"{$nameaccount}\" />\n<input type=\"hidden\" name=\"wpTitle\" value=\"{$nametitle}\" />\n<input type=\"hidden\" name=\"wpDescription\" value=\"{$namedescript}\" />\n<input type=\"hidden\" name=\"wpReason\" value=\"{$reason}\" />\n<input type=\"submit\" name=\"wpConfirm\" value=\"{$confirmaccount}\" />\n</form>");
             return;
         }
     }
     if ($wiki && !$name) {
         $name = $wiki;
     }
     $wgOut->wrapWikiMsg("== \$1 ==\n\$2\n== \$3 ==\n\$4\n\$5\n\$6", 'farmer-createwiki-form-title', 'farmer-createwiki-form-text1', 'farmer-createwiki-form-help', 'farmer-createwiki-form-text2', 'farmer-createwiki-form-text3', 'farmer-createwiki-form-text4');
     $formURL = wfMsgHTML('farmercreateurl');
     $formSitename = wfMsgHTML('farmercreatesitename');
     $formNextStep = wfMsgHTML('farmercreatenextstep');
     $token = htmlspecialchars($wgUser->editToken());
     $wgOut->addHTML(Xml::openElement('form', array('method' => 'post', 'action' => $action)) . "\n" . Xml::buildForm(array('farmer-createwiki-user' => Xml::element('b', array(), $wgUser->getName()), 'farmer-createwiki-name' => Xml::input('wpName', 20, $name), 'farmer-createwiki-title' => Xml::input('wpTitle', 20, $title), 'farmer-createwiki-description' => Xml::textarea('wpDescription', $description), 'farmer-createwiki-reason' => Xml::input('wpReason', 20, $reason)), 'farmer-button-submit') . "\n" . Html::Hidden('token', $token) . "\n" . Xml::closeElement('form'));
 }
Esempio n. 8
0
 function showForm($err = '')
 {
     global $wgOut;
     if ($err) {
         $wgOut->addHTML('<div class="wikierror">' . htmlspecialchars($err) . '</div>');
     }
     $wgOut->addWikiMsg('masseditregextext');
     $titleObj = SpecialPage::getTitleFor('MassEditRegex');
     $wgOut->addHTML(Xml::openElement('form', array('id' => 'masseditregex', 'method' => 'post', 'action' => $titleObj->getLocalURL('action=submit'))) . Xml::element('p', null, wfMsg('masseditregex-pagelisttxt')) . Xml::textarea('wpPageList', join("\n", $this->aPageList)) . Xml::namespaceSelector($this->iNamespace, null, 'namespace', wfMsg('masseditregex-namespace-intro')) . Xml::element('br') . Xml::element('span', null, wfMsg('masseditregex-listtype-intro')) . Xml::openElement('ul', array('style' => 'list-style: none')));
     // Generate HTML for the radio buttons (one for each list type)
     foreach (array('pagenames', 'pagename-prefixes', 'categories', 'backlinks') as $strValue) {
         // Have to use openElement because putting an Xml::xxx return value
         // inside an Xml::element causes the HTML code to be escaped and appear
         // on the page.
         $wgOut->addHTML(Xml::openElement('li') . Xml::radioLabel(wfMsg('masseditregex-listtype-' . $strValue), 'wpPageListType', $strValue, 'masseditregex-radio-' . $strValue, $strValue == $this->strPageListType) . Xml::closeElement('li'));
     }
     $wgOut->addHTML(Xml::closeElement('ul') . Xml::openElement('table', array('style' => 'width: 100%')) . Xml::openElement('tr') . Xml::openElement('td') . Xml::element('p', null, wfMsg('masseditregex-matchtxt')) . Xml::textarea('wpMatch', join("\n", $this->aMatch)) . Xml::closeElement('td') . Xml::openElement('td') . Xml::element('p', null, wfMsg('masseditregex-replacetxt')) . Xml::textarea('wpReplace', $this->strReplace) . Xml::closeElement('td') . Xml::closeElement('tr') . Xml::closeElement('table') . Xml::openElement('div', array('class' => 'editOptions')) . Xml::tags('span', array('class' => 'mw-summary', 'id' => 'wpSummaryLabel'), Xml::tags('label', array('for' => 'wpSummary'), wfMsg('summary'))) . ' ' . Xml::input('wpSummary', 60, $this->strSummary, array('id' => 'wpSummary', 'maxlength' => '200', 'tabindex' => '1')) . Xml::tags('div', array('class' => 'mw-summary-preview'), wfMsgExt('summary-preview', 'parseinline') . $this->sk->commentBlock($this->strSummary)) . Xml::closeElement('div') . Xml::element('input', array('id' => 'wpSave', 'name' => 'wpSave', 'type' => 'submit', 'value' => wfMsg('masseditregex-executebtn'), 'accesskey' => wfMsg('accesskey-save'), 'title' => wfMsg('masseditregex-tooltip-execute') . ' [' . wfMsg('accesskey-save') . ']')) . Xml::element('input', array('id' => 'wpPreview', 'name' => 'wpPreview', 'type' => 'submit', 'value' => wfMsg('showpreview'), 'accesskey' => wfMsg('accesskey-preview'), 'title' => wfMsg('tooltip-preview') . ' [' . wfMsg('accesskey-preview') . ']')));
     $wgOut->addHTML(Xml::closeElement('form'));
 }
	function showForm( $warning_msg = null ) {
		global $wgOut;
		$wgOut->addHTML(
			Xml::openElement( 'form', array( 'id' => 'powersearch', 'action' => $this->getTitle()->getFullUrl(), 'method' => 'post' ) ) . "\n" .
			self::hiddenField( 'title', $this->getTitle()->getPrefixedText() ) .
			self::hiddenField( 'continue', 1 )
		);
		if ( is_null( $warning_msg ) ) {
			$wgOut->addWikiMsg( 'replacetext_docu' );
		} else {
			$wgOut->wrapWikiMsg( "<div class=\"errorbox\">\n$1\n</div><br clear=\"both\" />", $warning_msg );
		}
		$wgOut->addHTML( '<table><tr><td style="vertical-align: top;">' );
		$wgOut->addWikiMsg( 'replacetext_originaltext' );
		$wgOut->addHTML( '</td><td>' );
		// 'width: auto' style is needed to override MediaWiki's
		// normal 'width: 100%', which causes the textarea to get
		// zero width in IE
		$wgOut->addHTML( Xml::textarea( 'target', $this->target, 50, 2, array( 'style' => 'width: auto;' ) ) );
		$wgOut->addHTML( '</td></tr><tr><td style="vertical-align: top;">' );
		$wgOut->addWikiMsg( 'replacetext_replacementtext' );
		$wgOut->addHTML( '</td><td>' );
		$wgOut->addHTML( Xml::textarea( 'replacement', $this->replacement, 50, 2, array( 'style' => 'width: auto;' ) ) );
		$wgOut->addHTML( '</td></tr></table>' );
		$wgOut->addHTML( Xml::tags( 'p', null,
				Xml::checkLabel( wfMsg( 'replacetext_useregex' ), 'use_regex', 'use_regex' ) ) . "\n" .
			Xml::element( 'p', array( 'style' => 'font-style: italic' ),
				wfMsg( 'replacetext_regexdocu' ) )
		);

		// The interface is heavily based on the one in Special:Search.
		$search_label = wfMsg( 'powersearch-ns' );
		$namespaces = SearchEngine::searchableNamespaces();
		$tables = $this->namespaceTables( $namespaces );
		$wgOut->addHTML(
			"<div class=\"mw-search-formheader\"></div>\n" .
			"<fieldset id=\"mw-searchoptions\">\n" . 
			Xml::tags( 'h4', null, wfMsgExt( 'powersearch-ns', array( 'parseinline' ) ) )
		);
		// The ability to select/unselect groups of namespaces in the
		// search interface exists only in some skins, like Vector -
		// check for the presence of the 'powersearch-togglelabel'
		// message to see if we can use this functionality here.
		if ( !wfEmptyMsg( 'powersearch-togglelabel', wfMsg( 'powersearch-togglelabel' ) ) ) {
			$wgOut->addHTML(
				Xml::tags(
					'div',
					array( 'id' => 'mw-search-togglebox' ),
					Xml::label( wfMsg( 'powersearch-togglelabel' ), 'mw-search-togglelabel' ) .
					Xml::element(
						'input',
						array(
							'type'=>'button',
							'id' => 'mw-search-toggleall',
							// 'onclick' value needed for MW 1.16
							'onclick' => 'mwToggleSearchCheckboxes("all");',
							'value' => wfMsg( 'powersearch-toggleall' )
						)
					) .
					Xml::element(
						'input',
						array(
							'type'=>'button',
							'id' => 'mw-search-togglenone',
							// 'onclick' value needed for MW 1.16
							'onclick' => 'mwToggleSearchCheckboxes("none");',
							'value' => wfMsg( 'powersearch-togglenone' )
						)
					)
				)
			);
		} // end if
		$wgOut->addHTML(
			Xml::element( 'div', array( 'class' => 'divider' ), '', false ) .
			"$tables\n</fieldset>"
		);
		//FIXME: raw html messages
		$optional_filters_label = wfMsg( 'replacetext_optionalfilters' );
		$category_search_label = wfMsg( 'replacetext_categorysearch' );
		$prefix_search_label = wfMsg( 'replacetext_prefixsearch' );
		$wgOut->addHTML(
			"<fieldset id=\"mw-searchoptions\">\n" . 
			Xml::tags( 'h4', null, wfMsgExt( 'replacetext_optionalfilters', array( 'parseinline' ) ) ) .
			Xml::element( 'div', array( 'class' => 'divider' ), '', false ) .
			"<p>$category_search_label\n" .
			Xml::input( 'category', 20, $this->category, array( 'type' => 'text' ) ) . '</p>' .
			"<p>$prefix_search_label\n" .
			Xml::input( 'prefix', 20, $this->prefix, array( 'type' => 'text' ) ) . '</p>' .
			"</fieldset>\n" .
			"<p>\n" .
			Xml::checkLabel( wfMsg( 'replacetext_editpages' ), 'edit_pages', 'edit_pages', true ) . '<br />' .
			Xml::checkLabel( wfMsg( 'replacetext_movepages' ), 'move_pages', 'move_pages' ) .
			"</p>\n" .
			Xml::submitButton( wfMsg( 'replacetext_continue' ) ) .
			Xml::closeElement( 'form' )
		);
		// Add Javascript specific to Special:Search
		if ( method_exists( $wgOut, 'addModules' ) ) {
			$wgOut->addModules( 'mediawiki.special.search' );
		} else {
			$wgOut->addScriptFile( 'search.js' );
		}
	}
 /**
  * @param $action string The action to build an editor for
  * @param $set bool Whether or not the action is activated
  * @param $parameters array Action parameters
  * @param $row stdClass abuse_filter row object
  * @return string
  */
 function buildConsequenceSelector($action, $set, $parameters, $row)
 {
     global $wgAbuseFilterAvailableActions, $wgMainCacheType;
     if (!in_array($action, $wgAbuseFilterAvailableActions)) {
         return '';
     }
     $readOnlyAttrib = array();
     $cbReadOnlyAttrib = array();
     // For checkboxes
     if (!$this->canEditFilter($row)) {
         $readOnlyAttrib['readonly'] = 'readonly';
         $cbReadOnlyAttrib['disabled'] = 'disabled';
     }
     switch ($action) {
         case 'throttle':
             // Throttling is only available via object caching
             if ($wgMainCacheType === CACHE_NONE) {
                 return '';
             }
             $throttleSettings = Xml::checkLabel($this->msg('abusefilter-edit-action-throttle')->text(), 'wpFilterActionThrottle', "mw-abusefilter-action-checkbox-{$action}", $set, array('class' => 'mw-abusefilter-action-checkbox') + $cbReadOnlyAttrib);
             $throttleFields = array();
             if ($set) {
                 array_shift($parameters);
                 $throttleRate = explode(',', $parameters[0]);
                 $throttleCount = $throttleRate[0];
                 $throttlePeriod = $throttleRate[1];
                 $throttleGroups = implode("\n", array_slice($parameters, 1));
             } else {
                 $throttleCount = 3;
                 $throttlePeriod = 60;
                 $throttleGroups = "user\n";
             }
             $throttleFields['abusefilter-edit-throttle-count'] = Xml::input('wpFilterThrottleCount', 20, $throttleCount, $readOnlyAttrib);
             $throttleFields['abusefilter-edit-throttle-period'] = $this->msg('abusefilter-edit-throttle-seconds')->rawParams(Xml::input('wpFilterThrottlePeriod', 20, $throttlePeriod, $readOnlyAttrib))->parse();
             $throttleFields['abusefilter-edit-throttle-groups'] = Xml::textarea('wpFilterThrottleGroups', $throttleGroups . "\n", 40, 5, $readOnlyAttrib);
             $throttleSettings .= Xml::tags('div', array('id' => 'mw-abusefilter-throttle-parameters'), Xml::buildForm($throttleFields));
             return $throttleSettings;
         case 'flag':
             $checkbox = Xml::checkLabel($this->msg('abusefilter-edit-action-flag')->text(), 'wpFilterActionFlag', "mw-abusefilter-action-checkbox-{$action}", true, array('disabled' => '1', 'class' => 'mw-abusefilter-action-checkbox'));
             return Xml::tags('p', null, $checkbox);
         case 'warn':
             global $wgAbuseFilterDefaultWarningMessage;
             $output = '';
             $checkbox = Xml::checkLabel($this->msg('abusefilter-edit-action-warn')->text(), 'wpFilterActionWarn', "mw-abusefilter-action-checkbox-{$action}", $set, array('class' => 'mw-abusefilter-action-checkbox') + $cbReadOnlyAttrib);
             $output .= Xml::tags('p', null, $checkbox);
             if ($set) {
                 $warnMsg = $parameters[0];
             } elseif ($row && isset($row->af_group) && $row->af_group && isset($wgAbuseFilterDefaultWarningMessage[$row->af_group])) {
                 $warnMsg = $wgAbuseFilterDefaultWarningMessage[$row->af_group];
             } else {
                 $warnMsg = 'abusefilter-warning';
             }
             $warnFields['abusefilter-edit-warn-message'] = $this->getExistingSelector($warnMsg);
             $warnFields['abusefilter-edit-warn-other-label'] = Xml::input('wpFilterWarnMessageOther', 45, $warnMsg ? $warnMsg : 'abusefilter-warning-', array('id' => 'mw-abusefilter-warn-message-other') + $cbReadOnlyAttrib);
             $previewButton = Xml::element('input', array('type' => 'button', 'id' => 'mw-abusefilter-warn-preview-button', 'value' => $this->msg('abusefilter-edit-warn-preview')->text()));
             $editButton = Xml::element('input', array('type' => 'button', 'id' => 'mw-abusefilter-warn-edit-button', 'value' => $this->msg('abusefilter-edit-warn-edit')->text()));
             $previewHolder = Xml::element('div', array('id' => 'mw-abusefilter-warn-preview'), '');
             $warnFields['abusefilter-edit-warn-actions'] = Xml::tags('p', null, "{$previewButton} {$editButton}") . "\n{$previewHolder}";
             $output .= Xml::tags('div', array('id' => 'mw-abusefilter-warn-parameters'), Xml::buildForm($warnFields));
             return $output;
         case 'tag':
             if ($set) {
                 $tags = $parameters;
             } else {
                 $tags = array();
             }
             $output = '';
             $checkbox = Xml::checkLabel($this->msg('abusefilter-edit-action-tag')->text(), 'wpFilterActionTag', "mw-abusefilter-action-checkbox-{$action}", $set, array('class' => 'mw-abusefilter-action-checkbox') + $cbReadOnlyAttrib);
             $output .= Xml::tags('p', null, $checkbox);
             $tagFields['abusefilter-edit-tag-tag'] = Xml::textarea('wpFilterTags', implode("\n", $tags), 40, 5, $readOnlyAttrib);
             $output .= Xml::tags('div', array('id' => 'mw-abusefilter-tag-parameters'), Xml::buildForm($tagFields));
             return $output;
         default:
             // Give grep a chance to find the usages:
             // abusefilter-edit-action-warn, abusefilter-edit-action-disallow
             // abusefilter-edit-action-flag, abusefilter-edit-action-blockautopromote
             // abusefilter-edit-action-degroup, abusefilter-edit-action-block
             // abusefilter-edit-action-throttle, abusefilter-edit-action-rangeblock
             // abusefilter-edit-action-tag
             $message = 'abusefilter-edit-action-' . $action;
             $form_field = 'wpFilterAction' . ucfirst($action);
             $status = $set;
             $thisAction = Xml::checkLabel($this->msg($message)->text(), $form_field, "mw-abusefilter-action-checkbox-{$action}", $status, array('class' => 'mw-abusefilter-action-checkbox') + $cbReadOnlyAttrib);
             $thisAction = Xml::tags('p', null, $thisAction);
             return $thisAction;
     }
 }
 /**
  * Get a labelled textarea to configure a variable
  *
  * @param $params Array
  *    Parameters are:
  *      var:        The variable to be configured (required)
  *      label:      The message name for the label (required)
  *      attribs:    Additional attributes for the input element (optional)
  *      controlName: The name for the input element (optional)
  *      value:      The current value of the variable (optional)
  *      help:		The html for the help text (optional)
  *
  * @return string
  */
 public function getTextArea($params)
 {
     if (!isset($params['controlName'])) {
         $params['controlName'] = 'config_' . $params['var'];
     }
     if (!isset($params['value'])) {
         $params['value'] = $this->getVar($params['var']);
     }
     if (!isset($params['attribs'])) {
         $params['attribs'] = array();
     }
     if (!isset($params['help'])) {
         $params['help'] = "";
     }
     return $this->label($params['label'], $params['controlName'], Xml::textarea($params['controlName'], $params['value'], 30, 5, $params['attribs'] + array('id' => $params['controlName'], 'class' => 'config-input-text', 'tabindex' => $this->nextTabIndex())), $params['help']);
 }
Esempio n. 12
0
 function showForm($warning_msg = null)
 {
     global $wgVersion;
     $out = $this->getOutput();
     $out->addHTML(Xml::openElement('form', array('id' => 'powersearch', 'action' => $this->getTitle()->getFullUrl(), 'method' => 'post')) . "\n" . $this->hiddenField('title', $this->getTitle()->getPrefixedText()) . $this->hiddenField('continue', 1));
     if (is_null($warning_msg)) {
         $out->addWikiMsg('replacetext_docu');
     } else {
         $out->wrapWikiMsg("<div class=\"errorbox\">\n\$1\n</div><br clear=\"both\" />", $warning_msg);
     }
     $out->addHTML('<table><tr><td style="vertical-align: top;">');
     $out->addWikiMsg('replacetext_originaltext');
     $out->addHTML('</td><td>');
     // 'width: auto' style is needed to override MediaWiki's
     // normal 'width: 100%', which causes the textarea to get
     // zero width in IE
     $out->addHTML(Xml::textarea('target', $this->target, 50, 2, array('style' => 'width: auto;')));
     $out->addHTML('</td></tr><tr><td style="vertical-align: top;">');
     $out->addWikiMsg('replacetext_replacementtext');
     $out->addHTML('</td><td>');
     $out->addHTML(Xml::textarea('replacement', $this->replacement, 50, 2, array('style' => 'width: auto;')));
     $out->addHTML('</td></tr></table>');
     $out->addHTML(Xml::tags('p', null, Xml::checkLabel($this->msg('replacetext_useregex')->text(), 'use_regex', 'use_regex')) . "\n" . Xml::element('p', array('style' => 'font-style: italic'), $this->msg('replacetext_regexdocu')->text()));
     // The interface is heavily based on the one in Special:Search.
     $namespaces = SearchEngine::searchableNamespaces();
     $tables = $this->namespaceTables($namespaces);
     $out->addHTML("<div class=\"mw-search-formheader\"></div>\n" . "<fieldset id=\"mw-searchoptions\">\n" . Xml::tags('h4', null, $this->msg('powersearch-ns')->parse()));
     // The ability to select/unselect groups of namespaces in the
     // search interface exists only in some skins, like Vector -
     // check for the presence of the 'powersearch-togglelabel'
     // message to see if we can use this functionality here.
     if ($this->msg('powersearch-togglelabel')->isDisabled()) {
         // do nothing
     } elseif (version_compare($wgVersion, '1.20', '>=')) {
         // In MediaWiki 1.20, this became a lot simpler after
         // the main work was passed off to Javascript
         $out->addHTML(Html::element('div', array('id' => 'mw-search-togglebox')));
     } else {
         // MW <= 1.19
         $out->addHTML(Xml::tags('div', array('id' => 'mw-search-togglebox'), Xml::label($this->msg('powersearch-togglelabel')->text(), 'mw-search-togglelabel') . Xml::element('input', array('type' => 'button', 'id' => 'mw-search-toggleall', 'onclick' => 'mwToggleSearchCheckboxes("all");', 'value' => $this->msg('powersearch-toggleall')->text())) . Xml::element('input', array('type' => 'button', 'id' => 'mw-search-togglenone', 'onclick' => 'mwToggleSearchCheckboxes("none");', 'value' => $this->msg('powersearch-togglenone')->text()))));
     }
     // end if
     $out->addHTML(Xml::element('div', array('class' => 'divider'), '', false) . "{$tables}\n</fieldset>");
     // @todo FIXME: raw html messages
     $category_search_label = $this->msg('replacetext_categorysearch')->text();
     $prefix_search_label = $this->msg('replacetext_prefixsearch')->text();
     $out->addHTML("<fieldset id=\"mw-searchoptions\">\n" . Xml::tags('h4', null, $this->msg('replacetext_optionalfilters')->parse()) . Xml::element('div', array('class' => 'divider'), '', false) . "<p>{$category_search_label}\n" . Xml::input('category', 20, $this->category, array('type' => 'text')) . '</p>' . "<p>{$prefix_search_label}\n" . Xml::input('prefix', 20, $this->prefix, array('type' => 'text')) . '</p>' . "</fieldset>\n" . "<p>\n" . Xml::checkLabel($this->msg('replacetext_editpages')->text(), 'edit_pages', 'edit_pages', true) . '<br />' . Xml::checkLabel($this->msg('replacetext_movepages')->text(), 'move_pages', 'move_pages') . "</p>\n" . Xml::submitButton($this->msg('replacetext_continue')->text()) . Xml::closeElement('form'));
     // Add Javascript specific to Special:Search
     $out->addModules('mediawiki.special.search');
 }
 function constructCreateForm()
 {
     global $wgOut, $wgScript;
     global $wgUserProperties, $wgActivityModes;
     $wgOut->addHTML(Xml::openElement('form', array('action' => $this->getTitle()->getLocalURL(), 'method' => 'post')));
     $wgOut->addHTML(Xml::element('h2', null, wfMsg('nss-create-account-header')) . "\n");
     $wgOut->addHTML("<table border=\"1\" id=\"newuser\">\n");
     $props = array_merge(array('username', 'email'), $wgUserProperties);
     foreach ($props as $i) {
         $msg = 'am-' . $i;
         $wgOut->addHTML("\t<tr><th>" . (wfEmptyMsg($msg, wfMsg($msg)) ? $i : wfMsgHtml($msg)) . "</th><td>" . Xml::input("am-" . str_replace(' ', '_', $i), 40) . "</td></tr>\n");
     }
     global $wgActivityModes;
     $select = new XmlSelect("am-active");
     $select->setDefault('active');
     $select->setAttribute('width', '100%');
     foreach ($wgActivityModes as $key) {
         $select->addOption($key);
     }
     $wgOut->addHTML("\t<tr><th>" . wfMsgHtml('am-active') . "</th><td>" . $select->getHTML() . "</td></tr>\n");
     $wgOut->addHTML("</table>\n");
     $wgOut->addHTML("<div id=\"newaccount-submit\">\n" . Html::Hidden('action', 'create') . Xml::checkLabel(wfMsg('nss-no-mail'), 'nss-no-mail', 'nss-no-mail') . "<br />\n" . Xml::element('input', array('type' => 'submit', 'value' => wfMsg('nss-create-account'))) . "</div>\n</form>\n");
     $wgOut->addHTML(Xml::openElement('form', array('action' => $this->getTitle()->getLocalURL(), 'method' => 'post')));
     $wgOut->addHTML("<div id=\"newaccount-raw\">\n" . Xml::textarea('nss-create-account-raw', '') . "\n" . Html::Hidden('action', 'create-raw') . Xml::checkLabel(wfMsg('nss-no-mail'), 'nss-no-mail', 'nss-no-mail') . "<br />\n" . Xml::element('input', array('type' => 'submit', 'value' => wfMsg('nss-create-account'))) . "</div>\n</form>\n");
 }
    function showForm()
    {
        global $wgOut, $wgUser, $wgContactRequireAll, $wgContactIncludeIP, $wgRequest;
        #TODO: show captcha
        $wgOut->setPageTitle(wfMsg('contactpage-title'));
        $wgOut->addHTML($this->formularText);
        if ($this->subject === '') {
            $this->subject = wfMsgForContent('contactpage-defsubject');
        }
        $msgSuffix = $wgContactRequireAll ? '-required' : '';
        $titleObj = SpecialPage::getTitleFor('Contact');
        $action = $titleObj->getLocalURL('action=submit');
        $token = $wgUser->isAnon() ? EDIT_TOKEN_SUFFIX : $wgUser->editToken();
        //this kind of sucks, really...
        $form = Xml::openElement('form', array('method' => 'post', 'action' => $action, 'id' => 'emailuser')) . Xml::openElement('fieldset') . Xml::element('legend', null, wfMsg('contactpage-legend')) . Xml::openElement('table', array('id' => 'mailheader')) . '<tr>
				<td class="mw-label">' . Xml::label(wfMsg('emailsubject'), 'wpSubject') . '</td>
				<td class="mw-input" id="mw-contactpage-subject">' . Xml::input('wpSubject', 60, $this->subject, array('type' => 'text', 'maxlength' => 200)) . '</td>
			</tr>
			<tr>
				<td class="mw-label">' . Xml::label(wfMsg("contactpage-fromname{$msgSuffix}"), 'wpFromName') . '</td>
				<td class="mw-input" id="mw-contactpage-from">' . Xml::input('wpFromName', 60, $this->fromname, array('type' => 'text', 'maxlength' => 200)) . '</td>
			</tr>
			<tr>
				<td class="mw-label">' . Xml::label(wfMsg("contactpage-fromaddress{$msgSuffix}"), 'wpFromAddress') . '</td>
				<td class="mw-input" id="mw-contactpage-address">' . Xml::input('wpFromAddress', 60, $this->fromaddress, array('type' => 'text', 'maxlength' => 200)) . '</td>
			</tr>';
        // Allow other extensions to add more fields into Special:Contact
        wfRunHooks('ContactFormBeforeMessage', array($this, &$form));
        $form .= '<tr>
				<td></td>
				<td class="mw-input" id="mw-contactpage-formfootnote">
					<small>' . wfMsg("contactpage-formfootnotes{$msgSuffix}") . '</small>
				</td>
			</tr>
			<tr>
				<td class="mw-label">' . Xml::label(wfMsg('emailmessage'), 'wpText') . '</td>
				<td class="mw-input">' . Xml::textarea('wpText', $this->text, 80, 20, array('id' => 'wpText')) . '</td>
			</tr>';
        if ($wgContactIncludeIP && $wgUser->isLoggedIn()) {
            $form .= '<tr>
					<td></td>
					<td class="mw-input">' . Xml::checkLabel(wfMsg('contactpage-includeip'), 'wpIncludeIP', 'wpIncludeIP', false) . '</td>
				</tr>';
        }
        $ccme = $this->wasPosted ? $this->cc_me : $wgUser->getBoolOption('ccmeonemails');
        $form .= '<tr>
				<td></td>
				<td class="mw-input">' . Xml::checkLabel(wfMsg('emailccme'), 'wpCCMe', 'wpCCMe', $ccme) . '<br />' . $this->getCaptcha() . '</td>
			</tr>
			<tr>
				<td></td>
				<td class="mw-submit">' . Xml::submitButton(wfMsg('emailsend'), array('name' => 'wpSend', 'accesskey' => 's')) . '</td>
			</tr>' . Html::hidden('wpEditToken', $token) . Html::hidden('formtype', $this->formType) . Xml::closeElement('table') . Xml::closeElement('fieldset') . Xml::closeElement('form');
        $wgOut->addHTML($form);
    }
Esempio n. 15
0
 static function buildEditBox($rules, $textName = 'wpFilterRules', $addResultDiv = true, $canEdit = true)
 {
     global $wgOut;
     $readOnlyAttrib = array();
     if (!$canEdit) {
         $readOnlyAttrib['readonly'] = 'readonly';
     }
     global $wgUser;
     $noTestAttrib = array();
     if (!$wgUser->isAllowed('abusefilter-modify')) {
         $noTestAttrib['disabled'] = 'disabled';
         $addResultDiv = false;
     }
     $rules = rtrim($rules) . "\n";
     $rules = Xml::textarea($textName, $rules, 40, 5, $readOnlyAttrib);
     $dropDown = self::getBuilderValues();
     // Generate builder drop-down
     $builder = '';
     $builder .= Xml::option(wfMsg('abusefilter-edit-builder-select'));
     foreach ($dropDown as $group => $values) {
         $builder .= Xml::openElement('optgroup', array('label' => wfMsg("abusefilter-edit-builder-group-{$group}"))) . "\n";
         foreach ($values as $content => $name) {
             $builder .= Xml::option(wfMsg("abusefilter-edit-builder-{$group}-{$name}"), $content) . "\n";
         }
         $builder .= Xml::closeElement('optgroup') . "\n";
     }
     $rules .= Xml::tags('select', array('id' => 'wpFilterBuilder', 'onchange' => 'addText();'), $builder) . ' ';
     // Add syntax checking
     $rules .= Xml::element('input', array('type' => 'button', 'onclick' => 'doSyntaxCheck()', 'value' => wfMsg('abusefilter-edit-check'), 'id' => 'mw-abusefilter-syntaxcheck') + $noTestAttrib);
     if ($addResultDiv) {
         $rules .= Xml::element('div', array('id' => 'mw-abusefilter-syntaxresult', 'style' => 'display: none;'), '&#160;');
     }
     // Add script
     $editScript = file_get_contents(dirname(__FILE__) . '/edit.js');
     $editScript = "var wgFilterBoxName = " . Xml::encodeJSVar($textName) . ";\n{$editScript}";
     // Import localisation.
     $importMessages = array('abusefilter-edit-syntaxok', 'abusefilter-edit-syntaxerr');
     $msgData = array();
     foreach ($importMessages as $msg) {
         $msgData[$msg] = wfMsg($msg);
     }
     $editScript .= "\nvar wgAbuseFilterMessages = " . json_encode($msgData) . ";\n";
     $wgOut->addInlineScript($editScript);
     return $rules;
 }
Esempio n. 16
0
 function showForm()
 {
     global $wgOut, $wgUser;
     $skin = $wgUser->getSkin();
     $wgOut->setPagetitle(wfMsg("emailpage"));
     $wgOut->addWikiMsg("emailpagetext");
     if ($this->subject === "") {
         $this->subject = wfMsgExt('defemailsubject', array('content', 'parsemag'));
     }
     $titleObj = SpecialPage::getTitleFor("Emailuser");
     $action = $titleObj->getLocalURL("target=" . urlencode($this->target->getName()) . "&action=submit");
     $wgOut->addHTML(Xml::openElement('form', array('method' => 'post', 'action' => $action, 'id' => 'emailuser')) . Xml::openElement('fieldset') . Xml::element('legend', null, wfMsgExt('email-legend', 'parsemag')) . Xml::openElement('table', array('class' => 'mw-emailuser-table')) . "<tr>\n\t\t\t\t<td class='mw-label'>" . Xml::label(wfMsg('emailfrom'), 'emailfrom') . "</td>\n\t\t\t\t<td class='mw-input' id='mw-emailuser-sender'>" . $skin->link($wgUser->getUserPage(), htmlspecialchars($wgUser->getName())) . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td class='mw-label'>" . Xml::label(wfMsg('emailto'), 'emailto') . "</td>\n\t\t\t\t<td class='mw-input' id='mw-emailuser-recipient'>" . $skin->link($this->target->getUserPage(), htmlspecialchars($this->target->getName())) . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td class='mw-label'>" . Xml::label(wfMsg('emailsubject'), 'wpSubject') . "</td>\n\t\t\t\t<td class='mw-input'>" . Xml::input('wpSubject', 60, $this->subject, array('type' => 'text', 'maxlength' => 200)) . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td class='mw-label'>" . Xml::label(wfMsg('emailmessage'), 'wpText') . "</td>\n\t\t\t\t<td class='mw-input'>" . Xml::textarea('wpText', $this->text, 80, 20, array('id' => 'wpText')) . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td></td>\n\t\t\t\t<td class='mw-input'>" . Xml::checkLabel(wfMsg('emailccme'), 'wpCCMe', 'wpCCMe', $wgUser->getBoolOption('ccmeonemails')) . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td></td>\n\t\t\t\t<td class='mw-submit'>" . Xml::submitButton(wfMsg('emailsend'), array('name' => 'wpSend', 'accesskey' => 's')) . "</td>\n\t\t\t</tr>" . Xml::hidden('wpEditToken', $wgUser->editToken()) . Xml::closeElement('table') . Xml::closeElement('fieldset') . Xml::closeElement('form'));
 }
 private function showSurvey($survey, $submitMsg, $opt, $loadFromDB = false)
 {
     global $wgUser, $wgOut, $wgOptInStyleVersion;
     UsabilityInitiativeHooks::initialize();
     UsabilityInitiativeHooks::addScript('OptIn/OptIn.js', $wgOptInStyleVersion);
     UsabilityInitiativeHooks::addStyle('OptIn/OptIn.css', $wgOptInStyleVersion);
     $loaded = array();
     if ($loadFromDB) {
         $dbr = wfGetDb(DB_SLAVE);
         $res = $dbr->select('optin_survey', array('ois_question', 'ois_answer', 'ois_answer_data'), array('ois_user' => $wgUser->getID(), 'ois_type' => $opt), __METHOD__);
         foreach ($res as $row) {
             $loaded[$row->ois_question] = array($row->ois_answer, $row->ois_answer_data);
         }
     }
     $query = array('from' => $this->mOrigin, 'fromquery' => $this->mOriginQuery);
     $retval = Xml::openElement('form', array('method' => 'post', 'action' => $this->getTitle()->getLinkURL($query), 'id' => 'optin-survey'));
     $retval .= Xml::hidden('opt', $opt);
     $retval .= Xml::hidden('token', $wgUser->editToken());
     $retval .= Xml::openElement('dl');
     foreach ($survey as $id => $question) {
         $answer = isset($loaded[$id]) ? $loaded[$id][0] : null;
         $answerdata = isset($loaded[$id]) ? $loaded[$id][1] : null;
         switch ($question['type']) {
             case 'dropdown':
                 $retval .= Xml::tags('dt', null, wfMsgWikiHtml($question['question']));
                 $retval .= Xml::openElement('dd');
                 $attrs = array('id' => "survey-{$id}", 'name' => "survey-{$id}");
                 if (isset($question['other'])) {
                     $attrs['class'] = 'optin-need-other';
                 }
                 $retval .= Xml::openElement('select', $attrs);
                 foreach ($question['answers'] as $aid => $answer) {
                     $retval .= Xml::option(wfMsg($answer), $aid, $answer === $aid);
                 }
                 if (isset($question['other'])) {
                     $retval .= Xml::option(wfMsg($question['other']), 'other', $answer === 'other');
                 }
                 $retval .= Xml::closeElement('select');
                 if (isset($question['other'])) {
                     $retval .= Xml::tags('div', array(), Xml::input("survey-{$id}-other", false, $answer === 'other' ? $answerdata : false, array('class' => 'optin-other-select', 'id' => "survey-{$id}-other")));
                 }
                 $retval .= Xml::closeElement('dd');
                 break;
             case 'radios':
                 $retval .= Xml::tags('dt', null, wfMsgWikiHtml($question['question']));
                 $retval .= Xml::openElement('dd');
                 $radios = array();
                 foreach ($question['answers'] as $aid => $answer) {
                     $radios[] = Xml::radioLabel(wfMsg($answer), "survey-{$id}", $aid, "survey-{$id}-{$aid}", $answer === $aid);
                 }
                 if (isset($question['other'])) {
                     $radios[] = Xml::radioLabel(wfMsg($question['other']), "survey-{$id}", 'other', "survey-{$id}-other-radio", $answer === 'other') . '&nbsp;' . Xml::input("survey-{$id}-other", false, $answer === 'other' ? $answerdata : false, array('class' => 'optin-other-radios'));
                 }
                 $retval .= implode(Xml::element('br'), $radios);
                 $retval .= Xml::closeElement('dd');
                 break;
             case 'checkboxes':
                 $answers = explode(',', $answer);
                 $retval .= Xml::tags('dt', null, wfMsgWikiHtml($question['question']));
                 $retval .= Xml::openElement('dd');
                 $checkboxes = array();
                 foreach ($question['answers'] as $aid => $answer) {
                     $checkboxes[] = Xml::checkLabel(wfMsg($answer), "survey-{$id}[]", "survey-{$id}-{$aid}", in_array($aid, $answers, true), array('value' => $aid));
                 }
                 if (isset($question['other'])) {
                     $checkboxes[] = Xml::checkLabel(wfMsg($question['other']), "survey-{$id}[]", "survey-{$id}-other-check", in_array('other', $answers, true), array('value' => 'other')) . '&nbsp;' . Xml::input("survey-{$id}-other", false, in_array('other', $answers, true) ? $answerdata : false, array('class' => 'optin-other-checks'));
                 }
                 $retval .= implode(Xml::element('br'), $checkboxes);
                 $retval .= Xml::closeElement('dd');
                 break;
             case 'yesno':
                 $retval .= Xml::tags('dt', null, wfMsgWikiHtml($question['question']));
                 $retval .= Xml::openElement('dd');
                 $retval .= Xml::radioLabel(wfMsg('optin-survey-yes'), "survey-{$id}", 'yes', "survey-{$id}-yes", $answer === 'yes', array('class' => 'survey-yes'));
                 $retval .= Xml::element('br');
                 $retval .= Xml::radioLabel(wfMsg('optin-survey-no'), "survey-{$id}", 'no', "survey-{$id}-no", $answer === 'no', array('class' => 'survey-no'));
                 $retval .= Xml::closeElement('dd');
                 if (isset($question['ifyes'])) {
                     $retval .= Xml::openElement('blockquote', array('id' => "survey-{$id}-ifyes-row", 'class' => 'survey-ifyes'));
                     $retval .= Xml::tags('dt', null, wfMsgWikiHtml($question['ifyes']));
                     $retval .= Xml::tags('dd', null, Xml::textarea("survey-{$id}-ifyes", $answerdata ? $answerdata : ''));
                     $retval .= Xml::closeElement('blockquote');
                 }
                 if (isset($question['ifno'])) {
                     $retval .= Xml::openElement('blockquote', array('id' => "survey-{$id}-ifno-row", 'class' => 'survey-ifno'));
                     $retval .= Xml::tags('dt', null, wfMsgWikiHtml($question['ifno']));
                     $retval .= Xml::tags('dd', null, Xml::textarea("survey-{$id}-ifno", $answerdata ? $answerdata : ''));
                     $retval .= Xml::closeElement('blockquote');
                 }
                 break;
             case 'resolution':
                 if ($answerdata) {
                     list($x, $y) = explode('x', $answerdata);
                 } else {
                     $x = $y = false;
                 }
                 $retval .= Xml::tags('dt', null, wfMsgWikiHtml($question['question']));
                 $retval .= Xml::openElement('dd');
                 $retval .= Xml::input("survey-{$id}-x", 5, $x, array('class' => 'optin-resolution-x', 'id' => "survey-{$id}-x"));
                 $retval .= ' x ';
                 $retval .= Xml::input("survey-{$id}-y", 5, $y, array('class' => 'optin-resolution-y', 'id' => "survey-{$id}-y"));
                 $retval .= Xml::closeElement('dd');
                 break;
             case 'textarea':
                 $retval .= Xml::tags('dt', null, wfMsgWikiHtml($question['question']));
                 $retval .= Xml::tags('dd', null, Xml::textarea("survey-{$id}", $answerdata ? $answerdata : ''));
                 break;
         }
     }
     $retval .= Xml::tags('dt', array('class' => 'optin-survey-submit'), Xml::element('a', array('id' => 'leave'), '', false) . Xml::submitButton(wfMsg($submitMsg)));
     $retval .= Xml::closeElement('dl');
     $retval .= Xml::closeElement('form');
     $wgOut->addHTML($retval);
 }
 protected function closeForm()
 {
     global $wgOut, $wgUser, $wgRequest;
     $status = '';
     $statusOK = false;
     if ($wgRequest->wasPosted() && $wgUser->matchEditToken($wgRequest->getVal('wpcEdittoken'))) {
         global $wgLocalDatabases;
         $wiki = $wgRequest->getVal('wpcWiki');
         $dreason = $wgRequest->getVal('wpcDisplayReason');
         $lreason = $wgRequest->getVal('wpcReason');
         if (!in_array($wiki, $wgLocalDatabases)) {
             $status = wfMsgExt('closewikis-page-err-nowiki', 'parseinline');
         } else {
             $statusOK = CloseWikis::close($wiki, $dreason, $wgUser);
             if ($statusOK) {
                 $status = wfMsgExt('closewikis-page-close-success', 'parseinline');
                 $logpage = new LogPage('closewiki');
                 $logpage->addEntry('close', $this->getTitle(), $lreason, array($wiki));
             } else {
                 $status = wfMsgExt('closewikis-page-err-closed', 'parseinline');
             }
         }
     }
     $legend = wfMsgHtml('closewikis-page-close');
     // If operation was successful, empty all fields
     $defaultWiki = $statusOK ? '' : $wgRequest->getVal('wpcWiki');
     $defaultDisplayReason = $statusOK ? '' : $wgRequest->getVal('wpcDisplayReason');
     $defaultReason = $statusOK ? '' : $wgRequest->getVal('wpcReason');
     // For some reason Xml::textarea( 'blabla', null ) produces an unclosed tag
     if (!$defaultDisplayReason) {
         $defaultDisplayReason = '';
     }
     $wgOut->addHTML("<fieldset><legend>{$legend}</legend>");
     if ($status) {
         $statusStyle = $statusOK ? 'success' : 'error';
         $wgOut->addHTML("<p><strong class=\"{$statusStyle}\">{$status}</strong></p>");
     }
     $wgOut->addHTML('<form method="post" action="' . htmlspecialchars($this->getTitle()->getLocalURL()) . '">');
     $form = array();
     $form['closewikis-page-close-wiki'] = $this->buildSelect(CloseWikis::getUnclosedList(), 'wpcWiki', $defaultWiki);
     $form['closewikis-page-close-dreason'] = Xml::textarea('wpcDisplayReason', $defaultDisplayReason);
     $form['closewikis-page-close-reason'] = Xml::input('wpcReason', false, $defaultReason);
     $wgOut->addHTML(Xml::buildForm($form, 'closewikis-page-close-submit'));
     $wgOut->addHTML(Html::hidden('wpcEdittoken', $wgUser->editToken()));
     $wgOut->addHTML("</form></fieldset>");
 }
Esempio n. 19
0
 function buildConsequenceSelector($action, $set, $parameters)
 {
     global $wgAbuseFilterAvailableActions;
     if (!in_array($action, $wgAbuseFilterAvailableActions)) {
         return;
     }
     $readOnlyAttrib = array();
     $cbReadOnlyAttrib = array();
     // For checkboxes
     if (!$this->canEdit()) {
         $readOnlyAttrib['readonly'] = 'readonly';
         $cbReadOnlyAttrib['disabled'] = 'disabled';
     }
     switch ($action) {
         case 'throttle':
             $throttleSettings = Xml::checkLabel(wfMsg('abusefilter-edit-action-throttle'), 'wpFilterActionThrottle', "mw-abusefilter-action-checkbox-{$action}", $set, array('class' => 'mw-abusefilter-action-checkbox') + $cbReadOnlyAttrib);
             $throttleFields = array();
             if ($set) {
                 array_shift($parameters);
                 $throttleRate = explode(',', $parameters[0]);
                 $throttleCount = $throttleRate[0];
                 $throttlePeriod = $throttleRate[1];
                 $throttleGroups = implode("\n", array_slice($parameters, 1));
             } else {
                 $throttleCount = 3;
                 $throttlePeriod = 60;
                 $throttleGroups = "user\n";
             }
             $throttleFields['abusefilter-edit-throttle-count'] = Xml::input('wpFilterThrottleCount', 20, $throttleCount, $readOnlyAttrib);
             $throttleFields['abusefilter-edit-throttle-period'] = wfMsgExt('abusefilter-edit-throttle-seconds', array('parseinline', 'replaceafter'), array(Xml::input('wpFilterThrottlePeriod', 20, $throttlePeriod, $readOnlyAttrib)));
             $throttleFields['abusefilter-edit-throttle-groups'] = Xml::textarea('wpFilterThrottleGroups', $throttleGroups . "\n", 40, 5, $readOnlyAttrib);
             $throttleSettings .= Xml::tags('div', array('id' => 'mw-abusefilter-throttle-parameters'), Xml::buildForm($throttleFields));
             return $throttleSettings;
         case 'flag':
             $checkbox = Xml::checkLabel(wfMsg('abusefilter-edit-action-flag'), 'wpFilterActionFlag', "mw-abusefilter-action-checkbox-{$action}", true, array('disabled' => '1', 'class' => 'mw-abusefilter-action-checkbox'));
             return Xml::tags('p', null, $checkbox);
         case 'warn':
             $output = '';
             $checkbox = Xml::checkLabel(wfMsg('abusefilter-edit-action-warn'), 'wpFilterActionWarn', "mw-abusefilter-action-checkbox-{$action}", $set, array('class' => 'mw-abusefilter-action-checkbox') + $cbReadOnlyAttrib);
             $output .= Xml::tags('p', null, $checkbox);
             $warnMsg = empty($set) ? 'abusefilter-warning' : $parameters[0];
             $warnFields['abusefilter-edit-warn-message'] = $this->getExistingSelector($warnMsg);
             $warnFields['abusefilter-edit-warn-other-label'] = Xml::input('wpFilterWarnMessageOther', 45, $warnMsg ? $warnMsg : 'abusefilter-warning-', array('id' => 'mw-abusefilter-warn-message-other') + $cbReadOnlyAttrib);
             $previewButton = Xml::element('input', array('type' => 'button', 'id' => 'mw-abusefilter-warn-preview-button', 'value' => wfMsg('abusefilter-edit-warn-preview')));
             $editButton = Xml::element('input', array('type' => 'button', 'id' => 'mw-abusefilter-warn-edit-button', 'value' => wfMsg('abusefilter-edit-warn-edit')));
             $previewHolder = Xml::element('div', array('id' => 'mw-abusefilter-warn-preview'), '');
             $warnFields['abusefilter-edit-warn-actions'] = Xml::tags('p', null, "{$previewButton} {$editButton}") . "\n{$previewHolder}";
             $output .= Xml::tags('div', array('id' => 'mw-abusefilter-warn-parameters'), Xml::buildForm($warnFields));
             return $output;
         case 'tag':
             if ($set) {
                 $tags = $parameters;
             } else {
                 $tags = array();
             }
             $output = '';
             $checkbox = Xml::checkLabel(wfMsg('abusefilter-edit-action-tag'), 'wpFilterActionTag', "mw-abusefilter-action-checkbox-{$action}", $set, array('class' => 'mw-abusefilter-action-checkbox') + $cbReadOnlyAttrib);
             $output .= Xml::tags('p', null, $checkbox);
             $tagFields['abusefilter-edit-tag-tag'] = Xml::textarea('wpFilterTags', implode("\n", $tags), 40, 5, $readOnlyAttrib);
             $output .= Xml::tags('div', array('id' => 'mw-abusefilter-tag-parameters'), Xml::buildForm($tagFields));
             return $output;
         default:
             $message = 'abusefilter-edit-action-' . $action;
             $form_field = 'wpFilterAction' . ucfirst($action);
             $status = $set;
             $thisAction = Xml::checkLabel(wfMsg($message), $form_field, "mw-abusefilter-action-checkbox-{$action}", $status, array('class' => 'mw-abusefilter-action-checkbox') + $cbReadOnlyAttrib);
             $thisAction = Xml::tags('p', null, $thisAction);
             return $thisAction;
     }
 }
	/**
	 * Create the html body and (depending on the GET variables) creates the page.
	 */
	function execute( $par ) {
		global $wgRequest, $wgOut, $wgScript;

		$this->setHeaders();

		# Get request data from, e.g.
		$action = $wgRequest->getText( 'action' );
		$refname = htmlentities( $wgRequest->getText( 'refname' ) );
		$author1 = htmlentities( $wgRequest->getText( 'author1' ), ENT_COMPAT, "UTF-8" );
		$author2 = htmlentities( $wgRequest->getText( 'author2' ), ENT_COMPAT, "UTF-8" );
		$author3 = htmlentities( $wgRequest->getText( 'author3' ), ENT_COMPAT, "UTF-8" );
		$author4 = htmlentities( $wgRequest->getText( 'author4' ), ENT_COMPAT, "UTF-8" );
		$author5 = htmlentities( $wgRequest->getText( 'author5' ), ENT_COMPAT, "UTF-8" );

		$surname1 = htmlentities( $wgRequest->getText( 'surname1' ), ENT_COMPAT, "UTF-8" );
		$surname2 = htmlentities( $wgRequest->getText( 'surname2' ), ENT_COMPAT, "UTF-8" );
		$surname3 = htmlentities( $wgRequest->getText( 'surname3' ), ENT_COMPAT, "UTF-8" );
		$surname4 = htmlentities( $wgRequest->getText( 'surname4' ), ENT_COMPAT, "UTF-8" );
		$surname5 = htmlentities( $wgRequest->getText( 'surname5' ), ENT_COMPAT, "UTF-8" );

		$pmid = htmlentities( $wgRequest->getText( 'pmid' ), ENT_COMPAT, "UTF-8" );

		$articletitle = htmlentities( $wgRequest->getText( 'articletitle' ) );
		$journal = htmlentities( $wgRequest->getText( 'journal' ) );
		$volume = htmlentities( $wgRequest->getText( 'volume' ) );
		$pages = htmlentities( $wgRequest->getText( 'pages' ) );
		$year = htmlentities( $wgRequest->getText( 'year' ) );

		$cat1 = htmlentities( $wgRequest->getText( 'cat1' ) );
		$cat2 = htmlentities( $wgRequest->getText( 'cat2' ) );
		$cat3 = htmlentities( $wgRequest->getText( 'cat3' ) );
		$cat4 = htmlentities( $wgRequest->getText( 'cat4' ) );

		$reqfilled = strlen( $author1 ) && strlen( $articletitle ) && strlen( $journal ) && strlen( $year ) && strlen( $refname );
		if ( $action != "submit" || !$reqfilled ) {
			if ( strlen( $pmid ) ) {
				$result = RefSearch::query_pmid( $pmid );
				$articletitle = $result["title"];
				$journal      = $result["journal"];
				$volume       = $result["volume"];
				$pages        = $result["pages"];
				$year         = $result["year"];
				$auths        = $result["authors"];
				if ( isset( $auths[0] ) ) {
					$author1   =  $auths[0][0];
					$surname1  =  $auths[0][1];
				}
				if ( isset( $auths[1] ) ) {
					$author2   =  $auths[1][0];
					$surname2  =  $auths[1][1];
				}
				if ( isset( $auths[2] ) ) {
					$author3   =  $auths[2][0];
					$surname3  =  $auths[2][1];
				}
				if ( isset( $auths[3] ) ) {
					$author4   =  $auths[3][0];
					$surname4  =  $auths[3][1];
				}
				if ( isset( $auths[4] ) ) {
					$author5   =  $auths[4][0];
					$surname5  =  $auths[4][1];
				}
			}

			# Output
			$wgOut->addHTML(
				Xml::fieldset( wfMsg( self::MSG . 'refcreate_legend' ) ) .
				Xml::openElement( 'form', array( 'action' => $wgScript, 'id' => 'mw_create-ref-form' ) ) .
				Html::Hidden( 'title', $this->getTitle()->getPrefixedText() ) .
				Html::Hidden( 'action', 'submit' ) .
				Xml::openElement( 'table', array( 'id' => 'mw_create-ref-table' ) ) .
				Xml::openElement( 'tbody' ) );

			$wgOut->addHTML(
				Xml::openElement( 'tr' ) .
				Xml::openElement( 'td', array( 'class' => 'mw-label' ) ) .
				Xml::element( 'label', array( 'for' => 'inp_pastearea' ), wfMsg( self::MSG . 'label_workspace' ) . ":" ) .
				Xml::closeElement( 'td' ) .
				Xml::openElement( 'td' ) .
				Xml::textarea( 'inp_pastearea', '', 20, 5, array( 'oninput' => 'autoPopulateRefFields()' ) ) .
				Xml::closeElement( 'td' ) .
				Xml::closeElement( 'tr' ) );

			self::addTableRow( $wgOut, "pmid", $pmid, 'PMID', 15 );

			self::add2ColTableRow( $wgOut, 'author1', 'surname1', $author1, $surname1,
				wfMsg( self::MSG . 'label_authorforename', '1' ), wfMsg( self::MSG . 'label_authorsurname', '1' ) );
			self::add2ColTableRow( $wgOut, 'author2', 'surname2', $author2, $surname2,
				wfMsg( self::MSG . 'label_authorforename', '2' ), wfMsg( self::MSG . 'label_authorsurname', '2' ) );
			self::add2ColTableRow( $wgOut, 'author3', 'surname3', $author3, $surname3,
				wfMsg( self::MSG . 'label_authorforename', '3' ), wfMsg( self::MSG . 'label_authorsurname', '3' ) );
			self::add2ColTableRow( $wgOut, 'author4', 'surname4', $author4, $surname4,
				wfMsg( self::MSG . 'label_authorforename', '4' ), wfMsg( self::MSG . 'label_authorsurname', '4' ) );
			self::add2ColTableRow( $wgOut, 'author5', 'surname5', $author5, $surname5,
				wfMsg( self::MSG . 'label_authorforename', '5' ), wfMsg( self::MSG . 'label_authorsurname', '5' ) );

			self::addTableRow( $wgOut, "articletitle", $articletitle, wfMsg( self::MSG . 'title' ) );
			self::addTableRow( $wgOut, "journal", $journal, wfMsg( self::MSG . 'journal' ) );
			self::addTableRow( $wgOut, "pages", $pages, wfMsg( self::MSG . 'pages' ) );
			self::addTableRow( $wgOut, "year", $year, wfMsg( self::MSG . 'year' ) );
			self::addTableRow( $wgOut, "refname", $refname, wfMsg( self::MSG . 'refname' ) );
			self::addTableRow( $wgOut, "cat1", $cat1, wfMsg( self::MSG . 'category', '1' ) );
			self::addTableRow( $wgOut, "cat2", $cat2, wfMsg( self::MSG . 'category', '2' ) );
			self::addTableRow( $wgOut, "cat3", $cat3, wfMsg( self::MSG . 'category', '3' ) );
			self::addTableRow( $wgOut, "cat4", $cat4, wfMsg( self::MSG . 'category', '4' ) );

			$wgOut->addHTML(
				Xml::openElement( 'tr' ) .
				Xml::openElement( 'td', array( 'class' => 'mw-submit' ) ) .
				Xml::element( 'input', array( 'value' => wfMsg( self::MSG . 'create' ), 'type' => 'submit' ) ) .
				Xml::closeElement( 'td' ) .
				Xml::closeElement( 'tr' ) .
				Xml::closeElement( 'tbody' ) .
				Xml::closeElement( 'table' ) .
				Xml::closeElement( 'form' ) .
				Xml::closeElement( 'fieldset' ) );
		}
		else
		{
			global $wgRefHelperCiteTemplate, $wgRefHelperPageTemplate, $wgRefHelperCiteNS;
			$db = wfGetDB( DB_MASTER );

			$citeTitle = null;
			if ( strlen( $wgRefHelperCiteNS ) ) $citeTitle = Title::newFromText( "$wgRefHelperCiteNS:$refname" );
			$pageTitle = Title::newFromText( $refname );


			$paramtext = '';
			$paramtext .= "| first1 = $author1\n";
			$paramtext .= "| last1 = $surname1\n";

			if ( strlen( $author2 ) || strlen( $surname2 ) ) {
				$paramtext .= "| first2 = $author2\n";
				$paramtext .= "| last2 = $surname2\n";
			}
			if ( strlen( $author3 ) || strlen( $surname3 ) ) {
				$paramtext .= "| first3 = $author3\n";
				$paramtext .= "| last3 = $surname3\n";
			}
			if ( strlen( $author4 ) || strlen( $surname4 ) ) {
				$paramtext .= "| first4 = $author4\n";
				$paramtext .= "| last4 = $surname4\n";
			}
			if ( strlen( $author5 ) || strlen( $surname5 ) ) {
				$paramtext .= "| first5 = $author5\n";
				$paramtext .= "| last5 = $surname5\n";
			}

			$paramtext .= "| refname = $refname\n";
			$paramtext .= "| articletitle = $articletitle\n";
			$paramtext .= "| titlelink = [[$refname|$articletitle]]\n";
			$paramtext .= "| journal = $journal\n";
			$paramtext .= "| volume = $volume\n";
			$paramtext .= "| pages = $pages\n";
			$paramtext .= "| pmid = $pmid\n";
			$paramtext .= "| year = $year\n";
			$paramtext .= "| lt = <\n"; // can be used to allow templates to create pages with onlyinclude, etc.
			$paramtext .= "| categories = ";
			if ( strlen( $cat1 ) ) $paramtext .= "[[Category:$cat1]]\n";
			if ( strlen( $cat2 ) ) $paramtext .= "[[Category:$cat2]]\n";
			if ( strlen( $cat3 ) ) $paramtext .= "[[Category:$cat3]]\n";
			if ( strlen( $cat4 ) ) $paramtext .= "[[Category:$cat4]]\n";

			if ( $citeTitle->exists() == false ) {
				$newcontent = '{{' . "$wgRefHelperCiteTemplate\n$paramtext}}\n";

				$citePage = new Article( $citeTitle );
				$citePage->doEdit( $newcontent, wfMsg( self::MSG . 'refcreate_autocomment' ) );
				$rev_id = $citePage->insertOn( $db );

				$wgOut->addWikiText( wfMsg( self::MSG . 'refcreate_success', array( "$wgRefHelperCiteNS:$refname" ) ) );
			}
			else {
				$wgOut->addWikiText( wfMsg( self::MSG . 'refcreate_failure', array( "$wgRefHelperCiteNS:$refname" ) ) );
			}
			if ( $pageTitle->exists() == false ) {
				$newcontent = '{{' . "$wgRefHelperPageTemplate\n$paramtext}}\n";

				$newPage = new Article( $pageTitle );
				$newPage->doEdit( $newcontent, wfMsg( self::MSG . 'refcreate_autocomment' ) );
				$rev_id = $newPage->insertOn( $db );

				$wgOut->addWikiText( wfMsg( self::MSG . 'refcreate_success', array( $refname ) ) );
			}
			else {
				$wgOut->addWikiText( wfMsg( self::MSG . 'refcreate_failure', array( $refname ) ) );
			}

			$wgOut->addWikiText( '[[Special:RefHelper|' . wfMsg( self::MSG . 'refcreate_another' ) . ']]' );
		}
	}
	/**
	 * Execute the subpage.
	 * @param $params array Array of subpage parameters.
	 */
	function execute( $params ) {
		global $wgOut, $wgUser, $wgLang, $wgRequest;

		if ( !count( $params ) ) {
			$wgOut->addWikiMsg( 'securepoll-too-few-params' );
			return;
		}
		
		$electionId = intval( $params[0] );
		$this->election = $this->context->getElection( $electionId );
		if ( !$this->election ) {
			$wgOut->addWikiMsg( 'securepoll-invalid-election', $electionId );
			return;
		}
		$this->initLanguage( $wgUser, $this->election );
		$wgOut->setPageTitle( wfMsg( 'securepoll-translate-title', 
			$this->election->getMessage( 'title' ) ) );

		$this->isAdmin = $this->election->isAdmin( $wgUser );

		$primary = $this->election->getLanguage();
		$secondary = $wgRequest->getVal( 'secondary_lang' );
		if ( $secondary !== null ) {
			# Language selector submitted: redirect to the subpage
			$wgOut->redirect( $this->getTitle( $secondary )->getFullUrl() );
			return;
		}

		if ( isset( $params[1] ) ) {
			$secondary = $params[1];
		} else {
			# No language selected, show the selector
			$this->showLanguageSelector( $primary );
			return;
		}

		$secondary = $params[1];
		$primaryName = $wgLang->getLanguageName( $primary );
		$secondaryName = $wgLang->getLanguageName( $secondary );
		if ( strval( $secondaryName ) === '' ) {
			$wgOut->addWikiMsg( 'securepoll-invalid-language', $secondary );
			$this->showLanguageSelector( $primary );
			return;
		}

		# Set a subtitle to return to the language selector
		$this->parent->setSubtitle( array( 
			$this->getTitle(),
			wfMsg( 'securepoll-translate-title', $this->election->getMessage( 'title' ) ) ) );

		# If the request was posted, do the submit
		if ( $wgRequest->wasPosted() && $wgRequest->getVal( 'action' ) == 'submit' ) {
			$this->doSubmit( $secondary );
			return;
		}

		# Show the form
		$action = $this->getTitle( $secondary )->getLocalUrl( 'action=submit' );
		$s = 
			Xml::openElement( 'form', array( 'method' => 'post', 'action' => $action ) ) .
			'<table class="mw-datatable TablePager securepoll-trans-table">' .
			'<col class="securepoll-col-trans-id" width="1*"/>' .
			'<col class="securepoll-col-primary" width="30%"/>' .
			'<col class="securepoll-col-secondary"/>' .
			'<tr><th>' . wfMsgHtml( 'securepoll-header-trans-id' ) . '</th>' . 
			'<th>' . htmlspecialchars( $primaryName ) . '</th>' .
			'<th>' . htmlspecialchars( $secondaryName ) . '</th></tr>';
		$entities = array_merge( array( $this->election ), $this->election->getDescendants() );
		foreach ( $entities as $entity ) {
			$entityName = $entity->getType() . '(' . $entity->getId() . ')';
			foreach ( $entity->getMessageNames() as $messageName ) {
				$controlName = 'trans_' . $entity->getId() . '_' . $messageName;
				$primaryText = $entity->getRawMessage( $messageName, $primary );
				$secondaryText = $entity->getRawMessage( $messageName, $secondary );
				$attribs = array( 'class' => 'securepoll-translate-box' );
				if ( !$this->isAdmin ) {
					$attribs['readonly'] = '1';
				}
				$s .= '<tr><td>' . htmlspecialchars( "$entityName/$messageName" ) . "</td>\n" .
					'<td>' . nl2br( htmlspecialchars( $primaryText ) ) . '</td>' .
					'<td>' . 
					Xml::textarea( $controlName, $secondaryText, 40, 3, $attribs ) .
					"</td></tr>\n";
			}
		}
		$s .= '</table>';
		if ( $this->isAdmin ) {
			$s .= 
			'<p style="text-align: center;">' . 
			Xml::submitButton( wfMsg( 'securepoll-submit-translate' ) ) .
			"</p>";
		}
		$s .= "</form>\n";
		$wgOut->addHTML( $s );
	}
Esempio n. 22
0
 protected function showTextbox($content, $name, $attribs = array())
 {
     global $wgOut, $wgUser;
     $wikitext = $this->safeUnicodeOutput($content);
     if ($wikitext !== '') {
         // Ensure there's a newline at the end, otherwise adding lines
         // is awkward.
         // But don't add a newline if the ext is empty, or Firefox in XHTML
         // mode will show an extra newline. A bit annoying.
         $wikitext .= "\n";
     }
     $attribs['accesskey'] = ',';
     $attribs['id'] = $name;
     if ($wgUser->getOption('editwidth')) {
         $attribs['style'] = 'width: 100%';
     }
     $wgOut->addHTML(Xml::textarea($name, $wikitext, $wgUser->getIntOption('cols'), $wgUser->getIntOption('rows'), $attribs));
 }
 function showUsernameForm()
 {
     if (is_array($this->mUserNames)) {
         $this->mUserNames = implode("\n", $this->mUserNames);
     }
     $form = Xml::tags('form', array('method' => 'post', 'action' => $this->getPageTitle()->getLocalUrl()), Xml::tags('fieldset', array(), Xml::element('legend', array(), $this->msg('centralauth-admin-manage')->text()) . Html::hidden('wpMethod', 'search') . Xml::element('p', array(), $this->msg('centralauth-admin-multi-username')->text()) . Xml::textarea('wpTarget', $this->mPrefixSearch ? '' : $this->mUserNames, 25, 20) . Xml::element('p', array(), $this->msg('centralauth-admin-multi-searchprefix')->text()) . Html::input('wpSearchTarget', $this->mPrefixSearch) . Xml::tags('p', array(), Xml::submitButton($this->msg('centralauth-admin-lookup-ro')->text()))));
     $this->getOutput()->addHTML($form);
 }
Esempio n. 24
0
 public function change($cid)
 {
     global $wgOut, $wgUser;
     $wgOut->setPagetitle(wfMsg('poll-title-change'));
     $dbr = wfGetDB(DB_SLAVE);
     $query = $dbr->select('poll', 'question, alternative_1, alternative_2, alternative_3, alternative_4, alternative_5, alternative_6, creater, dis', array('id' => $cid));
     while ($row = $dbr->fetchObject($query)) {
         $question = $row->question;
         $alternative_1 = $row->alternative_1;
         $alternative_2 = $row->alternative_2;
         $alternative_3 = $row->alternative_3;
         $alternative_4 = $row->alternative_4;
         $alternative_5 = $row->alternative_5;
         $alternative_6 = $row->alternative_6;
         $creater = $row->creater;
         $dis = $row->dis;
     }
     if (!isset($question) or $question == "") {
         $wgOut->addWikiMsg('poll-invalid-id');
         $wgOut->addHtml('<a href="' . $this->getTitle()->getFullURL('action=list') . '">' . wfMsg('poll-back') . '</a>');
         return;
     }
     if ($wgUser->getName() != $creater) {
         $wgOut->addWikiMsg('poll-change-right-error');
         $wgOut->addHtml('<a href="' . $this->getTitle()->getFullURL('action=list') . '">' . wfMsg('poll-back') . '</a>');
     } else {
         $wgOut->addHtml(Xml::openElement('form', array('method' => 'post', 'action' => $this->getTitle()->getFullURL('action=submit&id=' . $cid))));
         $wgOut->addHtml(Xml::openElement('table'));
         $wgOut->addHtml('<tr><td>' . wfMsg('poll-question') . ':</td><td>' . Xml::input('question', false, $question) . '</td></tr>');
         $wgOut->addHtml('<tr><td>' . wfMsg('poll-alternative') . ' 1:</td><td>' . Xml::input('poll_alternative_1', false, $alternative_1) . '</td></tr>');
         $wgOut->addHtml('<tr><td>' . wfMsg('poll-alternative') . ' 2:</td><td>' . Xml::input('poll_alternative_2', false, $alternative_2) . '</td></tr>');
         $wgOut->addHtml('<tr><td>' . wfMsg('poll-alternative') . ' 3:</td><td>' . Xml::input('poll_alternative_3', false, $alternative_3) . '</td></tr>');
         $wgOut->addHtml('<tr><td>' . wfMsg('poll-alternative') . ' 4:</td><td>' . Xml::input('poll_alternative_4', false, $alternative_4) . '</td></tr>');
         $wgOut->addHtml('<tr><td>' . wfMsg('poll-alternative') . ' 5:</td><td>' . Xml::input('poll_alternative_5', false, $alternative_5) . '</td></tr>');
         $wgOut->addHtml('<tr><td>' . wfMsg('poll-alternative') . ' 6:</td><td>' . Xml::input('poll_alternative_6', false, $alternative_6) . '</td></tr>');
         $wgOut->addHtml('<tr><td>' . wfMsg('poll-dis') . ':</td><td>' . Xml::textarea('dis', $dis) . '</td></tr>');
         $wgOut->addHtml('<tr><td>' . Xml::submitButton(wfMsg('poll-submit')) . '' . Html::Hidden('type', 'change') . '</td></tr>');
         $wgOut->addHtml(Xml::closeElement('table'));
         $wgOut->addHtml(Xml::closeElement('form'));
     }
 }
Esempio n. 25
0
 /**
  * @covers Xml::textarea
  */
 public function testTextareaAttribs()
 {
     $this->assertEquals('<textarea name="name" id="name" cols="20" rows="10">&lt;txt&gt;</textarea>', Xml::textarea('name', '<txt>', 20, 10), 'textarea() with custom attribs');
 }
 function formatConfigInput($var, $type, $wiki = '')
 {
     global $wgConfigure, $wgRequest;
     $val = $wgConfigure->getSetting($wiki, $var);
     $descr = wfMsg('configurewmf-var-' . strtolower($var));
     $descrlabel = Xml::label($descr, $var);
     $r = "<tr><td class='mw-label'>{$descrlabel}:</td>\n\n<td class='mw-input'>";
     switch ($type) {
         case 'string':
             $r .= Xml::input($var, false, $val);
             break;
         case 'bool':
             $r .= Xml::check($var, $val);
             break;
         case 'stringarray':
             $val = $val ? implode("\n", $val) : '';
             $r .= Xml::textarea($var, $val);
             break;
         case 'logo':
             global $wgConfigureStdlogo;
             $isstd = $val == $wgConfigureStdlogo;
             $r .= '<div>' . Xml::radioLabel(wfMsgHtml('configurewmf-stdlogo'), $var, 'stdlogo', 'wgLogoStdlogo', $isstd) . '</div>';
             $r .= '<div>' . Xml::radioLabel(wfMsgHtml('configurewmf-otherlogo'), $var, 'other', 'wgLogoOther', !$isstd) . '&#160;' . Xml::input("{$var}Other", false, $isstd ? '' : $val) . '</div>';
             break;
         case 'groupperms':
             $groups = $wgConfigure->getGroupPermissions($wiki);
             $group = $wgRequest->getVal('group');
             $perms = isset($groups[$group]) ? $groups[$group] : array();
             $rights = User::getAllRights();
             sort($rights);
             $checkboxes = array();
             foreach ($rights as $right) {
                 $label = wfMsgExt('configurewmf-permission', array('parseinline'), User::getRightDescription($right), $right);
                 $checkboxes[] = Xml::checkLabel($label, "{$var}-{$right}", "{$var}-{$right}", @$perms[$right]);
             }
             $firstCol = round(count($checkboxes) / 2);
             $checkboxes1 = array_slice($checkboxes, 0, $firstCol);
             $checkboxes2 = array_slice($checkboxes, $firstCol);
             $r .= '<table><tbody><tr><td><ul><li>' . implode('</li><li>', $checkboxes1) . '</li></ul></td><td><ul><li>' . implode('</li><li>', $checkboxes2) . '</li></ul></td></tr></tbody></table>';
             $r .= Html::Hidden('group', $group);
             break;
         case 'grouplist':
             $targetgroup = $wgRequest->getVal('group');
             $r .= '<ul>';
             foreach (array_keys($wgConfigure->getGroupPermissions($wiki)) as $group) {
                 if (in_array($group, $wgConfigure->getSetting($wiki, 'wgImplicitGroups'))) {
                     continue;
                 }
                 $checked = isset($val[$targetgroup]) ? in_array($group, $val[$targetgroup]) : false;
                 $checkbox = Xml::checkLabel(User::getGroupName($group), "{$var}-{$group}", "{$var}-{$group}", $checked);
                 $r .= "<li>{$checkbox}</li>\n";
             }
             $r .= '</ul>';
             break;
     }
     return $r . '</td></tr>';
 }
 /**
  * Generate a nice little box with a heading for output
  *
  * @param string $output Wiki text output
  * @param string $heading
  * @return string
  */
 private function makeOutput($output, $heading = 'expand_templates_output')
 {
     $out = "<h2>" . $this->msg($heading)->escaped() . "</h2>\n";
     $out .= Xml::textarea('output', $output, 10, 10, array('id' => 'output', 'readonly' => 'readonly'));
     return $out;
 }
	/**
	 * Generates and returns a "post new comment" form for the user to fill in
	 * and submit.
	 *
	 * @param $parent If provided, generates a "post reply" form to reply to
	 *   the given comment.
	 */
	public function getPostCommentForm( $parent = null ) {
		global $wgUser, $wgTitle, $wgScript, $wgRequest;
		global $wgWikilogModerateAnonymous;

		$comment = $this->mPostedComment;
		$opts = $this->mFormOptions;

		$preview = '';
		$pid = $parent ? $parent->mID : null;
		if ( $comment && $comment->mParent == $pid ) {
			$check = $this->validateComment( $comment );
			if ( $check ) {
				$preview = Xml::wrapClass( wfMsg( $check ), 'mw-warning', 'div' );
			} else {
				$preview = $this->mFormatter->formatComment( $this->mPostedComment );
			}
			$header = wfMsgHtml( 'wikilog-form-preview' );
			$preview = "<b>{$header}</b>{$preview}<hr/>";
		}

		$form =
			Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) .
			Html::hidden( 'action', 'wikilog' ) .
			Html::hidden( 'wpEditToken', $wgUser->editToken() ) .
			( $parent ? Html::hidden( 'wlParent', $parent->mID ) : '' );

		$fields = array();

		if ( $wgUser->isLoggedIn() ) {
			$fields[] = array(
				wfMsg( 'wikilog-form-name' ),
				$this->mSkin->userLink( $wgUser->getId(), $wgUser->getName() )
			);
		} else {
			$loginTitle = SpecialPage::getTitleFor( 'Userlogin' );
			$loginLink = $this->mSkin->link( $loginTitle,
				wfMsgHtml( 'loginreqlink' ), array(),
				array( 'returnto' => $wgTitle->getPrefixedUrl() )
			);
			$message = wfMsg( 'wikilog-posting-anonymously', $loginLink );
			$fields[] = array(
				Xml::label( wfMsg( 'wikilog-form-name' ), 'wl-name' ),
				Xml::input( 'wlAnonName', 25, $opts->consumeValue( 'wlAnonName' ),
					array( 'id' => 'wl-name', 'maxlength' => 255 ) ) .
					"<p>{$message}</p>"
			);
		}

		$autofocus = $parent ? array( 'autofocus' => 'autofocus' ) : array();
		$fields[] = array(
			Xml::label( wfMsg( 'wikilog-form-comment' ), 'wl-comment' ),
			Xml::textarea( 'wlComment', $opts->consumeValue( 'wlComment' ),
				40, 5, array( 'id' => 'wl-comment' ) + $autofocus )
		);

		if ( $this->mCaptchaForm ) {
			$fields[] = array( '', $this->mCaptchaForm );
		}

		if ( $wgWikilogModerateAnonymous && $wgUser->isAnon() ) {
			$fields[] = array( '', wfMsg( 'wikilog-anonymous-moderated' ) );
		}

		$fields[] = array( '',
			Xml::submitbutton( wfMsg( 'wikilog-submit' ), array( 'name' => 'wlActionCommentSubmit' ) ) . WL_NBSP .
			Xml::submitbutton( wfMsg( 'wikilog-preview' ), array( 'name' => 'wlActionCommentPreview' ) )
		);

		$form .= WikilogUtils::buildForm( $fields );

		foreach ( $opts->getUnconsumedValues() as $key => $value ) {
			$form .= Html::hidden( $key, $value );
		}

		$form = Xml::tags( 'form', array(
			'action' => "{$wgScript}#wl-comment-form",
			'method' => 'post'
		), $form );

		$msgid = ( $parent ? 'wikilog-post-reply' : 'wikilog-post-comment' );
		return Xml::fieldset( wfMsg( $msgid ), $preview . $form,
			array( 'id' => 'wl-comment-form' ) ) . "\n";
	}
Esempio n. 29
0
 /**
  * @param $subpage
  * @param $error bool
  * @param $name
  * @param $type
  * @param $wikis
  * @param $reason
  */
 function buildSetView($subpage, $error = false, $name = null, $type = null, $wikis = null, $reason = null)
 {
     global $wgLocalDatabases;
     $this->getOutput()->setSubtitle(wfMsgExt('centralauth-editset-subtitle', 'parseinline'));
     $set = $subpage || $subpage === '0' ? WikiSet::newFromID($subpage) : null;
     if (!$name) {
         $name = $set ? $set->getName() : '';
     }
     if (!$type) {
         $type = $set ? $set->getType() : WikiSet::OPTIN;
     }
     if (!$wikis) {
         $wikis = implode("\n", $set ? $set->getWikisRaw() : array());
     } else {
         $wikis = implode("\n", $wikis);
     }
     $url = SpecialPage::getTitleFor('WikiSets', $subpage)->getLocalUrl();
     if ($this->mCanEdit) {
         $legend = wfMsgHtml('centralauth-editset-legend-' . ($set ? 'edit' : 'new'), $name);
     } else {
         $legend = wfMsgHtml('centralauth-editset-legend-view', $name);
     }
     $this->getOutput()->addHTML("<fieldset><legend>{$legend}</legend>");
     if ($set) {
         $groups = $set->getRestrictedGroups();
         if ($groups) {
             $usage = "<ul>\n";
             foreach ($groups as $group) {
                 $usage .= "<li>" . wfMsgExt('centralauth-editset-grouplink', 'parseinline', $group) . "</li>\n";
             }
             $usage .= "</ul>";
         } else {
             $usage = wfMsgExt('centralauth-editset-nouse', 'parse');
         }
         $sortedWikis = $set->getWikisRaw();
         sort($sortedWikis);
     } else {
         $usage = '';
         $sortedWikis = array();
     }
     # Make an array of the opposite list of wikis
     # (all databases *excluding* the defined ones)
     $restWikis = array();
     foreach ($wgLocalDatabases as $wiki) {
         if (!in_array($wiki, $sortedWikis)) {
             $restWikis[] = $wiki;
         }
     }
     sort($restWikis);
     if ($this->mCanEdit) {
         if ($error) {
             $this->getOutput()->addHTML("<strong class='error'>{$error}</strong>");
         }
         $this->getOutput()->addHTML("<form action='{$url}' method='post'>");
         $form = array();
         $form['centralauth-editset-name'] = Xml::input('wpName', false, $name);
         if ($usage) {
             $form['centralauth-editset-usage'] = $usage;
         }
         $form['centralauth-editset-type'] = $this->buildTypeSelector('wpType', $type);
         $form['centralauth-editset-wikis'] = Xml::textarea('wpWikis', $wikis);
         $form['centralauth-editset-restwikis'] = Xml::textarea('wpRestWikis', implode("\n", $restWikis), 40, 5, array('readonly' => true));
         $form['centralauth-editset-reason'] = Xml::input('wpReason', 50, $reason);
         $this->getOutput()->addHTML(Xml::buildForm($form, 'centralauth-editset-submit'));
         $edittoken = Html::hidden('wpEditToken', $this->getUser()->getEditToken());
         $this->getOutput()->addHTML("<p>{$edittoken}</p></form></fieldset>");
     } else {
         $form = array();
         $form['centralauth-editset-name'] = htmlspecialchars($name);
         $form['centralauth-editset-usage'] = $usage;
         $form['centralauth-editset-type'] = wfMsg("centralauth-editset-{$type}");
         $form['centralauth-editset-wikis'] = self::buildTableByList($sortedWikis, 3, array('width' => '100%'));
         $form['centralauth-editset-restwikis'] = self::buildTableByList($restWikis, 3, array('width' => '100%'));
         $this->getOutput()->addHTML(Xml::buildForm($form));
     }
 }
	public static function render( $question, $config, $answer, $answerData ) {
		$html = Xml::tags( 'dt', null, wfMsgWikiHtml( $config['question'] ) );
		$html .= Xml::tags(
			'dd', null, Xml::textarea( "prefswitch-survey-{$question}", $answerData ? $answerData : '' )
		);
		return $html;
	}