本文整理汇总了PHP中SS_HTTPRequest::getVars方法的典型用法代码示例。如果您正苦于以下问题:PHP SS_HTTPRequest::getVars方法的具体用法?PHP SS_HTTPRequest::getVars怎么用?PHP SS_HTTPRequest::getVars使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SS_HTTPRequest
的用法示例。
在下文中一共展示了SS_HTTPRequest::getVars方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getList
/**
* The default implementation of the controller
* is to call the serializeList method on its model.
* @param SS_HTTPRequest $request
* @return string|JsonDataResponse|SS_HTTPResponse
*/
public function getList(SS_HTTPRequest $request)
{
$record = $this->getDataRecord();
if ($record->hasMethod('getSerializedList')) {
return $record->getSerializedList($request->getVars())->toJson();
}
}
示例2: getLocationsByDay
public function getLocationsByDay(SS_HTTPRequest $request)
{
try {
$query_string = $request->getVars();
$summit_id = intval($request->param('SUMMIT_ID'));
$day = strtolower(Convert::raw2sql($query_string['day']));
$summit = $this->summit_repository->getById($summit_id);
if (is_null($summit)) {
throw new NotFoundEntityException('Summit', sprintf(' id %s', $summit_id));
}
if (!$summit->isDayBelongs($day)) {
throw new EntityValidationException(sprintf('day %s does not belongs to summit id %s', $day, $summit_id));
}
$response = array('day' => $day, 'summit_id' => intval($summit_id), 'locations' => array());
foreach ($summit->getTopVenues() as $venue) {
$class_name = $venue->ClassName;
if ($class_name != 'SummitVenue' && $class_name != 'SummitExternalLocation' && $class_name != 'SummitHotel') {
continue;
}
$count = $summit->getPublishedEventsCountByDateLocation($day, $venue);
array_push($response['locations'], array('id' => intval($venue->ID), 'events_count' => intval($count)));
if ($class_name == 'SummitVenue') {
foreach ($venue->Rooms() as $room) {
$count = $summit->getPublishedEventsCountByDateLocation($day, $room);
array_push($response['locations'], array('id' => intval($room->ID), 'events_count' => intval($count)));
}
}
}
return $this->ok($response);
} catch (Exception $ex) {
SS_Log::log($ex->getMessage(), SS_Log::ERR);
return $this->serverError();
}
}
示例3: run
/**
* @param SS_HTTPRequest $request
*/
public function run($request)
{
// Only allow execution from the command line (for simplicity).
if (!Director::is_cli()) {
echo "<p>Sorry, but this can only be run from the command line.</p>";
return;
}
try {
// Get and validate desired maintenance mode setting.
$get = $request->getVars();
if (empty($get["args"])) {
throw new Exception("Please provide an argument (e.g. 'on' or 'off').", 1);
}
$arg = strtolower(current($get["args"]));
if ($arg != "on" && $arg != "off") {
throw new Exception("Invalid argument: '{$arg}' (expected 'on' or 'off')", 2);
}
// Get and write site configuration now.
$config = SiteConfig::current_site_config();
$previous = !empty($config->MaintenanceMode) ? "on" : "off";
$config->MaintenanceMode = $arg == "on";
$config->write();
// Output status and exit.
if ($arg != $previous) {
$this->output("Maintenance mode is now '{$arg}'.");
} else {
$this->output("NOTE: Maintenance mode was already '{$arg}' (nothing has changed).");
}
} catch (Exception $e) {
$this->output("ERROR: " . $e->getMessage());
if ($e->getCode() <= 2) {
$this->output("Usage: sake dev/tasks/MaintenanceMode [on|off]");
}
}
}
示例4: afterPurchase
/**
* Default action handler for this page
*
* @param SS_HTTPRequest $request
* @return Object AfterPurchasePage
*/
public function afterPurchase(SS_HTTPRequest $request)
{
if ($request->isGET()) {
if ($this->validateClickBankRequest) {
$cbreceipt = $request->getVar('cbreceipt');
$cbpop = $request->getVar('cbpop');
$name = $request->getVar('cname');
$email = $request->getVar('cemail');
if (!empty($cbreceipt) && !empty($cbpop)) {
if (ClickBankManager::validate_afterpurchase_request($request->getVars())) {
$member = DataObject::get_one('Member', "Email = '{$email}'");
// make the member status to logged-in
if ($member && $this->loginAfterClickBankRequestIsValid) {
$member->logIn();
}
// few handy replacement texts
$content = $this->Content;
$content = str_replace('$CBReceipt', $cbreceipt, $content);
$content = str_replace('$CBName', $name, $content);
$data = array('Title' => $this->Title, 'Content' => $content);
return $this->customise($data)->renderWith(array('AfterPurchasePage' => 'Page'));
}
}
} else {
$data = array('Title' => $this->Title, 'Content' => $this->Content);
return $this->customise($data)->renderWith(array('AfterPurchasePage' => 'Page'));
}
}
return $this->redirect('/server-error');
}
示例5: check
/**
* Check that the payment was successful using "Process Response" API (http://www.paymentexpress.com/Technical_Resources/Ecommerce_Hosted/PxPay.aspx).
*
* @param SS_HTTPRequest $request Request from the gateway - transaction response
* @return PaymentGateway_Result
*/
public function check($request)
{
$data = $request->getVars();
$url = $request->getVar('url');
$result = $request->getVar('result');
$userID = $request->getVar('userid');
//Construct the request to check the payment status
$request = new PxPayLookupRequest();
$request->setResponse($result);
//Get encrypted URL from DPS to redirect the user to
$request_string = $this->makeCheckRequest($request, $data);
//Obtain output XML
$response = new MifMessage($request_string);
//Parse output XML
$success = $response->get_element_text('Success');
if ($success && is_numeric($success) && $success > 0) {
return new PaymentGateway_Success();
} else {
if (is_numeric($success) && $success == 0) {
return new PaymentGateway_Failure();
} else {
return new PaymentGateway_Incomplete();
}
}
}
开发者ID:helpfulrobot,项目名称:frankmullenger-payment-paymentexpress,代码行数:31,代码来源:PaymentExpressGateway.php
示例6: getAttendees
public function getAttendees(SS_HTTPRequest $request)
{
try {
$query_string = $request->getVars();
$page = isset($query_string['page']) ? Convert::raw2sql($query_string['page']) : '';
$page_size = isset($query_string['items']) ? Convert::raw2sql($query_string['items']) : '';
$search_term = isset($query_string['term']) ? Convert::raw2sql($query_string['term']) : '';
$summit_id = intval($request->param('SUMMIT_ID'));
$summit = $this->summit_repository->getById($summit_id);
if (is_null($summit)) {
throw new NotFoundEntityException('Summit', sprintf(' id %s', $summit_id));
}
list($attendees, $count) = $this->summitattendee_repository->findAttendeesBySummit($search_term, $page, $page_size, $summit_id);
$attendees_array = array();
foreach ($attendees as $attendee) {
$attendees_array[] = array('id' => $attendee->ID, 'member_id' => $attendee->MemberID, 'name' => $attendee->Member->FullName, 'email' => $attendee->Member->Email, 'eventbrite_id' => $attendee->getTicketIDs(), 'ticket_bought' => $attendee->getBoughtDate(), 'checked_in' => $attendee->SummitHallCheckedIn, 'link' => 'summit-admin/' . $summit_id . '/attendees/' . $attendee->ID, 'schedule' => $attendee->Schedule()->toNestedArray());
}
return $this->ok(array('attendees' => $attendees_array, 'count' => $count));
} catch (NotFoundEntityException $ex2) {
SS_Log::log($ex2->getMessage(), SS_Log::WARN);
return $this->notFound($ex2->getMessage());
} catch (Exception $ex) {
SS_Log::log($ex->getMessage(), SS_Log::ERR);
return $this->serverError();
}
}
示例7: handleQuery
/**
* All requests pass through here and are redirected depending on HTTP verb and params
*
* @param SS_HTTPRequest $request HTTP request
* @return DataObjec|DataList DataObject/DataList result or stdClass on error
*/
public function handleQuery(SS_HTTPRequest $request)
{
//get requested model(s) details
$model = $request->param('ClassName');
$id = $request->param('ID');
$response = false;
$queryParams = $this->parseQueryParameters($request->getVars());
//validate Model name + store
if ($model) {
$model = $this->deSerializer->unformatName($model);
if (!class_exists($model)) {
return new RESTfulAPI_Error(400, "Model does not exist. Received '{$model}'.");
} else {
//store requested model data and query data
$this->requestedData['model'] = $model;
}
} else {
//if model missing, stop + return blank object
return new RESTfulAPI_Error(400, "Missing Model parameter.");
}
//check API access rules on model
if (!RESTfulAPI::api_access_control($model, $request->httpMethod())) {
return new RESTfulAPI_Error(403, "API access denied.");
}
//validate ID + store
if (($request->isPUT() || $request->isDELETE()) && !is_numeric($id)) {
return new RESTfulAPI_Error(400, "Invalid or missing ID. Received '{$id}'.");
} else {
if ($id !== NULL && !is_numeric($id)) {
return new RESTfulAPI_Error(400, "Invalid ID. Received '{$id}'.");
} else {
$this->requestedData['id'] = $id;
}
}
//store query parameters
if ($queryParams) {
$this->requestedData['params'] = $queryParams;
}
//map HTTP word to module method
switch ($request->httpMethod()) {
case 'GET':
return $this->findModel($model, $id, $queryParams, $request);
break;
case 'POST':
return $this->createModel($model, $request);
break;
case 'PUT':
return $this->updateModel($model, $id, $request);
break;
case 'DELETE':
return $this->deleteModel($model, $id, $request);
break;
default:
return new RESTfulAPI_Error(403, "HTTP method mismatch.");
break;
}
}
开发者ID:helpfulrobot,项目名称:colymba-silverstripe-restfulapi,代码行数:63,代码来源:RESTfulAPI_DefaultQueryHandler.php
示例8: preRequest
/**
* @inheritdoc
*
* @param SS_HTTPRequest $request
* @param Session $session
* @param DataModel $model
*
* @return bool
*/
public function preRequest(SS_HTTPRequest $request, Session $session, DataModel $model)
{
if (array_key_exists('flush', $request->getVars())) {
foreach (ClassInfo::implementorsOf('Flushable') as $class) {
$class::flush();
}
}
return true;
}
示例9: topics
/**
* @param SS_HTTPRequest $request
* @return string
*/
function topics(SS_HTTPRequest $request)
{
$params = $request->getVars();
$result = $this->course_topics_query->handle(new OpenStackImplementationNamesQuerySpecification($params["term"]));
$res = array();
foreach ($result->getResult() as $dto) {
array_push($res, array('label' => $dto->getLabel(), 'value' => $dto->getValue()));
}
return json_encode($res);
}
示例10: onBeforeHTTPError404
/**
* On every URL that generates a 404, we'll capture it here and see if we can
* find an old URL that it should be redirecting to.
*
* @param SS_HTTPRequest $request The request object
* @throws SS_HTTPResponse_Exception
*/
public function onBeforeHTTPError404($request)
{
// We need to get the URL ourselves because $request->allParams() only has a max of 4 params
$params = preg_split('|/+|', $request->getURL());
$getvars = $request->getVars();
unset($getvars['url']);
$page = self::find_old_page($params);
if ($page) {
$res = new SS_HTTPResponse();
$res->redirect(Controller::join_links($page, $getvars ? '?' . http_build_query($getvars) : null), 301);
throw new SS_HTTPResponse_Exception($res);
}
}
示例11: run
/**
* @param SS_HTTPRequest $request
* @throws MigrationException
*/
public function run($request)
{
// Only allow execution from the command line (for simplicity and security).
if (!Director::is_cli()) {
echo "<p>Sorry, but this can only be run from the command line.</p>";
return;
}
// Get and pre-process arguments. Format: ["argument" => true, "make" => "filename", ... ]
$getVars = $request->getVars();
$args = array();
if (isset($getVars["args"]) && is_array($getVars["args"])) {
foreach ($getVars["args"] as $arg) {
// Separate keys/values.
$argVals = explode(":", $arg, 2);
$key = $argVals[0];
$value = true;
if (count($argVals) > 1) {
$value = $argVals[1];
}
$args[$key] = $value;
}
}
// Unfortunately, SilverStripe is not using exceptions for database errors for some reason, so we must
// temporarily setup our own global error handler as a stop gap so we can properly handle transactions.
set_error_handler(function ($errno, $errstr) {
throw new MigrationException($errstr, $errno);
});
// Use a shutdown function to help clean up and track final exit status, in case an unexpected fatal error occurs.
$this->error = true;
register_shutdown_function(array($this, "shutdown"));
// Determine action to take. Wrap everything in a transaction so it can be rolled back in case of error.
DB::getConn()->transactionStart();
try {
if (isset($args["up"])) {
$this->up();
} elseif (isset($args["down"])) {
$this->down();
} elseif (isset($args["make"])) {
$this->make($args["make"]);
} else {
throw new MigrationException("Invalid or no migration arguments provided. Please specify either: 'up', 'down' or 'make:name_of_your_migration'.");
}
// Commit and clean up error state..
DB::getConn()->transactionEnd();
$this->error = false;
} catch (Exception $e) {
$this->shutdown($e);
}
// Shutdown method below will run next.
}
示例12: onBeforeHTTPError404
/**
* On every URL that generates a 404, we'll capture it here and see if we can
* find an old URL that it should be redirecting to.
*
* @param SS_HTTPRequest $request The request object
* @throws SS_HTTPResponse_Exception
*/
public function onBeforeHTTPError404($request)
{
// Build up the request parameters
$params = array_filter(array_values($request->allParams()), function ($v) {
return $v !== NULL;
});
$getvars = $request->getVars();
unset($getvars['url']);
$page = self::find_old_page($params);
if ($page) {
$res = new SS_HTTPResponse();
$res->redirect(Controller::join_links($page, $getvars ? '?' . http_build_query($getvars) : null), 301);
throw new SS_HTTPResponse_Exception($res);
}
}
示例13: index
/**
* @param SS_HTTPRequest $request
* @return $this
* Handle signup type
*/
public function index(SS_HTTPRequest $request)
{
$vars = $request->getVars();
if (array_key_exists('power', $vars) && $vars['power']) {
$data['type'] = 'PowerPlan';
$data['id'] = $vars['power'];
Session::set('Signup', $data);
} elseif (array_key_exists('gas', $vars) && $vars['gas']) {
$data['type'] = 'GasPlan';
$data['id'] = $vars['gas'];
Session::set('Signup', $data);
} else {
$this->redirect('home/result');
}
return $this;
}
示例14: getSearchResults
/**
* Process and render search results.
*
* @param array $data The raw request data submitted by user
* @param SearchForm $form The form instance that was submitted
* @param SS_HTTPRequest $request Request generated for this action
*/
public function getSearchResults($request)
{
$list = new ArrayList();
$v = $request->getVars();
$q = $v["Search"];
$input = DB::getConn()->addslashes($q);
$data = DB::query(<<<EOF
SELECT
\t`pages`.`ID`,
\t`pages`.`ClassName`,
\t`pages`.`Title`,
\tGROUP_CONCAT(`do`.`Content` SEPARATOR ' ') as `Content`,
\t`pages`.`PageID`,
\tSUM(MATCH (`do`.`Title`, `do`.`Content`) AGAINST ('{$input}' IN NATURAL LANGUAGE MODE)) as `relevance`
FROM
\tSearchableDataObjects as `pages`
JOIN
\tSearchableDataObjects as `do`
ON
\t`pages`.`ID` = `do`.`OwnerID` AND
\t`pages`.`ClassName` = `do`.`OwnerClassName`
WHERE
\t`pages`.`ID` = `pages`.`OwnerID` AND
`pages`.`ClassName` = `pages`.`OwnerClassName`
GROUP BY
\t`pages`.`ID`,
\t`pages`.`ClassName`
HAVING
\t`relevance`
ORDER BY
\t`relevance` DESC
EOF
);
foreach ($data as $row) {
$do = DataObject::get_by_id($row['ClassName'], $row['ID']);
if (!$do) {
continue;
}
$do->Title = $row['Title'];
$do->Content = $row['Content'];
$list->push($do);
}
$pageLength = Config::inst()->get('CustomSearch', 'items_per_page');
$ret = new PaginatedList($list, $request);
$ret->setPageLength($pageLength);
return $ret;
}
示例15: onBeforeHTTPError404
/**
* On every URL that generates a 404, we'll capture it here and see if we can
* find an old URL that it should be redirecting to.
*
* @param SS_HTTPRequest $request The request object
* @throws SS_HTTPResponse_Exception
*/
public function onBeforeHTTPError404($request)
{
// We need to get the URL ourselves because $request->allParams() only has a max of 4 params
$params = preg_split('|/+|', $request->getURL());
$cleanURL = trim(Director::makeRelative($request->getURL(false), '/'));
$getvars = $request->getVars();
unset($getvars['url']);
$page = self::find_old_page($params);
$cleanPage = trim(Director::makeRelative($page), '/');
if (!$cleanPage) {
$cleanPage = Director::makeRelative(RootURLController::get_homepage_link());
}
if ($page && $cleanPage != $cleanURL) {
$res = new SS_HTTPResponse();
$res->redirect(Controller::join_links($page, $getvars ? '?' . http_build_query($getvars) : null), 301);
throw new SS_HTTPResponse_Exception($res);
}
}