1: <?php
2: 3: 4: 5: 6: 7: 8: 9:
10:
11: if (!defined('XOOPS_ROOT_PATH')) exit();
12:
13: require_once XOOPS_ROOT_PATH . "/core/XCube_ActionForm.class.php";
14: require_once XOOPS_MODULE_PATH . "/legacy/class/Legacy_Validator.class.php";
15:
16: class Legacy_SearchResultsForm extends XCube_ActionForm
17: {
18: var $mQueries = array();
19: var $_mKeywordMin = 0;
20:
21: function Legacy_SearchResultsForm($keywordMin)
22: {
23: parent::XCube_ActionForm();
24: $this->_mKeywordMin = intval($keywordMin);
25: }
26:
27: function prepare()
28: {
29:
30:
31:
32: $this->mFormProperties['mids'] =new XCube_IntArrayProperty('mids');
33: $this->mFormProperties['andor'] =new XCube_StringProperty('andor');
34: $this->mFormProperties['query'] =new XCube_StringProperty('query');
35:
36:
37:
38:
39: $this->mFieldProperties['andor'] =new XCube_FieldProperty($this);
40: $this->mFieldProperties['andor']->setDependsByArray(array('mask'));
41: $this->mFieldProperties['andor']->addMessage('mask', _MD_LEGACY_ERROR_MASK, _MD_LEGACY_LANG_ANDOR);
42: $this->mFieldProperties['andor']->addVar('mask', '/^(AND|OR|exact)$/i');
43: }
44:
45: function fetch()
46: {
47: parent::fetch();
48:
49: $t_queries = array();
50:
51: $myts =& MyTextSanitizer::getInstance();
52: if ($this->get('andor') == 'exact' && strlen($this->get('query')) >= $this->_mKeywordMin) {
53: $this->mQueries[] = $myts->addSlashes($this->get('query'));
54: }
55: else {
56: $query = $this->get('query');
57: if (defined('XOOPS_USE_MULTIBYTES')) {
58: $query = xoops_trim($query);
59: }
60:
61: $separator = '/[\s,]+/';
62: if (defined('_MD_LEGACY_FORMAT_SEARCH_SEPARATOR')) {
63: $separator = _MD_LEGACY_FORMAT_SEARCH_SEPARATOR;
64: }
65:
66: $tmpArr = preg_split($separator, $query);
67: foreach ($tmpArr as $tmp) {
68: if (strlen($tmp) >= $this->_mKeywordMin) {
69: $this->mQueries[] = $myts->addSlashes($tmp);
70: }
71: }
72: }
73:
74: $this->set('query', implode(" ", $this->mQueries));
75: }
76:
77: function fetchAndor()
78: {
79: if ($this->get('andor') == "") {
80: $this->set('andor', 'AND');
81: }
82: }
83:
84: function validate()
85: {
86: parent::validate();
87:
88: if (!count($this->mQueries)) {
89: $this->addErrorMessage(_MD_LEGACY_ERROR_SEARCH_QUERY_REQUIRED);
90: }
91: }
92:
93: function update(&$params)
94: {
95: $mids = $this->get('mids');
96: if (count($mids) > 0) {
97: $params['mids'] = $mids;
98: }
99:
100: $params['queries'] = $this->mQueries;
101: $params['andor'] = $this->get('andor');
102: $params['maxhit'] = LEGACY_SEARCH_RESULT_MAXHIT;
103: }
104: }
105:
106: ?>
107: