Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/kernel/db/db_tag_processor.php
Show First 20 Lines • Show All 368 Lines • ▼ Show 20 Line(s) | |||||
else { | else { | ||||
// list without "list_name" parameter | // list without "list_name" parameter | ||||
$special = $main_list ? $this->Special : $this->BuildListSpecial($params); | $special = $main_list ? $this->Special : $this->BuildListSpecial($params); | ||||
} | } | ||||
$prefix_special = rtrim($this->Prefix . '.' . $special, '.'); | $prefix_special = rtrim($this->Prefix . '.' . $special, '.'); | ||||
$params['skip_counting'] = true; | $params['skip_counting'] = true; | ||||
/** @var kDBList $list */ | |||||
$list = $this->Application->recallObject($prefix_special, $this->Prefix . '_List', $params); | $list = $this->Application->recallObject($prefix_special, $this->Prefix . '_List', $params); | ||||
/* @var $list kDBList */ | |||||
if ( !array_key_exists('skip_quering', $params) || !$params['skip_quering'] ) { | if ( !array_key_exists('skip_quering', $params) || !$params['skip_quering'] ) { | ||||
if ( $requery ) { | if ( $requery ) { | ||||
$this->Application->HandleEvent(new kEvent($prefix_special . ':OnListBuild', $params)); | $this->Application->HandleEvent(new kEvent($prefix_special . ':OnListBuild', $params)); | ||||
} | } | ||||
if ( array_key_exists('offset', $params) ) { | if ( array_key_exists('offset', $params) ) { | ||||
$list->SetOffset($list->GetOffset() + $params['offset']); // apply custom offset | $list->SetOffset($list->GetOffset() + $params['offset']); // apply custom offset | ||||
▲ Show 20 Lines • Show All 154 Lines • ▼ Show 20 Line(s) | |||||
if ( ($i + 1) % $columns == 0 ) { | if ( ($i + 1) % $columns == 0 ) { | ||||
// record in next iteration is first in row too, then close this row | // record in next iteration is first in row too, then close this row | ||||
$o .= $block_end_row_params['name'] ? $this->Application->ParseBlock($block_end_row_params) : (!isset($params['no_table']) ? '</tr>' : ''); | $o .= $block_end_row_params['name'] ? $this->Application->ParseBlock($block_end_row_params) : (!isset($params['no_table']) ? '</tr>' : ''); | ||||
} | } | ||||
if ( $this->Special && $this->Application->hasObject($this->Prefix) ) { | if ( $this->Special && $this->Application->hasObject($this->Prefix) ) { | ||||
// object, produced by "kDBList::linkToParent" method, that otherwise would keep it's id | // object, produced by "kDBList::linkToParent" method, that otherwise would keep it's id | ||||
/** @var kDBBase $item */ | |||||
$item = $this->Application->recallObject($this->Prefix); | $item = $this->Application->recallObject($this->Prefix); | ||||
/* @var $item kDBBase */ | |||||
if ( $item instanceof kDBItem ) { | if ( $item instanceof kDBItem ) { | ||||
$this->Application->removeObject($this->Prefix); | $this->Application->removeObject($this->Prefix); | ||||
} | } | ||||
} | } | ||||
$list->GoNext(); | $list->GoNext(); | ||||
$i++; | $i++; | ||||
Show All 39 Lines | |||||
* Use only on item detail pages. | * Use only on item detail pages. | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @return int | * @return int | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function PreviousResource($params) | protected function PreviousResource($params) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
/** @var ListHelper $list_helper */ | |||||
$list_helper = $this->Application->recallObject('ListHelper'); | $list_helper = $this->Application->recallObject('ListHelper'); | ||||
/* @var $list_helper ListHelper */ | |||||
$select_clause = $this->Application->getUnitOption($object->Prefix, 'NavigationSelectClause', null); | $select_clause = $this->Application->getUnitOption($object->Prefix, 'NavigationSelectClause', null); | ||||
return $list_helper->getNavigationResource($object, $params['list'], false, $select_clause); | return $list_helper->getNavigationResource($object, $params['list'], false, $select_clause); | ||||
} | } | ||||
/** | /** | ||||
* Returns ID of next record (related to current) in list. | * Returns ID of next record (related to current) in list. | ||||
* Use only on item detail pages. | * Use only on item detail pages. | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @return int | * @return int | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function NextResource($params) | protected function NextResource($params) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
/** @var ListHelper $list_helper */ | |||||
$list_helper = $this->Application->recallObject('ListHelper'); | $list_helper = $this->Application->recallObject('ListHelper'); | ||||
/* @var $list_helper ListHelper */ | |||||
$select_clause = $this->Application->getUnitOption($object->Prefix, 'NavigationSelectClause', null); | $select_clause = $this->Application->getUnitOption($object->Prefix, 'NavigationSelectClause', null); | ||||
return $list_helper->getNavigationResource($object, $params['list'], true, $select_clause); | return $list_helper->getNavigationResource($object, $params['list'], true, $select_clause); | ||||
} | } | ||||
/** | /** | ||||
* Allows to modify block params & current list record before PrintList parses record | * Allows to modify block params & current list record before PrintList parses record | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | |||||
return ''; | return ''; | ||||
} | } | ||||
function PageLink($params) | function PageLink($params) | ||||
{ | { | ||||
static $default_per_page = Array (); | static $default_per_page = Array (); | ||||
/** @var kDBList $object */ | |||||
$object =& $this->GetList($params); | $object =& $this->GetList($params); | ||||
/* @var $object kDBList */ | |||||
// process sorting | // process sorting | ||||
if ($object->isMainList()) { | if ($object->isMainList()) { | ||||
if (!array_key_exists('sort_by', $params)) { | if (!array_key_exists('sort_by', $params)) { | ||||
$sort_by = $this->Application->GetVar('sort_by'); | $sort_by = $this->Application->GetVar('sort_by'); | ||||
if ($sort_by !== false) { | if ($sort_by !== false) { | ||||
$params['sort_by'] = $sort_by; | $params['sort_by'] = $sort_by; | ||||
Show All 24 Lines | |||||
// process per-page | // process per-page | ||||
$per_page = array_key_exists('per_page', $params) ? $params['per_page'] : $this->Application->GetVar($prefix_special . '_PerPage'); | $per_page = array_key_exists('per_page', $params) ? $params['per_page'] : $this->Application->GetVar($prefix_special . '_PerPage'); | ||||
if (!$per_page) { | if (!$per_page) { | ||||
// ensure, that per-page is always present | // ensure, that per-page is always present | ||||
list ($prefix, ) = explode('.', $prefix_special); | list ($prefix, ) = explode('.', $prefix_special); | ||||
if (!array_key_exists($prefix, $default_per_page)) { | if (!array_key_exists($prefix, $default_per_page)) { | ||||
/** @var ListHelper $list_helper */ | |||||
$list_helper = $this->Application->recallObject('ListHelper'); | $list_helper = $this->Application->recallObject('ListHelper'); | ||||
/* @var $list_helper ListHelper */ | |||||
$default_per_page[$prefix] = $list_helper->getDefaultPerPage($prefix); | $default_per_page[$prefix] = $list_helper->getDefaultPerPage($prefix); | ||||
} | } | ||||
if ($object->isMainList()) { | if ($object->isMainList()) { | ||||
$params[$prefix_special . '_PerPage'] = $this->Application->GetVar('per_page', $default_per_page[$prefix]); | $params[$prefix_special . '_PerPage'] = $this->Application->GetVar('per_page', $default_per_page[$prefix]); | ||||
} | } | ||||
else { | else { | ||||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Line(s) | |||||
* | * | ||||
* @param float $value | * @param float $value | ||||
* @param string $target_iso | * @param string $target_iso | ||||
* @param string $source_iso | * @param string $source_iso | ||||
* @return float | * @return float | ||||
*/ | */ | ||||
function ConvertCurrency($value, $target_iso, $source_iso = 'PRIMARY') | function ConvertCurrency($value, $target_iso, $source_iso = 'PRIMARY') | ||||
{ | { | ||||
/** @var CurrencyRates $converter */ | |||||
$converter = $this->Application->recallObject('CurrencyRates'); | $converter = $this->Application->recallObject('CurrencyRates'); | ||||
/* @var $converter CurrencyRates */ | |||||
return $converter->Convert($value, $source_iso, $target_iso); | return $converter->Convert($value, $source_iso, $target_iso); | ||||
} | } | ||||
function AddCurrencySymbol($value, $iso, $decimal_tag = '') | function AddCurrencySymbol($value, $iso, $decimal_tag = '') | ||||
{ | { | ||||
/** @var CurrencyRates $converter */ | |||||
$converter = $this->Application->recallObject('CurrencyRates'); | $converter = $this->Application->recallObject('CurrencyRates'); | ||||
/* @var $converter CurrencyRates */ | |||||
return $converter->AddCurrencySymbol($value, $iso, $decimal_tag); | return $converter->AddCurrencySymbol($value, $iso, $decimal_tag); | ||||
} | } | ||||
/** | /** | ||||
* Get's requested field value | * Get's requested field value | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @return string | * @return string | ||||
* @access public | * @access public | ||||
*/ | */ | ||||
function Field($params) | function Field($params) | ||||
{ | { | ||||
$field = $this->SelectParam($params, 'name,field'); | $field = $this->SelectParam($params, 'name,field'); | ||||
if (!$this->Application->isAdmin) { | if (!$this->Application->isAdmin) { | ||||
// don't apply kUtil::escape() on any field value on Front-End | // don't apply kUtil::escape() on any field value on Front-End | ||||
$params['no_special'] = 'no_special'; | $params['no_special'] = 'no_special'; | ||||
} | } | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
if (array_key_exists('db', $params) && $params['db']) { | if (array_key_exists('db', $params) && $params['db']) { | ||||
$value = $object->GetDBField($field); | $value = $object->GetDBField($field); | ||||
} | } | ||||
else { | else { | ||||
if (array_key_exists('currency', $params) && $params['currency']) { | if (array_key_exists('currency', $params) && $params['currency']) { | ||||
$source_iso = isset($params['currency_field']) ? $object->GetDBField($params['currency_field']) : 'PRIMARY'; | $source_iso = isset($params['currency_field']) ? $object->GetDBField($params['currency_field']) : 'PRIMARY'; | ||||
$target_iso = $this->GetISO($params['currency'], $source_iso); | $target_iso = $this->GetISO($params['currency'], $source_iso); | ||||
▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Line(s) | |||||
* | * | ||||
* @param $params | * @param $params | ||||
*/ | */ | ||||
function DateField($params) | function DateField($params) | ||||
{ | { | ||||
$field = $this->SelectParam($params, 'name,field'); | $field = $this->SelectParam($params, 'name,field'); | ||||
if ($field) { | if ($field) { | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
$timestamp = $object->GetDBField($field); | $timestamp = $object->GetDBField($field); | ||||
} | } | ||||
else { | else { | ||||
$timestamp = $params['value']; | $timestamp = $params['value']; | ||||
} | } | ||||
$date = $timestamp; | $date = $timestamp; | ||||
Show All 17 Lines | |||||
list ($replacement_name, $case_suffix_value) = explode('=', $case_suffux, 2); | list ($replacement_name, $case_suffix_value) = explode('=', $case_suffux, 2); | ||||
$replacements[$replacement_name] .= $case_suffix_value; | $replacements[$replacement_name] .= $case_suffix_value; | ||||
} | } | ||||
} | } | ||||
$format = array_key_exists('format', $params) ? $params['format'] : false; | $format = array_key_exists('format', $params) ? $params['format'] : false; | ||||
if (preg_match('/_regional_(.*)/', $format, $regs)) { | if (preg_match('/_regional_(.*)/', $format, $regs)) { | ||||
/** @var kDBItem $language */ | |||||
$language = $this->Application->recallObject('lang.current'); | $language = $this->Application->recallObject('lang.current'); | ||||
/* @var $language kDBItem */ | |||||
$format = $language->GetDBField($regs[1]); | $format = $language->GetDBField($regs[1]); | ||||
} | } | ||||
elseif (!$format) { | elseif (!$format) { | ||||
$format = null; | $format = null; | ||||
} | } | ||||
// escape formats, that are resolved to words by adodb_date | // escape formats, that are resolved to words by adodb_date | ||||
Show All 16 Lines | |||||
return $date_formatted; | return $date_formatted; | ||||
} | } | ||||
function SetField($params) | function SetField($params) | ||||
{ | { | ||||
// <inp2:SetField field="Value" src=p:cust_{$custom_name}"/> | // <inp2:SetField field="Value" src=p:cust_{$custom_name}"/> | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
$dst_field = $this->SelectParam($params, 'name,field'); | $dst_field = $this->SelectParam($params, 'name,field'); | ||||
list($prefix_special, $src_field) = explode(':', $params['src']); | list($prefix_special, $src_field) = explode(':', $params['src']); | ||||
/** @var kDBItem $src_object */ | |||||
$src_object = $this->Application->recallObject($prefix_special); | $src_object = $this->Application->recallObject($prefix_special); | ||||
/* @var $src_object kDBItem */ | |||||
$object->SetDBField($dst_field, $src_object->GetDBField($src_field)); | $object->SetDBField($dst_field, $src_object->GetDBField($src_field)); | ||||
} | } | ||||
/** | /** | ||||
* Depricated | * Depricated | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @return string | * @return string | ||||
* @deprecated parameter "as_label" of "Field" tag does the same | * @deprecated parameter "as_label" of "Field" tag does the same | ||||
*/ | */ | ||||
function PhraseField($params) | function PhraseField($params) | ||||
{ | { | ||||
$field_label = $this->Field($params); | $field_label = $this->Field($params); | ||||
$translation = $this->Application->Phrase( $field_label ); | $translation = $this->Application->Phrase( $field_label ); | ||||
return $translation; | return $translation; | ||||
} | } | ||||
function Error($params) | function Error($params) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
$field = $this->SelectParam($params, 'name,field'); | $field = $this->SelectParam($params, 'name,field'); | ||||
return $object->GetErrorMsg($field, false); | return $object->GetErrorMsg($field, false); | ||||
} | } | ||||
function HasError($params) | function HasError($params) | ||||
{ | { | ||||
if ($params['field'] == 'any') { | if ($params['field'] == 'any') { | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
$skip_fields = array_key_exists('except', $params) ? $params['except'] : false; | $skip_fields = array_key_exists('except', $params) ? $params['except'] : false; | ||||
$skip_fields = $skip_fields ? explode(',', $skip_fields) : Array(); | $skip_fields = $skip_fields ? explode(',', $skip_fields) : Array(); | ||||
return $object->HasErrors($skip_fields); | return $object->HasErrors($skip_fields); | ||||
} | } | ||||
else { | else { | ||||
$res = false; | $res = false; | ||||
Show All 28 Lines | |||||
return $this->Application->ParseBlock($params); | return $this->Application->ParseBlock($params); | ||||
} | } | ||||
return ''; | return ''; | ||||
} | } | ||||
function IsRequired($params) | function IsRequired($params) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
$field = $params['field']; | $field = $params['field']; | ||||
$formatter_class = $object->GetFieldOption($field, 'formatter'); | $formatter_class = $object->GetFieldOption($field, 'formatter'); | ||||
if ( $formatter_class == 'kMultiLanguage' ) { | if ( $formatter_class == 'kMultiLanguage' ) { | ||||
/** @var kMultiLanguage $formatter */ | |||||
$formatter = $this->Application->recallObject($formatter_class); | $formatter = $this->Application->recallObject($formatter_class); | ||||
/* @var $formatter kMultiLanguage */ | |||||
$field = $formatter->LangFieldName($field); | $field = $formatter->LangFieldName($field); | ||||
} | } | ||||
return $object->isRequired($field); | return $object->isRequired($field); | ||||
} | } | ||||
function FieldOption($params) | function FieldOption($params) | ||||
Show All 9 Lines | |||||
* Prints list a all possible field options | * Prints list a all possible field options | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @return string | * @return string | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function PredefinedOptions($params) | protected function PredefinedOptions($params) | ||||
{ | { | ||||
/** @var kDBList $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBList */ | |||||
$field = $params['field']; | $field = $params['field']; | ||||
$value = array_key_exists('value', $params) ? $params['value'] : $object->GetDBField($field); | $value = array_key_exists('value', $params) ? $params['value'] : $object->GetDBField($field); | ||||
$field_options = $object->GetFieldOptions($field); | $field_options = $object->GetFieldOptions($field); | ||||
if (!array_key_exists('options', $field_options) || !is_array($field_options['options'])) { | if (!array_key_exists('options', $field_options) || !is_array($field_options['options'])) { | ||||
trigger_error('Options not defined for <strong>'.$object->Prefix.'</strong> field <strong>'.$field.'</strong>', E_USER_WARNING); | trigger_error('Options not defined for <strong>'.$object->Prefix.'</strong> field <strong>'.$field.'</strong>', E_USER_WARNING); | ||||
return ''; | return ''; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Line(s) | |||||
$index++; | $index++; | ||||
} | } | ||||
} | } | ||||
return $o; | return $o; | ||||
} | } | ||||
function PredefinedSearchOptions($params) | function PredefinedSearchOptions($params) | ||||
{ | { | ||||
/** @var kDBList $object */ | |||||
$object =& $this->GetList($params); | $object =& $this->GetList($params); | ||||
/* @var $object kDBList */ | |||||
$params['value'] = $this->SearchField($params); | $params['value'] = $this->SearchField($params); | ||||
return $this->PredefinedOptions($params); | return $this->PredefinedOptions($params); | ||||
} | } | ||||
function Format($params, $object = null) | function Format($params, $object = null) | ||||
{ | { | ||||
$field = $this->SelectParam($params, 'name,field'); | $field = $this->SelectParam($params, 'name,field'); | ||||
if ( !isset($object) ) { | if ( !isset($object) ) { | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
} | } | ||||
$options = $object->GetFieldOptions($field); | $options = $object->GetFieldOptions($field); | ||||
$format = $options[$this->SelectParam($params, 'input_format') ? 'input_format' : 'format']; | $format = $options[$this->SelectParam($params, 'input_format') ? 'input_format' : 'format']; | ||||
$formatter_class = array_key_exists('formatter', $options) ? $options['formatter'] : false; | $formatter_class = array_key_exists('formatter', $options) ? $options['formatter'] : false; | ||||
if ( $formatter_class ) { | if ( $formatter_class ) { | ||||
/** @var kFormatter $formatter */ | |||||
$formatter = $this->Application->recallObject($formatter_class); | $formatter = $this->Application->recallObject($formatter_class); | ||||
/* @var $formatter kFormatter */ | |||||
$human_format = array_key_exists('human', $params) ? $params['human'] : false; | $human_format = array_key_exists('human', $params) ? $params['human'] : false; | ||||
$edit_size = array_key_exists('edit_size', $params) ? $params['edit_size'] : false; | $edit_size = array_key_exists('edit_size', $params) ? $params['edit_size'] : false; | ||||
$sample = array_key_exists('sample', $params) ? $params['sample'] : false; | $sample = array_key_exists('sample', $params) ? $params['sample'] : false; | ||||
if ( $sample ) { | if ( $sample ) { | ||||
return $formatter->GetSample($field, $options, $object); | return $formatter->GetSample($field, $options, $object); | ||||
} | } | ||||
Show All 11 Lines | |||||
* Returns grid padination information | * Returns grid padination information | ||||
* Can return links to pages | * Can return links to pages | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @return mixed | * @return mixed | ||||
*/ | */ | ||||
function PageInfo($params) | function PageInfo($params) | ||||
{ | { | ||||
/** @var kDBList $object */ | |||||
$object =& $this->GetList($params); | $object =& $this->GetList($params); | ||||
/* @var $object kDBList */ | |||||
$type = $params['type']; | $type = $params['type']; | ||||
unset($params['type']); // remove parameters used only by current tag | unset($params['type']); // remove parameters used only by current tag | ||||
$ret = ''; | $ret = ''; | ||||
switch ($type) { | switch ($type) { | ||||
case 'current': | case 'current': | ||||
$ret = $object->GetPage(); | $ret = $object->GetPage(); | ||||
▲ Show 20 Lines • Show All 206 Lines • ▼ Show 20 Line(s) | |||||
* if required) and item's id from it's IDField or field required | * if required) and item's id from it's IDField or field required | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @return Array (id,field) | * @return Array (id,field) | ||||
* @access private | * @access private | ||||
*/ | */ | ||||
function prepareInputName($params) | function prepareInputName($params) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
$field = $this->SelectParam($params, 'name,field'); | $field = $this->SelectParam($params, 'name,field'); | ||||
$formatter_class = $object->GetFieldOption($field, 'formatter'); | $formatter_class = $object->GetFieldOption($field, 'formatter'); | ||||
if ($formatter_class == 'kMultiLanguage') { | if ($formatter_class == 'kMultiLanguage') { | ||||
/** @var kMultiLanguage $formatter */ | |||||
$formatter = $this->Application->recallObject($formatter_class); | $formatter = $this->Application->recallObject($formatter_class); | ||||
/* @var $formatter kMultiLanguage */ | |||||
$force_primary = $object->GetFieldOption($field, 'force_primary'); | $force_primary = $object->GetFieldOption($field, 'force_primary'); | ||||
$field = $formatter->LangFieldName($field, $force_primary); | $field = $formatter->LangFieldName($field, $force_primary); | ||||
} | } | ||||
if (array_key_exists('force_id', $params)) { | if (array_key_exists('force_id', $params)) { | ||||
$id = $params['force_id']; | $id = $params['force_id']; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 107 Lines • ▼ Show 20 Line(s) | |||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @return bool | * @return bool | ||||
*/ | */ | ||||
function OrderChanged($params) | function OrderChanged($params) | ||||
{ | { | ||||
$list =& $this->GetList($params); | $list =& $this->GetList($params); | ||||
/** @var ListHelper $list_helper */ | |||||
$list_helper = $this->Application->recallObject('ListHelper'); | $list_helper = $this->Application->recallObject('ListHelper'); | ||||
/* @var $list_helper ListHelper */ | |||||
return $list_helper->hasUserSorting($list); | return $list_helper->hasUserSorting($list); | ||||
} | } | ||||
/** | /** | ||||
* Gets information of sorting field at "pos" position, | * Gets information of sorting field at "pos" position, | ||||
* like sorting field name (type="field") or sorting direction (type="direction") | * like sorting field name (type="field") or sorting direction (type="direction") | ||||
* | * | ||||
▲ Show 20 Lines • Show All 125 Lines • ▼ Show 20 Line(s) | |||||
* Checks if field value is equal to proposed one | * Checks if field value is equal to proposed one | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @return bool | * @return bool | ||||
* @deprecated | * @deprecated | ||||
*/ | */ | ||||
function FieldEquals($params) | function FieldEquals($params) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
return $object->GetDBField( $this->SelectParam($params, 'name,field') ) == $params['value']; | return $object->GetDBField( $this->SelectParam($params, 'name,field') ) == $params['value']; | ||||
} | } | ||||
/** | /** | ||||
* Checks, that grid has icons defined and they should be shown | * Checks, that grid has icons defined and they should be shown | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | |||||
$icons = $grid['Icons']; | $icons = $grid['Icons']; | ||||
if ( isset($params['name']) ) { | if ( isset($params['name']) ) { | ||||
$icon_name = $params['name']; | $icon_name = $params['name']; | ||||
return isset($icons[$icon_name]) ? $icons[$icon_name] : ''; | return isset($icons[$icon_name]) ? $icons[$icon_name] : ''; | ||||
} | } | ||||
/** @var Array $status_fields */ | |||||
$status_fields = $this->Application->getUnitOption($this->Prefix, 'StatusField', Array ()); | $status_fields = $this->Application->getUnitOption($this->Prefix, 'StatusField', Array ()); | ||||
/* @var $status_fields Array */ | |||||
if ( !$status_fields ) { | if ( !$status_fields ) { | ||||
return $icons['default']; | return $icons['default']; | ||||
} | } | ||||
/** @var kDBList $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBList */ | |||||
$icon = ''; | $icon = ''; | ||||
foreach ($status_fields as $status_field) { | foreach ($status_fields as $status_field) { | ||||
$icon .= $object->GetDBField($status_field) . '_'; | $icon .= $object->GetDBField($status_field) . '_'; | ||||
} | } | ||||
$icon = rtrim($icon, '_'); | $icon = rtrim($icon, '_'); | ||||
Show All 30 Lines | |||||
// 1. get objects in use for title construction | // 1. get objects in use for title construction | ||||
$objects = Array(); | $objects = Array(); | ||||
$object_status = Array(); | $object_status = Array(); | ||||
$status_labels = Array(); | $status_labels = Array(); | ||||
$prefixes = array_key_exists('prefixes', $title_info) ? $title_info['prefixes'] : false; | $prefixes = array_key_exists('prefixes', $title_info) ? $title_info['prefixes'] : false; | ||||
$all_tag_params = array_key_exists('tag_params', $title_info) ? $title_info['tag_params'] : false; | $all_tag_params = array_key_exists('tag_params', $title_info) ? $title_info['tag_params'] : false; | ||||
/* @var $prefixes Array */ | /** @var Array $prefixes */ | ||||
if ($prefixes) { | if ($prefixes) { | ||||
// extract tag_params passed directly to SectionTitle tag for specific prefix | // extract tag_params passed directly to SectionTitle tag for specific prefix | ||||
foreach ($params as $tp_name => $tp_value) { | foreach ($params as $tp_name => $tp_value) { | ||||
if (preg_match('/(.*)\[(.*)\]/', $tp_name, $regs)) { | if (preg_match('/(.*)\[(.*)\]/', $tp_name, $regs)) { | ||||
$all_tag_params[ $regs[1] ][ $regs[2] ] = $tp_value; | $all_tag_params[ $regs[1] ][ $regs[2] ] = $tp_value; | ||||
unset($params[$tp_name]); | unset($params[$tp_name]); | ||||
} | } | ||||
Show All 28 Lines | |||||
$title = str_replace('#'.$prefix_data['prefix_special'].'_titlefield#', $new_value, $title); | $title = str_replace('#'.$prefix_data['prefix_special'].'_titlefield#', $new_value, $title); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
// replace to section title | // replace to section title | ||||
$section = array_key_exists('section', $params) ? $params['section'] : false; | $section = array_key_exists('section', $params) ? $params['section'] : false; | ||||
if ($section) { | if ($section) { | ||||
/** @var kSectionsHelper $sections_helper */ | |||||
$sections_helper = $this->Application->recallObject('SectionsHelper'); | $sections_helper = $this->Application->recallObject('SectionsHelper'); | ||||
/* @var $sections_helper kSectionsHelper */ | |||||
$section_data =& $sections_helper->getSectionData($section); | $section_data =& $sections_helper->getSectionData($section); | ||||
$title = str_replace('#section_label#', '!' . $section_data['label'] . '!', $title); | $title = str_replace('#section_label#', '!' . $section_data['label'] . '!', $title); | ||||
} | } | ||||
// 2. replace phrases if any found in format string | // 2. replace phrases if any found in format string | ||||
$title = $this->Application->ReplaceLanguageTags($title, false); | $title = $this->Application->ReplaceLanguageTags($title, false); | ||||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | |||||
break; | break; | ||||
} | } | ||||
return $object->GetField($info_type); | return $object->GetField($info_type); | ||||
} | } | ||||
function GridInfo($params) | function GridInfo($params) | ||||
{ | { | ||||
/** @var kDBList $object */ | |||||
$object =& $this->GetList($params); | $object =& $this->GetList($params); | ||||
/* @var $object kDBList */ | |||||
switch ( $params['type'] ) { | switch ( $params['type'] ) { | ||||
case 'filtered': | case 'filtered': | ||||
return $object->GetRecordsCount(); | return $object->GetRecordsCount(); | ||||
case 'total': | case 'total': | ||||
return $object->GetRecordsCount(false); | return $object->GetRecordsCount(false); | ||||
Show All 23 Lines | |||||
* format. key=value can be substituted by <SQL>SELECT f1 AS OptionName, f2 AS OptionValue... FROM <PREFIX>TableName </SQL> | * format. key=value can be substituted by <SQL>SELECT f1 AS OptionName, f2 AS OptionValue... FROM <PREFIX>TableName </SQL> | ||||
* where prefix is TABLE_PREFIX | * where prefix is TABLE_PREFIX | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @return string | * @return string | ||||
*/ | */ | ||||
function ConfigFormElement($params) | function ConfigFormElement($params) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
$field = $params['field']; | $field = $params['field']; | ||||
/** @var InpCustomFieldsHelper $helper */ | |||||
$helper = $this->Application->recallObject('InpCustomFieldsHelper'); | $helper = $this->Application->recallObject('InpCustomFieldsHelper'); | ||||
/* @var $helper InpCustomFieldsHelper */ | |||||
$element_type = $object->GetDBField($params['element_type_field']); | $element_type = $object->GetDBField($params['element_type_field']); | ||||
if ($element_type == 'label') { | if ($element_type == 'label') { | ||||
$element_type = 'text'; | $element_type = 'text'; | ||||
} | } | ||||
$formatter_class = $object->GetFieldOption($field, 'formatter'); | $formatter_class = $object->GetFieldOption($field, 'formatter'); | ||||
▲ Show 20 Lines • Show All 201 Lines • ▼ Show 20 Line(s) | |||||
$ret = $ret[$params['type']]; | $ret = $ret[$params['type']]; | ||||
} | } | ||||
if ( array_key_exists('formatted', $params) && $params['formatted'] ) { | if ( array_key_exists('formatted', $params) && $params['formatted'] ) { | ||||
$object =& $this->GetList($params); | $object =& $this->GetList($params); | ||||
$formatter_class = $object->GetFieldOption($field, 'formatter'); | $formatter_class = $object->GetFieldOption($field, 'formatter'); | ||||
if ( $formatter_class ) { | if ( $formatter_class ) { | ||||
/** @var kFormatter $formatter */ | |||||
$formatter = $this->Application->recallObject($formatter_class); | $formatter = $this->Application->recallObject($formatter_class); | ||||
/* @var $formatter kFormatter */ | |||||
$ret = $formatter->Format($ret, $field, $object); | $ret = $formatter->Format($ret, $field, $object); | ||||
} | } | ||||
} | } | ||||
if ( !array_key_exists('no_special', $params) || !$params['no_special'] ) { | if ( !array_key_exists('no_special', $params) || !$params['no_special'] ) { | ||||
$ret = kUtil::escape($ret); | $ret = kUtil::escape($ret); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Line(s) | |||||
$field = $this->SelectParam($params, 'field,name'); | $field = $this->SelectParam($params, 'field,name'); | ||||
$error_var_name = $this->getPrefixSpecial() . '_' . $field . '_error'; | $error_var_name = $this->getPrefixSpecial() . '_' . $field . '_error'; | ||||
$pseudo = $this->Application->RecallVar($error_var_name); | $pseudo = $this->Application->RecallVar($error_var_name); | ||||
if ( $pseudo ) { | if ( $pseudo ) { | ||||
$this->Application->RemoveVar($error_var_name); | $this->Application->RemoveVar($error_var_name); | ||||
} | } | ||||
/** @var kDBItem $object */ | |||||
$object = $this->Application->recallObject($this->Prefix . '.' . $this->Special . '-item', null, Array ('skip_autoload' => true)); | $object = $this->Application->recallObject($this->Prefix . '.' . $this->Special . '-item', null, Array ('skip_autoload' => true)); | ||||
/* @var $object kDBItem */ | |||||
$object->SetError($field, $pseudo); | $object->SetError($field, $pseudo); | ||||
return $object->GetErrorMsg($field, false); | return $object->GetErrorMsg($field, false); | ||||
} | } | ||||
/** | /** | ||||
* Returns object used in tag processor | * Returns object used in tag processor | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @access public | * @access public | ||||
* @return kDBItem|kDBList | * @return kDBItem|kDBList | ||||
*/ | */ | ||||
function getObject($params = Array()) | function getObject($params = Array()) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $this->Application->recallObject($this->getPrefixSpecial(), $this->Prefix, $params); | $object = $this->Application->recallObject($this->getPrefixSpecial(), $this->Prefix, $params); | ||||
/* @var $object kDBItem */ | |||||
if ( isset($params['requery']) && $params['requery'] ) { | if ( isset($params['requery']) && $params['requery'] ) { | ||||
$this->Application->HandleEvent(new kEvent($this->getPrefixSpecial() . ':LoadItem', $params)); | $this->Application->HandleEvent(new kEvent($this->getPrefixSpecial() . ':LoadItem', $params)); | ||||
} | } | ||||
return $object; | return $object; | ||||
} | } | ||||
Show All 39 Lines | |||||
* Returns import/export process percent | * Returns import/export process percent | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @return int | * @return int | ||||
* @deprecated Please convert to event-model, not tag based | * @deprecated Please convert to event-model, not tag based | ||||
*/ | */ | ||||
function ExportStatus($params) | function ExportStatus($params) | ||||
{ | { | ||||
/** @var kCatDBItemExportHelper $export_object */ | |||||
$export_object = $this->Application->recallObject('CatItemExportHelper'); | $export_object = $this->Application->recallObject('CatItemExportHelper'); | ||||
/* @var $export_object kCatDBItemExportHelper */ | |||||
$event = new kEvent($this->getPrefixSpecial().':OnDummy'); | $event = new kEvent($this->getPrefixSpecial().':OnDummy'); | ||||
$action_method = 'perform'.ucfirst($this->Special); | $action_method = 'perform'.ucfirst($this->Special); | ||||
$field_values = $export_object->$action_method($event); | $field_values = $export_object->$action_method($event); | ||||
// finish code is done from JS now | // finish code is done from JS now | ||||
if ($field_values['start_from'] >= $field_values['total_records']) | if ($field_values['start_from'] >= $field_values['total_records']) | ||||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Line(s) | |||||
return $value; | return $value; | ||||
} | } | ||||
function FCKEditor($params) | function FCKEditor($params) | ||||
{ | { | ||||
$editor_name = array_key_exists('name', $params) ? $params['name'] : $this->InputName($params); | $editor_name = array_key_exists('name', $params) ? $params['name'] : $this->InputName($params); | ||||
/** @var fckFCKHelper $fck_helper */ | |||||
$fck_helper = $this->Application->recallObject('FCKHelper'); | $fck_helper = $this->Application->recallObject('FCKHelper'); | ||||
/* @var $fck_helper fckFCKHelper */ | |||||
if ( isset($params['mode']) && $params['mode'] == 'inline' ) { | if ( isset($params['mode']) && $params['mode'] == 'inline' ) { | ||||
return $fck_helper->CKEditorInlineTag($editor_name, $params); | return $fck_helper->CKEditorInlineTag($editor_name, $params); | ||||
} | } | ||||
return $fck_helper->CKEditorTag($editor_name, $this->CKEditorValue($params), $params); | return $fck_helper->CKEditorTag($editor_name, $this->CKEditorValue($params), $params); | ||||
} | } | ||||
Show All 22 Lines | |||||
* Creates link to an item including only it's id | * Creates link to an item including only it's id | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @return string | * @return string | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function ItemLink($params) | protected function ItemLink($params) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
if ( !isset($params['pass']) ) { | if ( !isset($params['pass']) ) { | ||||
$params['pass'] = 'm'; | $params['pass'] = 'm'; | ||||
} | } | ||||
$params[ $object->getPrefixSpecial() . '_id' ] = $object->GetID(); | $params[ $object->getPrefixSpecial() . '_id' ] = $object->GetID(); | ||||
return $this->Application->ProcessParsedTag('m', 'T', $params); | return $this->Application->ProcessParsedTag('m', 'T', $params); | ||||
} | } | ||||
/** | /** | ||||
* Creates a button for editing item in Admin Console | * Creates a button for editing item in Admin Console | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @return string | * @return string | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function AdminEditButton($params) | protected function AdminEditButton($params) | ||||
{ | { | ||||
if ( EDITING_MODE != EDITING_MODE_CONTENT ) { | if ( EDITING_MODE != EDITING_MODE_CONTENT ) { | ||||
return ''; | return ''; | ||||
} | } | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
$item_prefix = isset($params['item_prefix']) ? $params['item_prefix'] : $this->Prefix; | $item_prefix = isset($params['item_prefix']) ? $params['item_prefix'] : $this->Prefix; | ||||
if ( isset($params['template']) ) { | if ( isset($params['template']) ) { | ||||
$template = $params['template']; | $template = $params['template']; | ||||
} | } | ||||
else { | else { | ||||
$admin_template_prefix = $this->Application->getUnitOption($item_prefix, 'AdminTemplatePrefix'); | $admin_template_prefix = $this->Application->getUnitOption($item_prefix, 'AdminTemplatePrefix'); | ||||
▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Line(s) | |||||
$prefix = $this->getPrefixSpecial(); | $prefix = $this->getPrefixSpecial(); | ||||
if ( !$this->Application->GetVar($prefix . '_event') ) { | if ( !$this->Application->GetVar($prefix . '_event') ) { | ||||
$this->Application->HandleEvent(new kEvent($prefix . ':OnNew')); | $this->Application->HandleEvent(new kEvent($prefix . ':OnNew')); | ||||
} | } | ||||
} | } | ||||
function PrintSerializedFields($params) | function PrintSerializedFields($params) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
$field = $this->SelectParam($params, 'field'); | $field = $this->SelectParam($params, 'field'); | ||||
$data = unserialize($object->GetDBField($field)); | $data = unserialize($object->GetDBField($field)); | ||||
$o = ''; | $o = ''; | ||||
$std_params['name'] = $params['render_as']; | $std_params['name'] = $params['render_as']; | ||||
$std_params['field'] = $params['field']; | $std_params['field'] = $params['field']; | ||||
$std_params['pass_params'] = true; | $std_params['pass_params'] = true; | ||||
▲ Show 20 Lines • Show All 176 Lines • ▼ Show 20 Line(s) | |||||
/** | /** | ||||
* Checks, that "To" part of at least one of range filters is used | * Checks, that "To" part of at least one of range filters is used | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @return bool | * @return bool | ||||
*/ | */ | ||||
function RangeFiltersUsed($params) | function RangeFiltersUsed($params) | ||||
{ | { | ||||
/** @var kSearchHelper $search_helper */ | |||||
$search_helper = $this->Application->recallObject('SearchHelper'); | $search_helper = $this->Application->recallObject('SearchHelper'); | ||||
/* @var $search_helper kSearchHelper */ | |||||
return $search_helper->rangeFiltersUsed($this->getPrefixSpecial(), $params['grid']); | return $search_helper->rangeFiltersUsed($this->getPrefixSpecial(), $params['grid']); | ||||
} | } | ||||
/** | /** | ||||
* This is abstract tag, used to modify unit config data based on template, where it's used. | * This is abstract tag, used to modify unit config data based on template, where it's used. | ||||
* Tag is called from "combined_header" block in admin only. | * Tag is called from "combined_header" block in admin only. | ||||
* | * | ||||
▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Line(s) | |||||
* Displays option name by it's value | * Displays option name by it's value | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @return string | * @return string | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OptionValue($params) | protected function OptionValue($params) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
$value = $params['value']; | $value = $params['value']; | ||||
$field = $this->SelectParam($params, 'name,field'); | $field = $this->SelectParam($params, 'name,field'); | ||||
$field_options = $object->GetFieldOptions($field); | $field_options = $object->GetFieldOptions($field); | ||||
if ( isset($field_options['options'][$value]) ) { | if ( isset($field_options['options'][$value]) ) { | ||||
$value = $field_options['options'][$value]; | $value = $field_options['options'][$value]; | ||||
Show All 14 Lines | |||||
function FormName($params) | function FormName($params) | ||||
{ | { | ||||
$form_name = $this->SelectParam($params, 'name,form,form_name'); | $form_name = $this->SelectParam($params, 'name,form,form_name'); | ||||
if ( $form_name ) { | if ( $form_name ) { | ||||
$prefix = $this->getPrefixSpecial(); | $prefix = $this->getPrefixSpecial(); | ||||
if ( $this->Application->hasObject( $this->getPrefixSpecial() ) ) { | if ( $this->Application->hasObject( $this->getPrefixSpecial() ) ) { | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
if ( $object->getFormName() != $form_name ) { | if ( $object->getFormName() != $form_name ) { | ||||
trigger_error('Setting form to "<strong>' . $form_name . '</strong>" failed, since object "<strong>' . $this->getPrefixSpecial() . '</strong>" is created before FormName tag (e.g. in event or another tag).', E_USER_WARNING); | trigger_error('Setting form to "<strong>' . $form_name . '</strong>" failed, since object "<strong>' . $this->getPrefixSpecial() . '</strong>" is created before FormName tag (e.g. in event or another tag).', E_USER_WARNING); | ||||
} | } | ||||
} | } | ||||
else { | else { | ||||
$forms = $this->Application->GetVar('forms', Array ()); | $forms = $this->Application->GetVar('forms', Array ()); | ||||
$forms[ $this->getPrefixSpecial() ] = $form_name; | $forms[ $this->getPrefixSpecial() ] = $form_name; | ||||
$this->Application->SetVar('forms', $forms); | $this->Application->SetVar('forms', $forms); | ||||
} | } | ||||
return ''; | return ''; | ||||
} | } | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
return $object->getFormName(); | return $object->getFormName(); | ||||
} | } | ||||
/** | /** | ||||
* Just reloads the object using given parameters | * Just reloads the object using given parameters | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @return string | * @return string | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function ReloadItem($params) | protected function ReloadItem($params) | ||||
{ | { | ||||
$params['requery'] = 1; | $params['requery'] = 1; | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
return ''; | return ''; | ||||
} | } | ||||
} | } |