Source for file _dataobjectlist2.class.php
Documentation is available at _dataobjectlist2.class.php
* This file implements the abstract DataObjectList2 base class.
* This file is part of Quam Plures - {@link http://quamplures.net/}
* See also {@link https://launchpad.net/quam-plures}.
* @copyright (c) 2009 - 2011 by the Quam Plures developers - {@link http://quamplures.net/}
* @copyright (c)2003-2009 by Francois PLANQUE - {@link http://fplanque.net/}
* {@internal License choice
* - If you have received this file as part of a package, please find the license.txt file in
* the same folder or the closest folder above for complete license terms.
* - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
* then you must choose one of the following licenses before using the file:
* - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
* - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
* {@internal Open Source relicensing agreement:
* {@internal Below is a list of authors who have contributed to design/coding of this file: }}
* @author fplanque: Francois PLANQUE
if( !defined('QP_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
load_class('_core/ui/results/_results.class.php');
* FilteredResults > Results
* Default filter set (used if no specific params are passed)
* Current filter set (depending on user input)
* Check if the Result set is filtered or not
* Get a specific active filter
* Get every active filter that is not the same as the defaults
if( !isset ( $this->filters[$key] ) )
{ // Some value has not been copied over from defaults to active or specifically set:
if( !is_null($value)) // Note: NULL value are not copied over. that's normal.
{ // A NON NULL value is missing
elseif( $value != $this->filters[$key] )
* Show every active filter that is not the same as the defaults
if( !isset ( $this->filters[$key] ) )
{ // SOme value has not been copied over from defaults to active or specifically set:
if( !is_null($value)) // Note: NULL value ar enot copied over. that's normal.
{ // A NON NULL value is missing
pre_dump( 'no active value for default '. $key );
elseif( $value != $this->filters[$key] )
* Data Object List Base Class 2
* This is typically an abstract class, useful only when derived.
* Holds DataObjects in an array and allows walking through...
* This SECOND implementation will deprecate the first one when finished.
* If provided, executes SQL query via parent Results object
* @param integer number of lines displayed on one screen (null for default [20])
* @param string prefix to differentiate page/order params when multiple Results appear one same page
* @param string default ordering of columns (special syntax)
function DataObjectList2( & $Cache, $limit = null, $param_prefix = '', $default_order = NULL )
// WARNING: we are not passing any SQL query to the Results object
// This will make the Results object behave a little bit differently than usual:
parent::Results( NULL, $param_prefix, $default_order, $limit, NULL, false );
// The list objects will also be cached in this cache.
// Tje Cache object may also be useful to get table information for the Items.
$this->ID_col = $Cache->dbIDname;
* dummy docblock makes error-free autodocs
return $this->rows[ $idx ];
* Instantiate an object for requested row and cache it:
return $this->Cache->instantiate( $this->rows[$idx] );
* Get next object in list
{ // No more object in list
$r = false; // TODO: try with NULL
// We also keep a local ref in case we want to use it for display:
* Display a global title matching filter params
* @param string prefix to display if a title is generated
* @param string suffix to display if a title is generated
* @param string glue to use if multiple title elements are generated
* @param string comma separated list of titles inthe order we would like to display them
* @param string format to output, default 'htmlbody'
function get_filter_title( $prefix = ' ', $suffix = '', $glue = ' - ', $order = NULL, $format = 'htmlbody' )
$title_array = $this->get_filter_titles();
if( empty( $title_array ) )
// We have something to display:
$r = implode( $glue, $title_array );
* Move up the element order in database
* @param integer id element
if( ($obj = & $this->Cache->get_by_ID( $id )) === false )
$Messages->head = T_('Cannot edit entry!');
$Messages->add( T_('Requested entry does not exist any longer.'), 'error' );
// Get the ID of the inferior element which his order is the nearest
$rows = $DB->get_results( 'SELECT '. $this->Cache->dbIDname
. ' FROM '. $this->Cache->dbtablename
. ' WHERE '. $this->Cache->dbprefix. 'order < '. $order
. ' ORDER BY '. $this->Cache->dbprefix. 'order DESC
// instantiate the inferior element
$obj_inf = & $this->Cache->get_by_ID( $rows[0]->{$this->Cache->dbIDname} );
$obj->set( 'order', $obj_inf->order );
// Update inferior element order
$obj_inf->set( 'order', $order );
// EXPERIMENTAL FOR FADEOUT RESULT
$result_fadeout[$this->Cache->dbIDname][] = $id;
$result_fadeout[$this->Cache->dbIDname][] = $obj_inf->ID;
$Messages->add( T_('This element is already at the top.'), 'error' );
* Move down the element order in database
* @param integer id element
if( ($obj = & $this->Cache->get_by_ID( $id )) === false )
$Messages->head = T_('Cannot edit entry!');
$Messages->add( T_('Requested entry does not exist any longer.'), 'error' );
// Get the ID of the inferior element which his order is the nearest
$rows = $DB->get_results( 'SELECT '. $this->Cache->dbIDname
. ' FROM '. $this->Cache->dbtablename
. ' WHERE '. $this->Cache->dbprefix. 'order > '. $order
. ' ORDER BY '. $this->Cache->dbprefix. 'order ASC
// instantiate the inferior element
$obj_sup = & $this->Cache->get_by_ID( $rows[0]->{$this->Cache->dbIDname} );
$obj->set( 'order', $obj_sup->order );
// Update inferior element order
$obj_sup->set( 'order', $order );
// EXPERIMENTAL FOR FADEOUT RESULT
$result_fadeout[$this->Cache->dbIDname][] = $id;
$result_fadeout[$this->Cache->dbIDname][] = $obj_sup->ID;
$Messages->add( T_('This element is already at the bottom.'), 'error' );
|