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; }
/** * Render the special page and redirect the user to the editor (if page exists) * @param string $subpage The name of the page to edit */ public function executeWhenAvailable($subpage) { if (!is_string($subpage)) { $this->showPageNotFound(); return; } else { $title = Title::newFromText($subpage); if (is_null($title)) { $this->showPageNotFound(); return; } } $data = $this->getRequest()->getValues(); unset($data['title']); // Remove the title of the special page $section = (int) $this->getRequest()->getVal('section', 0); $output = $this->getOutput(); $output->addModules('mobile.special.mobileeditor.scripts'); $output->setPageTitle($this->msg('mobile-frontend-editor-redirect-title')->text()); $context = MobileContext::singleton(); $articleUrl = $context->getMobileUrl($title->getFullURL($data)); $targetUrl = $articleUrl . '#/editor/' . $section; $html = Html::openElement('div', array('id' => 'mw-mf-editor', 'data-targeturl' => $targetUrl)) . Html::openElement('noscript') . MobileUI::errorBox($this->msg('mobile-frontend-editor-unavailable')->text()) . Html::openElement('p') . Html::element('a', array('href' => $title->getLocalUrl()), $this->msg('returnto', $title->getText())->text()) . Html::closeElement('noscript') . Html::closeElement('div'); // #mw-mf-editorunavailable $output->addHTML($html); }
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(); }
private function render($parser, $params) { if (count($params) > 1) { $rating = $params[1]; } else { $rating = 0; } if (count($params) > 2) { $max = $params[2]; } else { $max = $GLOBALS['SemanticRating_DefaultMax']; } $output = Html::openElement('span', array('style' => 'white-space:nowrap;')); if ($rating < 0) { $rating = 0; } elseif ($rating > $max) { $rating = $max; } $i = 1; while ($i <= $rating) { $output .= Html::element('img', array('src' => $this->imagepath . 'yellowstar.png')); $i++; } if ($rating - $i + 1 != 0) { $output .= Html::element('img', array('src' => $this->imagepath . 'halfstar.png')); $i++; } while ($i <= $max) { $output .= Html::element('img', array('src' => $this->imagepath . 'greystar.png')); $i++; } $output .= Html::closeElement('span'); return $output; }
public function execute($par) { global $wgOut, $wgRequest; $this->setHeaders(); $code = $wgRequest->getVal('verify'); if ($code !== null) { $dbw = wfGetDB(DB_MASTER); $row = $dbw->selectRow('email_capture', array('ec_verified'), array('ec_code' => $code), __METHOD__); if ($row && !$row->ec_verified) { $dbw->update('email_capture', array('ec_verified' => 1), array('ec_code' => $code), __METHOD__); if ($dbw->affectedRows()) { $wgOut->addWikiMsg('emailcapture-success'); } else { $wgOut->addWikiMsg('emailcapture-failure'); } } elseif ($row && $row->ec_verified) { $wgOut->addWikiMsg('emailcapture-already-confirmed'); } else { $wgOut->addWikiMsg('emailcapture-invalid-code'); } } else { // Show simple form for submitting verification code $o = Html::openElement('form', array('action' => $this->getTitle()->getFullUrl(), 'method' => 'post')); $o .= Html::element('p', array(), wfMsg('emailcapture-instructions')); $o .= Html::openElement('blockquote'); $o .= Html::element('label', array('for' => 'emailcapture-verify'), wfMsg('emailcapture-verify')) . ' '; $o .= Html::input('verify', '', 'text', array('id' => 'emailcapture-verify', 'size' => 32)) . ' '; $o .= Html::input('submit', wfMsg('emailcapture-submit'), 'submit'); $o .= Html::closeElement('blockquote'); $o .= Html::closeElement('form'); $wgOut->addHtml($o); } }
/** * Return serialised results in specified format. * Implemented by subclasses. */ protected function getResultText(SMWQueryResult $res, $outputmode) { $html = ''; $id = uniqid(); // build an array of article IDs contained in the result set $objects = array(); foreach ($res->getResults() as $key => $object) { $objects[] = array($object->getTitle()->getArticleId()); $html .= $key . ': ' . $object->getSerialization() . "<br>\n"; } // build an array of data about the printrequests $printrequests = array(); foreach ($res->getPrintRequests() as $key => $printrequest) { $data = $printrequest->getData(); if ($data instanceof SMWPropertyValue) { $name = $data->getDataItem()->getKey(); } else { $name = null; } $printrequests[] = array($printrequest->getMode(), $printrequest->getLabel(), $name, $printrequest->getOutputFormat(), $printrequest->getParameters()); } // write out results and query params into JS arrays // Define the srf_filtered_values array SMWOutputs::requireScript('srf_slideshow', Html::inlineScript('srf_slideshow = {};')); SMWOutputs::requireScript('srf_slideshow' . $id, Html::inlineScript('srf_slideshow["' . $id . '"] = ' . json_encode(array($objects, $this->params['template'], $this->params['delay'] * 1000, $this->params['height'], $this->params['width'], $this->params['nav controls'], $this->params['effect'], json_encode($printrequests))) . ';')); SMWOutputs::requireResource('ext.srf.slideshow'); if ($this->params['nav controls']) { SMWOutputs::requireResource('jquery.ui.slider'); } return Html::element('div', array('id' => $id, 'class' => 'srf-slideshow ' . $id . ' ' . $this->params['class'])); }
/** * Input form for entering a category */ function makeInputForm() { $form = ''; $form .= Html::openElement('form', array('name' => 'ajaxtest', 'method' => 'GET', 'action' => $this->getTitle()->getLocalUrl())); $form .= Html::element('input', array('type' => 'text', 'name' => 'ajaxtest_text', 'id' => 'ajaxtest_text', 'value' => '', 'size' => '64')) . ' '; $form .= Html::element('br'); $form .= Html::element('label', array('for' => 'usestring'), 'use string value'); $form .= Html::element('input', array('type' => 'checkbox', 'name' => 'usestring', 'id' => 'usestring')); $form .= Html::element('br'); $form .= Html::element('label', array('for' => 'httpcache'), 'use http cache'); $form .= Html::element('input', array('type' => 'checkbox', 'name' => 'httpcache', 'id' => 'httpcache')); $form .= Html::element('br'); $form .= Html::element('label', array('for' => 'lastmod'), 'use last modified'); $form .= Html::element('input', array('type' => 'checkbox', 'name' => 'lastmod', 'id' => 'lastmod')); $form .= Html::element('br'); $form .= Html::element('label', array('for' => 'error'), 'trigger error'); $form .= Html::element('input', array('type' => 'checkbox', 'name' => 'error', 'id' => 'error')); $form .= Html::element('br'); $form .= Html::openElement('select', array('name' => 'ajaxtest_target', 'id' => 'ajaxtest_target')); $form .= Html::element('option', array('value' => 'function'), "function"); $form .= Html::element('option', array('value' => 'element'), "element"); $form .= Html::element('option', array('value' => 'input'), "input"); $form .= Html::closeElement('select'); $form .= Html::element('input', array('type' => 'button', 'onclick' => 'doAjaxTest();', 'value' => 'TEST')); $form .= Html::element('input', array('type' => 'button', 'onclick' => 'clearAjaxTest();', 'value' => 'CLEAR')); # $form .= Html::element( 'input', array( 'type' => 'button', 'onclick' => 'getElementById("ajaxtest_out").value= getElementById("ajaxtest_text").value;', 'value' => 'DUMMY' ) ); $form .= Html::closeElement('form'); $form .= Html::element('hr'); $form .= Html::element('input', array('type' => 'text', 'name' => 'ajaxtest_out', 'id' => 'ajaxtest_out', 'value' => '', 'size' => '64')) . ' '; $form .= Html::element('p', array('id' => 'ajaxtest_area')); $form .= Html::element('hr'); $form .= Html::element('p', array('id' => 'sajax_debug')); return $form; }
public function getConnectForm() { if ($this->getVar('wgDBserver') == 'localhost') { $this->parent->setVar('wgDBserver', ''); } return $this->getTextBox('wgDBserver', 'config-db-host-oracle', array(), $this->parent->getHelpBox('config-db-host-oracle-help')) . Html::openElement('fieldset') . Html::element('legend', array(), wfMsg('config-db-wiki-settings')) . $this->getTextBox('wgDBprefix', 'config-db-prefix') . $this->getTextBox('_OracleDefTS', 'config-oracle-def-ts') . $this->getTextBox('_OracleTempTS', 'config-oracle-temp-ts', array(), $this->parent->getHelpBox('config-db-oracle-help')) . Html::closeElement('fieldset') . $this->parent->getWarningBox(wfMsg('config-db-account-oracle-warn')) . $this->getInstallUserBox() . $this->getWebUserBox(); }
/** * 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')); }
/** * 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) * @param $title Title (default null) * @param $options array of options (default none; nosort/notools) * @return Html Table representing the requested Contribution Scores. */ function genContributionScoreTable($days, $limit, $title = null, $options = 'none') { global $wgContribScoreIgnoreBots, $wgContribScoreIgnoreBlockedUsers, $wgContribScoresUseRealName; $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')"; } $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(), $this->msg('contributionscores-score')->text()) . Html::element('th', array(), $this->msg('contributionscores-pages')->text()) . Html::element('th', array(), $this->msg('contributionscores-changes')->text()) . Html::element('th', array(), $this->msg('contributionscores-username')->text()); $altrow = ''; $lang = $this->getLanguage(); 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'>" . $lang->formatNum(round($row->wiki_rank, 0)) . "\n</td><td class='content'>" . $lang->formatNum($row->page_count) . "\n</td><td class='content'>" . $lang->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('style' => 'border-spacing: 0; padding: 0', 'class' => 'contributionscores-wrapper', 'lang' => htmlspecialchars($lang->getCode()), 'dir' => $lang->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; }
/** * Get the captcha form. * @return string */ function getForm(OutputPage $out) { global $wgReCaptchaSiteKey; // Insert reCAPTCHA script. // See https://developers.google.com/recaptcha/docs/faq $out->addHeadItem('g-recaptchascript', '<script src="https://www.google.com/recaptcha/api.js" async defer></script>'); $output = Html::element('div', array('class' => array('g-recaptcha', 'mw-confirmedit-captcha-fail' => !!$this->error), 'data-sitekey' => $wgReCaptchaSiteKey)); $htmlUrlencoded = htmlspecialchars(urlencode($wgReCaptchaSiteKey)); $output .= <<<HTML <noscript> <div style="width: 302px; height: 422px;"> <div style="width: 302px; height: 422px; position: relative;"> <div style="width: 302px; height: 422px; position: absolute;"> <iframe src="https://www.google.com/recaptcha/api/fallback?k={$htmlUrlencoded}" frameborder="0" scrolling="no" style="width: 302px; height:422px; border-style: none;"> </iframe> </div> <div style="width: 300px; height: 60px; border-style: none; bottom: 12px; left: 25px; margin: 0px; padding: 0px; right: 25px; background: #f9f9f9; border: 1px solid #c1c1c1; border-radius: 3px;"> <textarea id="g-recaptcha-response" name="g-recaptcha-response" class="g-recaptcha-response" style="width: 250px; height: 40px; border: 1px solid #c1c1c1; margin: 10px 25px; padding: 0px; resize: none;" > </textarea> </div> </div> </div> </noscript> HTML; return $output; }
/** * Main method. * * @since 0.1 * * @param string $subPage */ public function execute($subPage) { parent::execute($subPage); $out = $this->getOutput(); if (trim($subPage) === '') { $this->getOutput()->redirect(SpecialPage::getTitleFor('Institutions')->getLocalURL()); } else { $out->setPageTitle(wfMsgExt('ep-institution-title', 'parsemag', $this->subPage)); $org = EPOrg::selectRow(null, array('name' => $this->subPage)); if ($org === false) { $this->displayNavigation(); if ($this->getUser()->isAllowed('ep-org')) { $out->addWikiMsg('ep-institution-create', $this->subPage); EPOrg::displayAddNewControl($this->getContext(), array('name' => $this->subPage)); } else { $out->addWikiMsg('ep-institution-none', $this->subPage); } } else { $links = array(); if ($this->getUser()->isAllowed('ep-org')) { $links[wfMsg('ep-institution-nav-edit')] = SpecialPage::getTitleFor('EditInstitution', $this->subPage); } $this->displayNavigation($links); $this->displaySummary($org); $out->addHTML(Html::element('h2', array(), wfMsg('ep-institution-courses'))); EPCourse::displayPager($this->getContext(), array('org_id' => $org->getId())); if ($this->getUser()->isAllowed('ep-course')) { $out->addHTML(Html::element('h2', array(), wfMsg('ep-institution-add-course'))); EPCourse::displayAddNewControl($this->getContext(), array('org' => $org->getId())); } } } }
function execute($category) { global $wgUser, $wgRequest, $wgOut, $wgPageSchemasHandlerClasses; if (!$wgUser->isAllowed('generatepages')) { $wgOut->permissionRequired('generatepages'); return; } $this->setHeaders(); $param = $wgRequest->getText('param'); if (!empty($param) && !empty($category)) { // Generate the pages! $this->generatePages($param, $wgRequest->getArray('page')); $text = Html::element('p', null, wfMessage('ps-generatepages-success')->parse()); $wgOut->addHTML($text); return true; } if ($category == "") { // No category listed. // TODO - show an error message. return true; } // Standard "generate pages" form, with category name set. // Check for a valid category, with a page schema defined. $pageSchemaObj = new PSSchema($category); if (!$pageSchemaObj->isPSDefined()) { $text = Html::element('p', null, wfMessage('ps-generatepages-noschema')->parse()); $wgOut->addHTML($text); return true; } $text = Html::element('p', null, wfMessage('ps-generatepages-desc')->parse()) . "\n"; $text .= '<form method="post">'; $text .= Html::input('param', $category, 'hidden') . "\n"; $text .= '<div id="ps_check_all_check_none"> <input type="button" id="ps_check_all" value="' . wfMessage('powersearch-toggleall')->parse() . '" /> <input type="button" id="ps_check_none" value="' . wfMessage('powersearch-togglenone')->parse() . '" /> </div><br/>'; $wgOut->addModules('ext.pageschemas.generatepages'); // This hook will set an array of strings, with each value // as a title of a page to be created. $pageList = array(); foreach ($wgPageSchemasHandlerClasses as $psHandlerClass) { $pagesFromHandler = call_user_func(array($psHandlerClass, "getPagesToGenerate"), $pageSchemaObj); foreach ($pagesFromHandler as $page) { $pageList[] = $page; } } foreach ($pageList as $page) { if (!$page instanceof Title) { continue; } $pageName = PageSchemas::titleString($page); $text .= Html::input('page[]', $pageName, 'checkbox', array('checked' => true)); $text .= "\n" . Linker::link($page) . "<br />\n"; } $text .= "<br />\n"; $text .= Html::input(null, wfMessage('generatepages')->parse(), 'submit'); $text .= "\n</form>"; $wgOut->addHTML($text); return true; }
function execute($par) { $request = $this->getRequest(); $output = $this->getOutput(); $this->setHeaders(); $this->checkPermissions(); $output->addModules('ext.translate.special.pagemigration'); $output->addModuleStyles('jquery.uls.grid'); # Get request data from, e.g. $param = $request->getText('param'); # Do stuff # ... $out = ''; $out .= Html::openElement('div', array('class' => 'grid')); $out .= Html::openElement('div', array('class' => 'mw-tpm-sp-error row', 'id' => 'mw-tpm-sp-error-div')); $out .= Html::element('div', array('class' => 'mw-tpm-sp-error__message five columns hide')); $out .= Html::closeElement('div'); $out .= Html::openElement('form', array('class' => 'mw-tpm-sp-form row', 'id' => 'mw-tpm-sp-primary-form')); $out .= Html::element('input', array('id' => 'pm-summary', 'type' => 'hidden', 'value' => $this->msg('pm-summary-import')->inContentLanguage()->text())); $out .= Html::element('input', array('id' => 'title', 'class' => 'mw-searchInput', 'placeholder' => $this->msg('pm-pagename-placeholder')->text())); $out .= Html::element('input', array('id' => 'language', 'type' => 'text', 'placeholder' => $this->msg('pm-langcode-placeholder')->text())); $out .= Html::element('input', array('id' => 'action-import', 'class' => 'mw-ui-button mw-ui-primary', 'type' => 'button', 'value' => $this->msg('pm-import-button-label')->text())); $out .= Html::element('input', array('id' => 'action-save', 'class' => 'mw-ui-button mw-ui-constructive hide', 'type' => 'button', 'value' => $this->msg('pm-savepages-button-label')->text())); $out .= Html::element('input', array('id' => 'action-cancel', 'class' => 'mw-ui-button mw-ui-quiet hide', 'type' => 'button', 'value' => $this->msg('pm-cancel-button-label')->text())); $out .= Html::closeElement('form'); $out .= Html::openElement('div', array('class' => 'mw-tpm-sp-unit-listing')); $out .= Html::closeElement('div'); $out .= Html::closeElement('div'); $output->addHTML($out); }
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; }
/** * Handle the <htmltag> tag. * * @param $input string * @param $args array * @param $parser Parser * @param $frame PPFrame * @return string */ public static function render($input, $args, $parser, $frame) { global $wgHTMLTagsAttributes; if (!array_key_exists('tagname', $args)) { return wfMessage('htmltags-notagname')->text(); } $tagName = $args['tagname']; if (!array_key_exists($tagName, $wgHTMLTagsAttributes)) { return wfMessage('htmltags-unsupportedtag', $tagName)->escaped(); } $input = $parser->replaceVariables($input, $frame); $attributes = array(); foreach ($args as $key => $value) { if ($key == 'tagname') { continue; } if (in_array($key, $wgHTMLTagsAttributes[$tagName])) { $value = $parser->replaceVariables($value, $frame); // Prevent JS injection into, for instance, // the "href" attribute. $attributes[$key] = htmlspecialchars($value, ENT_QUOTES); } } // The use of Html::element() should prevent any further attempt // at JavaScript injection. return Html::element($tagName, $attributes, $input); }
function getInputHTML($value) { $attribs = array('id' => $this->mID, 'name' => $this->mName, 'size' => $this->getSize(), 'value' => $value) + $this->getTooltipAndAccessKey(); if ($this->mClass !== '') { $attribs['class'] = $this->mClass; } # @todo Enforce pattern, step, required, readonly on the server side as # well $allowedParams = array('min', 'max', 'pattern', 'title', 'step', 'placeholder', 'list', 'maxlength', 'tabindex', 'disabled', 'required', 'autofocus', 'multiple', 'readonly'); $attribs += $this->getAttributes($allowedParams); # Implement tiny differences between some field variants # here, rather than creating a new class for each one which # is essentially just a clone of this one. if (isset($this->mParams['type'])) { switch ($this->mParams['type']) { case 'email': $attribs['type'] = 'email'; break; case 'int': $attribs['type'] = 'number'; break; case 'float': $attribs['type'] = 'number'; $attribs['step'] = 'any'; break; # Pass through # Pass through case 'password': case 'file': $attribs['type'] = $this->mParams['type']; break; } } return Html::element('input', $attribs); }
public static function monthDropdownHTML($cur_month, $input_name, $is_disabled) { global $sfgTabIndex, $wgAmericanDates; $optionsText = ''; $month_names = SFFormUtils::getMonthNames(); // Add a "null" value at the beginning. array_unshift($month_names, null); foreach ($month_names as $i => $name) { if (is_null($name)) { $month_value = null; } else { // Pad out month to always be two digits. $month_value = $wgAmericanDates == true ? $name : str_pad($i, 2, '0', STR_PAD_LEFT); } $optionAttrs = array('value' => $month_value); if ($name == $cur_month || $i == $cur_month) { $optionAttrs['selected'] = 'selected'; } $optionsText .= Html::element('option', $optionAttrs, $name); } $selectAttrs = array('class' => 'monthInput', 'name' => $input_name . '[month]', 'tabindex' => $sfgTabIndex); if ($is_disabled) { $selectAttrs['disabled'] = 'disabled'; } $text = Html::rawElement('select', $selectAttrs, $optionsText); return $text; }
/** * 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"; }
/** * Renders special page output. * @param string $sParameter Name of the article, who's review should be edited, or user whos review should be displayed. * @return bool Allow other hooked methods to be executed. always true. */ public function execute($sParameter) { parent::execute($sParameter); $sOut = ''; $oOutputPage = $this->getOutput(); $oOutputPage->addModules('ext.bluespice.review.overview'); //TODO: Redundant? if (!$this->getUser()->isAllowed('workflowview')) { $sOut = wfMessage('bs-review-not-allowed')->plain(); $oOutputPage->addHTML($sOut); return true; } $oUser = User::newFromName($sParameter); if ($oUser && $oUser->getId() > 0) { $sName = $oUser->getRealName(); $sName = empty($sName) ? $oUser->getName() : $oUser->getRealName() . ' (' . $oUser->getName() . ')'; $oOutputPage->setPagetitle(wfMessage('bs-review-specialreview-header', 1, $sName)->text()); $oOutputPage->addJsConfigVars('bsSpecialReviewUserID', $oUser->getId()); $oOutputPage->addJsConfigVars('bsSpecialReviewUserName', $oUser->getName()); } else { $oOutputPage->setPagetitle(wfMessage('bs-review-specialreview-header', 0)->text()); } $oOutputPage->addHTML($sOut); $oOutputPage->addHTML(Html::element('div', array('id' => 'bs-review-overview'))); return true; }
/** * * @global OutputPage $wgOut * @param string $sParameter */ public function execute($sParameter) { parent::execute($sParameter); $this->checkForReadOnly(); $this->getAdminConfig(); $this->getOutput()->addHTML(Html::element('div', array('id' => 'bs-dashboards-admindashboard'))); return; }
public function reasonBlock() { $msg = wfMsgExt('phalanx-title-move-summary', 'parseinline'); $msg .= Html::element('p', array(), wfMsg('phalanx-stats-table-id') . " #{$this->block->id}"); $msg .= wfMsgExt('spamprotectionmatch', 'parseinline', "<nowiki>{$this->block->text}</nowiki>"); $this->logBlock(); return $msg; }
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; }
/** * Returns the HTML which is added to $wgOut after the article text. * * @return string */ protected function getHtml() { if (!$this->store->getRedirectTarget($this->mProperty)->equals($this->mProperty)) { return ''; } $list = $this->getSubpropertyList() . $this->getPropertyValueList(); $result = $list !== '' ? Html::element('div', array('id' => 'smwfootbr')) . $list : ''; return $result; }
/** * @param Array $extraParams: array of extra parameters to give to the image * @return String: <img> HTML tag with full path to the avatar image * */ function getAvatarHtml($extraParams = array()) { global $wgUploadPath; $site_prefix = $this->user_id; $name = HuijiPrefix::prefixToSiteName($site_prefix); $defaultParams = array('src' => "{$wgUploadPath}/avatars/{$this->getAvatarImage()}", 'alt' => 'avatar', 'border' => '0', 'class' => 'siteimg', 'data-name' => $name); $params = array_merge($extraParams, $defaultParams); return Html::element('img', $params, ''); }
/** * Show error page, that the user does not exist, or no user provided * @param string $msgKey Message key to use as error message body * @return string */ protected function displayNoUserError($msgKey) { $out = $this->getOutput(); // generate a user friendly error with a meaningful message $html = MobileUI::contentElement(MobileUI::errorBox(Html::element('h2', array(), $this->msg('mobile-frontend-profile-error')) . Html::element('p', array(), $this->msg($msgKey)))); // return page with status code 404, instead of 200 and output the error page $out->setStatusCode(404); $out->addHtml($html); }
/** * @see MapsBaseMap::getMapHTML() */ public function getMapHTML(array $params, Parser $parser, $mapName) { global $wgLang; $thumbs = $params['thumbs'] ? 'yes' : 'no'; $photos = $params['photos'] ? 'yes' : 'no'; $lang = $wgLang->getCode(); // https://secure.wikimedia.org/wikipedia/de/wiki/Wikipedia:WikiProjekt_Georeferenzierung/Wikipedia-World/en#Expert_mode return Html::element('iframe', array('id' => $mapName, 'style' => "width: {$params['width']}; height: {$params['height']}; clear: both;", 'src' => "http://toolserver.org/~kolossos/openlayers/kml-on-ol.php?zoom={$params['zoom']}&lat={$params['centre']['lat']}&lon={$params['centre']['lon']}&lang={$lang}&thumbs={$thumbs}&photo={$photos}"), wfMsg('maps-loading-map')); }
/** * Renrder the survey div. * * @since 0.1 * * @param Parser $parser * * @return string */ public function render(Parser $parser) { static $loadedJs = false; if (!$loadedJs) { $parser->getOutput()->addModules('ext.survey.tag'); $parser->getOutput()->addHeadItem(Skin::makeVariablesScript(array('wgSurveyDebug' => SurveySettings::get('JSDebug')))); } return Html::element('span', $this->parameters, $this->contents); }
function getForm(OutputPage $out) { $captcha = $this->getCaptcha(); if (!$captcha) { die("No questions found; set some in LocalSettings.php using the format from QuestyCaptcha.php."); } $index = $this->storeCaptcha($captcha); return "<p><label for=\"wpCaptchaWord\">{$captcha['question']}</label> " . Html::element('input', array('name' => 'wpCaptchaWord', 'id' => 'wpCaptchaWord', 'class' => 'mw-ui-input', 'required', 'autocomplete' => 'off', 'tabindex' => 1)) . "</p>\n" . Xml::element('input', array('type' => 'hidden', 'name' => 'wpCaptchaId', 'id' => 'wpCaptchaId', 'value' => $index)); }