本文整理汇总了PHP中SS_HTTPRequest::param方法的典型用法代码示例。如果您正苦于以下问题:PHP SS_HTTPRequest::param方法的具体用法?PHP SS_HTTPRequest::param怎么用?PHP SS_HTTPRequest::param使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SS_HTTPRequest
的用法示例。
在下文中一共展示了SS_HTTPRequest::param方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: childnodes
/**
* Request nodes from the server
*
* @param SS_HTTPRequest $request
* @return JSONString
*/
public function childnodes($request)
{
$data = array();
$rootObjectType = 'SiteTree';
if ($request->param('ID')) {
$rootObjectType = $request->param('ID');
}
if ($request->getVar('search')) {
return $this->performSearch($request->getVar('search'), $rootObjectType);
}
$parentId = $request->getVar('id');
if (!$parentId) {
$parentId = $rootObjectType . '-0';
}
$selectable = null;
if ($request->param('OtherID')) {
$selectable = explode(',', $request->param('OtherID'));
}
list($type, $id) = explode('-', $parentId);
if (!$type || $id < 0) {
$data = array(0 => array('data' => 'An error has occurred'));
} else {
$children = null;
if ($id == 0) {
$children = DataObject::get($rootObjectType, 'ParentID = 0');
} else {
$object = DataObject::get_by_id($type, $id);
$children = $this->childrenOfNode($object);
}
$data = array();
if ($children && count($children)) {
foreach ($children as $child) {
if ($child->ID < 0) {
continue;
}
$haskids = $child->numChildren() > 0;
$nodeData = array('title' => isset($child->MenuTitle) ? $child->MenuTitle : $child->Title);
if ($selectable && !in_array($child->ClassName, $selectable)) {
$nodeData['clickable'] = false;
}
$thumbs = null;
if ($child->ClassName == 'Image') {
$thumbs = $this->generateThumbnails($child);
$nodeData['icon'] = $thumbs['x16'];
} else {
if (!$haskids) {
$nodeData['icon'] = 'frontend-editing/images/page.png';
}
}
$nodeEntry = array('attributes' => array('id' => $child->ClassName . '-' . $child->ID, 'title' => Convert::raw2att($nodeData['title']), 'link' => $child->RelativeLink()), 'data' => $nodeData, 'state' => $haskids ? 'closed' : 'open');
if ($thumbs) {
$nodeEntry['thumbs'] = $thumbs;
}
$data[] = $nodeEntry;
}
}
}
return Convert::raw2json($data);
}
开发者ID:helpfulrobot,项目名称:silverstripe-australia-frontend-editing,代码行数:65,代码来源:SimpleTreeController.php
示例3: 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
示例4: handleRequest
/**
* Handle the url parsing for the documentation. In order to make this
* user friendly this does some tricky things..
*
* The urls which should work
* / - index page
* /en/sapphire - the index page of sapphire (shows versions)
* /2.4/en/sapphire - the docs for 2.4 sapphire.
* /2.4/en/sapphire/installation/
*
* @return SS_HTTPResponse
*/
public function handleRequest(SS_HTTPRequest $request)
{
// Workaround for root routing, e.g. Director::addRules(10, array('$Action' => 'DocumentationViewer'))
$this->Version = $request->param('Action') ? $request->param('Action') : $request->shift();
$this->Lang = $request->shift();
$this->ModuleName = $request->shift();
$this->Remaining = $request->shift(10);
DocumentationService::load_automatic_registration();
if (isset($this->Version)) {
// check to see if its a valid version. If its not a float then its not actually a version
// its actually a language and it needs to change. So this means we support 2 structures
// /2.4/en/sapphire/page and
// /en/sapphire/page which is a link to the latest one
if (!is_numeric($this->Version) && $this->Version != 'current') {
array_unshift($this->Remaining, $this->ModuleName);
// not numeric so /en/sapphire/folder/page
if (isset($this->Lang) && $this->Lang) {
$this->ModuleName = $this->Lang;
}
$this->Lang = $this->Version;
$this->Version = null;
} else {
// if(!DocumentationService::is_registered_version($this->Version)) {
// $this->httpError(404, 'The requested version could not be found.');
// }
}
}
if (isset($this->Lang)) {
// check to see if its a valid language
// if(!DocumentationService::is_registered_language($this->Lang)) {
// $this->httpError(404, 'The requested language could not be found.');
// }
} else {
$this->Lang = 'en';
}
// 'current' version mapping
$module = DocumentationService::is_registered_module($this->ModuleName, null, $this->Lang);
if ($this->Version && $module) {
$current = $module->getCurrentVersion();
if ($this->Version == 'current') {
$this->Version = $current;
} else {
if ($current == $this->Version) {
$this->Version = 'current';
$link = $this->Link($this->Remaining);
$this->response = new SS_HTTPResponse();
$this->redirect($link, 301);
// permanent redirect
return $this->response;
}
}
}
return parent::handleRequest($request);
}
示例5: compare
/**
* @param SS_HTTPRequest $request
* @return array
*/
public function compare($request)
{
$form = $this->CompareVersionsForm($request->param('VersionID'), $request->param('OtherVersionID'));
$negotiator = $this->getResponseNegotiator();
$controller = $this;
$negotiator->setCallback('CurrentForm', function () use(&$controller, &$form) {
return $form ? $form->forTemplate() : $controller->renderWith($controller->getTemplatesWithSuffix('_Content'));
});
$negotiator->setCallback('default', function () use(&$controller, &$form) {
return $controller->customise(array('EditForm' => $form))->renderWith($controller->getViewer('show'));
});
return $negotiator->respond($request);
}
示例6: 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' => ''));
}
示例7: 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();
}
}
示例8: date
public function date(SS_HTTPRequest $r)
{
$year = $r->param('ID');
$month = $r->param('OtherID');
if (!$year) {
return $this->httpError(404);
}
$startDate = $month ? "{$year}-{$month}-01" : "{$year}-01-01";
if (strtotime($startDate) === false) {
return $this->httpError(404, 'Invalid date');
}
$adder = $month ? '+1 month' : '+1 year';
$endDate = date('Y-m-d', strtotime($adder, strtotime($startDate)));
$this->articleList = $this->articleList->filter(array('Date:GreaterThanOrEqual' => $startDate, 'Date:LessThan' => $endDate));
return array('StartDate' => DBField::create_field('SS_DateTime', $startDate), 'EndDate' => DBField::create_field('SS_DateTime', $endDate));
}
示例9: handleRequest
public function handleRequest(SS_HTTPRequest $request, DataModel $model)
{
$this->pushCurrent();
$this->urlParams = $request->allParams();
$this->request = $request;
$this->response = new SS_HTTPResponse();
$this->setDataModel($model);
$urlsegment = $request->param('URLSegment');
$this->extend('onBeforeInit');
$this->init();
$this->extend('onAfterInit');
// First check products against URL segment
if ($product = Product::get()->filter(array('URLSegment' => $urlsegment, 'Disabled' => 0))->first()) {
$controller = Catalogue_Controller::create($product);
} elseif ($category = ProductCategory::get()->filter('URLSegment', $urlsegment)->first()) {
$controller = Catalogue_Controller::create($category);
} else {
// If CMS is installed
if (class_exists('ModelAsController')) {
$controller = ModelAsController::create();
}
}
$result = $controller->handleRequest($request, $model);
$this->popCurrent();
return $result;
}
示例10: getMember
public function getMember(SS_HTTPRequest $request)
{
try {
$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));
}
$member_id = intval($request->param('MEMBER_ID'));
$member = Member::get_by_id('Member', $member_id);
if (is_null($member)) {
throw new NotFoundEntityException('Member', sprintf(' id %s', $member_id));
}
$speaker = $member->Speaker()->ID ? $member->Speaker()->toMap() : '';
$affiliation = '';
if ($affiliation_obj = $member->getCurrentAffiliation()) {
$affiliation = $affiliation_obj->toMap();
$affiliation['Company'] = array('id' => $affiliation_obj->Organization()->ID, 'name' => $affiliation_obj->Organization()->Name);
}
echo json_encode(array('speaker' => $speaker, 'affiliation' => $affiliation));
} 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();
}
}
示例11: 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;
}
示例12: handleRequest
/**
* @uses ModelAsController::getNestedController()
* @param SS_HTTPRequest $request
* @param DataModel $model
* @return SS_HTTPResponse
*/
public function handleRequest(SS_HTTPRequest $request, DataModel $model)
{
// Check Translatable dependency
if (!class_exists('Translatable') || !SiteTree::has_extension('Translatable') && !SiteTree::has_extension('LanguagePrefixTranslatable')) {
throw new Exception('Dependency error: the LanguagePrefix module expects the Translatable module.');
}
$disablePrefixForDefaultLang = Config::inst()->get('prefixconfig', 'disable_prefix_for_default_lang');
$firstSegment = $request->param('URLSegment');
if ($firstSegment) {
$prefixUsed = $this->setLocale($firstSegment);
$defaultLocale = Translatable::default_locale();
$isDefaultLocale = $this->locale == $defaultLocale;
if ($prefixUsed) {
if ($isDefaultLocale && $disablePrefixForDefaultLang) {
$url = substr($request->getURL(true), strlen($firstSegment));
return $this->redirect($url, 301);
} else {
$request->shiftAllParams();
$request->shift(1);
}
} else {
/*
* if no prefix is used but $disablePrefixForDefaultLang
* is set, we go on like nothing happened. Otherwise a
* 404 is generated. @todo: maybe we should redirect
* pages that do actually exist, because this is a bit
* harsh?
*/
//if (!$isDefaultLocale || !$disablePrefixForDefaultLang) {
// return $this->showPageNotFound();
//}
}
}
return parent::handleRequest($request, $model);
}
示例13: show
public function show(SS_HTTPRequest $request)
{
$shot = ModuleScreenshot::get()->byID($request->param('ID'));
if (!$shot) {
return $this->httpError(404, 'That Screen shot could not be found');
}
return array('ModuleScreenshot' => $shot);
}
示例14: show
public function show(SS_HTTPRequest $r)
{
$presentation = Sluggable::get_by_slug('SchedPresentation', $r->param('ID'));
if (!$presentation) {
return $this->httpError(404);
}
return array('Presentation' => $presentation);
}
示例15: claim
/**
* @param SS_HTTPRequest $request
* @return SS_HTTPResponse
*/
public function claim(SS_HTTPRequest $request)
{
/** @var Order $order */
$order = Order::get()->byID($request->param('ID'));
$hash = $request->param('OtherID');
$realHash = FollowUpEmail::generate_hash($order);
if (!$order || !$order->exists() || empty($hash) || $hash !== $realHash) {
$this->httpError(404);
}
// Require a login if the order is attached to an account
if ($order->MemberID && $order->MemberID != Member::currentUserID()) {
return Security::permissionFailure($this->owner, _t('ShopEmail.NotYourOrder', 'You must log in to access this order.'));
}
// Otherwise if all is good, proceed to checkout
ShoppingCart::singleton()->setCurrent($order);
return $this->redirect(CheckoutPage::get()->first()->Link());
}