<?php
/**
 *	Project:	Quicty: Quick application build environment depends on PEAR and Smarty
 *	File:		Quicty/modules/template/bbs/lib/Pages/index.class.php
 *
 *	@copyright	Tomoyuki Negishi and ZubaPitaTech, Inc.
 *	@author		Tomoyuki Negishi <tomoyu-n@zubapita.jp>
 *	@license	http://www.opensource.org/licenses/bsd-license.php The BSD License
 *	@package	Quicty
 *	@version	$Id:$
 */
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();
	$this->site['name'] = 'Quicty Sample:BBS';
	$this->assign('site',$this->site);
	return true;
}

function list_record() {
	$this->cache_lifetime = 1800;
	if(!$this->is_cached($this->current_template,$this->cache_id)) {
		$form = $this->new_data_set('title');
		$perPage = 10;
		$condition = '';
		$form->bind_pager(array('perPage'=>$perPage,'condition'=>$condition,'prevImg'=>'前の'.$perPage.'件','nextImg'=>'次の'.$perPage.'件'));
		$table = $form->select_table_with_pager(' order by id');
		$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('title');
		$form->set_base_link_addr(quicty_base_url().'/');
		$form->set_restart_link_addr(quicty_base_url().'/');
		$form->validate_and_freeze();
		$form->bind_button_control();
		$result = $form->automatic_form_handler($condition);
		$this->title = $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
?>