当前位置: 首页>>代码示例>>PHP>>正文


PHP HTTP::setGetVar方法代码示例

本文整理汇总了PHP中HTTP::setGetVar方法的典型用法代码示例。如果您正苦于以下问题:PHP HTTP::setGetVar方法的具体用法?PHP HTTP::setGetVar怎么用?PHP HTTP::setGetVar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HTTP的用法示例。


在下文中一共展示了HTTP::setGetVar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: index

 public function index(SS_HTTPRequest $request)
 {
     $properties = Property::get();
     $filters = ArrayList::create();
     if ($search = $request->getVar('Keywords')) {
         $filters->push(ArrayData::create(array('Label' => "Keywords: '{$search}'", 'RemoveLink' => HTTP::setGetVar('Keywords', null))));
         $properties = $properties->filter(array('Title:PartialMatch' => $search));
     }
     if ($arrival = $request->getVar('ArrivalDate')) {
         $arrivalStamp = strtotime($arrival);
         $nightAdder = '+' . $request->getVar('Nights') . ' days';
         $startDate = date('Y-m-d', $arrivalStamp);
         $endDate = date('Y-m-d', strtotime($nightAdder, $arrivalStamp));
         $properties = $properties->filter(array('AvailableStart:GreaterThanOrEqual' => $startDate, 'AvailableEnd:LessThanOrEqual' => $endDate));
     }
     if ($bedrooms = $request->getVar('Bedrooms')) {
         $filters->push(ArrayData::create(array('Label' => "{$bedrooms} bedrooms", 'RemoveLink' => HTTP::setGetVar('Bedrooms', null))));
         $properties = $properties->filter(array('Bedrooms:GreaterThanOrEqual' => $bedrooms));
     }
     if ($bathrooms = $request->getVar('Bathrooms')) {
         $filters->push(ArrayData::create(array('Label' => "{$bathrooms} bathrooms", 'RemoveLink' => HTTP::setGetVar('Bathrooms', null))));
         $properties = $properties->filter(array('Bathrooms:GreaterThanOrEqual' => $bathrooms));
     }
     if ($minPrice = $request->getVar('MinPrice')) {
         $filters->push(ArrayData::create(array('Label' => "Min. \${$minPrice}", 'RemoveLink' => HTTP::setGetVar('MinPrice', null))));
         $properties = $properties->filter(array('PricePerNight:GreaterThanOrEqual' => $minPrice));
     }
     if ($maxPrice = $request->getVar('MaxPrice')) {
         $filters->push(ArrayData::create(array('Label' => "Max. \${$maxPrice}", 'RemoveLink' => HTTP::setGetVar('MaxPrice', null))));
         $properties = $properties->filter(array('PricePerNight:LessThanOrEqual' => $maxPrice));
     }
     $paginatedProperties = PaginatedList::create($properties, $request)->setPageLength(15)->setPaginationGetVar('s');
     return array('Results' => $paginatedProperties, 'ActiveFilters' => $filters);
 }
开发者ID:roopamjain01,项目名称:one_ring,代码行数:34,代码来源:PropertySearchPage.php

示例2: EditLink

 public function EditLink($id)
 {
     if ($obj = $this->list->byID($id)) {
         if ($obj->canEdit(Member::currentUser())) {
             return HTTP::setGetVar($this->ID(), $id);
         }
     }
 }
开发者ID:helpfulrobot,项目名称:burnbright-silverstripe-listeditor,代码行数:8,代码来源:ListEditField.php

示例3: PageLengthLimits

 public function PageLengthLimits()
 {
     $lengths = func_get_args();
     $result = new ArrayList();
     foreach ($lengths as $length) {
         $result->push(new ArrayData(array('PageLength' => $length, 'Link' => HTTP::setGetVar($this->getPaginationGetVar(), 0, HTTP::setGetVar($this->getLengthGetVar(), $length, null, '&')), 'CurrentBool' => $this->getPageLength() == $length || $length == $this->unlimitedLengthText && $this->getPageLength() == $this->unlimitedLength)));
     }
     return $result;
 }
开发者ID:christopherbolt,项目名称:silverstripe-bolttools,代码行数:9,代码来源:LimitedPaginatedList.php

示例4: addObject

 /**
  * Adds metadata into the URL.
  *
  * @param $url string
  * @param $obj DataObject to inject
  *
  * @return string transformed URL.
  */
 public function addObject($url, DataObject $dataObject)
 {
     $updatedUrl = HTTP::setGetVar('_ID', $dataObject->ID, $url, '&');
     $updatedUrl = HTTP::setGetVar('_ClassName', $dataObject->ClassName, $updatedUrl, '&');
     // Hack: fix the HTTP::setGetVar removing leading slash from the URL if BaseURL is used.
     if (strpos($url, '/') === 0) {
         return '/' . $updatedUrl;
     } else {
         return $updatedUrl;
     }
 }
开发者ID:silverstripe-terraformers,项目名称:silverstripe-staticpublishqueue,代码行数:19,代码来源:URLArrayObject.php

示例5: products

 /**
  * Action: get list of products for base feed
  * @param SS_HTTPRequest $request
  * @return XML list of GoogleBase products
  */
 function products($request)
 {
     $limit = $request->getVar('limit') ? $request->getVar('limit') : false;
     if (!$limit) {
         $link = Director::absoluteURL(HTTP::setGetVar('limit', 1000));
         die('A Limit is required, please try again using something like: <a href="' . $link . '">' . $link . '</a>');
     }
     $products = $this->ProductList();
     if ($products && $products->Count() > 0) {
         $productsItems = PaginatedList::create($products, $request)->setPageLength($limit)->setPaginationGetVar('start');
         $data = array('FeedTitle' => SiteConfig::current_site_config()->Title, 'FeedLink' => Director::absoluteURL('/'), 'FeedDescription' => 'Google Base Feed', 'Products' => $productsItems);
         return $this->renderWith('GoogleBase', $data);
     }
 }
开发者ID:helpfulrobot,项目名称:tylerkidd-silverstripe-shop-google-base,代码行数:19,代码来源:GoogleBase.php

示例6: testSetGetVar

 /**
  * Tests {@link HTTP::setGetVar()}
  */
 public function testSetGetVar()
 {
     // Hackery to work around volatile URL formats in test invocation,
     // and the inability of Director::absoluteBaseURL() to produce consistent URLs.
     $origURI = $_SERVER['REQUEST_URI'];
     $_SERVER['REQUEST_URI'] = 'relative/url/';
     $this->assertContains('relative/url/?foo=bar', HTTP::setGetVar('foo', 'bar'), 'Omitting a URL falls back to current URL');
     $_SERVER['REQUEST_URI'] = $origURI;
     $this->assertEquals('relative/url?foo=bar', HTTP::setGetVar('foo', 'bar', 'relative/url'), 'Relative URL without existing query params');
     $this->assertEquals('relative/url?baz=buz&amp;foo=bar', HTTP::setGetVar('foo', 'bar', '/relative/url?baz=buz'), 'Relative URL with existing query params, and new added key');
     $this->assertEquals('http://test.com/?foo=new&amp;buz=baz', HTTP::setGetVar('foo', 'new', 'http://test.com/?foo=old&buz=baz'), 'Absolute URL without path and multipe existing query params, overwriting an existing parameter');
     $this->assertContains('http://test.com/?foo=new', HTTP::setGetVar('foo', 'new', 'http://test.com/?foo=&foo=old'), 'Absolute URL and empty query param');
     // http_build_query() escapes angular brackets, they should be correctly urldecoded by the browser client
     $this->assertEquals('http://test.com/?foo%5Btest%5D=one&amp;foo%5Btest%5D=two', HTTP::setGetVar('foo[test]', 'two', 'http://test.com/?foo[test]=one'), 'Absolute URL and PHP array query string notation');
     $urls = array('http://www.test.com:8080', 'http://test.com:3000/', 'http://test.com:3030/baz/', 'http://baz:foo@test.com', 'http://baz@test.com/', 'http://baz:foo@test.com:8080', 'http://baz@test.com:8080');
     foreach ($urls as $testURL) {
         $this->assertEquals($testURL . '?foo=bar', HTTP::setGetVar('foo', 'bar', $testURL), 'Absolute URL and Port Number');
     }
 }
开发者ID:fanggu,项目名称:loveyourwater_ss_v3.1.6,代码行数:22,代码来源:HTTPTest.php

示例7: results

 /**
  * Overrides the ContentControllerSearchExtension and adds snippets to results.
  */
 function results($data, $form, $request)
 {
     $this->linkToAllSiteRSSFeed();
     $results = $form->getResults();
     $query = $form->getSearchQuery();
     // Add context summaries based on the queries.
     foreach ($results as $result) {
         $contextualTitle = new Text();
         $contextualTitle->setValue($result->MenuTitle ? $result->MenuTitle : $result->Title);
         $result->ContextualTitle = $contextualTitle->ContextSummary(300, $query);
         if (!$result->Content && $result->ClassName == 'File') {
             // Fake some content for the files.
             $result->ContextualContent = "A file named \"{$result->Name}\" ({$result->Size}).";
         } else {
             $result->ContextualContent = $result->obj('Content')->ContextSummary(300, $query);
         }
     }
     $rssLink = HTTP::setGetVar('rss', '1');
     // Render the result.
     $data = array('Results' => $results, 'Query' => $query, 'Title' => _t('SearchForm.SearchResults', 'Search Results'), 'RSSLink' => $rssLink);
     // Choose the delivery method - rss or html.
     if (!$this->owner->request->getVar('rss')) {
         // Add RSS feed to normal search.
         RSSFeed::linkToFeed($rssLink, "Search results for query \"{$query}\".");
         return $this->owner->customise($data)->renderWith(array('Page_results', 'Page'));
     } else {
         // De-paginate and reorder. Sort-by-relevancy doesn't make sense in RSS context.
         $fullList = $results->getList()->sort('LastEdited', 'DESC');
         // Get some descriptive strings
         $siteName = SiteConfig::current_site_config()->Title;
         $siteTagline = SiteConfig::current_site_config()->Tagline;
         if ($siteName) {
             $title = "{$siteName} search results for query \"{$query}\".";
         } else {
             $title = "Search results for query \"{$query}\".";
         }
         // Generate the feed content.
         $rss = new RSSFeed($fullList, $this->owner->request->getURL(), $title, $siteTagline, "Title", "ContextualContent", null);
         $rss->setTemplate('Page_results_rss');
         return $rss->outputToBrowser();
     }
 }
开发者ID:helpfulrobot,项目名称:gdmedia-silverstripe-gdm-express,代码行数:45,代码来源:ExpressHomePage.php

示例8: doChangePassword

 /**
  * Change the password
  *
  * @param array $data The user submitted data
  */
 function doChangePassword(array $data)
 {
     if ($member = Member::currentUser()) {
         // The user was logged in, check the current password
         if (isset($data['OldPassword']) && $member->checkPassword($data['OldPassword']) == false) {
             $this->clearMessage();
             $this->sessionMessage(_t('Member.ERRORPASSWORDNOTMATCH', "Your current password does not match, please try again"), "bad");
             Director::redirectBack();
             return;
         }
     }
     if (!$member) {
         if (Session::get('AutoLoginHash')) {
             $member = Member::member_from_autologinhash(Session::get('AutoLoginHash'));
         }
         // The user is not logged in and no valid auto login hash is available
         if (!$member) {
             Session::clear('AutoLoginHash');
             Director::redirect('loginpage');
             return;
         }
     }
     // Check the new password
     if ($data['NewPassword1'] == $data['NewPassword2']) {
         $isValid = $member->changePassword($data['NewPassword1']);
         if ($isValid->valid()) {
             $this->clearMessage();
             $this->sessionMessage(_t('Member.PASSWORDCHANGED', "Your password has been changed, and a copy emailed to you."), "good");
             Session::clear('AutoLoginHash');
             $redirectURL = HTTP::setGetVar('BackURL', urlencode(Director::absoluteBaseURL()), Security::Link('login'));
             Director::redirect($redirectURL);
         } else {
             $this->clearMessage();
             $this->sessionMessage(nl2br("We couldn't accept that password:\n" . $isValid->starredList()), "bad");
             Director::redirectBack();
         }
     } else {
         $this->clearMessage();
         $this->sessionMessage(_t('Member.ERRORNEWPASSWORD', "Your have entered your new password differently, try again"), "bad");
         Director::redirectBack();
     }
 }
开发者ID:racontemoi,项目名称:shibuichi,代码行数:47,代码来源:ChangePasswordForm.php

示例9: send

 /**
  * @param mixed $subject
  * @throws EntityValidationException
  * @throws NotFoundEntityException
  */
 public function send($subject)
 {
     if (!is_array($subject)) {
         return;
     }
     if (!isset($subject['Summit']) || !isset($subject['Speaker'])) {
         return;
     }
     $summit = $subject['Summit'];
     $speaker = $subject['Speaker'];
     if (!$speaker instanceof IPresentationSpeaker) {
         return;
     }
     if (!$summit instanceof ISummit) {
         return;
     }
     if (!$speaker->hasPendingRegistrationRequest()) {
         throw new EntityValidationException('speaker not has a pending registration request!');
     }
     $email = PermamailTemplate::get()->filter('Identifier', PRESENTATION_SPEAKER_CREATE_MEMBERSHIP_EMAIL)->first();
     if (is_null($email)) {
         throw new NotFoundEntityException(sprintf('Email Template %s does not exists on DB!', PRESENTATION_SPEAKER_CREATE_MEMBERSHIP_EMAIL));
     }
     $schedule_page = SummitAppSchedPage::get()->filter('SummitID', $summit->getIdentifier())->first();
     if (is_null($schedule_page)) {
         throw new NotFoundEntityException('Summit Schedule page does not exists!');
     }
     // reset token ...
     $registration_request = $speaker->RegistrationRequest();
     $token = $registration_request->generateConfirmationToken();
     $registration_request->write();
     $registration_url = Controller::join_links(Director::baseURL(), 'summit-login', 'registration');
     $registration_url = HTTP::setGetVar(SpeakerRegistrationRequest::ConfirmationTokenParamName, $token, $registration_url);
     $speaker->registerCreateMembershipSent();
     $email = EmailFactory::getInstance()->buildEmail(null, $speaker->getEmail());
     $email->setUserTemplate(PRESENTATION_SPEAKER_CREATE_MEMBERSHIP_EMAIL)->populateTemplate(array('Speaker' => $speaker, 'Summit' => $summit, 'RegistrationUrl' => $registration_url))->send();
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:42,代码来源:PresentationSpeakerNonRegisteredEmailSender.php

示例10: getUrl

 /**
  * returns the URL of the page with a specific
  * index
  * @param int $page
  * @return String
  */
 public function getUrl($page)
 {
     return HTTP::setGetVar($this->paginatedList->getPaginationGetVar(), ($page - 1) * $this->paginatedList->getPageLength());
 }
开发者ID:tom-alexander,项目名称:silverstripe-api,代码行数:10,代码来源:PaginatedListPaginatorAdapter.php

示例11: alternatePreviewLink

 /**
  * Use the CMS domain for iframed CMS previews to prevent single-origin violations
  * and SSL cert problems.
  */
 public function alternatePreviewLink($action = null)
 {
     $url = Director::absoluteURL($this->owner->Link());
     if ($this->owner->SubsiteID) {
         $url = HTTP::setGetVar('SubsiteID', $this->owner->SubsiteID, $url);
     }
     return $url;
 }
开发者ID:mikenz,项目名称:silverstripe-simplesubsites,代码行数:12,代码来源:SiteTreeSubsites.php

示例12: postRequest

 /**
  *	Attempt to redirect towards the highest priority link mapping that may have been defined.
  *
  *	@URLparameter direct <{BYPASS_LINK_MAPPINGS}> boolean
  */
 public function postRequest(SS_HTTPRequest $request, SS_HTTPResponse $response, DataModel $model)
 {
     // Bypass the request filter when requesting specific director rules such as "/admin" or "/dev".
     $requestURL = $request->getURL();
     $configuration = Config::inst();
     foreach ($configuration->get('Director', 'rules') as $segment => $controller) {
         // Retrieve the specific director rules.
         if (($position = strpos($segment, '$')) !== false) {
             $segment = rtrim(substr($segment, 0, $position), '/');
         }
         // Determine if the current request matches a specific director rule.
         if ($segment && strpos($requestURL, $segment) === 0) {
             // Continue processing the response.
             return true;
         }
     }
     // Bypass the request filter when using the direct GET parameter.
     if ($request->getVar('direct')) {
         // Continue processing the response.
         return true;
     }
     // Determine the default automated URL handling response status.
     $status = $response->getStatusCode();
     $success = $status >= 200 && $status < 300;
     $error = $status === 404;
     // Either hook into a page not found, or when enforced, replace the default automated URL handling.
     $enforce = $configuration->get('MisdirectionRequestFilter', 'enforce_misdirection');
     $replace = $configuration->get('MisdirectionRequestFilter', 'replace_default');
     if (($error || $enforce || $replace) && ($map = $this->service->getMappingByRequest($request))) {
         // Update the response code where appropriate.
         $responseCode = $map->ResponseCode;
         if ($responseCode == 0) {
             $responseCode = 303;
         } else {
             if ($responseCode == 301 && $map->ForwardPOSTRequest) {
                 $responseCode = 308;
             } else {
                 if ($responseCode == 303 && $map->ForwardPOSTRequest) {
                     $responseCode = 307;
                 }
             }
         }
         // Update the response using the link mapping redirection.
         $response->redirect($map->getLink(), $responseCode);
     } else {
         if ($error && ($fallback = $this->service->determineFallback($requestURL))) {
             // Update the response code where appropriate.
             $responseCode = $fallback['code'];
             if ($responseCode === 0) {
                 $responseCode = 303;
             }
             // Update the response using the fallback, enforcing no further redirection.
             $response->redirect(HTTP::setGetVar('direct', true, Controller::join_links(Director::absoluteBaseURL(), $fallback['link'])), $responseCode);
         } else {
             if (!$error && !$success && $replace) {
                 $response->setStatusCode(404);
                 // Retrieve the appropriate page not found response.
                 ClassInfo::exists('SiteTree') && ($page = ErrorPage::response_for(404)) ? $response->setBody($page->getBody()) : $response->setBody('No URL was matched!');
             }
         }
     }
     // Continue processing the response.
     return true;
 }
开发者ID:helpfulrobot,项目名称:nglasl-silverstripe-misdirection,代码行数:69,代码来源:MisdirectionRequestFilter.php

示例13: dateFilter

 /**
  *	Request media page children from the filtered date.
  */
 public function dateFilter()
 {
     // Apply the from date filter.
     $request = $this->getRequest();
     $from = $request->getVar('from');
     $link = $this->Link();
     $separator = '?';
     if ($from) {
         // Determine the formatted URL to represent the request filter.
         $date = new DateTime($from);
         $link .= $date->Format('Y/m/d/');
     }
     // Preserve the category/tag filters if they exist.
     $category = $request->getVar('category');
     $tag = $request->getVar('tag');
     if ($category) {
         $link = HTTP::setGetVar('category', $category, $link, $separator);
         $separator = '&';
     }
     if ($tag) {
         $link = HTTP::setGetVar('tag', $tag, $link, $separator);
     }
     // Allow extension customisation.
     $this->extend('updateFilter', $link);
     // Request the filtered paginated children.
     return $this->redirect($link);
 }
开发者ID:helpfulrobot,项目名称:nglasl-silverstripe-mediawesome,代码行数:30,代码来源:MediaHolder.php

示例14: PopupBaseLink

 /**
  * #################################
  *           Pagination
  * #################################
  */
 function PopupBaseLink()
 {
     $link = $this->FormAction() . "&action_callfieldmethod&fieldName={$this->Name()}";
     if (!strpos($link, 'ctf[ID]')) {
         $link = str_replace('&amp;', '&', HTTP::setGetVar('ctf[ID]', $this->sourceID(), $link));
     }
     return $link;
 }
开发者ID:ramziammar,项目名称:websites,代码行数:13,代码来源:ComplexTableField.php

示例15: BaseLink

 function BaseLink()
 {
     $link = $this->FormAction() . "&action_callfieldmethod&fieldName={$this->Name()}&ctf[ID]={$this->sourceID()}&methodName=ajax_refresh&SecurityID=" . Session::get('SecurityID');
     if (isset($_REQUEST['ctf'][$this->Name()]['sort'])) {
         $link = HTTP::setGetVar("ctf[{$this->Name()}][sort]", $_REQUEST['ctf'][$this->Name()]['sort']);
     }
     if (isset($_REQUEST['ctf'][$this->Name()]['dir'])) {
         $link = HTTP::setGetVar("ctf[{$this->Name()}][dir]", $_REQUEST['ctf'][$this->Name()]['dir']);
     }
     return str_replace('&amp;', '&', $link);
 }
开发者ID:ramziammar,项目名称:websites,代码行数:11,代码来源:TableListField.php


注:本文中的HTTP::setGetVar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。