Bibliography
Main parameters
According to the user’s choice, the variable sort_id determines the sort of the items to be displayed:
1: initial (year)
2: author
4: title
6: year
7: insertion date
20: selection (author, modern, ancient, from to)
The variable sort_key is used for:
0: first call of the options author and title (first letter not yet selected)
1: selection by first letter (author and title)
The function init_parameter (in functions.php), according the value of sort_id, initialize the other parameters used to compose the WHERE and ORDER clauses in the SQL query,
In bibliography.php and functions.php there is a reference to a selection or to a sort by keyword. The relevant instruction may be commented. This because a previous version of the system allowed the selection and the sort by means of the tables biblio_keyword and biblio_keyword_data. Since not all the entries in biblio_node has a link to these tables the selection by keyword has been removed from the user’s options. The references in the two programs have been left to facilitate the eventual new inclusion of this option. So the term keyword in the selection window is generic and does not refere to the two tables mentioned.
pageno: current page
total_rows: total number of lines to display, computed when displaying page 1
no_of_records_per_page: number of items to display in one page (see CONSTANT)
sort_key: 1: order by first letter
sort_key:0: order without considering the first letter
first_character: character chosen for the selection by the first letter
flag_search: 0: search without a string
flag_search:1: search by a string
Generating SQL query
In general a SQL query to read data has three parts:
SELECT
WHERE
ORDER
There are two functions sql_select and sql_where) to prepare the code of the SELECT and WHERE part according to the input parameters and some functions (named prepare_sql_ followed by a specification) to concatenate their output and complete the query. The term total in the name of a function prepare_sql_ means that the function is called on displaying the page 1 to compute the total number of item selected (variable total_rows). After a function prepare_sql_ is called to retrieve the data to display in the page.
Search with multiple search parameters
The term and used in the function name is to indicate the search for the entries that satisfy all the parameters.
The term or used in the function name is to indicate the search for the entries that satisfy at least one parameter.
There are some functions to generate the sql code:
– to search for the entries that have more than 1 parameter (prepare_sql_and_total, prepare_sql_and)
– to search for the entries that have 1 parameter (prepare_sql_or).
The items that satisfy all the search parameters must be displayed at the beginning of the items display (SEARCH RESULTS) and not be displayed in the following lines that report the items that satisfy at least one search parameter (PARTIAL SEARCH RESULTS).
The final display is performed by calling the function prepare_sql_and and making an operation of UNION with the results (prepare_sql_or) and excludes the items selected by the prepare_sql_and.
These two functions uses two variables (offset_and and offset_or) to compute the number of items to be selected for both the selections.
sel_and is a field added to the result of the function prepare_select to mark the item obtained by a selection and or by a selection or.
The logic of this structure is to send data to ajaxSelect in Bibliography.php prepared for the display regardless of the type of selection.
Page 1
prepare_sql_total is independent from parameters in search because the SELECT has the option COUNT(DISTINCT (biblio_node.nid)) so eliminating the duplicated items.
prepare_sql_and_total computes the total numbers of items selected with the and option.
prepare_sql_and_total_page determines the totale number of items selected with the and option to be displayed in the current page. This because the items that satisfy the and condition must precede other search’s results even in the pages following the first.
English
Italiano 