Commit 9354090c4cd47dd3d1398de3df07491fc8a33da6
1 parent
98ead185
actually sanely handle request input in a non-broken way.
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5305 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
26 additions
and
16 deletions
lib/browse/Criteria.inc
| @@ -165,17 +165,27 @@ class BrowseCriterion { | @@ -165,17 +165,27 @@ class BrowseCriterion { | ||
| 165 | if ($aPreValue != null) { | 165 | if ($aPreValue != null) { |
| 166 | // !#@&)*( (*&!@# *(&@NOT (*&!@# | 166 | // !#@&)*( (*&!@# *(&@NOT (*&!@# |
| 167 | $k = array_keys($aPreValue); | 167 | $k = array_keys($aPreValue); |
| 168 | - $k = $k[0]; | 168 | + $k = $this->getWidgetBase(); |
| 169 | $preval = $aPreValue[$k]; | 169 | $preval = $aPreValue[$k]; |
| 170 | - return $this->getNotWidget() . "<input type=\"text\" size=\"50\" name=\"" . $this->getWidgetBase() . "\" value=\"" . $preval . "\"/>"; | 170 | + return $this->getNotWidget($aPreValue) . "<input type=\"text\" size=\"50\" name=\"" . $this->getWidgetBase() . "\" value=\"" . $preval . "\"/>"; |
| 171 | } else { | 171 | } else { |
| 172 | - return $this->getNotWidget() . "<input type=\"text\" size=\"50\" name=\"" . $this->getWidgetBase() . "\" />"; | 172 | + return $this->getNotWidget($aPreValue) . "<input type=\"text\" size=\"50\" name=\"" . $this->getWidgetBase() . "\" />"; |
| 173 | } | 173 | } |
| 174 | } | 174 | } |
| 175 | 175 | ||
| 176 | - function getNotWidget() { | 176 | + function getNotWidget($aPreValue=null) { |
| 177 | + if (is_null($aPreValue)) { | ||
| 178 | + $is_positive = true; | ||
| 179 | + } | ||
| 177 | // not perfect, but acceptable. | 180 | // not perfect, but acceptable. |
| 178 | $form_name = $this->getWidgetBase() . '_not'; | 181 | $form_name = $this->getWidgetBase() . '_not'; |
| 182 | + $pos_select = ''; | ||
| 183 | + $neg_select = ''; | ||
| 184 | + if ($is_positive) { | ||
| 185 | + $pos_select = ' selected="true"'; | ||
| 186 | + } else { | ||
| 187 | + $neg_select = ' selected="true"'; | ||
| 188 | + } | ||
| 179 | if (!$this->bContains) { | 189 | if (!$this->bContains) { |
| 180 | $not_string = _kt('is not'); | 190 | $not_string = _kt('is not'); |
| 181 | $is_string = _kt('is'); | 191 | $is_string = _kt('is'); |
| @@ -183,7 +193,7 @@ class BrowseCriterion { | @@ -183,7 +193,7 @@ class BrowseCriterion { | ||
| 183 | $not_string = _kt('does not contain'); | 193 | $not_string = _kt('does not contain'); |
| 184 | $is_string = _kt('contains'); | 194 | $is_string = _kt('contains'); |
| 185 | } | 195 | } |
| 186 | - $widget = sprintf('<select name="%s"><option value="0">%s</option><option value="1">%s</option></select> ', $form_name, $is_string, $not_string); | 196 | + $widget = sprintf('<select name="%s"><option value="0"%s>%s</option><option value="1"%s>%s</option></select> ', $form_name, $pos_select, $is_string, $neg_select, $not_string); |
| 187 | return $widget; | 197 | return $widget; |
| 188 | } | 198 | } |
| 189 | 199 | ||
| @@ -308,10 +318,10 @@ class CreatorCriterion extends BrowseCriterion { | @@ -308,10 +318,10 @@ class CreatorCriterion extends BrowseCriterion { | ||
| 308 | if ($aPreValue != null) { | 318 | if ($aPreValue != null) { |
| 309 | // !#@&)*( (*&!@# *(&@NOT (*&!@# | 319 | // !#@&)*( (*&!@# *(&@NOT (*&!@# |
| 310 | $k = array_keys($aPreValue); | 320 | $k = array_keys($aPreValue); |
| 311 | - $k = $k[0]; | 321 | + $k = $this->getWidgetBase(); |
| 312 | $preval = $aPreValue[$k]; | 322 | $preval = $aPreValue[$k]; |
| 313 | } | 323 | } |
| 314 | - $sRet = $this->getNotWidget() . "<select size=\"1\" name=\"" . $this->getWidgetBase() . "\">\n"; | 324 | + $sRet = $this->getNotWidget($aPreValue) . "<select size=\"1\" name=\"" . $this->getWidgetBase() . "\">\n"; |
| 315 | $aUsers = User::getList();/*ok*/ | 325 | $aUsers = User::getList();/*ok*/ |
| 316 | $sRet .= "<option value=\"-1\">None</option>\n"; | 326 | $sRet .= "<option value=\"-1\">None</option>\n"; |
| 317 | foreach ($aUsers as $oUser) { | 327 | foreach ($aUsers as $oUser) { |
| @@ -345,9 +355,9 @@ class DateCreatedCriterion extends BrowseCriterion { | @@ -345,9 +355,9 @@ class DateCreatedCriterion extends BrowseCriterion { | ||
| 345 | $sToRender .= " Before date: <input type=\"text\" size=\"10\" name=\"" . $sEndWidget . "\" />"; | 355 | $sToRender .= " Before date: <input type=\"text\" size=\"10\" name=\"" . $sEndWidget . "\" />"; |
| 346 | $sToRender .= " <a href=\"javascript:show_calendar('MainForm." . $sEndWidget . "',null,null,'YYYY-MM-DD', false);\" onmouseover=\"window.status='Date Picker';return true;\" onmouseout=\"window.status='';return true;\"><img src=\"$default->graphicsUrl/calendar/calendar.gif\" name=\"imgCalendar\" width=\"34\" height=\"21\" border=\"0\" alt=\"\"></a>"; | 356 | $sToRender .= " <a href=\"javascript:show_calendar('MainForm." . $sEndWidget . "',null,null,'YYYY-MM-DD', false);\" onmouseover=\"window.status='Date Picker';return true;\" onmouseout=\"window.status='';return true;\"><img src=\"$default->graphicsUrl/calendar/calendar.gif\" name=\"imgCalendar\" width=\"34\" height=\"21\" border=\"0\" alt=\"\"></a>"; |
| 347 | */ | 357 | */ |
| 348 | - $sToRender = $this->getNotWidget(); | ||
| 349 | - $sToRender .= 'After Date: <span class="kt_calendar_holder"><strong class="kt_calendar_datetext">' . $aPreValue[$sStartWidget] . '</strong><input type="hidden" name="' . $sStartWidget . '" class="kt_calendar_value" value="' . $aPreValue[$sStartWidget] . '"/> <input type="button" onclick="init_kt_calendar(this);" value="select"></span> and '; | ||
| 350 | - $sToRender .= 'Before Date: <span class="kt_calendar_holder"><strong class="kt_calendar_datetext">' . $aPreValue[$sStartWidget] . '</strong><input type="hidden" name="' . $sEndWidget . '" class="kt_calendar_value" value="' . $aPreValue[$sEndWidget] . '"/> <input type="button" onclick="init_kt_calendar(this);" value="select"></span><br />'; | 358 | + $sToRender = $this->getNotWidget($aPreValue); |
| 359 | + $sToRender .= 'after: <span class="kt_calendar_holder"><strong class="kt_calendar_datetext">' . $aPreValue[$sStartWidget] . '</strong><input type="hidden" name="' . $sStartWidget . '" class="kt_calendar_value" value="' . $aPreValue[$sStartWidget] . '"/> <input type="button" onclick="init_kt_calendar(this);" value="select"></span> and '; | ||
| 360 | + $sToRender .= 'before: <span class="kt_calendar_holder"><strong class="kt_calendar_datetext">' . $aPreValue[$sStartWidget] . '</strong><input type="hidden" name="' . $sEndWidget . '" class="kt_calendar_value" value="' . $aPreValue[$sEndWidget] . '"/> <input type="button" onclick="init_kt_calendar(this);" value="select"></span><br />'; | ||
| 351 | return $sToRender; | 361 | return $sToRender; |
| 352 | } | 362 | } |
| 353 | function searchSQL ($aRequest) { | 363 | function searchSQL ($aRequest) { |
| @@ -412,10 +422,10 @@ class DocumentTypeCriterion extends BrowseCriterion { | @@ -412,10 +422,10 @@ class DocumentTypeCriterion extends BrowseCriterion { | ||
| 412 | if ($aPreValue != null) { | 422 | if ($aPreValue != null) { |
| 413 | // !#@&)*( (*&!@# *(&@NOT (*&!@# | 423 | // !#@&)*( (*&!@# *(&@NOT (*&!@# |
| 414 | $k = array_keys($aPreValue); | 424 | $k = array_keys($aPreValue); |
| 415 | - $k = $k[0]; | 425 | + $k = $this->getWidgetBase(); |
| 416 | $preval = $aPreValue[$k]; | 426 | $preval = $aPreValue[$k]; |
| 417 | } | 427 | } |
| 418 | - $sRet = $this->getNotWidget(); | 428 | + $sRet = $this->getNotWidget($aPreValue); |
| 419 | $sRet .= "<select size=\"1\" name=\"" . $this->getWidgetBase() . "\">\n"; | 429 | $sRet .= "<select size=\"1\" name=\"" . $this->getWidgetBase() . "\">\n"; |
| 420 | $aUsers = DocumentType::getList();/*ok*/ | 430 | $aUsers = DocumentType::getList();/*ok*/ |
| 421 | $sRet .= "<option value=\"-1\">None</option>\n"; | 431 | $sRet .= "<option value=\"-1\">None</option>\n"; |
| @@ -476,7 +486,7 @@ class GenericMetadataCriterion extends BrowseCriterion { | @@ -476,7 +486,7 @@ class GenericMetadataCriterion extends BrowseCriterion { | ||
| 476 | if ($aPreValue != null) { | 486 | if ($aPreValue != null) { |
| 477 | // !#@&)*( (*&!@# *(&@NOT (*&!@# | 487 | // !#@&)*( (*&!@# *(&@NOT (*&!@# |
| 478 | $k = array_keys($aPreValue); | 488 | $k = array_keys($aPreValue); |
| 479 | - $k = $k[0]; | 489 | + $k = $this->getWidgetBase(); |
| 480 | $preval = $aPreValue[$k]; | 490 | $preval = $aPreValue[$k]; |
| 481 | } | 491 | } |
| 482 | // If there's no lookup, just use the standard text input | 492 | // If there's no lookup, just use the standard text input |
| @@ -485,7 +495,7 @@ class GenericMetadataCriterion extends BrowseCriterion { | @@ -485,7 +495,7 @@ class GenericMetadataCriterion extends BrowseCriterion { | ||
| 485 | return parent::searchWidget($aRequest, $aPreValue); | 495 | return parent::searchWidget($aRequest, $aPreValue); |
| 486 | } | 496 | } |
| 487 | $this->bContains = false; // is | 497 | $this->bContains = false; // is |
| 488 | - $sRet = $this->getNotWidget(); | 498 | + $sRet = $this->getNotWidget($aPreValue); |
| 489 | $sRet .= "<select size=\"1\" name=\"" . $this->getWidgetBase() . "\">\n"; | 499 | $sRet .= "<select size=\"1\" name=\"" . $this->getWidgetBase() . "\">\n"; |
| 490 | $aSearch = array('document_field_id = ?', $this->getID()); | 500 | $aSearch = array('document_field_id = ?', $this->getID()); |
| 491 | $aMetaData = MetaData::getByDocumentField(DocumentField::get($this->getID()));/*ok*/ | 501 | $aMetaData = MetaData::getByDocumentField(DocumentField::get($this->getID()));/*ok*/ |
| @@ -635,10 +645,10 @@ class WorkflowStateCriterion extends BrowseCriterion { | @@ -635,10 +645,10 @@ class WorkflowStateCriterion extends BrowseCriterion { | ||
| 635 | if ($aPreValue != null) { | 645 | if ($aPreValue != null) { |
| 636 | // !#@&)*( (*&!@# *(&@NOT (*&!@# | 646 | // !#@&)*( (*&!@# *(&@NOT (*&!@# |
| 637 | $k = array_keys($aPreValue); | 647 | $k = array_keys($aPreValue); |
| 638 | - $k = $k[0]; | 648 | + $k = $this->getWidgetBase(); |
| 639 | $preval = $aPreValue[$k]; | 649 | $preval = $aPreValue[$k]; |
| 640 | } | 650 | } |
| 641 | - $sRet = $this->getNotWidget(); | 651 | + $sRet = $this->getNotWidget($aPreValue); |
| 642 | $sRet .= "<select size=\"1\" name=\"" . $this->getWidgetBase() . "\">\n"; | 652 | $sRet .= "<select size=\"1\" name=\"" . $this->getWidgetBase() . "\">\n"; |
| 643 | $aStates = KTWorkflowState::getList("ORDER BY workflow_id"); | 653 | $aStates = KTWorkflowState::getList("ORDER BY workflow_id"); |
| 644 | $sRet .= "<option value=\"-1\">None</option>\n"; | 654 | $sRet .= "<option value=\"-1\">None</option>\n"; |