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


PHP RequestInterface::getQueryParameters方法代码示例

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


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

示例1: httpGet

 /**
  * Intercepts GET requests on addressbook urls ending with ?export.
  *
  * @param RequestInterface $request
  * @param ResponseInterface $response
  * @return bool
  */
 function httpGet(RequestInterface $request, ResponseInterface $response)
 {
     $queryParams = $request->getQueryParameters();
     if (!array_key_exists('export', $queryParams)) {
         return;
     }
     $path = $request->getPath();
     $node = $this->server->tree->getNodeForPath($path);
     if (!$node instanceof IAddressBook) {
         return;
     }
     $this->server->transactionType = 'get-addressbook-export';
     // Checking ACL, if available.
     if ($aclPlugin = $this->server->getPlugin('acl')) {
         $aclPlugin->checkPrivileges($path, '{DAV:}read');
     }
     $nodes = $this->server->getPropertiesForPath($path, ['{' . Plugin::NS_CARDDAV . '}address-data'], 1);
     $format = 'text/directory';
     $output = null;
     $filenameExtension = null;
     switch ($format) {
         case 'text/directory':
             $output = $this->generateVCF($nodes);
             $filenameExtension = '.vcf';
             break;
     }
     $filename = preg_replace('/[^a-zA-Z0-9-_ ]/um', '', $node->getName());
     $filename .= '-' . date('Y-m-d') . $filenameExtension;
     $response->setHeader('Content-Disposition', 'attachment; filename="' . $filename . '"');
     $response->setHeader('Content-Type', $format);
     $response->setStatus(200);
     $response->setBody($output);
     // Returning false to break the event chain
     return false;
 }
开发者ID:BlaBlaNet,项目名称:hubzilla,代码行数:42,代码来源:VCFExportPlugin.php

示例2: httpGet

 /**
  * Intercepts GET requests on addressbook urls ending with ?photo.
  *
  * @param RequestInterface $request
  * @param ResponseInterface $response
  * @return bool|void
  */
 function httpGet(RequestInterface $request, ResponseInterface $response)
 {
     $queryParams = $request->getQueryParameters();
     // TODO: in addition to photo we should also add logo some point in time
     if (!array_key_exists('photo', $queryParams)) {
         return true;
     }
     $path = $request->getPath();
     $node = $this->server->tree->getNodeForPath($path);
     if (!$node instanceof Card) {
         return true;
     }
     $this->server->transactionType = 'carddav-image-export';
     // Checking ACL, if available.
     if ($aclPlugin = $this->server->getPlugin('acl')) {
         /** @var \Sabre\DAVACL\Plugin $aclPlugin */
         $aclPlugin->checkPrivileges($path, '{DAV:}read');
     }
     if ($result = $this->getPhoto($node)) {
         $response->setHeader('Content-Type', $result['Content-Type']);
         $response->setStatus(200);
         $response->setBody($result['body']);
         // Returning false to break the event chain
         return false;
     }
     return true;
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:34,代码来源:ImageExportPlugin.php

示例3: httpGet

 /**
  * Intercepts GET requests on calendar urls ending with ?export.
  *
  * @param RequestInterface $request
  * @param ResponseInterface $response
  * @return bool
  */
 function httpGet(RequestInterface $request, ResponseInterface $response)
 {
     $queryParams = $request->getQueryParameters();
     if (!array_key_exists('export', $queryParams)) {
         return;
     }
     $path = $request->getPath();
     $node = $this->server->getProperties($path, ['{DAV:}resourcetype', '{DAV:}displayname', '{http://sabredav.org/ns}sync-token', '{DAV:}sync-token', '{http://apple.com/ns/ical/}calendar-color']);
     if (!isset($node['{DAV:}resourcetype']) || !$node['{DAV:}resourcetype']->is('{' . Plugin::NS_CALDAV . '}calendar')) {
         return;
     }
     // Marking the transactionType, for logging purposes.
     $this->server->transactionType = 'get-calendar-export';
     $properties = $node;
     $start = null;
     $end = null;
     $expand = false;
     $componentType = false;
     if (isset($queryParams['start'])) {
         if (!ctype_digit($queryParams['start'])) {
             throw new BadRequest('The start= parameter must contain a unix timestamp');
         }
         $start = DateTime::createFromFormat('U', $queryParams['start']);
     }
     if (isset($queryParams['end'])) {
         if (!ctype_digit($queryParams['end'])) {
             throw new BadRequest('The end= parameter must contain a unix timestamp');
         }
         $end = DateTime::createFromFormat('U', $queryParams['end']);
     }
     if (isset($queryParams['expand']) && !!$queryParams['expand']) {
         if (!$start || !$end) {
             throw new BadRequest('If you\'d like to expand recurrences, you must specify both a start= and end= parameter.');
         }
         $expand = true;
         $componentType = 'VEVENT';
     }
     if (isset($queryParams['componentType'])) {
         if (!in_array($queryParams['componentType'], ['VEVENT', 'VTODO', 'VJOURNAL'])) {
             throw new BadRequest('You are not allowed to search for components of type: ' . $queryParams['componentType'] . ' here');
         }
         $componentType = $queryParams['componentType'];
     }
     $format = \Sabre\HTTP\Util::Negotiate($request->getHeader('Accept'), ['text/calendar', 'application/calendar+json']);
     if (isset($queryParams['accept'])) {
         if ($queryParams['accept'] === 'application/calendar+json' || $queryParams['accept'] === 'jcal') {
             $format = 'application/calendar+json';
         }
     }
     if (!$format) {
         $format = 'text/calendar';
     }
     $this->generateResponse($path, $start, $end, $expand, $componentType, $format, $properties, $response);
     // Returning false to break the event chain
     return false;
 }
开发者ID:pageer,项目名称:sabre-dav,代码行数:63,代码来源:ICSExportPlugin.php

示例4: httpGet

 /**
  * 'beforeMethod' event handles. This event handles intercepts GET requests ending
  * with ?mount
  *
  * @param RequestInterface $request
  * @param ResponseInterface $response
  * @return bool
  */
 function httpGet(RequestInterface $request, ResponseInterface $response)
 {
     $queryParams = $request->getQueryParameters();
     if (!array_key_exists('mount', $queryParams)) {
         return;
     }
     $currentUri = $request->getAbsoluteUrl();
     // Stripping off everything after the ?
     list($currentUri) = explode('?', $currentUri);
     $this->davMount($response, $currentUri);
     // Returning false to break the event chain
     return false;
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:21,代码来源:Plugin.php

示例5: httpGet

 /**
  * Intercepts GET requests on addressbook urls ending with ?export.
  *
  * @param RequestInterface $request
  * @param ResponseInterface $response
  * @return bool
  */
 function httpGet(RequestInterface $request, ResponseInterface $response)
 {
     $queryParams = $request->getQueryParameters();
     if (!array_key_exists('export', $queryParams)) {
         return;
     }
     $path = $request->getPath();
     $node = $this->server->tree->getNodeForPath($path);
     if (!$node instanceof IAddressBook) {
         return;
     }
     $this->server->transactionType = 'get-addressbook-export';
     // Checking ACL, if available.
     if ($aclPlugin = $this->server->getPlugin('acl')) {
         $aclPlugin->checkPrivileges($path, '{DAV:}read');
     }
     $response->setHeader('Content-Type', 'text/directory');
     $response->setStatus(200);
     $nodes = $this->server->getPropertiesForPath($path, ['{' . Plugin::NS_CARDDAV . '}address-data'], 1);
     $response->setBody($this->generateVCF($nodes));
     // Returning false to break the event chain
     return false;
 }
开发者ID:bogolubov,项目名称:owncollab_talks-1,代码行数:30,代码来源:VCFExportPlugin.php

示例6: httpGet

 /**
  * This method intercepts GET requests to collections and returns the html
  *
  * @param RequestInterface $request
  * @param ResponseInterface $response
  * @return bool
  */
 function httpGet(RequestInterface $request, ResponseInterface $response)
 {
     // We're not using straight-up $_GET, because we want everything to be
     // unit testable.
     $getVars = $request->getQueryParameters();
     $sabreAction = isset($getVars['sabreAction']) ? $getVars['sabreAction'] : null;
     // Asset handling, such as images
     if ($sabreAction === 'asset' && isset($getVars['assetName'])) {
         $this->serveAsset($getVars['assetName']);
         return false;
     }
     try {
         $this->server->tree->getNodeForPath($request->getPath());
     } catch (DAV\Exception\NotFound $e) {
         // We're simply stopping when the file isn't found to not interfere
         // with other plugins.
         return;
     }
     $response->setStatus(200);
     $response->setHeader('Content-Type', 'text/html; charset=utf-8');
     $response->setBody($this->generateDirectoryIndex($request->getPath()));
     return false;
 }
开发者ID:LobbyOS,项目名称:server,代码行数:30,代码来源:Plugin.php

示例7: handleDownloadToken

 /**
  * This sets a cookie to be able to recognize the start of the download
  * the content must not be longer than 32 characters and must only contain
  * alphanumeric characters
  *
  * @param RequestInterface $request
  * @param ResponseInterface $response
  */
 function handleDownloadToken(RequestInterface $request, ResponseInterface $response)
 {
     $queryParams = $request->getQueryParameters();
     /**
      * this sets a cookie to be able to recognize the start of the download
      * the content must not be longer than 32 characters and must only contain
      * alphanumeric characters
      */
     if (isset($queryParams['downloadStartSecret'])) {
         $token = $queryParams['downloadStartSecret'];
         if (!isset($token[32]) && preg_match('!^[a-zA-Z0-9]+$!', $token) === 1) {
             // FIXME: use $response->setHeader() instead
             setcookie('ocDownloadStarted', $token, time() + 20, '/');
         }
     }
 }
开发者ID:robinkanters,项目名称:core,代码行数:24,代码来源:filesplugin.php

示例8: httpGet

 /**
  * This method intercepts GET requests to collections and returns the html
  *
  * @param RequestInterface $request
  * @param ResponseInterface $response
  * @return bool
  */
 function httpGet(RequestInterface $request, ResponseInterface $response)
 {
     // We're not using straight-up $_GET, because we want everything to be
     // unit testable.
     $getVars = $request->getQueryParameters();
     // CSP headers
     $this->server->httpResponse->setHeader('Content-Security-Policy', "img-src 'self'; style-src 'self';");
     $sabreAction = isset($getVars['sabreAction']) ? $getVars['sabreAction'] : null;
     switch ($sabreAction) {
         case 'asset':
             // Asset handling, such as images
             $this->serveAsset(isset($getVars['assetName']) ? $getVars['assetName'] : null);
             return false;
         default:
         case 'info':
             try {
                 $this->server->tree->getNodeForPath($request->getPath());
             } catch (DAV\Exception\NotFound $e) {
                 // We're simply stopping when the file isn't found to not interfere
                 // with other plugins.
                 return;
             }
             $response->setStatus(200);
             $response->setHeader('Content-Type', 'text/html; charset=utf-8');
             $response->setBody($this->generateDirectoryIndex($request->getPath()));
             return false;
         case 'plugins':
             $response->setStatus(200);
             $response->setHeader('Content-Type', 'text/html; charset=utf-8');
             $response->setBody($this->generatePluginListing());
             return false;
     }
 }
开发者ID:pageer,项目名称:sabre-dav,代码行数:40,代码来源:Plugin.php

示例9: httpGet

 /**
  * Compute an HTTP GET method.
  *
  * @param  Request   $request     HTTP request.
  * @param  Response  $response    HTTP response.
  * @return bool
  * @throws Exception\Dav\Exception
  */
 function httpGet(Request $request, Response $response)
 {
     if (System\Collection::NAME . '/' . Node::NAME !== $request->getPath()) {
         return;
     }
     $queries = $request->getQueryParameters();
     if (isset($queries['test']) && 'mail' === $queries['test'] && isset($queries['payload'])) {
         $payload = @json_decode($queries['payload']);
         if (!$payload || !isset($payload->transport) || !isset($payload->username) || !isset($payload->password)) {
             throw new Exception\Dav\Exception('Payload is corrupted.');
         }
         Mail\Message::setDefaultTransport(new Mail\Transport\Smtp(new Socket\Client('tcp://' . $payload->transport), $payload->username, $payload->password));
         $message = new Mail\Message();
         $message['from'] = 'sabre/katana <' . $payload->username . '>';
         $message['to'] = $payload->username;
         $message['subject'] = 'Test mail from sabre/katana';
         $message->addContent(new Mail\Content\Text('Hey!' . "\n\n" . 'If you receive this email, it means that your ' . 'sabre/katana server is able to send emails! ' . "\n\n" . 'Congratulations :-).'));
         $message->send();
         $response->setHeader('Content-Type', 'application/json');
         $response->setBody(json_encode(true));
         return false;
     }
     $configuration = ['database' => ['dsn' => $this->configuration->database->dsn, 'username' => $this->configuration->database->username], 'mail' => ['address' => '', 'port' => '', 'username' => '', 'password' => '']];
     if (isset($this->configuration->mail)) {
         $socket = new Socket('tcp://' . $this->configuration->mail->transport);
         $configuration['mail']['address'] = $socket->getAddress();
         $configuration['mail']['port'] = $socket->hasPort() ? $socket->getPort() : 587;
         $configuration['mail']['username'] = $this->configuration->mail->username;
         $configuration['mail']['password'] = $this->configuration->mail->password;
         unset($socket);
     }
     $response->setHeader('Content-Type', 'application/json');
     $response->setBody(json_encode($configuration));
     return false;
 }
开发者ID:lkraav,项目名称:sabre-katana,代码行数:43,代码来源:Plugin.php


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