Example #1
0
/**
 * 支持的字段有
 * member表中的所有字段,ucenter_member表中的所有字段
 * 等级:title
 * 头像:avatar32 avatar64 avatar128 avatar256 avatar512
 * 个人中心地址:space_url
 * 认证图标:icons_html
 *
 * @param $fields array|string 如果是数组,则返回数组。如果不是数组,则返回对应的值
 * @param null $teamid
 * @return array|null
 */
function query_team($fields, $teamid = null)
{
    //如果fields不是数组,则返回值也不是数组
    if (!is_array($fields)) {
        $result = query_team(array($fields), $teamid);
        return $result[$fields];
    }
    //默认获取自己的资料
    $teamid = $teamid ? $teamid : 1;
    if (!$teamid) {
        return null;
    }
    //查询缓存,过滤掉已缓存的字段
    $cachedFields = array();
    $cacheResult = array();
    foreach ($fields as $field) {
        $cache = read_query_team_cache($teamid, $field);
        if (!empty($cache)) {
            $cacheResult[$field] = $cache;
            $cachedFields[] = $field;
        }
    }
    //获取两张用户表格中的所有字段
    $teamModel = M('Team');
    $teamFields = $teamModel->getDbFields();
    $teamFields = array_intersect($teamFields, $fields);
    //查询需要的字段
    $teamResult = array();
    if ($teamFields) {
        $teamResult = $teamModel->where(array('id' => $teamid))->field($teamFields)->find();
    }
    //读取头像数据
    $result = array();
    //读取头像数据
    if (in_array('cover', $fields)) {
        $result['cover'] = query_picture('url', $teamResult['cover']);
    }
    //合并结果,不包括缓存
    $result = array_merge($teamResult, $result);
    //写入缓存
    foreach ($result as $field => $value) {
        $result[$field] = $value;
        write_query_team_cache($teamid, $field, str_replace('"', '', $value));
    }
    //合并结果,包括缓存
    $result = array_merge($result, $cacheResult);
    //返回结果
    return $result;
}
 public function add($matchid = null)
 {
     if (IS_POST) {
         $MatchGame = D('MatchGame');
         $res = $MatchGame->update();
         $red_team_name = trim(query_team('name', I('post.red_team')));
         $bule_team_name = trim(query_team('name', I('post.blue_team')));
         $map['tid'] = I('post.blue_team');
         $members = D('TeamMember')->getMembersInfo($map);
         foreach ($members as $member) {
             $data['uid'] = $member['uid'];
             $data['match_game_id'] = $res;
             $data['game_place'] = $member['place'];
             $data['team_id'] = $member['tid'];
             D('MatchGameMember')->add($data);
         }
         $map['tid'] = I('post.red_team');
         $members = D('TeamMember')->getMembersInfo($map);
         foreach ($members as $member) {
             $data['uid'] = $member['uid'];
             $data['match_game_id'] = $res;
             $data['game_place'] = $member['place'];
             $data['team_id'] = $member['tid'];
             D('MatchGameMember')->add($data);
         }
         $guess['end_time'] = I('post.start_time');
         $guess['match_game_id'] = $res;
         $guess['game_id'] = I('post.game_id');
         $guess['match_id'] = I('post.match_id');
         $GuessWin = D('GuessWin');
         $resGuess = $GuessWin->addGuessWin($guess);
         if (false !== $resGuess) {
             $this->success('新增成功!', U('index?matchid=' . I('match_id')));
         } else {
             $error = $GuessWin->getError();
             $this->error(empty($error) ? '未知错误!' : $error);
         }
     } else {
         empty($matchid) && $this->error('参数错误!');
         $games = $this->getGames();
         $teams = $this->getTeams($matchid);
         $this->assign('teams', $teams);
         $this->assign('match_id', $matchid);
         $this->assign('games', $games);
         $this->meta_title = '添加小组赛';
         $this->display('edit');
     }
 }
<div class="form-item"><label class="item-label">蓝队结果:<?php 
echo query_team('name', $matchgame['blue_team']);
?>
<span
	class="check-tips">蓝队结果</span></label>
<div class="controls"><input type="text" class="text input-large"
	name="blue_team" value="<?php 
echo isset($matchgamedetail["blue_team"]) && $matchgamedetail["blue_team"] !== "" ? $matchgamedetail["blue_team"] : '0';
?>
"></div>
</div>


<div class="form-item"><label class="item-label">红队结果:<?php 
echo query_team('name', $matchgame['red_team']);
?>
<span
	class="check-tips">红队结果</span></label>
<div class="controls"><input type="text" class="text input-large"
	name="red_team" value="<?php 
echo isset($matchgamedetail["red_team"]) && $matchgamedetail["red_team"] !== "" ? $matchgamedetail["red_team"] : '0';
?>
"></div>
</div>

 
 <div class="form-item"><label class="item-label">视频ID<span
	class="check-tips">视频ID</span></label>
<div class="controls"><input type="text" class="text input-large"
	name="video_id" value="<?php 
                        ?>


														</div>
														<div class="width33"></div>
														<div class="width33">
															<?php 
                        if ($game['red_team']) {
                            ?>
<a
																href="<?php 
                            echo U('/matchgame/' . $game['id']);
                            ?>
">
																<?php 
                            echo query_team('name', $game['red_team']);
                            ?>
</a> <?php 
                        } else {
                            ?>
															<div class="vs">弃权</div><?php 
                        }
                        ?>
														</div>

													</div>
												</div>
											</li><?php 
                    }
                }
            } else {
            } else {
                ?>
 弃权<?php 
            }
            ?>
</li>
					<li></li>
					<li><?php 
            if ($guess['red_team']) {
                ?>
<a
							href="<?php 
                echo U('/team/' . $guess['red_team']);
                ?>
"><?php 
                echo query_team('name', $guess['red_team']);
                ?>
</a>
						<?php 
            } else {
                ?>
 弃权<?php 
            }
            ?>
</li>
				</ul>
			</div>
			<div class="guess-item-des">
				<ul>
					<li><span class="pull-left"><a
							href="<?php 
<div class="controls"><input type="text" class="text input-large"
	name="character" value=""></div>
</div>
 
<div class="form-item"><label class="item-label">邮箱<span
	class="check-tips">(用户邮箱,用于找回密码等安全操作)</span></label>
<div class="controls"><input type="text" class="text input-large"
	name="email" value=""></div>
</div>
<div class="form-item"><input type="hidden" value="<?php 
echo $team_id;
?>
"
	name="tid" /> <input type="hidden"
	value="<?php 
echo query_team('name', $team_id);
?>
" name="team_name" />
<button class="btn submit-btn" id="submit" type="submit"
	target-form="form-horizontal">确 定</button>
<button class="btn btn-return"
	onclick="javascript:history.back(-1);return false;">返 回</button>
</div>
</form>
</div>
<div class="cont-ft">
<div class="copyright">
<div class="fl">感谢使用<a href="http://www.quntiao.com/"
	target="_blank">群挑网</a>管理平台</div>
<div class="fr">V<?php 
echo QUNTIAO_VERSION;
                ?>
</td>
			<td><?php 
                echo $vo["blue_team"];
                ?>
</td>
			<td><?php 
                echo $vo["red_team"];
                ?>
</td>
			<td><?php 
                echo $vo["game_order"];
                ?>
</td>
			<td><?php 
                echo query_team('name', $vo['winner']);
                ?>
</td>
			<td><?php 
                echo $vo["status"];
                ?>
</td>
			<td>
			  <a
				href="<?php 
                echo U('MatchGameDetail/edit?id=' . $vo['id'] . '&&matchagemid=' . $matchgameid);
                ?>
" class="authorize">编辑</a>
			<a
				href="<?php 
                echo U('MatchGameDetail/delete?id=' . $vo['id'] . '&&matchgameid=' . $matchgameid);
    if (count($__LIST__) == 0) {
        echo "";
    } else {
        foreach ($__LIST__ as $key => $team) {
            $mod = $i % 2;
            ++$i;
            ?>
<li class="col-xs-4">
										<div>
											<a href="<?php 
            echo U('/team/' . $team['id']);
            ?>
"> <img
												src="/Public/Core/images/placeholder.png"
												lazy-src="<?php 
            echo query_team('cover', $team['id']);
            ?>
"
												alt="<?php 
            echo $team['name'];
            ?>
" width="52" height="52"></a>
										</div>
										<div class="team_name"><?php 
            echo $team['name'];
            ?>
</div>
									</li><?php 
        }
    }
} else {
			</li>
			<li></li>
		 <li>
		 
		
			
			
				<?php 
            if ($hotmatch['red_team']) {
                ?>
<a
		href="<?php 
                echo U('/matchgame/' . $hotmatch['id']);
                ?>
"><?php 
                echo query_team('name', $hotmatch['red_team']);
                ?>
</a>
			<?php 
            } else {
                ?>
		弃权<?php 
            }
            ?>
		
			</li>

	</ul>
	</div>
	<div class="hot-match-item-des">
	<ul>
            } else {
                ?>
 弃权<?php 
            }
            ?>
</li>
											<li></li>
											<li><?php 
            if ($newmatch['red_team']) {
                ?>
<a
													href="<?php 
                echo U('/matchgame/' . $newmatch['id']);
                ?>
"><?php 
                echo query_team('name', $newmatch['red_team']);
                ?>
</a>
												<?php 
            } else {
                ?>
 弃权<?php 
            }
            ?>
</li>

										</ul>
									</div>
									<div class="new-match-item-des">
										<ul>