<?
/*
=====================================================
 DataLife Engine - by SoftNews Media Group 
-----------------------------------------------------
 http://www.pc-soft.ru/
-----------------------------------------------------
 Copyright (c) 2004,2006 SoftNews Media Group
=====================================================
 Данный код защищен авторскими правами
=====================================================
 Файл: show.category.php
-----------------------------------------------------
 Назначение: вывод полного списка категорий
=====================================================
*/
if(!defined('DATALIFEENGINE'))
{
  die("Hacking attempt!");
}

function ShowCategory($parentid = 0, $sublevelmarker = '')
{ 
  global $tpl,$cat_info, $user_group, $member_id;

	$allow_list = explode (',', $user_group[$member_id['user_group']]['allow_cats']);

	if($parentid) {
		$sublevelmarker .= '&nbsp;&nbsp;&nbsp;';
  }

	if (count($cat_info)) {

		foreach ($cat_info as $cats) {
			if ($cats['parentid'] == $parentid) $root_category[] = $cats['id'];
		}

		$count_category = count($root_category);
		if ($count_category) {
			$counter = 0;
			foreach ($root_category as $id) {
				$counter++;

				if ($allow_list[0] == "all" OR in_array($id, $allow_list)) {

					if ($config['allow_alt_url'] == "yes")
						$tpl->set('[full-link]',$sublevelmarker."<a href=\"".$config['http_home_url']."category/{$cat_info[$id]['alt_name']}/\">");
					else 
						$tpl->set('[full-link]',$sublevelmarker."<a href=\"{$PHP_SELF}?do=cat&category=".$cat_info[$id]['alt_name']."\">");
					$tpl->set('[/full-link]',"</a>");
					$tpl->set('{title}', $cat_info[$id]['name']);

					$tpl->set_block("'\\[catheader\\].*?\\[/catheader\\]'si","");
					$tpl->set_block("'\\[catline\\](.*?)\\[/catline\\]'si","\\1");
					$tpl->set_block("'\\[catbreak\\].*?\\[/catbreak\\]'si","");
					$tpl->set_block("'\\[catfooter\\].*?\\[/catfooter\\]'si","");
					$tpl->compile('content');
				}
				ShowCategory($id, $sublevelmarker);
				if ($parentid == 0) {
					$tpl->set_block("'\\[catheader\\].*?\\[/catheader\\]'si","");
					$tpl->set_block("'\\[catline\\].*?\\[/catline\\]'si","");
					$tpl->set_block("'\\[catfooter\\].*?\\[/catfooter\\]'si","");
					$tpl->set_block("'\\[catbreak\\](.*?)\\[/catbreak\\]'si","\\1");
					$tpl->compile('content');
				}
			}
		}
	}
}

$tpl->load_template('category.tpl');
$tpl->set_block("'\\[catheader\\](.*?)\\[/catheader\\]'si","\\1");
$tpl->set_block("'\\[catline\\].*?\\[/catline\\]'si","");
$tpl->set_block("'\\[catbreak\\].*?\\[/catbreak\\]'si","");
$tpl->set_block("'\\[catfooter\\].*?\\[/catfooter\\]'si","");
$tpl->compile('content');
ShowCategory( 0, '  ');
$tpl->set_block("'\\[catheader\\].*?\\[/catheader\\]'si","");
$tpl->set_block("'\\[catline\\].*?\\[/catline\\]'si","");
$tpl->set_block("'\\[catbreak\\].*?\\[/catbreak\\]'si","");
$tpl->set_block("'\\[catfooter\\](.*?)\\[/catfooter\\]'si","\\1");
$tpl->compile('content');
$tpl->clear();

?>