summaryrefslogtreecommitdiff
path: root/framework/Data/ActiveRecord/Scaffold/TScaffoldSearch.php
diff options
context:
space:
mode:
authorwei <>2007-02-12 12:46:11 +0000
committerwei <>2007-02-12 12:46:11 +0000
commitfd4b8d9f45d1707035021bc19b8d5bc17ede66ce (patch)
tree093b8b3f92d4d6421f19a6d1e7c8211817f3d51d /framework/Data/ActiveRecord/Scaffold/TScaffoldSearch.php
parentf4c525abc3d4d3f3eecf1019770936e4ca39fd62 (diff)
Add IBM DB2 driver for active record.
Diffstat (limited to 'framework/Data/ActiveRecord/Scaffold/TScaffoldSearch.php')
-rw-r--r--framework/Data/ActiveRecord/Scaffold/TScaffoldSearch.php89
1 files changed, 89 insertions, 0 deletions
diff --git a/framework/Data/ActiveRecord/Scaffold/TScaffoldSearch.php b/framework/Data/ActiveRecord/Scaffold/TScaffoldSearch.php
new file mode 100644
index 00000000..a47a1a47
--- /dev/null
+++ b/framework/Data/ActiveRecord/Scaffold/TScaffoldSearch.php
@@ -0,0 +1,89 @@
+<?php
+
+Prado::using('System.Data.ActiveRecord.Scaffold.TScaffoldBase');
+
+class TScaffoldSearch extends TScaffoldBase
+{
+ private $_list;
+
+ public function getListView()
+ {
+ if($this->_list===null && ($id = $this->getListViewID()) !== null)
+ {
+ $this->_list = $this->getParent()->findControl($id);
+ if($this->_list ===null)
+ throw new TConfigurationException('scaffold_unable_to_find_list_view', $id);
+ }
+ return $this->_list;
+ }
+
+ public function setListView($value)
+ {
+ $this->_list = $value;
+ }
+
+ public function setListViewID($value)
+ {
+ $this->setViewState('ListViewID', $value);
+ }
+
+ public function getListViewID()
+ {
+ return $this->getViewState('ListViewID');
+ }
+
+ public function bubbleEvent($sender, $param)
+ {
+ if(strtolower($param->getCommandName())==='search')
+ {
+ if(($list = $this->getListView()) !== null)
+ {
+ $list->setSearchCondition($this->createSearchCondition());
+ $list->setSearchParameters(array());
+ return false;
+ }
+ }
+ $this->raiseBubbleEvent($this, $param);
+ return true;
+ }
+
+ protected function createSearchCondition()
+ {
+ $table = $this->getTableMetaData();
+ if(strlen($str=$this->getSearchText()->getText()) > 0)
+ return $table->getSearchRegExpCriteria($this->getFields(), $str);
+ }
+
+ protected function getFields()
+ {
+ if(strlen(trim($str=$this->getSearchableFields()))>0)
+ $fields = preg_split('/\s*,\s*/', $str);
+ else
+ $fields = array_keys($this->getTableMetaData()->getColumns());
+ return $fields;
+ }
+
+ public function getSearchableFields()
+ {
+ return $this->getViewState('SearchableFields','');
+ }
+
+ public function setSearchableFields($value)
+ {
+ $this->setViewState('SearchableFields', $value, '');
+ }
+
+ public function getSearchButton()
+ {
+ $this->ensureChildControls();
+ return $this->getRegisteredObject('_search');
+ }
+
+ public function getSearchText()
+ {
+ $this->ensureChildControls();
+ return $this->getRegisteredObject('_textbox');
+ }
+}
+
+?> \ No newline at end of file