HomepagePresenter.php 634 Bytes
Newer Older
Martin Gregor's avatar
Martin Gregor committed
1
2
3
4
5
6
7
8
9
<?php

/**
 * Homepage presenter.
 */
class HomepagePresenter extends BasePresenter
{
	public function renderDefault()
	{
10
11
12
13
14
15
16
17
18
19
20
        $count                  = $this->db->table('sentences')->count("*");
        $next_sentence_id       = (time() % $count) + 1;
        $current_sentence_id    = $next_sentence_id;

        while ($current_sentence_id == $next_sentence_id)
        {
            $current_sentence_id = mt_rand(1, $count);
        }

		$this->template->sentence = $this->db->table('sentences')->get($current_sentence_id);
        $this->template->next_sentence = $this->db->table('sentences')->get($next_sentence_id);
Martin Gregor's avatar
Martin Gregor committed
21
22
23
	}

}