这个图表非常复杂,需要仔细分析下:
Level1的比赛信息的格式有一些不同,其他level上面的就都是一样了。
将 /administrator/components/com_joomsport/admin.joomsport.html.php
中的方法bl_editMatch做修改:
将:
<!-- level -->
<?php
if(3 == $lists['tourn_type'])
{
?>
<tr>
<td>
<?php echo JText::_( "級別" ); ?>
</td>
<td>
<?php
echo JHTML::_('select.genericlist',
$lists['levels'],
'level',
'class="inputbox"',
'id',
'lev_name',
( (isset($row->level)) ? $row->level : 0 )
);
?>
</td>
</tr>
<?php
}
?>
<!-- end by Vincent 6th-Dec-2011 -->
改为:来为淘汰盃的比赛也增加level字段的编辑界面,但是请注意此处将不同于主席盃,不再是一个下拉列表
<!-- level -->
<?php
if(3 == $lists['tourn_type'])
{
?>
<tr>
<td>
<?php echo JText::_( "級別" ); ?>
</td>
<td>
<?php
echo JHTML::_('select.genericlist',
$lists['levels'],
'level',
'class="inputbox"',
'id',
'lev_name',
( (isset($row->level)) ? $row->level : 0 )
);
?>
</td>
</tr>
<?php
}
else if(2 == $lists['tourn_type'])
{
?>
<tr>
<td>
<?php echo JText::_( "級別" ); ?>
</td>
<td>
<input type="text" maxlength="1" size="2" name="level" value="<?php echo (isset($row->level)) ? $row->level : 0;?>" />
</td>
</tr>
<?php
}
?>
<!-- end by Vincent 6th-Dec-2011 -->
除此以外,我们需要多两个字段来记录一个新出现的信息:
将两个字段放在match表里,名为alias1和alias2;
将文件
/administrator/components/com_joomsport/admin.joomsport.class.php
添加这两个新字段:
class JTableMatch extends JTable
{
var $id = null;
var $m_id = null;
var $team1_id = null;
var $team2_id = null;
var $score1 = null;
var $score2 = null;
// added by Vincent 9th Dec 2011
var $number_label1 = null;
var $number_label2 = null;
// end
// added by Vincent 10th Dec 2011
var $comment1 = null;
var $comment2 = null;
// end
// added by Vincent 15th Jan 2012
var $alias1 = null;
var $alias2 = null;
// end
var $match_descr = null;
var $published = null;
var $is_extra = null;
var $m_played = null;
var $m_date = null;
var $m_time = null;
var $m_location = null;
var $bonus1 = null;
var $bonus2 = null;
var $m_remark = null;
//added by Vincent 5th Dec 2011
var $grp_id = null;
var $ordering = null;
var $level = null;
function __construct( &$db )
{
parent::__construct( '#__bl_match', 'id', $db );
}
}
将 /administrator/components/com_joomsport/admin.joomsport.html.php中的方法bl_editMatch:
<!-- added by Vincent 15th-Jan-2012 -->
<?php
if(2 == $lists['tourn_type'])
{
?>
<tr>
<td width="100">
<?php echo JText::_( '用於淘汰盃賽事第二至四階段的球隊介紹' ); ?>
</td>
<td>
<?php echo $lists['teams1'].' <input type="text" name="alias1" value="'.$row->alias1.'" size="5" maxlength="15" />?:?<input type="text" name="alias2" value="'.$row->alias2.'" size="5" maxlength="15" /> '.$lists['teams2'];?>
</td>
</tr>
<?php
}
?>
<!-- end -->
另外,现在系统将容许用户创建一个比赛,该比赛的主场与客场是同一个球队,将文件/administrator/components/com_joomsport/admin.joomsport.html.php中的方法bl_editMday:去掉其JavaScript函数中,对于同一场比赛两支球队需要ID不同的验证
function bl_add_match(){
var team1 = getObj('teams1');
var team2 = getObj('teams2');
var score1 = getObj('add_score1').value;
var score2 = getObj('add_score2').value;
var tm_played = getObj('tm_played').checked;
if (team1.value == 0 || team2.value == 0) {
alert("<?php echo JText::_( 'BLBE_JSMDNOT1' ); ?>");return;
}
if (((score1) == '' || (score2) == '') && tm_played){
alert("<?php echo JText::_( 'BLBE_JSMDNOT1' ); ?>");return;
}
//commented by Vincent 15th Jan 2012
//if ( team1.value == team2.value ){
//alert("<?php echo JText::_( 'BLBE_JSMDNOT2' ); ?>");return;
//}
--------------------------------------------------------------------以上部分已与server同步---------------------------------------------------------------------------------
在/components/com_joomsport/views/competebranch/tmpl/路径下创建两个文件:kickoffSecondPart.php与kickoffSecondPart.xml
kickoffSecondPart.xml内容如下:
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<layout title="淘汰盃第二至四階段佈局">
<message>
<![CDATA[賽事晉級圖淘汰盃第二至四階段佈局]]>
</message>
</layout>
<state>
<name>賽事晉級圖淘汰盃第二至四階段佈局</name>
<description>賽事晉級圖淘汰盃第二至四階段佈局</description>
<url addpath="/administrator/components/com_joomsport/elements">
<param name="sid" type="season" default="0" label="Select Season" description="Season" />
<param name="md_id" type="matchday" default="0" label="Select matchday" description="MatchDay of stage" />
</url>
<params>
</params>
</state>
</metadata>
这部分之后可能会再调整,一会儿再回来。
另外:对该视图的default.xml和kickoff.xml做修改,来区别不同局部。
现在来看这个视图的main controller文件:/components/com_joomsport/views/competebranch/view.html.php
在display方法里加入代码:
/*
* added by Vincent 15 Jan 2012
*/
if($this->getLayout() == 'kickoffSecondPart') {
$this->_displayKickoffSecondPart($tpl);
return;
}
所以,现在来看下这个新的成员方法_displayKickoffSecondPart应该完成哪些事。
1. 首先,前三个任务与上一个布局一样,它应该得到参数,即是season id与matchday id;
2. 根据season id得到比赛名称;
3. 得到当下的联赛盃season id,用它来确定每个team所属的group(甲乙丙丁);
1.