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


PHP Environment::getApplication方法代码示例

本文整理汇总了PHP中Environment::getApplication方法的典型用法代码示例。如果您正苦于以下问题:PHP Environment::getApplication方法的具体用法?PHP Environment::getApplication怎么用?PHP Environment::getApplication使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Environment的用法示例。


在下文中一共展示了Environment::getApplication方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: gatherActions

 private function gatherActions()
 {
     $service = Environment::getService('Nette\\Loaders\\RobotLoader');
     $class_list = $service->list;
     $actions = array();
     foreach ($class_list as $class => $file) {
         //zachtime annotation exception lebo nette si generuje nejake annotation claasy do robotloodera
         try {
             $r = new ReflectionClass($class);
             if ($r->isSubclassOf('Admin_SecurePresenter') && $r->getName() != 'BaseModulePresenter') {
                 $methods = $r->getMethods(ReflectionMethod::IS_PUBLIC);
                 foreach ($methods as $method) {
                     if (String::lower($method->class) == $class) {
                         if (strpos($method->getName(), 'action') !== false || strpos($method->getName(), 'handle') !== false) {
                             $actions[$class][] = $method->getName();
                         }
                     }
                 }
             }
         } catch (ReflectionException $e) {
         }
     }
     $actions = array_merge($actions, Environment::getApplication()->getModulesPermissions());
     $model = new UsersModuleModel();
     $model->saveActions($actions);
     return $actions;
 }
开发者ID:bazo,项目名称:Mokuji,代码行数:27,代码来源:UsersUsersPresenter.php

示例3: __construct

 public function __construct()
 {
     parent::__construct();
     $this->lang = Environment::getApplication()->getPresenter()->lang;
     $this->addText('email', 'email')->addRule(Form::FILLED, 'Please, fill in the email')->addRule(Form::EMAIL, 'E-mail is not valid');
     $this->addSubmit('submit', 'subscribe the newsletter');
     $this->onSuccess[] = callback($this, 'submitted');
     $this->setTranslator(new TranslationsModel($this->lang));
 }
开发者ID:osmcz,项目名称:website,代码行数:9,代码来源:NewsletterPlugin.php

示例4: __construct

 public function __construct(IComponentContainer $parent = null, $name = null)
 {
     parent::__construct($parent, $name);
     $script = new LiveClientScript($this);
     $this->setTranslator(new Translator(Environment::getApplication()->getPresenter()->lang));
     $this->getRenderer()->setClientScript($script);
     $renderer = $this->getRenderer();
     $renderer->wrappers['label']['suffix'] = ':';
 }
开发者ID:bazo,项目名称:diplomovka,代码行数:9,代码来源:LiveForm.php

示例5: __construct

 public function __construct(IComponentContainer $parent = null, $name = null)
 {
     parent::__construct($parent, $name);
     $this->addProtection();
     $script = new LiveClientScript($this);
     $this->setTranslator(new Translator(Environment::getApplication()->getPresenter()->lang));
     $this->getRenderer()->setClientScript($script);
     $this->getElementPrototype()->class = 'ajax';
 }
开发者ID:bazo,项目名称:Mokuji,代码行数:9,代码来源:LiveForm.php

示例6: run

 /**
  * Dispatch an HTTP request to a routing debugger. Please don't call directly.
  */
 public static function run()
 {
     if (!self::$enabled || Environment::getMode('production')) {
         return;
     }
     self::$enabled = FALSE;
     $debugger = new self(Environment::getApplication()->getRouter(), Environment::getHttpRequest());
     $debugger->paint();
 }
开发者ID:bazo,项目名称:Mokuji,代码行数:12,代码来源:RoutingDebugger.php

示例7: createComponentMenu

 public function createComponentMenu($name)
 {
     $menu = new AdminNavigationBuilder($this, $name);
     $menu->setTranslator($this->translator);
     $menu->add('Dashboard', ':Admin:Dashboard:');
     $menu->add('Pages', ':Admin:Pages:');
     $menu->add('Categories', ':Admin:Categories:');
     $menu->add('Menus', ':Admin:Menus:');
     $menu->add('Themes', ':Admin:Themes:');
     $module_items = Environment::getApplication()->getAdminNodes();
     $menu = $this->compileMenuItems($menu, $module_items);
     $menu->add('Modules', ':Admin:Modules:');
     $menu->add('Settings', ':Admin:Options:');
     $menu->template->presenter = $this;
     return $menu;
 }
开发者ID:bazo,项目名称:Mokuji,代码行数:16,代码来源:AdminBasePresenter.php

示例8: startup

 public function startup()
 {
     //$this->oldLayoutMode = false;
     //$this->oldModuleMode = false;
     parent::startup();
     $application = Environment::getApplication();
     if (!isset($this->lang)) {
         $this->lang = $this->getHttpRequest()->detectLanguage(array('en', 'sk'));
         $this->canonicalize();
     }
     $this->translator = new Translator($this->lang);
     $this->template->setTranslator($this->translator);
     $modul = explode(':', $this->getName());
     $this->module = $modul[0];
     $this->template->module = $this->module;
 }
开发者ID:bazo,项目名称:diplomovka,代码行数:16,代码来源:BasePresenter.php

示例9: __construct

 public function __construct(IEditableTranslator $translator, $layout = NULL, $height = NULL)
 {
     $this->translator = $translator;
     if ($height !== NULL) {
         if (!is_numeric($height)) {
             throw new InvalidArgumentException('Panel height has to be a numeric value.');
         }
         $this->height = $height;
     }
     if ($layout !== NULL) {
         $this->layout = $layout;
         if ($height === NULL) {
             $this->height = 500;
         }
     }
     Environment::getApplication()->onRequest[] = callback($this, 'processRequest');
 }
开发者ID:jsmitka,项目名称:Nette-Translation-Panel,代码行数:17,代码来源:TranslationPanel.php

示例10: latte

 /**
  * znova spracovava retazec s latte syntaxou s vyuzitim StringTemplate
  *
  * @param string $s
  * @return string
  */
 public static function latte($s)
 {
     // kedze HTML Purifier aj CKEditor escape-uju entity, tak by mi nefungovali nette linky -> robim replace
     $search = array('->', '=>');
     $replace = array('->', '=>');
     $s = str_replace($search, $replace, $s);
     $tpl = new StringTemplate();
     $tpl->presenter = Environment::getApplication()->getPresenter();
     // nutné např. pro rozchození linků
     $tpl->registerFilter(new LatteFilter());
     $tpl->content = $s;
     // obsah šablony (řetězec)
     $tpl->control = $tpl->presenter;
     // vrátíme vygenerovanou šablonu
     return $tpl->__toString();
     // nebo ji vypíšeme na výstup
     //		$tpl->render();
 }
开发者ID:radypala,项目名称:maga-website,代码行数:24,代码来源:Helpers.php

示例11: sendMsg

 /**
  * posle [chybovu] hlasku userovi nezavisle ci je ajax alebo nie
  *
  * @param string $msg hlaska
  * @param string $type pridava sa ako class k $flashes
  */
 public static function sendMsg(&$_this, $msg, $type = self::FLASH_MESSAGE_ERROR, $destination = 'this', $plink = false, $backlink = null)
 {
     $presenter = $_this->getPresenter();
     if ($presenter->isAjax()) {
         $presenter->payload->actions = array($type => $_this->translate($msg));
         $presenter->sendPayload();
     } else {
         $presenter->flashMessage($msg, $type);
         //	ak mame ulozeny kluc, kam sa mame vratit, ideme tam
         if ($backlink) {
             Environment::getApplication()->restoreRequest($backlink);
         } elseif ($plink) {
             $presenter->redirect($destination);
         } else {
             $_this->redirect($destination);
         }
     }
 }
开发者ID:radypala,项目名称:maga-website,代码行数:24,代码来源:BasePresenterControl.php

示例12: add

 /**
  * Add navigation node as a child
  * @staticvar int $counter
  * @param string $label
  * @param string $url
  * @param string $netteLink added - aby sa dalo testovat ifCurrent na cely presenter
  * @return NavigationNode
  */
 public function add($label, $url, $netteLink = null)
 {
     $navigationNode = new self();
     $navigationNode->label = $label;
     $navigationNode->url = $url;
     static $counter;
     $this->addComponent($navigationNode, ++$counter);
     /*added*/
     $uri = Environment::getHttpRequest()->getOriginalUri()->getPath();
     if ($netteLink) {
         $presenter = Environment::getApplication()->getPresenter();
         try {
             $presenter->link($netteLink);
         } catch (InvalidLinkException $e) {
         }
         $navigationNode->isCurrent = $presenter->getLastCreatedRequestFlag("current");
     } else {
         $navigationNode->isCurrent = $url == $uri;
     }
     /*added end*/
     return $navigationNode;
 }
开发者ID:radypala,项目名称:maga-website,代码行数:30,代码来源:NavigationNode.php

示例13: onLoginSubmitted

 /**
  * @param Form $form
  */
 public function onLoginSubmitted(Form $form)
 {
     try {
         $values = $form->getValues();
         $username = $values['user'];
         if ($username == '__guest') {
             $this->user->logout(TRUE);
         } else {
             $password = $this->credentials[$username];
             Environment::getUser()->login($username, $password);
         }
         $this->redirect('this');
     } catch (AuthenticationException $e) {
         Environment::getApplication()->presenter->flashMessage($e->getMessage(), 'error');
         $this->redirect('this');
     }
 }
开发者ID:radypala,项目名称:maga-website,代码行数:20,代码来源:UserPanel.php

示例14: generate

 /**
  * Iterates through all presenters and returns their actions with backlinks and arguments
  * @return array
  */
 private function generate()
 {
     $links = array();
     $depends = array();
     $iterator = new RegexIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator(APP_DIR)), '/Presenter\\.(php|PHP)$/m', RecursiveRegexIterator::GET_MATCH);
     foreach ($iterator as $path => $match) {
         $fileinfo = pathinfo($path);
         $reflection = new ReflectionClass($this->getClassNameFromPath($path));
         if ($reflection->isInstantiable()) {
             $depends[] = $path;
             $modules = $this->getModulesFromName($reflection->name);
             $link = '';
             if ($modules !== FALSE) {
                 $link .= implode(':', $modules);
             }
             $link .= ':';
             preg_match('/(?:[A-z0-9]+?_)*([A-z0-9]+)Presenter/m', $reflection->getName(), $match);
             $presenter = $match[1];
             $link .= $presenter;
             $persistent = array();
             foreach ($reflection->getProperties() as $property) {
                 foreach (AnnotationsParser::getAll($property) as $annotation => $value) {
                     if ($annotation == 'persistent') {
                         $persistent[] = $property;
                     }
                 }
             }
             $actions = array();
             foreach ($reflection->getMethods() as $action) {
                 if (preg_match('/^(action|render)(.*)$/m', $action->getName(), $name) && !in_array($name[2], $actions)) {
                     $action_name = lcfirst($name[2]);
                     $pattern = '/Method \\[.*? ' . $action . ' \\].*? (?:Parameters .*? \\{.*?Parameter #\\d+ \\[(.*?)\\].*?\\})? }/ms';
                     $set_required = FALSE;
                     $set_optional = FALSE;
                     foreach ($action->getParameters() as $arg) {
                         if (!$arg->isOptional()) {
                             $actions[$action_name]['arguments']['required'][$arg->getName()] = NULL;
                             $set_required = TRUE;
                         } else {
                             $actions[$action_name]['arguments']['optional'][$arg->getName()] = $arg->getDefaultValue();
                             $set_optional = TRUE;
                         }
                     }
                     if (!$set_required) {
                         $actions[$action_name]['arguments']['required'] = array();
                     }
                     if (!$set_optional) {
                         $actions[$action_name]['arguments']['optional'] = array();
                     }
                     $actions[$action_name]['arguments']['persistent'] = $persistent;
                 }
             }
             if (count($actions) == 0) {
                 $actions['Default']['arguments']['required'] = array();
                 $actions['Default']['arguments']['optional'] = array();
                 $actions['Default']['arguments']['persistent'] = array();
             }
             foreach ($actions as $action => $info) {
                 $label = ':' . $link . ':' . $action;
                 if (Environment::getApplication()->getPresenter() instanceof Presenter) {
                     $links[$label]['link'] = Environment::getApplication()->getPresenter()->link($label);
                 } else {
                     $links[$label]['link'] = 'false';
                 }
                 $links[$label]['action'] = $action;
                 $links[$label]['presenter'] = $presenter;
                 $links[$label]['modules'] = $modules;
                 $links[$label]['arguments'] = $info['arguments'];
             }
         }
     }
     return array('tree' => $this->categorize($links), 'depends' => $depends);
 }
开发者ID:jasir,项目名称:PresenterTreePanel,代码行数:77,代码来源:PresenterTreePanel.php

示例15: errorsAsFlashMessages

 /**
  * chyby vo formulari zobrazi ako flash a chyby zmaze
  *
  * @param AppForm $form
  */
 public static function errorsAsFlashMessages(MyAppForm $form)
 {
     $errors = $form->getErrors();
     foreach ($errors as $error) {
         Environment::getApplication()->getPresenter()->flashMessage($error, 'error');
     }
     $form->cleanErrors();
 }
开发者ID:radypala,项目名称:maga-website,代码行数:13,代码来源:MyAppForm.php


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