liberty
[ class tree: liberty ] [ index: liberty ] [ all elements ]

Source for file LibertyBase.php

Documentation is available at LibertyBase.php

  1. <?php
  2. /**
  3.  * Base class for Management of Liberty Content
  4.  *
  5.  * @package  liberty
  6.  * @version  $Header$
  7.  * @author   spider <spider@steelsun.com>
  8.  */
  9. // +----------------------------------------------------------------------+
  10. // | Copyright (c) 2004, bitweaver.org
  11. // +----------------------------------------------------------------------+
  12. // | All Rights Reserved. See below for details and a complete list of authors.
  13. // | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details
  14. // |
  15. // | For comments, please use phpdocu.sourceforge.net documentation standards!!!
  16. // | -> see http://phpdocu.sourceforge.net/
  17. // +----------------------------------------------------------------------+
  18. // | Authors: spider <spider@steelsun.com>
  19. // +----------------------------------------------------------------------+
  20.  
  21. /**
  22.  * required setup
  23.  */
  24. require_onceLIBERTY_PKG_PATH.'liberty_lib.php' );
  25. require_onceKERNEL_PKG_PATH.'BitBase.php' );
  26.  
  27. /**
  28.  * Virtual base class (as much as one can have such things in PHP) for all
  29.  * derived bitweaver classes that manage content.
  30.  *
  31.  * @package liberty
  32.  */
  33. class LibertyBase extends BitBase {
  34.  
  35.     /**
  36.      * Constructor building on BitBase object
  37.      *
  38.      * Object need to init the database connection early
  39.      * Database will be linked via a previously activated BitDb object
  40.      * which will provide the mDb pointer to that database
  41.      */
  42.     function __construct({
  43.         parent::__construct();
  44.     }
  45.  
  46.     /**
  47.      * given a content_type_guid this will return an object of the proper type
  48.      *
  49.      * @param the content type to be loaded
  50.      */
  51.     function getLibertyClass($pContentGuid{
  52.         // We can abuse getLibertyObject to do the work
  53.         $ret LibertyBase::getLibertyObject('1'$pContentGuidFALSE);
  54.         // Make sure we don't have a content_id set though.
  55.         unset($ret->mContentId);
  56.         return $ret;
  57.     }
  58.  
  59.     /**
  60.      * Given a content_id, this will return and object of the proper type
  61.      *
  62.      * @param integer content_id of the object to be returned
  63.      * @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.
  64.      * @param call load on the content. Defaults to true.
  65.      * @returns object of the appropriate content type class
  66.      */
  67.     public static function getLibertyObject$pContentId$pContentGuid=NULL$pLoadContent TRUE {
  68.         $ret NULL;
  69.         global $gLibertySystem$gBitUser$gBitSystem;
  70.  
  71.         ifBitBase::verifyId$pContentId ) ) {
  72.             // remove non integer bits from structure_id and content_id requests
  73.             // can happen with period's at the end of url's that are email'ed around
  74.             $pContentId preg_replace'/[\D]/'''$pContentId );
  75.             ifempty$pContentGuid ) ) {
  76.                 $pContentGuid $gLibertySystem->mDb->getOne"SELECT `content_type_guid` FROM `".BIT_DB_PREFIX."liberty_content` WHERE `content_id`=?"array$pContentId ) );
  77.             }
  78.             if!empty$pContentGuid && isset$gLibertySystem->mContentTypes[$pContentGuid&& $typeClass $gLibertySystem->getContentClassName$pContentGuid ) ) {
  79.                 $creator new $typeClass();
  80.                 $ret $creator->getNewObject$typeClass$pContentId$pLoadContent );
  81.             }
  82.         }
  83.         return $ret;
  84.     }
  85.  
  86.     /**
  87.      * 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.
  88.      *
  89.      * @param string class to be created
  90.      * @param integer id from the secondary table of the object to be returned
  91.      * @param call load on the content. Defaults to true.
  92.      * @returns object of the appropriate content type class
  93.      */
  94.     public function getNewObjectById$pClass$pPrimaryId$pLoadContent=TRUE {
  95.         $ret new $pClass$pPrimaryId );
  96.         if$ret && $pLoadContent {
  97.             $ret->load();
  98.         }
  99.         return $ret;
  100.     }
  101.  
  102.     /**
  103.      * 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.
  104.      *
  105.      * @param string class to be created
  106.      * @param integer content_id of the object to be returned
  107.      * @param call load on the content. Defaults to true.
  108.      * @returns object of the appropriate content type class
  109.      */
  110.     public function getNewObject$pClass$pContentId$pLoadContent=TRUE {
  111.         $ret new $pClassNULL$pContentId );
  112.         if$ret && $pLoadContent {
  113.             $ret->load();
  114.         }
  115.         return $ret;
  116.     }
  117. }
  118.  
  119. ?>

Documentation generated on Wed, 29 Jul 2015 13:56:47 +0000 by phpDocumentor 1.5.0-lsces