Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
SearchDoc Class Reference
+ Collaboration diagram for SearchDoc:

Public Member Functions

 __construct ($dbaccess= '', $fromid=0)
 
 onlyCount ()
 
 getOriginalQuery ()
 
 join ($jointure)
 
 count ()
 
 reset ()
 
 rewind ()
 
 isExecuted ()
 
 getFilters ()
 
 search ()
 
 getDocumentList ()
 
 returnsOnly (array $returns)
 
 getReturnsFields ()
 
 searchError ()
 
 getError ()
 
 setDebugMode ($debug=true)
 
 setRecursiveSearch ($recursiveMode=true, $level=2)
 
 getDebugInfo ()
 
 getSearchInfo ()
 
 setSlice ($slice)
 
 setOrder ($order, $orderbyLabel= '')
 
 useCollection ($dirid)
 
 setStart ($start)
 
 nextDoc ()
 
 getNextDoc ()
 
 getIds ()
 
 addFilter ($filter, $args= '')
 
 addGeneralFilter ($keywords, $useSpell=false, $usePartial=false)
 
 setPertinenceOrder ($keyword= '')
 
 getHighLightText (Doc &$doc, $beginTag= '< b >', $endTag= '</b >', $limit=200, $wordMode=true)
 
 noViewControl ()
 
 overrideViewControl ()
 
 setObjectReturn ($returnobject=true)
 
 isObjectReturn ()
 
 setValueReturn ()
 
 excludeConfidential ($exclude=true)
 
 getQueries ()
 

Static Public Member Functions

static getUserViewVector ($uid)
 
static checkGeneralFilter ($keyword)
 
static getGeneralFilter ($keywords, $useSpell=false, &$pertinenceOrder= '', &$highlightWords= '', $usePartial=false)
 
static sqlcond (array $values, $column, $integer=false)
 

Data Fields

 $fromid
 
 $dirid = 0
 
 $recursiveSearch = false
 
 $folderRecursiveLevel = 2
 
 $slice = "ALL"
 
 $start = 0
 
 $filters = array()
 
 $only = false
 
 $distinct = false
 
 $orderby = 'title'
 
 $orderbyLabel = ''
 
 $trash = ""
 
 $latest = true
 
 $userid = 0
 

Protected Member Functions

 countDocs ()
 
 getNextDocument (Array $v)
 
 recursiveSearchInit ()
 

Static Protected Member Functions

static testSpell ($word, $language="fr")
 

Protected Attributes

 $originalDirId = 0
 
 $returnsFields = array()
 

Detailed Description

document searches

$s=new SearchDoc($db,"IUSER");
$s->setObjectReturn(); // document object returns
$s->addFilter('us_extmail is not null'); // simple filter
$s->search(); // send search query
$c=$s->count();
print "count $c\n";
$k=0;
while ($doc=$s->nextDoc()) {
// iterate document by document
print "$k)".$doc->getTitle()."(".$doc->getRawValue("US_MAIL","nomail").")\n";clam
$k+

Definition at line 34 of file Class.SearchDoc.php.

Constructor & Destructor Documentation

__construct (   $dbaccess = '',
  $fromid = 0 
)

initialize with family

Parameters
string$dbaccessdatabase coordinate
int | string$fromidfamily identifier to filter

Definition at line 165 of file Class.SearchDoc.php.

+ Here is the call graph for this function:

Member Function Documentation

addFilter (   $filter,
  $args = '' 
)

add a condition in filters

Api:
add a new condition in filters
Parameters
string$filterthe filter string
string$argsarguments of the filter string (arguments are escaped to avoid sql injection)
Returns
void

Definition at line 783 of file Class.SearchDoc.php.

+ Here is the call graph for this function:

addGeneralFilter (   $keywords,
  $useSpell = false,
  $usePartial = false 
)

add global filter based on keyword to match any attribute value available example : foo : filter all values with has the word foo foo bar : the word foo and the word bar are set in document attributes foo OR bar : the word foo or the word bar are set in a document attributes foo OR (bar AND zou) : more complex logical expression

Api:
add global filter based on keyword
Parameters
string$keywords
bool$useSpelluse spell french checker
bool$usePartialif true each words are defined as partial characters
Exceptions
\Dcp\SearchDoc\ExceptionSD0004 SD0003 SD0002

Definition at line 816 of file Class.SearchDoc.php.

+ Here is the call graph for this function:

static checkGeneralFilter (   $keyword)
static

Verify if $keywords syntax is comptatible with a part of query for the moment verify only parenthesis balancing

Parameters
string$keyword
Returns
bool

Definition at line 831 of file Class.SearchDoc.php.

count ( )

count results search must be call before

See Also
SearchDoc::search()
Api:
count results after query search is sended
Returns
int

Definition at line 346 of file Class.SearchDoc.php.

+ Here is the call graph for this function:

countDocs ( )
protected

count returned document in sql select ressources

Returns
int

Definition at line 363 of file Class.SearchDoc.php.

+ Here is the call graph for this function:

excludeConfidential (   $exclude = true)

add a filter to not return confidential document if current user cannot see it

Api:
add a filter to not return confidential
Parameters
boolean$excludeset to true to exclude confidential
Returns
void

Definition at line 1203 of file Class.SearchDoc.php.

+ Here is the call graph for this function:

getDebugInfo ( )

return debug info if debug mode enabled

Deprecated:
use getSearchInfo instead
Returns
array of info

Definition at line 600 of file Class.SearchDoc.php.

+ Here is the call graph for this function:

getDocumentList ( )

return document iterator to be used in loop

$s=new \SearchDoc($dbaccess, $famName);
$s->setObjectReturn();
$s->search();
$dl=$s->getDocumentList();
foreach ($dl as $docId=>$doc) {
print $doc->getTitle();
}
Api:
get document iterator
Returns
DocumentList

Definition at line 505 of file Class.SearchDoc.php.

getError ( )

Return error message

Api:
get error message
Returns
string

Definition at line 560 of file Class.SearchDoc.php.

getFilters ( )

Return sql filters used for request

Returns
array of string

Definition at line 409 of file Class.SearchDoc.php.

static getGeneralFilter (   $keywords,
  $useSpell = false,
$pertinenceOrder = '',
$highlightWords = '',
  $usePartial = false 
)
static

get global filter

See Also
SearchDoc::addGeneralFilter
Parameters
string$keywords
bool$useSpell
string$pertinenceOrderreturn pertinence order
string$highlightWordsreturn words to be use by SearchHighlight class
bool$usePartialif true each words are defined as partial characters
Returns
string
Exceptions
\Dcp\Lex\LexException
\Dcp\SearchDoc\Exception

Definition at line 877 of file Class.SearchDoc.php.

+ Here is the call graph for this function:

getHighLightText ( Doc $doc,
  $beginTag = '<b>',
  $endTag = '</b>',
  $limit = 200,
  $wordMode = true 
)

return a document part where general filter term is found

See Also
SearchDoc::addGeneralFilter
Parameters
Doc$docdocument to analyze
string$beginTagdelimiter begin tag
string$endTagdelimiter end tag
int$limitfile size limit to analyze
Returns
mixed

Definition at line 1077 of file Class.SearchDoc.php.

+ Here is the call graph for this function:

getIds ( )

after search return only document identifiers instead of complete document

Api:
get only document identifiers
Returns
int[] document identifiers

Definition at line 731 of file Class.SearchDoc.php.

getNextDoc ( )

can, be use in loop search must be call before

See Also
SearchDoc::search
Api:
get next document results
Returns
Doc|array|bool false if this is the end

Definition at line 701 of file Class.SearchDoc.php.

+ Here is the call graph for this function:

getNextDocument ( Array  $v)
protected

Return an object document from array of values

Parameters
array$vthe values of documents
Returns
Doc the document object

Definition at line 755 of file Class.SearchDoc.php.

+ Here is the call graph for this function:

getOriginalQuery ( )

return original sql query before test permissions

Returns
string

Definition at line 306 of file Class.SearchDoc.php.

+ Here is the call graph for this function:

getQueries ( )

Get the SQL queries that will be executed by the search() method

Returns
array|bool boolean false on error, or array() of queries on success.

Definition at line 1240 of file Class.SearchDoc.php.

+ Here is the call graph for this function:

getReturnsFields ( )

Definition at line 538 of file Class.SearchDoc.php.

+ Here is the call graph for this function:

getSearchInfo ( )

return informations about query after search has been sent array indexes are : query, err, count, delay

Api:
get informations about query results
Returns
array of info

Definition at line 611 of file Class.SearchDoc.php.

static getUserViewVector (   $uid)
static

return memberof to be used in profile filters

Parameters
$uid
Returns
string

Definition at line 290 of file Class.SearchDoc.php.

+ Here is the call graph for this function:

isExecuted ( )

Verify if query is already sended to database

Returns
boolean

Definition at line 400 of file Class.SearchDoc.php.

isObjectReturn ( )

Definition at line 1183 of file Class.SearchDoc.php.

join (   $jointure)

add join condition

Api:
Add join condition
$s=new searchDoc();
$s->trash='only';
$s->join("id = dochisto(id)");
$s->addFilter("dochisto.uid = %d",$this->getSystemUserId());
// search all document which has been deleted by search DELETE code in history
$s->addFilter("dochisto.code = 'DELETE'");
$s->distinct=true;
$result= $s->search();
Parameters
string$jointure
Exceptions
Dcp\Exception

Definition at line 327 of file Class.SearchDoc.php.

nextDoc ( )

can, be use in loop search must be call before

See Also
Application::getNextDoc
Deprecated:
use Application::getNextDoc instead
See Also
SearchDoc::search
Returns
Doc|array or null if this is the end

Definition at line 686 of file Class.SearchDoc.php.

+ Here is the call graph for this function:

noViewControl ( )

no use access view control in filters

See Also
SearchDoc::overrideViewControl
Deprecated:
use SearchDoc::overrideViewControl instead
Returns
void

Definition at line 1156 of file Class.SearchDoc.php.

+ Here is the call graph for this function:

onlyCount ( )

Count results without returning data.

Note:

Api:
send query search and only count results
Returns
int the number of results
Exceptions
Dcp\SearchDoc\Exception
Dcp\Db\Exception

Definition at line 229 of file Class.SearchDoc.php.

+ Here is the call graph for this function:

overrideViewControl ( )

no use access view control in filters

Api:
no add view access criteria in final query
Returns
void

Definition at line 1166 of file Class.SearchDoc.php.

recursiveSearchInit ( )
protected

Definition at line 1214 of file Class.SearchDoc.php.

+ Here is the call graph for this function:

reset ( )

reset results to use another search

Returns
void

Definition at line 376 of file Class.SearchDoc.php.

+ Here is the call graph for this function:

returnsOnly ( array  $returns)

limit query to a subset of somes attributes

Parameters
array$returns

Definition at line 514 of file Class.SearchDoc.php.

+ Here is the call graph for this function:

rewind ( )

reset result offset use it to redo a document's iteration

Definition at line 389 of file Class.SearchDoc.php.

search ( )

send search the query is sent to database

Api:
send query
Returns
array|null|SearchDoc array of documents if no setObjectReturn else itself
Exceptions
Dcp\SearchDoc\Exception
Dcp\Db\Exception

Definition at line 427 of file Class.SearchDoc.php.

+ Here is the call graph for this function:

searchError ( )

return error message

Returns
string empty if no errors

Definition at line 551 of file Class.SearchDoc.php.

+ Here is the call graph for this function:

setDebugMode (   $debug = true)

do the search in debug mode, you can after the search get infrrmation with getDebugIndo()

Parameters
boolean$debugset to true search in debug mode
Deprecated:
no debug mode setting are necessary
Returns
void

Definition at line 571 of file Class.SearchDoc.php.

+ Here is the call graph for this function:

setObjectReturn (   $returnobject = true)

the return of search will be array of document's object

Api:
set return type : document object or document array
Parameters
bool$returnobjectset to true to return object, false to return raw data
Returns
void

Definition at line 1177 of file Class.SearchDoc.php.

setOrder (   $order,
  $orderbyLabel = '' 
)

use different order , default is title

Api:
set order to sort results
Parameters
string$orderthe new order, empty means no order
string$orderbyLabelstring of comma separated columns names on which the order should be performed on their label instead of their value (e.g. order enum by their label instead of their key)
Returns
void

Definition at line 635 of file Class.SearchDoc.php.

setPertinenceOrder (   $keyword = '')

add a order based on keyword consider how often the keyword terms appear in the document

Api:
add a order based on keyword
Parameters
string$keyword

Definition at line 854 of file Class.SearchDoc.php.

+ Here is the call graph for this function:

setRecursiveSearch (   $recursiveMode = true,
  $level = 2 
)

set recursive mode for folder searches can be use only if collection set if a static folder

Parameters
bool$recursiveModeset to true to use search in sub folders when collection is folder
int$levelIndicate depth to inspect subfolders
Exceptions
Dcp\SearchDoc\Exception
Api:
set recursive mode for folder searches
See Also
SearchDoc::useCollection
Returns
void

Definition at line 586 of file Class.SearchDoc.php.

setSlice (   $slice)

set maximum number of document to return

Api:
set maximum number of document to return
Parameters
int$slicethe limit ('ALL' means no limit)
Returns
Boolean

Definition at line 622 of file Class.SearchDoc.php.

setStart (   $start)

set offset where start the result window

Api:
set offset where start the result window
Parameters
int$startthe offset (0 is the begin)
Returns
Boolean true if set

Definition at line 668 of file Class.SearchDoc.php.

setValueReturn ( )

the return of search will be array of values

Deprecated:
use setObjectReturn(false) instead
Returns
void

Definition at line 1192 of file Class.SearchDoc.php.

+ Here is the call graph for this function:

static sqlcond ( array  $values,
  $column,
  $integer = false 
)
static

return where condition like : foo in ('x','y','z')

Parameters
array$valuesset of values
string$columndatabase column name
bool$integerset to true if database column is numeric type
Returns
string

Definition at line 1131 of file Class.SearchDoc.php.

+ Here is the call graph for this function:

static testSpell (   $word,
  $language = "fr" 
)
staticprotected

detect if word is a word of language if not the near word is set to do an OR condition

Parameters
string$wordword to analyze
string$language
Returns
string word with its correction if it is not correct

Definition at line 1104 of file Class.SearchDoc.php.

+ Here is the call graph for this function:

useCollection (   $dirid)

use folder or search document to search within it

Api:
use folder or search document
Parameters
int$dirididentifier of the collection
Returns
Boolean true if set

Definition at line 649 of file Class.SearchDoc.php.

Field Documentation

$dirid = 0

folder identifier filter int

Definition at line 45 of file Class.SearchDoc.php.

$distinct = false

bool

Definition at line 80 of file Class.SearchDoc.php.

$filters = array()

sql filters array

Definition at line 70 of file Class.SearchDoc.php.

$folderRecursiveLevel = 2

max recursive level int

Definition at line 55 of file Class.SearchDoc.php.

$fromid

family identifier filter string

Definition at line 40 of file Class.SearchDoc.php.

$latest = true

restriction to latest revision bool

Definition at line 100 of file Class.SearchDoc.php.

$only = false

search in sub-families set false if restriction to top family bool

Definition at line 75 of file Class.SearchDoc.php.

$orderby = 'title'

order of result : like sql order string

Definition at line 85 of file Class.SearchDoc.php.

$orderbyLabel = ''

order result by this attribute label/title string

Definition at line 90 of file Class.SearchDoc.php.

$originalDirId = 0
protected

Definition at line 156 of file Class.SearchDoc.php.

$recursiveSearch = false

recursive search for folders boolean

Definition at line 50 of file Class.SearchDoc.php.

$returnsFields = array()
protected

Definition at line 158 of file Class.SearchDoc.php.

$slice = "ALL"

number of results : set "ALL" if no limit int

Definition at line 60 of file Class.SearchDoc.php.

$start = 0

index of results begins int

Definition at line 65 of file Class.SearchDoc.php.

$trash = ""

to search in trash : [no|also|only] string

Definition at line 95 of file Class.SearchDoc.php.

$userid = 0

user identifier : set to current user by default int

Definition at line 105 of file Class.SearchDoc.php.


The documentation for this class was generated from the following file:
← centre documentaire © anakeen