1: <?php
2:
3: /**
4: *
5: * @package Plugin
6: * @subpackage SearchSolr
7: * @version SVN Revision $Rev:$
8: * @author marcus.gnass
9: * @copyright four for business AG
10: * @link http://www.4fb.de
11: */
12:
13: // assert CONTENIDO framework
14: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
15:
16: /**
17: * This module handles a search request using a Solr searcher implementation and
18: * displays the returned search results using a Smarty template.
19: *
20: * @author marcus.gnass
21: */
22: class SolrSearchModule {
23:
24: /**
25: *
26: * @var string
27: */
28: private $_searchTerm;
29:
30: /**
31: *
32: * @var int
33: */
34: private $_page;
35:
36: /**
37: *
38: * @var int
39: */
40: private $_itemsPerPage;
41:
42: /**
43: *
44: * @var string
45: */
46: private $_templateName;
47:
48: /**
49: *
50: * @var SolrObject
51: */
52: private $_results = NULL;
53:
54: /**
55: *
56: * @param array $options
57: */
58: public function __construct(array $options = NULL) {
59: if (NULL !== $options) {
60: foreach ($options as $name => $value) {
61: $name = '_' . $name;
62: $this->$name = $value;
63: }
64: }
65: $this->_results = $this->_getSearchResults();
66: }
67:
68: /**
69: *
70: * @return SolrObject
71: */
72: private function _getSearchResults() {
73: $searcher = new SolrSearcherSimple();
74: $searcher->setSearchTerm($this->_searchTerm);
75: $searcher->setPage($this->_page);
76: $searcher->setItemsPerPage($this->_itemsPerPage);
77: return $searcher->getSearchResults();
78: }
79:
80: /**
81: *
82: */
83: public function render() {
84: $tpl = cSmartyFrontend::getInstance();
85: $tpl->assign('label', $this->_label);
86: $tpl->assign('results', $this->_results);
87: $tpl->display($this->_templateName);
88: }
89:
90: }
91:
92: