Change Log of Joomsport: [VIEW]晉級圖-主席盃、碟及盾:给match表增加三个字段:grp_id,ordering,level(synchronized with ser

来源:互联网 发布:企业秀软件下载 编辑:程序博客网 时间:2024/06/08 16:41

Target:


For extended functionalities of [赛事晋级图]. Match table should have at least more 3 fields: grp_id, ordering and level.


grp_id: the match belongs to witch Group: A组, B组...

ordering: the order of the matches within the same group

level: the level of the match, 四分之一决赛(quarterfinal),半决赛(semi-final),决赛(final match)


let's add these fields to database:


grp_id


other-two-fields


sql-creat-two-fields


The type of 'level' is ENUM, which is the first time I use it, just for using it, because never tried.


PHP Change:


/administrator/components/com_joomsport/admin.joomsport.class.php:


note the lines following coment:

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;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 2011var $grp_id= null;var $ordering= null;var $level= null;function __construct( &$db ){parent::__construct( '#__bl_match', 'id', $db );}}


go to: /administrator/components/com_joomsport/admin.joomsport.php


add lines to function 'BL_MatchEdit':


// added by Vincent Zhang 6th-Dec-2011$levels = array();$levels[] = JHTML::_('select.option',  0, JText::_('選擇比賽級別'), 'id', 'lev_name' );$levels[] = JHTML::_('select.option',  1, JText::_('八強賽'), 'id', 'lev_name' );$levels[] = JHTML::_('select.option',  2, JText::_('四強賽'), 'id', 'lev_name' );$levels[] = JHTML::_('select.option',  3, JText::_('決賽'), 'id', 'lev_name' );$lists['levels'] = $levels;// end


and we can leave function 'BL_MatchSave' definition as it be.



/administrator/components/com_joomsport/admin.joomsport.html.php

add lines to function 'bl_editMatch':


<!-- level added by Vincent 6th-Dec-2011 --><tr><td><?php echo JText::_( "級別" ); ?></td><td><?phpecho JHTML::_('select.genericlist',$lists['levels'],'level','class="inputbox"','id','lev_name',( (isset($row->level)) ? $row->level : 0 ));  ?></td></tr>


For 'grp_id', add lines to function 'BL_MatchEdit':


$is_groups = array();$query = "SELECT id, group_name FROM #__bl_groups WHERE s_id = ".$season_id;$db->setQuery($query);$groups = $db->loadObjectList();$is_groups[] = JHTML::_('select.option',  0, JText::_('BLBE_SELGROUP'), 'id', 'group_name' );$groupis = array_merge($is_groups, $groups);$lists['groups'] = JHTML::_('select.genericlist', $groupis, 'grp_id', 'class="inputbox" size="1"', 'id', 'group_name', ( (isset($row->grp_id)) ? $row->grp_id : 0 ));


Please note that:


1.  the last parameter passed to JHTML::_ is the field name in database table: group_name, otherwise, the drop-down list item doesn't have label;

2. the 3rd parameter passed ot JHTML::_('select.genericlist') is the field name, namely the member variable's name of this match class: 'grp_id', it must be the same, because it is used as this HTML input control's name.


/administrator/components/com_joomsport/admin.joomsport.html.php:


<!-- ordering added by Vincent 6th-Dec-2011 --><tr><td width="100"><?php echo JText::_( 'BLBE_GROUPNAME' ); ?></td><td><?php echo $lists['groups'];?></td></tr><!-- ordering added by Vincent 6th-Dec-2011 --><tr><td><?php echo JText::_('BLBE_ORDERING');?></td><td><input type="text" maxlength="1" size="2" name="ordering" value="<?php echo htmlspecialchars($row->ordering);?>" /></td></tr>



原创粉丝点击