Detailed Description
Class provides site search routine.
- Author
- Dodonov A.A.
Definition at line 26 of file search.php.
Constructor & Destructor Documentation
Constructor.
- Author
- Dodonov A.A.
Definition at line 65 of file search.php.
{
try
{
$this->CachedMultyFS =
get_package(
'cached_multy_fs' ,
'last' , __FILE__ );
$this->Security =
get_package(
'security' ,
'last' , __FILE__ );
$this->String =
get_package(
'string' ,
'last' , __FILE__ );
}
catch( Exception $e )
{
}
}
Member Function Documentation
| build_query_string |
( |
|
$Fields | ) |
|
Function creates query string.
- Parameters
-
- Returns
- Search script.
- Exceptions
-
| Exception | - An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 833 of file search.php.
{
try
{
$QueryString = '1 = 1';
$SearchString = $this->Security->get_gp( 'search_string' , 'string' , '' );
if( $SearchString !== '' && isset( $Fields[ 0 ] ) )
{
$QueryString = '( '.$Fields[ 0 ]." LIKE '%".$SearchString."%'";
for( $i = 1 ; $i < count( $Fields ) ; $i++ )
{
$QueryString .= ' OR '.$Fields[ $i ]." LIKE '%".$SearchString."%'";
}
$QueryString .= ' )';
}
return( $QueryString );
}
catch( Exception $e )
{
}
}
| filter_results |
( |
|
$Results | ) |
|
Function filters results with the zero relevation.
- Parameters
-
| $Results | - Search results. |
- Returns
- Search results.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 196 of file search.php.
{
try
{
foreach( $Results as $i => $Records )
{
$Return = array();
foreach( $Records as $j => $Record )
{
$Relevation = intval(
get_field( $Record ,
'relevation' ) );
if( $Relevation > 0 )
{
$Return [] = $Record;
}
}
$Results[ $i ] = $Return;
}
return( $Results );
}
catch( Exception $e )
{
}
}
Function returns list of packages.
- Returns
- List of packages.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 98 of file search.php.
{
try
{
$Config = $this->CachedMultyFS->get_config( __FILE__ , 'cf_search_access' , 'exploded' );
$Packages = array();
foreach( $Config as $i => $ConfigLine )
{
$Settigs->load_settings( $ConfigLine );
$PackageName = $Settigs->get_setting( 'package_name' );
$PackageVersion = $Settigs->get_setting( 'package_version' );
$Packages [] =
get_package( $PackageName , $PackageVersion , __FILE__ );
}
return( $Packages );
}
catch( Exception $e )
{
}
}
| get_maximum_relevation |
( |
|
$Records | ) |
|
Function returns maximum relevation for the record set.
- Parameters
-
| $Records | - Search results. |
- Returns
- Maximum relevation.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 246 of file search.php.
{
try
{
$MaxRelevation = 0;
if( isset( $Records[ 0 ] ) )
{
$MaxRelevation = intval(
get_field( $Records[ 0 ] ,
'relevation' ) );
foreach( $Records as $j => $Record )
{
$Tmp = intval(
get_field( $Record ,
'relevation' ) );
if( $Tmp > $MaxRelevation )
{
$MaxRelevation = $Tmp;
}
}
}
return( $MaxRelevation );
}
catch( Exception $e )
{
}
}
| get_next_page_limitations |
( |
& |
$SearchLine | ) |
|
Function draws page switch control.
- Parameters
-
| $SearchLine | - List of records to draw. |
- Returns
- Fetching conditions.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 531 of file search.php.
{
try
{
if( isset( $SearchLine[ 9 ] ) === false )
{
return( '' );
}
$Limitations = $this->Security->get_gp( 'search_output_limitations' , 'string' , '' );
$Limitations = explode( ',' , $Limitations );
foreach( $SearchLine as $i => $Record )
{
$FetchId =
get_field( $Record ,
'fetch_id' );
$Limitations[ $FetchId ]++;
}
return( implode( ',' , $Limitations ) );
}
catch( Exception $e )
{
}
}
| get_records |
( |
& |
$Packages, |
|
|
|
$SearchString |
|
) |
| |
Function returns search results.
- Parameters
-
| $Packages | - Search packages. |
| $SearchString | - Search string. |
- Returns
- Search results.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 150 of file search.php.
{
try
{
$Results = array();
$Limitations = $this->Security->get_gp( 'search_output_limitations' , 'string' , '' );
$Limitations = explode( ',' , $Limitations );
foreach( $Packages as $i => $Package )
{
$Results [] = call_user_func(
array( $Package ,
'search' ) ,
get_field( $Limitations , $i , 0 ) , $SearchString
);
}
return( $Results );
}
catch( Exception $e )
{
}
}
| get_search_line |
( |
& |
$Results | ) |
|
Function composes records for the output.
- Parameters
-
| $Results | - Search results. |
- Returns
- Search results.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 345 of file search.php.
{
try
{
$SearchLine = array();
foreach( $Results as $i => $Result )
{
foreach( $Result as $j => $Record )
{
set_field( $Results[ $i ][ $j ] ,
'fetch_id' , $i );
}
}
foreach( $Results as $i => $Result )
{
$SearchLine = array_merge( $SearchLine , $Result );
}
return( array_slice( $SearchLine , 0 , 10 ) );
}
catch( Exception $e )
{
}
}
| get_switch_page_controler |
( |
& |
$SearchLine | ) |
|
Function draws page switch control.
- Parameters
-
| $SearchLine | - List of records to draw. |
- Returns
- Control's HTML code.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 660 of file search.php.
{
try
{
$Arrows = $this->get_left_arrow();
if( $NextLimitations != '' )
{
$Arrows [] = $this->get_right_arrow( $NextLimitations );
}
$Code = $this->CachedMultyFS->get_template( __FILE__ , 'search_form_controller.tpl' );
$Code = str_replace( '{arrows}' , implode( ' ' , $Arrows ) , $Code );
return( $Code );
}
catch( Exception $e )
{
}
}
| normalize_relevation |
( |
& |
$Results | ) |
|
Normalizing relevation.
- Parameters
-
| $Results | - Search results. |
- Returns
- Search results.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 296 of file search.php.
{
try
{
$Return = array();
foreach( $Results as $i => $Records )
{
foreach( $Records as $j => $Record )
{
$Results[ $i ][ $j ] , 'relevation' ,
intval(
get_field( $Results[ $i ][ $j ] ,
'relevation' ) ) / $MaxRelevation
);
}
}
return( $Results );
}
catch( Exception $e )
{
}
}
| output_search_results |
( |
& |
$SearchLine | ) |
|
Function draws search results.
- Parameters
-
| $SearchLine | - List of records to draw. |
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 701 of file search.php.
{
try
{
$this->Output = '';
foreach( $SearchLine as $i => $Result )
{
$TemplatePath = dirname( __FILE__ ).'/res/templates/search_item.tpl';
$this->Output .= $this->CachedMultyFS->file_get_contents( $TemplatePath );
$this->Output = $this->String->print_record( $this->Output , $Result );
$this->Output = str_replace(
'{item_number}' ,
$this->Security->get_gp(
'page' ,
'integer' , 0 ) * 10 + $i + 1 ,
$this->Output
);
}
}
catch( Exception $e )
{
}
}
| prepare_for_output |
( |
|
$SearchLine, |
|
|
|
$SearchString |
|
) |
| |
Function prepares records for the output.
- Parameters
-
| $SearchLine | - Search results. |
| $SearchString | - Search string. |
- Returns
- Search results.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 490 of file search.php.
{
try
{
foreach( $SearchLine as $i => $Result )
{
$Preview = $this->compile_preview( $Result , $SearchString );
set_field( $SearchLine[ $i ] ,
'record_text' , $Preview );
}
return( $SearchLine );
}
catch( Exception $e )
{
}
}
Function draws component.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 741 of file search.php.
{
try
{
$SearchString = $this->Security->get_gp( 'search_string' , 'string' , false );
if( $SearchString !== false )
{
$Records = $this->
get_records( $Packages , $SearchString );
}
}
catch( Exception $e )
{
}
}
Function draws component.
- Parameters
-
- Returns
- HTML code of the component.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 792 of file search.php.
{
try
{
$ContextSet =
get_package(
'gui::context_set' ,
'last' , __FILE__ );
$ContextSet->add_context( dirname( __FILE__ ).'/conf/cfcx_search_form' );
$ContextSet->add_context( dirname( __FILE__ ).'/conf/cfcx_search_results' );
if( $ContextSet->execute( $Options , $this , __FILE__ ) )return( $this->Output );
return( $this->Output );
}
catch( Exception $e )
{
}
}
Field Documentation
Cached packages.
- Author
- Dodonov A.A.
Definition at line 38 of file search.php.
Display function's result.
- Author
- Dodonov A.A.
Definition at line 53 of file search.php.
The documentation for this class was generated from the following file: