コード例 #1
0
 /**
  * (non-PHPdoc)
  * @see IModel::getTemplateParameters()
  */
 public function getTemplateParameters()
 {
     // get team info
     $teamId = NationalteamsDataService::getNationalTeamManagedByCurrentUser($this->_websoccer, $this->_db);
     if (!$teamId) {
         throw new Exception($this->_i18n->getMessage("nationalteams_user_requires_team"));
     }
     $result = $this->_db->querySelect("name", $this->_websoccer->getConfig("db_prefix") . "_verein", "id = %d", $teamId);
     $team = $result->fetch_array();
     $result->free();
     return array("team_name" => $team["name"], "players" => NationalteamsDataService::getNationalPlayersOfTeamByPosition($this->_websoccer, $this->_db, $teamId));
 }
コード例 #2
0
 /**
  * (non-PHPdoc)
  * @see IModel::getTemplateParameters()
  */
 public function getTemplateParameters()
 {
     // get team players
     if ($this->_nationalteam) {
         $clubId = NationalteamsDataService::getNationalTeamManagedByCurrentUser($this->_websoccer, $this->_db);
     } else {
         $clubId = $this->_websoccer->getUser()->getClubId($this->_websoccer, $this->_db);
     }
     // next x matches
     $nextMatches = MatchesDataService::getNextMatches($this->_websoccer, $this->_db, $clubId, $this->_websoccer->getConfig('formation_max_next_matches'));
     if (!count($nextMatches)) {
         throw new Exception($this->_i18n->getMessage('next_match_block_no_nextmatch'));
     }
     // currently selected match
     $matchId = $this->_websoccer->getRequestParameter('id');
     if (!$matchId) {
         $matchinfo = $nextMatches[0];
     } else {
         foreach ($nextMatches as $nextMatch) {
             if ($nextMatch['match_id'] == $matchId) {
                 $matchinfo = $nextMatch;
                 break;
             }
         }
     }
     if (!isset($matchinfo)) {
         throw new Exception('illegal match id');
     }
     $players = null;
     if ($clubId > 0) {
         if ($this->_nationalteam) {
             $players = NationalteamsDataService::getNationalPlayersOfTeamByPosition($this->_websoccer, $this->_db, $clubId);
         } else {
             $players = PlayersDataService::getPlayersOfTeamByPosition($this->_websoccer, $this->_db, $clubId, 'DESC', count($matchinfo) && $matchinfo['match_type'] == 'cup', isset($matchinfo['match_type']) && $matchinfo['match_type'] != 'friendly');
         }
     }
     // load template
     if ($this->_websoccer->getRequestParameter('templateid')) {
         $formation = FormationDataService::getFormationByTemplateId($this->_websoccer, $this->_db, $clubId, $this->_websoccer->getRequestParameter('templateid'));
     } else {
         // get previously saved formation and tactic
         $formation = FormationDataService::getFormationByTeamId($this->_websoccer, $this->_db, $clubId, $matchinfo['match_id']);
     }
     for ($benchNo = 1; $benchNo <= 5; $benchNo++) {
         if ($this->_websoccer->getRequestParameter('bench' . $benchNo)) {
             $formation['bench' . $benchNo] = $this->_websoccer->getRequestParameter('bench' . $benchNo);
         } else {
             if (!isset($formation['bench' . $benchNo])) {
                 $formation['bench' . $benchNo] = '';
             }
         }
     }
     for ($subNo = 1; $subNo <= 3; $subNo++) {
         if ($this->_websoccer->getRequestParameter('sub' . $subNo . '_out')) {
             $formation['sub' . $subNo . '_out'] = $this->_websoccer->getRequestParameter('sub' . $subNo . '_out');
             $formation['sub' . $subNo . '_in'] = $this->_websoccer->getRequestParameter('sub' . $subNo . '_in');
             $formation['sub' . $subNo . '_minute'] = $this->_websoccer->getRequestParameter('sub' . $subNo . '_minute');
             $formation['sub' . $subNo . '_condition'] = $this->_websoccer->getRequestParameter('sub' . $subNo . '_condition');
             $formation['sub' . $subNo . '_position'] = $this->_websoccer->getRequestParameter('sub' . $subNo . '_position');
         } else {
             if (!isset($formation['sub' . $subNo . '_out'])) {
                 $formation['sub' . $subNo . '_out'] = '';
                 $formation['sub' . $subNo . '_in'] = '';
                 $formation['sub' . $subNo . '_minute'] = '';
                 $formation['sub' . $subNo . '_condition'] = '';
                 $formation['sub' . $subNo . '_position'] = '';
             }
         }
     }
     $setup = $this->getFormationSetup($formation);
     // select players from team by criteria
     $criteria = $this->_websoccer->getRequestParameter('preselect');
     if ($criteria !== NULL) {
         if ($criteria == 'strongest') {
             $sortColumn = 'w_staerke';
         } elseif ($criteria == 'freshest') {
             $sortColumn = 'w_frische';
         } else {
             $sortColumn = 'w_zufriedenheit';
         }
         $proposedPlayers = FormationDataService::getFormationProposalForTeamId($this->_websoccer, $this->_db, $clubId, $setup['defense'], $setup['dm'], $setup['midfield'], $setup['om'], $setup['striker'], $setup['outsideforward'], $sortColumn, 'DESC', $this->_nationalteam, isset($matchinfo['match_type']) && $matchinfo['match_type'] == 'cup');
         for ($playerNo = 1; $playerNo <= 11; $playerNo++) {
             $playerIndex = $playerNo - 1;
             if (isset($proposedPlayers[$playerIndex])) {
                 $formation['player' . $playerNo] = $proposedPlayers[$playerIndex]['id'];
                 $formation['player' . $playerNo . '_pos'] = $proposedPlayers[$playerIndex]['position'];
             }
         }
         // clear bench (prevents duplicate players)
         for ($benchNo = 1; $benchNo <= 5; $benchNo++) {
             $formation['bench' . $benchNo] = '';
         }
         for ($subNo = 1; $subNo <= 3; $subNo++) {
             $formation['sub' . $subNo . '_out'] = '';
             $formation['sub' . $subNo . '_in'] = '';
             $formation['sub' . $subNo . '_minute'] = '';
             $formation['sub' . $subNo . '_condition'] = '';
             $formation['sub' . $subNo . '_position'] = '';
         }
     }
     // free kick taker
     if ($this->_websoccer->getRequestParameter('freekickplayer')) {
         $formation['freekickplayer'] = $this->_websoccer->getRequestParameter('freekickplayer');
     } else {
         if (!isset($formation['freekickplayer'])) {
             $formation['freekickplayer'] = '';
         }
     }
     // tactical options
     if ($this->_websoccer->getRequestParameter('offensive')) {
         $formation['offensive'] = $this->_websoccer->getRequestParameter('offensive');
     } else {
         if (!isset($formation['offensive'])) {
             $formation['offensive'] = 40;
         }
     }
     if ($this->_websoccer->getRequestParameter('longpasses')) {
         $formation['longpasses'] = $this->_websoccer->getRequestParameter('longpasses');
     }
     if ($this->_websoccer->getRequestParameter('counterattacks')) {
         $formation['counterattacks'] = $this->_websoccer->getRequestParameter('counterattacks');
     }
     for ($playerNo = 1; $playerNo <= 11; $playerNo++) {
         // set player from request
         if ($this->_websoccer->getRequestParameter('player' . $playerNo)) {
             $formation['player' . $playerNo] = $this->_websoccer->getRequestParameter('player' . $playerNo);
             $formation['player' . $playerNo . '_pos'] = $this->_websoccer->getRequestParameter('player' . $playerNo . '_pos');
             // set to 0 if no previous formation is available
         } else {
             if (!isset($formation['player' . $playerNo])) {
                 $formation['player' . $playerNo] = '';
                 $formation['player' . $playerNo . '_pos'] = '';
             }
         }
     }
     return array('nextMatches' => $nextMatches, 'next_match' => $matchinfo, 'previous_matches' => MatchesDataService::getPreviousMatches($matchinfo, $this->_websoccer, $this->_db), 'players' => $players, 'formation' => $formation, 'setup' => $setup, 'captain_id' => TeamsDataService::getTeamCaptainIdOfTeam($this->_websoccer, $this->_db, $clubId));
 }