<?php
/*
* Created on 25.03.2006 by *Camper*
*/
class page_Application extends Page{
function init(){
parent::init();
$this->add('ListApplication', null, 'Content');
if($_GET['application_id'])$this->add('Text', 'reload', 'Content')
->set("<img src=\"amodules3/templates/shared/pixel.gif\" onLoad=\"".
$this->api->getScriptRenderFunc($_GET['application_id'])."\">");
}
function defaultTemplate(){
return array('application', '_top');
}
}
class ListApplication extends Grid{
function init(){
parent::init();
$this
->addColumn('ajax', 'name', 'Application name')->makeSortable()
->addColumn('text', 'description', 'Description')
->addColumn('text', 'dirname', 'Deploy dirname')
->addColumn('version,expander', 'version', 'Version')
->addColumn('text', 'svn', 'Do svn add')
->addColumn('expander', 'edit', 'Edit')
->addColumn('deploy,expander', 'deploy', 'Deploy')
->setSource('application a')
;
$this->addButton('Add application')->redirect('AddApplication');
$this->add('Paginator', null, 'paginator');
}
function format_version($field){
$ver = $this->api->db->getOne('select name from version where application_id = '.
$this->current_row['id'].' order by id desc');
if($ver == '')$ver = 'Add version';
$this->current_row[$field] = $ver;
}
function format_deploy($field){
$undeployed=$this->api->db->getHash("select id, name from version where application_id=".
$this->current_row['id']." and deploy_dts is null");
if($undeployed['id']!=''){
$isuptodate=$this->api->db->getOne("select count(*) from script where version_id=".
$undeployed['id'])==0;
$this->current_row[$field]=$isuptodate?"Is up to date":"<strong>Deploy version {$undeployed['name']}</strong>";
}else{
$this->current_row[$field]="Is up to date";
}
}
function format_ajax($field){
$onclick=$this->api->getScriptRenderFunc($this->current_row['id']);
//$onclick="alert('1')";
$caption="<a href=#Script onclick=\"".$onclick.
"\">".
$this->current_row[$field]."</a>";
$this->current_row[$field]=$caption;
}
private function getVerId($id){
return $this->api->db->getOne("select id from version where application_id = $id order by id desc");
}
function format_link($field){
$app = $this->current_row[$field];
$app_id = $this->current_row['id'];
$this->current_row[$field]="<a href=".$this->api->getDestinationURL('Script', array('application_id'=>
$app_id, 'ver'=>$this->getVerId($app_id))).">".$app."</a>";
}
}
class FormInsert extends Text{
function init(){
parent::init();
$this->set("<a href=".$this->api->getDestinationURL('AddApplication').">Add application</a>");
}
}
?>