<?php
	require_once( $GLOBALS["site_root"] . "/includes/widgets/AdminTextbox.inc.php" );

	class AdminAutocomplete extends AdminTextbox {
		protected $bStrict = false;

		public function setStrict( $v ) { $this->bStrict = $v; }

		public function __construct( $id , $parent = NULL ) {
			parent::__construct( $id , $parent );
		}

		protected function getAutocompleteHints( $filter ) { return array(); }
		protected function getLabelForId( $id ) { return ""; }

		public function handleEvents() {
			if (!isset( $this->aP["inajax"] )) return parent::handleEvents();
			if (!isset( $this->aP["id"] )) return parent::handleEvents();
			if (!isset( $this->aP["ajaxevent"] )) return parent::handleEvents();
			if ($this->aP["id"]!=$this->getId()) return parent::handleEvents();
			switch ($this->aP["ajaxevent"]) {
			case "get_autocomplete_hints":
				$retval = $this->getAutocompleteHints( $this->aP["filter"] );
				FNTH_echo_json_response( $retval );
				fo3_exit();
			}
			return parent::handleEvents();
		}

		public function render() {
			if ($this->sRendered) return $this->sRendered;
			$this->setParam( "bStrict" , $this->bStrict );
			$data = array();
			$data["strict"]=$this->bStrict;
			$this->setParam( "value_inp" , $this->getLabelForId( $this->getValue() ) );
			FNTHPage::addUniquePageFullInit( sprintf( "InitAdminAutocomplete( '%s' , %s );" , $this->getId() , json_encode( $data ) ) );
			return parent::render();
		}

	}


?>
