<?php
# Copyright by Manuel
# Support www.ilch.de
defined (
'main'
)
or
die
(
'no direct access'
);
class
design
extends
tpl {
var
$html
;
var
$design
;
var
$vars
;
var
$was
;
var
$file
;
function
design (
$title
,
$hmenu
,
$was
= 1,
$file
= NULL ) {
global
$allgAr
;
$this
->vars =
array
();
$this
->file =
$file
; # setzte das file standart 0 weil durch was definiert
$this
->was =
$was
; # 0 = smalindex, 1 = normal index , 2 = admin
$this
->design =
$this
->get_design();
$link
=
$this
->htmlfile();
$tpl
=
new
tpl (
$link
, 2 );
if
(
$tpl
->list_exists (
'boxleft'
) ) {
$tpl
->set (
'boxleft'
,
$this
->get_boxes (
'l'
,
$tpl
) );
}
if
(
$tpl
->list_exists (
'boxright'
) ) {
$tpl
->set (
'boxright'
,
$this
->get_boxes (
'r'
,
$tpl
) );
}
# ab 0.6 = ... 5 menu listen moeglich
for
(
$i
=1;
$i
<=5;
$i
++) {
if
(
$tpl
->list_exists (
'menunr'
.
$i
) ) {
$tpl
->set (
'menunr'
.
$i
,
$this
->get_boxes (
$i
,
$tpl
) );
}
}
$ar
=
array
(
'TITLE'
=>
$title
,
'HMENU'
=>
$hmenu
,
'SITENAME'
=>
$allgAr
[
'title'
],
'hmenuende'
=>
''
,
'vmenuende'
=>
''
,
'hmenubegi'
=>
''
,
'vmenubegi'
=>
''
,
'hmenupoint'
=>
''
,
'vmenupoint'
=>
''
,
'DESIGN'
=>
$this
->design
);
$tpl
->set_ar(
$ar
);
$this
->html =
$tpl
->get(0);
$this
->html .=
'{EXPLODE}'
;
$this
->html .=
$tpl
->get(1);
unset (
$tpl
);
$zsave0
=
array
();
preg_match_all (
"/\{_boxes_([^\{\}]+)\}/"
,
$this
->html ,
$zsave0
);
$this
->replace_boxes(
$zsave0
[1]);
unset (
$zsave0
);
$this
->vars_replace();
unset (
$this
->vars );
$this
->html =
explode
(
'{EXPLODE}'
,
$this
->html);
}
function
header () {
echo
$this
->html[0];
unset (
$this
->html[0]);
}
function
footer (
$exit
= 0) {
echo
$this
->html[1];
unset (
$this
->html[1]);
if
(
$exit
== 1) {
exit
();
}
}
function
htmlfile () {
if
( !
is_null
(
$this
->file ) AND
file_exists
(
'include/designs/'
.
$this
->design.
'/templates/'
.
$this
->file ) ) {
$f
=
'designs/'
.
$this
->design.
'/templates/'
.
$this
->file;
}
elseif
( !
is_null
(
$this
->file ) AND
file_exists
(
'include/templates/'
.
$this
->file ) ) {
$f
=
'templates/'
.
$this
->file;
}
elseif
(
$this
->was == 0 ) {
$f
=
'templates/small_index.htm'
;
}
elseif
(
$this
->was == 1 ) {
$f
=
'designs/'
.
$this
->design.
'/index.htm'
;
}
elseif
(
$this
->was == 2 ) {
$f
=
'admin/templates/index.htm'
;
}
return
(
$f
);
}
function
replace_boxes (
$zsave0
) {
foreach
(
$zsave0
as
$v
) {
$dat
=
strtolower
(
$v
);
$buffer
=
$this
->get_boxcontent (
$dat
);
if
(
$buffer
!== FALSE ) {
$this
->vars[
'_boxes_'
.
$v
] =
$buffer
;
}
}
if
( !
is_array
(
$this
->vars) ) {
$this
->vars =
array
();
}
}
function
vars_replace() {
foreach
(
$this
->vars
as
$k
=>
$v
) {
$this
->html =
str_replace
(
'{'
.
$k
.
'}'
,
$v
,
$this
->html);
}
}
#####
function
get_boxes (
$wo
,
$tpl
) {
global
$lang
,
$allgAr
,
$menu
;
if
(
is_numeric
(
$wo
) ) {
$datei
=
'menunr'
.
$wo
;
}
elseif
(
$wo
==
'l'
) {
$datei
=
'boxleft'
;
$wo
= 1;
}
elseif
(
$wo
==
'r'
) {
$datei
=
'boxright'
;
$wo
= 2;
}
$retur
=
''
;
$ex_ebene
= 0;
$ex_was
= 1;
$firstmep
= FALSE;
$hovmenup
=
''
;
$abf
=
"SELECT * FROM `prefix_menu` WHERE wo = "
.
$wo
.
" AND ( recht >= "
.
$_SESSION
[
'authright'
].
" OR recht = 0 ) ORDER by pos"
;
$erg
= db_query(
$abf
);
while
(
$row
= db_fetch_assoc(
$erg
) ) {
$subhauptx
=
$row
[
'was'
];
$whileMenP
= (
$subhauptx
>= 7 ? TRUE : FALSE );
if
((
$row
[
'was'
] >= 7 AND
$ex_was
== 1) OR (
$ex_ebene
< (
$row
[
'ebene'
]-1)) OR (
$ex_was
<= 4 AND
$row
[
'ebene'
] <> 0) OR (
$row
[
'was'
] >= 7 AND !
$tpl
->list_exists(
$hovmenup
))) {
continue
;
}
# nur wenn ein menu in
die
variable
$menuzw
geschrieben wurde
# wird in diese
if
abfrage gesprungen
if
( (
$whileMenP
=== FALSE ) AND !
empty
(
$menuzw
) ) {
$menuzw
.=
$this
->get_boxes_get_menu_close (
$ex_ebene
, 0,
$menuzw
,
$wmpE
,
$wmpTE
,
$wmpTEE
);
$retur
.=
$tpl
->list_get(
$datei
,
array
(htmlentities(
$boxname
),
$menuzw
.
$menuzwE
));
$menuzw
=
''
;
}
if
(
$row
[
'was'
] == 1 ) {
#
die
box wird direkt in
die
to
return
variable geschrieben
$buffer
=
$this
->get_boxcontent(
$row
[
'path'
]);
$retur
.=
$tpl
->list_get(
$datei
,
array
(
$row
[
'name'
] ,
$buffer
) );
}
elseif
(
$row
[
'was'
] >= 2 AND
$row
[
'was'
] <= 4 ) {
# der name des menues wird gesetzt
# und
die
variable wird gesetzt.
$boxname
=
$row
[
'name'
];
$menuzw
=
''
;
$menuzwE
=
''
;
$ex_ebene
= 0; # ex ebene
$hovmenu
=
''
;
if
(
$row
[
'was'
] == 2 AND
$tpl
->list_exists(
'hmenupoint'
)) {
$hovmenu
=
'hmenu'
;
}
elseif
(
$row
[
'was'
] == 3 AND
$tpl
->list_exists(
'vmenupoint'
)) {
$hovmenu
=
'vmenu'
;
}
$firstmep
= TRUE;
if
(!
empty
(
$hovmenu
)) {
$menuzw
.=
$tpl
->list_get(
$hovmenu
.
'begi'
,
array
());
$menuzwE
.=
$tpl
->list_get(
$hovmenu
.
'ende'
,
array
());
}
$hovmenup
=
$hovmenu
.
'point'
;
}
elseif
(
$whileMenP
) {
# menupunkt wird generiert
$ebene
=
$row
[
'ebene'
];
$menuTarget
= (
$subhauptx
== 8 ?
'_blank'
:
'_self'
);
list (
$wmpA
,
$wmpE
,
$wmpTE
,
$wmpTEE
) =
explode
(
'|'
,
$tpl
->list_get (
$hovmenup
,
array
(
$menuTarget
, (
$subhauptx
== 8 ?
''
:
'index.php?'
) .
$row
[
'path'
],
$row
[
'name'
])));
if
(!
empty
(
$menuzw
) AND
$firstmep
=== FALSE) {
$menuzw
.=
$this
->get_boxes_get_menu_close (
$ex_ebene
,
$ebene
,
$menuzw
,
$wmpE
,
$wmpTE
,
$wmpTEE
);
}
$menuzw
.=
$wmpA
;
$firstmep
= FALSE;
}
$ex_was
=
$row
[
'was'
];
$ex_ebene
=
$row
[
'ebene'
];
}
if
(!
empty
(
$menuzw
) ) {
$menuzw
.=
$this
->get_boxes_get_menu_close (
$ex_ebene
, 0,
$menuzw
,
$wmpE
,
$wmpTE
,
$wmpTEE
);
$retur
.=
$tpl
->list_get(
$datei
,
array
(htmlentities(
$boxname
),
$menuzw
.
$menuzwE
));
}
return
(
$retur
);
}
function
get_boxes_get_menu_close (
$ex_ebene
,
$ebene
,
$menuzw
,
$wmpE
,
$wmpTE
,
$wmpTEE
) {
$menu1
=
''
;
if
(
$ex_ebene
==
$ebene
AND !
empty
(
$menuzw
) ) {
$menu1
.=
$wmpE
.
"\n"
;
}
elseif
(
$ex_ebene
>
$ebene
) {
$menu1
.=
$wmpE
.
"\n"
;
for
(
$i
=0;
$i
<(
$ex_ebene
-
$ebene
);
$i
++ ) {
$menu1
.=
$wmpTEE
.
"\n"
;
}
}
elseif
(
$ex_ebene
<
$ebene
) {
$menu1
.=
$wmpTE
.
"\n"
;
}
return
(
$menu1
);
}
function
get_boxcontent (
$box
) {
global
$lang
,
$allgAr
,
$menu
;
if
(
file_exists
(
'include/boxes/'
.
$box
) ) {
$pfad
=
'include/boxes/'
.
$box
;
}
elseif
(
file_exists
(
'include/contents/selfbp/selfb/'
.
str_replace
(
'self_'
,
''
,
$box
) ) ) {
$pfad
=
'include/contents/selfbp/selfb/'
.
str_replace
(
'self_'
,
''
,
$box
);
}
elseif
(
file_exists
(
'include/boxes/'
.
$box
.
'.php'
) ) {
$pfad
=
'include/boxes/'
.
$box
.
'.php'
;
}
elseif
(
file_exists
(
'include/boxes/'
.
$box
.
'.htm'
) ) {
$pfad
=
'include/boxes/'
.
$box
.
'.htm'
;
}
elseif
(
file_exists
(
'include/contents/selfbp/selfb/'
.
str_replace
(
'self_'
,
''
,
$box
).
'.php'
) ) {
$pfad
=
'include/contents/selfbp/selfb/'
.
str_replace
(
'self_'
,
''
,
$box
).
'.htm'
;
}
elseif
(
file_exists
(
'include/contents/selfbp/selfb/'
.
str_replace
(
'self_'
,
''
,
$box
).
'.htm'
) ) {
$pfad
=
'include/contents/selfbp/selfb/'
.
str_replace
(
'self_'
,
''
,
$box
).
'.htm'
;
}
else
{
return
( FALSE );
}
ob_start();
require_once
(
$pfad
);
$buffer
= ob_get_contents();
ob_end_clean();
return
(
$buffer
);
}
}
?>