class_mcPUIX_CONFIG.inc.php 2.16 KB
<?php
class mcPUIX_CONFIG {
//'KINDOF'	=> 'DATASET',
	protected static $Tables = array();

	public static function setTableConfig($param_tablename, array $param_TableValues) {
		mcPUIX_CONFIG::$Tables[$param_tablename] = $param_TableValues;
	}
	
	/**
	 *	return the table config
	 * 
	 * @param string $param_tablename
	 * @param array $param_ManipulateTableConfig
	 * @return array( mcPUIX::PUIXArray => array( mcPUIX::DBUIConfig => array( $param_tablename => array()) ) ) || FALSE
	 */
	public static function getTableConfig($param_tablename, array $param_ManipulateTableConfig=null) {
		if(array_key_exists($param_tablename, mcPUIX_CONFIG::$Tables) && is_array(mcPUIX_CONFIG::$Tables[$param_tablename])) {
			$Config = mcPUIX_CONFIG::$Tables[$param_tablename];
			if(is_array($param_ManipulateTableConfig)) {
				
				if(!array_key_exists('TABLE', $Config) || !is_array($Config['TABLE'])) {
					$Config['TABLE'] = array();
				}
				foreach($param_ManipulateTableConfig as $key => $value) {
					$Config['TABLE'][$key] = $value;
				}
			} 
			
			$result = array(
				mcPUIX::PUIXArray => array( mcPUIX::DBUIConfig => array( $param_tablename => $Config) )
			);
			
			return $result;
			
		} else {
			return false;
		}

	}

	public static function getReferenceTableName($param_tablename) {
		if(mcArray::checkKeyHasFullArray(mcPUIX_CONFIG::$Tables[$param_tablename], 'TABLE', mcPUIX::PUIX_SUB_REFERENCELIST)) {
			if(mcPUIX_CONFIG::$Tables[$param_tablename]['TABLE'][mcPUIX::PUIX_SUB_REFERENCELIST]['TABLENAME']) {
				$Tablename_LIST = mcPUIX_CONFIG::$Tables[$param_tablename]['TABLE'][mcPUIX::PUIX_SUB_REFERENCELIST]['TABLENAME'];		
			} else {
				return false;
			}
			
		} else {
			return false;
		}
		return $Tablename_LIST;
	}
	
	PUBLIC STATIC FUNCTION getReferenceListTableName($param_tablename) {
		foreach(mcPUIX_CONFIG::$Tables as $tablename => $tableValues) {
			if(mcArray::checkKeyHasFullArray($tableValues, 'TABLE', mcPUIX::PUIX_SUB_REFERENCELIST) 
					&& $tableValues['TABLE'][mcPUIX::PUIX_SUB_REFERENCELIST]['TABLENAME']
					&& $tableValues['TABLE'][mcPUIX::PUIX_SUB_REFERENCELIST]['TABLENAME'] === $param_tablename
			) {
				return $tableValues['TABLE']['TABLENAME'];
			}
		}
	}
}
?>