Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Mon, Sep 29, 1:12 AM

in-portal

Index: trunk/kernel/units/statistics/statistics_tag_processor.php
===================================================================
--- trunk/kernel/units/statistics/statistics_tag_processor.php (revision 4764)
+++ trunk/kernel/units/statistics/statistics_tag_processor.php (revision 4765)
@@ -1,285 +1,287 @@
<?php
class StatisticsTagProcessor extends kDBTagProcessor {
var $TagCache = Array(); // parsed tag (in sql queries only) values are cached
var $CurrentSQL = ''; // sql query being currently processed
var $PostFormatting = false; // apply formatting to sql query results
var $PostFormattingParams = Array(); // post formatting params if any
function CalculateValue($params)
{
$object =& $this->getObject($params);
$this->CurrentSQL = $object->GetDBField($params['field']);
// 1. replace prefix to actual one
$this->CurrentSQL = str_replace("<%prefix%>", TABLE_PREFIX, $this->CurrentSQL);
// 2. replace all pseudo-tags found in sql with their values
while ( ($tag = $this->FindTag()) != false ) {
$this->CurrentSQL = str_replace('<%'.$tag.'%>', $this->ProcessStatisticTag($tag), $this->CurrentSQL);
}
// 3. query sql and process gathered data
$values = $this->Conn->GetCol($this->CurrentSQL);
if (!$values) return '';
if (!$this->PostFormatting) return array_shift($values);
switch ($this->PostFormatting) {
case 'number':
// simple-specific postformatting
$lang =& $this->Application->recallObject('lang.current');
$value = $lang->formatNumber($value, $this->PostFormattingParams['precision']);
break;
case 'COUNT':
// extended postformatting
$value = count($values);
break;
case 'SUM':
$value = 0;
foreach ($values as $cur_value) {
$value += $cur_value;
}
if ($this->PostFormattingParams['format_as'] == 'file') {
$value = size($value);
}
break;
// other type of information (not from db)
case 'SysFileSize':
$value = size( dir_size(FULL_PATH.'/') );
break;
default: // simple-default postformatting
$value = adodb_date($this->PostFormatting, array_shift($values));
break;
}
$this->PostFormatting = false;
$this->PostFormattingParams = Array();
return $value;
}
function FindTag()
{
// finds tag in current sql & returns it if found, false otherwise
$tagOpen = '<%'; $tagClose = '%>'; $tagOpenLen = strlen($tagOpen);
$startPos = strpos($this->CurrentSQL, $tagOpen);
if( $startPos !== false )
{
$endPos = strpos($this->CurrentSQL, $tagClose, $startPos);
return ($endPos > $startPos) ? substr($this->CurrentSQL, $startPos + $tagOpenLen, $endPos - $startPos - $tagOpenLen) : false;
}
return false;
}
function ProcessStatisticTag($tag)
{
$tag = trim($tag);
if (isset($this->TagCache[$tag])) {
return $this->TagCache[$tag];
}
$object =& $this->getObject();
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);
$tag_params = Array();
foreach ($rets AS $key => $val){
$tag_params[$val[1]] = str_replace(Array('\\' . $val[2], '+'), Array($val[2], ' '), $val[3]);
}
switch ($tag_name) {
case 'm:config':
// m:config name="<variable_name>"
return $this->Application->ConfigValue($tag_params['name']);
break;
case 'm:post_format':
// m:post_format field="<field_name>" type="<formatting_type>" precision="2"
$lang =& $this->Application->recallObject('lang.current');
switch ($tag_params['type']) {
case 'date':
$this->PostFormatting = $lang->GetDBField('DateFormat');
break;
case 'time':
$this->PostFormatting = $lang->GetDBField('TimeFormat');
break;
case 'currency':
$this->PostFormatting = 'number';
$this->PostFormattingParams['precision'] = $tag_params['precision'];
break;
}
return $tag_params['field'];
break;
case 'm:custom_action':
// m:custom_action sql="empty" action="SysFileSize"
$this->PostFormatting = $tag_params['action'];
return ($tag_params['sql'] == 'empty') ? 'SELECT 1' : $tag_params['sql'];
break;
case 'modules:get_current':
return $object->GetDBField('Module');
break;
case 'm:sql_action':
//m:sql_action sql="SHOW TABLES" action="COUNT" field="*"
$this->PostFormatting = $tag_params['action'];
$this->PostFormattingParams = $tag_params;
return $tag_params['sql'];
break;
case 'link:hit_count':
if ($tag_params['type'] == 'top') {// by now only top is supported
$top_links_count = $this->Application->ConfigValue('Link_TopCount');
$sql = 'SELECT Hits
FROM '.TABLE_PREFIX.'Link
ORDER BY Hits DESC LIMIT 0, '.$top_links_count;
return $this->getLastRecord($sql, 'Hits');
}
break;
case 'article:hit_count':
if ($tag_params['type'] == 'top') {// by now only top is supported
$top_articles_count = $this->Application->ConfigValue('News_VotesToHot');
$min_votes = $this->Application->ConfigValue('News_MinVotes');
$sql = 'SELECT CachedRating
FROM '.TABLE_PREFIX.'News
WHERE CachedVotesQty > '.$min_votes.'
ORDER BY CachedRating DESC LIMIT 0, '.$top_articles_count;
return $this->getLastRecord($sql, 'CachedRating');
}
break;
case 'topic:hit_count':
if ($tag_params['type'] == 'top') {// by now only top is supported
$top_posts_count = $this->Application->ConfigValue('Topic_PostsToPop');
$sql = 'SELECT Views
FROM '.TABLE_PREFIX.'Topic
ORDER BY Views DESC LIMIT 0, '.$top_posts_count;
return $this->getLastRecord($sql, 'Views');
}
break;
}
}
function getLastRecord($sql, $field)
{
$records = $this->Conn->GetCol($sql);
return count($records) ? array_pop($records) : 0;
}
/**
* Allows to get pending item count for prefix
*
* @param Array $params
* @return int
*/
function CountPending($params)
{
$prefix = $params['prefix'];
$value = $this->Application->getCache('statistics.pending', $prefix);
if ($value === false) {
$statistics_info = $this->Application->getUnitOption($prefix.'.pending', 'StatisticsInfo');
if (!$statistics_info) {
return 0;
}
$table = $this->Application->getUnitOption($prefix, 'TableName');
$status_field = array_shift( $this->Application->getUnitOption($prefix, 'StatusField') );
$sql = 'SELECT COUNT(*)
FROM '.$table.'
WHERE '.$status_field.' = '.$statistics_info['status'];
$value = $this->Conn->GetOne($sql);
$this->Application->setCache('statistics.pending', $prefix, $value);
}
return $value;
}
function GetTotalPending()
{
$sql = 'SELECT Prefix
- FROM '.TABLE_PREFIX.'ItemTypes';
+ FROM '.TABLE_PREFIX.'ItemTypes
+ WHERE LENGTH(ClassName) > 0';
$prefixes = $this->Conn->GetCol($sql);
$sum = 0;
foreach ($prefixes as $prefix) {
$sum += $this->CountPending( Array('prefix' => $prefix) );
}
return $sum;
}
function PrintPendingStatistics($params)
{
$sql = 'SELECT Prefix
- FROM '.TABLE_PREFIX.'ItemTypes';
+ FROM '.TABLE_PREFIX.'ItemTypes
+ WHERE LENGTH(ClassName) > 0';
$check_prefixes = $this->Conn->GetCol($sql);
if (!$check_prefixes) {
return '';
}
$ret = '';
$columns = $params['columns'];
$block_params = $this->prepareTagParams( Array('name' => $this->SelectParam($params, 'render_as,block') ) );
$prefixes = Array();
foreach ($check_prefixes as $prefix) {
$statistics_info = $this->Application->getUnitOption($prefix.'.pending', 'StatisticsInfo');
if ($statistics_info) {
$prefixes[] = $prefix;
}
}
$row_number = 0;
foreach ($prefixes as $i => $prefix) {
$block_params['prefix'] = $prefix;
$statistics_info = $this->Application->getUnitOption($prefix.'.pending', 'StatisticsInfo');
if ($i % $columns == 0) {
$column_number = 1;
$ret .= '<tr>';
}
$block_params['column_number'] = $column_number;
$block_params['is_first'] = $i < $columns ? 1 : 0;
$template = $statistics_info['url']['t'];
unset($statistics_info['url']['t']);
$url = $this->Application->HREF($template, '', $statistics_info['url']);
if ($statistics_info['js_url'] != '#url#') {
$statistics_info['js_url'] = 'javascript:'.$statistics_info['js_url'];
}
$block_params['url'] = str_replace('#url#', $url, $statistics_info['js_url']);
$block_params['icon'] = $statistics_info['icon'];
$block_params['label'] = $statistics_info['label'];
$ret .= $this->Application->ParseBlock($block_params);
$column_number++;
if (($i+1) % $columns == 0) {
$ret .= '</tr>';
}
}
return $ret;
}
}
?>
\ No newline at end of file
Property changes on: trunk/kernel/units/statistics/statistics_tag_processor.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.2
\ No newline at end of property
+1.3
\ No newline at end of property
Index: trunk/core/kernel/event_manager.php
===================================================================
--- trunk/core/kernel/event_manager.php (revision 4764)
+++ trunk/core/kernel/event_manager.php (revision 4765)
@@ -1,487 +1,487 @@
<?php
define('hBEFORE', 1);
define('hAFTER', 2);
define('reBEFORE', 1);
define('reAFTER', 2);
class kEventManager extends kBase {
/**
* Connection to database
*
* @var kDBConnection
* @access public
*/
var $Conn;
/**
* Cache of QueryString parameters
* from config, that are represented
* in enviroment variable
*
* @var Array
*/
var $queryMaps = Array();
/**
* Build events registred for
* pseudo classes. key - pseudo class
* value - event name
*
* @var Array
* @access private
*/
var $buildEvents=Array();
/**
* Events, that should be run before parser initialization
*
* @var Array
*/
var $beforeRegularEvents = Array();
/**
* Events, that should be run after parser initialization
*
* @var Array
*/
var $afterRegularEvents = Array();
/**
* Holds before hooks
* key - prefix.event (to link to)
* value - hooked event info
*
* @var Array
* @access private
*/
var $beforeHooks=Array();
/**
* Holds after hooks
* key - prefix.event (to link to)
* value - hooked event info
*
* @var Array
* @access private
*/
var $afterHooks = Array();
var $recursionStack = Array();
function kEventManager()
{
parent::kBase();
$this->Conn =& $this->Application->GetADODBConnection();
}
/**
* Set's new enviroment parameter mappings
* between their names as application vars
*
* @param Array $new_query_maps
* @access public
*/
/*function setQueryMaps($new_query_maps)
{
$this->queryMaps = $new_query_maps;
}*/
/**
* Adds new query map to already parsed query maps
*
* @param string $prefix
*/
function setQueryMap($prefix_special)
{
list($prefix) = explode('.', $prefix_special);
$query_map = $this->Application->getUnitOption($prefix, 'QueryString');
if ($query_map) {
$this->queryMaps[$prefix_special] = $query_map;
}
else {
unset($this->queryMaps[$prefix]);
}
// 'passed' is set later in ProcessRequest - do we really need it here? (it breakes HTTPQuery initialization...)
// $this->Application->SetVar('passed', implode(',', array_keys($this->queryMaps)) );
return $query_map;
}
/**
* Registers new regular event
*
* @param string $short_name name to be used to store last maintenace run info
* @param string $event_name
* @param int $run_interval run interval in seconds
* @param int $type before or after regular event
*/
function registerRegularEvent($short_name, $event_name, $run_interval, $type = reBEFORE)
{
if($type == reBEFORE)
{
$this->beforeRegularEvents[$short_name] = Array('EventName' => $event_name, 'RunInterval' => $run_interval);
}
else
{
$this->afterRegularEvents[$short_name] = Array('EventName' => $event_name, 'RunInterval' => $run_interval);
}
}
function registerBuildEvent($pseudo_class,$build_event_name)
{
$this->buildEvents[$pseudo_class]=$build_event_name;
}
/**
* Returns build event by pseudo class
* name if any defined in config
*
* @param string $pseudo_class
* @return kEvent
* @access public
*/
function &getBuildEvent($pseudo_class)
{
$false = false;
if( !isset($this->buildEvents[$pseudo_class]) ) return $false;
$event = new kEvent();
$event->Name=$this->buildEvents[$pseudo_class];
$event->MasterEvent=null;
return $event;
}
/**
* Check if event is called twice, that causes recursion
*
* @param kEvent $event
*/
function isRecursion(&$event)
{
$event_key = $event->getPrefixSpecial().':'.$event->Name;
return in_array($event_key, $this->recursionStack) ? true : false;
}
function pushEvent(&$event)
{
$event_key = $event->getPrefixSpecial().':'.$event->Name;
array_push($this->recursionStack, $event_key);
}
function popEvent()
{
array_pop($this->recursionStack);
}
/**
* Allows to process any type of event
*
* @param kEvent $event
* @access public
*/
function HandleEvent(&$event)
{
if ($this->isRecursion($event)) {
return true;
}
$this->pushEvent($event);
if( !$this->Application->prefixRegistred($event->Prefix) )
{
$unit_config_reader =& $this->Application->recallObject('kUnitConfigReader');
$unit_config_reader->loadConfig($event->Prefix);
}
if( !$this->Application->prefixRegistred($event->Prefix) )
{
trigger_error('Prefix <b>'.$event->Prefix.'</b> not registred (requested event <b>'.$event->Name.'</b>)', E_USER_NOTICE);
return false;
}
if (!$event->SkipBeforeHooks) {
$this->processHooks($event, hBEFORE);
if ($event->status == erFATAL) return true;
}
-
+
$event_handler =& $this->Application->recallObject($event->Prefix.'_EventHandler');
$event_handler->processEvent($event);
if ($event->status == erFATAL) return true;
if (!$event->SkipAfterHooks) {
$this->processHooks($event, hAFTER);
}
$this->popEvent();
return true;
}
function ProcessRequest()
{
$this->processOpener();
// 1. get events from $_POST
$events = $this->Application->GetVar('events');
if ($events === false) $events = Array();
// 2. if nothing there, then try to find them in $_GET
if ($this->queryMaps && !$events) {
// if we got $_GET type submit (links, not javascript)
foreach ($this->queryMaps as $prefix_special => $query_map) {
$query_map = array_flip($query_map);
if (isset($query_map['event'])) {
$event_name = $this->Application->GetVar($prefix_special.'_event');
if ($event_name) {
$events[$prefix_special] = $event_name;
}
}
}
$actions = $this->Application->GetVar('do');
if ($actions) {
list($prefix, $event_name) = explode('_', $actions);
$events[$prefix] = $event_name;
}
}
$passed = explode(',', $this->Application->GetVar('passed'));
foreach($events as $prefix_special => $event_name)
{
if(!$event_name) continue;
if( is_array($event_name) )
{
$event_name = key($event_name);
$events[$prefix_special] = $event_name;
$this->Application->SetVar($prefix_special.'_event', $event_name);
}
$event = new kEvent();
$event->Name=$event_name;
$event->Prefix_Special=$prefix_special;
$prefix_special=explode('.',$prefix_special);
$event->Prefix=$prefix_special[0];
array_push($passed, $prefix_special[0]);
$event->Special=isset($prefix_special[1])?$prefix_special[1]:'';
$event->redirect_params = Array('opener'=>'s', 'pass'=>'all');
$event->redirect = true;
$event_handler =& $this->Application->recallObject($event->Prefix.'_EventHandler');
$event->setEventParam('top_prefix', $this->Application->GetTopmostPrefix($event->Prefix));
if (($this->Application->GetVar('u_id') == -1) || $event_handler->CheckPermission($event)) {
$this->HandleEvent($event);
}
if ($event->status == erPERM_FAIL) {
$event->redirect = $this->Application->IsAdmin() ? 'no_permission' : $this->Application->ConfigValue('NoPermissionTemplate');
// restore stuff, that processOpener() changed
$this->Application->RestoreVar('opener_stack');
// don't save last_template, because no_permission template does js history.back and could cause invalid opener_stack content
$this->Application->SetVar('skip_last_template', 1);
}
// should do redirect but to no_permissions template
if ( ($event->status == erSUCCESS || $event->status == erPERM_FAIL) && ($event->redirect === true || strlen($event->redirect) > 0)) {
$this->Application->Redirect($event->redirect, $event->redirect_params, null, $event->redirect_script);
}
}
$this->Application->SetVar('events', $events);
$this->Application->SetVar('passed', implode(',', $passed));
}
function processOpener()
{
$opener_action = $this->Application->GetVar('m_opener');
$opener_stack = $this->Application->RecallVar('opener_stack');
$opener_stack = $opener_stack ? unserialize($opener_stack) : Array();
switch ($opener_action) {
case 'r': // "reset" opener stack
$opener_stack = Array();
break;
case 'd': // "down/push" new template to opener stack, deeplevel++
if ($this->Application->GetVar('front')) {
array_push($opener_stack, '../'.$this->Application->RecallVar('last_template') );
}
else {
array_push($opener_stack, $this->Application->RecallVar('last_template') );
}
break;
case 'u': // "up/pop" last template from opener stack, deeplevel--
array_pop($opener_stack);
break;
case 'p': //pop-up - do not store last template
$this->Application->SetVar('skip_last_template', 1);
break;
default: // "s/0," stay on same deep level
break;
}
if (!$this->Application->GetVar('skip_last_template')) {
$this->Application->SetVar('m_opener', 's');
}
$this->Application->StoreVar('opener_stack', serialize($opener_stack));
}
function registerHook($hookto_prefix, $hookto_special, $hookto_event, $mode, $do_prefix, $do_special, $do_event, $conditional)
{
if( !$this->Application->getUnitOptions($hookto_prefix) )
{
if($this->Application->isDebugMode())
{
trigger_error('Prefix <b>'.$hookto_prefix.'</b> doesn\'t exist when trying to hook from <b>'.$do_prefix.':'.$do_event.'</b>', E_USER_WARNING);
}
return;
}
$hookto_prefix_special = rtrim($hookto_prefix.'.'.$hookto_special, '.');
if ($mode == hBEFORE) {
$this->beforeHooks[strtolower($hookto_prefix_special.'.'.$hookto_event)][] = Array(
'DoPrefix' => $do_prefix,
'DoSpecial' => $do_special,
'DoEvent' => $do_event,
'Conditional' => $conditional,
);
}
elseif ($mode == hAFTER) {
$this->afterHooks[strtolower($hookto_prefix_special.'.'.$hookto_event)][] = Array(
'DoPrefix' => $do_prefix,
'DoSpecial' => $do_special,
'DoEvent' => $do_event,
'Conditional' => $conditional,
);
}
}
/**
* Enter description here...
*
* @param kEvent $event
* @param int $mode hBEFORE or hAFTER
* @return Array
*/
function &getHooks(&$event, $mode, $special = null)
{
$event_key = !isset($special) ? $event->Prefix_Special : $event->Prefix.'.'.$special;
if ($mode == hBEFORE) {
$mode_hooks =& $this->beforeHooks;
}
else {
$mode_hooks =& $this->afterHooks;
}
$hooks = getArrayValue($mode_hooks, strtolower($event_key.'.'.$event->Name));
if (!$hooks) {
$hooks = Array();
}
return $hooks;
}
/**
* Enter description here...
*
* @param kEvent $event
* @param int $mode hBEFORE or hAFTER
*/
function processHooks(&$event, $mode)
{
// * - get hooks that are valid with any special of given prefix
$hooks = array_merge($this->getHooks($event, $mode, '*'), $this->getHooks($event, $mode));
if ($hooks) {
foreach ($hooks as $hook) {
if ($hook['DoSpecial'] == '*') {
// use same special as master event
$hook['DoSpecial'] = $event->Special;
}
$prefix_special = rtrim($hook['DoPrefix'].'_'.$hook['DoSpecial'], '_');
if ( $hook['Conditional'] && !$this->Application->GetVar($prefix_special) ) {
continue;
}
$hook_event = new kEvent( Array('name'=>$hook['DoEvent'],'prefix'=>$hook['DoPrefix'],'special'=>$hook['DoSpecial']) );
$hook_event->MasterEvent =& $event;
$this->HandleEvent($hook_event);
}
}
}
/**
* Set's new event for $prefix_special
* passed
*
* @param string $prefix_special
* @param string $event_name
* @access public
*/
function setEvent($prefix_special,$event_name)
{
$actions =& $this->Application->recallObject('kActions');
$actions->Set('events['.$prefix_special.']',$event_name);
}
/**
* Run registred regular events with specified event type
*
* @param int $event_type
*/
function RunRegularEvents($event_type = reBEFORE, $from_cron=false)
{
// if RegularEvents are set to run from cron
if (!$from_cron && $this->Application->ConfigValue('UseCronForRegularEvent')) return ;
$events_source = ($event_type == reBEFORE) ? $this->beforeRegularEvents : $this->afterRegularEvents;
/*if(rand(0, 100) < 90)
{
return;
}*/
$sql = 'SELECT Data FROM '.TABLE_PREFIX.'Cache WHERE VarName = %s';
$event_last_runs = $this->Conn->GetOne( sprintf($sql, $this->Conn->qstr('RegularEventRuns') ) );
$event_last_runs = $event_last_runs ? unserialize($event_last_runs) : Array();
foreach($events_source as $short_name => $event_data)
{
$event_last_run = getArrayValue($event_last_runs, $short_name);
if($event_last_run && $event_last_run > adodb_mktime() - $event_data['RunInterval'])
{
continue;
}
else
{
$event = new kEvent($event_data['EventName']);
$event->redirect = false;
$this->Application->HandleEvent($event);
$event_last_runs[$short_name] = adodb_mktime();
}
}
$sql = 'REPLACE INTO '.TABLE_PREFIX.'Cache (VarName,Data,Cached) VALUES (%s,%s,%s)';
$this->Conn->Query( sprintf($sql, $this->Conn->qstr('RegularEventRuns'), $this->Conn->qstr(serialize($event_last_runs)), adodb_mktime() ) );
}
/**
* Allows to determine, that required event is beeing processed right now
*
* @param string $event_key Event name in format prefix[.special]:event_name
* @return bool
*/
function eventRunning($event_key)
{
return array_search($event_key, $this->recursionStack) !== false;
}
}
?>
\ No newline at end of file
Property changes on: trunk/core/kernel/event_manager.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.30
\ No newline at end of property
+1.31
\ No newline at end of property
Index: trunk/core/kernel/utility/formatters/formatters_config.php
===================================================================
--- trunk/core/kernel/utility/formatters/formatters_config.php (revision 4764)
+++ trunk/core/kernel/utility/formatters/formatters_config.php (revision 4765)
@@ -1,19 +1,22 @@
<?php
$config = Array(
'Prefix' => 'formatters',
+
+ 'EventHandlerClass' => Array('class' => 'kEventHandler', 'file' => '', 'build_event' => 'OnBuild'),
+
'RegisterClasses' => Array(
Array('pseudo'=>'kFormatter','class'=>'kFormatter','file'=>'formatter.php','build_event'=>'','require_classes'=>''),
Array('pseudo'=>'kOptionsFormatter','class'=>'kOptionsFormatter','file'=>'options_formatter.php','build_event'=>'','require_classes'=>'kFormatter'),
Array('pseudo'=>'kLEFTFormatter','class'=>'kLEFTFormatter','file'=>'left_formatter.php','build_event'=>'','require_classes'=>'kFormatter'),
Array('pseudo'=>'kDateFormatter','class'=>'kDateFormatter','file'=>'date_formatter.php','build_event'=>'','require_classes'=>'kFormatter'),
Array('pseudo'=>'kUploadFormatter','class'=>'kUploadFormatter','file'=>'upload_formatter.php','build_event'=>'','require_classes'=>'kFormatter'),
Array('pseudo'=>'kPictureFormatter','class'=>'kPictureFormatter','file'=>'upload_formatter.php','build_event'=>'','require_classes'=>'kUploadFormatter'),
Array('pseudo'=>'kMultiLanguage','class'=>'kMultiLanguage','file'=>'multilang_formatter.php','build_event'=>'','require_classes'=>'kFormatter'),
Array('pseudo'=>'kPasswordFormatter','class'=>'kPasswordFormatter','file'=>'password_formatter.php','build_event'=>'','require_classes'=>'kFormatter'),
Array('pseudo'=>'kCCDateFormatter','class'=>'kCCDateFormatter','file'=>'ccdate_formatter.php','build_event'=>'','require_classes'=>'kFormatter'),
Array('pseudo'=>'kUnitFormatter','class'=>'kUnitFormatter','file'=>'unit_formatter.php','build_event'=>'','require_classes'=>'kFormatter'),
Array('pseudo'=>'kFilesizeFormatter','class'=>'kFilesizeFormatter','file'=>'filesize_formatter.php','build_event'=>'','require_classes'=>'kFormatter'),
Array('pseudo'=>'kSerializedFormatter','class'=>'kSerializedFormatter','file'=>'serialized_formatter.php','build_event'=>'','require_classes'=>'kFormatter'),
),
);
Property changes on: trunk/core/kernel/utility/formatters/formatters_config.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.2
\ No newline at end of property
+1.3
\ No newline at end of property
Index: trunk/core/kernel/utility/unit_config_reader.php
===================================================================
--- trunk/core/kernel/utility/unit_config_reader.php (revision 4764)
+++ trunk/core/kernel/utility/unit_config_reader.php (revision 4765)
@@ -1,587 +1,587 @@
<?php
- class kUnitConfigReader extends kBase {
+class kUnitConfigReader extends kBase {
- /**
+ /**
* Configs readed
*
* @var Array
* @access private
*/
- var $configData=Array();
- var $configFiles=Array();
+ var $configData=Array();
+ var $configFiles=Array();
- var $CacheExpired = false;
+ var $CacheExpired = false;
- var $prefixFiles = array();
+ var $prefixFiles = array();
- /**
+ /**
* Scan kernel and user classes
* for available configs
*
* @access protected
*/
- function Init($prefix,$special)
- {
- parent::Init($prefix,$special);
- }
+ function Init($prefix,$special)
+ {
+ parent::Init($prefix,$special);
+ }
- /**
+ /**
* Checks if config file is allowed for includion (if module of config is installed)
*
* @param string $config_path relative path from in-portal directory
*/
- function configAllowed($config_path)
- {
- $module_found = false;
- if (!$this->Application->ModuleInfo) return false;
-
- foreach($this->Application->ModuleInfo as $module_name => $module_info)
- {
- $module_path = '/'.$module_info['Path'];
- if (preg_match('/^'.preg_quote($module_path, '/').'/', $config_path)) {
-// if (substr($config_path, 0, strlen($module_path)) == $module_path) {
- // config file path starts with module folder path
- $module_found = true;
- break;
- }
+ function configAllowed($config_path)
+ {
+ $module_found = false;
+ if (!$this->Application->ModuleInfo) return false;
+
+ foreach($this->Application->ModuleInfo as $module_name => $module_info)
+ {
+ $module_path = '/'.$module_info['Path'];
+ if (preg_match('/^'.preg_quote($module_path, '/').'/', $config_path)) {
+ // if (substr($config_path, 0, strlen($module_path)) == $module_path) {
+ // config file path starts with module folder path
+ $module_found = true;
+ break;
}
- return $module_found;
}
+ return $module_found;
+ }
- /**
+ /**
* Returns true if config exists and is allowed for reading
*
* @param string $prefix
* @return bool
*/
- function prefixRegistred($prefix)
- {
- return isset($this->configData[$prefix]) ? true : false;
- }
+ function prefixRegistred($prefix)
+ {
+ return isset($this->configData[$prefix]) ? true : false;
+ }
- /**
+ /**
* Read configs from all directories
* on path specified
*
* @param string $folderPath
* @access public
*/
- function processFolder($folderPath, $cached)
- {
- $fh = opendir($folderPath);
- while (($sub_folder = readdir($fh))) {
- $full_path = $folderPath.'/'.$sub_folder;
- if( $this->isDir($full_path) && file_exists($this->getConfigName($full_path)) )
- {
- if (filemtime($full_path) > $cached) {
- $this->CacheExpired = true;
-
- $file = $this->getConfigName($full_path);
- if ( $this->Application->isDebugMode() && constOn('DBG_PROFILE_INCLUDES') )
- {
-
- if ( in_array($file, get_required_files()) ) return;
- global $debugger;
- /*$debugger->IncludeLevel++;
- $before_time = getmicrotime();
- $before_mem = memory_get_usage();*/
- k4_include_once(FULL_PATH.$file);
- /*$used_time = getmicrotime() - $before_time;
- $used_mem = memory_get_usage() - $before_mem;
- $debugger->IncludeLevel--;
- $debugger->IncludesData['file'][] = str_replace(FULL_PATH, '', $file);
- $debugger->IncludesData['mem'][] = $used_mem;
- $debugger->IncludesData['time'][] = $used_time;
- $debugger->IncludesData['level'][] = -1;*/
- }
- else {
- include_once($file);
- }
+ function processFolder($folderPath, $cached)
+ {
+ $fh = opendir($folderPath);
+ while (($sub_folder = readdir($fh))) {
+ $full_path = $folderPath.'/'.$sub_folder;
+ if( $this->isDir($full_path) && file_exists($this->getConfigName($full_path)) )
+ {
+ if (filemtime($full_path) > $cached) {
+ $this->CacheExpired = true;
- if ( !isset($config) || !$config ) continue;
- $prefix = $config['Prefix'];
- $config['BasePath'] = $full_path;
- $this->configData[$prefix] = $config;
+ $file = $this->getConfigName($full_path);
+ if ( $this->Application->isDebugMode() && constOn('DBG_PROFILE_INCLUDES') )
+ {
+
+ if ( in_array($file, get_required_files()) ) return;
+ global $debugger;
+ /*$debugger->IncludeLevel++;
+ $before_time = getmicrotime();
+ $before_mem = memory_get_usage();*/
+ k4_include_once(FULL_PATH.$file);
+ /*$used_time = getmicrotime() - $before_time;
+ $used_mem = memory_get_usage() - $before_mem;
+ $debugger->IncludeLevel--;
+ $debugger->IncludesData['file'][] = str_replace(FULL_PATH, '', $file);
+ $debugger->IncludesData['mem'][] = $used_mem;
+ $debugger->IncludesData['time'][] = $used_time;
+ $debugger->IncludesData['level'][] = -1;*/
}
+ else {
+ include_once($file);
+ }
+
+ if ( !isset($config) || !$config ) continue;
+ $prefix = $config['Prefix'];
+ $config['BasePath'] = $full_path;
+ $this->configData[$prefix] = $config;
}
}
}
+ }
- function postProcessConfig($prefix, $config_key, $dst_prefix_var)
- {
- $main_config =& $this->configData[$prefix];
- $sub_configs = getArrayValue($main_config, $config_key);
- if (!$sub_configs) {
- return false;
- }
- unset($main_config[$config_key]);
-
- foreach ($sub_configs as $sub_prefix => $sub_config) {
- if ($config_key == 'AggregateConfigs' && !isset($this->configData[$sub_prefix])) {
- $this->loadConfig($sub_prefix);
- }
- $sub_config['Prefix'] = $sub_prefix;
- $this->configData[$sub_prefix] = array_merge_recursive2($this->configData[$$dst_prefix_var], $sub_config);
+ function postProcessConfig($prefix, $config_key, $dst_prefix_var)
+ {
+ $main_config =& $this->configData[$prefix];
+ $sub_configs = getArrayValue($main_config, $config_key);
+ if (!$sub_configs) {
+ return false;
+ }
+ unset($main_config[$config_key]);
- // when merging empty array to non-empty results non-empty array, but empty is required
- foreach ($sub_config as $sub_key => $sub_value) {
- if (!$sub_value) {
- unset($this->configData[$sub_prefix][$sub_key]);
- }
- }
- if ($config_key == 'Clones') {
- $this->prefixFiles[$sub_prefix] = $this->prefixFiles[$prefix];
- }
+ foreach ($sub_configs as $sub_prefix => $sub_config) {
+ if ($config_key == 'AggregateConfigs' && !isset($this->configData[$sub_prefix])) {
+ $this->loadConfig($sub_prefix);
+ }
+ $sub_config['Prefix'] = $sub_prefix;
+ $this->configData[$sub_prefix] = array_merge_recursive2($this->configData[$$dst_prefix_var], $sub_config);
- $this->postProcessConfig($sub_prefix, $config_key, $dst_prefix_var);
- if ($config_key == 'AggregateConfigs') {
- $this->postProcessConfig($sub_prefix, 'Clones', 'prefix');
+ // when merging empty array to non-empty results non-empty array, but empty is required
+ foreach ($sub_config as $sub_key => $sub_value) {
+ if (!$sub_value) {
+ unset($this->configData[$sub_prefix][$sub_key]);
}
}
+ if ($config_key == 'Clones') {
+ $this->prefixFiles[$sub_prefix] = $this->prefixFiles[$prefix];
+ }
- if (!$prefix) {
- // configs, that used only for cloning & not used ifself
- unset($this->configData[$prefix]);
+ $this->postProcessConfig($sub_prefix, $config_key, $dst_prefix_var);
+ if ($config_key == 'AggregateConfigs') {
+ $this->postProcessConfig($sub_prefix, 'Clones', 'prefix');
}
}
- function ParseConfigs()
- {
- foreach ($this->configData as $prefix => $config) {
- $this->parseConfig($prefix);
- $this->Application->HandleEvent( new kEvent($prefix.':OnAfterConfigRead') );
- }
+ if (!$prefix) {
+ // configs, that used only for cloning & not used ifself
+ unset($this->configData[$prefix]);
}
+ }
- function CacheParsedData()
- {
- $event_manager =& $this->Application->recallObject('EventManager');
- $aggregator =& $this->Application->recallObject('TagsAggregator', 'kArray');
+ function ParseConfigs()
+ {
+ $this->parseConfig('formatters'); // !TEMPORARY!, until config dependecy is created
+ foreach ($this->configData as $prefix => $config) {
+ $this->parseConfig($prefix);
+ $this->Application->HandleEvent( new kEvent($prefix.':OnAfterConfigRead') );
+ }
+ }
- $config_vars = Array(
- 'SessionTimeout',
- 'SessionCookieName',
- 'SessionReferrerCheck',
- 'CookieSessions',
- 'UseCronForRegularEvent',
- 'User_GuestGroup',
- 'User_LoggedInGroup',
- 'SessionTimeout',
- 'UseModRewrite',
- 'AdminDirectory',
- );
-
- foreach ($config_vars as $var) {
- $this->Application->ConfigValue($var);
- }
-
- $cache = Array(
- 'Factory.Files' => $this->Application->Factory->Files,
- 'Factory.realClasses' => $this->Application->Factory->realClasses,
- 'Factory.Dependencies' => $this->Application->Factory->Dependencies,
- 'ConfigReader.prefixFiles' => $this->prefixFiles,
- 'EventManager.buildEvents' => $event_manager->buildEvents,
- 'EventManager.beforeRegularEvents' => $event_manager->beforeRegularEvents,
- 'EventManager.afterRegularEvents' => $event_manager->afterRegularEvents,
- 'EventManager.beforeHooks' => $event_manager->beforeHooks,
- 'EventManager.afterHooks' => $event_manager->afterHooks,
- 'TagsAggregator.data' => $aggregator->_Array,
-
- // the following caches should be reset based on admin interaction (adjusting config, enabling modules etc)
- 'Application.Caches.ConfigVariables' => $this->Application->Caches['ConfigVariables'],
- 'Application.ConfigCacheIds' => $this->Application->ConfigCacheIds,
- 'Application.ConfigHash' => $this->Application->ConfigHash,
- 'Application.ModuleInfo' => $this->Application->ModuleInfo,
- );
+ function CacheParsedData()
+ {
+ $event_manager =& $this->Application->recallObject('EventManager');
+ $aggregator =& $this->Application->recallObject('TagsAggregator', 'kArray');
+
+ $config_vars = Array(
+ 'SessionTimeout',
+ 'SessionCookieName',
+ 'SessionReferrerCheck',
+ 'CookieSessions',
+ 'UseCronForRegularEvent',
+ 'User_GuestGroup',
+ 'User_LoggedInGroup',
+ 'SessionTimeout',
+ 'UseModRewrite',
+ 'AdminDirectory',
+ );
+
+ foreach ($config_vars as $var) {
+ $this->Application->ConfigValue($var);
+ }
+
+ $cache = Array(
+ 'Factory.Files' => $this->Application->Factory->Files,
+ 'Factory.realClasses' => $this->Application->Factory->realClasses,
+ 'Factory.Dependencies' => $this->Application->Factory->Dependencies,
+ 'ConfigReader.prefixFiles' => $this->prefixFiles,
+ 'EventManager.buildEvents' => $event_manager->buildEvents,
+ 'EventManager.beforeRegularEvents' => $event_manager->beforeRegularEvents,
+ 'EventManager.afterRegularEvents' => $event_manager->afterRegularEvents,
+ 'EventManager.beforeHooks' => $event_manager->beforeHooks,
+ 'EventManager.afterHooks' => $event_manager->afterHooks,
+ 'TagsAggregator.data' => $aggregator->_Array,
+
+ // the following caches should be reset based on admin interaction (adjusting config, enabling modules etc)
+ 'Application.Caches.ConfigVariables' => $this->Application->Caches['ConfigVariables'],
+ 'Application.ConfigCacheIds' => $this->Application->ConfigCacheIds,
+ 'Application.ConfigHash' => $this->Application->ConfigHash,
+ 'Application.ModuleInfo' => $this->Application->ModuleInfo,
+ );
- $conn =& $this->Application->GetADODBConnection();
- $conn->Query('REPLACE '.TABLE_PREFIX.'Cache (VarName, Data, Cached) VALUES ("configs_parsed", '.$conn->qstr(serialize($cache)).', '.adodb_mktime().')');
- }
+ $conn =& $this->Application->GetADODBConnection();
+ $conn->Query('REPLACE '.TABLE_PREFIX.'Cache (VarName, Data, Cached) VALUES ("configs_parsed", '.$conn->qstr(serialize($cache)).', '.adodb_mktime().')');
+ }
- function ResetParsedData($include_sections=false)
- {
- $conn =& $this->Application->GetADODBConnection();
- $conn->Query('DELETE FROM '.TABLE_PREFIX.'Cache WHERE VarName = "configs_parsed"');
+ function ResetParsedData($include_sections=false)
+ {
+ $conn =& $this->Application->GetADODBConnection();
+ $conn->Query('DELETE FROM '.TABLE_PREFIX.'Cache WHERE VarName = "configs_parsed"');
- if ($include_sections) {
- $conn->Query('DELETE FROM '.TABLE_PREFIX.'Cache WHERE VarName = "sections_parsed"');
- }
+ if ($include_sections) {
+ $conn->Query('DELETE FROM '.TABLE_PREFIX.'Cache WHERE VarName = "sections_parsed"');
}
+ }
- function RestoreParsedData()
- {
- $conn =& $this->Application->GetADODBConnection();
- $data = $conn->GetRow('SELECT Data, Cached FROM '.TABLE_PREFIX.'Cache WHERE VarName = "configs_parsed"');
- if ($data && $data['Cached'] > 0 ) {
- $cache = unserialize($data['Data']);
- $this->Application->Factory->Files = $cache['Factory.Files'];
- $this->Application->Factory->realClasses = $cache['Factory.realClasses'];
- $this->Application->Factory->Dependencies = $cache['Factory.Dependencies'];
- $this->prefixFiles = $cache['ConfigReader.prefixFiles'];
+ function RestoreParsedData()
+ {
+ $conn =& $this->Application->GetADODBConnection();
+ $data = $conn->GetRow('SELECT Data, Cached FROM '.TABLE_PREFIX.'Cache WHERE VarName = "configs_parsed"');
+ if ($data && $data['Cached'] > 0 ) {
+ $cache = unserialize($data['Data']);
+ $this->Application->Factory->Files = $cache['Factory.Files'];
+ $this->Application->Factory->realClasses = $cache['Factory.realClasses'];
+ $this->Application->Factory->Dependencies = $cache['Factory.Dependencies'];
+ $this->prefixFiles = $cache['ConfigReader.prefixFiles'];
- $event_manager =& $this->Application->recallObject('EventManager');
- $event_manager->buildEvents = $cache['EventManager.buildEvents'];
- $event_manager->beforeRegularEvents = $cache['EventManager.beforeRegularEvents'];
- $event_manager->afterRegularEvents = $cache['EventManager.afterRegularEvents'];
- $event_manager->beforeHooks = $cache['EventManager.beforeHooks'];
- $event_manager->afterHooks = $cache['EventManager.afterHooks'];
+ $event_manager =& $this->Application->recallObject('EventManager');
+ $event_manager->buildEvents = $cache['EventManager.buildEvents'];
+ $event_manager->beforeRegularEvents = $cache['EventManager.beforeRegularEvents'];
+ $event_manager->afterRegularEvents = $cache['EventManager.afterRegularEvents'];
+ $event_manager->beforeHooks = $cache['EventManager.beforeHooks'];
+ $event_manager->afterHooks = $cache['EventManager.afterHooks'];
- $aggregator =& $this->Application->recallObject('TagsAggregator', 'kArray');
- $aggregator->_Array = $cache['TagsAggregator.data'];
+ $aggregator =& $this->Application->recallObject('TagsAggregator', 'kArray');
+ $aggregator->_Array = $cache['TagsAggregator.data'];
- $this->Application->ConfigHash = $cache['Application.ConfigHash'];
+ $this->Application->ConfigHash = $cache['Application.ConfigHash'];
- $this->Application->Caches['ConfigVariables'] = $cache['Application.ConfigCacheIds'];
- $this->Application->ConfigCacheIds = $cache['Application.ConfigCacheIds'];
+ $this->Application->Caches['ConfigVariables'] = $cache['Application.ConfigCacheIds'];
+ $this->Application->ConfigCacheIds = $cache['Application.ConfigCacheIds'];
- $this->Application->ModuleInfo = $cache['Application.ModuleInfo'];
+ $this->Application->ModuleInfo = $cache['Application.ModuleInfo'];
- return true;
+ return true;
- }
- else return false;
}
+ else return false;
+ }
- function findConfigFiles($folderPath)
- {
- // if FULL_PATH = "/" ensure, that all "/" in $folderPath are not deleted
- $reg_exp = '/^'.preg_quote(FULL_PATH, '/').'/';
- $folderPath = preg_replace($reg_exp, '', $folderPath, 1); // this make sense, since $folderPath may NOT contain FULL_PATH
+ function findConfigFiles($folderPath)
+ {
+ // if FULL_PATH = "/" ensure, that all "/" in $folderPath are not deleted
+ $reg_exp = '/^'.preg_quote(FULL_PATH, '/').'/';
+ $folderPath = preg_replace($reg_exp, '', $folderPath, 1); // this make sense, since $folderPath may NOT contain FULL_PATH
- $fh=opendir(FULL_PATH.$folderPath);
- while(($sub_folder=readdir($fh)))
+ $fh=opendir(FULL_PATH.$folderPath);
+ while(($sub_folder=readdir($fh)))
+ {
+ $full_path = FULL_PATH.$folderPath.'/'.$sub_folder;
+ if( $this->isDir($full_path))
{
- $full_path = FULL_PATH.$folderPath.'/'.$sub_folder;
- if( $this->isDir($full_path))
- {
- if ( file_exists(FULL_PATH.$this->getConfigName($folderPath.'/'.$sub_folder)) ) {
- $this->configFiles[] = $this->getConfigName($folderPath.'/'.$sub_folder);
- }
- $this->findConfigFiles($full_path);
+ if ( file_exists(FULL_PATH.$this->getConfigName($folderPath.'/'.$sub_folder)) ) {
+ $this->configFiles[] = $this->getConfigName($folderPath.'/'.$sub_folder);
+ }
+ $this->findConfigFiles($full_path);
-// if (filemtime($full_path) > $cached) { }
+ // if (filemtime($full_path) > $cached) { }
- }
}
}
+ }
- function includeConfigFiles()
- {
- $this->Application->refreshModuleInfo();
- if (defined('CACHE_CONFIGS_FILES')) {
- $conn =& $this->Application->GetADODBConnection();
- $data = $conn->GetRow('SELECT Data, Cached FROM '.TABLE_PREFIX.'Cache WHERE VarName = "config_files"');
- if ($data && $data['Cached'] > 0 ) {
- $this->configFiles = unserialize($data['Data']);
- $files_cached = $data['Cached'];
- }
- else {
- $this->findConfigFiles($folderPath);
- }
+ function includeConfigFiles()
+ {
+ $this->Application->refreshModuleInfo();
+ if (defined('CACHE_CONFIGS_FILES')) {
+ $conn =& $this->Application->GetADODBConnection();
+ $data = $conn->GetRow('SELECT Data, Cached FROM '.TABLE_PREFIX.'Cache WHERE VarName = "config_files"');
+ if ($data && $data['Cached'] > 0 ) {
+ $this->configFiles = unserialize($data['Data']);
+ $files_cached = $data['Cached'];
}
else {
- $this->findConfigFiles($folderPath);
- }
-
-
- foreach ($this->configFiles as $filename)
- {
- $this->loadConfigFile($filename);
+ $this->findConfigFiles(''); // search from base directory
}
}
+ else {
+ $this->findConfigFiles(''); // search from base directory
+ }
- function scanModules($folderPath)
+ foreach ($this->configFiles as $filename)
{
- if (defined('CACHE_PARSED_CONFIGS') && CACHE_PARSED_CONFIGS) {
- $restored = $this->RestoreParsedData();
- if ($restored) return;
- }
- $this->includeConfigFiles();
- $this->ParseConfigs();
+ $this->loadConfigFile($filename);
+ }
+ }
- if (defined('CACHE_PARSED_CONFIGS')) {
- $this->CacheParsedData();
- }
+ function scanModules($folderPath)
+ {
+ if (defined('CACHE_PARSED_CONFIGS') && CACHE_PARSED_CONFIGS) {
+ $restored = $this->RestoreParsedData();
+ if ($restored) return;
+ }
+ $this->includeConfigFiles();
+ $this->ParseConfigs();
- if (defined('CACHE_CONFIGS_FILES') && $files_cached == 0) {
- $conn =& $this->Application->GetADODBConnection();
- $conn->Query('REPLACE '.TABLE_PREFIX.'Cache (VarName, Data, Cached) VALUES ("config_files", '.$conn->qstr(serialize($this->configFiles)).', '.adodb_mktime().')');
- }
+ if (defined('CACHE_PARSED_CONFIGS')) {
+ $this->CacheParsedData();
+ }
- unset($this->configFiles);
+ if (defined('CACHE_CONFIGS_FILES') && $files_cached == 0) {
+ $conn =& $this->Application->GetADODBConnection();
+ $conn->Query('REPLACE '.TABLE_PREFIX.'Cache (VarName, Data, Cached) VALUES ("config_files", '.$conn->qstr(serialize($this->configFiles)).', '.adodb_mktime().')');
}
- /**
+ unset($this->configFiles);
+ }
+
+ /**
* Register nessasary classes
*
* @param string $prefix
* @access private
*/
- function parseConfig($prefix)
- {
- $config =& $this->configData[$prefix];
- $event_manager =& $this->Application->recallObject('EventManager');
-
- $register_classes = getArrayValue($config,'RegisterClasses');
- if (!$register_classes) $register_classes = Array();
- $class_params=Array('ItemClass','ListClass','EventHandlerClass','TagProcessorClass');
- foreach($class_params as $param_name)
- {
- if ( !(isset($config[$param_name]) ) ) continue;
- $config[$param_name]['pseudo'] = $this->getPrefixByParamName($param_name,$prefix);
- $register_classes[] = $config[$param_name];
+ function parseConfig($prefix)
+ {
+ $config =& $this->configData[$prefix];
+ $event_manager =& $this->Application->recallObject('EventManager');
+
+ $register_classes = getArrayValue($config,'RegisterClasses');
+ if (!$register_classes) $register_classes = Array();
+ $class_params=Array('ItemClass','ListClass','EventHandlerClass','TagProcessorClass');
+ foreach($class_params as $param_name)
+ {
+ if ( !(isset($config[$param_name]) ) ) continue;
+ $config[$param_name]['pseudo'] = $this->getPrefixByParamName($param_name,$prefix);
+ $register_classes[] = $config[$param_name];
+ }
+
+ foreach($register_classes as $class_info)
+ {
+ $this->Application->registerClass(
+ $class_info['class'],
+ $config['BasePath'].'/'.$class_info['file'],
+ $class_info['pseudo'],
+ getArrayValue($class_info, 'require_classes')
+ );
+ if (getArrayValue($class_info, 'build_event')) {
+ $event_manager->registerBuildEvent($class_info['pseudo'],$class_info['build_event']);
}
+ }
- foreach($register_classes as $class_info)
+ $regular_events = getArrayValue($config, 'RegularEvents');
+ if($regular_events)
+ {
+ foreach($regular_events as $short_name => $regular_event_info)
{
- $this->Application->registerClass(
- $class_info['class'],
- $config['BasePath'].'/'.$class_info['file'],
- $class_info['pseudo'],
- getArrayValue($class_info, 'require_classes')
- );
- if (getArrayValue($class_info, 'build_event')) {
- $event_manager->registerBuildEvent($class_info['pseudo'],$class_info['build_event']);
- }
+ $event_manager->registerRegularEvent( $short_name, $config['Prefix'].':'.$regular_event_info['EventName'], $regular_event_info['RunInterval'], $regular_event_info['Type'] );
}
+ }
- $regular_events = getArrayValue($config, 'RegularEvents');
- if($regular_events)
- {
- foreach($regular_events as $short_name => $regular_event_info)
- {
- $event_manager->registerRegularEvent( $short_name, $config['Prefix'].':'.$regular_event_info['EventName'], $regular_event_info['RunInterval'], $regular_event_info['Type'] );
+ $hooks = getArrayValue($config, 'Hooks');
+ if (is_array($hooks) && count($hooks) > 0) {
+ foreach ($hooks as $hook) {
+ if (isset($config['ParentPrefix']) && $hook['HookToPrefix'] == $config['ParentPrefix']) {
+ trigger_error('Depricated Hook Usage [prefix: <b>'.$config['Prefix'].'</b>; do_prefix: <b>'.$hook['DoPrefix'].'</b>] use <b>#PARENT#</b> and <b>HookToPrefix</b> value where HookToPrefix is same as ParentPrefix', E_USER_NOTICE);
}
- }
-
- $hooks = getArrayValue($config, 'Hooks');
- if (is_array($hooks) && count($hooks) > 0) {
- foreach ($hooks as $hook) {
- if (isset($config['ParentPrefix']) && $hook['HookToPrefix'] == $config['ParentPrefix']) {
- trigger_error('Depricated Hook Usage [prefix: <b>'.$config['Prefix'].'</b>; do_prefix: <b>'.$hook['DoPrefix'].'</b>] use <b>#PARENT#</b> and <b>HookToPrefix</b> value where HookToPrefix is same as ParentPrefix', E_USER_NOTICE);
- }
- if ($hook['HookToPrefix'] == '') {
- $hook['HookToPrefix'] = $config['Prefix']; // new: set hooktoprefix to current prefix if not set
- }
+ if ($hook['HookToPrefix'] == '') {
+ $hook['HookToPrefix'] = $config['Prefix']; // new: set hooktoprefix to current prefix if not set
+ }
- if (isset($config['ParentPrefix']) && $hook['HookToPrefix'] == '#PARENT#') {
- // new: allow to set hook to parent prefix what ever it is
- $hook['HookToPrefix'] = $config['ParentPrefix'];
- }
+ if (isset($config['ParentPrefix']) && $hook['HookToPrefix'] == '#PARENT#') {
+ // new: allow to set hook to parent prefix what ever it is
+ $hook['HookToPrefix'] = $config['ParentPrefix'];
+ }
- $do_prefix = $hook['DoPrefix'] == '' ? $config['Prefix'] : $hook['DoPrefix'];
+ $do_prefix = $hook['DoPrefix'] == '' ? $config['Prefix'] : $hook['DoPrefix'];
- if ( !is_array($hook['HookToEvent']) ) {
- $hook_events = Array( $hook['HookToEvent'] );
- }
- else {
- $hook_events = $hook['HookToEvent'];
- }
- foreach ($hook_events as $hook_event) {
- $this->Application->registerHook($hook['HookToPrefix'], $hook['HookToSpecial'], $hook_event, $hook['Mode'], $do_prefix, $hook['DoSpecial'], $hook['DoEvent'], $hook['Conditional']);
- }
+ if ( !is_array($hook['HookToEvent']) ) {
+ $hook_events = Array( $hook['HookToEvent'] );
+ }
+ else {
+ $hook_events = $hook['HookToEvent'];
+ }
+ foreach ($hook_events as $hook_event) {
+ $this->Application->registerHook($hook['HookToPrefix'], $hook['HookToSpecial'], $hook_event, $hook['Mode'], $do_prefix, $hook['DoSpecial'], $hook['DoEvent'], $hook['Conditional']);
}
}
+ }
- if ( is_array(getArrayValue($config, 'AggregateTags')) ) {
- foreach ($config['AggregateTags'] as $aggregate_tag) {
- $aggregate_tag['LocalPrefix'] = $config['Prefix'];
- $this->Application->registerAggregateTag($aggregate_tag);
- }
+ if ( is_array(getArrayValue($config, 'AggregateTags')) ) {
+ foreach ($config['AggregateTags'] as $aggregate_tag) {
+ $aggregate_tag['LocalPrefix'] = $config['Prefix'];
+ $this->Application->registerAggregateTag($aggregate_tag);
}
+ }
- if ( $this->Application->isDebugMode() && dbg_ConstOn('DBG_VALIDATE_CONFIGS') && isset($config['TableName']) )
- {
- global $debugger;
- $tablename = $config['TableName'];
+ if ( $this->Application->isDebugMode() && dbg_ConstOn('DBG_VALIDATE_CONFIGS') && isset($config['TableName']) )
+ {
+ global $debugger;
+ $tablename = $config['TableName'];
- $conn =& $this->Application->GetADODBConnection();
- $res = $conn->Query("DESCRIBE $tablename");
+ $conn =& $this->Application->GetADODBConnection();
+ $res = $conn->Query("DESCRIBE $tablename");
- foreach ($res as $field) {
- $f_name = $field['Field'];
- if (getArrayValue($config, 'Fields')) {
- if ( !array_key_exists ($f_name, $config['Fields']) ) {
- $debugger->appendHTML("<b class='debug_error'>Config Warning: </b>Field $f_name exists in the database, but is not defined in config file for prefix <b>".$config['Prefix']."</b>!");
- safeDefine('DBG_RAISE_ON_WARNINGS', 1);
- }
- else {
- $options = $config['Fields'][$f_name];
- if ($field['Null'] == '') {
- if ( $f_name != $config['IDField'] && !isset($options['not_null']) && !isset($options['required']) ) {
- $debugger->appendHTML("<b class='debug_error'>Config Error: </b>Field $f_name in config for prefix <b>".$config['Prefix']."</b> is NOT NULL in the database, but is not configured as not_null or required!");
- safeDefine('DBG_RAISE_ON_WARNINGS', 1);
- }
- if ( isset($options['not_null']) && !isset($options['default']) ) {
- $debugger->appendHTML("<b class='debug_error'>Config Error: </b>Field $f_name in config for prefix <b>".$config['Prefix']."</b> is described as NOT NULL, but does not have DEFAULT value!");
- safeDefine('DBG_RAISE_ON_WARNINGS', 1);
- }
+ foreach ($res as $field) {
+ $f_name = $field['Field'];
+ if (getArrayValue($config, 'Fields')) {
+ if ( !array_key_exists ($f_name, $config['Fields']) ) {
+ $debugger->appendHTML("<b class='debug_error'>Config Warning: </b>Field $f_name exists in the database, but is not defined in config file for prefix <b>".$config['Prefix']."</b>!");
+ safeDefine('DBG_RAISE_ON_WARNINGS', 1);
+ }
+ else {
+ $options = $config['Fields'][$f_name];
+ if ($field['Null'] == '') {
+ if ( $f_name != $config['IDField'] && !isset($options['not_null']) && !isset($options['required']) ) {
+ $debugger->appendHTML("<b class='debug_error'>Config Error: </b>Field $f_name in config for prefix <b>".$config['Prefix']."</b> is NOT NULL in the database, but is not configured as not_null or required!");
+ safeDefine('DBG_RAISE_ON_WARNINGS', 1);
+ }
+ if ( isset($options['not_null']) && !isset($options['default']) ) {
+ $debugger->appendHTML("<b class='debug_error'>Config Error: </b>Field $f_name in config for prefix <b>".$config['Prefix']."</b> is described as NOT NULL, but does not have DEFAULT value!");
+ safeDefine('DBG_RAISE_ON_WARNINGS', 1);
}
-
}
+
}
}
}
}
+ }
- function loadConfigFile($filename)
- {
- $config_found = file_exists(FULL_PATH.$filename) && $this->configAllowed($filename);
-
- if( defined('DEBUG_MODE') && DEBUG_MODE && constOn('DBG_PROFILE_INCLUDES') )
- {
- if ( in_array($filename, get_required_files()) ) return;
- global $debugger;
- /*$debugger->IncludeLevel++;
- $before_time = getmicrotime();
- $before_mem = memory_get_usage();*/
- if($config_found) {
- $file = FULL_PATH.$filename;
- $debugger->ProfileStart('inc_'.crc32($file), $file);
- include_once($file);
- $debugger->ProfileFinish('inc_'.crc32($file));
- $debugger->profilerAddTotal('includes', 'inc_'.crc32($file));
- }
- /*$used_time = getmicrotime() - $before_time;
- $used_mem = memory_get_usage() - $before_mem;
- $debugger->IncludeLevel--;
- $debugger->IncludesData['file'][] = str_replace(FULL_PATH, '', $filename);
- $debugger->IncludesData['mem'][] = $used_mem;
- $debugger->IncludesData['time'][] = $used_time;
- $debugger->IncludesData['level'][] = -1;*/
- }
- else
- {
- if($config_found) include_once(FULL_PATH.$filename);
- }
-
- if($config_found && isset($config) && $config)
- {
- $prefix = isset($config['Prefix']) ? $config['Prefix'] : '';
-
- preg_match('/\/(.*)\//U', $filename, $rets);
- $config['ModuleFolder'] = $rets[1];
- $config['BasePath'] = dirname(FULL_PATH.$filename);
- $this->configData[$prefix] = $config;
- $this->prefixFiles[$prefix] = $filename;
+ function loadConfigFile($filename)
+ {
+ $config_found = file_exists(FULL_PATH.$filename) && $this->configAllowed($filename);
+
+ if( defined('DEBUG_MODE') && DEBUG_MODE && constOn('DBG_PROFILE_INCLUDES') )
+ {
+ if ( in_array($filename, get_required_files()) ) return;
+ global $debugger;
+ /*$debugger->IncludeLevel++;
+ $before_time = getmicrotime();
+ $before_mem = memory_get_usage();*/
+ if($config_found) {
+ $file = FULL_PATH.$filename;
+ $debugger->ProfileStart('inc_'.crc32($file), $file);
+ include_once($file);
+ $debugger->ProfileFinish('inc_'.crc32($file));
+ $debugger->profilerAddTotal('includes', 'inc_'.crc32($file));
+ }
+ /*$used_time = getmicrotime() - $before_time;
+ $used_mem = memory_get_usage() - $before_mem;
+ $debugger->IncludeLevel--;
+ $debugger->IncludesData['file'][] = str_replace(FULL_PATH, '', $filename);
+ $debugger->IncludesData['mem'][] = $used_mem;
+ $debugger->IncludesData['time'][] = $used_time;
+ $debugger->IncludesData['level'][] = -1;*/
+ }
+ else
+ {
+ if($config_found) include_once(FULL_PATH.$filename);
+ }
+
+ if($config_found && isset($config) && $config)
+ {
+ $prefix = isset($config['Prefix']) ? $config['Prefix'] : '';
+
+ preg_match('/\/(.*)\//U', $filename, $rets);
+ $config['ModuleFolder'] = $rets[1];
+ $config['BasePath'] = dirname(FULL_PATH.$filename);
+ $this->configData[$prefix] = $config;
+ $this->prefixFiles[$prefix] = $filename;
- $this->postProcessConfig($prefix, 'AggregateConfigs', 'sub_prefix');
- $this->postProcessConfig($prefix, 'Clones', 'prefix');
- }
+ $this->postProcessConfig($prefix, 'AggregateConfigs', 'sub_prefix');
+ $this->postProcessConfig($prefix, 'Clones', 'prefix');
}
+ }
- function loadConfig($prefix)
- {
- if (!isset($this->prefixFiles[$prefix])) {
- trigger_error('Configuration file for prefix '.$prefix.' is unknown', E_USER_ERROR);
- return ;
- }
- $file = $this->prefixFiles[$prefix];
- $this->loadConfigFile($file);
- $this->Application->HandleEvent( new kEvent($prefix.':OnAfterConfigRead') );
- }
+ function loadConfig($prefix)
+ {
+ if (!isset($this->prefixFiles[$prefix])) {
+ trigger_error('Configuration file for prefix '.$prefix.' is unknown', E_USER_ERROR);
+ return ;
+ }
+ $file = $this->prefixFiles[$prefix];
+ $this->loadConfigFile($file);
+ $this->Application->HandleEvent( new kEvent($prefix.':OnAfterConfigRead') );
+ }
- /**
+ /**
* Reads unit (specified by $prefix)
* option specified by $option
*
* @param string $prefix
* @param string $name
* @param mixed $default
* @return string
* @access public
*/
- function getUnitOption($prefix, $name, $default = false)
- {
- if (preg_match('/(.*)\.(.*)/', $prefix, $rets)) {
- if (!isset($this->configData[$rets[1]])) {
- $this->loadConfig($rets[1]);
- }
- $ret = getArrayValue($this->configData, $rets[1], $name, $rets[2]);
+ function getUnitOption($prefix, $name, $default = false)
+ {
+ if (preg_match('/(.*)\.(.*)/', $prefix, $rets)) {
+ if (!isset($this->configData[$rets[1]])) {
+ $this->loadConfig($rets[1]);
}
- else {
- if (!isset($this->configData[$prefix])) {
- $this->loadConfig($prefix);
- }
- $ret = getArrayValue($this->configData, $prefix, $name);
+ $ret = getArrayValue($this->configData, $rets[1], $name, $rets[2]);
+ }
+ else {
+ if (!isset($this->configData[$prefix])) {
+ $this->loadConfig($prefix);
}
- return $ret === false ? $default : $ret;
+ $ret = getArrayValue($this->configData, $prefix, $name);
}
+ return $ret === false ? $default : $ret;
+ }
- /**
+ /**
* Read all unit with $prefix options
*
* @param string $prefix
* @return Array
* @access public
*/
- function getUnitOptions($prefix)
- {
- return $this->prefixRegistred($prefix) ? $this->configData[$prefix] : false;
- }
+ function getUnitOptions($prefix)
+ {
+ return $this->prefixRegistred($prefix) ? $this->configData[$prefix] : false;
+ }
- /**
+ /**
* Set's new unit option value
*
* @param string $prefix
* @param string $name
* @param string $value
* @access public
*/
- function setUnitOption($prefix, $name, $value)
- {
- if (preg_match('/(.*)\.(.*)/', $prefix, $rets)) {
- $this->configData[$rets[1]][$name][$rets[2]] = $value;
- }
- else {
- $this->configData[$prefix][$name] = $value;
- }
-
+ function setUnitOption($prefix, $name, $value)
+ {
+ if (preg_match('/(.*)\.(.*)/', $prefix, $rets)) {
+ $this->configData[$rets[1]][$name][$rets[2]] = $value;
}
-
- function getPrefixByParamName($paramName,$prefix)
- {
- $pseudo_class_map=Array(
- 'ItemClass'=>'%s',
- 'ListClass'=>'%s_List',
- 'EventHandlerClass'=>'%s_EventHandler',
- 'TagProcessorClass'=>'%s_TagProcessor'
- );
- return sprintf($pseudo_class_map[$paramName],$prefix);
+ else {
+ $this->configData[$prefix][$name] = $value;
}
- /**
+ }
+
+ function getPrefixByParamName($paramName,$prefix)
+ {
+ $pseudo_class_map=Array(
+ 'ItemClass'=>'%s',
+ 'ListClass'=>'%s_List',
+ 'EventHandlerClass'=>'%s_EventHandler',
+ 'TagProcessorClass'=>'%s_TagProcessor'
+ );
+ return sprintf($pseudo_class_map[$paramName],$prefix);
+ }
+
+ /**
* Get's config file name based
* on folder name supplied
*
* @param string $folderPath
* @return string
* @access private
*/
- function getConfigName($folderPath)
- {
- return $folderPath.'/'.basename($folderPath).'_config.php';
- }
+ function getConfigName($folderPath)
+ {
+ return $folderPath.'/'.basename($folderPath).'_config.php';
+ }
- /**
+ /**
* is_dir ajustment to work with
* directory listings too
*
* @param string $folderPath
* @return bool
* @access private
*/
- function isDir($folderPath)
- {
- $base_name = basename($folderPath);
- $ret = !( $base_name == '.' || $base_name == '..' );
- return $ret && is_dir($folderPath);
- }
+ function isDir($folderPath)
+ {
+ $base_name = basename($folderPath);
+ $ret = !( $base_name == '.' || $base_name == '..' );
+ return $ret && is_dir($folderPath);
+ }
- }
+}
?>
\ No newline at end of file
Property changes on: trunk/core/kernel/utility/unit_config_reader.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.36
\ No newline at end of property
+1.37
\ No newline at end of property
Index: trunk/core/units/statistics/statistics_tag_processor.php
===================================================================
--- trunk/core/units/statistics/statistics_tag_processor.php (revision 4764)
+++ trunk/core/units/statistics/statistics_tag_processor.php (revision 4765)
@@ -1,285 +1,287 @@
<?php
class StatisticsTagProcessor extends kDBTagProcessor {
var $TagCache = Array(); // parsed tag (in sql queries only) values are cached
var $CurrentSQL = ''; // sql query being currently processed
var $PostFormatting = false; // apply formatting to sql query results
var $PostFormattingParams = Array(); // post formatting params if any
function CalculateValue($params)
{
$object =& $this->getObject($params);
$this->CurrentSQL = $object->GetDBField($params['field']);
// 1. replace prefix to actual one
$this->CurrentSQL = str_replace("<%prefix%>", TABLE_PREFIX, $this->CurrentSQL);
// 2. replace all pseudo-tags found in sql with their values
while ( ($tag = $this->FindTag()) != false ) {
$this->CurrentSQL = str_replace('<%'.$tag.'%>', $this->ProcessStatisticTag($tag), $this->CurrentSQL);
}
// 3. query sql and process gathered data
$values = $this->Conn->GetCol($this->CurrentSQL);
if (!$values) return '';
if (!$this->PostFormatting) return array_shift($values);
switch ($this->PostFormatting) {
case 'number':
// simple-specific postformatting
$lang =& $this->Application->recallObject('lang.current');
$value = $lang->formatNumber($value, $this->PostFormattingParams['precision']);
break;
case 'COUNT':
// extended postformatting
$value = count($values);
break;
case 'SUM':
$value = 0;
foreach ($values as $cur_value) {
$value += $cur_value;
}
if ($this->PostFormattingParams['format_as'] == 'file') {
$value = size($value);
}
break;
// other type of information (not from db)
case 'SysFileSize':
$value = size( dir_size(FULL_PATH.'/') );
break;
default: // simple-default postformatting
$value = adodb_date($this->PostFormatting, array_shift($values));
break;
}
$this->PostFormatting = false;
$this->PostFormattingParams = Array();
return $value;
}
function FindTag()
{
// finds tag in current sql & returns it if found, false otherwise
$tagOpen = '<%'; $tagClose = '%>'; $tagOpenLen = strlen($tagOpen);
$startPos = strpos($this->CurrentSQL, $tagOpen);
if( $startPos !== false )
{
$endPos = strpos($this->CurrentSQL, $tagClose, $startPos);
return ($endPos > $startPos) ? substr($this->CurrentSQL, $startPos + $tagOpenLen, $endPos - $startPos - $tagOpenLen) : false;
}
return false;
}
function ProcessStatisticTag($tag)
{
$tag = trim($tag);
if (isset($this->TagCache[$tag])) {
return $this->TagCache[$tag];
}
$object =& $this->getObject();
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);
$tag_params = Array();
foreach ($rets AS $key => $val){
$tag_params[$val[1]] = str_replace(Array('\\' . $val[2], '+'), Array($val[2], ' '), $val[3]);
}
switch ($tag_name) {
case 'm:config':
// m:config name="<variable_name>"
return $this->Application->ConfigValue($tag_params['name']);
break;
case 'm:post_format':
// m:post_format field="<field_name>" type="<formatting_type>" precision="2"
$lang =& $this->Application->recallObject('lang.current');
switch ($tag_params['type']) {
case 'date':
$this->PostFormatting = $lang->GetDBField('DateFormat');
break;
case 'time':
$this->PostFormatting = $lang->GetDBField('TimeFormat');
break;
case 'currency':
$this->PostFormatting = 'number';
$this->PostFormattingParams['precision'] = $tag_params['precision'];
break;
}
return $tag_params['field'];
break;
case 'm:custom_action':
// m:custom_action sql="empty" action="SysFileSize"
$this->PostFormatting = $tag_params['action'];
return ($tag_params['sql'] == 'empty') ? 'SELECT 1' : $tag_params['sql'];
break;
case 'modules:get_current':
return $object->GetDBField('Module');
break;
case 'm:sql_action':
//m:sql_action sql="SHOW TABLES" action="COUNT" field="*"
$this->PostFormatting = $tag_params['action'];
$this->PostFormattingParams = $tag_params;
return $tag_params['sql'];
break;
case 'link:hit_count':
if ($tag_params['type'] == 'top') {// by now only top is supported
$top_links_count = $this->Application->ConfigValue('Link_TopCount');
$sql = 'SELECT Hits
FROM '.TABLE_PREFIX.'Link
ORDER BY Hits DESC LIMIT 0, '.$top_links_count;
return $this->getLastRecord($sql, 'Hits');
}
break;
case 'article:hit_count':
if ($tag_params['type'] == 'top') {// by now only top is supported
$top_articles_count = $this->Application->ConfigValue('News_VotesToHot');
$min_votes = $this->Application->ConfigValue('News_MinVotes');
$sql = 'SELECT CachedRating
FROM '.TABLE_PREFIX.'News
WHERE CachedVotesQty > '.$min_votes.'
ORDER BY CachedRating DESC LIMIT 0, '.$top_articles_count;
return $this->getLastRecord($sql, 'CachedRating');
}
break;
case 'topic:hit_count':
if ($tag_params['type'] == 'top') {// by now only top is supported
$top_posts_count = $this->Application->ConfigValue('Topic_PostsToPop');
$sql = 'SELECT Views
FROM '.TABLE_PREFIX.'Topic
ORDER BY Views DESC LIMIT 0, '.$top_posts_count;
return $this->getLastRecord($sql, 'Views');
}
break;
}
}
function getLastRecord($sql, $field)
{
$records = $this->Conn->GetCol($sql);
return count($records) ? array_pop($records) : 0;
}
/**
* Allows to get pending item count for prefix
*
* @param Array $params
* @return int
*/
function CountPending($params)
{
$prefix = $params['prefix'];
$value = $this->Application->getCache('statistics.pending', $prefix);
if ($value === false) {
$statistics_info = $this->Application->getUnitOption($prefix.'.pending', 'StatisticsInfo');
if (!$statistics_info) {
return 0;
}
$table = $this->Application->getUnitOption($prefix, 'TableName');
$status_field = array_shift( $this->Application->getUnitOption($prefix, 'StatusField') );
$sql = 'SELECT COUNT(*)
FROM '.$table.'
WHERE '.$status_field.' = '.$statistics_info['status'];
$value = $this->Conn->GetOne($sql);
$this->Application->setCache('statistics.pending', $prefix, $value);
}
return $value;
}
function GetTotalPending()
{
$sql = 'SELECT Prefix
- FROM '.TABLE_PREFIX.'ItemTypes';
+ FROM '.TABLE_PREFIX.'ItemTypes
+ WHERE LENGTH(ClassName) > 0';
$prefixes = $this->Conn->GetCol($sql);
$sum = 0;
foreach ($prefixes as $prefix) {
$sum += $this->CountPending( Array('prefix' => $prefix) );
}
return $sum;
}
function PrintPendingStatistics($params)
{
$sql = 'SELECT Prefix
- FROM '.TABLE_PREFIX.'ItemTypes';
+ FROM '.TABLE_PREFIX.'ItemTypes
+ WHERE LENGTH(ClassName) > 0';
$check_prefixes = $this->Conn->GetCol($sql);
if (!$check_prefixes) {
return '';
}
$ret = '';
$columns = $params['columns'];
$block_params = $this->prepareTagParams( Array('name' => $this->SelectParam($params, 'render_as,block') ) );
$prefixes = Array();
foreach ($check_prefixes as $prefix) {
$statistics_info = $this->Application->getUnitOption($prefix.'.pending', 'StatisticsInfo');
if ($statistics_info) {
$prefixes[] = $prefix;
}
}
$row_number = 0;
foreach ($prefixes as $i => $prefix) {
$block_params['prefix'] = $prefix;
$statistics_info = $this->Application->getUnitOption($prefix.'.pending', 'StatisticsInfo');
if ($i % $columns == 0) {
$column_number = 1;
$ret .= '<tr>';
}
$block_params['column_number'] = $column_number;
$block_params['is_first'] = $i < $columns ? 1 : 0;
$template = $statistics_info['url']['t'];
unset($statistics_info['url']['t']);
$url = $this->Application->HREF($template, '', $statistics_info['url']);
if ($statistics_info['js_url'] != '#url#') {
$statistics_info['js_url'] = 'javascript:'.$statistics_info['js_url'];
}
$block_params['url'] = str_replace('#url#', $url, $statistics_info['js_url']);
$block_params['icon'] = $statistics_info['icon'];
$block_params['label'] = $statistics_info['label'];
$ret .= $this->Application->ParseBlock($block_params);
$column_number++;
if (($i+1) % $columns == 0) {
$ret .= '</tr>';
}
}
return $ret;
}
}
?>
\ No newline at end of file
Property changes on: trunk/core/units/statistics/statistics_tag_processor.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.2
\ No newline at end of property
+1.3
\ No newline at end of property

Event Timeline