Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • Solr
  • SolrIndexer
  • SolrSearcherAbstract
  • SolrSearcherSimple
  • SolrSearchModule

Exceptions

  • SolrException
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: 
  3: /**
  4:  *
  5:  * @package Plugin
  6:  * @subpackage SearchSolr
  7:  * @author Marcus Gnaß <marcus.gnass@4fb.de>
  8:  * @copyright four for business AG
  9:  * @link http://www.4fb.de
 10:  */
 11: 
 12: // assert CONTENIDO framework
 13: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 14: 
 15: /**
 16:  * This module handles a search request using a Solr searcher implementation and
 17:  * displays the returned search results using a Smarty template.
 18:  *
 19:  * @author Marcus Gnaß <marcus.gnass@4fb.de>
 20:  */
 21: class SolrSearchModule {
 22: 
 23:     /**
 24:      *
 25:      * @var string
 26:      */
 27:     private $_searchTerm;
 28: 
 29:     /**
 30:      *
 31:      * @var int
 32:      */
 33:     private $_page;
 34: 
 35:     /**
 36:      *
 37:      * @var int
 38:      */
 39:     private $_itemsPerPage;
 40: 
 41:     /**
 42:      *
 43:      * @var string
 44:      */
 45:     private $_templateName;
 46: 
 47:     /**
 48:      *
 49:      * @var SolrObject
 50:      */
 51:     private $_response = NULL;
 52: 
 53:     /**
 54:      *
 55:      * @param array $options
 56:      */
 57:     public function __construct(array $options = NULL) {
 58:         if (NULL !== $options) {
 59:             foreach ($options as $name => $value) {
 60:                 $name = '_' . $name;
 61:                 $this->$name = $value;
 62:             }
 63:         }
 64:         $this->_response = $this->_getSearchResults();
 65:     }
 66: 
 67:     /**
 68:      *
 69:      * @return SolrObject
 70:      */
 71:     private function _getSearchResults() {
 72:         $searcher = new SolrSearcherSimple();
 73:         $searcher->setSearchTerm($this->_searchTerm);
 74:         $searcher->setPage($this->_page);
 75:         $searcher->setItemsPerPage($this->_itemsPerPage);
 76:         return $searcher->getSearchResults();
 77:     }
 78: 
 79:     /**
 80:      *
 81:      */
 82:     public function render() {
 83:         $tpl = cSmartyFrontend::getInstance();
 84:         $tpl->assign('label', $this->_label);
 85:         $tpl->assign('href', cUri::getInstance()->build(array(
 86:             'idart' => cRegistry::getArticleId(),
 87:             'lang' => cRegistry::getLanguageId()
 88:         )));
 89:         $tpl->assign('searchTerm', $this->_searchTerm);
 90:         $tpl->assign('page', $this->_page);
 91:         $tpl->assign('itemsPerPage', $this->_itemsPerPage);
 92: 
 93:         // calculate number of pages
 94:         $numPages = $this->_response->numFound / $this->_itemsPerPage;
 95:         if (is_float($numPages)) {
 96:             $numPages = ceil($numPages);
 97:         }
 98: 
 99:         $tpl->assign('numPages', $numPages);
100:         $tpl->assign('numFound', $this->_response->numFound);
101:         $tpl->assign('start', $this->_response->start);
102:         if (false === $this->_response->docs) {
103:             $tpl->assign('results', array());
104:         } else {
105:             $tpl->assign('results', $this->_response->docs);
106:         }
107:         $tpl->display($this->_templateName);
108:     }
109: 
110: }
111: 
112: 
CMS CONTENIDO 4.9.11 API documentation generated by ApiGen 2.8.0