当前位置: 首页>>代码示例>>PHP>>正文


PHP Environment::getHttpResponse方法代码示例

本文整理汇总了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);
			}
		}
	}
开发者ID:norbe,项目名称:AutoUse,代码行数:31,代码来源:ErrorPresenter.php

示例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);
 }
开发者ID:vlki,项目名称:nette,代码行数:12,代码来源:JsonResponse.php

示例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);
 }
开发者ID:vlki,项目名称:nette,代码行数:12,代码来源:DownloadResponse.php

示例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;
 }
开发者ID:jakubkulhan,项目名称:shopaholic,代码行数:39,代码来源:ShowPresenter.php

示例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);
         }
     }
 }
开发者ID:vrana,项目名称:nette,代码行数:27,代码来源:ErrorPresenter.php

示例6: getHttpResponse

 /**
  * @return IHttpResponse
  */
 protected function getHttpResponse()
 {
     return Environment::getHttpResponse();
 }
开发者ID:jakubkulhan,项目名称:shopaholic,代码行数:7,代码来源:Presenter.php

示例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;
 }
开发者ID:jakubkulhan,项目名称:shopaholic,代码行数:60,代码来源:ContentPresenter.php

示例8: getResponse

 /**
  * @return IHttpResponse
  */
 public function getResponse()
 {
     return Environment::getHttpResponse();
 }
开发者ID:bazo,项目名称:Mokuji,代码行数:7,代码来源:HttpContext.php

示例9: send

 /**
  * Sends response to output.
  * @return void
  */
 public function send()
 {
     Environment::getHttpResponse()->redirect($this->uri, $this->code);
 }
开发者ID:radypala,项目名称:maga-website,代码行数:8,代码来源:RedirectingResponse.php

示例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);
*/
开发者ID:vrana,项目名称:nette,代码行数:23,代码来源:test.service.php

示例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);
 }
开发者ID:radypala,项目名称:maga-website,代码行数:10,代码来源:Cookie.php

示例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);
 }
开发者ID:romcok,项目名称:treeview,代码行数:10,代码来源:JsonResponse.php

示例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";
     }
 }
开发者ID:bazo,项目名称:Mokuji,代码行数:29,代码来源:HeaderControl.php


注:本文中的Environment::getHttpResponse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。