public function testSetGetParams() { $params = array('foo' => 'bar', 'boo' => 'bah', 'fee' => 'fi'); $this->_request->setParams($params); $received = $this->_request->getParams(); $this->assertSame($params, array_intersect_assoc($params, $received)); }
/** * @group ZF-5107 */ public function testGetParamsShouldHonorParamSourcesSetting() { $_GET = array('foo' => 'bar'); $_POST = array('foo' => 'baz'); $this->_request->setParamSources(array('_POST')); $params = $this->_request->getParams(); $this->assertEquals(array('foo' => 'baz'), $params); }
public function testSetNullParamsUnsetsKeys() { $this->_request->setParams(array('foo' => 'bar', 'bar' => 'baz')); $this->assertEquals('bar', $this->_request->getParam('foo')); $this->assertEquals('baz', $this->_request->getParam('bar')); $this->_request->setParams(array('foo' => null)); $params = $this->_request->getParams(); $this->assertFalse(isset($params['foo'])); $this->assertTrue(isset($params['bar'])); }
public function testGetParamsWithGetAndPost() { $_GET = array('get' => true); $_POST = array('post' => true); $params = array('foo' => 'bar', 'boo' => 'bah', 'fee' => 'fi'); $this->_request->setParams($params); $expected = $params + $_GET + $_POST; $received = $this->_request->getParams(); $this->assertSame($params, array_intersect_assoc($params, $received)); }
/** * Конструктор модели * @param null|\Zend_Application_Bootstrap_Bootstrap $bootstrap */ public function __construct(Zend_Application_Bootstrap_Bootstrap $bootstrap = null) { if ($bootstrap instanceof Zend_Application_Bootstrap_Bootstrap) { $this->_boot = $bootstrap; } else { $this->_boot = Zend_Controller_Front::getInstance()->getParam('bootstrap'); } $this->_cnf = $this->_boot->getOptions(); $this->_request = $this->_boot->getResource('Request'); $this->_params = $this->_request->getParams(); $this->_usersession = $this->_boot->getResource('UserSession'); $this->_db = $this->_boot->getResource('Db'); $this->_translate = $this->_boot->getResource('Translate'); if (isset($this->_params['module'])) { $this->setModule($this->_params['module']); } if (method_exists($this, 'init')) { $this->init(); } }
/** * Parse more Zend_Controller_Request->getPathInfo() * @param Zend_Controller_Request_Http $request * @static * @return boolean */ public static function getPathParts($request) { $pathParts = $request->getParams(); l($pathParts, __METHOD__ . ' $request->getParams()', Zend_Log::DEBUG); $pathParts['host'] = (!empty($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST']) . "/"; // SERVER_NAME? $pathParts['module'] = $request->getModuleName(); /* $pathParts = array( 'host' => (!empty($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST']) . "/", // SERVER_NAME? 'module' => $request->getModuleName(), 'controller' => $request->getParam('controller'), // AKA $request->getControllerName() 'action' => $request->getParam('action'), // AKA $request->getActionName() 'id' => $request->getParam('id'), // since 5/7/2009 (WAS @deprecated, moved into Zx_IndexController) 'page' => $request->getParam('page') // since 5/7/2009 (WAS @deprecated, moved into Zx_IndexController) ); */ // pre-router data @deprecated, use Zend_Controller_Router_Route for route rules! /* $s = substr($_SERVER['REQUEST_URI'], 1, -1); $a = explode('/', $s); $pathParts['controller0'] = $a[0]; if (count($a) > 1) { $pathParts['action0'] = $a[1]; } */ $prefix = self::getHttpPrefix(); $pathParts['path'] = $pathParts['controller'] . "/" . ($pathParts['action'] == 'index' ? '' : $pathParts['action'] . "/"); $pathParts['hostpath'] = $pathParts['host'] . $pathParts['path']; $pathParts['url'] = $prefix . $pathParts['path']; $pathParts['urlController'] = $prefix . $pathParts['controller'] . "/"; // controller only Zend_Registry::set('path', $pathParts); Zend_Registry::set('page', isset($pathParts['page']) ? $pathParts['page'] : 1); // set to 1 if non-exists #echo "DEBUG:<br><textarea rows=10 cols=100>" . print_r($pathParts, 1) . "</textarea><br>";die; /* Array ( [host] => il [module] => default [controller] => index [action] => index [id] => [url] => http://il/index/index/ ) */ return $pathParts; }
/** * */ public function guardar() { $this->load->library(array("module/noticias/noticias_validar")); header('Content-type: application/json'); $request = new Zend_Controller_Request_Http(); $params = $request->getParams(); //print_r($params); if ($this->noticias_validar->esValido($params)) { $noticia = $this->_noticia_model->getById($params["id"]); if (is_null($noticia)) { $this->_noticia_model->insert(array("fecha" => DATE("Y-m-d H:i:s"), "nombre" => $params["titulo"], "descripcion" => $params["descripcion"], "id_usuario" => $this->session->userdata('session_idUsuario'))); } else { $this->_noticia_model->update(array("nombre" => $params["titulo"], "descripcion" => $params["descripcion"]), $noticia->id); } echo json_encode(array("error" => $this->noticias_validar->getErrores(), "correcto" => true)); } else { echo json_encode(array("error" => $this->noticias_validar->getErrores(), "correcto" => false)); } }
/** * Return Original Attribute value from Request * * @param Zend_Controller_Request_Http $request * @return mixed */ protected function _getRequestValue(Zend_Controller_Request_Http $request) { $attrCode = $this->getAttribute()->getAttributeCode(); if ($this->_requestScope) { if (strpos($this->_requestScope, '/') !== false) { $params = $request->getParams(); $parts = explode('/', $this->_requestScope); foreach ($parts as $part) { if (isset($params[$part])) { $params = $params[$part]; } else { $params = array(); } } } else { $params = $request->getParam($this->_requestScope); } if (isset($params[$attrCode])) { $value = $params[$attrCode]; } else { $value = false; } if (!$this->_requestScopeOnly && $value === false) { $value = $request->getParam($attrCode, false); } } else { $value = $request->getParam($attrCode, false); } return $value; }
private function _getParent(Zend_Controller_Request_Http $request) { $controller = $request->getControllerName(); $action = $request->getActionName(); if ($controller == 'index' && $action == 'collections') { // we don't need to know anything: we are in the root return '0'; } if ($controller == 'browse') { // we are in mode selection // parent is the same, but action = share if ($action == 'mode') { // rebuild the query, keep only location and provider $parent = array('controller' => 'browse', 'action' => 'share', 'p' => $request->getParam('p'), 'l' => $request->getParam('l')); return X_Env::encode(http_build_query($parent)); //$request->getParams(); } // if ($action == 'share') { // we need the providerObj to know the parent :( $location = $request->getParam('l', false); if ($location === false) { // NICE, parent is the ROOT return '0'; } $providerId = $request->getParam('p'); $providerObj = X_VlcShares_Plugins::broker()->getPlugins($providerId); if ($providerObj instanceof X_VlcShares_Plugins_ResolverInterface) { // easy: provider will give us the parent $location = X_Env::decode($location); return X_Env::encode($providerObj->getParentLocation($location)); } // so providerObj is not Resolver.... f**k // rude way? return '0'; } if ($action == 'selection') { // same as 'controls' Q_Q return '0'; } } if ($controller == 'controls') { // f**k: how can i manage this? return '0'; } $data = array('controller' => $controller, 'action' => $action); $data = array_merge($data, $request->getParams()); return X_Env::encode(http_build_query($data)); }
/** * Gets all input. * * @return array */ public function getInput() { return $this->_request->getParams(); }
public function getParams() { $ret = parent::getParams(); if (in_array(self::USE_VARS, $this->_paramSources) && is_array($this->_vars)) { $ret += $this->_vars; } return $ret; }
/** * Ustawia wartosci filtrow * * Nie wymaga przeslania danych via POST * * @param Zend_Controller_Request_Http $request * @return Logic_Search_Abstract */ public function setFilterDataFromRequest(Zend_Controller_Request_Http $request) { if (!is_object($this->_form)) { throw new Logic_Search_Exception('Nie ustanowiono obiektu formularza filtrow'); } if ($this->_form->isValid($request->getParams())) { $this->saveFilterData($this->_form->getValues()); } $this->_form->setDefaults($this->getFilterData()); return $this; }
echo 'Method: ', $request->getMethod(), '<br/>', "\n"; echo 'Headrs: <br/>', "\n"; echo ' Accept: ', $request->getHeader('accept'), '<br/>', "\n"; echo ' User-agent: ', $request->getHeader('user-agent'), '<br/>', "\n"; echo ' Accept-charset: ', $request->getHeader('accept-charset'), '<br/>', "\n"; echo ' Accept-language: ', $request->getHeader('accept-language'), '<br/>', "\n"; if ($request->getMethod() == 'PUT') { $fh = fopen('php://input', 'r'); if (!$fh) { echo 'Can\'t load PUT data'; die; } $data = ''; while (!feof($fh)) { $data .= fgets($fh); } fclose($fh); } else { $data = print_r($request->getParams(), true); } echo 'Data: ', $data; echo '<br/>', "\n", 'Server vars: ', '<br/>', "\n"; echo '<br/>', "\n", '$_SERVER: ', '<br/>', "\n"; print_r($_SERVER); echo '<br/>', "\n", '$_ENV: ', '<br/>', "\n"; print_r($_ENV); echo '<br/>', "\n", '$_POST: ', '<br/>', "\n"; print_r($_POST); echo '<br/>', "\n", '$_GET: ', '<br/>', "\n"; print_r($_GET); }