<?php
class datasets_form_options extends myQuicty {

function __construct($page) {
	parent::__construct();
	$this->page = $page;
	$this->form = $this->page->form;
}

function set_form_options() {
	$this->form->set_base_link_addr(quicty_base_url().'/datasets/');
	$this->form->set_restart_link_addr(quicty_base_url().'/datasets/');
	$this->form->set_button_status('use_confirm',false);
	
	if($_REQUEST['application_id']) {
		$this->application = $this->select_row('application','where id='.$_REQUEST['application_id']);
		$defaults['dbname'] = $this->application['db_name'];
		$defaults['system'] = $this->application['system'];
		$defaults['path'] = $this->application['path'];
		$defaults['host'] = $this->application['host'];
		$defaults['port'] = $this->application['port'];
		$defaults['user'] = $this->application['user'];
		$defaults['password'] = $this->application['password'];
		$defaults['persistent'] = $this->application['persistent'];
	}
	$defaults['default_sort'] = 'id';
	$this->form->setDefaults($defaults);
}

// filters

function default_path($value) {
	$system = $this->form->getElementValue('system');
	if(!$value AND ($system[0]=='sqlite' OR $system[0]=='sqlite3')) 
		$value = 'var/sqlite';
	return $value;
}

function set_form_filters() {
	$this->form->applyFilter('_ALL_','trim');
	$this->form->applyFilter('path',array($this,'default_path'));
}

} // end of class datasets_form_options
?>