<?php

require_once "../../libs/env.php";
require_once "../../libs/ontology/ontoServices.php";
// Do this before we assign the facets, so we do not duplicate this huge structure
// in the JSON vars.
$t->assign("templateVarsJSON", json_encode($t->_tpl_vars));
$bigint = 999999;
// $facetinfo = getCategoriesInFacet("__ALL", "both", "HTML_UL_ATAG", "id_", $bigint );
$facetinfo = getCategoriesInFacet("__ALL", "both", "HTML_UL_OC", "handleLink", $bigint);
$t->assign("facets", $facetinfo);
$t->assign('page_title', 'Delphi Category Browser');
// Display template
$t->display('browser.tpl');
}
?>
<HTML>
<script>
function query(e, id) {
	//alert( "Query for category: " + id );
	location.href = "../modules/facetBrowser/facetBrowse.php?cats="+id;
	if (!e) var e = window.event;
	e.cancelBubble = true;
	if (e.stopPropagation) e.stopPropagation();
	return false;
}
</script>
<BODY>
<?php 
$facetinfo = getCategoriesInFacet($facetname, true, $retType, $HTparam, $depth);
if (!$facetinfo || count($facetinfo) == 0) {
    echo "<h2>Cannot find categories";
    if ($facetname != "__ALL") {
        echo " for facet: " . $facetname;
    }
    echo "</h2>";
} else {
    echo "<h2>Facet info:</h2>\r\n\t";
    foreach ($facetinfo as $facet) {
        echo "<h3>" . $facet['facet'] . " (" . $facet['id'] . ")</h3>";
        echo "<p>" . $facet['desc'] . "</p>";
        if ($retType == 'HTML_UL' || $retType == 'HTML_UL_ATAG' || $retType == 'HTML_UL_ATTR' || $retType == 'HTML_UL_OC') {
            echo $facet['items'];
        } else {
            // Get as PHP and output completely