本文整理汇总了PHP中PhutilURI::setQueryParams方法的典型用法代码示例。如果您正苦于以下问题:PHP PhutilURI::setQueryParams方法的具体用法?PHP PhutilURI::setQueryParams怎么用?PHP PhutilURI::setQueryParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhutilURI
的用法示例。
在下文中一共展示了PhutilURI::setQueryParams方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processRequest
public function processRequest()
{
$request = $this->getRequest();
if (!PhabricatorEnv::getEnvConfig('auth.password-auth-enabled')) {
return new Aphront400Response();
}
if ($request->getUser()->getPHID()) {
$view = new AphrontRequestFailureView();
$view->setHeader('Already Logged In');
$view->appendChild('<p>You are already logged in.</p>');
$view->appendChild('<div class="aphront-failure-continue">' . '<a class="button" href="/">Return Home</a>' . '</div>');
return $this->buildStandardPageResponse($view, array('title' => 'Already Logged In'));
}
$token = $this->token;
$email = $request->getStr('email');
$target_user = id(new PhabricatorUser())->loadOneWhere('email = %s', $email);
if (!$target_user || !$target_user->validateEmailToken($token)) {
$view = new AphrontRequestFailureView();
$view->setHeader('Unable to Login');
$view->appendChild('<p>The authentication information in the link you clicked is ' . 'invalid or out of date. Make sure you are copy-and-pasting the ' . 'entire link into your browser. You can try again, or request ' . 'a new email.</p>');
$view->appendChild('<div class="aphront-failure-continue">' . '<a class="button" href="/login/email/">Send Another Email</a>' . '</div>');
return $this->buildStandardPageResponse($view, array('title' => 'Email Sent'));
}
$session_key = $target_user->establishSession('web');
$request->setCookie('phusr', $target_user->getUsername());
$request->setCookie('phsid', $session_key);
if (PhabricatorEnv::getEnvConfig('account.editable')) {
$next = '/settings/page/password/?token=' . $token;
} else {
$next = '/';
}
$uri = new PhutilURI('/login/validate/');
$uri->setQueryParams(array('phusr' => $target_user->getUsername(), 'next' => $next));
return id(new AphrontRedirectResponse())->setURI((string) $uri);
}
示例2: buildResponseString
public function buildResponseString()
{
$console = $this->getConsole();
if ($console) {
// NOTE: We're stripping query parameters here both for readability and
// to mitigate BREACH and similar attacks. The parameters are available
// in the "Request" tab, so this should not impact usability. See T3684.
$uri = $this->getRequest()->getRequestURI();
$uri = new PhutilURI($uri);
$uri->setQueryParams(array());
Javelin::initBehavior('dark-console', array('uri' => (string) $uri, 'key' => $console->getKey($this->getRequest()), 'color' => $console->getColor(), 'quicksand' => $this->getRequest()->isQuicksand()));
}
// Flatten the response first, so we initialize any behaviors and metadata
// we need to.
$content = array('payload' => $this->content);
$this->encodeJSONForHTTPResponse($content);
$response = CelerityAPI::getStaticResourceResponse();
$request = $this->getRequest();
if ($request) {
$viewer = $request->getViewer();
if ($viewer) {
$postprocessor_key = $viewer->getUserSetting(PhabricatorAccessibilitySetting::SETTINGKEY);
if (strlen($postprocessor_key)) {
$response->setPostprocessorKey($postprocessor_key);
}
}
}
$object = $response->buildAjaxResponse($content['payload'], $this->error);
$response_json = $this->encodeJSONForHTTPResponse($object);
return $this->addJSONShield($response_json);
}
示例3: processControllerRequest
public function processControllerRequest(PhortuneProviderController $controller, AphrontRequest $request)
{
$cart = $controller->loadCart($request->getInt('cartID'));
if (!$cart) {
return new Aphront404Response();
}
switch ($controller->getAction()) {
case 'checkout':
$return_uri = $this->getControllerURI('charge', array('cartID' => $cart->getID()));
$cancel_uri = $this->getControllerURI('cancel', array('cartID' => $cart->getID()));
$total_in_cents = $cart->getTotalPriceInCents();
$price = PhortuneCurrency::newFromUSDCents($total_in_cents);
$result = $this->newPaypalAPICall()->setRawPayPalQuery('SetExpressCheckout', array('PAYMENTREQUEST_0_AMT' => $price->formatBareValue(), 'PAYMENTREQUEST_0_CURRENCYCODE' => $price->getCurrency(), 'RETURNURL' => $return_uri, 'CANCELURL' => $cancel_uri, 'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale'))->resolve();
$uri = new PhutilURI('https://www.sandbox.paypal.com/cgi-bin/webscr');
$uri->setQueryParams(array('cmd' => '_express-checkout', 'token' => $result['TOKEN']));
return id(new AphrontRedirectResponse())->setIsExternal(true)->setURI($uri);
case 'charge':
var_dump($_REQUEST);
break;
case 'cancel':
var_dump($_REQUEST);
break;
}
throw new Exception("The rest of this isn't implemented yet.");
}
示例4: getBrowseURI
public function getBrowseURI()
{
if (!$this->isBrowsable()) {
return null;
}
$uri = new PhutilURI('/typeahead/browse/' . get_class($this) . '/');
$uri->setQueryParams($this->parameters);
return (string) $uri;
}
示例5: getUserInfo
private function getUserInfo()
{
if ($this->userInfo === null) {
$uri = new PhutilURI('https://api.twitter.com/1.1/users/show.json');
$uri->setQueryParams(array('user_id' => $this->getAccountID()));
$data = $this->newOAuth1Future($uri)->setMethod('GET')->resolveJSON();
$this->userInfo = $data;
}
return $this->userInfo;
}
示例6: processRequest
public function processRequest()
{
$request = $this->getRequest();
if (!PhabricatorEnv::getEnvConfig('auth.password-auth-enabled')) {
return new Aphront400Response();
}
$token = $this->token;
$email = $request->getStr('email');
// NOTE: We need to bind verification to **addresses**, not **users**,
// because we verify addresses when they're used to login this way, and if
// we have a user-based verification you can:
//
// - Add some address you do not own;
// - request a password reset;
// - change the URI in the email to the address you don't own;
// - login via the email link; and
// - get a "verified" address you don't control.
$target_email = id(new PhabricatorUserEmail())->loadOneWhere('address = %s', $email);
$target_user = null;
if ($target_email) {
$target_user = id(new PhabricatorUser())->loadOneWhere('phid = %s', $target_email->getUserPHID());
}
if (!$target_email || !$target_user || !$target_user->validateEmailToken($target_email, $token)) {
$view = new AphrontRequestFailureView();
$view->setHeader('Unable to Login');
$view->appendChild('<p>The authentication information in the link you clicked is ' . 'invalid or out of date. Make sure you are copy-and-pasting the ' . 'entire link into your browser. You can try again, or request ' . 'a new email.</p>');
$view->appendChild('<div class="aphront-failure-continue">' . '<a class="button" href="/login/email/">Send Another Email</a>' . '</div>');
return $this->buildStandardPageResponse($view, array('title' => 'Login Failure'));
}
// Verify email so that clicking the link in the "Welcome" email is good
// enough, without requiring users to go through a second round of email
// verification.
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
$target_email->setIsVerified(1);
$target_email->save();
$session_key = $target_user->establishSession('web');
unset($unguarded);
$request->setCookie('phusr', $target_user->getUsername());
$request->setCookie('phsid', $session_key);
if (PhabricatorEnv::getEnvConfig('account.editable')) {
$next = (string) id(new PhutilURI('/settings/panel/password/'))->setQueryParams(array('token' => $token, 'email' => $email));
} else {
$next = '/';
}
$uri = new PhutilURI('/login/validate/');
$uri->setQueryParams(array('phusr' => $target_user->getUsername(), 'next' => $next));
return id(new AphrontRedirectResponse())->setURI((string) $uri);
}
示例7: getProxiedFuture
protected function getProxiedFuture()
{
if (!$this->future) {
$params = $this->params;
if (!$this->params) {
throw new Exception('You must setRawAWSQuery()!');
}
if (!$this->getAWSAccessKey()) {
throw new Exception('You must setAWSKeys()!');
}
$params['AWSAccessKeyId'] = $this->getAWSAccessKey();
$params['Version'] = '2011-12-15';
$params['Timestamp'] = date('c');
$params = $this->sign($params);
$uri = new PhutilURI('http://' . $this->getHost() . '/');
$uri->setQueryParams($params);
$this->future = new HTTPFuture($uri);
}
return $this->future;
}
示例8: processRequest
public function processRequest()
{
$request = $this->getRequest();
$user = $request->getUser();
$status = id(new PhabricatorCalendarEventQuery())->setViewer($user)->withIDs(array($this->id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
if (!$status) {
return new Aphront404Response();
}
if ($request->isFormPost()) {
$status->delete();
$uri = new PhutilURI($this->getApplicationURI());
$uri->setQueryParams(array('deleted' => true));
return id(new AphrontRedirectResponse())->setURI($uri);
}
$dialog = new AphrontDialogView();
$dialog->setUser($user);
$dialog->setTitle(pht('Really delete status?'));
$dialog->appendChild(pht('Permanently delete this status? This action can not be undone.'));
$dialog->addSubmitButton(pht('Delete'));
$dialog->addCancelButton($this->getApplicationURI('event/'));
return id(new AphrontDialogResponse())->setDialog($dialog);
}
示例9: render
public function render()
{
require_celerity_resource('differential-changeset-view-css');
$changesets = $this->changesets;
$output = array();
$mapping = array();
foreach ($changesets as $key => $changeset) {
$file = $changeset->getFilename();
$class = 'differential-changeset';
if (!$this->editable) {
$class .= ' differential-changeset-noneditable';
}
$ref = $this->references[$key];
$detail_button = null;
if ($this->standaloneViews) {
$detail_uri = new PhutilURI($this->renderURI);
$detail_uri->setQueryParams(array('ref' => $ref, 'whitespace' => $this->whitespace));
$detail_button = phutil_render_tag('a', array('class' => 'button small grey', 'href' => $detail_uri, 'target' => '_blank'), 'View Standalone / Raw');
}
$uniq_id = celerity_generate_unique_node_id();
$detail = new DifferentialChangesetDetailView();
$detail->setChangeset($changeset);
$detail->addButton($detail_button);
$detail->appendChild(phutil_render_tag('div', array('id' => $uniq_id), '<div class="differential-loading">Loading...</div>'));
$output[] = $detail->render();
$mapping[$uniq_id] = $ref;
}
Javelin::initBehavior('differential-populate', array('registry' => $mapping, 'whitespace' => $this->whitespace, 'uri' => $this->renderURI));
Javelin::initBehavior('differential-show-more', array('uri' => $this->renderURI, 'whitespace' => $this->whitespace));
Javelin::initBehavior('differential-comment-jump', array());
if ($this->editable) {
$undo_templates = $this->renderUndoTemplates();
$revision = $this->revision;
Javelin::initBehavior('differential-edit-inline-comments', array('uri' => '/differential/comment/inline/edit/' . $revision->getID() . '/', 'undo_templates' => $undo_templates));
}
return '<div class="differential-review-stage" id="differential-review-stage">' . implode("\n", $output) . '</div>';
}
示例10: renderStandardLoginButton
/**
* Render a standard login/register button element.
*
* The `$attributes` parameter takes these keys:
*
* - `uri`: URI the button should take the user to when clicked.
* - `method`: Optional HTTP method the button should use, defaults to GET.
*
* @param AphrontRequest HTTP request.
* @param string Request mode string.
* @param map Additional parameters, see above.
* @return wild Login button.
*/
protected function renderStandardLoginButton(AphrontRequest $request, $mode, array $attributes = array())
{
PhutilTypeSpec::checkMap($attributes, array('method' => 'optional string', 'uri' => 'string', 'sigil' => 'optional string'));
$viewer = $request->getUser();
$adapter = $this->getAdapter();
if ($mode == 'link') {
$button_text = pht('Link External Account');
} else {
if ($mode == 'refresh') {
$button_text = pht('Refresh Account Link');
} else {
if ($mode == 'invite') {
$button_text = pht('Register Account');
} else {
if ($this->shouldAllowRegistration()) {
$button_text = pht('Login or Register');
} else {
$button_text = pht('Login');
}
}
}
}
$icon = id(new PHUIIconView())->setSpriteSheet(PHUIIconView::SPRITE_LOGIN)->setSpriteIcon($this->getLoginIcon());
$button = id(new PHUIButtonView())->setSize(PHUIButtonView::BIG)->setColor(PHUIButtonView::GREY)->setIcon($icon)->setText($button_text)->setSubtext($this->getProviderName());
$uri = $attributes['uri'];
$uri = new PhutilURI($uri);
$params = $uri->getQueryParams();
$uri->setQueryParams(array());
$content = array($button);
foreach ($params as $key => $value) {
$content[] = phutil_tag('input', array('type' => 'hidden', 'name' => $key, 'value' => $value));
}
return phabricator_form($viewer, array('method' => idx($attributes, 'method', 'GET'), 'action' => (string) $uri, 'sigil' => idx($attributes, 'sigil')), $content);
}
示例11: renderResultList
protected function renderResultList(array $events, PhabricatorSavedQuery $query, array $handles)
{
assert_instances_of($events, 'PhabricatorCalendarEvent');
$viewer = $this->requireViewer();
$list = new PHUIObjectItemListView();
foreach ($events as $event) {
if ($event->getUserPHID() == $viewer->getPHID()) {
$href = $this->getApplicationURI('/event/edit/' . $event->getID() . '/');
} else {
$from = $event->getDateFrom();
$month = phabricator_format_local_time($from, $viewer, 'm');
$year = phabricator_format_local_time($from, $viewer, 'Y');
$uri = new PhutilURI($this->getApplicationURI());
$uri->setQueryParams(array('month' => $month, 'year' => $year));
$href = (string) $uri;
}
$from = phabricator_datetime($event->getDateFrom(), $viewer);
$to = phabricator_datetime($event->getDateTo(), $viewer);
$creator_handle = $handles[$event->getUserPHID()];
$color = $event->getStatus() == PhabricatorCalendarEvent::STATUS_AWAY ? 'red' : 'yellow';
$item = id(new PHUIObjectItemView())->setHeader($event->getTerseSummary($viewer))->setHref($href)->setBarColor($color)->addByline(pht('Creator: %s', $creator_handle->renderLink()))->addAttribute(pht('From %s to %s', $from, $to))->addAttribute(id(new PhutilUTF8StringTruncator())->setMaximumGlyphs(64)->truncateString($event->getDescription()));
$list->addItem($item);
}
return $list;
}
示例12: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$cart = id(new PhortuneCartQuery())->setViewer($viewer)->withIDs(array($id))->needPurchases(true)->executeOne();
if (!$cart) {
return new Aphront404Response();
}
$cancel_uri = $cart->getCancelURI();
$merchant = $cart->getMerchant();
switch ($cart->getStatus()) {
case PhortuneCart::STATUS_BUILDING:
return $this->newDialog()->setTitle(pht('Incomplete Cart'))->appendParagraph(pht('The application that created this cart did not finish putting ' . 'products in it. You can not checkout with an incomplete ' . 'cart.'))->addCancelButton($cancel_uri);
case PhortuneCart::STATUS_READY:
// This is the expected, normal state for a cart that's ready for
// checkout.
break;
case PhortuneCart::STATUS_CHARGED:
case PhortuneCart::STATUS_PURCHASING:
case PhortuneCart::STATUS_HOLD:
case PhortuneCart::STATUS_REVIEW:
case PhortuneCart::STATUS_PURCHASED:
// For these states, kick the user to the order page to give them
// information and options.
return id(new AphrontRedirectResponse())->setURI($cart->getDetailURI());
default:
throw new Exception(pht('Unknown cart status "%s"!', $cart->getStatus()));
}
$account = $cart->getAccount();
$account_uri = $this->getApplicationURI($account->getID() . '/');
$methods = id(new PhortunePaymentMethodQuery())->setViewer($viewer)->withAccountPHIDs(array($account->getPHID()))->withMerchantPHIDs(array($merchant->getPHID()))->withStatuses(array(PhortunePaymentMethod::STATUS_ACTIVE))->execute();
$e_method = null;
$errors = array();
if ($request->isFormPost()) {
// Require CAN_EDIT on the cart to actually make purchases.
PhabricatorPolicyFilter::requireCapability($viewer, $cart, PhabricatorPolicyCapability::CAN_EDIT);
$method_id = $request->getInt('paymentMethodID');
$method = idx($methods, $method_id);
if (!$method) {
$e_method = pht('Required');
$errors[] = pht('You must choose a payment method.');
}
if (!$errors) {
$provider = $method->buildPaymentProvider();
$charge = $cart->willApplyCharge($viewer, $provider, $method);
try {
$provider->applyCharge($method, $charge);
} catch (Exception $ex) {
$cart->didFailCharge($charge);
return $this->newDialog()->setTitle(pht('Charge Failed'))->appendParagraph(pht('Unable to make payment: %s', $ex->getMessage()))->addCancelButton($cart->getCheckoutURI(), pht('Continue'));
}
$cart->didApplyCharge($charge);
$done_uri = $cart->getCheckoutURI();
return id(new AphrontRedirectResponse())->setURI($done_uri);
}
}
$cart_table = $this->buildCartContentTable($cart);
$cart_box = id(new PHUIObjectBoxView())->setFormErrors($errors)->setHeaderText(pht('Cart Contents'))->setTable($cart_table);
$title = $cart->getName();
if (!$methods) {
$method_control = id(new AphrontFormStaticControl())->setLabel(pht('Payment Method'))->setValue(phutil_tag('em', array(), pht('No payment methods configured.')));
} else {
$method_control = id(new AphrontFormRadioButtonControl())->setLabel(pht('Payment Method'))->setName('paymentMethodID')->setValue($request->getInt('paymentMethodID'));
foreach ($methods as $method) {
$method_control->addButton($method->getID(), $method->getFullDisplayName(), $method->getDescription());
}
}
$method_control->setError($e_method);
$account_id = $account->getID();
$payment_method_uri = $this->getApplicationURI("{$account_id}/card/new/");
$payment_method_uri = new PhutilURI($payment_method_uri);
$payment_method_uri->setQueryParams(array('merchantID' => $merchant->getID(), 'cartID' => $cart->getID()));
$form = id(new AphrontFormView())->setUser($viewer)->appendChild($method_control);
$add_providers = $this->loadCreatePaymentMethodProvidersForMerchant($merchant);
if ($add_providers) {
$new_method = javelin_tag('a', array('class' => 'button grey', 'href' => $payment_method_uri), pht('Add New Payment Method'));
$form->appendChild(id(new AphrontFormMarkupControl())->setValue($new_method));
}
if ($methods || $add_providers) {
$submit = id(new AphrontFormSubmitControl())->setValue(pht('Submit Payment'))->setDisabled(!$methods);
if ($cart->getCancelURI() !== null) {
$submit->addCancelButton($cart->getCancelURI());
}
$form->appendChild($submit);
}
$provider_form = null;
$pay_providers = $this->loadOneTimePaymentProvidersForMerchant($merchant);
if ($pay_providers) {
$one_time_options = array();
foreach ($pay_providers as $provider) {
$one_time_options[] = $provider->renderOneTimePaymentButton($account, $cart, $viewer);
}
$one_time_options = phutil_tag('div', array('class' => 'phortune-payment-onetime-list'), $one_time_options);
$provider_form = new PHUIFormLayoutView();
$provider_form->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Pay With'))->setValue($one_time_options));
}
$payment_box = id(new PHUIObjectBoxView())->setHeaderText(pht('Choose Payment Method'))->appendChild($form)->appendChild($provider_form);
$description_box = $this->renderCartDescription($cart);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Checkout'));
//.........这里部分代码省略.........
示例13: generateDiffusionURI
//.........这里部分代码省略.........
$branch = idx($params, 'branch');
$commit = idx($params, 'commit');
$line = idx($params, 'line');
if (strlen($callsign)) {
$callsign = phutil_escape_uri_path_component($callsign) . '/';
}
if (strlen($branch)) {
$branch = phutil_escape_uri_path_component($branch) . '/';
}
if (strlen($path)) {
$path = ltrim($path, '/');
$path = str_replace(array(';', '$'), array(';;', '$$'), $path);
$path = phutil_escape_uri($path);
}
$path = "{$branch}{$path}";
if (strlen($commit)) {
$commit = str_replace('$', '$$', $commit);
$commit = ';' . phutil_escape_uri($commit);
}
if (strlen($line)) {
$line = '$' . phutil_escape_uri($line);
}
$req_callsign = false;
$req_branch = false;
$req_commit = false;
switch ($action) {
case 'history':
case 'browse':
case 'change':
case 'lastmodified':
case 'tags':
case 'branches':
case 'lint':
case 'refs':
$req_callsign = true;
break;
case 'branch':
$req_callsign = true;
$req_branch = true;
break;
case 'commit':
$req_callsign = true;
$req_commit = true;
break;
}
if ($req_callsign && !strlen($callsign)) {
throw new Exception(pht("Diffusion URI action '%s' requires callsign!", $action));
}
if ($req_commit && !strlen($commit)) {
throw new Exception(pht("Diffusion URI action '%s' requires commit!", $action));
}
switch ($action) {
case 'change':
case 'history':
case 'browse':
case 'lastmodified':
case 'tags':
case 'branches':
case 'lint':
case 'pathtree':
case 'refs':
$uri = "/diffusion/{$callsign}{$action}/{$path}{$commit}{$line}";
break;
case 'branch':
if (strlen($path)) {
$uri = "/diffusion/{$callsign}repository/{$path}";
} else {
$uri = "/diffusion/{$callsign}";
}
break;
case 'external':
$commit = ltrim($commit, ';');
$uri = "/diffusion/external/{$commit}/";
break;
case 'rendering-ref':
// This isn't a real URI per se, it's passed as a query parameter to
// the ajax changeset stuff but then we parse it back out as though
// it came from a URI.
$uri = rawurldecode("{$path}{$commit}");
break;
case 'commit':
$commit = ltrim($commit, ';');
$callsign = rtrim($callsign, '/');
$uri = "/r{$callsign}{$commit}";
break;
default:
throw new Exception(pht("Unknown Diffusion URI action '%s'!", $action));
}
if ($action == 'rendering-ref') {
return $uri;
}
$uri = new PhutilURI($uri);
if (isset($params['lint'])) {
$params['params'] = idx($params, 'params', array()) + array('lint' => $params['lint']);
}
if (idx($params, 'params')) {
$uri->setQueryParams($params['params']);
}
return $uri;
}
示例14: newJIRAFuture
public function newJIRAFuture($path, $method, $params = array())
{
$uri = new PhutilURI($this->getJIRAURI($path));
if ($method == 'GET') {
$uri->setQueryParams($params);
$params = array();
} else {
// For other types of requests, JIRA expects the request body to be
// JSON encoded.
$params = json_encode($params);
}
// JIRA returns a 415 error if we don't provide a Content-Type header.
return $this->newOAuth1Future($uri, $params)->setMethod($method)->addHeader('Content-Type', 'application/json');
}
示例15: renderChangesetLink
private function renderChangesetLink(DifferentialChangeset $changeset)
{
$display_file = $changeset->getDisplayFilename();
if ($this->standaloneViewLink) {
$id = $changeset->getID();
$vs_id = idx($this->vsMap, $id);
$ref = $vs_id ? $id . '/' . $vs_id : $id;
$detail_uri = new PhutilURI($this->renderURI);
$detail_uri->setQueryParams(array('ref' => $ref, 'whitespace' => $this->whitespace, 'revision_id' => $this->revisionID));
return phutil_render_tag('a', array('href' => $detail_uri, 'target' => '_blank'), phutil_escape_html($display_file));
}
return phutil_render_tag('a', array('href' => '#' . $changeset->getAnchorName()), phutil_escape_html($display_file));
}