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
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • PHP
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • cSearch
  • cSearchBaseAbstract
  • cSearchIndex
  • cSearchResult
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo

Class cSearchResult

CONTENIDO API - SearchResult Object

This object ranks and displays the result of the indexed fulltext search. If you are not comfortable with this API feel free to use your own methods to display the search results. The search result is basically an array with article ID's.

If $search_result = $search->searchIndex($searchword, $searchwordex);

use object with

$oSearchResults = new cSearchResult($search_result, 10);

// html-tags to emphasize the located searchwords $oSearchResults->setReplacement('<span style="color:red">', '</span>');

$num_res = $oSearchResults->getNumberOfResults(); $num_pages = $oSearchResults->getNumberOfPages(); // first result page $res_page = $oSearchResults->getSearchResultPage(1);

foreach ($res_page as $key => $val) { $headline = $oSearchResults->getSearchContent($key, 'HTMLHEAD'); $first_headline = $headline[0]; $text = $oSearchResults->getSearchContent($key, 'HTML'); $first_text = $text[0]; $similarity = $oSearchResults->getSimilarity($key); $iOccurrence = $oSearchResults->getOccurrence($key); }

cSearchBaseAbstract
Extended by cSearchResult
Package: Core\Frontend\Search
Copyright: four for business AG <www.4fb.de>
License: http://www.contenido.org/license/LIZENZ.txt
Author: Willi Man
Located at classes/search/class.search.result.php
Methods summary
public
# __construct( array $search_result, integer $result_per_page, cDb $oDB = NULL, boolean $bDebug = false )

Constructor to create an instance of this class.

Constructor to create an instance of this class.

Compute ranking factor for each search result and order the search results by ranking factor.

NOTE: The ranking factor is the sum of occurences of matching searchterms weighted by similarity (in %) between searchword and matching word in the article.

TODO: One can think of more sophisticated ranking strategies. The content type information could be used for example because a matching word in the headline (CMS_HEADLINE[1]) could be weighted more than a matching word in the text (CMS_HTML[1]).

Parameters

$search_result
array
$search_result list of article ids
$result_per_page
integer
$result_per_page number of items per page
$oDB
cDb
$oDB [optional] CONTENIDO database object
$bDebug
boolean
$bDebug [optional] flag to enable debugging

Throws

cInvalidArgumentException

Overrides

cSearchBaseAbstract::__construct()
public
# setOrderedSearchResult( array $ranked_search, integer $result_per_page )

Parameters

$ranked_search
array
$ranked_search
$result_per_page
integer
$result_per_page
public string
# getContent( integer $art_id, string $cms_type, integer $id = 0 )

Parameters

$art_id
integer
$art_id Id of an article
$cms_type
string
$cms_type
$id
integer
$id [optional]

Returns

string
Content of an article, specified by it's content type

Throws

cDbException
cException
public array
# getSearchContent( integer $art_id, string $cms_type, integer $cms_nr = NULL )

Parameters

$art_id
integer
$art_id Id of an article
$cms_type
string
$cms_type Content type
$cms_nr
integer
$cms_nr [optional]

Returns

array
Content of an article in search result, specified by its type* Content of an article in search result, specified by its type

Throws

cDbException
cException
public array
# getSearchResultPage( integer $page_id )

Returns articles in page.

Returns articles in page.

Parameters

$page_id
integer
$page_id

Returns

array
Articles in page $page_id
public integer
# getNumberOfPages( )

Returns number of result pages.

Returns number of result pages.

Returns

integer
public integer
# getNumberOfResults( )

Returns number of results.

Returns number of results.

Returns

integer
public integer
# getSimilarity( integer $art_id )

Parameters

$art_id
integer
$art_id Id of an article

Returns

integer
Similarity between searchword and matching word in article
public integer
# getOccurrence( integer $art_id )

Parameters

$art_id
integer
$art_id Id of an article

Returns

integer
number of matching searchwords found in article
public
# setReplacement( string $rep1, string $rep2 )

Parameters

$rep1
string
$rep1 The opening html-tag to emphasize the searchword e.g. ''
$rep2
string
$rep2 The closing html-tag e.g. ''
public integer
# getArtCat( integer $artid )

Parameters

$artid
integer
$artid

Returns

integer
Category Id

Throws

cDbException

Todo

refactor this because it shouldn't be the Search's job
Methods inherited from cSearchBaseAbstract
_debug()
Properties summary
protected object $_index
#

Instance of class Index

Instance of class Index

protected integer $_results
#

Number of results

Number of results

protected integer $_pages
#

Number of result pages

Number of result pages

protected integer $_resultPage
#

Current result page

Current result page

protected integer $_resultPerPage
#

Results per page to display

Results per page to display

protected array $_replacement array()
#

Array of html-tags to emphasize the searchwords

Array of html-tags to emphasize the searchwords

protected array $_rankStructure array()
#

Array of article id's with ranking information

Array of article id's with ranking information

protected array $_orderedSearchResult array()
#

Array of result-pages with array's of article id's

Array of result-pages with array's of article id's

protected array $_searchResult array()
#

Array of article id's with information about cms-types, occurence of keyword/searchword, similarity .

Array of article id's with information about cms-types, occurence of keyword/searchword, similarity .

Properties inherited from cSearchBaseAbstract
$cfg, $client, $lang, $oDB
CMS CONTENIDO 4.10.0 API documentation generated by ApiGen 2.8.0