1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
if (!class_exists("DLFixedPrepare", false)) { |
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* Class DLFixedPrepare |
6
|
|
|
*/ |
7
|
|
|
class DLFixedPrepare |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* @param array $data |
11
|
|
|
* @param DocumentParser $modx |
12
|
|
|
* @param $_DL |
13
|
|
|
* @param prepare_DL_Extender $_eDL |
14
|
|
|
* @return array |
15
|
|
|
*/ |
16
|
|
|
public static function buildMenu(array $data, DocumentParser $modx, $_DL, prepare_DL_Extender $_eDL) |
17
|
|
|
{ |
18
|
|
|
$params = $_DL->getCFGDef('params', array()); |
19
|
|
|
if ($_DL->getCfgDef('currentDepth', 1) < $_DL->getCFGDef('maxDepth', 5)) { |
20
|
|
|
$params['currentDepth'] = $_DL->getCfgDef('currentDepth', 1) + 1; |
21
|
|
|
$params['parents'] = $data['id']; |
22
|
|
|
$params['idType'] = 'parents'; |
23
|
|
|
$params['documents'] = ''; |
24
|
|
|
$data['dl.submenu'] = ($data['isfolder']) ? $modx->runSnippet('DLBuildMenu', $params) : ''; |
|
|
|
|
25
|
|
|
} else { |
26
|
|
|
$data['dl.submenu'] = ''; |
27
|
|
|
} |
28
|
|
|
$data['dl.currentDepth'] = $_DL->getCfgDef('currentDepth', 1); |
29
|
|
|
|
30
|
|
|
if (($parentIDs = $_eDL->getStore('parentIDs')) === null) { |
31
|
|
|
$parentIDs = array_values($modx->getParentIds($modx->documentObject['id'])); |
|
|
|
|
32
|
|
|
$_eDL->setStore('parentIDs', $parentIDs); |
33
|
|
|
} |
34
|
|
|
$isActive = ((is_array($parentIDs) && in_array($data['id'], |
35
|
|
|
$parentIDs)) || $data['id'] == $modx->documentObject['id']); |
36
|
|
|
$activeClass = $_DL->getCfgDef('activeClass', 'active'); |
37
|
|
|
if ($isActive) { |
38
|
|
|
$data['dl.class'] .= ' ' . $activeClass; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
if (strpos($data['dl.class'], 'current') !== false && strpos($data['dl.class'], |
42
|
|
|
' ' . $activeClass) === false |
43
|
|
|
) { |
44
|
|
|
$data['dl.class'] = str_replace('current', 'current ' . $activeClass, $data['dl.class']); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
$tpl = empty($data['dl.submenu']) ? 'noChildrenRowTPL' : 'mainRowTpl'; |
48
|
|
|
|
49
|
|
|
$_DL->renderTPL = $_DL->getCfgDef($tpl); |
50
|
|
|
if (strpos($data['dl.class'], 'current') !== false) { |
51
|
|
|
$_DL->renderTPL = $_DL->getCfgDef('TplCurrent', $_DL->renderTPL); |
52
|
|
|
$_DL->renderTPL = $_DL->getCfgDef('TplCurrent' . $data['dl.currentDepth'], $_DL->renderTPL); |
53
|
|
|
if (empty($data['dl.submenu'])) { |
54
|
|
|
$_DL->renderTPL = $_DL->getCfgDef('TplCurrentNoChildren' . $data['dl.currentDepth'], |
55
|
|
|
$_DL->renderTPL); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
return $data; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @param array $data |
64
|
|
|
* @param DocumentParser $modx |
65
|
|
|
* @param DocLister $_DocLister |
66
|
|
|
* @param prepare_DL_Extender $_extDocLister |
67
|
|
|
* @return array |
68
|
|
|
*/ |
69
|
|
|
public static function firstChar( |
|
|
|
|
70
|
|
|
array $data, |
71
|
|
|
DocumentParser $modx, |
72
|
|
|
DocLister $_DocLister, |
73
|
|
|
prepare_DL_Extender $_extDocLister |
74
|
|
|
) { |
75
|
|
|
$char = mb_substr($data['pagetitle'], 0, 1, 'UTF-8'); |
76
|
|
|
$oldChar = $_extDocLister->getStore('char'); |
77
|
|
|
if ($oldChar !== $char) { |
78
|
|
|
$sanitarInIDs = $_DocLister->sanitarIn($_DocLister->getIDs()); |
79
|
|
|
$where = sqlHelper::trimLogicalOp($_DocLister->getCFGDef('addWhereList', '')); |
80
|
|
|
$where = sqlHelper::trimLogicalOp(($where ? $where . ' AND ' : '') . $_DocLister->filtersWhere()); |
81
|
|
|
$where = sqlHelper::trimLogicalOp(($where ? $where . ' AND ' : '') . "SUBSTRING(c.pagetitle,1,1) = '" . $modx->db->escape($char) . "'"); |
82
|
|
|
|
83
|
|
|
if ($_DocLister->getCFGDef('idType', 'parents') == 'parents') { |
|
|
|
|
84
|
|
|
|
85
|
|
|
if ($where != '') { |
86
|
|
|
$where .= " AND "; |
87
|
|
|
} |
88
|
|
|
$where = "WHERE {$where} c.parent IN (" . $sanitarInIDs . ")"; |
89
|
|
|
if (!$_DocLister->getCFGDef('showNoPublish', 0)) { |
|
|
|
|
90
|
|
|
$where .= " AND c.deleted=0 AND c.published=1"; |
91
|
|
|
} |
92
|
|
|
} else { |
93
|
|
|
if ($sanitarInIDs != "''") { |
94
|
|
|
$where .= ($where ? " AND " : "") . "c.id IN ({$sanitarInIDs}) AND"; |
95
|
|
|
} |
96
|
|
|
$where = sqlHelper::trimLogicalOp($where); |
97
|
|
|
if ($_DocLister->getCFGDef('showNoPublish', 0)) { |
98
|
|
|
if ($where != '') { |
99
|
|
|
$where = "WHERE {$where}"; |
100
|
|
|
} |
101
|
|
|
} else { |
102
|
|
|
if ($where != '') { |
103
|
|
|
$where = "WHERE {$where} AND "; |
104
|
|
|
} else { |
105
|
|
|
$where = "WHERE {$where} "; |
106
|
|
|
} |
107
|
|
|
$where .= "c.deleted=0 AND c.published=1"; |
108
|
|
|
} |
109
|
|
|
} |
110
|
|
|
$q = $_DocLister->dbQuery("SELECT count(c.id) as total FROM " . $_DocLister->getTable('site_content', |
111
|
|
|
'c') . " " . $where); |
112
|
|
|
$total = $modx->db->getValue($q); |
113
|
|
|
$data['OnNewChar'] = $_DocLister->parseChunk($_DocLister->getCFGDef('tplOnNewChar'), |
114
|
|
|
compact("char", "total")); |
115
|
|
|
$_extDocLister->setStore('char', $char); |
116
|
|
|
|
117
|
|
|
if ($oldChar !== null) { |
118
|
|
|
$data['CharSeparator'] = $_DocLister->parseChunk($_DocLister->getCFGDef('tplCharSeparator'), |
119
|
|
|
compact("char", "total")); |
120
|
|
|
} |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
return $data; |
124
|
|
|
} |
125
|
|
|
} |
126
|
|
|
} |
127
|
|
|
|