<?php
/**
 * 志愿者活动状态
 * $Id$
 * @author zongbiao
 * @package jp.fishow.entity.definition
 */
class EventStatus
{
	public $id;
	public $name;
	public $title;
	
	function __construct($record) {
		$this->id = $record["id"];
		$this->name = $record["name"];
		$this->title = $record["title"];
	}
	
	/**
	 * 返回示例的列表
	 * @return array ImageType一覧
	 */
	public static function getList() {
		static $result;
			
		if ((!is_array($result)) || (count($result) < 1)) {
			
			$data = array();
			$tmp = array("id"=>1, "name"=>"NEW", "title"=>"审核中");
			array_push($data, $tmp);
			
			$tmp = array("id"=>2, "name"=>"NG", "title"=>"审核不通过");
			array_push($data, $tmp);
			
			$tmp = array("id"=>3, "name"=>"OK", "title"=>"征集中");
			array_push($data, $tmp);
			
			$tmp = array("id"=>4, "name"=>"FINISH", "title"=>"已结束");
			array_push($data, $tmp);
			
			$result = array();
			foreach ($data as $row) {
				$tmp2 = new EventStatus($row);
				array_push($result, $tmp2);
			}
		}
		return $result;
	}
	
	/**
	 * 通过定义名称获取object
	 * @return EventStatus 对应实例。没有的时候返回null。
	 */
	public static function getByName($name) {
		$list = EventStatus::getList();
		foreach ($list as $tmp) {
			if ($tmp->name == $name) {
				return $tmp;
			}
		}
		return null;
	}
	
	/**
	 * 通过定义名称获取title
	 */
	public static function getTitleByName($name) {
		$list = EventStatus::getList();
		foreach ($list as $tmp) {
			if ($tmp->name == $name) {
				return $tmp->title;
			}
		}
		return null;
	}

}