Location: PHPKode > projects > Tv.2 CMS > tv2engine/tv2Client.class.php
<?php // Sorry for excess comments. Please read HTML docs for general overview.

/** 
 * Abstract class for classes using tv2Xdb
 *
 * @package tv2-engine
 * @author Emilis Dambauskas (hide@address.com)
 * @copyright 2002–2003 Emilis Dambauskas under {@link http://opensource.org/licenses/artistic-license.php Artistic license}
 * @version $Id: tv2Client.class.php,v 1.3 2003/07/27 16:01:29 lunaticlt Exp $
 * @class tv2Client
 */
class tv2Client
{
	
	/**
	 * {@link tv2Xdb} object
	 * @attribute private object $xdb
	 */
	var $xdb;
	
	/**
	 * {@link tv2FileHelper} object
	 * @attribute private object $fh
	 */
	var $fh;
	
	
	/**
	 * Loads {@link this::$xdb}
	 *
	 * @constructor tv2Client   
	 */  
	function tv2Client()
	{
		$this->loadXdb();
	}
	
	/**
	 * Sends an error to the {@link $errors} object and returns FALSE
	 *
	 * @method private error
	 * @return boolean always FALSE
	 * @param string $msg error message
	 * @use $errors
	 */
	function error($msg)
	{
		$GLOBALS['errors']->add(get_class($this).': '.$msg);
		return FALSE;
	}
	
	/**
	 * Loads {@link tv2Xdb} into global variable $xdb and links
	 * {@link this::$xdb} to it.
	 * ATTENTION: always copy the code from this method to
	 * {@link tv2Site::loadXdb()} when changed.
	 *
	 * @method private loadXdb   
	 * @use $xdb  
	 * @use ENGINE_DIR 
	 * @use $config 
	 */ 
	function loadXdb()
	{
		global $config;
		
		// load Tv2 Xdb if not loaded
		if (!@$GLOBALS['xdb'])
		{
			require_once(ENGINE_DIR.'tv2Xdb.class.php');
			$GLOBALS['xdb'] = &new tv2Xdb();
			$GLOBALS['xdb']->fat_table = $config['xdb']['fat_table'];
			$GLOBALS['xdb']->dir = $config['xdb']['dir'];
			
			$GLOBALS['xdb']->ver = @$config['xdb']['ver'];
			$GLOBALS['xdb']->ver_context = @$config['xdb']['ver_context'];
			$GLOBALS['xdb']->ver_table = @$config['xdb']['ver_table'];
			
			$GLOBALS['xdb']->connect();
		}
		if (!is_object(@$this->xdb))
				$this->xdb = &$GLOBALS['xdb'];
		
		if (@$this->xdb_vfilter)
				$this->xdb->setVersionFilter($this->xdb_vfilter);
		if (@$this->xdb_vprefs)
				$this->xdb->setVersionPreferences($this->xdb_vprefs);
	}
	
	/**
	 * Loads tv2FileHelper into $this->fh.
	 * ATTENTION: always copy the code from this method to
	 * {@link tv2Site::loadFileHelper()} when changed.
	 *
	 * @method private loadFileHelper
	 * @use ENGINE_DIR  
	 */ 
	function loadFileHelper()
	{
		if (!is_object(@$this->fh))
		{
			require_once(ENGINE_DIR.'tv2FileHelper.class.php');
			$this->fh = &new tv2FileHelper();
		}
	}
}

?>
Return current item: Tv.2 CMS