static function tableMessageRowHTML($css_class, $name, $value) { $cell1 = HTML::element('td', array('class' => $css_class), $name); $cell2 = HTML::element('td', array('class' => 'msg'), $value); $text = HTML::rawElement('tr', null, $cell1 . "\n" . $cell2); $text .= "\n"; return $text; }
/** * Main function for special page. At the current time only produces html for the blacklist. * Should support updating the blacklist. * * @global $wgOut object * @global $wgRequest object * @param $par */ public function execute($par) { global $wgOut, $wgRequest; $this->setHeaders(); //$this->outputHeader(); $wgOut->addWikiMsg('archivelinks-modify-blacklist-desc'); $wgOut->addHTML(HTML::openElement('form', array('method' => 'post', 'action' => SpecialPage::getTitleFor('ModifyBlacklist')->getLocalUrl())) . HTML::openElement('fieldset') . HTML::element('legend', null, wfMsg('ModifyArchiveBlacklist')) . HTML::openElement('table') . HTML::openElement('tr') . HTML::openElement('td') . wfMsg('archivelinks-modify-blacklist-blacklist-or-whitelist-field-label') . HTML::closeElement('td') . HTML::openElement('td') . HTML::element('input', array('name' => 'bl_blacklist-whitelist', 'type' => 'radio', 'value' => 'blacklist')) . ' ' . wfMsg('archivelinks-modify-blacklist-blacklist-field-label') . HTML::closeElement('td') . HTML::closeElement('tr') . HTML::openElement('tr') . HTML::openElement('td') . HTML::closeElement('td') . HTML::openElement('td') . HTML::element('input', array('name' => 'bl_blacklist-whitelist', 'type' => 'radio', 'value' => 'whitelist')) . ' ' . wfMsg('archivelinks-modify-blacklist-whitelist-field-label') . HTML::closeElement('td') . HTML::closeElement('tr') . HTML::openElement('tr') . HTML::openElement('td') . wfMsg('archivelinks-modify-blacklist-add-or-remove-field-label') . HTML::closeElement('td') . HTML::openElement('td') . HTML::element('input', array('name' => 'bl_add-remove', 'type' => 'radio', 'value' => 'add')) . ' ' . wfMsg('archivelinks-modify-blacklist-add-field-label') . HTML::closeElement('td') . HTML::closeElement('tr') . HTML::openElement('tr') . HTML::openElement('td') . HTML::closeElement('td') . HTML::openElement('td') . HTML::element('input', array('name' => 'bl_add-remove', 'type' => 'radio', 'value' => 'remove')) . ' ' . wfMsg('archivelinks-modify-blacklist-remove-field-label') . HTML::closeElement('td') . HTML::closeElement('tr') . HTML::openElement('tr') . HTML::openElement('td') . HTML::element('label', array('for' => 'bl_url'), wfMsg('archivelinks-modify-blacklist-url-field-label')) . HTML::closeElement('td') . HTML::openElement('td') . HTML::element('input', array('name' => 'bl_url', 'type' => 'text', 'size' => '110')) . HTML::closeElement('td') . HTML::closeElement('tr') . HTML::openElement('tr') . HTML::openElement('td') . HTML::element('label', array('for' => 'bl_duration'), wfMsg('archivelinks-modify-blacklist-duration-field-label')) . HTML::closeElement('td') . HTML::openElement('td') . HTML::element('input', array('name' => 'bl_duration', 'type' => 'text', 'size' => '60')) . HTML::closeElement('td') . HTML::closeElement('tr') . HTML::openElement('tr') . HTML::openElement('td') . HTML::element('label', array('for' => 'bl_reason'), wfMsg('archivelinks-modify-blacklist-reason-field-label')) . HTML::closeElement('td') . HTML::openElement('td') . HTML::element('input', array('name' => 'bl_reason', 'type' => 'text', 'size' => '60')) . HTML::closeElement('td') . HTML::closeElement('tr') . HTML::closeElement('table') . XML::submitButton('Blacklist URL') . HTML::closeElement('fieldset') . HTML::closeElement('form')); }
function setupAttachmentListSection(&$data) { $_data = ''; $attachmentContainerDiv = \HTML::element('br') . \HTML::element('div', array('id' => 'PageAttachmentContainer')); $page = $this->session->getCurrentPage(); if ($this->isSetupAttachmentListSection($page)) { $pageTitle = $page->getPageTitle(); if ($this->staticConfig->isDisallowAttachmentsUsingMagicWord()) { $script = \HTML::inlineScript(' function pageAttachment_isLoadPageAttachments() { return ((typeof pageAttachment__ALLOW_ATTACHMENTS__ == "boolean") ? pageAttachment__ALLOW_ATTACHMENTS__ : true); } '); } else { $script = \HTML::inlineScript(' function pageAttachment_isLoadPageAttachments() { return true; } '); } $script .= \HTML::inlineScript(' function pageAttachment_getAttachToPageTitle() { return "' . $pageTitle . '"; } '); if ($this->session->isForceReload()) { $script .= \HTML::inlineScript(' function pageAttachment_isForceReload() { return true; } '); } else { $script .= \HTML::inlineScript(' function pageAttachment_isForceReload() { return false; } '); } $_data = $script; } else { $allowAttachmentsUsingMagicWord = $this->staticConfig->isAllowAttachmentsUsingMagicWord(); if ($allowAttachmentsUsingMagicWord && $this->isSetupAttachmentListSection($page, $allowAttachmentsUsingMagicWord)) { $pageTitle = $page->getPageTitle(); $script = \HTML::inlineScript(' function pageAttachment_isLoadPageAttachments() { return ((typeof pageAttachment__ALLOW_ATTACHMENTS__ == "boolean") ? pageAttachment__ALLOW_ATTACHMENTS__ : false); } '); $script .= \HTML::inlineScript(' function pageAttachment_getAttachToPageTitle() { return "' . $pageTitle . '"; } '); if ($this->session->isForceReload()) { $script .= \HTML::inlineScript(' function pageAttachment_isForceReload() { return true; } '); } else { $script .= \HTML::inlineScript(' function pageAttachment_isForceReload() { return false; } '); } } else { $script = \HTML::inlineScript(' function pageAttachment_isLoadPageAttachments() { return false; } '); } $_data = $script; } $data = $attachmentContainerDiv . $_data; return true; }
static function attrRowHTML( $cssClass, $fieldName, $value ) { $fieldNameAttrs = array( 'class' => $cssClass, 'style' => 'font-weight: normal;' ); $fieldNameCell = HTML::rawElement( 'td', $fieldNameAttrs, $fieldName ); $valueCell = HTML::element( 'td', array( 'class' => 'msg', 'style' => 'font-weight: bold;' ), $value ); $text = HTML::rawElement( 'tr', null, $fieldNameCell . "\n" . $valueCell ); $text .= "\n"; return $text; }
/** * Get an HTML table of data for the user's congressional representatives * @return string HTML for the table */ private function getCongressTables() { global $wgCongressLookupErrorPage, $wgRequest; $myRepresentatives = CongressLookupDB::getRepresentative($this->zip); $mySenators = CongressLookupDB::getSenators($this->zip); $congressTable = ''; $congressTable .= Html::element('h4', array(), wfMsg('congresslookup-your-reps')); if ($myRepresentatives) { foreach ($myRepresentatives as $myRepresentative) { $congressTable .= "\n" . Html::openElement('table', array('class' => 'person')); $congressTable .= "\n" . Html::rawElement('tr', array(), Html::element('td', array('class' => 'name'), $myRepresentative['name'])); $congressTable .= "\n" . Html::rawElement('tr', array(), Html::element('td', array(), wfMsg('congresslookup-phone', $myRepresentative['phone']))); if ($myRepresentative['twitter']) { $congressTable .= "\n" . Html::rawElement('tr', array(), Html::rawElement('td', array(), wfMsg('congresslookup-twitter', self::getTwitterHtml($myRepresentative['twitter'])))); } $congressTable .= "\n" . Html::rawElement('tr', array(), Html::rawElement('td', array(), Html::element('a', array('href' => $myRepresentative['contactform'], 'target' => '_blank'), wfMsg('congresslookup-contact-form')))); $congressTable .= Html::rawElement('tr', array(), Html::rawElement('td', array(), $this->getSocialMedia($myRepresentative))); $congressTable .= "\n" . Html::closeElement('table'); } if (count($myRepresentatives) > 1) { $congressTable .= HTML::element('p', array('class' => 'note'), wfMsg('congresslookup-multiple-house-reps')); } } else { $congressTable .= Html::element('p', array(), wfMsg('congresslookup-no-house-rep')); } foreach ($mySenators as $senator) { $congressTable .= "\n" . Html::openElement('table', array('class' => 'person')); $congressTable .= "\n" . Html::rawElement('tr', array(), Html::element('td', array('class' => 'name'), $senator['name'])); $congressTable .= "\n" . Html::rawElement('tr', array(), Html::element('td', array(), wfMsg('congresslookup-phone', $senator['phone']))); /* $congressTable .= "\n" . Html::rawElement( 'tr', array(), Html::element( 'td', array(), wfMsg( 'congresslookup-fax', $senator['fax'] ) ) ); */ if ($senator['twitter']) { $congressTable .= "\n" . Html::rawElement('tr', array(), Html::rawElement('td', array(), wfMsg('congresslookup-twitter', self::getTwitterHtml($senator['twitter'])))); } $congressTable .= "\n" . Html::rawElement('tr', array(), Html::rawElement('td', array(), Html::element('a', array('href' => $senator['contactform'], 'target' => '_blank'), wfMsg('congresslookup-contact-form')))); $congressTable .= Html::rawElement('tr', array(), Html::rawElement('td', array(), $this->getSocialMedia($senator))); $congressTable .= "\n" . Html::closeElement('table'); } if (count($mySenators) == 0) { $congressTable .= Html::element('p', array(), wfMsg('congresslookup-no-senators')); } $errorPage = SpecialPage::getTitleFor($wgCongressLookupErrorPage); $errorUrl = $errorPage->getLocalURL(array('zip' => $wgRequest->getVal('zip'))); $congressTable .= Html::openElement('p'); $congressTable .= Html::element('a', array('href' => $errorUrl), wfMsg('congresslookup-report-errors')); $congressTable .= Html::closeElement('p'); return $congressTable; }
/** * @dataProvider providesHtml5InputTypes */ function testHtmlElementAcceptsNewHtml5TypesInHtml5Mode($HTML5InputType) { $this->enableHTML5(); $this->assertEquals('<input type="' . $HTML5InputType . '" />', HTML::element('input', array('type' => $HTML5InputType)), 'In HTML5, HTML::element() should accept type="' . $HTML5InputType . '"'); }
/** * Insert the captcha prompt into the edit form. */ function getForm() { global $wgOut, $wgEnableAPI; // Uses addModuleStyles so it is loaded when JS is disabled. $wgOut->addModuleStyles('ext.confirmEdit.fancyCaptcha.styles'); $title = SpecialPage::getTitleFor('Captcha', 'image'); $index = $this->getCaptchaIndex(); if ($wgEnableAPI) { // Loaded only if JS is enabled $wgOut->addModules('ext.confirmEdit.fancyCaptcha'); $captchaReload = Html::element('small', array('class' => 'confirmedit-captcha-reload fancycaptcha-reload'), wfMessage('fancycaptcha-reload-text')->text()); } else { $captchaReload = ''; } $form = Html::openElement('div') . Html::element('label', array('for' => 'wpCaptchaWord'), parent::getMessage('label') . ' ' . wfMessage('createacct-captcha')->text()) . Html::openElement('div', array('class' => 'mw-createacct-captcha-container')) . Html::openElement('div', array('class' => 'mw-createacct-captcha-and-reload')) . Html::openElement('div', array('class' => 'fancycaptcha-image-container')) . Html::element('img', array('class' => 'fancycaptcha-image', 'src' => $title->getLocalUrl('wpCaptchaId=' . urlencode($index)), 'alt' => '')) . $captchaReload . Html::closeElement('div') . Html::closeElement('div') . "\n" . Html::element('input', array('name' => 'wpCaptchaWord', 'class' => 'mw-ui-input', 'id' => 'wpCaptchaWord', 'type' => 'text', 'size' => '12', 'autocomplete' => 'off', 'autocorrect' => 'off', 'autocapitalize' => 'off', 'required' => 'required', 'tabindex' => 1, 'placeholder' => wfMessage('createacct-imgcaptcha-ph'))); // tab in before the edit textarea if ($this->action == 'usercreate') { $form .= HTML::element('small', array('class' => 'mw-createacct-captcha-assisted'), wfMessage('createacct-imgcaptcha-help')); } $form .= Html::element('input', array('type' => 'hidden', 'name' => 'wpCaptchaId', 'id' => 'wpCaptchaId', 'value' => $index)) . Html::closeElement('div') . Html::closeElement('div') . "\n"; return $form; }
function composeAttachmentListTable($protectedPage, $titleRowColumns, $headerRowColumns, $attachmentRows) { global $wgLang; global $wgPageAttachment_colToDisplay; global $wgPageAttachment_colWidth; global $wgPageAttachment_descriptionMaxLength; global $wgPageAttachment_descriptionPopupWidth; global $wgPageAttachment_descriptionPopupHeight; $skinName = $this->runtimeConfig->getSkinName(); $userLangCode = $this->runtimeConfig->getUserLanguageCode(); $rtlLang = $this->runtimeConfig->isRightToLeftLanguage(); $colWidths = $this->getColWidths($skinName, $userLangCode); $colgroupCols = ''; foreach ($colWidths as $colWidth) { $colgroupCols .= \HTML::element('col', array('width' => $colWidth . '%')); } $colgroup = \HTML::rawElement('colgroup', null, $colgroupCols); // // Title Row // $titleRowColKeys = array_keys($titleRowColumns); $titleRowCols = ''; foreach ($titleRowColKeys as $colKey) { $attrs = array('class' => 'titleRow_col_' . $colKey, 'colspan' => $this->getTitleRowColSpan($skinName, $userLangCode, $colKey)); $titleRowCols .= \HTML::rawElement('th', $attrs, $titleRowColumns[$colKey]); } $titleRow = \HTML::rawElement('tr', array('class' => 'TitleRow'), $titleRowCols); // // Header Row // $headerRowColKeys = array_keys($headerRowColumns); $headerRowCols = ''; foreach ($headerRowColKeys as $colKey) { $headerRowCols .= \HTML::element('th', array('class' => 'headerRow_col_' . $colKey), $headerRowColumns[$colKey]); } $headerRow = \HTML::rawElement('tr', array('class' => 'HeaderRow'), $headerRowCols); $thead = \HTML::rawElement('thead', null, $titleRow . $headerRow); // // Attachment Rows // $viewMoreImgURL = $this->resource->getViewMoreImageURL(); $viewMoreImgIcon = \HTML::rawElement('img', array('src' => $viewMoreImgURL)); $atRows = ''; if ($this->security->isViewAttachmentsAllowed($protectedPage)) { if (isset($attachmentRows) && count($attachmentRows) > 0) { foreach ($attachmentRows as $row) { $rowCols = $row; $rowColKeys = array_keys($rowCols); $atRowsCols = ''; foreach ($rowColKeys as $colKey) { if ($colKey == 'Description') { if ($rowCols[$colKey] == '') { $atRowsCols .= \HTML::rawElement('td', array('class' => 'attachmentRow_col_' . $colKey), ''); } else { if (strlen($rowCols[$colKey]) > $wgPageAttachment_descriptionMaxLength) { $descriptionAndIcon = ''; $desc = \PageAttachment\Utility\StringUtil::trimText($rowCols[$colKey], $wgPageAttachment_descriptionMaxLength); $descriptionAndIcon = $desc . '... ' . $viewMoreImgIcon; $atRowsCols .= \HTML::rawElement('td', array('class' => 'attachmentRow_col_' . $colKey, 'onmouseover' => 'pageAttachment_showPopup(this, "' . $wgPageAttachment_descriptionPopupWidth . '", "' . $wgPageAttachment_descriptionPopupHeight . '", "' . $rowCols[$colKey] . '", ' . ($rtlLang == true ? "true" : "false") . ');', 'onmouseout' => 'pageAttachment_removePopup();'), $descriptionAndIcon); } else { $atRowsCols .= \HTML::rawElement('td', array('class' => 'attachmentRow_col_' . $colKey), $rowCols[$colKey]); } } } else { $atRowsCols .= \HTML::rawElement('td', array('class' => 'attachmentRow_col_' . $colKey), $rowCols[$colKey]); } } $atRows .= \HTML::rawElement('tr', array('class' => 'AttachmentRow'), $atRowsCols); } } else { $colSpan = count($colWidths); $atRowsCol = \HTML::element('td', array('class' => 'messageAttachmentsNone', 'colspan' => $colSpan), \wfMsg('AttachmentsNone')); $atRows = \HTML::rawElement('tr', array('class' => 'MessageRow'), $atRowsCol); } // Status Message $statusMsg = $this->session->getStatusMessage(); if (isset($statusMsg)) { $statusMsg = $this->formatStatusMessage($statusMsg); $colSpan = count($colWidths); $atRowCol = \HTML::rawElement('td', array('class' => 'message', 'colspan' => $colSpan), $statusMsg); $atRows .= \HTML::rawElement('tr', array('class', 'MessageRow'), $atRowCol); } } else { if ($this->security->isViewAttachmentsRequireLogin() && !$this->security->isLoggedIn()) { $statusMsg = \wfMsg('YouMustBeLoggedInToViewAttachments'); } else { $statusMsg = \wfMsg('ViewAttachmentIsNotPermitted'); } $statusMsg = $this->formatStatusMessage($statusMsg); $colSpan = count($colWidths); $atRowCol = \HTML::rawElement('td', array('class' => 'message', 'colspan' => $colSpan), $statusMsg); $atRows .= \HTML::rawElement('tr', array('class', 'MessageRow'), $atRowCol); } $tbody = \HTML::rawElement('tbody', null, $atRows); $data = \HTML::rawElement('table', array('cellspacing' => '0'), $colgroup . $thead . $tbody); return $data; }
/** * Uses the HTML functions to output the appropiate form for the special page if no archived version * exists or if no query has been specified by the user yet. * * @global $wgOut object */ private function output_form() { global $wgOut; $this->setHeaders(); $wgOut->addWikiMsg('archivelinks-view-archive-desc'); $wgOut->addHTML(HTML::openElement('form', array('method' => 'get', 'action' => SpecialPage::getTitleFor('ViewArchive')->getLocalUrl())) . HTML::openElement('fieldset') . HTML::element('legend', null, wfMsg('ViewArchive')) . XML::inputLabel(wfMsg('archivelinks-view-archive-url-field'), 'archive_url', 'archive-links-archive-url', 120) . HTML::element('br') . XML::submitButton(wfMsg('archivelinks-view-archive-submit-button')) . HTML::closeElement('fieldset') . HTML::closeElement('form')); }
/** * This is the function resposible for rewriting the link html to insert the [cache] link * after each external link on the page. This function will get called once for every external link. * * @global $wgArchiveLinksConfig array * @param $url string The url of the page (what would appear in href) * @param $text string The assoicated text of the URL (what would go between the anchor tags) * @param $link string The rewritten text of the URL * @param $attributes array Any attributes for the anchor tag * @return bool */ public static function rewriteLinks(&$url, &$text, &$link, &$attributes) { if (isset($attributes['rel']) && $attributes['rel'] === 'nofollow') { global $wgArchiveLinksConfig; if ($wgArchiveLinksConfig['use_multiple_archives']) { //need to add support for more than one archival service at once // (a page where you can select one from a list of choices) } else { switch ($wgArchiveLinksConfig['archive_service']) { case 'local': //We need to have something to figure out where the filestore is... $link_to_archive = urlencode(substr_replace($url, '', 0, 7)); break; case 'wikiwix': $link_to_archive = 'http://archive.wikiwix.com/cache/?url=' . $url; break; case 'webcitation': $link_to_archive = 'http://webcitation.org/query?url=' . $url; break; case 'internet_archive': default: if (false) { $db_slave = wfGetDB(DB_SLAVE); $db_slave->select('el_archive_link_history', '*'); } else { $link_to_archive = 'http://wayback.archive.org/web/*/' . $url; } break; } } $link = HTML::element('a', array('rel' => 'nofollow', 'class' => $attributes['class'], 'href' => $url), $text) . HTML::openElement('sup') . HTML::openElement('small') . ' ' . HTML::element('a', array('rel' => 'nofollow', 'href' => $link_to_archive), '[' . wfMsg('archivelinks-cache-title') . ']') . HTML::closeElement('small') . HTML::closeElement('sup'); return false; } else { return true; } }
public function getExpansionPrefix( $class, $elementId ) { if ( ! $this->isCollapsible ) { return ''; } // if it is collapsible, continue $prefix = HTML::element('span', array( 'id' => "prefix-collapsed-$elementId" , 'class' => "collapse-$class" ) , "▶" ) ; $prefix .= HTML::element('span', array( 'id' => "prefix-expanded-$elementId" , 'class' => "expand-$class" ) , "▼" ) ; return $prefix ; }
/** * displayResultsForDebug * * Displays useful information for debugging purposes. * Enable with $wgDonationInterfaceDisplayDebug, or the adapter equivalent. * @return null */ protected function displayResultsForDebug($results = array()) { global $wgOut; $results = empty($results) ? $this->adapter->getTransactionAllResults() : $results; if ($this->adapter->getGlobal('DisplayDebug') !== true) { return; } $wgOut->addHTML(HTML::element('span', null, $results['message'])); if (!empty($results['errors'])) { $wgOut->addHTML(HTML::openElement('ul')); foreach ($results['errors'] as $code => $value) { $wgOut->addHTML(HTML::element('li', null, "Error {$code}: {$value}")); } $wgOut->addHTML(HTML::closeElement('ul')); } if (!empty($results['data'])) { $wgOut->addHTML(HTML::openElement('ul')); foreach ($results['data'] as $key => $value) { if (is_array($value)) { $wgOut->addHTML(HTML::openElement('li', null, $key) . HTML::openElement('ul')); foreach ($value as $key2 => $val2) { $wgOut->addHTML(HTML::element('li', null, "{$key2}: {$val2}")); } $wgOut->addHTML(HTML::closeElement('ul') . HTML::closeElement('li')); } else { $wgOut->addHTML(HTML::element('li', null, "{$key}: {$value}")); } } $wgOut->addHTML(HTML::closeElement('ul')); } else { $wgOut->addHTML("Empty Results"); } if (array_key_exists('Donor', $_SESSION)) { $wgOut->addHTML("Session Donor Vars:" . HTML::openElement('ul')); foreach ($_SESSION['Donor'] as $key => $val) { $wgOut->addHTML(HTML::element('li', null, "{$key}: {$val}")); } $wgOut->addHTML(HTML::closeElement('ul')); } else { $wgOut->addHTML("No Session Donor Vars:"); } if (is_array($this->adapter->debugarray)) { $wgOut->addHTML("Debug Array:" . HTML::openElement('ul')); foreach ($this->adapter->debugarray as $val) { $wgOut->addHTML(HTML::element('li', null, $val)); } $wgOut->addHTML(HTML::closeElement('ul')); } else { $wgOut->addHTML("No Debug Array"); } }
/** * Get the body of the ad, with all transformations applied. */ public function renderHtml() { $adCaption = $this->getCaption(); $adBody = wfMessage($this->getDbKey())->parse(); $adMainLink = $this->getMainLink(); $adMainLink = empty($adMainLink) ? null : Skin::makeInternalOrExternalUrl($this->getMainLink()); $adHtml = HTML::openElement('div', array('class' => 'promotion', 'data-adname' => $this->getName())); $adHtml .= HTML::openElement('div', array('class' => 'header')); //$adHtml .= HTML::element( 'span', array( 'class' => 'icon pull-right' ) ); if (empty($adMainLink)) { $adHtml .= HTML::element('span', array('class' => 'caption'), $adCaption); } else { $adHtml .= HTML::element('a', array('class' => 'caption', 'href' => $adMainLink), $adCaption); } $adHtml .= HTML::closeElement('div'); $adHtml .= HTML::rawElement('div', array('class' => 'content'), $adBody); if ($adMainLink) { $adHtml .= HTML::openElement('div', array('class' => 'mainlink')); $adHtml .= HTML::element('a', array('href' => $adMainLink), 'לפרטים נוספים...'); $adHtml .= HTML::closeElement('div'); } $adHtml .= HTML::closeElement('div'); return $adHtml; }