本文整理汇总了PHP中Xml::dateMenu方法的典型用法代码示例。如果您正苦于以下问题:PHP Xml::dateMenu方法的具体用法?PHP Xml::dateMenu怎么用?PHP Xml::dateMenu使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Xml
的用法示例。
在下文中一共展示了Xml::dateMenu方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showOptions
/**
* Show options for the log list
* @param $type String
* @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($type = '', $user = '', $page = '', $pattern = '', $year = '', $month = '', $filter = null, $tagFilter = '')
{
global $wgScript, $wgMiserMode;
$action = htmlspecialchars($wgScript);
$title = SpecialPage::getTitleFor('Log');
$special = htmlspecialchars($title->getPrefixedDBkey());
$tagSelector = ChangeTags::buildTagFilterSelector($tagFilter);
$this->out->addHTML("<form action=\"{$action}\" method=\"get\"><fieldset>" . Xml::element('legend', array(), wfMsg('log')) . Xml::hidden('title', $special) . "\n" . $this->getTypeMenu($type) . "\n" . $this->getUserInput($user) . "\n" . $this->getTitleInput($page) . "\n" . (!$wgMiserMode ? $this->getTitlePattern($pattern) . "\n" : "") . "<p>" . Xml::dateMenu($year, $month) . "\n" . ($tagSelector ? Xml::tags('p', null, implode(' ', $tagSelector)) : '') . "\n" . ($filter ? "</p><p>" . $this->getFilterLinks($type, $filter) . "\n" : "") . "\n" . Xml::submitButton(wfMsg('allpagessubmit')) . "</p>\n" . "</fieldset></form>");
}
示例2: testDateMenu
public function testDateMenu()
{
$curYear = intval(gmdate('Y'));
$prevYear = $curYear - 1;
$curMonth = intval(gmdate('n'));
$prevMonth = $curMonth - 1;
if ($prevMonth == 0) {
$prevMonth = 12;
}
$nextMonth = $curMonth + 1;
if ($nextMonth == 13) {
$nextMonth = 1;
}
$this->assertEquals('<label for="year">From year (and earlier):</label> <input id="year" maxlength="4" size="7" type="number" value="2011" name="year" /> <label for="month">From month (and earlier):</label> <select id="month" name="month" class="mw-month-selector"><option value="-1">all</option>' . "\n" . '<option value="1">January</option>' . "\n" . '<option value="2" selected="">February</option>' . "\n" . '<option value="3">March</option>' . "\n" . '<option value="4">April</option>' . "\n" . '<option value="5">May</option>' . "\n" . '<option value="6">June</option>' . "\n" . '<option value="7">July</option>' . "\n" . '<option value="8">August</option>' . "\n" . '<option value="9">September</option>' . "\n" . '<option value="10">October</option>' . "\n" . '<option value="11">November</option>' . "\n" . '<option value="12">December</option></select>', Xml::dateMenu(2011, 02), "Date menu for february 2011");
$this->assertEquals('<label for="year">From year (and earlier):</label> <input id="year" maxlength="4" size="7" type="number" value="2011" name="year" /> <label for="month">From month (and earlier):</label> <select id="month" name="month" class="mw-month-selector"><option value="-1">all</option>' . "\n" . '<option value="1">January</option>' . "\n" . '<option value="2">February</option>' . "\n" . '<option value="3">March</option>' . "\n" . '<option value="4">April</option>' . "\n" . '<option value="5">May</option>' . "\n" . '<option value="6">June</option>' . "\n" . '<option value="7">July</option>' . "\n" . '<option value="8">August</option>' . "\n" . '<option value="9">September</option>' . "\n" . '<option value="10">October</option>' . "\n" . '<option value="11">November</option>' . "\n" . '<option value="12">December</option></select>', Xml::dateMenu(2011, -1), "Date menu with negative month for 'All'");
$this->assertEquals(Xml::dateMenu($curYear, $curMonth), Xml::dateMenu('', $curMonth), "Date menu year is the current one when not specified");
$wantedYear = $nextMonth == 1 ? $curYear : $prevYear;
$this->assertEquals(Xml::dateMenu($wantedYear, $nextMonth), Xml::dateMenu('', $nextMonth), "Date menu next month is 11 months ago");
$this->assertEquals('<label for="year">From year (and earlier):</label> <input id="year" maxlength="4" size="7" type="number" name="year" /> <label for="month">From month (and earlier):</label> <select id="month" name="month" class="mw-month-selector"><option value="-1">all</option>' . "\n" . '<option value="1">January</option>' . "\n" . '<option value="2">February</option>' . "\n" . '<option value="3">March</option>' . "\n" . '<option value="4">April</option>' . "\n" . '<option value="5">May</option>' . "\n" . '<option value="6">June</option>' . "\n" . '<option value="7">July</option>' . "\n" . '<option value="8">August</option>' . "\n" . '<option value="9">September</option>' . "\n" . '<option value="10">October</option>' . "\n" . '<option value="11">November</option>' . "\n" . '<option value="12">December</option></select>', Xml::dateMenu('', ''), "Date menu with neither year or month");
}
示例3: doPagerStuff
function doPagerStuff()
{
$request = $this->getRequest();
$out = $this->getOutput();
$localpage = $this->getPageTitle()->getLocalUrl();
$searchConds = false;
$type = $request->getVal('rwqSearchtype');
$target = $request->getVal('target');
$year = $request->getIntOrNull('year');
$month = $request->getIntOrNull('month');
$search = $request->getVal('rwqSearch');
if ($type === 'founder') {
$user = User::newFromName($search);
if (!$user || !$user->getID()) {
$out->addWikiMsg('requestwikiqueue-usernotfound');
} else {
$searchConds = array('cw_user' => $user->getID());
}
} elseif ($type === 'sitename') {
$searchConds = array('cw_sitename' => $search);
} elseif ($type === 'status') {
$searchConds = array('cw_status' => $search);
}
$selecttypeform = "<select name=\"rwqSearchtype\"><option value=\"founder\">founder</option><option value=\"sitename\">sitename</option><option value=\"status\">status</option></select>";
$form = Xml::openElement('form', array('action' => $localpage, 'method' => 'get'));
$form .= '<fieldset><legend>' . $this->msg('requestwikiqueue-searchrequest')->escaped() . '</legend>';
$form .= Xml::openElement('table');
# TODO: Should be escaped against HTML, but should NOT escape $selecttypeform
$form .= '<tr><td>Find wiki requests where the ' . $selecttypeform . ' is ';
$form .= Xml::input('rwqSearch', 40, '') . '</td></tr>';
$form .= '<tr><td>' . Xml::dateMenu($year, $month) . '</td>';
$form .= '<td>' . Xml::submitButton($this->msg('requestwikiqueue-searchbutton')->escaped()) . '</td></tr>';
$form .= Xml::closeElement('table');
$form .= '</fieldset>';
$form .= Xml::closeElement('form');
$out->addHTML($form);
$pager = new RequestWikiQueuePager($this, $searchConds, $year, $month);
$out->addHTML($pager->getNavigationBar() . $pager->getBody() . $pager->getNavigationBar());
}
示例4: testDateMenu
public function testDateMenu()
{
$curYear = intval(gmdate('Y'));
$prevYear = $curYear - 1;
$curMonth = intval(gmdate('n'));
$prevMonth = $curMonth - 1;
if ($prevMonth == 0) {
$prevMonth = 12;
}
$nextMonth = $curMonth + 1;
if ($nextMonth == 13) {
$nextMonth = 1;
}
$this->assertEquals('<label for="year">From year (and earlier):</label> <input name="year" size="4" value="2011" id="year" maxlength="4" /> <label for="month">From month (and earlier):</label> <select id="month" name="month" class="mw-month-selector"><option value="-1">all</option>' . "\n" . '<option value="1">January</option>' . "\n" . '<option value="2" selected="selected">February</option>' . "\n" . '<option value="3">March</option>' . "\n" . '<option value="4">April</option>' . "\n" . '<option value="5">May</option>' . "\n" . '<option value="6">June</option>' . "\n" . '<option value="7">July</option>' . "\n" . '<option value="8">August</option>' . "\n" . '<option value="9">September</option>' . "\n" . '<option value="10">October</option>' . "\n" . '<option value="11">November</option>' . "\n" . '<option value="12">December</option></select>', Xml::dateMenu(2011, 02), "Date menu for february 2011");
$this->assertEquals('<label for="year">From year (and earlier):</label> <input name="year" size="4" value="2011" id="year" maxlength="4" /> <label for="month">From month (and earlier):</label> <select id="month" name="month" class="mw-month-selector"><option value="-1">all</option>' . "\n" . '<option value="1">January</option>' . "\n" . '<option value="2">February</option>' . "\n" . '<option value="3">March</option>' . "\n" . '<option value="4">April</option>' . "\n" . '<option value="5">May</option>' . "\n" . '<option value="6">June</option>' . "\n" . '<option value="7">July</option>' . "\n" . '<option value="8">August</option>' . "\n" . '<option value="9">September</option>' . "\n" . '<option value="10">October</option>' . "\n" . '<option value="11">November</option>' . "\n" . '<option value="12">December</option></select>', Xml::dateMenu(2011, -1), "Date menu with negative month for 'All'");
$this->assertEquals(Xml::dateMenu($curYear, $curMonth), Xml::dateMenu('', $curMonth), "Date menu year is the current one when not specified");
$this->markTestIncomplete("Broken");
// @todo FIXME: next month can be in the next year
// test failing because it is now december
$this->assertEquals(Xml::dateMenu($prevYear, $nextMonth), Xml::dateMenu('', $nextMonth), "Date menu next month is 11 months ago");
# @todo FIXME: Please note there is no year there!
$this->assertEquals('<label for="year">From year (and earlier):</label> <input name="year" size="4" value="" id="year" maxlength="4" /> <label for="month">From month (and earlier):</label> <select id="month" name="month" class="mw-month-selector"><option value="-1">all</option>' . "\n" . '<option value="1">January</option>' . "\n" . '<option value="2">February</option>' . "\n" . '<option value="3">March</option>' . "\n" . '<option value="4">April</option>' . "\n" . '<option value="5">May</option>' . "\n" . '<option value="6">June</option>' . "\n" . '<option value="7">July</option>' . "\n" . '<option value="8">August</option>' . "\n" . '<option value="9">September</option>' . "\n" . '<option value="10">October</option>' . "\n" . '<option value="11">November</option>' . "\n" . '<option value="12">December</option></select>', Xml::dateMenu('', ''), "Date menu with neither year or month");
}
示例5: onView
/**
* Print the history page for an article.
*/
function onView()
{
$out = $this->getOutput();
$request = $this->getRequest();
/**
* Allow client caching.
*/
if ($out->checkLastModified($this->page->getTouched())) {
return;
// Client cache fresh and headers sent, nothing more to do.
}
wfProfileIn(__METHOD__);
$this->preCacheMessages();
$config = $this->context->getConfig();
# Fill in the file cache if not set already
$useFileCache = $config->get('UseFileCache');
if ($useFileCache && HTMLFileCache::useFileCache($this->getContext())) {
$cache = HTMLFileCache::newFromTitle($this->getTitle(), 'history');
if (!$cache->isCacheGood()) {
ob_start(array(&$cache, 'saveToFileCache'));
}
}
// Setup page variables.
$out->setFeedAppendQuery('action=history');
$out->addModules('mediawiki.action.history');
if ($config->get('UseMediaWikiUIEverywhere')) {
$out = $this->getOutput();
$out->addModuleStyles(array('mediawiki.ui.input', 'mediawiki.ui.checkbox'));
}
// Handle atom/RSS feeds.
$feedType = $request->getVal('feed');
if ($feedType) {
$this->feed($feedType);
wfProfileOut(__METHOD__);
return;
}
// Fail nicely if article doesn't exist.
if (!$this->page->exists()) {
$out->addWikiMsg('nohistory');
# show deletion/move log if there is an entry
LogEventsList::showLogExtract($out, array('delete', 'move'), $this->getTitle(), '', array('lim' => 10, 'conds' => array("log_action != 'revision'"), 'showIfEmpty' => false, 'msgKey' => array('moveddeleted-notice')));
wfProfileOut(__METHOD__);
return;
}
/**
* Add date selector to quickly get to a certain time
*/
$year = $request->getInt('year');
$month = $request->getInt('month');
$tagFilter = $request->getVal('tagfilter');
$tagSelector = ChangeTags::buildTagFilterSelector($tagFilter);
/**
* Option to show only revisions that have been (partially) hidden via RevisionDelete
*/
if ($request->getBool('deleted')) {
$conds = array('rev_deleted != 0');
} else {
$conds = array();
}
if ($this->getUser()->isAllowed('deletedhistory')) {
$checkDeleted = Xml::checkLabel($this->msg('history-show-deleted')->text(), 'deleted', 'mw-show-deleted-only', $request->getBool('deleted')) . "\n";
} else {
$checkDeleted = '';
}
// Add the general form
$action = htmlspecialchars(wfScript());
$out->addHTML("<form action=\"{$action}\" method=\"get\" id=\"mw-history-searchform\">" . Xml::fieldset($this->msg('history-fieldset-title')->text(), false, array('id' => 'mw-history-search')) . Html::hidden('title', $this->getTitle()->getPrefixedDBkey()) . "\n" . Html::hidden('action', 'history') . "\n" . Xml::dateMenu($year == null ? MWTimestamp::getLocalInstance()->format('Y') : $year, $month) . ' ' . ($tagSelector ? implode(' ', $tagSelector) . ' ' : '') . $checkDeleted . Xml::submitButton($this->msg('allpagessubmit')->text()) . "\n" . '</fieldset></form>');
wfRunHooks('PageHistoryBeforeList', array(&$this->page, $this->getContext()));
// Create and output the list.
$pager = new HistoryPager($this, $year, $month, $tagFilter, $conds);
$out->addHTML($pager->getNavigationBar() . $pager->getBody() . $pager->getNavigationBar());
$out->preventClickjacking($pager->getPreventClickjacking());
wfProfileOut(__METHOD__);
}
示例6: getForm
/**
* Generates the namespace selector form with hidden attributes.
* @return String: HTML fragment
*/
protected function getForm()
{
global $wgScript;
$this->opts['title'] = $this->getTitle()->getPrefixedText();
if (!isset($this->opts['target'])) {
$this->opts['target'] = '';
} else {
$this->opts['target'] = str_replace('_', ' ', $this->opts['target']);
}
if (!isset($this->opts['namespace'])) {
$this->opts['namespace'] = '';
}
if (!isset($this->opts['nsInvert'])) {
$this->opts['nsInvert'] = '';
}
if (!isset($this->opts['associated'])) {
$this->opts['associated'] = false;
}
if (!isset($this->opts['contribs'])) {
$this->opts['contribs'] = 'user';
}
if (!isset($this->opts['year'])) {
$this->opts['year'] = '';
}
if (!isset($this->opts['month'])) {
$this->opts['month'] = '';
}
if ($this->opts['contribs'] == 'newbie') {
$this->opts['target'] = '';
}
if (!isset($this->opts['tagfilter'])) {
$this->opts['tagfilter'] = '';
}
if (!isset($this->opts['topOnly'])) {
$this->opts['topOnly'] = false;
}
$form = Xml::openElement('form', array('method' => 'get', 'action' => $wgScript, 'class' => 'mw-contributions-form'));
# Add hidden params for tracking except for parameters in $skipParameters
$skipParameters = array('namespace', 'nsInvert', 'deletedOnly', 'target', 'contribs', 'year', 'month', 'topOnly', 'associated');
foreach ($this->opts as $name => $value) {
if (in_array($name, $skipParameters)) {
continue;
}
$form .= "\t" . Html::hidden($name, $value) . "\n";
}
$tagFilter = ChangeTags::buildTagFilterSelector($this->opts['tagfilter']);
if ($tagFilter) {
$filterSelection = Xml::tags('td', array('class' => 'mw-label'), array_shift($tagFilter)) . Xml::tags('td', array('class' => 'mw-input'), implode(' ', $tagFilter));
} else {
$filterSelection = Xml::tags('td', array('colspan' => 2), '');
}
$targetSelection = Xml::tags('td', array('colspan' => 2), Xml::radioLabel($this->msg('sp-contributions-newbies')->text(), 'contribs', 'newbie', 'newbie', $this->opts['contribs'] == 'newbie', array('class' => 'mw-input')) . '<br />' . Xml::radioLabel($this->msg('sp-contributions-username')->text(), 'contribs', 'user', 'user', $this->opts['contribs'] == 'user', array('class' => 'mw-input')) . ' ' . Html::input('target', $this->opts['target'], 'text', array('size' => '40', 'required' => '', 'class' => 'mw-input') + ($this->opts['target'] ? array() : array('autofocus'))) . ' ');
$namespaceSelection = Xml::tags('td', array('class' => 'mw-label'), Xml::label($this->msg('namespace')->text(), 'namespace', '')) . Xml::tags('td', null, Html::namespaceSelector(array('selected' => $this->opts['namespace'], 'all' => ''), array('name' => 'namespace', 'id' => 'namespace', 'class' => 'namespaceselector')) . ' ' . Html::rawElement('span', array('style' => 'white-space: nowrap'), Xml::checkLabel($this->msg('invert')->text(), 'nsInvert', 'nsInvert', $this->opts['nsInvert'], array('title' => $this->msg('tooltip-invert')->text(), 'class' => 'mw-input')) . ' ') . Html::rawElement('span', array('style' => 'white-space: nowrap'), Xml::checkLabel($this->msg('namespace_association')->text(), 'associated', 'associated', $this->opts['associated'], array('title' => $this->msg('tooltip-namespace_association')->text(), 'class' => 'mw-input')) . ' '));
$extraOptions = Xml::tags('td', array('colspan' => 2), Html::rawElement('span', array('style' => 'white-space: nowrap'), Xml::checkLabel($this->msg('history-show-deleted')->text(), 'deletedOnly', 'mw-show-deleted-only', $this->opts['deletedOnly'], array('class' => 'mw-input'))) . Html::rawElement('span', array('style' => 'white-space: nowrap'), Xml::checkLabel($this->msg('sp-contributions-toponly')->text(), 'topOnly', 'mw-show-top-only', $this->opts['topOnly'], array('class' => 'mw-input'))));
$dateSelectionAndSubmit = Xml::tags('td', array('colspan' => 2), Xml::dateMenu($this->opts['year'], $this->opts['month']) . ' ' . Xml::submitButton($this->msg('sp-contributions-submit')->text(), array('class' => 'mw-submit')));
$form .= Xml::fieldset($this->msg('sp-contributions-search')->text()) . Xml::openElement('table', array('class' => 'mw-contributions-table')) . Xml::openElement('tr') . $targetSelection . Xml::closeElement('tr') . Xml::openElement('tr') . $namespaceSelection . Xml::closeElement('tr') . Xml::openElement('tr') . $filterSelection . Xml::closeElement('tr') . Xml::openElement('tr') . $extraOptions . Xml::closeElement('tr') . Xml::openElement('tr') . $dateSelectionAndSubmit . Xml::closeElement('tr') . Xml::closeElement('table');
$explain = $this->msg('sp-contributions-explain');
if ($explain->exists()) {
$form .= "<p id='mw-sp-contributions-explain'>{$explain}</p>";
}
$form .= Xml::closeElement('fieldset') . Xml::closeElement('form');
return $form;
}
示例7: showOptions
/**
* Show options for the log list
*
* @param array|string $types
* @param string $user
* @param string $page
* @param string $pattern
* @param int $year Year
* @param int $month Month
* @param array $filter
* @param string $tagFilter Tag to select by default
*/
public function showOptions($types = array(), $user = '', $page = '', $pattern = '', $year = 0, $month = 0, $filter = null, $tagFilter = '')
{
global $wgScript, $wgMiserMode;
$title = SpecialPage::getTitleFor('Log');
// 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', $title->getPrefixedDBkey());
// 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((int) $year, (int) $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($this->msg('logeventslist-submit')->text());
// Fieldset
$html = Xml::fieldset($this->msg('log')->text(), $html);
// Form wrapping
$html = Xml::tags('form', array('action' => $wgScript, 'method' => 'get'), $html);
$this->getOutput()->addHTML($html);
}
示例8: getForm
/**
* Generates the namespace selector form with hidden attributes.
* @return string HTML fragment
*/
protected function getForm()
{
$this->opts['title'] = $this->getPageTitle()->getPrefixedText();
if (!isset($this->opts['target'])) {
$this->opts['target'] = '';
} else {
$this->opts['target'] = str_replace('_', ' ', $this->opts['target']);
}
if (!isset($this->opts['namespace'])) {
$this->opts['namespace'] = '';
}
if (!isset($this->opts['nsInvert'])) {
$this->opts['nsInvert'] = '';
}
if (!isset($this->opts['associated'])) {
$this->opts['associated'] = false;
}
if (!isset($this->opts['contribs'])) {
$this->opts['contribs'] = 'user';
}
if (!isset($this->opts['year'])) {
$this->opts['year'] = '';
}
if (!isset($this->opts['month'])) {
$this->opts['month'] = '';
}
if ($this->opts['contribs'] == 'newbie') {
$this->opts['target'] = '';
}
if (!isset($this->opts['tagfilter'])) {
$this->opts['tagfilter'] = '';
}
if (!isset($this->opts['topOnly'])) {
$this->opts['topOnly'] = false;
}
if (!isset($this->opts['newOnly'])) {
$this->opts['newOnly'] = false;
}
if (!isset($this->opts['hideMinor'])) {
$this->opts['hideMinor'] = false;
}
$form = Html::openElement('form', ['method' => 'get', 'action' => wfScript(), 'class' => 'mw-contributions-form']);
# Add hidden params for tracking except for parameters in $skipParameters
$skipParameters = ['namespace', 'nsInvert', 'deletedOnly', 'target', 'contribs', 'year', 'month', 'topOnly', 'newOnly', 'hideMinor', 'associated', 'tagfilter'];
foreach ($this->opts as $name => $value) {
if (in_array($name, $skipParameters)) {
continue;
}
$form .= "\t" . Html::hidden($name, $value) . "\n";
}
$tagFilter = ChangeTags::buildTagFilterSelector($this->opts['tagfilter']);
if ($tagFilter) {
$filterSelection = Html::rawElement('div', [], implode(' ', $tagFilter));
} else {
$filterSelection = Html::rawElement('div', [], '');
}
$this->getOutput()->addModules('mediawiki.userSuggest');
$labelNewbies = Xml::radioLabel($this->msg('sp-contributions-newbies')->text(), 'contribs', 'newbie', 'newbie', $this->opts['contribs'] == 'newbie', ['class' => 'mw-input']);
$labelUsername = Xml::radioLabel($this->msg('sp-contributions-username')->text(), 'contribs', 'user', 'user', $this->opts['contribs'] == 'user', ['class' => 'mw-input']);
$input = Html::input('target', $this->opts['target'], 'text', ['size' => '40', 'required' => '', 'class' => ['mw-input', 'mw-ui-input-inline', 'mw-autocomplete-user']] + ($this->opts['contribs'] === 'newbie' || $this->opts['target'] ? [] : ['autofocus' => true]));
$targetSelection = Html::rawElement('div', [], $labelNewbies . '<br>' . $labelUsername . ' ' . $input . ' ');
$namespaceSelection = Xml::tags('div', [], Xml::label($this->msg('namespace')->text(), 'namespace', '') . ' ' . Html::namespaceSelector(['selected' => $this->opts['namespace'], 'all' => ''], ['name' => 'namespace', 'id' => 'namespace', 'class' => 'namespaceselector']) . ' ' . Html::rawElement('span', ['class' => 'mw-input-with-label'], Xml::checkLabel($this->msg('invert')->text(), 'nsInvert', 'nsInvert', $this->opts['nsInvert'], ['title' => $this->msg('tooltip-invert')->text(), 'class' => 'mw-input']) . ' ') . Html::rawElement('span', ['class' => 'mw-input-with-label'], Xml::checkLabel($this->msg('namespace_association')->text(), 'associated', 'associated', $this->opts['associated'], ['title' => $this->msg('tooltip-namespace_association')->text(), 'class' => 'mw-input']) . ' '));
$filters = [];
if ($this->getUser()->isAllowed('deletedhistory')) {
$filters[] = Html::rawElement('span', ['class' => 'mw-input-with-label'], Xml::checkLabel($this->msg('history-show-deleted')->text(), 'deletedOnly', 'mw-show-deleted-only', $this->opts['deletedOnly'], ['class' => 'mw-input']));
}
$filters[] = Html::rawElement('span', ['class' => 'mw-input-with-label'], Xml::checkLabel($this->msg('sp-contributions-toponly')->text(), 'topOnly', 'mw-show-top-only', $this->opts['topOnly'], ['class' => 'mw-input']));
$filters[] = Html::rawElement('span', ['class' => 'mw-input-with-label'], Xml::checkLabel($this->msg('sp-contributions-newonly')->text(), 'newOnly', 'mw-show-new-only', $this->opts['newOnly'], ['class' => 'mw-input']));
$filters[] = Html::rawElement('span', ['class' => 'mw-input-with-label'], Xml::checkLabel($this->msg('sp-contributions-hideminor')->text(), 'hideMinor', 'mw-hide-minor-edits', $this->opts['hideMinor'], ['class' => 'mw-input']));
Hooks::run('SpecialContributions::getForm::filters', [$this, &$filters]);
$extraOptions = Html::rawElement('div', [], implode('', $filters));
$dateSelectionAndSubmit = Xml::tags('div', [], Xml::dateMenu($this->opts['year'] === '' ? MWTimestamp::getInstance()->format('Y') : $this->opts['year'], $this->opts['month']) . ' ' . Html::submitButton($this->msg('sp-contributions-submit')->text(), ['class' => 'mw-submit'], ['mw-ui-progressive']));
$form .= Xml::fieldset($this->msg('sp-contributions-search')->text(), $targetSelection . $namespaceSelection . $filterSelection . $extraOptions . $dateSelectionAndSubmit, ['class' => 'mw-contributions-table']);
$explain = $this->msg('sp-contributions-explain');
if (!$explain->isBlank()) {
$form .= "<p id='mw-sp-contributions-explain'>{$explain->parse()}</p>";
}
$form .= Xml::closeElement('form');
return $form;
}
示例9: getForm
/**
* Generates the namespace selector form with hidden attributes.
* @param $this->opts Array: the options to be included.
*/
protected function getForm()
{
global $wgScript;
$this->opts['title'] = $this->getTitle()->getPrefixedText();
if (!isset($this->opts['target'])) {
$this->opts['target'] = '';
} else {
$this->opts['target'] = str_replace('_', ' ', $this->opts['target']);
}
if (!isset($this->opts['namespace'])) {
$this->opts['namespace'] = '';
}
if (!isset($this->opts['contribs'])) {
$this->opts['contribs'] = 'user';
}
if (!isset($this->opts['year'])) {
$this->opts['year'] = '';
}
if (!isset($this->opts['month'])) {
$this->opts['month'] = '';
}
if ($this->opts['contribs'] == 'newbie') {
$this->opts['target'] = '';
}
if (!isset($this->opts['tagfilter'])) {
$this->opts['tagfilter'] = '';
}
$f = Xml::openElement('form', array('method' => 'get', 'action' => $wgScript));
# Add hidden params for tracking
foreach ($this->opts as $name => $value) {
if (in_array($name, array('namespace', 'target', 'contribs', 'year', 'month'))) {
continue;
}
$f .= "\t" . Xml::hidden($name, $value) . "\n";
}
$tagFilter = ChangeTags::buildTagFilterSelector($this->opts['tagfilter']);
$f .= '<fieldset>' . Xml::element('legend', array(), wfMsg('sp-contributions-search')) . Xml::radioLabel(wfMsgExt('sp-contributions-newbies', array('parsemag')), 'contribs', 'newbie', 'newbie', $this->opts['contribs'] == 'newbie' ? true : false) . '<br />' . Xml::radioLabel(wfMsgExt('sp-contributions-username', array('parsemag')), 'contribs', 'user', 'user', $this->opts['contribs'] == 'user' ? true : false) . ' ' . Html::input('target', $this->opts['target'], 'text', array('size' => '20', 'required' => '') + ($this->opts['target'] ? array() : array('autofocus'))) . ' ' . '<span style="white-space: nowrap">' . Xml::label(wfMsg('namespace'), 'namespace') . ' ' . Xml::namespaceSelector($this->opts['namespace'], '') . '</span>' . ($tagFilter ? Xml::tags('p', null, implode(' ', $tagFilter)) : '') . Xml::openElement('p') . '<span style="white-space: nowrap">' . Xml::dateMenu($this->opts['year'], $this->opts['month']) . '</span>' . ' ' . Xml::submitButton(wfMsg('sp-contributions-submit')) . Xml::closeElement('p');
$explain = wfMsgExt('sp-contributions-explain', 'parseinline');
if (!wfEmptyMsg('sp-contributions-explain', $explain)) {
$f .= "<p id='mw-sp-contributions-explain'>{$explain}</p>";
}
$f .= '</fieldset>' . Xml::closeElement('form');
return $f;
}
示例10: history
/**
* Print the history page for an article.
* @return nothing
*/
function history()
{
global $wgOut, $wgRequest, $wgScript;
/**
* Allow client caching.
*/
if ($wgOut->checkLastModified($this->article->getTouched())) {
return;
}
// Client cache fresh and headers sent, nothing more to do.
wfProfileIn(__METHOD__);
// Setup page variables.
$wgOut->setPageTitle(wfMsg('history-title', $this->title->getPrefixedText()));
$wgOut->setPageTitleActionText(wfMsg('history_short'));
$wgOut->setArticleFlag(false);
$wgOut->setArticleRelated(true);
$wgOut->setRobotPolicy('noindex,nofollow');
$wgOut->setSyndicated(true);
$wgOut->setFeedAppendQuery('action=history');
$wgOut->addModules(array('mediawiki.legacy.history', 'mediawiki.action.history'));
// Creation of a subtitle link pointing to [[Special:Log]]
$logPage = SpecialPage::getTitleFor('Log');
$logLink = $this->skin->link($logPage, wfMsgHtml('viewpagelogs'), array(), array('page' => $this->title->getPrefixedText()), array('known', 'noclasses'));
$wgOut->setSubtitle($logLink);
// Handle atom/RSS feeds.
$feedType = $wgRequest->getVal('feed');
if ($feedType) {
wfProfileOut(__METHOD__);
return $this->feed($feedType);
}
// Fail nicely if article doesn't exist.
if (!$this->title->exists()) {
$wgOut->addWikiMsg('nohistory');
# show deletion/move log if there is an entry
LogEventsList::showLogExtract($wgOut, array('delete', 'move'), $this->title->getPrefixedText(), '', array('lim' => 10, 'conds' => array("log_action != 'revision'"), 'showIfEmpty' => false, 'msgKey' => array('moveddeleted-notice')));
wfProfileOut(__METHOD__);
return;
}
/**
* Add date selector to quickly get to a certain time
*/
$year = $wgRequest->getInt('year');
$month = $wgRequest->getInt('month');
$tagFilter = $wgRequest->getVal('tagfilter');
$tagSelector = ChangeTags::buildTagFilterSelector($tagFilter);
/**
* Option to show only revisions that have been (partially) hidden via RevisionDelete
*/
if ($wgRequest->getBool('deleted')) {
$conds = array("rev_deleted != '0'");
} else {
$conds = array();
}
$checkDeleted = Xml::checkLabel(wfMsg('history-show-deleted'), 'deleted', 'mw-show-deleted-only', $wgRequest->getBool('deleted')) . "\n";
// Add the general form
$action = htmlspecialchars($wgScript);
$wgOut->addHTML("<form action=\"{$action}\" method=\"get\" id=\"mw-history-searchform\">" . Xml::fieldset(wfMsg('history-fieldset-title'), false, array('id' => 'mw-history-search')) . Html::hidden('title', $this->title->getPrefixedDBKey()) . "\n" . Html::hidden('action', 'history') . "\n" . Xml::dateMenu($year, $month) . ' ' . ($tagSelector ? implode(' ', $tagSelector) . ' ' : '') . $checkDeleted . Xml::submitButton(wfMsg('allpagessubmit')) . "\n" . '</fieldset></form>');
wfRunHooks('PageHistoryBeforeList', array(&$this->article));
// Create and output the list.
$pager = new HistoryPager($this, $year, $month, $tagFilter, $conds);
$wgOut->addHTML($pager->getNavigationBar() . $pager->getBody() . $pager->getNavigationBar());
$wgOut->preventClickjacking($pager->getPreventClickjacking());
wfProfileOut(__METHOD__);
}
示例11: getForm
/**
* Generates the namespace selector form with hidden attributes.
* @return String: HTML fragment
*/
protected function getForm()
{
global $wgScript;
$this->opts['title'] = $this->getTitle()->getPrefixedText();
if (!isset($this->opts['target'])) {
$this->opts['target'] = '';
} else {
$this->opts['target'] = str_replace('_', ' ', $this->opts['target']);
}
if (!isset($this->opts['namespace'])) {
$this->opts['namespace'] = '';
}
if (!isset($this->opts['contribs'])) {
$this->opts['contribs'] = 'user';
}
if (!isset($this->opts['year'])) {
$this->opts['year'] = '';
}
if (!isset($this->opts['month'])) {
$this->opts['month'] = '';
}
if ($this->opts['contribs'] == 'newbie') {
$this->opts['target'] = '';
}
if (!isset($this->opts['tagFilter'])) {
$this->opts['tagFilter'] = '';
}
if (!isset($this->opts['topOnly'])) {
$this->opts['topOnly'] = false;
}
$f = Xml::openElement('form', array('method' => 'get', 'action' => $wgScript, 'class' => 'mw-contributions-form'));
# Add hidden params for tracking except for parameters in $skipParameters
$skipParameters = array('namespace', 'deletedOnly', 'target', 'contribs', 'year', 'month', 'topOnly');
foreach ($this->opts as $name => $value) {
if (in_array($name, $skipParameters)) {
continue;
}
$f .= "\t" . Html::hidden($name, $value) . "\n";
}
$tagFilter = ChangeTags::buildTagFilterSelector($this->opts['tagFilter']);
$f .= Xml::fieldset(wfMsg('sp-contributions-search')) . Xml::radioLabel(wfMsgExt('sp-contributions-newbies', array('parsemag')), 'contribs', 'newbie', 'newbie', $this->opts['contribs'] == 'newbie') . '<br />' . Xml::radioLabel(wfMsgExt('sp-contributions-username', array('parsemag')), 'contribs', 'user', 'user', $this->opts['contribs'] == 'user') . ' ' . Html::input('target', $this->opts['target'], 'text', array('size' => '20', 'required' => '') + ($this->opts['target'] ? array() : array('autofocus'))) . ' ' . Html::rawElement('span', array('style' => 'white-space: nowrap'), Xml::label(wfMsg('namespace'), 'namespace') . ' ' . Xml::namespaceSelector($this->opts['namespace'], '')) . Xml::checkLabel(wfMsg('history-show-deleted'), 'deletedOnly', 'mw-show-deleted-only', $this->opts['deletedOnly']) . '<br />' . Xml::tags('p', null, Xml::checkLabel(wfMsg('sp-contributions-toponly'), 'topOnly', 'mw-show-top-only', $this->opts['topOnly'])) . ($tagFilter ? Xml::tags('p', null, implode(' ', $tagFilter)) : '') . Html::rawElement('p', array('style' => 'white-space: nowrap'), Xml::dateMenu($this->opts['year'], $this->opts['month']) . ' ' . Xml::submitButton(wfMsg('sp-contributions-submit'))) . ' ';
$explain = wfMessage('sp-contributions-explain');
if ($explain->exists()) {
$f .= "<p id='mw-sp-contributions-explain'>{$explain}</p>";
}
$f .= Xml::closeElement('fieldset') . Xml::closeElement('form');
return $f;
}
示例12: execute
function execute($par)
{
$this->checkPermissions();
$out = $this->getOutput();
$request = $this->getRequest();
$this->setHeaders();
$type = $request->getVal('cuSearchType');
$target = $request->getVal('cuSearch');
$year = $request->getIntOrNull('year');
$month = $request->getIntOrNull('month');
$error = false;
$dbr = wfGetDB(DB_SLAVE);
$searchConds = false;
if ($type === null) {
$type = 'target';
} elseif ($type == 'initiator') {
$user = User::newFromName($target);
if (!$user || !$user->getID()) {
$error = 'checkuser-user-nonexistent';
} else {
$searchConds = array('cul_user' => $user->getID());
}
} else {
$type = 'target';
// Is it an IP?
list($start, $end) = IP::parseRange($target);
if ($start !== false) {
if ($start == $end) {
$searchConds = array('cul_target_hex = ' . $dbr->addQuotes($start) . ' OR ' . '(cul_range_end >= ' . $dbr->addQuotes($start) . ' AND ' . 'cul_range_start <= ' . $dbr->addQuotes($end) . ')');
} else {
$searchConds = array('(cul_target_hex >= ' . $dbr->addQuotes($start) . ' AND ' . 'cul_target_hex <= ' . $dbr->addQuotes($end) . ') OR ' . '(cul_range_end >= ' . $dbr->addQuotes($start) . ' AND ' . 'cul_range_start <= ' . $dbr->addQuotes($end) . ')');
}
} else {
// Is it a user?
$user = User::newFromName($target);
if ($user && $user->getID()) {
$searchConds = array('cul_type' => array('userips', 'useredits'), 'cul_target_id' => $user->getID());
} elseif ($target) {
$error = 'checkuser-user-nonexistent';
}
}
}
$out->addHTML(Linker::linkKnown($this->getCheckUserFormTitle(), $this->msg('checkuser-log-return')));
$searchTypes = array('initiator', 'target');
$select = "<select name=\"cuSearchType\" style='margin-top:.2em;'>\n";
foreach ($searchTypes as $searchType) {
if ($type == $searchType) {
$checked = 'selected="selected"';
} else {
$checked = '';
}
$caption = wfMsgHtml('checkuser-search-' . $searchType);
$select .= "<option value=\"{$searchType}\" {$checked}>{$caption}</option>\n";
}
$select .= '</select>';
$encTarget = htmlspecialchars($target);
$msgSearch = wfMsgHtml('checkuser-search');
$input = "<input type=\"text\" name=\"cuSearch\" value=\"{$encTarget}\" size=\"40\"/>";
$msgSearchForm = wfMsgHtml('checkuser-search-form', $select, $input);
$formAction = $this->getTitle()->escapeLocalURL();
$msgSearchSubmit = '  ' . wfMsgHtml('checkuser-search-submit') . '  ';
$s = "<form method='get' action=\"{$formAction}\">\n" . "<fieldset><legend>{$msgSearch}</legend>\n" . "<p>{$msgSearchForm}</p>\n" . "<p>" . Xml::dateMenu($year, $month) . "   \n" . "<input type=\"submit\" name=\"cuSearchSubmit\" value=\"{$msgSearchSubmit}\"/></p>\n" . "</fieldset></form>\n";
$out->addHTML($s);
if ($error !== false) {
$out->wrapWikiMsg('<div class="errorbox">$1</div>', $error);
return;
}
$pager = new CheckUserLogPager($this, $searchConds, $year, $month);
$out->addHTML($pager->getNavigationBar() . $pager->getBody() . $pager->getNavigationBar());
}
示例13: displayRevisions
/**
* Display a list with the passed revisions.
*
* @since 0.1
*
* @param EPPageObject $object
*/
protected function displayRevisions(EPPageObject $object)
{
$conditions = array('type' => get_class($object));
if ($object->hasIdField()) {
$conditions['object_id'] = $object->getId();
}
$action = htmlspecialchars($GLOBALS['wgScript']);
$request = $this->getRequest();
$out = $this->getOutput();
/**
* Add date selector to quickly get to a certain time
*/
$year = $request->getInt('year');
$month = $request->getInt('month');
$tagFilter = $request->getVal('tagfilter');
$tagSelector = ChangeTags::buildTagFilterSelector($tagFilter);
/**
* Option to show only revisions that have been (partially) hidden via RevisionDelete
*/
if ($request->getBool('deleted')) {
$conditions['deleted'] = true;
}
$checkDeleted = Xml::checkLabel($this->msg('history-show-deleted')->text(), 'deleted', 'mw-show-deleted-only', $request->getBool('deleted')) . "\n";
$out->addHTML("<form action=\"{$action}\" method=\"get\" id=\"mw-history-searchform\">" . Xml::fieldset($this->msg('history-fieldset-title')->text(), false, array('id' => 'mw-history-search')) . Html::hidden('title', $this->getTitle()->getPrefixedDBKey()) . "\n" . Html::hidden('action', 'history') . "\n" . Xml::dateMenu($year, $month) . ' ' . ($tagSelector ? implode(' ', $tagSelector) . ' ' : '') . $checkDeleted . Xml::submitButton($this->msg('allpagessubmit')->text()) . "\n" . '</fieldset></form>');
$pager = new EPRevisionPager($this->getContext(), $conditions);
if ($pager->getNumRows()) {
$out->addHTML($pager->getNavigationBar() . $pager->getBody() . $pager->getNavigationBar());
} else {
// TODO
}
}
示例14: getForm
//.........这里部分代码省略.........
if (!isset($this->opts['month'])) {
$this->opts['month'] = '';
}
if ($this->opts['contribs'] == 'newbie') {
$this->opts['target'] = '';
}
if (!isset($this->opts['tagfilter'])) {
$this->opts['tagfilter'] = '';
}
if (!isset($this->opts['topOnly'])) {
$this->opts['topOnly'] = false;
}
// JRS 12/5/13 Redesign styling
$form = Html::openElement('div', array('class' => 'section_text'));
$form .= Html::openElement('form', array('method' => 'get', 'action' => $wgScript, 'class' => 'mw-contributions-form'));
# Add hidden params for tracking except for parameters in $skipParameters
$skipParameters = array('namespace', 'nsInvert', 'deletedOnly', 'target', 'contribs', 'year', 'month', 'topOnly', 'associated');
foreach ($this->opts as $name => $value) {
if (in_array($name, $skipParameters)) {
continue;
}
$form .= "\t" . Html::hidden($name, $value) . "\n";
}
$tagFilter = ChangeTags::buildTagFilterSelector($this->opts['tagfilter']);
if ($tagFilter) {
$filterSelection = Html::rawElement('td', array('class' => 'mw-label'), array_shift($tagFilter));
$filterSelection .= Html::rawElement('td', array('class' => 'mw-input'), implode(' ', $tagFilter));
} else {
$filterSelection = Html::rawElement('td', array('colspan' => 2), '');
}
$labelNewbies = Xml::radioLabel($this->msg('sp-contributions-newbies')->text(), 'contribs', 'newbie', 'newbie', $this->opts['contribs'] == 'newbie', array('class' => 'mw-input'));
$labelUsername = Xml::radioLabel($this->msg('sp-contributions-username')->text(), 'contribs', 'user', 'user', $this->opts['contribs'] == 'user', array('class' => 'mw-input'));
$input = Html::input('target', $this->opts['target'], 'text', array('size' => '40', 'required' => '', 'class' => 'input_med') + ($this->opts['target'] ? array() : array('autofocus')));
$targetSelection = Html::rawElement('td', array('colspan' => 2), $labelNewbies . '<br />' . $labelUsername . ' ' . $input . ' ');
// $namespaceSelection = Xml::tags(
// 'td',
// array( 'class' => 'mw-label' ),
// Xml::label(
// $this->msg( 'namespace' )->text(),
// 'namespace',
// ''
// )
// );
// $namespaceSelection .= Html::rawElement(
// 'td',
// null,
// Html::namespaceSelector(
// array( 'selected' => $this->opts['namespace'], 'all' => '' ),
// array(
// 'name' => 'namespace',
// 'id' => 'namespace',
// 'class' => 'namespaceselector',
// )
// ) . ' ' .
// Html::rawElement(
// 'span',
// array( 'style' => 'white-space: nowrap' ),
// Xml::checkLabel(
// $this->msg( 'invert' )->text(),
// 'nsInvert',
// 'nsInvert',
// $this->opts['nsInvert'],
// array(
// 'title' => $this->msg( 'tooltip-invert' )->text(),
// 'class' => 'mw-input'
// )
// ) . ' '
// ) .
// Html::rawElement( 'span', array( 'style' => 'white-space: nowrap' ),
// Xml::checkLabel(
// $this->msg( 'namespace_association' )->text(),
// 'associated',
// 'associated',
// $this->opts['associated'],
// array(
// 'title' => $this->msg( 'tooltip-namespace_association' )->text(),
// 'class' => 'mw-input'
// )
// ) . ' '
// )
// );
$namespaceSelection = Xml::tags('td', null, Xml::label($this->msg('namespace')->text(), 'namespace', '') . ' ' . Html::namespaceSelector(array('selected' => $this->opts['namespace'], 'all' => ''), array('name' => 'namespace', 'id' => 'namespace', 'class' => 'namespaceselector')));
$namespaceSelectionOptions = Xml::tags('td', null, Html::rawElement('span', array('style' => 'white-space: nowrap'), Xml::checkLabel($this->msg('invert')->text(), 'nsInvert', 'nsInvert', $this->opts['nsInvert'], array('title' => $this->msg('tooltip-invert')->text(), 'class' => 'mw-input')) . ' ') . Html::rawElement('span', array('style' => 'white-space: nowrap'), Xml::checkLabel($this->msg('namespace_association')->text(), 'associated', 'associated', $this->opts['associated'], array('title' => $this->msg('tooltip-namespace_association')->text(), 'class' => 'mw-input')) . ' '));
if ($this->getUser()->isAllowed('deletedhistory')) {
$deletedOnlyCheck = Html::rawElement('span', array('style' => 'white-space: nowrap'), Xml::checkLabel($this->msg('history-show-deleted')->text(), 'deletedOnly', 'mw-show-deleted-only', $this->opts['deletedOnly'], array('class' => 'mw-input')));
} else {
$deletedOnlyCheck = '';
}
$checkLabelTopOnly = Html::rawElement('span', array('style' => 'white-space: nowrap'), Xml::checkLabel($this->msg('sp-contributions-toponly')->text(), 'topOnly', 'mw-show-top-only', $this->opts['topOnly'], array('class' => 'mw-input')));
$extraOptions = Html::rawElement('td', array('colspan' => 2), $deletedOnlyCheck . $checkLabelTopOnly);
$dateSelectionAndSubmit = Xml::tags('td', array('colspan' => 2), Xml::dateMenu($this->opts['year'] === '' ? MWTimestamp::getInstance()->format('Y') : $this->opts['year'], $this->opts['month']) . ' ' . Xml::submitButton($this->msg('sp-contributions-submit')->text(), array('class' => 'mw-submit button primary', 'style' => 'float:right;margin:5px;')));
$form .= Xml::fieldset($this->msg('sp-contributions-search')->text());
$form .= Html::rawElement('table', array('class' => 'mw-contributions-table'), "\n" . Html::rawElement('tr', array(), $targetSelection) . "\n" . Html::rawElement('tr', array(), $namespaceSelection) . "\n" . Html::rawElement('tr', array(), $namespaceSelectionOptions) . "\n" . Html::rawElement('tr', array(), $filterSelection) . "\n" . Html::rawElement('tr', array(), $extraOptions) . "\n" . Html::rawElement('tr', array(), $dateSelectionAndSubmit) . "\n");
$explain = $this->msg('sp-contributions-explain');
if (!$explain->isBlank()) {
$form .= "<p id='mw-sp-contributions-explain'>{$explain->parse()}</p>";
}
$form .= Xml::closeElement('fieldset') . Xml::closeElement('form');
return $form;
}