<?php
// ÆÀÂÛÄ£¿é
class AnnouncementAction extends Action {
	public function defaults($id = 0) {
		$id or $id = intval(R('id'));
		$isCreateHtml = defined('IN_CREATEHTML');
		if (C('urlmodel') == 1) {
			$url = Url :: getContentUrl('announcement', $id);
			$path = Url :: getContentPath('announcement', $id);
			if (is_file($path)) {
				if (!$isCreateHtml) {
					header('Location:' . $url);
					exit;
				}
			} else $isCreateHtml = true;
		}
		$data = M('announcement') -> find($id);
		$this -> assign('extract', $data);
		$tpl = 'announcement';
		if ($isCreateHtml) {
			$html = $this -> fetch($tpl);
			$size = FileUtil :: write($path , $html);
			if (!defined('IN_CREATEHTML')) {
				echo $html;
			} else {
				return $size;
			}
		} else $this -> display($tpl);
	}
}