Exemple #1
0
 /**
  * This function builds the list of the best players.
  *
  * @access private
  * @author kalmer
  * @param string  $parameters['suffix'] the suffix
  * @param integer $parameters['width']  the width of the <code>body</code>
  * 		in pixels
  * @return string the parsed list
  * @uses O_FOLDER to access the manager for errors
  * @uses View     for managing errors
  */
 private static function buildBestPlayers($parameters)
 {
     require_once O_FOLDER . 'errors/ErrorView.php';
     \PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array(new ErrorView(), 'raiseError'));
     require_once 'HTML/Template/IT.php';
     $tpl = new \HTML_Template_IT(O_FOLDER . 'assets/tpl');
     $tpl->loadTemplatefile('rankings.tpl');
     require_once O_FOLDER . 'konkureerimine/Ranking.php';
     $timestamps = Ranking::getTimestamps();
     if (sizeOf($timestamps) > 0) {
         $rankings = Ranking::getRankings($timestamps[0]);
         $atLeastAPlayer = FALSE;
         foreach ($rankings as $idRanking) {
             $ranking = new Ranking($idRanking);
             if ($ranking->getPos() > 1) {
                 break;
             } else {
                 require_once dirname(__FILE__) . '/../haldus/kasutajad/Human.php';
                 $user = new Human();
                 $user->setId($ranking->getIdHuman());
                 $user->setCompleteHuman($parameters);
                 if ($ranking->getIdSchool() > 0) {
                     require_once dirname(__FILE__) . '/../haldus/kasutajad/School.php';
                     $school = new School($ranking->getIdSchool());
                     $nameOSchool = $school->name;
                 } else {
                     $nameOSchool = '';
                 }
                 if ($ranking->getTypeOCompetition() == 'F') {
                     $tpl->setCurrentBlock('females');
                     $tpl->setVariable(array('FIRST-NAME-OF-FEMALE' => $user->firstName, 'LAST-NAME-OF-FEMALE' => $ranking->getLastName(), 'SCHOOL-OF-FEMALE' => $nameOSchool == '' ? '' : sprintf(' (%1$s)', $nameOSchool)));
                 } else {
                     $tpl->setCurrentBlock('males');
                     $tpl->setVariable(array('FIRST-NAME-OF-MALE' => $user->firstName, 'LAST-NAME-OF-MALE' => $ranking->getLastName(), 'SCHOOL-OF-MALE' => $nameOSchool == '' ? '' : sprintf(' (%1$s)', $nameOSchool)));
                 }
                 $tpl->parseCurrentBlock();
                 $atLeastAPlayer = TRUE;
             }
         }
         if ($atLeastAPlayer) {
             $tpl->setCurrentBlock('rankings');
             $tpl->setVariable(array('ADDITIONAL-CLASS' => $parameters['width'] > 1301 && $parameters['width'] < 1800 ? '  BoxInSidebar' : '', 'LOCATION-IN-NORMAL' => DOMAIN));
             $tpl->parseCurrentBlock();
             return $tpl->get('rankings');
         }
     }
     return '';
 }