<?php
/*
* @package LabCMS
* @copyright (c) 2006 Alexander Levin aka Loki (loki_angel@mail.ru)
* @support http://labcms.ru
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/

function menu_tree_config_tree_id($parent_id=0, $level=0, $parent_select=array())
{
	global $parent_select;
	$result=Db::i()->select(
		"SELECT t.tree_id,  name,  pos
		FROM ?_tree t
		WHERE t.parent_id=?
		ORDER BY pos",
		$parent_id
	);
	if (count($result)) {
		foreach ($result as $tree) {
			$margin="";
			for($i=0; $i<$level*3; $i++) $margin.="&nbsp;";
			$parent_select[$tree['tree_id']]=$margin.$tree['name'];
			$parent_select+=menu_tree_config_tree_id($tree['tree_id'], $level+1, $parent_select);
		}
		return $parent_select;
	} else {
		return array();
	}
}