- About myPageDisplay
- Installation instructions
- Class Methods
- myPageDisplay Class Constructor
- Method: last_message
- Method: getVersion
- Method: set_this_page
- Method: get_total_rows
- Method: get_number_of_pages
- Method: get_page_result
- Method: get_page_num_rows
- Method: get_number_of_fields
- Method: get_field_names
- Method: free_db_result
- Method: rebuild_query_string
- Method: navigation_links
- Method: page_info
- Method: simple_prev_next_link
- Method: css_prev_next_link
- Method: set_this_sortCol
- Method: set_this_sortOrder
- Method: reverseOrder
- Method: displayOrder
- Method: setCheckBox
- Method: setColumnHeaders
- Method: setActions
- Method: showColumnHeaders
- Method: createListTable
- Method: passedActionCheck
- Method: checkLogic
- Method: checkCondition
- Method: getHrefArgs
- Method: buildHrefArgs
- Method: getFuncArgs
- Method: getOnClickArgs
- Method: getFieldVal
- Examples
- Change Log
- License (LGPL)
About myPageDisplay
myPageDisplay is a simple PHP class for the creation of page navigation & columnar data output with dynamically sorted colums
I couldn't find anything that did all that I wanted it to, in that it would create a navigation bar, print a table of data and have dynamic columns that could sort in both ascending and descending order. I've used the navigation ideas from other scripts I have come across, but the columnar thing is my own so, no doubt, this is the area where things might go wrong! :-(
The class can be used to produce just navigation links or just the columnar data or, of course, both. :-)
The process order is as follows:-
- Set_this_sortCol & set_this_sortOrder will read the query line and set the relevant variables. Pass a default value for 1st pass.
- Set the column headers. This is a passed array of arrays stipulating the column name, width, sort flag, alignment and either an array of link information or a straight link.
- Set the action array. If you need to perform an action on the columns, such as Edit or Delete, then set the actions array and an action column will be created
- Set the sql statement. In the example files I have used a function to enable sorting.
- Get the result handle for the sql statement
- Generate the navigation links
- Generate the table. This will create the column headers and calculate the sort order, etc.
I haven't been writing classes in PHP for long, so please excuse any mistakes, etc. Hope you like it and find it useful.
Requirements
MySQL.Installing myPageDisplay
Download the files from phpclasses.org and unzip it to your chosen directory. The directory structure below will be generated.
Extracted Files /test.sql /example.php /classes/mypagedisplay_class.php /images/mypagedisplay_buttons/asc_order.png /images/mypagedisplay_buttons/button_first.gif /images/mypagedisplay_buttons/button_last.gif /images/mypagedisplay_buttons/button_next.gif /images/mypagedisplay_buttons/button_previous.gif /images/mypagedisplay_buttons/b_edit.png /images/mypagedisplay_buttons/b_delete.png /images/mypagedisplay_buttons/desc_order.png /images/mypagedisplay_buttons/small_key.gif /style/style.css
The only file that is required is the 'mypagedisplay_class.php' which can sit in any directory you want. The rest of the files and the directory structure used are just for the example file. However, as the class is designed to work with a css stylesheet to improve the look and feel a style.css is supplied as an example. Also the icons supplied are here as an example. Feel free to change to suit your environment.
myPageDisplay Class Constructor
The constructor initialises a number of variables that are used throughout the class
// SQL query related variables
$this->sql = ''; // sql statment to use for query
$this->result = ''; // return value for sql statement
// Page related variables
$this->current_page = 0; // current page number
$this->number_of_pages= 0; // total number of pages returned
$this->num_rows = 0; // total number of rows returned
$this->num_fields = 0; // number of fields in a query
$this->field_names = array(); // array of field names in query
$this->number_of_links= 10; // the number of page links to be viewed on each page
$this->rows_on_page = 20; // the number of rows to be viewed on each page
$this->get_page_var = 'page'; // the name of the variable used inside a query string to identify the page required
$this->get_pagn_var = 'pagn'; // the name of the variable used inside a query string to identify the pagination state required
$this->get_rown_var = 'rown'; // the name of the variable used inside a query string to identify the number of rows per page
$this->str_first = "<<";
$this->str_next = ">";
$this->str_previous = "<";
$this->str_last = ">>";
// Column related variables
$this->sortCol = ''; // sorted column name
$this->sortOrder = ''; // sort direction. either 'asc' or 'desc'
$this->columnHeaders = array(); // array of column headers. seee function description, showColumnHeaders, for more detail
$this->get_scol_var = 'sCol'; // the name of the variable used inside a query string to identify the column to be sorted
$this->get_sord_var = 'sOrder'; // the name of the variable used inside a query string to identify the direction of the sort
$this->actions = array(); // this array holds the action and corresponding function list to be displayedon each row
$this->actionColumn = false; // set to true if actions are required
// General variables
$this->paginate = true; // set to false to turn off pagination
$this->debug = false; // set to true to view debug messages
$this->rootDir = ''; // path to root directory
$this->version = '1.1f'; // current version number of this class
Method: last_message($message)
Used for debugging purposes. Set $this->debug to TRUE to display debug messages
Method: getVersion()
Used to display the current version of the class
Method: set_this_page()
Sets the current active page number
Dependants: $this->get_page_var (default: 'page') which is passed as part of the request
Returns: $this->current_page
Called By: page_info(), navigation_links(), get_page_result()
Method: get_total_rows()
Returns the total number of rows for the SQL query
Dependants: $this->sql which is set in the calling script
Returns: $this->all_rows
Called By: get_page_result()
Method: get_number_of_pages()
Calculates the number of pages, based on the total rows divided by the number of rows to be displayed per page.Dependants: $this->all_rows, $this->rows_on_page
Returns: $this->number_of_pages
Called By: navigation_links()
Method: get_page_result()
Core method that returns the query object that is used to generate the columns. If $this->paginate is set to TRUE then a limit is added to the sql statement to give the paginated results.Dependants: $this->sql, which is set in the calling script, $this->paginate, $this->rows_on_page
Returns: $this->all_rows
Calls: get_total_rows()
Called By: none
Method: get_page_num_rows()
Calculates the number of rows returned the the SQL statement for teh current pageDependants: $this->result which is generated by the get_page_result() method
Returns: $this->num_rows
Called By: none
Example $mypd = new myPageDisplay; $mypd->sql = getSql($sortCol, $sortOrder); $result = $mypd->get_page_result(); // result set $num_rows = $mypd->get_page_num_rows(); // number of records in result set $mypd->free_db_result();
Method: get_number_of_fields()
Count the number of fields in a row that are requested by the SQL statementDependants: $this->result
Returns: $this->num_fields
Called By: get_field_names()
Method: get_field_names()
Generates the array $this->field_names for use in building the href and action functionsDependants: $this->get_number_of_fields
Returns: $this->field_names
Called By: getHrefArgs(), getFuncArgs()
Method: free_db_result()
Destroys the SQL object generated by get_page_result() methodDependants: $this->result
Returns: none
Called By: none
Example $mypd = new myPageDisplay; $mypd->sql = getSql($sortCol, $sortOrder); $result = $mypd->get_page_result(); // result set $num_rows = $mypd->get_page_num_rows(); // number of records in result set $mypd->free_db_result();
Method: rebuild_query_string($curr_var)
Generates an additional query taken from the quersystring, without the variable (s) specified by $curr_varDependants: $curr_var is usually the $this->get_page_var being passed (default: 'page'), but can be an array of exclusions
Returns: $qs
Called By: navigation_links(), showColumnHeaders()
Method: navigation_links($separator = " | ", $css_current = "", $use_prev_next_css = false, $prev_next = false)
Builds and returns the navigation links.
| Passed: | $separator | separator value to be shown between page links |
| $css_current | the css value to use for links | |
| $use_prev_next_css | use css values for previous and next symbols if set to TRUE | |
| $prev_next | display backward & forward symbols ONLY if set to TRUE |
Dependants: $this->number_of_links, $this->get_page_var, $this->str_first, $this->str_previous, $this->str_next, $this->str_last
Calls: get_number_of_pages(), set_this_page(), rebuild_query_string()
Returns: $this->nav_string
Called By: simple_prev_next_link(), css_prev_next_link(), or calling script
Example
$mypd = new myPageDisplay;
$mypd->sql = getSql($sortCol, $sortOrder);
$result = $mypd->get_page_result(); // result set
$num_rows = $mypd->get_page_num_rows(); // number of records in result set
$css_page_links = $mypd->navigation_links(" ", '', true, false); // the navigation links (define a CSS class selector for the current link)
$simple_page_links = $mypd->navigation_links(" | ", '', false, false); // basic the navigation links with a seperator
$mypd->free_db_result();
Method: page_info($to = "-")
This will tell the visitor the current number of records that are shown on the this pageDependants: $this->rows_on_page, $this->all_rows
Calls: set_this_page(),
Returns: $this->info
Called By: none
Example
$mypd = new myPageDisplay;
$mypd->sql = getSql($sortCol, $sortOrder);
$result = $mypd->get_page_result(); // result set
$num_rows = $mypd->get_page_num_rows(); // number of records in result set
$css_page_links = $mypd->navigation_links(" ", '', true, false); // the navigation links (define a CSS class selector for the current link)
$simple_page_links = $mypd->navigation_links(" | ", '', false, false); // basic the navigation links with a seperator
$nav_info = $mypd->page_info("to"); // information about the number of records on page ("to" is the text between the number)
$mypd->free_db_result();
Method: simple_prev_next_link()
Simple method to show only the page back and forward link.Dependants: none
Calls: navigation_links(" ", "", false, true)
Returns: $simple_links
Called By: none
Example $mypd = new myPageDisplay; $mypd->sql = getSql($sortCol, $sortOrder); $result = $mypd->get_page_result(); // result set $num_rows = $mypd->get_page_num_rows(); // number of records in result set $simple_nav_links = $mypd->simple_prev_next_link(); // the navigation with only the back and forward links $mypd->free_db_result();
Method: css_prev_next_link()
Simple method to show only the page back and forward link using css style.Dependants: none
Calls: navigation_links(" ", "", true, true)
Returns: $simple_links
Called By: none
Example $mypd = new myPageDisplay; $mypd->sql = getSql($sortCol, $sortOrder); $result = $mypd->get_page_result(); // result set $num_rows = $mypd->get_page_num_rows(); // number of records in result set $css_nav_links = $mypd->css_prev_next_link(); // the navigation with only the back and forward links $mypd->free_db_result();
Method: set_this_sortCol($col)
Sets the current sort column ($this->sortCol). This is passed to our example function getSql() to determine the column to sort on for the selection, as well as used by other methods within the class.
Passed: $col - this is only used if the $this->get_scol_var variable is not set in the $_REQUEST array
Dependants: $this->get_scol_var
Returns: $this->sortCol
Called By: none
Example
$mypd = new myPageDisplay;
$sortCol = $mypd->set_this_sortCol('rescueCentreName'); // Set the sort column. If not passed use the default passed
$sortOrder = $mypd->set_this_sortOrder('asc'); // Set the sort oreder. If not passed use the default passed
$mypd->sql = getSql($sortCol, $sortOrder);
$result = $mypd->get_page_result(); // result set
$num_rows = $mypd->get_page_num_rows(); // number of records in result set
$css_nav_links = $mypd->css_prev_next_link(); // the navigation with only the back and forward links
$mypd->free_db_result();
// *****************************************************************
function getSql($sortCol, $sortOrder){
global $db;
$sql = "SELECT id,
rescueCentreName,
town,
county,
locked
FROM myPageDisplay
ORDER BY ";
// Generate sort statement to use for list by means of using the case statement
switch ($sortCol) {
case 'rescueCentreName':
if($sortOrder == "asc" && $sortCol == "rescueCentreName") {
$sql .= "rescueCentreName";
} else {
$sql .= "rescueCentreName DESC";
}
break;
case 'town':
if($sortOrder == "asc" && $sortCol == "town") {
$sql .= "town";
} else {
$sql .= "town DESC";
}
break;
case 'county':
if($sortOrder == "asc" && $sortCol == "county") {
$sql .= "county";
} else {
$sql .= "county DESC";
}
break;
default :
$sql .= "rescueCentreName";
break;
}
return $sql;
} # function getSql($sortCol, $sortOrder)
Method: set_this_sortOrder($order)
Sets the current sort order ($this->sortOrder) to either 'asc' or 'desc'. This is passed to our example function getSql() to determine the order of the selection, as well as used by other methods within the class.
Passed: $order - this is only used if the $this->get_scol_var variable is not set in the $_REQUEST array
Dependants: $this->get_scol_var
Returns: $this->sortOrder
Called By: none
Example
$mypd = new myPageDisplay;
$sortCol = $mypd->set_this_sortCol('rescueCentreName'); // Set the sort column. If not passed use the default passed
$sortOrder = $mypd->set_this_sortOrder('asc'); // Set the sort oreder. If not passed use the default passed
$mypd->sql = getSql($sortCol, $sortOrder);
$result = $mypd->get_page_result(); // result set
$num_rows = $mypd->get_page_num_rows(); // number of records in result set
$css_nav_links = $mypd->css_prev_next_link(); // the navigation with only the back and forward links
$mypd->free_db_result();
// *****************************************************************
function getSql($sortCol, $sortOrder){
global $db;
$sql = "SELECT id,
rescueCentreName,
town,
county,
locked
FROM myPageDisplay
ORDER BY ";
// Generate sort statement to use for list by means of using the case statement
switch ($sortCol) {
case 'rescueCentreName':
if($sortOrder == "asc" && $sortCol == "rescueCentreName") {
$sql .= "rescueCentreName";
} else {
$sql .= "rescueCentreName DESC";
}
break;
case 'town':
if($sortOrder == "asc" && $sortCol == "town") {
$sql .= "town";
} else {
$sql .= "town DESC";
}
break;
case 'county':
if($sortOrder == "asc" && $sortCol == "county") {
$sql .= "county";
} else {
$sql .= "county DESC";
}
break;
default :
$sql .= "rescueCentreName";
break;
}
return $sql;
} # function getSql($sortCol, $sortOrder)
Method: reverseOrder($curr_col)
Reverses the current order for the column.Dependants: $this->sortCol is compared to $curr_col. If the same then reverse order, otherwise new column set to ascending order.
Returns: $sortOrder
Called By: showColumnHeaders()
Method: displayOrder()
Generate a bit of javascript that will change the classnames of the sorted columnsDependants: $this->sortCol, $this->sortOrder
Returns: $str
Called By: createListTable()
Method: setCheckBox($checkbox_array)
Sets the global checkbox array with passed value and the checkboxColumn flag to true
The array that is passed is an array of arrays consisting of the following:
| 'aTitle' | => | title line displayed for checkbox tip | |
| 'aName' | => | name of fieeldname array used by php | |
| 'aFunction' | => | additional function to perform if checkbox clicked | |
| 'aCriteria' | => | display this checkbox if criteria met | |
| 'cAlign' | => | alignment (left, center, right) | |
| 'cWidth' | => | column width (%, px, etc) |
Dependants: $this->checkbox, $this->checkboxColumn
Returns: none
Called By: none
Example
$mypd = new myPageDisplay;
if(isset($_POST['saleUpd'])) {
foreach($_POST['saleUpd'] as $key=>$id){
print "key=$key, id=$id<br />";
}
}
$mypd->setCheckBox(array( 'aTitle' => 'Select for sale update',
'aName' => 'saleUpd',
'aValue' => 'id',
'aFunction' => '',
'aCriteria' => '',
'cAlign' => 'right',
'cWidth' => '6%'
)
);
Method: setColumnHeaders($col_array)
Set the columnHeaders variable $this->columnHeaders.
The array that is passed is an array of arrays consisting of the following:
| 'cTitle' | => | column name | |
| 'cField' | => | db field name | |
| 'cWidth' | => | column width (%, px, etc) | |
| 'cSort' | => | sort column? 1 = true, 0 = false | |
| 'cAlign' | => | alignment (left, center, right) | |
| 'fFunction' | => | function to perform on db field | |
| 'fLink' | => | link action for db field | |
| 'lTarget' | => | target for link action, eg "_blank" for new window |
Dependants: $this->columnHeaders
Returns: none
Called By: none
Example
$mypd = new myPageDisplay;
$mypd->setColumnHeaders(array (
array( 'cTitle' => "ID",
'cField' => 'id',
'cWidth' => '5%',
'cSort' => 0,
'cAlign' => 'center',
'fFunction' => '',
'fLink' => '',
'lTarget' => ''
),
array( 'cTitle' => "Rescue Centre",
'cField' => 'rescueCentreName',
'cWidth' => '35%',
'cSort' => 1,
'cAlign' => 'left',
'fFunction' => '',
'fLink' => array($_SERVER['PHP_SELF'],'cmd=0','r=id'),
'lTarget' => ''
),
array( 'cTitle' => "Town",
'cField' => 'town',
'cWidth' => '15%',
'cSort' => 1,
'cAlign' => 'left',
'fFunction' => '',
'fLink' => '',
'lTarget' => ''
),
array( 'cTitle' => "County",
'cField' => 'county',
'cWidth' => '20%',
'cSort' => 1,
'cAlign' => 'left',
'fFunction' => '',
'fLink' => 'http://maps.google.co.uk/',
'lTarget' => '_blank'
),
array( 'cTitle' => "Soundex",
'cField' => 'rescueCentreName',
'cWidth' => '5%',
'cSort' => 0,
'cAlign' => 'center',
'fFunction' => 'soundex',
'fLink' => '',
'lTarget' => ''
),
array( 'cTitle' => "Padded Town",
'cField' => 'town',
'cWidth' => '20%',
'cSort' => 0,
'cAlign' => 'right',
'fFunction' => array('str_pad' => array('town','20','_','STR_PAD_LEFT')),
'fLink' => '',
'lTarget' => ''
)
)
);
Method: setActions($action_array)
Set the actions variable $this->actions and $this->actionColumn to
TRUE so that an action column is displayed.
The array that is passed is an array of arrays consisting of the following:
| 'aTitle' | => | title for action button | |
| 'aImage' | => | image to use for action button | |
| 'iWidth' | => | image width, in px | |
| 'iHeight' | => | image height, in px | |
| 'aAction' | => | action to perform on this row | |
| 'aFunction' | => | additional function to perform before taking action | |
| 'aCriteria' | => | display this action if criteria met | |
| 'aTarget' | => | target window action, eg "_blank" for new window |
Dependants: $this->actions, $this->actionColumn
Returns: none
Called By: none
Example $mypd = new myPageDisplay; $mypd->setActions(array(
array( 'aTitle' => 'Edit record',
'aImage' => '/images/mypagedisplay_buttons/b_edit.png',
'iWidth' => '16',
'iHeight' => '16',
'aAction' => array($_SERVER['PHP_SELF'],'cmd=1','id=id'),
'aFunction' => '',
'aCriteria' => '',
'aTarget' => '_blank'
),
array( 'aTitle' => 'Delete record',
'aImage' => '/images/mypagedisplay_buttons/b_delete.png',
'iWidth' => '16',
'iHeight' => '16',
'aAction' => array($_SERVER['PHP_SELF'],'cmd=2','id=id'),
'aFunction' => 'return confirm(\'Are you sure you want to remove this item?\')',
'aCriteria' => '',
'aTarget' => ''
),
array( 'aTitle' => 'Unlock record',
'aImage' => '/images/mypagedisplay_buttons/small_key.gif',
'iWidth' => '16',
'iHeight' => '16',
'aAction' => array($_SERVER['PHP_SELF'],'cmd=3','id=id'),
'aFunction' => '',
'aCriteria' => array(''=>array('locked', '==', 'yes')),
'aTarget' => ''
)
)
);
Method: showColumnHeaders()
Builds the row that contains the column headers.Dependants: $this->columnHeaders, $this->get_scol_var, $this->checkboxColumn, $this->checkbox, $this->get_sord_var, $this->actionColumn, $this->actions
Returns: $str
Calls: reverseOrder(), rebuild_query_string()
Called By: createListTable()
Method: createListTable()
Generates the columnar report in a table formatDependants: $this->num_rows, this->columnHeaders, $this->result, $this->checkboxColumn, $this->checkbox, $this->actionColumn, $this->actions
Calls: showColumnHeaders(), getHrefArgs(), getFuncArgs(), passedActionCheck(), displayOrder()
Returns: $this->all_rows
Called By: get_number_of_pages(), page_info()
Example
$mypd = new myPageDisplay;
$sortCol = $mypd->set_this_sortCol('rescueCentreName'); // Set the sort column. If not passed use the default passed
$sortOrder = $mypd->set_this_sortOrder('asc'); // Set the sort oreder. If not passed use the default passed
$mypd->sql = getSql($sortCol, $sortOrder);
$result = $mypd->get_page_result(); // result set
$num_rows = $mypd->get_page_num_rows(); // number of records in result set
$css_nav_links = $mypd->css_prev_next_link(); // the navigation with only the back and forward links
$tmpString = $mypd->createListTable(); // Generate the result table
echo '<div class="pagerBar"><span style="float: left">'.$nav_info.' of '.$mypd->all_rows.' Records</span><span style="float: right;">'.$css_page_links.'</span></div>';
echo '<p>'.$tmpString.'</p>';
$mypd->free_db_result();
Method: passedActionCheck($args, $i)
See if conditional statements sent by the action array are metPassed: $i is the current row number and $args is action criteria specified in the setActions array
Dependants: none
Returns: true or false
Calls: checkCondition(), checkLogic()
Called By: createListTable()
Method: checkLogic($logic, $check)
Check status of dynamic conditional statment.Passed: $l is either an 'and' or an 'or'. $check determines the value that is returned
Dependants: none
Returns: value (-1, 0, 1)
Calls: none
Called By: passedActionCheck()
Method: checkCondition($larg, $condition, $rarg)
Passes or fails the condition statements prepared by the passed variables. That is to say if the left argument passes the condition with the right argument.Passed: $larg = left argument, $condition = the conditional statement and $rarg = right argument
Dependants: none
Returns: $pass (0 or 1)
Calls: none
Called By: passedActionCheck()
Method: getHrefArgs($args, $i)
Generates additional query string for a link, taken from the passed arrayPassed: $i is the current row number and $args is the href string/array passed by 'fLink' in the setColumnHeaders array
Dependants: none
Returns: $str
Calls: get_field_names(), buildHrefArgs()
Called By: createListTable()
Method: buildHrefArgs($args, $i)
Builds the arguments to be used in the element.Passed: $i is the current row number and $args is the array element passed by 'fLink' in the setColumnHeaders array
Dependants: $this->field_names, $this->result
Returns: $str or false if failed
Calls: none()
Called By: getHrefArgs()
Method: getFuncArgs($args, $i)
Generates additional query string for a function, taken from the passed arrayPassed: $i is the current row number and $args is action criteria specified in the setActions array
Dependants: $this->field_names, $this->result
Returns: $str which is the result from the function specified in $args
Calls: get_field_names()
Called By: createListTable()
Method: getOnClickArgs($args, $i)
Generates additional query string for the onClick setActions, taken from the passed arrayPassed: $i is the current row number and $args is action criteria specified in the setActions['aFunction'] array
Dependants: $this->field_names, $this->result
Returns: $str which is the result from the function specified in $args
Calls: get_field_names()
Called By: createListTable()
Example
<?php
$mypd = new myPageDisplay;
$mypd->setActions(array(
array( 'aTitle' => 'View enquiry',
'aImage' => $rootDir.'images/icons/read_message.gif',
'iWidth' => '16',
'iHeight' => '16',
'aAction' => '',
'aFunction' => array('viewMessage'=>array('id')),
'aCriteria' => '',
'aTarget' => ''
)
)
);
..... rest of mypagedisplay code here .....
?>
<script language="javascript" type="text/javascript">
//<![CDATA[
<!--
function viewMessage(id) {
// open a blank window
var aWindow = window.open("message_view.php?id="+id, "_blank","scrollbars=yes,menubar=yes,resizable=yes,toolbar=no,width=700,height=400");
aWindow.document.close();
}
//-->
//]]>
</script>
Method: getFieldVal($val, $i)
Returns the value of the field name passed as $valPassed: $i is the current row number and $val holds the passed fieldname
Dependants: $this->field_names, $this->result
Returns: $val which is the result of the sql query if fieldname passed
Calls: get_field_names()
Called By: createListTable()
Examples
<?php
include("classes/mypagedisplay_class.php"); // include mypagedisplay class
$mypd = new myPageDisplay;
$sortCol = $mypd->set_this_sortCol('rescueCentreName'); // Set the sort column. If not passed use the default passed
$sortOrder = $mypd->set_this_sortOrder('asc'); // Set the sort oreder. If not passed use the default passed
// Set the array of column headers to use
// Consists of array of arrays, eg.
// array( 'cTitle' => column name,
// 'cField' => db field name,
// 'cWidth' => column width (%, px, etc),
// 'cSort' => sort column? 1 = true, 0 = false,
// 'cAlign' => alignment (left, center, right),
// 'fFunction' => function to perform on db field, eg. function or array of functions
// 'fLink' => link action for db field :- eg. Direct link or array('link',arg0,arg1,.....,argn)
// 'lTarget' => target for link action, eg "_blank" for new window
// )
$mypd->setColumnHeaders(array (
array( 'cTitle' => "ID",
'cField' => 'id',
'cWidth' => '5%',
'cSort' => 0,
'cAlign' => 'center',
'fFunction' => '',
'fLink' => '',
'lTarget' => ''
),
array( 'cTitle' => "Rescue Centre",
'cField' => 'rescueCentreName',
'cWidth' => '30%',
'cSort' => 1,
'cAlign' => 'left',
'fFunction' => '',
'fLink' => array('link' => $_SERVER['PHP_SELF'],
'transargs' => 'r=id',
'notransargs' => array('cmd=0', $myArgs)
),
'lTarget' => ''
),
array( 'cTitle' => "Town",
'cField' => 'town',
'cWidth' => '15%',
'cSort' => 1,
'cAlign' => 'left',
'fFunction' => '',
'fLink' => '',
'lTarget' => ''
),
array( 'cTitle' => "County",
'cField' => 'county',
'cWidth' => '16%',
'cSort' => 1,
'cAlign' => 'left',
'fFunction' => '',
'fLink' => 'http://maps.google.co.uk/',
'fLink' => array('link' => 'http://maps.google.co.uk/',
'transargs' => '',
'notransargs' => ''
),
'lTarget' => '_blank'
),
array( 'cTitle' => "Soundex",
'cField' => 'rescueCentreName',
'cWidth' => '6%',
'cSort' => 0,
'cAlign' => 'center',
'fFunction' => 'soundex',
'fLink' => '',
'lTarget' => ''
),
array( 'cTitle' => "Padded Town",
'cField' => 'town',
'cWidth' => '15%',
'cSort' => 0,
'cAlign' => 'right',
'fFunction' => array('str_pad' => array('town','20','_','STR_PAD_LEFT')),
'fLink' => '',
'lTarget' => ''
)
)
);
// Set the array of actions to use in the action column
// Do not set if no actions are required.
// Consists of array of arrays, eg.
// array( 'aTitle' => title for action button,
// 'aImage' => image to use for action button,
// 'iWidth' => image width, in px,
// 'iHeight' => image height, in px,
// 'aAction' => action to perform on this row,
// 'aFunction' => additional function to perform before taking action,
// 'aCriteria' => display this action if criteria met,
// 'aTarget' => target window action, eg "_blank" for new window
// )
$mypd->setActions(array(
array( 'aTitle' => 'Edit record',
'aImage' => '/images/mypagedisplay_buttons/b_edit.png',
'iWidth' => '16',
'iHeight' => '16',
'aAction' => array('link' => $_SERVER['PHP_SELF'],
'transargs' => 'id=id',
'notransargs' => array('cmd=1', $myArgs)
),
'aFunction' => '',
'aCriteria' => '',
'aTarget' => '_blank'
),
array( 'aTitle' => 'Delete record',
'aImage' => '/images/mypagedisplay_buttons/b_delete.png',
'iWidth' => '16',
'iHeight' => '16',
'aAction' => array('link' => $_SERVER['PHP_SELF'],
'transargs' => 'id=id',
'notransargs' => array('cmd=2', $myArgs)
),
'aFunction' => 'return confirm(\'Are you sure you want to remove this item?\')',
'aCriteria' => '',
'aTarget' => ''
),
array( 'aTitle' => 'Unlock record',
'aImage' => '/images/mypagedisplay_buttons/small_key.gif',
'iWidth' => '16',
'iHeight' => '16',
'aAction' => array('link' => $_SERVER['PHP_SELF'],
'transargs' => 'id=id',
'notransargs' => array('cmd=3', $myArgs)
),
'aFunction' => '',
'aCriteria' => array(''=>array('locked', '==', 'yes')),
'aTarget' => ''
)
)
);
// SQL statement
$mypd->sql = getSql($sortCol, $sortOrder);
$result = $mypd->get_page_result(); // result set
$num_rows = $mypd->get_page_num_rows(); // number of records in result set
$css_page_links = $mypd->navigation_links(" ", true, true); // the navigation links (define a CSS class selector for the current link)
$simple_page_links= $mypd->navigation_links(" | ", false, false); // basic the navigation links
$nav_info = $mypd->page_info("to"); // information about the number of records on page ("to" is the text between the number)
$simple_nav_links = $mypd->simple_prev_next_link(); // the navigation with only the back and forward links
$css_nav_links = $mypd->css_prev_next_link(); // the navigation with only the back and forward links
$total_recs = $mypd->get_total_rows(); // the total number of records
$tmpString = $mypd->createListTable(); // Generate the result table
echo "<p><b>Style Sheet Navigation page links:</b></p>";
echo '<div class="pagerBar"><span style="float: left">'.$nav_info.' of '.$mypd->all_rows.' Records</span><span style="float: right">'.$css_page_links.'</span></div>';
echo $tmpString;
$mypd->free_db_result();
// *****************************************************************
function getSql($sortCol, $sortOrder){
global $db;
$sql = "SELECT id,
rescueCentreName,
town,
county,
locked
FROM myPageDisplay
ORDER BY ";
// Generate sort statement to use for list by means of using the case statement
switch ($sortCol) {
case 'rescueCentreName':
if($sortOrder == "asc" && $sortCol == "rescueCentreName") {
$sql .= "rescueCentreName";
} else {
$sql .= "rescueCentreName DESC";
}
break;
case 'town':
if($sortOrder == "asc" && $sortCol == "town") {
$sql .= "town";
} else {
$sql .= "town DESC";
}
break;
case 'county':
if($sortOrder == "asc" && $sortCol == "county") {
$sql .= "county";
} else {
$sql .= "county DESC";
}
break;
default :
$sql .= "rescueCentreName";
break;
}
return $sql;
} # function getSql($sortCol, $sortOrder)
?>
Change Log
31-07-2007 Peter C Barkway (version 1.1h)
1. Added new function getOnClickArgs() to allow for javascript & php functions to be called by an action button
2. Modified function createListTable() to account for above
3. Changed class name from listLinkAction to mpdListLinkAction
15-05-2007 Peter C Barkway (version 1.1g)
1. Added new function setCheckBox() to allow for multiple selection of lines for a mass change.
2. Added new function getFieldVal() used by the checkbox column facility
3. Modified function showColumnHeaders() to account for above
4. Modified function createListTable() to account for above
08-02-2007 Peter C Barkway (version 1.1f)
1. Changed the class for odd and even rows to be prefixed with mpd to make it easier to identify in stylesheet
2. Added javascript functions to allow for a hover effect on each row. Therefore new stylesheet element of
mpdEvenHover & .mpdOddHover can be used.
3. Added new class to the first column called mpdFirstCol. This allows you to use a seperate colour for the
first column in the table. Combine this with the rollover and you can achieve a spreasheet like effect.
4. Removed the <b></b> from around the sortInactiveButton column header. Update to style.css required to reflect this.
5. Updated style.css, example.php and help to reflect all changes.
28-01-2007 Peter C Barkway (version 1.1f beta)
1. setActions now requires a new format for the elements. This creates greater readability for the arguments.
$mypd->setActions(array(
array( 'aTitle' => 'Edit record',
'aImage' => '/images/mypagedisplay_buttons/b_edit.png',
'iWidth' => '16',
'iHeight' => '16',
'aAction' => array('link' => $_SERVER['PHP_SELF'],
'transargs' => 'id=id',
'notransargs' => array('cmd=1', $myArgs)
),
'aFunction' => '',
'aCriteria' => '',
'aTarget' => '_blank'
2. New function buildHrefArgs() to allow for an array of arguments for the href query string to be passed.
This is useful if you want to pass the arguments from $_SERVER['QUERY_STRING']. Also, the fLink element
now requires an array passed, as per example below.
$myArgs = explode("&", $_SERVER['QUERY_STRING']);
$mypd->setColumnHeaders(array (
array( 'cTitle' => "Host Server",
'cField' => 'hostname',
'cWidth' => '30%',
'cSort' => 1,
'cAlign' => 'left',
'fFunction' => '',
'fLink' => array('link' => 'view_host_details.php',
'transargs' => 'hid=id',
'notransargs' => array('hb=1', $myArgs)
),
'lTarget' => ''
)
)
);
3. Extra error checking on lines 640 to make sure invalid query string arguments are caught
16-12-2006 Peter C Barkway (version 1.1f beta)
1. If align or width left blank then these items will now be omitted from the line
2. New variable ($this->get_pagn_var) so that calling script can check the current status
of the pagination. It was decided to let the class handle this, as with the current
page number, rather than the calling script.
3. New variable ($this->get_rown_var) so that calling script can check the requested number
of rows on a page. Done for the same reason as 2.
4. example.php updated to reflect above changes.
Thanks goes to Alan for highlighting the above.
12-12-2006 Peter C Barkway (version 1.1e)
1. Added additional variable to allow for non-pagination of reports. Ideal for printing.
$this->paginate set by default to TRUE. Set to FALSE to turn pagination off.
2. Modified array input that is used for column headers and actions. This is to make the
whole thing, arrays & code, more readable/understandable. If you are updating from an
earlier version then you will have to update your input arrays (sorry!)
3. Updated example file to reflect better the uses of the application and the above changes.
4. Set the method get_total_rows() to be called by the method get_page_result() and use the
variable $this->all_rows in all other methods. This cuts the number of times it is called
to just a single time. Should speed up execution.
5. New help file (help.html) to give more detail of methods, etc.
02-11-2006 Peter C Barkway (version 1.1d)
1. Additional array element for actions to allow the specification of the target window
Example:-
$mypd->setActions(array( 'Edit record' => array('./images/mypagedisplay_buttons/b_edit.png','16','16',array($_SERVER['PHP_SELF'],'cmd=1','id=id'),'','','_blank'),
'Delete Record' => array('./images/mypagedisplay_buttons/b_delete.png','16','16',array($_SERVER['PHP_SELF'],'cmd=2','id=id'),'return confirm(\'Are you sure you want to remove this item?\')','',''),
'Unlock user' => array('./images/mypagedisplay_buttons/small_key.gif','16','16',array($_SERVER['PHP_SELF'],'cmd=2','id=id'),'',array(''=>array('locked', '==', 'yes')),'')
)
);
2. Fixed action icons title so it works with Mozilla
3. Updated example stylesheet to work with Mozilla properly
4. Updated example.php to work with Mozilla properly
5. Fixed previous and first icon errors - now display correct icons if css is used
6. Modified stylesheet to work with FF
11-10-2006 Peter C Barkway (version 1.1c)
1. Addition of action array functionality. This allows the programmer to generate an array that identifies actions that can
be performed on each row, for example, Delete or Edit a record. The array takes the following format
// array ( "Action Title" => array(path to action icon, //value[0]
// width of icon, //value[1]
// height of icon, //value[2]
// Action Link array (path to link file,arg1, arg2...argn) || function //value[3]
// onclick command, //value[4]
// Conditonal statement array ('logic'=>array(left arg, condition, right arg)) //value[5]
// )
Example:-
$mypd->setActions(array( 'Edit record' => array('./images/mypagedisplay_buttons/b_edit.png','16','16',array($_SERVER['PHP_SELF'],'cmd=1','id=id'),'',''),
'Delete Record' => array('./images/mypagedisplay_buttons/b_delete.png','16','16',array($_SERVER['PHP_SELF'],'cmd=2','id=id'),'return confirm(\'Are you sure you want to remove this item?\')',''),
'Unlock user' => array('./images/mypagedisplay_buttons/small_key.gif','16','16',array($_SERVER['PHP_SELF'],'cmd=2','id=id'),'',array(''=>array('locked', '==', 'yes')) )
)
);
The conditional array (value[5]) is there to perform a check to see if you want this action to take place or not. It allows for
a certain amount of logic, ie AND & OR. The 1st logic statement should be left blank as it is always ignored but all others
should be completed. The array that follows is for the left conditional argument (usually the column name), the conditional match
and the right conditional argument (a value). An example would be:-
array('' => array('locked', '==', 'yes')),
'and'=> array('live', '==', 'no')
)
2. Modified the columnHeaders array to add extra element to specify the target of the href link, eg '_blank' will load new page.
3. Modified sample style.css file to add listLinkAction style
4. Update sql get statement in the example file to reflect above changes.
5. Modified test.sql file to enable the above changes to be tested
09-10-2006 Peter C Barkway (version 1.1b)
Additional finctions to allow for a function to be passed that gets performed on each item. This can consist of a single
function, such as strtoupper() or a more complex user defined functions, eg. imageDisplay('foo.jpg',640,480)
To initiate a complex function the arguments must be passed as an array of arrays with the array ket being the function
name and the array list are the arguments, which can consist of a mix of static and dynamic data. The dynamic data is
represented by the field name required and is looked up during the function creation.
The example file has been updated to reflect this new functionality.
The column headers will now look like:-
$mypd->setColumnHeaders(array ( "ID" => array('id' ,' 5%',0,'center','',''),
"Rescue Centre" => array('rescueCentreName','35%',1,'left','',array('./index.php','cmd=0','r=id')),
"Town" => array('town', '15%',1,'left','',''),
"County" => array('county', '20%',1,'left','','http://maps.google.co.uk/'),
"Soundex" => array('rescueCentreName',' 5%',0,'center','soundex',''),
"Padded Town" => array('rescueCentreName','20%',0,'right',array('str_pad'=>array('town','20','_','STR_PAD_LEFT')),'')
)
);
07-10-2006 Peter C Barkway (version 1.1a)
Didn't take long for a new version. I realised that I hadn't allowed for the ability to
generate href links within the column. To do this an extra array, or single link, is passed
with the ColumnHeaders array.
A new function, getHrefArgs(), has been incorporated in order to deal with this additional array.
It's role is to generate the request argument for the link. That is to say that static arguments
and dynamic arguments can be passed. For example cmd=1 & id=rescue_id would have a quick test performed
to see if the value part is a valid column within the current sql statement. If it is then the current
value for that column will be parsed through, otherwise the existing, static, value will be used.
For example if the following is passed:-
$mypd->setColumnHeaders(array ( "ID" => array('id' ,'10%',0,'center',''),
"Rescue Centre" => array('rescueCentreName','40%',1,'left',array('/example.php','cmd=0','r=id')),
"Town" => array('town', '25%',1,'left',''),
"County" => array('county', '25%',1,'left','http://maps.google.co.uk/')
)
);
The Rescue Centre & County columns will be recognised as having href links being required for each row.
In the case of the County colum it is a straight static link that is required and nothing will change on
this line as there are no arguments to parse. However, the Rescue Centre column is slightly more complex and
an array is passed as an argument. This is how the array is treated:-
1. val[0] is always considered to be the basis of the href link
2. val[1] is split on the '=' and the value checked to see if it is a valid column. It isn't and
it is therefore left as is and appended to val[0].
3. val[2] is split and the value checked. 'id' is a valid column so the actual value is substituted
before being appended to the above string.
The result should look something like:-
<a href="/example.php?cmd=0&r=12">05-10-2006 Peter C Barkway (version 1.0a)
* First release of myPageDisplay
myPageDisplay License (LGPL)
GNU LIBRARY GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the library GPL. It is
numbered 2 because it goes with version 2 of the ordinary GPL.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Library General Public License, applies to some
specially designated Free Software Foundation software, and to any
other libraries whose authors decide to use it. You can use it for
your libraries, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if
you distribute copies of the library, or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link a program with the library, you must provide
complete object files to the recipients so that they can relink them
with the library, after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
Our method of protecting your rights has two steps: (1) copyright
the library, and (2) offer you this license which gives you legal
permission to copy, distribute and/or modify the library.
Also, for each distributor's protection, we want to make certain
that everyone understands that there is no warranty for this free
library. If the library is modified by someone else and passed on, we
want its recipients to know that what they have is not the original
version, so that any problems introduced by others will not reflect on
the original authors' reputations.
.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that companies distributing free
software will individually obtain patent licenses, thus in effect
transforming the program into proprietary software. To prevent this,
we have made it clear that any patent must be licensed for everyone's
free use or not licensed at all.
Most GNU software, including some libraries, is covered by the ordinary
GNU General Public License, which was designed for utility programs. This
license, the GNU Library General Public License, applies to certain
designated libraries. This license is quite different from the ordinary
one; be sure to read it in full, and don't assume that anything in it is
the same as in the ordinary license.
The reason we have a separate public license for some libraries is that
they blur the distinction we usually make between modifying or adding to a
program and simply using it. Linking a program with a library, without
changing the library, is in some sense simply using the library, and is
analogous to running a utility program or application program. However, in
a textual and legal sense, the linked executable is a combined work, a
derivative of the original library, and the ordinary General Public License
treats it as such.
Because of this blurred distinction, using the ordinary General
Public License for libraries did not effectively promote software
sharing, because most developers did not use the libraries. We
concluded that weaker conditions might promote sharing better.
However, unrestricted linking of non-free programs would deprive the
users of those programs of all benefit from the free status of the
libraries themselves. This Library General Public License is intended to
permit developers of non-free programs to use free libraries, while
preserving your freedom as a user of such programs to change the free
libraries that are incorporated in them. (We have not seen how to achieve
this as regards changes in header files, but we have achieved it as regards
changes in the actual functions of the Library.) The hope is that this
will lead to faster development of free libraries.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, while the latter only
works together with the library.
Note that it is possible for a library to be covered by the ordinary
General Public License rather than by this special one.
.
GNU LIBRARY GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library which
contains a notice placed by the copyright holder or other authorized
party saying it may be distributed under the terms of this Library
General Public License (also called "this License"). Each licensee is
addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
.
6. As an exception to the Sections above, you may also compile or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
c) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
d) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the source code distributed need not include anything that is normally
distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Library General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS