<?php
class <!--{$class_name}--> extends myQuicty {

function pre_dispatch_index() {
	parent::pre_dispatch_index();
	$this->page['base_url'] = quicty_base_url();
	$this->page['data_name'] = '<!--{$data_name}-->';
	return true;
}

function file_upload() {
	$this->form = $this->new_data_obj('<!--{$data_name}-->');
	$this->form->bind_data_view('<!--{$data_name}-->.view.conf');
	$this->form->set_base_link_addr(quicty_base_url().'<!--{$dir_name}-->/upload.html');
	$this->form->set_restart_link_addr(quicty_base_url().'<!--{$dir_name}-->/upload.html');
	$this->form->validate_and_freeze();
	$this->form->set_button_label('insert','アップロード');
	$this->form->set_button_status('use_confirm',false);
	$this->form->bind_button_control();
	$this->form_insert_message = 'アップロードしました';
	if($this->QuictyStatus=='INSERT') {
		$file = $this->form->move_upload_file2dir();
		if($file['result']) {
			$message .= 'uploaded dir = '.$file['dir']."\n";
			$message .= 'file name = '.$file['name']."\n";
			$message .= 'file path = '.$file['path']."\n";
			$message .= 'file type = '.$file['type']."\n";
			$message .= 'file size = '.$file['size']."\n";
			$message .= 'mime type = '.$file['mime_type']."\n";
			if(substr($file['mime_type'],0,5)=='text/') {
				$file_body = file_get_contents($file['path']);
				$message .= "\nfile body-----------\n\n".$file_body;
			}
		}
	}
	$result['message'] = $message;
	return $result;
}

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

function dispatch_index() {
	$this->page['name'] = '<!--{$page_title}-->のアップロード';
	$result = $this->file_upload();
	$this->assign_form('input_form',$this->form);
	$this->page['message'] = nl2br($result['message']);
	$this->assign('page',$this->page);
	$this->display($this->current_template);
}


} // end of class <!--{$class_name}-->
?>