當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Nette\Environment類代碼示例

本文整理匯總了PHP中Nette\Environment的典型用法代碼示例。如果您正苦於以下問題:PHP Environment類的具體用法?PHP Environment怎麽用?PHP Environment使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Environment類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: dataFormatTemplateFiles

	public function dataFormatTemplateFiles()
	{
		$context = \Nette\Environment::getContext();
		return array(
			array('Nella\Foo\Bar::render', array(
				$context->params['appDir'] . "/Foo/Bar.latte",
				$context->params['appDir'] . "/templates/Foo/Bar.latte",
				__DIR__ . "/Foo/Bar.latte",
				__DIR__ . "/templates/Foo/Bar.latte",
				NELLA_FRAMEWORK_DIR . "/Foo/Bar.latte",
				NELLA_FRAMEWORK_DIR . "/templates/Foo/Bar.latte",
			)),
			array('Nella\Foo\Bar::renderBaz', array(
				$context->params['appDir'] . "/Foo/Bar.baz.latte",
				$context->params['appDir'] . "/templates/Foo/Bar.baz.latte",
				__DIR__ . "/Foo/Bar.baz.latte",
				__DIR__ . "/templates/Foo/Bar.baz.latte",
				NELLA_FRAMEWORK_DIR . "/Foo/Bar.baz.latte",
				NELLA_FRAMEWORK_DIR . "/templates/Foo/Bar.baz.latte",
			)),
			array('Nella\Foo::renderBarBaz', array(
				$context->params['appDir'] . "/Foo.barBaz.latte",
				$context->params['appDir'] . "/templates/Foo.barBaz.latte",
				__DIR__ . "/Foo.barBaz.latte",
				__DIR__ . "/templates/Foo.barBaz.latte",
				NELLA_FRAMEWORK_DIR . "/Foo.barBaz.latte",
				NELLA_FRAMEWORK_DIR . "/templates/Foo.barBaz.latte",
			)),
		);
	}
開發者ID:norbe,項目名稱:framework,代碼行數:30,代碼來源:ControlTest.php

示例2: getCache

 /**
  * @return Cache
  */
 protected static function getCache()
 {
     if (self::$cache === NULL) {
         self::$cache = \Nette\Environment::getService('webloader.cache');
     }
     return self::$cache;
 }
開發者ID:lohini,項目名稱:webloader,代碼行數:10,代碼來源:PreFileFilter.php

示例3: match

 /**
  * @param Nette\Web\IHttpRequest $httpRequest
  * @return Nette\Application\PresenterRequest|NULL
  */
 public function match(\Nette\Http\IRequest $httpRequest)
 {
     /** @var $appRequest \Nette\Application\Request */
     $appRequest = parent::match($httpRequest);
     // doplněno: pokud match vrátí NULL, musíme také vrátit NULL
     if (!$appRequest) {
         return $appRequest;
     }
     // musím si přeložit host, kvůli localhostu to není dané
     if (strpos($httpRequest->url->host, '.localhost') !== false && !\Nette\Environment::isProduction()) {
         // jsme na localhostu
         $host = substr($httpRequest->url->host, 0, strripos($httpRequest->url->host, '.localhost'));
         // musíme si doménu osamostatnit od .localhost
         $host = str_replace('_', '.', $host);
         // na lokálu mám místo teček podtržení
     } else {
         // jsme na produkci
         $host = $httpRequest->url->host;
     }
     // zkusím zda je soubor již v cache
     if (is_file(WEB_DIR . '/' . $host . '/cache' . $httpRequest->url->path)) {
         return new Nette\Application\Request('Frontend', 'POST', array('action' => 'cache', 'file' => WEB_DIR . '/' . $host . '/cache' . $httpRequest->url->path));
     }
     /*
     if ($params = $this->doFilterParams($this->getRequestParams($appRequest), $appRequest, self::WAY_IN)) {
     	return $this->setRequestParams($appRequest, $params);
     }
     */
     // $pages = $this->context->createPages();
     $data = array('action' => 'default');
     return new Nette\Application\Request('Frontend', 'POST', $data);
 }
開發者ID:pemasat,項目名稱:nixla,代碼行數:36,代碼來源:DynamicRoute.php

示例4: renderShow

 public function renderShow($id)
 {
     $service = new TripService($this->entityManager);
     $trip = $service->find($id);
     $this->template->trip = $trip;
     try {
         $eventService = new EventService();
         $config = Environment::getConfig('api');
         $events = $eventService->getEvents($trip->arrival, new DateTime(), new EventfulMapper($config->eventfulUser, $config->eventfulPassword, $config->eventfulKey));
         $this->template->events = $events;
     } catch (InvalidStateException $e) {
         $this->template->events = array();
     }
     $articleService = new ArticleService($this->entityManager);
     $this->template->article = $articleService->buildArticle($trip->arrival, new ArticleWikipediaMapper());
     try {
         $airportMapper = new AirportTravelMathMapper();
         $airportService = new AirportService();
         $locationService = new LocationService();
         $coordinates = $locationService->getCoordinates($trip->getDeparture());
         $from = $airportService->searchNearestAirport($airportMapper, $coordinates['latitude'], $coordinates['longitude']);
         $coordinates = $locationService->getCoordinates($trip->getArrival());
         $to = $airportService->searchNearestAirport($airportMapper, $coordinates['latitude'], $coordinates['longitude']);
         $flightMapper = new FlightKayakMapper();
         $flightService = new FlightService($this->entityManager);
         $depart_date = new DateTime('now');
         $return_date = new DateTime('+1 week');
         $this->template->flights = $flightService->buildFlights($flightMapper, $from, $to, $depart_date, $return_date, '1', 'e', 'n');
     } catch (FlightException $e) {
         $this->template->flightsError = "Connection with search system <a href='http://kayak.com'>Kayak</a> failed.";
     } catch (AirportException $e) {
         $this->template->flightsError = $e->getMessage();
     }
 }
開發者ID:jff15,項目名稱:travelbot,代碼行數:34,代碼來源:TripPresenter.php

示例5: handleUploads

 /**
  * Handles uploaded files
  * forwards it to model
  */
 public function handleUploads()
 {
     // Iterujeme nad přijatými soubory
     foreach (\Nette\Environment::getHttpRequest()->getFiles() as $name => $controlValue) {
         // MFU vždy posílá soubory v této struktuře:
         //
         // array(
         //	"token" => "blablabla",
         //	"files" => array(
         //		0 => HttpUploadedFile(...),
         //		...
         //	)
         // )
         $isFormMFU = (is_array($controlValue) and isset($controlValue["files"]) and isset($_POST[$name]["token"]));
         if ($isFormMFU) {
             $token = $_POST[$name]["token"];
             foreach ($controlValue["files"] as $file) {
                 self::processFile($token, $file);
             }
         }
         // soubory, které se netýkají MFU nezpracujeme -> zpracuje si je standardním způsobem formulář
     }
     return true;
     // Skip all next
 }
開發者ID:patrickkusebauch,項目名稱:27skauti,代碼行數:29,代碼來源:MFUUIHTML4SingleUpload.php

示例6: setLocale

 public function setLocale($lang)
 {
     switch ($lang) {
         case 'en':
             setlocale(LC_ALL, 'en_EN.UTF8', 'en_EN.UTF-8', 'en_EN	');
             break;
         case 'cs':
         default:
             setlocale(LC_ALL, 'cs_CZ.UTF8', 'cs_CZ.UTF-8', 'cs_CZ');
     }
     $this->lang = $lang;
     $cache = Environment::getCache();
     $cacheName = 'getText-' . $this->lang;
     if (isset($cache[$cacheName])) {
         $this->dictionary = unserialize($cache[$cacheName]);
     } else {
         $dict = new Model\Dictionary('utils/translate');
         try {
             $this->dictionary = $dict->getPairs($this->lang);
             $cache->save($cacheName, serialize((array) $this->dictionary), array('expire' => time() + 60 * 30, 'refresh' => TRUE, 'tags' => array('dictionary')));
         } catch (DibiException $e) {
             echo $e;
         }
     }
 }
開發者ID:soundake,項目名稱:pd,代碼行數:25,代碼來源:Translate.php

示例7: renderBlueScreen

 /**
  * Renders blue screen.
  * @param  \Exception
  * @return void
  */
 public static function renderBlueScreen(\Exception $exception)
 {
     if (class_exists('Nette\\Environment', FALSE)) {
         $application = Environment::getContext()->hasService('Nette\\Application\\Application', TRUE) ? Environment::getContext()->getService('Nette\\Application\\Application') : NULL;
     }
     require __DIR__ . '/templates/bluescreen.phtml';
 }
開發者ID:JanTvrdik,項目名稱:nette,代碼行數:12,代碼來源:DebugHelpers.php

示例8: log_write

function log_write($data, FileDownload $file, IDownloader $downloader)
{
    $cache = Environment::getCache("FileDownloader/log");
    $log = array();
    $tid = (string) $file->getTransferId();
    if (!isset($cache["registry"])) {
        $cache["registry"] = array();
    }
    $reg = $cache["registry"];
    $reg[$tid] = true;
    $cache["registry"] = $reg;
    if (isset($cache[$tid])) {
        $log = $cache[$tid];
    }
    Debugger::fireLog("Data: " . $data . "; " . $downloader->end);
    $data = $data . ": " . Helpers::bytes($file->transferredBytes) . " <->; ";
    if ($downloader instanceof AdvancedDownloader and $downloader->isInitialized()) {
        $data .= "position: " . Helpers::bytes($downloader->position) . "; ";
        //$data .= "length: ".Helpers::bytes($downloader->length)."; ";
        $data .= "http-range: " . Helpers::bytes($downloader->start) . "-" . Helpers::bytes($downloader->end) . "; ";
        $data .= "progress (con: " . round($file->transferredBytes / $downloader->end * 100) . "% X ";
        $data .= "file: " . round($downloader->position / $file->sourceFileSize * 100) . "%)";
    }
    $log[] = $data;
    $cache[$tid] = $log;
}
開發者ID:jkuchar,項目名稱:FileDownloader-example,代碼行數:26,代碼來源:example_library.php

示例9: createTemplate

 /**
  * @return Nette\Templates\ITemplate
  */
 protected function createTemplate()
 {
     $template = new Nette\Templates\FileTemplate();
     $presenter = $this->getPresenter(FALSE);
     $template->onPrepareFilters[] = callback($this, 'templatePrepareFilters');
     // default parameters
     $template->control = $this;
     $template->presenter = $presenter;
     $template->user = Nette\Environment::getUser();
     $template->baseUri = Nette\Environment::getVariable('baseUri', NULL);
     $template->basePath = rtrim($template->baseUri, '/');
     // flash message
     if ($presenter !== NULL && $presenter->hasFlashSession()) {
         $id = $this->getParamId('flash');
         $template->flashes = $presenter->getFlashSession()->{$id};
     }
     if (!isset($template->flashes) || !is_array($template->flashes)) {
         $template->flashes = array();
     }
     // default helpers
     $template->registerHelper('escape', 'Nette\\Templates\\TemplateHelpers::escapeHtml');
     $template->registerHelper('escapeUrl', 'rawurlencode');
     $template->registerHelper('stripTags', 'strip_tags');
     $template->registerHelper('nl2br', 'nl2br');
     $template->registerHelper('substr', 'iconv_substr');
     $template->registerHelper('repeat', 'str_repeat');
     $template->registerHelper('replaceRE', 'Nette\\String::replace');
     $template->registerHelper('implode', 'implode');
     $template->registerHelper('number', 'number_format');
     $template->registerHelperLoader('Nette\\Templates\\TemplateHelpers::loader');
     return $template;
 }
開發者ID:JPalounek,項目名稱:IconStore,代碼行數:35,代碼來源:Control.php

示例10: getConfig

 public function getConfig()
 {
     if (!$this->config) {
         $this->config = Environment::getConfig();
     }
     return $this->config;
 }
開發者ID:GymvodNette,項目名稱:cv2-authentizace,代碼行數:7,代碼來源:BasePresenter.php

示例11: handleUpload

 public function handleUpload()
 {
     $files = \Nette\Environment::getHttpRequest()->getFile("user_file");
     foreach ($files as $file) {
         call_user_func($this->handler, $file);
     }
 }
開發者ID:janmarek,項目名稱:Neuron,代碼行數:7,代碼來源:UploadControl.php

示例12: getContext

 /**
  * @return \Nette\DI\Container
  */
 protected function getContext()
 {
     static $context;
     if (!$context) {
         $context = \Nette\Environment::getContext();
     }
     return $context;
 }
開發者ID:nella,項目名稱:testing,代碼行數:11,代碼來源:TestCase.php

示例13: getStorageDir

	/**
	 * @internal
	 * @return string
	 */
	protected function getStorageDir()
	{
		if ($this instanceof FileEntity) {
			return \Nette\Environment::getContext()->expand(FileService::STORAGE_DIR);
		} else {
			return \Nette\Environment::getContext()->expand(ImageService::STORAGE_DIR);
		}
	}
開發者ID:norbe,項目名稱:framework,代碼行數:12,代碼來源:BaseFileEntity.php

示例14: validateEntity

 private function validateEntity($entity)
 {
     $errors = Environment::getService("validator")->validate($entity);
     if (count($errors) > 0) {
         foreach ($errors as $violation) {
             throw new \Neuron\Model\ValidationException($violation->getMessage(), $violation->getPropertyPath());
         }
     }
 }
開發者ID:janmarek,項目名稱:Neuron,代碼行數:9,代碼來源:ValidationSubscriber.php

示例15: createTemplate

 /**
  * @return Template
  */
 protected function createTemplate($file = null)
 {
     $template = new Template($file);
     $template->baseUrl = \Nette\Environment::getHttpRequest()->url->baseUrl;
     $template->basePath = rtrim($template->baseUrl, '/');
     $template->interface = $this;
     $template->registerHelperLoader('Nette\\Templating\\Helpers::loader');
     return $template;
 }
開發者ID:jurasm2,項目名稱:multiplefileupload,代碼行數:12,代碼來源:AbstractInterface.php


注:本文中的Nette\Environment類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。