本文整理汇总了PHP中FormOptions::fetchValuesFromRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP FormOptions::fetchValuesFromRequest方法的具体用法?PHP FormOptions::fetchValuesFromRequest怎么用?PHP FormOptions::fetchValuesFromRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FormOptions
的用法示例。
在下文中一共展示了FormOptions::fetchValuesFromRequest方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setupOptions
public function setupOptions()
{
$this->opts = new FormOptions();
$this->opts->add('hidebots', false, FormOptions::BOOL);
$this->opts->add('hidesysops', false, FormOptions::BOOL);
$this->opts->fetchValuesFromRequest($this->getRequest());
if ($this->opts->getValue('hidebots') == 1) {
$this->hideRights[] = 'bot';
}
if ($this->opts->getValue('hidesysops') == 1) {
$this->hideGroups[] = 'sysop';
}
}
示例2: setupOptions
public function setupOptions()
{
$this->opts = new FormOptions();
$this->opts->add('hidebots', false, FormOptions::BOOL);
$this->opts->add('hidesysops', false, FormOptions::BOOL);
$this->opts->fetchValuesFromRequest($this->getRequest());
$this->groups = array();
if ($this->opts->getValue('hidebots') == 1) {
$this->groups['bot'] = true;
}
if ($this->opts->getValue('hidesysops') == 1) {
$this->groups['sysop'] = true;
}
}
示例3: setup
protected function setup($par)
{
global $wgRequest, $wgUser, $wgEnableNewpagesUserFilter;
// Options
$opts = new FormOptions();
$this->opts = $opts;
// bind
$opts->add('hideliu', false);
$opts->add('hidepatrolled', false);
$opts->add('hidebots', false);
$opts->add('hideredirs', true);
$opts->add('limit', (int) $wgUser->getOption('rclimit'));
$opts->add('offset', '');
$opts->add('namespace', '0');
$opts->add('username', '');
$opts->add('feed', '');
// Set values
$opts->fetchValuesFromRequest($wgRequest);
if ($par) {
$this->parseParams($par);
}
// Validate
$opts->validateIntBounds('limit', 0, 5000);
if (!$wgEnableNewpagesUserFilter) {
$opts->setValue('username', '');
}
// Store some objects
$this->skin = $wgUser->getSkin();
}
示例4: setup
protected function setup($par)
{
global $wgEnableNewpagesUserFilter;
// Options
$opts = new FormOptions();
$this->opts = $opts;
// bind
$opts->add('hideliu', false);
$opts->add('hidepatrolled', $this->getUser()->getBoolOption('newpageshidepatrolled'));
$opts->add('hidebots', false);
$opts->add('hideredirs', true);
$opts->add('limit', $this->getUser()->getIntOption('rclimit'));
$opts->add('offset', '');
$opts->add('namespace', '0');
$opts->add('username', '');
$opts->add('feed', '');
$opts->add('tagfilter', '');
$opts->add('invert', false);
$this->customFilters = array();
wfRunHooks('SpecialNewPagesFilters', array($this, &$this->customFilters));
foreach ($this->customFilters as $key => $params) {
$opts->add($key, $params['default']);
}
// Set values
$opts->fetchValuesFromRequest($this->getRequest());
if ($par) {
$this->parseParams($par);
}
// Validate
$opts->validateIntBounds('limit', 0, 5000);
if (!$wgEnableNewpagesUserFilter) {
$opts->setValue('username', '');
}
}
示例5: execute
function execute($par)
{
$out = $this->getOutput();
$this->setHeaders();
$this->outputHeader();
$opts = new FormOptions();
$opts->add('target', '');
$opts->add('namespace', '', FormOptions::INTNULL);
$opts->add('limit', 50);
$opts->add('from', 0);
$opts->add('back', 0);
$opts->add('hideredirs', false);
$opts->add('hidetrans', false);
$opts->add('hidelinks', false);
$opts->add('hideimages', false);
$opts->fetchValuesFromRequest($this->getRequest());
$opts->validateIntBounds('limit', 0, 5000);
// Give precedence to subpage syntax
if (isset($par)) {
$opts->setValue('target', $par);
}
// Bind to member variable
$this->opts = $opts;
$this->target = Title::newFromURL($opts->getValue('target'));
if (!$this->target) {
$out->addHTML($this->whatlinkshereForm());
return;
}
$this->getSkin()->setRelevantTitle($this->target);
$this->selfTitle = $this->getTitle($this->target->getPrefixedDBkey());
$out->setPageTitle(wfMsg('whatlinkshere-title', $this->target->getPrefixedText()));
$out->setSubtitle(wfMsg('whatlinkshere-backlink', Linker::link($this->target, $this->target->getPrefixedText(), array(), array('redirect' => 'no'))));
$this->showIndirectLinks(0, $this->target, $opts->getValue('limit'), $opts->getValue('from'), $opts->getValue('back'));
}
示例6: execute
public function execute($par)
{
global $wgLogRestrictions;
$this->setHeaders();
$this->outputHeader();
$opts = new FormOptions();
$opts->add('type', '');
$opts->add('user', '');
$opts->add('page', '');
$opts->add('pattern', false);
// $opts->add( 'year', null, FormOptions::INTNULL ); don't default to zero
$opts->add('year', '');
$opts->add('month', null, FormOptions::INTNULL);
$opts->add('tagfilter', '');
$opts->add('offset', '');
$opts->add('dir', '');
$opts->add('offender', '');
// Set values
$opts->fetchValuesFromRequest($this->getRequest());
if ($par !== null) {
$this->parseParams($opts, (string) $par);
}
# Don't let the user get stuck with a certain date
if ($opts->getValue('offset') || $opts->getValue('dir') == 'prev') {
$opts->setValue('year', '');
$opts->setValue('month', '');
}
// If the user doesn't have the right permission to view the specific
// log type, throw a PermissionsError
// If the log type is invalid, just show all public logs
$type = $opts->getValue('type');
if (!LogPage::isLogType($type)) {
$opts->setValue('type', '');
} elseif (isset($wgLogRestrictions[$type]) && !$this->getUser()->isAllowed($wgLogRestrictions[$type])) {
throw new PermissionsError($wgLogRestrictions[$type]);
}
# Handle type-specific inputs
$qc = array();
if ($opts->getValue('type') == 'suppress') {
$offender = User::newFromName($opts->getValue('offender'), false);
if ($offender && $offender->getId() > 0) {
$qc = array('ls_field' => 'target_author_id', 'ls_value' => $offender->getId());
} elseif ($offender && IP::isIPAddress($offender->getName())) {
$qc = array('ls_field' => 'target_author_ip', 'ls_value' => $offender->getName());
}
}
# Some log types are only for a 'User:' title but we might have been given
# only the username instead of the full title 'User:username'. This part try
# to lookup for a user by that name and eventually fix user input. See bug 1697.
wfRunHooks('GetLogTypesOnUser', array(&$this->typeOnUser));
if (in_array($opts->getValue('type'), $this->typeOnUser)) {
# ok we have a type of log which expect a user title.
$target = Title::newFromText($opts->getValue('page'));
if ($target && $target->getNamespace() === NS_MAIN) {
# User forgot to add 'User:', we are adding it for him
$opts->setValue('page', Title::makeTitleSafe(NS_USER, $opts->getValue('page')));
}
}
$this->show($opts, $qc);
}
示例7: execute
public function execute($par)
{
$this->setHeaders();
$this->outputHeader();
$out = $this->getOutput();
$this->addHelpLink('Help:New images');
$opts = new FormOptions();
$opts->add('like', '');
$opts->add('showbots', false);
$opts->add('hidepatrolled', false);
$opts->add('limit', 50);
$opts->add('offset', '');
$opts->fetchValuesFromRequest($this->getRequest());
if ($par !== null) {
$opts->setValue(is_numeric($par) ? 'limit' : 'like', $par);
}
$opts->validateIntBounds('limit', 0, 500);
$this->opts = $opts;
if (!$this->including()) {
$this->setTopText();
$this->buildForm();
}
$pager = new NewFilesPager($this->getContext(), $opts);
$out->addHTML($pager->getBody());
if (!$this->including()) {
$out->addHTML($pager->getNavigationBar());
}
}
示例8: execute
public function execute($par)
{
// Shortcut by using $par
if ($par) {
$this->getOutput()->redirect($this->getTitle()->getLinkURL(array('user' => $par)));
return;
}
$this->setHeaders();
$this->outputHeader();
// Parse options
$opt = new \FormOptions();
$opt->add('user', '');
$opt->add('delete', '');
$opt->add('reason', '');
$opt->fetchValuesFromRequest($this->getRequest());
// Parse user
$user = $opt->getValue('user');
$userObj = \User::newFromName($user);
$userExists = $userObj && $userObj->getId() !== 0;
// If current task is delete and user is not allowed
$canDoAdmin = $this->getUser()->isAllowed('avataradmin');
if ($opt->getValue('delete')) {
if (!$canDoAdmin) {
throw new \PermissionsError('avataradmin');
}
// Delete avatar if the user exists
if ($userExists) {
if (Avatars::deleteAvatar($userObj)) {
global $wgAvatarLogInRC;
$logEntry = new \ManualLogEntry('avatar', 'delete');
$logEntry->setPerformer($this->getUser());
$logEntry->setTarget($userObj->getUserPage());
$logEntry->setComment($opt->getValue('reason'));
$logId = $logEntry->insert();
$logEntry->publish($logId, $wgAvatarLogInRC ? 'rcandudp' : 'udp');
}
}
}
$this->getOutput()->addModules(array('mediawiki.userSuggest'));
$this->showForm($user);
if ($userExists) {
$haveAvatar = Avatars::hasAvatar($userObj);
if ($haveAvatar) {
$html = \Xml::tags('img', array('src' => Avatars::getLinkFor($user, 'original') . '&nocache&ver=' . dechex(time()), 'height' => 400), '');
$html = \Xml::tags('p', array(), $html);
$this->getOutput()->addHTML($html);
// Add a delete button
if ($canDoAdmin) {
$this->showDeleteForm($user);
}
} else {
$this->getOutput()->addWikiMsg('viewavatar-noavatar');
}
} else {
if ($user) {
$this->getOutput()->addWikiMsg('viewavatar-nouser');
}
}
}
示例9: execute
public function execute($par)
{
$this->useTransactionalTimeLimit();
$this->checkPermissions();
$this->checkReadOnly();
$this->setHeaders();
$this->outputHeader();
$this->addHelpLink('Help:Merge history');
$opts = new FormOptions();
$opts->add('target', '');
$opts->add('dest', '');
$opts->add('target', '');
$opts->add('mergepoint', '');
$opts->add('reason', '');
$opts->add('merge', false);
$opts->fetchValuesFromRequest($this->getRequest());
$target = $opts->getValue('target');
$dest = $opts->getValue('dest');
$targetObj = Title::newFromText($target);
$destObj = Title::newFromText($dest);
$status = Status::newGood();
$this->mOpts = $opts;
$this->mTargetObj = $targetObj;
$this->mDestObj = $destObj;
if ($opts->getValue('merge') && $targetObj && $destObj && $opts->getValue('mergepoint') !== '') {
$this->merge();
return;
}
if ($target === '' && $dest === '') {
$this->showMergeForm();
return;
}
if (!$targetObj instanceof Title) {
$status->merge(Status::newFatal('mergehistory-invalid-source'));
} elseif (!$targetObj->exists()) {
$status->merge(Status::newFatal('mergehistory-no-source', wfEscapeWikiText($targetObj->getPrefixedText())));
}
if (!$destObj instanceof Title) {
$status->merge(Status::newFatal('mergehistory-invalid-destination'));
} elseif (!$destObj->exists()) {
$status->merge(Status::newFatal('mergehistory-no-destination', wfEscapeWikiText($destObj->getPrefixedText())));
}
if ($targetObj && $destObj && $targetObj->equals($destObj)) {
$status->merge(Status::newFatal('mergehistory-same-destination'));
}
$this->mStatus = $status;
$this->showMergeForm();
if ($status->isOK()) {
$this->showHistory();
}
}
示例10: setup
protected function setup($par)
{
global $wgRequest, $wgUser;
// Options
$opts = new FormOptions();
$this->opts = $opts;
// bind
$opts->add('page1', '');
$opts->add('page2', '');
$opts->add('rev1', '');
$opts->add('rev2', '');
$opts->add('action', '');
// Set values
$opts->fetchValuesFromRequest($wgRequest);
$title1 = Title::newFromText($opts->getValue('page1'));
$title2 = Title::newFromText($opts->getValue('page2'));
if ($title1 && $title1->exists() && $opts->getValue('rev1') == '') {
$pda = new Article($title1);
$pdi = $pda->getID();
$pdLastRevision = Revision::loadFromPageId(wfGetDB(DB_SLAVE), $pdi);
$opts->setValue('rev1', $pdLastRevision->getId());
} elseif ($opts->getValue('rev1') != '') {
$pdrev = Revision::newFromId($opts->getValue('rev1'));
if ($pdrev) {
$opts->setValue('page1', $pdrev->getTitle()->getPrefixedText());
}
}
if ($title2 && $title2->exists() && $opts->getValue('rev2') == '') {
$pda = new Article($title2);
$pdi = $pda->getID();
$pdLastRevision = Revision::loadFromPageId(wfGetDB(DB_SLAVE), $pdi);
$opts->setValue('rev2', $pdLastRevision->getId());
} elseif ($opts->getValue('rev2') != '') {
$pdrev = Revision::newFromId($opts->getValue('rev2'));
if ($pdrev) {
$opts->setValue('page2', $pdrev->getTitle()->getPrefixedText());
}
}
// Store some objects
$this->skin = $wgUser->getSkin();
}
示例11: execute
/**
* Show the special page
*
* @param string $par Parameter passed to the page or null
*/
public function execute($par)
{
$out = $this->getOutput();
$this->setHeaders();
$this->outputHeader();
$opts = new FormOptions();
$opts->add('username', '');
$opts->add('hidebots', false, FormOptions::BOOL);
$opts->add('hidesysops', false, FormOptions::BOOL);
$opts->fetchValuesFromRequest($this->getRequest());
if ($par !== null) {
$opts->setValue('username', $par);
}
// Mention the level of cache staleness...
$cacheText = '';
$dbr = wfGetDB(DB_SLAVE, 'recentchanges');
$rcMax = $dbr->selectField('recentchanges', 'MAX(rc_timestamp)', '', __METHOD__);
if ($rcMax) {
$cTime = $dbr->selectField('querycache_info', 'qci_timestamp', ['qci_type' => 'activeusers'], __METHOD__);
if ($cTime) {
$secondsOld = wfTimestamp(TS_UNIX, $rcMax) - wfTimestamp(TS_UNIX, $cTime);
} else {
$rcMin = $dbr->selectField('recentchanges', 'MIN(rc_timestamp)');
$secondsOld = time() - wfTimestamp(TS_UNIX, $rcMin);
}
if ($secondsOld > 0) {
$cacheTxt = '<br>' . $this->msg('cachedspecial-viewing-cached-ttl')->durationParams($secondsOld);
}
}
$pager = new ActiveUsersPager($this->getContext(), $opts);
$usersBody = $pager->getBody();
$days = $this->getConfig()->get('ActiveUserDays');
$formDescriptor = ['username' => ['type' => 'user', 'name' => 'username', 'label-message' => 'activeusers-from'], 'hidebots' => ['type' => 'check', 'name' => 'hidebots', 'label-message' => 'activeusers-hidebots', 'default' => false], 'hidesysops' => ['type' => 'check', 'name' => 'hidesysops', 'label-message' => 'activeusers-hidesysops', 'default' => false]];
$htmlForm = HTMLForm::factory('ooui', $formDescriptor, $this->getContext())->setIntro($this->msg('activeusers-intro')->numParams($days) . $cacheText)->setWrapperLegendMsg('activeusers')->setSubmitTextMsg('activeusers-submit')->setMethod('get')->prepareForm()->displayForm(false);
if ($usersBody) {
$out->addHTML($pager->getNavigationBar() . Html::rawElement('ul', [], $usersBody) . $pager->getNavigationBar());
} else {
$out->addWikiMsg('activeusers-noresult');
}
}
示例12: execute
function execute($par)
{
$out = $this->getOutput();
$this->setHeaders();
$this->outputHeader();
$this->addHelpLink('Help:What links here');
$opts = new FormOptions();
$opts->add('target', '');
$opts->add('namespace', '', FormOptions::INTNULL);
$opts->add('limit', $this->getConfig()->get('QueryPageDefaultLimit'));
$opts->add('from', 0);
$opts->add('back', 0);
$opts->add('hideredirs', false);
$opts->add('hidetrans', false);
$opts->add('hidelinks', false);
$opts->add('hideimages', false);
$opts->add('invert', false);
$opts->fetchValuesFromRequest($this->getRequest());
$opts->validateIntBounds('limit', 0, 5000);
// Give precedence to subpage syntax
if ($par !== null) {
$opts->setValue('target', $par);
}
// Bind to member variable
$this->opts = $opts;
$this->target = Title::newFromText($opts->getValue('target'));
if (!$this->target) {
if (!$this->including()) {
$out->addHTML($this->whatlinkshereForm());
}
return;
}
$this->getSkin()->setRelevantTitle($this->target);
$this->selfTitle = $this->getPageTitle($this->target->getPrefixedDBkey());
$out->setPageTitle($this->msg('whatlinkshere-title', $this->target->getPrefixedText()));
$out->addBacklinkSubtitle($this->target);
$this->showIndirectLinks(0, $this->target, $opts->getValue('limit'), $opts->getValue('from'), $opts->getValue('back'));
}
示例13: execute
public function execute($par)
{
global $wgRequest;
$this->setHeaders();
$this->outputHeader();
$opts = new FormOptions();
$opts->add('type', '');
$opts->add('user', '');
$opts->add('page', '');
$opts->add('pattern', false);
$opts->add('year', null, FormOptions::INTNULL);
$opts->add('month', null, FormOptions::INTNULL);
$opts->add('tagfilter', '');
$opts->add('offset', '');
$opts->add('dir', '');
$opts->add('offender', '');
// Set values
$opts->fetchValuesFromRequest($wgRequest);
if ($par) {
$this->parseParams($opts, (string) $par);
}
# Don't let the user get stuck with a certain date
if ($opts->getValue('offset') || $opts->getValue('dir') == 'prev') {
$opts->setValue('year', '');
$opts->setValue('month', '');
}
# Handle type-specific inputs
$qc = array();
if ($opts->getValue('type') == 'suppress') {
$offender = User::newFromName($opts->getValue('offender'), false);
if ($offender && $offender->getId() > 0) {
$qc = array('ls_field' => 'target_author_id', 'ls_value' => $offender->getId());
} elseif ($offender && IP::isIPAddress($offender->getName())) {
$qc = array('ls_field' => 'target_author_ip', 'ls_value' => $offender->getName());
}
}
$this->show($opts, $qc);
}
示例14: setup
public function setup()
{
global $wgRequest;
$opts = new FormOptions();
// Bind to the member variable
$this->opts = $opts;
$opts->add('mode', self::MODE_STATS);
$opts->add('image', APCImages::IMG_NONE);
$opts->add('clearcache', false);
$opts->add('limit', 20);
$opts->add('offset', 0);
$opts->add('display', '');
$opts->add('delete', '');
$opts->add('sort', 'hits');
$opts->add('sortdir', 0);
$opts->add('scope', 'active');
$opts->add('searchi', '');
// MediaWiki captures search, ARGH!
$opts->fetchValuesFromRequest($wgRequest);
$opts->validateIntBounds('limit', 0, 5000);
$opts->validateIntBounds('sortdir', 0, 1);
$this->opts->consumeValues(array('display', 'clearcache', 'image'));
}
示例15: execute
public function execute($par)
{
global $wgLanguageCode;
$this->setHeaders();
$this->checkPermissions();
$server = TTMServer::primary();
if (!$server instanceof SearchableTTMServer) {
throw new ErrorPageError('tux-sst-nosolr-title', 'tux-sst-nosolr-body');
}
$out = $this->getOutput();
$out->addModuleStyles('jquery.uls.grid');
$out->addModuleStyles('ext.translate.special.searchtranslations.styles');
$out->addModuleStyles('ext.translate.special.translate.styles');
$out->addModules('ext.translate.special.searchtranslations');
$out->addModules('ext.translate.special.searchtranslations.operatorsuggest');
TranslateUtils::addSpecialHelpLink($out, 'Help:Extension:Translate#searching');
$this->opts = $opts = new FormOptions();
$opts->add('query', '');
$opts->add('sourcelanguage', $wgLanguageCode);
$opts->add('language', '');
$opts->add('group', '');
$opts->add('grouppath', '');
$opts->add('filter', '');
$opts->add('match', '');
$opts->add('case', '');
$opts->add('limit', $this->limit);
$opts->add('offset', 0);
$opts->fetchValuesFromRequest($this->getRequest());
$queryString = $opts->getValue('query');
if ($queryString === '') {
$this->showEmptySearch();
return;
}
$params = $opts->getAllValues();
$filter = $opts->getValue('filter');
try {
$translationSearch = new CrossLanguageTranslationSearchQuery($params, $server);
if (in_array($filter, $translationSearch->getAvailableFilters())) {
if ($opts->getValue('language') === '') {
$params['language'] = $this->getLanguage()->getCode();
$opts->setValue('language', $params['language']);
}
$documents = $translationSearch->getDocuments();
$total = $translationSearch->getTotalHits();
$resultset = $translationSearch->getResultSet();
} else {
$resultset = $server->search($queryString, $params, $this->hl);
$documents = $server->getDocuments($resultset);
$total = $server->getTotalHits($resultset);
}
} catch (TTMServerException $e) {
error_log('Translation search server unavailable:' . $e->getMessage());
throw new ErrorPageError('tux-sst-solr-offline-title', 'tux-sst-solr-offline-body');
}
// Part 1: facets
$facets = $server->getFacets($resultset);
$facetHtml = '';
if (count($facets['language']) > 0) {
if ($filter !== '') {
$facets['language'] = array_merge($facets['language'], array($opts->getValue('language') => $total));
}
$facetHtml = Html::element('div', array('class' => 'row facet languages', 'data-facets' => FormatJson::encode($this->getLanguages($facets['language'])), 'data-language' => $opts->getValue('language')), $this->msg('tux-sst-facet-language'));
}
if (count($facets['group']) > 0) {
$facetHtml .= Html::element('div', array('class' => 'row facet groups', 'data-facets' => FormatJson::encode($this->getGroups($facets['group'])), 'data-group' => $opts->getValue('group')), $this->msg('tux-sst-facet-group'));
}
// Part 2: results
$resultsHtml = '';
$title = Title::newFromText($queryString);
if ($title && !in_array($filter, $translationSearch->getAvailableFilters())) {
$handle = new MessageHandle($title);
$code = $handle->getCode();
$language = $opts->getValue('language');
if ($handle->isValid() && $code !== '' && $code !== $language) {
$groupId = $handle->getGroup()->getId();
$helpers = new TranslationHelpers($title, $groupId);
$document['wiki'] = wfWikiId();
$document['localid'] = $handle->getTitleForBase()->getPrefixedText();
$document['content'] = $helpers->getTranslation();
$document['language'] = $handle->getCode();
array_unshift($documents, $document);
$total++;
}
}
foreach ($documents as $document) {
$text = $document['content'];
$text = TranslateUtils::convertWhiteSpaceToHTML($text);
list($pre, $post) = $this->hl;
$text = str_replace($pre, '<strong class="tux-search-highlight">', $text);
$text = str_replace($post, '</strong>', $text);
$title = Title::newFromText($document['localid'] . '/' . $document['language']);
if (!$title) {
// Should not ever happen but who knows...
continue;
}
$resultAttribs = array('class' => 'row tux-message', 'data-title' => $title->getPrefixedText(), 'data-language' => $document['language']);
$handle = new MessageHandle($title);
if ($handle->isValid()) {
$groupId = $handle->getGroup()->getId();
$helpers = new TranslationHelpers($title, $groupId);
//.........这里部分代码省略.........