Index: trunk/admin/category/permcacheupdate.php =================================================================== diff -u -N -r3162 -r4124 --- trunk/admin/category/permcacheupdate.php (.../permcacheupdate.php) (revision 3162) +++ trunk/admin/category/permcacheupdate.php (.../permcacheupdate.php) (revision 4124) @@ -135,8 +135,24 @@ var $doneCats; var $table; + /** + * Kernel Application + * + * @var kApplication + */ + var $Application = null; + /** + * Enter description here... + * + * @var kDBConnection + */ + var $Conn = null; + function clsCacheUpdater($continuing=false) { + $this->Application =& kApplication::Instance(); + $this->Conn =& $this->Application->GetADODBConnection(); + $this->conn =& GetADODBConnection(); $this->iteration = 0; $this->table=$GLOBALS['objSession']->GetEditTable('permCacheUpdate'); @@ -209,6 +225,8 @@ $data['current_id'] = 0; $data['title'] = Array(); $data['named_path'] = Array(); + $data['category_template'] = ''; + $data['item_template'] = ''; $this->Stack->Push($data); } @@ -236,6 +254,8 @@ $next_data = Array(); $next_data['title'] = $data['title']; $next_data['named_path'] = $data['named_path']; + $next_data['category_template'] = $data['category_template']; + $next_data['item_template'] = $data['item_template']; $next_data['current_id'] = $data['children'][$data['current_child']]; //next iteration should process child $next_data['perms'] = $data['perms']; //we should copy our permissions to child - inheritance $next_data['perms']->SetCatId($next_data['current_id']); @@ -253,24 +273,35 @@ } function UpdateCachedPath(&$data) { - $sql = 'UPDATE '.GetTablePrefix().'Category SET CachedNavbar="'.addslashes(join('>',$data['title'])) .'" WHERE CategoryId = '.$data['current_id']; - $this->conn->Execute($sql); - - $path = implode('/', $data['named_path'] ); - $sql = 'UPDATE '.GetTablePrefix().'Category SET NamedParentPath = "'.addslashes($path).'" WHERE CategoryId = '.$data['current_id']; - $this->conn->Execute($sql); + $fields_hash = Array( 'CachedNavbar' => implode('>', $data['title']), + 'NamedParentPath' => implode('/', $data['named_path'] ), + 'CachedCategoryTemplate'=> $data['category_template'], + 'CachedItemTemplate' => $data['item_template'], + ); + + $this->Conn->doUpdate($fields_hash, TABLE_PREFIX.'Category', 'CategoryId = '.$data['current_id']); } function QueryTitle(&$data) { - $sql = sprintf('SELECT Name, Filename FROM '.GetTablePrefix().'Category WHERE CategoryId = %s', - $data['current_id']); + $sql = 'SELECT Name, Filename, CategoryTemplate, ItemTemplate + FROM '.GetTablePrefix().'Category + WHERE CategoryId = '.$data['current_id']; + $rs = $this->conn->Execute($sql); if ($rs && !$rs->EOF) { $data['title'][] = $rs->fields['Name']; $data['named_path'][] = $rs->fields['Filename']; + + // if explicitly set, then use it; use parent template otherwise + if ($rs->fields['CategoryTemplate']) { + $data['category_template'] = $rs->fields['CategoryTemplate']; + } + if ($rs->fields['ItemTemplate']) { + $data['item_template'] = $rs->fields['ItemTemplate']; + } } } Index: trunk/kernel/action.php =================================================================== diff -u -N -r4121 -r4124 --- trunk/kernel/action.php (.../action.php) (revision 4121) +++ trunk/kernel/action.php (.../action.php) (revision 4124) @@ -750,8 +750,8 @@ $objEditItems->SourceTable = $objSession->GetEditTable("Category"); $fields_hash = Array( 'ParentId' => GetVar('ParentId'), - 'Name' => GetVar('cat_name'), - 'Description' => inp_escape(GetVar('cat_desc'), (int)$_POST["html_enable"]), + 'Name' => inp_escape(GetVar('cat_name'), (int)GetVar('html_enable')), + 'Description' => inp_escape(GetVar('cat_desc'), (int)GetVar('html_enable')), 'CreatedOn' => $created_on, 'EditorsPick' => GetVar('cat_pick'), 'Status' => (int)GetVar('status'), @@ -766,7 +766,8 @@ 'CategoryTemplate' => GetVar('category_template'), 'ItemTemplate' => GetVar('item_template'), ); - + + $objSession->SetVariable('PermCache_UpdateRequired', 1); $cat =& $objEditItems->Add_NEW($fields_hash); saveCustomFields('c', $cat->Get('ResourceId'), 1); break; @@ -776,14 +777,18 @@ $application->SetVar('c_mode', 't'); $objEditItems = new clsCatList(); - $objEditItems->SourceTable = $objSession->GetEditTable("Category"); + $objEditItems->SourceTable = $objSession->GetEditTable('Category'); // check if name of cat isn't changed: begin if (GetVar('CategoryId') > 0) { $original_cats = new clsCatList(); $original_cat = $original_cats->GetItemByField('CategoryId', GetVar('CategoryId')); - $match_fields = Array('Name' => 'cat_name', 'Filename' => 'filename'); + $match_fields = Array( 'Name' => 'cat_name', + 'Filename' => 'filename', + 'CategoryTemplate' => 'category_template', + 'ItemTemplate' => 'item_template'); + foreach ($match_fields as $db_field => $submit_field) { if ($original_cat->Get($db_field) != stripslashes( GetVar($submit_field) )) { $objSession->SetVariable('PermCache_UpdateRequired', 1);