本文整理汇总了PHP中Environment::getHttpResponse方法的典型用法代码示例。如果您正苦于以下问题:PHP Environment::getHttpResponse方法的具体用法?PHP Environment::getHttpResponse怎么用?PHP Environment::getHttpResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Environment
的用法示例。
在下文中一共展示了Environment::getHttpResponse方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionDefault
public function actionDefault($exception)
{
$application = Environment::getApplication();
$application->catchExceptions = FALSE;
if ($this->isAjax()) {
$this->payload->error = (string)$exception;
$this->sendPayload();
} else {
$this->template->robots = 'noindex,noarchive';
if ($exception instanceof /*Nette\Application\*/BadRequestException) {
Environment::getHttpResponse()->setCode($exception->getCode());
switch($exception->getCode()) {
case 403:
$this->template->title = _('403 Permission denied');
break;
default:
Environment::getHttpResponse()->setCode(404);
$this->template->title = _('404 Not Found');
break;
}
} else {
Environment::getHttpResponse()->setCode(500);
$this->template->title = _("Don't recognize error");
Debug::processException($exception);
}
}
}
示例2: send
/**
* Sends response to output.
* @return void
*/
public function send()
{
/*Nette\*/
Environment::getHttpResponse()->setContentType($this->contentType);
/*Nette\*/
Environment::getHttpResponse()->expire(FALSE);
echo json_encode($this->payload);
}
示例3: send
/**
* Sends response to output.
* @return void
*/
public function send()
{
/*Nette\*/
Environment::getHttpResponse()->setContentType($this->contentType);
/*Nette\*/
Environment::getHttpResponse()->setHeader('Content-Disposition', 'attachment; filename="' . $this->name . '"');
readfile($this->file);
}
示例4: actionDefault
public function actionDefault($path = '', $page_number = 0, $letter = NULL)
{
// get nice name
$path = explode('/', rtrim($path, '/'));
$last = array_pop($path);
$rest = implode('/', $path);
// what's with rest?
if (!empty($rest)) {
$this->redirect(301, 'this', $last);
$this->terminate();
return;
}
// default page?
if (empty($last)) {
$this->setView('default');
$this->template->path = '';
$this->template->page = NULL;
return;
}
$this->template->path = $last;
// try to find it in database
$page = mapper::pages()->findByNiceName($last);
$this->template->page = $page;
if ($page === NULL) {
$this->setView('notfound');
Environment::getHttpResponse()->setCode(404);
} else {
if ($page->getRef() === NULL) {
$this->setView('page');
} else {
$this->setView(get_class($page->getRef()));
$this->template->{get_class($page->getRef())} = $page->getRef();
$this->template->letter = $letter;
$this->template->have_letter = TRUE;
}
$this->template->title = $page->getName();
}
$this->template->page_number = $page_number;
}
示例5: renderDefault
/**
* @return void
*/
public function renderDefault($exception)
{
if ($this->isAjax()) {
$this->getPayload()->events[] = array('error', $exception->getMessage());
$this->terminate();
} else {
$this->template->robots = 'noindex,noarchive';
$httpResponse = Environment::getHttpResponse();
if ($exception instanceof BadRequestException) {
if (!$httpResponse->isSent()) {
$httpResponse->setCode($exception->getCode());
}
$this->template->title = '404 Not Found';
$this->setView('404');
} else {
if (!$httpResponse->isSent()) {
$httpResponse->setCode(500);
}
$this->template->title = '500 Internal Server Error';
$this->setView('500');
Debug::processException($exception);
}
}
}
示例6: getHttpResponse
/**
* @return IHttpResponse
*/
protected function getHttpResponse()
{
return Environment::getHttpResponse();
}
示例7: 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;
}
示例8: getResponse
/**
* @return IHttpResponse
*/
public function getResponse()
{
return Environment::getHttpResponse();
}
示例9: send
/**
* Sends response to output.
* @return void
*/
public function send()
{
Environment::getHttpResponse()->redirect($this->uri, $this->code);
}
示例10:
<h1>Nette\Environment services test</h1>
<pre>
<?php
require_once '../../Nette/loader.php';
/*use Nette\Debug;*/
/*use Nette\Environment;*/
echo "Environment::getHttpResponse\n";
$obj = Environment::getHttpResponse();
Debug::dump($obj->class);
echo "Environment::getApplication\n";
$obj = Environment::getApplication();
Debug::dump($obj->class);
echo "Environment::getCache(...)\n";
Environment::setVariable('tempDir', __FILE__);
$obj = Environment::getCache('my');
Debug::dump($obj->class);
/* in PHP 5.3
echo "Environment::getXyz(...)\n";
Environment::setServiceAlias('Nette\Web\IUser', 'xyz');
$obj = Environment::getXyz();
Debug::dump($obj->class);
*/
示例11: setItemsPerPageCookie
/**
* set itemsPerPage cookie for current PresenterComponent
*
* @param PresenterComponent
* @param int
*/
public static function setItemsPerPageCookie($_this, $itemsPerPage)
{
Environment::getHttpResponse()->setCookie(self::getCookieItemsPerPageKey($_this), $itemsPerPage, Tools::YEAR);
}
示例12: send
/**
* Sends response to output.
* @return void
*/
public function send()
{
Environment::getHttpResponse()->setContentType($this->contentType);
Environment::getHttpResponse()->setExpiration(FALSE);
echo json_encode($this->payload);
}
示例13: renderBegin
public function renderBegin()
{
$response = Environment::getHttpResponse();
if ($this->docType == self::XHTML_1_STRICT && $this->contentType == self::APPLICATION_XHTML && ($this->forceContentType || $this->isClientXhtmlCompatible())) {
$contentType = self::APPLICATION_XHTML;
$response->setHeader('Vary', 'Accept');
echo "<?xml version='1.0' encoding='utf-8'?>\n";
} else {
$contentType = self::TEXT_HTML;
Environment::getHttpResponse()->setContentType($contentType, 'utf-8');
}
$response->setContentType($contentType, 'utf-8');
echo $this->getDocTypeString() . "\n";
echo '<html' . ($this->xml ? ' xmlns="http://www.w3.org/1999/xhtml" xml:lang="' . $this->language . '" lang="' . $this->language . '"' : '') . ">\n";
echo "<head>\n";
$metaLanguage = Html::el('meta')->content($this->language);
$metaLanguage->attrs['http-equiv'] = 'Content-Language';
echo $metaLanguage . "\n";
$metaContentType = Html::el('meta')->content($contentType);
$metaContentType->attrs['http-equiv'] = 'Content-Type';
echo $metaContentType . "\n";
echo Html::el('title', $this->getTitleString()) . "\n";
if ($this->favicon != '') {
echo Html::el('link')->rel('shortcut icon')->href(Environment::getVariable('baseUri') . $this->favicon) . "\n";
}
foreach ($this->metaTags as $name => $content) {
echo Html::el('meta')->name($name)->content($content) . "\n";
}
}