Esempio n. 1
0
 function doTagRow($tag, $hitcount)
 {
     static $sk = null, $doneTags = array();
     if (!$sk) {
         $sk = $this->getSkin();
     }
     if (in_array($tag, $doneTags)) {
         return '';
     }
     global $wgLang;
     $newRow = '';
     $newRow .= Xml::tags('td', null, Xml::element('tt', null, $tag));
     $disp = ChangeTags::tagDescription($tag);
     $disp .= ' (' . $sk->link(Title::makeTitle(NS_MEDIAWIKI, "Tag-{$tag}"), wfMsgHtml('tags-edit')) . ')';
     $newRow .= Xml::tags('td', null, $disp);
     $msg = wfMessage("tag-{$tag}-description");
     $desc = !$msg->exists() ? '' : $msg->parse();
     $desc .= ' (' . $sk->link(Title::makeTitle(NS_MEDIAWIKI, "Tag-{$tag}-description"), wfMsgHtml('tags-edit')) . ')';
     $newRow .= Xml::tags('td', null, $desc);
     $hitcount = wfMsgExt('tags-hitcount', array('parsemag'), $wgLang->formatNum($hitcount));
     $hitcount = $sk->link(SpecialPage::getTitleFor('Recentchanges'), $hitcount, array(), array('tagfilter' => $tag));
     $newRow .= Xml::tags('td', null, $hitcount);
     $doneTags[] = $tag;
     return Xml::tags('tr', null, $newRow) . "\n";
 }
 /**
  * GetPreferences hook handler.
  * @param $user User
  * @param $preferences Array: Preference descriptions
  */
 public static function getPreferences($user, &$preferences)
 {
     $gadgets = Gadget::loadStructuredList();
     if (!$gadgets) {
         return true;
     }
     $options = array();
     $default = array();
     foreach ($gadgets as $section => $thisSection) {
         $available = array();
         foreach ($thisSection as $gadget) {
             if ($gadget->isAllowed($user)) {
                 $gname = $gadget->getName();
                 # bug 30182: dir="auto" because it's often not translated
                 $desc = '<span dir="auto">' . $gadget->getDescription() . '</span>';
                 $available[$desc] = $gname;
                 if ($gadget->isEnabled($user)) {
                     $default[] = $gname;
                 }
             }
         }
         if ($section !== '') {
             $section = wfMsgExt("gadget-section-{$section}", 'parseinline');
             if (count($available)) {
                 $options[$section] = $available;
             }
         } else {
             $options = array_merge($options, $available);
         }
     }
     $preferences['gadgets-intro'] = array('type' => 'info', 'label' => '&#160;', 'default' => Xml::tags('tr', array(), Xml::tags('td', array('colspan' => 2), wfMsgExt('gadgets-prefstext', 'parse'))), 'section' => 'gadgets', 'raw' => 1, 'rawrow' => 1);
     $preferences['gadgets'] = array('type' => 'multiselect', 'options' => $options, 'section' => 'gadgets', 'label' => '&#160;', 'prefix' => 'gadget-', 'default' => $default);
     return true;
 }
 /**
  * AjaxAddScript hook
  * Adds scripts
  */
 public static function addResources($out)
 {
     global $wgExtensionAssetsPath, $wgJsMimeType;
     global $wgUsabilityInitiativeResourceMode;
     global $wgEnableJS2system, $wgEditToolbarRunTests;
     global $wgStyleVersion;
     wfRunHooks('UsabilityInitiativeLoadModules');
     if (!self::$doOutput) {
         return true;
     }
     // Default to raw
     $mode = $wgUsabilityInitiativeResourceMode;
     // Just an alias
     if (!isset(self::$scriptFiles['base_sets'][$mode])) {
         $mode = 'raw';
     }
     // Include base-set of scripts
     self::$scripts = array_merge(self::$scriptFiles['base_sets'][$mode], self::$scriptFiles['modules'][$mode], self::$scripts);
     // Provide enough support to make things work, even when js2 is not
     // in use (eventually it will be standard, but right now it's not)
     if (!$wgEnableJS2system) {
         $out->includeJQuery();
     }
     // Include base-set of styles
     self::$styles = array_merge(self::$styleFiles['base_sets'][$mode], self::$styles);
     if ($wgEditToolbarRunTests) {
         // Include client side tests
         self::$scripts = array_merge(self::$scripts, self::$scriptFiles['tests']);
     }
     // Loops over each script
     foreach (self::$scripts as $script) {
         // Add javascript to document
         if ($script['src'][0] == '/') {
             // Path is relative to $wgScriptPath
             global $wgScriptPath;
             $src = "{$wgScriptPath}{$script['src']}";
         } else {
             // Path is relative to $wgExtensionAssetsPath
             $src = "{$wgExtensionAssetsPath}/UsabilityInitiative/{$script['src']}";
         }
         $version = isset($script['version']) ? $script['version'] : $wgStyleVersion;
         $out->addScriptFile($src, $version);
     }
     // Transforms messages into javascript object members
     foreach (self::$messages as $i => $message) {
         $escapedMessageValue = Xml::escapeJsString(wfMsg($message));
         $escapedMessageKey = Xml::escapeJsString($message);
         self::$messages[$i] = "'{$escapedMessageKey}':'{$escapedMessageValue}'";
     }
     // Add javascript to document
     if (count(self::$messages) > 0) {
         $out->addScript(Xml::tags('script', array('type' => $wgJsMimeType), 'mw.usability.addMessages({' . implode(',', self::$messages) . '});'));
     }
     // Loops over each style
     foreach (self::$styles as $style) {
         // Add css for various styles
         $out->addLink(array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => $wgExtensionAssetsPath . "/UsabilityInitiative/" . "{$style['src']}?{$style['version']}"));
     }
     return true;
 }
 public function generateFormStart()
 {
     $form = $this->generateBannerHeader();
     $form .= Xml::openElement('div', array('id' => 'mw-creditcard'));
     // provide a place at the top of the form for displaying general messages
     if ($this->form_errors['general']) {
         $form .= Xml::openElement('div', array('id' => 'mw-payflow-general-error'));
         if (is_array($this->form_errors['general'])) {
             foreach ($this->form_errors['general'] as $this->form_errors_msg) {
                 $form .= Xml::tags('p', array('class' => 'creditcard-error-msg'), $this->form_errors_msg);
             }
         } else {
             $form .= Xml::tags('p', array('class' => 'creditcard-error-msg'), $this->form_errors_msg);
         }
         $form .= Xml::closeElement('div');
     }
     // add noscript tags for javascript disabled browsers
     $form .= $this->getNoScript();
     // open form
     $form .= Xml::openElement('div', array('id' => 'mw-creditcard-form'));
     // Xml::element seems to convert html to htmlentities
     $form .= "<p class='creditcard-error-msg'>" . $this->form_errors['retryMsg'] . "</p>";
     $form .= Xml::openElement('form', array('name' => 'payment', 'method' => 'post', 'action' => $this->getNoCacheAction(), 'onsubmit' => 'return formCheck(this)', 'autocomplete' => 'off'));
     $form .= Xml::openElement('div', array('id' => 'left-column', 'class' => 'payflow-cc-form-section'));
     $form .= $this->generatePersonalContainer();
     $form .= Xml::closeElement('div');
     // close div#left-column
     $form .= Xml::openElement('div', array('id' => 'right-column', 'class' => 'payflow-cc-form-section'));
     $form .= $this->generatePaymentContainer();
     return $form;
 }
Esempio n. 5
0
function redircite_render($input, $args, &$parser) {
	// Generate HTML code and add it to the $redirciteMarkerList array
	// Add "xx-redircite-marker-NUMBER-redircite-xx" to the output,
	// which will be translated to the HTML stored in $redirciteMarkerList by
	// redircite_afterTidy()
	global $redirciteMarkerList;
	# Verify that $input is a valid title
	$inputTitle = Title::newFromText($input);
	if(!$inputTitle)
		return $input;
	$link1 = $parser->recursiveTagParse("[[$input]]");
	$title1 = Title::newFromText($input);
	if(!$title1->exists()) // Page doesn't exist
		// Just output a normal (red) link
		return $link1;
	$articleObj = new Article($title1);
	$title2 = Title::newFromRedirect($articleObj->fetchContent());
	if(!$title2) // Page is not a redirect
		// Just output a normal link
		return $link1;
	
	$link2 = $parser->recursiveTagParse("[[{$title2->getPrefixedText()}|$input]]");
	
	$marker = "xx-redircite-marker-" . count($redirciteMarkerList) . "-redircite-xx";
	$onmouseout = 'this.firstChild.innerHTML = "'. Xml::escapeJsString($input) . '";';
	$onmouseover = 'this.firstChild.innerHTML = "' . Xml::escapeJsString($title2->getPrefixedText()) . '";';
	return Xml::tags('span', array(
					'onmouseout' => $onmouseout,
					'onmouseover' => $onmouseover),
					$link2);
}
 public function getDiv($value)
 {
     global $wgOut, $wgPromoterAdPreview;
     if (array_key_exists('language', $this->mParams)) {
         $language = $this->mParams['language'];
     } else {
         $language = $wgOut->getContext()->getLanguage()->getCode();
     }
     $html = Xml::openElement('div', array('id' => Sanitizer::escapeId("pr-ad-list-element-{$this->mParams['ad']}"), 'class' => "pr-ad-list-element"));
     // Make the label; this consists of a text link to the ad editor, and a series of status icons
     if (array_key_exists('withlabel', $this->mParams)) {
         $adName = $this->mParams['ad'];
         $html .= Xml::openElement('div', array('class' => 'pr-ad-list-element-label'));
         $html .= Linker::link(SpecialPage::getTitleFor('PromoterAds', "edit/{$adName}"), htmlspecialchars($adName), array('class' => 'pr-ad-list-element-label-text'));
         $html .= ' (' . Linker::link(SpecialPage::getTitleFor('Randompage'), $this->msg('promoter-live-preview'), array('class' => 'pr-ad-list-element-label-text'), array('ad' => $adName, 'uselang' => $language, 'force' => '1')) . ')';
         // TODO: Output status icons
         $html .= Xml::tags('div', array('class' => 'pr-ad-list-element-label-icons'), '');
         $html .= Xml::closeElement('div');
     }
     // Add the ad preview
     if ($wgPromoterAdPreview) {
         $html .= $this->getInputHTML(null);
     }
     $html .= Xml::closeElement('div');
     return $html;
 }
Esempio n. 7
0
 public static function render($input, $args, $parser, $frame)
 {
     // Disable cache so that CSS will get loaded.
     $parser->disableCache();
     // If this call is contained in a transcluded page or template,
     // or if the input is empty, display nothing.
     if (!$frame->title->equals($parser->getTitle()) || $input == '') {
         return;
     }
     // TODO: Do processing here, like parse to an array
     $error_msg = null;
     // Recreate the top-level <PageSchema> tag, with whatever
     // attributes it contained, because that was actually a tag-
     // function call, as opposed to a real XML tag.
     $input = Xml::tags('PageSchema', $args, $input);
     if ($xml_object = PageSchemas::validateXML($input, $error_msg)) {
         // Store the XML in the page_props table
         $parser->getOutput()->setProperty('PageSchema', $input);
         // Display the schema on the screen
         global $wgOut, $wgScriptPath;
         $wgOut->addStyle($wgScriptPath . '/extensions/PageSchemas/PageSchemas.css');
         $text = PageSchemas::displaySchema($xml_object);
     } else {
         // Store error message in the page_props table
         $parser->getOutput()->setProperty('PageSchema', $error_msg);
         $text = Html::element('p', null, "The (incorrect) XML definition for this template is:") . "\n";
         $text .= Html::element('pre', null, $input);
     }
     return $text;
 }
 function execute($query)
 {
     global $wgUser, $wgOut, $wgRequest;
     $this->setHeaders();
     if (!$wgUser->isAllowed('datatransferimport')) {
         global $wgOut;
         $wgOut->permissionRequired('datatransferimport');
         return;
     }
     if ($wgRequest->getCheck('import_file')) {
         $text = DTUtils::printImportingMessage();
         $uploadResult = ImportStreamSource::newFromUpload("file_name");
         // handling changed in MW 1.17
         if ($uploadResult instanceof Status) {
             $source = $uploadResult->value;
         } else {
             $source = $uploadResult;
         }
         $importSummary = $wgRequest->getVal('import_summary');
         $forPagesThatExist = $wgRequest->getVal('pagesThatExist');
         $text .= self::modifyPages($source, $importSummary, $forPagesThatExist);
     } else {
         $formText = DTUtils::printFileSelector('XML');
         $formText .= DTUtils::printExistingPagesHandling();
         $formText .= DTUtils::printImportSummaryInput('XML');
         $formText .= DTUtils::printSubmitButton();
         $text = "\t" . Xml::tags('form', array('enctype' => 'multipart/form-data', 'action' => '', 'method' => 'post'), $formText) . "\n";
     }
     $wgOut->addHTML($text);
 }
	static function tooltip( $parser, $tooltip = null, $text = null ) {
		if ( !$text ) {
			return;
		}
		
		$tooltip = Xml::tags( 'span',
			array( 'style' => 'display: none', 'class' => 'mw-tooltip' ),
			$tooltip );
		
		$text .= "\n$tooltip";
		$text = Xml::tags( 'span',
			array( 'class' => 'mw-tooltip-text' ), $text );
			
		// Script for hover behaviour hacked in by Andrew Garrett, 2010-08-09
		static $scriptDone = false;
		if ( ! $scriptDone ) {
			$scriptDone = true;
		global $wgOut, $IP, $wgScriptPath;
		$output = $parser->getOutput();
		
		// Figure out the web-accessible path to the extension.
		$dir = dirname( __FILE__ );
		if ( strpos( $dir, $IP ) === 0 ) {
			$dir = substr( $dir, strlen($IP) );
			$dir = $wgScriptPath . $dir;
			
			$output->addHeadItem( "<link rel=\"stylesheet\" type=\"text/css\" href=\"$dir/jquery-tooltip/jquery.tooltip.css\"/>" );
			$output->addHeadItem( Html::linkedScript( "$dir/jquery-tooltip/jquery.tooltip.pack.js" ) );
			$output->addHeadItem( Html::linkedScript( "$dir/hover.js" ) );
		}
		}
		
		return $text;
	}
	/**
	 * Returns HTML5 output of the form
	 * GLOBALS: $wgLang, $wgScript
	 * @return string
	 */
	protected function getForm() {
		global $wgLang, $wgScript;

		$form = Xml::tags( 'form',
			array(
				'action' => $wgScript,
				'method' => 'get'
			),

			'<table><tr><td>' .
				wfMsgHtml( 'translate-page-language' ) .
			'</td><td>' .
				TranslateUtils::languageSelector( $wgLang->getCode(), $this->options['language'] ) .
			'</td></tr><tr><td>' .
				wfMsgHtml( 'translate-magic-module' ) .
			'</td><td>' .
				$this->moduleSelector( $this->options['module'] ) .
			'</td></tr><tr><td colspan="2">' .
				Xml::submitButton( wfMsg( 'translate-magic-submit' ) ) . ' ' .
				Xml::submitButton( wfMsg( 'translate-magic-cm-export' ), array( 'name' => 'export' ) ) .
			'</td></tr></table>' .
			Html::hidden( 'title', $this->getTitle()->getPrefixedText() )
		);
		return $form;
	}
Esempio n. 11
0
 /**
  * Creates HTML for the given tags
  *
  * @param string $tags Comma-separated list of tags
  * @param string $page A label for the type of action which is being displayed,
  *   for example: 'history', 'contributions' or 'newpages'
  * @param IContextSource|null $context
  * @note Even though it takes null as a valid argument, an IContextSource is preferred
  *       in a new code, as the null value is subject to change in the future
  * @return array Array with two items: (html, classes)
  *   - html: String: HTML for displaying the tags (empty string when param $tags is empty)
  *   - classes: Array of strings: CSS classes used in the generated html, one class for each tag
  */
 public static function formatSummaryRow($tags, $page, IContextSource $context = null)
 {
     if (!$tags) {
         return ['', []];
     }
     if (!$context) {
         $context = RequestContext::getMain();
     }
     $classes = [];
     $tags = explode(',', $tags);
     $displayTags = [];
     foreach ($tags as $tag) {
         if (!$tag) {
             continue;
         }
         $description = self::tagDescription($tag, $context);
         if ($description === false) {
             continue;
         }
         $displayTags[] = Xml::tags('span', ['class' => 'mw-tag-marker ' . Sanitizer::escapeClass("mw-tag-marker-{$tag}")], $description);
         $classes[] = Sanitizer::escapeClass("mw-tag-{$tag}");
     }
     if (!$displayTags) {
         return ['', []];
     }
     $markers = $context->msg('tag-list-wrapper')->numParams(count($displayTags))->rawParams($context->getLanguage()->commaList($displayTags))->parse();
     $markers = Xml::tags('span', ['class' => 'mw-tag-markers'], $markers);
     return [$markers, $classes];
 }
Esempio n. 12
0
 function show()
 {
     global $wgOut, $wgUser;
     // Header
     $wgOut->setSubTitle(wfMsg('abusefilter-tools-subtitle'));
     $wgOut->addWikiMsg('abusefilter-tools-text');
     // Expression evaluator
     $eval = '';
     $eval .= AbuseFilter::buildEditBox('', 'wpTestExpr');
     // Only let users with permission actually test it
     if ($wgUser->isAllowed('abusefilter-modify')) {
         $eval .= Xml::tags('p', null, Xml::element('input', array('type' => 'button', 'id' => 'mw-abusefilter-submitexpr', 'onclick' => 'doExprSubmit();', 'value' => wfMsg('abusefilter-tools-submitexpr'))));
         $eval .= Xml::element('p', array('id' => 'mw-abusefilter-expr-result'), ' ');
     }
     $eval = Xml::fieldset(wfMsg('abusefilter-tools-expr'), $eval);
     $wgOut->addHTML($eval);
     // Associated script
     $exprScript = file_get_contents(dirname(__FILE__) . '/tools.js');
     $wgOut->addInlineScript($exprScript);
     global $wgUser;
     if ($wgUser->isAllowed('abusefilter-modify')) {
         // Hacky little box to re-enable autoconfirmed if it got disabled
         $rac = '';
         $rac .= Xml::inputLabel(wfMsg('abusefilter-tools-reautoconfirm-user'), 'wpReAutoconfirmUser', 'reautoconfirm-user', 45);
         $rac .= '&#160;';
         $rac .= Xml::element('input', array('type' => 'button', 'id' => 'mw-abusefilter-reautoconfirmsubmit', 'onclick' => 'doReautoSubmit();', 'value' => wfMsg('abusefilter-tools-reautoconfirm-submit')));
         $rac = Xml::fieldset(wfMsg('abusefilter-tools-reautoconfirm'), $rac);
         $wgOut->addHTML($rac);
     }
 }
Esempio n. 13
0
 function getPageHeader()
 {
     // show the names of the three lists of pages, with the one
     // corresponding to the current "mode" not being linked
     $approvedPagesTitle = SpecialPage::getTitleFor('ApprovedRevs');
     $navLine = wfMessage('approvedrevs-view')->parse() . ' ';
     if ($this->mMode == '') {
         $navLine .= Xml::element('strong', null, wfMessage('approvedrevs-approvedpages')->text());
     } else {
         $navLine .= Xml::element('a', array('href' => $approvedPagesTitle->getLocalURL()), wfMessage('approvedrevs-approvedpages')->text());
     }
     $navLine .= ' | ';
     if ($this->mMode == 'notlatest') {
         $navLine .= Xml::element('strong', null, wfMessage('approvedrevs-notlatestpages')->text());
     } else {
         $navLine .= Xml::element('a', array('href' => $approvedPagesTitle->getLocalURL(array('show' => 'notlatest'))), wfMessage('approvedrevs-notlatestpages')->text());
     }
     $navLine .= ' | ';
     if ($this->mMode == 'unapproved') {
         $navLine .= Xml::element('strong', null, wfMessage('approvedrevs-unapprovedpages')->text());
     } else {
         $navLine .= Xml::element('a', array('href' => $approvedPagesTitle->getLocalURL(array('show' => 'unapproved'))), wfMessage('approvedrevs-unapprovedpages')->text());
     }
     return Xml::tags('p', null, $navLine) . "\n";
 }
 function show()
 {
     $out = $this->getOutput();
     $user = $this->getUser();
     // Header
     $out->addWikiMsg('abusefilter-tools-text');
     // Expression evaluator
     $eval = '';
     $eval .= AbuseFilter::buildEditBox('', 'wpTestExpr');
     // Only let users with permission actually test it
     if ($user->isAllowed('abusefilter-modify')) {
         $eval .= Xml::tags('p', null, Xml::element('input', array('type' => 'button', 'id' => 'mw-abusefilter-submitexpr', 'value' => $this->msg('abusefilter-tools-submitexpr')->text())));
         $eval .= Xml::element('p', array('id' => 'mw-abusefilter-expr-result'), ' ');
     }
     $eval = Xml::fieldset($this->msg('abusefilter-tools-expr')->text(), $eval);
     $out->addHTML($eval);
     $out->addModules('ext.abuseFilter.tools');
     if ($user->isAllowed('abusefilter-modify')) {
         // Hacky little box to re-enable autoconfirmed if it got disabled
         $rac = '';
         $rac .= Xml::inputLabel($this->msg('abusefilter-tools-reautoconfirm-user')->text(), 'wpReAutoconfirmUser', 'reautoconfirm-user', 45);
         $rac .= '&#160;';
         $rac .= Xml::element('input', array('type' => 'button', 'id' => 'mw-abusefilter-reautoconfirmsubmit', 'value' => $this->msg('abusefilter-tools-reautoconfirm-submit')->text()));
         $rac = Xml::fieldset($this->msg('abusefilter-tools-reautoconfirm')->text(), $rac);
         $out->addHTML($rac);
     }
 }
Esempio n. 15
0
 function doTagRow($tag, $hitcount)
 {
     static $sk = null, $doneTags = array();
     if (!$sk) {
         global $wgUser;
         $sk = $wgUser->getSkin();
     }
     if (in_array($tag, $doneTags)) {
         return '';
     }
     $newRow = '';
     $newRow .= Xml::tags('td', null, Xml::element('tt', null, $tag));
     $disp = ChangeTags::tagDescription($tag);
     $disp .= ' (' . $sk->link(Title::makeTitle(NS_MEDIAWIKI, "Tag-{$tag}"), wfMsg('tags-edit')) . ')';
     $newRow .= Xml::tags('td', null, $disp);
     $desc = wfMsgExt("tag-{$tag}-description", 'parseinline');
     $desc = wfEmptyMsg("tag-{$tag}-description", $desc) ? '' : $desc;
     $desc .= ' (' . $sk->link(Title::makeTitle(NS_MEDIAWIKI, "Tag-{$tag}-description"), wfMsg('tags-edit')) . ')';
     $newRow .= Xml::tags('td', null, $desc);
     $hitcount = wfMsg('tags-hitcount', $hitcount);
     $hitcount = $sk->link(SpecialPage::getTitleFor('RecentChanges'), $hitcount, array(), array('tagfilter' => $tag));
     $newRow .= Xml::tags('td', null, $hitcount);
     $doneTags[] = $tag;
     return Xml::tags('tr', null, $newRow) . "\n";
 }
 public function generateFormStart()
 {
     global $wgOut;
     $form = parent::generateBannerHeader();
     $form .= Xml::openElement('table', array('width' => '100%', 'cellspacing' => 0, 'cellpadding' => 0, 'border' => 0));
     $form .= Xml::openElement('tr');
     $form .= Xml::openElement('td', array('id' => 'appeal', 'valign' => 'top'));
     $template = self::generateTextTemplate();
     $form .= $template;
     $form .= Xml::closeElement('td');
     $form .= Xml::openElement('td', array('id' => 'donate', 'valign' => 'top'));
     // add noscript tags for javascript disabled browsers
     $form .= $this->getNoScript();
     $form .= Xml::tags('h2', array('id' => 'donate-head'), wfMsg('donate_interface-please-complete'));
     // provide a place at the top of the form for displaying general messages
     if ($this->form_errors['general']) {
         $form .= Xml::openElement('div', array('id' => 'mw-payflow-general-error'));
         if (is_array($this->form_errors['general'])) {
             foreach ($this->form_errors['general'] as $this->form_errors_msg) {
                 $form .= Xml::tags('p', array('class' => 'creditcard-error-msg'), $this->form_errors_msg);
             }
         } else {
             $form .= Xml::tags('p', array('class' => 'creditcard-error-msg'), $this->form_errors_msg);
         }
         $form .= Xml::closeElement('div');
         // close div#mw-payflow-general-error
     }
     // Xml::element seems to convert html to htmlentities
     $form .= "<p class='creditcard-error-msg'>" . $this->form_errors['retryMsg'] . "</p>";
     $form .= Xml::openElement('form', array('name' => 'payment', 'method' => 'post', 'action' => $this->getNoCacheAction(), 'onsubmit' => 'return formCheck(this)', 'autocomplete' => 'off'));
     $form .= $this->generateBillingContainer();
     return $form;
 }
	function getHtmlResult() {
		$ballot = $this->election->getBallot();
		if ( !is_callable( array( $ballot, 'getColumnLabels' ) ) ) {
			throw new MWException( __METHOD__.': ballot type not supported by this tallier' );
		}
		$optionLabels = array();
		foreach ( $this->question->getOptions() as $option ) {
			$optionLabels[$option->getId()] = $option->parseMessageInline( 'text' );
		}

		$labels = $ballot->getColumnLabels( $this->question );
		$s = "<table class=\"securepoll-table\">\n" .
			"<tr>\n" .
			"<th>&#160;</th>\n";
		foreach ( $labels as $label ) {
			$s .= Xml::element( 'th', array(), $label ) . "\n";
		}
		$s .= Xml::element( 'th', array(), wfMsg( 'securepoll-average-score' ) );
		$s .= "</tr>\n";
		
		foreach ( $this->averages as $oid => $average ) {
			$s .= "<tr>\n" . 
				Xml::tags( 'td', array( 'class' => 'securepoll-results-row-heading' ),
					$optionLabels[$oid] ) .
				"\n";
			foreach ( $labels as $score => $label ) {
				$s .= Xml::element( 'td', array(), $this->histogram[$oid][$score] ) . "\n";
			}
			$s .= Xml::element( 'td', array(), $average ) . "\n";
			$s .= "</tr>\n";
		}
		$s .= "</table>\n";
		return $s;
	}
Esempio n. 18
0
 function doTagRow($tag, $hitcount)
 {
     $user = $this->getUser();
     $newRow = '';
     $newRow .= Xml::tags('td', null, Xml::element('code', null, $tag));
     $disp = ChangeTags::tagDescription($tag);
     if ($user->isAllowed('editinterface')) {
         $disp .= ' ';
         $editLink = Linker::link(Title::makeTitle(NS_MEDIAWIKI, "Tag-{$tag}"), $this->msg('tags-edit')->escaped());
         $disp .= $this->msg('parentheses')->rawParams($editLink)->escaped();
     }
     $newRow .= Xml::tags('td', null, $disp);
     $msg = $this->msg("tag-{$tag}-description");
     $desc = !$msg->exists() ? '' : $msg->parse();
     if ($user->isAllowed('editinterface')) {
         $desc .= ' ';
         $editDescLink = Linker::link(Title::makeTitle(NS_MEDIAWIKI, "Tag-{$tag}-description"), $this->msg('tags-edit')->escaped());
         $desc .= $this->msg('parentheses')->rawParams($editDescLink)->escaped();
     }
     $newRow .= Xml::tags('td', null, $desc);
     $active = isset($this->definedTags[$tag]) ? 'tags-active-yes' : 'tags-active-no';
     $active = $this->msg($active)->escaped();
     $newRow .= Xml::tags('td', null, $active);
     $hitcountLabel = $this->msg('tags-hitcount')->numParams($hitcount)->escaped();
     $hitcountLink = Linker::link(SpecialPage::getTitleFor('Recentchanges'), $hitcountLabel, array(), array('tagfilter' => $tag));
     // add raw $hitcount for sorting, because tags-hitcount contains numbers and letters
     $newRow .= Xml::tags('td', array('data-sort-value' => $hitcount), $hitcountLink);
     return Xml::tags('tr', null, $newRow) . "\n";
 }
Esempio n. 19
0
 function doTagRow($tag, $hitcount)
 {
     static $doneTags = array();
     if (in_array($tag, $doneTags)) {
         return '';
     }
     $newRow = '';
     $newRow .= Xml::tags('td', null, Xml::element('code', null, $tag));
     $disp = ChangeTags::tagDescription($tag);
     $disp .= ' ';
     $editLink = Linker::link(Title::makeTitle(NS_MEDIAWIKI, "Tag-{$tag}"), $this->msg('tags-edit')->escaped());
     $disp .= $this->msg('parentheses')->rawParams($editLink)->escaped();
     $newRow .= Xml::tags('td', null, $disp);
     $msg = $this->msg("tag-{$tag}-description");
     $desc = !$msg->exists() ? '' : $msg->parse();
     $desc .= ' ';
     $editDescLink = Linker::link(Title::makeTitle(NS_MEDIAWIKI, "Tag-{$tag}-description"), $this->msg('tags-edit')->escaped());
     $desc .= $this->msg('parentheses')->rawParams($editDescLink)->escaped();
     $newRow .= Xml::tags('td', null, $desc);
     $hitcount = $this->msg('tags-hitcount')->numParams($hitcount)->escaped();
     $hitcount = Linker::link(SpecialPage::getTitleFor('Recentchanges'), $hitcount, array(), array('tagfilter' => $tag));
     $newRow .= Xml::tags('td', null, $hitcount);
     $doneTags[] = $tag;
     return Xml::tags('tr', null, $newRow) . "\n";
 }
 function show()
 {
     global $wgOut, $wgUser, $wgRequest;
     AbuseFilter::disableConditionLimit();
     if (!$wgUser->isAllowed('abusefilter-modify')) {
         $wgOut->addWikiMsg('abusefilter-mustbeeditor');
         return;
     }
     $this->loadParameters();
     $wgOut->setPageTitle(wfMsg('abusefilter-test'));
     $wgOut->addWikiMsg('abusefilter-test-intro', self::$mChangeLimit);
     $output = '';
     $output .= AbuseFilter::buildEditBox($this->mFilter, 'wpTestFilter') . "\n";
     $output .= Xml::inputLabel(wfMsg('abusefilter-test-load-filter'), 'wpInsertFilter', 'mw-abusefilter-load-filter', 10, '') . '&#160;' . Xml::element('input', array('type' => 'button', 'value' => wfMsg('abusefilter-test-load'), 'id' => 'mw-abusefilter-load'));
     $output = Xml::tags('div', array('id' => 'mw-abusefilter-test-editor'), $output);
     $output .= Xml::tags('p', null, Xml::checkLabel(wfMsg('abusefilter-test-shownegative'), 'wpShowNegative', 'wpShowNegative', $this->mShowNegative));
     // Selectory stuff
     $selectFields = array();
     $selectFields['abusefilter-test-user'] = Xml::input('wpTestUser', 45, $this->mTestUser);
     $selectFields['abusefilter-test-period-start'] = Xml::input('wpTestPeriodStart', 45, $this->mTestPeriodStart);
     $selectFields['abusefilter-test-period-end'] = Xml::input('wpTestPeriodEnd', 45, $this->mTestPeriodEnd);
     $selectFields['abusefilter-test-page'] = Xml::input('wpTestPage', 45, $this->mTestPage);
     $output .= Xml::buildForm($selectFields, 'abusefilter-test-submit');
     $output .= Html::hidden('title', $this->getTitle('test')->getPrefixedText());
     $output = Xml::tags('form', array('action' => $this->getTitle('test')->getLocalURL(), 'method' => 'post'), $output);
     $output = Xml::fieldset(wfMsg('abusefilter-test-legend'), $output);
     $wgOut->addHTML($output);
     if ($wgRequest->wasPosted()) {
         $this->doTest();
     }
 }
Esempio n. 21
0
    function execute($par)
    {
        global $wgOut, $wgUser;
        global $wgFreenodeChatChannel, $wgFreenodeChatExtraParameters;
        // Preperation.
        $this->setHeaders();
        // Introduction message, explaining to users what this is etc.
        $wgOut->addWikiMsg('freenodechat-header');
        // Prepare query string to pass to widget.
        $queryAssoc = array('channels' => $wgFreenodeChatChannel);
        if ($wgUser->IsLoggedIn()) {
            $queryAssoc['nick'] = str_replace(' ', '_', $wgUser->getName());
        }
        if ($wgFreenodeChatExtraParameters) {
            $queryAssoc = array_merge($queryAssoc, $wgFreenodeChatExtraParameters);
        }
        foreach ($queryAssoc as $parameter => $value) {
            $query[] = $parameter . '=' . urlencode($value);
        }
        $queryString = implode('&', $query);
        // Output widget.
        $wgOut->addHTML(Xml::openElement('iframe', array('width' => '1000', 'height' => '500', 'scrolling' => 'no', 'border' => '0', 'onLoad' => 'freenodeChatExpand( this )', 'src' => 'http://webchat.freenode.net/?' . $queryString)) . Xml::closeElement('iframe'));
        // Hack to make the chat area a reasonable size.
        $wgOut->addHTML(Xml::tags('script', array('type' => 'text/javascript'), '/* <![CDATA[ */
function freenodeChatExpand( elem ) {
	height = elem.height;
	width  = elem.width;
	elem.height = screen.height - 500;
	elem.width  = screen.width  - 250;
}
/* ]]> */'));
    }
 function showList()
 {
     global $wgOut, $wgScript;
     $errors = array();
     // Validate search IP
     $ip = $this->mSearchIP;
     if (!IP::isIPAddress($ip) && strlen($ip)) {
         $errors[] = array('globalblocking-list-ipinvalid', $ip);
         $ip = '';
     }
     $wgOut->addWikiMsg('globalblocking-list-intro');
     // Build the search form
     $searchForm = '';
     $searchForm .= Xml::openElement('fieldset') . Xml::element('legend', null, wfMsg('globalblocking-search-legend'));
     $searchForm .= Xml::openElement('form', array('method' => 'get', 'action' => $wgScript, 'name' => 'globalblocklist-search'));
     $searchForm .= Html::hidden('title', SpecialPage::getTitleFor('GlobalBlockList')->getPrefixedText());
     if (is_array($errors) && count($errors) > 0) {
         $errorstr = '';
         foreach ($errors as $error) {
             if (is_array($error)) {
                 $msg = array_shift($error);
             } else {
                 $msg = $error;
                 $error = array();
             }
             $errorstr .= Xml::tags('li', null, wfMsgExt($msg, array('parseinline'), $error));
         }
         $wgOut->addWikiMsg('globalblocking-unblock-errors', count($errors));
         $wgOut->addHTML(Xml::tags('ul', array('class' => 'error'), $errorstr));
     }
     $fields = array();
     $fields['globalblocking-search-ip'] = Xml::input('ip', 45, $ip);
     $searchForm .= Xml::buildForm($fields, 'globalblocking-search-submit');
     $searchForm .= Xml::closeElement('form') . Xml::closeElement('fieldset');
     $wgOut->addHTML($searchForm);
     // Build a list of blocks.
     $conds = array();
     if (strlen($ip)) {
         list($range_start, $range_end) = IP::parseRange($ip);
         if ($range_start != $range_end) {
             // They searched for a range. Match that exact range only
             $conds = array('gb_address' => $ip);
         } else {
             // They searched for an IP. Match any range covering that IP
             $hex_ip = IP::toHex($ip);
             $ip_pattern = substr($hex_ip, 0, 4) . '%';
             // Don't bother checking blocks out of this /16.
             $dbr = wfGetDB(DB_SLAVE);
             $conds = array('gb_range_end>=' . $dbr->addQuotes($hex_ip), 'gb_range_start<=' . $dbr->addQuotes($hex_ip), 'gb_range_start like ' . $dbr->addQuotes($ip_pattern), 'gb_expiry>' . $dbr->addQuotes($dbr->timestamp(wfTimestampNow())));
         }
     }
     $pager = new GlobalBlockListPager($this, $conds);
     $body = $pager->getBody();
     if ($body != '') {
         $wgOut->addHTML($pager->getNavigationBar() . Html::rawElement('ul', array(), $body) . $pager->getNavigationBar());
     } else {
         $wgOut->wrapWikiMsg("<div class='mw-globalblocking-noresults'>\n\$1</div>\n", array('globalblocking-list-noresults'));
     }
 }
Esempio n. 23
0
 /**
  * Wrap some XHTML text in an anchor tag with the given attributes
  */
 protected function linkWrap($linkAttribs, $contents)
 {
     if ($linkAttribs) {
         return Xml::tags('a', $linkAttribs, $contents);
     } else {
         return $contents;
     }
 }
 function formatRow($result)
 {
     global $wgLang;
     $title = Title::makeTitle(NS_CATEGORY, $result->cl_to);
     $titleText = $this->getSkin()->makeLinkObj($title, htmlspecialchars($title->getText()));
     $count = wfMsgExt('nmembers', array('parsemag', 'escape'), $wgLang->formatNum($result->count));
     return Xml::tags('li', null, "{$titleText} ({$count})") . "\n";
 }
 function showHistoryInfo()
 {
     global $wgLang;
     $html = wfMsgExt('lqt_revision_as_of', 'parseinline', array($wgLang->timeanddate($this->mDisplayRevision->getTimestamp()), $wgLang->date($this->mDisplayRevision->getTimestamp()), $wgLang->time($this->mDisplayRevision->getTimestamp())));
     $html .= '<br />';
     $html .= $this->getChangeDescription();
     $html = Xml::tags('div', array('class' => 'lqt_history_info'), $html);
     $this->output->addHTML($html);
 }
 function showList()
 {
     $out = $this->getOutput();
     $pager = new MajorChangesLogPager($this->mModeFilter, $this->mRevTagFilter, $this->mUserFilter, $this->mTitleFilter);
     $pager->doQuery();
     $result = $pager->getResult();
     if ($result && $result->numRows() !== 0) {
         $out->addHTML($pager->getNavigationBar() . Xml::tags('ul', array('class' => 'plainlinks'), $pager->getBody()) . $pager->getNavigationBar());
     } else {
         $out->addWikiMsg('majorchanges-log-noresults');
     }
 }
 /**
  * EditPage::showEditForm:initial hook
  * Adds the modules to the edit form
  */
 public static function addModules(&$toolbar)
 {
     global $wgOut, $wgUser, $wgJsMimeType;
     global $wgWikiEditorModules, $wgUsabilityInitiativeResourceMode;
     // Modules
     $preferences = array();
     $enabledModules = array();
     $modules = $wgWikiEditorModules;
     $modules['global'] = true;
     foreach ($modules as $module => $enable) {
         if ($enable['global'] || $enable['user'] && isset(self::$modules[$module]['preferences']['enable']) && $wgUser->getOption(self::$modules[$module]['preferences']['enable']['key']) || $module == 'global') {
             if ($module !== 'global') {
                 UsabilityInitiativeHooks::initialize();
             }
             $enabledModules[$module] = true;
             // Messages
             if (isset(self::$modules[$module]['i18n'], self::$modules[$module]['messages'])) {
                 wfLoadExtensionMessages(self::$modules[$module]['i18n']);
                 UsabilityInitiativeHooks::addMessages(self::$modules[$module]['messages']);
             }
             // Variables
             if (isset(self::$modules[$module]['variables'])) {
                 $variables = array();
                 foreach (self::$modules[$module]['variables'] as $variable) {
                     global ${$variable};
                     $variables[$variable] = ${$variable};
                 }
                 UsabilityInitiativeHooks::addVariables($variables);
             }
             // Preferences
             if (isset(self::$modules[$module]['preferences'])) {
                 foreach (self::$modules[$module]['preferences'] as $name => $preference) {
                     if (!isset($preferences[$module])) {
                         $preferences[$module] = array();
                     }
                     $preferences[$module][$name] = $wgUser->getOption($preference['key']);
                 }
             }
         } else {
             $enabledModules[$module] = false;
         }
     }
     // Load global messages
     wfLoadExtensionMessages('WikiEditor');
     UsabilityInitiativeHooks::addMessages(self::$messages);
     // Add all scripts
     foreach (self::$scripts[$wgUsabilityInitiativeResourceMode] as $script) {
         UsabilityInitiativeHooks::addScript(basename(dirname(__FILE__)) . '/' . $script['src'], $script['version']);
     }
     // Preferences (maybe the UsabilityInitiative class could do most of this for us?)
     $wgOut->addScript(Xml::tags('script', array('type' => $wgJsMimeType), 'var wgWikiEditorPreferences = ' . FormatJson::encode($preferences, true) . ";\n" . 'var wgWikiEditorEnabledModules = ' . FormatJson::encode($enabledModules, true) . ';'));
     return true;
 }
 function formatRow($row)
 {
     $out = '';
     $data = MBFeedbackItem::load($row);
     $outData = null;
     foreach (SpecialMoodBar::$fields as $field) {
         $outData = MoodBarFormatter::getHTMLRepresentation($data, $field);
         $out .= Xml::tags('td', null, $outData);
     }
     $out = Xml::tags('tr', $this->getRowAttrs($row), $out) . "\n";
     return $out;
 }
 /**
  * BeforePageDisplay hook
  * Adds the modules to the edit form
  */
 public static function addModules()
 {
     global $wgUser, $wgJsMimeType, $wgOut;
     global $wgVectorModules, $wgUsabilityInitiativeResourceMode;
     // Don't load Vector modules for non-Vector skins
     // They won't work but will throw unused JS in the client's face
     // Using instanceof to catch any skins subclassing Vector
     if (!$wgUser->getSkin() instanceof SkinVector) {
         return true;
     }
     // Modules
     $preferences = array();
     $enabledModules = array();
     foreach ($wgVectorModules as $module => $enable) {
         if ($enable['global'] || $enable['user'] && isset(self::$modules[$module]['preferences']['enable']) && $wgUser->getOption(self::$modules[$module]['preferences']['enable']['key'])) {
             UsabilityInitiativeHooks::initialize();
             $enabledModules[$module] = true;
             // Messages
             if (isset(self::$modules[$module]['i18n'], self::$modules[$module]['messages'])) {
                 wfLoadExtensionMessages(self::$modules[$module]['i18n']);
                 UsabilityInitiativeHooks::addMessages(self::$modules[$module]['messages']);
             }
             // Variables
             if (isset(self::$modules[$module]['variables'])) {
                 $variables = array();
                 foreach (self::$modules[$module]['variables'] as $variable) {
                     global ${$variable};
                     $variables[$variable] = ${$variable};
                 }
                 UsabilityInitiativeHooks::addVariables($variables);
             }
             // Preferences
             if (isset(self::$modules[$module]['preferences'])) {
                 foreach (self::$modules[$module]['preferences'] as $name => $preference) {
                     if (!isset($preferences[$module])) {
                         $preferences[$module] = array();
                     }
                     $preferences[$module][$name] = $wgUser->getOption($preference['key']);
                 }
             }
         } else {
             $enabledModules[$module] = false;
         }
     }
     // Add all scripts
     foreach (self::$scripts[$wgUsabilityInitiativeResourceMode] as $script) {
         UsabilityInitiativeHooks::addScript(basename(dirname(__FILE__)) . '/' . $script['src'], $script['version']);
     }
     // Preferences (maybe the UsabilityInitiative class could do most of this for us?)
     $wgOut->addScript(Xml::tags('script', array('type' => $wgJsMimeType), 'var wgVectorPreferences = ' . FormatJson::encode($preferences, true) . ";\n" . 'var wgVectorEnabledModules = ' . FormatJson::encode($enabledModules, true) . ';'));
     return true;
 }
Esempio n. 30
0
 protected function getResultText(SMWQueryResult $res, $outputmode)
 {
     $result = '';
     $columnClasses = array();
     if ($this->mShowHeaders != SMW_HEADERS_HIDE) {
         // building headers
         $headers = array();
         foreach ($res->getPrintRequests() as $pr) {
             $attribs = array();
             $columnClass = str_replace(array(' ', '_'), '-', $pr->getText(SMW_OUTPUT_WIKI));
             $attribs['class'] = $columnClass;
             // Also add this to the array of classes, for
             // use in displaying each row.
             $columnClasses[] = $columnClass;
             $text = $pr->getText($outputmode, $this->mShowHeaders == SMW_HEADERS_PLAIN ? null : $this->mLinker);
             $headers[] = Html::rawElement('th', $attribs, $text === '' ? '&nbsp;' : $text);
         }
         $headers = '<tr>' . implode("\n", $headers) . '</tr>';
         if ($outputmode == SMW_OUTPUT_HTML) {
             $headers = '<thead>' . $headers . '</thead>';
         }
         $headers = "\n{$headers}\n";
         $result .= $headers;
     }
     $tableRows = array();
     $rowNum = 1;
     while ($subject = $res->getNext()) {
         $tableRows[] = $this->getRowForSubject($subject, $outputmode, $columnClasses, $rowNum++);
     }
     $tableRows = implode("\n", $tableRows);
     if ($outputmode == SMW_OUTPUT_HTML) {
         $tableRows = '<tbody>' . $tableRows . '</tbody>';
     }
     $result .= $tableRows;
     // print further results footer
     if ($this->linkFurtherResults($res)) {
         $link = $res->getQueryLink();
         if ($this->getSearchLabel($outputmode)) {
             $link->setCaption($this->getSearchLabel($outputmode));
         }
         $result .= "\t<tr class=\"smwfooter\"><td class=\"sortbottom\" colspan=\"" . $res->getColumnCount() . '"> ' . $link->getText($outputmode, $this->mLinker) . "</td></tr>\n";
     }
     // Put the <table> tag around the whole thing
     $tableAttrs = array('class' => $this->mHTMLClass);
     if ($this->mFormat == 'broadtable') {
         $tableAttrs['width'] = '100%';
     }
     $result = Xml::tags('table', $tableAttrs, $result);
     $this->isHTML = $outputmode == SMW_OUTPUT_HTML;
     // yes, our code can be viewed as HTML if requested, no more parsing needed
     return $result;
 }