summaryrefslogtreecommitdiff
path: root/demos/quickstart/protected/controls/SearchBox.php
diff options
context:
space:
mode:
authorxue <>2006-05-09 12:11:38 +0000
committerxue <>2006-05-09 12:11:38 +0000
commitf4de82bcdafba51e4eed9cae6b2d3e5375ffd115 (patch)
tree08f98e1763e87f0639961c6da33224082345c7c3 /demos/quickstart/protected/controls/SearchBox.php
parent92dca3315f083f00dcff610ea207af52284d0616 (diff)
Diffstat (limited to 'demos/quickstart/protected/controls/SearchBox.php')
-rw-r--r--demos/quickstart/protected/controls/SearchBox.php41
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