Einchecken des OnlineStands
This commit is contained in:
468
.classes/generic/renderClass.php
Normal file
468
.classes/generic/renderClass.php
Normal file
@@ -0,0 +1,468 @@
|
||||
<?php
|
||||
|
||||
require_once ( 'renderClass_abstract.php' );
|
||||
require_once ( 'renderFormClass.php' );
|
||||
require_once ( 'renderFunctionsClass.php' );
|
||||
require_once ( 'renderImageClass.php' );
|
||||
require_once ( 'renderNavigationClass.php' );
|
||||
require_once ( 'renderPopupClass.php' );
|
||||
require_once ( 'renderSpecialContentClass.php' );
|
||||
require_once ( 'renderWidgetClass.php' );
|
||||
|
||||
class renderClass extends renderClass_abstract
|
||||
{
|
||||
private $_editable = false;
|
||||
private $_tplElements = array ( );
|
||||
private $_data = array ( );
|
||||
private $_db = null;
|
||||
private $_html = null;
|
||||
|
||||
public $_renderSearch = array ( "\r\n" , "\n" , "\r" , "\t" );
|
||||
public $_renderReplace = '';
|
||||
|
||||
public $_pathTpl = PATH_PORTAL_TPL;
|
||||
public $_config = array ( );
|
||||
public $_layout = '';
|
||||
public $_template = '';
|
||||
public $_langArray = array ( );
|
||||
public $_textsFromConfig = true;
|
||||
public $_navpath = array ( );
|
||||
public $_postData = null;
|
||||
public $_errors = null;
|
||||
public $_tpl = null;
|
||||
public $_subTemplate = '';
|
||||
public $_siteId = '';
|
||||
public $_dataParameter = array ( );
|
||||
public $_website = array ( );
|
||||
public $_webkey = 0;
|
||||
public $_modrewrite = false;
|
||||
public $_specialSite = false;
|
||||
|
||||
public function setPathTpl ( $pathTpl )
|
||||
{
|
||||
$this -> _pathTpl = $pathTpl;
|
||||
}
|
||||
|
||||
public function setConfig ( $config )
|
||||
{
|
||||
$this -> _config = $config;
|
||||
if ( isset ( $this -> _config[ 'portal' ][ 'website' ] ) )
|
||||
{
|
||||
$this -> setWebsite ( $this -> _config[ 'portal' ][ 'website' ] );
|
||||
}
|
||||
}
|
||||
|
||||
public function setLayout ( $layout )
|
||||
{
|
||||
$this -> _layout = $layout;
|
||||
}
|
||||
|
||||
public function setTemplate ( $template )
|
||||
{
|
||||
$this -> _template = $template;
|
||||
}
|
||||
|
||||
public function setEditable ( $editable )
|
||||
{
|
||||
$this -> _editable = $editable;
|
||||
}
|
||||
|
||||
public function setSubTemplate ( $subtemplate )
|
||||
{
|
||||
$this -> _subTemplate = $subtemplate;
|
||||
}
|
||||
|
||||
public function setTplElements ( $tplElements )
|
||||
{
|
||||
$this -> _tplElements = $tplElements;
|
||||
}
|
||||
|
||||
public function setSiteId ( $siteId )
|
||||
{
|
||||
$this -> _siteId = $siteId;
|
||||
}
|
||||
|
||||
public function setDataParameter ( $dataParameter )
|
||||
{
|
||||
$this -> _dataParameter = $dataParameter;
|
||||
}
|
||||
|
||||
public function setLang ( $langArray )
|
||||
{
|
||||
$this -> _langArray = $langArray;
|
||||
}
|
||||
|
||||
public function setTextsFromConfig ( $fromConfig )
|
||||
{
|
||||
$this -> _textsFromConfig = $fromConfig;
|
||||
}
|
||||
|
||||
public function setWebkey ( $_webkey )
|
||||
{
|
||||
$this -> _webkey = $_webkey;
|
||||
}
|
||||
|
||||
private function setWebsite ( $website )
|
||||
{
|
||||
$return_array = array ( );
|
||||
$tmp_array = array_flip ( $website[ 'navId' ] );
|
||||
foreach ( $tmp_array as $key => $value )
|
||||
{
|
||||
foreach ( $website as $tmp_key => $tmp_value )
|
||||
{
|
||||
$return_array[ $key ][ $tmp_key ] = $website[ $tmp_key ][ $value ];
|
||||
}
|
||||
}
|
||||
$this -> _website = $return_array;
|
||||
}
|
||||
|
||||
public function setData ( $data )
|
||||
{
|
||||
$this -> _data = $data;
|
||||
}
|
||||
|
||||
public function setNavpath ( $navpath )
|
||||
{
|
||||
$this -> _navpath = $navpath;
|
||||
}
|
||||
|
||||
public function setDb ( $db )
|
||||
{
|
||||
$this -> _db = $db;
|
||||
}
|
||||
|
||||
public function setErrors ( $errors )
|
||||
{
|
||||
$this -> _errors = $errors;
|
||||
}
|
||||
|
||||
public function setPostData ( $postData )
|
||||
{
|
||||
$this -> _postData = $postData;
|
||||
}
|
||||
|
||||
public function setSpecialSite ( $specialSite )
|
||||
{
|
||||
$this -> _specialSite = $specialSite;
|
||||
}
|
||||
|
||||
public function output ( )
|
||||
{
|
||||
$html = $this -> readTemplate ( );
|
||||
echo $html -> saveHTML ( );
|
||||
}
|
||||
|
||||
public function applySortRules ( $tpl , $node , $xpath )
|
||||
{
|
||||
$elements = $xpath -> query ( ".//*[@data-sortable]" , $node );
|
||||
foreach ( $elements as $sortNode )
|
||||
{
|
||||
$sortImg = $tpl -> createElement ( 'img' );
|
||||
$sortText = $sortNode -> firstChild;
|
||||
$href = $this -> _postData;
|
||||
if ( $sortNode -> getAttribute ( 'data-sortable' ) === $this -> _postData[ 'orderBy' ] )
|
||||
{
|
||||
if ( $this -> _postData[ 'orderDir' ] === 'ASC' )
|
||||
{
|
||||
$sortImg -> setAttributeNode ( new DOMAttr ( 'src' , PATH_IMG . 'icon-sortup.png' ) );
|
||||
$href[ 'orderDir' ] = 'DESC';
|
||||
}
|
||||
else
|
||||
{
|
||||
$sortImg -> setAttributeNode ( new DOMAttr ( 'src' , PATH_IMG . 'icon-sortdown.png' ) );
|
||||
$href[ 'orderDir' ] = 'ASC';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$sortImg -> setAttributeNode ( new DOMAttr ( 'src' , PATH_IMG . 'icon-sortwo.png' ) );
|
||||
$href[ 'orderBy' ] = $sortNode -> getAttribute ( 'data-sortable' );
|
||||
}
|
||||
|
||||
$newLink = '';
|
||||
foreach ( $href as $key => $value )
|
||||
{
|
||||
$newLink .= '&' . $key . '=' . $value;
|
||||
}
|
||||
|
||||
$sortNode -> setAttribute ( 'href' , $sortNode -> getAttribute ( 'href' ) . '?' . substr ( $newLink , 1 ) );
|
||||
$sortNode -> replaceChild ( $sortImg , $sortText );
|
||||
$sortNode -> appendChild ( new DOMText ( $sortText -> nodeValue ) );
|
||||
}
|
||||
}
|
||||
|
||||
public function applyFunction ( $name , $data , $tpl , $node , $prefix )
|
||||
{
|
||||
switch ( $name )
|
||||
{
|
||||
case 'createNavigationRights' :
|
||||
$rights = renderFunctionsClass :: createNavigationRights ( $data , $tpl , $node );
|
||||
break;
|
||||
default :
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private function readTemplate ( )
|
||||
{
|
||||
$html = file_get_contents ( $this -> _pathTpl . $this -> _layout . '/tpl_' . $this -> _template . '.php' );
|
||||
$html = str_replace ( $this -> _renderSearch , $this -> _renderReplace , $html );
|
||||
$html = str_replace ( array ( 'PHP_ROOT_PATH/' , 'PHP_SITE_PATH/' ) , array ( PATH_ROOT , PATH_SITE ) , $html );
|
||||
$tpl = new DOMDocument ( );
|
||||
$tpl -> preserveWhitespace = false;
|
||||
$tpl -> formatOutput = false;
|
||||
$tpl -> loadHTML ( $html );
|
||||
$this -> _tpl = $tpl;
|
||||
|
||||
if ( $this -> _template === 'portal' )
|
||||
{
|
||||
if ( ! isset ( $this -> _data [ 'keyvisual' ] ) )
|
||||
{
|
||||
if ( file_exists ( PATH_IMG . $this -> _layout . '/keyvisual_' . $this -> _siteId . '.jpg' ) )
|
||||
{
|
||||
$this -> _data[ 'keyvisual' ][ ] = array ( 'id' => $this -> _siteId , 'path' => PATH_IMG . $this -> _layout . '/' , 'navId' => '' , 'src' => 'keyvisual_' . $this -> _siteId . '.jpg' , 'title' => null );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this -> _data[ 'keyvisual' ][ ] = array ( 'id' => 0 , 'path' => PATH_IMG . $this -> _layout . '/' , 'navId' => '' , 'src' => 'keyvisual_0.jpg', 'title' => null );
|
||||
}
|
||||
}
|
||||
|
||||
$this -> _data [ 'headline_main' ] = $this -> _langArray [ 'portal' ][ 'headline_main' ];
|
||||
$this -> _data [ 'headline_site' ] = $this -> _langArray [ 'headline' ][ $this -> _siteId ];
|
||||
}
|
||||
|
||||
foreach ( $this -> _data as $id => $content )
|
||||
{
|
||||
$tmp_content = null;
|
||||
switch ( $id )
|
||||
{
|
||||
case 'headline_main' :
|
||||
$tmp_content = $this -> _tpl -> createDocumentFragment ( );
|
||||
$tmp_content -> appendChild ( new DOMText ( $content ) );
|
||||
break;
|
||||
|
||||
case 'headline_site' :
|
||||
$tmp_content = $this -> _tpl -> createDocumentFragment ( );
|
||||
|
||||
foreach ( $content as $arrHeadline )
|
||||
{
|
||||
$headline = $this -> _tpl -> createElement ( 'h1' );
|
||||
$headline -> setAttributeNode ( new DOMAttr ( 'class' , $arrHeadline[ 1 ] ) );
|
||||
$headline -> appendChild ( new DOMText ( $arrHeadline[ 0 ] ) );
|
||||
$tmp_content -> appendChild ( $headline );
|
||||
}
|
||||
break;
|
||||
|
||||
case 'sub_content' :
|
||||
$tmp_content = renderPopupClass :: createPopup ( $content );
|
||||
break;
|
||||
|
||||
case 'content' :
|
||||
case 'login' :
|
||||
$tmp_content = ( is_null ( $content[ 'siteContents' ] ) )
|
||||
? null
|
||||
: $this -> getPageContents ( $content[ 'siteContents' ] );
|
||||
break;
|
||||
|
||||
case 'keyvisual' :
|
||||
$tmp_content = $this -> _tpl -> createDocumentFragment( );
|
||||
foreach ( $content as $img_data )
|
||||
{
|
||||
$tmp_content -> appendChild ( renderImageClass :: createImage ( $img_data , false , $id ) );
|
||||
}
|
||||
break;
|
||||
|
||||
case 'navi_main' :
|
||||
case 'navi_special' :
|
||||
case 'navi_sub' :
|
||||
case 'navi_last' :
|
||||
$tmp_content = renderNavigationClass :: createNavigation ( $content );
|
||||
break;
|
||||
|
||||
case 'spielbericht_gespielt' :
|
||||
case 'spielbericht_abgesagt' :
|
||||
case 'spielbericht_pokal' :
|
||||
case 'spielbericht_spielfrei' :
|
||||
case 'uebersicht' :
|
||||
$tmp_content = renderSpecialContentClass :: createSpecialContent ( $id , $content , ( ( $id === 'uebersicht' ) ? 'spielbericht_gespielt' : $id ) );
|
||||
break;
|
||||
|
||||
case 'widget' :
|
||||
$tmp_content = renderWidgetClass :: createWidget ( $content );
|
||||
break;
|
||||
|
||||
default :
|
||||
break;
|
||||
}
|
||||
|
||||
if ( ! is_null ( $tmp_content ) )
|
||||
{
|
||||
if ( in_array ( $id , array ( 'uebersicht' , 'spielbericht' , 'spielbericht_gespielt' , 'spielbericht_abgesagt' , 'spielbericht_pokal' , 'spielbericht_spielfrei' , 'widget' ) ) )
|
||||
{
|
||||
$node = $tpl -> getElementById ( 'content' );
|
||||
}
|
||||
else if ( in_array ( $id , array ( 'keyvisual' ) ) )
|
||||
{
|
||||
$node = $tpl -> getElementById ( $id );
|
||||
$node -> setAttributeNode ( new DOMAttr ( 'data-editable' , $id ) );
|
||||
$node -> setAttributeNode ( new DOMAttr ( 'id' , $id . '_' . $content[ 0 ][ 'id' ] ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$node = $tpl -> getElementById ( $id );
|
||||
}
|
||||
$node -> appendChild ( $tmp_content );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $this -> _editable === true )
|
||||
{
|
||||
/* Editor Layer einbinden */
|
||||
$html = file_get_contents ( $this -> _pathTpl . $this -> _layout . '/tpl_editor.php' );
|
||||
$html = str_replace ( $this -> _renderSearch , $this -> _renderReplace , $html );
|
||||
$html = str_replace ( array ( 'PHP_ROOT_PATH/' , 'PHP_SITE_PATH' ) , array ( PATH_ROOT , PATH_SITE ) , $html );
|
||||
$editor = new DOMDocument ( );
|
||||
$editor -> preserveWhitespace = false;
|
||||
$editor -> formatOutput = false;
|
||||
$editor -> loadHTML ( $html );
|
||||
$eCont = $editor -> getElementById ( 'editor_layer' );
|
||||
$new_node = $tpl -> importNode ( $eCont , true );
|
||||
$body = $tpl -> getElementsByTagName( 'body' ) -> item( 0 );
|
||||
$body -> insertBefore ( $new_node , $body -> firstChild );
|
||||
|
||||
/* Editor Elemente einbinden - Nur für Standardseiten */
|
||||
if ( ! $this -> _specialSite )
|
||||
{
|
||||
$html = file_get_contents ( $this -> _pathTpl . $this -> _layout . '/tpl_elements.php' );
|
||||
$html = str_replace ( $this -> _renderSearch , $this -> _renderReplace , $html );
|
||||
$html = str_replace ( array ( 'PHP_ROOT_PATH/' , 'PHP_SITE_PATH' ) , array ( PATH_ROOT , PATH_SITE ) , $html );
|
||||
$elements = new DOMDocument ( );
|
||||
$elements -> preserveWhitespace = false;
|
||||
$elements -> formatOutput = false;
|
||||
$elements -> loadHTML ( $html );
|
||||
$eCont = $elements -> getElementById ( 'editor_elements' );
|
||||
$eCont = $tpl -> importNode ( $eCont , true );
|
||||
$elemCont = $tpl -> getElementById ( 'element_content' );
|
||||
foreach ( $this -> _website[ $this -> _webkey ][ 'contentElems' ] as $subTpl )
|
||||
{
|
||||
$node = renderSpecialContentClass :: createSpecialContent ( $subTpl , array ( 0 => array ( 'content' => 'text' ) ) , null );
|
||||
$node -> setAttribute( 'class' , $node -> getAttribute( 'class' ) . ' elem_button' );
|
||||
$node -> setAttributeNode ( new DOMAttr ( 'data-editable' , $subTpl ) );
|
||||
$new_node = $tpl -> importNode ( $node , true );
|
||||
$elemCont -> appendChild ( $new_node );
|
||||
}
|
||||
$body = $tpl -> getElementsByTagName( 'body' ) -> item( 0 );
|
||||
$body -> insertBefore ( $eCont , $body -> firstChild );
|
||||
}
|
||||
|
||||
$head = $tpl -> getElementsByTagName( 'head' ) -> item( 0 );
|
||||
|
||||
/* Editor CSS ( lokal ) einbinden */
|
||||
$css = $this -> _tpl -> createElement ( 'link' );
|
||||
$css -> setAttributeNode ( new DOMAttr ( 'href' , PATH_CSS . $this -> _layout . '_editor.css' ) );
|
||||
$css -> setAttributeNode ( new DOMAttr ( 'type' , 'text/css' ) );
|
||||
$css -> setAttributeNode ( new DOMAttr ( 'rel' , 'stylesheet' ) );
|
||||
$head -> appendChild ( $css );
|
||||
|
||||
/* Editor JS - Variablen einbinden */
|
||||
$data = 'var userId = "' . $_SESSION[ 'sess_userId' ] . '";' . "\n";
|
||||
$data .= 'var sessLang = "' . $_SESSION[ 'sess_loginLang' ] . '";' . "\n";
|
||||
$data .= 'var navigationId = "' . $this -> _siteId . '";' . "\n";
|
||||
$data .= 'var pathMed = "' . PATH_MED . '";' . "\n";
|
||||
$data .= 'var stdKeyvisual = "' . PATH_MED . $this -> _website[ $this -> _webkey ][ 'prefix' ] . '/sample_keyvis.jpg";' . "\n";
|
||||
$data .= 'var stdImage = "' . PATH_MED . $this -> _website[ $this -> _webkey ][ 'prefix' ] . '/sample_image.jpg";' . "\n";
|
||||
|
||||
foreach ( $this -> _website[ $this -> _webkey ] as $var => $value )
|
||||
{
|
||||
if ( is_array( $value ) )
|
||||
{
|
||||
$data .= 'var ' . $var . ' = ' . json_encode ( $value ) . ';' . "\n";
|
||||
continue;
|
||||
}
|
||||
$data .= 'var ' . $var . ' = "' . $value . '";' . "\n";
|
||||
}
|
||||
|
||||
$data .= ( $this -> _specialSite )
|
||||
? 'var specialSite = true;'
|
||||
: 'var specialSite = false;';
|
||||
|
||||
$js = $this -> _tpl -> createElement ( 'script' );
|
||||
$js -> setAttributeNode ( new DOMAttr ( 'type' , 'text/javascript' ) );
|
||||
$js -> appendChild ( new DOMCdataSection ( utf8_encode ( $data ) ) );
|
||||
$head -> appendChild ( $js );
|
||||
|
||||
/* Editor Sprachdatei ( remote ) einbinden */
|
||||
$js = $this -> _tpl -> createElement ( 'script' );
|
||||
$js -> setAttributeNode ( new DOMAttr ( 'type' , 'text/javascript' ) );
|
||||
$js -> setAttributeNode ( new DOMAttr ( 'src' , $this -> _website[ $this -> _webkey ][ 'editorUrl' ] . 'v' . $this -> _website[ $this -> _webkey ][ 'editorVersion' ] . '/js/lang.js.php?lang=' . $_SESSION[ 'sess_loginLang' ] ) );
|
||||
$head -> appendChild ( $js );
|
||||
|
||||
/* Editor JS ( remote ) einbinden */
|
||||
$js = $this -> _tpl -> createElement ( 'script' );
|
||||
$js -> setAttributeNode ( new DOMAttr ( 'type' , 'text/javascript' ) );
|
||||
$js -> setAttributeNode ( new DOMAttr ( 'src' , $this -> _website[ $this -> _webkey ][ 'editorUrl' ] . 'v' . $this -> _website[ $this -> _webkey ][ 'editorVersion' ] . '/js/editor.js' ) );
|
||||
$head -> appendChild ( $js );
|
||||
|
||||
$js = $this -> _tpl -> createElement ( 'script' );
|
||||
$js -> setAttributeNode ( new DOMAttr ( 'type' , 'text/javascript' ) );
|
||||
$js -> setAttributeNode ( new DOMAttr ( 'src' , $this -> _website[ $this -> _webkey ][ 'editorUrl' ] . 'v' . $this -> _website[ $this -> _webkey ][ 'editorVersion' ] . '/js/ckeditor/ckeditor.js' ) );
|
||||
$head -> appendChild ( $js );
|
||||
|
||||
}
|
||||
|
||||
/* Nicht benötigte Elemente entfernen */
|
||||
foreach ( $this -> _tplElements as $element )
|
||||
{
|
||||
if ( ! isset ( $this -> _data [ $element ] ) )
|
||||
{
|
||||
$oldNode = $tpl -> getElementById ( $element );
|
||||
$oldNode -> parentNode -> removeChild ( $oldNode );
|
||||
}
|
||||
}
|
||||
|
||||
return $tpl;
|
||||
}
|
||||
|
||||
private function getPageContents ( $content )
|
||||
{
|
||||
$arrContent = explode ( ';' , $content );
|
||||
|
||||
$tbl_prefix = ( $this -> _webkey !== 0 )
|
||||
? $this -> _website[ $this -> _webkey ][ 'prefix' ]
|
||||
: 'portal';
|
||||
|
||||
$new_node = $this -> _tpl -> createDocumentFragment ( );
|
||||
|
||||
foreach ( $arrContent as $singleContent )
|
||||
{
|
||||
$tmp_content = explode ( '_' , $singleContent );
|
||||
$tmp_result = $this -> _db -> query ( 'SELECT * FROM ' . $tbl_prefix . '_content_' . $tmp_content [ 0 ] . ' WHERE id = "' . $tmp_content [ 1 ] . '";' );
|
||||
$tmp_data = $tmp_result -> fetch_assoc ( );
|
||||
|
||||
switch ( $tmp_content[ 0 ] )
|
||||
{
|
||||
case 'form' :
|
||||
$new_node = renderFormClass :: createForm ( $tmp_data );
|
||||
break;
|
||||
|
||||
default :
|
||||
$node = renderSpecialContentClass :: createSpecialContent ( $tmp_content[ 0 ] , array ( $tmp_data ) , $tmp_content[ 0 ] );
|
||||
|
||||
if ( $this -> _editable )
|
||||
{
|
||||
$node -> setAttributeNode ( new DOMAttr ( 'data-editable' , $tmp_content[ 0 ] ) );
|
||||
$node -> setAttributeNode ( new DOMAttr ( 'id' , 'content_' . $tmp_content[ 0 ] . '_' . $tmp_content[ 1 ] ) );
|
||||
}
|
||||
|
||||
$new_node -> appendChild ( $node );
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return $new_node;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
25
.classes/generic/renderClass_abstract.php
Normal file
25
.classes/generic/renderClass_abstract.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
class renderClass_abstract
|
||||
{
|
||||
protected static $_instance = null;
|
||||
|
||||
/**
|
||||
* Konstruktor
|
||||
*/
|
||||
public function __construct ( )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Destruktor
|
||||
*/
|
||||
public function __destruct ( )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
107
.classes/generic/renderFormClass.php
Normal file
107
.classes/generic/renderFormClass.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
class renderFormClass extends renderClass_abstract
|
||||
{
|
||||
private $_formData = array ( );
|
||||
|
||||
public function createForm ( $formData )
|
||||
{
|
||||
$arrFields = explode ( ';' , $formData[ 'content' ] );
|
||||
$fieldCounter = 0;
|
||||
|
||||
$new_node = $this -> _tpl -> createDocumentFragment ( );
|
||||
$node = $this -> _tpl -> createElement ( 'form' );
|
||||
$node -> setAttributeNode ( new DOMAttr ( 'action' , $formData[ 'action' ] ) );
|
||||
$node -> setAttributeNode ( new DOMAttr ( 'method' , $formData[ 'method' ] ) );
|
||||
$node -> setAttributeNode ( new DOMAttr ( 'class' , $formData[ 'class' ] ) );
|
||||
|
||||
if ( ! is_null ( $this -> _errors ) )
|
||||
{
|
||||
foreach ( $this -> _errors as $error )
|
||||
{
|
||||
$errorNode = $this -> _tpl -> createElement ( 'p' );
|
||||
$errorNode -> setAttributeNode ( new DOMAttr ( 'class' , 'error' ) );
|
||||
$errorNode -> appendChild ( new DOMText ( $this -> _langArray[ 'error' ][ $error ] ) );
|
||||
$node -> appendChild ( $errorNode );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
foreach ( $arrFields as $singleField )
|
||||
{
|
||||
$arrData = explode ( ':' , $singleField );
|
||||
$arrDefinition = explode ( '_' , $arrData[ 0 ] );
|
||||
$arrValue = explode ( '_' , $arrData[ 1 ] );
|
||||
|
||||
/* Inputs */
|
||||
if ( $arrDefinition[ 0 ] === 'input' && ( $arrDefinition[ 1 ] !== 'hidden' && $arrDefinition[ 1 ] !== 'submit' ) )
|
||||
{
|
||||
$tmp_div = $this -> _tpl -> createElement ( 'div' );
|
||||
++$fieldCounter;
|
||||
if ( $fieldCounter % 2 === 1 )
|
||||
{
|
||||
$tmp_div -> setAttributeNode ( new DOMAttr ( 'class' , 'left' ) );
|
||||
}
|
||||
}
|
||||
|
||||
$tmp_node = $this -> _tpl -> createElement ( $arrDefinition[ 0 ] );
|
||||
|
||||
if ( $arrDefinition[ 0 ] === 'input' )
|
||||
{
|
||||
$tmp_node -> setAttributeNode ( new DOMAttr ( 'type' , $arrDefinition[ 1 ] ) );
|
||||
$tmp_node -> setAttributeNode ( new DOMAttr ( 'id' , $arrValue[ 0 ] ) );
|
||||
$tmp_node -> setAttributeNode ( new DomAttr ( 'name' , $arrValue[ 0 ] ) );
|
||||
$tmp_node -> setAttributeNode ( new DomAttr ( 'autocomplete' , 'off' ) );
|
||||
|
||||
if ( $arrDefinition[ 1 ] !== 'hidden' && $arrDefinition[ 1 ] !== 'submit' && isset ( $this -> _postData[ $arrValue[ 0 ] ] ) )
|
||||
{
|
||||
$tmp_node -> setAttributeNode ( new DomAttr ( 'value' , $this -> _postData[ $arrValue[ 0 ] ] ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $arrDefinition[ 1 ] === 'submit' && isset ( $this -> _langArray[ 'form' ][ $arrValue[ 0 ] ] ) )
|
||||
{
|
||||
$tmp_node -> setAttributeNode ( new DOMAttr ( 'value' , $this -> _langArray[ 'form' ][ $arrValue[ 0 ] ] ) );
|
||||
}
|
||||
elseif ( isset ( $arrValue[ 1 ] ) )
|
||||
{
|
||||
$tmp_node -> setAttributeNode ( new DOMAttr ( 'value' , $arrValue[ 1 ] ) );
|
||||
}
|
||||
elseif ( isset ( $this -> _langArray[ 'formText' ][ $arrValue[ 0 ] ] ) )
|
||||
{
|
||||
$tmp_node -> appendChild ( new DOMText ( $this -> _langArray[ 'formText' ][ $arrValue[ 0 ] ] ) );
|
||||
}
|
||||
|
||||
if ( $arrDefinition[ 0 ] === 'input'&& ( $arrDefinition[ 1 ] !== 'hidden' && $arrDefinition[ 1 ] !== 'submit' ) )
|
||||
{
|
||||
$tmp_div -> appendChild ( $tmp_node );
|
||||
|
||||
$tmp_node = $this -> _tpl -> createElement ( 'label' );
|
||||
$tmp_node -> setAttributeNode ( new DOMAttr ( 'for' , $arrValue[ 0 ] ) );
|
||||
$tmp_node -> appendChild ( new DOMText ( $this -> _langArray[ 'form' ][ $arrValue[ 0 ] ] ) );
|
||||
$tmp_div -> appendChild ( $tmp_node );
|
||||
|
||||
$node -> appendChild ( $tmp_div );
|
||||
if ( $fieldCounter % 2 === 0 )
|
||||
{
|
||||
$tmp_br = $this -> _tpl -> createElement ( 'br' );
|
||||
$tmp_br -> setAttributeNode ( new DOMAttr ( 'class' , 'fix' ) );
|
||||
$node -> appendChild ( $tmp_br );
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$node -> appendChild ( $tmp_node );
|
||||
}
|
||||
|
||||
}
|
||||
$new_node -> appendChild ( $node );
|
||||
|
||||
return $new_node;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
89
.classes/generic/renderFunctionsClass.php
Normal file
89
.classes/generic/renderFunctionsClass.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
class renderFunctionsClass extends renderClass_abstract
|
||||
{
|
||||
private $_navData = array ( );
|
||||
private $_subtpl = null;
|
||||
private $_node = null;
|
||||
private $_websiteIds = array ( );
|
||||
private $_prefix = '';
|
||||
|
||||
public function createNavigationRights ( $navData , $tpl , $node )
|
||||
{
|
||||
$this -> _navData = $navData;
|
||||
$this -> _subtpl = $tpl;
|
||||
$this -> _node = $node;
|
||||
$this -> _prefix = renderFunctionsClass :: getNavigationPrefix ( );
|
||||
|
||||
$node = renderFunctionsClass :: getNavigationNode ( 0 );
|
||||
if ( $node !== false )
|
||||
{
|
||||
$this -> _node -> appendChild ( $node );
|
||||
}
|
||||
|
||||
return $this -> _node;
|
||||
}
|
||||
|
||||
private function getNavigationPrefix ( )
|
||||
{
|
||||
foreach ( $this -> _navData[ 0 ] as $tmp_data )
|
||||
{
|
||||
foreach ( $tmp_data as $key => $value )
|
||||
{
|
||||
if ( strpos ( $key , '_' ) !== false )
|
||||
{
|
||||
return substr ( $key , 0 , strpos ( $key , '_' ) + 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getNavigationNode ( $navStart )
|
||||
{
|
||||
if ( ! isset ( $this -> _navData[ $navStart ] ) || count ( $this -> _navData [ $navStart ] ) == 0 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
$newNode = $this -> _subtpl -> createElement ( 'ul' );
|
||||
foreach ( $this -> _navData [ $navStart ] AS $key => $value )
|
||||
{
|
||||
$newLi = $this -> _subtpl -> createElement ( 'li' );
|
||||
|
||||
$input = $this -> _subtpl -> createElement ( 'input' );
|
||||
$input -> setAttributeNode ( new DOMAttr ( 'type' , 'checkbox' ) );
|
||||
$input -> setAttributeNode ( new DOMAttr ( 'name' , str_replace ( '_outer' , '' , $this -> _node -> getAttribute ( 'id' ) . '[ ]' ) ) );
|
||||
$input -> setAttributeNode ( new DOMAttr ( 'value' , $this -> _prefix . $value[ $this -> _prefix . 'navId' ] ) );
|
||||
$input -> setAttributeNode ( new DOMAttr ( 'id' , $this -> _prefix . $value[ $this -> _prefix . 'navId' ] ) );
|
||||
if ( $this -> _prefix === 'portal_' && array_key_exists ( $value[ $this -> _prefix . 'navId' ] , $this -> _website ) )
|
||||
{
|
||||
$input -> setAttributeNode ( new DOMAttr ( 'data-referer' , $this -> _website[ $value[ $this -> _prefix . 'navId' ] ][ 'prefix' ] . 'Rights' ) );
|
||||
}
|
||||
$label = $this -> _subtpl -> createElement ( 'label' );
|
||||
$label -> setAttributeNode ( new DOMAttr ( 'for' , $this -> _prefix . $value[ $this -> _prefix . 'navId' ] ) );
|
||||
$label -> appendChild ( new DOMText ( $value[ $this -> _prefix . 'navName' ] ) );
|
||||
|
||||
$newLi -> appendChild ( $input );
|
||||
$newLi -> appendChild ( $label );
|
||||
|
||||
$sub_node = renderFunctionsClass :: getNavigationNode ( $value [ $this -> _prefix . 'navId' ] );
|
||||
if ( $sub_node !== false )
|
||||
{
|
||||
$newLi -> setAttributeNode ( new DOMAttr ( 'class' , 'hasChild' ) );
|
||||
$newLi -> appendChild ( $sub_node );
|
||||
}
|
||||
$newNode -> appendChild ( $newLi );
|
||||
|
||||
}
|
||||
|
||||
unset ( $this -> _navData [ $navStart ] );
|
||||
|
||||
return $newNode;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
37
.classes/generic/renderImageClass.php
Normal file
37
.classes/generic/renderImageClass.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
class renderImageClass extends renderClass_abstract
|
||||
{
|
||||
private $_imgData = array ( );
|
||||
|
||||
public function createImage ( $imgData , $isEditable , $type )
|
||||
{
|
||||
$this -> _imgData = $imgData;
|
||||
$new_node = $this -> _tpl -> createDocumentFragment ( );
|
||||
$node = $this -> _tpl -> createElement ( 'img' );
|
||||
|
||||
$node -> setAttributeNode ( new DOMAttr ( 'src' , $this -> _imgData[ 'path' ] . $this -> _imgData[ 'navId' ] . $this -> _imgData[ 'src' ] ) );
|
||||
if ( ! is_null ( $imgData[ 'title' ] ) && $imgData[ 'title' ] !== '' )
|
||||
{
|
||||
$node -> setAttributeNode ( new DOMAttr ( 'title' , $this -> _imgData[ 'title' ] ) );
|
||||
}
|
||||
|
||||
if ( isset ( $imgData[ 'id' ] ) && $isEditable )
|
||||
{
|
||||
$node -> setAttributeNode ( new DOMAttr ( 'data-editable' , $type ) );
|
||||
$node -> setAttributeNode ( new DOMAttr ( 'id' , $type . '_' . $this -> _imgData[ 'id' ] ) );
|
||||
}
|
||||
else if ( $isEditable )
|
||||
{
|
||||
$node -> setAttributeNode ( new DOMAttr ( 'data-editable' , $type ) );
|
||||
$node -> setAttributeNode ( new DOMAttr ( 'id' , $type . '_0' ) );
|
||||
}
|
||||
|
||||
$new_node -> appendChild ( $node );
|
||||
|
||||
return $new_node;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
109
.classes/generic/renderNavigationClass.php
Normal file
109
.classes/generic/renderNavigationClass.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
class renderNavigationClass extends renderClass_abstract
|
||||
{
|
||||
private $_navData = array ( );
|
||||
private $_node = null;
|
||||
private $_prefix = '';
|
||||
private $_firstKey = 0;
|
||||
|
||||
public function createNavigation ( $navData )
|
||||
{
|
||||
$this -> _navData = $navData;
|
||||
$this -> _node = $this -> _tpl -> createDocumentFragment ( );
|
||||
$navKeys = array_keys ( $navData );
|
||||
$firstKey = $navKeys[ 0 ];
|
||||
$this -> _firstKey = $firstKey;
|
||||
$this -> _prefix = renderNavigationClass :: getNavigationPrefix ( );
|
||||
|
||||
$node = renderNavigationClass :: getNavigationNode ( $this -> _firstKey );
|
||||
if ( $node !== false )
|
||||
{
|
||||
$this -> _node -> appendChild ( $node );
|
||||
}
|
||||
|
||||
return $this -> _node;
|
||||
}
|
||||
|
||||
private function getNavigationPrefix ( )
|
||||
{
|
||||
foreach ( $this -> _navData[ $this -> _firstKey ][ 0 ] as $key => $value )
|
||||
{
|
||||
if ( strpos ( $key , '_' ) !== false )
|
||||
{
|
||||
return substr ( $key , 0 , strpos ( $key , '_' ) + 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getNavigationNode ( $navStart )
|
||||
{
|
||||
if ( ! isset ( $this -> _navData[ $navStart ] ) || count ( $this -> _navData [ $navStart ] ) == 0 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$newNode = $this -> _tpl -> createElement ( 'ul' );
|
||||
foreach ( $this -> _navData [ $navStart ] AS $key => $value )
|
||||
{
|
||||
if ( $this -> _textsFromConfig )
|
||||
{
|
||||
if ( array_key_exists ( $value [ $this -> _prefix . 'navId' ] , $this -> _website ) )
|
||||
{
|
||||
$navTitle = $this -> _website[ $value [ $this -> _prefix . 'navId' ] ][ 'names' ];
|
||||
}
|
||||
else
|
||||
{
|
||||
$navTitle = $this -> _langArray [ 'navi' ][ 'site_' . $value [ $this -> _prefix . 'navId' ] ];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$navTitle = $value[ $this -> _prefix . 'navName' ];
|
||||
}
|
||||
if ( $this -> _modrewrite )
|
||||
{
|
||||
$navHref = $value[ $this -> _prefix . 'navLink' ];
|
||||
}
|
||||
else
|
||||
{
|
||||
$navHref = ( ! isset ( $value[ $this -> _prefix . 'navType' ] ) || ( isset ( $value[ $this -> _prefix . 'navType' ] ) && $value[ $this -> _prefix . 'navType' ] === 'html' ) )
|
||||
? $value [ $this -> _prefix . 'navTarget' ]
|
||||
: 'javascript:void( 0 );';
|
||||
}
|
||||
|
||||
$newLi = $this -> _tpl -> createElement ( 'li' );
|
||||
$newHref = $this -> _tpl -> createElement ( 'a' );
|
||||
if ( in_array ( $value[ $this -> _prefix . 'navId' ] , $this -> _navpath ) )
|
||||
{
|
||||
$newHref -> setAttributeNode ( new DOMAttr ( 'class' , 'active' ) );
|
||||
}
|
||||
$newHref -> appendChild ( new DOMText ( $navTitle ) );
|
||||
$newHref -> setAttributeNode ( new DOMAttr ( 'href' , $navHref ) );
|
||||
if ( isset ( $value[ $this -> _prefix . 'navType' ] ) && $value[ $this -> _prefix . 'navType' ] === 'js' )
|
||||
{
|
||||
$newHref -> setAttributeNode ( new DOMAttr ( 'onclick' , $value[ $this -> _prefix . 'navTarget' ] ) );
|
||||
}
|
||||
$newLi -> appendChild ( $newHref );
|
||||
|
||||
$sub_node = renderNavigationClass :: getNavigationNode ( $value[ $this -> _prefix . 'navId' ] );
|
||||
if ( $sub_node !== false )
|
||||
{
|
||||
$newLi -> appendChild ( $sub_node );
|
||||
}
|
||||
$newNode -> appendChild ( $newLi );
|
||||
|
||||
}
|
||||
|
||||
unset ( $this -> _navData [ $navStart ] );
|
||||
|
||||
return $newNode;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
278
.classes/generic/renderPopupClass.php
Normal file
278
.classes/generic/renderPopupClass.php
Normal file
@@ -0,0 +1,278 @@
|
||||
<?php
|
||||
|
||||
class renderPopupClass extends renderClass_abstract
|
||||
{
|
||||
private $_imgData = array ( );
|
||||
|
||||
public function createPopup ( $popupData )
|
||||
{
|
||||
if ( $this -> _subTemplate !== '' )
|
||||
{
|
||||
$html = file_get_contents ( $this -> _pathTpl . $this -> _layout . '/tpl_' . $this -> _template . '_' . $this -> _subTemplate . '.php' );
|
||||
$html = str_replace ( $this -> _renderSearch , $this -> _renderReplace , $html );
|
||||
$subTpl = new DOMDocument ( );
|
||||
$subTpl -> preserveWhitespace = false;
|
||||
$subTpl -> formatOutput = true;
|
||||
$subTpl -> loadHTML ( $html );
|
||||
$subCont = $subTpl -> getElementById ( 'sub_content' ) -> firstChild;
|
||||
|
||||
$xpath = new DOMXpath ( $subTpl );
|
||||
|
||||
/* Textersetzungen */
|
||||
foreach ( $this -> _langArray [ $this -> _template ] as $key => $value )
|
||||
{
|
||||
$replaces = $xpath -> query ( "//*[starts-with( . , '%" . $key . "%' )]" );
|
||||
foreach ( $replaces as $replace )
|
||||
{
|
||||
if ( $replace -> firstChild -> nodeType === 3 )
|
||||
{
|
||||
$replace -> replaceChild ( new DOMCdataSection ( $value ) , $replace -> firstChild );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Funktionen */
|
||||
if ( isset ( $popupData[ 'functions' ] ) && ! empty ( $popupData[ 'functions' ] ) )
|
||||
{
|
||||
foreach ( $popupData[ 'functions' ] as $function )
|
||||
{
|
||||
if ( $function[ 'position' ] === 'userWebsiteRights' )
|
||||
{
|
||||
$node = $subTpl -> getElementById ( 'websiteRights' ) -> cloneNode ( true );
|
||||
$node -> firstChild -> nodeValue = $node -> firstChild -> nodeValue . ': ' . $this -> _website[ $function[ 'key' ] ][ 'names' ];
|
||||
$node -> removeAttribute ( 'id' );
|
||||
$node -> setAttributeNode ( new DOMAttr ( 'id' , $function[ 'prefix' ] . 'Rights' ) );
|
||||
|
||||
$newNode = $subTpl -> getElementById ( 'websiteRights' ) -> parentNode -> insertBefore ( $node , $subTpl -> getElementById ( 'websiteRights' ) );
|
||||
|
||||
/* Elemente ersetzen */
|
||||
$arr_replaces = array ( 'for' , 'id' , 'name' , 'onclick' );
|
||||
foreach ( $arr_replaces as $str_replace )
|
||||
{
|
||||
$replaces = $xpath -> query ( ".//*[contains(@" . $str_replace . " , 'Website')]" , $newNode );
|
||||
foreach ( $replaces as $replace )
|
||||
{
|
||||
$attribute = $replace -> getAttribute ( $str_replace );
|
||||
$replace -> removeAttribute ( $str_replace );
|
||||
$replace -> setAttributeNode ( new DOMAttr ( $str_replace , str_replace ( 'Website' , $function[ 'prefix' ] , $attribute ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
$elem = $xpath -> query ( ".//*[@id='user" . $function[ 'prefix' ] . "Rights_outer']" , $newNode );
|
||||
$node = $elem -> item( 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
$node = $subTpl -> getElementById ( $function[ 'position' ] . '_outer' );
|
||||
}
|
||||
|
||||
if ( ! is_null ( $node ) )
|
||||
{
|
||||
$this -> applyFunction ( $function[ 'name' ] , $function[ 'data' ] , $subTpl , $node , $function[ 'prefix' ] );
|
||||
}
|
||||
}
|
||||
|
||||
$node = $subTpl -> getElementById ( 'websiteRights' );
|
||||
$node -> parentNode -> removeChild ( $node );
|
||||
}
|
||||
|
||||
/* Headerdaten */
|
||||
if ( isset ( $popupData[ 'header' ] ) && ! empty ( $popupData[ 'header' ] ) )
|
||||
{
|
||||
$header_node = $subTpl -> getElementById ( 'sub_content_header' );
|
||||
foreach ( $popupData[ 'header' ] as $key => $value )
|
||||
{
|
||||
$replaces = $xpath -> query ( ".//*[@id='" . $key . "']" , $header_node );
|
||||
foreach ( $replaces as $replaceNode )
|
||||
{
|
||||
switch ( $replaceNode -> tagName )
|
||||
{
|
||||
case 'select' :
|
||||
foreach ( $value as $optionValue => $optionName )
|
||||
{
|
||||
$option = $subTpl -> createElement ( 'option' );
|
||||
$option -> setAttributeNode ( new DOMAttr ( 'value' , $optionValue ) );
|
||||
if ( isset ( $this -> _postData[ $key ] ) && $this -> _postData[ $key ] == $optionValue )
|
||||
{
|
||||
$option -> setAttributeNode ( new DOMAttr ( 'selected' , 'selected' ) );
|
||||
}
|
||||
$option -> appendChild ( new DOMText ( $optionName ) );
|
||||
$replaceNode -> appendChild ( $option );
|
||||
}
|
||||
break;
|
||||
case 'input' :
|
||||
$replaceNode -> setAttributeNode ( new DOMAttr ( 'value' , $value ) );
|
||||
$replaceNode -> setAttributeNode ( new DOMAttr ( 'autocomplete' , 'off' ) );
|
||||
default :
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this -> applySortRules ( $subTpl , $subCont , $xpath);
|
||||
|
||||
/* Ausgabedaten */
|
||||
if ( isset ( $popupData[ 'main' ] ) && ! empty ( $popupData[ 'main' ] ) )
|
||||
{
|
||||
$main = $subTpl -> getElementById ( 'sub_content_main' );
|
||||
$subNode = $main -> firstChild;
|
||||
|
||||
$testArray = $popupData[ 'main' ][ 0 ];
|
||||
|
||||
/* Datenfelder */
|
||||
$arr_mainKeys = array ( );
|
||||
foreach ( $testArray as $key => $value )
|
||||
{
|
||||
$elements = $xpath -> query ( "//*[@data-name='" . $key . "']" , $main );
|
||||
if ( $elements -> length !== 0 )
|
||||
{
|
||||
$arr_mainKeys[ ] = $key;
|
||||
}
|
||||
}
|
||||
|
||||
/* Eingabefelder */
|
||||
$arr_mainInputs = array ( );
|
||||
foreach ( $testArray as $key => $value )
|
||||
{
|
||||
$elements = $xpath -> query ( "//form//*[@name='" . $key . "' or @name='" . $key . "[ ]']" , $main );
|
||||
if ( $elements -> length !== 0 )
|
||||
{
|
||||
$arr_mainInputs[ ] = $key;
|
||||
}
|
||||
}
|
||||
|
||||
/* Hauptdaten */
|
||||
foreach ( $popupData[ 'main' ] as $dataArray )
|
||||
{
|
||||
$dataNode = $main -> firstChild -> cloneNode ( true );
|
||||
|
||||
/* Schaltflächen ( Links ) für die Bearbeitung in den Übersichtsseiten */
|
||||
foreach ( $this -> _dataParameter as $key => $new_parameter )
|
||||
{
|
||||
$data_navigation = $xpath -> query ( ".//*[@data-navigation='" . $key . "']//a" , $dataNode );
|
||||
if ( $data_navigation -> length !== 0 )
|
||||
{
|
||||
foreach ( $data_navigation as $navigation_item )
|
||||
{
|
||||
if ( $navigation_item -> hasAttribute ( 'href' ) )
|
||||
{
|
||||
$navigation_item -> setAttribute ( 'href' , $navigation_item -> getAttribute ( 'href' ) . '&' . $new_parameter . '=' . $dataArray[ $new_parameter ] );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* Spezielle Regeln anwenden */
|
||||
switch ( $this -> _template )
|
||||
{
|
||||
/* Aktive - inaktive Elemente Unterscheiden */
|
||||
case 'usermanagement' :
|
||||
if ( isset ( $dataArray[ 'userActive' ] ) && $dataArray[ 'userActive' ] === 'Y')
|
||||
{
|
||||
$dataNode -> setAttributeNode ( new DOMAttr ( 'class' , 'data_active' ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$dataNode -> setAttributeNode ( new DOMAttr ( 'class' , 'data_inactive' ) );
|
||||
}
|
||||
break;
|
||||
default :
|
||||
break;
|
||||
}
|
||||
|
||||
/* Werte zuweisen */
|
||||
foreach ( $arr_mainKeys as $key => $value )
|
||||
{
|
||||
$elements = $xpath -> query ( ".//*[@data-name='" . $value . "']" , $dataNode );
|
||||
if ( $elements -> item( 0 ) -> hasChildNodes( ) )
|
||||
{
|
||||
$elements -> item( 0 ) -> removeChild ( $elements -> item( 0 ) -> firstChild );
|
||||
}
|
||||
/* TODO : Warum ist ein utf8_encode nötig? Evtl Server - Konfig */
|
||||
// $elements -> item( 0 ) -> appendChild ( new DOMText ( ( mb_detect_encoding ( $dataArray[ $value ] ) === 'UTF-8' ) ? $dataArray[ $value ] : utf8_encode ( $dataArray[ $value ] ) ) );
|
||||
$elements -> item( 0 ) -> appendChild ( new DOMText ( $dataArray[ $value ] ) );
|
||||
}
|
||||
|
||||
foreach ( $arr_mainInputs as $key => $value )
|
||||
{
|
||||
$elements = $xpath -> query ( ".//form//*[@name='" . $value . "' or @name='" . $value . "[ ]']" , $dataNode );
|
||||
foreach ( $elements as $element )
|
||||
{
|
||||
switch ( $element -> tagName )
|
||||
{
|
||||
case 'input' :
|
||||
if ( $element -> hasAttribute ( 'type' ) )
|
||||
{
|
||||
switch ( $element -> getAttribute ( 'type' ) )
|
||||
{
|
||||
case 'text' :
|
||||
case 'hidden' :
|
||||
$element -> removeAttribute ( 'value' );
|
||||
$element -> setAttributeNode ( new DOMAttr ( 'value' , $dataArray[ $value ] ) );
|
||||
break;
|
||||
case 'radio' :
|
||||
if ( $element -> hasAttribute ( 'id' ) && $element -> getAttribute ( 'id' ) === ( $value . '_' . $dataArray[ $value ] ) )
|
||||
{
|
||||
$element -> setAttributeNode ( new DOMAttr ( 'checked' , 'checked' ) );
|
||||
}
|
||||
break;
|
||||
case 'checkbox' :
|
||||
if ( is_array ( $dataArray[ $value ] ) )
|
||||
{
|
||||
if ( $element -> hasAttribute ( 'id' ) && in_array ( $element -> getAttribute ( 'id' ) , $dataArray[ $value ] ) )
|
||||
{
|
||||
$element -> setAttributeNode ( new DOMAttr ( 'checked' , 'checked' ) );
|
||||
}
|
||||
}
|
||||
break;
|
||||
default :
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$element -> removeAttribute ( 'value' );
|
||||
$element -> setAttributeNode ( new DOMAttr ( 'value' , $dataArray[ $value ] ) );
|
||||
}
|
||||
break;
|
||||
default :
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$main -> appendChild ( $dataNode );
|
||||
}
|
||||
|
||||
$subNode -> parentNode -> removeChild ( $subNode );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* TODO : Keine Daten */
|
||||
$oldNode = $subTpl -> getElementById ( 'sub_content_main' );
|
||||
$oldNode -> parentNode -> removeChild ( $oldNode );
|
||||
}
|
||||
}
|
||||
|
||||
/* Fehlermeldungen */
|
||||
if ( ! is_null ( $this -> _errors ) )
|
||||
{
|
||||
$main = $subTpl -> getElementById ( 'sub_content_main' );
|
||||
$subNode = $main -> firstChild;
|
||||
foreach ( $this -> _errors as $error )
|
||||
{
|
||||
$errorNode = $subTpl -> createElement ( 'p' );
|
||||
$errorNode -> setAttributeNode ( new DOMAttr ( 'class' , 'error' ) );
|
||||
$errorNode -> appendChild ( new DOMText ( $this -> _langArray[ 'error' ][ $error ] ) );
|
||||
$main -> insertBefore ( $errorNode , $subNode);
|
||||
}
|
||||
}
|
||||
|
||||
$new_node = $this -> _tpl -> importNode ( $subCont , true );
|
||||
return $new_node;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
60
.classes/generic/renderSpecialContentClass.php
Normal file
60
.classes/generic/renderSpecialContentClass.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
class renderSpecialContentClass extends renderClass_abstract
|
||||
{
|
||||
public function createSpecialContent ( $id , $popupData , $type )
|
||||
{
|
||||
$html = file_get_contents ( $this -> _pathTpl . $this -> _layout . '/tpl_' . $this -> _template . '_' . $id . '.php' );
|
||||
$html = str_replace ( $this -> _renderSearch , $this -> _renderReplace , $html );
|
||||
$subTpl = new DOMDocument ( );
|
||||
$subTpl -> preserveWhitespace = false;
|
||||
$subTpl -> formatOutput = true;
|
||||
$subTpl -> loadHTML ( $html );
|
||||
|
||||
$xpath = new DOMXpath ( $subTpl );
|
||||
$subCont = $xpath -> query ( ".//*[contains(concat(' ', @class, ' '), ' " . $id . " ')]" ) -> item( 0 );
|
||||
|
||||
foreach ( $popupData as $singleData )
|
||||
{
|
||||
$tmp_node = $subCont -> firstChild -> cloneNode ( true );
|
||||
if ( isset ( $singleData[ 'id' ] ) )
|
||||
{
|
||||
$subCont -> setAttributeNode ( new DOMAttr ( 'id' , $type . '_' . $singleData[ 'id' ] ) );
|
||||
}
|
||||
|
||||
foreach ( $singleData as $key => $data )
|
||||
{
|
||||
$nodeList = $xpath -> query ( ".//*[contains(concat(' ', @class, ' '), ' " . $key . " ')]" , $tmp_node );
|
||||
if ( $nodeList -> length !== 0 )
|
||||
{
|
||||
|
||||
foreach ( $nodeList as $node )
|
||||
{
|
||||
switch ( $key )
|
||||
{
|
||||
case 'link' :
|
||||
$node -> setAttributeNode ( new DOMAttr ( 'href' , $data ) );
|
||||
break;
|
||||
|
||||
default :
|
||||
$node -> appendChild ( new DOMCdataSection ( $data ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$subCont -> appendChild ( $tmp_node );
|
||||
}
|
||||
|
||||
$subCont -> removeChild ( $subCont -> firstChild );
|
||||
|
||||
|
||||
$new_node = $this -> _tpl -> importNode ( $subCont , true );
|
||||
return $new_node;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
34
.classes/generic/renderWidgetClass.php
Normal file
34
.classes/generic/renderWidgetClass.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
class renderWidgetClass extends renderClass_abstract
|
||||
{
|
||||
|
||||
public function createWidget ( $widgetData )
|
||||
{
|
||||
$html = file_get_contents ( $this -> _pathTpl . $this -> _layout . '/tpl_' . $this -> _template . '_widget_' . $widgetData[ 'tpl' ] . '.php' );
|
||||
$html = str_replace ( $this -> _renderSearch , $this -> _renderReplace , $html );
|
||||
|
||||
foreach ( $widgetData as $key => $value )
|
||||
{
|
||||
$html = str_replace ( '%%' . $key . '%%' , $value , $html );
|
||||
}
|
||||
|
||||
$subTpl = new DOMDocument ( );
|
||||
$subTpl -> preserveWhitespace = false;
|
||||
$subTpl -> formatOutput = true;
|
||||
$subTpl -> loadHTML ( $html );
|
||||
|
||||
$xpath = new DOMXpath ( $subTpl );
|
||||
$subCont = $xpath -> query ( ".//*[contains(concat(' ', @class, ' '), ' " . $widgetData[ 'tpl' ] . " ')]" ) -> item( 0 );
|
||||
|
||||
if ( isset ( $widgetData[ 'id' ] ) )
|
||||
{
|
||||
$subCont -> setAttributeNode ( new DOMAttr ( 'id' , 'widget_' . $widgetData[ 'id' ] ) );
|
||||
}
|
||||
|
||||
$new_node = $this -> _tpl -> importNode ( $subCont , true );
|
||||
return $new_node;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user