Source for file LibertyBase.php
Documentation is available at LibertyBase.php
* Base class for Management of Liberty Content
* @author spider <spider@steelsun.com>
// +----------------------------------------------------------------------+
// | Copyright (c) 2004, bitweaver.org
// +----------------------------------------------------------------------+
// | All Rights Reserved. See below for details and a complete list of authors.
// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details
// | For comments, please use phpdocu.sourceforge.net documentation standards!!!
// | -> see http://phpdocu.sourceforge.net/
// +----------------------------------------------------------------------+
// | Authors: spider <spider@steelsun.com>
// +----------------------------------------------------------------------+
require_once( LIBERTY_PKG_PATH. 'liberty_lib.php' );
require_once( KERNEL_PKG_PATH. 'BitBase.php' );
* Virtual base class (as much as one can have such things in PHP) for all
* derived bitweaver classes that manage content.
* Constructor building on BitBase object
* Object need to init the database connection early
* Database will be linked via a previously activated BitDb object
* which will provide the mDb pointer to that database
* given a content_type_guid this will return an object of the proper type
* @param the content type to be loaded
// We can abuse getLibertyObject to do the work
// Make sure we don't have a content_id set though.
* Given a content_id, this will return and object of the proper type
* @param integer content_id of the object to be returned
* @param string optional content_type_guid of pConId. This will save a select if you happen to have this info. If not, this method will look it up for you.
* @param call load on the content. Defaults to true.
* @returns object of the appropriate content type class
public static function getLibertyObject( $pContentId, $pContentGuid= NULL, $pLoadContent = TRUE ) {
global $gLibertySystem, $gBitUser, $gBitSystem;
if( BitBase::verifyId( $pContentId ) ) {
// remove non integer bits from structure_id and content_id requests
// can happen with period's at the end of url's that are email'ed around
if( empty( $pContentGuid ) ) {
$pContentGuid = $gLibertySystem->mDb->getOne( "SELECT `content_type_guid` FROM `". BIT_DB_PREFIX. "liberty_content` WHERE `content_id`=?", array( $pContentId ) );
if( !empty( $pContentGuid ) && isset ( $gLibertySystem->mContentTypes[$pContentGuid] ) && $typeClass = $gLibertySystem->getContentClassName( $pContentGuid ) ) {
$creator = new $typeClass();
$ret = $creator->getNewObject( $typeClass, $pContentId, $pLoadContent );
* Simple method to create a given class with a specified primary_id. The purpose of a method is to allow for derived classes to override as necessary.
* @param string class to be created
* @param integer id from the secondary table of the object to be returned
* @param call load on the content. Defaults to true.
* @returns object of the appropriate content type class
$ret = new $pClass( $pPrimaryId );
if( $ret && $pLoadContent ) {
* Simple method to create a given class with a specified content_id. The purpose of a method is to allow for derived classes to override as necessary.
* @param string class to be created
* @param integer content_id of the object to be returned
* @param call load on the content. Defaults to true.
* @returns object of the appropriate content type class
public function getNewObject( $pClass, $pContentId, $pLoadContent= TRUE ) {
$ret = new $pClass( NULL, $pContentId );
if( $ret && $pLoadContent ) {
|