?>
<HTML>
<BODY>
<?php 
if (empty($_GET['c']) && empty($_GET['k'])) {
    echo "<h3>You have to specify concepts ('c' param) and/or a keyword string ('k' param)</h3>";
} else {
    $matchImages = empty($_GET['i']) ? false : ($_GET['i'] != 0 ? true : false);
    $page = empty($_GET['p']) ? 1 : $_GET['p'];
    $pageSize = empty($_GET['s']) ? 36 : $_GET['s'];
    empty($_GET['c']) ? $catIDs = array() : ($catIDs = explode(",", $_GET['c']));
    empty($_GET['k']) ? $kwds = false : ($kwds = $_GET['k']);
    if (count($catIDs) <= 1) {
        $qCatIDs =& $catIDs;
    } else {
        $qCatIDs =& orderCatsForQuery($catIDs, $matchImages);
    }
    $objsquery = prepareObjsQuery($qCatIDs, $kwds, $matchImages, $page - 1, $pageSize);
    $catsquery = prepareResultsCatsQuery($qCatIDs, $kwds, $matchImages);
    echo "<h3>Objects Query:</h3><pre>" . $objsquery . "</pre>" . "<h3>Objects Query:</h3><pre>" . $catsquery . "</pre>";
}
echo '<hr><form method="get">
				<p>Enter Concept(s): <input type="text" name="c" maxlength="300" /></p>
				<p>Enter Keyword(s): <input type="text" name="k" maxlength="300" /></p>
				<p>With Images(s): <input type="checkbox" name="i" value="1" checked="true" /></p>
				<p>Page Num:  <input type="text" name="p" maxlength="10" /></p>
				<p>Page Size: <input type="text" name="s" maxlength="10" /></p>
				<input type="submit" value="Show Query" />
				</form>';
?>
</BODY>
Exemplo n.º 2
0
function queryResultsCategories($catIDs, $kwds, $tag, $user, $countsWithImages, $retType, $HTparam)
{
    global $facets;
    global $db;
    checkAndLoadFacets();
    if (count($facets) == 0) {
        return false;
    }
    // Can't find any facets in DB - just bail
    if (empty($catIDs) && empty($kwds) && empty($tag)) {
        error_log("queryResultsCategories() called with no categories or keywords");
        return false;
    }
    $retVal = array();
    if (count($catIDs) <= 1) {
        $qCatIDs =& $catIDs;
    } else {
        $qCatIDs =& orderCatsForQuery($catIDs, $countsWithImages);
    }
    //error_log( "queryObjects() Kwds: ".(empty($kwds)?"None":$kwds));
    //error_log( "queryObjects() Cats: ".(empty($qCatIDs)?"None":implode(",", $qCatIDs)));
    //$tqMain = buildMainQueryForTerm( $qCatIDs, 0, $kwds, $countsWithImages );
    $tqFull = prepareResultsCatsQuery($qCatIDs, $kwds, $tag, $user, $countsWithImages);
    $catsresult =& $db->query($tqFull);
    if (PEAR::isError($catsresult)) {
        error_log("queryResultsCategories() main Query error: " . $catsresult->getMessage());
        error_log("queryResultsCategories() Query : " . $tqFull);
        return false;
    }
    //error_log( "queryResultsCategories() Query : ".$tqFull);
    PopulateFacetsFromResultSet($catsresult, false);
    // Facets now exist as array in $facets. Nodes are avail in hashMap.
    $retVal = array();
    //error_log( "getCategoriesForObject() considering ".count($facets)." facets...  ");
    $fid = -1;
    // Stub this until we decide to allow facet spec
    $largeNum = 999999;
    foreach ($facets as $facet) {
        if ($fid < 0 || $fid == $facet->id) {
            $items = array();
            if (!empty($facet->arrChildren)) {
                $facet->PruneForOutput(0, $catIDs);
                switch ($retType) {
                    default:
                        return false;
                    case "PHP":
                        $items = $facet->GeneratePHPItems(0, $largeNum, 1, false, 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( "queryResultsCategories() dumping HTML for: ".$facet->name);
                        $items = $facet->GenerateHTMLItems(0, $largeNum, 1, false, 1, "none", "");
                        break;
                    case "HTML_UL_ATAG":
                        //error_log( "queryResultsCategories() dumping HTML for: ".$facet->name);
                        $items = $facet->GenerateHTMLItems(0, $largeNum, 1, false, 1, 'A_Tag', $HTparam);
                        break;
                    case "HTML_UL_ATTR":
                        //error_log( "queryResultsCategories() dumping HTML for: ".$facet->name);
                        $items = $facet->GenerateHTMLItems(0, $largeNum, 1, false, 1, 'attr', $HTparam);
                        break;
                    case "HTML_UL_OC":
                        //error_log( "queryResultsCategories() dumping HTML for: ".$facet->name);
                        $items = $facet->GenerateHTMLItems(0, $largeNum, 1, false, 1, 'onclick', $HTparam);
                        break;
                }
                // Only add a new item if there are children for that facet
                $facetVal = array('facet' => $facet->name, 'id' => $facet->id, 'desc' => $facet->description, 'notes' => $facet->notes, 'items' => $items);
                $retVal[] = $facetVal;
            }
        }
    }
    return $retVal;
}