Index: trunk/core/kernel/db/db_tag_processor.php
===================================================================
diff -u -r3368 -r3373
--- trunk/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 3368)
+++ trunk/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 3373)
@@ -1,22 +1,22 @@
Conn =& $this->Application->GetADODBConnection();
}
-
-
+
+
/**
* Returns true if "new" button was pressed in toolbar
*
@@ -28,7 +28,7 @@
$object =& $this->getObject($params);
return $object->GetID() <= 0;
}
-
+
/**
* Returns view menu name for current prefix
*
@@ -40,24 +40,24 @@
$item_name = $this->Application->getUnitOption($this->Prefix, 'ViewMenuPhrase');
return $this->Application->Phrase($item_name);
}
-
+
function ViewMenu($params)
{
$block_params = $params;
unset($block_params['block']);
$block_params['name'] = $params['block'];
-
+
$list =& $this->GetList($params);
$block_params['PrefixSpecial'] = $list->getPrefixSpecial();
return $this->Application->ParseBlock($block_params);
}
-
+
function SearchKeyword($params)
{
$list =& $this->GetList($params);
return $this->Application->RecallVar($list->getPrefixSpecial().'_search_keyword');
}
-
+
/**
* Draw filter menu content (for ViewMenu) based on filters defined in config
*
@@ -75,10 +75,10 @@
trigger_error('no filters defined for prefix '.$this->Prefix.', but DrawFilterMenu tag used', E_USER_WARNING);
return '';
}
-
+
// Params: label, filter_action, filter_status
$block_params['name'] = $params['item_block'];
-
+
$view_filter = $this->Application->RecallVar($this->getPrefixSpecial().'_view_filter');
if($view_filter === false)
{
@@ -87,18 +87,18 @@
$view_filter = $this->Application->RecallVar($this->getPrefixSpecial().'_view_filter');
}
$view_filter = unserialize($view_filter);
-
+
$filters = Array();
$prefix_special = $this->getPrefixSpecial();
-
+
foreach($filter_menu['Filters'] as $filter_key => $filter_params)
{
if(!$filter_params)
{
$filters[] = $separator;
continue;
}
-
+
$block_params['label'] = addslashes( $this->Application->Phrase($filter_params['label']) );
if( getArrayValue($view_filter,$filter_key) )
{
@@ -108,26 +108,26 @@
else
{
$submit = 1;
- $status = 0;
+ $status = 0;
}
$block_params['filter_action'] = 'set_filter("'.$prefix_special.'","'.$filter_key.'","'.$submit.'");';
$block_params['filter_status'] = $status;
$filters[] = $this->Application->ParseBlock($block_params);
}
return implode('', $filters);
}
-
+
function IterateGridFields($params)
{
$mode = $params['mode'];
$def_block = $params['block'];
-
+
$grids = $this->Application->getUnitOption($this->Prefix,'Grids');
$grid_config = $grids[$params['grid']]['Fields'];
-
+
$std_params['pass_params']='true';
$std_params['PrefixSpecial']=$this->getPrefixSpecial();
-
+
$o = '';
foreach ($grid_config as $field => $options) {
$block_params = Array();
@@ -139,7 +139,7 @@
}
return $o;
}
-
+
/**
* Prints list content using block specified
*
@@ -155,39 +155,39 @@
$list->Query();
$o = '';
$list->GoFirst();
-
+
$block_params=$this->prepareTagParams($params);
$block_params['name'] = $this->SelectParam($params, 'render_as,block');
$block_params['pass_params'] = 'true';
-
- while (!$list->EOL())
+
+ while (!$list->EOL())
{
$this->Application->SetVar( $this->getPrefixSpecial().'_id', $list->GetDBField($id_field) ); // for edit/delete links using GET
$o.= $this->Application->ParseBlock($block_params, 1);
$list->GoNext();
}
-
+
$this->Application->SetVar( $this->getPrefixSpecial().'_id', '');
- return $o;
+ return $o;
}
-
+
function InitList($params)
{
$list_name = $params['list_name'];
-
+
$names_mapping = $this->Application->GetVar('NamesToSpecialMapping');
-
+
if( !getArrayValue($names_mapping,$list_name) )
{
$list =& $this->GetList($params);
}
}
-
+
function BuildListSpecial($params)
{
return $this->Special;
}
-
+
/**
* Enter description here...
*
@@ -204,7 +204,7 @@
$requery = getArrayValue($params, 'requery');
if ($list_name && !$requery){
$names_mapping = $this->Application->GetVar('NamesToSpecialMapping');
-
+
$special = getArrayValue($names_mapping, $list_name);
if(!$special)
{
@@ -215,59 +215,62 @@
{
$special = $this->BuildListSpecial($params);
}
-
+
$prefix_special = rtrim($this->Prefix.'.'.$special, '.');
$params['skip_counting'] = true;
$list =& $this->Application->recallObject( $prefix_special, $this->Prefix.'_List',$params);
- $list->Query();
+ if ($requery) {
+ $this->Application->HandleEvent($an_event, $prefix_special.':OnListBuild', $params);
+ }
+ $list->Query($requery);
$this->Special = $special;
-
+
if ($list_name) {
$names_mapping[$list_name] = $special;
$this->Application->SetVar('NamesToSpecialMapping', $names_mapping);
}
-
+
return $list;
}
-
+
function ListMarker($params)
{
$list =& $this->GetList($params);
$ret = $list->getPrefixSpecial();
if( getArrayValue($params, 'as_preg') ) $ret = preg_quote($ret, '/');
return $ret;
}
-
+
function SubmitName($params)
{
$list =& $this->GetList($params);
-
+
$prefix_special = $list->getPrefixSpecial();
-
+
return 'events['.$prefix_special.']['.$params['event'].']';
}
-
-
+
+
function CombinedSortingDropDownName($params)
{
$list =& $this->GetList($params);
$prefix_special = $list->getPrefixSpecial();
-
+
return $prefix_special.'_CombinedSorting';
}
-
+
function SortingSelected($params)
{
$list =& $this->GetList($params);
$user_sorting_start = $this->getUserSortIndex();
-
+
$sorting = strtolower($list->GetOrderField($user_sorting_start).'|'.$list->GetOrderDirection($user_sorting_start));
-
+
if ($sorting == strtolower($params['sorting'])) return $params['selected'];
}
-
-
-
+
+
+
/**
* Prints list content using block specified
*
@@ -279,62 +282,62 @@
{
$per_page = $this->SelectParam($params, 'per_page,max_items');
if ($per_page !== false) $params['per_page'] = $per_page;
-
+
$list =& $this->GetList($params);
$o = '';
$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);
ksort($list->Records);
}
-
+
$list->GoFirst();
-
+
$block_params=$this->prepareTagParams($params);
$block_params['name']=$this->SelectParam($params, 'render_as,block');
$block_params['pass_params']='true';
-
+
$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');
-
+
$block_end_row_params=$this->prepareTagParams($params);
$block_end_row_params['name'] = $this->SelectParam($params, 'row_end_render_as,block_row_end,row_end_block');
-
+
$block_empty_cell_params = $this->prepareTagParams($params);
$block_empty_cell_params['name'] = $this->SelectParam($params, 'empty_cell_render_as,block_empty_cell,empty_cell_block');
-
+
$i=0;
-
+
$backup_id=$this->Application->GetVar($this->Prefix."_id");
$displayed = array();
- while (!$list->EOL())
+ while (!$list->EOL())
{
$this->Application->SetVar( $this->getPrefixSpecial().'_id', $list->GetDBField($id_field) ); // for edit/delete links using GET
- $this->Application->SetVar( $this->Prefix.'_id', $list->GetDBField($id_field) );
-
+ $this->Application->SetVar( $this->Prefix.'_id', $list->GetDBField($id_field) );
+
if ($i % $columns == 0) {
$o.= $block_start_row_params['name'] ? $this->Application->ParseBlock($block_start_row_params, 1) : '
';
}
-
+
if (!$list->getCurrentRecord()){
$o.= $block_empty_cell_params['name'] ? $this->Application->ParseBlock($block_params, 1) : ' | ';
}
else {
$o.= $this->Application->ParseBlock($block_params, 1);
array_push($displayed, $list->GetDBField($id_field));
}
-
+
if (($i+1) % $columns == 0) {
$o.= $block_end_row_params['name'] ? $this->Application->ParseBlock($block_end_row_params, 1) : '
';
}
-
+
$list->GoNext();
-
+
$i++;
}
$cur_displayed = $this->Application->GetVar($this->Prefix.'_displayed_ids');
@@ -344,22 +347,22 @@
else {
$cur_displayed = explode(',', $cur_displayed);
}
-
+
$displayed = array_unique(array_merge($displayed, $cur_displayed));
$this->Application->SetVar($this->Prefix.'_displayed_ids', implode(',',$displayed));
-
+
$this->Application->SetVar( $this->Prefix.'_id', $backup_id);
$this->Application->SetVar( $this->getPrefixSpecial().'_id', '');
-
+
if (isset($params['more_link_render_as'])) {
$block_params = $params;
$params['render_as'] = $params['more_link_render_as'];
$o .= $this->MoreLink($params);
}
-
- return $o;
+
+ return $o;
}
-
+
function MoreLink($params)
{
$per_page = $this->SelectParam($params, 'per_page,max_items');
@@ -371,18 +374,18 @@
return $this->Application->ParseBlock($block_params, 1);
}
}
-
+
function NotLastItem($params)
{
$object =& $this->getObject($params); // maybe we should use $this->GetList($params) instead
return ($object->CurrentIndex < min($object->PerPage, $object->RecordsCount) - 1);
}
-
+
function PageLink($params)
{
$t = isset($params['template']) ? $param['template'] : '';
if (!$t) $t = $this->Application->GetVar('t');
-
+
if (isset($params['page'])) {
$this->Application->SetVar($this->getPrefixSpecial().'_Page', $params['page']);
}
@@ -391,16 +394,16 @@
// $get = $http_query->getRedirectParams();
$pass = Array('pass' => 'all,'.$this->getPrefixSpecial());
// $pass = array_merge($get, $pass);
-
+
return $this->Application->HREF($t, '', $pass);
}
-
+
function ColumnWidth($params)
{
$columns = $this->Application->Parser->GetParam('columns');
return round(100/$columns).'%';
}
-
+
/**
* Append prefix and special to tag
* params (get them from tagname) like
@@ -418,7 +421,7 @@
$ret['PrefixSpecial'] = $this->getPrefixSpecial();
return $ret;
}
-
+
function GetISO($currency)
{
if ($currency == 'selected') {
@@ -432,21 +435,21 @@
}
return $iso;
}
-
+
function ConvertCurrency($value, $iso)
{
$converter =& $this->Application->recallObject('kCurrencyRates');
// convery primary currency to selected (if they are the same, converter will just return)
$value = $converter->Convert($value, 'PRIMARY', $iso);
return $value;
}
-
+
function AddCurrencySymbol($value, $iso)
{
$this->Application->setUnitOption('curr', 'AutoLoad', false);
$currency =& $this->Application->recallObject('curr.-'.$iso);
if( !$currency->isLoaded() ) $currency->Load($iso, 'ISO');
-
+
$symbol = $currency->GetDBField('Symbol');
if (!$symbol) $symbol = $currency->GetDBField('ISO').' ';
if ($currency->GetDBField('SymbolPosition') == 0) {
@@ -457,7 +460,7 @@
}
return $value;
}
-
+
/**
* Get's requested field value
*
@@ -468,14 +471,14 @@
function Field($params)
{
$field = $this->SelectParam($params, 'name,field');
-
+
if( !$this->Application->IsAdmin() ) $params['no_special'] = 'no_special';
$object =& $this->getObject($params);
if ( $this->HasParam($params, 'db') )
{
- $value = $object->GetDBField($field);
+ $value = $object->GetDBField($field);
}
else
{
@@ -487,7 +490,7 @@
$object->SetDBField($field, $value);
$object->Fields[$field]['converted'] = true;
}
-
+
$format = getArrayValue($params, 'format');
if( !$format || $format == '$format' )
{
@@ -502,50 +505,50 @@
}
}
$value = $object->GetField($field, $format);
-
+
if( $this->SelectParam($params, 'negative') )
{
if(strpos($value, '-') === 0)
{
$value = substr($value, 1);
}
- else
+ else
{
$value = '-'.$value;
}
}
-
+
if( $this->HasParam($params, 'currency') )
{
$value = $this->AddCurrencySymbol($value, $iso);
$params['no_special'] = 1;
}
}
-
+
if( getArrayValue($params,'nl2br' ) ) $value = nl2br($value);
if( !$this->HasParam($params, 'no_special') ) $value = htmlspecialchars($value);
if( getArrayValue($params,'checked' ) ) $value = ($value == 1) ? 'checked' : '';
if( getArrayValue($params,'as_label') ) $value = $this->Application->Phrase($value);
-
+
$first_chars = $this->SelectParam($params,'first_chars,cut_first');
if($first_chars)
{
$needs_cut = strlen($value) > $first_chars;
$value = substr($value,0,$first_chars);
if($needs_cut) $value .= ' ...';
}
-
+
if ($value != '') $this->Application->Parser->DataExists = true;
-
+
if( $this->HasParam($params, 'currency') )
{
//restoring value in original currency, for other Field tags to work properly
- $object->SetDBField($field, $original);
+ $object->SetDBField($field, $original);
}
-
+
return $value;
}
-
+
/**
* Checks if parameter is passed
* Note: works like Tag and line simple method too
@@ -559,27 +562,27 @@
if( !isset($param_name) )
{
$param_name = $this->SelectParam($params, 'name');
- $params = $this->Application->Parser->Params;
+ $params = $this->Application->Parser->Params;
}
$value = getArrayValue($params, $param_name);
- return $value && ($value != '$'.$param_name);
+ return $value && ($value != '$'.$param_name);
}
-
+
function PhraseField($params)
{
$field_label = $this->Field($params);
$translation = $this->Application->Phrase( $field_label );
return $translation;
}
-
+
function Error($params)
{
$field = $params['field'];
$object =& $this->getObject($params);
$msg = $object->GetErrorMsg($field, false);
return $msg;
}
-
+
function HasError($params)
{
if ($params['field'] == 'any')
@@ -588,7 +591,7 @@
$skip_fields = getArrayValue($params, 'except');
$skip_fields = $skip_fields ? explode(',', $skip_fields) : Array();
-
+
return $object->HasErrors($skip_fields);
}
else
@@ -604,7 +607,7 @@
return $res;
}
}
-
+
function IsRequired($params)
{
$field = $params['field'];
@@ -613,7 +616,7 @@
$options = $object->GetFieldOptions($field);
return getArrayValue($options,'required');
}
-
+
function PredefinedOptions($params)
{
$field = $params['field'];
@@ -627,22 +630,22 @@
if($empty_value === false) $empty_value = '';
$options['options'] = array_merge_recursive2( Array($empty_value => ''), $options['options'] );
}
-
+
$block_params = $this->prepareTagParams($params);
-
+
$block_params['name'] = $this->SelectParam($params, 'render_as,block');
$block_params['field'] = $params['field'];
$block_params['pass_params'] = 'true';
$block_params['field_name'] = $this->InputName($params);
$block_params['PrefixSpecial'] = $this->getPrefixSpecial();
-
+
$selected_param_name = getArrayValue($params,'selected_param');
if(!$selected_param_name) $selected_param_name = $params['selected'];
$selected = $params['selected'];
-
+
$o = '';
if( $this->HasParam($params,'no_empty') && !getArrayValue($options['options'],'') ) array_shift($options['options']);
-
+
if( strpos($value, '|') !== false )
{
// multiple selection checkboxes
@@ -668,14 +671,14 @@
}
return $o;
}
-
+
function Format($params)
{
$field = $params['field'];
$object =& $this->getObject($params);
$options = $object->GetFieldOptions($field);
-
+
$formatter_class = getArrayValue($options,'formatter');
if($formatter_class)
{
@@ -685,18 +688,18 @@
$sample = getArrayValue($params,'sample');
if($sample)
{
- return $formatter->GetSample($field, $options, $object);
+ return $formatter->GetSample($field, $options, $object);
}
elseif($human_format || $edit_size)
{
$format = $formatter->HumanFormat($options['format']);
return $edit_size ? strlen($format) : $format;
}
}
-
+
return $options['format'];
}
-
+
/**
* Print grid pagination using
* block names specified
@@ -710,28 +713,28 @@
$list =& $this->GetList($params);
$prefix_special = $list->getPrefixSpecial();
$total_pages = $list->GetTotalPages();
-
+
if ($total_pages) $this->Application->Parser->DataExists = true;
-
+
if($total_pages == 0) $total_pages = 1; // display 1st page as selected in case if we have no pages at all
$o = '';
-
+
// what are these 2 lines for?
$this->Application->SetVar($prefix_special.'_event','');
$this->Application->SetVar($prefix_special.'_id','');
-
+
$current_page = $list->Page; // $this->Application->RecallVar($prefix_special.'_Page');
-
+
$block_params = $this->prepareTagParams($params);
-
+
$split = ( isset($params['split'] ) ? $params['split'] : 10 );
-
+
$split_start = $current_page - ceil($split/2);
if ($split_start < 1){
$split_start = 1;
}
$split_end = $split_start + $split-1;
-
+
if ($split_end > $total_pages) {
$split_end = $total_pages;
$split_start = max($split_end - $split + 1, 1);
@@ -744,25 +747,25 @@
$prev_block_params['page'] = max($current_page-$split, 1);
$prev_block_params['name'] = $this->SelectParam($params, 'prev_page_split_render_as,prev_page_split_block');
if ($prev_block_params['name']){
- $o .= $this->Application->ParseBlock($prev_block_params, 1);
+ $o .= $this->Application->ParseBlock($prev_block_params, 1);
}
}
-
+
$prev_block_params['name'] = 'page';
$prev_block_params['page'] = $current_page-1;
$prev_block_params['name'] = $this->SelectParam($params, 'prev_page_render_as,block_prev_page,prev_page_block');
if ($prev_block_params['name']) {
$this->Application->SetVar($this->getPrefixSpecial().'_Page', $current_page-1);
- $o .= $this->Application->ParseBlock($prev_block_params, 1);
- }
+ $o .= $this->Application->ParseBlock($prev_block_params, 1);
+ }
}
else {
if ( $no_prev_page_block = $this->SelectParam($params, 'no_prev_page_render_as,block_no_prev_page') ) {
$block_params['name'] = $no_prev_page_block;
- $o .= $this->Application->ParseBlock($block_params, 1);
- }
+ $o .= $this->Application->ParseBlock($block_params, 1);
+ }
}
-
+
$separator_params['name'] = $this->SelectParam($params, 'separator_render_as,block_separator');
for ($i = $split_start; $i <= $split_end; $i++)
{
@@ -772,32 +775,32 @@
else {
$block = $this->SelectParam($params, 'link_render_as,inactive_render_as,block_link,inactive_block');
}
-
+
$block_params['name'] = $block;
$block_params['page'] = $i;
$this->Application->SetVar($this->getPrefixSpecial().'_Page', $i);
$o .= $this->Application->ParseBlock($block_params, 1);
-
- if ($this->SelectParam($params, 'separator_render_as,block_separator')
- && $i < $split_end)
+
+ if ($this->SelectParam($params, 'separator_render_as,block_separator')
+ && $i < $split_end)
{
$o .= $this->Application->ParseBlock($separator_params, 1);
}
}
-
+
if ($current_page < $total_pages){
$next_block_params = $this->prepareTagParams();
$next_block_params['page']=$current_page+1;
$next_block_params['name'] = $this->SelectParam($params, 'next_page_render_as,block_next_page,next_page_block');
if ($next_block_params['name']){
$this->Application->SetVar($this->getPrefixSpecial().'_Page', $current_page+1);
- $o .= $this->Application->ParseBlock($next_block_params, 1);
- }
+ $o .= $this->Application->ParseBlock($next_block_params, 1);
+ }
if ($total_pages > $split){
$next_block_params['page']=min($current_page+$split, $total_pages);
$next_block_params['name'] = $this->SelectParam($params, 'next_page_split_render_as,next_page_split_block');
if ($next_block_params['name']){
- $o .= $this->Application->ParseBlock($next_block_params, 1);
+ $o .= $this->Application->ParseBlock($next_block_params, 1);
}
}
}
@@ -892,19 +895,19 @@
{
$list_sortings = $this->Application->getUnitOption($this->Prefix, 'ListSortings');
$sorting_prefix = getArrayValue($list_sortings, $this->Special) ? $this->Special : '';
-
+
$user_sorting_start = 0;
if ( $forced_sorting = getArrayValue($list_sortings, $sorting_prefix, 'ForcedSorting') ) {
$user_sorting_start = count($forced_sorting);
}
return $user_sorting_start;
}
-
+
/**
* Returns order direction for given field
- *
- *
*
+ *
+ *
* @param Array $params
* @return string
* @access public
@@ -913,9 +916,9 @@
{
$field = $params['field'];
$user_sorting_start = $this->getUserSortIndex();
-
+
$list =& $this->GetList($params);
-
+
if ($list->GetOrderField($user_sorting_start) == $field)
{
return strtolower($list->GetOrderDirection($user_sorting_start));
@@ -942,11 +945,11 @@
$user_sorting_start = $this->getUserSortIndex() + --$params['pos'];
$list =& $this->GetList($params);
// $object =& $this->Application->recallObject( $this->getPrefixSpecial() );
-
+
if($params['type'] == 'field') return $list->GetOrderField($user_sorting_start);
if($params['type'] == 'direction') return $list->GetOrderDirection($user_sorting_start);
}
-
+
/**
* Checks if sorting field/direction matches passed field/direction parameter
*
@@ -957,11 +960,11 @@
{
$params['type'] = isset($params['field']) ? 'field' : 'direction';
$value = $this->OrderInfo($params);
-
+
if( isset($params['field']) ) return $params['field'] == $value;
if( isset($params['direction']) ) return $params['direction'] == $value;
}
-
+
/**
* Returns list perpage
*
@@ -973,7 +976,7 @@
$object =& $this->getObject($params);
return $object->PerPage;
}
-
+
/**
* Checks if list perpage matches value specified
*
@@ -985,14 +988,14 @@
$object =& $this->getObject($params);
return $object->PerPage == $params['value'];
}
-
+
function SaveEvent($params)
{
// SaveEvent is set during OnItemBuild, but we may need it before any other tag calls OnItemBuild
$object =& $this->getObject($params);
return $this->Application->GetVar($this->getPrefixSpecial().'_SaveEvent');
}
-
+
function NextId($params)
{
$object =& $this->getObject($params);
@@ -1006,7 +1009,7 @@
}
return '';
}
-
+
function PrevId($params)
{
$object =& $this->getObject($params);
@@ -1020,22 +1023,22 @@
}
return '';
}
-
+
function IsSingle($params)
{
return ($this->NextId($params) === '' && $this->PrevId($params) === '');
}
-
+
function IsLast($params)
{
return ($this->NextId($params) === '');
}
-
+
function IsFirst($params)
{
return ($this->PrevId($params) === '');
}
-
+
/**
* Checks if field value is equal to proposed one
*
@@ -1049,28 +1052,28 @@
// if( getArrayValue($params,'inverse') ) $ret = !$ret;
return $ret;
}
-
+
function ItemIcon($params)
{
$object =& $this->getObject($params);
$grids = $this->Application->getUnitOption($this->Prefix,'Grids');
$icons =& $grids[ $params['grid'] ]['Icons'];
-
+
$key = '';
$status_fields = $this->Application->getUnitOption($this->Prefix,'StatusField');
if(!$status_fields) return $icons['default'];
-
+
foreach($status_fields as $status_field)
{
$key .= $object->GetDBField($status_field).'_';
}
$key = rtrim($key,'_');
$value = ($key !== false) ? $key : 'default';
-
+
return isset($icons[$value]) ? $icons[$value] : $icons['default'];
}
-
+
/**
* Generates bluebar title + initializes prefixes used on page
*
@@ -1082,20 +1085,20 @@
$title_presets = $this->Application->getUnitOption($this->Prefix,'TitlePresets');
$title_info = getArrayValue($title_presets, $params['title_preset'] );
if($title_info === false) return $params['title'];
-
+
if( getArrayValue($title_presets,'default') )
{
// use default labels + custom labels specified in preset used
$title_info = array_merge_recursive2($title_presets['default'], $title_info);
}
-
+
$title = $title_info['format'];
-
+
// 1. get objects in use for title construction
$objects = Array();
$object_status = Array();
$status_labels = Array();
-
+
$prefixes = getArrayValue($title_info,'prefixes');
$all_tag_params = getArrayValue($title_info,'tag_params');
if($prefixes)
@@ -1105,13 +1108,13 @@
{
$prefix_data = $this->Application->processPrefix($prefix_special);
$prefix_data['prefix_special'] = rtrim($prefix_data['prefix_special'],'.');
-
+
if($all_tag_params)
{
$tag_params = getArrayValue($all_tag_params, $prefix_data['prefix_special']);
if(!$tag_params) $tag_params = Array();
}
-
+
$tag_params = array_merge_recursive2($params, $tag_params);
$objects[ $prefix_data['prefix_special'] ] =& $this->Application->recallObject($prefix_data['prefix_special'], $prefix_data['prefix'], $tag_params);
$object_status[ $prefix_data['prefix_special'] ] = $objects[ $prefix_data['prefix_special'] ]->GetID() ? 'edit' : 'new';
@@ -1132,10 +1135,10 @@
}
}
}
-
+
// 2. replace phrases if any found in format string
$title = $this->Application->ReplaceLanguageTags($title,false);
-
+
// 3. find and replace any replacement vars
preg_match_all('/#(.*_.*)#/Uis',$title,$rets);
if($rets[1])
@@ -1149,13 +1152,13 @@
$title = str_replace('#'.$replacement_var.'#', $new_value, $title);
}
}
-
+
$cut_first = getArrayValue($params,'cut_first');
if( $cut_first && strlen($title) > $cut_first && !preg_match('/(.*)<\/a>/',$title) ) $title = substr($title, 0, $cut_first).' ...';
-
+
return $title;
}
-
+
function getInfo(&$object, $info_type)
{
switch ($info_type)
@@ -1174,9 +1177,9 @@
break;
}
}
-
+
/**
- * Parses block depending on its element type.
+ * Parses block depending on its element type.
* For radio and select elements values are taken from 'value_list_field' in key1=value1,key2=value2
* format. key=value can be substituted by SELECT f1 AS OptionName, f2 AS OptionValue... FROM TableName
* where prefix is TABLE_PREFIX
@@ -1188,14 +1191,14 @@
{
$object =& $this->getObject($params);
$field = $params['field'];
-
+
$helper =& $this->Application->recallObject('InpCustomFieldsHelper');
-
- $element_type = $object->GetDBField($params['element_type_field']);
-
+
+ $element_type = $object->GetDBField($params['element_type_field']);
+
if($element_type == 'label') $element_type = 'text';
$params['name'] = $params['blocks_prefix'].$element_type;
-
+
switch($element_type)
{
case 'select':
@@ -1204,11 +1207,11 @@
$field_options['options'] = $helper->GetValuesHash( $object->GetDBField($params['value_list_field']) );
$object->SetFieldOptions($field, $field_options);
break;
-
+
case 'textarea':
$params['field_params'] = $helper->ParseConfigSQL($object->GetDBField($params['value_list_field']));
- break;
-
+ break;
+
case 'password':
case 'text':
case 'checkbox':
@@ -1217,7 +1220,7 @@
}
return $this->Application->ParseBlock($params, 1);
}
-
+
/**
* Get's requested custom field value
*
@@ -1230,13 +1233,13 @@
$object =& $this->getObject($params);
$field = $this->SelectParam($params, 'name,field');
-
+
$lang_id = $this->Application->GetVar('m_lang');
-
+
$sql = ' SELECT cv.l'.$lang_id.'_Value FROM '.TABLE_PREFIX.'CustomField cf
LEFT JOIN '.TABLE_PREFIX.'CustomMetaData cv
ON cf.CustomFieldId = cv.CustomFieldId
- WHERE cf.Type = '.$this->Application->getUnitOption($this->Prefix, 'ItemType').'
+ WHERE cf.Type = '.$this->Application->getUnitOption($this->Prefix, 'ItemType').'
AND cv.ResourceId = '.$object->GetDBField('ResourceId').'
AND cf.FieldName = "'.$field.'"';
return $this->Conn->GetOne($sql);
@@ -1247,11 +1250,11 @@
$object =& $this->Application->recallObject($this->Prefix); // not using Special here (for what purpose ?)
$field = $this->SelectParam($params, 'name,field');
-
+
$sql = ' SELECT FieldLabel FROM '.TABLE_PREFIX.'CustomField WHERE FieldName = "'.$field.'"';
return $this->Application->Phrase($this->Conn->GetOne($sql));
- }
-
+ }
+
/**
* transposes 1-dimensional array elements for vertical alignment according to given columns and per_page parameters
*
@@ -1274,7 +1277,7 @@
reset($imatrix);
return $imatrix;
}
-
+
/**
* If data was modfied & is in TempTables mode, then parse block with name passed;
* remove modification mark if not in TempTables mode
@@ -1289,24 +1292,24 @@
$main_prefix = getArrayValue($params, 'main_prefix');
if($main_prefix && $main_prefix != '$main_prefix')
{
- $top_prefix = $main_prefix;
+ $top_prefix = $main_prefix;
}
else
{
- $top_prefix = $this->Application->GetTopmostPrefix($this->Prefix);
+ $top_prefix = $this->Application->GetTopmostPrefix($this->Prefix);
}
-
+
$temp_tables = $this->Application->GetVar($top_prefix.'_mode') == 't';
$modified = $this->Application->RecallVar($top_prefix.'_modified');
-
+
if($temp_tables && $modified)
{
return $this->Application->ParseBlock($params);
}
$this->Application->RemoveVar($top_prefix.'_modified');
return '';
}
-
+
/**
* Returns list record count queries (on all pages)
*
@@ -1319,7 +1322,7 @@
if (!$list->Counted) $list->CountRecs();
return $list->RecordsCount;
}
-
+
/**
* Range filter field name
*
@@ -1331,7 +1334,7 @@
$field = $this->SelectParam($params, 'field,name');
return 'custom_filters['.$this->getPrefixSpecial().']['.$field.'_'.$params['type'].']';
}
-
+
/**
* Return range filter field value
*
@@ -1341,22 +1344,22 @@
function SearchField($params) // RangeValue
{
$field = $this->SelectParam($params, 'field,name');
-
+
$custom_filters = $this->Application->RecallVar($this->getPrefixSpecial().'_custom_filters');
$custom_filters = $custom_filters ? unserialize($custom_filters) : Array();
-
+
$append = getArrayValue($params, 'type');
-
+
return getArrayValue($custom_filters, $field.( $append ? '_'.$append : '') );
}
-
+
function SearchFormat($params)
{
$field = $params['field'];
$object =& $this->GetList($params);
$options = $object->GetFieldOptions($field);
-
+
$formatter_class = getArrayValue($options,'formatter');
if($formatter_class)
{
@@ -1366,18 +1369,18 @@
$sample = getArrayValue($params,'sample');
if($sample)
{
- return $formatter->GetSample($field, $options, $object);
+ return $formatter->GetSample($field, $options, $object);
}
elseif($human_format || $edit_size)
{
$format = $formatter->HumanFormat($options['format']);
return $edit_size ? strlen($format) : $format;
}
}
-
+
return $options['format'];
}
-
+
/**
* Returns error of range field
*
@@ -1387,7 +1390,7 @@
function SearchError($params)
{
$field = $this->SelectParam($params, 'field,name');
-
+
$error_var_name = $this->getPrefixSpecial().'_'.$field.'_'.$params['type'].'_error';
$error_msg = $this->Application->RecallVar($error_var_name);
if($error_msg)
@@ -1396,7 +1399,7 @@
}
return $error_msg;
}
-
+
/**
* Returns templates path for module, which is gathered from prefix module
*