Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/units/statistics/statistics_tag_processor.php
Show All 38 Lines | |||||
$values = $this->Conn->GetCol($this->CurrentSQL); | $values = $this->Conn->GetCol($this->CurrentSQL); | ||||
if (!$values) return ''; | if (!$values) return ''; | ||||
if (!$this->PostFormatting) return array_shift($values); | if (!$this->PostFormatting) return array_shift($values); | ||||
switch ($this->PostFormatting) { | switch ($this->PostFormatting) { | ||||
case 'number': | case 'number': | ||||
// simple-specific postformatting | // simple-specific postformatting | ||||
/** @var LanguagesItem $lang */ | |||||
$lang = $this->Application->recallObject('lang.current'); | $lang = $this->Application->recallObject('lang.current'); | ||||
/* @var $lang LanguagesItem */ | |||||
$value = $lang->formatNumber($value, $this->PostFormattingParams['precision']); | $value = $lang->formatNumber($value, $this->PostFormattingParams['precision']); | ||||
break; | break; | ||||
case 'COUNT': | case 'COUNT': | ||||
// extended postformatting | // extended postformatting | ||||
$value = count($values); | $value = count($values); | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | |||||
function ProcessStatisticTag($tag) | function ProcessStatisticTag($tag) | ||||
{ | { | ||||
$tag = trim($tag); | $tag = trim($tag); | ||||
if (isset($this->TagCache[$tag])) { | if (isset($this->TagCache[$tag])) { | ||||
return $this->TagCache[$tag]; | return $this->TagCache[$tag]; | ||||
} | } | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject(); | $object = $this->getObject(); | ||||
/* @var $object kDBItem */ | |||||
list($tag_name, $tag_params) = explode(' ', $tag, 2); // 1st - function, 2nd .. nth - params | list($tag_name, $tag_params) = explode(' ', $tag, 2); // 1st - function, 2nd .. nth - params | ||||
preg_match_all('/([\${}a-zA-Z0-9_.-]+)=(["\']{1,1})(.*?)(?<!\\\)\\2/s', $tag_params, $rets, PREG_SET_ORDER); | preg_match_all('/([\${}a-zA-Z0-9_.-]+)=(["\']{1,1})(.*?)(?<!\\\)\\2/s', $tag_params, $rets, PREG_SET_ORDER); | ||||
$tag_params = Array(); | $tag_params = Array(); | ||||
foreach ($rets AS $key => $val){ | foreach ($rets AS $key => $val){ | ||||
$tag_params[$val[1]] = str_replace(Array('\\' . $val[2], '+'), Array($val[2], ' '), $val[3]); | $tag_params[$val[1]] = str_replace(Array('\\' . $val[2], '+'), Array($val[2], ' '), $val[3]); | ||||
} | } | ||||
switch ($tag_name) { | switch ($tag_name) { | ||||
case 'm:config': | case 'm:config': | ||||
// m:config name="<variable_name>" | // m:config name="<variable_name>" | ||||
return $this->Application->ConfigValue($tag_params['name']); | return $this->Application->ConfigValue($tag_params['name']); | ||||
break; | break; | ||||
case 'm:post_format': | case 'm:post_format': | ||||
// m:post_format field="<field_name>" type="<formatting_type>" precision="2" | // m:post_format field="<field_name>" type="<formatting_type>" precision="2" | ||||
/** @var LanguagesItem $lang */ | |||||
$lang = $this->Application->recallObject('lang.current'); | $lang = $this->Application->recallObject('lang.current'); | ||||
/* @var $lang LanguagesItem */ | |||||
switch ($tag_params['type']) { | switch ($tag_params['type']) { | ||||
case 'date': | case 'date': | ||||
$this->PostFormatting = $lang->GetDBField('DateFormat'); | $this->PostFormatting = $lang->GetDBField('DateFormat'); | ||||
break; | break; | ||||
case 'time': | case 'time': | ||||
$this->PostFormatting = $lang->GetDBField('TimeFormat'); | $this->PostFormatting = $lang->GetDBField('TimeFormat'); | ||||
▲ Show 20 Lines • Show All 115 Lines • ▼ Show 20 Line(s) | |||||
/** | /** | ||||
* Get prefixes, that are allowed to have pending items (check module licenses too) | * Get prefixes, that are allowed to have pending items (check module licenses too) | ||||
* | * | ||||
* @return Array | * @return Array | ||||
*/ | */ | ||||
function getPendingPrefixes() | function getPendingPrefixes() | ||||
{ | { | ||||
/** @var kModulesHelper $modules_helper */ | |||||
$modules_helper = $this->Application->recallObject('ModulesHelper'); | $modules_helper = $this->Application->recallObject('ModulesHelper'); | ||||
/* @var $modules_helper kModulesHelper */ | |||||
$licensed_modules = array_map('strtolower', $modules_helper->_GetModules()); | $licensed_modules = array_map('strtolower', $modules_helper->_GetModules()); | ||||
$sql = 'SELECT LOWER(Module), Prefix | $sql = 'SELECT LOWER(Module), Prefix | ||||
FROM '.TABLE_PREFIX.'ItemTypes it | FROM '.TABLE_PREFIX.'ItemTypes it | ||||
LEFT JOIN '.TABLE_PREFIX.'Modules m ON m.Name = it.Module | LEFT JOIN '.TABLE_PREFIX.'Modules m ON m.Name = it.Module | ||||
WHERE (m.Loaded = 1) AND (LENGTH(it.ClassName) > 0)'; | WHERE (m.Loaded = 1) AND (LENGTH(it.ClassName) > 0)'; | ||||
$prefixes = $this->Conn->GetCol($sql, 'Prefix'); | $prefixes = $this->Conn->GetCol($sql, 'Prefix'); | ||||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Line(s) | |||||
if (($i+1) % $columns == 0) { | if (($i+1) % $columns == 0) { | ||||
$ret .= '</tr>'; | $ret .= '</tr>'; | ||||
} | } | ||||
} | } | ||||
return $ret; | return $ret; | ||||
} | } | ||||
} | } | ||||
No newline at end of file | No newline at end of file |