-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaction.show_comp.php
More file actions
115 lines (110 loc) · 3.05 KB
/
Copy pathaction.show_comp.php
File metadata and controls
115 lines (110 loc) · 3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
/*
This file is part of CMS Made Simple module: Tourney.
Copyright (C) 2014-2016 Tom Phane <tpgww@onepost.net>
Refer to licence and other details at the top of file Tourney.module.php
More info at http://dev.cmsmadesimple.org/projects/tourney
Action to chart, list, print a tournament on a separate page in backend
*/
//setup for a full chart, or an un-labelled one, or a list
if (isset($params['chart']))
{
unset($params['chart']);
$titles = 1;
$list = FALSE;
}
elseif (isset($params['list']))
{
unset($params['list']);
$list = TRUE;
}
elseif (isset($params['print']))
{
unset($params['print']);
$titles = 0;
$list = FALSE;
}
else
{
$newparms = $this->GetEditParms($params,$params['active_tab']);
$this->Redirect($id,'addedit_comp',$returnid,$newparms);
}
$bracket_id = $params['bracket_id'];
$pref = cms_db_prefix();
$sql = 'SELECT * FROM '.$pref.'module_tmt_brackets WHERE bracket_id=?';
$bdata = $db->GetRow($sql,array($bracket_id));
//refresh the matches table, if necessary
$sch = new tmtSchedule();
switch ($bdata['type'])
{
case Tourney::DETYPE:
$sch->UpdateDEMatches ($this,$bracket_id);
break;
case Tourney::RRTYPE:
$sch->NextRRMatches($this,$bracket_id);
break;
default:
// case Tourney::KOTYPE:
$sch->UpdateKOMatches($this,$bracket_id);
break;
}
unset($sch);
$tplvars = array();
$lyt = new tmtLayout();
if (!$list)
{
$bdata['chartbuild'] = 1; //tell downstream that rebuild is needed
list($chartfile,$errkey) = $lyt->GetChart($this,$bdata,FALSE,$titles);
if ($chartfile)
{
$basename = basename($chartfile);
list($height,$width) = $lyt->GetChartSize();
$rooturl = (empty($_SERVER['HTTPS'])) ? $config['root_url'] : $config['ssl_url'];
$tplvars['image'] = $this->CreateImageObject($rooturl.'/tmp/'.$basename,(int)$height+30);
$tplname = 'admin_chart.tpl';
if($titles == 0)
//force refresh next time
$db->Execute(
'UPDATE '.$pref.'module_tmt_brackets SET chartbuild = 1 WHERE bracket_id=?',
array($bracket_id));
}
else
{
$message = $this->PrettyMessage('err_chart',FALSE);
if($errkey)
$message .= '<br /><br />'.$this->Lang($errkey);
$newparms = $this->GetEditParms($params,'charttab',$message);
$this->Redirect($id,'addedit_comp',$returnid,$newparms);
}
}
else
{
$res = $lyt->GetList($this,$bdata,FALSE);
if (is_array($res))
{
$tplvars['pagetitle'] = $bdata['name'];
if (!empty($bdata['description']))
$tplvars['pagedesc'] = $bdata['description'];
else
$tplvars['pagedesc'] = NULL;
$tplvars['items'] = $res;
$tplname = 'admin_list.tpl';
}
else //$res (if any) is error-message key
{
$message = $this->Lang('err_list');
if($res)
$message .= ': '.strtolower($this->Lang($res));
$newparms = $this->GetEditParms($params,'charttab',$message);
$this->Redirect($id,'addedit_comp',$returnid,$newparms);
}
}
unset($lyt);
$tplvars += array(
'startform' => $this->CreateFormStart($id,'show_comp',$returnid),
'endform' => $this->CreateFormEnd(),
'hidden' => $this->GetHiddenParms($id,$params),
'close' => $this->CreateInputSubmit($id,'cancel',$this->Lang('close'))
);
tmtTemplate::Process($this,$tplname,$tplvars);
?>