本文整理汇总了PHP中SS_HTTPRequest::requestVar方法的典型用法代码示例。如果您正苦于以下问题:PHP SS_HTTPRequest::requestVar方法的具体用法?PHP SS_HTTPRequest::requestVar怎么用?PHP SS_HTTPRequest::requestVar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SS_HTTPRequest
的用法示例。
在下文中一共展示了SS_HTTPRequest::requestVar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: refresh
/**
* Refreshes the file list. If passed an array of ids, it will add those to the list.
*
* @todo Add some better error handling.
* @param SS_HTTPRequest
* @return string|SS_Viewer
*/
public function refresh(SS_HTTPRequest $r)
{
if ($r->requestVar('ids')) {
$id = reset($r->requestVar('ids'));
if ($file = DataObject::get_by_id("File", (int) $id)) {
$this->processFile($file);
} else {
die("File {$id} doesn't exist");
}
} else {
$file = $this->File();
}
return $this->customise(array('File' => $file))->renderWith($this->AttachedFilesTemplate);
}
示例2: 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
示例3: getToken
protected function getToken(SS_HTTPRequest $request)
{
$token = $request->requestVar('token');
if (!$token) {
$token = $request->getHeader('X-Auth-Token');
}
return $token;
}
示例4: deletefile
/**
* Delete a file
*
* @param SS_HTTPRequest
*/
public function deletefile(SS_HTTPRequest $r)
{
if ($file = DataObject::get_by_id("File", (int) $r->requestVar('id'))) {
$file->delete();
return new SS_HTTPResponse("OK", 200);
}
return false;
}
示例5: GET
function GET(SS_HTTPRequest $request)
{
// If we get a request var set as 'Error', trigger an errpr
if ($request->requestVar('Error')) {
$this->addResponseHeader('x-exception-id', '1');
return $this->respondWithError(404);
}
// Normal response - set a header, and respond
$this->addResponseHeader('x-some-sideinfo', 'Zap!');
return $this->respondWith('ID', 'Baz', 'Qux');
}
示例6: index
public function index(SS_HTTPRequest $r) {
if(isset($_FILES["Filedata"]) && is_uploaded_file($_FILES["Filedata"]["tmp_name"])) {
$upload_folder = urldecode($r->requestVar('uploadFolder'));
if(isset($_REQUEST['FolderID'])) {
if($folder = DataObject::get_by_id("Folder", Convert::raw2sql($_REQUEST['FolderID']))) {
$upload_folder = UploadifyField::relative_asset_dir($folder->Filename);
}
}
$ext = strtolower(end(explode('.', $_FILES['Filedata']['name'])));
$class = in_array($ext, UploadifyField::$image_extensions) ? $r->requestVar('imageClass') : $r->requestVar('fileClass');
$file = new $class();
$u = new Upload();
$u->loadIntoFile($_FILES['Filedata'], $file, $upload_folder);
$file->write();
echo $file->ID;
}
else {
echo ' '; // return something or SWFUpload won't fire uploadSuccess
}
}
示例7: spellcheck
public function spellcheck(SS_HTTPRequest $request)
{
$this->owner->request->addHeader('Content-Type', 'text/plain');
$this->owner->request->addHeader('Content-Encoding', 'UTF-8');
$this->owner->request->addHeader('Expires', 'Mon, 26 Jul 1007 05:00:00 GMT');
$this->owner->request->addHeader('Last-Modified', SS_DateTime::now()->Format('D, d M Y H:i:s') . ' GMT');
$this->owner->request->addHeader('Cache-Control', 'no-store, no-cache, must-revalidate');
$this->owner->request->addHeader('Cache-Control', 'post-check=0, pre-check=0');
$this->owner->request->addHeader('Pragma', 'no-cache');
$engine = self::$engine;
$shell = self::$shell;
if (!defined('SPELLCHECK_POST_SS3')) {
$engine = Config::inst()->get('CMSSpellChecker', 'engine') ?: $engine;
$shell = Config::inst()->get('CMSSpellChecker', 'shell') ?: $shell;
}
if (!defined('PSPELL_FAST')) {
define('PSPELL_FAST', 1);
}
# Fast mode (least number of suggestions)
if (!defined('PSPELL_NORMAL')) {
define('PSPELL_NORMAL', 2);
}
# Normal mode (more suggestions)
if (!defined('PSPELL_BAD_SPELLERS')) {
define('PSPELL_BAD_SPELLERS', 3);
}
# Slow mode (a lot of suggestions)
$config['general.engine'] = $engine;
$config['PSpell.mode'] = PSPELL_FAST;
$config['PSpell.spelling'] = '';
$config['PSpell.jargon'] = '';
$config['PSpell.encoding'] = '';
$config['PSpellShell.mode'] = PSPELL_FAST;
$config['PSpellShell.aspell'] = $shell;
$config['PSpellShell.tmp'] = '/tmp';
$output = array('id' => null, 'result' => null, 'error' => null);
$raw = $request->requestVar('json_data') ?: '';
if (!$raw) {
$raw = '' . file_get_contents('php://input');
}
if (!$raw) {
$output['error'] = array('errstr' => 'Could not get raw post data', 'errfile' => '', 'errline' => null, 'errcontext' => '', 'level' => 'FATAL');
echo json_encode($output);
exit;
}
$input = json_decode($raw, true);
if (isset($config['general.engine'])) {
$spellchecker = new $config['general.engine']($config);
$result = call_user_func_array(array($spellchecker, $input['method']), $input['params']);
}
$output['id'] = $input['id'];
$output['result'] = $result;
echo json_encode($output);
}
示例8: preview
function preview(SS_HTTPRequest $request)
{
$strValue = $request->requestVar('markdown');
if ($strValue) {
$shortCodeParser = ShortcodeParser::get_active();
$strValue = $shortCodeParser->parse($strValue);
$parseDown = new Parsedown();
$strValue = $parseDown->text($strValue);
}
return $strValue;
}
示例9: run
/**
*
* @param SS_HTTPRequest $request
*/
public function run($request)
{
$memberEmail = $request->requestVar('email');
$message = trim($request->requestVar('message'));
if (!$memberEmail) {
echo 'Please provide an email, eg ?email=user@example.com' . PHP_EOL;
exit(1);
}
$members = Member::get()->filter('Email', $memberEmail);
if (!$members->count()) {
echo 'Please provide an existing member email' . PHP_EOL;
exit(1);
}
$member = $members->first();
if (!$message) {
echo 'Please provide a message, eg ?message=hello' . PHP_EOL;
exit(1);
}
TimelineEvent::notify($member, $message);
echo 'Member ' . $member->Email . ' has been notified' . PHP_EOL;
}
示例10: refresh
/**
* Refreshes the file list. If passed an array of IDs in the request,
* it augments the list with those files.
*
* @param SS_HTTPRequest
* @return SSViewer
*/
public function refresh(SS_HTTPRequest $r)
{
if ($r->requestVar('ids')) {
$ids = array_unique($r->requestVar('ids'));
$files = new DataObjectSet();
$implodestring = implode(',', $ids);
$implodestring = preg_replace("/^[,]/", "", $implodestring);
if ($set = DataObject::get("File", "`ID` IN ({$implodestring})")) {
foreach ($set as $file) {
$this->processFile($file);
$files->push($file);
}
$files->merge($this->Files());
$files->removeDuplicates();
} else {
die("File {$id} doesn't exist");
}
} else {
$files = $this->Files();
}
return $this->customise(array('Files' => $files))->renderWith($this->AttachedFilesTemplate);
}
示例11: sort
/**
* A controller action that handles the reordering of the panels
*
* @param SS_HTTPRequest The current request
* @return SS_HTTPResponse
*/
public function sort(SS_HTTPRequest $r)
{
if ($sort = $r->requestVar('dashboard-panel')) {
foreach ($sort as $index => $id) {
if ($panel = DashboardPanel::get()->byID((int) $id)) {
if ($panel->MemberID == Member::currentUserID()) {
$panel->SortOrder = $index;
$panel->write();
}
}
}
}
}
示例12: getresults
public function getresults(SS_HTTPRequest $r)
{
$q = Convert::raw2sql($r->requestVar('q'));
$results = DataObject::get($this->sourceClass, $this->labelField . " LIKE '%{$q}%'");
if ($results) {
$set = new DataObjectSet();
foreach ($results->toDropdownMap('ID', $this->labelField) as $key => $val) {
$set->push(new ArrayData(array('Key' => $key, 'Val' => $val)));
}
} else {
$set = false;
}
return $this->customise(array('Results' => $set))->renderWith('LiveDropdownField_results');
}
示例13: search_suggest
/**
* @param SS_HTTPRequest $req
* @return string
*/
public function search_suggest(SS_HTTPRequest $req)
{
/** @var SS_HTTPResponse $response */
$response = $this->owner->getResponse();
$callback = $req->requestVar('callback');
// convert the search results into usable json for search-as-you-type
if (ShopSearch::config()->search_as_you_type_enabled) {
$searchVars = $req->requestVars();
$searchVars[ShopSearch::config()->qs_query] = $searchVars['term'];
unset($searchVars['term']);
$results = ShopSearch::inst()->suggestWithResults($searchVars);
} else {
$results = array('suggestions' => ShopSearch::inst()->suggest($req->requestVar('term')));
}
if ($callback) {
$response->addHeader('Content-type', 'application/javascript');
$response->setBody($callback . '(' . json_encode($results) . ');');
} else {
$response->addHeader('Content-type', 'application/json');
$response->setBody(json_encode($results));
}
return $response;
}
开发者ID:helpfulrobot,项目名称:markguinn-silverstripe-shop-search,代码行数:27,代码来源:ShopSearchControllerExtension.php
示例14: importlist
public function importlist(SS_HTTPRequest $request)
{
if ($id = $request->requestVar('FolderID')) {
if (is_numeric($id)) {
$files = DataObject::get("File", "\"ParentID\" = {$id} AND \"File\".\"ClassName\" != 'Folder'");
if ($ext = $request->requestVar('FileExt')) {
$ext = str_replace('*.', '', $ext);
$ext_arr = explode(';', $ext);
$ext = ' AND (';
$x = 0;
foreach ($ext_arr as $e) {
if ($x++ == 0) {
$ext .= " Name LIKE '%.{$e}' ";
} else {
$ext .= " OR Name LIKE '%.{$e}' ";
}
}
$ext .= ')';
$files = DataObject::get("File", "ParentID = {$id} AND File.ClassName != 'Folder'" . $ext);
} else {
$files = DataObject::get("File", "ParentID = {$id} AND File.ClassName != 'Folder'");
}
if ($files && $this->form) {
if ($record = $this->form->getRecord()) {
if ($relation_name = $this->getForeignRelationName($record)) {
foreach ($files as $f) {
if ($f->{$relation_name}) {
$f->Disabled = true;
}
}
}
}
}
return $this->customise(array('Files' => $files))->renderWith('ImportList');
}
}
}
示例15: getPulledRegionIDs
/**
* Looks first for the X-Pull-Regions header and then for a __regions__ get/post var.
* @return array
*/
protected function getPulledRegionIDs()
{
if (!$this->request) {
return array();
}
$header = $this->request->getHeader(self::PULL_HEADER);
if (!empty($header)) {
return explode(',', $header);
}
$param = $this->request->requestVar(self::PULL_PARAM);
if (!empty($param)) {
return explode(',', $param);
}
return array();
}