function getMessagesFormatted($severity = self::MESSAGE_WARNING, $header = null)
 {
     global $wgTitle, $wgUser;
     $ret = '';
     foreach ($this->mMessages as $message) {
         if ($message[1] <= $severity) {
             $ret .= '* ' . $message[0] . "\n";
         }
     }
     if ($ret != '') {
         if (!$this->mParser) {
             $parser = new Parser();
         }
         if ($header == null) {
             $header = '';
         } elseif ($header != '') {
             $header = Html::rawElement('div', array('class' => 'heading'), $header);
         }
         $ret = Html::rawElement('div', array('class' => 'messages'), $header . "\n" . $ret);
         $ret = $parser->parse($ret, $wgTitle, ParserOptions::newFromUser($wgUser));
     } else {
         $ret = null;
     }
     return $ret;
 }
 /**
  * Function generates Contribution Scores tables in HTML format (not wikiText)
  *
  * @param $days int Days in the past to run report for
  * @param $limit int Maximum number of users to return (default 50)
  *
  * @return HTML Table representing the requested Contribution Scores.
  */
 function genContributionScoreTable($days, $limit, $title = null, $options = 'none')
 {
     global $wgContribScoreIgnoreBots, $wgContribScoreIgnoreBlockedUsers, $wgContribScoresUseRealName, $wgLang;
     $opts = explode(',', strtolower($options));
     $dbr = wfGetDB(DB_SLAVE);
     $userTable = $dbr->tableName('user');
     $userGroupTable = $dbr->tableName('user_groups');
     $revTable = $dbr->tableName('revision');
     $ipBlocksTable = $dbr->tableName('ipblocks');
     $sqlWhere = "";
     $nextPrefix = "WHERE";
     if ($days > 0) {
         $date = time() - 60 * 60 * 24 * $days;
         $dateString = $dbr->timestamp($date);
         $sqlWhere .= " {$nextPrefix} rev_timestamp > '{$dateString}'";
         $nextPrefix = "AND";
     }
     if ($wgContribScoreIgnoreBlockedUsers) {
         $sqlWhere .= " {$nextPrefix} rev_user NOT IN (SELECT ipb_user FROM {$ipBlocksTable} WHERE ipb_user <> 0)";
         $nextPrefix = "AND";
     }
     if ($wgContribScoreIgnoreBots) {
         $sqlWhere .= " {$nextPrefix} rev_user NOT IN (SELECT ug_user FROM {$userGroupTable} WHERE ug_group='bot')";
         $nextPrefix = "AND";
     }
     $sqlMostPages = "SELECT rev_user,\n\t\t\t\t\t\t COUNT(DISTINCT rev_page) AS page_count,\n\t\t\t\t\t\t COUNT(rev_id) AS rev_count\n\t\t\t\t\t\t FROM {$revTable}\n\t\t\t\t\t\t {$sqlWhere}\n\t\t\t\t\t\t GROUP BY rev_user\n\t\t\t\t\t\t ORDER BY page_count DESC\n\t\t\t\t\t\t LIMIT {$limit}";
     $sqlMostRevs = "SELECT rev_user,\n\t\t\t\t\t\t COUNT(DISTINCT rev_page) AS page_count,\n\t\t\t\t\t\t COUNT(rev_id) AS rev_count\n\t\t\t\t\t\t FROM {$revTable}\n\t\t\t\t\t\t {$sqlWhere}\n\t\t\t\t\t\t GROUP BY rev_user\n\t\t\t\t\t\t ORDER BY rev_count DESC\n\t\t\t\t\t\t LIMIT {$limit}";
     $sql = "SELECT user_id, " . "user_name, " . "user_real_name, " . "page_count, " . "rev_count, " . "page_count+SQRT(rev_count-page_count)*2 AS wiki_rank " . "FROM {$userTable} u JOIN (({$sqlMostPages}) UNION ({$sqlMostRevs})) s ON (user_id=rev_user) " . "ORDER BY wiki_rank DESC " . "LIMIT {$limit}";
     $res = $dbr->query($sql);
     $sortable = in_array('nosort', $opts) ? '' : ' sortable';
     $output = "<table class=\"wikitable contributionscores plainlinks{$sortable}\" >\n" . "<tr class='header'>\n" . Html::element('th', array(), wfMsg('contributionscores-score')) . Html::element('th', array(), wfMsg('contributionscores-pages')) . Html::element('th', array(), wfMsg('contributionscores-changes')) . Html::element('th', array(), wfMsg('contributionscores-username'));
     $altrow = '';
     foreach ($res as $row) {
         // Use real name if option used and real name present.
         if ($wgContribScoresUseRealName && $row->user_real_name !== '') {
             $userLink = Linker::userLink($row->user_id, $row->user_name, $row->user_real_name);
         } else {
             $userLink = Linker::userLink($row->user_id, $row->user_name);
         }
         $output .= Html::closeElement('tr');
         $output .= "<tr class='{$altrow}'>\n<td class='content'>" . $wgLang->formatNum(round($row->wiki_rank, 0)) . "\n</td><td class='content'>" . $wgLang->formatNum($row->page_count) . "\n</td><td class='content'>" . $wgLang->formatNum($row->rev_count) . "\n</td><td class='content'>" . $userLink;
         # Option to not display user tools
         if (!in_array('notools', $opts)) {
             $output .= Linker::userToolLinks($row->user_id, $row->user_name);
         }
         $output .= Html::closeElement('td') . "\n";
         if ($altrow == '' && empty($sortable)) {
             $altrow = 'odd ';
         } else {
             $altrow = '';
         }
     }
     $output .= Html::closeElement('tr');
     $output .= Html::closeElement('table');
     $dbr->freeResult($res);
     if (!empty($title)) {
         $output = Html::rawElement('table', array('cellspacing' => 0, 'cellpadding' => 0, 'class' => 'contributionscores-wrapper', 'lang' => $wgLang->getCode(), 'dir' => $wgLang->getDir()), "\n" . "<tr>\n" . "<td style='padding: 0px;'>{$title}</td>\n" . "</tr>\n" . "<tr>\n" . "<td style='padding: 0px;'>{$output}</td>\n" . "</tr>\n");
     }
     return $output;
 }
 /**
  * EditPageBeforeEditToolbar hook
  *
  * Disable the old toolbar if the new one is enabled
  *
  * @param $toolbar html
  * @return bool
  */
 public static function EditPageBeforeEditToolbar(&$toolbar)
 {
     if (self::isEnabled('toolbar')) {
         $toolbar = Html::rawElement('div', array('class' => 'wikiEditor-oldToolbar', 'style' => 'display:none;'), $toolbar);
     }
     return true;
 }
 /**
  * Render message box with system messages, e.g. errors or already logged-in notices
  *
  * @param bool $register Whether the user can register an account
  */
 protected function renderMessageHtml($register = false)
 {
     $msgBox = '';
     // placeholder for displaying any login-related system messages (eg errors)
     // Render logged-in notice (beta/alpha)
     if ($this->data['loggedin']) {
         $msg = $register ? 'mobile-frontend-userlogin-loggedin-register' : 'userlogin-loggedin';
         $msgBox .= Html::element('div', array('class' => 'alert warning'), wfMessage($msg)->params($this->data['loggedinuser'])->parse());
     }
     // Render login errors
     $message = $this->data['message'];
     $messageType = $this->data['messagetype'];
     if ($message) {
         $heading = '';
         $class = 'alert';
         if ($messageType == 'error') {
             $heading = wfMessage('mobile-frontend-sign-in-error-heading')->text();
             $class .= ' error';
         }
         $msgBox .= Html::openElement('div', array('class' => $class));
         $msgBox .= $heading ? Html::rawElement('h2', array(), $heading) : '';
         $msgBox .= $message;
         $msgBox .= Html::closeElement('div');
     } else {
         $msgBox .= $this->getLogoHtml();
     }
     echo $msgBox;
 }
 public static function getHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args)
 {
     global $sfgTabIndex, $sfgFieldNum, $sfgShowOnSelect;
     $checkbox_class = $is_mandatory ? 'mandatoryField' : 'createboxInput';
     $span_class = 'checkboxSpan';
     if (array_key_exists('class', $other_args)) {
         $span_class .= ' ' . $other_args['class'];
     }
     $input_id = "input_{$sfgFieldNum}";
     // get list delimiter - default is comma
     if (array_key_exists('delimiter', $other_args)) {
         $delimiter = $other_args['delimiter'];
     } else {
         $delimiter = ',';
     }
     $cur_values = SFUtils::getValuesArray($cur_value, $delimiter);
     if (($possible_values = $other_args['possible_values']) == null) {
         $possible_values = array();
     }
     $text = '';
     foreach ($possible_values as $key => $possible_value) {
         $cur_input_name = $input_name . '[' . $key . ']';
         if (array_key_exists('value_labels', $other_args) && is_array($other_args['value_labels']) && array_key_exists($possible_value, $other_args['value_labels'])) {
             $label = $other_args['value_labels'][$possible_value];
         } else {
             $label = $possible_value;
         }
         $checkbox_attrs = array('id' => $input_id, 'tabindex' => $sfgTabIndex, 'class' => $checkbox_class);
         if (in_array($possible_value, $cur_values)) {
             $checkbox_attrs['checked'] = 'checked';
         }
         if ($is_disabled) {
             $checkbox_attrs['disabled'] = 'disabled';
         }
         $checkbox_input = Html::input($cur_input_name, $possible_value, 'checkbox', $checkbox_attrs);
         // Make a span around each checkbox, for CSS purposes.
         $text .= "\t" . Html::rawElement('span', array('class' => $span_class), $checkbox_input . ' ' . $label) . "\n";
         $sfgTabIndex++;
         $sfgFieldNum++;
     }
     $outerSpanID = "span_{$sfgFieldNum}";
     $outerSpanClass = 'checkboxesSpan';
     if ($is_mandatory) {
         $outerSpanClass .= ' mandatoryFieldSpan';
     }
     if (array_key_exists('show on select', $other_args)) {
         $outerSpanClass .= ' sfShowIfChecked';
         foreach ($other_args['show on select'] as $div_id => $options) {
             if (array_key_exists($outerSpanID, $sfgShowOnSelect)) {
                 $sfgShowOnSelect[$outerSpanID][] = array($options, $div_id);
             } else {
                 $sfgShowOnSelect[$outerSpanID] = array(array($options, $div_id));
             }
         }
     }
     $text .= Html::hidden($input_name . '[is_list]', 1);
     $outerSpanAttrs = array('id' => $outerSpanID, 'class' => $outerSpanClass);
     $text = "\t" . Html::rawElement('span', $outerSpanAttrs, $text) . "\n";
     return $text;
 }
 function formatValue($name, $value)
 {
     global $wgLang, $wgContLang;
     static $linker = null;
     if (empty($linker)) {
         $linker = class_exists('DummyLinker') ? new DummyLinker() : new Linker();
     }
     $row = $this->mCurrentRow;
     $ns = $row->page_namespace;
     $title = $row->page_title;
     if (is_null($ns)) {
         $ns = $row->thread_article_namespace;
         $title = $row->thread_article_title;
     }
     switch ($name) {
         case 'thread_subject':
             $title = Title::makeTitleSafe($ns, $title);
             $link = $linker->link($title, $value, array(), array(), array('known'));
             return Html::rawElement('div', array('dir' => $wgContLang->getDir()), $link);
         case 'th_timestamp':
             $formatted = $wgLang->timeanddate($value);
             $title = Title::makeTitleSafe($ns, $title);
             return $linker->link($title, $formatted, array(), array('lqt_oldid' => $row->th_id));
         default:
             return parent::formatValue($name, $value);
     }
 }
 function formatRow($row)
 {
     $time = htmlspecialchars($this->getLanguage()->userDate($row->log_timestamp, $this->getUser()));
     $paramsSerialized = unserialize($row->log_params);
     $paramsOldFormat = null;
     // If the params aren't serialized, it's an older log format
     if ($paramsSerialized === false) {
         $paramsOldFormat = explode("\n", $row->log_params);
     }
     $targetName = $paramsSerialized === false ? $paramsOldFormat[0] : $paramsSerialized['4::target'];
     $logPageId = (int) $row->log_page;
     $currentTitle = $logPageId && $logPageId !== 0 ? Title::newFromID($logPageId) : null;
     $targetTitleObj = Title::newFromText($targetName);
     // Make sure the target is NS_MAIN
     if ($targetTitleObj->getNamespace() !== NS_MAIN) {
         return false;
     }
     $originalNameDisplay = '';
     if ($currentTitle && $targetName !== $currentTitle->getFullText()) {
         $originalNameDisplay = ' ' . $this->msg('newarticles-original-title')->params($targetName);
     }
     $pageLink = Linker::link($originalNameDisplay ? $currentTitle : $targetTitleObj);
     $articleTypeDisplay = '';
     if (isset($row->pp_value) && $row->pp_value === 'portal') {
         $pageLink = Html::rawElement('strong', [], $pageLink);
         $articleTypeReadable = WRArticleType::getReadableArticleTypeFromCode($row->pp_value);
         $articleTypeDisplay = $this->msg('newarticles-articletype')->params($articleTypeReadable)->text();
         $articleTypeDisplay = ' ' . $articleTypeDisplay;
     }
     $formattedRow = Html::rawElement('li', [], "{$time}: {$pageLink}{$articleTypeDisplay}{$originalNameDisplay}") . "\n";
     return $formattedRow;
 }
 /**
  * Hook: GetPreferences adds user preference
  * @see https://www.mediawiki.org/wiki/Manual:Hooks/GetPreferences
  *
  * @param User $user
  * @param array $preferences
  *
  * @return true
  */
 public static function onGetPreferences($user, &$preferences)
 {
     // Intro text, do not escape the message here as it contains
     // href links
     $preferences['srf-prefs-intro'] = array('type' => 'info', 'label' => '&#160;', 'default' => Html::rawElement('span', array('class' => 'srf-prefs-intro'), wfMessage('srf-prefs-intro-text')->parseAsBlock()), 'section' => 'smw/srf', 'raw' => 1, 'rawrow' => 1);
     return true;
 }
Exemple #9
0
/**
 * add the cite link to the toolbar
 *
 * @param $skin Skin
 *
 * @return bool
 */
function wfSpecialCiteToolbox(&$skin)
{
    if (isset($skin->data['nav_urls']['cite'])) {
        echo Html::rawElement('li', array('id' => 't-cite'), Linker::link(SpecialPage::getTitleFor('Cite'), wfMessage('cite_article_link')->text(), Linker::tooltipAndAccessKeyAttribs('cite-article'), $skin->data['nav_urls']['cite']['args']));
    }
    return true;
}
Exemple #10
0
 function mathTagHook($content, $attributes, $parser)
 {
     $text = MathHooks::mathTagHook($content, $attributes, $parser);
     // the MathHooks::mathTagHooks function returns a array with some attributes, but we only want to change the text, which is at [0].
     $text[0] = Html::rawElement('span', array('class' => 'math-wrapper'), $text[0]);
     return $text;
 }
Exemple #11
0
 /**
  * Prepare data output
  *
  * @since 1.8
  *
  * @param array $data label => value
  */
 protected function getFormatOutput(array $data)
 {
     //Init
     $dataObject = array();
     static $statNr = 0;
     $chartID = 'sparkline-' . $this->params['charttype'] . '-' . ++$statNr;
     $this->isHTML = true;
     // Prepare data array
     foreach ($data as $key => $value) {
         if ($value >= $this->params['min']) {
             $dataObject['label'][] = $key;
             $dataObject['value'][] = $value;
         }
     }
     $dataObject['charttype'] = $this->params['charttype'];
     // Encode data objects
     $requireHeadItem = array($chartID => FormatJson::encode($dataObject));
     SMWOutputs::requireHeadItem($chartID, Skin::makeVariablesScript($requireHeadItem));
     // RL module
     SMWOutputs::requireResource('ext.srf.sparkline');
     // Processing placeholder
     $processing = SRFUtils::htmlProcessingElement(false);
     // Chart/graph placeholder
     $chart = Html::rawElement('div', array('id' => $chartID, 'class' => 'container', 'style' => "display:none;"), null);
     // Beautify class selector
     $class = $this->params['class'] ? ' ' . $this->params['class'] : '';
     // Chart/graph wrappper
     return Html::rawElement('span', array('class' => 'srf-sparkline' . $class), $processing . $chart);
 }
 protected function display()
 {
     $output = $this->getOutput();
     // Top Infobox Messaging
     if ($this->msgType != null) {
         $msg = wfMessage($this->msgKey);
         if ($msg->exists()) {
             $output->addHTML(Html::rawElement('div', array('class' => "informations {$this->msgType}"), $msg->parse()));
         }
     }
     switch (strtolower($this->action)) {
         case strtolower(self::ACTION_USE_INVITATION):
             $this->displayInvitation();
             break;
         case strtolower(self::ACTION_NEW):
             $this->displayNew();
             break;
         case strtolower(self::ACTION_CHANGE):
             $this->displayChange();
             break;
         case strtolower(self::ACTION_RENEW):
             $this->displayRenew();
             break;
         case strtolower(self::ACTION_CANCEL):
             $this->processCancel();
             break;
         case strtolower(self::ACTION_LIST):
         default:
             $this->displayList();
             break;
     }
 }
 public function execute($par)
 {
     $this->setHeaders();
     $this->outputHeader();
     $out = $this->getOutput();
     $out->disallowUserJs();
     # Prevent hijacked user scripts from sniffing passwords etc.
     $this->requireLogin('prefsnologintext2');
     $this->checkReadOnly();
     if ($par == 'reset') {
         $this->showResetForm();
         return;
     }
     $out->addModules('mediawiki.special.preferences');
     $out->addModuleStyles('mediawiki.special.preferences.styles');
     if ($this->getRequest()->getCheck('success')) {
         $out->wrapWikiMsg(Html::rawElement('div', array('class' => 'mw-preferences-messagebox successbox', 'id' => 'mw-preferences-success'), Html::element('p', array(), '$1')), 'savedprefs');
     }
     $this->addHelpLink('Help:Preferences');
     // Load the user from the master to reduce CAS errors on double post (T95839)
     $user = $this->getUser()->getInstanceForUpdate() ?: $this->getUser();
     $htmlForm = Preferences::getFormObject($user, $this->getContext());
     $htmlForm->setSubmitCallback(array('Preferences', 'tryUISubmit'));
     $sectionTitles = $htmlForm->getPreferenceSections();
     $prefTabs = '';
     foreach ($sectionTitles as $key) {
         $prefTabs .= Html::rawElement('li', array('role' => 'presentation', 'class' => $key === 'personal' ? 'selected' : null), Html::rawElement('a', array('id' => 'preftab-' . $key, 'role' => 'tab', 'href' => '#mw-prefsection-' . $key, 'aria-controls' => 'mw-prefsection-' . $key, 'aria-selected' => $key === 'personal' ? 'true' : 'false', 'tabIndex' => $key === 'personal' ? 0 : -1), $htmlForm->getLegend($key)));
     }
     $out->addHTML(Html::rawElement('ul', array('id' => 'preftoc', 'role' => 'tablist'), $prefTabs));
     $htmlForm->show();
 }
    public static function getHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args)
    {
        global $sfgTabIndex, $sfgFieldNum;
        global $wgOut;
        $scripts = array("https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false");
        $scriptsHTML = '';
        foreach ($scripts as $script) {
            $scriptsHTML .= Html::linkedScript($script);
        }
        $wgOut->addHeadItem($scriptsHTML, $scriptsHTML);
        $wgOut->addModules('ext.semanticforms.maps');
        $parsedCurValue = SFOpenLayersInput::parseCoordinatesString($cur_value);
        $coordsInput = Html::element('input', array('type' => 'text', 'class' => 'sfCoordsInput', 'name' => $input_name, 'value' => $parsedCurValue, 'size' => 40));
        $mapUpdateButton = Html::element('input', array('type' => 'button', 'class' => 'sfUpdateMap', 'value' => wfMessage('sf-maps-setmarker')->parse()), null);
        $addressLookupInput = Html::element('input', array('type' => 'text', 'class' => 'sfAddressInput', 'size' => 40, 'placeholder' => wfMessage('sf-maps-enteraddress')->parse()), null);
        $addressLookupButton = Html::element('input', array('type' => 'button', 'class' => 'sfLookUpAddress', 'value' => wfMessage('sf-maps-lookupcoordinates')->parse()), null);
        $mapCanvas = Html::element('div', array('class' => 'sfMapCanvas', 'style' => 'height: 500px; width: 500px;'), 'Map goes here...');
        $fullInputHTML = <<<END
<div style="padding-bottom: 10px;">
{$coordsInput}
{$mapUpdateButton}
</div>
<div style="padding-bottom: 10px;">
{$addressLookupInput}
{$addressLookupButton}
</div>
{$mapCanvas}

END;
        $text = Html::rawElement('div', array('class' => 'sfGoogleMapsInput'), $fullInputHTML);
        return $text;
    }
 /**
  * Show the special page
  * @param string|null $par
  */
 public function execute($par)
 {
     $this->setHeaders();
     $this->outputHeader();
     $out = $this->getOutput();
     $out->addModuleStyles('mediawiki.special');
     $out->addHTML(\Html::openElement('table', array('class' => 'wikitable mw-listgrouprights-table')) . '<tr>' . \Html::element('th', null, $this->msg('listgrants-grant')->text()) . \Html::element('th', null, $this->msg('listgrants-rights')->text()) . '</tr>');
     foreach ($this->getConfig()->get('GrantPermissions') as $grant => $rights) {
         $descs = array();
         $rights = array_filter($rights);
         // remove ones with 'false'
         foreach ($rights as $permission => $granted) {
             $descs[] = $this->msg('listgrouprights-right-display', \User::getRightDescription($permission), '<span class="mw-listgrants-right-name">' . $permission . '</span>')->parse();
         }
         if (!count($descs)) {
             $grantCellHtml = '';
         } else {
             sort($descs);
             $grantCellHtml = '<ul><li>' . implode("</li>\n<li>", $descs) . '</li></ul>';
         }
         $id = \Sanitizer::escapeId($grant);
         $out->addHTML(\Html::rawElement('tr', array('id' => $id), "<td>" . $this->msg("grant-{$grant}")->escaped() . "</td>" . "<td>" . $grantCellHtml . '</td>'));
     }
     $out->addHTML(\Html::closeElement('table'));
 }
	/**
	 * @param $tpl
	 * @return bool
	 */
	public static function addToolboxLink( &$tpl ) {
		global $wgOut, $wgShortUrlPrefix;

		if ( !is_string( $wgShortUrlPrefix ) ) {
			$urlPrefix = SpecialPage::getTitleFor( 'ShortUrl' )->getCanonicalUrl() . '/';
		} else {
			$urlPrefix = $wgShortUrlPrefix;
		}

		$title = $wgOut->getTitle();
		if ( ShortUrlUtils::needsShortUrl( $title ) ) {
			$shortId = ShortUrlUtils::encodeTitle( $title );
			$shortURL = $urlPrefix . $shortId;
			$html = Html::rawElement( 'li',	array( 'id' => 't-shorturl' ),
				Html::Element( 'a', array(
					'href' => $shortURL,
					'title' => wfMsg( 'shorturl-toolbox-title' )
				),
				wfMsg( 'shorturl-toolbox-text' ) )
			);

			echo $html;
		}
		return true;
	}
 /**
  * Prepare data output
  *
  * @since 1.8
  *
  * @param array $data label => value
  */
 protected function getFormatOutput(array $data)
 {
     static $statNr = 0;
     $chartID = 'jqplot-' . $this->params['charttype'] . '-' . ++$statNr;
     $this->isHTML = true;
     // Prepare data objects
     if (in_array($this->params['charttype'], array('bar', 'line'))) {
         // Parse bar relevant data
         $dataObject = $this->prepareBarData($data);
     } elseif (in_array($this->params['charttype'], array('pie', 'donut'))) {
         //Parse pie/donut relevant data
         $dataObject = $this->preparePieData($data);
     } else {
         // Return with an error
         return Html::rawElement('span', array('class' => "error"), wfMessage('srf-error-missing-layout')->inContentLanguage()->text());
     }
     // Encode data objects
     $requireHeadItem = array($chartID => FormatJson::encode($dataObject));
     SMWOutputs::requireHeadItem($chartID, Skin::makeVariablesScript($requireHeadItem));
     // Processing placeholder
     $processing = SRFUtils::htmlProcessingElement($this->isHTML);
     // Ensure right conversion
     $width = strstr($this->params['width'], "%") ? $this->params['width'] : $this->params['width'] . 'px';
     // Chart/graph placeholder
     $chart = Html::rawElement('div', array('id' => $chartID, 'class' => 'container', 'style' => "display:none; width: {$width}; height: {$this->params['height']}px;"), null);
     // Beautify class selector
     $class = $this->params['charttype'] ? '-' . $this->params['charttype'] : '';
     $class = $this->params['class'] ? $class . ' ' . $this->params['class'] : $class . ' jqplot-common';
     // Chart/graph wrappper
     return Html::rawElement('div', array('class' => 'srf-jqplot' . $class), $processing . $chart);
 }
 public function execute($params = false)
 {
     $sEditLinkText = wfMessage('bs-widget-edit')->text();
     $oTitle = Title::makeTitle(NS_USER, RequestContext::getMain()->getUser()->getName() . '/Widgetbar');
     $sEditLink = Linker::link($oTitle, Html::rawElement('span', array(), $sEditLinkText), array('id' => 'bs-widgetbar-edit', 'class' => 'icon-pencil clearfix'), array('action' => 'edit', 'preload' => ''));
     $aOut = array();
     $aOut[] = '<div id="bs-widget-container" >';
     $aOut[] = '  <div class="icon-plus" id="bs-widget-tab" title="' . wfMessage('bs-widget-container-tooltip')->text() . '" tabindex="100">[+/-]</div>';
     $aOut[] = '  <div id="bs-flyout">';
     $aOut[] = '    <h4 id="bs-flyout-heading">' . wfMessage('bs-widget-flyout-heading')->text() . '</h4>';
     $aOut[] = '    <div id="bs-flyout-content">';
     $aOut[] = '      <div id="bs-flyout-content-widgets">';
     $aOut[] = '        <h4 id="bs-flyout-content-widgets-header">' . wfMessage("bs-widget-flyout-heading")->plain() . $sEditLink . '</h4>';
     foreach ($this->_mWidgets as $oWidgetView) {
         if ($oWidgetView instanceof ViewWidget) {
             $aOut[] = $oWidgetView->execute();
         } else {
             wfDebug(__METHOD__ . ': Invalid widget.');
         }
     }
     $aOut[] = '      </div>';
     $aOut[] = '    </div>';
     $aOut[] = '  </div>';
     $aOut[] = '</div>';
     return implode("\n", $aOut);
 }
 /**
  * @param Skin $skin
  * @return bool
  */
 public static function onSkinTemplateToolboxEnd(&$skin)
 {
     if (isset($skin->data['nav_urls']['citeThisPage'])) {
         echo Html::rawElement('li', array('id' => 't-cite'), Linker::link(SpecialPage::getTitleFor('CiteThisPage'), wfMessage('citethispage-link')->escaped(), Linker::tooltipAndAccessKeyAttribs('citethispage'), $skin->data['nav_urls']['citeThisPage']['args']));
     }
     return true;
 }
Exemple #20
0
 /**
  * @see SMWResultPrinter::getFormatOutput
  *
  * @since 1.8
  *
  * @param array $data label => value
  * @return string
  */
 protected function getFormatOutput(array $data)
 {
     // Object count
     static $statNr = 0;
     $d3chartID = 'd3-chart-' . ++$statNr;
     $this->isHTML = true;
     // Reorganize the raw data
     foreach ($data as $name => $value) {
         if ($value >= $this->params['min']) {
             $dataObject[] = array('label' => $name, 'value' => $value);
         }
     }
     // Ensure right conversion
     $width = strstr($this->params['width'], "%") ? $this->params['width'] : $this->params['width'] . 'px';
     // Prepare transfer objects
     $d3data = array('data' => $dataObject, 'parameters' => array('colorscheme' => $this->params['colorscheme'] ? $this->params['colorscheme'] : null, 'charttitle' => $this->params['charttitle'], 'charttext' => $this->params['charttext'], 'datalabels' => $this->params['datalabels']));
     // Encoding
     $requireHeadItem = array($d3chartID => FormatJson::encode($d3data));
     SMWOutputs::requireHeadItem($d3chartID, Skin::makeVariablesScript($requireHeadItem));
     // RL module
     $resource = 'ext.srf.d3.chart.' . $this->params['charttype'];
     SMWOutputs::requireResource($resource);
     // Chart/graph placeholder
     $chart = Html::rawElement('div', array('id' => $d3chartID, 'class' => 'container', 'style' => 'display:none;'), null);
     // Processing placeholder
     $processing = SRFUtils::htmlProcessingElement($this->isHTML);
     // Beautify class selector
     $class = $this->params['charttype'] ? '-' . $this->params['charttype'] : '';
     $class = $this->params['class'] ? $class . ' ' . $this->params['class'] : $class . ' d3-chart-common';
     // D3 wrappper
     return Html::rawElement('div', array('class' => 'srf-d3-chart' . $class, 'style' => "width:{$width}; height:{$this->params['height']}px;"), $processing . $chart);
 }
 /**
  * Callback function to output a restriction
  *
  * @param object $row Database row
  * @return string
  */
 function formatRow($row)
 {
     wfProfileIn(__METHOD__);
     static $infinity = null;
     if (is_null($infinity)) {
         $infinity = wfGetDB(DB_SLAVE)->getInfinity();
     }
     $title = Title::makeTitleSafe($row->pt_namespace, $row->pt_title);
     if (!$title) {
         wfProfileOut(__METHOD__);
         return Html::rawElement('li', array(), Html::element('span', array('class' => 'mw-invalidtitle'), Linker::getInvalidTitleDescription($this->getContext(), $row->pt_namespace, $row->pt_title))) . "\n";
     }
     $link = Linker::link($title);
     $description_items = array();
     $protType = $this->msg('restriction-level-' . $row->pt_create_perm)->escaped();
     $description_items[] = $protType;
     $lang = $this->getLanguage();
     $expiry = strlen($row->pt_expiry) ? $lang->formatExpiry($row->pt_expiry, TS_MW) : $infinity;
     if ($expiry != $infinity) {
         $user = $this->getUser();
         $description_items[] = $this->msg('protect-expiring-local', $lang->userTimeAndDate($expiry, $user), $lang->userDate($expiry, $user), $lang->userTime($expiry, $user))->escaped();
     }
     wfProfileOut(__METHOD__);
     // @todo i18n: This should use a comma separator instead of a hard coded comma, right?
     return '<li>' . $lang->specialList($link, implode($description_items, ', ')) . "</li>\n";
 }
 function formatRow($result)
 {
     $title = new TitleValue(NS_CATEGORY, $result->cat_title);
     $text = $title->getText();
     $link = $this->linkRenderer->renderHtmlLink($title, $text);
     $count = $this->msg('nmembers')->numParams($result->cat_pages)->escaped();
     return Html::rawElement('li', null, $this->getLanguage()->specialList($link, $count)) . "\n";
 }
Exemple #23
0
 public function onView()
 {
     global $wgDisableCounters;
     $title = $this->getTitle()->getSubjectPage();
     $pageInfo = self::pageCountInfo($title);
     $talkInfo = self::pageCountInfo($title->getTalkPage());
     return Html::rawElement('table', array('class' => 'wikitable mw-page-info'), Html::rawElement('tr', array(), Html::element('th', array(), '') . Html::element('th', array(), wfMsg('pageinfo-subjectpage')) . Html::element('th', array(), wfMsg('pageinfo-talkpage'))) . Html::rawElement('tr', array(), Html::element('th', array('colspan' => 3), wfMsg('pageinfo-header-edits'))) . Html::rawElement('tr', array(), Html::element('td', array(), wfMsg('pageinfo-edits')) . Html::element('td', array(), $this->getLang()->formatNum($pageInfo['edits'])) . Html::element('td', array(), $this->getLang()->formatNum($talkInfo['edits']))) . Html::rawElement('tr', array(), Html::element('td', array(), wfMsg('pageinfo-authors')) . Html::element('td', array(), $this->getLang()->formatNum($pageInfo['authors'])) . Html::element('td', array(), $this->getLang()->formatNum($talkInfo['authors']))) . (!$this->getUser()->isAllowed('unwatchedpages') ? '' : Html::rawElement('tr', array(), Html::element('th', array('colspan' => 3), wfMsg('pageinfo-header-watchlist'))) . Html::rawElement('tr', array(), Html::element('td', array(), wfMsg('pageinfo-watchers')) . Html::element('td', array('colspan' => 2), $this->getLang()->formatNum($pageInfo['watchers'])))) . ($wgDisableCounters ? '' : Html::rawElement('tr', array(), Html::element('th', array('colspan' => 3), wfMsg('pageinfo-header-views'))) . Html::rawElement('tr', array(), Html::element('td', array(), wfMsg('pageinfo-views')) . Html::element('td', array(), $this->getLang()->formatNum($pageInfo['views'])) . Html::element('td', array(), $this->getLang()->formatNum($talkInfo['views']))) . Html::rawElement('tr', array(), Html::element('td', array(), wfMsg('pageinfo-viewsperedit')) . Html::element('td', array(), $this->getLang()->formatNum(sprintf('%.2f', $pageInfo['edits'] ? $pageInfo['views'] / $pageInfo['edits'] : 0))) . Html::element('td', array(), $this->getLang()->formatNum(sprintf('%.2f', $talkInfo['edits'] ? $talkInfo['views'] / $talkInfo['edits'] : 0))))));
 }
 /**
  * This method actually generates the output
  * @param array $params List of parameters
  * @return string HTML output
  */
 public function execute($params = false)
 {
     $sTargetId = $this->getTargetId() . '-target';
     $sLink = Html::element('a', array('class' => 'bs-tooltip-link', 'id' => $this->getTargetId(), 'data-bs-tt-title' => wfMessage('bs-whoisonline-widget-title')->plain(), 'data-bs-tt-target' => $sTargetId, 'data-bs-tt-maxheight' => BsConfig::get('MW::WhoIsOnline::LimitCount') * 20), $this->getOption('title'));
     $sTarget = Html::rawElement('div', array('class' => 'bs-tooltip-body bs-whoisonline-portlet', 'id' => $sTargetId), $this->oPortlet ? $this->oPortlet->execute() : '');
     $sOut = $sLink . '<div class="bs-tooltip">' . $sTarget . '</div>';
     return $sOut;
 }
 function formatMonthlyQuotas()
 {
     $html = Xml::openElement('ul');
     $html .= Html::rawElement('li', array(), '<b>' . wfFormatNumber($this->mCurrentRow->wpp_monthly_page_hits) . '</b> ' . wfMessage('wp-Hits')->text());
     $html .= Html::rawElement('li', array(), '<b>' . wfFormatSizeMB($this->mCurrentRow->wpp_monthly_bandwidth) . '</b> ' . wfMessage('wp-bandwidth')->text());
     $html .= Xml::closeElement('ul');
     return $html;
 }
Exemple #26
0
 /**
  * Send the text to be displayed above the options
  */
 function setTopText()
 {
     global $wgContLang;
     $message = $this->msg('newimagestext')->inContentLanguage();
     if (!$message->isDisabled()) {
         $this->getOutput()->addWikiText(Html::rawElement('p', array('lang' => $wgContLang->getCode(), 'dir' => $wgContLang->getDir()), "\n" . $message->plain() . "\n"), false, false);
     }
 }
 /**
  * This is largely cadged from PageHistory::history
  *
  * @return string HTML
  */
 public function onView()
 {
     if ($this->page->getID() == 0) {
         $s = $this->msg('nocredits')->parse();
     } else {
         $s = $this->getCredits(-1);
     }
     return Html::rawElement('div', ['id' => 'mw-credits'], $s);
 }
 /**
  * Get a list of frameworks (including introduction paragraph and links
  * to the framework run pages)
  *
  * @return string HTML
  */
 private function getFrameworkListHtml()
 {
     $list = '<ul>';
     foreach (self::$frameworks as $framework => $initFn) {
         $list .= Html::rawElement('li', array(), Linker::link($this->getPageTitle($framework), $this->msg("javascripttest-{$framework}-name")->escaped()));
     }
     $list .= '</ul>';
     return $this->msg('javascripttest-pagetext-frameworks')->rawParams($list)->parseAsBlock();
 }
Exemple #29
0
 /**
  * Returns an introductory text for a predefined property
  *
  * @note In order to enable a more detailed description for a specific
  * predefined property a concatenated message key can be used (e.g
  * 'smw-pa-property-predefined' + <internal property key> => '_asksi' )
  *
  * @since 1.9
  *
  * @return string
  */
 protected function getPredefinedPropertyIntro()
 {
     if (!$this->mProperty->isUserDefined()) {
         $propertyName = htmlspecialchars($this->mTitle->getText());
         $propertyKey = 'smw-pa-property-predefined' . strtolower($this->mProperty->getKey());
         $messageKey = wfMessage($propertyKey)->exists() ? $propertyKey : 'smw-pa-property-predefined-default';
         return Html::rawElement('div', array('class' => 'smw-pa-property-predefined-intro'), wfMessage($messageKey, $propertyName)->parse());
     }
     return '';
 }
Exemple #30
0
 /**
  * Core parser tag hook function for 'pre'.
  * Text is treated roughly as 'nowiki' wrapped in an HTML 'pre' tag;
  * valid HTML attributes are passed on.
  *
  * @param string $text
  * @param array $attribs
  * @param Parser $parser
  * @return string HTML
  */
 public static function pre($text, $attribs, $parser)
 {
     // Backwards-compatibility hack
     $content = StringUtils::delimiterReplace('<nowiki>', '</nowiki>', '$1', $text, 'i');
     $attribs = Sanitizer::validateTagAttributes($attribs, 'pre');
     // We need to let both '"' and '&' through,
     // for strip markers and entities respectively.
     $content = str_replace(['>', '<'], ['&gt;', '&lt;'], $content);
     return Html::rawElement('pre', $attribs, $content);
 }