Location: PHPKode > projects > Community Learning Network > cln/lib/CLN/interfaces/kbSearch-metadata.php
<?php
/*
 * KB Search - metadata Interface
 *
 * Copyright (c) 2003-4 St. Christopher House
 *
 * Developed by The Working Group Inc.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.  
 *
 * @version $Id: kbSearch-metadata.php,v 1.5 2005/01/25 21:15:02 derekbrooks Exp $
 *
 */

// instantiate empty metadata object - is this cool? - dwc
$metadata = new $GLOBALS['classes']['metadata']['classname']('','');

require_once "HTML/Form.php";
if(!isset($form)) $form = new HTML_Form('');

//*******************************************************
// prepare variables for search by program

$searchContributors = (!isset($_REQUEST['searchContributors'])) ? '' : $_REQUEST['searchContributors'];
$searchUnits = (!isset($_REQUEST['searchUnits'])) ? array() : $_REQUEST['searchUnits'];

?>
<fieldset class="kbSearchFieldset" id="kbSearchProgram" style="display: none;">
	<legend accesskey="p">Search by Program</legend>

	<div class="grRow">
		<span class="grFormLabel"><label for="searchContributors">Contributors:</label></span>
		<input type="text" class="grFormElement" id="searchContributors" name="searchContributors" value="<?php echo $searchContributors; ?>" size="30" maxlength="128" />
	</div>

	<div class="grRow">
		<span class="grFormLabel"><label for="searchUnits">Program: </label></span>
		<span class="kbSearchCheckist">

		<?php
		$units = $metadata->getUnits();
		foreach($units as $unit) {

			//echo '<div class="kbSearchFloatingInput">';

			if(in_array($unit,$searchUnits)) {
				$checked = TRUE;
			} else {
				$checked = FALSE;
			}

			$form->displayCheckbox("searchUnits[]", $checked, 'value="'.$unit.'" class="grFormElement" id="searchUnits['.$unit.']"');

			echo '<label for="searchUnits[]">'.$unit.'</label><br/>';
		}
				?>
		
		</span>
	</div>		

</fieldset>

<?php

//*******************************************************
// prepare variables for detailed metadata fields

$searchDescription = (!isset($_REQUEST['searchDescription'])) ? '' : $_REQUEST['searchDescription'];
$searchVersion = (!isset($_REQUEST['searchVersion'])) ? '' : $_REQUEST['searchVersion'];
$searchUserLang = (!isset($_REQUEST['searchUserLang'])) ? array() : $_REQUEST['searchUserLang'];
$searchContext = (!isset($_REQUEST['searchContext'])) ? '' : $_REQUEST['searchContext'];
$searchAgeRanges = (!isset($_REQUEST['searchAgeRanges'])) ? array() : $_REQUEST['searchAgeRanges'];

?>
<fieldset class="kbSearchFieldset" id="kbSearchDetailed" style="display:none;">
	<legend accesskey="d">Detailed Metadata Fields</legend>

	<div class="grRow">
		<span class="grFormLabel"><label  for="searchDescription">Description: </label></span>
		<input class="grFormElement" type="text" id="searchDescription" name="searchDescription" value="<?php echo $searchDescription; ?>" size="30" maxlength="100"/>
	</div>
	
	
	<div class="grRow">
		<span class="grFormLabel"><label for="searchVersion">Version: </label>
		</span>
		<input class="grFormElement" type="text" id="searchVersion" name="searchVersion" size="10" maxlength="10" value="<?php echo $searchVersion; ?>" />
	</div>
	
	<div class="grRow">
			<span class="grFormLabel">User's Natural Language: </span>
			<span class="kbSearchCheckList">
	<?php
foreach($GLOBALS['languages'] as $langId => $language) {

	if(in_array($langId, $searchUserLang)) {
		$checked = TRUE;
	} else {
		$checked = FALSE;
	}
	$form->displayCheckbox("searchUserLang[]", $checked, 'value="'.$langId.'" class="grFormElement" id="searchUserLang['.$langId.']"');

	echo '<label for="searchUserLang">'.$language.'</label><br/>';
	}
	?>
			</span>
	</div>
	
	<div class="grRow">
		<span class="grFormLabel"><label for="searchContext">Context:</label></span>
		<input class="grFormElement" type="text" id="searchContext" name="searchContext" size="50" maxlength="128" value="<?php echo $searchContext; ?>" />
	</div>
	
	<div class="grRow">
		<span class="grFormLabel"><label>Age range of audience: </label>
		</span>
	<?php
	$ageRanges = $metadata->getAgeRanges();
foreach($ageRanges as $ageRange) {
	echo '<div class="grRow"><span class="grFormLabel"><label for="searchAgeRanges">'.$ageRange.'</label></span>';
	if(in_array($ageRange, $searchAgeRanges)) {
		$checked = TRUE;
	} else {
		$checked = FALSE;
	}
	$form->displayCheckbox("searchAgeRanges[]", $checked, 'value="'.$ageRange.'" class="grFormElement" id="searchAgeRanges[' .$ageRange .']"');
	echo '</div>';
}
	?>
	</div>
</fieldset>
Return current item: Community Learning Network