Exemplo n.º 1
0
	/**
	 * @param string
	 */
	public function __construct($containerClass = 'Nette\DI\Container')
	{
		parent::__construct($containerClass);

		$container = $this->getContainer();

		// Back compatability
		Environment::setConfigurator($this);
		Environment::setContext($container);

		// Nella X-Powered
		@header("X-Powered-By: Nette Framework with Nella"); // @ - headers may have been sent

		// Upload dir (tmp files - Mupltiple File Uploader)
		if (isset($container->params['tempDir'])) {
			$container->params['uploadDir'] = $container->expand("%tempDir%/uploads");
		}

		// File storage dirs (upoaded images and other files)
		if (defined('STORAGE_DIR')) {
			$container->params['storageDir'] = realpath(STORAGE_DIR);
		} else {
			$container->params['storageDir'] = $container->expand("%appDir%/storage");
		}

		// Image cache dir (public folteder for images thumbnails and other formats)
		if (defined('IMAGE_CACHE_DIR')) {
			$container->params['imageCacheDir'] = realpath(IMAGE_CACHE_DIR);
		} else {
			$container->params['imageCacheDir'] = $container->expand("%wwwDir%/images");
		}

		// Namespace prefixes
		$container->params['namespaces'] = array(0 => 'App', 9 => 'Nella');
		// Templates dirs (application parts dirs)
		$container->params['templates'] = array(0 => $container->params['appDir'], 9 => NELLA_FRAMEWORK_DIR);
		// Flash message types
		$container->params['flashes'] = array(
			'success' => "success",
			'error' => "error",
			'info' => "info",
			'warning' => "warning",
		);

		// Set file upload temp dir
		ini_set('upload_tmp_dir', $container->params['uploadDir']);
		// Set session dir
		ini_set('session.save_path', $container->expand("%tempDir%/sessions"));

		// Init multilple file upload listener
		Forms\Controls\MultipleFileUpload::register(
			$container->httpRequest,
			$container->params['uploadDir']
		);

		$this->onAfterLoadConfig[] = function(Container $container) {
			// Load panels
			if (!$container->params['consoleMode'] && !$container->params['productionMode']) {
				$container->callbackPanel;
				$container->versionPanel;
				$container->translatorPanel;
				$container->debugPanel;
				$container->userPanel;
			}
		};
	}