/*************************************************************** * * MakeNav - * PLEASE TEST BEFORE PRODCTION USE * @author Gabriel Crowe 12:47 01 November 2007 * * usage example: * MakeNav($sectid,$recursedepth,$prestyle,$thissect) ***************************************************************/ if (!function_exists('GetParentSections')) { function GetParentSections($connect,$sectref) { $query = "SELECT [Section Text], [nParentSectionID], [nSectionID] FROM [Catalog Section] WHERE [nSectionID] LIKE '".$sectref."'"; $result = odbc_exec($connect, $query); $returnstring=""; while(odbc_fetch_row($result)){ $SectionText = odbc_result($result, 1); $nParentSectionID = odbc_result($result, 2); $nSectionID = odbc_result($result, 3); if ($nSectionID!=0) {$returnstring=GetParentSections($connect,$nParentSectionID).$nSectionID."|";} } odbc_free_result($result); //odbc_close($connect); return $returnstring; } } if (!function_exists('GetParentSectionsWrapper')) { function GetParentSectionsWrapper($sectid) { $connect = odbc_pconnect("ActinicCatalog9","","", SQL_CUR_USE_ODBC); $resultage = GetParentSections($connect,$sectid); odbc_close_all(); return $resultage; } } if (!function_exists('useful_odbc_num_rows')) { function useful_odbc_num_rows($result){ $num_rows=0; while($temp = odbc_fetch_into($result, &$counter)) { $num_rows++; } @odbc_fetch_row($result, 0); // reset cursor return $num_rows; } } if (!function_exists('SectionList')) { function SectionList($connect,$sectid,$recursedepth,$rendermode,$thispatharr,$stylecounter,$respect) { $recursedepth=$recursedepth-1; $stylecounter=$stylecounter+1; if($respect==true) { $query = "SELECT [sPageName], [Section text], [nSectionID] FROM [Catalog Section] WHERE [nParentSectionID]=".$sectid." AND [bHideOnWebSite]=0 AND [bIncludeToSiteMap]=1 ORDER BY [Catalogue Section Sequence] ASC"; } else { $query = "SELECT [sPageName], [Section text], [nSectionID] FROM [Catalog Section] WHERE [nParentSectionID]=".$sectid." AND [bHideOnWebSite]=0 ORDER BY [Catalogue Section Sequence] ASC"; } $result = odbc_exec($connect, $query); $numrows = useful_odbc_num_rows($result); if ($numrows!=0) {echo "\n\n\n\n"; } odbc_free_result($result); } } if (!function_exists('MakeNav')) { function MakeNav($sectid,$recursedepth,$rendermode,$thissect,$respect=true) { $thispath = GetParentSectionsWrapper($thissect); $thispatharr = explode("|",$thispath); //sPagetitle, sPageName, sMetaKeywords, sMetaDescription, sSectionImageFile, sSectionDescription, sSectionText $connect = odbc_pconnect("ActinicCatalog9","","", SQL_CUR_USE_ODBC); SectionList($connect,$sectid,$recursedepth,$rendermode,$thispatharr,0,$respect); odbc_close_all(); $connect = null; } } /*************************************************************** * * Ref2file - Use Actinic's pwn database, to convert a prod ref, to a filename * * @param int $ref the product reference. * @author Gabriel Crowe 18:04 08 September 2007 * ***************************************************************/ if (!function_exists('GetSectFileName')) { function GetSectFileName($sectref) { $connect = odbc_connect("ActinicCatalog9","",""); $query = "SELECT [sPageName] FROM [Catalog Section] WHERE [nSectionID]=".$sectref.""; $result = odbc_exec($connect, $query); while(odbc_fetch_row($result)){ //$name = odbc_result($result, 2); $url = odbc_result($result, 1); } odbc_close($connect); return $url; } } if (!function_exists('GetSectName')) { function GetSectName($sectref) { $connect = odbc_connect("ActinicCatalog9","",""); $query = "SELECT [Section Text] FROM [Catalog Section] WHERE [nSectionID]=".$sectref.""; $result = odbc_exec($connect, $query); while(odbc_fetch_row($result)){ //$name = odbc_result($result, 2); $SectionText = odbc_result($result, 1); } odbc_close($connect); return $SectionText; } } if (!function_exists('GetProdParent')) { function GetProdParent($prodrefs) { $prodrefs = str_replace("{","",$prodrefs); $prodrefs = str_replace("}","",$prodrefs); $connect = odbc_connect("ActinicCatalog9","",""); $query = "SELECT [nParentSectionID] FROM [product] WHERE [Product Reference]='".$prodrefs."'"; $result = odbc_exec($connect, $query); while(odbc_fetch_row($result)){ $parentid = odbc_result($result, 1); } odbc_close($connect); return $parentid; } } if (!function_exists('Ref2file')) { function Ref2file($ref) { return GetSectFileName(GetProdParent($ref)); } }