Location: PHPKode > projects > mediaIndex > includes/viewSearch.php
<?php
_addMessage("Searching <em>{$_POST['query']}</em> for keyword '<b>".stripslashes($_POST['match'])."</b>'...");

// print metadata and/or include standard html files
_includeFile(_MEDIAPATH.$GLOBALS['dir']->path."HEADER.html");
_printSubtitle("Searching " . $GLOBALS['dir']->title);

echo "<div class=\"description\">" . _parseText($GLOBALS['dir']->desc) . "</div>\n";

_includeFile(_MEDIAPATH.$GLOBALS['dir']->path."README.html");

if ($_POST['query']=="filenames") {
    $_files = $GLOBALS['dir']->searchFilenames($_POST['match']);
} elseif ($_POST['query']=="descriptions") {
    $_files = $GLOBALS['dir']->searchDescriptions($_POST['match']);
}

// show no files if none, exit early
if (count($_files) == 0) {
    echo "<p>No files match search criteria within this directory.</p>";
    _includeFile(_MEDIAPATH.$GLOBALS['dir']->path."FOOTER.html");
    return;
}

// construct array of group handlers, populate them with files
$files = array();
foreach ($_files as $_file) {
    $files[$_file->groupRef->groupName]['files'][] = $_file;
    $files[$_file->groupRef->groupName]['object'] = $_file->groupRef;
}

// loop groups, sort, send to group to print
foreach ($files as $groupName=>$mixed) {
    echo "<div class=\"group\">".$groupName."</div>\n";
    usort($mixed['files'], "_key_compare");
    $mixed['object']->printGroup($mixed['files']);
}

_includeFile(_MEDIAPATH.$GLOBALS['dir']->path."FOOTER.html");

?>
Return current item: mediaIndex