Index: trunk/core/kernel/startup.php =================================================================== diff -u -N -r2596 -r2600 --- trunk/core/kernel/startup.php (.../startup.php) (revision 2596) +++ trunk/core/kernel/startup.php (.../startup.php) (revision 2600) @@ -8,32 +8,28 @@ define('INPORTAL_ENV', 1); -if( !isset($_SERVER['DOCUMENT_ROOT']) || !$_SERVER['DOCUMENT_ROOT'] ) -{ - $full_path = str_replace('\\', '/', dirname(FULL_PATH)); - if (!isset($_SERVER['PATH_INFO'])) { - $_SERVER['PATH_INFO'] = $_SERVER['PHP_SELF']; - } - $path_info = str_replace('\\', '/', dirname($_SERVER['PATH_INFO'])); +# New path detection method -// echo "replacing ".$path_info.' (path_info) with "" in '.$full_path.' (full_path) = '.str_replace($path_info, '', $full_path).'
'; - $_SERVER['DOCUMENT_ROOT'] = str_replace($path_info, '', $full_path); -} +echo "FULL_PATH: ".FULL_PATH.'
'; -$doc_root = rtrim(realpath($_SERVER['DOCUMENT_ROOT']), '/'); -$doc_root = str_replace('\\', '/', $doc_root); // windows hack -define('DOC_ROOT', $doc_root); +$fp = str_replace('\\', '/', dirname(FULL_PATH)); +$ps = preg_replace("/\/admin$/", '', str_replace('\\', '/', dirname($_SERVER['PHP_SELF']))); -include_once(KERNEL_PATH.'/globals.php'); // non OOP functions used through kernel, e.g. print_pre +echo "fp: $fp
"; +echo "ps: $ps
"; -safeDefine('INPORTAL_TAGS', true); +$_SERVER['DOCUMENT_ROOT'] = $fp; +define('DOC_ROOT', $fp); +define('BASE_PATH', $ps); -$reg = '/'.preg_quote (DOC_ROOT, '/').'/i'; -define('BASE_PATH', $base_path = ereg_replace('/admin', '', preg_replace($reg, '', str_replace('\\', '/', FULL_PATH)))); +# /New method +include_once(KERNEL_PATH.'/globals.php'); // non OOP functions used through kernel, e.g. print_pre + +safeDefine( 'INPORTAL_TAGS', true); safeDefine( 'SERVER_NAME', $_SERVER['HTTP_HOST']); -safeDefine( 'KERNEL_PATH', DOC_ROOT.BASE_PATH.'/kernel4'); -safeDefine( 'PROTOCOL', 'http://'); +safeDefine( 'KERNEL_PATH', FULL_PATH.'/kernel4'); +safeDefine( 'PROTOCOL', isset($_SERVER["HTTPS"]) ? 'https://' : 'http://'); $vars = parse_portal_ini(FULL_PATH.'/config.php'); @@ -58,8 +54,13 @@ ini_set('memory_limit', '50M'); -define('MODULES_PATH', DOC_ROOT.BASE_PATH); -define('EXPORT_PATH', DOC_ROOT.BASE_PATH.'/admin/export'); +echo "FULL_PATH: ".FULL_PATH.'
'; +echo "DOC_ROOT: ".DOC_ROOT.'
'; +echo "BASE_PATH: ".BASE_PATH.'
'; +echo "MODULES_PATH: ".DOC_ROOT.'
'; + +define('MODULES_PATH', FULL_PATH); +define('EXPORT_PATH', FULL_PATH.'/admin/export'); define('GW_CLASS_PATH', MODULES_PATH.'/in-commerce/units/gateways/gw_classes'); // Payment Gateway Classes Path safeDefine('ENV_VAR_NAME','env'); Index: trunk/core/kernel/db/dblist.php =================================================================== diff -u -N -r2581 -r2600 --- trunk/core/kernel/db/dblist.php (.../dblist.php) (revision 2581) +++ trunk/core/kernel/db/dblist.php (.../dblist.php) (revision 2600) @@ -5,19 +5,19 @@ * */ define('FLT_SYSTEM', 1); - + /** * User Having/Where filter * */ define('FLT_NORMAL', 2); - + /** * User "Search" Having/Where filter * */ define('FLT_SEARCH', 3); - + /** * User "View Menu" Having/Where filter * @@ -31,82 +31,82 @@ * @package kernel4 */ class kDBList extends kDBBase { - + /** * Description * * @var array * @access public */ var $OrderFields; - + /** * Holds counted total number of records in the query - without pagination (system+user filters) * * @var int * @access public */ var $RecordsCount; - - + + /** * Records count with system filters only applied * * @var int * @access private */ var $NoFilterCount = 0; - + /** * Record count selected to be * showed on current page * * @var int */ var $SelectedCount=0; - + /** * Array of records selected * * @var Array * @access private */ var $Records; - + var $CurrentIndex = 0; - + /** * List items per-page * * @var int * @access public */ var $PerPage; - + /** * Pages count in list based on PerPage & RecordsCount attributes * * @var int * @access public */ var $TotalPages; - + /** * Description * * @var int * @access public */ - - var $Direction; + + var $Direction; /** * Holds current page number - used when forming LIMIT clause of SELECT statement * * @var int * @access public */ var $Page; - + /** * Holds offset for LIMIT clause, calculated in {@link kDBList::PerPage()} * @@ -122,28 +122,28 @@ * @access private */ var $hasCounted = false; - + /** * Holds list WHERE filter object * * @var kMultipleFilter * @access private */ var $WhereFilter = Array(FLT_SYSTEM => null, FLT_NORMAL => null, FLT_SEARCH => null, FLT_VIEW => null); - + /** * Holds list HAVING filter object * * @var kMultipleFilter * @access private */ var $HavingFilter = Array(FLT_SYSTEM => null, FLT_NORMAL => null, FLT_SEARCH => null, FLT_VIEW => null); - + var $GroupByFields = Array(); - + var $Queried = false; var $Counted = false; - + /** * Creates kDBList * @@ -152,26 +152,26 @@ function kDBList() { parent::kDBBase(); $this->OrderFields = Array(); - + $this->WhereFilter[FLT_SYSTEM] =& $this->Application->makeClass('kMultipleFilter', FLT_TYPE_AND); $this->WhereFilter[FLT_NORMAL] =& $this->Application->makeClass('kMultipleFilter', FLT_TYPE_OR); - + $this->WhereFilter[FLT_SEARCH] =& $this->Application->makeClass('kMultipleFilter', FLT_TYPE_OR); $this->WhereFilter[FLT_SEARCH]->setType(FLT_TYPE_OR); - + $this->WhereFilter[FLT_VIEW] =& $this->Application->makeClass('kMultipleFilter', FLT_TYPE_AND); - + $this->HavingFilter[FLT_SYSTEM] =& $this->Application->makeClass('kMultipleFilter', FLT_TYPE_AND); $this->HavingFilter[FLT_NORMAL] =& $this->Application->makeClass('kMultipleFilter', FLT_TYPE_OR); - + $this->HavingFilter[FLT_SEARCH] =& $this->Application->makeClass('kMultipleFilter', FLT_TYPE_OR); $this->HavingFilter[FLT_SEARCH]->setType(FLT_TYPE_OR); - + $this->HavingFilter[FLT_VIEW] =& $this->Application->makeClass('kMultipleFilter', FLT_TYPE_AND); - + $this->PerPage = -1; } - + /** * Adds new or replaces old filter with same name * @@ -184,12 +184,12 @@ function addFilter($name, $clause, $filter_type = WHERE_FILTER, $filter_scope = FLT_SYSTEM) { $filter_name = ($filter_type == WHERE_FILTER) ? 'WhereFilter' : 'HavingFilter'; - + $filter =& $this->$filter_name; $filter =& $filter[$filter_scope]; $filter->addFilter($name,$clause); } - + /** * Removes specified filter from filters list * @@ -201,12 +201,12 @@ function removeFilter($name, $filter_type = WHERE_FILTER, $filter_scope = FLT_SYSTEM) { $filter_name = ($filter_type == WHERE_FILTER) ? 'WhereFilter' : 'HavingFilter'; - + $filter =& $this->$filter_name; $filter =& $filter[$filter_scope]; $filter->removeFilter($name); } - + /** * Clear list filters * @@ -236,7 +236,7 @@ $this->HavingFilter[FLT_VIEW]->clearFilters(); } } - + /** * Counts the total number of records base on the query resulted from {@link kDBList::GetSelectSQL()} * @@ -252,7 +252,7 @@ { $all_sql = $this->GetSelectSQL(true,false); $sql = $this->getCountSQL($all_sql); - + if( $this->GetGroupClause() ) { $this->RecordsCount = count( $this->Conn->GetCol($sql) ); @@ -261,7 +261,7 @@ { $this->RecordsCount = (int)$this->Conn->GetOne($sql); } - + $system_sql = $this->GetSelectSQL(true,true); if ($system_sql == $all_sql) { //no need to query the same again $this->NoFilterCount = $this->RecordsCount; @@ -271,7 +271,7 @@ $this->NoFilterCount = (int)$this->Conn->GetOne($sql); $this->Counted = true; } - + function getCountSQL($sql) { if ( preg_match("/DISTINCT(.*?)FROM(?!_)/is",$sql,$regs ) ) @@ -283,7 +283,7 @@ return preg_replace("/^.*SELECT(.*?)FROM(?!_)/is", "SELECT COUNT(*) AS count FROM ", $sql); } } - + /** * Queries the database with SQL resulted from {@link kDBList::GetSelectSQL()} and stores result in {@link kDBList::SelectRS} * @@ -301,25 +301,25 @@ echo get_class($this)." Query SQL: $q LIMIT ".$this->PerPage." OFFSET ".$this->Offset." Page: ".$this->Page."
"; } //$rs = $this->Conn->SelectLimit($q, $this->PerPage, $this->Offset); - + //in case we have not counted records try to select one more item to find out if we have something more than perpage - $limit = $this->Counted ? $this->PerPage : $this->PerPage+1; - + $limit = $this->Counted ? $this->PerPage : $this->PerPage+1; + $sql = $q.' '.$this->Conn->getLimitClause($this->Offset,$limit); - + $this->Records = $this->Conn->Query($sql); $this->SelectedCount = count($this->Records); if (!$this->Counted) $this->RecordsCount = $this->SelectedCount; if (!$this->Counted && $this->SelectedCount > $this->PerPage && $this->PerPage != -1) $this->SelectedCount--; - + if ($this->Records === false) { //handle errors here return false; } $this->Queried = true; - return true; + return true; } - + /** * Builds full select query except for LIMIT clause * @@ -330,20 +330,20 @@ { $q = parent::GetSelectSQL($this->SelectClause); if(!$for_counting) $q = $this->addCalculatedFields($q); - + $where = $this->GetWhereClause($for_counting,$system_filters_only); $having = $this->GetHavingClause($for_counting,$system_filters_only); $order = $this->GetOrderClause(); $group = $this->GetGroupClause(); - - if (!empty($where)) $q .= ' WHERE ' . $where; + + if (!empty($where)) $q .= ' WHERE ' . $where; if (!empty($group)) $q .= ' GROUP BY ' . $group; if (!empty($having)) $q .= ' HAVING ' . $having; if ( !$for_counting && !empty($order) ) $q .= ' ORDER BY ' . $order; - + return str_replace('%1$s',$this->TableName,$q); } - + function extractCalculatedFields($clause) { if ( is_array($this->CalculatedFields) ) { @@ -354,7 +354,7 @@ } return $clause; } - + /** * Returns WHERE clause of the query * @@ -365,9 +365,9 @@ function GetWhereClause($for_counting=false,$system_filters_only=false) { $where =& $this->Application->makeClass('kMultipleFilter'); - + $where->addFilter('system_where', $this->WhereFilter[FLT_SYSTEM] ); - + if (!$system_filters_only) { $where->addFilter('view_where', $this->WhereFilter[FLT_VIEW] ); $search_w = $this->WhereFilter[FLT_SEARCH]->getSQL(); @@ -378,16 +378,16 @@ $where->addFilter('search_where', $search_w ); } } - + if( $for_counting ) // add system_having and view_having to where { $where->addFilter('system_having', $this->extractCalculatedFields( $this->HavingFilter[FLT_SYSTEM]->getSQL() ) ); if (!$system_filters_only) $where->addFilter('view_having', $this->extractCalculatedFields( $this->HavingFilter[FLT_VIEW]->getSQL() ) ); } - + return $where->getSQL(); } - + /** * Depricated method * @@ -399,11 +399,11 @@ if( $this->Application->isDebugMode() ) { global $debugger; - $debugger->appendTrace(); + $debugger->appendTrace(); } trigger_error('Depricated method kDBList->SetWhereClause. Use kDBList->addFilter instead.', E_USER_ERROR); } - + /** * Returns HAVING clause of the query * @@ -414,9 +414,9 @@ function GetHavingClause($for_counting=false, $system_filters_only=false) { if( $for_counting ) return ''; - + $having =& $this->Application->makeClass('kMultipleFilter'); - + $having->addFilter('system_having', $this->HavingFilter[FLT_SYSTEM] ); if (!$system_filters_only) { $having->addFilter('view_having', $this->HavingFilter[FLT_VIEW] ); @@ -425,10 +425,10 @@ $having->addFilter('search_having', $this->HavingFilter[FLT_SEARCH] ); } } - + return $having->getSQL(); } - + /** * Returns GROUP BY clause of the query * @@ -444,7 +444,7 @@ { $this->GroupByFields[$field] = $field; } - + function RemoveGroupByField($field) { unset($this->GroupByFields[$field]); @@ -465,10 +465,10 @@ $lang = $this->Application->GetVar('m_lang'); $field = 'l'.$lang.'_'.$field; } - + $this->OrderFields[] = Array($field, $direction); } - + /** * Removes all order fields * @@ -479,7 +479,7 @@ { $this->OrderFields = Array(); } - + /** * Returns ORDER BY Clause of the query * @@ -492,35 +492,35 @@ { $ret = ''; foreach ($this->OrderFields as $field) { - + $name = $field[0]; $ret .= isset($this->Fields[$name]) && !isset($this->VirtualFields[$name]) ? '`'.$this->TableName.'`.' : ''; if ($field[0] == 'RAND()') { $ret .= $field[0].' '.$field[1].','; } else { - $ret .= '`'.$field[0] . '` ' . $field[1] . ','; + $ret .= '`'.$field[0] . '` ' . $field[1] . ','; } } $ret = rtrim($ret, ','); return $ret; } - - function GetOrderField($pos=NULL) + + function GetOrderField($pos=NULL) { if(!(isset($this->OrderFields[$pos]) && $this->OrderFields[$pos]) ) { $pos = 0; } return isset($this->OrderFields[$pos][0]) ? $this->OrderFields[$pos][0] : ''; } - - function GetOrderDirection($pos=NULL) + + function GetOrderDirection($pos=NULL) { if( !getArrayValue($this->OrderFields, $pos) ) $pos = 0; return getArrayValue($this->OrderFields, $pos, 1); } - + /** * Return unformatted field value * @@ -533,23 +533,23 @@ $row =& $this->getCurrentRecord(); return $row[$name]; } - + function HasField($name) { $row =& $this->getCurrentRecord(); return isset($row[$name]); } - + function GetFieldValues() { return $this->getCurrentRecord(); } - + function &getCurrentRecord() { return $this->Records[$this->CurrentIndex]; } - + /** * Description * @@ -561,7 +561,7 @@ { $this->CurrentIndex = 0; } - + /** * Description * @@ -595,7 +595,7 @@ { return ($this->CurrentIndex >= $this->SelectedCount); } - + /** * Description * @@ -610,8 +610,8 @@ $this->TotalPages = (($this->RecordsCount - ($this->RecordsCount % $this->PerPage)) / $this->PerPage) // integer part of division + (($this->RecordsCount % $this->PerPage) != 0); // adds 1 if there is a reminder return $this->TotalPages; - } - + } + /** * Sets number of records to query per page * @@ -623,12 +623,12 @@ { $this->PerPage = $per_page; } - + function GetPerPage() { return $this->PerPage == -1 ? $this->RecordsCount : $this->PerPage; } - + /** * Description * @@ -652,7 +652,7 @@ } //$this->GoFirst(); } - + /** * Sets current item field value * (doesn't apply formatting) @@ -666,7 +666,7 @@ { $this->Records[$this->CurrentIndex][$name] = $value; } - + /** * Apply where clause, that links this object to it's parent item * @@ -680,10 +680,10 @@ { $parent_table_key = $this->Application->getUnitOption($this->Prefix, 'ParentTableKey'); $foreign_key_field = $this->Application->getUnitOption($this->Prefix, 'ForeignKey'); - + $parent_object =& $this->Application->recallObject($parent_prefix.'.'.$special); $parent_id = $parent_object->GetDBField($parent_table_key); - + $this->addFilter('parent_filter', '`'.$this->TableName.'`.`'.$foreign_key_field.'` = '.$parent_id); // only for list in this case } } Index: trunk/core/kernel/application.php =================================================================== diff -u -N -r2592 -r2600 --- trunk/core/kernel/application.php (.../application.php) (revision 2592) +++ trunk/core/kernel/application.php (.../application.php) (revision 2600) @@ -7,43 +7,43 @@ * The class incapsulates the main run-cycle of the script, provide access to all other objects in the framework.
*
* The class is a singleton, which means that there could be only one instance of KernelApplication in the script.
-* This could be guranteed by NOT calling the class constuctor directly, but rather calling KernelApplication::Instance() method, +* This could be guranteed by NOT calling the class constuctor directly, but rather calling KernelApplication::Instance() method, * which returns an instance of the application. The method gurantees that it will return exactly the same instance for any call.
* See singleton pattern by GOF. * @package kernel4 */ class kApplication { - + /** * Is true, when Init method was called already, prevents double initialization * * @var bool */ var $InitDone = false; - + /** * Holds internal TemplateParser object * @access private * @var TemplateParser */ var $Parser; - + /** * Holds parser output buffer * @access private * @var string */ var $HTML; - + /** * Prevents request from beeing proceeded twice in case if application init is called mere then one time * * @var bool * @todo This is not good anyway (by Alex) */ var $RequestProcessed = false; - + /** * The main Factory used to create * almost any class of kernel and @@ -53,42 +53,42 @@ * @var kFactory */ var $Factory; - + /** * Reference to debugger * * @var Debugger */ var $Debugger = null; - + /** * Holds all phrases used * in code and template * * @var PhrasesCache */ var $Phrases; - + /** * Holds DBConnection * * @var kDBConnection */ var $DB; - + /** * Maintains list of user-defined error handlers * * @var Array */ var $errorHandlers = Array(); - + /** * Returns kApplication instance anywhere in the script. * - * This method should be used to get single kApplication object instance anywhere in the + * This method should be used to get single kApplication object instance anywhere in the * Kernel-based application. The method is guranteed to return the SAME instance of kApplication. - * Anywhere in the script you could write: + * Anywhere in the script you could write: * * $application =& kApplication::Instance(); * @@ -97,8 +97,8 @@ * $this->Application =& kApplication::Instance(); * * to get the instance of kApplication. Note that we call the Instance method as STATIC - directly from the class. - * To use descendand of standard kApplication class in your project you would need to define APPLICATION_CLASS constant - * BEFORE calling kApplication::Instance() for the first time. If APPLICATION_CLASS is not defined the method would + * To use descendand of standard kApplication class in your project you would need to define APPLICATION_CLASS constant + * BEFORE calling kApplication::Instance() for the first time. If APPLICATION_CLASS is not defined the method would * create and return default KernelApplication instance. * @static * @access public @@ -107,7 +107,7 @@ function &Instance() { static $instance = false; - + if(!$instance) { if (!defined('APPLICATION_CLASS')) define('APPLICATION_CLASS', 'kApplication'); @@ -116,7 +116,7 @@ } return $instance; } - + /** * Initializes the Application * @@ -129,82 +129,81 @@ function Init() { if($this->InitDone) return false; - + if( $this->isDebugMode() && dbg_ConstOn('DBG_PROFILE_MEMORY') ) { $GLOBALS['debugger']->appendMemoryUsage('Application before Init:'); } - - if( !$this->isDebugMode() ) + + if( !$this->isDebugMode() ) { error_reporting(0); ini_set('display_errors', 0); } - + $error_handler = set_error_handler( Array(&$this,'handleError') ); if($error_handler) $this->errorHandlers[] = $error_handler; - - + + $this->DB = new kDBConnection(SQL_TYPE, Array(&$this,'handleSQLError') ); $this->DB->Connect(SQL_SERVER, SQL_USER, SQL_PASS, SQL_DB); $this->DB->debugMode = $this->isDebugMode(); - + $this->Factory = new kFactory(); - + $this->registerDefaultClasses(); - $this->SetDefaultConstants(); - + // 1. to read configs before doing any recallObject (called from "SetDefaultConstants" anyway) //$config_reader =& $this->recallObject('kUnitConfigReader'); - + if( !$this->GetVar('m_lang') ) $this->SetVar('m_lang', $this->GetDefaultLanguageId() ); if( !$this->GetVar('m_theme') ) $this->SetVar('m_theme', $this->GetDefaultThemeId() ); if( $this->GetVar('m_cat_id') === false ) $this->SetVar('m_cat_id', 0); - + $this->Phrases = new PhrasesCache( $this->GetVar('m_lang') ); - + $this->SetVar('lang.current_id', $this->GetVar('m_lang') ); $language =& $this->recallObject('lang.current', null, Array('live_table'=>true) ); - + if( !$this->GetVar('m_theme') ) $this->SetVar('m_theme', $this->GetDefaultThemeId() ); $this->SetVar('theme.current_id', $this->GetVar('m_theme') ); - + if( !$this->RecallVar('UserGroups') ) { $ses =& $this->recallObject('Session'); $user_groups = trim($ses->GetField('GroupList'), ','); if (!$user_groups) $user_groups = $this->ConfigValue('User_GuestGroup'); $this->StoreVar('UserGroups', $user_groups); } - + if( !$this->RecallVar('curr_iso') ) $this->StoreVar('curr_iso', $this->GetPrimaryCurrency() ); - + $this->SetVar('visits_id', $this->RecallVar('visit_id') ); - + $this->ValidateLogin(); // TODO: write that method - + if( $this->isDebugMode() ) { $GLOBALS['debugger']->profileFinish('kernel4_startup'); } - + if( defined('CMS') && CMS == 1 && !$this->GetVar('admin') && !$this->IsAdmin() ) { define('MOD_REWRITE', 1); } - + $this->InitDone = true; return true; } - + function GetDefaultLanguageId() { $table = $this->getUnitOption('lang','TableName'); $id_field = $this->getUnitOption('lang','IDField'); return $this->DB->GetOne('SELECT '.$id_field.' FROM '.$table.' WHERE PrimaryLang = 1'); } - + function GetDefaultThemeId() { if (defined('DBG_FORCE_THEME') && DBG_FORCE_THEME){ @@ -214,13 +213,13 @@ $id_field = $this->getUnitOption('theme','IDField'); return $this->DB->GetOne('SELECT '.$id_field.' FROM '.$table.' WHERE PrimaryTheme = 1'); } - + function GetPrimaryCurrency() { $this->setUnitOption('mod','AutoLoad',false); $module =& $this->recallObject('mod'); $this->setUnitOption('mod','AutoLoad',true); - + if( $module->Load('In-Commerce') && $module->GetDBField('Loaded') == 1 ) { $table = $this->getUnitOption('curr','TableName'); @@ -231,7 +230,7 @@ return 'USD'; } } - + /** * Registers default classes such as ItemController, GridController and LoginController * @@ -243,17 +242,17 @@ { $this->registerClass('kArray',KERNEL_PATH.'/utility/params.php'); $this->registerClass('Params',KERNEL_PATH.'/utility/params.php'); - + $this->registerClass('HTTPQuery', KERNEL_PATH.'/utility/http_query.php', 'HTTPQuery', Array('Params') ); - + $this->registerClass('Session', KERNEL_PATH.'/session/session.php'); $this->registerClass('SessionStorage', KERNEL_PATH.'/session/session.php'); - + $this->registerClass('kEventManager', KERNEL_PATH.'/event_manager.php', 'EventManager'); $this->registerClass('kUnitConfigReader', KERNEL_PATH.'/utility/unit_config_reader.php'); - + $this->registerClass('Params', KERNEL_PATH.'/utility/params.php', 'kActions'); - + $this->registerClass('kFormatter', KERNEL_PATH.'/utility/formatters.php'); $this->registerClass('kOptionsFormatter', KERNEL_PATH.'/utility/formatters.php'); $this->registerClass('kUploadFormatter', KERNEL_PATH.'/utility/formatters.php'); @@ -265,35 +264,35 @@ $this->registerClass('kCCDateFormatter', KERNEL_PATH.'/utility/formatters.php'); $this->registerClass('kUnitFormatter', KERNEL_PATH.'/utility/formatters.php'); $this->registerClass('kFilesizeFormatter', KERNEL_PATH.'/utility/formatters.php'); - + $this->registerClass('kTempTablesHandler', KERNEL_PATH.'/utility/temp_handler.php'); - + $event_manager =& $this->recallObject('EventManager'); $event_manager->registerBuildEvent('kTempTablesHandler', 'OnTempHandlerBuild'); - + $this->registerClass('TemplatesCache',KERNEL_PATH.'/parser/template.php'); $this->registerClass('Template',KERNEL_PATH.'/parser/template.php'); $this->registerClass('TemplateParser',KERNEL_PATH.'/parser/template_parser.php'); - + $this->registerClass('MainProcessor', KERNEL_PATH.'/processors/main_processor.php','m_TagProcessor'); - + $this->registerClass('kMultipleFilter', KERNEL_PATH.'/utility/filters.php'); $this->registerClass('kDBList', KERNEL_PATH.'/db/dblist.php'); $this->registerClass('kDBItem', KERNEL_PATH.'/db/dbitem.php'); $this->registerClass('kDBEventHandler', KERNEL_PATH.'/db/db_event_handler.php'); $this->registerClass('kDBTagProcessor', KERNEL_PATH.'/db/db_tag_processor.php'); - + $this->registerClass('kTagProcessor', KERNEL_PATH.'/processors/tag_processor.php'); $this->registerClass('kEmailMessage',KERNEL_PATH.'/utility/email.php'); $this->registerClass('kSmtpClient',KERNEL_PATH.'/utility/smtp_client.php'); - + if (file_exists(MODULES_PATH.'/in-commerce/units/currencies/currency_rates.php')) { $this->registerClass('kCurrencyRates',MODULES_PATH.'/in-commerce/units/currencies/currency_rates.php'); } - + $this->registerClass('FCKeditor', DOC_ROOT.BASE_PATH.'/admin/editor/cmseditor/fckeditor.php'); // need this? } - + /** * Defines default constants if it's not defined before - in config.php * @@ -302,14 +301,14 @@ function SetDefaultConstants() { if (!defined('SERVER_NAME')) define('SERVER_NAME', $_SERVER['HTTP_HOST']); - + $admin_dir = $this->ConfigValue('AdminDirectory'); if(!$admin_dir) $admin_dir = 'admin'; safeDefine('ADMIN_DIR', $admin_dir); - + $this->registerModuleConstants(); } - + /** * Registers each module specific constants if any found * @@ -323,24 +322,24 @@ if( file_exists($contants_file) ) k4_include_once($contants_file); } } - + function ProcessRequest() { $event_manager =& $this->recallObject('EventManager'); - + if( $this->isDebugMode() && dbg_ConstOn('DBG_SHOW_HTTPQUERY') ) { global $debugger; $http_query =& $this->recallObject('HTTPQuery'); $debugger->appendHTML('HTTPQuery:'); $debugger->dumpVars($http_query->_Params); } - + $event_manager->ProcessRequest(); $event_manager->RunRegularEvents(reBEFORE); $this->RequestProcessed = true; } - + /** * Actually runs the parser against current template and stores parsing result * @@ -355,44 +354,44 @@ { $GLOBALS['debugger']->appendMemoryUsage('Application before Run:'); } - + if (!$this->RequestProcessed) $this->ProcessRequest(); - + $this->InitParser(); $template_cache =& $this->recallObject('TemplatesCache'); $t = $this->GetVar('t'); - + if(defined('CMS') && CMS) { $cms_handler =& $this->recallObject('cms_EventHandler'); if( !$template_cache->TemplateExists($t) ) { - $t = $cms_handler->GetDesignTemplate(); + $t = $cms_handler->GetDesignTemplate(); } else { $cms_handler->SetCatByTemplate(); } } - + if( $this->isDebugMode() && dbg_ConstOn('DBG_PROFILE_MEMORY') ) { $GLOBALS['debugger']->appendMemoryUsage('Application before Parsing:'); } - + $this->HTML = $this->Parser->Parse( $template_cache->GetTemplateBody($t), $t ); - + if( $this->isDebugMode() && dbg_ConstOn('DBG_PROFILE_MEMORY') ) { $GLOBALS['debugger']->appendMemoryUsage('Application after Parsing:'); } } - + function InitParser() { if( !is_object($this->Parser) ) $this->Parser =& $this->recallObject('TemplateParser'); } - + /** * Send the parser results to browser * @@ -406,39 +405,39 @@ { $GLOBALS['debugger']->appendMemoryUsage('Application before Done:'); } - + if( $this->GetVar('admin') ) { $reg = '/('.preg_quote(BASE_PATH, '/').'.*\.html)(#.*){0,1}(")/sU'; $this->HTML = preg_replace($reg, "$1?admin=1$2$3", $this->HTML); } - + //eval("?".">".$this->HTML); - + echo $this->HTML; $this->Phrases->UpdateCache(); - + flush(); - + $event_manager =& $this->recallObject('EventManager'); $event_manager->RunRegularEvents(reAFTER); - + $session =& $this->recallObject('Session'); $session->SaveData(); //$this->SaveBlocksCache(); } - + function SaveBlocksCache() { /*if (defined('EXPERIMENTAL_PRE_PARSE')) { $data = serialize($this->PreParsedCache); - - $this->DB->Query('REPLACE '.TABLE_PREFIX.'Cache (VarName, Data, Cached) VALUES ("blocks_cache", '.$this->DB->qstr($data).', '.time().')'); + + $this->DB->Query('REPLACE '.TABLE_PREFIX.'Cache (VarName, Data, Cached) VALUES ("blocks_cache", '.$this->DB->qstr($data).', '.time().')'); }*/ } - + // Facade - + /** * Returns current session id (SID) * @access public @@ -449,13 +448,13 @@ $session =& $this->recallObject('Session'); return $session->GetID(); } - + function DestroySession() { $session =& $this->recallObject('Session'); $session->Destroy(); } - + /** * Returns variable passed to the script as GET/POST/COOKIE * @@ -468,7 +467,7 @@ $http_query =& $this->recallObject('HTTPQuery'); return $http_query->Get($var,$mode); } - + /** * Returns ALL variables passed to the script as GET/POST/COOKIE * @@ -480,11 +479,11 @@ $http_query =& $this->recallObject('HTTPQuery'); return $http_query->GetParams(); } - + /** * Set the variable 'as it was passed to the script through GET/POST/COOKIE' * - * This could be useful to set the variable when you know that + * This could be useful to set the variable when you know that * other objects would relay on variable passed from GET/POST/COOKIE * or you could use SetVar() / GetVar() pairs to pass the values between different objects.
* @@ -522,7 +521,7 @@ $http_query =& $this->recallObject('HTTPQuery'); return $http_query->Remove($var); } - + /** * Returns session variable value * @@ -539,7 +538,7 @@ $session =& $this->recallObject('Session'); return $session->RecallVar($var,$default); } - + /** * Stores variable $val in session under name $var * @@ -559,15 +558,15 @@ { $session =& $this->recallObject('Session'); $session->StoreVarDefault($var, $val); - } - + } + /** - * Links HTTP Query variable with session variable + * Links HTTP Query variable with session variable * * If variable $var is passed in HTTP Query it is stored in session for later use. If it's not passed it's recalled from session. * This method could be used for making sure that GetVar will return query or session value for given * variable, when query variable should overwrite session (and be stored there for later use).
- * This could be used for passing item's ID into popup with multiple tab - + * This could be used for passing item's ID into popup with multiple tab - * in popup script you just need to call LinkVar('id', 'current_id') before first use of GetVar('id'). * After that you can be sure that GetVar('id') will return passed id or id passed earlier and stored in session * @access public @@ -587,10 +586,10 @@ $this->SetVar($var, $this->RecallVar($ses_var, $default)); } } - + /** * Returns variable from HTTP Query, or from session if not passed in HTTP Query - * + * * The same as LinkVar, but also returns the variable value taken from HTTP Query if passed, or from session if not passed. * Returns the default value if variable does not exist in session and was not passed in HTTP Query * @@ -618,13 +617,13 @@ $templates_cache =& $this->recallObject('TemplatesCache'); $templates_cache->SetTemplateBody($title,$body); } - + function ProcessTag($tag_data) { $a_tag = new Tag($tag_data,$this->Parser); return $a_tag->DoProcessTag(); } - + function ProcessParsedTag($prefix, $tag, $params) { $a_tag = new Tag('',$this->Parser); @@ -665,9 +664,9 @@ if (defined('ADMIN') && $prefix == '') $prefix='/admin'; if (defined('ADMIN') && $prefix == '_FRONT_END_') $prefix = ''; $index_file = isset($index_file) ? $index_file : (defined('INDEX_FILE') ? INDEX_FILE : basename($_SERVER['SCRIPT_NAME'])); - + if( isset($params['index_file']) ) $index_file = $params['index_file']; - + if (getArrayValue($params, 'opener') == 'u') { $opener_stack=$this->RecallVar('opener_stack'); if($opener_stack) { @@ -688,59 +687,59 @@ $t = $this->GetVar('t'); } } - + $pass = isset($params['pass']) ? $params['pass'] : ''; $pass_events = isset($params['pass_events']) ? $params['pass_events'] : false; // pass events with url - - - + + + if (defined('MOD_REWRITE') && MOD_REWRITE) { $env = $this->BuildEnv('', $params, $pass, $pass_events, false); $env = ltrim($env, ':-'); - + $session =& $this->recallObject('Session'); $sid = $session->NeedQueryString() ? '?sid='.$this->GetSID() : ''; // $env = str_replace(':', '/', $env); $ret = rtrim($this->BaseURL($prefix).$t.'.html/'.$env.'/'.$sid, '/'); - + } else { $env = $this->BuildEnv($t, $params, $pass, $pass_events); $ret = $this->BaseURL($prefix).$index_file.'?'.$env; } - + return $ret; } - + function BuildEnv($t, $params, $pass='all', $pass_events=false, $env_var=true) { $session =& $this->recallObject('Session'); $sid = $session->NeedQueryString() && !(defined('MOD_REWRITE') && MOD_REWRITE) ? $this->GetSID() : ''; if( getArrayValue($params,'admin') == 1 ) $sid = $this->GetSID(); - + $ret = ''; if ($env_var) { $ret = ENV_VAR_NAME.'='; } $ret .= defined('INPORTAL_ENV') ? $sid.'-'.$t : $sid.':'.$t; - + $pass = str_replace('all', trim($this->GetVar('passed'), ','), $pass); - + if(strlen($pass) > 0) { - $pass_info = array_unique( explode(',',$pass) ); // array( prefix[.special], prefix[.special] ... + $pass_info = array_unique( explode(',',$pass) ); // array( prefix[.special], prefix[.special] ... foreach($pass_info as $pass_element) { $ret.=':'; list($prefix)=explode('.',$pass_element); $query_vars = $this->getUnitOption($prefix,'QueryString'); - + //if pass events is off and event is not implicity passed if(!$pass_events && !isset($params[$pass_element.'_event'])) { $params[$pass_element.'_event'] = ''; // remove event from url if requested //otherwise it will use value from get_var } - + if($query_vars) { $tmp_string=Array(0=>$pass_element); @@ -752,12 +751,12 @@ unset( $params[$pass_element.'_'.$var_name] ); } } - + $escaped = array(); foreach ($tmp_string as $tmp_val) { $escaped[] = str_replace(Array('-',':'), Array('\-','\:'), $tmp_val); } - + if ($this->getUnitOption($prefix, 'PortalStyleEnv') == true) { $ret.= array_shift($escaped).array_shift($escaped).'-'.implode('-',$escaped); } @@ -770,43 +769,43 @@ unset($params['pass']); unset($params['opener']); unset($params['m_event']); - + if ($this->GetVar('admin') && !isset($params['admin'])) { $params['admin'] = 1; } - + if( getArrayValue($params,'escape') ) { $ret = addslashes($ret); unset($params['escape']); } - + foreach ($params as $param => $value) { $ret .= '&'.$param.'='.$value; } - + return $ret; } - + function BaseURL($prefix='') { return PROTOCOL.SERVER_NAME.(defined('PORT')?':'.PORT : '').BASE_PATH.$prefix.'/'; } - + function Redirect($t='', $params=null, $prefix='', $index_file=null) { if ($t == '' || $t === true) $t = $this->GetVar('t'); - + // pass prefixes and special from previous url if (!isset($params['pass'])) $params['pass'] = 'all'; - + $location = $this->HREF($t, $prefix, $params, $index_file); $a_location = $location; $location = "Location: $location"; //echo " location : $location
"; - - + + if( $this->isDebugMode() && dbg_ConstOn('DBG_REDIRECT') ) { $GLOBALS['debugger']->appendTrace(); @@ -823,18 +822,18 @@ header("$location"); } } - + $session =& $this->recallObject('Session'); $session->SaveData(); $this->SaveBlocksCache(); exit; } - + function Phrase($label) { return $this->Phrases->GetPhrase($label); } - + /** * Replace language tags in exclamation marks found in text * @@ -847,7 +846,7 @@ { return $this->Phrases->ReplaceLanguageTags($text,$force_escape); } - + /** * Validtates user in session if required * @@ -858,14 +857,14 @@ { // Original Kostja call //$login_controller =& $this->Factory->MakeClass(LOGIN_CONTROLLER, Array('model' => USER_MODEL, 'prefix' => 'login')); - + // Call proposed by Alex //$login_controller =& $this->RecallObject(LOGIN_CONTROLLER, Array('model' => USER_MODEL, 'prefix' => 'login')); - + //$login_controller->CheckLogin(); } } - + /** * Returns configuration option value by name * @@ -876,7 +875,7 @@ { return $this->DB->GetOne('SELECT VariableValue FROM '.TABLE_PREFIX.'ConfigurationValues WHERE VariableName = '.$this->DB->qstr($name) ); } - + /** * Allows to process any type of event * @@ -892,11 +891,11 @@ $event_manager =& $this->recallObject('EventManager'); $event_manager->HandleEvent($event); } - + /** * Registers new class in the factory * - * @param string $real_class Real name of class as in class declaration + * @param string $real_class Real name of class as in class declaration * @param string $file Filename in what $real_class is declared * @param string $pseudo_class Name under this class object will be accessed using getObject method * @param Array $dependecies List of classes required for this class functioning @@ -905,9 +904,9 @@ */ function registerClass($real_class, $file, $pseudo_class = null, $dependecies = Array() ) { - $this->Factory->registerClass($real_class, $file, $pseudo_class, $dependecies); + $this->Factory->registerClass($real_class, $file, $pseudo_class, $dependecies); } - + /** * Add $class_name to required classes list for $depended_class class. * All required class files are included before $depended_class file is included @@ -920,7 +919,7 @@ { $this->Factory->registerDependency($depended_class, $class_name); } - + /** * Registers Hook from subprefix event to master prefix event * @@ -941,7 +940,7 @@ $event_manager =& $this->recallObject('EventManager'); $event_manager->registerHook($hookto_prefix, $hookto_special, $hookto_event, $mode, $do_prefix, $do_special, $do_event, $conditional); } - + /** * Allows one TagProcessor tag act as other TagProcessor tag * @@ -953,7 +952,7 @@ $aggregator =& $this->recallObject('TagsAggregator', 'kArray'); $aggregator->SetArrayValue($tag_info['AggregateTo'], $tag_info['AggregatedTagName'], Array($tag_info['LocalPrefix'], $tag_info['LocalTagName'], getArrayValue($tag_info, 'LocalSpecial'))); } - + /** * Returns object using params specified, * creates it if is required @@ -966,11 +965,11 @@ */ function &recallObject($name,$pseudo_class=null,$event_params=Array()) { - $func_args =& func_get_args(); + $func_args = func_get_args(); $result =& ref_call_user_func_array( Array(&$this->Factory, 'getObject'), $func_args ); return $result; } - + /** * Checks if object with prefix passes was already created in factory * @@ -982,7 +981,7 @@ { return isset($this->Factory->Storage[$name]); } - + /** * Removes object from storage by given name * @@ -993,7 +992,7 @@ { $this->Factory->DestroyObject($name); } - + /** * Get's real class name for pseudo class, * includes class file and creates class @@ -1006,12 +1005,12 @@ */ function &makeClass($pseudo_class) { - $func_args =& func_get_args(); + $func_args = func_get_args(); $result =& ref_call_user_func_array( Array(&$this->Factory, 'makeClass'), $func_args); - + return $result; } - + /** * Checks if application is in debug mode * @@ -1023,7 +1022,7 @@ { return defined('DEBUG_MODE') && DEBUG_MODE; } - + /** * Checks if it is admin * @@ -1034,7 +1033,7 @@ { return defined('ADMIN') && ADMIN; } - + /** * Reads unit (specified by $prefix) * option specified by $option @@ -1050,7 +1049,7 @@ $unit_config_reader =& $this->recallObject('kUnitConfigReader'); return $unit_config_reader->getUnitOption($prefix,$option); } - + /** * Set's new unit option value * @@ -1065,7 +1064,7 @@ $unit_config_reader =& $this->recallObject('kUnitConfigReader'); return $unit_config_reader->setUnitOption($prefix,$option,$value); } - + /** * Read all unit with $prefix options * @@ -1079,7 +1078,7 @@ $unit_config_reader =& $this->recallObject('kUnitConfigReader'); return $unit_config_reader->getUnitOptions($prefix); } - + /** * Returns true if config exists and is allowed for reading * @@ -1091,7 +1090,7 @@ $unit_config_reader =& $this->recallObject('kUnitConfigReader'); return $unit_config_reader->prefixRegistred($prefix); } - + /** * Splits any mixing of prefix and * special into correct ones @@ -1105,7 +1104,7 @@ { return $this->Factory->processPrefix($prefix_special); } - + /** * Set's new event for $prefix_special * passed @@ -1119,8 +1118,8 @@ $event_manager =& $this->recallObject('EventManager'); $event_manager->setEvent($prefix_special,$event_name); } - - + + /** * SQL Error Handler * @@ -1133,19 +1132,19 @@ */ function handleSQLError($code,$msg,$sql) { - global $debugger; + global $debugger; if($debugger) { $errorLevel=defined('DBG_SQL_FAILURE') && DBG_SQL_FAILURE ? E_USER_ERROR : E_USER_WARNING; $debugger->dumpVars($_REQUEST); $debugger->appendTrace(); - + $error_msg = ''.$msg.' ('.$code.')
SQL: '.$debugger->formatSQL($sql); $long_id=$debugger->mapLongError($error_msg); trigger_error( substr($msg.' ('.$code.') ['.$sql.']',0,1000).' #'.$long_id, $errorLevel); return true; } - else + else { //$errorLevel = defined('IS_INSTALL') && IS_INSTALL ? E_USER_WARNING : E_USER_ERROR; $errorLevel = E_USER_WARNING; @@ -1155,7 +1154,7 @@ return $errorLevel == E_USER_ERROR ? false : true; } } - + /** * Default error handler * @@ -1174,9 +1173,9 @@ fwrite($fp, '['.$time.'] #'.$errno.': '.strip_tags($errstr).' in ['.$errfile.'] on line '.$errline."\n"); fclose($fp); } - + if( !$this->errorHandlers ) return true; - + $i = 0; // while (not foreach) because it is array of references in some cases $eh_count = count($this->errorHandlers); while($i < $eh_count) @@ -1195,7 +1194,7 @@ $i++; } } - + /** * Returns & blocks next ResourceId available in system * @@ -1211,7 +1210,7 @@ $this->DB->Query('UNLOCK TABLES'); return $id; } - + /** * Returns main prefix for subtable prefix passes * @@ -1227,8 +1226,8 @@ $current_prefix = $parent_prefix; } return $current_prefix; - } - + } + function EmailEventAdmin($email_event_name, $to_user_id = -1, $send_params = false) { return $this->EmailEvent($email_event_name, 1, $to_user_id, $send_params); @@ -1238,7 +1237,7 @@ { return $this->EmailEvent($email_event_name, 0, $to_user_id, $send_params); } - + function EmailEvent($email_event_name, $email_event_type, $to_user_id = -1, $send_params = false) { $event = new kEvent('emailevents:OnEmailEvent'); @@ -1253,7 +1252,7 @@ return $event; } - + function LoggedIn() { $user =& $this->recallObject('u'); @@ -1268,7 +1267,7 @@ } if( $cat_id == 0 ) { - $cat_hierarchy = Array(0); + $cat_hierarchy = Array(0); } else { @@ -1280,9 +1279,9 @@ $cat_hierarchy = array_reverse($cat_hierarchy); array_push($cat_hierarchy, 0); } - + $groups = $this->RecallVar('UserGroups'); - + foreach($cat_hierarchy as $category_id) { $sql = 'SELECT PermissionValue FROM '.TABLE_PREFIX.'Permissions @@ -1295,10 +1294,10 @@ return $res; } } - + return 0; } - + /** * Set's any field of current visit * @@ -1311,7 +1310,7 @@ $visit->SetDBField($field, $value); $visit->Update(); } - + } ?> \ No newline at end of file Index: trunk/core/kernel/parser/template_parser.php =================================================================== diff -u -N -r2596 -r2600 --- trunk/core/kernel/parser/template_parser.php (.../template_parser.php) (revision 2596) +++ trunk/core/kernel/parser/template_parser.php (.../template_parser.php) (revision 2600) @@ -354,7 +354,6 @@ } $tname = $template_cache->GetRealFilename($this->TemplateName).'.tpl'; - $output = ''; $is_cached = false; ob_start(); Index: trunk/core/kernel/utility/http_query.php =================================================================== diff -u -N -r2416 -r2600 --- trunk/core/kernel/utility/http_query.php (.../http_query.php) (revision 2416) +++ trunk/core/kernel/utility/http_query.php (.../http_query.php) (revision 2600) @@ -8,7 +8,7 @@ * @access private */ var $Post; - + /** * $_GET vars * @@ -23,44 +23,44 @@ * @access private */ var $Cookie; - + /** * $_SERVER vars * * @var Array * @access private */ var $Server; - + /** * $_ENV vars * * @var Array * @access private */ var $Env; - + /** * Order in what write * all vars together in - * the same array + * the same array * * @var string */ var $Order; - + /** * Uploaded files info * * @var Array * @access private */ var $Files; - + var $specialsToRemove = Array(); - + var $Admin = false; - + /** * Loads info from $_POST, $_GET and * related arrays into common place @@ -75,15 +75,15 @@ $this->Order = $order; $this->Admin = defined('ADMIN') && ADMIN; $this->AddAllVars(); - + $this->specialsToRemove = $this->Get('remove_specials'); if($this->specialsToRemove) { $this->_Params = $this->removeSpecials($this->_Params); } ini_set('magic_quotes_gpc', 0); } - + function removeSpecials($array) { $ret = Array(); @@ -102,7 +102,7 @@ } return $removed ? $ret : $array; } - + /** * All all requested vars to * common storage place @@ -139,34 +139,34 @@ } } } - + function convertFiles() { if (!$_FILES) { return false; } - + $file_keys = Array('error','name','size','tmp_name','type'); - + $tmp = Array(); foreach($_FILES as $file_name => $file_info) { if( is_array($file_info['error']) ) { $tmp[$file_name] = $this->getArrayLevel( $file_info['error'], $file_name ); } - else + else { $normal_files[$file_name] = $file_info; } } - + if(!$tmp) return false; - + $files = $_FILES; - $_FILES = Array(); - + $_FILES = Array(); + foreach($tmp as $prefix => $prefix_files) { $anchor =& $_FILES; @@ -182,7 +182,7 @@ foreach($file_keys as $file_key) { $inner_anchor =& $files[$prefix][$file_key]; - if (isset($copy)) + if (isset($copy)) { $work_copy = $copy; } @@ -193,40 +193,40 @@ array_shift($work_copy); foreach($work_copy as $prefix_file_key) { - $inner_anchor =& $inner_anchor[$prefix_file_key]; + $inner_anchor =& $inner_anchor[$prefix_file_key]; } $anchor[$field_name][$file_key] = $inner_anchor[$field_name]; } } } - + // keys: img_temp, 0, values: LocalPath, ThumbPath } - + function getArrayLevel(&$level, $prefix='') { $ret['keys'] = $prefix ? Array($prefix) : Array(); - $ret['value'] = Array(); - + $ret['value'] = Array(); + foreach($level as $level_key => $level_value) { if( is_array($level_value) ) { $ret['keys'][] = $level_key; $tmp = $this->getArrayLevel($level_value); - + $ret['keys'] = array_merge($ret['keys'], $tmp['keys']); $ret['value'] = array_merge($ret['value'], $tmp['value']); } else { - $ret['value'][] = $level_key; + $ret['value'][] = $level_key; } } - + return $ret; } - + /** * Owerwrites GET events with POST events in case if they are set and not empty * @@ -254,8 +254,9 @@ function processQueryString() { // env=SID:TEMPLATE:m-1-1-1-1:l0-0-0:n-0-0-0:bb-0-0-1-1-1-0 - - $env_var =& $this->Get(ENV_VAR_NAME); + + + $env_var = $this->Get(ENV_VAR_NAME); if($env_var) { $sid = $this->Get('sid'); @@ -268,23 +269,23 @@ $env_var = rtrim( implode($split_by, $env_var), '/'); } $env_var = str_replace('\:','_&+$$+&_',$env_var); // replace escaped "=" with spec-chars :) - + $parts=explode(':',$env_var); - + if (defined('MOD_REWRITE') && MOD_REWRITE) $env_var = str_replace('/', ':', $env_var); - + if (defined('INPORTAL_ENV')) { $sub_parts = array_shift($parts); - + list($sid, $t) = explode('-', $sub_parts, 2); - - + + // Save Session ID if($sid) { $this->Set('sid',$sid); $this->Get['sid'] = $sid; } - + // Save Template Name $t=$this->getTemplateName( trim($t, '/') ); if(!$t) $t='index'; @@ -294,7 +295,7 @@ // Save Session ID $sid=array_shift($parts); if($sid) $this->Set('sid',$sid); - + // Save Template Name $t=$this->getTemplateName( array_shift($parts) ); if(!$t) $t='index'; @@ -305,28 +306,28 @@ { $query_maps=Array(); $event_manger =& $this->Application->recallObject('EventManager'); - + $passed = Array(); - + foreach($parts as $mixed_part) { //In-portal old style env conversion - adds '-' between prefix and first var $mixed_part = str_replace('_&+$$+&_',':',$mixed_part); - $mixed_part = preg_replace("/^([a-zA-Z]+)([0-9]+)-(.*)/", "$1-$2-$3", $mixed_part); - + $mixed_part = preg_replace("/^([a-zA-Z]+)([0-9]+)-(.*)/", "$1-$2-$3", $mixed_part); + $escaped_part = str_replace('\-', '_&+$$+&_', $mixed_part); $escaped_part = explode('-', $escaped_part); - + $mixed_part = array(); foreach ($escaped_part as $escaped_val) { $mixed_part[] = str_replace('_&+$$+&_', '-', $escaped_val); } - + $prefix_special=array_shift($mixed_part); // l.pick, l list($prefix)=explode('.',$prefix_special); - + $query_maps[$prefix_special]=$this->Application->getUnitOption($prefix,'QueryString'); - + // if config is not defined for prefix in QueryString, then don't process it if( $query_maps[$prefix_special] ) { @@ -343,7 +344,7 @@ { unset($query_maps[$prefix_special]); } - + } $this->Set('passed', implode(',', $passed)); $event_manger->setQueryMaps($query_maps); @@ -355,7 +356,7 @@ $this->Set('t',$t); } } - + /** * Decides what template name to * use from $_GET or from $_POST @@ -368,16 +369,16 @@ { $t_from_post = $this->Get('t'); $t= $t_from_post ? $t_from_post : $querystring_template; - + if ( is_numeric($t) ) { - $t = $this->Application->DB->GetOne('SELECT CONCAT(FilePath, \'/\', FileName) FROM '.TABLE_PREFIX.'ThemeFiles + $t = $this->Application->DB->GetOne('SELECT CONCAT(FilePath, \'/\', FileName) FROM '.TABLE_PREFIX.'ThemeFiles WHERE FileId = '.$t); } $t = preg_replace("/\.tpl$/", '', $t); - + return $t; } - + /** * Saves variables from array specified * into common variable storage place @@ -395,7 +396,7 @@ } return $array; } - + function MergeVars($array, $strip_slashes=true) { if ($strip_slashes) $array = $this->StripSlashes($array); @@ -405,7 +406,7 @@ } return $array; } - + function StripSlashes($array) { //if( !get_magic_quotes_gpc() ) return $array; @@ -425,7 +426,7 @@ } return $array; } - + /** * Returns the hash of http params * matching the mask with values @@ -438,7 +439,7 @@ { return $this->Application->ExtractByMask($this->Vars, $mask); } - + /** * Returns the sprintf'ed by format list of * http params matching the mask and set to on @@ -455,13 +456,13 @@ foreach ($this->GetParams() as $name => $val) { if (eregi($mask, $name, $regs) && $val == 'on') { - + $result.= sprintf($format, $regs[1]); } } return $result; } - + /** * Returns the sprintf'ed by format list of * http params matching the mask and set to on Index: trunk/core/kernel/utility/unit_config_reader.php =================================================================== diff -u -N -r2596 -r2600 --- trunk/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 2596) +++ trunk/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 2600) @@ -1,7 +1,7 @@ Application->GetADODBConnection(); $this->modules_installed = $db->GetCol('SELECT CONCAT(\'/\',Path) AS Path, Name FROM '.TABLE_PREFIX.'Modules WHERE Loaded = 1','Name'); $this->scanModules(MODULES_PATH); } - + /** * Checks if config file is allowed for includion (if module of config is installed) * @@ -49,12 +49,12 @@ if( substr($config_path, 0, strlen($module_path)) == $module_path ) { $module_found = true; - break; + break; } } return $module_found; } - + /** * Returns true if config exists and is allowed for reading * @@ -65,7 +65,7 @@ { return isset($this->configData[$prefix]) ? true : false; } - + /** * Read configs from all directories * on path specified @@ -86,9 +86,9 @@ $file = $this->getConfigName($full_path); if ( defined('DEBUG_MODE') && dbg_ConstOn('DBG_PROFILE_INCLUDES')) { - + if ( in_array($file, get_required_files()) ) return; - global $debugger; + global $debugger; $debugger->IncludeLevel++; $before_time = getmicrotime(); $before_mem = memory_get_usage(); @@ -104,23 +104,23 @@ else { include_once($file); } - + $prefix=$config['Prefix']; $config['BasePath']=$full_path; $this->configData[$prefix] = $config; } } } } - + function ParseConfigs() { foreach ($this->configData as $prefix => $config) { $this->parseConfig($prefix); } } - + function findConfigFiles($folderPath) { $folderPath = str_replace(DOC_ROOT.BASE_PATH, '', $folderPath); @@ -134,20 +134,20 @@ $this->configFiles[] = $this->getConfigName($folderPath.'/'.$sub_folder); } $this->findConfigFiles($full_path); - + // if (filemtime($full_path) > $cached) { } - + } } } - + function includeConfigFiles() { $db =& $this->Application->GetADODBConnection(); - + foreach ($this->configFiles as $filename) { - $config_found = file_exists(DOC_ROOT.BASE_PATH.$filename) && $this->configAllowed($filename); + $config_found = file_exists(FULL_PATH.$filename) && $this->configAllowed($filename); if( defined('DEBUG_MODE') && DEBUG_MODE && dbg_ConstOn('DBG_PROFILE_INCLUDES')) { if ( in_array($filename, get_required_files()) ) return; @@ -166,22 +166,22 @@ } else { - if($config_found) include_once(DOC_ROOT.BASE_PATH.$filename); + if($config_found) include_once(FULL_PATH.$filename); } - + if($config_found) { $prefix = $config['Prefix']; - $config['BasePath'] = dirname(DOC_ROOT.BASE_PATH.$filename); + $config['BasePath'] = dirname(FULL_PATH.$filename); $this->configData[$prefix] = $config; } } } - + function scanModules($folderPath) { global $debugger; - + if (defined('CACHE_CONFIGS_FILES')) { $conn =& $this->Application->GetADODBConnection(); $data = $conn->GetRow('SELECT Data, Cached FROM '.TABLE_PREFIX.'Cache WHERE VarName = "config_files"'); @@ -190,14 +190,13 @@ $files_cached = $data['Cached']; } else { - $files_cached = 0; + $files_cached = 0; } } else { $files_cached = 0; } - - + if (defined('CACHE_CONFIGS_DATA') && CACHE_CONFIGS_DATA) { $conn =& $this->Application->GetADODBConnection(); $data = $conn->GetRow('SELECT Data, Cached FROM '.TABLE_PREFIX.'Cache WHERE VarName = "config_data"'); @@ -206,21 +205,21 @@ $data_cached = $data['Cached']; } else { - $data_cached = 0; + $data_cached = 0; } } else { $data_cached = 0; } - + if ( !defined('CACHE_CONFIGS_FILES') || $files_cached == 0 ) { $this->findConfigFiles($folderPath); } - + if ( !defined('CACHE_CONFIGS_DATA') || $data_cached == 0) { $this->includeConfigFiles(); } - + /*// && (time() - $cached) > 600) - to skip checking files modified dates if ( !defined('CACHE_CONFIGS') ) { $fh=opendir($folderPath); @@ -233,22 +232,22 @@ } } }*/ - + if (defined('CACHE_CONFIGS_DATA') && $data_cached == 0) { $conn->Query('REPLACE '.TABLE_PREFIX.'Cache (VarName, Data, Cached) VALUES ("config_data", '.$conn->qstr(serialize($this->configData)).', '.time().')'); } - + $this->ParseConfigs(); - + if (defined('CACHE_CONFIGS_FILES') && $files_cached == 0) { $conn->Query('REPLACE '.TABLE_PREFIX.'Cache (VarName, Data, Cached) VALUES ("config_files", '.$conn->qstr(serialize($this->configFiles)).', '.time().')'); } - + unset($this->configFiles); // unset($this->configData); - + } - + /** * Register nessasary classes * @@ -269,7 +268,7 @@ $config['BasePath'].'/'.$class_info['file'], $pseudo_class); $event_manager->registerBuildEvent($pseudo_class,$class_info['build_event']); - + // register classes on which current class depends $require_classes = getArrayValue($class_info, 'require_classes'); if($require_classes) @@ -280,7 +279,7 @@ } } } - + $register_classes = getArrayValue($config,'RegisterClasses'); if($register_classes) { @@ -289,41 +288,41 @@ $this->Application->registerClass( $class_info['class'], $config['BasePath'].'/'.$class_info['file'], $class_info['pseudo']); - } + } } - + $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'] ); - } + } } - + if ( is_array(getArrayValue($config, 'Hooks')) ) { foreach ($config['Hooks'] as $hook) { $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']); + $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); + $this->Application->registerAggregateTag($aggregate_tag); } } - + if ( $this->Application->isDebugMode() && dbg_ConstOn('DBG_VALIDATE_CONFIGS') && isset($config['TableName']) ) { global $debugger; @@ -357,7 +356,7 @@ } } } - + /** * Reads unit (specified by $prefix) * option specified by $option @@ -371,7 +370,7 @@ { return isset($this->configData[$prefix][$name]) ? $this->configData[$prefix][$name] : false; } - + /** * Read all unit with $prefix options * @@ -383,7 +382,7 @@ { return $this->prefixRegistred($prefix) ? $this->configData[$prefix] : false; } - + /** * Set's new unit option value * @@ -396,7 +395,7 @@ { $this->configData[$prefix][$name] = $value; } - + function getPrefixByParamName($paramName,$prefix) { $pseudo_class_map=Array( @@ -405,9 +404,9 @@ 'EventHandlerClass'=>'%s_EventHandler', 'TagProcessorClass'=>'%s_TagProcessor' ); - return sprintf($pseudo_class_map[$paramName],$prefix); + return sprintf($pseudo_class_map[$paramName],$prefix); } - + /** * Get's config file name based * on folder name supplied @@ -420,7 +419,7 @@ { return $folderPath.'/'.basename($folderPath).'_config.php'; } - + /** * is_dir ajustment to work with * directory listings too @@ -435,9 +434,9 @@ $ret=!($base_name=='.'||$base_name=='..'); return $ret&&is_dir($folderPath); } - - + + } - + ?> \ No newline at end of file Index: trunk/core/kernel/utility/factory.php =================================================================== diff -u -N -r2597 -r2600 --- trunk/core/kernel/utility/factory.php (.../factory.php) (revision 2597) +++ trunk/core/kernel/utility/factory.php (.../factory.php) (revision 2600) @@ -1,15 +1,15 @@ $regs[1].$regs[3].$regs[4], 'special'=>$regs[2]); - + $tmp=explode('_',$prefix_special,2); $tmp[0]=explode('.',$tmp[0]); @@ -65,8 +65,8 @@ $prefix_special.='.'.$special; // new2 return Array('prefix'=>$prefix,'special'=>$special,'prefix_special'=>$prefix_special); } - - + + /** * Returns object using params specified, * creates it if is required @@ -78,28 +78,26 @@ */ function &getObject($name,$pseudo_class='',$event_params=Array()) { - // $name = 'l.pick', $pseudo_class = 'l' - //echo 'N: '.$name.' - P: '.$pseudo_class."\n"; $ret=$this->processPrefix($name); if (!$pseudo_class) $pseudo_class = $ret['prefix']; $name=rtrim($name,'.'); if( isset($this->Storage[$name]) ) return $this->Storage[$name]; - + if(!isset($this->realClasses[$pseudo_class])) { if( $this->Application->isDebugMode() ) $GLOBALS['debugger']->appendTrace(); - trigger_error('RealClass not defined for pseudo_class '.$pseudo_class.'', E_USER_ERROR); + trigger_error('RealClass not defined for pseudo_class '.$pseudo_class.'', E_USER_ERROR); } - + $funs_args = func_get_args(); array_splice($funs_args, 0, 3, Array($pseudo_class) ); - + $this->Storage[$name] =& ref_call_user_func_array( Array(&$this,'makeClass'), $funs_args); $this->Storage[$name]->Init($ret['prefix'],$ret['special'],$event_params); - + $prefix=$this->Storage[$name]->Prefix; $special=$this->Storage[$name]->Special; - + $event_manager =& $this->getObject('EventManager'); $event =& $event_manager->getBuildEvent($pseudo_class); if($event) @@ -111,21 +109,21 @@ } $this->Application->HandleEvent($event); } - + return $this->Storage[$name]; } - - + + /** * Removes object from storage, so next time it could be created from scratch * * @param string $name Object's name in the Storage */ function DestroyObject($name) { - unset($this->Storage[$name]); + unset($this->Storage[$name]); } - + /** * Includes file containing class * definition for real class name @@ -136,21 +134,20 @@ function includeClassFile($real_class) { if (class_exists($real_class)) return; - if(!$this->Files[$real_class]) trigger_error('Real Class '.$real_class.' is not registered with the Factory', E_USER_ERROR); if(!file_exists($this->Files[$real_class])) trigger_error('Include file for class '.$real_class.' ('.$this->Files[$real_class].') does not exists', E_USER_ERROR); - + if( $deps = getArrayValue($this->Dependencies, $real_class) ) { foreach($deps as $dep_class_name) { $this->includeClassFile($dep_class_name); } } - + k4_include_once($this->Files[$real_class]); } - + /** * Get's real class name for pseudo class, * includes class file and creates class @@ -166,22 +163,20 @@ { $real_class = $this->realClasses[$pseudo_class]; $this->includeClassFile($real_class); - + $mem_before = memory_get_usage(); $time_before = getmicrotime(); - + if( func_num_args() == 1 ) { - $class = new $real_class(); + $class = new $real_class(); } else { $func_args = func_get_args(); $pseudo_class = array_shift($func_args); - $class =& ref_call_user_func_array( Array($real_class,'makeClass'), $func_args ); } - if( $this->Application->isDebugMode() && dbg_ConstOn('DBG_PROFILE_MEMORY') ) { $mem_after = memory_get_usage(); @@ -194,11 +189,11 @@ } return $class; } - + /** * Registers new class in the factory * - * @param string $real_class Real name of class as in class declaration + * @param string $real_class Real name of class as in class declaration * @param string $file Filename in what $real_class is declared * @param string $pseudo_class Name under this class object will be accessed using getObject method * @param Array $dependecies List of classes required for this class functioning @@ -208,23 +203,22 @@ { if(!isset($pseudo_class)) $pseudo_class = $real_class; if(!isset($this->Files[$real_class])) $this->Files[$real_class]=$file; - + if( getArrayValue($this->realClasses, $pseudo_class) ) { $this->registerDependency($real_class, $pseudo_class); } - if($dependecies) { foreach($dependecies as $required_class) { $this->registerDependency($real_class, $required_class); } } - + $this->realClasses[$pseudo_class]=$real_class; } - + /** * Add $class_name to required classes list for $depended_class class. * All required class files are included before $depended_class file is included @@ -237,7 +231,6 @@ { $this->Dependencies[$depended_class][] = $this->realClasses[$class_name]; } - } ?> \ No newline at end of file Index: trunk/kernel/units/themes/themes_tag_processor.php =================================================================== diff -u -N -r2469 -r2600 --- trunk/kernel/units/themes/themes_tag_processor.php (.../themes_tag_processor.php) (revision 2469) +++ trunk/kernel/units/themes/themes_tag_processor.php (.../themes_tag_processor.php) (revision 2600) @@ -1,22 +1,22 @@ Application->recallObject( $this->getPrefixSpecial(), $this->Prefix, $params ); - + $css_url = $this->Application->BaseURL('/kernel/stylesheets'); - $css_path = rtrim( str_replace( $this->Application->BaseURL(), DOC_ROOT.BASE_PATH.'/', $css_url), '/' ); - + $css_path = rtrim( str_replace( $this->Application->BaseURL(), FULL_PATH.'/', $css_url), '/' ); + $last_compiled = $object->GetDBField('LastCompiled'); - + $style_name = strtolower( $object->GetDBField('StyleName') ); - + if( file_exists($css_path.'/'.$style_name.'-'.$last_compiled.'.css') ) { $ret = $css_url.'/'.$style_name.'-'.$last_compiled.'.css'; - + } else { @@ -34,9 +34,9 @@ } if($last_compiled) $ret = $css_url.'/'.$style_name.'-'.$last_compiled.'.css'; } - + if (isset($params['file_only'])) return $ret; - + return ''; } } Index: trunk/core/kernel/event_manager.php =================================================================== diff -u -N -r2592 -r2600 --- trunk/core/kernel/event_manager.php (.../event_manager.php) (revision 2592) +++ trunk/core/kernel/event_manager.php (.../event_manager.php) (revision 2600) @@ -2,20 +2,20 @@ 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 @@ -24,7 +24,7 @@ * @var Array */ var $queryMaps=Array(); - + /** * Build events registred for * pseudo classes. key - pseudo class @@ -34,22 +34,22 @@ * @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) @@ -59,7 +59,7 @@ * @access private */ var $beforeHooks=Array(); - + /** * Holds after hooks * key - prefix.event (to link to) @@ -69,13 +69,13 @@ * @access private */ var $afterHooks = Array(); - + function kEventManager() { parent::kBase(); $this->Conn =& $this->Application->GetADODBConnection(); } - + /** * Set's new enviroment parameter mappings * between their names as application vars @@ -87,7 +87,7 @@ { $this->queryMaps=$new_query_maps; } - + /** * Registers new regular event * @@ -107,12 +107,12 @@ $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 @@ -123,14 +123,15 @@ */ function &getBuildEvent($pseudo_class) { - if( !isset($this->buildEvents[$pseudo_class]) ) return false; - + $false = false; + if( !isset($this->buildEvents[$pseudo_class]) ) return $false; + $event = new kEvent(); $event->Name=$this->buildEvents[$pseudo_class]; $event->MasterEvent=null; return $event; } - + /** * Allows to process any type of event * @@ -144,40 +145,40 @@ trigger_error('Prefix '.$event->Prefix.' not registred (requested event '.$event->Name.')', 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); } - + 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($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'])) { - $events[$prefix_special]=$this->Application->GetVar($prefix_special.'_event'); + $events[$prefix_special]=$this->Application->GetVar($prefix_special.'_event'); } } $actions = $this->Application->GetVar('do'); @@ -186,7 +187,7 @@ $events[$prefix] = $event_name; } } - + $passed = explode(',', $this->Application->GetVar('passed')); foreach($events as $prefix_special => $event_name) { @@ -197,30 +198,30 @@ $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; $this->HandleEvent($event); - + if($event->status==erSUCCESS && ($event->redirect === true || strlen($event->redirect) > 0) ) { - $this->Application->Redirect($event->redirect, $event->redirect_params, null, $event->redirect_script); + $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'); @@ -231,7 +232,7 @@ 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') ); @@ -240,18 +241,18 @@ 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; - + default: // "s/0," stay on same deep level break; } $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) ) @@ -280,7 +281,7 @@ ); } } - + /** * Enter description here... * @@ -302,12 +303,12 @@ 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 @@ -321,7 +322,7 @@ $actions =& $this->Application->recallObject('kActions'); $actions->Set('events['.$prefix_special.']',$event_name); } - + /** * Run registred regular events with specified event type * @@ -330,16 +331,16 @@ function RunRegularEvents($event_type = reBEFORE) { $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); @@ -353,9 +354,9 @@ $event->redirect = false; $this->Application->HandleEvent($event); $event_last_runs[$short_name] = 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)), mktime() ) ); } Index: trunk/core/kernel/utility/filters.php =================================================================== diff -u -N -r2592 -r2600 --- trunk/core/kernel/utility/filters.php (.../filters.php) (revision 2592) +++ trunk/core/kernel/utility/filters.php (.../filters.php) (revision 2600) @@ -1,10 +1,10 @@ setType($type); } - + /** * Enter description here... * @@ -40,7 +38,7 @@ { $this->type = $new_type; } - + /** * Adds new or replaces old filter with same name * @@ -52,14 +50,14 @@ { if( is_object($clause) && $clause->hasFilters() ) { - $this->filters[$name] = $clause->getSQL(); + $this->filters[$name] = $clause->getSQL(); } elseif( !is_object($clause) && strlen($clause) ) { $this->filters[$name] = $clause; } } - + /** * Removes specified filter from filters list * @@ -70,7 +68,7 @@ { unset($this->filters[$name]); } - + /** * Remove all added filters * @@ -80,7 +78,7 @@ { $this->filters = Array(); } - + /** * Build where clause based on added filters and multiple filter type * @@ -91,10 +89,10 @@ { $filter_count = count($this->filters); if(!$filter_count) return ''; - + return '('.implode(') '.$this->type.' (',$this->filters).')'; } - + /** * Allows to check if some filters are added to multiple filter * Index: trunk/core/units/themes/themes_tag_processor.php =================================================================== diff -u -N -r2469 -r2600 --- trunk/core/units/themes/themes_tag_processor.php (.../themes_tag_processor.php) (revision 2469) +++ trunk/core/units/themes/themes_tag_processor.php (.../themes_tag_processor.php) (revision 2600) @@ -1,22 +1,22 @@ Application->recallObject( $this->getPrefixSpecial(), $this->Prefix, $params ); - + $css_url = $this->Application->BaseURL('/kernel/stylesheets'); - $css_path = rtrim( str_replace( $this->Application->BaseURL(), DOC_ROOT.BASE_PATH.'/', $css_url), '/' ); - + $css_path = rtrim( str_replace( $this->Application->BaseURL(), FULL_PATH.'/', $css_url), '/' ); + $last_compiled = $object->GetDBField('LastCompiled'); - + $style_name = strtolower( $object->GetDBField('StyleName') ); - + if( file_exists($css_path.'/'.$style_name.'-'.$last_compiled.'.css') ) { $ret = $css_url.'/'.$style_name.'-'.$last_compiled.'.css'; - + } else { @@ -34,9 +34,9 @@ } if($last_compiled) $ret = $css_url.'/'.$style_name.'-'.$last_compiled.'.css'; } - + if (isset($params['file_only'])) return $ret; - + return ''; } } Index: trunk/core/kernel/parser/template.php =================================================================== diff -u -N -r2374 -r2600 --- trunk/core/kernel/parser/template.php (.../template.php) (revision 2374) +++ trunk/core/kernel/parser/template.php (.../template.php) (revision 2600) @@ -14,7 +14,7 @@ } } } - + function SetBasePath($base_path=null) { if (isset($base_path)) { @@ -24,20 +24,20 @@ } return false; } - + function GetFullPath() { return $this->BasePath.'/'.$this->Filename.'.tpl'; } - + function LoadTemplate($silent=0) { $filename = $this->GetFullPath(); if(file_exists($filename)) { if (filesize ($filename) == 0) { trigger_error("Template file size is 0: $filename", ($silent ? E_USER_NOTICE : E_USER_ERROR) ); } - + $handle = fopen ($filename, "r"); $contents = fread ($handle, filesize ($filename)); $this->SetBody($contents); @@ -51,12 +51,12 @@ return false; } } - + function SetBody($body) { $this->Body = $body; } - + function GetBody() { return $this->Body; @@ -67,32 +67,32 @@ var $Templates = Array(); var $BasePath; var $FileNames = Array(); - + var $ModulesCache = Array(); - + function TemplatesCache() { parent::kBase(); $this->SetThemePath(); - $this->BasePath = DOC_ROOT.BASE_PATH.THEMES_PATH; - + $this->BasePath = FULL_PATH.THEMES_PATH; + $conn =& $this->Application->GetADODBConnection(); $this->ModulesCache = $conn->GetCol('SELECT LOWER(Name) FROM '.TABLE_PREFIX.'Modules'); } - + function SetThemePath() { if ( defined('SPECIAL_TEMPLATES_FOLDER') ) { - safeDefine( 'THEMES_PATH', preg_replace('/'.preg_quote(rtrim(DOC_ROOT.BASE_PATH, '/'), '/').'/i','',str_replace('\\', '/', FULL_PATH)). SPECIAL_TEMPLATES_FOLDER ); + safeDefine( 'THEMES_PATH', preg_replace('/'.preg_quote(rtrim(FULL_PATH, '/'), '/').'/i','',str_replace('\\', '/', FULL_PATH)). SPECIAL_TEMPLATES_FOLDER ); } else { $current_theme = $this->Application->GetVar('m_theme'); $folder = $this->Application->DB->GetOne('SELECT Name FROM '.TABLE_PREFIX.'Theme WHERE ThemeId = '.$current_theme); - - safeDefine( 'THEMES_PATH', preg_replace('/'.preg_quote(rtrim(DOC_ROOT.BASE_PATH, '/'), '/').'/i','',str_replace('\\', '/', FULL_PATH)). ( defined('ADMIN') ? '/admin/templates' : '/themes/'.$folder)); + + safeDefine( 'THEMES_PATH', preg_replace('/'.preg_quote(rtrim(FULL_PATH, '/'), '/').'/i','',str_replace('\\', '/', FULL_PATH)). ( defined('ADMIN') ? '/admin/templates' : '/themes/'.$folder)); } } - + function LoadTemplate($filename, $title=NULL, $silent=0) { if (preg_match('#^[\/]{0,1}([^\/]*)\/(.*)#', $filename, $regs)) { @@ -103,20 +103,20 @@ $first_dir = ''; $module_filename = $filename; } - + if ( defined('ADMIN') && ADMIN && in_array(strtolower($first_dir), $this->ModulesCache)) { $path = MODULES_PATH.'/'.strtolower($first_dir).'/admin_templates'; } else { $path = $this->BasePath; $module_filename = $first_dir.'/'.$module_filename; } - + $template =& new Template($path, $module_filename, $silent); if (!isset($title)) $title = $filename; $this->SetTemplate($title, $template); } - + function GetRealFilename($filename, $base=null) { if (preg_match('#^[\/]{0,1}([^\/]*)\/(.*)#', $filename, $regs)) { $module_filename = $regs[2]; @@ -126,7 +126,7 @@ $first_dir = ''; $module_filename = $filename; } - + if ( defined('ADMIN') && ADMIN && in_array(strtolower($first_dir), $this->ModulesCache)) { $path = MODULES_PATH.'/'.strtolower($first_dir).'/admin_templates'; } @@ -136,22 +136,22 @@ } return $path.'/'.$module_filename; } - + function SetTemplate($title, &$template, $filename=null) { if (!isset($filename)) $filename=$title; $this->Templates[$title] = $template; $this->FileNames[$title] = $filename; } - + function &GetTemplate($title, $silent=0) { if (!isset($this->Templates[$title])) { $this->LoadTemplate($title, null, $silent); } return $this->Templates[$title]; } - + function GetTemplateBody($title, $silent=0) { $template =& $this->GetTemplate($title, $silent); @@ -160,25 +160,25 @@ } return $template->GetBody(); } - + function GetTemplateFileName($title) { return $this->FileNames[$title]; } - + function SetTemplateBody($title, $body) { $template =& new Template(); $template->SetBody($body); $this->SetTemplate($title, $template); } - + function ParseTemplate($template_name) { $Parser =& new TemplateParser($this->Application); return $Parser->Parse( $this->GetTemplateBody($template_name) ); } - + function TemplateExists($filename) { if (!preg_match("/\.tpl$/", $filename)) $filename .= '.tpl';