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
    • SIWECOS
    • 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 cSearch

CONTENIDO API - Search Object

This object starts a indexed fulltext search.

TODO:

  • The way to set the search options could be done much more better!
  • The computation of the set of searchable articles should not be

treated in this class.

  • It is better to compute the array of searchable articles from the

outside and to pass the array of searchable articles as parameter.

  • Avoid foreach loops.

Use object with

$options = array( // use db function regexp 'db' => 'regexp', // combine searchwords with or 'combine' => 'or' );

The range of searchable articles is by default the complete content which is online and not protected.

With option 'searchable_articles' you can define your own set of searchable articles.

If parameter 'searchable_articles' is set, the options 'cat_tree', 'categories', 'articles', 'exclude', 'artspecs', 'protected' and 'dontshowofflinearticles' won't have any effect.

$options = array( // use db function regexp 'db' => 'regexp', // combine searchwords with or 'combine' => 'or', 'searchable_articles' => array(5, 6, 9, 13) );

One can define the range of searchable articles by setting the parameter 'exclude' to false which means the range of categories defined by parameter 'cat_tree' or 'categories' and the range of articles defined by parameter 'articles' is included.

$options = array( // use db function regexp 'db' => 'regexp', // combine searchwords with or 'combine' => 'or', // searchrange specified in 'cat_tree', 'categories' and // 'articles' is included 'exclude' => false, // tree with root 12 included 'cat_tree' => array(12), // categories 100, 111 included 'categories' => array(100,111), // article 33 included 'articles' => array(33), // array of article specifications => search only articles with // these artspecs 'artspecs' => array(2, 3), // results per page 'res_per_page' => 2, // do not search articles or articles in categories which are // offline or protected 'protected' => true, // search offline articles or articles in categories which are // offline 'dontshowofflinearticles' => false );

You can build the complement of the range of searchable articles by setting the parameter 'exclude' to true which means the range of categories defined by parameter 'cat_tree' or 'categories' and the range of articles defined by parameter 'articles' is excluded from search.

$options = array( // use db function regexp 'db' => 'regexp', // combine searchwords with or 'combine' => 'or', // searchrange specified in 'cat_tree', 'categories' and // 'articles' is excluded 'exclude' => true, // tree with root 12 excluded 'cat_tree' => array(12), // categories 100, 111 excluded 'categories' => array(100,111), // article 33 excluded 'articles' => array(33), // array of article specifications => search only articles with // these artspecs 'artspecs' => array(2, 3), // results per page 'res_per_page' => 2, // do not search articles or articles in categories which are // offline or protected 'protected' => true, // search offline articles or articles in categories which are // offline 'dontshowofflinearticles' => false );

$search = new Search($options);

// search only in these cms-types $search->setCmsOptions(array( "htmlhead", "html", "head", "text", "imgdescr", "link", "linkdescr" ));

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

The search result structure has following form Array ( [20] => Array ( [CMS_HTML] => Array ( [0] => 1 [1] => 1 [2] => 1 ) [keyword] => Array ( [0] => content [1] => contenido [2] => wwwcontenidoorg ) [search] => Array ( [0] => con [1] => con [2] => con ) [occurence] => Array ( [0] => 1 [1] => 5 [2] => 1 ) [similarity] => 60 ) )

The keys of the array are the article ID's found by search.

Searching 'con' matches keywords 'content', 'contenido' and 'wwwcontenidoorg' in article with ID 20 in content type CMS_HTML[1]. The search term occurs 7 times. The maximum similarity between searchterm and matching keyword is 60%.

// rank and display the results $oSearchResults = new cSearchResult($search_result, 10);

cSearchBaseAbstract
Extended by cSearch
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.php
Methods summary
public
# __construct( array $options, cDb $db = NULL )

Constructor to create an instance of this class.

Constructor to create an instance of this class.

Parameters

$options
array
$options $options['db'] 'regexp' => DB search with REGEXP 'like' => DB search with LIKE 'exact' => exact match; $options['combine'] 'and', 'or' Combination of search words with AND, OR $options['exclude'] 'true' => searchrange specified in 'cat_tree', 'categories' and 'articles' is excluded; 'false' => searchrange specified in 'cat_tree', 'categories' and 'articles' is included $options['cat_tree'] e.g. array(8) => The complete tree with root 8 is in/excluded from search $options['categories'] e.g. array(10, 12) => Categories 10, 12 in/excluded $options['articles'] e.g. array(23) => Article 33 in/excluded $options['artspecs'] e.g. array(2, 3) => search only articles with certain article specifications $options['protected'] 'true' => do not search articles which are offline (locked) or articles in catgeories which are offline (protected) $options['dontshowofflinearticles'] 'false' => search offline articles or articles in categories which are offline $options['searchable_articles'] array of article ID's which should be searchable
$db
cDb
$db [optional] CONTENIDO database object

Throws

cDbException
cInvalidArgumentException

Overrides

cSearchBaseAbstract::__construct()
public boolean|array
# searchIndex( string $searchwords, string $searchwords_exclude = '' )

indexed fulltext search

indexed fulltext search

Parameters

$searchwords
string
$searchwords The search words
$searchwords_exclude
string
$searchwords_exclude [optional] The words, which should be excluded from search

Returns

boolean|array

Throws

cDbException
cException
cInvalidArgumentException
public
# setCmsOptions( mixed $cms_options )

Parameters

$cms_options
mixed
$cms_options The cms-types (htmlhead, html, ...) which should explicitly be searched.
public array
# stripWords( string $searchwords )

Parameters

$searchwords
string
$searchwords The search-words

Returns

array
of stripped search-words
public array
# getSubTree( integer $cat_start )

Returns the category tree array.

Returns the category tree array.

Parameters

$cat_start
integer
$cat_start Root of a category tree

Returns

array
Category Tree

Throws

cDbException
cInvalidArgumentException

Todo

This is not the job for search, should be outsourced ...
public array
# getSearchableArticles( array $search_range )

Returns list of searchable article ids in given search range.

Returns list of searchable article ids in given search range.

Parameters

$search_range
array
$search_range

Returns

array

Throws

cDbException
cInvalidArgumentException
public array
# getArticleSpecifications( )

Fetch all article specifications which are online.

Fetch all article specifications which are online.

Returns

array
Array of article specification Ids

Throws

cDbException
cInvalidArgumentException
public
# setArticleSpecification( integer $iArtspecID )

Set article specification.

Set article specification.

Parameters

$iArtspecID
integer
$iArtspecID
public boolean
# addArticleSpecificationsByName( string $sArtSpecName )

Add all article specifications matching name of article specification (client dependent but language independent).

Add all article specifications matching name of article specification (client dependent but language independent).

Parameters

$sArtSpecName
string
$sArtSpecName

Returns

boolean

Throws

cDbException
cInvalidArgumentException
Methods inherited from cSearchBaseAbstract
_debug()
Properties summary
protected object $_index
#

Instance of class Index

Instance of class Index

protected array $_searchWords array()
#

search words

search words

protected array $_searchWordsExclude array()
#

words which should be excluded from search

words which should be excluded from search

protected string $_searchOption
#

type of db search

type of db search

like => 'sql like' regexp => 'sql regexp'

protected string $_searchCombination
#

logical combination of searchwords (and, or)

logical combination of searchwords (and, or)

protected array $_searchableArts array()
#

array of searchable articles

array of searchable articles

protected array $_articleSpecs array()
#

article specifications

article specifications

protected boolean $_protected
#

If $protected = true => do not search articles which are offline or articles in catgeories which are offline (protected) unless the user has access to them.

If $protected = true => do not search articles which are offline or articles in catgeories which are offline (protected) unless the user has access to them.

protected boolean $_dontshowofflinearticles
#

If $dontshowofflinearticles = false => search offline articles or articles in categories which are offline.

If $dontshowofflinearticles = false => search offline articles or articles in categories which are offline.

protected boolean $_exclude
#

If $exclude = true => the specified search range is excluded from search, otherwise included.

If $exclude = true => the specified search range is excluded from search, otherwise included.

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.1 API documentation generated by ApiGen 2.8.0