diff options
author | wei <> | 2006-05-07 03:34:25 +0000 |
---|---|---|
committer | wei <> | 2006-05-07 03:34:25 +0000 |
commit | 30eddf57c8de433e8ea02b9e552c8e1744a505a7 (patch) | |
tree | 9e81f3a15f9a695cb96c5cc4dd80de5a3a0bb7b2 /demos/quickstart/protected/controls/SearchBox.php | |
parent | 0bb2822f68dfe3cf568affd4acf0d8120d9d53c7 (diff) |
Add search to quickstart demo.
Diffstat (limited to 'demos/quickstart/protected/controls/SearchBox.php')
-rw-r--r-- | demos/quickstart/protected/controls/SearchBox.php | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/demos/quickstart/protected/controls/SearchBox.php b/demos/quickstart/protected/controls/SearchBox.php new file mode 100644 index 00000000..b579cd91 --- /dev/null +++ b/demos/quickstart/protected/controls/SearchBox.php @@ -0,0 +1,41 @@ +<?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()->getPageService();
+ $page = $ps->constructUrl('Search', array('q' => $query));
+ $this->getApplication()->getResponse()->redirect($page);
+ }
+ }
+}
+
+?>
\ No newline at end of file |