Index: trunk/core/kernel/db/db_tag_processor.php
===================================================================
diff -u -N -r4225 -r4287
--- trunk/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 4225)
+++ trunk/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 4287)
@@ -140,6 +140,14 @@
return $o;
}
+ function GridFieldsCount($params)
+ {
+ $grids = $this->Application->getUnitOption($this->Prefix, 'Grids');
+ $grid_config = $grids[$params['grid']]['Fields'];
+
+ return count($grid_config);
+ }
+
/**
* Prints list content using block specified
*
@@ -288,8 +296,9 @@
$direction = (isset($params['direction']) && $params['direction']=="H")?"H":"V";
$columns = (isset($params['columns'])) ? $params['columns'] : 1;
+
$id_field = (isset($params['id_field'])) ? $params['id_field'] : $this->Application->getUnitOption($this->Prefix, 'IDField');
-
+
if ($columns>1 && $direction=="V") {
$list->Records = $this->LinearToVertical($list->Records, $columns, $list->GetPerPage());
$list->SelectedCount=count($list->Records);
@@ -301,7 +310,7 @@
$block_params=$this->prepareTagParams($params);
$block_params['name']=$this->SelectParam($params, 'render_as,block');
$block_params['pass_params']='true';
-
+ $block_params['column_width'] = 100 / $columns;
$block_start_row_params=$this->prepareTagParams($params);
$block_start_row_params['name'] = $this->SelectParam($params, 'row_start_render_as,block_row_start,row_start_block');
@@ -325,7 +334,7 @@
}
if (!$list->getCurrentRecord()){
- $o.= $block_empty_cell_params['name'] ? $this->Application->ParseBlock($block_params, 1) : '
| ';
+ $o.= $block_empty_cell_params['name'] ? $this->Application->ParseBlock($block_empty_cell_params, 1) : ' | ';
}
else {
$o.= $this->Application->ParseBlock($block_params, 1);
@@ -1334,6 +1343,7 @@
if ($temp_tables && $modified) {
$block_params = $this->prepareTagParams($params);
$block_params['name'] = $this->SelectParam($params, 'render_as,name');
+ $block_params['edit_mode'] = $temp_tables ? 1 : 0;
return $this->Application->ParseBlock($block_params);
}
$this->Application->RemoveVar($top_prefix.'_modified');
Index: trunk/kernel/admin_templates/user_selector.tpl
===================================================================
diff -u -N
--- trunk/kernel/admin_templates/user_selector.tpl (revision 0)
+++ trunk/kernel/admin_templates/user_selector.tpl (revision 4287)
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
Index: trunk/kernel/admin_templates/incs/script.js
===================================================================
diff -u -N -r4243 -r4287
--- trunk/kernel/admin_templates/incs/script.js (.../script.js) (revision 4243)
+++ trunk/kernel/admin_templates/incs/script.js (.../script.js) (revision 4287)
@@ -52,13 +52,13 @@
$array[$array.length] = arguments[arguments.length - 1];
}
-function processHooks($function_name, $hook_type)
+function processHooks($function_name, $hook_type, $prefix_special)
{
var $i = 0;
var $local_hooks = getArrayValue($hooks, $function_name, $hook_type);
while($i < $local_hooks.length) {
- $local_hooks[$i]($function_name);
+ $local_hooks[$i]($function_name, $prefix_special);
$i++;
}
}
@@ -133,11 +133,13 @@
submitted = true;
var $form = document.getElementById($form_prefix+'_form');
+ processHooks('SubmitKF', hBEFORE);
if (typeof $form.onsubmit == "function") {
$form.onsubmit();
}
$form.submit();
+ processHooks('SubmitKF', hAFTER);
$form.target = '';
$form.t.value = t;
@@ -261,6 +263,7 @@
if(!isset($height)) $height=400;
if(!isset(multi_line)) multi_line=0;
openwin('',$window_name,$width,$height);
+ set_hidden_field('return_template', document.kernel_form.elements['t'].value); // where should return after popup is done
set_hidden_field('translator_wnd_name', $window_name);
set_hidden_field('translator_field', field);
set_hidden_field('translator_t', t);
@@ -277,6 +280,7 @@
if(!isset($window_name)) var $window_name = 'select_'+t.replace(/(\/|-)/g, '_');
if(!isset(multi_line)) multi_line=0;
openwin('',$window_name,750,400);
+ set_hidden_field('return_template', document.kernel_form.elements['t'].value); // where should return after popup is done
set_hidden_field('translator_wnd_name', $window_name);
set_hidden_field('translator_field', field);
set_hidden_field('translator_t', t);
@@ -302,27 +306,37 @@
submit_event(prefix,'',$t,url);
}
-function openSelector($prefix,$url,$window_name,$width,$height,$event)
+function openSelector($prefix, $url, $dst_field, $window_size, $event)
{
+ var $kf = document.getElementById($form_prefix + '_form');
var $regex = new RegExp('(.*)\?env=' + document.getElementById('sid').value + '-(.*?):(.*)');
var $t = $regex.exec($url)[2];
- if(!isset($window_name)) var $window_name = 'select_'+$t.replace(/(\/|-)/g, '_');
- if(!isset($width)) $width=750;
- if(!isset($height)) $height=400;
+ var $window_name = 'select_'+$t.replace(/(\/|-)/g, '_');
+
+ if (!isset($window_size)) $window_size = '750x400';
+
+ $window_size = $window_size.split('x');
+
if(!isset($event)) $event='';
processHooks('openSelector', hBEFORE);
- cur_opener = get_hidden_field('m_opener');
- set_hidden_field('m_opener','p');
-
- openwin('',$window_name,$width,$height);
+
+ var $prev_action = $kf.action;
+ var $prev_opener = get_hidden_field('m_opener');
+
+ set_hidden_field('m_opener', 'p');
set_hidden_field('main_prefix', $prefix);
- document.kernel_form.target=$window_name;
- var old_action = document.kernel_form.action;
+ set_hidden_field('dst_field', $dst_field);
+ set_hidden_field('return_template', $kf.elements['t'].value); // where should return after popup is done
+
+ openwin('',$window_name,$window_size[0],$window_size[1]);
document.kernel_form.action = $url;
- submit_event($prefix,$event,$t);
+ document.kernel_form.target = $window_name;
+
+ submit_event($prefix, $event, $t);
+
processHooks('openSelector', hAFTER);
- document.kernel_form.action = old_action;
- set_hidden_field('m_opener',cur_opener);
+ $kf.action = $prev_action;
+ set_hidden_field('m_opener', $prev_opener);
}
function openwin($url,$name,$width,$height)
@@ -507,9 +521,16 @@
submit_event($prefix_special,'OnApplyFilters');
}
-function RemoveTranslationLink($string)
+function RemoveTranslationLink($string, $escaped)
{
- return $string.match(/<a href="(.*)">(.*)<\/a>/) ? RegExp.$2 : $string;
+ if (!isset($escaped)) $escaped = true;
+
+ if ($escaped) {
+ return $string.match(/<a href="(.*)">(.*)<\/a>/) ? RegExp.$2 : $string;
+ }
+ else {
+ return $string.match(/(.*)<\/a>/) ? RegExp.$2 : $string;
+ }
}
function redirect($url)
Index: trunk/kernel/admin_templates/stylesheets/block_style_edit.tpl
===================================================================
diff -u -N -r3664 -r4287
--- trunk/kernel/admin_templates/stylesheets/block_style_edit.tpl (.../block_style_edit.tpl) (revision 3664)
+++ trunk/kernel/admin_templates/stylesheets/block_style_edit.tpl (.../block_style_edit.tpl) (revision 4287)
@@ -57,7 +57,7 @@
{
if( ValidateRequired() )
{
- openSelector('selectors','',null,850,460,'OnOpenStyleEditor');
+ openSelector('selectors', '', '', '850x460', 'OnOpenStyleEditor');
}
else
{
Index: trunk/kernel/admin_templates/stylesheets/base_style_edit.tpl
===================================================================
diff -u -N -r3664 -r4287
--- trunk/kernel/admin_templates/stylesheets/base_style_edit.tpl (.../base_style_edit.tpl) (revision 3664)
+++ trunk/kernel/admin_templates/stylesheets/base_style_edit.tpl (.../base_style_edit.tpl) (revision 4287)
@@ -50,7 +50,7 @@
{
if( ValidateRequired() )
{
- openSelector('selectors','',null,850,460,'OnOpenStyleEditor');
+ openSelector('selectors', '', '', '850x460', 'OnOpenStyleEditor');
}
else
{
Index: trunk/kernel/constants.php
===================================================================
diff -u -N -r3553 -r4287
--- trunk/kernel/constants.php (.../constants.php) (revision 3553)
+++ trunk/kernel/constants.php (.../constants.php) (revision 4287)
@@ -2,7 +2,8 @@
define('HAVING_FILTER', 1);
define('WHERE_FILTER', 2);
-
+ define('AGGREGATE_FILTER', 3);
+
define('FLT_TYPE_AND', 'AND');
define('FLT_TYPE_OR', 'OR');
Index: trunk/core/kernel/db/dblist.php
===================================================================
diff -u -N -r3703 -r4287
--- trunk/core/kernel/db/dblist.php (.../dblist.php) (revision 3703)
+++ trunk/core/kernel/db/dblist.php (.../dblist.php) (revision 4287)
@@ -147,6 +147,8 @@
*/
var $HavingFilter = Array(FLT_SYSTEM => null, FLT_NORMAL => null, FLT_SEARCH => null, FLT_VIEW => null);
+ var $AggregateFilter = Array(FLT_SYSTEM => null, FLT_NORMAL => null);
+
var $GroupByFields = Array();
var $Queried = false;
@@ -166,18 +168,17 @@
$this->WhereFilter[FLT_NORMAL] =& $this->Application->makeClass('kMultipleFilter', FLT_TYPE_OR);
$this->WhereFilter[FLT_SEARCH] =& $this->Application->makeClass('kMultipleFilter', FLT_TYPE_OR);
- $this->WhereFilter[FLT_SEARCH]->setType(FLT_TYPE_OR);
-
$this->WhereFilter[FLT_VIEW] =& $this->Application->makeClass('kMultipleFilter', FLT_TYPE_AND);
$this->HavingFilter[FLT_SYSTEM] =& $this->Application->makeClass('kMultipleFilter', FLT_TYPE_AND);
$this->HavingFilter[FLT_NORMAL] =& $this->Application->makeClass('kMultipleFilter', FLT_TYPE_OR);
-
+
$this->HavingFilter[FLT_SEARCH] =& $this->Application->makeClass('kMultipleFilter', FLT_TYPE_OR);
- $this->HavingFilter[FLT_SEARCH]->setType(FLT_TYPE_OR);
-
$this->HavingFilter[FLT_VIEW] =& $this->Application->makeClass('kMultipleFilter', FLT_TYPE_AND);
+ $this->AggregateFilter[FLT_SYSTEM] =& $this->Application->makeClass('kMultipleFilter', FLT_TYPE_AND);
+ $this->AggregateFilter[FLT_NORMAL] =& $this->Application->makeClass('kMultipleFilter', FLT_TYPE_OR);
+
$this->PerPage = -1;
}
@@ -192,7 +193,10 @@
*/
function addFilter($name, $clause, $filter_type = WHERE_FILTER, $filter_scope = FLT_SYSTEM)
{
- $filter_name = ($filter_type == WHERE_FILTER) ? 'WhereFilter' : 'HavingFilter';
+ $filter_source = Array( WHERE_FILTER => 'WhereFilter',
+ HAVING_FILTER => 'HavingFilter',
+ AGGREGATE_FILTER => 'AggregateFilter');
+ $filter_name = $filter_source[$filter_type];
$filter =& $this->$filter_name;
$filter =& $filter[$filter_scope];
@@ -209,7 +213,10 @@
*/
function removeFilter($name, $filter_type = WHERE_FILTER, $filter_scope = FLT_SYSTEM)
{
- $filter_name = ($filter_type == WHERE_FILTER) ? 'WhereFilter' : 'HavingFilter';
+ $filter_source = Array( WHERE_FILTER => 'WhereFilter',
+ HAVING_FILTER => 'HavingFilter',
+ AGGREGATE_FILTER => 'AggregateFilter');
+ $filter_name = $filter_source[$filter_type];
$filter =& $this->$filter_name;
$filter =& $filter[$filter_scope];
@@ -224,23 +231,24 @@
*/
function clearFilters($user=true,$system=true,$search=true,$view=true)
{
- if($system)
- {
+ if ($system) {
$this->WhereFilter[FLT_SYSTEM]->clearFilters();
$this->HavingFilter[FLT_SYSTEM]->clearFilters();
+ $this->AggregateFilter[FLT_SYSTEM]->clearFilters();
}
- if($user)
- {
+
+ if ($user) {
$this->WhereFilter[FLT_NORMAL]->clearFilters();
$this->HavingFilter[FLT_NORMAL]->clearFilters();
+ $this->AggregateFilter[FLT_NORMAL]->clearFilters();
}
- if($search)
- {
+
+ if ($search) {
$this->WhereFilter[FLT_SEARCH]->clearFilters();
$this->HavingFilter[FLT_SEARCH]->clearFilters();
}
- if($view)
- {
+
+ if ($view) {
$this->WhereFilter[FLT_VIEW]->clearFilters();
$this->HavingFilter[FLT_VIEW]->clearFilters();
}
@@ -397,7 +405,7 @@
function GetSelectSQL($for_counting=false,$system_filters_only=false)
{
$q = parent::GetSelectSQL($this->SelectClause);
- if(!$for_counting) $q = $this->addCalculatedFields($q);
+ $q = !$for_counting ? $this->addCalculatedFields($q, 0) : str_replace('%2$s', '', $q);
$where = $this->GetWhereClause($for_counting,$system_filters_only);
$having = $this->GetHavingClause($for_counting,$system_filters_only);
@@ -412,12 +420,19 @@
return str_replace('%1$s',$this->TableName,$q);
}
- function extractCalculatedFields($clause)
+ /**
+ * Enter description here...
+ *
+ * @param string $clause where clause to extract calculated fields from
+ * @param int $aggregated 0 - having + aggregated, 1 - having only, 2 - aggregated only
+ * @return string
+ */
+ function extractCalculatedFields($clause, $aggregated = 1)
{
- if ( is_array($this->CalculatedFields) ) {
- foreach($this->CalculatedFields as $field_name => $field_expression)
- {
- $clause = preg_replace('/`'.$field_name.'`/', $field_expression, $clause);
+ $fields = $this->getCalculatedFields($aggregated);
+ if (is_array($fields) && count($fields) > 0) {
+ foreach ($fields as $field_name => $field_expression) {
+ $clause = preg_replace('/[`]{0,1}'.$field_name.'[`]{0,1}/', $field_expression, $clause);
}
}
return $clause;
@@ -449,7 +464,7 @@
if( $for_counting ) // add system_having and view_having to where
{
- $where->addFilter('system_having', $this->extractCalculatedFields( $this->HavingFilter[FLT_SYSTEM]->getSQL() ) );
+ $where->addFilter('system_having', $this->extractCalculatedFields($this->HavingFilter[FLT_SYSTEM]->getSQL()) );
if (!$system_filters_only) $where->addFilter('view_having', $this->extractCalculatedFields( $this->HavingFilter[FLT_VIEW]->getSQL() ) );
}
@@ -476,16 +491,24 @@
* Returns HAVING clause of the query
*
* @param bool $for_counting don't return having filter in case if this is counting sql
+ * @param bool $system_filters_only return only system having filters
+ * @param int $aggregated 0 - aggregated and having, 1 - having only, 2 - aggregated only
* @return string
* @access public
*/
- function GetHavingClause($for_counting=false, $system_filters_only=false)
+ function GetHavingClause($for_counting=false, $system_filters_only=false, $aggregated = 0)
{
- if( $for_counting ) return '';
+ if ($for_counting) {
+ return $this->extractCalculatedFields($this->AggregateFilter[FLT_SYSTEM]->getSQL(), 2);
+ }
$having =& $this->Application->makeClass('kMultipleFilter');
$having->addFilter('system_having', $this->HavingFilter[FLT_SYSTEM] );
+ if ($aggregated == 0) {
+ $having->addFilter('system_aggregated', $this->AggregateFilter[FLT_SYSTEM] );
+ }
+
if (!$system_filters_only) {
$having->addFilter('view_having', $this->HavingFilter[FLT_VIEW] );
$search_w = $this->WhereFilter[FLT_SEARCH]->getSQL();
Index: trunk/kernel/admin_templates/popups/translator.tpl
===================================================================
diff -u -N -r3664 -r4287
--- trunk/kernel/admin_templates/popups/translator.tpl (.../translator.tpl) (revision 3664)
+++ trunk/kernel/admin_templates/popups/translator.tpl (.../translator.tpl) (revision 4287)
@@ -52,6 +52,8 @@
+
+
+
+
+
|
-
-
-
-
-
-
+
|
@@ -216,13 +224,17 @@
$Menus[''+'_select_menu'].addMenuItem('','Grids[""].ClearSelection();');
$Menus[''+'_select_menu'].addMenuItem('','Grids[""].InvertSelection();');
+ processHooks('ViewMenu', hBEFORE, '');
+
$Menus[''+'_view_menu'] = new Menu('');
$Menus[''+'_view_menu'].addMenuItem( $Menus[''+'_filter_menu'] );
$Menus[''+'_view_menu'].addMenuItem( $Menus[''+'_sorting_menu'] );
$Menus[''+'_view_menu'].addMenuItem( $Menus[''+'_perpage_menu'] );
$Menus[''+'_view_menu'].addMenuItem( $Menus[''+'_select_menu'] );
+
+ processHooks('ViewMenu', hAFTER, '');
}
@@ -235,7 +247,7 @@
@@ -301,7 +313,7 @@
_Sort1_Dir" name="_Sort1_Dir" value="asc">
-
+
nobottomnotop">
@@ -316,9 +328,14 @@
+
+
+ | %"> |
+
+
Index: trunk/kernel/admin_templates/stylesheets/style_editor.tpl
===================================================================
diff -u -N -r3664 -r4287
--- trunk/kernel/admin_templates/stylesheets/style_editor.tpl (.../style_editor.tpl) (revision 3664)
+++ trunk/kernel/admin_templates/stylesheets/style_editor.tpl (.../style_editor.tpl) (revision 4287)
@@ -4,6 +4,9 @@
+
+
+