blob: 167b586fc9eedc912f4de69e9ae4437fb48b6acb (
plain)
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
 | <?php
class SearchBox extends TTemplateControl
{
	public function getText()
	{
        $this->ensureChildControls();
        return $this->getRegisteredObject('search')->getText();
    }
    public function getTextBox()
    {
        $this->ensureChildControls();
        return $this->getRegisteredObject('search');
    }
	public function getButton()
	{
		$this->ensureChildControls();
        return $this->getRegisteredObject('find');
	}
	public function onInit($param)
	{
		parent::onInit($param);
		if(strlen($q = $this->Page->Request['q']) > 0)
			$this->search->setText($q);
	}
	public function doSearch($sender, $param)
	{
		if(strlen($query = $this->search->getText()) >0)
		{
			$ps = $this->getApplication()->getService();
			$page = $ps->constructUrl('Search', array('q' => $query), false);
			$this->getApplication()->getResponse()->redirect($page);
		}
	}
}
 |