/**
	 * Get rating tier dropdown select
	 * @param int $selected, selected tier
	 * @return string
	 */	
	 public static function getRatingTierMenu( $selected = '' ) {
		$s  = "<label for='wpRatingTier'>" . wfMsgHtml('readerfeedback-tierfilter') . "</label>&#160;";
		$s .= Xml::openElement( 'select', array('name' => 'ratingtier', 'id' => 'wpRatingTier') );
		$s .= Xml::option( wfMsg( "readerfeedback-tier-high" ), 3, $selected===3);
		$s .= Xml::option( wfMsg( "readerfeedback-tier-medium" ), 2, $selected===2 );
		$s .= Xml::option( wfMsg( "readerfeedback-tier-poor" ), 1, $selected===1 );
		$s .= Xml::closeElement('select')."\n";
		return $s;
	}
Esempio n. 2
0
    function buildForm()
    {
        global $wgScript;
        $languages = Language::getLanguageNames(false);
        ksort($languages);
        $out = Xml::openElement('form', array('method' => 'get', 'action' => $wgScript, 'id' => 'mw-allmessages-form')) . Xml::fieldset(wfMsg('allmessages-filter-legend')) . Xml::hidden('title', $this->getTitle()) . Xml::openElement('table', array('class' => 'mw-allmessages-table')) . "\n" . '<tr>
				<td class="mw-label">' . Xml::label(wfMsg('allmessages-prefix'), 'mw-allmessages-form-prefix') . "</td>\n\n\t\t\t\t<td class=\"mw-input\">" . Xml::input('prefix', 20, str_replace('_', ' ', $this->prefix), array('id' => 'mw-allmessages-form-prefix')) . "</td>\n\n\t\t\t</tr>\n\t\t\t<tr>\n\n\t\t\t\t<td class='mw-label'>" . wfMsg('allmessages-filter') . "</td>\n\n\t\t\t\t<td class='mw-input'>" . Xml::radioLabel(wfMsg('allmessages-filter-unmodified'), 'filter', 'unmodified', 'mw-allmessages-form-filter-unmodified', $this->filter == 'unmodified' ? true : false) . Xml::radioLabel(wfMsg('allmessages-filter-all'), 'filter', 'all', 'mw-allmessages-form-filter-all', $this->filter == 'all' ? true : false) . Xml::radioLabel(wfMsg('allmessages-filter-modified'), 'filter', 'modified', 'mw-allmessages-form-filter-modified', $this->filter == 'modified' ? true : false) . "</td>\n\n\t\t\t</tr>\n\t\t\t<tr>\n\n\t\t\t\t<td class=\"mw-label\">" . Xml::label(wfMsg('allmessages-language'), 'mw-allmessages-form-lang') . "</td>\n\n\t\t\t\t<td class=\"mw-input\">" . Xml::openElement('select', array('id' => 'mw-allmessages-form-lang', 'name' => 'lang'));
        foreach ($languages as $lang => $name) {
            $selected = $lang == $this->langCode ? true : false;
            $out .= Xml::option($lang . ' - ' . $name, $lang, $selected) . "\n";
        }
        $out .= Xml::closeElement('select') . "</td>\n\n\t\t\t</tr>\n\t\t\t<tr>\n\n\t\t\t\t<td></td>\n\t\t\t\t<td>" . Xml::submitButton(wfMsg('allmessages-filter-submit')) . "</td>\n\n\t\t\t</tr>" . Xml::closeElement('table') . $this->table->getHiddenFields(array('title', 'prefix', 'filter', 'lang')) . Xml::closeElement('fieldset') . Xml::closeElement('form');
        return $out;
    }
Esempio n. 3
0
 function execute($par)
 {
     global $wgOut, $wgUser;
     $this->setHeaders();
     if (!$wgUser->isAllowed('stafflog')) {
         throw new PermissionsError('stafflog');
     }
     $pager = new StaffLoggerPager("");
     $sTypesDropDown = Xml::openElement('select', array('name' => 'type', 'id' => 'StaffLogFilterType'));
     foreach ($this->aTypes as $k => $v) {
         $sTypesDropDown .= Xml::option($v, $k, $k == $this->request->getText('type', ''));
     }
     $sTypesDropDown .= Xml::closeElement('select');
     $wgOut->addHTML(Xml::openElement('form', array('method' => 'get', 'action' => $this->getTitle()->getLocalURL())) . Xml::openElement('fieldset') . Xml::element('legend', null, wfMsg('stafflog-filter-label'), false) . Xml::inputLabel(wfMsg('stafflog-filter-user'), 'user', 'StaffLogFilterUser', false, htmlspecialchars($this->request->getText('user', ''), ENT_QUOTES, 'UTF-8')) . Xml::label(wfMsg('stafflog-filter-type'), 'StaffLogFilterType') . ' ' . $sTypesDropDown . ' ' . Xml::submitButton(wfMsg('stafflog-filter-apply')) . Xml::closeElement('fieldset') . Xml::closeElement('form') . Xml::openElement('div', array('class' => 'mw-spcontent')) . $pager->getNavigationBar() . '<ul>' . $pager->getBody() . '</ul>' . $pager->getNavigationBar() . Xml::closeElement('div'));
 }
Esempio n. 4
0
 public static function trailerForm(&$items, $opts)
 {
     $opts->consumeValue('trailer');
     global $wgRequest;
     $default = $wgRequest->getVal('trailer', '');
     global $wgLang;
     if (is_callable(array('LanguageNames', 'getNames'))) {
         $languages = LanguageNames::getNames($wgLang->getCode(), LanguageNames::FALLBACK_NORMAL, LanguageNames::LIST_MW);
     } else {
         $languages = Language::getLanguageNames(false);
     }
     ksort($languages);
     $options = Xml::option(wfMsg('cleanchanges-language-na'), '', $default === '');
     foreach ($languages as $code => $name) {
         $selected = "/{$code}" === $default;
         $options .= Xml::option("{$code} - {$name}", "/{$code}", $selected) . "\n";
     }
     $str = Xml::openElement('select', array('name' => 'trailer', 'class' => 'mw-language-selector', 'id' => 'sp-rc-language')) . $options . Xml::closeElement('select');
     $items['tailer'] = array(wfMsgHtml('cleanchanges-language'), $str);
     return true;
 }
 /**
  * This method actually generates the output
  * @return string HTML output
  */
 public function execute($param = false)
 {
     $sHeadline = wfMessage($this->getOption('i18nKeyName'))->plain();
     $help = Xml::element('span', array('style' => 'color: #777777; font-size: 10px;'), wfMessage('bs-extendedsearch-search-help-multiselect')->plain(), false);
     $sEntries = '';
     foreach ($this->entries as $datasetArray) {
         $bSelected = false;
         if (isset($datasetArray['selected']) && $datasetArray['selected'] === true) {
             $bSelected = true;
         }
         $sEntries .= Xml::option(htmlspecialchars($datasetArray['text'], ENT_QUOTES, 'UTF-8'), $datasetArray['value'], $bSelected);
     }
     $sFormSelect = Xml::openElement('select', array('name' => $this->getOption('urlFieldName'), 'multiple' => 'true', 'size' => 10, 'style' => 'width: 200px'));
     $sFormSelect .= $sEntries;
     $sFormSelect .= Xml::closeElement('select');
     $divBody = $sHeadline . '<br />' . $help . '<br />' . $sFormSelect;
     if (isset($this->dirtyAppended)) {
         $divBody .= $this->dirtyAppended;
     }
     $sOut = Xml::openElement('div', array('class' => 'bs-extendedsearch-multivaluefield')) . $divBody . Xml::closeElement('div');
     return $sOut;
 }
Esempio n. 6
0
function wfTimezone($input, array $args, Parser $parser, PPFrame $frame)
{
    //time to convert (format specified below)
    //$time = 'Tuesday, April 21, 2009 2:32:46 PM';
    $time = $args['time'];
    //time zone provided by the user
    $inputTz = $args['zone'];
    // create the DateTimeZone object
    $dtzone = new DateTimeZone($inputTz);
    // now create the DateTime object for this time and user time zone
    $dtime = new DateTime($time, $dtzone);
    // Get the timestamp
    $timestamp = $dtime->format('U');
    // create an array listing the time zones
    $timezones = array('Kwajalein' => '(GMT-12:00) International Date Line West', 'Pacific/Midway' => '(GMT-11:00) Midway Island', 'Pacific/Samoa' => '(GMT-11:00) Samoa', 'Pacific/Honolulu' => '(GMT-10:00) Hawaii', 'America/Anchorage' => '(GMT-09:00) Alaska', 'America/Los_Angeles' => '(GMT-08:00) Pacific Time (US &amp; Canada)', 'America/Tijuana' => '(GMT-08:00) Tijuana, Baja California', 'America/Denver' => '(GMT-07:00) Mountain Time (US &amp; Canada)', 'America/Chihuahua' => '(GMT-07:00) Chihuahua', 'America/Mazatlan' => '(GMT-07:00) Mazatlan', 'America/Phoenix' => '(GMT-07:00) Arizona', 'America/Regina' => '(GMT-06:00) Saskatchewan', 'America/Tegucigalpa' => '(GMT-06:00) Central America', 'America/Chicago' => '(GMT-06:00) Central Time (US &amp; Canada)', 'America/Mexico_City' => '(GMT-06:00) Mexico City', 'America/Monterrey' => '(GMT-06:00) Monterrey', 'America/New_York' => '(GMT-05:00) Eastern Time (US &amp; Canada)', 'America/Bogota' => '(GMT-05:00) Bogota', 'America/Lima' => '(GMT-05:00) Lima', 'America/Rio_Branco' => '(GMT-05:00) Rio Branco', 'America/Indiana/Indianapolis' => '(GMT-05:00) Indiana (East)', 'America/Caracas' => '(GMT-04:30) Caracas', 'America/Halifax' => '(GMT-04:00) Atlantic Time (Canada)', 'America/Manaus' => '(GMT-04:00) Manaus', 'America/Santiago' => '(GMT-04:00) Santiago', 'America/La_Paz' => '(GMT-04:00) La Paz', 'America/St_Johns' => '(GMT-03:30) Newfoundland', 'America/Argentina/Buenos_Aires' => '(GMT-03:00) Georgetown', 'America/Sao_Paulo' => '(GMT-03:00) Brasilia', 'America/Godthab' => '(GMT-03:00) Greenland', 'America/Montevideo' => '(GMT-03:00) Montevideo', 'Atlantic/South_Georgia' => '(GMT-02:00) Mid-Atlantic', 'Atlantic/Azores' => '(GMT-01:00) Azores', 'Atlantic/Cape_Verde' => '(GMT-01:00) Cape Verde Is.', 'Europe/Dublin' => '(GMT) Dublin', 'Europe/Lisbon' => '(GMT) Lisbon', 'Europe/London' => '(GMT) London', 'Africa/Monrovia' => '(GMT) Monrovia', 'Atlantic/Reykjavik' => '(GMT) Reykjavik', 'Africa/Casablanca' => '(GMT) Casablanca', 'Europe/Belgrade' => '(GMT+01:00) Belgrade', 'Europe/Bratislava' => '(GMT+01:00) Bratislava', 'Europe/Budapest' => '(GMT+01:00) Budapest', 'Europe/Ljubljana' => '(GMT+01:00) Ljubljana', 'Europe/Prague' => '(GMT+01:00) Prague', 'Europe/Sarajevo' => '(GMT+01:00) Sarajevo', 'Europe/Skopje' => '(GMT+01:00) Skopje', 'Europe/Warsaw' => '(GMT+01:00) Warsaw', 'Europe/Zagreb' => '(GMT+01:00) Zagreb', 'Europe/Brussels' => '(GMT+01:00) Brussels', 'Europe/Copenhagen' => '(GMT+01:00) Copenhagen', 'Europe/Madrid' => '(GMT+01:00) Madrid', 'Europe/Paris' => '(GMT+01:00) Paris', 'Africa/Algiers' => '(GMT+01:00) West Central Africa', 'Europe/Amsterdam' => '(GMT+01:00) Amsterdam', 'Europe/Berlin' => '(GMT+01:00) Berlin', 'Europe/Rome' => '(GMT+01:00) Rome', 'Europe/Stockholm' => '(GMT+01:00) Stockholm', 'Europe/Vienna' => '(GMT+01:00) Vienna', 'Europe/Minsk' => '(GMT+02:00) Minsk', 'Africa/Cairo' => '(GMT+02:00) Cairo', 'Europe/Helsinki' => '(GMT+02:00) Helsinki', 'Europe/Riga' => '(GMT+02:00) Riga', 'Europe/Sofia' => '(GMT+02:00) Sofia', 'Europe/Tallinn' => '(GMT+02:00) Tallinn', 'Europe/Vilnius' => '(GMT+02:00) Vilnius', 'Europe/Athens' => '(GMT+02:00) Athens', 'Europe/Bucharest' => '(GMT+02:00) Bucharest', 'Europe/Istanbul' => '(GMT+02:00) Istanbul', 'Asia/Jerusalem' => '(GMT+02:00) Jerusalem', 'Asia/Amman' => '(GMT+02:00) Amman', 'Asia/Beirut' => '(GMT+02:00) Beirut', 'Africa/Windhoek' => '(GMT+02:00) Windhoek', 'Africa/Harare' => '(GMT+02:00) Harare', 'Asia/Kuwait' => '(GMT+03:00) Kuwait', 'Asia/Riyadh' => '(GMT+03:00) Riyadh', 'Asia/Baghdad' => '(GMT+03:00) Baghdad', 'Africa/Nairobi' => '(GMT+03:00) Nairobi', 'Asia/Tbilisi' => '(GMT+03:00) Tbilisi', 'Europe/Moscow' => '(GMT+03:00) Moscow', 'Europe/Volgograd' => '(GMT+03:00) Volgograd', 'Asia/Tehran' => '(GMT+03:30) Tehran', 'Asia/Muscat' => '(GMT+04:00) Muscat', 'Asia/Baku' => '(GMT+04:00) Baku', 'Asia/Yerevan' => '(GMT+04:00) Yerevan', 'Asia/Yekaterinburg' => '(GMT+05:00) Ekaterinburg', 'Asia/Karachi' => '(GMT+05:00) Karachi', 'Asia/Tashkent' => '(GMT+05:00) Tashkent', 'Asia/Kolkata' => '(GMT+05:30) Calcutta', 'Asia/Colombo' => '(GMT+05:30) Sri Jayawardenepura', 'Asia/Katmandu' => '(GMT+05:45) Kathmandu', 'Asia/Dhaka' => '(GMT+06:00) Dhaka', 'Asia/Almaty' => '(GMT+06:00) Almaty', 'Asia/Novosibirsk' => '(GMT+06:00) Novosibirsk', 'Asia/Rangoon' => '(GMT+06:30) Yangon (Rangoon)', 'Asia/Krasnoyarsk' => '(GMT+07:00) Krasnoyarsk', 'Asia/Bangkok' => '(GMT+07:00) Bangkok', 'Asia/Jakarta' => '(GMT+07:00) Jakarta', 'Asia/Brunei' => '(GMT+08:00) Beijing', 'Asia/Chongqing' => '(GMT+08:00) Chongqing', 'Asia/Hong_Kong' => '(GMT+08:00) Hong Kong', 'Asia/Urumqi' => '(GMT+08:00) Urumqi', 'Asia/Irkutsk' => '(GMT+08:00) Irkutsk', 'Asia/Ulaanbaatar' => '(GMT+08:00) Ulaan Bataar', 'Asia/Kuala_Lumpur' => '(GMT+08:00) Kuala Lumpur', 'Asia/Singapore' => '(GMT+08:00) Singapore', 'Asia/Taipei' => '(GMT+08:00) Taipei', 'Australia/Perth' => '(GMT+08:00) Perth', 'Asia/Seoul' => '(GMT+09:00) Seoul', 'Asia/Tokyo' => '(GMT+09:00) Tokyo', 'Asia/Yakutsk' => '(GMT+09:00) Yakutsk', 'Australia/Darwin' => '(GMT+09:30) Darwin', 'Australia/Adelaide' => '(GMT+09:30) Adelaide', 'Australia/Canberra' => '(GMT+10:00) Canberra', 'Australia/Melbourne' => '(GMT+10:00) Melbourne', 'Australia/Sydney' => '(GMT+10:00) Sydney', 'Australia/Brisbane' => '(GMT+10:00) Brisbane', 'Australia/Hobart' => '(GMT+10:00) Hobart', 'Asia/Vladivostok' => '(GMT+10:00) Vladivostok', 'Pacific/Guam' => '(GMT+10:00) Guam', 'Pacific/Port_Moresby' => '(GMT+10:00) Port Moresby', 'Asia/Magadan' => '(GMT+11:00) Magadan', 'Pacific/Fiji' => '(GMT+12:00) Fiji', 'Asia/Kamchatka' => '(GMT+12:00) Kamchatka', 'Pacific/Auckland' => '(GMT+12:00) Auckland', 'Pacific/Tongatapu' => '(GMT+13:00) Nukualofa');
    $html = Xml::openElement('select', array('name' => 'tz'));
    foreach ($timezones as $tz => $tzDescription) {
        // create the DateTimeZone object
        $dtzone = new DateTimeZone($tz);
        // first convert the timestamp into a string representing the local time
        $time = date('r', $timestamp);
        // now create the DateTime object for this time
        $dtime = new DateTime($time);
        // convert this to the specific timezone using the DateTimeZone object
        $dtime->setTimeZone($dtzone);
        // print the time using your preferred format
        // TODO add new formats
        $time = $dtime->format('g:i A m/d/y');
        if ($tz == $inputTz) {
            $html .= Xml::option($tz . ' ' . $time, $tzDescription, true);
        } else {
            $html .= Xml::option($tz . ' ' . $time, $tzDescription, false);
        }
    }
    $html .= Xml::closeElement('select');
    return $html;
}
 public function addOption($name, $value = false)
 {
     // Stab stab stab
     $value = $value !== false ? $value : $name;
     $this->options[] = Xml::option($name, $value, $value === $this->default);
 }
 /**
  * Build a drop-down box for selecting a collaborative watchlist tag
  *
  * @param array $rlIds A list of collaborative watchlist ids
  * @param String $label The label for the select tag
  * @param String $elemId The id of the select tag
  * @return String A string containing HTML
  */
 public static function tagSelector($rlIds, $label = '', $elemId = 'mw-collaborative-watchlist-addtag-selector')
 {
     global $wgContLang;
     $tagsAndInfo = CollabWatchlistChangesList::getValidTagsAndInfo($rlIds);
     $optionsAll = array();
     $options = array();
     foreach ($tagsAndInfo as $tagName => $info) {
         $optionsAll[] = Xml::option($tagName . ' ' . $info['rt_description'], $tagName);
         foreach ($info['cw_ids'] as $rlId) {
             $options[$rlId][] = Xml::option($tagName, $tagName);
         }
     }
     $ret = Xml::openElement('select', array('id' => $elemId, 'name' => 'collabwatchlisttag', 'class' => 'mw-collaborative-watchlist-tag-selector')) . implode("\n", $optionsAll) . Xml::closeElement('select');
     if (!is_null($label)) {
         $ret = Xml::label($label, $elemId) . '&nbsp;' . $ret;
     }
     foreach ($options as $rlId => $optionsRl) {
         $ret .= Xml::openElement('select', array('style' => 'display: none;', 'id' => $elemId . '-' . $rlId, 'name' => 'collabwatchlisttag-rl', 'class' => 'mw-collaborative-watchlist-tag-selector')) . implode("\n", $optionsRl) . Xml::closeElement('select');
     }
     $ret .= Xml::openElement('select', array('style' => 'display: none;', 'id' => $elemId . '-empty', 'name' => 'collabwatchlisttag-rl', 'class' => 'mw-collaborative-watchlist-tag-selector')) . Xml::closeElement('select');
     return $ret;
 }
 private function showForm()
 {
     global $wgImportSources, $wgExportMaxLinkDepth;
     $action = $this->getTitle()->getLocalUrl(array('action' => 'submit'));
     $user = $this->getUser();
     $out = $this->getOutput();
     if ($user->isAllowed('importupload')) {
         $out->addHTML(Xml::fieldset($this->msg('import-upload')->text()) . Xml::openElement('form', array('enctype' => 'multipart/form-data', 'method' => 'post', 'action' => $action, 'id' => 'mw-import-upload-form')) . $this->msg('importtext')->parseAsBlock() . Html::hidden('action', 'submit') . Html::hidden('source', 'upload') . Xml::openElement('table', array('id' => 'mw-import-table')) . "<tr>\n\t\t\t\t\t<td class='mw-label'>" . Xml::label($this->msg('import-upload-filename')->text(), 'xmlimport') . "</td>\n\t\t\t\t\t<td class='mw-input'>" . Xml::input('xmlimport', 50, '', array('type' => 'file')) . ' ' . "</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($this->msg('import-comment')->text(), 'mw-import-comment') . "</td>\n\t\t\t\t\t<td class='mw-input'>" . Xml::input('log-comment', 50, '', array('id' => 'mw-import-comment', 'type' => 'text')) . ' ' . "</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($this->msg('import-interwiki-rootpage')->text(), 'mw-interwiki-rootpage') . "</td>\n\t\t\t\t\t<td class='mw-input'>" . Xml::input('rootpage', 50, $this->rootpage, array('id' => 'mw-interwiki-rootpage', 'type' => 'text')) . ' ' . "</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($this->msg('uploadbtn')->text()) . "</td>\n\t\t\t\t</tr>" . Xml::closeElement('table') . Html::hidden('editToken', $user->getEditToken()) . Xml::closeElement('form') . Xml::closeElement('fieldset'));
     } else {
         if (empty($wgImportSources)) {
             $out->addWikiMsg('importnosources');
         }
     }
     if ($user->isAllowed('import') && !empty($wgImportSources)) {
         # Show input field for import depth only if $wgExportMaxLinkDepth > 0
         $importDepth = '';
         if ($wgExportMaxLinkDepth > 0) {
             $importDepth = "<tr>\n\t\t\t\t\t\t\t<td class='mw-label'>" . $this->msg('export-pagelinks')->parse() . "</td>\n\t\t\t\t\t\t\t<td class='mw-input'>" . Xml::input('pagelink-depth', 3, 0) . "</td>\n\t\t\t\t\t\t</tr>";
         }
         $out->addHTML(Xml::fieldset($this->msg('importinterwiki')->text()) . Xml::openElement('form', array('method' => 'post', 'action' => $action, 'id' => 'mw-import-interwiki-form')) . $this->msg('import-interwiki-text')->parseAsBlock() . Html::hidden('action', 'submit') . Html::hidden('source', 'interwiki') . Html::hidden('editToken', $user->getEditToken()) . Xml::openElement('table', array('id' => 'mw-import-table')) . "<tr>\n\t\t\t\t\t<td class='mw-label'>" . Xml::label($this->msg('import-interwiki-source')->text(), 'interwiki') . "</td>\n\t\t\t\t\t<td class='mw-input'>" . Xml::openElement('select', array('name' => 'interwiki')));
         foreach ($wgImportSources as $prefix) {
             $selected = $this->interwiki === $prefix ? ' selected="selected"' : '';
             $out->addHTML(Xml::option($prefix, $prefix, $selected));
         }
         $out->addHTML(Xml::closeElement('select') . Xml::input('frompage', 50, $this->frompage) . "</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>\n\t\t\t\t\t</td>\n\t\t\t\t\t<td class='mw-input'>" . Xml::checkLabel($this->msg('import-interwiki-history')->text(), 'interwikiHistory', 'interwikiHistory', $this->history) . "</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>\n\t\t\t\t\t</td>\n\t\t\t\t\t<td class='mw-input'>" . Xml::checkLabel($this->msg('import-interwiki-templates')->text(), 'interwikiTemplates', 'interwikiTemplates', $this->includeTemplates) . "</td>\n\t\t\t\t</tr>\n\t\t\t\t{$importDepth}\n\t\t\t\t<tr>\n\t\t\t\t\t<td class='mw-label'>" . Xml::label($this->msg('import-interwiki-namespace')->text(), 'namespace') . "</td>\n\t\t\t\t\t<td class='mw-input'>" . Html::namespaceSelector(array('selected' => $this->namespace, 'all' => ''), array('name' => 'namespace', 'id' => 'namespace', 'class' => 'namespaceselector')) . "</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($this->msg('import-comment')->text(), 'mw-interwiki-comment') . "</td>\n\t\t\t\t\t<td class='mw-input'>" . Xml::input('log-comment', 50, '', array('id' => 'mw-interwiki-comment', 'type' => 'text')) . ' ' . "</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($this->msg('import-interwiki-rootpage')->text(), 'mw-interwiki-rootpage') . "</td>\n\t\t\t\t\t<td class='mw-input'>" . Xml::input('rootpage', 50, $this->rootpage, array('id' => 'mw-interwiki-rootpage', 'type' => 'text')) . ' ' . "</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>\n\t\t\t\t\t</td>\n\t\t\t\t\t<td class='mw-submit'>" . Xml::submitButton($this->msg('import-interwiki-submit')->text(), Linker::tooltipAndAccesskeyAttribs('import')) . "</td>\n\t\t\t\t</tr>" . Xml::closeElement('table') . Xml::closeElement('form') . Xml::closeElement('fieldset'));
     }
 }
 /**
  * Creates the input label of the restriction level
  * @param string $pr_level Protection level
  * @return string Formatted HTML
  */
 protected function getLevelMenu($pr_level)
 {
     // Temporary array
     $m = array($this->msg('restriction-level-all')->text() => 0);
     $options = array();
     // First pass to load the log names
     foreach ($this->getConfig()->get('RestrictionLevels') as $type) {
         // Messages used can be 'restriction-level-sysop' and 'restriction-level-autoconfirmed'
         if ($type != '' && $type != '*') {
             $text = $this->msg("restriction-level-{$type}")->text();
             $m[$text] = $type;
         }
     }
     // Third pass generates sorted XHTML content
     foreach ($m as $text => $type) {
         $selected = $type == $pr_level;
         $options[] = Xml::option($text, $type, $selected);
     }
     return '<span class="mw-input-with-label">' . Xml::label($this->msg('restriction-level')->text(), $this->IdLevel) . ' ' . Xml::tags('select', array('id' => $this->IdLevel, 'name' => $this->IdLevel), implode("\n", $options)) . "</span>";
 }
Esempio n. 11
0
 /**
  * Retrieves and shows the gathered info to the user
  * @param $target Mixed: user whose info we're looking up
  * @param $emailUser String: e-mail address (like example@example.com)
  */
 function showInfo($target, $emailUser = '')
 {
     global $wgOut, $wgLang, $wgScript;
     $count = 0;
     $users = array();
     $userTarget = '';
     // Look for @ in username
     if (strpos($target, '@') !== false) {
         // Find username by email
         $emailUser = htmlspecialchars($emailUser);
         $dbr = wfGetDB(DB_SLAVE);
         $res = $dbr->select('user', array('user_name'), array('user_email' => $target), __METHOD__);
         $loop = 0;
         foreach ($res as $row) {
             if ($loop === 0) {
                 $userTarget = $row->user_name;
             }
             if (!empty($emailUser) && $emailUser == $row->user_name) {
                 $userTarget = $emailUser;
             }
             $users[] = $row->user_name;
             $loop++;
         }
         $count = $loop;
     }
     $ourUser = !empty($userTarget) ? $userTarget : $target;
     $user = User::newFromName($ourUser);
     if ($user == null || $user->getId() == 0) {
         $wgOut->addWikiText('<span class="error">' . wfMsg('lookupuser-nonexistent', $target) . '</span>');
     } else {
         # Multiple matches?
         if ($count > 1) {
             $options = array();
             if (!empty($users) && is_array($users)) {
                 foreach ($users as $id => $userName) {
                     $options[] = Xml::option($userName, $userName, $userName == $userTarget);
                 }
             }
             $selectForm = "\n" . Xml::openElement('select', array('id' => 'email_user', 'name' => 'email_user'));
             $selectForm .= "\n" . implode("\n", $options) . "\n";
             $selectForm .= Xml::closeElement('select') . "\n";
             $wgOut->addHTML(Xml::openElement('fieldset') . "\n" . Xml::openElement('form', array('method' => 'get', 'action' => $wgScript)) . "\n" . Html::hidden('title', $this->getTitle()->getPrefixedText()) . "\n" . Html::hidden('target', $target) . "\n" . Xml::openElement('table', array('border' => '0')) . "\n" . Xml::openElement('tr') . "\n" . Xml::openElement('td', array('align' => 'right')) . wfMsgHtml('lookupuser-foundmoreusers') . Xml::closeElement('td') . "\n" . Xml::openElement('td', array('align' => 'left')) . "\n" . $selectForm . Xml::closeElement('td') . "\n" . Xml::openElement('td', array('colspan' => '2', 'align' => 'center')) . Xml::submitButton(wfMsgHtml('go')) . Xml::closeElement('td') . "\n" . Xml::closeElement('tr') . "\n" . Xml::closeElement('table') . "\n" . Xml::closeElement('form') . "\n" . Xml::closeElement('fieldset'));
         }
         $authTs = $user->getEmailAuthenticationTimestamp();
         if ($authTs) {
             $authenticated = wfMsg('lookupuser-authenticated', $wgLang->timeanddate($authTs));
         } else {
             $authenticated = wfMsg('lookupuser-not-authenticated');
         }
         $optionsString = '';
         foreach ($user->getOptions() as $name => $value) {
             $optionsString .= "{$name} = {$value} <br />";
         }
         $name = $user->getName();
         if ($user->getEmail()) {
             $email = $user->getEmail();
         } else {
             $email = wfMsg('lookupuser-no-email');
         }
         if ($user->getRegistration()) {
             $registration = $wgLang->timeanddate($user->getRegistration());
         } else {
             $registration = wfMsg('lookupuser-no-registration');
         }
         $wgOut->addWikiText('*' . wfMsg('username') . ' [[User:'******'|' . $name . ']] (' . $wgLang->pipeList(array('[[User talk:' . $name . '|' . wfMsg('talkpagelinktext') . ']]', '[[Special:Contributions/' . $name . '|' . wfMsg('contribslink') . ']])')));
         $wgOut->addWikiText('*' . wfMsg('lookupuser-id', $user->getId()));
         $wgOut->addWikiText('*' . wfMsg('lookupuser-email', $email, $name));
         $wgOut->addWikiText('*' . wfMsg('lookupuser-realname', $user->getRealName()));
         $wgOut->addWikiText('*' . wfMsg('lookupuser-registration', $registration));
         $wgOut->addWikiText('*' . wfMsg('lookupuser-touched', $wgLang->timeanddate($user->mTouched)));
         $wgOut->addWikiText('*' . wfMsg('lookupuser-info-authenticated', $authenticated));
         $wgOut->addWikiText('*' . wfMsg('lookupuser-useroptions') . '<br />' . $optionsString);
     }
 }
Esempio n. 12
0
 /**
  * Build protection level selector
  *
  * @param string $action action to protect
  * @param string $selected current protection level
  * @return String: HTML fragment
  */
 function buildSelector($action, $selected)
 {
     global $wgUser;
     // If the form is disabled, display all relevant levels. Otherwise,
     // just show the ones this user can use.
     $levels = MWNamespace::getRestrictionLevels($this->mTitle->getNamespace(), $this->disabled ? null : $wgUser);
     $id = 'mwProtect-level-' . $action;
     $attribs = array('id' => $id, 'name' => $id, 'size' => count($levels), 'onchange' => 'ProtectionForm.updateLevels(this)') + $this->disabledAttrib;
     $out = Xml::openElement('select', $attribs);
     foreach ($levels as $key) {
         $out .= Xml::option($this->getOptionLabel($key), $key, $key == $selected);
     }
     $out .= Xml::closeElement('select');
     return $out;
 }
	/**
	 * @param string $pr_level Determines which option is selected as default
	 * @return string Formatted HTML
	 * @private
	 */
	function getLevelMenu( $pr_level ) {
		global $wgRestrictionLevels;

		// Temporary array
		$m = array( $this->msg( 'restriction-level-all' )->text() => 0 );
		$options = array();

		// First pass to load the log names
		foreach ( $wgRestrictionLevels as $type ) {
			if ( $type != '' && $type != '*' ) {
				// Messages: restriction-level-sysop, restriction-level-autoconfirmed
				$text = $this->msg( "restriction-level-$type" )->text();
				$m[$text] = $type;
			}
		}

		// Is there only one level (aside from "all")?
		if ( count( $m ) <= 2 ) {
			return '';
		}
		// Third pass generates sorted XHTML content
		foreach ( $m as $text => $type ) {
			$selected = ( $type == $pr_level );
			$options[] = Xml::option( $text, $type, $selected );
		}

		return Xml::label( $this->msg( 'restriction-level' )->text(), $this->IdLevel ) . '&#160;' .
			Xml::tags( 'select',
				array( 'id' => $this->IdLevel, 'name' => $this->IdLevel ),
				implode( "\n", $options ) );
	}
Esempio n. 14
0
 private function showForm()
 {
     global $wgUser, $wgOut, $wgRequest, $wgTitle, $wgImportSources, $wgExportMaxLinkDepth;
     if (!$wgUser->isAllowed('import') && !$wgUser->isAllowed('importupload')) {
         return $wgOut->permissionRequired('import');
     }
     $action = $wgTitle->getLocalUrl('action=submit');
     if ($wgUser->isAllowed('importupload')) {
         $wgOut->addWikiMsg("importtext");
         $wgOut->addHTML(Xml::fieldset(wfMsg('import-upload')) . Xml::openElement('form', array('enctype' => 'multipart/form-data', 'method' => 'post', 'action' => $action, 'id' => 'mw-import-upload-form')) . Xml::hidden('action', 'submit') . Xml::hidden('source', 'upload') . Xml::openElement('table', array('id' => 'mw-import-table')) . "<tr>\n\t\t\t\t\t<td class='mw-label'>" . Xml::label(wfMsg('import-upload-filename'), 'xmlimport') . "</td>\n\t\t\t\t\t<td class='mw-input'>" . Xml::input('xmlimport', 50, '', array('type' => 'file')) . ' ' . "</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('import-comment'), 'mw-import-comment') . "</td>\n\t\t\t\t\t<td class='mw-input'>" . Xml::input('log-comment', 50, '', array('id' => 'mw-import-comment', 'type' => 'text')) . ' ' . "</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('uploadbtn')) . "</td>\n\t\t\t\t</tr>" . Xml::closeElement('table') . Xml::hidden('editToken', $wgUser->editToken()) . Xml::closeElement('form') . Xml::closeElement('fieldset'));
     } else {
         if (empty($wgImportSources)) {
             $wgOut->addWikiMsg('importnosources');
         }
     }
     if ($wgUser->isAllowed('import') && !empty($wgImportSources)) {
         # Show input field for import depth only if $wgExportMaxLinkDepth > 0
         $importDepth = '';
         if ($wgExportMaxLinkDepth > 0) {
             $importDepth = "<tr>\n\t\t\t\t\t\t\t<td class='mw-label'>" . wfMsgExt('export-pagelinks', 'parseinline') . "</td>\n\t\t\t\t\t\t\t<td class='mw-input'>" . Xml::input('pagelink-depth', 3, 0) . "</td>\n\t\t\t\t\t\t</tr>";
         }
         $wgOut->addHTML(Xml::fieldset(wfMsg('importinterwiki')) . Xml::openElement('form', array('method' => 'post', 'action' => $action, 'id' => 'mw-import-interwiki-form')) . wfMsgExt('import-interwiki-text', array('parse')) . Xml::hidden('action', 'submit') . Xml::hidden('source', 'interwiki') . Xml::hidden('editToken', $wgUser->editToken()) . Xml::openElement('table', array('id' => 'mw-import-table')) . "<tr>\n\t\t\t\t\t<td class='mw-label'>" . Xml::label(wfMsg('import-interwiki-source'), 'interwiki') . "</td>\n\t\t\t\t\t<td class='mw-input'>" . Xml::openElement('select', array('name' => 'interwiki')));
         foreach ($wgImportSources as $prefix) {
             $selected = $this->interwiki === $prefix ? ' selected="selected"' : '';
             $wgOut->addHTML(Xml::option($prefix, $prefix, $selected));
         }
         $wgOut->addHTML(Xml::closeElement('select') . Xml::input('frompage', 50, $this->frompage) . "</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>\n\t\t\t\t\t</td>\n\t\t\t\t\t<td class='mw-input'>" . Xml::checkLabel(wfMsg('import-interwiki-history'), 'interwikiHistory', 'interwikiHistory', $this->history) . "</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>\n\t\t\t\t\t</td>\n\t\t\t\t\t<td class='mw-input'>" . Xml::checkLabel(wfMsg('import-interwiki-templates'), 'interwikiTemplates', 'interwikiTemplates', $this->includeTemplates) . "</td>\n\t\t\t\t</tr>\n\t\t\t\t{$importDepth}\n\t\t\t\t<tr>\n\t\t\t\t\t<td class='mw-label'>" . Xml::label(wfMsg('import-interwiki-namespace'), 'namespace') . "</td>\n\t\t\t\t\t<td class='mw-input'>" . Xml::namespaceSelector($this->namespace, '') . "</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('import-comment'), 'mw-interwiki-comment') . "</td>\n\t\t\t\t\t<td class='mw-input'>" . Xml::input('log-comment', 50, '', array('id' => 'mw-interwiki-comment', 'type' => 'text')) . ' ' . "</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>\n\t\t\t\t\t</td>\n\t\t\t\t\t<td class='mw-submit'>" . Xml::submitButton(wfMsg('import-interwiki-submit'), array('accesskey' => 's')) . "</td>\n\t\t\t\t</tr>" . Xml::closeElement('table') . Xml::closeElement('form') . Xml::closeElement('fieldset'));
     }
 }
Esempio n. 15
0
 public function showForm($err)
 {
     global $wgOut, $wgUser, $wgSysopUserBans;
     $wgOut->setPageTitle(wfMsg('blockip-title'));
     $wgOut->addWikiMsg('blockiptext');
     if ($wgSysopUserBans) {
         $mIpaddress = Xml::label(wfMsg('ipadressorusername'), 'mw-bi-target');
     } else {
         $mIpaddress = Xml::label(wfMsg('ipaddress'), 'mw-bi-target');
     }
     $mIpbexpiry = Xml::label(wfMsg('ipbexpiry'), 'wpBlockExpiry');
     $mIpbother = Xml::label(wfMsg('ipbother'), 'mw-bi-other');
     $mIpbreasonother = Xml::label(wfMsg('ipbreason'), 'wpBlockReasonList');
     $mIpbreason = Xml::label(wfMsg('ipbotherreason'), 'mw-bi-reason');
     $titleObj = SpecialPage::getTitleFor('Blockip');
     $user = User::newFromName($this->BlockAddress);
     $alreadyBlocked = false;
     $otherBlockedMsgs = array();
     if ($err && $err[0] != 'ipb_already_blocked') {
         $key = array_shift($err);
         $msg = wfMsgReal($key, $err);
         $wgOut->setSubtitle(wfMsgHtml('formerror'));
         $wgOut->addHTML(Xml::tags('p', array('class' => 'error'), $msg));
     } elseif ($this->BlockAddress) {
         # Get other blocks, i.e. from GlobalBlocking or TorBlock extension
         wfRunHooks('OtherBlockLogLink', array(&$otherBlockedMsgs, $this->BlockAddress));
         $userId = is_object($user) ? $user->getId() : 0;
         $currentBlock = Block::newFromDB($this->BlockAddress, $userId);
         if (!is_null($currentBlock) && !$currentBlock->mAuto && ($currentBlock->mRangeStart == $currentBlock->mRangeEnd || $currentBlock->mAddress == $this->BlockAddress)) {
             $alreadyBlocked = true;
             # Set the block form settings to the existing block
             if (!$this->wasPosted) {
                 $this->BlockAnonOnly = $currentBlock->mAnonOnly;
                 $this->BlockCreateAccount = $currentBlock->mCreateAccount;
                 $this->BlockEnableAutoblock = $currentBlock->mEnableAutoblock;
                 $this->BlockEmail = $currentBlock->mBlockEmail;
                 $this->BlockHideName = $currentBlock->mHideName;
                 $this->BlockAllowUsertalk = $currentBlock->mAllowUsertalk;
                 if ($currentBlock->mExpiry == 'infinity') {
                     $this->BlockOther = 'indefinite';
                 } else {
                     $this->BlockOther = wfTimestamp(TS_ISO_8601, $currentBlock->mExpiry);
                 }
                 $this->BlockReason = $currentBlock->mReason;
             }
         }
     }
     # Show other blocks from extensions, i.e. GlockBlocking and TorBlock
     if (count($otherBlockedMsgs)) {
         $wgOut->addHTML(Html::rawElement('h2', array(), wfMsgExt('ipb-otherblocks-header', 'parseinline', count($otherBlockedMsgs))) . "\n");
         $list = '';
         foreach ($otherBlockedMsgs as $link) {
             $list .= Html::rawElement('li', array(), $link) . "\n";
         }
         $wgOut->addHTML(Html::rawElement('ul', array('class' => 'mw-blockip-alreadyblocked'), $list) . "\n");
     }
     # Username/IP is blocked already locally
     if ($alreadyBlocked) {
         $wgOut->addWikiMsg('ipb-needreblock', $this->BlockAddress);
     }
     $scBlockExpiryOptions = wfMsgForContent('ipboptions');
     $showblockoptions = $scBlockExpiryOptions != '-';
     if (!$showblockoptions) {
         $mIpbother = $mIpbexpiry;
     }
     $blockExpiryFormOptions = Xml::option(wfMsg('ipbotheroption'), 'other');
     foreach (explode(',', $scBlockExpiryOptions) as $option) {
         if (strpos($option, ':') === false) {
             $option = "{$option}:{$option}";
         }
         list($show, $value) = explode(':', $option);
         $show = htmlspecialchars($show);
         $value = htmlspecialchars($value);
         $blockExpiryFormOptions .= Xml::option($show, $value, $this->BlockExpiry === $value ? true : false) . "\n";
     }
     $reasonDropDown = Xml::listDropDown('wpBlockReasonList', wfMsgForContent('ipbreason-dropdown'), wfMsgForContent('ipbreasonotherlist'), $this->BlockReasonList, 'wpBlockDropDown', 4);
     global $wgStylePath, $wgStyleVersion;
     $wgOut->addHTML(Xml::tags('script', array('type' => 'text/javascript', 'src' => "{$wgStylePath}/common/block.js?{$wgStyleVersion}"), '') . Xml::openElement('form', array('method' => 'post', 'action' => $titleObj->getLocalURL('action=submit'), 'id' => 'blockip')) . Xml::openElement('fieldset') . Xml::element('legend', null, wfMsg('blockip-legend')) . Xml::openElement('table', array('border' => '0', 'id' => 'mw-blockip-table')) . "<tr>\n\t\t\t\t<td class='mw-label'>\n\t\t\t\t\t{$mIpaddress}\n\t\t\t\t</td>\n\t\t\t\t<td class='mw-input'>" . Html::input('wpBlockAddress', $this->BlockAddress, 'text', array('tabindex' => '1', 'id' => 'mw-bi-target', 'onchange' => 'updateBlockOptions()', 'size' => '45', 'required' => '') + ($this->BlockAddress ? array() : array('autofocus'))) . "\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr>");
     if ($showblockoptions) {
         $wgOut->addHTML("\n\t\t\t\t<td class='mw-label'>\n\t\t\t\t\t{$mIpbexpiry}\n\t\t\t\t</td>\n\t\t\t\t<td class='mw-input'>" . Xml::tags('select', array('id' => 'wpBlockExpiry', 'name' => 'wpBlockExpiry', 'onchange' => 'considerChangingExpiryFocus()', 'tabindex' => '2'), $blockExpiryFormOptions) . "</td>");
     }
     $wgOut->addHTML("\n\t\t\t</tr>\n\t\t\t<tr id='wpBlockOther'>\n\t\t\t\t<td class='mw-label'>\n\t\t\t\t\t{$mIpbother}\n\t\t\t\t</td>\n\t\t\t\t<td class='mw-input'>" . Xml::input('wpBlockOther', 45, $this->BlockOther, array('tabindex' => '3', 'id' => 'mw-bi-other')) . "\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td class='mw-label'>\n\t\t\t\t\t{$mIpbreasonother}\n\t\t\t\t</td>\n\t\t\t\t<td class='mw-input'>\n\t\t\t\t\t{$reasonDropDown}\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr id=\"wpBlockReason\">\n\t\t\t\t<td class='mw-label'>\n\t\t\t\t\t{$mIpbreason}\n\t\t\t\t</td>\n\t\t\t\t<td class='mw-input'>" . Html::input('wpBlockReason', $this->BlockReason, 'text', array('tabindex' => '5', 'id' => 'mw-bi-reason', 'maxlength' => '200', 'size' => '45') + ($this->BlockAddress ? array('autofocus') : array())) . "\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr id='wpAnonOnlyRow'>\n\t\t\t\t<td>&nbsp;</td>\n\t\t\t\t<td class='mw-input'>" . Xml::checkLabel(wfMsg('ipbanononly'), 'wpAnonOnly', 'wpAnonOnly', $this->BlockAnonOnly, array('tabindex' => '6')) . "\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr id='wpCreateAccountRow'>\n\t\t\t\t<td>&nbsp;</td>\n\t\t\t\t<td class='mw-input'>" . Xml::checkLabel(wfMsg('ipbcreateaccount'), 'wpCreateAccount', 'wpCreateAccount', $this->BlockCreateAccount, array('tabindex' => '7')) . "\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr id='wpEnableAutoblockRow'>\n\t\t\t\t<td>&nbsp;</td>\n\t\t\t\t<td class='mw-input'>" . Xml::checkLabel(wfMsg('ipbenableautoblock'), 'wpEnableAutoblock', 'wpEnableAutoblock', $this->BlockEnableAutoblock, array('tabindex' => '8')) . "\n\t\t\t\t</td>\n\t\t\t</tr>");
     if (self::canBlockEmail($wgUser)) {
         $wgOut->addHTML("\n\t\t\t\t<tr id='wpEnableEmailBan'>\n\t\t\t\t\t<td>&nbsp;</td>\n\t\t\t\t\t<td class='mw-input'>" . Xml::checkLabel(wfMsg('ipbemailban'), 'wpEmailBan', 'wpEmailBan', $this->BlockEmail, array('tabindex' => '9')) . "\n\t\t\t\t\t</td>\n\t\t\t\t</tr>");
     }
     // Allow some users to hide name from block log, blocklist and listusers
     if ($wgUser->isAllowed('hideuser')) {
         $wgOut->addHTML("\n\t\t\t\t<tr id='wpEnableHideUser'>\n\t\t\t\t\t<td>&nbsp;</td>\n\t\t\t\t\t<td class='mw-input'><strong>" . Xml::checkLabel(wfMsg('ipbhidename'), 'wpHideName', 'wpHideName', $this->BlockHideName, array('tabindex' => '10')) . "\n\t\t\t\t\t</strong></td>\n\t\t\t\t</tr>");
     }
     # Watchlist their user page? (Only if user is logged in)
     if ($wgUser->isLoggedIn()) {
         $wgOut->addHTML("\n\t\t\t<tr id='wpEnableWatchUser'>\n\t\t\t\t<td>&nbsp;</td>\n\t\t\t\t<td class='mw-input'>" . Xml::checkLabel(wfMsg('ipbwatchuser'), 'wpWatchUser', 'wpWatchUser', $this->BlockWatchUser, array('tabindex' => '11')) . "\n\t\t\t\t</td>\n\t\t\t</tr>");
     }
     # Can we explicitly disallow the use of user_talk?
     global $wgBlockAllowsUTEdit;
     if ($wgBlockAllowsUTEdit) {
         $wgOut->addHTML("\n\t\t\t\t<tr id='wpAllowUsertalkRow'>\n\t\t\t\t\t<td>&nbsp;</td>\n\t\t\t\t\t<td class='mw-input'>" . Xml::checkLabel(wfMsg('ipballowusertalk'), 'wpAllowUsertalk', 'wpAllowUsertalk', $this->BlockAllowUsertalk, array('tabindex' => '12')) . "\n\t\t\t\t\t</td>\n\t\t\t\t</tr>");
     }
     $wgOut->addHTML("\n\t\t\t<tr>\n\t\t\t\t<td style='padding-top: 1em'>&nbsp;</td>\n\t\t\t\t<td  class='mw-submit' style='padding-top: 1em'>" . Xml::submitButton(wfMsg($alreadyBlocked ? 'ipb-change-block' : 'ipbsubmit'), array('name' => 'wpBlock', 'tabindex' => '13', 'accesskey' => 's')) . "\n\t\t\t\t</td>\n\t\t\t</tr>" . Xml::closeElement('table') . Xml::hidden('wpEditToken', $wgUser->editToken()) . ($alreadyBlocked ? Xml::hidden('wpChangeBlock', 1) : "") . Xml::closeElement('fieldset') . Xml::closeElement('form') . Xml::tags('script', array('type' => 'text/javascript'), 'updateBlockOptions()') . "\n");
     $wgOut->addHTML($this->getConvenienceLinks());
     if (is_object($user)) {
         $this->showLogFragment($wgOut, $user->getUserPage());
     } elseif (preg_match('/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}/', $this->BlockAddress)) {
         $this->showLogFragment($wgOut, Title::makeTitle(NS_USER, $this->BlockAddress));
     } elseif (preg_match('/^\\w{1,4}:\\w{1,4}:\\w{1,4}:\\w{1,4}:\\w{1,4}:\\w{1,4}:\\w{1,4}:\\w{1,4}/', $this->BlockAddress)) {
         $this->showLogFragment($wgOut, Title::makeTitle(NS_USER, $this->BlockAddress));
     }
 }
 protected function speedcatDropdownRows()
 {
     global $wgAdvancedSearchSpeedCatDropdown, $wgRequest;
     if (!isset($wgAdvancedSearchSpeedCatDropdown) || empty($wgAdvancedSearchSpeedCatDropdown)) {
         return '';
     }
     $sel = $wgRequest->getVal('scdd');
     $retval = Xml::openElement('tr');
     $retval .= Xml::openElement('td', array('colspan' => 3));
     $retval .= wfMsg('advancedsearch-speedcat-dropdown');
     $retval .= Xml::openElement('select', array('name' => 'scdd'));
     $retval .= Xml::option('', '', is_null($sel));
     foreach (@$wgAdvancedSearchSpeedCatDropdown as $key => $value) {
         if (is_int($key)) {
             $key = $value;
         }
         $retval .= Xml::option($key, $value, $sel == $value);
     }
     $retval .= Xml::closeElement('select');
     $retval .= Xml::closeElement('td');
     $retval .= Xml::closeElement('tr');
     return $retval;
 }
Esempio n. 17
0
    protected function openShowImage()
    {
        global $wgImageLimits, $wgEnableUploads, $wgSend404Code;
        $this->loadFile();
        $out = $this->getContext()->getOutput();
        $user = $this->getContext()->getUser();
        $lang = $this->getContext()->getLanguage();
        $dirmark = $lang->getDirMarkEntity();
        $request = $this->getContext()->getRequest();
        $sizeSel = intval($user->getOption('imagesize'));
        if (!isset($wgImageLimits[$sizeSel])) {
            $sizeSel = User::getDefaultOption('imagesize');
            // The user offset might still be incorrect, specially if
            // $wgImageLimits got changed (see bug #8858).
            if (!isset($wgImageLimits[$sizeSel])) {
                // Default to the first offset in $wgImageLimits
                $sizeSel = 0;
            }
        }
        $max = $wgImageLimits[$sizeSel];
        $maxWidth = $max[0];
        $maxHeight = $max[1];
        if ($this->displayImg->exists()) {
            # image
            $page = $request->getIntOrNull('page');
            if (is_null($page)) {
                $params = array();
                $page = 1;
            } else {
                $params = array('page' => $page);
            }
            $width_orig = $this->displayImg->getWidth($page);
            $width = $width_orig;
            $height_orig = $this->displayImg->getHeight($page);
            $height = $height_orig;
            $longDesc = wfMessage('parentheses', $this->displayImg->getLongDesc())->text();
            wfRunHooks('ImageOpenShowImageInlineBefore', array(&$this, &$out));
            if ($this->displayImg->allowInlineDisplay()) {
                # image
                # "Download high res version" link below the image
                # $msgsize = wfMessage( 'file-info-size', $width_orig, $height_orig, Linker::formatSize( $this->displayImg->getSize() ), $mime )->escaped();
                # We'll show a thumbnail of this image
                if ($width > $maxWidth || $height > $maxHeight) {
                    # Calculate the thumbnail size.
                    # First case, the limiting factor is the width, not the height.
                    if ($width / $height >= $maxWidth / $maxHeight) {
                        $height = round($height * $maxWidth / $width);
                        $width = $maxWidth;
                        # Note that $height <= $maxHeight now.
                    } else {
                        $newwidth = floor($width * $maxHeight / $height);
                        $height = round($height * $newwidth / $width);
                        $width = $newwidth;
                        # Note that $height <= $maxHeight now, but might not be identical
                        # because of rounding.
                    }
                    $msgbig = wfMessage('show-big-image')->escaped();
                    if ($this->displayImg->getRepo()->canTransformVia404()) {
                        $thumbSizes = $wgImageLimits;
                    } else {
                        # Creating thumb links triggers thumbnail generation.
                        # Just generate the thumb for the current users prefs.
                        $thumbOption = $user->getOption('thumbsize');
                        $thumbSizes = array(isset($wgImageLimits[$thumbOption]) ? $wgImageLimits[$thumbOption] : $wgImageLimits[User::getDefaultOption('thumbsize')]);
                    }
                    # Generate thumbnails or thumbnail links as needed...
                    $otherSizes = array();
                    foreach ($thumbSizes as $size) {
                        if ($size[0] < $width_orig && $size[1] < $height_orig && $size[0] != $width && $size[1] != $height) {
                            $otherSizes[] = $this->makeSizeLink($params, $size[0], $size[1]);
                        }
                    }
                    $msgsmall = wfMessage('show-big-image-preview')->rawParams($this->makeSizeLink($params, $width, $height))->parse();
                    if (count($otherSizes)) {
                        $msgsmall .= ' ' . Html::rawElement('span', array('class' => 'mw-filepage-other-resolutions'), wfMessage('show-big-image-other')->rawParams($lang->pipeList($otherSizes))->params(count($otherSizes))->parse());
                    }
                } elseif ($width == 0 && $height == 0) {
                    # Some sort of audio file that doesn't have dimensions
                    # Don't output a no hi res message for such a file
                    $msgsmall = '';
                } elseif ($this->displayImg->isVectorized()) {
                    # For vectorized images, full size is just the frame size
                    $msgsmall = '';
                } else {
                    # Image is small enough to show full size on image page
                    $msgsmall = wfMessage('file-nohires')->parse();
                }
                $params['width'] = $width;
                $params['height'] = $height;
                $thumbnail = $this->displayImg->transform($params);
                $showLink = true;
                $anchorclose = Html::rawElement('div', array('class' => 'mw-filepage-resolutioninfo'), $msgsmall);
                $isMulti = $this->displayImg->isMultipage() && $this->displayImg->pageCount() > 1;
                if ($isMulti) {
                    $out->addHTML('<table class="multipageimage"><tr><td>');
                }
                if ($thumbnail) {
                    $options = array('alt' => $this->displayImg->getTitle()->getPrefixedText(), 'file-link' => true);
                    $out->addHTML('<div class="fullImageLink" id="file">' . $thumbnail->toHtml($options) . $anchorclose . "</div>\n");
                }
                if ($isMulti) {
                    $count = $this->displayImg->pageCount();
                    if ($page > 1) {
                        $label = $out->parse(wfMessage('imgmultipageprev')->text(), false);
                        $link = Linker::linkKnown($this->getTitle(), $label, array(), array('page' => $page - 1));
                        $thumb1 = Linker::makeThumbLinkObj($this->getTitle(), $this->displayImg, $link, $label, 'none', array('page' => $page - 1));
                    } else {
                        $thumb1 = '';
                    }
                    if ($page < $count) {
                        $label = wfMessage('imgmultipagenext')->text();
                        $link = Linker::linkKnown($this->getTitle(), $label, array(), array('page' => $page + 1));
                        $thumb2 = Linker::makeThumbLinkObj($this->getTitle(), $this->displayImg, $link, $label, 'none', array('page' => $page + 1));
                    } else {
                        $thumb2 = '';
                    }
                    global $wgScript;
                    $formParams = array('name' => 'pageselector', 'action' => $wgScript, 'onchange' => 'document.pageselector.submit();');
                    $options = array();
                    for ($i = 1; $i <= $count; $i++) {
                        $options[] = Xml::option($lang->formatNum($i), $i, $i == $page);
                    }
                    $select = Xml::tags('select', array('id' => 'pageselector', 'name' => 'page'), implode("\n", $options));
                    $out->addHTML('</td><td><div class="multipageimagenavbox">' . Xml::openElement('form', $formParams) . Html::hidden('title', $this->getTitle()->getPrefixedDBkey()) . wfMessage('imgmultigoto')->rawParams($select)->parse() . Xml::submitButton(wfMessage('imgmultigo')->text()) . Xml::closeElement('form') . "<hr />{$thumb1}\n{$thumb2}<br style=\"clear: both\" /></div></td></tr></table>");
                }
            } else {
                # if direct link is allowed but it's not a renderable image, show an icon.
                if ($this->displayImg->isSafeFile()) {
                    $icon = $this->displayImg->iconThumb();
                    $out->addHTML('<div class="fullImageLink" id="file">' . $icon->toHtml(array('file-link' => true)) . "</div>\n");
                }
                $showLink = true;
            }
            if ($showLink) {
                $filename = wfEscapeWikiText($this->displayImg->getName());
                $linktext = $filename;
                if (isset($msgbig)) {
                    $linktext = wfEscapeWikiText($msgbig);
                }
                $medialink = "[[Media:{$filename}|{$linktext}]]";
                if (!$this->displayImg->isSafeFile()) {
                    $warning = wfMessage('mediawarning')->plain();
                    // dirmark is needed here to separate the file name, which
                    // most likely ends in Latin characters, from the description,
                    // which may begin with the file type. In RTL environment
                    // this will get messy.
                    // The dirmark, however, must not be immediately adjacent
                    // to the filename, because it can get copied with it.
                    // See bug 25277.
                    $out->addWikiText(<<<EOT
<div class="fullMedia"><span class="dangerousLink">{$medialink}</span> {$dirmark}<span class="fileInfo">{$longDesc}</span></div>
<div class="mediaWarning">{$warning}</div>
EOT
);
                } else {
                    $out->addWikiText(<<<EOT
<div class="fullMedia">{$medialink} {$dirmark}<span class="fileInfo">{$longDesc}</span>
</div>
EOT
);
                }
            }
            // Add cannot animate thumbnail warning
            if (!$this->displayImg->canAnimateThumbIfAppropriate()) {
                // Include the extension so wiki admins can
                // customize it on a per file-type basis
                // (aka say things like use format X instead).
                // additionally have a specific message for
                // file-no-thumb-animation-gif
                $ext = $this->displayImg->getExtension();
                $noAnimMesg = wfMessageFallback('file-no-thumb-animation-' . $ext, 'file-no-thumb-animation')->plain();
                $out->addWikiText(<<<EOT
<div class="mw-noanimatethumb">{$noAnimMesg}</div>
EOT
);
            }
            if (!$this->displayImg->isLocal()) {
                $this->printSharedImageText();
            }
        } else {
            # Image does not exist
            if (!$this->getID()) {
                # No article exists either
                # Show deletion log to be consistent with normal articles
                LogEventsList::showLogExtract($out, array('delete', 'move'), $this->getTitle()->getPrefixedText(), '', array('lim' => 10, 'conds' => array("log_action != 'revision'"), 'showIfEmpty' => false, 'msgKey' => array('moveddeleted-notice')));
            }
            if ($wgEnableUploads && $user->isAllowed('upload')) {
                // Only show an upload link if the user can upload
                $uploadTitle = SpecialPage::getTitleFor('Upload');
                $nofile = array('filepage-nofile-link', $uploadTitle->getFullURL(array('wpDestFile' => $this->mPage->getFile()->getName())));
            } else {
                $nofile = 'filepage-nofile';
            }
            // Note, if there is an image description page, but
            // no image, then this setRobotPolicy is overriden
            // by Article::View().
            $out->setRobotPolicy('noindex,nofollow');
            $out->wrapWikiMsg("<div id='mw-imagepage-nofile' class='plainlinks'>\n\$1\n</div>", $nofile);
            if (!$this->getID() && $wgSend404Code) {
                // If there is no image, no shared image, and no description page,
                // output a 404, to be consistent with articles.
                $request->response()->header('HTTP/1.1 404 Not Found');
            }
        }
        $out->setFileVersion($this->displayImg);
    }
 /**
  * Get a selector of time period options
  * @param int $selected, selected level
  */
 protected function getPeriodMenu($selected = null)
 {
     $s = '<label for="period">' . wfMsgHtml('checkuser-period') . '</label>&#160;';
     $s .= Xml::openElement('select', array('name' => 'period', 'id' => 'period', 'style' => 'margin-top:.2em;'));
     $s .= Xml::option(wfMsg('checkuser-week-1'), 7, $selected === 7);
     $s .= Xml::option(wfMsg('checkuser-week-2'), 14, $selected === 14);
     $s .= Xml::option(wfMsg('checkuser-month'), 31, $selected === 31);
     $s .= Xml::option(wfMsg('checkuser-all'), 0, $selected === 0);
     $s .= Xml::closeElement('select') . "\n";
     return $s;
 }
Esempio n. 19
0
 /**
  * @static
  * @param string $status
  * @param CodeView $view
  * @return string
  */
 static function buildStatusList($status, $view)
 {
     $states = CodeRevision::getPossibleStates();
     $out = '';
     foreach ($states as $state) {
         $out .= Xml::option($view->statusDesc($state), $state, $status === $state);
     }
     return $out;
 }
 /**
  * @return string
  */
 function getPageHeader()
 {
     list($self) = explode('/', $this->getTitle()->getPrefixedDBkey());
     # Form tag
     $out = Xml::openElement('form', array('method' => 'get', 'action' => wfScript(), 'id' => 'mw-listusers-form')) . Xml::fieldset($this->msg('listusers')->text()) . Html::hidden('title', $self);
     # Username field
     $out .= Xml::label($this->msg('listusersfrom')->text(), 'offset') . ' ' . Html::input('username', $this->requestedUser, 'text', array('id' => 'offset', 'size' => 20, 'autofocus' => $this->requestedUser === '')) . ' ';
     # Group drop-down list
     $out .= Xml::label($this->msg('group')->text(), 'group') . ' ' . Xml::openElement('select', array('name' => 'group', 'id' => 'group')) . Xml::option($this->msg('group-all')->text(), '');
     foreach ($this->getAllGroups() as $group => $groupText) {
         $out .= Xml::option($groupText, $group, $group == $this->requestedGroup);
     }
     $out .= Xml::closeElement('select') . '<br />';
     $out .= Xml::checkLabel($this->msg('listusers-editsonly')->text(), 'editsOnly', 'editsOnly', $this->editsOnly);
     $out .= '&#160;';
     $out .= Xml::checkLabel($this->msg('listusers-creationsort')->text(), 'creationSort', 'creationSort', $this->creationSort);
     $out .= '&#160;';
     $out .= Xml::checkLabel($this->msg('listusers-desc')->text(), 'desc', 'desc', $this->mDefaultDirection);
     $out .= '<br />';
     Hooks::run('SpecialListusersHeaderForm', array($this, &$out));
     # Submit button and form bottom
     $out .= Html::hidden('limit', $this->mLimit);
     $out .= Xml::submitButton($this->msg('allpagessubmit')->text());
     Hooks::run('SpecialListusersHeader', array($this, &$out));
     $out .= Xml::closeElement('fieldset') . Xml::closeElement('form');
     return $out;
 }
Esempio n. 21
0
 /**
  * Output a drop-down box for language options for the file
  *
  * @param Array $langChoices Array of string language codes
  * @param String $curLang Language code file is being viewed in.
  * @param String $defaultLang Language code that image is rendered in by default
  * @return String HTML to insert underneath image.
  */
 protected function doRenderLangOpt(array $langChoices, $curLang, $defaultLang)
 {
     global $wgScript;
     sort($langChoices);
     $curLang = wfBCP47($curLang);
     $defaultLang = wfBCP47($defaultLang);
     $opts = '';
     $haveCurrentLang = false;
     $haveDefaultLang = false;
     // We make a list of all the language choices in the file.
     // Additionally if the default language to render this file
     // is not included as being in this file (for example, in svgs
     // usually the fallback content is the english content) also
     // include a choice for that. Last of all, if we're viewing
     // the file in a language not on the list, add it as a choice.
     foreach ($langChoices as $lang) {
         $code = wfBCP47($lang);
         $name = Language::fetchLanguageName($code, $this->getContext()->getLanguage()->getCode());
         if ($name !== '') {
             $display = wfMessage('img-lang-opt', $code, $name)->text();
         } else {
             $display = $code;
         }
         $opts .= "\n" . Xml::option($display, $code, $curLang === $code);
         if ($curLang === $code) {
             $haveCurrentLang = true;
         }
         if ($defaultLang === $code) {
             $haveDefaultLang = true;
         }
     }
     if (!$haveDefaultLang) {
         // Its hard to know if the content is really in the default language, or
         // if its just unmarked content that could be in any language.
         $opts = Xml::option(wfMessage('img-lang-default')->text(), $defaultLang, $defaultLang === $curLang) . $opts;
     }
     if (!$haveCurrentLang && $defaultLang !== $curLang) {
         $name = Language::fetchLanguageName($curLang, $this->getContext()->getLanguage()->getCode());
         if ($name !== '') {
             $display = wfMessage('img-lang-opt', $curLang, $name)->text();
         } else {
             $display = $curLang;
         }
         $opts = Xml::option($display, $curLang, true) . $opts;
     }
     $select = Html::rawElement('select', array('id' => 'mw-imglangselector', 'name' => 'lang'), $opts);
     $submit = Xml::submitButton(wfMessage('img-lang-go')->text());
     $formContents = wfMessage('img-lang-info')->rawParams($select, $submit)->parse() . Html::hidden('title', $this->getTitle()->getPrefixedDBkey());
     $langSelectLine = Html::rawElement('div', array('id' => 'mw-imglangselector-line'), Html::rawElement('form', array('action' => $wgScript), $formContents));
     return $langSelectLine;
 }
 function buildSelector($action, $selected)
 {
     global $wgRestrictionLevels;
     $id = 'mwProtect-level-' . $action;
     $attribs = array('id' => $id, 'name' => $id, 'size' => count($wgRestrictionLevels), 'onchange' => 'protectLevelsUpdate(this)') + $this->disabledAttrib;
     $out = wfOpenElement('select', $attribs);
     foreach ($wgRestrictionLevels as $key) {
         $out .= Xml::option($this->getOptionLabel($key), $key, $key == $selected);
     }
     $out .= "</select>\n";
     return $out;
 }
 /**
  * @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;
 }
Esempio n. 24
0
    protected function openShowImage()
    {
        global $wgOut, $wgUser, $wgImageLimits, $wgRequest, $wgLang, $wgContLang, $wgEnableUploads;
        $this->loadFile();
        $sizeSel = intval($wgUser->getOption('imagesize'));
        if (!isset($wgImageLimits[$sizeSel])) {
            $sizeSel = User::getDefaultOption('imagesize');
            // The user offset might still be incorrect, specially if
            // $wgImageLimits got changed (see bug #8858).
            if (!isset($wgImageLimits[$sizeSel])) {
                // Default to the first offset in $wgImageLimits
                $sizeSel = 0;
            }
        }
        $max = $wgImageLimits[$sizeSel];
        $maxWidth = $max[0];
        $maxHeight = $max[1];
        $sk = $wgUser->getSkin();
        $dirmark = $wgContLang->getDirMark();
        if ($this->displayImg->exists()) {
            # image
            $page = $wgRequest->getIntOrNull('page');
            if (is_null($page)) {
                $params = array();
                $page = 1;
            } else {
                $params = array('page' => $page);
            }
            $width_orig = $this->displayImg->getWidth($page);
            $width = $width_orig;
            $height_orig = $this->displayImg->getHeight($page);
            $height = $height_orig;
            $longDesc = wfMsg('parentheses', $this->displayImg->getLongDesc());
            wfRunHooks('ImageOpenShowImageInlineBefore', array(&$this, &$wgOut));
            if ($this->displayImg->allowInlineDisplay()) {
                # image
                # "Download high res version" link below the image
                # $msgsize = wfMsgHtml('file-info-size', $width_orig, $height_orig, $sk->formatSize( $this->displayImg->getSize() ), $mime );
                # We'll show a thumbnail of this image
                if ($width > $maxWidth || $height > $maxHeight) {
                    # Calculate the thumbnail size.
                    # First case, the limiting factor is the width, not the height.
                    if ($width / $height >= $maxWidth / $maxHeight) {
                        $height = round($height * $maxWidth / $width);
                        $width = $maxWidth;
                        # Note that $height <= $maxHeight now.
                    } else {
                        $newwidth = floor($width * $maxHeight / $height);
                        $height = round($height * $newwidth / $width);
                        $width = $newwidth;
                        # Note that $height <= $maxHeight now, but might not be identical
                        # because of rounding.
                    }
                    $msgbig = wfMsgHtml('show-big-image');
                    $msgsmall = wfMsgExt('show-big-image-thumb', 'parseinline', $wgLang->formatNum($width), $wgLang->formatNum($height));
                } else {
                    # Image is small enough to show full size on image page
                    $msgsmall = wfMsgExt('file-nohires', array('parseinline'));
                }
                $params['width'] = $width;
                $thumbnail = $this->displayImg->transform($params);
                $showLink = true;
                $anchorclose = '';
                if (!$this->displayImg->mustRender()) {
                    $anchorclose = "<br />" . $msgsmall;
                }
                $isMulti = $this->displayImg->isMultipage() && $this->displayImg->pageCount() > 1;
                if ($isMulti) {
                    $wgOut->addHTML('<table class="multipageimage"><tr><td>');
                }
                if ($thumbnail) {
                    $options = array('alt' => $this->displayImg->getTitle()->getPrefixedText(), 'file-link' => true);
                    $wgOut->addHTML('<div class="fullImageLink" id="file">' . $thumbnail->toHtml($options) . $anchorclose . "</div>\n");
                }
                if ($isMulti) {
                    $count = $this->displayImg->pageCount();
                    if ($page > 1) {
                        $label = $wgOut->parse(wfMsg('imgmultipageprev'), false);
                        $link = $sk->link($this->mTitle, $label, array(), array('page' => $page - 1), array('known', 'noclasses'));
                        $thumb1 = $sk->makeThumbLinkObj($this->mTitle, $this->displayImg, $link, $label, 'none', array('page' => $page - 1));
                    } else {
                        $thumb1 = '';
                    }
                    if ($page < $count) {
                        $label = wfMsg('imgmultipagenext');
                        $link = $sk->link($this->mTitle, $label, array(), array('page' => $page + 1), array('known', 'noclasses'));
                        $thumb2 = $sk->makeThumbLinkObj($this->mTitle, $this->displayImg, $link, $label, 'none', array('page' => $page + 1));
                    } else {
                        $thumb2 = '';
                    }
                    global $wgScript;
                    $formParams = array('name' => 'pageselector', 'action' => $wgScript, 'onchange' => 'document.pageselector.submit();');
                    for ($i = 1; $i <= $count; $i++) {
                        $options[] = Xml::option($wgLang->formatNum($i), $i, $i == $page);
                    }
                    $select = Xml::tags('select', array('id' => 'pageselector', 'name' => 'page'), implode("\n", $options));
                    $wgOut->addHTML('</td><td><div class="multipageimagenavbox">' . Xml::openElement('form', $formParams) . Html::hidden('title', $this->getTitle()->getPrefixedDbKey()) . wfMsgExt('imgmultigoto', array('parseinline', 'replaceafter'), $select) . Xml::submitButton(wfMsg('imgmultigo')) . Xml::closeElement('form') . "<hr />{$thumb1}\n{$thumb2}<br clear=\"all\" /></div></td></tr></table>");
                }
            } else {
                # if direct link is allowed but it's not a renderable image, show an icon.
                if ($this->displayImg->isSafeFile()) {
                    $icon = $this->displayImg->iconThumb();
                    $wgOut->addHTML('<div class="fullImageLink" id="file">' . $icon->toHtml(array('file-link' => true)) . "</div>\n");
                }
                $showLink = true;
            }
            if ($showLink) {
                $filename = wfEscapeWikiText($this->displayImg->getName());
                $linktext = $filename;
                if (isset($msgbig)) {
                    $linktext = wfEscapeWikiText($msgbig);
                }
                $medialink = "[[Media:{$filename}|{$linktext}]]";
                if (!$this->displayImg->isSafeFile()) {
                    $warning = wfMsgNoTrans('mediawarning');
                    $wgOut->addWikiText(<<<EOT
<div class="fullMedia"><span class="dangerousLink">{$medialink}</span>{$dirmark} <span class="fileInfo">{$longDesc}</span></div>
<div class="mediaWarning">{$warning}</div>
EOT
);
                } else {
                    $wgOut->addWikiText(<<<EOT
<div class="fullMedia">{$medialink}{$dirmark} <span class="fileInfo">{$longDesc}</span>
</div>
EOT
);
                }
            }
            if (!$this->displayImg->isLocal()) {
                $this->printSharedImageText();
            }
        } else {
            # Image does not exist
            if ($wgEnableUploads && $wgUser->isAllowed('upload')) {
                // Only show an upload link if the user can upload
                $uploadTitle = SpecialPage::getTitleFor('Upload');
                $nofile = array('filepage-nofile-link', $uploadTitle->getFullUrl(array('wpDestFile' => $this->img->getName())));
            } else {
                $nofile = 'filepage-nofile';
            }
            $wgOut->setRobotPolicy('noindex,nofollow');
            $wgOut->wrapWikiMsg("<div id='mw-imagepage-nofile' class='plainlinks'>\n\$1\n</div>", $nofile);
            if (!$this->getID()) {
                // If there is no image, no shared image, and no description page,
                // output a 404, to be consistent with articles.
                $wgRequest->response()->header("HTTP/1.1 404 Not Found");
            }
        }
    }
 public function generateStateDropdown()
 {
     require_once dirname(__FILE__) . '/includes/stateAbbreviations.inc';
     $states = statesMenuXML();
     $state_opts = Xml::option('', '');
     // generate dropdown of state opts
     foreach ($states as $value => $state_name) {
         if ($value !== 'YY' && $value !== 'XX') {
             $selected = $this->getEscapedValue('state') == $value ? true : false;
             $state_opts .= Xml::option($value, $value, $selected);
         }
     }
     $state_menu = Xml::openElement('select', array('name' => 'state', 'id' => 'state'));
     $state_menu .= $state_opts;
     $state_menu .= Xml::closeElement('select');
     return $state_menu;
 }
 /**
  * @param $msg string
  */
 protected function showAccountConfirmForm($msg = '')
 {
     global $wgAccountRequestTypes;
     $out = $this->getOutput();
     $reqUser = $this->getUser();
     $titleObj = $this->getFullTitle();
     $accountReq = $this->accountReq;
     // convenience
     if (!$accountReq || $accountReq->isDeleted() && !$this->showRejects) {
         $out->addHTML($this->msg('confirmaccount-badid')->escaped());
         $out->returnToMain(true, $titleObj);
         return;
     }
     # Output any failure message
     if ($msg != '') {
         $out->addHTML('<div class="errorbox">' . $msg . '</div><div class="visualClear"></div>');
     }
     $out->addWikiMsg('confirmaccount-text');
     $rejectTimestamp = $accountReq->getRejectTimestamp();
     $heldTimestamp = $accountReq->getHeldTimestamp();
     $reason = strlen($accountReq->getHandlingComment()) ? htmlspecialchars($accountReq->getHandlingComment()) : $this->msg('confirmaccount-noreason')->escaped();
     $adminId = $accountReq->getHandlingUser();
     if ($rejectTimestamp) {
         $datim = $this->getLanguage()->timeanddate($rejectTimestamp, true);
         $date = $this->getLanguage()->date($rejectTimestamp, true);
         $time = $this->getLanguage()->time($rejectTimestamp, true);
         # Auto-rejected requests have a user ID of zero
         if ($adminId) {
             $out->addHTML('<p><b>' . $this->msg('confirmaccount-reject', User::whoIs($adminId), $datim, $date, $time)->parse() . '</b></p>');
             $out->addHTML('<p><strong>' . $this->msg('confirmaccount-rational')->escaped() . '</strong><i> ' . $reason . '</i></p>');
         } else {
             $out->addHTML("<p><i> {$reason} </i></p>");
         }
     } elseif ($heldTimestamp) {
         $datim = $this->getLanguage()->timeanddate($heldTimestamp, true);
         $date = $this->getLanguage()->date($heldTimestamp, true);
         $time = $this->getLanguage()->time($heldTimestamp, true);
         $out->addHTML('<p><b>' . $this->msg('confirmaccount-held', User::whoIs($adminId), $datim, $date, $time)->parse() . '</b></p>');
         $out->addHTML('<p><strong>' . $this->msg('confirmaccount-rational')->escaped() . '</strong><i> ' . $reason . '</i></p>');
     }
     $form = Xml::openElement('form', array('method' => 'post', 'name' => 'accountconfirm', 'action' => $titleObj->getLocalUrl()));
     $form .= "<fieldset>";
     $form .= '<legend>' . $this->msg('confirmaccount-leg-user')->escaped() . '</legend>';
     $form .= '<table cellpadding=\'4\'>';
     $form .= "<tr><td>" . Xml::label($this->msg('username')->text(), 'wpNewName') . "</td>";
     $form .= "<td>" . Xml::input('wpNewName', 30, $this->reqUsername, array('id' => 'wpNewName')) . "</td></tr>\n";
     $econf = '';
     if ($accountReq->getEmailAuthTimestamp()) {
         $econf = ' <strong>' . $this->msg('confirmaccount-econf')->escaped() . '</strong>';
     }
     $form .= "<tr><td>" . $this->msg('confirmaccount-email')->escaped() . "</td>";
     $form .= "<td>" . htmlspecialchars($accountReq->getEmail()) . $econf . "</td></tr>\n";
     if (count($wgAccountRequestTypes) > 1) {
         $options = array();
         $form .= "<tr><td><strong>" . $this->msg('confirmaccount-reqtype')->escaped() . "</strong></td><td>";
         foreach ($wgAccountRequestTypes as $i => $params) {
             // Give grep a chance to find the usages: confirmaccount-pos-0, confirmaccount-pos-1
             $options[] = Xml::option($this->msg("confirmaccount-pos-{$i}")->text(), $i, $i == $this->reqType);
         }
         $form .= Xml::openElement('select', array('name' => "wpType"));
         $form .= implode("\n", $options);
         $form .= Xml::closeElement('select') . "\n";
         $form .= "</td></tr>\n";
     }
     $form .= '</table></fieldset>';
     $userAreas = ConfirmAccount::getUserAreaConfig();
     if ($this->hasItem('AreasOfInterest') && count($userAreas) > 0) {
         $form .= '<fieldset>';
         $form .= '<legend>' . $this->msg('confirmaccount-leg-areas')->escaped() . '</legend>';
         $form .= "<div style='height:150px; overflow:scroll; background-color:#f9f9f9;'>";
         $form .= "<table cellspacing='5' cellpadding='0' style='background-color:#f9f9f9;'><tr valign='top'>";
         $count = 0;
         foreach ($userAreas as $name => $conf) {
             $count++;
             if ($count > 5) {
                 $form .= "</tr><tr valign='top'>";
                 $count = 1;
             }
             $formName = "wpArea-" . htmlspecialchars(str_replace(' ', '_', $name));
             if ($conf['project'] != '') {
                 $pg = Linker::linkKnown(Title::newFromText($conf['project']), $this->msg('requestaccount-info')->escaped());
             } else {
                 $pg = '';
             }
             $form .= "<td>" . Xml::checkLabel($name, $formName, $formName, $this->reqAreas[$name] > 0) . " {$pg}</td>\n";
         }
         $form .= "</tr></table></div>";
         $form .= '</fieldset>';
     }
     if ($this->hasItem('Biography') || $this->hasItem('RealName')) {
         $form .= '<fieldset>';
         $form .= '<legend>' . $this->msg('confirmaccount-leg-person')->escaped() . '</legend>';
         if ($this->hasItem('RealName')) {
             $form .= '<table cellpadding=\'4\'>';
             $form .= "<tr><td>" . $this->msg('confirmaccount-real')->escaped() . "</td>";
             $form .= "<td>" . htmlspecialchars($accountReq->getRealName()) . "</td></tr>\n";
             $form .= '</table>';
         }
         if ($this->hasItem('Biography')) {
             $form .= "<p>" . $this->msg('confirmaccount-bio')->escaped() . "\n";
             $form .= "<textarea tabindex='1' name='wpNewBio' id='wpNewBio' rows='12' cols='80' style='width:100%; background-color:#f9f9f9;'>" . htmlspecialchars($this->reqBio) . "</textarea></p>\n";
         }
         $form .= '</fieldset>';
     }
     if ($this->hasItem('CV') || $this->hasItem('Notes') || $this->hasItem('Links')) {
         $form .= '<fieldset>';
         $form .= '<legend>' . $this->msg('confirmaccount-leg-other')->escaped() . '</legend>';
         if ($this->hasItem('CV')) {
             $form .= '<p>' . $this->msg('confirmaccount-attach')->escaped() . ' ';
             if ($accountReq->getFileName() !== null) {
                 $form .= Linker::makeKnownLinkObj($titleObj, htmlspecialchars($accountReq->getFileName()), 'file=' . $accountReq->getFileStorageKey());
             } else {
                 $form .= $this->msg('confirmaccount-none-p')->escaped();
             }
         }
         if ($this->hasItem('Notes')) {
             $form .= "</p><p>" . $this->msg('confirmaccount-notes')->escaped() . "\n";
             $form .= "<textarea tabindex='1' readonly='readonly' name='wpNotes' id='wpNotes' rows='3' cols='80' style='width:100%'>" . htmlspecialchars($accountReq->getNotes()) . "</textarea></p>\n";
         }
         if ($this->hasItem('Links')) {
             $form .= "<p>" . $this->msg('confirmaccount-urls')->escaped() . "</p>\n";
             $form .= self::parseLinks($accountReq->getUrls());
         }
         $form .= '</fieldset>';
     }
     if ($reqUser->isAllowed('requestips')) {
         $blokip = SpecialPage::getTitleFor('Block');
         $link = Linker::makeKnownLinkObj($blokip, $this->msg('confirmaccount-blockip')->escaped(), 'ip=' . $accountReq->getIP() . '&wpCreateAccount=1');
         $form .= '<fieldset>';
         $form .= '<legend>' . $this->msg('confirmaccount-leg-ip')->escaped() . '</legend>';
         $wordSeparator = $this->msg('word-separator')->plain();
         $form .= "<p>";
         // @todo FIXME: Bad i18n. Should probably be something like
         // "confirmaccount-ip $1 ($2)" to get rid of this mess.
         $form .= $this->msg('confirmaccount-ip')->escaped();
         $form .= $wordSeparator;
         $form .= htmlspecialchars($accountReq->getIP());
         $form .= $wordSeparator;
         $form .= $this->msg('parentheses')->rawParams($link)->escaped();
         $form .= "</p>\n";
         if ($accountReq->getXFF()) {
             $form .= "<p>" . $this->msg('confirmaccount-xff')->escaped() . $wordSeparator . htmlspecialchars($accountReq->getXFF()) . "</p>\n";
         }
         if ($accountReq->getAgent()) {
             $form .= "<p>" . $this->msg('confirmaccount-agent')->escaped() . $wordSeparator . htmlspecialchars($accountReq->getAgent()) . "</p>\n";
         }
         $form .= '</fieldset>';
     }
     $form .= '<fieldset>';
     $form .= '<legend>' . $this->msg('confirmaccount-legend')->escaped() . '</legend>';
     $form .= "<strong>" . $this->msg('confirmaccount-confirm')->parse() . "</strong>\n";
     $form .= "<table cellpadding='5'><tr>";
     $form .= "<td>" . Xml::radio('wpSubmitType', 'accept', $this->submitType == 'accept', array('id' => 'submitCreate', 'onclick' => 'document.getElementById("wpComment").style.display="block"'));
     $form .= ' ' . Xml::label($this->msg('confirmaccount-create')->text(), 'submitCreate') . "</td>\n";
     $form .= "<td>" . Xml::radio('wpSubmitType', 'reject', $this->submitType == 'reject', array('id' => 'submitDeny', 'onclick' => 'document.getElementById("wpComment").style.display="block"'));
     $form .= ' ' . Xml::label($this->msg('confirmaccount-deny')->text(), 'submitDeny') . "</td>\n";
     $form .= "<td>" . Xml::radio('wpSubmitType', 'hold', $this->submitType == 'hold', array('id' => 'submitHold', 'onclick' => 'document.getElementById("wpComment").style.display="block"'));
     $form .= ' ' . Xml::label($this->msg('confirmaccount-hold')->text(), 'submitHold') . "</td>\n";
     $form .= "<td>" . Xml::radio('wpSubmitType', 'spam', $this->submitType == 'spam', array('id' => 'submitSpam', 'onclick' => 'document.getElementById("wpComment").style.display="none"'));
     $form .= ' ' . Xml::label($this->msg('confirmaccount-spam')->text(), 'submitSpam') . "</td>\n";
     $form .= "</tr></table>";
     $form .= "<div id='wpComment'><p>" . $this->msg('confirmaccount-reason')->escaped() . "</p>\n";
     $form .= "<p><textarea name='wpReason' id='wpReason' rows='3' cols='80' style='width:80%; display=block;'>" . htmlspecialchars($this->reason) . "</textarea></p></div>\n";
     $form .= "<p>" . Xml::submitButton($this->msg('confirmaccount-submit')->text()) . "</p>\n";
     $form .= '</fieldset>';
     $form .= Html::Hidden('title', $titleObj->getPrefixedDBKey()) . "\n";
     $form .= Html::Hidden('action', 'reject');
     $form .= Html::Hidden('acrid', $accountReq->getId());
     $form .= Html::Hidden('wpShowRejects', $this->showRejects);
     $form .= Html::Hidden('wpEditToken', $reqUser->getEditToken($accountReq->getId())) . "\n";
     $form .= Xml::closeElement('form');
     $out->addHTML($form);
     global $wgMemc;
     # Set a key to who is looking at this request.
     # Have it expire in 10 minutes...
     $key = wfMemcKey('acctrequest', 'view', $accountReq->getId());
     $wgMemc->set($key, $reqUser->getID(), 60 * 10);
 }
Esempio n. 27
0
 /**
  * Build a drop-down box for selecting a namespace
  *
  * @param $params array:
  * - selected: [optional] Id of namespace which should be pre-selected
  * - all: [optional] Value of item for "all namespaces". If null or unset, no <option> is generated to select all namespaces
  * - label: text for label to add before the field
  * @param $selectAttribs array HTML attributes for the generated select element.
  * - id:   [optional], default: 'namespace'
  * - name: [optional], default: 'namespace'
  * @return string HTML code to select a namespace.
  */
 public static function namespaceSelector(array $params = array(), array $selectAttribs = array())
 {
     global $wgContLang;
     // Default 'id' & 'name' <select> attributes
     $selectAttribs = $selectAttribs + array('id' => 'namespace', 'name' => 'namespace');
     ksort($selectAttribs);
     // Is a namespace selected?
     if (isset($params['selected'])) {
         // If string only contains digits, convert to clean int. Selected could also
         // be "all" or "" etc. which needs to be left untouched.
         // PHP is_numeric() has issues with large strings, PHP ctype_digit has other issues
         // and returns false for already clean ints. Use regex instead..
         if (preg_match('/^\\d+$/', $params['selected'])) {
             $params['selected'] = intval($params['selected']);
         }
         // else: leaves it untouched for later processing
     } else {
         $params['selected'] = '';
     }
     // Array holding the <option> elements
     $options = array();
     if (isset($params['all'])) {
         // add an <option> that would let the user select all namespaces.
         // Value is provided by user, the name shown is localized.
         $options[$params['all']] = wfMsg('namespacesall');
     }
     // Add defaults <option> according to content language
     $options += $wgContLang->getFormattedNamespaces();
     // Convert $options to HTML
     $optionsHtml = array();
     foreach ($options as $nsId => $nsName) {
         if ($nsId < NS_MAIN) {
             continue;
         }
         if ($nsId === 0) {
             $nsName = wfMsg('blanknamespace');
         }
         $optionsHtml[] = Xml::option($nsName, $nsId, $nsId === $params['selected']);
     }
     // Forge a <select> element and returns it
     $ret = '';
     if (isset($params['label'])) {
         $ret .= Xml::label($params['label'], $selectAttribs['id']) . '&#160;';
     }
     $ret .= Html::openElement('select', $selectAttribs) . "\n" . implode("\n", $optionsHtml) . "\n" . Html::closeElement('select');
     return $ret;
 }
Esempio n. 28
0
 /**
  * Get a "<select>" element which has options for each of the allowed limits
  *
  * @return String: HTML fragment
  */
 public function getLimitSelect()
 {
     # Add the current limit from the query string
     # to avoid that the limit is lost after clicking Go next time
     if (!in_array($this->mLimit, $this->mLimitsShown)) {
         $this->mLimitsShown[] = $this->mLimit;
         sort($this->mLimitsShown);
     }
     $s = Html::openElement('select', array('name' => 'limit')) . "\n";
     foreach ($this->mLimitsShown as $key => $value) {
         # The pair is either $index => $limit, in which case the $value
         # will be numeric, or $limit => $text, in which case the $value
         # will be a string.
         if (is_int($value)) {
             $limit = $value;
             $text = $this->getLanguage()->formatNum($limit);
         } else {
             $limit = $key;
             $text = $value;
         }
         $s .= Xml::option($text, $limit, $limit == $this->mLimit) . "\n";
     }
     $s .= Html::closeElement('select');
     return $s;
 }
Esempio n. 29
0
 /**
  * This accepts an array of form
  * label => value
  * label => ( label => value, label => value )
  *
  * @param array $options
  * @param bool $default
  * @return string
  */
 static function formatOptions($options, $default = false)
 {
     $data = '';
     foreach ($options as $label => $value) {
         if (is_array($value)) {
             $contents = self::formatOptions($value, $default);
             $data .= Html::rawElement('optgroup', array('label' => $label), $contents) . "\n";
         } else {
             $data .= Xml::option($label, $value, $value === $default) . "\n";
         }
     }
     return $data;
 }
	/**
	 * Show a language selector to allow the user to choose the language to
	 * translate.
	 */
	function showLanguageSelector( $selectedCode ) {
		$s = 
			Xml::openElement( 'form', 
				array( 
					'action' => $this->getTitle( false )->getLocalUrl()
				) 
			) .
			Xml::openElement( 
				'select', 
				array( 'id' => 'secondary_lang', 'name' => 'secondary_lang' ) 
			) . "\n";
		
		$languages = Language::getLanguageNames();
		ksort( $languages );
		foreach ( $languages as $code => $name ) {
			$s .= "\n" . Xml::option( "$code - $name", $code, $code == $selectedCode );
		}
		$s .= "\n</select>\n" . 
			'<p>' . Xml::submitButton( wfMsg( 'securepoll-submit-select-lang' ) ) . '</p>' .
			"</form>\n";
		global $wgOut;
		$wgOut->addHTML( $s );
	}