本文整理汇总了PHP中Zend_Controller_Request_Http::isPost方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Controller_Request_Http::isPost方法的具体用法?PHP Zend_Controller_Request_Http::isPost怎么用?PHP Zend_Controller_Request_Http::isPost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Controller_Request_Http
的用法示例。
在下文中一共展示了Zend_Controller_Request_Http::isPost方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testIsPost
public function testIsPost()
{
$_SERVER['REQUEST_METHOD'] = 'POST';
$this->assertTrue($this->_request->isPost());
$_SERVER['REQUEST_METHOD'] = 'GET';
$this->assertFalse($this->_request->isPost());
}
示例2: getRequestParameters
public function getRequestParameters()
{
if ($this->request->isPost()) {
return $this->request->getPost();
} else {
return $this->request->getQuery();
}
}
示例3: addAction
public function addAction()
{
$form = new Front_Form_Contact();
if ($this->_request->isPost()) {
$data = $this->_request->getPost();
if ($form->isValid($data)) {
$dataFiltrees = $form->getValues();
$contact = new Application_Model_Contact();
$contact->setPrenom($dataFiltrees['prenom'])->setNom($dataFiltrees['nom'])->setEmail($dataFiltrees['email'])->setTelephone($dataFiltrees['telephone']);
$this->mapper->insert($contact);
$this->_flashMessenger->addMessage('Le contact ' . $contact->getPrenom() . ' a bien été créé');
$this->_redirector->gotoRouteAndExit(['controller' => 'contact'], null, true);
}
}
$this->view->contactForm = $form;
}
示例4: editAction
public function editAction()
{
$itemId = $this->_request->getParam('id');
if (is_null($itemId)) {
$this->getRedirector()->gotoSimpleAndExit('index');
}
$page = $this->getModelMapper()->find($itemId, $this->getModel());
if (is_null($page)) {
throw new Zend_Controller_Action_Exception("Страница не найдена", 404);
}
//$this->view->item = $page;
$form = $this->getForm('edit');
$form->addElement('hidden', 'currentUrl');
$element = $form->getElement('currentUrl');
$element->setValue($this->_hostHttp->getServer('REQUEST_URI'));
$form->getDisplayGroup('basic')->addElement($element);
$dataPage = $page->getOptions();
foreach ($dataPage as $key => $value) {
$form->setDefault($key, $value);
}
foreach ($form->getElements() as $key => $element) {
if ($element instanceof Zend_Form_Element_Image) {
$imageValue = $form->getValue($element->getAttrib('data-input')) != '' ? $form->getValue($element->getAttrib('data-input')) : '/files/images/product/2012-05-22_foto_nv.jpg';
$form->setDefault($element->getName(), $imageValue);
}
}
if ($this->_hostHttp->isPost()) {
if ($form->isValid($this->_hostHttp->getPost())) {
$this->saveFormData($form);
$this->clearCache($this->_getNamespace());
$this->getRedirector()->gotoUrlAndExit($this->_request->getParam('currentUrl'));
}
$form->setDefaults($form->getValues());
}
$colsTable = $this->getModelMapper()->getDbTable()->info('cols');
$uri = in_array('full_path', $colsTable) ? $page->getFullPath() : $page->getPath();
$config = array(Zend_Navigation_Page_Mvc::factory(array('label' => 'На сайт', 'uri' => '/' . strtolower($this->getNameModule()) . '/' . $uri . '/')));
$containerNav = new Zend_Navigation($config);
$this->view->assign(array('item' => $page, 'form' => $form, 'container_nav' => $containerNav));
}
示例5: widget
/**
* Implements {@link iPMS_Widget_Interface::widget()}
*
* @param Zend_Controller_Request_Http $request
* @return Zend_Form|null A Zend_Form instance or null if user is already authenticated
*/
public function widget(Zend_Controller_Request_Http $request)
{
$auh = Zend_Auth::getInstance();
if (!$auh->hasIdentity()) {
$form = $this->getForm('loginForm');
if ($request->isPost() && is_array($request->getPost('loginForm')) && $form->isValid($request->getPost('loginForm'))) {
$authDbAdapter = new Zend_Auth_Adapter_DbTable(null, 'users', 'username', 'password', 'MD5(?) AND active = 1');
$authDbAdapter->setIdentity($form->getValue('username'))->setCredential($form->getValue('password'));
$result = $authDbAdapter->authenticate();
if ($result->isValid()) {
$auh->getStorage()->write($authDbAdapter->getResultRowObject(null, 'password'));
Zend_Session::regenerateId();
// Protection against session's fixation attacks
/**
* @var $redirector Zend_Controller_Action_Helper_Redirector
*/
$redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
$redirector->gotoUrl('/');
}
}
return $form;
}
return null;
}
示例6: isConfirmedPost
/**
* Returns true if the request method is POST and an _xfConfirm parameter exists and is true
*
* @return boolean
*/
public function isConfirmedPost()
{
return $this->_request->isPost() && $this->_input->filterSingle('_xfConfirm', XenForo_Input::UINT);
}
示例7: match
public function match(Zend_Controller_Request_Http $request)
{
$this->fetchDefault();
$front = $this->getFront();
$p = explode('/', trim($request->getPathInfo(), '/'));
// get module name
if ($request->getModuleName()) {
$module = $request->getModuleName();
} else {
$p = explode('/', trim($request->getPathInfo(), '/'));
$module = !empty($p[0]) ? $p[0] : $this->getFront()->getDefault('module');
}
if (!$module) {
return false;
}
$realModule = $this->getModuleByFrontName($module);
if (!$realModule) {
if ($moduleFrontName = array_search($module, $this->_modules)) {
$realModule = $module;
$module = $moduleFrontName;
} else {
return false;
}
}
if (!Mage::app()->isInstalled()) {
Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('install'))->sendResponse();
exit;
}
if (Mage::app()->isInstalled() && !$request->isPost()) {
$shouldBeSecure = substr(Mage::getStoreConfig('web/unsecure/base_url'), 0, 5) === 'https' || Mage::getStoreConfigFlag('web/secure/use_in_adminhtml') && substr(Mage::getStoreConfig('web/secure/base_url'), 0, 5) === 'https';
if ($shouldBeSecure && !Mage::app()->getStore()->isCurrentlySecure()) {
$url = Mage::getBaseUrl('link', true) . ltrim($request->getPathInfo(), '/');
Mage::app()->getFrontController()->getResponse()->setRedirect($url)->sendResponse();
exit;
}
}
// get controller name
if ($request->getControllerName()) {
$controller = $request->getControllerName();
} else {
$controller = !empty($p[1]) ? $p[1] : $front->getDefault('controller');
}
$controllerFileName = $this->getControllerFileName($realModule, $controller);
if (!$controllerFileName || !is_readable($controllerFileName)) {
$controller = 'index';
$action = 'noroute';
$controllerFileName = $this->getControllerFileName($realModule, $controller);
}
$controllerClassName = $this->getControllerClassName($realModule, $controller);
if (!$controllerClassName) {
$controller = 'index';
$action = 'noroute';
$controllerFileName = $this->getControllerFileName($realModule, $controller);
}
// get action name
if (empty($action)) {
if ($request->getActionName()) {
$action = $request->getActionName();
} else {
$action = !empty($p[2]) ? $p[2] : $front->getDefault('action');
}
}
// include controller file if needed
if (!class_exists($controllerClassName, false)) {
include $controllerFileName;
if (!class_exists($controllerClassName)) {
throw Mage::exception('Mage_Core', Mage::helper('core')->__('Controller file was loaded but class does not exist'));
}
}
// instantiate controller class
$controllerInstance = new $controllerClassName($request, $front->getResponse());
if (!$controllerInstance->hasAction($action)) {
return false;
}
// set values only after all the checks are done
$request->setModuleName($module);
$request->setControllerName($controller);
$request->setActionName($action);
// set parameters from pathinfo
for ($i = 3, $l = sizeof($p); $i < $l; $i += 2) {
$request->setParam($p[$i], isset($p[$i + 1]) ? $p[$i + 1] : '');
}
// dispatch action
$request->setDispatched(true);
$controllerInstance->dispatch($action);
return true;
#$request->isDispatched();
}
示例8: _assertIsPost
/**
* Determines whether the given request is a post request
*
* @param HttpRequest $request
* @return boolean
*/
protected function _assertIsPost(HttpRequest $request)
{
return $request->isPost();
}
示例9: onAdminMenu
/**
* WordPress admin_menu hook
* Initializes an admin panel from a Zend_Form object and injects it into
* WordPress.
*
* @return Zend
*/
public function onAdminMenu()
{
if ($form = $this->bootstrap('admin')->getResource('admin')) {
$frontController = $this->bootstrap('frontController')
->getResource('frontController');
$request = new Zend_Controller_Request_Http();
$view = new Vulnero_Admin_View();
$view->form = $form;
if ($request->isPost() && $form->isValid($request->getPost())) {
// handle save
}
add_options_page(
'Vulnero Title', // Title
'Vulnero Menu Title', // Menu Title
'manage_options', // WordPress Access Level
'vulnero', // Plugin Name
array($view, 'renderWordPress')
);
}
}
示例10: array
$request = new Zend_Controller_Request_Http();
// setup the form
$form = new Zend_Form();
$form->setMethod("post");
$form->setAttrib("enctype", Zend_Form::ENCTYPE_MULTIPART);
// file element, upload is optional, but if file is uploaded run multiple validators
$file1 = $form->createElement("file", "file1");
$file1->setRequired(false)->setLabel("File:")->addValidator('Count', true, 2)->addValidator('Size', true, "100KB")->addValidator('Extension', true, 'jpg')->addValidator('MimeType', true, array('image/jpeg'))->addValidator('ImageSize', true, array(0, 0, 340, 480));
// add another file element with same validators
$file2 = clone $file1;
$file2->setName("file2");
$submit = $form->createElement("submit", "submit");
$submit->setLabel("GO!");
$form->addElements(array($file1, $file2, $submit));
// check the form
if ($request->isPost()) {
$formData = $request->getPost();
if ($form->isValid($formData)) {
echo "FORM VALID";
} else {
print_r($form->getMessages());
}
}
?>
<html>
<head>
<title>Test</title>
</head>
<body>
<?php
echo $form->render(new Zend_View());