本文整理汇总了PHP中Environment::getHttpRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP Environment::getHttpRequest方法的具体用法?PHP Environment::getHttpRequest怎么用?PHP Environment::getHttpRequest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Environment
的用法示例。
在下文中一共展示了Environment::getHttpRequest方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Dispatch an HTTP request to a routing debugger. Please don't call directly.
*/
public static function run()
{
if (!self::$enabled || Environment::getMode('production')) {
return;
}
self::$enabled = FALSE;
$debugger = new self(Environment::getApplication()->getRouter(), Environment::getHttpRequest());
$debugger->paint();
}
示例2: renderDefault
public function renderDefault()
{
$this->template->form = $this->getComponent('loginForm');
$referer = Environment::getHttpRequest()->getReferer();
if ($referer) {
if ($referer->path === $this->link('Settings:changeLogin')) {
$this->template->msg = __('Now login with new username and password.');
}
}
}
示例3: isActive
public static function isActive($item_url)
{
$url = Environment::getHttpRequest()->getUri()->getAbsoluteUri();
$url_arr = parse_url($url);
$item_url_arr = parse_url($item_url);
$url_without_params = $url_arr['host'] . $url_arr['path'];
if (isset($item_url_arr['path'])) {
$item_url_without_params = $item_url_arr['host'] . $item_url_arr['path'];
} else {
$item_url_without_params = $item_url_arr['host'];
}
return $url_without_params == $item_url_without_params;
}
示例4: processRequest
/**
* Handles an incomuing request and saves the data if necessary.
*/
public function processRequest()
{
$request = Environment::getHttpRequest();
if ($request->isPost() && $request->isAjax() && $request->getHeader('X-Callback-Client')) {
$data = json_decode(file_get_contents('php://input'), TRUE);
if (count($data) > 0) {
foreach ($data as $key => $value) {
if (isset($this->items[$key]) && isset($this->items[$key]['callback']) && $value === TRUE) {
callback($this->items[$key]['callback'])->invokeArgs($this->items[$key]['args']);
}
}
}
exit;
}
}
示例5: processRequest
/**
* Handles an incomuing request and saves the data if necessary.
*/
public function processRequest()
{
$request = Environment::getHttpRequest();
if ($request->isPost() && $request->isAjax() && $request->getHeader('X-FTP-Permission-Client')) {
foreach ($this->items as $mode => $items) {
foreach ($items as $item) {
$path = ROOT_DIR . $item;
if (!file_exists($path)) {
throw new FileNotFoundException('File or Directory "' . $path . '" does NOT exist!');
}
// dump($item);
// dump($mode);
chmod($path, $mode);
}
}
echo 'chmod set';
exit;
}
}
示例6: actionDelete
/**
* Removes item from cart
*/
public function actionDelete()
{
// check request
$request = Environment::getHttpRequest();
if (!$request->isMethod('POST')) {
$this->redirectUri(Environment::getHttpRequest()->getReferer()->getAbsoluteUri());
$this->terminate();
return;
}
// find product
$product_id = $request->getPost('product_id', 0);
$amount = intval($request->getPost('amount', 1));
$cart = Environment::getSession(SESSION_ORDER_NS);
$product = mapper::products()->findById($product_id);
if ($product === NULL) {
$this->redirectUri($request->getReferer()->getAbsoluteUri());
$this->terminate();
return;
}
// delete product
if (!isset($cart->products)) {
$cart->products = array();
}
if (isset($cart->products[$product->getId()])) {
$cart->products[$product->getId()] -= $amount;
if ($cart->products[$product->getId()] < 1) {
unset($cart->products[$product->getId()]);
}
}
// calculate total
$cart->total = 0;
mapper::products()->findByIds(array_keys($cart->products));
foreach ($cart->products as $id => $amount) {
$cart->total += intval(mapper::products()->findById($id)->getPrice()) * $amount;
}
// redirect
//$this->redirectUri($request->getReferer()->getAbsoluteUri());
$this->redirect('showCart');
$this->terminate();
return;
}
示例7: add
/**
* Add navigation node as a child
* @staticvar int $counter
* @param string $label
* @param string $url
* @param string $netteLink added - aby sa dalo testovat ifCurrent na cely presenter
* @return NavigationNode
*/
public function add($label, $url, $netteLink = null)
{
$navigationNode = new self();
$navigationNode->label = $label;
$navigationNode->url = $url;
static $counter;
$this->addComponent($navigationNode, ++$counter);
/*added*/
$uri = Environment::getHttpRequest()->getOriginalUri()->getPath();
if ($netteLink) {
$presenter = Environment::getApplication()->getPresenter();
try {
$presenter->link($netteLink);
} catch (InvalidLinkException $e) {
}
$navigationNode->isCurrent = $presenter->getLastCreatedRequestFlag("current");
} else {
$navigationNode->isCurrent = $url == $uri;
}
/*added end*/
return $navigationNode;
}
示例8: actionFulltext
public function actionFulltext()
{
// get dirty
$this->template->num_docs = fulltext::index()->numDocs();
$this->template->dirty = fulltext::dirty();
$this->template->num_dirty = count($this->template->dirty);
// index
$index = fulltext::index();
$this->template->update_now = array_slice($this->template->dirty, 0, 50);
if (!empty($this->template->update_now)) {
adminlog::log(__('Attempt to update fulltext'));
}
foreach (mapper::products()->findByIds($this->template->update_now) as $product) {
// delete old
foreach ($index->termDocs(new Zend_Search_Lucene_Index_Term($product->getId(), 'id')) as $id) {
$index->delete($id);
}
// add
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::Keyword('id', $product->getId()));
$doc->addField(Zend_Search_Lucene_Field::UnStored('name', $product->getName()));
$doc->addField(Zend_Search_Lucene_Field::UnStored('nice_name', $product->getNiceName()));
$doc->addField(Zend_Search_Lucene_Field::Unstored('code', $product->getCode()));
$doc->addField(Zend_Search_Lucene_Field::UnStored('meta_keywords', $product->getMetaKeywords()));
$doc->addField(Zend_Search_Lucene_Field::UnStored('meta_description', $product->getMetaDescription()));
$description = '';
if (strlen($product->getDescription()) < 1) {
if (strlen($product->getMetaDescription()) < 1) {
$description = $product->getName();
} else {
$description = $product->getMetaDescription();
}
} else {
$description = $product->getDescription();
}
if ($manufacturer = mapper::products()->findManufacturerOf($product->getId())) {
$doc->addField(Zend_Search_Lucene_Field::UnStored('manufacturer', $manufacturer->getName()));
$description .= ' ' . $manufacturer->getName();
$description .= ' ' . $manufacturer->getDescription();
}
if ($category = mapper::products()->findCategoryOf($product->getId())) {
$doc->addField(Zend_Search_Lucene_Field::UnStored('category', $category->getName()));
$description .= ' ' . $category->getName();
$description .= ' ' . $category->getDescription();
}
$description .= ' ' . $product->getName();
$doc->addField(Zend_Search_Lucene_Field::UnStored('description', $description));
$index->addDocument($doc);
}
// undirty updated
foreach ($this->template->update_now as $id) {
fulltext::dirty($id, FALSE);
}
// log
adminlog::log(__('Successfully updated %d fulltext items, %d remains'), count($this->template->update_now), $this->template->num_dirty - count($this->template->update_now));
// refresh
$s = 5;
Environment::getHttpResponse()->setHeader('Refresh', $s . '; ' . (string) Environment::getHttpRequest()->getOriginalUri());
$this->template->next_update = $s;
}
示例9: getRequest
/**
* @return IHttpRequest
*/
public function getRequest()
{
return Environment::getHttpRequest();
}
示例10: actionUpload
/**
* Upload souboru
*/
public function actionUpload()
{
// check user rights
// if (!Environment::getUser()->isAllowed("files", "upload")) {
// $this->sendError("Access denied.");
// }
// path
$folder = Environment::getHttpRequest()->getPost("folder");
try {
$folderPath = $this->getFolderPath($folder);
} catch (InvalidArgumentException $e) {
$this->sendError("Folder does not exist or is not writeable.");
}
// file
$file = Environment::getHttpRequest()->getFile("file");
// check
if ($file === null || !$file->isOk()) {
$this->sendError("Upload error.");
}
// move
$fileName = String::webalize($file->getName(), ".");
$path = $folderPath . "/" . $fileName;
if (@$file->move($path)) {
@chmod($path, 0666);
if ($file->isImage()) {
$this->payload->filename = ($folder ? "{$folder}/" : "") . $fileName;
$this->payload->type = "image";
} else {
$this->payload->filename = $this->baseFolderUri . ($folder ? "{$folder}/" : "") . $fileName;
$this->payload->type = "file";
}
$this->terminate(new JsonResponse($this->payload, "text/plain"));
} else {
$this->sendError("Move failed.");
}
}
示例11: getHttpRequest
/**
* @return IHttpRequest
*/
protected function getHttpRequest()
{
return class_exists('Environment') ? Environment::getHttpRequest() : new HttpRequest();
}
示例12: handleBuy
$uri = $this->mycontrol->link('this?x=1&round=1#frag');
echo "3.12 {$uri}\n\n";
$uri = $this->mycontrol->link('//this?x=1&round=1#frag');
echo "3.13 {$uri}\n\n";
}
/**
* @view: default
*/
public function handleBuy($x = 1, $y = 1)
{
}
}
class OtherPresenter extends TestPresenter
{
}
class Submodule_OtherPresenter extends TestPresenter
{
}
Environment::setVariable('appDir', dirname(__FILE__));
$httpRequest = Environment::getHttpRequest();
$uri = clone $httpRequest->getUri();
$uri->scriptPath = '/index.php';
$uri->host = 'localhost';
$httpRequest->setUri($uri);
$application = Environment::getApplication();
$application->setRouter(new SimpleRouter());
$request = new PresenterRequest('Test', HttpRequest::GET, array());
TestPresenter::$invalidLinkMode = TestPresenter::INVALID_LINK_WARNING;
$presenter = new TestPresenter($request);
$presenter->autoCanonicalize = FALSE;
$presenter->run();
示例13: processRequest
/**
* Handles an incomuing request and saves the data if necessary.
*/
public function processRequest()
{
// Try starting the session
try {
$session = Environment::getSession('Nette.Addons.TranslationPanel');
} catch (InvalidStateException $e) {
$session = FALSE;
}
$request = Environment::getHttpRequest();
if ($request->isPost() && $request->isAjax() && $request->getHeader('X-Translation-Client')) {
$data = json_decode(file_get_contents('php://input'));
if ($data) {
if ($session) {
$stack = isset($session['stack']) ? $session['stack'] : array();
}
foreach ($data as $string => $value) {
$this->translator->setTranslation($string, $value);
if ($session && isset($stack[$string])) {
unset($stack[$string]);
}
}
$this->translator->save();
if ($session) {
$session['stack'] = $stack;
}
}
}
}
示例14: array
'error' => array(
'avatar' => 0,
),
'size' => array(
'avatar' => 3013,
),
),
);
*/
// invalid #1
$_POST = array('name' => array(NULL), 'note' => array(NULL), 'gender' => array(NULL), 'send' => array(NULL), 'country' => array(NULL), 'countrym' => '', 'password' => array(NULL), 'firstperson' => TRUE, 'secondperson' => array('age' => array(NULL)), 'submit1' => array(NULL), 'userid' => array(NULL));
$_FILES = array('avatar' => array('name' => 'readme.txt', 'type' => 'text/plain'), 'secondperson' => array('name' => array(NULL), 'type' => array(NULL), 'tmp_name' => array(NULL), 'error' => array(NULL), 'size' => array(NULL)));
echo "<h2>Invalid data #1</h2>\n";
echo "Submitted?\n";
$dolly = clone $form;
Environment::getHttpRequest()->initialize();
Debug::dump(gettype($dolly->isSubmitted()));
echo "Values:\n";
Debug::dump($dolly->getValues());
// invalid #2
$_POST = array('name' => "invalidªªªutf", 'note' => "invalidªªªutf", 'userid' => "invalidªªªutf", 'secondperson' => array(NULL));
$tmp = array('name' => 'readme.txt', 'type' => 'text/plain', 'tmp_name' => 'C:\\PHP\\temp\\php1D5B.tmp', 'error' => 0, 'size' => 209);
$_FILES = array('name' => $tmp, 'note' => $tmp, 'gender' => $tmp, 'send' => $tmp, 'country' => $tmp, 'countrym' => $tmp, 'password' => $tmp, 'firstperson' => $tmp, 'secondperson' => array('age' => $tmp), 'submit1' => $tmp, 'userid' => $tmp);
echo "<h2>Invalid data #2</h2>\n";
echo "Submitted?\n";
$dolly = clone $form;
Environment::getHttpRequest()->initialize();
Debug::dump(gettype($dolly->isSubmitted()));
echo "Values:\n";
Debug::dump($dolly->getValues());
示例15: getItemsPerPageCookie
/**
* get itemsPerPage cookie for current PresenterComponent
*
* @param PresenterComponent
* @return int
*/
public static function getItemsPerPageCookie($_this)
{
return Environment::getHttpRequest()->getCookie(self::getCookieItemsPerPageKey($_this));
}