Changeset 41
- Timestamp:
- Sep 14, 2020, 12:22:36 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Locale/cs.php
r39 r41 50 50 'Search' => 'Hledat', 51 51 'hour' => 'hodinu', 52 'yoctosecond' => 'yoctosekund', 53 'zeptosecond' => 'zeptosekund', 54 'attosecond' => 'attosekund', 55 'femtosecond' => 'femtosekund', 56 'pikosecond' => 'pikosekund', 57 'nanosecond' => 'nanosekund', 58 'microsecond' => 'mikrosekund', 59 'millisecond' => 'milisekund', 60 'second' => 'sekund', 61 'minutes' => 'minut', 62 'minute' => 'minuta', 63 'hours' => 'hodin', 64 'hour' => 'hodina', 65 'days' => 'dnů', 66 'day' => 'den', 67 'weeks' => 'týdnů', 68 'week' => 'týden', 69 'months' => 'měsíců', 70 'month' => 'měsíc', 71 'years' => 'roků', 72 'year' => 'rok', 73 'decades' => 'desetiletí', 74 'decade' => 'desetiletí', 75 'centuries' => 'století', 76 'century' => 'století', 77 'millennia' => 'tisíciletí', 78 'millennium' => 'tisíciletí', 52 79 ), 53 80 'URL' => array( -
trunk/Packages/Common/PrefixMultiplier.php
r39 r41 1 1 <?php 2 2 3 function InitPrefixMultipliers() 4 { 5 global $PrefixMultipliers; 3 6 $PrefixMultipliers = array 4 7 ( … … 48 51 'Definition' => array 49 52 ( 50 array('ys', 'yoctosecond', pow(10, -24)),51 array('zs', 'zeptosecond', pow(10, -21)),52 array('as', 'attosecond', pow(10, -18)),53 array('fs', 'femtosecond', pow(10, -15)),54 array('ps', 'pikosecond', pow(10, -12)),55 array('ns', 'nanosecond', pow(10, -9)),56 array('us', 'mikrosecond', pow(10, -6)),57 array('ms', 'milisecond', pow(10, -3)),58 array('s', 'second', 1),59 array( 'minutes', 'minute', 60),60 array( 'hours', 'hour', 60 * 60) ,61 array( 'days', 'day', 24 * 60 * 60),62 array( 'weeks', 'week', 7 * 24 * 60 * 60),63 array( 'months', 'month', 30 * 24 * 60 * 60),64 array( 'years', 'year', 364 * 24 * 60 * 60),65 array( 'desitiletí', 'desetiletí', 10 * 364 * 24 * 60 * 60),66 array( 'staletí', 'staletí', 100 * 364 * 24 * 60 * 60),67 array( 'tisíciletí', 'tisiciletí', 10000 * 364 * 24 * 60 * 60),53 array('ys', T('yoctosecond'), pow(10, -24)), 54 array('zs', T('zeptosecond'), pow(10, -21)), 55 array('as', T('attosecond'), pow(10, -18)), 56 array('fs', T('femtosecond'), pow(10, -15)), 57 array('ps', T('pikosecond'), pow(10, -12)), 58 array('ns', T('nanosecond'), pow(10, -9)), 59 array('us', T('microsecond'), pow(10, -6)), 60 array('ms', T('millisecond'), pow(10, -3)), 61 array('s', T('second'), 1), 62 array(T('minutes'), T('minute'), 60), 63 array(T('hours'), T('hour'), 60 * 60) , 64 array(T('days'), T('day'), 24 * 60 * 60), 65 array(T('weeks'), T('week'), 7 * 24 * 60 * 60), 66 array(T('months'), T('month'), 30 * 24 * 60 * 60), 67 array(T('years'), T('year'), 364 * 24 * 60 * 60), 68 array(T('decades'), T('decade'), 10 * 364 * 24 * 60 * 60), 69 array(T('centuries'), T('century'), 100 * 364 * 24 * 60 * 60), 70 array(T('millennia'), T('millennium'), 10000 * 364 * 24 * 60 * 60), 68 71 ), 69 72 ), 70 73 ); 74 } 71 75 72 76 class PrefixMultiplier … … 117 121 } 118 122 } 123 124 InitPrefixMultipliers(); -
trunk/SQL/Upgrade.txt
r21 r41 15 15 MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6; 16 16 17 -- 41 18 19 CREATE TABLE `Year` ( 20 `Id` int(11) NOT NULL, 21 `Year` int(11) NOT NULL, 22 `MoneyKm` int(11) NOT NULL, 23 `LapLength` DECIMAL(10,1) NOT NULL 24 ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 25 26 ALTER TABLE `Year` ADD PRIMARY KEY (`Id`); 27 28 ALTER TABLE `Year` 29 MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT; 30 COMMIT; 31 32 INSERT INTO `Year` (`Id`, `Year`, `MoneyKm`, `LapLength`) VALUES 33 (1, 2018, 30, '1.5'), 34 (2, 2019, 30, '1.5'), 35 (3, 2020, 10, '0.0'); -
trunk/index.php
r40 r41 6 6 include_once('Run.php'); 7 7 include_once('Packages/Common/Base.php'); 8 include_once('Packages/Common/Locale.php'); 8 9 include_once('Packages/Common/PrefixMultiplier.php'); 9 include_once('Packages/Common/Locale.php');10 10 11 11 session_start(); … … 29 29 var $LinkLocaleExceptions; 30 30 var $Title; 31 var $LapLength; 32 var $MoneyKm; 33 var $MaxRunnerSpeed; 34 var $MinRunnerSpeed; 31 35 32 36 function __construct() … … 36 40 $this->LinkLocaleExceptions = array(); 37 41 $this->Title = ''; 42 $this->LapLength = 0; // km 43 $this->MoneyKm = 0; // Kč 44 $this->MaxRunnerSpeed = 20; // km/hour 45 $this->MinRunnerSpeed = 2; // km/hour 38 46 } 39 47 … … 468 476 $Output .= '<div class="page-title">'.$Title.' '.$DbRow['Name'].'</div>'; 469 477 $Output .= '<div class="section-title">'.$this->ItemsYearList('/'.$UrlDir.'/', $TeamId, 'Team', 'Name="'.$DbRow['Name'].'"').'</div>'; 478 $this->LoadYearParameters($DbRow['Year']); 470 479 $Output .= '<div class="section-title">'. 471 480 T('Runners').': '.$DbRow['RunnerCount'].', '. … … 546 555 $Output .= '<table class="WideTable">'; 547 556 $Output .= $Order['Output']; 557 $TableStat = $Table.'Stat'; 548 558 $DbResult = $this->Database->query('SELECT *'. 549 ', (SELECT TIME_TO_SEC(TIMEDIFF('.$Table.'Stat.Time, B.Time)) FROM '.$Table.'Stat AS B WHERE (B.Time < '.$Table.'Stat.Time) AND (B.'.$Table.' = '.$Table.'Stat.'.$Table.') ORDER BY B.Time DESC LIMIT 1) AS Duration'.550 ', (SELECT '.$Table.'Stat.Distance - B.Distance FROM '.$Table.'Stat AS B WHERE (B.Time < '.$Table.'Stat.Time) AND (B.'.$Table.' = '.$Table.'Stat.'.$Table.') ORDER BY B.Time DESC LIMIT 1) AS Length'.559 ', (SELECT '.$TableStat.'.Distance - B.Distance FROM '.$TableStat.' AS B WHERE (B.Time < '.$TableStat.'.Time) AND (B.'.$Table.' = '.$TableStat.'.'.$Table.') ORDER BY B.Time DESC LIMIT 1) AS Length'. 560 ', (SELECT TIME_TO_SEC(TIMEDIFF('.$TableStat.'.Time, B.Time)) FROM '.$TableStat.' AS B WHERE (B.Time < '.$TableStat.'.Time) AND (B.'.$Table.' = '.$TableStat.'.'.$Table.') ORDER BY B.Time DESC LIMIT 1) AS Duration'. 551 561 ', NULL AS Speed'. 552 ' FROM '.$Table .'Stat'.562 ' FROM '.$TableStat. 553 563 ' WHERE '.$Where.$Order['SQL'].$PageList['SQLLimit']); 554 564 while ($Item = $DbResult->fetch_assoc()) … … 559 569 '<td>'.$Item['Money'].'</td>'. 560 570 '<td>'.$Item['Rank'].'</td>'; 561 if ( $Item['Duration'] != null) $Output .= '<td>'.$PrefixMultiplier->Add($Item['Duration'], '', 4, 'Time').'</td>';571 if (($Item['Duration'] != null) and ($Item['Duration'] < $Item['Length'] / $this->MinRunnerSpeed * 3600)) $Output .= '<td>'.$PrefixMultiplier->Add($Item['Duration'], '', 4, 'Time').'</td>'; 562 572 else $Output .= '<td> </td>'; 563 573 $Output .= '<td>'.$Item['Length'].'</td>'; 564 if ($Item['Duration'] > 0) $Output .= '<td>'.$PrefixMultiplier->Add($Item['Length'] / $Item['Duration'] * 3600, '', 4, 'Decimal').'</td>'; 574 $Speed = $Item['Length'] / $Item['Duration'] * 3600; 575 if (($Item['Duration'] > 0) and ($Item['Duration'] < $Item['Length'] * 3600 / $this->MinRunnerSpeed)) 576 $Output .= '<td>'.$PrefixMultiplier->Add($Speed, '', 4, 'Decimal').'</td>'; 565 577 else $Output .= '<td> </td>'; 566 578 $Output .= '</tr>'; … … 577 589 $Where = '1'; 578 590 579 $DailyTableMaxId = 'SELECT * FROM (SELECT MAX(Id) AS MaxId FROM `'.$Table.'Stat` AS T1 WHERE T1.'.$Table.'='.$Id.' GROUP BY DATE(Time)) AS T2 LEFT JOIN '.$Table.'Stat AS T3 ON T3.Id=T2.MaxId'; 580 $DailyTableMinId = 'SELECT * FROM (SELECT MIN(Id) AS MinId FROM `'.$Table.'Stat` AS T1 WHERE T1.'.$Table.'='.$Id.' GROUP BY DATE(Time)) AS T2 LEFT JOIN '.$Table.'Stat AS T3 ON T3.Id=T2.MinId'; 591 $TableStat = $Table.'Stat'; 592 $DailyTableMaxId = 'SELECT * FROM (SELECT MAX(Id) AS MaxId FROM '.$TableStat.' AS T1 WHERE T1.'.$Table.'='.$Id.' GROUP BY DATE(Time)) AS T2 LEFT JOIN '.$TableStat.' AS T3 ON T3.Id=T2.MaxId'; 593 $DailyTableMinId = 'SELECT * FROM (SELECT MIN(Id) AS MinId FROM '.$TableStat.' AS T1 WHERE T1.'.$Table.'='.$Id.' GROUP BY DATE(Time)) AS T2 LEFT JOIN '.$TableStat.' AS T3 ON T3.Id=T2.MinId'; 581 594 $DbResult = $this->Database->query('SELECT COUNT(*) FROM ('.$DailyTableMaxId.') AS B'); 582 595 $DbRow = $DbResult->fetch_row(); … … 598 611 $Output .= '<table class="WideTable">'; 599 612 $Output .= $Order['Output']; 600 $DbResult = $this->Database->query('SELECT * '. 601 ', (SELECT T4.Distance - B.Distance + 1.5 FROM ('.$DailyTableMinId.') AS B WHERE (DATE(B.Time) = DATE(T4.Time)) AND (B.'.$Table.' = T4.'.$Table.') ORDER BY B.Time DESC LIMIT 1) AS Length'. 602 ', (SELECT TIME_TO_SEC(TIMEDIFF(T4.Time, B.Time)) / (Length - 1.5) * Length FROM ('.$DailyTableMinId.') AS B WHERE (DATE(B.Time) = DATE(T4.Time)) AND (B.'.$Table.' = T4.'.$Table.') ORDER BY B.Time DESC LIMIT 1) AS Duration'. 603 ', NULL AS Speed'. 604 ' FROM ('.$DailyTableMaxId.') AS T4'. 605 ' WHERE '.$Where.$Order['SQL'].$PageList['SQLLimit']); 613 614 if ($this->LapLength == 0) 615 { 616 $DbResult = $this->Database->query('SELECT * '. 617 ', COALESCE((SELECT T4.Distance - B.Distance FROM ('.$DailyTableMaxId.') AS B WHERE (DATE(B.Time) < DATE(T4.Time)) AND (B.'.$Table.' = T4.'.$Table.') ORDER BY B.Time DESC LIMIT 1), T4.Distance) AS Length'. 618 ', NULL AS Duration'. 619 ', NULL AS Speed'. 620 ' FROM ('.$DailyTableMaxId.') AS T4'. 621 ' WHERE '.$Where.$Order['SQL'].$PageList['SQLLimit']); 622 } else 623 { 624 $DbResult = $this->Database->query('SELECT * '. 625 ', COALESCE((SELECT T4.Distance - B.Distance FROM ('.$DailyTableMaxId.') AS B WHERE (DATE(B.Time) < DATE(T4.Time)) AND (B.'.$Table.' = T4.'.$Table.') ORDER BY B.Time DESC LIMIT 1), T4.Distance) AS Length'. 626 //', (SELECT COUNT(*) * '.$this->LapLength.' FROM '.$TableStat.' AS B WHERE (DATE(B.Time) = DATE(T4.Time)) AND (B.'.$Table.' = T4.'.$Table.')) AS LapLength'. 627 ', (SELECT TIME_TO_SEC(TIMEDIFF(T4.Time, B.Time)) / (Length - '.$this->LapLength.') * Length FROM ('.$DailyTableMinId.') AS B WHERE (DATE(B.Time) = DATE(T4.Time)) AND (B.'.$Table.' = T4.'.$Table.') ORDER BY B.Time DESC LIMIT 1) AS Duration'. 628 ', NULL AS Speed'. 629 ' FROM ('.$DailyTableMaxId.') AS T4'. 630 ' WHERE '.$Where.$Order['SQL'].$PageList['SQLLimit']); 631 } 606 632 while ($Item = $DbResult->fetch_assoc()) 607 633 { … … 700 726 if (!is_numeric($RunnerId)) die(T('Runner id needs to be numeric')); 701 727 702 $DbResult = $this->Database->query('SELECT Runner.Name, Team.Name AS TeamName, Team.Id AS TeamId FROM Runner LEFT JOIN Team ON Team.Id=Runner.Team WHERE Runner.Id='.$RunnerId);728 $DbResult = $this->Database->query('SELECT Runner.Name, Team.Name AS TeamName, Team.Id AS TeamId, Team.Year FROM Runner LEFT JOIN Team ON Team.Id=Runner.Team WHERE Runner.Id='.$RunnerId); 703 729 $DbRow = $DbResult->fetch_assoc(); 704 730 $this->Title = T('Runner').' '.$DbRow['Name'].' - '.$this->Title; … … 707 733 $Output .= '<div class="section-title"><a href="'.$this->Link('/team/'.$DbRow['TeamId']).'">'.$DbRow['TeamName'].'</a></div>'; 708 734 $Output .= '<div class="section-title">'.$this->ItemsYearList('/runner/', $RunnerId, 'Runner', 'Name="'.$DbRow['Name'].'"').'</div>'; 735 $this->LoadYearParameters($DbRow['Year']); 709 736 710 737 $Output .= $this->ShowDetailed('Runner', $RunnerId); … … 732 759 } 733 760 if ($Year == 0) $Year = $this->GetLatestYear(); 761 $this->LoadYearParameters($Year); 734 762 return $Year; 735 763 } … … 876 904 } 877 905 906 function LoadYearParameters($Year) 907 { 908 $DbResult = $this->Database->query('SELECT * FROM `Year` WHERE `Year`.`Year`='.$Year); 909 if ($DbResult->num_rows > 0) 910 { 911 $DbRow = $DbResult->fetch_assoc(); 912 $this->LapLength = $DbRow['LapLength']; 913 $this->MoneyKm = $DbRow['MoneyKm']; 914 } 915 } 916 878 917 function Run() 879 918 { … … 917 956 $this->LocaleManager->LoadLocale($this->LocaleManager->LangCode); 918 957 } 958 InitPrefixMultipliers(); 919 959 920 960 if (GetRemoteAddress() != '')
Note:
See TracChangeset
for help on using the changeset viewer.