Source for file PNObjectArray.class.php
Documentation is available at PNObjectArray.class.php
* Zikula Application Framework
* @copyright Robert Gasch
* @link http://www.zikula.org
* @version $Id: PNObjectArray.class.php 24439 2008-07-03 22:43:52Z Guite $
* @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
* @author Robert Gasch rgasch@gmail.com
* @subpackage PNObjectArrayUtil
* @subpackage PNObjectArrayUtil
* Constructur, init everything to sane defaults and handle parameters
* @param init Initialization value (see _init() for details)
* @param where The where clause to apply to the DB get/select (optional) (default='')
$this->_objLimitOffset = - 1;
$this->_objLimitNumRows = - 1;
$this->_objAssocKey = '';
$this->_objDistinct = false;
$this->_init ($init, $where);
* Internal intialization routine
* @param init Initialization value (can be an object or a string directive) (optional) (default=null)
* @param where The where clause to use when retrieving the object array (optional) (default='')
* @param orderBy The order-by clause to use when retrieving the object array (optional) (default='')
* @param assocKey Key field to use for building an associative array (optional) (default=null)
* If $init is an arrary it is set(), otherwise it is interpreted as a string specifying
* the source from where the data should be retrieved from.
function _init ($init= null, $where= '', $orderBy= '', $assocKey= null)
$ckey = $tkey . "_column";
$this->_table = isset ($pntables[$tkey]) ? $pntables[$tkey] : '';
$this->_columns = isset ($pntables[$ckey]) ? $pntables[$ckey] : '';
$this->get($where, $orderBy, - 1, - 1, $assocKey, true);
return pn_exit ("Invalid init-directive [$init] found in PNObject::init() ...");
return pn_exit ("Unexpected parameter type init [$init] in PNObject::init() ...");
* Set (and return) the object data. Since we dont' have a definitive key, we don't cache
* @param data The data to assign
* Return the record count for the given object set
* @param where The where-clause to use
* @param doJoin whether or not to use the auto-join for the count
* @return The object's data set count
function getCount ($where= '', $doJoin= false)
* Generate a filter for the array view. Default implementation which can be overridden by subclasses.
* @param filter An array containing the set filter values (optional) (default=array())
* @return The generated filter (where-clause) string
* Return/Select the object using the given where clause.
* @param where The where-clause to use
* @param sort The order-by clause to use
* @param limitOffset The limiting offset
* @param limitNumRows The limiting number of rows
* @param assocKey Key field to use for building an associative array (optional) (default=null)
* @param force whether or not to force a DB-get (optional) (default=false)
* @param distinct whether or not to do a select distinct (optional) (default=false)
* @return The object's data value
function getWhere ($where= '', $sort= '', $limitOffset=- 1, $limitNumRows=- 1, $assocKey= null, $force= false, $distinct= false)
if ((($where != $this->_objWhere || $sort != $this->_objSort ||
$limitOffset != $this->_objLimitOffset || $limitNumRows != $this->_objLimitNumRows ||
$assocKey != $this->_objAssocKey || $distinct != $this->_objDistinct) || !$objData) || $force) {
$this->select($where, $sort, $limitOffset, $limitNumRows, $assocKey, $distinct);
* Return the current object data. Maps to $this->getWhere().
* @param where The where-clause to use
* @param sort The order-by clause to use
* @param limitOffset The limiting offset
* @param limitNumRows The limiting number of rows
* @param assocKey Key field to use for building an associative array (optional) (default=null)
* @param force whether or not to force a DB-get (optional) (default=false)
* @param distinct whether or not to do a select distinct (optional) (default=false)
* @return The object's data value
function get ($where= '', $sort= '', $limitOffset=- 1, $limitNumRows=- 1, $assocKey= null, $force= false, $distinct= false)
return $this->getWhere ($where, $sort, $limitOffset, $limitNumRows, $assocKey, $force, $distinct);
* Return the currently set object data
* @return The object's data array
* Generic select handler for an object. Select (and set) the specified object array
* @param where The where-clause to use
* @param orderBy The order-by clause to use
* @param limitOffset The limiting offset
* @param limitNumRows The limiting number of rows
* @param assocKey Key field to use for building an associative array (optional) (default=null)
* @param distinct whether or not to use the distinct clause
* @return The selected Object-Array
function select ($where= '', $orderBy= '', $limitOffset=- 1, $limitNumRows=- 1, $assocKey= false, $distinct= false)
$this->_objWhere = $where;
$this->_objSort = $orderBy;
$this->_objLimitOffset = $limitOffset;
$this->_objLimitNumRows = $limitNumRows;
$this->_objAssocKey = $assocKey;
$this->_objDistinct = $distinct;
* Iterate over the object data and post-process it
* @return The Object Data
* Generic function to retrieve
* @return The Object Data
* Save an object - if it has an ID update it, otherwise insert it
* Generic insert handler for an object (ID is inserted into the object data)
* @return The Object Data
* Generic upate handler for an object
* @return The Object Data
* Generic delete handler for an object
* @return The Object Data
* Delete with a where-clause
* @param where The where-clause to use
* @return The Object Data
* Clean the acquired input
* @param objArray The object-array to clean (optional) (default=null, reverts to $this->_objData)
* @return The Object Data
function clean ($objArray= null)
* Get a selector for the object array
* @param name The name of the selector to generate
* @param selected The currently selected value (optional) (default=-1234)
* @param defaultValue The default value (optional) (default=0)
* @param defaultText The default text (optional) (default='')
* @param allValue The all-selected value (optional) (default=0)
* @param allText The all-selected text (optional) (default='')
* @param idField The id field to use (optional) (default='id')
* @param nameField The name field to use (optional) (default='title')
* @param submit whether or not to submit the form upon selection (optional) (default=false)
* @param ignoreList The list of entries to ignore (default=null)
* @return The generated selector html text
function getSelector ($name, $selected=- 1234, $defaultValue= 0, $defaultText= '',
$allValue= 0, $allText= '', $idField= 'id', $nameField= 'title',
$submit= false, $ignoreList= null)
$html = '<select name="'. $name. '"'
. ($submit ? ' onChange="this.form.submit();"' : '')
$html .= "<option value=\"$defaultValue\">$defaultText</option>";
$html .= "<option value=\"$allValue\">$allText</option>";
if (strpos($ignoreList, '$val') === false) {
$sel = ($val== $selected ? "selected" : "");
$html .= "<option value=\"$val\" $sel>$disp</option>";
* Constructur, init everything to sane defaults and handle parameters
* @return Boolean indicating whether or not validation passed successfully
* Get the hashcode for this object data array
function getHash ($includeStandardFields= true, $objArray= null)
foreach ($objArray as $obj) {
if (!$includeStandardFields) {
|