Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
93.48% |
43 / 46 |
|
66.67% |
4 / 6 |
CRAP | |
0.00% |
0 / 1 |
| SitesController | |
93.33% |
42 / 45 |
|
66.67% |
4 / 6 |
12.04 | |
0.00% |
0 / 1 |
| index | |
97.14% |
34 / 35 |
|
0.00% |
0 / 1 |
7 | |||
| view | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| impressum | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| websitefunctions | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| gotutorial | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| privacypolicy | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | App::uses('SgfParser', 'Utility'); |
| 4 | |
| 5 | class SitesController extends AppController |
| 6 | { |
| 7 | public $helpers = ['Html', 'Form']; |
| 8 | |
| 9 | /** |
| 10 | * @param mixed $var Variable parameter |
| 11 | * @return void |
| 12 | */ |
| 13 | public function index($var = null) |
| 14 | { |
| 15 | $this->set('_page', 'home'); |
| 16 | $this->set('_title', 'Tsumego Hero'); |
| 17 | |
| 18 | // Set default lastVisit tsumego ID if not already set (for first-time visitors) |
| 19 | if (empty($_COOKIE['lastVisit'])) |
| 20 | Util::setCookie('lastVisit', Constants::$DEFAULT_TSUMEGO_ID); |
| 21 | |
| 22 | $this->loadModel('Tsumego'); |
| 23 | $this->loadModel('Set'); |
| 24 | $this->loadModel('TsumegoStatus'); |
| 25 | $this->loadModel('User'); |
| 26 | $this->loadModel('DayRecord'); |
| 27 | $this->loadModel('Schedule'); |
| 28 | $this->loadModel('Sgf'); |
| 29 | $this->loadModel('SetConnection'); |
| 30 | $this->loadModel('PublishDate'); |
| 31 | |
| 32 | $uReward = $this->User->find('all', ['limit' => 5, 'order' => 'reward DESC']) ?: []; |
| 33 | $urNames = []; |
| 34 | foreach ($uReward as $user) |
| 35 | $urNames[] = $this->checkPicture($user); |
| 36 | |
| 37 | $today = date('Y-m-d'); |
| 38 | $dayRecord = $this->DayRecord->find('first', ['conditions' => ['date' => $today]]); |
| 39 | if (!$dayRecord) |
| 40 | $dayRecord = $this->DayRecord->find('first', ['conditions' => ['date' => date('Y-m-d', strtotime('yesterday'))]]); |
| 41 | |
| 42 | $currentQuote = 'q01'; |
| 43 | |
| 44 | $tsumegoFilters = new TsumegoFilters('published'); |
| 45 | $tsumegoButtonsOfPublishedTsumegos = new TsumegoButtons($tsumegoFilters); |
| 46 | |
| 47 | if ($dayRecord) |
| 48 | { |
| 49 | $currentQuote = $dayRecord['DayRecord']['quote']; |
| 50 | $userOfTheDay = $this->User->find('first', ['conditions' => ['id' => $dayRecord['DayRecord']['user_id']]]); |
| 51 | if (!$userOfTheDay) |
| 52 | $userOfTheDay = ['User' => ['id' => 0, 'name' => 'Guest']]; |
| 53 | $this->set('userOfTheDay', $this->checkPictureLarge($userOfTheDay)); |
| 54 | } |
| 55 | |
| 56 | $this->set('tsumegoButtonsOfPublishedTsumegos', $tsumegoButtonsOfPublishedTsumegos); |
| 57 | $this->set('dayRecords', ClassRegistry::init('DayRecord')->find('all', ['order' => 'date ASC'])); |
| 58 | $this->set('quote', $currentQuote); |
| 59 | $this->set('dayRecord', $dayRecord); |
| 60 | $this->set('urNames', $urNames); |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * @param string|int|null $id |
| 65 | * @return void |
| 66 | */ |
| 67 | public function view($id = null) |
| 68 | { |
| 69 | $news = $this->Site->find('all'); |
| 70 | $this->set('news', $news[$id]); |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * @return void |
| 75 | */ |
| 76 | public function impressum() |
| 77 | { |
| 78 | $this->set('_page', 'about'); |
| 79 | $this->set('_title', 'Tsumego Hero - Legal Notice'); |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * @return void |
| 84 | */ |
| 85 | public function websitefunctions() |
| 86 | { |
| 87 | $this->set('_page', 'websitefunctions'); |
| 88 | $this->set('_title', 'Tsumego Hero - Website Functions'); |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * @return void |
| 93 | */ |
| 94 | public function gotutorial() |
| 95 | { |
| 96 | $this->set('_page', 'gotutorial'); |
| 97 | $this->set('_title', 'Tsumego Hero - Go Tutorial'); |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * @return void |
| 102 | */ |
| 103 | public function privacypolicy() |
| 104 | { |
| 105 | $this->set('_page', 'privacypolicy'); |
| 106 | $this->set('_title', 'Tsumego Hero - Privacy Policy'); |
| 107 | } |
| 108 | |
| 109 | } |