Index: trunk/core/units/general/xml_helper.php =================================================================== diff -u -N -r4358 -r4418 --- trunk/core/units/general/xml_helper.php (.../xml_helper.php) (revision 4358) +++ trunk/core/units/general/xml_helper.php (.../xml_helper.php) (revision 4418) @@ -10,6 +10,12 @@ */ var $CurrentElement = null; + /** + * Parses XML data specified and returns root node + * + * @param string $xml + * @return kXMLNode + */ function &Parse($xml = null) { $xml_parser = xml_parser_create(); @@ -60,8 +66,22 @@ var $Attributes = array(); var $Children = array(); var $Data = null; + + var $firstChild = null; + var $lastChild = null; + /** + * Parent node + * + * @var kXMLNode + */ var $Parent = null; - + /** + * Node position relative to other nodes of it's parent + * + * @var int + */ + var $Position = 0; + function kXMLNode($name, $attrs = array()) { $this->Name = $name; @@ -73,8 +93,24 @@ $this->Parent =& $elem; } + /** + * Adds new child to current node + * + * @param kXMLNode $a_child + */ function AddChild(&$a_child) { + $node_count = count($this->Children); + $a_child->Position = $node_count; + + if ($node_count == 0) { + $this->firstChild =& $a_child; + $this->lastChild =& $a_child; + } + else { + $this->lastChild =& $a_child; + } + $this->Children[] =& $a_child; $a_child->SetParent($this); } @@ -104,6 +140,17 @@ } } + function &GetChildByPosition($position) + { + if ($position < count($this->Children) ) { + return $this->Children[$position]; + } + else { + $false = false; + return $false; + } + } + function &FindChild($name) { $name = strtoupper($name); @@ -131,6 +178,22 @@ return $child->Data; } } + + /** + * Returns next node to this, false in case of end list + * + * @return kXMLNode + */ + function &NextSibling() + { + if (!is_null($this->Parent)) { + return $this->Parent->GetChildByPosition($this->Position + 1); + } + else { + $false = false; + return $false; + } + } } ?> \ No newline at end of file Index: trunk/core/kernel/globals.php =================================================================== diff -u -N -r4243 -r4418 --- trunk/core/kernel/globals.php (.../globals.php) (revision 4243) +++ trunk/core/kernel/globals.php (.../globals.php) (revision 4418) @@ -301,7 +301,7 @@ * @param unknown_type $post * @return unknown */ - function curl_post($url, $post, $headers=null) + function curl_post($url, $post, $headers=null, $request_type = 'POST') { if( is_array($post) ) { @@ -328,8 +328,12 @@ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); } - curl_setopt($ch, CURLOPT_POST, 1); - curl_setopt($ch, CURLOPT_POSTFIELDS, $post); + // if we have post data, then POST else use GET method instead + if ($request_type == 'POST') { + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, $post); + } + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch,CURLOPT_REFERER, PROTOCOL.SERVER_NAME); Index: trunk/kernel/units/general/xml_helper.php =================================================================== diff -u -N -r4358 -r4418 --- trunk/kernel/units/general/xml_helper.php (.../xml_helper.php) (revision 4358) +++ trunk/kernel/units/general/xml_helper.php (.../xml_helper.php) (revision 4418) @@ -10,6 +10,12 @@ */ var $CurrentElement = null; + /** + * Parses XML data specified and returns root node + * + * @param string $xml + * @return kXMLNode + */ function &Parse($xml = null) { $xml_parser = xml_parser_create(); @@ -60,8 +66,22 @@ var $Attributes = array(); var $Children = array(); var $Data = null; + + var $firstChild = null; + var $lastChild = null; + /** + * Parent node + * + * @var kXMLNode + */ var $Parent = null; - + /** + * Node position relative to other nodes of it's parent + * + * @var int + */ + var $Position = 0; + function kXMLNode($name, $attrs = array()) { $this->Name = $name; @@ -73,8 +93,24 @@ $this->Parent =& $elem; } + /** + * Adds new child to current node + * + * @param kXMLNode $a_child + */ function AddChild(&$a_child) { + $node_count = count($this->Children); + $a_child->Position = $node_count; + + if ($node_count == 0) { + $this->firstChild =& $a_child; + $this->lastChild =& $a_child; + } + else { + $this->lastChild =& $a_child; + } + $this->Children[] =& $a_child; $a_child->SetParent($this); } @@ -104,6 +140,17 @@ } } + function &GetChildByPosition($position) + { + if ($position < count($this->Children) ) { + return $this->Children[$position]; + } + else { + $false = false; + return $false; + } + } + function &FindChild($name) { $name = strtoupper($name); @@ -131,6 +178,22 @@ return $child->Data; } } + + /** + * Returns next node to this, false in case of end list + * + * @return kXMLNode + */ + function &NextSibling() + { + if (!is_null($this->Parent)) { + return $this->Parent->GetChildByPosition($this->Position + 1); + } + else { + $false = false; + return $false; + } + } } ?> \ No newline at end of file Index: trunk/admin/category/category_items.php =================================================================== diff -u -N -r4330 -r4418 --- trunk/admin/category/category_items.php (.../category_items.php) (revision 4330) +++ trunk/admin/category/category_items.php (.../category_items.php) (revision 4418) @@ -36,15 +36,17 @@ //Display header $sec = $objSections->GetSection($section); + $additional_env = '&t=category/category_items&prefix=c'; + $objCatToolBar = new clsToolBar(); - $objCatToolBar->Add("img_save", "la_Save","#","swap('img_save','toolbar/tool_select_f2.gif');", "swap('img_save', 'toolbar/tool_select.gif');","edit_submit('category','CatEditStatus','$saveURL',1,'');","tool_select.gif"); - $objCatToolBar->Add("img_cancel", "la_Cancel","#","swap('img_cancel','toolbar/tool_cancel_f2.gif');", "swap('img_cancel', 'toolbar/tool_cancel.gif');","edit_submit('category','CatEditStatus','$cancelURL',2,'');","tool_cancel.gif"); + $objCatToolBar->Add("img_save", "la_Save","#","swap('img_save','toolbar/tool_select_f2.gif');", "swap('img_save', 'toolbar/tool_select.gif');","edit_submit('category','CatEditStatus','$saveURL',1,'$additional_env');","tool_select.gif"); + $objCatToolBar->Add("img_cancel", "la_Cancel","#","swap('img_cancel','toolbar/tool_cancel_f2.gif');", "swap('img_cancel', 'toolbar/tool_cancel.gif');","edit_submit('category','CatEditStatus','$cancelURL',2,'$additional_env');","tool_cancel.gif"); if (isset($en_prev) || isset($en_next)) { $url = 'admin/index4_direct.php'; $StatusField = 'CatEditStatus'; $form = 'category'; - MultiEditButtons($objCatToolBar,$en_next,$en_prev,$form,$StatusField,$url,$sec->Get("OnClick"),'&t=category/category_items&prefix=c','la_PrevCategory','la_NextCategory'); + MultiEditButtons($objCatToolBar,$en_next,$en_prev,$form,$StatusField,$url,$sec->Get("OnClick"), $additional_env,'la_PrevCategory','la_NextCategory'); } int_header($objCatToolBar,NULL,$title); Index: trunk/core/kernel/utility/http_query.php =================================================================== diff -u -N -r4149 -r4418 --- trunk/core/kernel/utility/http_query.php (.../http_query.php) (revision 4149) +++ trunk/core/kernel/utility/http_query.php (.../http_query.php) (revision 4418) @@ -303,6 +303,7 @@ $url_parts = $url ? explode('/', $url) : Array(); + $process_module = true; if($this->Get('rewrite') == 'on' || !$url_parts) { // set default values @@ -406,6 +407,7 @@ if (!$url_part) { // no more parts left in url + $process_module = false; $sql = 'SELECT CachedCategoryTemplate FROM '.TABLE_PREFIX.'Category WHERE CategoryId = '.$category_id; @@ -419,9 +421,10 @@ $url_part = 'index'; } } - elseif ($url_part && count($url_parts) == 0 && $category_id) { + elseif ($url_part && count($url_parts) <= 1 && $category_id) { // only filename left, no other parts - $sql = 'SELECT ParentPath, CachedItemTemplate + $process_module = false; + $sql = 'SELECT ParentPath, CachedItemTemplate, CachedCategoryTemplate FROM '.TABLE_PREFIX.'Category WHERE CategoryId = '.$category_id; $category_data = $this->Conn->GetRow($sql); @@ -430,17 +433,30 @@ $module_info = $this->Application->findModule('RootCat', $root_category_id); if ($module_info) { $module_prefix = $module_info['Var']; - $module_event = new kEvent($module_prefix.':ParseEnv', Array('url_parts' => Array($url_part)) ); + $module_event = new kEvent($module_prefix.':ParseEnv', Array('url_parts' => array_merge(Array($url_part), $url_parts)) ); $this->Application->HandleEvent($module_event); - - if ($module_event->status == erSUCCESS) { + + if ($module_event->status == erSUCCESS && $this->Get($module_prefix.'_id')) { $item_template = $category_data['CachedItemTemplate']; if ($item_template) { $url_parts = explode('/', $item_template); array_push($url_parts, $url_part); // save item's filename as not processed $url_part = array_shift($url_parts); } } + elseif (!$module_event->getEventParam('url_parts')) { + // parseEnv has processed that param + $url_part = ''; + $category_template = $category_data['CachedCategoryTemplate']; + if ($category_template) { + $category_template = explode('/', $category_template); + $url_part = array_shift($category_template); + $url_parts = $category_template; + } + else { + $url_part = 'index'; + } + } } } @@ -549,7 +565,9 @@ if ( isset($module_prefix) ) { $passed[] = $module_prefix; $module_event = new kEvent($module_prefix.':ParseEnv', Array('url_parts' => $url_parts) ); - $this->Application->HandleEvent($module_event); + if ($process_module) { + $this->Application->HandleEvent($module_event); + } $item_id = $this->Get($module_prefix.'_id'); $module_params = Array($module_prefix.'_id' => $item_id ? $item_id : '0' ); Index: trunk/core/kernel/event_handler.php =================================================================== diff -u -N -r4149 -r4418 --- trunk/core/kernel/event_handler.php (.../event_handler.php) (revision 4149) +++ trunk/core/kernel/event_handler.php (.../event_handler.php) (revision 4418) @@ -234,7 +234,10 @@ { $this->Application->SetVar($event->getPrefixSpecial().'_'.$var_name, $var_value); } - if (!$url_parts) return false; + if (!$url_parts) { +// $event->status = erFAIL; + return false; + } $ret = ''; $url_part = array_shift($url_parts); @@ -246,7 +249,11 @@ $url_part = $url_parts ? array_shift($url_parts) : ''; } - if(!$url_part) return true; + if (!$url_part) { + $event->setEventParam('url_parts', $url_parts); +// $event->status = erFAIL; + return true; + } // match module reviews page if( preg_match('/(.*)_([\d]+)$/', $url_part, $rets) ) @@ -273,6 +280,7 @@ array_unshift($url_parts, $url_part); $event->status = erFAIL; } + $event->setEventParam('url_parts', $url_parts); } } Index: trunk/core/kernel/utility/unit_config_reader.php =================================================================== diff -u -N -r4380 -r4418 --- trunk/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 4380) +++ trunk/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 4418) @@ -123,7 +123,7 @@ // 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_config][$sub_key]); + unset($this->configData[$sub_prefix][$sub_key]); } } Index: trunk/core/kernel/utility/event.php =================================================================== diff -u -N -r4169 -r4418 --- trunk/core/kernel/utility/event.php (.../event.php) (revision 4169) +++ trunk/core/kernel/utility/event.php (.../event.php) (revision 4418) @@ -170,7 +170,9 @@ function getEventParam($name) { - return getArrayValue($this->specificParams, $name); + $args = func_get_args(); + array_unshift($args, $this->specificParams); + return call_user_func_array('getArrayValue', $args); // getArrayValue($this->specificParams, $name); } function getPrefixSpecial($from_submit=false) @@ -189,7 +191,7 @@ */ function setPseudoClass($appendix) { - $this->pseudoClass=$this->Prefix.$appendix; + $this->pseudoClass = $this->Prefix.$appendix; } function Init($prefix, $special = '')