本文整理汇总了PHP中WebRequest::setVal方法的典型用法代码示例。如果您正苦于以下问题:PHP WebRequest::setVal方法的具体用法?PHP WebRequest::setVal怎么用?PHP WebRequest::setVal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebRequest
的用法示例。
在下文中一共展示了WebRequest::setVal方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getList
/**
* Finds search suggestions phrases for chosen query
*
* @requestParam string $query search term for suggestions
*
* @responseParam array $items The list of phrases matching the query
*
* @example &query=los
*/
public function getList()
{
wfProfileIn(__METHOD__);
if (!empty($this->wg->EnableLinkSuggestExt)) {
$query = trim($this->request->getVal(self::PARAMETER_QUERY, null));
if (empty($query)) {
throw new MissingParameterApiException(self::PARAMETER_QUERY);
}
$request = new WebRequest();
$request->setVal('format', 'array');
$linkSuggestions = LinkSuggest::getLinkSuggest($request);
if (!empty($linkSuggestions)) {
foreach ($linkSuggestions as $suggestion) {
$searchSuggestions[]['title'] = $suggestion;
}
$this->response->setVal('items', $searchSuggestions);
} else {
throw new NotFoundApiException();
}
$this->response->setCacheValidity(WikiaResponse::CACHE_STANDARD);
} else {
throw new NotFoundApiException('Link Suggest extension not available');
}
wfProfileOut(__METHOD__);
}
示例2:
function __construct(WebRequest $request)
{
// put the username and password field in the expected place for validation MAIN-1283
$request->setVal('userloginext01', $request->getVal('username'));
$request->setVal('userloginext02', $request->getVal('password'));
$request->setVal('email', $this->getUserEmail($request));
$request->setVal('type', 'signup');
parent::__construct($request);
}
示例3: explode
function __construct(WebRequest $request)
{
$this->fbUserId = $request->getVal('fbuserid');
$this->fbFeedOptions = explode(',', $request->getVal('fbfeedoptions', ''));
// get an email from Facebook API
$resp = F::app()->sendRequest('FacebookSignup', 'getFacebookData', array('fbUserId' => $this->fbUserId));
// add an email to the request and pass it to the underlying class
$request->setVal('email', $resp->getVal('email', false));
if ($request->getVal('type', '') == '') {
$request->setVal('type', 'signup');
}
parent::__construct($request);
}
示例4: __construct
public function __construct(WebRequest $request)
{
parent::__construct($request);
$groups = explode(',', $this->mOid);
foreach ($groups as $groupName) {
// fake request to a group
$groupRequest = new WebRequest();
$groupRequest->setVal('type', 'group');
$groupRequest->setVal('oid', $groupName);
$builder = new AssetsManagerGroupBuilder($groupRequest);
$this->mContent .= "\n\n" . $builder->getContent();
$this->mContentType = $builder->getContentType();
}
}
示例5: __construct
public function __construct(WebRequest $request)
{
parent::__construct($request);
$files = explode(',', $this->mOid);
foreach ($files as $file) {
// fake single SASS file request
$sassRequest = new WebRequest();
$sassRequest->setVal('type', 'sass');
$sassRequest->setVal('oid', $file);
$builder = new AssetsManagerSassBuilder($sassRequest);
$this->mContent .= "\n\n/* {$file} */\n" . $builder->getContent();
}
$this->mContentType = AssetsManager::TYPE_CSS;
}
示例6: loadRequest
/**
* Initialize instance variables from request and create an Upload handler
*
* @param WebRequest $request The request to extract variables from
*/
protected function loadRequest($request)
{
global $wgUser, $wgMaxUploadFiles;
// let's make the parent happy
wfSuppressWarnings();
$_FILES['wpUploadFile'] = $_FILES['wpUploadFile0'];
wfRestoreWarnings();
// Guess the desired name from the filename if not provided
$this->mDesiredDestNames = array();
$this->mUploads = array();
// deal with session keys, if we have some pick the first one, for now
$vals = $request->getValues();
$fromsession = false;
foreach ($vals as $k => $v) {
if (preg_match("@^wpSessionKey@", $k)) {
$request->setVal('wpSessionKey', $v);
$fromsession = true;
$filenum = preg_replace("@wpSessionKey@", '', $k);
$request->setVal('wpDestFile', $request->getVal('wpDestFile' . $filenum));
$up = UploadBase::createFromRequest($request);
$this->mUploads[] = $up;
$this->mDesiredDestNames[] = $request->getVal('wpDestFile' . $filenum);
}
}
parent::loadRequest($request);
$this->mUploadClicked = $request->wasPosted() && ($request->getCheck('wpUpload') || $request->getCheck('wpUploadIgnoreWarning'));
if (!$fromsession) {
for ($i = 0; $i < $wgMaxUploadFiles; $i++) {
$this->mDesiredDestNames[$i] = $request->getText('wpDestFile' . $i);
if (!$this->mDesiredDestNames[$i] && $request->getFileName('wpUploadFile' . $i) !== null) {
$this->mDesiredDestNames[$i] = $request->getFileName('wpUploadFile' . $i);
}
wfSuppressWarnings();
$request->setVal('wpUploadFile', $_FILES['wpUploadFile' . $i]);
wfRestoreWarnings();
$request->setVal('wpDestFile', $request->getVal('wpDestFile' . $i));
move_uploaded_file('wpUploadFile' . $i, 'wpUploadFile');
wfSuppressWarnings();
$_FILES['wpUploadFile'] = $_FILES['wpUploadFile' . $i];
wfRestoreWarnings();
$up = UploadBase::createFromRequest($request);
if ($up) {
$this->mUploads[] = $up;
}
}
}
$this->mDesiredDestName = $this->mDesiredDestNames[0];
$this->mUpload = $this->mUploads[0];
}
示例7: testResourceLoaderModifyMaxAge
/**
* @group Slow
* @slowExecutionTime 0.01651 ms
* @dataProvider resourceLoaderModifyMaxAgeDataProvider
*
* @param $timestamp int timestamp in URL
* @param $ttl int expected caching period
*/
public function testResourceLoaderModifyMaxAge($version, $ttl)
{
global $wgHooks;
$resourceLoader = new ResourceLoader();
$resourceLoader->register('WikiaTestModule', array('class' => 'TestResourceLoaderModule'));
$request = new WebRequest();
$request->setVal('modules', 'WikiaTestModule');
$request->setVal('version', join('-', $version));
// set up hooks
$wgHooks['ResourceLoaderCacheControlHeaders'][] = 'ResourceLoaderTest::onResourceLoaderCacheControlHeaders';
ob_start();
$resourceLoader->respond(new ResourceLoaderContext($resourceLoader, $request));
ob_end_clean();
// hook ResourceLoaderHooks::onResourceLoaderModifyMaxAge was called
// check modified caching period with expected one
$this->assertEquals($ttl, self::$ttl, 'TTL should match expected value');
}
示例8: testPageIsTrackable
/**
* @dataProvider pageIsTrackableProvider
* @param $ns int namespace
* @param $action string action=... value
* @param $exists bool does the page exist?
* @param $expectedResult bool expected result
*/
public function testPageIsTrackable($ns, $action, $exists, $expectedResult)
{
$title = $this->mockClassWithMethods('Title', ['getNamespace' => $ns, 'exists' => $exists]);
$request = new WebRequest();
$request->setVal('action', $action);
$this->mockGlobalVariable('wgRequest', $request);
$this->assertEquals($expectedResult, LyricFindHooks::pageIsTrackable($title));
}
示例9: testSassBuilder
/**
* @group Slow
* @slowExecutionTime 0.85936 ms
*/
public function testSassBuilder()
{
// disable memcache layer in this test
$mock_memc = $this->getMock('stdClass', array('get', 'set'));
$mock_memc->expects($this->any())->method('get')->will($this->returnValue(false));
$mock_memc->expects($this->any())->method('set')->will($this->returnValue(true));
$this->mockGlobalVariable('wgMemc', $mock_memc);
$request = new WebRequest();
$request->setVal('oid', self::SASS_FILE);
$request->setVal('cb', $this->cb);
$builder = new AssetsManagerSassBuilder($request);
$this->assertContains('#foo', $builder->getContent());
// test URLs rewriting
$this->assertContains('sprite.png', $builder->getContent());
$this->assertContains("{$this->cdn}/skins/shared/images/sprite.png", $builder->getContent());
$this->assertNotContains('/* $wgCdnStylePath */', $builder->getContent());
// test base64 encoding
$this->assertNotContains('blank.gif', $builder->getContent());
$this->assertContains('data:image/gif;base64,', $builder->getContent());
$this->assertNotContains('/* base64 */', $builder->getContent());
}
示例10: onBeforeInitialize
/**
* If the user has specified that they want to edit the page with VE, suppress any redirect.
* @param Title $title Title being used for request
* @param Article|null $article
* @param OutputPage $output
* @param User $user
* @param WebRequest $request
* @param MediaWiki $mediaWiki
* @return bool Always true
*/
public static function onBeforeInitialize(Title $title, $article, OutputPage $output, User $user, WebRequest $request, MediaWiki $mediaWiki)
{
if ($request->getVal('veaction') === 'edit') {
$request->setVal('redirect', 'no');
}
return true;
}
示例11: getBuilder
/**
* Returns instance of AssetsManager builder handling given type of assets
*
* @param string $type assets type ('one', 'group', 'groups', 'sass')
* @param string $oid assets / group name
* @return AssetsManagerBaseBuilder instance of builder
*/
private function getBuilder($type, $oid)
{
$type = ucfirst($type);
// TODO: add a factory method to AssetsManager
$className = "AssetsManager{$type}Builder";
if (class_exists($className)) {
$request = new WebRequest();
$request->setVal('oid', $oid);
$builder = new $className($request);
return $builder;
} else {
return null;
}
}
示例12: setUpRequest
protected function setUpRequest($params = array())
{
$wgRequest = new WebRequest();
foreach ($params as $key => $value) {
$wgRequest->setVal($key, $value);
}
$this->mockGlobalVariable('wgRequest', $wgRequest);
}