Commit ed1661a1accd8d0df310911a7d2056c8bda7a2ed
1 parent
1c623fdf
Criteria now know how to generate the WHERE part of statements when
they're being searched on in HTML form submissions. git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3085 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
32 additions
and
7 deletions
lib/browse/Criteria.inc
| @@ -38,6 +38,8 @@ class BrowseCriterion { | @@ -38,6 +38,8 @@ class BrowseCriterion { | ||
| 38 | var $bFolderCriterion = false; | 38 | var $bFolderCriterion = false; |
| 39 | var $aOptions = array(); | 39 | var $aOptions = array(); |
| 40 | var $iID; | 40 | var $iID; |
| 41 | + var $bString = false; | ||
| 42 | + var $sSearchTable = "D"; | ||
| 41 | 43 | ||
| 42 | function BrowseCriterion ($sDisplay, $sDocumentField, $sSortField, $iID) { | 44 | function BrowseCriterion ($sDisplay, $sDocumentField, $sSortField, $iID) { |
| 43 | $this->sDisplay =& $sDisplay; | 45 | $this->sDisplay =& $sDisplay; |
| @@ -124,10 +126,15 @@ class BrowseCriterion { | @@ -124,10 +126,15 @@ class BrowseCriterion { | ||
| 124 | return $this->sSortField; | 126 | return $this->sSortField; |
| 125 | } | 127 | } |
| 126 | 128 | ||
| 129 | + function getSearchField () { | ||
| 130 | + return $this->sDocumentField; | ||
| 131 | + } | ||
| 132 | + | ||
| 127 | function getLookup () { | 133 | function getLookup () { |
| 128 | return $this->aLookup; | 134 | return $this->aLookup; |
| 129 | } | 135 | } |
| 130 | 136 | ||
| 137 | + | ||
| 131 | function getName() { | 138 | function getName() { |
| 132 | return $this->sDocumentField; | 139 | return $this->sDocumentField; |
| 133 | } | 140 | } |
| @@ -147,10 +154,23 @@ class BrowseCriterion { | @@ -147,10 +154,23 @@ class BrowseCriterion { | ||
| 147 | function searchWidget ($aRequest) { | 154 | function searchWidget ($aRequest) { |
| 148 | return "<input type=\"text\" size=\"50\" name=\"bmd" . $this->getID() . "\" />"; | 155 | return "<input type=\"text\" size=\"50\" name=\"bmd" . $this->getID() . "\" />"; |
| 149 | } | 156 | } |
| 157 | + | ||
| 158 | + function getSearchTable() { | ||
| 159 | + return $this->sSearchTable; | ||
| 160 | + } | ||
| 161 | + | ||
| 162 | + function searchSQL ($aRequest) { | ||
| 163 | + if ($this->bString) { | ||
| 164 | + return array($this->getSearchTable() . "." . $this->getSearchField() . " LIKE '%" . DBUtil::escapeSimple($aRequest['bmd' . $this->getID()]) . "%'", array()); | ||
| 165 | + } else { | ||
| 166 | + return array($this->getSearchTable() . "." . $this->getSearchField() . " = ?", array($aRequest['bmd' . $this->getID()])); | ||
| 167 | + } | ||
| 168 | + } | ||
| 150 | } | 169 | } |
| 151 | 170 | ||
| 152 | class NameCriterion extends BrowseCriterion { | 171 | class NameCriterion extends BrowseCriterion { |
| 153 | var $bFolderCriterion = true; | 172 | var $bFolderCriterion = true; |
| 173 | + var $bString = true; | ||
| 154 | function documentDisplay ($oDocument) { | 174 | function documentDisplay ($oDocument) { |
| 155 | $aOptions = $this->aOptions; | 175 | $aOptions = $this->aOptions; |
| 156 | if (array_key_exists('displayFullPath', $aOptions)) { | 176 | if (array_key_exists('displayFullPath', $aOptions)) { |
| @@ -192,6 +212,7 @@ class IDCriterion extends BrowseCriterion { | @@ -192,6 +212,7 @@ class IDCriterion extends BrowseCriterion { | ||
| 192 | 212 | ||
| 193 | class TitleCriterion extends BrowseCriterion { | 213 | class TitleCriterion extends BrowseCriterion { |
| 194 | var $bFolderCriterion = true; | 214 | var $bFolderCriterion = true; |
| 215 | + var $bString = true; | ||
| 195 | function documentDisplay ($oDocument) { | 216 | function documentDisplay ($oDocument) { |
| 196 | return $oDocument->getName(); | 217 | return $oDocument->getName(); |
| 197 | } | 218 | } |
| @@ -280,12 +301,12 @@ class GenericMetadataCriterion extends BrowseCriterion { | @@ -280,12 +301,12 @@ class GenericMetadataCriterion extends BrowseCriterion { | ||
| 280 | "field" => "value", | 301 | "field" => "value", |
| 281 | "joinColumn" => "document_id", | 302 | "joinColumn" => "document_id", |
| 282 | ); | 303 | ); |
| 283 | - var $iFieldID; | 304 | + var $bString = true; |
| 305 | + var $sSearchTable = "DFL"; | ||
| 284 | 306 | ||
| 285 | - function GenericMetadataCriterion ($sDisplay, $sDocumentField, $sSortField, $iFieldID) { | ||
| 286 | - $this->iFieldID = $iFieldID; | ||
| 287 | - $this->BrowseCriterion($sDisplay, $sDocumentField, $sSortField, $iFieldID); | ||
| 288 | - $this->aLookup['whereClause'] = 'document_field_id = ' . $iFieldID; | 307 | + function GenericMetadataCriterion ($sDisplay, $sDocumentField, $sSortField, $iID) { |
| 308 | + $this->BrowseCriterion($sDisplay, $sDocumentField, $sSortField, $iID); | ||
| 309 | + $this->aLookup['whereClause'] = 'document_field_id = ' . $iID; | ||
| 289 | } | 310 | } |
| 290 | 311 | ||
| 291 | function documentDisplay ($oDocument) { | 312 | function documentDisplay ($oDocument) { |
| @@ -294,7 +315,7 @@ class GenericMetadataCriterion extends BrowseCriterion { | @@ -294,7 +315,7 @@ class GenericMetadataCriterion extends BrowseCriterion { | ||
| 294 | "FROM $default->document_fields_link_table AS DFL " . | 315 | "FROM $default->document_fields_link_table AS DFL " . |
| 295 | "WHERE DFL.document_id = ? " . | 316 | "WHERE DFL.document_id = ? " . |
| 296 | "AND DFL.document_field_id = ?"; | 317 | "AND DFL.document_field_id = ?"; |
| 297 | - $aParams = array($oDocument->getID(), $this->iFieldID); | 318 | + $aParams = array($oDocument->getID(), $this->getID()); |
| 298 | 319 | ||
| 299 | $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'value'); | 320 | $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'value'); |
| 300 | if (PEAR::isError($res)) { | 321 | if (PEAR::isError($res)) { |
| @@ -306,9 +327,13 @@ class GenericMetadataCriterion extends BrowseCriterion { | @@ -306,9 +327,13 @@ class GenericMetadataCriterion extends BrowseCriterion { | ||
| 306 | 327 | ||
| 307 | function getName() { | 328 | function getName() { |
| 308 | global $default; | 329 | global $default; |
| 309 | - $aQuery = array("SELECT name FROM $default->document_fields_table WHERE id = ?", array($this->iFieldID)); /*ok*/ | 330 | + $aQuery = array("SELECT name FROM $default->document_fields_table WHERE id = ?", array($this->getID())); /*ok*/ |
| 310 | return "gmd_" . DBUtil::getOneResultKey($aQuery, 'name'); | 331 | return "gmd_" . DBUtil::getOneResultKey($aQuery, 'name'); |
| 311 | } | 332 | } |
| 333 | + | ||
| 334 | + function getSearchField () { | ||
| 335 | + return $this->aLookup['field']; | ||
| 336 | + } | ||
| 312 | } | 337 | } |
| 313 | 338 | ||
| 314 | class Criteria { | 339 | class Criteria { |