Index: branches/RC/core/kernel/db/db_tag_processor.php =================================================================== diff -u -r10116 -r10356 --- branches/RC/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 10116) +++ branches/RC/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 10356) @@ -70,8 +70,7 @@ $block_params['name'] = $params['spearator_block']; $separator = $this->Application->ParseBlock($block_params); $filter_menu = $this->Application->getUnitOption($this->Prefix,'FilterMenu'); - if(!$filter_menu) - { + if (!$filter_menu) { trigger_error('no filters defined for prefix '.$this->Prefix.', but DrawFilterMenu tag used', E_USER_WARNING); return ''; } @@ -80,9 +79,8 @@ $block_params['name'] = $params['item_block']; $view_filter = $this->Application->RecallVar($this->getPrefixSpecial().'_view_filter'); - if($view_filter === false) - { - $event_params = Array('prefix'=>$this->Prefix,'special'=>$this->Special,'name'=>'OnRemoveFilters'); + if ($view_filter === false) { + $event_params = Array ('prefix' => $this->Prefix, 'special' => $this->Special, 'name' => 'OnRemoveFilters'); $this->Application->HandleEvent( new kEvent($event_params) ); $view_filter = $this->Application->RecallVar($this->getPrefixSpecial().'_view_filter'); } @@ -121,10 +119,94 @@ $filters[] = $this->Application->ParseBlock($block_params); } - return implode('', $filters); } + /** + * Draws auto-refresh submenu in View Menu. + * + * @param Array $params + * @return string + */ + function DrawAutoRefreshMenu($params) + { + $refresh_intervals = $this->Application->ConfigValue('AutoRefreshIntervals'); + if (!$refresh_intervals) { + trigger_error('no filters defined for prefix '.$this->Prefix.', but DrawAutoRefreshMenu tag used', E_USER_WARNING); + return ''; + } + + $refresh_intervals = explode(',', $refresh_intervals); + $view_name = $this->Application->RecallVar($this->getPrefixSpecial().'_current_view'); + $current_refresh_interval = $this->Application->RecallPersistentVar($this->getPrefixSpecial().'_refresh_interval.'.$view_name); + if ($current_refresh_interval === false) { + // if no interval was selected before, then choose 1st interval + $current_refresh_interval = $refresh_intervals[0]; + } + + $ret = ''; + $block_params = $this->prepareTagParams($params); + $block_params['name'] = $params['render_as']; + + foreach ($refresh_intervals as $refresh_interval) { + $block_params['label'] = $this->_formatInterval($refresh_interval); + $block_params['refresh_interval'] = $refresh_interval; + $block_params['selected'] = $current_refresh_interval == $refresh_interval; + $ret .= $this->Application->ParseBlock($block_params); + } + return $ret; + } + + /** + * Tells, that current grid is using auto refresh + * + * @param Array $params + * @return bool + */ + function UseAutoRefresh($params) + { + $view_name = $this->Application->RecallVar($this->getPrefixSpecial().'_current_view'); + return $this->Application->RecallPersistentVar($this->getPrefixSpecial().'_auto_refresh.'.$view_name); + } + + /** + * Returns current grid refresh interval + * + * @param Array $params + * @return bool + */ + function AutoRefreshInterval($params) + { + $view_name = $this->Application->RecallVar($this->getPrefixSpecial().'_current_view'); + return $this->Application->RecallPersistentVar($this->getPrefixSpecial().'_refresh_interval.'.$view_name); + } + + /** + * Formats time interval using given text for hours and minutes + * + * @param int $intervalmMinutes + * @param string $hour_text Text for hours + * @param string $min_text Text for minutes + * @return unknown + */ + function _formatInterval($interval, $hour_text = 'h', $min_text = 'min') + { + // 65 + $minutes = $interval % 60; + $hours = ($interval - $minutes) / 60; + + $ret = ''; + if ($hours) { + $ret .= $hours.$hour_text.' '; + } + + if ($minutes) { + $ret .= $minutes.$min_text; + } + + return $ret; + } + function IterateGridFields($params) { $mode = $params['mode'];