Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/kernel/db/dblist.php
Show First 20 Lines • Show All 665 Lines • ▼ Show 20 Line(s) | |||||
* @access public | * @access public | ||||
*/ | */ | ||||
function GetFormattedTotal($field, $total_function) | function GetFormattedTotal($field, $total_function) | ||||
{ | { | ||||
$res = $this->getTotal($field, $total_function); | $res = $this->getTotal($field, $total_function); | ||||
$formatter_class = $this->GetFieldOption($field, 'formatter'); | $formatter_class = $this->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 */ | |||||
$res = $formatter->Format($res, $field, $this); | $res = $formatter->Format($res, $field, $this); | ||||
} | } | ||||
return $res; | return $res; | ||||
} | } | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | |||||
* | * | ||||
* @param bool $for_counting merge where filters with having filters + replace field names for having fields with their values | * @param bool $for_counting merge where filters with having filters + replace field names for having fields with their values | ||||
* @param bool $system_filters_only | * @param bool $system_filters_only | ||||
* @return string | * @return string | ||||
* @access private | * @access private | ||||
*/ | */ | ||||
private function GetWhereClause($for_counting=false,$system_filters_only=false) | private function GetWhereClause($for_counting=false,$system_filters_only=false) | ||||
{ | { | ||||
/** @var kMultipleFilter $where */ | |||||
$where = $this->Application->makeClass('kMultipleFilter'); | $where = $this->Application->makeClass('kMultipleFilter'); | ||||
/* @var $where kMultipleFilter */ | |||||
$where->addFilter( | $where->addFilter( | ||||
'system_where', | 'system_where', | ||||
$this->extractCalculatedFields($this->WhereFilter[self::FLT_SYSTEM]->getSQL()) | $this->extractCalculatedFields($this->WhereFilter[self::FLT_SYSTEM]->getSQL()) | ||||
); | ); | ||||
if (!$system_filters_only) { | if (!$system_filters_only) { | ||||
$where->addFilter('view_where', $this->WhereFilter[self::FLT_VIEW] ); | $where->addFilter('view_where', $this->WhereFilter[self::FLT_VIEW] ); | ||||
Show All 32 Lines | |||||
* @param bool $system_filters_only return only system having filters | * @param bool $system_filters_only return only system having filters | ||||
* @param int $aggregated 0 - aggregated and having, 1 - having only, 2 - aggregated only | * @param int $aggregated 0 - aggregated and having, 1 - having only, 2 - aggregated only | ||||
* @return string | * @return string | ||||
* @access private | * @access private | ||||
*/ | */ | ||||
private function GetHavingClause($for_counting=false, $system_filters_only=false, $aggregated = 0) | private function GetHavingClause($for_counting=false, $system_filters_only=false, $aggregated = 0) | ||||
{ | { | ||||
if ($for_counting) { | if ($for_counting) { | ||||
/** @var kMultipleFilter $aggregate_filter */ | |||||
$aggregate_filter = $this->Application->makeClass('kMultipleFilter'); | $aggregate_filter = $this->Application->makeClass('kMultipleFilter'); | ||||
/* @var $aggregate_filter kMultipleFilter */ | |||||
$aggregate_filter->addFilter('aggregate_system', $this->AggregateFilter[kDBList::FLT_SYSTEM]); | $aggregate_filter->addFilter('aggregate_system', $this->AggregateFilter[kDBList::FLT_SYSTEM]); | ||||
if (!$system_filters_only) { | if (!$system_filters_only) { | ||||
$aggregate_filter->addFilter('aggregate_view', $this->AggregateFilter[kDBList::FLT_VIEW]); | $aggregate_filter->addFilter('aggregate_view', $this->AggregateFilter[kDBList::FLT_VIEW]); | ||||
} | } | ||||
return $this->extractCalculatedFields($aggregate_filter->getSQL(), 2); | return $this->extractCalculatedFields($aggregate_filter->getSQL(), 2); | ||||
} | } | ||||
/** @var kMultipleFilter $having */ | |||||
$having = $this->Application->makeClass('kMultipleFilter'); | $having = $this->Application->makeClass('kMultipleFilter'); | ||||
/* @var $having kMultipleFilter */ | |||||
$having->addFilter('system_having', $this->HavingFilter[kDBList::FLT_SYSTEM] ); | $having->addFilter('system_having', $this->HavingFilter[kDBList::FLT_SYSTEM] ); | ||||
if ($aggregated == 0) { | if ($aggregated == 0) { | ||||
if (!$system_filters_only) { | if (!$system_filters_only) { | ||||
$having->addFilter('view_aggregated', $this->AggregateFilter[kDBList::FLT_VIEW] ); | $having->addFilter('view_aggregated', $this->AggregateFilter[kDBList::FLT_VIEW] ); | ||||
} | } | ||||
$having->addFilter('system_aggregated', $this->AggregateFilter[kDBList::FLT_SYSTEM]); | $having->addFilter('system_aggregated', $this->AggregateFilter[kDBList::FLT_SYSTEM]); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 491 Lines • ▼ Show 20 Line(s) | |||||
if (is_array($parent_table_key)) $parent_table_key = getArrayValue($parent_table_key, $parent_prefix); | if (is_array($parent_table_key)) $parent_table_key = getArrayValue($parent_table_key, $parent_prefix); | ||||
$foreign_key_field = $this->Application->getUnitOption($this->Prefix, 'ForeignKey'); | $foreign_key_field = $this->Application->getUnitOption($this->Prefix, 'ForeignKey'); | ||||
if (is_array($foreign_key_field)) $foreign_key_field = getArrayValue($foreign_key_field, $parent_prefix); | if (is_array($foreign_key_field)) $foreign_key_field = getArrayValue($foreign_key_field, $parent_prefix); | ||||
if (!$parent_table_key || !$foreign_key_field) { | if (!$parent_table_key || !$foreign_key_field) { | ||||
return ; | return ; | ||||
} | } | ||||
/** @var kDBItem $parent_object */ | |||||
$parent_object = $this->Application->recallObject($parent_prefix.'.'.$special); | $parent_object = $this->Application->recallObject($parent_prefix.'.'.$special); | ||||
/* @var $parent_object kDBItem */ | |||||
if (!$parent_object->isLoaded()) { | if (!$parent_object->isLoaded()) { | ||||
$this->addFilter('parent_filter', 'FALSE'); | $this->addFilter('parent_filter', 'FALSE'); | ||||
trigger_error('Parent ID not found (prefix: "<strong>' . rtrim($parent_prefix.'.'.$special, '.') . '</strong>"; sub-prefix: "<strong>' . $this->getPrefixSpecial() . '</strong>")', E_USER_NOTICE); | trigger_error('Parent ID not found (prefix: "<strong>' . rtrim($parent_prefix.'.'.$special, '.') . '</strong>"; sub-prefix: "<strong>' . $this->getPrefixSpecial() . '</strong>")', E_USER_NOTICE); | ||||
return ; | return ; | ||||
} | } | ||||
// only for list in this case | // only for list in this case | ||||
Show All 24 Lines | |||||
* @access public | * @access public | ||||
*/ | */ | ||||
public function GetCol($field, $formatted = false, $format = null) | public function GetCol($field, $formatted = false, $format = null) | ||||
{ | { | ||||
$i = 0; | $i = 0; | ||||
$ret = Array (); | $ret = Array (); | ||||
if ($formatted && array_key_exists('formatter', $this->Fields[$field])) { | if ($formatted && array_key_exists('formatter', $this->Fields[$field])) { | ||||
/** @var kFormatter $formatter */ | |||||
$formatter = $this->Application->recallObject($this->Fields[$field]['formatter']); | $formatter = $this->Application->recallObject($this->Fields[$field]['formatter']); | ||||
/* @var $formatter kFormatter */ | |||||
while ($i < $this->SelectedCount) { | while ($i < $this->SelectedCount) { | ||||
$ret[] = $formatter->Format($this->Records[$i][$field], $field, $this, $format); | $ret[] = $formatter->Format($this->Records[$i][$field], $field, $this, $format); | ||||
$i++; | $i++; | ||||
} | } | ||||
} | } | ||||
else { | else { | ||||
while ($i < $this->SelectedCount) { | while ($i < $this->SelectedCount) { | ||||
▲ Show 20 Lines • Show All 398 Lines • Show Last 20 Lines |