-
Notifications
You must be signed in to change notification settings - Fork 0
/
staticList.php
116 lines (110 loc) · 4.65 KB
/
staticList.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?php
/**
* Plugin mySubStatic
* @version 3.0.3
* @author Cyrille G. @ re7net.com
* pages statique à deux niveaux
**/
$plugin = $this->plxMotor->plxPlugins->getInstance('mySubStatic');
$format_group = $plugin->format_group ;
$home = ((empty($this->plxMotor->get) or preg_match('/^page[0-9]*/', $this->plxMotor->get)) and basename($_SERVER['SCRIPT_NAME']) == "index.php");
# Si on a la variable extra, on affiche un lien vers la page d'accueil (avec $extra comme nom)
if ($extra != '') {
$menus[][] = strtr($format, [
'#static_id' => 'static-home',
'#static_class' => 'static menu menu-item',
'#static_url' => $this->plxMotor->urlRewrite(),
'#static_name' => plxUtils::strCheck($extra),
'#static_status' => $home ? 'active' : 'noactive',
]);
}
$group_active = '';
if ($this->plxMotor->aStats) {
$xmlStatList = simplexml_load_file(PLX_ROOT . PLX_CONFIG_PATH . 'statiques.xml');
foreach ($this->plxMotor->aStats as $k => $v) {
$sub = is_numeric(substr($v['group'],0,3));
$children='';
if ($v['active'] == 1 and $v['menu'] == 'oui') { # La page est bien active et dispo ds le menu
if ($v['url'][0] == '?') # url interne commençant par ?
$url = $this->plxMotor->urlRewrite($v['url']);
elseif (plxUtils::checkSite($v['url'], false)) # url externe en http ou autre
$url = $v['url'];
else # url page statique
$url = $this->plxMotor->urlRewrite('?static' . intval($k) . '/' . $v['url']);
# contient-elle un sous-groupe ?
$subGroup = $xmlStatList->xpath('//document/statique/group[starts-with(., "'.$k.'")]');
if(isset($subGroup[0]) && $sub !== '1' ) $children =' has-children ';
$stat = strtr($format, [
'#static_id' => 'static-' . intval($k),
'#static_class' => 'static menu menu-item'.$children,
'#static_name' => plxUtils::strCheck($v['name']),
'#static_status' => ($this->staticId() == intval($k)) ? 'active' : 'noactive',
'#static_url' => $url,
]);
if (empty($v['group']))
$menus[][] = $stat;
else
$menus[$v['group']][] = $stat;
if ($group_active == '' and $home === false and $this->staticId() == intval($k) and $v['group'] != '')
$group_active = $v['group'];
# est ce un sous groupe ?
if(isset(
$this->plxMotor->aStats[substr($v['group'],0,3)]['group'])
and $this->plxMotor->aStats[substr($v['group'],0,3)]['group'] !=''
and $this->plxMotor->aStats[substr($v['group'],0,3)]['menu'] =='oui'
) {
# insertion du marker de sous-groupe dans le menu
if(!isset($found[substr($v['group'],0,3)])) {// test si déjà vu
$found[substr($v['group'],0,3)] ='set';
end($menus[$this->plxMotor->aStats[substr($v['group'],0,3)]['group']]);
$key = key($menus[$this->plxMotor->aStats[substr($v['group'],0,3)]['group']]);
# ajout du marker.
$menus[$this->plxMotor->aStats[substr($v['group'],0,3)]['group']][$key].='<!-- '.substr($v['group'],0,3).' -->';
}
}
}
}
}
if ($menublog) {
if ($this->plxMotor->aConf['homestatic'] != '' and isset($this->plxMotor->aStats[$this->plxMotor->aConf['homestatic']])) {
if ($this->plxMotor->aStats[$this->plxMotor->aConf['homestatic']]['active']) {
$menu = ' '.strtr($format, [
'#static_id' => 'static-blog',
'#static_status'=> (
$this->plxMotor->get and
preg_match('#^(?:blog|categorie|archives|tag|article)#', $_SERVER['QUERY_STRING'] . $this->plxMotor->mode)
) ? 'active' : 'noactive',
'#static_url' => $this->plxMotor->urlRewrite('?blog'),
'#static_name' => L_PAGEBLOG_TITLE,
'#static_class' => 'static menu',
]).PHP_EOL;
array_splice($menus, (intval($menublog) - 1), 0, array($menu));
}
}
}
# Hook Plugins
if (eval($this->plxMotor->plxPlugins->callHook('plxShowStaticListEnd'))) return;
# Affichage des pages statiques + menu Accueil et Blog
if ($menus) {
foreach ($menus as $k => $v) {
if (is_numeric($k)) {
echo "\n" . (is_array($v) ? $v[0] : $v);
} else {
if( !array_key_exists(trim(substr($k,0,3)),$this->plxMotor->aStats)) {
$group = strtr($format_group, [
'#group_id' => 'static-group-' . plxUtils::urlify($k),
'#group_class' => 'static group',
'#group_status' => ($group_active == $k) ? 'active' : 'noactive',
'#group_name' => plxUtils::strCheck($k),
]).PHP_EOL;
?>
<li class="menu has-children">
<?= $group ?>
<ul id="static-<?= plxUtils::urlify($k) ?>" class="sub-menu">
<?= implode("\t\t" . PHP_EOL, $v); ?>
</ul>
</li><?php
}
}
}
}