<?php
	require_once( $GLOBALS["site_root"] . "/includes/widgets/Widget.inc.php" );
	require_once( $GLOBALS["site_root"] . "/includes/widgets/FrontendTextbox.inc.php" );
	require_once( $GLOBALS["site_root"] . "/includes/widgets/FrontendSubmit.inc.php" );
	require_once( $GLOBALS["site_root"] . "/includes/widgets/FrontendCheckbox.inc.php" );

	require_once( $GLOBALS["site_root"] . "/includes/urlgen/Forum.inc.php" );

	class ForumSearchForm extends Widget {
		public $forum_search_text;
		public $forum_search_submit;
		public $forum_search_in_topics;
		public $forum_search_in_posts;

		public function __construct( $id = "ForumSearchForm" , $parent = null ) {
			parent::__construct( $id , $parent );
			$this->forum_search_text = new FrontendTextbox( "forum_search_text" , $this );
			$this->forum_search_submit = new FrontendSubmit( "forum_search_submit" , $this );
			$this->forum_search_submit->setValue( __("forum_Search" , "attr" ) );

			$this->forum_search_in_topics = new FrontendCheckbox( "forum_search_in_topics" , $this );
			$this->forum_search_in_posts = new FrontendCheckbox( "forum_search_in_posts" , $this );
		}

		protected function initializeWidgets() {
			$this->forum_search_in_topics->setTitle( __("forum_Search_in_topics" ) );
			$this->forum_search_in_topics->setShowTitle( true );
			$this->forum_search_in_posts->setTitle( __("forum_Search_in_posts" ) );
			$this->forum_search_in_posts->setShowTitle( true );

			$this->forum_search_submit->refreshValueFromArray( $this->aG );
			if ($this->forum_search_submit->isSubmitted()) {
				$this->refreshChildValuesFromArray( $this->aG );
			} else {
				// default checkbox values
				$this->forum_search_in_topics->setChecked( false );
				$this->forum_search_in_posts->setChecked( true );
			}
		}

		public function render() {
			if ($this->sRendered) return $this->sRendered;
			$this->setParam( "url_forum_search_hits" , ForumURL::renderSearchURL() ); 
			$this->initializeWidgets();
			return parent::render();
		}
	}

?>
