Index: trunk/core/kernel/session/session.php =================================================================== diff -u -r937 -r939 --- trunk/core/kernel/session/session.php (.../session.php) (revision 937) +++ trunk/core/kernel/session/session.php (.../session.php) (revision 939) @@ -331,41 +331,53 @@ { if (!empty($this->CachedSID) && $use_cache) return $this->CachedSID; $http_query =& $this->Application->recallObject('HTTPQuery'); + $get_sid=$this->Application->GetVar($this->GETName); switch ($this->Mode) { case smAUTO: - if ($this->CookiesEnabled) { //Cookies has the priority - we ignore everything else - $sid = $http_query->Cookie[$this->CookieName]; - } - else { - $sid = $http_query->Get($this->GETName); - } + //Cookies has the priority - we ignore everything else + $sid=$this->CookiesEnabled?$http_query->Cookie[$this->CookieName]:$get_sid; break; case smCOOKIES_ONLY: - $sid = $http_query->Cookie[$this->CookieName]; + $sid = $http_query->Cookie[$this->CookieName]; break; case smGET_ONLY: - $sid = $http_query->Get($this->GETName); + $sid = $get_sid; break; case smCOOKIES_AND_GET: - $cookie_sid = $http_query->Cookie[$this->CookieName]; - $get_sid = $http_query->Get($this->GETName); - //both sids should match if cookies are enabled - if (!$this->CookiesEnabled || ($cookie_sid == $get_sid)) - $sid = $get_sid; //we use get here just in case cookies are disabled - else - $sid = ''; + $cookie_sid = $http_query->Cookie[$this->CookieName]; + //both sids should match if cookies are enabled + if (!$this->CookiesEnabled || ($cookie_sid == $get_sid)) + { + $sid = $get_sid; //we use get here just in case cookies are disabled + } + else + { + $sid = ''; + } break; } $this->CachedSID = $sid; return $this->CachedSID; } + /** + * Returns session id + * + * @return int + * @access public + */ function GetID() { return $this->SID; } + /** + * Generates new session id + * + * @return int + * @access private + */ function GenerateSID() { list($usec, $sec) = explode(" ",microtime()); @@ -383,6 +395,12 @@ return $this->SID; } + /** + * Set's new session id + * + * @param int $new_sid + * @access private + */ function setSID($new_sid) { $this->SID=$new_sid; @@ -421,6 +439,11 @@ ); } + /** + * Refreshes session expiration time + * + * @access private + */ function Refresh() { if ($this->CookiesEnabled) $this->SetSessionCookie(); //we need to refresh the cookie Index: trunk/core/kernel/application.php =================================================================== diff -u -r937 -r939 --- trunk/core/kernel/application.php (.../application.php) (revision 937) +++ trunk/core/kernel/application.php (.../application.php) (revision 939) @@ -165,14 +165,8 @@ // 1. to read configs before doing any recallObject $config_reader =& $this->recallObject('kUnitConfigReader'); + $this->Phrases = new PhrasesCache( $this->RecallVar('LanguageId', DEFAULT_LANGUAGE_ID) ); - // 2. to virtually create SID and T application vars just - // in case if they are needed before ProcessRequest method call - $event_manager =& $this->recallObject('EventManager'); - $event_manager->processQueryString(); - - $this->Phrases =& new PhrasesCache($this->RecallVar('LanguageId', DEFAULT_LANGUAGE_ID)); - $this->ValidateLogin(); // TODO: write that method } @@ -185,15 +179,15 @@ */ function RegisterDefaultClasses() { - $this->registerClass('Utilites',KERNEL_PATH.'/utility/utilities.php'); + //$this->registerClass('Utilites',KERNEL_PATH.'/utility/utilities.php'); $this->registerClass('HTTPQuery',KERNEL_PATH.'/utility/http_query.php'); $this->registerClass('Session',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('Configuration',KERNEL_PATH.'/utility/configuration.php'); + //$this->registerClass('Configuration',KERNEL_PATH.'/utility/configuration.php'); $this->registerClass('TemplatesCache',KERNEL_PATH.'/parser/template.php'); $this->registerClass('TemplateParser',KERNEL_PATH.'/parser/template_parser.php'); Index: trunk/core/kernel/utility/http_query.php =================================================================== diff -u -r932 -r939 --- trunk/core/kernel/utility/http_query.php (.../http_query.php) (revision 932) +++ trunk/core/kernel/utility/http_query.php (.../http_query.php) (revision 939) @@ -67,8 +67,10 @@ */ function HTTPQuery($order='CGPF') { + parent::Params(); $this->Order = $order; $this->AddAllVars(); + $this->processQueryString(); ini_set("magic_quotes_gpc", 0); } @@ -107,6 +109,75 @@ } } + /** + * Process QueryString only, create + * events, ids, based on config + * set template name and sid in + * desired application variables. + * + * @access private + */ + 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); + if($env_var) + { + $parts=explode(':',$env_var); + + // 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'; + $this->Set('t',$t); + + if($parts) + { + $query_maps=Array(); + $event_manger =& $this->Application->recallObject('EventManager'); + + foreach($parts as $mixed_part) + { + $mixed_part=explode('-',$mixed_part); + $prefix_special=array_shift($mixed_part); // l.pick, l + list($prefix)=explode('.',$prefix_special); + + $query_maps[$prefix_special]=$this->Application->getUnitOption($prefix,'QueryString'); + foreach($query_maps[$prefix_special] as $index => $var_name) + { + // l_id, l_page, l_bla-bla-bla + $this->Set($prefix_special.'_'.$var_name,$mixed_part[$index-1]); + } + } + $event_manger->setQueryMaps($query_maps); + } + } + else + { + $t=$this->getTemplateName('index'); + $this->Set('t',$t); + } + } + + /** + * Decides what template name to + * use from $_GET or from $_POST + * + * @param string $querystring_template + * @return string + * @access private + */ + function getTemplateName($querystring_template) + { + $t_from_post=$this->Get('t'); + $t=$t_from_post?$t_from_post:$querystring_template; + return $t; + } + function post_convert($array) { $out = Array(); Index: trunk/core/kernel/db/db_event_handler.php =================================================================== diff -u -r938 -r939 --- trunk/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 938) +++ trunk/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 939) @@ -360,8 +360,6 @@ $this->prepareObject(&$object,&$event); $object->setID(0); $this->Application->SetVar($event->Prefix_Special.'_SaveEvent','OnCreate'); - - $event->redirect=false; } Index: trunk/core/kernel/utility/params.php =================================================================== diff -u -r932 -r939 --- trunk/core/kernel/utility/params.php (.../params.php) (revision 932) +++ trunk/core/kernel/utility/params.php (.../params.php) (revision 939) @@ -8,7 +8,8 @@ function Params($params_str=null) { - if ($params_str != '') $this->SplitParamsStr($params_str); + parent::kBase(); + if($params_str != '') $this->SplitParamsStr($params_str); } /** Index: trunk/core/kernel/event_manager.php =================================================================== diff -u -r937 -r939 --- trunk/core/kernel/event_manager.php (.../event_manager.php) (revision 937) +++ trunk/core/kernel/event_manager.php (.../event_manager.php) (revision 939) @@ -11,7 +11,7 @@ * from config, that are represented * in enviroment variable * - * @var unknown_type + * @var Array */ var $queryMaps=Array(); @@ -45,6 +45,18 @@ */ var $afterHooks=Array(); + /** + * 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; + } + function registerBuildEvent($pseudo_class,$build_event_name) { $this->buildEvents[$pseudo_class]=$build_event_name; @@ -80,64 +92,6 @@ $event_handler->processEvent(&$event); } - function getTemplateName($querystring_template) - { - $t_from_post=$this->Application->GetVar('t'); - $t=$t_from_post?$t_from_post:$querystring_template; - return $t; - } - - /** - * Process QueryString only, create - * events, ids, based on config - * set template name and sid in - * desired application variables. - * - * @access public - */ - 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->Application->GetVar(ENV_VAR_NAME); - if($env_var) - { - $parts=explode(':',$env_var); - - // Save Session ID - $sid=array_shift($parts); - if($sid) $this->Application->SetVar('sid',$sid); - - // Save Template Name - $t=$this->getTemplateName( array_shift($parts) ); - if(!$t) $t='index'; - $this->Application->SetVar('t',$t); - - if($parts) - { - foreach($parts as $mixed_part) - { - $mixed_part=explode('-',$mixed_part); - $prefix_special=array_shift($mixed_part); // l.pick, l - list($prefix)=explode('.',$prefix_special); - - $this->queryMaps[$prefix_special]=$this->Application->getUnitOption($prefix,'QueryString'); - foreach($this->queryMaps[$prefix_special] as $index => $var_name) - { - // l_id, l_page, l_bla-bla-bla - $this->Application->SetVar($prefix_special.'_'.$var_name,$mixed_part[$index-1]); - } - } - } - } - else - { - $t=$this->getTemplateName('index'); - $this->Application->SetVar('t',$t); - } - } - - function ProcessRequest() { // 1. get events from $_POST @@ -158,7 +112,6 @@ } //print_pre($events); - //$t=$this->Application->GetVar('t'); foreach($events as $prefix_special => $event_name) { if(!$event_name) continue;