Index: trunk/admin/category/permcacheupdate.php =================================================================== diff -u -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']; + } } }