<?php require_once "apiSetup.php"; require_once "../libs/ontology/ontoServices.php"; if (empty($_GET['f'])) { $fid = -1; } else { $facetname = $_GET['f']; $fid = findFacetID($facetname); } ?> <HTML> <BODY> <?php $facetinfo = getFacets(); if (!$facetinfo || count($facetinfo) == 0) { echo "<h2>Cannot get facets...</h2>"; } else { if (isset($facetname) && $fid < 0) { echo "<h2>Bad facet name: " . $facetname . "</h2>"; } else { ?> <h2>Facet info:</h2> <TABLE BORDER=2 CELLSPACING=0 CELLPADDING=0> <TR> <TD><h3>Facet</h3></TD> <TD><h3>ID</h3></TD> </TR> <?php foreach ($facetinfo as $facet) { if ($fid < 0 || $facet['id'] == $fid) {
function getCategoriesForObject($forObjID, $facetname, $countsWithImages, $retType, $HTparam) { //:String global $facets; global $db; checkAndLoadFacets(); if (count($facets) == 0) { return false; } // Can't find any facets in DB - just bail // If facet is qualified, then just get info for that facet. Otherwise get for all. if (!isset($facetname) || $facetname == "__ALL") { $fid = -1; } else { $fid = findFacetID($facetname); if ($fid < 0) { echo "Bad facet name: " . $facetname; return false; } } $countCol = $countsWithImages ? "n_matches_w_img" : "n_matches"; $tqCountsByCat = "select c.id, c.parent_id, c.facet_id, c.display_name, c." . $countCol . " from categories c, obj_cats oc where c.id=oc.cat_id" . " AND oc.obj_id=" . $forObjID; if ($fid >= 0) { $tqCountsByCat .= " AND c.facet_id=" . $fid; } $tqCountsByCat .= " order by id"; $countsresult =& $db->query($tqCountsByCat); PopulateFacetsFromResultSet($countsresult, false); // Facets now exist as array in $facets. Nodes are avail in hashMap. // Note that we do not prune since this is for the details, not a full query. $retVal = array(); //error_log( "getCategoriesForObject() considering ".count($facets)." facets... "); $largeNum = 999999; foreach ($facets as $facet) { if ($fid < 0 || $fid == $facet->id) { $items = array(); if (!empty($facet->arrChildren)) { switch ($retType) { default: return false; case "PHP": $items = $facet->GeneratePHPItems(0, $largeNum, 1, true, false); break; case "JSON": // $items = $facet->GeneratePHPItems( 0, $largeNum, 1, false, false ); // Convert to JSON // break; return false; // NYI // NYI case "HTML_UL": //error_log( "getCategoriesForObject() dumping HTML for: ".$facet->name); $items = $facet->GenerateHTMLItems(0, $largeNum, 1, true, 1, "none", ""); break; case "HTML_UL_ATAG": //error_log( "getCategoriesForObject() dumping HTML for: ".$facet->name); $items = $facet->GenerateHTMLItems(0, $largeNum, 1, true, 1, 'A_Tag', $HTparam); break; case "HTML_UL_ATTR": //error_log( "getCategoriesForObject() dumping HTML for: ".$facet->name); $items = $facet->GenerateHTMLItems(0, $largeNum, 1, true, 1, 'attr', $HTparam); break; case "HTML_UL_OC": //error_log( "getCategoriesForObject() dumping HTML for: ".$facet->name); $items = $facet->GenerateHTMLItems(0, $largeNum, 1, true, 1, 'onclick', $HTparam); break; } // Only add a new item if there are children for that facet $facetVal = array('facet' => $facet->name, 'desc' => $facet->description, 'notes' => $facet->notes, 'id' => $facet->id, 'items' => $items); $retVal[] = $facetVal; } } } return $retVal; }