Example #1
0
 public function getEventsString($event)
 {
     $str = '';
     if (in_array($event, $this->events)) {
         $str = '<span class="fa fa-check"></span>';
         if ($this->best > 0 && self::$sortAttribute === $event && self::$sortDesc !== true) {
             $str = self::$sortDesc === true ? '' : '[' . $this->pos . ']' . $str;
             $str .= Results::formatTime($this->best, $event);
         }
     }
     return $str;
 }
Example #2
0
 private static function formatSum($row)
 {
     switch ($row['eventId']) {
         case '333mbf':
             return array_sum(array_map(function ($row) {
                 $result = $row[0]['average'];
                 $difference = 99 - substr($result, 0, 2);
                 return $difference;
             }, array($row['first'], $row['second'], $row['third'])));
         case '333fm':
             return $row['sum'] / 100;
         default:
             return Results::formatTime($row['sum'], $row['eventId']);
     }
 }
Example #3
0
 private function makePerson($result, $appendUnit = true, $type = 'both')
 {
     switch ($type) {
         case 'average':
             $score = $result->average;
             break;
         case 'single':
             $score = $result->best;
             break;
         default:
             $score = $result->average ?: $result->best;
             break;
     }
     $temp = new stdClass();
     $temp->name = $result->personName;
     $temp->name_zh = preg_match('{\\((.*?)\\)}i', $result->personName, $matches) ? $matches[1] : $result->personName;
     $temp->link = CHtml::link($temp->name, array('/results/p', 'id' => $result->personId), array('target' => '_blank'));
     $temp->link_zh = CHtml::link($temp->name_zh, array('/results/p', 'id' => $result->personId), array('target' => '_blank'));
     $temp->score = Results::formatTime($score, $result->eventId);
     $temp->score_zh = $temp->score;
     if ($appendUnit && is_numeric($temp->score)) {
         switch ($result->eventId) {
             case '333fm':
                 $unit = array('en' => ' turns', 'zh' => '步');
                 break;
             default:
                 $unit = array('en' => ' seconds', 'zh' => '秒');
                 break;
         }
         $temp->score .= $unit['en'];
         $temp->score_zh .= $unit['zh'];
     }
     return $temp;
 }
 protected function getPersonRankValue($results, $eventId, $attribute)
 {
     if (!isset($results['personRanks'][$eventId])) {
         return '-';
     }
     $model = $results['personRanks'][$eventId];
     $attribute = explode('.', $attribute);
     if (isset($attribute[1])) {
         $model = $model->{$attribute[0]};
         $attribute = $attribute[1];
     } else {
         $attribute = $attribute[0];
     }
     if ($model === null) {
         return '-';
     }
     $value = isset($model[$attribute]) ? $model[$attribute] : '-';
     if ($attribute === 'best') {
         $value = Results::formatTime($value, "{$eventId}");
     }
     if ($attribute === 'solve') {
         $value .= '/' . $model['attempt'];
     }
     return $value;
 }