/**
  * Register MFU into Nette
  */
 public static function register()
 {
     self::init();
     $application = Environment::getApplication();
     $application->onStartup[] = callback("MultipleFileUpload::handleUploads");
     $application->onShutdown[] = callback("MultipleFileUpload::cleanCache");
 }
 /**
  * Register MFU into Nette
  */
 public static function register()
 {
     self::init();
     $application = Environment::getApplication();
     $application->onStartup[] = callback(__CLASS__, "handleUploads");
     $application->onShutdown[] = callback(__CLASS__, "cleanCache");
 }
Exemplo n.º 3
0
 public function __construct(\Nette\IComponentContainer $parent = null, $name = null)
 {
     parent::__construct($parent, $name);
     $this->setJoinFiles(Environment::isProduction());
     $this->setTempUri(Environment::getVariable("baseUri") . "data/webtemp");
     $this->setTempPath(WWW_DIR . "/data/webtemp");
     $this->setSourcePath(WWW_DIR . "/js");
     $presenter = Environment::getApplication()->getPresenter();
     $this->filters[] = new VariablesFilter(array("baseUri" => Environment::getVariable("baseUri"), "texylaPreviewPath" => $presenter->link(":Texyla:preview"), "texylaFilesPath" => $presenter->link(":Texyla:listFiles"), "texylaFilesUploadPath" => $presenter->link(":Texyla:upload")));
     if (Environment::isProduction()) {
         $this->filters[] = "JSMin::minify";
     }
     $this->init();
 }
 /**
  * Přesměruje zpět na RequestButton, když je z něj požadavek.
  * Používá ho RequestButtonReceiver a tuto funkcy lze zavolat i třeba v signálu.
  *
  * @param AppForm|PresenterComponent|NULL Null znamená vzít presenter z prostředí, u AppForm se kontroluje jestli nebyl stisknut další RequestButton.
  * @throw AbortException
  */
 public static function redirectBack($form = NULL)
 {
     if ($form === NULL) {
         $presenter = \Nette\Environment::getApplication()->getPresenter();
     } else {
         if ($form instanceof PresenterComponent or $form instanceof AppForm) {
             $presenter = $form->getPresenter();
         }
     }
     $backlinkId = $presenter->getParam(RequestButton::BACKLINK_KEY);
     if ($backlinkId and ($form === NULL or !$form->isSubmitted() instanceof RequestButton) and RequestButtonStorage::is($backlinkId)) {
         $presenter->redirect(RequestButtonStorage::getDestination($backlinkId), array(RequestButton::RECEIVED_KEY => $backlinkId, 'do' => NULL) + RequestButtonStorage::getDestinationArgs($backlinkId));
     }
 }
Exemplo n.º 5
0
 /**
  * @param TexyHandlerInvocation  handler invocation
  * @param string
  * @param string
  * @param TexyModifier
  * @param TexyLink
  * @return TexyHtml|string|FALSE
  */
 public function netteLink($invocation, $phrase, $content, $modifier, $link)
 {
     // is there link?
     if (!$link) {
         return $invocation->proceed();
     }
     $url = $link->URL;
     if (String::startsWith($url, "plink://")) {
         $url = substr($url, 8);
         list($presenter, $params) = explode("?", $url, 2);
         $arr = array();
         if ($params) {
             parse_str($params, $arr);
         }
         $link->URL = Environment::getApplication()->getPresenter()->link($presenter, $arr);
     }
     return $invocation->proceed();
 }
Exemplo n.º 6
0
 public function setUrl($url)
 {
     $uriScript = new UriScript($url);
     $uriScript->setScriptPath(Environment::getHttpRequest()->getUri()->getScriptPath());
     $httpRequest = new HttpRequest($uriScript);
     $presenterRequest = Environment::getApplication()->getRouter()->match($httpRequest);
     if ($presenterRequest === null || !String::startsWith($url, Environment::getVariable("baseUri"))) {
         $this->url = $url ?: null;
         $this->destination = null;
         $this->params = array();
     } else {
         $presenter = $presenterRequest->getPresenterName();
         $params = $presenterRequest->getParams();
         $action = isset($params["action"]) ? $params["action"] : "default";
         $module = isset($params["module"]) ? $params["module"] . ":" : "";
         unset($params["action"]);
         $this->destination = "{$module}{$presenter}:{$action}";
         $this->params = $params;
         $this->url = null;
     }
 }
Exemplo n.º 7
0
 * @copyright  Copyright (c) 2010 John Doe
 * @package    MyApplication
 */
use Nette\Debug;
use Nette\Environment;
use Nette\Application\Route;
use Nette\Application\SimpleRouter;
// REMOVE THIS LINE
if (!is_file(LIBS_DIR . '/Nette/loader.php')) {
    die('Copy Nette Framework to /libs/ directory.');
}
// Step 1: Load Nette Framework
// this allows load Nette Framework classes automatically so that
// you don't have to litter your code with 'require' statements
require LIBS_DIR . '/Nette/loader.php';
// Step 2: Configure environment
// 2a) enable Nette\Debug for better exception and error visualisation
Debug::enable();
// 2b) load configuration from config.ini file
Environment::loadConfig();
// Step 3: Configure application
// 3a) get and setup a front controller
$application = Environment::getApplication();
$application->errorPresenter = 'Error';
//$application->catchExceptions = TRUE;
// Step 4: Setup application router
$router = $application->getRouter();
$router[] = new Route('index.php', array('presenter' => 'Homepage', 'action' => 'default'), Route::ONE_WAY);
$router[] = new Route('<presenter>/<action>/<id>', array('presenter' => 'Homepage', 'action' => 'default', 'id' => NULL));
// Step 5: Run the application!
$application->run();
Exemplo n.º 8
0
 /**
  * @param $presenter Presenter
  * @param $response PresenterResponse
  * @internal
  */
 public function onShutdown($presenter, $response)
 {
     $this->response = $response;
     $application = Environment::getApplication();
     $presenter = $application->getPresenter();
     $request = $presenter->getRequest();
     $httpRequest = Environment::getHttpRequest();
     $entry = array();
     if ($signal = $presenter->getSignal()) {
         $receiver = empty($signal[0]) ? $presenter->name : $signal[0];
         $signal = $receiver . " :: " . $signal[1];
     }
     if ($response !== NULL) {
         $rInfo = get_class($response);
         if ($response->getReflection()->hasMethod('getCode')) {
             $rInfo .= ' (' . $response->code . ')';
         }
     }
     $entry['info']['presenter'] = $presenter->backlink();
     $entry['info']['response'] = $response === NULL ? 'NO RESPONSE' : $rInfo;
     $entry['info']['uri'] = $httpRequest->getUrl();
     $entry['info']['uriPath'] = $httpRequest->getUrl()->path;
     $entry['info']['request'] = $request->getMethod();
     $entry['info']['signal'] = $signal;
     $entry['info']['time'] = number_format((microtime(TRUE) - Debugger::$time) * 1000, 1, '.', ' ');
     $entry['dumps']['HttpRequest'] = Helpers::clickableDump($httpRequest);
     $entry['dumps']['PresenterRequest'] = Helpers::clickableDump($request);
     $entry['dumps']['Presenter'] = Helpers::clickableDump($presenter);
     $entry['dumps']['PresenterResponse'] = Helpers::clickableDump($response);
     foreach (self::$dumps as $key => $dump) {
         if (is_numeric($key)) {
             $entry['dumps'][] = $dump;
         } else {
             $entry['dumps'][$key] = $dump;
         }
     }
     $session = Environment::getSession('debug/RequestsPanel');
     if (!isset($session->logs)) {
         $session->logs = array();
     }
     $session->logs[] = $entry;
 }
Exemplo n.º 9
0
 /**
  * @return Application
  */
 public function getApplication()
 {
     return Environment::getApplication();
 }
Exemplo n.º 10
0
 /**
  * @return Doctrine\ORM\EntityManager
  */
 public function getEntityManager()
 {
     return Environment::getApplication()->getContext()->getService('Doctrine\\ORM\\EntityManager');
 }
Exemplo n.º 11
0
require LIBS_DIR . '/Nette/loader.php';
require APP_DIR . '/routers/StaticRouter.php';
require APP_DIR . '/managers/PageManager.php';
require APP_DIR . '/classes/TemplateLocator.php';
require APP_DIR . '/classes/PresenterFactory.php';

// Enable and setup Nette\Debug
Debug::enable();
Debug::$strictMode = !Debug::$productionMode;

// Configure environment
date_default_timezone_set('Europe/Prague');
Html::$xhtml = FALSE;

// Configure application
$application = Env::getApplication();
$application->errorPresenter = 'Error';
$application->catchExceptions = Debug::$productionMode;

// Configure application context
$context = $application->getContext();
$context->addService('StaticWeb\\TemplateLocator', 'StaticWeb\\TemplateLocator');
$context->addService('StaticWeb\\PageManager', function() use ($context) {
	$manager = new PageManager();
	$manager->setContext($context);
	return $manager;
});
$context->addService('Nette\\Application\\IPresenterFactory', function() use ($context) {
	return new PresenterFactory(Env::getVariable('appDir'), $context);
});
$context->addService('Nette\\Application\\IRouter', function() use ($context) {
 /**
  * Renders HTML code for custom panel.
  * @return string
  * @see IDebugPanel::getPanel()
  */
 public function getPanel()
 {
     if ($this->response instanceof \Nette\Application\Responses\ForwardResponse || $this->response instanceof \Nette\Application\Responses\RedirectResponse) {
         return '';
     }
     /** @var Template */
     $template = new FileTemplate();
     $template->setFile(dirname(__FILE__) . "/bar.latte");
     $template->registerFilter(new Engine());
     $template->presenter = $template->control = $template->rootComponent = Environment::getApplication()->getPresenter();
     if ($template->presenter === NULL) {
         return NULL;
     }
     $template->wrap = static::$wrap;
     $template->cache = static::$cache ? Environment::getCache('Debugger.Panels.ComponentTree') : NULL;
     $template->dumps = static::$dumps;
     $template->parametersOpen = static::$parametersOpen;
     $template->presenterOpen = static::$presenterOpen;
     $template->showSources = static::$showSources;
     $template->omittedVariables = static::$omittedTemplateVariables;
     $template->registerHelper('parametersInfo', callback($this, 'getParametersInfo'));
     $template->registerHelper('editlink', callback($this, 'buildEditorLink'));
     $template->registerHelper('highlight', callback($this, 'highlight'));
     $template->registerHelper('filterMethods', callback($this, 'filterMethods'));
     $template->registerHelper('renderedTemplates', callback($this, 'getRenderedTemplates'));
     $template->registerHelper('isPersistent', callback($this, 'isPersistent'));
     $template->registerHelperLoader('Nette\\Templating\\Helpers::loader');
     ob_start();
     $template->render();
     return ob_get_clean();
 }
	/**
	 * Returns Application instance.
	 *
	 * @author   David Grudl
	 * @return   Nette\Application\Application
	 */
	protected function getApplication()
	{
		return Env::getApplication();
	}