Commit 1137964a by Frederick d. Maus

TestSystem: 3880 13m20s

1 parent 35e52e8e
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
* Description of class_mcPDOLogger
*
* @author Frederick <frederick at mensch.coop>
*/
class mcPDOLogger {
private static $Messages = array();
public static function add($param_order, array $param_bindValueArray=null, $param_optional='') {
mcPDOLogger::$Messages[] = array(
'order' => $param_order,
'bindValue' => $param_bindValueArray,
'optional' => $param_optional
);
}
public static function getMessagesAsText() {
$MessageAsText = '';
foreach(mcPDOLogger::$Messages as $message) {
$MessageAsText .= "\n".$message['order']."\n";
}
mcPDOLogger::$Messages = array();
return $MessageAsText;
}
}
?>
<?xml version="1.0" encoding="utf-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="item" >
<xsd:complexType mixed="true">
<xsd:attribute name="key" use="required" type="xsd:string"/>
<xsd:attribute name="value" use="required" type="xsd:string"/>
<xsd:attribute name="label" use="required" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="DBUIList" >
<xsd:complexType mixed="true">
<xsd:sequence>
<xsd:element ref="item" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
<xsd:attribute name="count" use="required" type="xsd:integer"/>
</xsd:complexType>
</xsd:element>
<xsd:simpleType name="Element_type">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="text"/>
<xsd:enumeration value="time"/>
<xsd:enumeration value="url"/>
<xsd:enumeration value="select"/>
<xsd:enumeration value="int"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:element name="DBUIElement" >
<xsd:complexType mixed="true">
<xsd:sequence>
<xsd:element ref="DBUIList" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="label" use="required" type="xsd:string"/>
<xsd:attribute name="objvar" use="required" type="xsd:string"/>
<xsd:attribute name="value" use="required" type="xsd:string"/>
<xsd:attribute name="type" type="Element_type" />
<xsd:attribute name="show" type="xsd:boolean"/>
<xsd:attribute name="edit" type="xsd:boolean"/>
<xsd:attribute name="fixed" type="xsd:boolean"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="DBUIRow" >
<xsd:complexType mixed="true">
<xsd:sequence>
<xsd:element ref="DBUIElement" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
<xsd:attribute name="i" use="required" type="xsd:integer"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="DBUIArray" >
<xsd:complexType mixed="true">
<xsd:sequence>
<xsd:element ref="DBUIRow" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
<xsd:attribute name="count" use="required" type="xsd:integer"/>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<?php
/*
* Created on 27.02.2008
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
class Converter{
private static $Specials = array (
'&' => '',
'' => '',
'' => '',
'' => '',
'' => '',
'' => ''
);
/**
* Convert all HTML entities to their applicable characters for the Database
*
* @param string param_string
* @return string
*/
public static function decodeString($param_string){
// if(!is_array($param_string) && !is_object($param_string)) {
// $param_string = html_entity_decode($param_string, 1,"UTF-8");
// $param_string = addslashes($param_string);
// }
return $param_string;
}
/**
* Convert all applicable characters to HTML entities
*
* @param string param_string
* @return string
*/
public static function encodeString($param_string, $param_encode = true){
// $param_string = strip_tags($param_string);
// $param_string = htmlentities($param_string, 1,"UTF-8");
// $param_string = trim($param_string);
$param_string = stripslashes($param_string);
// D::show($param_string,"encode",1);
// if(!is_numeric($param_string)){
// $param_string = "'" . mysql_real_escape_string($param_string) . "'";
// }
if($param_encode){
return htmlspecialchars($param_string, 2,"UTF-8");
}
else{
return $param_string;
}
}
public static function StringToUrl($param_Url) {
return htmlentities($param_Url);
}
}
?>
\ No newline at end of file
<?php
class mcPUIX {
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->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() {
if(Category2mcPUIX::$unsetCONFIG) {
foreach(Category2mcPUIX::$Tables as $tablename => $values) {
mcPUIX_CONFIG::setTableConfig($tablename, $values);
}
Category2mcPUIX::$unsetCONFIG = false;
}
}
protected static $Tables = array ();
}
?>
<?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::DBUIArray => 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::DBUIArray => 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', 'LIST_TABLE')) {
if(mcPUIX_CONFIG::$Tables[$param_tablename]['TABLE']['LIST_TABLE']['TABLENAME']) {
$Tablename_LIST = mcPUIX_CONFIG::$Tables[$param_tablename]['TABLE']['LIST_TABLE']['TABLENAME'];
} else {
return false;
}
} else {
return false;
}
return $Tablename_LIST;
}
}
?>
\ No newline at end of file
<?
class mcPUIX_DOM {
/**
* copy the param_ConfigArray into the value param_ValueArray
* examples @see mcPUIX_PHPTest::testPrepareArrayForDOMElement()
* function prepare Array for @see mcPUIX_DOM::getDOMElement_DBUIArray
*
* @param string $param_tablename
* @param array $param_ConfigArray -- $param_ConfigArray[mcPUIX::DBUIArray][mcPUIX::DBUIConfig][$param_tablename] = array()
* -- return from mcPUIX_CONFIG::getTableConfig
* @param array $param_ValueArray -- $param_ValueArray[mcPUIX::DBUIArray][mcPUIX::PDOValues] = array(0=>val1, 1=>val2)
* @param array $param_SetDefault -- array( columnName1 => array( type=>, value=>, edit=>, show=>, ...), ... )
* @return array -- array(
* mcPUIX::DBUIArray => array(
* mcPUIX::DOMValues => array()
* )
* );
*
* @since 20120307
* @author f
*/
public static function prepareArrayForDOMElement($param_tablename, array $param_ConfigArray, array $param_ValueArray=null, array $param_SetDefault=null) {
// D::show(array($param_ConfigArray, $param_ValueArray ) ,$param_tablename);
if(mcArray::checkKeyHasFullArray($param_ConfigArray, mcPUIX::DBUIArray, mcPUIX::DBUIConfig, $param_tablename)) {
if(mcArray::checkKeyHasFullArray($param_ValueArray, mcPUIX::DBUIArray, mcPUIX::PDOValues)) {
/**
* condition: check if there is a reference table as list
*/
if(mcArray::checkKeyHasFullArray($param_ConfigArray[mcPUIX::DBUIArray][mcPUIX::DBUIConfig][$param_tablename], 'TABLE', 'LIST_TABLE')
&& $param_ConfigArray[mcPUIX::DBUIArray][mcPUIX::DBUIConfig][$param_tablename]['TABLE']['LIST_TABLE']['TABLENAME']
&& $param_ConfigArray[mcPUIX::DBUIArray][mcPUIX::DBUIConfig][$param_tablename]['TABLE']['LIST_TABLE']['REFERENCE_KEY']
&& $param_ConfigArray[mcPUIX::DBUIArray][mcPUIX::DBUIConfig][$param_tablename]['TABLE']['ELEMENTID']
&& mcArray::checkKeyHasFullArray($param_ConfigArray[mcPUIX::DBUIArray][mcPUIX::DBUIConfig], $param_ConfigArray[mcPUIX::DBUIArray][mcPUIX::DBUIConfig][$param_tablename]['TABLE']['LIST_TABLE']['TABLENAME'])
) {
$Reference_Config = $param_ConfigArray[mcPUIX::DBUIArray][mcPUIX::DBUIConfig][$param_ConfigArray[mcPUIX::DBUIArray][mcPUIX::DBUIConfig][$param_tablename]['TABLE']['LIST_TABLE']['TABLENAME']];
$Reference_TableName = $param_ConfigArray[mcPUIX::DBUIArray][mcPUIX::DBUIConfig][$param_tablename]['TABLE']['LIST_TABLE']['TABLENAME'];
$Reference_Config = array( mcPUIX::DBUIArray => array( mcPUIX::DBUIConfig => array( $Reference_TableName => $Reference_Config) ) );
$Reference_ElementID = $param_ConfigArray[mcPUIX::DBUIArray][mcPUIX::DBUIConfig][$param_tablename]['TABLE']['ELEMENTID'];
$Reference_REFERENCE_KEY = $param_ConfigArray[mcPUIX::DBUIArray][mcPUIX::DBUIConfig][$param_tablename]['TABLE']['LIST_TABLE']['REFERENCE_KEY'];
// D::show($Reference_Config, '$Reference_Config $Reference_ElementID:'.$Reference_ElementID.' ## $Reference_REFERENCE_KEY:'.$Reference_REFERENCE_KEY);
$Reference = true;
} else {
$Reference = false;
}
$copy_ConfigArray = $param_ConfigArray[mcPUIX::DBUIArray][mcPUIX::DBUIConfig][$param_tablename];
//D::show(array($copy_ConfigArray, $param_ConfigArray) ,$param_tablename);
foreach($param_ValueArray[mcPUIX::DBUIArray][mcPUIX::PDOValues] as &$value_row) {
foreach($value_row as $row_key => &$row_val) {
/**
* reference
*/
if($row_key === mcPUIX::DBUIArray) {
}
/**
* Reference List
*/
else if($row_val === mcPUIX::DBUIArray) {
if($Reference) {
$Reference_SetDefault = array(
$Reference_REFERENCE_KEY => array(
'value' => $value_row[$Reference_REFERENCE_KEY]['value']
)
);
// D::show(array($Reference_SetDefault, $value_row), '$Reference_SetDefault');
if(mcArray::checkKeyHasFullArray($value_row, mcPUIX::DBUIArray, mcPUIX::PDOValues)) {
$ReferenceValues = array(mcPUIX::DBUIArray => array(mcPUIX::PDOValues => $value_row[mcPUIX::DBUIArray][mcPUIX::PDOValues]));
$Reference_DOMValues = mcPUIX_DOM::prepareArrayForDOMElement($Reference_TableName, $Reference_Config, $ReferenceValues, $Reference_SetDefault);
// $value_row[mcPUIX::DBUIArray][mcPUIX::DOMValues] = $Reference_DOMValues[mcPUIX::DBUIArray][mcPUIX::DOMValues];
unset($value_row[mcPUIX::DBUIArray]);
} else {
$Reference_DOMValues = mcPUIX_DOM::prepareArrayForDOMElement($Reference_TableName, $Reference_Config, null, $Reference_SetDefault);
}
if(array_key_exists($row_key, $param_ConfigArray[mcPUIX::DBUIArray][mcPUIX::DBUIConfig][$param_tablename])) {
$row_val = $param_ConfigArray[mcPUIX::DBUIArray][mcPUIX::DBUIConfig][$param_tablename][$row_key];
unset($copy_ConfigArray[$row_key]);
} else {
$row_val = array();
}
$row_val['value'] = $Reference_DOMValues;
}
}
/**
* normal
*/
else {
$value = $row_val;
if(array_key_exists($row_key, $param_ConfigArray[mcPUIX::DBUIArray][mcPUIX::DBUIConfig][$param_tablename])) {
$row_val = $param_ConfigArray[mcPUIX::DBUIArray][mcPUIX::DBUIConfig][$param_tablename][$row_key];
unset($copy_ConfigArray[$row_key]);
} else {
$row_val = array();
}
if(!is_null($param_SetDefault)) {
foreach($param_SetDefault as $default_rowkey => $default_rowvalues) {
if($default_rowkey=='*' || $default_rowkey==$row_key) {
foreach($default_rowvalues as $default_key => $default_value) {
$row_val[$default_key] = $default_value;
if($default_key==='value') {
$value = $default_value;
}
}
}
}
}
$row_val['value'] = $value;
}
}
/**
* @todo Performance muss theoretisch nur einmal ausgeführt werden @f 100722
*/
if(!is_null($param_SetDefault) && is_array($copy_ConfigArray)) {
foreach($copy_ConfigArray as $copy_ConfigDataKey => &$copy_ConfigDataArray) {
foreach($param_SetDefault as $default_rowkey => &$default_rowvalues) {
if($default_rowkey=='*' || $default_rowkey==$copy_ConfigDataKey) {
foreach($default_rowvalues as $default_key => $default_value) {
$copy_ConfigDataArray[$default_key] = $default_value;
}
}
}
}
}
/**
* alle Datensätze sollen erstmal makiert sein -- da sie sonst gelöscht werden
*/
if(array_key_exists(mcPUIX::FORM_DO_ROW, $copy_ConfigArray)) {
$copy_ConfigArray[mcPUIX::FORM_DO_ROW]['value'] = mcPUIX::FORM_DO_SAVE;
}
// D::show(array('array_merge' => array($value_row, $copy_ConfigArray)), '$value_row, $copy_ConfigArray');
$value_row= array_merge($value_row, $copy_ConfigArray);
// D::show($value_row, '$value_row');
}
$return = array(
mcPUIX::DBUIArray => array(
mcPUIX::DOMValues => $param_ValueArray[mcPUIX::DBUIArray][mcPUIX::PDOValues]
)
);
} else {
$return = array(
mcPUIX::DBUIArray => array(
mcPUIX::DOMValues => array()
)
);
}
if(mcArray::checkKeyHasFullArray($param_ConfigArray[mcPUIX::DBUIArray][mcPUIX::DBUIConfig][$param_tablename], 'TABLE')
&& array_key_exists('NEW_ROW', $param_ConfigArray[mcPUIX::DBUIArray][mcPUIX::DBUIConfig][$param_tablename]['TABLE'])
&& $param_ConfigArray[mcPUIX::DBUIArray][mcPUIX::DBUIConfig][$param_tablename]['TABLE']['NEW_ROW']
) {
$return[mcPUIX::DBUIArray][mcPUIX::DOMValues]['NEW_ROW'] = $param_ConfigArray[mcPUIX::DBUIArray][mcPUIX::DBUIConfig][$param_tablename];
foreach($return[mcPUIX::DBUIArray][mcPUIX::DOMValues]['NEW_ROW'] as $NEW_key => &$NEW_values) {
if(array_key_exists('type', $NEW_values) && $NEW_values['type'] === mcPUIX::DBUIArray) {
unset($return[mcPUIX::DBUIArray][mcPUIX::DOMValues]['NEW_ROW'][$NEW_key]);
}
/**
* copy default values into NEW_ROW
*/
if(is_array($param_SetDefault)) {
if(mcArray::checkKeyHasFullArray($param_SetDefault, $NEW_key)) {
$NEW_values = array_merge ( $NEW_values, $param_SetDefault[$NEW_key]);
}
}
}
if($param_ConfigArray[mcPUIX::DBUIArray][mcPUIX::DBUIConfig][$param_tablename]['TABLE']['ELEMENTID']) {
if($param_ConfigArray[mcPUIX::DBUIArray][mcPUIX::DBUIConfig][$param_tablename]['TABLE']['KINDOF'] === 'LIST') {
unset($return[mcPUIX::DBUIArray][mcPUIX::DOMValues]['NEW_ROW'][$param_ConfigArray[mcPUIX::DBUIArray][mcPUIX::DBUIConfig][$param_tablename]['TABLE']['ELEMENTID']]);
} else if($param_ConfigArray[mcPUIX::DBUIArray][mcPUIX::DBUIConfig][$param_tablename]['TABLE']['KINDOF'] === 'RELATION') {
}
}
$return[mcPUIX::DBUIArray][mcPUIX::DOMValues]['NEW_ROW'][mcPUIX::FORM_DO_ROW]['value'] = mcPUIX::FORM_DO_NEW;
}
return $return;
}
return false;
}
/**
* return DOMElement with DBUIArray
*
* @param DOMDocument $param_DOMDocument
* @param array $param_Array -- $param_Array[mcPUIX::DBUIArray][mcPUIX::DOMValues] = array()
* -- return from mcPUIX_DOM::prepareArrayForDOMElement
* @return type
*/
public static function getDOMElement_DBUIArray(DOMDocument $param_DOMDocument, array $param_Array) {
// D::show($param_Array, 'getDOMElement_DBUIArray');
$DOMElement = $param_DOMDocument->createElement(mcPUIX::DBUIArray);
if(mcArray::checkKeyHasFullArray($param_Array, mcPUIX::DBUIArray, mcPUIX::DOMValues)) {
$DOMElement->setAttribute('count', count($param_Array));
foreach($param_Array[mcPUIX::DBUIArray][mcPUIX::DOMValues] as $i => $row) {
$DOMElement_Row = $DOMElement->appendChild($param_DOMDocument->createElement(mcPUIX::DOMRow));
$DOMElement_Row->setAttribute('i', $i);
if(is_array($row)) {
// D::show($row, 'getDOMElement_DBUIArray'.$i);
foreach($row as $column_name => $column_value) {
// if(mcArray::checkKeyHasFullArray($column_value, 'value', mcPUIX::DBUIArray)) {
// $DOM_Reference = mcPUIX_DOM::getDOMElement_DBUIArray($param_DOMDocument, $row);
// $DOMElement_Row->appendChild($DOM_Reference);
// // D::show($row,' JETZT NE NEUE TABELLE');
// } else
if($column_name === 'TABLE') {
} else if ($column_name === mcPUIX::FORM_DO_ROW) {
} else {
$DOMElement_Row->appendChild(mcPUIX_DOM::getDOMElement_Element($param_DOMDocument, $column_name, $column_value));
}
}
if(mcArray::checkKeyHasFullArray($row, mcPUIX::FORM_DO_ROW)) {
$DOMElement_Row->appendChild(mcPUIX_DOM::getDOMElement_Element($param_DOMDocument, mcPUIX::FORM_DO_ROW, $row[mcPUIX::FORM_DO_ROW]));
}
}
}
}
return $DOMElement;
}
public static function getDOMElement_DBUIList(DOMDocument $param_DOMDocument, array $param_Array) {
$DOMElement = $param_DOMDocument->createElement(mcPUIX::DOMList);
$DOMElement->setAttribute('count', count($param_Array));
foreach($param_Array as $key => $value) {
$DOMElement_Row = $DOMElement->appendChild($param_DOMDocument->createElement('item'));
$DOMElement_Row->setAttribute('key', $key);
$DOMElement_Row->setAttribute('value', $value);
$DOMElement_Row->setAttribute('label', $value);
}
return $DOMElement;
}
/**
* return a DOMElement like <Element value='' label='' objvar='' ... /> with optional attributes
*
* special cases depends from $param_Values['type']
*
* @since 100713
* @author f
*
* @param DOMDocument $param_DOMDocument
* @param string $param_objvar
* @param array $param_ValuesAttributes=array() ... attributes for the XML DOMElement
* @param string $param_ElementName='Element'
* @return DOMElement
*/
public static function getDOMElement_Element(DOMDocument $param_DOMDocument, $param_objvar, array $param_ValuesAttributes=array(), $param_ElementName=mcPUIX::DOMElement) {
$value = '';
$values_Select_List_values = null;
$values_DBUArray = null;
if(array_key_exists('value', $param_ValuesAttributes)) {
$value = $param_ValuesAttributes['value'];
unset($param_ValuesAttributes['value']);
if(mcArray::checkKeyHasFullArray($value, mcPUIX::DBUIArray, mcPUIX::DOMValues)) {
$values_DBUArray = $value;
$value = null;
}
}
if(array_key_exists('values', $param_ValuesAttributes) && is_array($param_ValuesAttributes['values'])) {
$values_Select_List_values = $param_ValuesAttributes['values'];
unset ($param_ValuesAttributes['values']);
}
if(!array_key_exists('label', $param_ValuesAttributes) || !$param_ValuesAttributes['label']) {
/**
* @todo schönheitshalber sollte Language hier raus, da es zu sehr spezifisch ist @f 100721
*/
$param_ValuesAttributes['label'] = Language::getWord($param_objvar);
}
if(!array_key_exists('objvar', $param_ValuesAttributes) || !$param_ValuesAttributes['objvar']) {
$param_ValuesAttributes['objvar'] = $param_objvar;
}
$DOMElement =$param_DOMDocument->createElement($param_ElementName);
$DOMElement->nodeValue = Converter::encodeString($value);
if(array_key_exists('type', $param_ValuesAttributes)) {
if($param_ValuesAttributes['type'] == mcPUIX::DBUIArray) {
$DOM_Reference = mcPUIX_DOM::getDOMElement_DBUIArray($param_DOMDocument, $values_DBUArray);
$DOMElement->appendChild($DOM_Reference);
} else if($param_ValuesAttributes['type'] == 'text') {
$DOMElement->nodeValue = Converter::encodeString($value);
/**
* @todo wenn als value dann alle HTML-tags rauschmeissen!!!
*/
//$param_ValuesAttributes['value'] = substr($value, 0, 508).' ...' ;
} else {
if($param_ValuesAttributes['type'] == 'url') {
$DOMElement->nodeValue = Converter::StringToUrl($value);
} else if($param_ValuesAttributes['type'] == 'time') {
if(!$value) {
$value = time();
}
$param_ValuesAttributes['day'] = date('d', $value);
$param_ValuesAttributes['month'] = date('m', $value);
$param_ValuesAttributes['year'] = date('Y', $value);
$param_ValuesAttributes['hour'] = date('G', $value);
$param_ValuesAttributes['minute'] = date('i', $value);
$param_ValuesAttributes['weekday'] = date('N', $value);
} else if($param_ValuesAttributes['type'] == 'select') {
if($values_Select_List_values) {
$DOMElement->appendChild(mcPUIX_DOM::getDOMElement_DBUIList($param_DOMDocument, $values_Select_List_values));
}
}
$param_ValuesAttributes['value'] = $value;
}
} else {
$param_ValuesAttributes['value'] = $value;
}
if(!is_null($param_ValuesAttributes)) {
// D::show($param_ValuesAttributes,$param_objvar )
if(array_key_exists('objvar', $param_ValuesAttributes)) {
$DOMElement->setAttribute('objvar', $param_ValuesAttributes['objvar']);
unset($param_ValuesAttributes['objvar']);
}
/**
* @todo hier ist bei französischen Strings ne WArnung, da kein Utf8 @f 100718
*/
foreach($param_ValuesAttributes as $PName => $PValue) {
if(is_array($PValue)) {
/**
* @todo noch mal checken was, wann hier kommt ... @f 100724
*/
// D::show($PValue, $param_objvar.' - '.$PName);
} else {
$DOMElement->setAttribute($PName, $PValue);
}
}
}
return $DOMElement;
}
}
?>
\ No newline at end of file
<?
class mcPUIX_PDO {
/**
* @param string $param_tablename
* @param array $param_ConfigArray[mcPUIX::DBUIArray][mcPUIX::DBUIConfig][$param_tablename]
* @param array $param_NewArray => $param_NewArray[mcPUIX::DBUIArray] = array()
* @return array
*/
public static function prepareArrayForDBOperation($param_tablename, array $param_ConfigArray, array $param_NewArray=null /*, array $param_OriginalArray=null*/) {
if(mcArray::checkKeyHasFullArray($param_ConfigArray, mcPUIX::DBUIArray, mcPUIX::DBUIConfig, $param_tablename)
&& mcArray::checkKeyHasFullArray($param_NewArray, mcPUIX::DBUIArray) ) {
// D::show(array($param_NewArray[mcPUIX::DBUIArray], $param_ConfigArray[mcPUIX::DBUIArray][mcPUIX::DBUIConfig][$param_tablename]), $param_tablename. ' for ');
$ConfigArray = $param_ConfigArray[mcPUIX::DBUIArray][mcPUIX::DBUIConfig][$param_tablename];
$result = array(mcPUIX::DBUIArray => array(mcPUIX::PDOToSaveValues => array($param_tablename => $result)));
$DeleteRows = $NewRows = $UpdateRows = $ErrorRows = array();
if(array_key_exists('TABLE', $ConfigArray)) {
$BoolRequired = $BoolPrimary = $BoolActiveRow = false;
if(mcArray::checkKeyHasFullArray($ConfigArray, mcPUIX::FORM_DO_ROW)) {
$BoolActiveRow = true;
}
if(array_key_exists('REQUIRED', $ConfigArray['TABLE']) && is_array($ConfigArray['TABLE']['REQUIRED'])) {
$BoolRequired = true;
}
if(array_key_exists('PRIMARY', $ConfigArray['TABLE']) && is_array($ConfigArray['TABLE']['PRIMARY'])) {
$BoolPrimary = true;
}
foreach($param_NewArray[mcPUIX::DBUIArray] as $NewKey => &$NewData) {
// D::show($NewData, $NewKey. ' for ');
if($BoolRequired === true) {
foreach($ConfigArray['TABLE']['REQUIRED'] as $RequiredKey) {
if(!array_key_exists($RequiredKey, $NewData) || !$NewData[$RequiredKey]) {
$ErrorRows[] = $param_NewArray[mcPUIX::DBUIArray][$NewKey];
unset($param_NewArray[mcPUIX::DBUIArray][$NewKey]);
break;
}
}
}
// if( 'NEW_ROW' === $NewKey) {
if($NewData[mcPUIX::FORM_DO_ROW] === mcPUIX::FORM_DO_NEW) {
$BoolErrorRow = false;
foreach($ConfigArray['TABLE']['LISTID'] as $LISTID) {
if(!array_key_exists($LISTID, $NewData)) {
$ErrorRows[] = $param_NewArray[mcPUIX::DBUIArray][$NewKey];
$BoolErrorRow = true;
break;
}
}
if($BoolErrorRow === false) {
$NewRows[] = $param_NewArray[mcPUIX::DBUIArray][$NewKey];
}
// D::show($NewData, 'NEW_ROW '.$NewKey);
}
if($BoolActiveRow === true) {
// if(!array_key_exists(mcPUIX::FORM_DO_ROW, $NewData) || !$NewData[mcPUIX::FORM_DO_ROW]) {
if($NewData[mcPUIX::FORM_DO_ROW] === mcPUIX::FORM_DO_DELETE) {
$DeleteRows[] = $param_NewArray[mcPUIX::DBUIArray][$NewKey];
unset($param_NewArray[mcPUIX::DBUIArray][$NewKey]);
// } else if(array_key_exists($NewKey, $param_NewArray[mcPUIX::DBUIArray])) {
} else if($NewData[mcPUIX::FORM_DO_ROW] === mcPUIX::FORM_DO_SAVE) {
$BoolErrorRow = false;
foreach($ConfigArray['TABLE']['PRIMARY'] as $PrimaryKey) {
if(!array_key_exists($PrimaryKey, $NewData)) {
$ErrorRows[] = $param_NewArray[mcPUIX::DBUIArray][$NewKey];
$BoolErrorRow = true;
break;
}
}
if($BoolErrorRow == false) {
$UpdateRows[] = $param_NewArray[mcPUIX::DBUIArray][$NewKey];
}
if(mcArray::checkKeyHasFullArray($NewData, mcPUIX::DBUIArray)) {
$Tablename_LIST = mcPUIX_CONFIG::getReferenceTableName($param_tablename);
/**
*
*
* QQQQQQQQQQQQQQ hier muss code hin
*/
// D::show($param_ConfigArray[mcPUIX::DBUIArray][mcPUIX::DBUIConfig][$Tablename_LIST], $Tablename_LIST.' CONFIG');
// D::show($NewData[mcPUIX::DBUIArray], '1 '.$Tablename_LIST);
// D::cf('1 '.$Tablename_LIST);
$result_List = mcPUIX_PDO::prepareArrayForDBOperation($Tablename_LIST, $param_ConfigArray, $NewData);
// D::show($result_List, '2 '.$Tablename_LIST);
// $result[mcPUIX::DBUIArray][mcPUIX::PDOToSaveValues][$Tablename_LIST] = $result_List[mcPUIX::DBUIArray][mcPUIX::PDOToSaveValues][$Tablename_LIST];
$result = array_merge_recursive ($result, $result_List);
// D::show($result_List, $Tablename_LIST. '##dddddddddddddddddddd ddddddd');
}
}
} else if($NewData[mcPUIX::FORM_DO_ROW] === mcPUIX::FORM_DO_SAVE) {
$UpdateRows[] = $param_NewArray[mcPUIX::DBUIArray][$NewKey];
// break;
}
}
}
$result[mcPUIX::DBUIArray][mcPUIX::PDOToSaveValues][$param_tablename]['DeleteRows'] = $DeleteRows;
$result[mcPUIX::DBUIArray][mcPUIX::PDOToSaveValues][$param_tablename]['UpdateRows'] = $UpdateRows;
$result[mcPUIX::DBUIArray][mcPUIX::PDOToSaveValues][$param_tablename]['ErrorRows'] = $ErrorRows;
$result[mcPUIX::DBUIArray][mcPUIX::PDOToSaveValues][$param_tablename]['NewRows'] = $NewRows;
//D::show($result, '$result');
return $result;
}
}
/**
* return loaded PDO Table as DBUIArray
*
* @param Account $param_HostAccount
* @param PDOLevel $param_iStorable
* @param string $param_tablename
* @param array $param_SelectArray
* @return array(
* mcPUIX::DBUIArray => array(
* mcPUIX::PDOValues => array(0=>val1, 1=>val2)
* )
* )
*/
public static function getTableAsDBUIArray(Account &$param_HostAccount, PDOLevel &$param_iStorable, $param_tablename, $param_SQLWhere='', $param_depth=0) {
$ConfigArray = mcPUIX_CONFIG::getTableConfig($param_tablename);
$ConfigArray = $ConfigArray[mcPUIX::DBUIArray][mcPUIX::DBUIConfig][$param_tablename];
if(mcArray::checkKeyHasFullArray($ConfigArray, 'TABLE')
&& array_key_exists('TABLENAME', $ConfigArray['TABLE']) && $ConfigArray['TABLE']['TABLENAME']
) {
$var_query = 'select * from '.$ConfigArray['TABLE']['TABLENAME'].' '.$param_SQLWhere;
// where SNIfProfileID = 0 or SNIfProfileID = :SNIfProfileID ';
// $var_bindValueArray = array(':SNIfProfileID' => $param_Object->getObjVar('Profile')->getObjVar('SNIfProfileID'), );
// D::cf(''.$var_query);
$stmt = $param_iStorable->PDO_query($var_query, $var_bindValueArray);
if($stmt){
$PDOTable = $param_iStorable->PDO_fetchAll($stmt);
if($param_depth>0) {
if(mcArray::checkKeyHasFullArray($ConfigArray['TABLE'], 'LIST_TABLE')) {
if($ConfigArray['TABLE']['LIST_TABLE']['TABLENAME'] && $ConfigArray['TABLE']['LIST_TABLE']['REFERENCE_KEY']) {
foreach($PDOTable as &$PDORow) {
if($PDORow[$ConfigArray['TABLE']['LIST_TABLE']['REFERENCE_KEY']]) {
// D::show($PDORow, '$PDORow');
// D::show($ConfigArray, '$ConfigArray');
$SQLWhere = ' where '.$ConfigArray['TABLE']['LIST_TABLE']['REFERENCE_KEY'].'='.$PDORow[$ConfigArray['TABLE']['LIST_TABLE']['REFERENCE_KEY']];
$PDOTableList = mcPUIX_PDO::getTableAsDBUIArray($param_HostAccount, $param_iStorable, $ConfigArray['TABLE']['LIST_TABLE']['TABLENAME'], $SQLWhere, $param_depth-1);
if(mcArray::checkKeyHasFullArray($PDOTableList, mcPUIX::DBUIArray, mcPUIX::PDOValues)) {
$PDORow[mcPUIX::DBUIArray] = $PDOTableList[mcPUIX::DBUIArray];
}
// D::show($PDOTableList, '$PDOTableList: '.$SQLWhere);
}
}
}
}
}
$result = array(
mcPUIX::DBUIArray => array(
mcPUIX::PDOValues => $PDOTable
)
);
// D::show($result, $var_query);
return $result;
} else {
return false;
}
}
}
public static function getDatabaseTable_where($param_PrimaryKeys, $param_PrimaryValues, &$param_query, array &$param_bindValueArray) {
$param_query .= ' where ';
foreach($param_PrimaryKeys as $Pkey => $PrimaryKey ) {
if(array_key_exists($PrimaryKey, $param_PrimaryValues)){
if($Pkey>0) {
$param_query .= ' and ';
}
$param_query .= ' '.$PrimaryKey.'=:'.$PrimaryKey.'_'.$param_PrimaryValues[$PrimaryKey];
$param_bindValueArray[':'.$PrimaryKey.'_'.$param_PrimaryValues[$PrimaryKey]] = $param_PrimaryValues[$PrimaryKey];
} else {
return Error::newError('DevError',"not enough primary values for keys ",$param_query);
}
}
return true;
}
public static function updateDatabaseTable(Account &$param_HostAccount, PDOLevel &$param_iStorable, array $param_ConfigArray, array $param_PreparedArray=null ) {
// [mcPUIX::DBUIArray][mcPUIX::PDOToSaveValues][$param_tablename]
// [mcPUIX::DBUIArray][mcPUIX::DBUIConfig][$param_tablename]
// D::show($param_PreparedArray,'##########updateDatabaseTable: $param_ConfigArray');
// D::show($param_ConfigArray, '$param_ConfigArray');
// D::show($param_PreparedArray, '$param_PreparedArray: ');
if(mcArray::checkKeyHasFullArray($param_PreparedArray, mcPUIX::DBUIArray, mcPUIX::PDOToSaveValues)) {
// D::ulli($tablename.' before');
foreach($param_PreparedArray[mcPUIX::DBUIArray][mcPUIX::PDOToSaveValues] as $tablename => $preparedArray) {
//D::show($preparedArray, '$tablename: '.$tablename);
if(mcArray::checkKeyHasFullArray($param_ConfigArray, mcPUIX::DBUIArray, mcPUIX::DBUIConfig, $tablename)) {
$ConfigArray = $param_ConfigArray[mcPUIX::DBUIArray][mcPUIX::DBUIConfig][$tablename];
// D::show(array($ConfigArray, $preparedArray), $i++.' updateDatabaseTable: '.$tablename);
$TableConfig = null;
$BoolActiveRow = false;
if(array_key_exists(mcPUIX::FORM_DO_ROW, $ConfigArray) && is_array($ConfigArray[mcPUIX::FORM_DO_ROW])) {
$BoolActiveRow = true;
}
if(array_key_exists('TABLE', $ConfigArray)
&& array_key_exists('TABLENAME', $ConfigArray['TABLE']) && $ConfigArray['TABLE']['TABLENAME']
&& array_key_exists('PRIMARY', $ConfigArray['TABLE']) && is_array($ConfigArray['TABLE']['PRIMARY'])
) {
//D::cf($tablename.' ');
$TableConfig = $ConfigArray['TABLE'];
//D::ulli($tablename. ' config');
unset($TableConfig['TABLENAME']);
/**
* delete the rows
*/
if(mcArray::checkKeyHasFullArray($preparedArray, 'DeleteRows')) {
foreach($preparedArray['DeleteRows'] as $DeleteRow) {
$var_bindValueArray = array();
$var_query = 'delete from '.$ConfigArray['TABLE']['TABLENAME'].' ' ;
if(mcPUIX_PDO::getDatabaseTable_where($TableConfig['PRIMARY'], $DeleteRow, $var_query, $var_bindValueArray)) {
//D::show($var_bindValueArray, '$var_query: '.$var_query);
$stmt = $param_iStorable->PDO_query($var_query, $var_bindValueArray);
if($stmt) {
} else {
return Error::newError('DevUser','delete Dataset Error from Table '.$ConfigArray['TABLE']['TABLENAME'].' ',$query);
}
}
}
}
/**
* update the rows
*/
if(mcArray::checkKeyHasFullArray($preparedArray, 'UpdateRows')) {
foreach($preparedArray['UpdateRows'] as $UpdateRow) {
//D::show(array($TableConfig,$UpdateRow),'UpdateRows UpdateRows');
$var_bindValueArray = array();
$var_query = 'update '.$ConfigArray['TABLE']['TABLENAME'].' set ';
$i=0;
$bool_doUpdate = false;
foreach($UpdateRow as $row_key => $row_value) {
if($row_key!==mcPUIX::FORM_DO_ROW
&& $row_key!==mcPUIX::DBUIArray
&& false===array_search($row_key, $TableConfig['PRIMARY'])) {
if($i>0) {
$var_query .= ', ';
}
$var_query .= ' '.$row_key.'=:'.$row_key.'_'.$i.'';
$var_bindValueArray[':'.$row_key.'_'.$i] = $row_value;
$i++;
$bool_doUpdate = true;
}
}
if($bool_doUpdate && mcPUIX_PDO::getDatabaseTable_where($TableConfig['PRIMARY'], $UpdateRow, $var_query, $var_bindValueArray)) {
$stmt = $param_iStorable->PDO_query($var_query, $var_bindValueArray);
if($stmt) {
} else {
return Error::newError('UserError',"Fehler beim speichern von SocialNetInterfaceAddon ",$query);
}
} else {
// return Error::newError('DevError',"not enough primary values for keys ",$query);
}
}
}
//D::show($preparedArray['NewRows'], 'NewRows1');
/**
* insert the new rows
*/
if(mcArray::checkKeyHasFullArray($preparedArray, 'NewRows')) {
//D::show($preparedArray['NewRows'], 'NewRows2');
foreach($preparedArray['NewRows'] as $NewRow) {
unset($NewRow[mcPUIX::FORM_DO_ROW]);
if($TableConfig['KINDOF'] === 'LIST') {
if($NewRow) {
// D::show($NewRow,'NewRows');
$param_iStorable->PDO_insertRow($ConfigArray['TABLE']['TABLENAME'], $ConfigArray['TABLE']['LISTID'], $ConfigArray['TABLE']['ELEMENTID'], $NewRow, true);
}
} else if($TableConfig['KINDOF'] == 'DATASET') {
D::show($preparedArray['NewRows'], 'FOR DATASET INSERT NOT IMPLEMENTED');
} else if($TableConfig['KINDOF'] === 'RELATION') {
// D::show($preparedArray['NewRows'], 'FOR RELATION INSERT NOT IMPLEMENTED');
if($NewRow) {
// D::show($NewRow,'NewRows');
$param_iStorable->PDO_insertRow($ConfigArray['TABLE']['TABLENAME'], $ConfigArray['TABLE']['LISTID'], null, $NewRow, true);
}
}
}
}
// $DataBaseArray = array_merge($preparedArray['NewRows'], $preparedArray['UpdateRows']);
// D::show($DataBaseArray);
// return $DataBaseArray;
} else {
D::show($ConfigArray['TABLE']);
return Error::newError('DevError','Table Config is wrong, missing data');
}
}
}
}
}
}
?>
\ No newline at end of file
<!--
last update 07.07.2010 @f
templates/function in this file
<xsl:template match="XMLArra" />
<xsl:template match="DBUIElement" />
-->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:php="http://php.net/xsl" >
<xsl:template match="/">
<xsl:apply-templates select="DBUIElement" />
<xsl:apply-templates select="DBUIArray" />
</xsl:template>
<xsl:template match="mcPUIX">
<xsl:param name="param_inputBE">0</xsl:param>
<xsl:apply-templates select="DBUIElement" >
<xsl:with-param name="param_inputBE" ><xsl:value-of select="$param_inputBE" /></xsl:with-param>
</xsl:apply-templates>
<xsl:apply-templates select="DBUIArray" >
<xsl:with-param name="param_inputBE" ><xsl:value-of select="$param_inputBE" /></xsl:with-param>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="DBUIArray">
<xsl:param name="param_inputBE">0</xsl:param>
<xsl:param name="param_noform">0</xsl:param>
<xsl:choose>
<xsl:when test="@edit=1 and $param_noform=0">
<div class="row"><span class="element"><xsl:value-of select="@label" /> count(<xsl:value-of select="@count" />) </span> </div>
<xsl:for-each select="DBUIRow">
<div class="row"><span class="element"><xsl:value-of select="@label" /> i(<xsl:value-of select="@i" />) </span> </div>
<xsl:apply-templates select="DBUIElement" >
<xsl:with-param name="param_inputBE" ><xsl:value-of select="$param_inputBE" />[<xsl:value-of select="@i" />]</xsl:with-param>
</xsl:apply-templates>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<!--<xsl:value-of select="count(DBUIRow[@i='NEW_ROW'])" />/<xsl:value-of select="count(DBUIRow)" />-->
<xsl:if test="count(DBUIRow[@i='NEW_ROW'])!=count(DBUIRow)">
<table border="1">
<xsl:for-each select="DBUIRow">
<xsl:choose>
<xsl:when test="position()=1">
<tr valign="top">
<xsl:for-each select="DBUIElement">
<xsl:if test="@show=1">
<td><b><xsl:value-of select="@label" /></b></td>
</xsl:if>
</xsl:for-each>
</tr>
</xsl:when>
</xsl:choose>
<xsl:choose>
<xsl:when test="@i='NEW_ROW'">
</xsl:when>
<xsl:otherwise>
<tr valign="top">
<xsl:for-each select="DBUIElement">
<xsl:choose>
<xsl:when test="@show=1">
<td>
<!-- <xsl:value-of select="position()" />-->
<xsl:apply-templates select=".">
<xsl:with-param name="param_inputBE" ><xsl:value-of select="$param_inputBE" />[<xsl:value-of select="local-name(../..)" />][<xsl:value-of select="../@i" />]</xsl:with-param>
<xsl:with-param name="param_withoutLabel" >1</xsl:with-param>
</xsl:apply-templates>
</td>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="." >
<xsl:with-param name="param_inputBE" ><xsl:value-of select="$param_inputBE" />[<xsl:value-of select="local-name(../..)" />][<xsl:value-of select="../@i" />]</xsl:with-param>
<xsl:with-param name="param_withoutLabel" >1</xsl:with-param>
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</tr>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</table>
</xsl:if>
<table border="1">
<xsl:for-each select="DBUIRow[@i='NEW_ROW']">
<xsl:choose>
<xsl:when test="position()=1">
<tr valign="top">
<xsl:for-each select="DBUIElement">
<xsl:if test="@show=1">
<td><b><xsl:value-of select="@label" /></b></td>
</xsl:if>
</xsl:for-each>
</tr>
<tr valign="top">
<xsl:for-each select="DBUIElement">
<xsl:choose>
<xsl:when test="@show=1">
<td>
<!-- <xsl:value-of select="position()" />-->
<xsl:apply-templates select=".">
<xsl:with-param name="param_inputBE" ><xsl:value-of select="$param_inputBE" />[<xsl:value-of select="local-name(../..)" />][<xsl:value-of select="../@i" />]</xsl:with-param>
<xsl:with-param name="param_withoutLabel" >1</xsl:with-param>
</xsl:apply-templates>
</td>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="." >
<xsl:with-param name="param_inputBE" ><xsl:value-of select="$param_inputBE" />[<xsl:value-of select="local-name(../..)" />][<xsl:value-of select="../@i" />]</xsl:with-param>
<xsl:with-param name="param_withoutLabel" >1</xsl:with-param>
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</tr>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</table>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="DBUIElement">
<xsl:param name="param_url">?</xsl:param>
<xsl:param name="param_only_objvar">0</xsl:param>
<xsl:param name="param_noform">0</xsl:param>
<xsl:param name="param_withoutLabel">0</xsl:param>
<xsl:param name="param_inputBE" />
<xsl:if test="(@objvar=$param_only_objvar or $param_only_objvar=0)">
<span class="{@objvar}Font">
<div class="row">
<xsl:if test="$param_withoutLabel=0">
<span class="label">
<xsl:if test="@label"><xsl:value-of select="@label" />:</xsl:if>
<xsl:text disable-output-escaping="no">&#160;</xsl:text>
</span>
</xsl:if>
<span class="element">
<xsl:choose>
<xsl:when test="@edit=1 and $param_noform=0">
<!--<xsl:variable name="var_form_name"><xsl:value-of select="@objvar" /></xsl:variable>-->
<xsl:if test="@element_classname">
<input type="hidden" name="{$param_inputBE}[element_classname]" value="{@element_classname}" />
</xsl:if>
<xsl:choose>
<xsl:when test="@fixed=1">
<input type="hidden" name="{$param_inputBE}[{@objvar}]" value="{@value}" />
<xsl:if test="@show=1"><xsl:value-of select="@value" /></xsl:if>
</xsl:when>
<xsl:when test="@type='DBUIArray'">
<xsl:apply-templates select="DBUIArray" >
<xsl:with-param name="param_inputBE" ><xsl:value-of select="$param_inputBE" /></xsl:with-param>
</xsl:apply-templates>
</xsl:when>
<xsl:when test="@type='hidden'">
<input type="hidden" name="{$param_inputBE}[{@objvar}]" value="{@value}" />
<xsl:if test="@show=1"><xsl:value-of select="@value" /></xsl:if>
</xsl:when>
<xsl:when test="@type='text'">
<textarea name="{$param_inputBE}[{@objvar}]" class="width" cols="40" rows="20">
<xsl:value-of select="." />
<xsl:text disable-output-escaping="no">&#160;</xsl:text>
</textarea>
</xsl:when>
<xsl:when test="@type='file'">
<xsl:call-template name="Function_FileUploadFormular">
<xsl:with-param name="param_inputBE" select="$param_inputBE" />
</xsl:call-template>
</xsl:when>
<xsl:when test="@type='select'">
<select name="{$param_inputBE}[{@objvar}]" size="1" class="width">
<xsl:for-each select="DBUIList/item">
<xsl:choose>
<xsl:when test="@key=../../@value">
<option value="{@key}" selected="selected"><xsl:value-of select="@value" /></option>
</xsl:when>
<xsl:otherwise>
<option value="{@key}"><xsl:value-of select="@value" /></option>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</select>
</xsl:when>
<xsl:when test="@type='password'">
<div class="row">
<span class="element">1. <input type="password" name="{$param_inputBE}[password2]" class="width" maxlength="{@form_Length}" value="{@value}" /></span>
</div>
<div class="row">
<span class="element">2. <input type="password" name="{$param_inputBE}[password1]" class="width" maxlength="{@form_Length}" value="{@value}" /></span>
</div>
</xsl:when>
<xsl:when test="@type='time'">
<xsl:call-template name="Function_TimeFormular">
<xsl:with-param name="param_prefix"><xsl:value-of select="@objvar" />_</xsl:with-param>
<xsl:with-param name="param_time"><xsl:value-of select="End" /></xsl:with-param>
<xsl:with-param name="param_inputBE" select="$param_inputBE" />
</xsl:call-template>
</xsl:when>
<xsl:when test="@type='checkbox'">
<xsl:choose>
<xsl:when test="@value=1">
<input type="checkbox" name="{$param_inputBE}[{@objvar}]" value="1" checked="checked" />
</xsl:when>
<xsl:otherwise>
<input type="checkbox" name="{$param_inputBE}[{@objvar}]" />
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="var_maxlength"><xsl:value-of select="@maxlength" /></xsl:variable>
<input name="{$param_inputBE}[{@objvar}]" class="width" type="text" size="{@size}" maxlength="{@maxlength}" value="{@value}" />
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="@show=1">
<xsl:choose>
<xsl:when test="@objvar='EMail'">
<!--<xsl:variable name="EMail"><xsl:value-of select="@value" /></xsl:variable>-->
<span class="LinkFont">
<a href="mailto:{@value}"><xsl:value-of select="@value" /><xsl:text disable-output-escaping="no">&#160;</xsl:text></a>
</span>
</xsl:when>
<xsl:when test="@type='text'">
<xsl:value-of select="." disable-output-escaping="yes"/>
</xsl:when>
<xsl:when test="@type='FORM_TYPE_SEOLINK'">
<a href="{@value}">SEOL</a>
</xsl:when>
<xsl:when test="@ID">
<a href="{$param_url}"><xsl:value-of select="@value" /><xsl:text disable-output-escaping="no">&#160;</xsl:text></a>
</xsl:when>
<xsl:when test="@type='DBUIArray'">
<xsl:apply-templates select="DBUIArray" >
<xsl:with-param name="param_inputBE" ><xsl:value-of select="$param_inputBE" /></xsl:with-param>
</xsl:apply-templates>
</xsl:when>
<xsl:when test="@type='time'">
<xsl:variable name="var_var"><xsl:value-of select="@value" /></xsl:variable>
<xsl:value-of select="php:function('date', 'j.n.Y H:i', string($var_var) )" />
</xsl:when>
<xsl:when test="@type='url'">
<a href="{@value}"><xsl:value-of select="@value" /></a>
</xsl:when>
<xsl:when test="@type='file'">
<!--<xsl:variable name="var_var"><xsl:value-of select="@value" /></xsl:variable>-->
<xsl:variable name="var_imgname"><xsl:value-of select="DBUIElement" /></xsl:variable>
<xsl:variable name="var_varfile"><xsl:value-of select="." /></xsl:variable>
<xsl:choose>
<xsl:when test="../DBUIElement[@objvar='Mime'] = 'image'">
<img src="files/{$var_var}" height="200" title="{$var_imgname}"/>
</xsl:when>
<xsl:otherwise>
<a href="file.php?p[0]={@value}"> <xsl:value-of select="@value" /></a>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise><xsl:value-of select="@value" disable-output-escaping="yes"/></xsl:otherwise>
</xsl:choose>
</xsl:when>
</xsl:choose>
</span>
</div>
</span>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
<?php
require_once 'basepath.inc.php';
require_once $__BASEPATH_EX.'include/config.php';
/**
* Language
*/
require_once $__BASEPATH_EX.'include/Forest/mensch.coop/php/class_Language.mensch.coop.inc.php';
require_once $__BASEPATH_EX.'include/System/php/class_Language.inc.php';
require_once $__BASEPATH_EX.'include/System/php/class_CONSTKindOf.inc.php';
/**
* Converter
*/
require_once $__BASEPATH_EX . 'include/Lib/Tools/mcClasses/mcPUIX/class_Converter.inc.php';
require_once $__BASEPATH_EX.'include/Lib/Tools/mcClasses/mcPUIX/class_mcPUIX_DOM.inc.php';
$_PHPUNIT_mcPUIX_DOMTest_XSD = $__BASEPATH_EX . 'include/Lib/Tools/mcClasses/mcPUIX/Element.xsd';
$_PHPUNIT_mcPUIX_DOMTest_XSL = $__BASEPATH_EX . 'include/Lib/Tools/mcClasses/mcPUIX/mcPUIX.xsl';
/**
* Test class for mcPUIX_DOM.
* Generated by PHPUnit on 2010-07-13 at 14:12:14.
*/
class mcPUIX_DOMTest extends PHPUnit_Framework_TestCase {
protected $stylesheet;
protected $processor;
protected function setUp() {
global $_PHPUNIT_mcPUIX_DOMTest_XSL;
$this->stylesheet = new DOMDocument;
$this->stylesheet->load($_PHPUNIT_mcPUIX_DOMTest_XSL);
$this->processor = new XSLTProcessor;
$this->processor->importStylesheet($this->stylesheet);
}
protected function tearDown() {
}
private function checkXML(DOMDocument $param_DOMDocument) {
$DOMHtml = new DOMDocument;
$this->assertTrue($DOMHtml->loadHTML($this->processor->transformToDoc($param_DOMDocument)->saveXML()), 'validate DOMElement with xsd');
return $DOMHtml;
}
private function checkXMLString(DOMDocument $param_DOMDocument, array $param_SearchStringArray, $param_SearchStringDirection=false) {
$this->checkXML($param_DOMDocument);
$HTMLString = $this->processor->transformToDoc($param_DOMDocument)->saveXML();
foreach($param_SearchStringArray as $TagName) {
$this->assertTrue(substr_count($HTMLString, $TagName)>0, 'found string('.$TagName.')');
// $this->assertTrue(substr_count($HTMLString, $TagName.'l')>0, 'found string('.$TagName.')');
if($param_SearchStringDirection) {
$HTMLString = strstr($HTMLString, $TagName);
}
}
return $HTMLString;
}
private function checkGetDOMElement_Element(array $param_OptionalAttributes=array(), array $param_SearchStringArray=array()) {
global $_LOSP_CHARSET;
global $_PHPUNIT_mcPUIX_DOMTest_XSD;
$DOMDocument = new DOMDocument('1.0', $_LOSP_CHARSET);
$DOMDocument->appendChild(mcPUIX_DOM::getDOMElement_Element($DOMDocument, 'objvar', $param_OptionalAttributes));
echo "\n".$DOMDocument->saveXML()."\n";
$this->assertTrue($DOMDocument->schemaValidate($_PHPUNIT_mcPUIX_DOMTest_XSD), 'validate DOMElement with xsd');
$this->checkXMLString($DOMDocument, $param_SearchStringArray, true);
}
private function checkGetDOMElement_DBUIArray(array $param_Array, array $param_SearchStringArray=array()) {
global $_LOSP_CHARSET;
global $_PHPUNIT_mcPUIX_DOMTest_XSD;
$DOMDocument = new DOMDocument('1.0', $_LOSP_CHARSET);
$DOMDocument->appendChild(mcPUIX_DOM::getDOMElement_DBUIArray($DOMDocument, $param_Array));
$this->assertTrue($DOMDocument->schemaValidate($_PHPUNIT_mcPUIX_DOMTest_XSD), 'validate DOMElement with xsd');
}
public function testGetDOMElement_Element() {
/**
* test default
*/
// $this->checkGetDOMElement_Element();
/**
* test as text
*/
$var_OptionalAttributes = array(
'type' => 'text',
'show' => true,
'edit' => true
);
$this->checkGetDOMElement_Element($var_OptionalAttributes, array('textarea'));
/**
* teset as select
*/
$var_OptionalAttributes = array(
'type' => 'select',
'show' => true,
'edit' => true,
'value' => '1',
'values' => array('1' => 'eins', '2' => 'zwei')
);
// $this->checkGetDOMElement_Element($var_OptionalAttributes, array('select', 'option'));
}
public function testGetDOMElement_DBUIArray() {
$array = array(
array(
'INT' => array('type'=> 'int', 'show'=> true, 'value' => 1),
'KEY' => array('show'=> true, 'value' => 'key'),
'TEXT' => array('type'=> 'text', 'show'=> true, 'value' => 1, 'edit' => true),
'SELECT'=> array('type'=> 'select', 'show'=> true, 'value' => '', 'values' => array('select1', 'select2'), 'edit' => true),
),
array(
'ID' => array('type'=> 'int', 'show'=> true, 'value' => 1),
'Key' => array('show'=> true, 'value' => 'key'),
'value' => array('type'=> 'text', 'show'=> true, 'value' => 1),
'select'=> array('type'=> 'select', 'show'=> true, 'values' => array('select1', 'select2')),
),
array(
'ID' => array('type'=>'int', 'show'=> true, 'value' => 1),
'Key' => array('show'=>true, 'value'=>'key'),
'value' => array('type'=>'text', 'show'=>true, 'value'=>1, 'edit'=>true, 'fixed'=>true),
'select'=> array('type'=>'select', 'show'=> true, 'values' => array('select1', 'select2'), 'value' => 1),
)
);
// $this->checkGetDOMElement_DBUIArray($array, array('<option value="1" selected="selected">', '</textarea>', '</select>', '</option>'));
}
}
?>
\ No newline at end of file
<?php
require_once 'PHPUnit/Framework.php';
require_once dirname(__FILE__) . '/../../../../../../include/Lib/Tools/mcClasses/mcPUIX/class_mcPUIX_PDO.inc.php';
/**
* Test class for mcPUIX_PDO.
* Generated by PHPUnit on 2010-07-13 at 14:12:11.
*/
class mcPUIX_PDOTest extends PHPUnit_Framework_TestCase {
/**
* @var mcPUIX_PDO
*/
protected $object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp() {
$this->object = new mcPUIX_PDO;
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
protected function tearDown() {
}
}
?>
\ No newline at end of file
<?php
//require_once 'PHPUnit/Framework.php';
require_once 'basepath.inc.php';
require_once $__BASEPATH_EX . 'include/config.php';
require_once $__BASEPATH_EX . 'include/Lib/Tools/mcClasses/mcPUIX/class_mcPUIX_PHP.inc.php';
/**
* Test class for mcPUIX_PHP.
* Generated by PHPUnit on 2010-07-13 at 14:12:12.
*/
class mcPUIX_PHPTest extends PHPUnit_Framework_TestCase {
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp() {
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
protected function tearDown() {
}
public function testPrepareArrayForDOMElement() {
$ValueArray = array(
mcPUIX::DBUIArray => array(
array( 'key1' => 'value11',
'key2' => 'value12',
'key3' => 'value13',
'key4' => 'value14',
),
array( 'key1' => 'value21',
'key2' => 'value22',
'key3' => 'value23',
'key4' => 'value24',
),
)
);
$ConfigArray = array(
'key1' => array('edit'=>true, 'show'=>true, 'type'=>'text'),
'key2' => array('edit'=>true, 'show'=>false, 'type'=>'text'),
'key3' => array('edit'=>true, 'show'=>true, 'type'=>'text'),
'key4' => array('edit'=>false, 'show'=>true, 'type'=>'text'),
);
/**
* default case
*/
$result = mcPUIX_DOM::prepareArrayForDOMElement($ConfigArray, $ValueArray);
$HaveToResult = array(
array(
'key1' => array('edit'=>true, 'show'=>true, 'type'=>'text', 'value'=>'value11'),
'key2' => array('edit'=>true, 'show'=>false, 'type'=>'text', 'value'=>'value12'),
'key3' => array('edit'=>true, 'show'=>true, 'type'=>'text', 'value'=>'value13'),
'key4' => array('edit'=>false, 'show'=>true, 'type'=>'text', 'value'=>'value14'),
),
array(
'key1' => array('edit'=>true, 'show'=>true, 'type'=>'text', 'value'=>'value21'),
'key2' => array('edit'=>true, 'show'=>false, 'type'=>'text', 'value'=>'value22'),
'key3' => array('edit'=>true, 'show'=>true, 'type'=>'text', 'value'=>'value23'),
'key4' => array('edit'=>false, 'show'=>true, 'type'=>'text', 'value'=>'value24'),
),
);
$this->checkArrayDiff($result, $HaveToResult);
/**
* case but more $param_ConfigArray then $param_ValueArray
*/
$ConfigArray['key5'] = array('edit'=>false, 'show'=>true, 'type'=>'checkbox');
$HaveToResult[0]['key5']= array('edit'=>false, 'show'=>true, 'type'=>'checkbox');
$HaveToResult[1]['key5']= array('edit'=>false, 'show'=>true, 'type'=>'checkbox');
$result = mcPUIX_DOM::prepareArrayForDOMElement($ConfigArray,$ValueArray);
$this->checkArrayDiff($result, $HaveToResult);
unset($ConfigArray['key5']);
unset($HaveToResult[0]['key5']);
unset($HaveToResult[1]['key5']);
/**
* default case with $param_SetDefault
*/
$SetDefault = array(
'*' => array('type' => 'checkbox',)
);
$result = mcPUIX_DOM::prepareArrayForDOMElement($ConfigArray, $ValueArray, $SetDefault);
$HaveToResult = array(
array(
'key1' => array('edit'=>true, 'show'=>true, 'type'=>'checkbox', 'value'=>'value11'),
'key2' => array('edit'=>true, 'show'=>false, 'type'=>'checkbox', 'value'=>'value12'),
'key3' => array('edit'=>true, 'show'=>true, 'type'=>'checkbox', 'value'=>'value13'),
'key4' => array('edit'=>false, 'show'=>true, 'type'=>'checkbox', 'value'=>'value14'),
),
array(
'key1' => array('edit'=>true, 'show'=>true, 'type'=>'checkbox', 'value'=>'value21'),
'key2' => array('edit'=>true, 'show'=>false, 'type'=>'checkbox', 'value'=>'value22'),
'key3' => array('edit'=>true, 'show'=>true, 'type'=>'checkbox', 'value'=>'value23'),
'key4' => array('edit'=>false, 'show'=>true, 'type'=>'checkbox', 'value'=>'value24'),
),
);
$this->checkArrayDiff($result, $HaveToResult);
}
public function testPrepareArrayForDBOperation() {
$ConfigArray = array(
'TABLE' => array(
'PRIMARY' => array('Primary1ID', 'Primary2ID'),
'REQUIRED' => array('Required1', 'Required2'),
),
mcPUIX::FORM_DO_ROW => array(),
'Key1' => array(),
'Key2' => array(),
);
/**
* nothing new
*/
$NewArray = array();
$result = mcPUIX_PDO::prepareArrayForDBOperation($ConfigArray, $NewArray);
$HaveToResult = array(
'UpdateRows' => array(
),
'DeleteRows' => array(
),
'ErrorRows' => array(
),
'NewRows' => array(
),
);
$this->checkArrayDiff($result, $HaveToResult);
/**
*
*/
$NewArray = array(
// UpdateRows
0 => array(
mcPUIX::FORM_DO_ROW => 1,
'Key1' => 'value',
'Key2' => '',
'Primary1ID' => 1,
'Primary2ID' => 2,
'Required1' => 'require',
'Required2' => 'require',
),
// DeleteRows
1 => array(
mcPUIX::FORM_DO_ROW => false, // !!!
'Key1' => 'value',
'Key2' => '',
'Primary1ID' => 1,
'Primary2ID' => 2,
'Required1' => 'require',
'Required2' => 'require',
),
// ErrorRows
2 => array(
mcPUIX::FORM_DO_ROW => 1,
'Key1' => 'value',
'Key2' => '',
'Primary1ID' => 1,
'Primary2ID' => 2,
'Required1' => 'require',
'Required2' => false, // !!!
),
// NewRows
3 => array(
mcPUIX::FORM_DO_ROW => 1,
'Key1' => 'value',
'Key2' => '',
'Primary1ID' => 0, // !!!
'Primary2ID' => 0, // !!!
'Required1' => 'require',
'Required2' => 'require',
),
);
$result = mcPUIX_PDO::prepareArrayForDBOperation($ConfigArray, $NewArray);
$HaveToResult = array(
'UpdateRows' => array(
$NewArray[0]
),
'DeleteRows' => array(
$NewArray[1]
),
'ErrorRows' => array(
$NewArray[2]
),
'NewRows' => array(
$NewArray[3]
),
);
$this->checkArrayDiff($result, $HaveToResult);
}
/**
* check arrays rekursiv until the 3. level
*
* @param array $param_array1
* @param array $param_array2
*/
private function checkArrayDiff(array $param_array1, array $param_array2) {
$diff = array_diff_assoc ($param_array1, $param_array2);
$this->assertTrue(empty($diff), 'validate DOMElement with xsd');
foreach($param_array1 as $key_1 => $value_1) {
$diff_1 = array_diff_assoc ($value_1, $param_array2[$key_1]);
$this->assertTrue(empty($diff_1), 'validate DOMElement with xsd');
$this->assertTrue((count($value_1) == count($param_array2[$key_1])), 'count');
foreach($value_1 as $key_2 => $value_2 ) {
$diff_2 = array_diff_assoc ($value_2, $param_array2[$key_1][$key_2]);
$this->assertTrue(empty($diff_2), 'validate DOMElement with xsd');
$this->assertTrue(count($value_2) == count($param_array2[$key_1][$key_2]), 'count');
}
}
}
}
?>
\ No newline at end of file
<?php
/**
* @var link to the basic path from the basic dir
*/
$__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/';
?>
\ 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!