<?php
class index extends myQuicty {

public function pre_dispatch_index() {
	parent::pre_dispatch_index();
	$this->caching = 0;// caching page
	$this->cache_id = get_query_id();
	$this->page['base_url'] = quicty_base_url();
	return true;
}

function list_record() {
	$this->cache_lifetime = 1800;
	if(!$this->is_cached($this->current_template,$this->cache_id)) {
		$form = $this->new_data_set('subject');
		$perPage = 10;
		$condition = '';
		$form->bind_pager(array('perPage'=>$perPage,'condition'=>$condition,'prevImg'=>'前の'.$perPage.'件','nextImg'=>'次の'.$perPage.'件'));
		$table = $form->select_table_with_pager(' order by update_datetime desc');
		$this->assign('table_view',$form->display_table_value($table));
		$this->assign('display_cmd','info');
		$navi = $form->get_pager_links();
		$this->assign('pager_navi',$navi['all']);
		$this->assign('page',$this->page);
		//-- End of list_record
	}
	$result = $this->display($this->current_template,$this->cache_id);
}

function display_record($condition='') {
	$this->cache_lifetime = 36000;
	if(!$this->is_cached($this->current_template,$this->cache_id)) {
		$form = $this->new_data_set('subject');
		$form->set_base_link_addr(quicty_base_url().'/');
		$form->set_restart_link_addr(quicty_base_url().'/');
		if(($this->QuictyStatus=='INSERT' or $this->QuictyStatus=='UPDATE' or $this->QuictyStatus=='DELETE')
			and $this->user['level'] < registerd_user) {
				$this->page['message'] = "投稿・更新は、ログインしないと、できません\n";
				$this->QuictyStatus='START';
		}
		$form->validate_and_freeze();
		$form->bind_button_control();
		$result = $form->automatic_form_handler($condition);
		$this->subject = $result['values'];
		$this->assign_form('input_form',$form);
		$this->assign('page',$this->page);
		//-- End of display_record
		
	}
	$this->display($this->current_template,$this->cache_id);
}

//------------------------------------------------------------------

function dispatch_index() {
	$this->page['name'] = '話題の一覧';
	$this->list_record('');
}

function dispatch_add() {
	$this->page['name'] = '話題の追加';
	$this->display_record('');
}

function dispatch_info() {
	$this->page['name'] = '話題の表示';
	$condition = ' where id='.$_GET['id'];
	$this->display_record($condition);
}

function dispatch_edit() {
	$this->page['name'] = '話題の編集';
	$this->display_record($condition);
}

function dispatch_delete() {
	$this->page['name'] = '話題の削除';
	$this->display_record($condition);
}

} // end of index class
?>