<?php

CLASS AKB_SEARCHCUSTOMFIELDS extends AKB_PANEL
{
	/**
		* SetPanelSettings
		* This function is a chance to set any last minute global variables for
		* the template to use
		*
		* @return void
		*/
	function SetPanelSettings() {
		$customFields = custom_fields_helper::get_all_custom_fields();
		$GLOBALS['CustomFieldOptions'] = $this->deriveCustomFieldOptions($customFields);
	}

	function deriveCustomFieldOptions($customFields) {

		$buildHTML = "";
		foreach ($customFields as $cfid=>$cfObj) {
			$height='height:23px;';
			$heightClass='Height21';

			if (sizeof($cfObj->customFieldDataArray) > 1) {
				$heightClass='Height125';
				$height='height:125px;';
			}
			if (strtolower($GLOBALS['template']) == 'windows') {
				$buildHTML .= "<tr><td class=\"SearchFieldLabel\">".$cfObj->name."</td></tr>";
				$buildHTML .= '<tr><td> <select id="category" name="cfid" class="Field400 ISSFormat '.$heightClass.' ISSelectReplacement" multiple="multiple" style="width:244px;'.$height.'">';
				foreach ($cfObj->customFieldDataArray as $cfDataObj) {
					$buildHTML .= "<option class=\"".$cfObj->type." forceKey".$cfid."\" value=\"".$cfDataObj->data."\">".$cfDataObj->data."</option>";
				}
				$buildHTML .= '</select></td>';
				$buildHTML .= "</tr>";
			} else {
				$height='';
				$buildHTML .= "<tr><td class=\"SearchFieldLabel\">&nbsp;&nbsp;".$cfObj->name.":</td>";
				$buildHTML .= '<td> <select id="category" name="cfid" class="Field400 ISSFormat '.$heightClass.' ISSelectReplacement" multiple="multiple" style="'.$height.'">';
				foreach ($cfObj->customFieldDataArray as $cfDataObj) {
					$buildHTML .= "<option class=\"".$cfObj->type." forceKey".$cfid."\" value=\"".$cfDataObj->data."\">".$cfDataObj->data."</option>";
				}
				$buildHTML .= '</select></td>';
				$buildHTML .= "</tr>";
			}

		}
		return $buildHTML;
	}
}
?>
