Class: ItemSearch

Source Location: /CORE/system/classes/search/ItemSearch.php

Class ItemSearch

Class Overview

This Class is used for searching in Items.

The Search is performed within the content (text_5) and the following DB Columns:

  • name
  • description
  • catchwords
Following columns are selected by default:
  • id
  • name
  • language
By calling
, you add columns to your SearchResult. If you - for example - want to show the catchwords of an Item within the result screen, call
  1. addResultColumn('catchwords')
before executing
  1. search('foo')
.

Make sure the column name to add is existing, otherwise the search will fail with an SQL exception!

Hidden and deleted pages are not searched by default. You can

to search everything or
where $flag is one of
and
to exclude those from the seared items.

If you want to perform an language independet search, call

or
  1. $search->setSearchLanguageID(null)
or even simpler, call the constructor without a language
  1. new ItemSearch($itemtypenull)
.

Located in /CORE/system/classes/search/ItemSearch.php [line 73]



		
				Author(s):
		
  • Kevin Papst
Information Tags:
Version:  $Id: ItemSearch.php,v 1.15 2008/11/30 15:39:45 kpapst Exp $
Copyright:  Copyright (C) Kevin Papst
License:  GNU Public License

Properties

Methods

[ Top ]
Descendants
Child Class Description
MenuSearch This Class is used for searching in Menus!

[ Top ]
Property Summary
array   $FLAGS   Array of item flags to be excluded from the search.
mixed   $LANGUAGE_INDEPENDENT   Use this constant for searching in all languages (Language independent).

[ Top ]
Method Summary
ItemSearch   ItemSearch()   Initialize the ItemSearch with Itemtype and language.
void   addIgnoreFlag()   Adds a flag to the list of ignored items.
void   addResultColumn()   Adds a Column (from the Item table) that will be selected when searching.
void   finalize()   Call this to make sure all resources are freed.
void   init()  
void   resetIgnoreFlags()   Resets the list of ignored items.
array   search()   Perform the Search with the configured Options.
void   setLimit()   Set the Limit of Search Results.
void   setLimiter()   Set the Start and End Limits of the Serach Results.
void   setSearchContentOnly()   Sets whether we search in Content only or in all available Columns.
void   setSearchLanguageID()   Set the Searchable Language.
void   _performSearch()  

[ Top ]
Properties
array   $FLAGS = array(FLAG_TRASH,FLAG_HIDDEN) [line 106]

Array of item flags to be excluded from the search.

  • FLAG_TRASH, FLAG_HIDDEN

API Tags:
Access:  public


[ Top ]
mixed   $LANGUAGE_INDEPENDENT = SEARCH_LANGUAGE_INDEPENDENT [line 80]

Use this constant for searching in all languages (Language independent).

API Tags:
Deprecated:  use the constant SEARCH_LANGUAGE_INDEPENDENT instead.
Access:  public


[ Top ]
Methods
Constructor ItemSearch  [line 113]

  ItemSearch ItemSearch( int $itemtype, [int $language = null]  )

Initialize the ItemSearch with Itemtype and language.

Parameters:
int   $itemtype:  the ItemtypeID to search in
int   $language:  the LanguageID to search for


[ Top ]
addIgnoreFlag  [line 129]

  void addIgnoreFlag( $flag  )

Adds a flag to the list of ignored items.

Possible values: FLAG_TRASH,FLAG_HIDDEN

Parameters:
   $flag: 


[ Top ]
addResultColumn  [line 224]

  void addResultColumn( String $column  )

Adds a Column (from the Item table) that will be selected when searching.

Make sure the Column exists, otherwise the Search will fail!

Parameters:
String   $column:  the Column Name to select


[ Top ]
finalize  [line 319]

  void finalize( )

Call this to make sure all resources are freed.



[ Top ]
init  [line 137]

  void init( $itemtype, [ $language = null]  )

Parameters:
   $itemtype: 
   $language: 

API Tags:
Access:  protected


[ Top ]
resetIgnoreFlags  [line 121]

  void resetIgnoreFlags( )

Resets the list of ignored items.



[ Top ]
search  [line 237]

  array search( String $searchterm  )

Perform the Search with the configured Options.

An Array of SearchResult Objects is returned. If no result could be found, an empty array will be returned.

Parameters:
String   $searchterm:  the String to search for

API Tags:
Return:  an array of SearchResult Objects


[ Top ]
setLimit  [line 184]

  void setLimit( int $limit  )

Set the Limit of Search Results.

Parameters:
int   $limit:  a Limit of max. Results


[ Top ]
setLimiter  [line 194]

  void setLimiter( int $start, int $end  )

Set the Start and End Limits of the Serach Results.

Parameters:
int   $start:  the Start Value of Results
int   $end:  the End Value of Results


[ Top ]
setSearchContentOnly  [line 175]

  void setSearchContentOnly( boolean $bool  )

Sets whether we search in Content only or in all available Columns.

Parameters:
boolean   $bool:  true to search in Content only, false to search all Columns


[ Top ]
setSearchLanguageID  [line 205]

  void setSearchLanguageID( int $id  )

Set the Searchable Language.

See Class Doc for information about Language independent Search!

Parameters:
int   $id:  the LanguageID


[ Top ]
_performSearch  [line 283]

  void _performSearch( $searchterm, $EXTENSION, $COLUMNS, $SEARCH_COLUMN, $LIMIT  )

Parameters:
   $searchterm: 
   $EXTENSION: 
   $COLUMNS: 
   $SEARCH_COLUMN: 
   $LIMIT: 

API Tags:
Access:  protected


[ Top ]