1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
<?php
/**
* Data Object List Base Class
*
* "data objects by fplanque" :P
*
* b2evolution - {@link http://b2evolution.net/}
* Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
* @copyright (c)2003-2005 by Francois PLANQUE - {@link http://fplanque.net/}
*
* @package evocore
*/
if( !defined('DB_USER') ) die( 'Please, do not access this page directly.' );
/**
* Data Object List Base Class
*
* This is typically an abstract class, useful only when derived.
*
* @package evocore
* @version beta
* @abstract
*/
class DataObjectList
{
/**#@+
* @access private
*/
var $dbtablename;
var $dbprefix;
var $dbIDname;
var $posts_per_page = 15;
/**
* SQL query string
*/
var $request;
/**
* DB Result set (array)
*/
var $result;
/**
* Number of rows in result set. Typically equal to $posts_per_page, once loaded.
*/
var $result_num_rows = 0;
/**
* Object array
*/
var $Obj = array();
/**
* Current object idx in array:
*/
var $current_idx = 0;
/**#@-*/
/**
* Constructor
*
* {@internal DataObjectList::DataObjectList(-) }}
*
* @param string Name of table in database
* @param string Prefix of fields in the table
* @param string Name of the ID field (including prefix)
*/
function DataObjectList( $tablename, $prefix = '', $dbIDname = 'ID' )
{
$this->dbtablename = $tablename;
$this->dbprefix = $prefix;
$this->dbIDname = $dbIDname;
}
/**
* Get nummber of rows available for display
*
* {@internal DataObjectList::get_num_rows(-) }}
*
* @return integer
*/
function get_num_rows()
{
return $this->result_num_rows;
}
/**
* Get next comment in list
*
* {@internal CommentList::get_next(-) }}
*/
function get_next()
{
if( $this->current_idx >= $this->result_num_rows )
{ // No more comment in list
return false;
}
return $this->Obj[$this->current_idx++];
}
/**
* Rewind resultset
*
* {@internal DataObjectList::restart(-) }}
*/
function restart()
{
$this->current_idx = 0;
}
/**
* Template function: display message if list is empty
*
* {@internal DataObjectList::display_if_empty(-) }}
*
* @param string String to display if list is empty
* @return true if empty
*/
function display_if_empty( $message = '' )
{
if( empty($message) )
{ // Default message:
$message = T_('Sorry, there is nothing to display...');
}
if( $this->result_num_rows == 0 )
{
echo $message;
return true;
}
return false;
}
}
?>
|