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
  • Smarty
    • Cacher
    • Compiler
    • Config
    • Debug
    • PluginsBlock
    • PluginsFilter
    • PluginsFunction
    • PluginsInternal
    • PluginsModifier
    • PluginsModifierCompiler
    • PluginsShared
    • Security
    • Template
    • TemplateResources
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

  • Swift_FailoverTransport
  • Swift_LoadBalancedTransport
  • Swift_MailTransport
  • Swift_Plugins_Loggers_ArrayLogger
  • Swift_Plugins_Loggers_EchoLogger
  • Swift_SendmailTransport
  • Swift_SmtpTransport
  • Swift_Transport_AbstractSmtpTransport
  • Swift_Transport_Esmtp_Auth_CramMd5Authenticator
  • Swift_Transport_Esmtp_Auth_LoginAuthenticator
  • Swift_Transport_Esmtp_Auth_PlainAuthenticator
  • Swift_Transport_Esmtp_AuthHandler
  • Swift_Transport_EsmtpTransport
  • Swift_Transport_FailoverTransport
  • Swift_Transport_LoadBalancedTransport
  • Swift_Transport_MailTransport
  • Swift_Transport_SendmailTransport
  • Swift_Transport_SimpleMailInvoker
  • Swift_Transport_StreamBuffer

Interfaces

  • Swift_Plugins_Logger
  • Swift_Plugins_Pop_Pop3Exception
  • Swift_Transport
  • Swift_Transport_Esmtp_Authenticator
  • Swift_Transport_EsmtpHandler
  • Swift_Transport_IoBuffer
  • Swift_Transport_MailInvoker
  • Swift_Transport_SmtpAgent
  • Swift_TransportException
  • Overview
  • Package
  • Function
  • Todo
  • Download
  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 $_response = 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->_response = $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('href', cUri::getInstance()->build(array(
 87:             'idart' => cRegistry::getArticleId(),
 88:             'lang' => cRegistry::getLanguageId()
 89:         )));
 90:         $tpl->assign('searchTerm', $this->_searchTerm);
 91:         $tpl->assign('page', $this->_page);
 92:         $tpl->assign('itemsPerPage', $this->_itemsPerPage);
 93: 
 94:         // calculate number of pages
 95:         $numPages = $this->_response->numFound / $this->_itemsPerPage;
 96:         if (is_float($numPages)) {
 97:             $numPages = ceil($numPages);
 98:         }
 99: 
100:         $tpl->assign('numPages', $numPages);
101:         $tpl->assign('numFound', $this->_response->numFound);
102:         $tpl->assign('start', $this->_response->start);
103:         if (false === $this->_response->docs) {
104:             $tpl->assign('results', array());
105:         } else {
106:             $tpl->assign('results', $this->_response->docs);
107:         }
108:         $tpl->display($this->_templateName);
109:     }
110: 
111: }
112: 
113: 
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen