<?php
//=================================================================\\
// displaycategories.php v1.2 \\
//----------------------------------------------------------------------------------------------------------------------\\
// This file is part of Accessories Me PHP Affiliate Script. \\
//----------------------------------------------------------------------------------------------------------------------\\
// File purpose: Stores Amazon BrowseNode number and name data \\
// Display list of main categories for navigation \\
// Display list of sub categories for navigation \\
// Returns BrowseNode names from category arrays \\
//-----------------------------------------------------------------------------------------------------------------------\\
// COPYRIGHT: (C) 2004, 2005 Len Johnson \\
// Website: http://www.accessories.me.uk \\
// Email: hide@address.com \\
// Mail: GB WEBS, 4 Leominster Walk, West Midlands, B45 9SW, UK \\
// Support: http://www.accessories.me.uk/forum-2.htm \\
//------------------------------------------------------------------------------------------------------------------------\\
// DONATIONS: If you have found this script useful you can make a donation to support \\
// it's continued development at http://www.accessories.me.uk/about12.htm \\
//------------------------------------------------------------------------------------------------------------------------\\
// COPYING/LICENSE: Accessories Me PHP Affiliate Script is free software; \\
// you can redistribute it and/or modify it under the terms of the GNU General Public License \\
// as published by the Free Software Foundation; either version 2 \\
// of the License, or (at your option) any later version. See LICENSE.TXT \\
//------------------------------------------------------------------------------------------------------------------------\\
// Accessories Me PHP Affiliate Script is distributed in the hope that it will be useful, \\
// but WITHOUT ANY WARRANTY; \\
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. \\
// See the GNU General Public License for more details. \\
//-------------------------------------------------------------------------------------------------------------------------\\
// You should have received a copy of the GNU General Public License along with this program; \\
// if not, write to: \\
// Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. \\
// http://www.opensource.org/licenses/gpl-license.html \\
//-------------------------------------------------------------------------------------------------------------------------\\
//=================================================================\\
// CHANGELOG \\
// 03-02-05 Typo in comments corrected \\
//-------------------------------------------------------------------------------------------------------------------------\\
// Amazon BrowseNodes
// Research these at http://www.accessories.me.uk/about15.htm (USA nodes)
$mainCategoryList = array(3221551=>'iPods', 10836511=>'Accessories', 13630591=>'iPod Minis');
$subCategoryList = array(
13630561 => array( 13630571 => 'Apple', 13630581 => 'Other Brands', ),
13660271 => array( 10836511 => 'iPod Accessories', 13630591 => 'iPod Minis', 3221551 => 'iPods', ),
// Enter additional sub category arrays above this comment
// NB: Each array should be followed by a comma
10836511 => array(13630601=> '20 GB with Click Wheel', 13630661=> '20 GB with Dock Connector',
13630631=> '40 GB with Click Wheel', 13630691=> '40 GB with Dock Connector', 13676141=> 'iPod Photo', 13630561 => 'iPod Mini Accessories',)
);
/*
Browse menu parent IN PROGRESS
function browseMenuParent($BrowseNode)
{
global $subCategoryList;
global $SearchIndex;
foreach($subCategoryList as $key => $val)
{
foreach($val as $fin_key => $fin_val)
{
if($fin_key == $BrowseNode )
{
echo '<a href="browse.php?SearchIndex=' . $SearchIndex . '&BrowseNode=' . $key . '">';
echo getCategoryName($key) . '</a> :: ';
}
}
}
}
*/
function categoryParent($BrowseNode)
{
global $subCategoryList;
foreach($subCategoryList as $key => $val)
{
if(in_array($BrowseNode, $val))
{
$foundit=1;
}
if($foundit)
{
echo getCategoryName($key);
}
}
}
function categoryParentUrl($BrowseNode)
{
global $subCategoryList;
global $SearchIndex;
foreach($subCategoryList as $key => $val)
{
if(in_array($BrowseNode, $val))
{
echo '<a href="browse.php?SearchIndex=' . $SearchIndex . '&BrowseNode=' . $key . '">' . getCategoryName($key);
}
}
}
// Display list of main categories for below title navigation
function newSubCategories($BrowseNode)
{
global $SearchIndex;
global $subCategoryList;
foreach ($subCategoryList as $key => $val)
{
if ($key == $BrowseNode)
{
asort($val);
$categories = count($val);
$columns = 4;
$rows = ceil($categories/$columns);
echo '<table border="0" cellpadding="0" cellspacing="0" width = "100%"><tr>';
reset($val);
for($col = 0; $col<$columns; $col++)
{
echo '<td width = "'.(100/$columns).'%" valign = top><ul>';
for($row = 0; $row<$rows; $row++)
{
$category = each($val);
if($category)
{
$node = $category['key'];
$name = $category['value'];
echo '<li><span class="subcat"><a href ="browse.php?SearchIndex=' . $SearchIndex . '&BrowseNode=' . $node . '">' . $name . '</a></span></li>';
}
}
echo '</ul></td>';
}
echo '</tr></table>';
}
}
}
// Display list of main categories for navigation
function showMainCategories($SearchIndex)
{
global $mainCategoryList;
foreach($mainCategoryList as $key => $val)
{
echo '<li><a href ="browse.php?SearchIndex=' . $SearchIndex . '&BrowseNode=' . $key . '">' . $val . '</a></li>';
}
}
// Display list of sub categories for navigation
function showSubCategories($BrowseNode)
{
global $SearchIndex;
global $subCategoryList;
echo '<br /><br />';
foreach ($subCategoryList as $key => $val)
{
if ($key == $BrowseNode)
{
foreach ($val as $fin_key=>$fin_val)
{
echo '<li><a href ="browse.php?SearchIndex=' . $SearchIndex . '&BrowseNode=' . $fin_key . '">' . $fin_val . '</a></li>';
}
}
}
}
// Get BrowseNode name
// MUST be defined in the $mainCategoryList and $subCategoryList arrays above
function getCategoryName($BrowseNode)
{
global $mainCategoryList;
global $subCategoryList;
if(isset($mainCategoryList[$BrowseNode]))
{
return $mainCategoryList[$BrowseNode];
}
elseif(!isset($mainCategoryList[$BrowseNode]))
{
foreach ($subCategoryList as $val)
{
foreach ($val as $key=>$fin_val)
{
if ($key == $BrowseNode)
{
return $fin_val;
}
}
}
}
else
{
return '';
}
}
?>