Commit 18ce4b7f by Frederick d. Maus

mcPUIX

1 parent abd01318
......@@ -74,7 +74,8 @@ class D {
foreach($param_bindValueArray as $string => $value) {
$param_query = str_replace($string, $value, $param_query);
}
D::li(highlight_string($param_query, true));
// D::li(highlight_string($param_query, true));
D::li($param_query, $param_print, $param_force);
D::show($param_bindValueArray, $param_query);
}
......
......@@ -9,61 +9,77 @@ if(!isset($_LOSP_DEV)) {
$_LOSP_DEV = true;
}
if(!isset($__mc_D_LOGFILE)) {
/**
/**
* @todo @since 20110325 die vars müssen eigentlich hier aus __mc raus ... da sie freeSN abhängig sind @author f@mensch.coop
*/
if(isset($_TREE) && $_TREE) {
if(isset($_TREE) && $_TREE) {
$string = $_TREE;
} else if(isset($_PAGE_NAME) && $_PAGE_NAME) {
} else if(isset($_PAGE_NAME) && $_PAGE_NAME) {
$string = $_PAGE_NAME;
} else {
} else {
$string = 'no';
}
}
if(!isset($__mc_D_LOGFILE)) {
/**
* @var string -- file for the D Output
*/
$__mc_D_LOGFILE = $__BASEPATH_EX.'log/mc.'.$string.'.DEV_D.log';
//
}
if(!isset($__mc_D_LOGFILE_RESET)) {
if(!isset($__mc_D_LOGFILE_RESET)) {
/**
* @var bool
* remove every time the file and start a new file
* @author f@mensch.coop @since 20120301
*/
$__mc_D_LOGFILE_RESET = true;
}
}
if(!isset($__mc_D_SCREENOUTPUT)) {
/**
* @var boolean -- activate the D Output on screen
*/
$__mc_D_SCREENOUTPUT = false;
}
if(!isset($__mc_PDO_LOGFILE)) {
if(!isset($__mc_INPUT_LOGFILE)) {
/**
* @var string -- file for the D Output
*/
$__mc_PDO_LOGFILE = $__BASEPATH_EX.'log/mc.'.$string.'.DEV_PDO.sql';
}
$__mc_INPUT_LOGFILE = $__BASEPATH_EX.'log/mc.'.$string.'.DEV_INPUT.log';
if(!isset($__mc_PDO_LOGFILE_RESET)) {
if(!isset($__mc_INPUT_LOGFILE_RESET)) {
/**
* @var bool
* remove every time the file and start a new file
* @author f@mensch.coop @since 20120301
*/
$__mc_PDO_LOGFILE_RESET = true;
$__mc_INPUT_LOGFILE_RESET = true;
}
}
if(!isset($__mc_PDO_LOGFILE)) {
/**
* @var string -- file for the D Output
*/
$__mc_PDO_LOGFILE = $__BASEPATH_EX.'log/mc.'.$string.'.DEV_PDO.sql';
if(!isset($__mc_D_SCREENOUTPUT)) {
if(!isset($__mc_PDO_LOGFILE_RESET)) {
/**
* @var boolean -- activate the D Output on screen
* @var bool
* remove every time the file and start a new file
* @author f@mensch.coop @since 20120301
*/
$__mc_D_SCREENOUTPUT = false;
$__mc_PDO_LOGFILE_RESET = true;
}
}
if(!isset($__mcPerformance_backtrace)) {
/**
* @var boolean -- activate the D Output on screen
......
......@@ -53,6 +53,27 @@ if($_LOSP_DEV) {
}
}
if($__mc_INPUT_LOGFILE) {
$INPUTtext = print_r(array( '_GET' => $_GET, '_POST' => $_POST ), true);
if($__mc_INPUT_LOGFILE_RESET) {
$var_message = '-- ['.date('d. m. Y G:i').'] DEVMODE: logfile wurde zurvor geloescht';
unlink ( $__mc_INPUT_LOGFILE );
mcFile::write($__mc_INPUT_LOGFILE, $var_message.mcCONST::LINEBREAK.$INPUTtext, 'w');
} else {
$var_message = mcCONST::LINEBREAK.mcCONST::LINEBREAK.mcCONST::LINEBREAK.mcCONST::LINEBREAK.mcCONST::LINEBREAK.mcCONST::LINEBREAK
.'-- ################################################'.mcCONST::LINEBREAK
.'-- ################################################'.mcCONST::LINEBREAK
.'-- ################################################'.mcCONST::LINEBREAK
.'-- # ['.date('d. m. Y G:i').'] DEVMODE #'.mcCONST::LINEBREAK
.'-- ################################################'.mcCONST::LINEBREAK;
mcFile::write($__mc_INPUT_LOGFILE, $var_message.mcCONST::LINEBREAK.$INPUTtext, 'a');
}
}
//mcFile::write('log/tmp.bla', date('d.m.Y G:i:s').': '.$_SERVER['SCRIPT_NAME'].' -- '.$_SERVER['REQUEST_URI'].mcCONST::TAB.($_SERVER['SCRIPT_NAME']==$_SERVER['REQUEST_URI']).mcCONST::LINEBREAK, 'a');
if(is_array($__mc_Report)) {
foreach($__mc_Report as $Report) {
......
......@@ -56,7 +56,7 @@
</xsd:element>
<xsd:element name="DBUIArray" >
<xsd:element name="PUIXArray" >
<xsd:complexType mixed="true">
<xsd:sequence>
<xsd:element ref="DBUIRow" minOccurs="0" maxOccurs="unbounded" />
......
<?php
interface imcPUIX {
public function getDOMElement_edit(Account &$param_HostAccount, iStorable &$param_iStorable, DOMDocument $param_DOMDocument, DOMElement &$param_DOMElement, $param_KindOf=null, array $param_DOMElemente=null);
public function getDOMElement_show(Account &$param_HostAccount, iStorable &$param_iStorable, DOMDocument $param_DOMDocument, DOMElement &$param_DOMElement, $param_KindOf=null, array $param_DOMElemente=null);
public function manipulatePost_Data(Account &$param_HostAccount, iStorable &$param_iStorable, array &$param_Data);
class mcPUIX extends mcClass {
public function setRootTable();
}
abstract class mcPUIX extends mcClass implements imcPUIX {
const DBUIConfig = 'DBUIConfig';
const PUIX_SUB_REFERENCELIST = 'PUIX_SUB_REFERENCELIST'; // mcPUIX::PUIX_SUB_REFERENCELIST
const PDOValues = 'PDOValues';
const PDOToSaveValues = 'PDOToSaveValues';
const PDOLoadDepth = 'PDOLoadDepth';
const DOMmcPUIX = 'mcPUIX';
const DOMmcPUIX_edit = 'DOMmcPUIX_edit';
const DOMmcPUIX_show = 'DOMmcPUIX_show';
const DOMRow = 'DBUIRow';
const DOMList = 'DBUIList';
const DOMElement = 'DBUIElement';
const DOMValues = 'DOMValues';
##
// DBUIArray evt überprüfen
const DBUIArray = 'DBUIArray';
// PUIXArray evt überprüfen
const PUIXArray = 'PUIXArray';
// const FORMValues = 'DBUIFormValues'; mcPUIX::FORM_DO_ROW
const FORM_POST_VALUES = 'FORM_POST_VALUES';
const FORM_REQUIRED = 'FORM_REQUIRED'; // mcPUIX::FORM_REQUIRED
const FORM_NEW_ROW = 'FORM_NEW_ROW'; // mcPUIX::FORM_NEW_ROW
const FORM_DO_VAR = 'FORM_DO_VAR'; // mcPUIX::FORM_DO_VAR
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
......@@ -25,32 +46,39 @@ class mcPUIX extends mcClass {
const FORM_DO_SELECT = 'FORM_DO_SELECT'; // mcPUIX::FORM_DO_SELECT
const FORM_TYPE_SEOLINK = 'FORM_TYPE_SEOLINK';
const FORM_TYPE_BASISELEMENT_SHORT = 'FORM_TYPE_BASISELEMENT_SHORT';
const STATE_LOADED = 'loaded';
const STATE_CHANGED = 'changed';
const STATE_SAVED = 'saved';
private $DBTab_State = array();
protected $RootTable;
/**
*
* @var array('tablename' => array(mcPUIX::DBUIArray => array()))
* @var array('tablename' => array(mcPUIX::PUIXArray => array()))
*/
private $DBTab = array();
/**
*
* @var aBasisElementAddon
*/
protected $BasisElementAddon = null;
protected $PUIXHostObject = null;
public $ThisClassName;
public function __construct(aBasisElementAddon $BasisElementAddon) {
public function __construct( $PUIXHostObject) {
$this->mcID = mcObjectStatistic::getCount__construct($this);
$this->BasisElementAddon = $BasisElementAddon;
$this->PUIXHostObject = $PUIXHostObject;
$this->ThisClassName = get_class($this);
$this->setRootTable();
}
protected $SearchAttributes = null;
public function setSearchAttributes(array $param_SearchAttributes) {
$this->SearchAttributes = $param_SearchAttributes;
}
private function setTableValues($param_tablename, $param_tablevalues) {
$this->DBTab[$param_tablename] = $param_tablevalues;
......@@ -58,22 +86,63 @@ class mcPUIX extends mcClass {
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) {
public function loadPDOTable(Account &$param_HostAccount, iStorable &$param_iStorable, $param_SQLWhere='', $param_depth=null) {
$param_tablename = $this->RootTable;
if($param_SQLWhere==='' && !is_null($this->SearchAttributes)) {
$param_SQLWhere = ' where ';
$bool_AND = false;
foreach($this->SearchAttributes as $col => $val) {
if($col === mcPUIX::PDOLoadDepth) {
$param_depth = $val;
}
else if($col !== mcPUIX::PUIX_SUB_REFERENCELIST) {
if($bool_AND) {
$param_SQLWhere .= ' AND ';
} else {
$bool_AND = true;
}
$param_SQLWhere .= ' '.$col.'="'.$val.'" ';
}
}
}
if(is_null($param_depth)) {
$param_depth = 0;
}
$DBTable = mcPUIX_PDO::getTableAsDBUIArray($param_HostAccount, $param_iStorable, $param_tablename, $param_SQLWhere, $param_depth);
// D::show($DBTable, '$DBTable '.$this->BasisElementAddon);
// D::show($DBTable, '$DBTable '.$this->PUIXHostObject);
$this->setTableValues($param_tablename, $DBTable);
$this->DBTab_State[$param_tablename] = mcPUIX::STATE_LOADED;
}
public function setData($param_tablename, $param_values) {
public function setData(Account &$param_HostAccount, iStorable &$param_iStorable, $param_values) {
$param_tablename = $this->RootTable;
D::ulli(__CLASS__.'::'.__FUNCTION__.': ' . $param_tablename.' ## '.mcPUIX::STATE_CHANGED);
$this->setTableValues($param_tablename, $param_values);
$this->DBTab_State[$param_tablename] = mcPUIX::STATE_CHANGED;
if(is_object($this->PUIXHostObject)) {
if(mcArray::checkKeyHasFullArray($param_values, get_class($this->PUIXHostObject))) {
$values = $param_values[get_class($this->PUIXHostObject)];
} else {
return false;
}
} else {
$values = $param_values;
}
if(mcArray::checkKeyHasFullArray($values, $this->ThisClassName, mcPUIX::PUIXArray, mcPUIX::FORM_POST_VALUES)) {
$this->manipulatePost_Data($param_HostAccount, $param_iStorable, $values[$this->ThisClassName][mcPUIX::PUIXArray][mcPUIX::FORM_POST_VALUES]);
}
public function savePDOTable(Account &$param_HostAccount, iStorable &$param_iStorable, $param_tablename) {
$this->setTableValues($param_tablename, $values[$this->ThisClassName]);
$this->DBTab_State[$param_tablename] = mcPUIX::STATE_CHANGED;
}
public function savePDOTable(Account &$param_HostAccount, iStorable &$param_iStorable) {
$param_tablename = $this->RootTable;
$DBUIArray_Values = $this->getTableValues($param_tablename);
// D::show($this->DBTab , '$this->DBTab');
......@@ -81,15 +150,15 @@ class mcPUIX extends mcClass {
$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')) {
if(mcArray::checkKeyHasFullArray($DBUIConfig, mcPUIX::PUIXArray, mcPUIX::DBUIConfig, $param_tablename, 'TABLE', mcPUIX::PUIX_SUB_REFERENCELIST, '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];
$DBUIConfig[mcPUIX::PUIXArray][mcPUIX::DBUIConfig][$Tablename_LIST] = $DBUIConfig_LIST[mcPUIX::PUIXArray][mcPUIX::DBUIConfig][$Tablename_LIST];
}
// D::show($DBUIArray_Values, $param_tablename);
$PreparedArray = mcPUIX_PDO::prepareArrayForDBOperation($param_tablename, $DBUIConfig, $DBUIArray_Values);
// D::show($PreparedArray, '$PreparedArray = mcPUIX_PDO::prepareArrayForDBOperation');
......@@ -97,6 +166,19 @@ class mcPUIX extends mcClass {
$DBUIArrayNew = mcPUIX_PDO::updateDatabaseTable($param_HostAccount, $param_iStorable, $DBUIConfig, $PreparedArray);
$this->setTableValues($param_tablename, $DBUIArrayNew);
$this->DBTab_State[$param_tablename] = mcPUIX::STATE_SAVED;
if(is_array($this->SearchAttributes)) {
$this->loadPDOTable($param_HostAccount, $param_iStorable);
}
}
protected function getFormPathToThis() {
$formpath = '';
if(is_object($this->PUIXHostObject)) {
$formpath .= '['.get_class($this->PUIXHostObject).']';
}
$formpath .= '['.$this->ThisClassName.']['.mcPUIX::PUIXArray.']['.mcPUIX::FORM_POST_VALUES.']';
return $formpath;
}
public function getObjDOMElement(Account &$param_HostAccount, iStorable &$param_iStorable, DOMDocument $param_DOMDocument, $param_KindOf=null, array $param_DOMElemente=null) {
......@@ -106,8 +188,18 @@ class mcPUIX extends mcClass {
$DOMElement->setAttribute('label', Language::getWord(get_class($this)));
if($param_KindOf=='form') {
$DOMElement->setAttribute('edit', true);
$DOMElement_edit = $param_DOMDocument->createElement(mcPUIX::DOMmcPUIX_edit);
$DOMElement_edit->setAttribute('edit', true);
$DOMElement_edit->setAttribute('formpath', $this->getFormPathToThis());
$DOMElement->appendChild($DOMElement_edit);
$this->getDOMElement_edit($param_HostAccount, $param_iStorable, $param_DOMDocument, $DOMElement_edit, $param_KindOf, $param_DOMElemente);
}
$DOMElement_show = $param_DOMDocument->createElement(mcPUIX::DOMmcPUIX_show);
$DOMElement->appendChild($DOMElement_show);
$this->getDOMElement_show($param_HostAccount, $param_iStorable, $param_DOMDocument, $DOMElement_show, $param_KindOf, $param_DOMElemente);
return $DOMElement;
}
......@@ -125,7 +217,7 @@ class mcPUIX extends mcClass {
protected static $Tables = array ();
public function walk_ListElements(Account &$param_HostAccount, iStorable &$param_iStorable, $param_tablename, array $param_callbackfncForList=null, array $param_callbackfncForListElements=null) {
if(mcArray::checkKeyHasFullArray($this->DBTab, $param_tablename, mcPUIX::DBUIArray, mcPUIX::PDOValues) ) {
if(mcArray::checkKeyHasFullArray($this->DBTab, $param_tablename, mcPUIX::PUIXArray, mcPUIX::PDOValues) ) {
$callbackfncForList = false;
if(is_array($param_callbackfncForList) && !empty ($param_callbackfncForList)) {
......@@ -137,7 +229,7 @@ class mcPUIX extends mcClass {
$callbackfncForListElements = true;
}
foreach($this->DBTab[$param_tablename][mcPUIX::DBUIArray][mcPUIX::PDOValues] as &$ListData) {
foreach($this->DBTab[$param_tablename][mcPUIX::PUIXArray][mcPUIX::PDOValues] as &$ListData) {
if($callbackfncForList) {
foreach($param_callbackfncForList as $fncForList) {
$this->$fncForList($param_HostAccount, $param_iStorable, $ListData);
......@@ -155,5 +247,8 @@ class mcPUIX extends mcClass {
}
}
}
}
?>
\ No newline at end of file
......@@ -12,7 +12,7 @@ class mcPUIX_CONFIG {
*
* @param string $param_tablename
* @param array $param_ManipulateTableConfig
* @return array( mcPUIX::DBUIArray => array( mcPUIX::DBUIConfig => array( $param_tablename => array()) ) ) || FALSE
* @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])) {
......@@ -28,7 +28,7 @@ class mcPUIX_CONFIG {
}
$result = array(
mcPUIX::DBUIArray => array( mcPUIX::DBUIConfig => array( $param_tablename => $Config) )
mcPUIX::PUIXArray => array( mcPUIX::DBUIConfig => array( $param_tablename => $Config) )
);
return $result;
......@@ -40,9 +40,9 @@ class mcPUIX_CONFIG {
}
public static function getReferenceTableName($param_tablename) {
if(mcArray::checkKeyHasFullArray(mcPUIX_CONFIG::$Tables[$param_tablename], 'TABLE', 'LIST_TABLE')) {
if(mcPUIX_CONFIG::$Tables[$param_tablename]['TABLE']['LIST_TABLE']['TABLENAME']) {
$Tablename_LIST = mcPUIX_CONFIG::$Tables[$param_tablename]['TABLE']['LIST_TABLE']['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;
}
......@@ -53,5 +53,15 @@ class mcPUIX_CONFIG {
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'];
}
}
}
}
?>
\ No newline at end of file
......@@ -30,7 +30,7 @@ class mcPUIX_PHPTest extends PHPUnit_Framework_TestCase {
public function testPrepareArrayForDOMElement() {
$ValueArray = array(
mcPUIX::DBUIArray => array(
mcPUIX::PUIXArray => array(
array( 'key1' => 'value11',
'key2' => 'value12',
'key3' => 'value13',
......@@ -115,7 +115,7 @@ class mcPUIX_PHPTest extends PHPUnit_Framework_TestCase {
$ConfigArray = array(
'TABLE' => array(
'PRIMARY' => array('Primary1ID', 'Primary2ID'),
'REQUIRED' => array('Required1', 'Required2'),
mcPUIX::FORM_REQUIRED => array('Required1', 'Required2'),
),
mcPUIX::FORM_DO_ROW => array(),
'Key1' => array(),
......
......@@ -4,10 +4,10 @@
*/
$__BASEPATH_EX= '../../../../../';
/**
* only important for when you inclue 'include/Lib/Tools/mcClasses/include.php,
* in the moment this makes RequireClass.inc.php
*/
$__PATH_to_mcClasses= $__BASEPATH_EX .'include/Lib/Tools/mcClasses/';
// ist in die config gewandert
///**
// * only important for when you inclue 'include/Lib/Tools/mcClasses/include.php,
// * in the moment this makes RequireClass.inc.php
// */
//$__PATH_to_mcClasses= $__BASEPATH_EX .'include/Lib/Tools/mcClasses/';
?>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!