<?php
	FNTH_class( "Textbox" );

	class AdminTextbox extends FNTHTextbox {
		protected $bShowTitle = false;
		protected $sOnEnter = "";

		public function setShowTitle( $v ) { $this->bShowTitle = $v; }

		public function modifyGetPost( &$g, &$p ) {
			$id = $this->getId();
			if (isset( $this->aG[$id] )) $this->setValue( $this->aG[$id] );
			if (isset( $this->aP[$id] )) $this->setValue( $this->aP[$id] );
			parent::modifyGetPost( $g , $p );
		}

		public function setOnEnterCallback( $cb ) {
			$this->sOnEnter = $cb;
		}

		public function __construct( $id = "AdminTextbox" , $parent = null ) {
			$this->addMediaDirectory( $GLOBALS["site_root"] , $GLOBALS["site_www"] , "design/rp/","widgets/");
			parent::__construct( $id , $parent );
			$this->setAttribute( "class" , "AdminTextbox" );
			$this->setParam("language",$GLOBALS["language"]);
		}

		public function render() {
			$this->setParam( "bShowTitle" , $this->bShowTitle );
			$datas = array();
			if (!empty( $this->sOnEnter ))
				$datas["on_enter_callback"] = $this->sOnEnter;

			FNTHPage::addUniquePageFullInit( sprintf( "InitAdminTextbox('%s',%s);" , $this->getId() , json_encode( $datas ) ) );
			return parent::render();
		}

	}
?>
