本文整理汇总了PHP中WebRequest类的典型用法代码示例。如果您正苦于以下问题:PHP WebRequest类的具体用法?PHP WebRequest怎么用?PHP WebRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WebRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: loadRequest
/**
* Initialize instance variables from request and create an Upload handler
*
* What was changed here: $this->mIgnoreWarning is now unconditionally true
* and we use our own handler for $this->mUpload instead of UploadBase
*
* @param WebRequest $request The request to extract variables from
*/
protected function loadRequest($request)
{
global $wgUser;
$this->mRequest = $request;
$this->mSourceType = $request->getVal('wpSourceType', 'file');
$this->mUpload = FanBoxUpload::createFromRequest($request);
$this->mUploadClicked = $request->wasPosted() && ($request->getCheck('wpUpload') || $request->getCheck('wpUploadIgnoreWarning'));
// Guess the desired name from the filename if not provided
$this->mDesiredDestName = $request->getText('wpDestFile');
if (!$this->mDesiredDestName && $request->getFileName('wpUploadFile') !== null) {
$this->mDesiredDestName = $request->getFileName('wpUploadFile');
}
$this->mComment = $request->getText('wpUploadDescription');
$this->mLicense = $request->getText('wpLicense');
$this->mDestWarningAck = $request->getText('wpDestFileWarningAck');
$this->mIgnoreWarning = true;
//$request->getCheck( 'wpIgnoreWarning' ) || $request->getCheck( 'wpUploadIgnoreWarning' );
$this->mWatchthis = $request->getBool('wpWatchthis') && $wgUser->isLoggedIn();
$this->mCopyrightStatus = $request->getText('wpUploadCopyStatus');
$this->mCopyrightSource = $request->getText('wpUploadSource');
$this->mForReUpload = $request->getBool('wpForReUpload');
// updating a file
$this->mCancelUpload = $request->getCheck('wpCancelUpload') || $request->getCheck('wpReUpload');
// b/w compat
// If it was posted check for the token (no remote POST'ing with user credentials)
$token = $request->getVal('wpEditToken');
if ($this->mSourceType == 'file' && $token == null) {
// Skip token check for file uploads as that can't be faked via JS...
// Some client-side tools don't expect to need to send wpEditToken
// with their submissions, as that's new in 1.16.
$this->mTokenOk = true;
} else {
$this->mTokenOk = $wgUser->matchEditToken($token);
}
}
示例3: send
public function send($message, $list)
{
$webRequest = new WebRequest();
$params = array("profileId" => $this->profileId, "user" => $this->user, "pwd" => $this->pwd, "senderId" => $this->senderId, "mobileno" => implode(",", $list), "msgtext" => "this is a test message");
$result = $webRequest->get("http://bulksmsindia.mobi/sendurlcomma.aspx?", $params);
return $result;
}
示例4: onEditPageImportFormData
/**
* Concatenate categories on EditPage POST
*
* @param EditPage $editPage
* @param WebRequest $request
*
* @return Boolean because it's a hook
*/
public static function onEditPageImportFormData($editPage, $request)
{
$app = F::app();
if ($request->wasPosted()) {
$categories = $editPage->safeUnicodeInput($request, 'categories');
$categories = CategoryHelper::changeFormat($categories, 'json', 'array');
// Concatenate categories to article wikitext (if there are any).
if (!empty($categories)) {
if (!empty($app->wg->EnableAnswers)) {
// don't add categories if the page is a redirect
$magicWords = $app->wg->ContLang->getMagicWords();
$redirects = $magicWords['redirect'];
// first element doesn't interest us
array_shift($redirects);
// check for localized versions of #REDIRECT
foreach ($redirects as $alias) {
if (stripos($editPage->textbox1, $alias) === 0) {
return true;
}
}
}
// Extract categories from the article, merge them with those passed in, weed out
// duplicates and finally append them back to the article (BugId:99348).
$data = CategoryHelper::extractCategoriesFromWikitext($editPage->textbox1, true);
$categories = CategoryHelper::getUniqueCategories($data['categories'], $categories);
$categories = CategoryHelper::changeFormat($categories, 'array', 'wikitext');
// Remove trailing whitespace (BugId:11238)
$editPage->textbox1 = $data['wikitext'] . rtrim($categories);
}
}
return true;
}
示例5: loadDataFromRequest
/**
* @param WebRequest $request
*
* @return array("<overall message>","<select value>","<text field value>")
*/
function loadDataFromRequest($request)
{
if ($request->getCheck($this->mName)) {
$list = $request->getText($this->mName);
$text = $request->getText($this->mName . '-other');
// Should be built the same as in mediawiki.htmlform.js
if ($list == 'other') {
$final = $text;
} elseif (!in_array($list, $this->mFlatOptions, true)) {
# User has spoofed the select form to give an option which wasn't
# in the original offer. Sulk...
$final = $text;
} elseif ($text == '') {
$final = $list;
} else {
$final = $list . $this->msg('colon-separator')->inContentLanguage()->text() . $text;
}
} else {
$final = $this->getDefault();
$list = 'other';
$text = $final;
foreach ($this->mFlatOptions as $option) {
$match = $option . $this->msg('colon-separator')->inContentLanguage()->text();
if (strpos($text, $match) === 0) {
$list = $option;
$text = substr($text, strlen($match));
break;
}
}
}
return array($final, $list, $text);
}
示例6: 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;
}
示例7: 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));
}
示例8: initializeFromRequest
/**
* @param WebRequest $request
*/
function initializeFromRequest(&$request)
{
$upload = $request->getUpload('wpUploadFile');
$desiredDestName = $request->getText('wpDestFile');
if (!$desiredDestName) {
$desiredDestName = $upload->getName();
}
$this->initialize($desiredDestName, $upload);
}
示例9: newFromRequest
/**
* Constructs a page from WebRequest.
* This interface is a big klunky.
* @param $request WebRequest
* @return TranslationEditPage
*/
public static function newFromRequest(WebRequest $request)
{
$title = Title::newFromText($request->getText('page'));
if (!$title) {
return null;
}
$obj = new self($title);
$obj->suggestions = $request->getText('suggestions');
return $obj;
}
示例10: getUserEmail
/**
* Try and get an email for the user from Facebook. If Facebook has an email for the user
* we don't have to confirm it, Facebook has done that for us. If Facebook doesn't have one,
* try and pull one from the form and make note that we'll have to confirm the user.
* @param WebRequest $request
* @return String
*/
private function getUserEmail(WebRequest $request)
{
$userInfo = FacebookClient::getInstance()->getUserInfo();
$userEmail = $userInfo->getProperty('email');
if (empty($userEmail)) {
// Email didn't come from facebook, we have to confirm it ourselves
$this->hasConfirmedEmail = false;
$userEmail = $request->getVal('email', '');
}
return $userEmail;
}
示例11: 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;
}
示例12: upload
public function upload()
{
$cfile = new CURLFile('useruploaddata.xls', 'application/vnd.ms-excel', 'useruploaddata.xls');
$webRequest = new WebRequest();
$params = array("action" => 'login', "username" => "admin", "password" => "admin");
$result = $webRequest->post("http://localhost/rozgarmela/admin/", $params);
//echo "tried to login, result is " . $result . "\n";
$params = array("user_group_id" => 'JobSeeker', "import_file" => $cfile, "file_type" => 'xls', "csv_delimiter" => 'semicolon', "encodingFromCharset" => 'UTF-8', "action" => 'Import');
$result = $webRequest->post("http://localhost/rozgarmela/admin/import-users/", $params);
echo "sent data, result is " . $result . "\n";
return $result;
}
示例13: loadDataFromRequest
/**
* @param WebRequest $request
*
* @return string
*/
function loadDataFromRequest($request)
{
if ($request->getCheck($this->mName)) {
$val = $request->getText($this->mName);
if ($val === 'other') {
$val = $request->getText($this->mName . '-other');
}
return $val;
} else {
return $this->getDefault();
}
}
示例14: __construct
public function __construct(WebRequest $request)
{
$this->mType = $request->getText('type');
$this->mOid = preg_replace('/\\?.*$/', '', $request->getText('oid'));
parse_str(urldecode($request->getText('params')), $this->mParams);
$this->mCb = $request->getInt('cb');
if (!empty($this->mParams['noexternals'])) {
$this->mNoExternals = true;
}
if (!empty($this->mParams['forceprofile'])) {
$this->mForceProfile = true;
}
}
示例15: 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();
}
}