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

	require_once( $GLOBALS["site_root"] . "/includes/models/AllUsers.inc.php" );
	require_once( $GLOBALS["site_root"] . "/includes/models/AllJobs.inc.php" );

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

	class InfoPanel extends Widget {
		protected $aTickerParams = array();
		protected $facebook_iframe_src = "http://www.facebook.com/plugins/likebox.php";
		protected $facebook_iframe_params = array(
			"href" => "facebook.com%2Fforditok.tolmacsok",
			"width" => 250,
			"colorscheme" => "light",
			"show_faces" => "true",
			"stream" => "false",
			"header" => "false",
			"connections" => 4,
			"height" => 195 );

		public function __construct( $id = "InfoPanel" , $parent = null ) {
			parent::__construct( $id , $parent );
			$GLOBALS["GlobalInfoPanel"] = $this;
		}

		/*
		public static function addTickerInfo( $tickerinfo ) {
			if (!isset( $GLOBALS["GlobalInfoPanel"] )) return;
			$GLOBALS["GlobalInfoPanel"]->setTickerInfo( $tickerinfo );
		}
		*/


		protected function generateLangDefs() {
			fo3_add_js_langdef( "Please_type_at_least_2_chars" );
		}
		
		protected function getGlobalInfo() {
			$allusers = new AllUsersModel();
			$alljobs = new AllJobsModel();
			$globalinfo = array();
			// if (isset( $this->aP["first"])) {
				$globalinfo["t_numofagencies"]=$allusers->getActiveAgencies();
				$globalinfo["t_numoffreelancers"]=$allusers->getActiveFreelancers();
				$globalinfo["t_numofparttimers"]=$allusers->getActiveParttimers();
				$globalinfo["t_numoftranslationjobs"]=$alljobs->getActiveJobs();
				$globalinfo["t_numofallmembers"]=$allusers->getAllMembers();
			// }
			$globalinfo["t_online_users"]=$allusers->getOnlineUsers();
			$globalinfo["t_online_members"]=$allusers->getOnlineUsers( 1 );
			return $globalinfo;
		}

		protected function generateArticleParams() {
			$this->setParam( "url_information1" , ArticleURL::renderURLFromArticleName( "informacio1" ) );
			$this->setParam( "url_legend" , ArticleURL::renderURLFromArticleName( "legend" ) );
			$this->setParam( "url_education" , ArticleURL::renderURLFromArticleName( "education" ) );
		}

		public function render() {
			if ($this->sRendered) return $this->sRendered;
			$this->setParam( "bDebug" , FNTHPage::isDebugPage() );
			$this->generateLangDefs();
			$members = new MembersModel();
			if ($GLOBALS["language"]=="hu")
				$this->setParam( "last_registered_members" , $members->getLastRegisteredMembers() );
			$this->setParam( "globalinfo" , $this->getGlobalInfo() );
			$data = array();
			$data["facebook_iframe_src"]=$this->facebook_iframe_src;
			$data["facebook_iframe_params"]=$this->facebook_iframe_params;
			FNTHPage::addUniquePageFullInit( sprintf( "InitInfoPanel('%s',%s);",
				$this->getId(),json_encode( $data ) ) );

			$this->generateArticleParams();
			return parent::render();
		}
	}	
?>
