本文整理汇总了PHP中Request::getVar方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getVar方法的具体用法?PHP Request::getVar怎么用?PHP Request::getVar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Request
的用法示例。
在下文中一共展示了Request::getVar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: post
public function post(\Request $request)
{
$factory = new Factory();
$view = new \View\JsonView(array('success' => true));
$response = new \Response($view);
if (!$request->isVar('command')) {
throw new \Exception('Bad command');
}
switch ($request->getVar('command')) {
case 'add':
$factory->postNew();
break;
case 'deactivate':
$this->deactivate($factory, filter_input(INPUT_POST, 'lotId', FILTER_SANITIZE_NUMBER_INT));
break;
case 'activate':
$this->activate($factory, filter_input(INPUT_POST, 'lotId', FILTER_SANITIZE_NUMBER_INT));
break;
case 'delete':
Factory::delete(filter_input(INPUT_POST, 'lotId', FILTER_SANITIZE_NUMBER_INT));
break;
default:
throw new \Exception('Bad command:' . $request->getVar('command'));
}
return $response;
}
示例2: post
public function post(\Request $request)
{
$factory = new Factory();
$view = new \View\JsonView(array('success' => true));
if (!$request->isVar('command')) {
throw new \Exception('Bad command');
}
switch ($request->getVar('command')) {
case 'chooseWinners':
$view = $this->chooseWinners();
break;
case 'complete':
$factory->completeGame();
break;
case 'notify':
$view = $view = new \View\JsonView(array('sent' => $factory->notify()));
break;
case 'completeLottery':
$factory->completeLottery();
break;
case 'pickup':
$this->postPickUp();
break;
default:
throw new \Exception('Bad command:' . $request->getVar('command'));
}
$response = new \Response($view);
return $response;
}
示例3: post
public function post(\Request $request)
{
$factory = new Factory();
$view = new \View\JsonView(array('success' => true));
if (!$request->isVar('command')) {
throw new \Exception('Bad command');
}
switch ($request->getVar('command')) {
case 'add':
$factory->postNew();
break;
case 'updateSignupStart':
$view = new \View\JsonView($this->updateSignupStart());
break;
case 'updateSignupEnd':
$view = new \View\JsonView($this->updateSignupEnd());
break;
case 'updatePickupDeadline':
$view = new \View\JsonView($this->updatePickupDeadline());
break;
case 'updateKickoff':
$view = new \View\JsonView($this->updateKickoff());
break;
case 'complete':
$this->completeGame();
break;
default:
throw new \Exception('Bad command:' . $request->getVar('command'));
}
$response = new \Response($view);
return $response;
}
示例4: saveThumbnail
private function saveThumbnail(\Request $request)
{
$latitude = $request->getVar('latitude');
$longitude = $request->getVar('longitude');
Factory::createMapThumbnail($latitude, $longitude);
$json['result'] = 'true';
$response = new \View\JsonView($json);
return $response;
}
示例5: post
public function post(\Request $request)
{
$factory = new Factory();
$view = new \View\JsonView(array('success' => true));
if (!$request->isVar('command')) {
throw new \Exception('Bad command');
}
switch ($request->getVar('command')) {
case 'ban':
$factory->ban($request->getVar('id'), $request->getVar('reason'));
break;
case 'unban':
$factory->unban($request->getVar('id'));
break;
case 'ineligible':
$factory->ineligible($request->getVar('id'), $request->getVar('reason'));
break;
case 'eligible':
$factory->eligible($request->getVar('id'));
break;
case 'delete':
$factory->delete($request->getVar('id'));
break;
case 'assign':
if (!$this->assign()) {
$view = new \View\JsonView(array('success' => false));
}
break;
default:
throw new \Exception('Bad command:' . $request->getVar('command'));
}
$response = new \Response($view);
return $response;
}
示例6: post
public function post(\Request $request)
{
$social_links = \contact\Factory\ContactInfo\Social::pullSavedLinks();
$label = $request->getVar('label');
$url = $request->getVar('url');
if (empty($url)) {
unset($social_links[$label]);
} else {
$social_links[$label] = $url;
}
\contact\Factory\ContactInfo\Social::saveLinks($social_links);
echo 'post successful';
exit;
}
示例7: onResources
/**
* Return data on a resource view (this will be some form of HTML)
*
* @param object $resource Current resource
* @param string $option Name of the component
* @param array $areas Active area(s)
* @param string $rtrn Data to be returned
* @return array
*/
public function onResources($model, $option, $areas, $rtrn = 'all')
{
if (!$model->type->params->get('plg_share')) {
return;
}
$arr = array('area' => $this->_name, 'html' => '', 'metadata' => '');
$resource = $model->resource;
$sef = Route::url('index.php?option=com_resources&' . ($resource->alias ? 'alias=' . $resource->alias : 'id=' . $resource->id));
$url = Request::base() . ltrim($sef, '/');
// Incoming action
$sharewith = Request::getVar('sharewith', '');
if ($sharewith) {
// Log the activity
if (!User::isGuest()) {
Event::trigger('system.logActivity', ['activity' => ['action' => 'shared', 'scope' => 'resource', 'scope_id' => $resource->id, 'description' => Lang::txt('PLG_RESOURCES_SHARE_ENTRY_SHARED', '<a href="' . $sef . '">' . $resource->title . '</a>', $sharewith), 'details' => array('with' => $sharewith, 'title' => $resource->title, 'url' => $sef)], 'recipients' => [['resource', $resource->id], ['user', $resource->created_by], ['user', User::get('id')]]]);
}
// Email form
if ($sharewith == 'email') {
// Instantiate a view
$view = $this->view('email', 'options')->set('option', $option)->set('resource', $resource)->set('_params', $this->params)->set('url', $url)->setErrors($this->getErrors());
// Return the output
$view->display();
exit;
}
return $this->share($sharewith, $url, $resource);
}
// Build the HTML meant for the "about" tab's metadata overview
if ($rtrn == 'all' || $rtrn == 'metadata') {
// Instantiate a view
$view = $this->view('default', 'options')->set('option', $option)->set('resource', $resource)->set('_params', $this->params)->set('url', $url)->setErrors($this->getErrors());
// Return the output
$arr['metadata'] = $view->loadTemplate();
}
return $arr;
}
示例8: __construct
/**
Class constructor
@public
**/
function __construct($page, $num_results, $total_items, $limit = 0, $baseURL = null, $automakeSEF = false, $detect_formatting = true)
{
// bind
$this->_total = $total_items;
$this->_num_results = $num_results;
$this->_limit = $limit;
$this->_limitstart = $this->_curpage > 1 ? $this->_curpage * $limit - $limit : 0;
if ($this->_limit) {
$this->_num_pages = $this->_total > $this->_limit ? ceil($this->_total / $this->_limit) : 0;
}
$this->_single_page = $this->_num_pages < 1;
// check out-of-range page index
$this->_curpage = $page > $this->_num_pages ? 1 : $page;
// set base URL if don't exists
$this->_baseURL = $baseURL;
if (empty($baseURL)) {
$config =& Factory::getConfig();
$uri = URL::getURI();
$this->_baseURL = $config->baseURL . $uri->_url;
}
// if true, URL::_ will be used
$this->_automakeSEF = $automakeSEF;
$this->_detect_formatting = $detect_formatting;
// get component format
if ($detect_formatting) {
$component_format = Request::getVar('format');
if ($component_format) {
$this->__component_format = 'format=' . Request::getVar('format');
} else {
// turn it off if no special formatting found
$this->_detect_formatting = false;
}
}
}
示例9: actionDisplay
public function actionDisplay()
{
$id = Request::getVar('id', null);
$alias = Request::getVar('alias', null);
$model = Video::getInstance();
if ($id == null or $id == "") {
if ($alias != null and $alias != "") {
$obj_item = $model->getItemByAlias($alias);
} else {
header("Location: /");
}
} else {
$obj_item = $model->getItem($id);
}
$items = $model->getItems($obj_item['catID'], true, 4);
$items2 = $model->getItems($obj_item['catID'], false, 9);
$obj_category = $model->getCategory($obj_item['catID']);
$data['item'] = $obj_item;
$data['items'] = $items;
$data['items2'] = $items2;
$data['category'] = $obj_category;
$page_title = $obj_item['title'];
$page_keyword = $obj_item['metakey'] != "" ? $obj_item['metakey'] : $page_title;
$page_description = $obj_item['metadesc'] != "" ? $obj_item['metadesc'] : $page_title;
setSysConfig("seopage.title", $page_title);
setSysConfig("seopage.keyword", $page_keyword);
setSysConfig("seopage.description", $page_description);
Request::setVar('alias', $obj_category['alias']);
$this->render('default', $data);
}
示例10: suggestions_getContent
function suggestions_getContent()
{
global $template;
// open template
$template->setFile('suggestions.tmpl');
$messageText = array(-3 => array('type' => 'error', 'message' => _('Fehler beim eintragen des Vorschlags.')), -2 => array('type' => 'error', 'message' => _('Es wurde kein Nachrichtentext angegeben.')), -1 => array('type' => 'error', 'message' => _('Du hast schon die Maximalzahl an möglichen Vorschlägen erreicht.')), 1 => array('type' => 'success', 'message' => _('Der Vorschlag wurde erfolgreich verschickt.')));
$suggestionsCount = suggestions_countSuggestion($_SESSION['player']->playerID);
$action = Request::getVar('action', '');
switch ($action) {
/****************************************************************************************************
*
* Nachricht eintragen
*
****************************************************************************************************/
case 'add':
if ($suggestionsCount >= SUGGESTIONS_MAX) {
$messageID = -1;
break;
}
$message = Request::getVar('inputMessage', '');
if (empty($message)) {
$messageID = -2;
break;
}
$messageID = suggestions_addSuggestion($_SESSION['player']->playerID, $message);
if ($messageID > 0) {
$suggestionsCount++;
}
break;
}
$template->addVars(array('max_suggestions' => $suggestionsCount >= SUGGESTIONS_MAX ? true : false, 'status_msg' => isset($messageID) ? $messageText[$messageID] : ''));
}
示例11: controller_exec
function controller_exec()
{
global $conf;
if (!authorized()) {
$err_str = 'Access restricted.';
if ($conf['modes']['db']['enabled']) {
$group = $conf['access_limit_to_group'];
Toolbar::title('Databases', 'databases');
Toolbar::preferences('com_databases', '200');
$err_str = "<p class=\"error\">Not authorized, access is limited to \"<em>{$group}</em>\"</p>. <h3>Use the Databases component parameters to change this</h3>";
}
print $err_str;
return;
}
// Get the task
$task = Request::getVar('task', 'list');
$task_file = JPATH_COMPONENT . DS . 'tasks' . DS . $task . '.php';
if (require_once $task_file) {
$task_func = 'dv_' . $task;
if (function_exists($task_func)) {
if (file_exists(JPATH_COMPONENT . DS . 'tasks' . DS . 'html' . DS . $task . '.js')) {
$document = App::get('document');
$document->addScript(DB_PATH . DS . 'tasks' . DS . 'html' . DS . $task . '.js?v=2');
}
$task_func();
}
}
}
示例12: onAfterRoute
/**
* Hook for after routing application
*
* @return void
*/
public function onAfterRoute()
{
if (!App::isAdmin() && !App::isSite()) {
return;
}
$client = 'Site';
if (App::isAdmin()) {
$client = 'Admin';
return;
}
// Check if active for this client (Site|Admin)
if (!$this->params->get('activate' . $client) || Request::getVar('format') == 'pdf') {
return;
}
Html::behavior('framework');
if ($this->params->get('jqueryui')) {
Html::behavior('framework', true);
}
if ($this->params->get('jqueryfb')) {
Html::behavior('modal');
}
if ($this->params->get('noconflict' . $client)) {
Document::addScript(Request::root(true) . '/core/assets/js/jquery.noconflict.js');
}
}
示例13: getParams
/**
* Parse the URL parameters and map each parameter (in order) to the given array of names
*
* @param array varNames: Array of names to map the URL parameters to
* @return object: Object with properties named after var names mapped to URL parameters
*/
protected function getParams($varNames)
{
$i = 0;
// Strict processing doesn't allow extra or missing parameters in the URL
$strictProcessing = false;
$params = false;
// check if there are more parameters than needed
$extraParameter = Request::getVar('p' . count($varNames), '');
if ($strictProcessing && !empty($extraParameter)) {
// too many parameters in the URL
//throw new \Exception('Too many parameters');
App::abort(404, Lang::txt('Page Not Found'));
}
// Go through each var name and assign a sequential URL parameter's value to it
foreach ($varNames as $varName) {
$value = Request::getVar('p' . $i, '');
if (!empty($value)) {
$params->{$varName} = $value;
} else {
if ($strictProcessing) {
// missing parameter in the URL
//throw new \Exception('Too few parameters');
App::abort(404, Lang::txt('Page Not Found'));
}
break;
}
$i++;
}
return $params;
}
示例14: onAfterRoute
/**
* Method to catch the onAfterRoute event.
*
* @return boolean
*/
public function onAfterRoute()
{
$task = Request::getVar('task', 'none');
if (User::isGuest() || !App::isSite() || $task == 'user.logout') {
return false;
}
$menuId = $this->params->get('menuId', 0);
if (!$menuId) {
return false;
}
$menu = App::get('menu');
$activeMenu = $menu->getActive();
$defaultMenu = $menu->getDefault();
// If routing to the home page...
if ($activeMenu == $defaultMenu) {
// Reset the active menu item and
// overwrite request vars
$menu->setActive($menuId);
$menu->setDefault($menuId, $defaultMenu->language);
$item = $menu->getItem($menuId);
$vars = $item->query;
$vars['Itemid'] = $menuId;
foreach ($vars as $key => $var) {
Request::setVar($key, $var);
}
}
return true;
}
示例15: authorizeTask
/**
* Authorize
*
* @return void
*/
public function authorizeTask()
{
$oauth_token = \Request::getVar('oauth_token');
if (empty($oauth_token)) {
throw new Exception('Forbidden', 403);
}
$db = \App::get('db');
$db->setQuery("SELECT * FROM `#__oauthp_tokens` WHERE token=" . $db->Quote($oauth_token) . " AND user_id=0 LIMIT 1;");
$result = $db->loadObject();
if ($result === false) {
throw new Exception('Internal Server Error', 500);
}
if (empty($result)) {
throw new Exception('Forbidden', 403);
}
if (Request::method() == 'GET') {
$this->view->oauth_token = $oauth_token;
$this->view->display();
return;
}
if (Request::method() == 'POST') {
$token = Request::get('token', '' . 'post');
if ($token != sha1($this->verifier)) {
throw new Exception('Forbidden', 403);
}
echo "posted";
return;
}
throw new Exception('Method Not Allowed', 405);
}