<?php
/**
 * DOCman 1.4.x - Joomla! Document Manager
 * @version $Id: categories.html.php 765 2009-01-05 20:55:57Z mathias $
 * @package DOCman_1.4
 * @copyright (C) 2003-2009 Joomlatools
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
 * @link http://www.joomlatools.eu/ Official website
 **/
defined('_VALID_MOS') or die('Restricted access');

if (defined('_DOCMAN_HTML_CATEGORIES')) {
    return;
} else {
    define('_DOCMAN_HTML_CATEGORIES', 1);
}

class HTML_DMCategories
{
    function displayCategory(&$links, &$paths, &$data)
    {
        $tpl = &new DOCMAN_Theme();

        // Assign values to the Savant instance.
        $tpl->assignRef('links', $links);
        $tpl->assignRef('paths', $paths);
        $tpl->assignRef('data', $data);

        // Display a template using the assigned values.
        return $tpl->fetch('categories/category.tpl.php');
    }

    function displayCategoryList(&$items)
    {
        $tpl = &new DOCMAN_Theme();

        // Assign values to the Savant instance.
        $tpl->assignRef('items', $items);

        // Display a template using the assigned values.
        return $tpl->fetch('categories/list.tpl.php');
    }

	function displayList(&$tpl, &$items, $level)
	{
		$text = '';
		if (count($items)) {
			foreach($items as $item) :
				if (is_array($item)) :
					$text = $text . HTML_DMCategories::displayList($tpl, $item, $level+1);
				endif;
				
				if (!is_array($item)) :
					
					// Assign values to the Savant instance.
					$tpl->assignRef('item', $item);
					$tpl->assignRef('level', $level);

					// Display a template using the assigned values.
					$text = $text . $tpl->fetch('categories/fulllist.tpl.php');
				endif;
			endforeach;
		}
		return $text;
	}
	
    function displayCategoryFullList(&$items)
    {
		if (count($items)) {
			/*
			 * Include the list_item template and pass the item to it
			*/
			$level = 0;
			/*$text = "<div id=\"dm_cats\">".
				    "<h3>"._DML_TPL_CATS."<span>"._DML_TPL_FILES."</span></h3><div>";*/

			$tpl = &new DOCMAN_Theme();
			$text = $text . HTML_DMCategories::displayList($tpl, $items, $level);
		}
		return $text; //."</div></div>";
;

        // Assign values to the Savant instance.
        //$tpl->assignRef('items', $items);

        // Display a template using the assigned values.
        //echo $tpl->fetch('categories/fulllist.tpl.php');
		//return prueba;
    }	
}