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


PHP SS_HTTPRequest类代码示例

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


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

示例1: getHTTPRequest

 protected function getHTTPRequest($method = 'GET', $class = 'ApiTest_Book', $id = '', $params = array())
 {
     $request = new SS_HTTPRequest($method, 'api/' . $class . '/' . $id, $params);
     $request->match($this->url_pattern);
     $request->setRouteParams(array('Controller' => 'RESTfulAPI'));
     return $request;
 }
开发者ID:8secs,项目名称:cocina,代码行数:7,代码来源:RESTfulAPI_DefaultQueryHandler_Test.php

示例2: show

 public function show(SS_HTTPRequest $request)
 {
     $root = $this->readFolder($this->Folder);
     $folderPath = "";
     if (is_null($request->param('Action'))) {
         $folder = $root;
     } else {
         foreach ($request->latestParams() as $param) {
             if (!is_null($param)) {
                 $folderPath .= "/" . $param;
             }
         }
         $folder = $this->readFolder($folderPath);
     }
     if (class_exists("BreadcrumbNavigation") && isset($folder)) {
         $parentFolders = explode("/", $folderPath);
         $parents = array_reverse($folder->parentStack());
         for ($i = 1; $i < count($parents); $i++) {
             $parents[$i]->markExpanded();
             $parents[$i]->markOpened();
             if ($i > 0) {
                 $do = new DataObject();
                 $do->Link = $parents[$i]->AbsoluteLink();
                 $do->MenuTitle = $parents[$i]->MenuTitle();
                 if ($i == count($parents) - 1) {
                     $do->isSelf = true;
                 }
                 $this->owner->AddBreadcrumbAfter($do);
             }
         }
         $this->MetaTitle = "Gallery: " . $parents[count($parents) - 1]->MenuTitle();
     }
     return $this->customise(array('Content' => $this->customise(array('RootFolder' => $root, 'CurrentFolder' => $folder))->renderWith('AssetsGalleryMain', 'Page'), 'Form' => ''));
 }
开发者ID:helpfulrobot,项目名称:exadium-silverstripe-module-assets-gallery,代码行数:34,代码来源:AssetsGallery.php

示例3: handleRequest

 public function handleRequest(SS_HTTPRequest $request, DataModel $model)
 {
     if (!$request) {
         user_error("Controller::handleRequest() not passed a request!", E_USER_ERROR);
     }
     $this->urlParams = $request->allParams();
     $this->request = $request;
     $this->setDataModel($model);
     // Find our action or set to index if not found
     $action = $this->request->param("Action");
     if (!$action) {
         $action = "index";
     }
     $result = $this->{$action}($request);
     // Try to determine what response we are dealing with
     if ($result instanceof SS_HTTPResponse) {
         $this->response = $result;
     } else {
         $this->response = new SS_HTTPResponse();
         $this->response->setBody($result);
     }
     // If we had a redirection or something, halt processing.
     if ($this->response->isFinished()) {
         return $this->response;
     }
     ContentNegotiator::process($this->response);
     HTTP::add_cache_headers($this->response);
     return $this->response;
 }
开发者ID:i-lateral,项目名称:silverstripe-checkout,代码行数:29,代码来源:PaymentHandler.php

示例4: index

 public function index(SS_HTTPRequest $request)
 {
     if ($request->isPOST()) {
         $update = json_decode($request->getBody());
         $joblog = TranscodeJob::get()->filter('JobID', (int) $update->id)->first();
         // return if status already is done (some protection)
         if ($joblog->JobStatus !== "started") {
             return "Error: job status not started";
         }
         // save full update into log object -- no, may contain passwords etc. -- well, fixed but still...
         //format_id
         // load files into appropriate relations
         $transcodable = $joblog->Transcodable();
         $transcodable->loadTranscodedFiles();
         if (count(get_object_vars($update->errors))) {
             $joblog->JobErrorMessage = json_encode($update->errors);
             $joblog->JobStatus = "error";
         } else {
             if ($transcodable->transcodingComplete()) {
                 // set status to done when complete...
                 $joblog->JobErrorMessage = "";
                 $joblog->JobStatus = "done";
             }
         }
         // write logfile
         $joblog->write();
     } else {
         // this shouldn't happen
         return "Well hello there...";
     }
     return "Updated";
 }
开发者ID:helpfulrobot,项目名称:micschk-silverstripe-html5-media,代码行数:32,代码来源:Transcode_Controller.php

示例5: run

 /**
  * 
  * @param SS_HTTPRequest $request
  */
 public function run($request)
 {
     increase_time_limit_to();
     echo 'Pass ?refresh=1 to refresh your members<br/>';
     echo '<hr/>';
     $refresh = $request->getVar('refresh');
     if ($refresh) {
         DB::alteration_message("Resetting all members location");
         DB::query('UPDATE Member SET Latitude = 0, Longitude = 0');
     }
     $Members = Member::get()->filter(array('Latitude' => 0));
     foreach ($Members as $Member) {
         DB::alteration_message('Processing member #' . $Member->ID . ' - ' . $Member->getTitle());
         if (!$Member->Latitude) {
             if ($Member->canBeGeolocalized()) {
                 DB::alteration_message($Member->GeocodeText());
                 if (!$Member->CountryCode) {
                     DB::alteration_message("Warning ! This member has no country code", "error");
                 }
                 /* @var $res Geocoder\Model\Address */
                 $res = $Member->Geocode();
                 if ($res) {
                     DB::alteration_message('Geocode success on ' . $res->getLatitude() . ',' . $res->getLongitude() . ' : ' . $res->getStreetNumber() . ', ' . $res->getStreetName() . ' ' . $res->getPostalCode() . ' ' . $res->getLocality() . ' ' . $res->getCountry(), 'created');
                     $Member->write();
                 } else {
                     DB::alteration_message('Geocode error', 'error');
                 }
             } else {
                 DB::alteration_message('Cannot be geolocalized', 'error');
             }
         } else {
             DB::alteration_message('Already geolocalized', 'error');
         }
     }
 }
开发者ID:lekoala,项目名称:silverstripe-geotools,代码行数:39,代码来源:GeolocateAllMembersTask.php

示例6: testIndex

    public function testIndex()
    {
        $logger = $this->getMock('Psr\\Log\\LoggerInterface');
        $logger->expects($this->once())->method('info');
        $controller = new Controller($logger);
        $prop = new \ReflectionProperty(__NAMESPACE__ . '\\Controller', 'response');
        $prop->setAccessible(true);
        $prop->setValue($controller, new \SS_HTTPResponse());
        $req = new \SS_HTTPRequest('GET', '/');
        $req->setBody(<<<JSON
{
  "csp-report": {
    "document-uri": "http://example.com/signup.html",
    "referrer": "",
    "blocked-uri": "http://example.com/css/style.css",
    "violated-directive": "style-src cdn.example.com",
    "original-policy": "default-src 'none'; style-src cdn.example.com; report-uri /_/csp-reports"
  }
}
JSON
);
        $response = $controller->index($req);
        $this->assertEquals(204, $response->getStatusCode());
        $this->assertEquals('', $response->getBody());
    }
开发者ID:helpfulrobot,项目名称:camspiers-silverstripe-csp-logging,代码行数:25,代码来源:ControllerTest.php

示例7: downloads

 /**
  * This may need to be optimised. We'll just have to see how it performs.
  *
  * @param SS_HTTPRequest $req
  * @return array
  */
 public function downloads(SS_HTTPRequest $req)
 {
     $downloads = new ArrayList();
     $member = Member::currentUser();
     if (!$member || !$member->exists()) {
         $this->httpError(401);
     }
     // create a dropdown for sorting
     $sortOptions = Config::inst()->get('DownloadableAccountPageController', 'sort_options');
     if ($sortOptions) {
         $sort = $req->requestVar('sort');
         if (empty($sort)) {
             reset($sortOptions);
             $sort = key($sortOptions);
         }
         $sortControl = new DropdownField('download-sort', 'Sort By:', $sortOptions, $sort);
     } else {
         $sort = 'PurchaseDate';
         $sortControl = '';
     }
     // create a list of downloads
     $orders = $member->getPastOrders();
     if (!empty($orders)) {
         foreach ($orders as $order) {
             if ($order->DownloadsAvailable()) {
                 $downloads->merge($order->getDownloads());
             }
         }
     }
     Requirements::javascript(SHOP_DOWNLOADABLE_FOLDER . '/javascript/AccountPage_downloads.js');
     return array('Title' => 'Digital Purchases', 'Content' => '', 'SortControl' => $sortControl, 'HasDownloads' => $downloads->count() > 0, 'Downloads' => $downloads->sort($sort));
 }
开发者ID:helpfulrobot,项目名称:markguinn-silverstripe-shop-downloadable,代码行数:38,代码来源:DownloadableAccountPageController.php

示例8: getDefault

 protected static function getDefault(SS_HTTPRequest $request, $var, $default)
 {
     if ($value = $request->getVar($var)) {
         return $value;
     }
     return $default;
 }
开发者ID:helpfulrobot,项目名称:tom-alexander-silverstripe-griddle,代码行数:7,代码来源:GriddleField.php

示例9: 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();
     }
 }
开发者ID:tom-alexander,项目名称:silverstripe-api,代码行数:13,代码来源:ApiController.php

示例10: run

 /**
  * @param SS_HTTPRequest $request
  */
 public function run($request)
 {
     /** =========================================
          * @var Page $page
         ===========================================*/
     if (class_exists('Page')) {
         if (Page::has_extension('TwitterCardMeta')) {
             // Should we overwrite?
             $overwrite = $request->getVar('overwrite') ? true : false;
             echo sprintf('Overwrite is %s', $overwrite ? 'enabled' : 'disabled') . $this->eol . $this->eol;
             $pages = Page::get();
             foreach ($pages as $page) {
                 $id = $page->ID;
                 echo $this->hr;
                 echo 'Updating page: ' . $page->Title . $this->eol;
                 foreach ($this->fields_to_update as $fieldName) {
                     $oldData = DB::query("SELECT {$fieldName} FROM Page WHERE ID = {$id}")->column($fieldName);
                     $newData = DB::query("SELECT {$fieldName} FROM SiteTree WHERE ID = {$id}")->column($fieldName);
                     if (!empty($oldData)) {
                         // If new data has been saved and we don't want to overwrite, exit the loop
                         if (!empty($newData) && $overwrite === false) {
                             continue;
                         }
                         DB::query("UPDATE SiteTree SET {$fieldName} = '{$oldData[0]}' WHERE ID = {$id}");
                     } else {
                         echo 'Field "' . $fieldName . '" empty.' . $this->eol;
                     }
                 }
             }
         }
     }
 }
开发者ID:toastnz,项目名称:twitter-card-meta,代码行数:35,代码来源:MigrateSiteTreeMetaTask.php

示例11: delete

 public function delete(SS_HTTPRequest $request)
 {
     $rid = $request->getVar('RID');
     $record = TestObject::get()->filter(array('ID' => $rid))->first();
     $record->delete();
     return $this->customise(new ArrayData(array('Title' => 'Orient DB Demo', 'SubTitle' => "Deleted Record {$rid}", 'Content' => $content)))->renderWith(array('OrientController', 'AppController'));
 }
开发者ID:Cumquat,项目名称:silverstripe-orientdb-poc,代码行数:7,代码来源:OrientController.php

示例12: getGoogleMapPin

 public function getGoogleMapPin(SS_HTTPRequest $request)
 {
     $color = Convert::raw2sql($request->param('Color'));
     $path = ASSETS_PATH . '/maps/pins';
     // create folder on assets if does not exists ....
     if (!is_dir($path)) {
         mkdir($path, $mode = 0775, $recursive = true);
     }
     // if not get it from google (default)
     $ping_url = "http://chart.apis.google.com/chart?cht=mm&chs=32x32&chco=FFFFFF,{$color},000000&ext=.png";
     $write_2_disk = true;
     if (file_exists($path . '/pin_' . $color . '.jpg')) {
         // if we have the file on assets use it
         $ping_url = $path . '/pin_' . $color . '.jpg';
         $write_2_disk = false;
     }
     $body = file_get_contents($ping_url);
     if ($write_2_disk) {
         file_put_contents($path . '/pin_' . $color . '.jpg', $body);
     }
     $ext = 'jpg';
     $response = new SS_HTTPResponse($body, 200);
     $response->addHeader('Content-Type', 'image/' . $ext);
     return $response;
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:25,代码来源:GoogleImagesApi.php

示例13: 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();
     }
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:34,代码来源:SummitAppLocationsApi.php

示例14: beforeCallActionHandler

 /**
  * Due to a bug, this could be called twice before 4.0,
  * see https://github.com/silverstripe/silverstripe-framework/pull/5173
  *
  * @param SS_HTTPRequest $request
  * @param string $action
  */
 public function beforeCallActionHandler($request, $action)
 {
     // This could be called twice
     if ($this->owner->beforeCallActionHandlerCalled) {
         return;
     }
     // If we don't have an action, getViewer will be called immediatly
     // If we have custom routes, request action is different than action
     $allParams = $request->allParams();
     $requestAction = null;
     if (!empty($allParams['Action'])) {
         $requestAction = $allParams['Action'];
     }
     if (!$this->owner->hasMethod($action) || $requestAction && $requestAction != $action) {
         self::clearBuffer();
     }
     $class = get_class($this->owner);
     DebugBar::withDebugBar(function (DebugBar\DebugBar $debugbar) use($class, $action) {
         /* @var $timeData DebugBar\DataCollector\TimeDataCollector */
         $timeData = $debugbar['time'];
         if (!$timeData) {
             return;
         }
         if ($timeData->hasStartedMeasure("handle")) {
             $timeData->stopMeasure("handle");
         }
         $timeData->startMeasure("action", "{$class} action {$action}");
     });
     $this->owner->beforeCallActionHandlerCalled = true;
 }
开发者ID:lekoala,项目名称:silverstripe-debugbar,代码行数:37,代码来源:DebugBarControllerExtension.php

示例15: getEventsAction

 public function getEventsAction(SS_HTTPRequest $request)
 {
     // Search date
     $date = DBField::create_field("SS_Datetime", $request->param("SearchDate"));
     if (!$date->getValue()) {
         $date = SS_Datetime::now();
     }
     // Get event data
     $cache = SS_Cache::factory(self::EVENTS_CACHE_NAME);
     $cacheKey = $date->Format('Y_m_d');
     if ($result = $cache->load($cacheKey)) {
         $data = unserialize($result);
     } else {
         $data = EventsDataUtil::get_events_data_for_day($date);
         $cache->save(serialize($data), $cacheKey);
     }
     // Get init data
     if ($request->param("GetAppConfig")) {
         $cache = SS_Cache::factory(self::CONFIG_CACHE_NAME);
         $cacheKey = 'APP_CONFIG';
         if ($result = $cache->load($cacheKey)) {
             $configData = unserialize($result);
         } else {
             $configData = AppConfigDataUtil::get_config_data();
             $cache->save(serialize($configData), $cacheKey);
         }
         $data['appConfig'] = $configData;
     }
     return $this->sendResponse($data);
 }
开发者ID:ehyland,项目名称:some-painter-cms,代码行数:30,代码来源:EventsController.php


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