<?php
/**
* FileName: mod_remository_search.php
* Date: July 2007
* License: GNU General Public License
* Script Version #: 2.00
* ReMOSitory Version #: 2.20 or above
* MOS Version #: 4.5 or above
* Joomla Version 1.0.x
* Author: Martin Brampton - martin@remository.com (http://www.remository.com)
**/

defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

global $mainframe;

$Small_Text_Len = 150;
$Large_Text_Len = 500;
if (file_exists($mainframe->getCfg('absolute_path').'/components/com_remository/language/'.$mainframe->getCfg('lang').'.php')) require_once($mainframe->getCfg('absolute_path').'/components/com_remository/language/'.$mainframe->getCfg('lang').'.php');
else require_once($mainframe->getCfg('absolute_path').'/components/com_remository/language/english.php');

class mod_remository_search {

	function mod_remository_search () {
		$component_url = sefRelToAbs('index.php?option=com_remository&func=search&Itemid='.$this->getItemid('com_remository'));
		$this->display($component_url);
	}

	function getItemID ($component_string) {
		global $database;
		if (isset($GLOBALS['remosef_itemids'][$component_string])) return $GLOBALS['remosef_itemids'][$component_string];
		$database->setQuery("SELECT id, (CASE menutype WHEN 'mainmenu' THEN 1 WHEN 'topmenu' THEN 2 WHEN 'othermenu' THEN 3 ELSE 99 END) menorder"
					." FROM #__menu WHERE link = 'index.php?option=$component_string' AND published=1 ORDER BY menorder");
		$GLOBALS['remosef_itemids'][$component_string] = $database->loadResult();
		return $GLOBALS['remosef_itemids'][$component_string];
	}


	function display ($actionurl) {
		$search_text = _DOWN_SEARCH_TEXT;
		$button_text = _DOWN_SUB_BUTTON;
		$file_title = _DOWN_SEARCH_FILETITLE;
		$file_desc = _DOWN_SEARCH_FILEDESC;

		echo <<<SEARCH_HTML

		<form method="post" action="$actionurl">
		<table width="100%" border="0" cellspacing="0" cellpadding="0" class="sectiontableentry2">
		<tr>
			<td width="60%" align="left">
				
			</td>
		</tr>
		<tr>
			<td colspan="2">
				<input class="inputbox" type="text" name="search_text" size="15"/>
			</td>
		</tr>
		<tr>
			<td colspan="2">
				<input class="button" type="submit" name="submit" value="Cari"/>
			</td>
		</tr>
		<tr>
			<td width="60%" align="right">
				<b>$file_title</b>&nbsp;
			</td>
			<td>
				<input type="checkbox" name="search_filetitle" value="1" checked="checked"/>
			</td>
		</tr>
		<tr>
			<td width="60%" align="right">
				<b>$file_desc</b>&nbsp;
			</td>
			<td>
				<input type="checkbox" name="search_filedesc" value="1" checked="checked"/>
			</td>
		</tr>
		</table>
		<input type="hidden" name="submit" value="submit"/>
	</form>

SEARCH_HTML;

	}

}

new mod_remository_search();

?>