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


	class MemberSitemapPanel extends Widget {
		protected $sType = "freelancer";


		public function setType( $v ) { $this->sType = $v; }

		protected function getMembers() {
			$query = sprintf( "select member_id from members where member_type='%s' and expires_tstamp>now() and not is_deleted order by member_id" , FNTH_db_addslashes( $this->sType ) );
			$retval = array();
			$member_ids = FNTH_db_get_column( $query , "member_id" );
			$mm = new MemberModel();
			$retval = $mm->getMembersFromMemberIds( $member_ids );
			return $retval;
		}

		protected function getTitle() {
			switch ($this->sType) {
			case "freelancer":$val=__("usertype_freelancers");break;
			case "parttime":$val=__("usertype_parttimers");break;
			case "agency":$val=__("usertype_agencies");break;
			}
			return strtoupper( substr( $val , 0 , 1 ) ) . substr( $val , 1 );
		}

		public function render() {
			if ($this->sRendered) return $this->sRendered;
			$this->setParam( "title" , $this->getTitle() );

			getFNTHPerformance()->checkPoint( "before" );
			$this->setParam( "members" , $this->getMembers() );
			getFNTHPerformance()->checkPoint( "after" );
			$this->setParam( "performance" , getFNTHPerformance()->renderTimes() );
			// echo getFNTHPerformance()->renderTimes();exit();

			return parent::render();
		}

	}

?>
