本文整理汇总了PHP中Nette\Application\UI\Control::loadState方法的典型用法代码示例。如果您正苦于以下问题:PHP Control::loadState方法的具体用法?PHP Control::loadState怎么用?PHP Control::loadState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Application\UI\Control
的用法示例。
在下文中一共展示了Control::loadState方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadState
/**
* Loads state informations.
* @param array
* @return void
*/
public function loadState(array $params)
{
/** check for invalid parameter value and in that case set it
* to default value.
*/
//if(isset($params['page']) && gettype($params['page']) != "integer" )
// $params['page'] = $this->page;
//dump("guuuu");
parent::loadState($params);
$this->getPaginator()->page = $this->page;
}
示例2: loadState
public function loadState(array $params)
{
$session = $this->getSession();
if (!empty($params) && isset($params['settings'])) {
$settings = array();
foreach ($params['settings'] as $key => $val) {
$settings[$key] = $val;
}
$session['settings'] = $settings;
} elseif (!empty($session['settings'])) {
foreach ($session['settings'] as $key => $val) {
$params['settings'][$key] = $val;
}
}
parent::loadState($params);
}
示例3: loadState
function loadState(array $params)
{
parent::loadState($params);
if (count($this->sort) == 0) {
foreach ($this->defaultSort as $k => $v) {
if (!isset($this->sort[$k])) {
$this->sort[$k] = $v;
}
}
}
foreach ($this->sort as $k => $v) {
if (!in_array($k, $this->enabledSort) && !isset($this->defaultSort[$k])) {
unset($this->sort[$k]);
continue;
}
if (!in_array($v, array_keys($this->enableValues))) {
unset($this->sort[$k]);
continue;
}
}
foreach ($this->defaultFilter as $k => $v) {
if (!isset($this->filter[$k])) {
$this->filter[$k] = $v;
}
}
foreach ($this->filter as $k => $v) {
if (!in_array($k, $this->enableFilter)) {
unset($this->filter[$k]);
continue;
}
}
if (!is_null($this->countCallback)) {
$this->count = call_user_func($this->countCallback, $this->getDbFilter());
} else {
throw new \LogicException('Missing count callback');
}
$this->limit = Nette\Utils\Validators::isNumericInt($this->limit) ? $this->limit : static::DEFAULT_LIMIT;
$this->page = Nette\Utils\Validators::isNumericInt($this->page) && $this->page <= ceil($this->count / $this->limit) && $this->page > 0 ? $this->page : 1;
$this->cleanSortKeys = $this->defaultSort;
foreach ($this->enabledSort as $k => $v) {
if (isset($this->cleanSortKeys[$k])) {
unset($this->cleanSortKeys[$k]);
}
}
}
示例4: loadState
public function loadState(array $params)
{
return $this->control->loadState($params);
}
示例5: loadState
/**
* Loads state informations.
* @param array
* @return void
*/
public function loadState(array $params)
{
parent::loadState($params);
if ($this->getParent() instanceof DataGrid) {
$this->getPaginator()->page = $this->getParent()->page;
}
}
示例6: loadState
/**
* Loads params
* @param array
* @return void
*/
public function loadState(array $params)
{
if (isset($params['order'])) {
$params['order'] = explode('.', (string) $params['order']);
// validate
$copy = $params['order'];
sort($copy);
if ($copy != range(0, $this->width * $this->width - 1)) {
unset($params['order']);
}
}
parent::loadState($params);
}
示例7: loadState
/**
* @param array $params
* @throws \Nette\Application\BadRequestException
*/
public function loadState(array $params)
{
parent::loadState($params);
if ($this->hasFilteringForm()) {
foreach ($params as $column => $value) {
if (!isset($this->filteringConditions[$column])) {
continue;
}
$this->filteringData[$column] = $value;
$this['filteringForm-' . $column]->setDefaultValue($value);
}
}
if ($this->view !== '') {
if (!$this->hasView($this->view)) {
throw new BadRequestException();
}
} elseif (!empty($this->views)) {
reset($this->views);
$this->view = key($this->views);
}
}
示例8: loadState
/**
* Loads state informations.
* @param array
* @return void
*/
public function loadState(array $params)
{
if ($this->rememberState) {
$session = $this->getStateSession();
foreach ($this->getPersistentParams() as $name) {
if (isset($session[$name]) && !isset($params[$name])) {
$params[$name] = $session[$name];
}
}
}
parent::loadState($params);
}
示例9: loadState
/**
* Loads state information
* @param array
* @return void
*/
public function loadState(array $params)
{
parent::loadState($params);
$datetime = \DateTime::createFromFormat('!Y-m', date($this->year . '-' . $this->month));
if ($datetime === false) {
$datetime = \DateTime::createFromFormat('!Y-m', date('Y-m'));
}
$this->month = $datetime->format('n');
$this->year = $datetime->format('Y');
}
示例10: loadState
/**
* @param array $params
* @return void
*/
public function loadState(array $params)
{
parent::loadState(static::processParams($params));
if (!$this->polluted && !$this->isInDefaultState()) {
$this->polluted = TRUE;
}
if (!$this->polluted) {
if ($this->defaultOrderBy !== NULL) {
$this->orderBy = array_merge($this->defaultOrderBy, $this->orderBy);
$this->polluted = TRUE;
}
if ($this->defaultFilters !== NULL) {
$this->setFilters($this->defaultFilters, FALSE);
$this->polluted = TRUE;
}
}
$i = 0;
foreach ($this->orderBy as $column => $dir) {
try {
$this['columns']->getComponent($column)->setSortedBy(TRUE, $dir, $i++);
} catch (\RuntimeException $e) {
unset($this->orderBy[$column]);
}
if (!$this->multiSort && $i > 1) {
unset($this->orderBy[$column]);
}
}
$this->validateState();
}
示例11: loadState
public function loadState(array $params)
{
if (isset($params['page']) and !Validators::is($params['page'], 'numericint')) {
$params['page'] = 1;
}
parent::loadState($params);
$this->getPaginator()->setPage($this->page);
$this->page = $this->getPaginator()->getPage();
}
示例12: loadState
/**
* @param array
*/
public function loadState(array $params)
{
parent::loadState($params);
// get items per page from session
if ($this->session !== NULL && $this->canSetItemsPerPage) {
if (isset($this->sessionSection->{$this->getSessionReposity()}) && in_array($this->sessionSection->{$this->getSessionReposity()}, array_keys($this->itemsPerPageList), TRUE)) {
$this->setItemsPerPage($this->sessionSection->{$this->getSessionReposity()});
} else {
unset($this->sessionSection->{$this->getSessionReposity()});
}
}
$this->getPaginator()->page = $this->page;
$this->getPaginator()->itemsPerPage = $this->itemsPerPage;
$this->page = $this->getPaginator()->page;
$this->itemsPerPage = $this->getPaginator()->itemsPerPage;
$this["itemsPerPage"]->setDefaults(["itemsPerPage" => $this->itemsPerPage]);
}
示例13: loadState
/**
* Loads state informations.
*
* @param array
* @return void
*/
public function loadState(array $params)
{
parent::loadState($params);
$this->getPaginator()->setDate(new DateTime($this->date ?: 'now'));
}
示例14: loadState
/**
* Get and load session params
* @param array $params
*/
public function loadState(array $params)
{
parent::loadState($params);
$this->getSession();
$this->loadSession();
}
示例15: loadState
/**
* Loads state informations
* @author Pavel Železný <info@pavelzelezny.cz>
* @param array $params
* @return void
*/
public function loadState(array $params)
{
parent::loadState($params);
$this->getPaginator()->setPage($this->getPage());
}