BxBaseSearch.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup DolphinCore Dolphin Core
  7. * @{
  8. */
  9. require_once(BX_DIRECTORY_PATH_INC . "design.inc.php");
  10. bx_import('BxDolSearch');
  11. class BxBaseSearch extends BxDolSearch
  12. {
  13. protected $_oTemplate;
  14. protected $_sIdForm = 'sys_search_form';
  15. protected $_sIdResults = 'sys_search_results';
  16. protected $_sSuffixQuickSearch = '_quick';
  17. public function __construct($aChoice, $oTemplate)
  18. {
  19. parent::__construct($aChoice);
  20. $this->_oTemplate = $oTemplate ? $oTemplate : BxDolTemplate::getInstance();
  21. }
  22. public function getForm($iDesignBoxTemplate = BX_DB_PADDING_DEF, $sTitle = false)
  23. {
  24. if (false === $sTitle)
  25. $sTitle = _t( "_Search");
  26. $aValues = $this->getKeyTitlesPairs ();
  27. $aValue = isset($_GET['type']) ? bx_process_input($_GET['type']) : array_keys($aValues);
  28. $sIdForm = $this->_sIdForm . ($this->_bQuickSearch ? $this->_sSuffixQuickSearch : '');
  29. $sIdResults = $this->_sIdResults . ($this->_bQuickSearch ? $this->_sSuffixQuickSearch : '');
  30. $sIdLoadingContainer = $this->_bQuickSearch ? $sIdResults : $sIdForm;
  31. $aForm = array(
  32. 'form_attrs' => array(
  33. 'id' => $sIdForm,
  34. 'action' => '',
  35. 'method' => 'post',
  36. 'onsubmit' => "return bx_search('#{$sIdForm}', '#{$sIdResults}', '#{$sIdLoadingContainer}');",
  37. ),
  38. 'inputs' => array(
  39. 'quick_search' => array(
  40. 'type' => 'hidden',
  41. 'name' => 'quick_search',
  42. 'value' => $this->_bQuickSearch ? 1 : 0,
  43. ),
  44. 'section' => array(
  45. 'type' => 'checkbox_set',
  46. 'name' => 'section',
  47. 'caption' => _t('_Section'),
  48. 'values' => $aValues,
  49. 'value' => $aValue,
  50. ),
  51. 'keyword' => array(
  52. 'type' => 'text',
  53. 'name' => 'keyword',
  54. 'caption' => _t('_Keyword'),
  55. ),
  56. 'search' => array(
  57. 'type' => 'submit',
  58. 'name' => 'search',
  59. 'value' => _t('_Search'),
  60. )
  61. )
  62. );
  63. if ($this->_bQuickSearch) {
  64. unset($aForm['inputs']['section']);
  65. unset($aForm['inputs']['search']);
  66. unset($aForm['inputs']['keyword']['caption']);
  67. }
  68. bx_import('BxTemplFormView');
  69. $oForm = new BxTemplFormView($aForm);
  70. $sForm = $oForm->getCode();
  71. if (!$this->_bQuickSearch) {
  72. bx_import('BxTemplPaginate');
  73. $o = new BxTemplPaginate(array());
  74. $o->addCssJs();
  75. }
  76. return DesignBoxContent($sTitle, $sForm, $iDesignBoxTemplate);
  77. }
  78. public function getResultsContainer($sCode = '')
  79. {
  80. $sIdResults = $this->_sIdResults . ($this->_bQuickSearch ? $this->_sSuffixQuickSearch : '');
  81. return '<div id="' . $sIdResults . '" class="bx-def-margin-top">' . $sCode . '</div>';
  82. }
  83. }
  84. /** @} */