本文整理汇总了PHP中WebRequest::getBool方法的典型用法代码示例。如果您正苦于以下问题:PHP WebRequest::getBool方法的具体用法?PHP WebRequest::getBool怎么用?PHP WebRequest::getBool使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebRequest
的用法示例。
在下文中一共展示了WebRequest::getBool方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadDataFromRequest
/**
* @param WebRequest $request
*
* @return string
*/
function loadDataFromRequest($request)
{
$invert = isset($this->mParams['invert']) && $this->mParams['invert'];
// GetCheck won't work like we want for checks.
// Fetch the value in either one of the two following case:
// - we have a valid token (form got posted or GET forged by the user)
// - checkbox name has a value (false or true), ie is not null
if ($request->getCheck('wpEditToken') || $request->getVal($this->mName) !== null) {
return $invert ? !$request->getBool($this->mName) : $request->getBool($this->mName);
} else {
return $this->getDefault();
}
}
示例2: onAfterInitialize
public static function onAfterInitialize($title, $article, $output, $user, WebRequest $request, $wiki)
{
global $wgPaidAssetDropConfig;
if ($request->getBool(static::PAD_FORCE_PARAMETER, false)) {
$wgPaidAssetDropConfig = true;
}
return true;
}
示例3: shouldShowVForm
/**
* Whether to show new vertically laid out login form.
* ?useNew=1 forces new style, ?useNew=0 forces old style,
* otherwise consult $wgUseVFormUserLogin.
* @return Boolean
*/
private function shouldShowVForm()
{
global $wgUseVFormCreateAccount, $wgUseVFormUserLogin;
if ($this->mType == 'signup') {
return $this->mRequest->getBool('useNew', $wgUseVFormCreateAccount);
} else {
return $this->mRequest->getBool('useNew', $wgUseVFormUserLogin);
}
}
示例4: onAfterInitialize
/**
* Handle URL parameters and set proper global variables early enough
*
* @author Sergey Naumov
*/
public static function onAfterInitialize($title, $article, $output, $user, WebRequest $request, $wiki)
{
global $wgAdDriverUseSevenOneMedia, $wgNoExternals, $wgUsePostScribe;
// TODO: we shouldn't have it in AdEngine - ticket for Platform: PLATFORM-1296
$wgNoExternals = $request->getBool('noexternals', $wgNoExternals);
// use PostScribe with 71Media - check scriptwriter.js:35
if ($wgAdDriverUseSevenOneMedia) {
$wgUsePostScribe = true;
}
return true;
}
示例5: showSummarizeForm
/**
* @param $thread Thread
*/
function showSummarizeForm($thread)
{
$submitted_nonce = $this->request->getVal('lqt_nonce');
$nonce_key = wfMemcKey('lqt-nonce', $submitted_nonce, $this->user->getName());
if (!$this->handleNonce($submitted_nonce, $nonce_key)) {
return;
}
if ($thread->summary()) {
$article = $thread->summary();
} else {
$t = $this->newSummaryTitle($thread);
$article = new Article($t, 0);
}
$html = Xml::openElement('div', array('class' => 'lqt-edit-form lqt-summarize-form'));
$this->output->addHTML($html);
$this->output->addWikiMsg('lqt-summarize-intro');
$talkpage = $thread->article();
LqtHooks::$editTalkpage = $talkpage;
LqtHooks::$editArticle = $article;
LqtHooks::$editThread = $thread;
LqtHooks::$editType = 'summarize';
LqtHooks::$editAppliesTo = $thread;
$e = new EditPage($article);
// Add an offset so it works if it's on the wrong page.
$dbr = wfGetDB(DB_SLAVE);
$offset = wfTimestamp(TS_UNIX, $thread->topmostThread()->sortkey());
$offset++;
$offset = $dbr->timestamp($offset);
$e->suppressIntro = true;
$e->editFormTextBeforeContent .= $this->perpetuate('lqt_method', 'hidden') . $this->perpetuate('lqt_operand', 'hidden') . Html::hidden('lqt_nonce', MWCryptRand::generateHex(32)) . Html::hidden('offset', $offset);
$e->edit();
if ($e->didSave) {
$bump = !$this->request->getCheck('wpBumpThread') || $this->request->getBool('wpBumpThread');
LqtView::summarizeMetadataUpdates(array('thread' => $thread, 'article' => $article, 'summary' => $e->summary, 'bump' => $bump));
if ($submitted_nonce && $nonce_key) {
global $wgMemc;
$wgMemc->set($nonce_key, 1, 3600);
}
}
if ($this->output->getRedirect() != '') {
$redirectTitle = clone $talkpage->getTitle();
$redirectTitle->setFragment('#' . $this->anchorName($thread));
$this->output->redirect($this->title->getLocalURL());
}
$this->output->addHTML('</div>');
}
示例6: setupQuery
/**
* Basic setup and applies the limiting factors from the WebRequest object.
* @param WebRequest $request
* @private
*/
function setupQuery($request)
{
$page = $this->db->tableName('page');
$user = $this->db->tableName('user');
$this->joinClauses = array("LEFT OUTER JOIN {$page} ON log_namespace=page_namespace AND log_title=page_title", "INNER JOIN {$user} ON user_id=log_user");
$this->whereClauses = array();
$this->limitType($request->getVal('type'));
$this->limitUser($request->getText('user'));
$this->limitTitle($request->getText('page'), $request->getBool('pattern'));
$this->limitTime($request->getVal('from'), '>=');
$this->limitTime($request->getVal('until'), '<=');
list($this->limit, $this->offset) = $request->getLimitOffset();
// XXX This all needs to use Pager, ugly hack for now.
global $wgMiserMode;
if ($wgMiserMode) {
$this->offset = min($this->offset, 10000);
}
}
示例7: loadDataFromRequest
/**
* @param WebRequest $request
*
* @return string
*/
function loadDataFromRequest($request)
{
$invert = false;
if (isset($this->mParams['invert']) && $this->mParams['invert']) {
$invert = true;
}
// GetCheck won't work like we want for checks.
// Fetch the value in either one of the two following case:
// - we have a valid token (form got posted or GET forged by the user)
// - checkbox name has a value (false or true), ie is not null
if ($request->getCheck('wpEditToken') || $request->getVal($this->mName) !== null) {
// XOR has the following truth table, which is what we want
// INVERT VALUE | OUTPUT
// true true | false
// false true | true
// false false | false
// true false | true
return $request->getBool($this->mName) xor $invert;
} else {
return $this->getDefault();
}
}
示例8: safeUnicodeInput
/**
* Filter an input field through a Unicode de-armoring process if it
* came from an old browser with known broken Unicode editing issues.
*
* @param WebRequest $request
* @param string $field
* @return string
* @access private
*/
function safeUnicodeInput($request, $field)
{
$text = rtrim($request->getText($field));
return $request->getBool('safemode') ? $this->unmakesafe($text) : $text;
}
示例9: execute
/**
* Main entry point.
*
* @param array $session initial session array
*
* @return Array: new session array
*/
public function execute(array $session)
{
$this->session = $session;
if (isset($session['settings'])) {
$this->settings = $session['settings'] + $this->settings;
}
$this->exportVars();
$this->setupLanguage();
if (($this->getVar('_InstallDone') || $this->getVar('_UpgradeDone')) && $this->request->getVal('localsettings')) {
$this->request->response()->header('Content-type: application/x-httpd-php');
$this->request->response()->header('Content-Disposition: attachment; filename="LocalSettings.php"');
$ls = InstallerOverrides::getLocalSettingsGenerator($this);
$rightsProfile = $this->rightsProfiles[$this->getVar('_RightsProfile')];
foreach ($rightsProfile as $group => $rightsArr) {
$ls->setGroupRights($group, $rightsArr);
}
echo $ls->getText();
return $this->session;
}
$cssDir = $this->request->getVal('css');
if ($cssDir) {
$cssDir = $cssDir == 'rtl' ? 'rtl' : 'ltr';
$this->request->response()->header('Content-type: text/css');
echo $this->output->getCSS($cssDir);
return $this->session;
}
if (isset($session['happyPages'])) {
$this->happyPages = $session['happyPages'];
} else {
$this->happyPages = array();
}
if (isset($session['skippedPages'])) {
$this->skippedPages = $session['skippedPages'];
} else {
$this->skippedPages = array();
}
$lowestUnhappy = $this->getLowestUnhappy();
# Special case for Creative Commons partner chooser box.
if ($this->request->getVal('SubmitCC')) {
$page = $this->getPageByName('Options');
$this->output->useShortHeader();
$this->output->allowFrames();
$page->submitCC();
return $this->finish();
}
if ($this->request->getVal('ShowCC')) {
$page = $this->getPageByName('Options');
$this->output->useShortHeader();
$this->output->allowFrames();
$this->output->addHTML($page->getCCDoneBox());
return $this->finish();
}
# Get the page name.
$pageName = $this->request->getVal('page');
if (in_array($pageName, $this->otherPages)) {
# Out of sequence
$pageId = false;
$page = $this->getPageByName($pageName);
} else {
# Main sequence
if (!$pageName || !in_array($pageName, $this->pageSequence)) {
$pageId = $lowestUnhappy;
} else {
$pageId = array_search($pageName, $this->pageSequence);
}
# If necessary, move back to the lowest-numbered unhappy page
if ($pageId > $lowestUnhappy) {
$pageId = $lowestUnhappy;
if ($lowestUnhappy == 0) {
# Knocked back to start, possible loss of session data.
$this->showSessionWarning = true;
}
}
$pageName = $this->pageSequence[$pageId];
$page = $this->getPageByName($pageName);
}
# If a back button was submitted, go back without submitting the form data.
if ($this->request->wasPosted() && $this->request->getBool('submit-back')) {
if ($this->request->getVal('lastPage')) {
$nextPage = $this->request->getVal('lastPage');
} elseif ($pageId !== false) {
# Main sequence page
# Skip the skipped pages
$nextPageId = $pageId;
do {
$nextPageId--;
$nextPage = $this->pageSequence[$nextPageId];
} while (isset($this->skippedPages[$nextPage]));
} else {
$nextPage = $this->pageSequence[$lowestUnhappy];
}
$this->output->redirect($this->getUrl(array('page' => $nextPage)));
return $this->finish();
//.........这里部分代码省略.........
示例10: fetchValuesFromRequest
public function fetchValuesFromRequest(WebRequest $r, $values = false)
{
if (!$values) {
$values = array_keys($this->options);
}
foreach ($values as $name) {
$default = $this->options[$name]['default'];
$type = $this->options[$name]['type'];
switch ($type) {
case self::BOOL:
$value = $r->getBool($name, $default);
break;
case self::INT:
$value = $r->getInt($name, $default);
break;
case self::STRING:
$value = $r->getText($name, $default);
break;
case self::INTNULL:
$value = $r->getIntOrNull($name);
break;
default:
throw new MWException('Unsupported datatype');
}
if ($value !== null) {
$this->options[$name]['value'] = $value === $default ? null : $value;
}
}
}
示例11: onAfterInitialize
/**
* Handle URL parameters and set proper global variables early enough :)
*
* - Detect debug mode for assets (allinone=0) - sets $wgAllInOne and $wgResourceLoaderDebug
*
* @author macbre
*/
public static function onAfterInitialize($title, $article, $output, $user, WebRequest $request, $wiki)
{
global $wgResourceLoaderDebug, $wgAllInOne, $wgUseSiteJs, $wgUseSiteCss, $wgAllowUserJs, $wgAllowUserCss, $wgBuckySampling;
$wgAllInOne = $request->getBool('allinone', $wgAllInOne) !== false;
if ($wgAllInOne === false) {
$wgResourceLoaderDebug = true;
wfDebug("Wikia: using resource loader debug mode\n");
}
$wgUseSiteJs = $request->getBool('usesitejs', $wgUseSiteJs) !== false;
$wgUseSiteCss = $request->getBool('usesitecss', $wgUseSiteCss) !== false;
$wgAllowUserJs = $request->getBool('useuserjs', $request->getBool('allowuserjs', $wgAllowUserJs)) !== false;
$wgAllowUserCss = $request->getBool('useusercss', $request->getBool('allowusercss', $wgAllowUserCss)) !== false;
$wgBuckySampling = $request->getInt('buckysampling', $wgBuckySampling);
return true;
}
示例12: onAfterInitialize
/**
* Handle URL parameters and set proper global variables early enough :)
*
* - Detect debug mode for assets (allinone=0) - sets $wgAllInOne and $wgResourceLoaderDebug
*
* @author macbre
*/
public static function onAfterInitialize($title, $article, $output, $user, WebRequest $request, $wiki)
{
// allinone
global $wgResourceLoaderDebug, $wgAllInOne;
$wgAllInOne = $request->getBool('allinone', $wgAllInOne) !== false;
if ($wgAllInOne === false) {
$wgResourceLoaderDebug = true;
wfDebug("Wikia: using resource loader debug mode\n");
}
return true;
}