本文整理汇总了PHP中OutputPage::addHTML方法的典型用法代码示例。如果您正苦于以下问题:PHP OutputPage::addHTML方法的具体用法?PHP OutputPage::addHTML怎么用?PHP OutputPage::addHTML使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OutputPage
的用法示例。
在下文中一共展示了OutputPage::addHTML方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
/**
* Perform a book information request and output the result
* if available, or an error if appropriate
*
* @param string $isbn ISBN to be queried
* @param OutputPage $output OutputPage object to use
*/
public static function show($isbn, $output)
{
if (self::isValidISBN($isbn)) {
$result = BookInformationCache::get($isbn);
if ($result === false) {
$driver = self::getDriver();
if ($driver !== false) {
$result = $driver->submitRequest($isbn);
if ($result->isCacheable()) {
BookInformationCache::set($isbn, $result);
}
} else {
$output->addHTML(self::makeError('nodriver'));
return;
}
}
if ($result->getResponseCode() == BookInformationResult::RESPONSE_OK) {
$output->addHTML(self::makeResult($result));
} elseif ($result->getResponseCode() == BookInformationResult::RESPONSE_NOSUCHITEM) {
$output->addHTML(self::makeError('nosuchitem'));
} else {
$output->addHTML(self::makeError('noresponse'));
}
} else {
$output->addHTML(self::makeError('invalidisbn'));
}
}
示例2: doModLangs
/**
* @param $group MessageGroup
*/
public function doModLangs($group)
{
global $wgLang;
$languages = array_keys(Language::getLanguageNames(false));
$modified = $codes = array();
foreach ($languages as $code) {
if ($code === 'en') {
continue;
}
$cache = new MessageGroupCache($group, $code);
if ($cache->isValid()) {
continue;
}
$link = $this->skin->link($this->getTitle(), htmlspecialchars(TranslateUtils::getLanguageName($code, false, $wgLang->getCode()) . " ({$code})"), array(), array('group' => $group->getId(), 'language' => $code));
if (!$cache->exists()) {
$modified[] = wfMsgHtml('translate-manage-modlang-new', $link);
} else {
$modified[] = $link;
}
$codes[] = $code;
}
if (count($modified)) {
$this->out->addWikiMsg('translate-manage-modlangs', $wgLang->formatNum(count($modified)));
if ($this->user->isAllowed('translate-manage')) {
$this->out->addHTML($this->rebuildButton($group, $codes, 'import'));
}
$this->out->addHTML('<ul><li>' . implode("</li>\n<li>", $modified) . '</li></ul>');
}
}
示例3: showEditFormFields
/**
* Show error message for missing or incorrect captcha on EditPage.
* @param EditPage $editPage
* @param OutputPage $out
*/
function showEditFormFields(&$editPage, &$out)
{
$page = $editPage->getArticle()->getPage();
if (!isset($page->ConfirmEdit_ActivateCaptcha)) {
return;
}
unset($page->ConfirmEdit_ActivateCaptcha);
$out->addHTML(Html::openElement('div', array('id' => 'mw-confirmedit-error-area', 'class' => 'errorbox')) . Html::element('strong', array(), $out->msg('errorpagetitle')->text()) . Html::element('div', array('id' => 'errorbox-body'), $out->msg('captcha-sendemail-fail')->text()) . Html::closeElement('div'));
$this->showEditCaptcha = true;
}
示例4: showEditFormFields
/**
* Show error message for missing or incorrect captcha on EditPage.
* @param EditPage $editPage
* @param OutputPage $out
*/
function showEditFormFields(&$editPage, &$out)
{
$page = $editPage->getArticle()->getPage();
if (!isset($page->ConfirmEdit_ActivateCaptcha)) {
return;
}
if ($this->action !== 'edit') {
unset($page->ConfirmEdit_ActivateCaptcha);
$out->addWikiText($this->getMessage($this->action));
$out->addHTML($this->getForm($out));
}
}
示例5: outputResults
/**
* Format and output report results using the given information plus
* OutputPage
*
* @param OutputPage $out OutputPage to print to
* @param Skin $skin User skin to use [unused]
* @param DatabaseBase $dbr (read) connection to use
* @param int $res Result pointer
* @param int $num Number of available result rows
* @param int $offset Paging offset
*/
protected function outputResults($out, $skin, $dbr, $res, $num, $offset)
{
if ($num > 0) {
$gallery = new ImageGallery();
# $res might contain the whole 1,000 rows, so we read up to
# $num [should update this to use a Pager]
for ($i = 0; $i < $num && ($row = $dbr->fetchObject($res)); $i++) {
$namespace = isset($row->namespace) ? $row->namespace : NS_FILE;
$title = Title::makeTitleSafe($namespace, $row->title);
if ($title instanceof Title && $title->getNamespace() == NS_FILE) {
$gallery->add($title, $this->getCellHtml($row));
}
}
$out->addHTML($gallery->toHtml());
}
}
示例6: outputResults
/**
* Format and output report results using the given information plus
* OutputPage
*
* @param OutputPage $out OutputPage to print to
* @param Skin $skin User skin to use
* @param Database $dbr Database (read) connection to use
* @param int $res Result pointer
* @param int $num Number of available result rows
* @param int $offset Paging offset
*/
protected function outputResults($out, $skin, $dbr, $res, $num, $offset)
{
if ($num > 0) {
$gallery = new ImageGallery();
$gallery->useSkin($skin);
# $res might contain the whole 1,000 rows, so we read up to
# $num [should update this to use a Pager]
for ($i = 0; $i < $num && ($row = $dbr->fetchObject($res)); $i++) {
$image = $this->prepareImage($row);
if ($image) {
$gallery->add($image->getTitle(), $this->getCellHtml($row));
}
}
$out->addHTML($gallery->toHtml());
}
}
示例7: outputResults
/**
* Format and output report results using the given information plus
* OutputPage
*
* @param OutputPage $out OutputPage to print to
* @param Skin $skin User skin to use [unused]
* @param DatabaseBase $dbr (read) connection to use
* @param ResultWrapper $res Result pointer
* @param int $num Number of available result rows
* @param int $offset Paging offset
*/
protected function outputResults($out, $skin, $dbr, $res, $num, $offset)
{
if ($num > 0) {
$gallery = ImageGalleryBase::factory(false, $this->getContext());
# $res might contain the whole 1,000 rows, so we read up to
# $num [should update this to use a Pager]
$i = 0;
foreach ($res as $row) {
$i++;
$namespace = isset($row->namespace) ? $row->namespace : NS_FILE;
$title = Title::makeTitleSafe($namespace, $row->title);
if ($title instanceof Title && $title->getNamespace() == NS_FILE) {
$gallery->add($title, $this->getCellHtml($row));
}
if ($i === $num) {
break;
}
}
$out->addHTML($gallery->toHtml());
}
}
示例8: showOptions
/**
* Show options for the log list
*
* @param $types string or Array
* @param $user String
* @param $page String
* @param $pattern String
* @param $year Integer: year
* @param $month Integer: month
* @param $filter: array
* @param $tagFilter: array?
*/
public function showOptions($types = array(), $user = '', $page = '', $pattern = '', $year = '', $month = '', $filter = null, $tagFilter = '')
{
global $wgScript, $wgMiserMode;
$action = $wgScript;
$title = SpecialPage::getTitleFor('Log');
$special = $title->getPrefixedDBkey();
// For B/C, we take strings, but make sure they are converted...
$types = $types === '' ? array() : (array) $types;
$tagSelector = ChangeTags::buildTagFilterSelector($tagFilter);
$html = Html::hidden('title', $special);
// Basic selectors
$html .= $this->getTypeMenu($types) . "\n";
$html .= $this->getUserInput($user) . "\n";
$html .= $this->getTitleInput($page) . "\n";
$html .= $this->getExtraInputs($types) . "\n";
// Title pattern, if allowed
if (!$wgMiserMode) {
$html .= $this->getTitlePattern($pattern) . "\n";
}
// date menu
$html .= Xml::tags('p', null, Xml::dateMenu($year, $month));
// Tag filter
if ($tagSelector) {
$html .= Xml::tags('p', null, implode(' ', $tagSelector));
}
// Filter links
if ($filter) {
$html .= Xml::tags('p', null, $this->getFilterLinks($filter));
}
// Submit button
$html .= Xml::submitButton(wfMsg('allpagessubmit'));
// Fieldset
$html = Xml::fieldset(wfMsg('log'), $html);
// Form wrapping
$html = Xml::tags('form', array('action' => $action, 'method' => 'get'), $html);
$this->out->addHTML($html);
}
示例9: showLogExtract
/**
* Show protection long extracts for this page
*
* @param OutputPage $out
* @access private
*/
function showLogExtract(&$out)
{
# Show relevant lines from the protection log:
$protectLogPage = new LogPage('protect');
$out->addHTML(Xml::element('h2', null, $protectLogPage->getName()->text()));
LogEventsList::showLogExtract($out, 'protect', $this->mTitle);
# Let extensions add other relevant log extracts
Hooks::run('ProtectionForm::showLogExtract', [$this->mArticle, $out]);
}
示例10: showHtmlPreview
/**
* Wraps the provided html code in a div and outputs it to the page
*
* @param Title $title
* @param ParserOutput $pout
* @param OutputPage $out
*/
private function showHtmlPreview(Title $title, ParserOutput $pout, OutputPage $out)
{
$lang = $title->getPageViewLanguage();
$out->addHTML("<h2>" . $this->msg('expand_templates_preview')->escaped() . "</h2>\n");
$out->addHTML(Html::openElement('div', array('class' => 'mw-content-' . $lang->getDir(), 'dir' => $lang->getDir(), 'lang' => $lang->getHtmlCode())));
$out->addParserOutputContent($pout);
$out->addHTML(Html::closeElement('div'));
}
示例11: showHtmlPreview
/**
* Render the supplied wiki text and append to the page as a preview
*
* @param Title $title
* @param string $text
* @param OutputPage $out
*/
private function showHtmlPreview($title, $text, $out)
{
global $wgParser;
$pout = $wgParser->parse($text, $title, new ParserOptions());
$out->addHTML("<h2>" . wfMsgHtml('expand_templates_preview') . "</h2>\n");
global $wgRawHtml, $wgRequest, $wgUser;
if ($wgRawHtml) {
// To prevent cross-site scripting attacks, don't show the preview if raw HTML is
// allowed and a valid edit token is not provided (bug 71111). However, MediaWiki
// does not currently provide logged-out users with CSRF protection; in that case,
// do not show the preview unless anonymous editing is allowed.
if ($wgUser->isAnon() && !$wgUser->isAllowed('edit')) {
$error = array('expand_templates_preview_fail_html_anon');
} elseif (!$wgUser->matchEditToken($wgRequest->getVal('wpEditToken'))) {
$error = array('expand_templates_preview_fail_html');
} else {
$error = false;
}
if ($error) {
$out->wrapWikiMsg("<div class='previewnote'>\n\$1\n</div>", $error);
return;
}
}
$out->addHTML($pout->getText());
}
示例12: editPageShowEditFormFields
/**
* EditPage::showEditForm:fields hook
*
* Adds the event fields to the edit form
*
* @param EditPage $editPage the current EditPage object.
* @param OutputPage $outputPage object.
* @return bool
*/
public static function editPageShowEditFormFields($editPage, $outputPage)
{
if ($editPage->contentModel !== CONTENT_MODEL_WIKITEXT) {
return true;
}
$req = $outputPage->getContext()->getRequest();
$editingStatsId = $req->getVal('editingStatsId');
if (!$editingStatsId || !$req->wasPosted()) {
$editingStatsId = self::getEditingStatsId();
}
$outputPage->addHTML(Xml::element('input', array('type' => 'hidden', 'name' => 'editingStatsId', 'id' => 'editingStatsId', 'value' => $editingStatsId)));
return true;
}
示例13: viewHook
/**
* Hook into Article::view() to provide syntax highlighting for
* custom CSS and JavaScript pages
*
* @param string $text
* @param Title $title
* @param OutputPage $output
* @return bool
*/
public static function viewHook($text, $title, $output)
{
// Determine the language
preg_match('!\\.(css|js)$!u', $title->getText(), $matches);
$lang = $matches[1] == 'css' ? 'css' : 'javascript';
// Attempt to format
$geshi = self::prepare($text, $lang);
if ($geshi instanceof GeSHi) {
$out = $geshi->parse_code();
if (!$geshi->error()) {
// Done
$output->addHeadItem("source-{$lang}", self::buildHeadItem($geshi));
$output->addHTML("<div dir=\"ltr\">{$out}</div>");
return false;
}
}
// Bottle out
return true;
}
示例14: showHtmlPreview
/**
* Wraps the provided html code in a div and outputs it to the page
*
* @param Title $title
* @param string $html
* @param OutputPage $out
*/
private function showHtmlPreview(Title $title, $html, OutputPage $out)
{
$lang = $title->getPageViewLanguage();
$out->addHTML("<h2>" . $this->msg('expand_templates_preview')->escaped() . "</h2>\n");
global $wgRawHtml;
if ($wgRawHtml) {
$request = $this->getRequest();
$user = $this->getUser();
// To prevent cross-site scripting attacks, don't show the preview if raw HTML is
// allowed and a valid edit token is not provided (bug 71111). However, MediaWiki
// does not currently provide logged-out users with CSRF protection; in that case,
// do not show the preview unless anonymous editing is allowed.
if ($user->isAnon() && !$user->isAllowed('edit')) {
$error = array('expand_templates_preview_fail_html_anon');
} elseif (!$user->matchEditToken($request->getVal('wpEditToken'), '', $request)) {
$error = array('expand_templates_preview_fail_html');
} else {
$error = false;
}
if ($error) {
$out->wrapWikiMsg("<div class='previewnote'>\n\$1\n</div>", $error);
return;
}
}
$out->addHTML(Html::openElement('div', array('class' => 'mw-content-' . $lang->getDir(), 'dir' => $lang->getDir(), 'lang' => $lang->getHtmlCode())));
$out->addHTML($html);
$out->addHTML(Html::closeElement('div'));
}
示例15: onEditPageShowEditFormFields
/**
* Called when the normal wikitext editor is shown.
* Inserts a 'veswitched' hidden field if requested by the client
*
* @param $editPage EditPage
* @param $output OutputPage
* @return boolean true
*/
public static function onEditPageShowEditFormFields(EditPage $editPage, OutputPage $output)
{
$request = $output->getRequest();
if ($request->getBool('veswitched')) {
$output->addHTML(Xml::input('veswitched', false, '1', array('type' => 'hidden')));
}
return true;
}