class_mcPUIX.inc.php 4.39 KB
<?php

class mcPUIX extends mcClass {
	const DBUIConfig = 'DBUIConfig';
	
	const PDOValues = 'PDOValues';
	const PDOToSaveValues = 'PDOToSaveValues';
	
	const DOMmcPUIX = 'mcPUIX';
	const DOMRow = 'DBUIRow';
	const DOMList = 'DBUIList';
	const DOMElement = 'DBUIElement';
	const DOMValues = 'DOMValues';	
	##

	// DBUIArray evt überprüfen
	const DBUIArray = 'DBUIArray';

//	const FORMValues = 'DBUIFormValues'; mcPUIX::FORM_DO_ROW
	
	const FORM_DO_ROW = 'FORM_DO_ROW';			// mcPUIX::FORM_DO_ROW
	const FORM_DO_SAVE = 'FORM_DO_SAVE';		// mcPUIX::FORM_DO_SAVE
	const FORM_DO_DELETE = 'FORM_DO_DELETE';	// mcPUIX::FORM_DO_DELETE
	const FORM_DO_NEW = 'FORM_DO_NEW';			// mcPUIX::FORM_DO_NEW
	const FORM_DO_SELECT = 'FORM_DO_SELECT';	// mcPUIX::FORM_DO_SELECT
	
	const FORM_TYPE_SEOLINK = 'FORM_TYPE_SEOLINK';
	
	const STATE_LOADED = 'loaded';
	const STATE_CHANGED = 'changed';
	const STATE_SAVED = 'saved';
	private $DBTab_State = array();
	
	/**
	 *
	 * @var array('tablename' => array(mcPUIX::DBUIArray => array()))
	 */
	private $DBTab = array();
	/**
	 *
	 * @var aBasisElementAddon
	 */
	protected $BasisElementAddon = null;
	

	public function __construct(aBasisElementAddon $BasisElementAddon) {
		
		$this->mcID = mcObjectStatistic::getCount__construct($this);
		
		$this->BasisElementAddon = $BasisElementAddon;
	}
	

	
	private function setTableValues($param_tablename, $param_tablevalues) {
		$this->DBTab[$param_tablename] = $param_tablevalues;
	}
	public function getTableValues($param_tablename) {
		return $this->DBTab[$param_tablename];
	}	
	public function loadPDOTable(Account &$param_HostAccount, iStorable &$param_iStorable, $param_tablename, $param_SQLWhere='', $param_depth=0) {
		$DBTable = mcPUIX_PDO::getTableAsDBUIArray($param_HostAccount, $param_iStorable, $param_tablename, $param_SQLWhere, $param_depth);
//		D::show($DBTable, '$DBTable '.$this->BasisElementAddon);
		$this->setTableValues($param_tablename, $DBTable);	
		$this->DBTab_State[$param_tablename] = mcPUIX::STATE_LOADED;
	}

	public function  setData($param_tablename, $param_values) {
		D::ulli(__CLASS__.'::'.__FUNCTION__.': ' . $param_tablename.' ## '.mcPUIX::STATE_CHANGED);
		$this->setTableValues($param_tablename, $param_values);	
		$this->DBTab_State[$param_tablename] = mcPUIX::STATE_CHANGED;
		
		
	}

	public function savePDOTable(Account &$param_HostAccount, iStorable &$param_iStorable, $param_tablename) { 
		$DBUIArray_Values = $this->getTableValues($param_tablename);
		
//		D::show($this->DBTab , '$this->DBTab');
				
		$ManipulateTableConfig = null;
		$DBUIConfig = mcPUIX_CONFIG::getTableConfig($param_tablename, $ManipulateTableConfig);
//		D::show($DBUIConfig, '$DBUIConfig');
		if(mcArray::checkKeyHasFullArray($DBUIConfig, mcPUIX::DBUIArray, mcPUIX::DBUIConfig, $param_tablename, 'TABLE', 'LIST_TABLE', 'TABLENAME')) {
			$Tablename_LIST = mcPUIX_CONFIG::getReferenceTableName($param_tablename);
			$ManipulateTableConfig = null;
			$DBUIConfig_LIST = mcPUIX_CONFIG::getTableConfig($Tablename_LIST, $ManipulateTableConfig);
			$DBUIConfig[mcPUIX::DBUIArray][mcPUIX::DBUIConfig][$Tablename_LIST] = $DBUIConfig_LIST[mcPUIX::DBUIArray][mcPUIX::DBUIConfig][$Tablename_LIST];

		}
		
		
		$PreparedArray = mcPUIX_PDO::prepareArrayForDBOperation($param_tablename, $DBUIConfig, $DBUIArray_Values);
		
//		D::show($PreparedArray, '$PreparedArray = mcPUIX_PDO::prepareArrayForDBOperation');
		
		$DBUIArrayNew = mcPUIX_PDO::updateDatabaseTable($param_HostAccount, $param_iStorable, $DBUIConfig, $PreparedArray);
		$this->setTableValues($param_tablename, $DBUIArrayNew);
		$this->DBTab_State[$param_tablename] = mcPUIX::STATE_SAVED;
	}
	
	public function getObjDOMElement(Account &$param_HostAccount, iStorable &$param_iStorable, DOMDocument $param_DOMDocument, $param_KindOf=null, array $param_DOMElemente=null) {

		$DOMElement = $param_DOMDocument->createElement(mcPUIX::DOMmcPUIX);
		$DOMElement->setAttribute('class', get_class($this));
		$DOMElement->setAttribute('label', Language::getWord(get_class($this)));

		if($param_KindOf=='form') {
			$DOMElement->setAttribute('edit', true);
		}
		return $DOMElement;

	}

	protected static $unsetCONFIG = true;
	public static function setmcPUIX_CONFIG(array $param_Configs) {
		if(mcPUIX::$unsetCONFIG) {
			foreach($param_Configs as $tablename => $values) {
//				D::show($values, $tablename);
				mcPUIX_CONFIG::setTableConfig($tablename, $values);
			}			
			mcPUIX::$unsetCONFIG = false;
		}
	}	
	protected static $Tables = array ();
}
?>