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


PHP Environment::getSession方法代码示例

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


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

示例1: createComponent

 public function createComponent($name)
 {
     switch ($name) {
         case 'searchForm':
             $form = new AppForm($this, $name);
             $form->addText('q', __('Query:'));
             $form['q']->getControlPrototype()->onclick('if (this.value === "' . __('Input search keywords') . '") {
                     this._default = this.value;
                     this.value = "";
                 }');
             $form['q']->getControlPrototype()->onblur('if (this.value === "" && this._default !== undefined) {
                     this.value = this._default;
                 }');
             $form->setAction($this->link('Search:default'));
             $form->setMethod('get');
             if (isset(Environment::getSession(SESSION_SEARCH_NS)->last)) {
                 $form->setDefaults(array('q' => Environment::getSession(SESSION_SEARCH_NS)->last));
             } else {
                 $form->setDefaults(array('q' => __('Input search keywords')));
             }
             break;
         default:
             return parent::createComponent($name);
     }
 }
开发者ID:jakubkulhan,项目名称:shopaholic,代码行数:25,代码来源:BasePresenter.php

示例2: increaseRead

 public static function increaseRead($id)
 {
     $reader = Environment::getSession('reader');
     if ($reader[$id] == NULL) {
         dibi::query('UPDATE [works] SET [read] = [read] + 1 WHERE workId=%i', $id);
         $reader[$id] = TRUE;
     }
 }
开发者ID:xixixao,项目名称:chytrapalice,代码行数:8,代码来源:Model.php

示例3: __construct

 public function __construct($parent = NULL, $name = NULL)
 {
     parent::__construct($parent, $name);
     $this->form = new AppForm($this, 'form');
     $this->form->addSubmit('yes', _('Yes'))->onClick[] = array($this, 'confirmClicked');
     $this->form->addSubmit('no', _('No'))->onClick[] = array($this, 'cancelClicked');
     $this->form->addHidden('token');
     $this->question = Html::el('p');
     $this->session = Environment::getSession('ConfirmationDialog/tokens');
 }
开发者ID:bazo,项目名称:Mokuji,代码行数:10,代码来源:ConfirmationDialog.php

示例4: handleSubmit

 public function handleSubmit($form)
 {
     $values = $form->getValues();
     $query = $values['query'];
     $data = $this->presenter->model('search')->search($query);
     $session = Environment::getSession('search');
     $session->query = $query;
     $session->search_result = $data;
     $this->getPresenter()->redirect('Search:search', array('query' => $query));
 }
开发者ID:bazo,项目名称:Mokuji,代码行数:10,代码来源:SearchForm.php

示例5: getService

 /**
  * Gets the service object of the specified type.
  * @param  string service name
  * @param  array  options in case service is not singleton
  * @return mixed
  */
 public static function getService($name, array $options = NULL)
 {
     if (!is_string($name) || $name === '') {
         throw new InvalidArgumentException("Service name must be a non-empty string, " . gettype($name) . " given.");
     }
     $session = Environment::getSession('MokujiServiceLocator');
     $lower = strtolower($name);
     if (isset($session->{$lower})) {
         // instantiated singleton
         if ($options) {
             throw new InvalidArgumentException("Service named '{$name}' is singleton and therefore can not have options.");
         }
         return $session->{$lower};
     } elseif (isset($session->factories[$lower])) {
         list($factory, $singleton, $defOptions) = $session->factories[$lower];
         if ($singleton && $options) {
             throw new InvalidArgumentException("Service named '{$name}' is singleton and therefore can not have options.");
         } elseif ($defOptions) {
             $options = $options ? $options + $defOptions : $defOptions;
         }
         if (is_string($factory) && strpos($factory, ':') === FALSE) {
             // class name
             Framework::fixNamespace($factory);
             if (!class_exists($factory)) {
                 throw new AmbiguousServiceException("Cannot instantiate service '{$name}', class '{$factory}' not found.");
             }
             $service = new $factory();
             if ($options && method_exists($service, 'setOptions')) {
                 $service->setOptions($options);
                 // TODO: better!
             }
         } else {
             // factory callback
             $factory = callback($factory);
             if (!$factory->isCallable()) {
                 throw new InvalidStateException("Cannot instantiate service '{$name}', handler '{$factory}' is not callable.");
             }
             $service = $factory->invoke($options);
             if (!is_object($service)) {
                 throw new AmbiguousServiceException("Cannot instantiate service '{$name}', value returned by '{$factory}' is not object.");
             }
         }
         if ($singleton) {
             $session->{$lower} = $service;
             unset($session->factories[$lower]);
         }
         return $service;
     }
     if ($this->parent !== NULL) {
         return $this->parent->getService($name, $options);
     } else {
         throw new InvalidStateException("Service '{$name}' not found.");
     }
 }
开发者ID:bazo,项目名称:Mokuji,代码行数:60,代码来源:MokujiServiceLocator.php

示例6: actionSearch

 public function actionSearch($query)
 {
     $session = Environment::getSession('search');
     if ($session->query != $query) {
         $data = $this->model('search')->search($query);
     } else {
         $data = $session->search_result;
     }
     $this->template->query = $query;
     $this->template->data = $data;
     $this->view = 'results';
 }
开发者ID:bazo,项目名称:Mokuji,代码行数:12,代码来源:FrontSearchPresenter.php

示例7: createComponentTree

 public function createComponentTree()
 {
     $tree = new TreeView();
     $tree->useAjax = true;
     $mode = null === $this->mode ? 1 : $this->mode;
     $session = Environment::getSession();
     $tree->mode = $mode;
     $tree->rememberState = true;
     $tree->addLink('default', 'name', 'id', true, $this->presenter);
     $tree->dataSource = SitemapModel::findAll();
     //$tree->enableSorting(array($this, 'move'));
     //$tree->renderer->wrappers['link']['collapse'] = null;
     //$tree->renderer->wrappers['link']['expand'] = null;
     //$tree->renderer->wrappers['node']['icon'] = null;
     $tree->renderer->wrappers['link']['collapse'] = 'a class="ui-icon ui-icon-circlesmall-minus" style="float: left"';
     $tree->renderer->wrappers['link']['expand'] = 'a class="ui-icon ui-icon-circlesmall-plus" style="float: left"';
     $tree->renderer->wrappers['node']['icon'] = 'span class="ui-icon ui-icon-document" style="float: left"';
     return $tree;
 }
开发者ID:romcok,项目名称:treeview,代码行数:19,代码来源:HomepagePresenter.php

示例8: renderDefault

 public function renderDefault($q, $page = 1)
 {
     try {
         $ids = array();
         foreach (fulltext::index()->find($q) as $hit) {
             $ids[] = $hit->getDocument()->id;
         }
         $this->template->paginator = new Paginator();
         $this->template->paginator->setItemCount(count($ids));
         $this->template->paginator->setItemsPerPage(Environment::getVariable('itemsPerPage', 30));
         $this->template->paginator->setPage($page);
         $this->template->products = mapper::products()->findByIds(array_slice($ids, $this->template->paginator->getOffset(), $this->template->paginator->getLength()));
         $this->template->title = __('Search results for ``%s"', $q);
         $this->template->q = $q;
         Environment::getSession(SESSION_SEARCH_NS)->last = $q;
         searchlog::log($q);
     } catch (Exception $e) {
         $this->template->products = array();
     }
 }
开发者ID:jakubkulhan,项目名称:shopaholic,代码行数:20,代码来源:SearchPresenter.php

示例9: renderProduct

 public function renderProduct()
 {
     // recent products
     if (!isset(Environment::getSession(SESSION_RECENTPRODUCTS_NS)->recent)) {
         Environment::getSession(SESSION_RECENTPRODUCTS_NS)->recent = array();
     }
     array_unshift(Environment::getSession(SESSION_RECENTPRODUCTS_NS)->recent, $this->template->product);
     $already_in = array();
     foreach (Environment::getSession(SESSION_RECENTPRODUCTS_NS)->recent as &$_) {
         $id = $_->getId();
         if (isset($already_in[$id])) {
             $_ = FALSE;
         }
         $already_in[$id] = TRUE;
     }
     Environment::getSession(SESSION_RECENTPRODUCTS_NS)->recent = array_slice(array_filter(Environment::getSession(SESSION_RECENTPRODUCTS_NS)->recent), 0, 5);
     // visited products
     array_push(Environment::getSession(SESSION_ORDER_NS)->visited, array($this->template->product, time()));
     // fill template
     $this->template->nav = mapper::categories()->findForNavByProductId($this->template->product->getId());
 }
开发者ID:jakubkulhan,项目名称:shopaholic,代码行数:21,代码来源:ShowPresenter.php

示例10: editFormSubmitted

 public function editFormSubmitted($form)
 {
     $func = 'save';
     switch ($form->name) {
         case 'studentsEditForm':
             $model = 'students';
             break;
         case 'teachersEditForm':
             $model = 'teachers';
             break;
         case 'coursesEditForm':
             $model = 'courses';
             break;
         case 'roomsEditForm':
             $model = 'school';
             $func = 'saveNewRoom';
             break;
         case 'departmentsEditForm':
             $model = 'school';
             $func = 'saveNewDepartment';
             break;
         case 'learning_timesEditForm':
             $model = 'school';
             $func = 'saveNewLearningTime';
             break;
     }
     $values = $form->getValues();
     $this->model($model)->{$func}($values);
     $namespace = Environment::getSession()->getNamespace('table');
     $table = $namespace->table;
     unset($namespace->table);
     $this->redirect('default', array('table' => $table));
 }
开发者ID:bazo,项目名称:diplomovka,代码行数:33,代码来源:TablesPresenter.php

示例11: onDataFormSubmit

 /**
  * Data form
  * @param string
  */
 public function onDataFormSubmit(Form $form)
 {
     // check for validity
     if (!$form->isValid()) {
         return;
     }
     // get data
     $order = Environment::getSession(SESSION_ORDER_NS);
     $order->data = $form->getValues();
     if ($order->data['same_delivery']) {
         foreach ($order->data as $k => $v) {
             if (strncmp($k, 'payer_', strlen('payer_')) === 0) {
                 $order->data['delivery_' . substr($k, strlen('payer_'))] = $v;
             }
         }
     }
     $this->redirect('complete');
 }
开发者ID:jakubkulhan,项目名称:shopaholic,代码行数:22,代码来源:OrderPresenter.php

示例12: Route

<?php

/**
 * Nette TreeView example bootstrap file.
 *
 * @copyright  Copyright (c) 2010 Roman Novák
 * @package    nette-treeview
 */
// 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(false);
Debug::enableProfiler();
// 2b) load configuration from config.ini file
Environment::loadConfig();
Environment::getSession()->start();
dibi::connect(Environment::getConfig('database'));
// Step 3: Configure application
// 3a) get and setup a front controller
$application = Environment::getApplication();
//$application->errorPresenter = 'Error';
$application->catchExceptions = false;
// 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();
开发者ID:romcok,项目名称:treeview,代码行数:31,代码来源:bootstrap.php

示例13: Exception

//Environment::setMode(Environment::DEVELOPMENT, false);
// 2b) load configuration from config.ini file
//require LIBS_DIR . '/Custom/MultipleConfigurator.php';
//Environment::setConfigurator(new MultipleConfigurator());
//$config = Environment::loadConfig();
// 2c) check if cache, sessions and log directories are writable
if (@file_put_contents(Environment::expand('%tempDir%/_check'), '') === FALSE) {
    throw new Exception("Make directory '" . Environment::getVariable('tempDir') . "' writable!");
}
if (@file_put_contents(Environment::expand('%sessionDir%/_check'), '') === FALSE) {
    throw new Exception("Make directory '" . Environment::getVariable('sessionDir') . "' writable!");
}
if (@file_put_contents(Environment::expand('%logDir%/_check'), '') === FALSE) {
    throw new Exception("Make directory '" . Environment::getVariable('logDir') . "' writable!");
}
$session = Environment::getSession();
$session->setSavePath(Environment::getVariable('sessionDir'));
//Environment::getHttpResponse()->cookiePath = '/'; // toto tu treba, aby fungovali cookie..v novsej verzii je to uz fixnute
$session->setExpiration($config['session']['lifetime']);
if (!$session->isStarted()) {
    $session->start();
}
/**
 * create new httpRequest for CLI
 * @see http://wiki.nette.org/cs/cookbook/http-routovani-v-cli
 */
if (Environment::isConsole()) {
    function createHttpRequestService()
    {
        $config = Environment::getConfig('httpRequest');
        // params can be taken from config or command line if needed
开发者ID:radypala,项目名称:maga-website,代码行数:31,代码来源:bootstrap.php

示例14: getSession

 /**
  * @return Session
  */
 protected function getSession($namespace = NULL)
 {
     return Environment::getSession($namespace);
 }
开发者ID:bazo,项目名称:diplomovka,代码行数:7,代码来源:Presenter.php

示例15: getNodeSession

 protected function getNodeSession()
 {
     return Environment::getSession()->getNamespace('Nette.Extras.TreeView/' . $this->getTreeView()->getName() . '/' . $this->getName());
 }
开发者ID:romcok,项目名称:treeview,代码行数:4,代码来源:TreeViewNode.php


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