Location: PHPKode > projects > AModules3 > amodules-3.0.1/mini-apps/02-DBver_control/main.php
<?php
/*
 * Created on 25.03.2006 by *Camper*
 */
include "../../trunk/loader.php";
class DBver extends ApiAdmin{
	public $logger;
    public $apinfo=array(
            'version'=>'0.41',
            'release'=>'0.5',
            'name'=>'DB Version control'
            );
	
	function init(){
		$this->readConfig('config.php');
		parent::init();
		$this->logger=$this->add('Logger');
		$this->dbConnect();
		$this->api->add('VersionControl');
		$this->template->trySet('page_title', $this->apinfo['name']);

		$this->template->del('Content');
		$this->template->del('Locator');
		$this->template->del('msgbox');
		$this->template->del('RightSidebar');
		$this->template->del('InfoWindow');
	}
	function layout_Menu(){
		$this->add('Menu', null, 'Menu')
			->addMenuItem('Application')
			->addMenuItem('About')
		;
	}		
	function initLayout(){
		$this
			->addLayout('Content')
			->addLayout('Menu')
		;
	}
	function page_Index(){
		$this->redirect('Application');
	}
	function page_AddApplication($p){
		$this->frame('Content', 'Add application')->add('FormApplication', null, 'content');
	}
	function page_Application($p){
		$this->add('page_Application', null, 'Content');
	}
	function page_AddVersion($p){
		$this->frame('Content', 'Add version for '.$this->getAppName($this->recall('application_id')), $p)
			->add('FormVersion', null, 'content');
	}
	function getAppName($id){
		return $this->api->db->getOne("select name from application where id=$id");
	}
	function getCurrentVersion($app_id){
		if(!$app_id)throw new BaseException('Application ID is not defined. Ask developer to straighten his hands.');
		$old_ver=$this->db->getOne("select max(name) from version where application_id=$app_id");
		return $old_ver;
	}
	function getCurrentVersionId($app_id){
		if(!$app_id)throw new BaseException('Application ID is not defined. Ask developer to straighten his hands.');
		$old_ver=$this->db->getOne("select max(id) from version where application_id=$app_id");
		return $old_ver;
	}
	function getNextVersion($app_id){
		$old_ver=$this->getCurrentVersion($app_id);
		$new_ver=round($old_ver+0.1, 1);
		return $new_ver;
	}
	function getScriptRenderFunc($app_id){
		return "aasn('Script','".
					$this->api->getDestinationURL('Script', array(
						'id'=>$app_id,
						'application_id'=>$app_id,
	                    'cut_object'=>'Script'
				))."')";
	}
}
		
$db_ver = new DBver('DBver_control');
$db_ver->main();
Return current item: AModules3