ultimix

- Main Page
- Data Structures
- Files
- Examples

- Data Structures
- Data Structure Index
- Data Fields

Public Member Functions | Data Fields
search_1_0_0 Class Reference

## Public Member Functions
| __construct ()
| get_list_of_packages ()
| get_records (&$Packages, $SearchString)
| filter_results ($Results)
| get_maximum_relevation ($Records)
| normalize_relevation (&$Results)
| get_search_line (&$Results)
| prepare_for_output ($SearchLine, $SearchString)
| get_next_page_limitations (&$SearchLine)
| get_switch_page_controler (&$SearchLine)
| output_search_results (&$SearchLine)
| search_results ()
| view ($Options)
| build_query_string ($Fields)

## Data Fields
| $BlockSettings = false
| $CachedMultyFS = false
| $Security = false
| $String = false
| $Output = false

## Detailed Description

Class provides site search routine.

Author
  Dodonov A.A.

Definition at line 26 of file search.php.

## Constructor & Destructor Documentation

__construct | ( |  | ) |

Constructor.

Author
  Dodonov A.A.

Definition at line 65 of file search.php.

{
try
{
$this->BlockSettings = get_package_object( 'settings::settings' , 'last' , __FILE__ );
$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 )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

## Member Function Documentation

build_query_string | ( |  | $Fields | ) |

Function creates query string.

Parameters

  $Fields | - Fields.

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 )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $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 )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

get_list_of_packages | ( |  | ) |

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' );
$Settigs = get_package_object( 'settings::settings' , 'last' , __FILE__ );
$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 )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $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 )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $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 )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $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 )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $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();
/* setting fetches ids */
foreach( $Results as $i => $Result )
{
foreach( $Result as $j => $Record )
{
set_field( $Results[ $i ][ $j ] , 'fetch_id' , $i );
}
}
/* composing records */
foreach( $Results as $i => $Result )
{
$SearchLine = array_merge( $SearchLine , $Result );
}
return( array_slice( $SearchLine , 0 , 10 ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $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();
$NextLimitations = $this->get_next_page_limitations( $SearchLine );
if( $NextLimitations != '' )
{
$Arrows [] = $this->get_right_arrow( $NextLimitations );
}
$Code = $this->CachedMultyFS->get_template( __FILE__ , 'search_form_controller.tpl' );
$Code = str_replace( '{arrows}' , implode( '&nbsp;' , $Arrows ) , $Code );
return( $Code );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $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 )
{
$MaxRelevation = $this->get_maximum_relevation( $Records );
foreach( $Records as $j => $Record )
{
set_field(
$Results[ $i ][ $j ] , 'relevation' ,
intval( get_field( $Results[ $i ][ $j ] , 'relevation' ) ) / $MaxRelevation
);
}
}
return( $Results );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $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
);
}
$this->Output .= $this->get_switch_page_controler( $SearchLine );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $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 )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

search_results | ( |  | ) |

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
{
$Packages = $this->get_list_of_packages();
$SearchString = $this->Security->get_gp( 'search_string' , 'string' , false );
if( $SearchString !== false )
{
$Records = $this->get_records( $Packages , $SearchString );
$FilteredRecords = $this->filter_results( $Records );
$NormalizedRecords = $this->normalize_relevation( $FilteredRecords );
$SearchLine = $this->get_search_line( $NormalizedRecords );
$SearchLine = $this->prepare_for_output( $SearchLine , $SearchString );
$this->output_search_results( $SearchLine );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

view | ( |  | $Options | ) |

Function draws component.

Parameters

  $Options | - Settings.

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 )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

## Field Documentation

$BlockSettings = false

Cached packages.

Author
  Dodonov A.A.

Definition at line 38 of file search.php.

$CachedMultyFS = false

Definition at line 39 of file search.php.

$Output = false

Display function's result.

Author
  Dodonov A.A.

Definition at line 53 of file search.php.

$Security = false

Definition at line 40 of file search.php.

$String = false

Definition at line 41 of file search.php.

The documentation for this class was generated from the following file:

- packages/search/search.php