@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * Build and return document tree view nodes |
5 | 5 | * |
6 | 6 | */ |
7 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
7 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
8 | 8 | die('<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.'); |
9 | 9 | } |
10 | 10 | |
@@ -18,11 +18,11 @@ discard block |
||
18 | 18 | exit('send some data'); |
19 | 19 | } //?? |
20 | 20 | |
21 | -$indent = (int)$_REQUEST['indent']; |
|
22 | -$parent = (int)$_REQUEST['parent']; |
|
23 | -$expandAll = (int)$_REQUEST['expandAll']; |
|
21 | +$indent = (int) $_REQUEST['indent']; |
|
22 | +$parent = (int) $_REQUEST['parent']; |
|
23 | +$expandAll = (int) $_REQUEST['expandAll']; |
|
24 | 24 | $output = ''; |
25 | -$theme = $manager_theme . "/"; |
|
25 | +$theme = $manager_theme."/"; |
|
26 | 26 | $hereid = isset($_REQUEST['id']) && is_numeric($_REQUEST['id']) ? $_REQUEST['id'] : ''; |
27 | 27 | |
28 | 28 | if (isset($_REQUEST['showonlyfolders'])) { |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
3 | - die('<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.'); |
|
3 | + die('<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -12,443 +12,443 @@ discard block |
||
12 | 12 | * @return string |
13 | 13 | */ |
14 | 14 | function makeHTML($indent, $parent, $expandAll, $theme, $hereid = '') { |
15 | - global $modx; |
|
16 | - global $icons, $iconsPrivate, $_style; |
|
17 | - global $_lang, $opened, $opened2, $closed2; //added global vars |
|
18 | - global $modx_textdir; |
|
19 | - |
|
20 | - $output = ''; |
|
21 | - |
|
22 | - // setup spacer |
|
23 | - $level = 0; |
|
24 | - $spacer = '<span class="indent">'; |
|
25 | - for($i = 2; $i <= $indent; $i++) { |
|
26 | - $spacer .= '<i></i>'; |
|
27 | - $level++; |
|
28 | - } |
|
29 | - $spacer .= '</span>'; |
|
30 | - |
|
31 | - // manage order-by |
|
32 | - if(!isset($_SESSION['tree_sortby']) && !isset($_SESSION['tree_sortdir'])) { |
|
33 | - // This is the first startup, set default sort order |
|
34 | - $_SESSION['tree_sortby'] = 'menuindex'; |
|
35 | - $_SESSION['tree_sortdir'] = 'ASC'; |
|
36 | - } |
|
37 | - |
|
38 | - switch($_SESSION['tree_sortby']) { |
|
39 | - case 'createdon': |
|
40 | - case 'editedon': |
|
41 | - case 'publishedon': |
|
42 | - case 'pub_date': |
|
43 | - case 'unpub_date': |
|
44 | - $sortby = sprintf('CASE WHEN %s IS NULL THEN 1 ELSE 0 END, %s', 'sc.' . $_SESSION['tree_sortby'], 'sc.' . $_SESSION['tree_sortby']); |
|
45 | - break; |
|
46 | - default: |
|
47 | - $sortby = 'sc.' . $_SESSION['tree_sortby']; |
|
48 | - }; |
|
49 | - |
|
50 | - $orderby = $modx->db->escape($sortby . ' ' . $_SESSION['tree_sortdir']); |
|
51 | - |
|
52 | - // Folder sorting gets special setup ;) Add menuindex and pagetitle |
|
53 | - if($_SESSION['tree_sortby'] == 'isfolder') { |
|
54 | - $orderby .= ', menuindex ASC, pagetitle'; |
|
55 | - } |
|
56 | - |
|
57 | - $tblsc = $modx->getFullTableName('site_content'); |
|
58 | - $tbldg = $modx->getFullTableName('document_groups'); |
|
59 | - $tblst = $modx->getFullTableName('site_templates'); |
|
60 | - // get document groups for current user |
|
61 | - $docgrp = (isset($_SESSION['mgrDocgroups']) && is_array($_SESSION['mgrDocgroups'])) ? implode(',', $_SESSION['mgrDocgroups']) : ''; |
|
62 | - $showProtected = false; |
|
63 | - if(isset ($modx->config['tree_show_protected'])) { |
|
64 | - $showProtected = (boolean) $modx->config['tree_show_protected']; |
|
65 | - } |
|
66 | - $mgrRole = (isset ($_SESSION['mgrRole']) && (string) $_SESSION['mgrRole'] === '1') ? '1' : '0'; |
|
67 | - if($showProtected == false) { |
|
68 | - $access = "AND (1={$mgrRole} OR sc.privatemgr=0" . (!$docgrp ? ')' : " OR dg.document_group IN ({$docgrp}))"); |
|
69 | - } else { |
|
70 | - $access = ''; |
|
71 | - } |
|
72 | - $docgrp_cond = $docgrp ? "OR dg.document_group IN ({$docgrp})" : ''; |
|
73 | - $field = "DISTINCT sc.id, pagetitle, longtitle, menutitle, parent, isfolder, published, pub_date, unpub_date, richtext, searchable, cacheable, deleted, type, template, templatename, menuindex, donthit, hidemenu, alias, contentType, privateweb, privatemgr, |
|
15 | + global $modx; |
|
16 | + global $icons, $iconsPrivate, $_style; |
|
17 | + global $_lang, $opened, $opened2, $closed2; //added global vars |
|
18 | + global $modx_textdir; |
|
19 | + |
|
20 | + $output = ''; |
|
21 | + |
|
22 | + // setup spacer |
|
23 | + $level = 0; |
|
24 | + $spacer = '<span class="indent">'; |
|
25 | + for($i = 2; $i <= $indent; $i++) { |
|
26 | + $spacer .= '<i></i>'; |
|
27 | + $level++; |
|
28 | + } |
|
29 | + $spacer .= '</span>'; |
|
30 | + |
|
31 | + // manage order-by |
|
32 | + if(!isset($_SESSION['tree_sortby']) && !isset($_SESSION['tree_sortdir'])) { |
|
33 | + // This is the first startup, set default sort order |
|
34 | + $_SESSION['tree_sortby'] = 'menuindex'; |
|
35 | + $_SESSION['tree_sortdir'] = 'ASC'; |
|
36 | + } |
|
37 | + |
|
38 | + switch($_SESSION['tree_sortby']) { |
|
39 | + case 'createdon': |
|
40 | + case 'editedon': |
|
41 | + case 'publishedon': |
|
42 | + case 'pub_date': |
|
43 | + case 'unpub_date': |
|
44 | + $sortby = sprintf('CASE WHEN %s IS NULL THEN 1 ELSE 0 END, %s', 'sc.' . $_SESSION['tree_sortby'], 'sc.' . $_SESSION['tree_sortby']); |
|
45 | + break; |
|
46 | + default: |
|
47 | + $sortby = 'sc.' . $_SESSION['tree_sortby']; |
|
48 | + }; |
|
49 | + |
|
50 | + $orderby = $modx->db->escape($sortby . ' ' . $_SESSION['tree_sortdir']); |
|
51 | + |
|
52 | + // Folder sorting gets special setup ;) Add menuindex and pagetitle |
|
53 | + if($_SESSION['tree_sortby'] == 'isfolder') { |
|
54 | + $orderby .= ', menuindex ASC, pagetitle'; |
|
55 | + } |
|
56 | + |
|
57 | + $tblsc = $modx->getFullTableName('site_content'); |
|
58 | + $tbldg = $modx->getFullTableName('document_groups'); |
|
59 | + $tblst = $modx->getFullTableName('site_templates'); |
|
60 | + // get document groups for current user |
|
61 | + $docgrp = (isset($_SESSION['mgrDocgroups']) && is_array($_SESSION['mgrDocgroups'])) ? implode(',', $_SESSION['mgrDocgroups']) : ''; |
|
62 | + $showProtected = false; |
|
63 | + if(isset ($modx->config['tree_show_protected'])) { |
|
64 | + $showProtected = (boolean) $modx->config['tree_show_protected']; |
|
65 | + } |
|
66 | + $mgrRole = (isset ($_SESSION['mgrRole']) && (string) $_SESSION['mgrRole'] === '1') ? '1' : '0'; |
|
67 | + if($showProtected == false) { |
|
68 | + $access = "AND (1={$mgrRole} OR sc.privatemgr=0" . (!$docgrp ? ')' : " OR dg.document_group IN ({$docgrp}))"); |
|
69 | + } else { |
|
70 | + $access = ''; |
|
71 | + } |
|
72 | + $docgrp_cond = $docgrp ? "OR dg.document_group IN ({$docgrp})" : ''; |
|
73 | + $field = "DISTINCT sc.id, pagetitle, longtitle, menutitle, parent, isfolder, published, pub_date, unpub_date, richtext, searchable, cacheable, deleted, type, template, templatename, menuindex, donthit, hidemenu, alias, contentType, privateweb, privatemgr, |
|
74 | 74 | MAX(IF(1={$mgrRole} OR sc.privatemgr=0 {$docgrp_cond}, 1, 0)) AS hasAccess, GROUP_CONCAT(document_group SEPARATOR ',') AS roles"; |
75 | - $from = "{$tblsc} AS sc LEFT JOIN {$tbldg} dg on dg.document = sc.id LEFT JOIN {$tblst} st on st.id = sc.template"; |
|
76 | - $where = "(parent={$parent}) {$access} GROUP BY sc.id"; |
|
77 | - $result = $modx->db->select($field, $from, $where, $orderby); |
|
78 | - if($modx->db->getRecordCount($result) == 0) { |
|
79 | - $output .= sprintf('<div><a class="empty">%s%s <span class="empty">%s</span></a></div>', $spacer, $_style['tree_deletedpage'], $_lang['empty_folder']); |
|
80 | - } |
|
81 | - |
|
82 | - $nodeNameSource = $_SESSION['tree_nodename'] == 'default' ? $modx->config['resource_tree_node_name'] : $_SESSION['tree_nodename']; |
|
83 | - |
|
84 | - while($row = $modx->db->getRow($result)) { |
|
85 | - $node = ''; |
|
86 | - |
|
87 | - $nodetitle = getNodeTitle($nodeNameSource, $row); |
|
88 | - $nodetitleDisplay = $nodetitle; |
|
89 | - |
|
90 | - $treeNodeClass = 'node'; |
|
91 | - $treeNodeClass .= $row['hasAccess'] == 0 ? ' protected' : ''; |
|
92 | - |
|
93 | - if($row['deleted'] == 1) { |
|
94 | - $treeNodeClass .= ' deleted'; |
|
95 | - //$nodetitleDisplay = sprintf('<span class="deletedNode">%s</span>', $nodetitle); |
|
96 | - } elseif($row['published'] == 0) { |
|
97 | - $treeNodeClass .= ' unpublished'; |
|
98 | - //$nodetitleDisplay = sprintf('<span class="unpublishedNode">%s</span>', $nodetitle); |
|
99 | - } elseif($row['hidemenu'] == 1) { |
|
100 | - $treeNodeClass .= ' hidemenu'; |
|
101 | - //$nodetitleDisplay = sprintf('<span class="notInMenuNode%s">%s</span>', $protectedClass, $nodetitle); |
|
102 | - } else { |
|
103 | - //$nodetitleDisplay = sprintf('<span class="publishedNode%s">%s</span>', $protectedClass, $nodetitle); |
|
104 | - } |
|
105 | - |
|
106 | - if($row['id'] == $hereid) { |
|
107 | - $treeNodeClass .= ' current'; |
|
108 | - } |
|
109 | - |
|
110 | - $weblinkDisplay = $row['type'] == 'reference' ? sprintf(' %s', $_style['tree_linkgo']) : ''; |
|
111 | - $pageIdDisplay = '<small>(' . ($modx_textdir ? '‏' : '') . $row['id'] . ')</small>'; |
|
112 | - |
|
113 | - // Prepare displaying user-locks |
|
114 | - $lockedByUser = ''; |
|
115 | - $rowLock = $modx->elementIsLocked(7, $row['id'], true); |
|
116 | - if($rowLock && $modx->hasPermission('display_locks')) { |
|
117 | - if($rowLock['sid'] == $modx->sid) { |
|
118 | - $title = $modx->parseText($_lang["lock_element_editing"], array( |
|
119 | - 'element_type' => $_lang["lock_element_type_7"], |
|
120 | - 'lasthit_df' => $rowLock['lasthit_df'] |
|
121 | - )); |
|
122 | - $lockedByUser = '<span title="' . $title . '" class="editResource">' . $_style['tree_preview_resource'] . '</span>'; |
|
123 | - } else { |
|
124 | - $title = $modx->parseText($_lang["lock_element_locked_by"], array( |
|
125 | - 'element_type' => $_lang["lock_element_type_7"], |
|
126 | - 'username' => $rowLock['username'], |
|
127 | - 'lasthit_df' => $rowLock['lasthit_df'] |
|
128 | - )); |
|
129 | - if($modx->hasPermission('remove_locks')) { |
|
130 | - $lockedByUser = '<span onclick="modx.tree.unlockElement(7, ' . $row['id'] . ', this);return false;" title="' . $title . '" class="lockedResource">' . $_style['icons_secured'] . '</span>'; |
|
131 | - } else { |
|
132 | - $lockedByUser = '<span title="' . $title . '" class="lockedResource">' . $_style['icons_secured'] . '</span>'; |
|
133 | - } |
|
134 | - } |
|
135 | - } |
|
136 | - |
|
137 | - $url = $modx->makeUrl($row['id']); |
|
138 | - |
|
139 | - $title = ''; |
|
140 | - if(isDateNode($nodeNameSource)) { |
|
141 | - $title = $_lang['pagetitle'] . ': ' . $row['pagetitle'] . '[+lf+]'; |
|
142 | - } |
|
143 | - $title .= $_lang['id'] . ': ' . $row['id']; |
|
144 | - $title .= '[+lf+]' . $_lang['resource_opt_menu_title'] . ': ' . $row['menutitle']; |
|
145 | - $title .= '[+lf+]' . $_lang['resource_opt_menu_index'] . ': ' . $row['menuindex']; |
|
146 | - $title .= '[+lf+]' . $_lang['alias'] . ': ' . (!empty($row['alias']) ? $row['alias'] : '-'); |
|
147 | - $title .= '[+lf+]' . $_lang['template'] . ': ' . $row['templatename']; |
|
148 | - $title .= '[+lf+]' . $_lang['publish_date'] . ': ' . $modx->toDateFormat($row['pub_date']); |
|
149 | - $title .= '[+lf+]' . $_lang['unpublish_date'] . ': ' . $modx->toDateFormat($row['unpub_date']); |
|
150 | - $title .= '[+lf+]' . $_lang['page_data_web_access'] . ': ' . ($row['privateweb'] ? $_lang['private'] : $_lang['public']); |
|
151 | - $title .= '[+lf+]' . $_lang['page_data_mgr_access'] . ': ' . ($row['privatemgr'] ? $_lang['private'] : $_lang['public']); |
|
152 | - $title .= '[+lf+]' . $_lang['resource_opt_richtext'] . ': ' . ($row['richtext'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
153 | - $title .= '[+lf+]' . $_lang['page_data_searchable'] . ': ' . ($row['searchable'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
154 | - $title .= '[+lf+]' . $_lang['page_data_cacheable'] . ': ' . ($row['cacheable'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
155 | - $title = $modx->htmlspecialchars($title); |
|
156 | - $title = str_replace('[+lf+]', ' ', $title); // replace line-breaks with empty space as fall-back |
|
157 | - |
|
158 | - $data = array( |
|
159 | - 'id' => $row['id'], |
|
160 | - 'pagetitle' => $row['pagetitle'], |
|
161 | - 'longtitle' => $row['longtitle'], |
|
162 | - 'menutitle' => $row['menutitle'], |
|
163 | - 'parent' => $parent, |
|
164 | - 'isfolder' => $row['isfolder'], |
|
165 | - 'published' => $row['published'], |
|
166 | - 'deleted' => $row['deleted'], |
|
167 | - 'type' => $row['type'], |
|
168 | - 'menuindex' => $row['menuindex'], |
|
169 | - 'donthit' => $row['donthit'], |
|
170 | - 'hidemenu' => $row['hidemenu'], |
|
171 | - 'alias' => $row['alias'], |
|
172 | - 'contenttype' => $row['contentType'], |
|
173 | - 'privateweb' => $row['privateweb'], |
|
174 | - 'privatemgr' => $row['privatemgr'], |
|
175 | - 'hasAccess' => $row['hasAccess'], |
|
176 | - 'template' => $row['template'], |
|
177 | - 'nodetitle' => $nodetitle, |
|
178 | - 'url' => $url, |
|
179 | - 'title' => $title, |
|
180 | - 'nodetitleDisplay' => $nodetitleDisplay, |
|
181 | - 'weblinkDisplay' => $weblinkDisplay, |
|
182 | - 'pageIdDisplay' => $pageIdDisplay, |
|
183 | - 'lockedByUser' => $lockedByUser, |
|
184 | - 'treeNodeClass' => $treeNodeClass, |
|
185 | - 'treeNodeSelected' => $row['id'] == $hereid ? ' treeNodeSelected' : '', |
|
186 | - 'tree_page_click' => $modx->config['tree_page_click'], |
|
187 | - 'showChildren' => 1, |
|
188 | - 'openFolder' => 1, |
|
189 | - 'contextmenu' => '', |
|
190 | - 'tree_minusnode' => $_style['tree_minusnode'], |
|
191 | - 'tree_plusnode' => $_style['tree_plusnode'], |
|
192 | - 'spacer' => $spacer, |
|
193 | - 'subMenuState' => '', |
|
194 | - 'level' => $level, |
|
195 | - 'isPrivate' => 0, |
|
196 | - 'roles' => ($row['roles'] ? $row['roles'] : '') |
|
197 | - ); |
|
198 | - |
|
199 | - $ph = $data; |
|
200 | - $ph['nodetitle_esc'] = addslashes($nodetitle); |
|
201 | - $ph['indent'] = $indent + 1; |
|
202 | - $ph['expandAll'] = $expandAll; |
|
203 | - $ph['isPrivate'] = ($row['privateweb'] || $row['privatemgr']) ? 1 : 0; |
|
204 | - |
|
205 | - if(!$row['isfolder']) { |
|
206 | - $tpl = getTplSingleNode(); |
|
207 | - switch($row['id']) { |
|
208 | - case $modx->config['site_start'] : |
|
209 | - $icon = $_style['tree_page_home']; |
|
210 | - break; |
|
211 | - case $modx->config['error_page'] : |
|
212 | - $icon = $_style['tree_page_404']; |
|
213 | - break; |
|
214 | - case $modx->config['site_unavailable_page'] : |
|
215 | - $icon = $_style['tree_page_hourglass']; |
|
216 | - break; |
|
217 | - case $modx->config['unauthorized_page'] : |
|
218 | - $icon = $_style['tree_page_info']; |
|
219 | - break; |
|
220 | - default: |
|
221 | - if(isset($icons[$row['contentType']])) { |
|
222 | - $icon = $icons[$row['contentType']]; |
|
223 | - } else { |
|
224 | - $icon = $_style['tree_page']; |
|
225 | - } |
|
226 | - } |
|
227 | - $ph['icon'] = $icon; |
|
228 | - |
|
229 | - // invoke OnManagerNodePrerender event |
|
230 | - $prenode = $modx->invokeEvent("OnManagerNodePrerender", array('ph' => $ph)); |
|
231 | - if(is_array($prenode)) { |
|
232 | - $phnew = array(); |
|
233 | - foreach($prenode as $pnode) { |
|
234 | - $phnew = array_merge($phnew, unserialize($pnode)); |
|
235 | - } |
|
236 | - $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
237 | - } |
|
238 | - |
|
239 | - if($ph['contextmenu']) { |
|
240 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
241 | - } |
|
242 | - |
|
243 | - if($_SESSION['tree_show_only_folders']) { |
|
244 | - if($row['parent'] == 0) { |
|
245 | - $node .= $modx->parseText($tpl, $ph); |
|
246 | - } else { |
|
247 | - $node .= ''; |
|
248 | - } |
|
249 | - } else { |
|
250 | - $node .= $modx->parseText($tpl, $ph); |
|
251 | - } |
|
252 | - |
|
253 | - } else { |
|
254 | - $ph['icon_folder_open'] = $_style['tree_folderopen_new']; |
|
255 | - $ph['icon_folder_close'] = $_style['tree_folder_new']; |
|
256 | - |
|
257 | - if($_SESSION['tree_show_only_folders']) { |
|
258 | - $tpl = getTplFolderNodeNotChildren(); |
|
259 | - $checkFolders = checkIsFolder($row['id'], 1) ? 1 : 0; // folders |
|
260 | - $checkDocs = checkIsFolder($row['id'], 0) ? 1 : 0; // no folders |
|
261 | - $ph['tree_page_click'] = 3; |
|
262 | - |
|
263 | - // expandAll: two type for partial expansion |
|
264 | - if($expandAll == 1 || ($expandAll == 2 && in_array($row['id'], $opened))) { |
|
265 | - if($expandAll == 1) { |
|
266 | - $opened2[] = $row['id']; |
|
267 | - } |
|
268 | - $ph['icon'] = $ph['icon_folder_open']; |
|
269 | - $ph['icon_node_toggle'] = $ph['tree_minusnode']; |
|
270 | - $ph['node_toggle'] = 1; |
|
271 | - $ph['subMenuState'] = ' open'; |
|
272 | - |
|
273 | - if(($checkDocs && !$checkFolders) || (!$checkDocs && !$checkFolders)) { |
|
274 | - $ph['showChildren'] = 1; |
|
275 | - $ph['icon_node_toggle'] = ''; |
|
276 | - $ph['icon'] = $ph['icon_folder_close']; |
|
277 | - } elseif(!$checkDocs && $checkFolders) { |
|
278 | - $ph['showChildren'] = 0; |
|
279 | - $ph['openFolder'] = 2; |
|
280 | - } else { |
|
281 | - $ph['openFolder'] = 2; |
|
282 | - } |
|
283 | - |
|
284 | - // invoke OnManagerNodePrerender event |
|
285 | - $prenode = $modx->invokeEvent("OnManagerNodePrerender", array( |
|
286 | - 'ph' => $ph, |
|
287 | - 'opened' => '1' |
|
288 | - )); |
|
289 | - if(is_array($prenode)) { |
|
290 | - $phnew = array(); |
|
291 | - foreach($prenode as $pnode) { |
|
292 | - $phnew = array_merge($phnew, unserialize($pnode)); |
|
293 | - } |
|
294 | - $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
295 | - } |
|
296 | - |
|
297 | - if($ph['contextmenu']) { |
|
298 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
299 | - } |
|
300 | - |
|
301 | - $node .= $modx->parseText($tpl, $ph); |
|
302 | - if($checkFolders) { |
|
303 | - $node .= makeHTML($indent + 1, $row['id'], $expandAll, $theme, $hereid); |
|
304 | - } |
|
305 | - $node .= '</div></div>'; |
|
306 | - } else { |
|
307 | - $closed2[] = $row['id']; |
|
308 | - $ph['icon'] = $ph['icon_folder_close']; |
|
309 | - $ph['icon_node_toggle'] = $ph['tree_plusnode']; |
|
310 | - $ph['node_toggle'] = 0; |
|
311 | - |
|
312 | - if(($checkDocs && !$checkFolders) || (!$checkDocs && !$checkFolders)) { |
|
313 | - $ph['showChildren'] = 1; |
|
314 | - $ph['icon_node_toggle'] = ''; |
|
315 | - } elseif(!$checkDocs && $checkFolders) { |
|
316 | - $ph['showChildren'] = 0; |
|
317 | - $ph['openFolder'] = 2; |
|
318 | - } else { |
|
319 | - $ph['openFolder'] = 2; |
|
320 | - } |
|
321 | - |
|
322 | - // invoke OnManagerNodePrerender event |
|
323 | - $prenode = $modx->invokeEvent("OnManagerNodePrerender", array( |
|
324 | - 'ph' => $ph, |
|
325 | - 'opened' => '0' |
|
326 | - )); |
|
327 | - if(is_array($prenode)) { |
|
328 | - $phnew = array(); |
|
329 | - foreach($prenode as $pnode) { |
|
330 | - $phnew = array_merge($phnew, unserialize($pnode)); |
|
331 | - } |
|
332 | - $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
333 | - } |
|
334 | - |
|
335 | - if($ph['contextmenu']) { |
|
336 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
337 | - } |
|
338 | - |
|
339 | - $node .= $modx->parseText($tpl, $ph); |
|
340 | - $node .= '</div></div>'; |
|
341 | - } |
|
342 | - } else { |
|
343 | - $tpl = getTplFolderNode(); |
|
344 | - // expandAll: two type for partial expansion |
|
345 | - if($expandAll == 1 || ($expandAll == 2 && in_array($row['id'], $opened))) { |
|
346 | - if($expandAll == 1) { |
|
347 | - $opened2[] = $row['id']; |
|
348 | - } |
|
349 | - $ph['icon'] = $ph['icon_folder_open']; |
|
350 | - $ph['icon_node_toggle'] = $ph['tree_minusnode']; |
|
351 | - $ph['node_toggle'] = 1; |
|
352 | - $ph['subMenuState'] = ' open'; |
|
353 | - |
|
354 | - if($ph['donthit'] == 1) { |
|
355 | - $ph['tree_page_click'] = 3; |
|
356 | - $ph['icon_node_toggle'] = ''; |
|
357 | - $ph['icon'] = $ph['icon_folder_close']; |
|
358 | - $ph['showChildren'] = 0; |
|
359 | - } |
|
360 | - |
|
361 | - // invoke OnManagerNodePrerender event |
|
362 | - $prenode = $modx->invokeEvent("OnManagerNodePrerender", array( |
|
363 | - 'ph' => $ph, |
|
364 | - 'opened' => '1' |
|
365 | - )); |
|
366 | - if(is_array($prenode)) { |
|
367 | - $phnew = array(); |
|
368 | - foreach($prenode as $pnode) { |
|
369 | - $phnew = array_merge($phnew, unserialize($pnode)); |
|
370 | - } |
|
371 | - $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
372 | - if($ph['showChildren'] == 0) { |
|
373 | - unset($opened2[$row['id']]); |
|
374 | - $ph['node_toggle'] = 0; |
|
375 | - $ph['subMenuState'] = ''; |
|
376 | - } |
|
377 | - } |
|
378 | - |
|
379 | - if($ph['showChildren'] == 0) { |
|
380 | - $ph['icon_node_toggle'] = ''; |
|
381 | - $ph['donthit'] = 1; |
|
382 | - $ph['icon'] = $ph['icon_folder_close']; |
|
383 | - $tpl = getTplFolderNodeNotChildren(); |
|
384 | - } |
|
385 | - |
|
386 | - if($ph['contextmenu']) { |
|
387 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
388 | - } |
|
389 | - |
|
390 | - $node .= $modx->parseText($tpl, $ph); |
|
391 | - if($ph['donthit'] == 0) { |
|
392 | - $node .= makeHTML($indent + 1, $row['id'], $expandAll, $theme, $hereid); |
|
393 | - } |
|
394 | - $node .= '</div></div>'; |
|
395 | - } else { |
|
396 | - $closed2[] = $row['id']; |
|
397 | - $ph['icon'] = $ph['icon_folder_close']; |
|
398 | - $ph['icon_node_toggle'] = $ph['tree_plusnode']; |
|
399 | - $ph['node_toggle'] = 0; |
|
400 | - |
|
401 | - if($ph['donthit'] == 1) { |
|
402 | - $ph['tree_page_click'] = 3; |
|
403 | - $ph['icon_node_toggle'] = ''; |
|
404 | - $ph['icon'] = $ph['icon_folder_close']; |
|
405 | - $ph['showChildren'] = 0; |
|
406 | - } |
|
407 | - |
|
408 | - // invoke OnManagerNodePrerender event |
|
409 | - $prenode = $modx->invokeEvent("OnManagerNodePrerender", array( |
|
410 | - 'ph' => $ph, |
|
411 | - 'opened' => '0' |
|
412 | - )); |
|
413 | - if(is_array($prenode)) { |
|
414 | - $phnew = array(); |
|
415 | - foreach($prenode as $pnode) { |
|
416 | - $phnew = array_merge($phnew, unserialize($pnode)); |
|
417 | - } |
|
418 | - $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
419 | - } |
|
420 | - |
|
421 | - if($ph['showChildren'] == 0) { |
|
422 | - $ph['icon_node_toggle'] = ''; |
|
423 | - $ph['donthit'] = 1; |
|
424 | - $ph['icon'] = $ph['icon_folder_close']; |
|
425 | - $tpl = getTplFolderNodeNotChildren(); |
|
426 | - } |
|
427 | - |
|
428 | - if($ph['contextmenu']) { |
|
429 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
430 | - } |
|
431 | - |
|
432 | - $node .= $modx->parseText($tpl, $ph); |
|
433 | - $node .= '</div></div>'; |
|
434 | - } |
|
435 | - } |
|
436 | - } |
|
437 | - |
|
438 | - // invoke OnManagerNodeRender event |
|
439 | - $data['node'] = $node; |
|
440 | - $evtOut = $modx->invokeEvent('OnManagerNodeRender', $data); |
|
441 | - if(is_array($evtOut)) { |
|
442 | - $evtOut = implode("\n", $evtOut); |
|
443 | - } |
|
444 | - if($evtOut != '') { |
|
445 | - $node = trim($evtOut); |
|
446 | - } |
|
447 | - |
|
448 | - $output .= $node; |
|
449 | - } |
|
450 | - |
|
451 | - return $output; |
|
75 | + $from = "{$tblsc} AS sc LEFT JOIN {$tbldg} dg on dg.document = sc.id LEFT JOIN {$tblst} st on st.id = sc.template"; |
|
76 | + $where = "(parent={$parent}) {$access} GROUP BY sc.id"; |
|
77 | + $result = $modx->db->select($field, $from, $where, $orderby); |
|
78 | + if($modx->db->getRecordCount($result) == 0) { |
|
79 | + $output .= sprintf('<div><a class="empty">%s%s <span class="empty">%s</span></a></div>', $spacer, $_style['tree_deletedpage'], $_lang['empty_folder']); |
|
80 | + } |
|
81 | + |
|
82 | + $nodeNameSource = $_SESSION['tree_nodename'] == 'default' ? $modx->config['resource_tree_node_name'] : $_SESSION['tree_nodename']; |
|
83 | + |
|
84 | + while($row = $modx->db->getRow($result)) { |
|
85 | + $node = ''; |
|
86 | + |
|
87 | + $nodetitle = getNodeTitle($nodeNameSource, $row); |
|
88 | + $nodetitleDisplay = $nodetitle; |
|
89 | + |
|
90 | + $treeNodeClass = 'node'; |
|
91 | + $treeNodeClass .= $row['hasAccess'] == 0 ? ' protected' : ''; |
|
92 | + |
|
93 | + if($row['deleted'] == 1) { |
|
94 | + $treeNodeClass .= ' deleted'; |
|
95 | + //$nodetitleDisplay = sprintf('<span class="deletedNode">%s</span>', $nodetitle); |
|
96 | + } elseif($row['published'] == 0) { |
|
97 | + $treeNodeClass .= ' unpublished'; |
|
98 | + //$nodetitleDisplay = sprintf('<span class="unpublishedNode">%s</span>', $nodetitle); |
|
99 | + } elseif($row['hidemenu'] == 1) { |
|
100 | + $treeNodeClass .= ' hidemenu'; |
|
101 | + //$nodetitleDisplay = sprintf('<span class="notInMenuNode%s">%s</span>', $protectedClass, $nodetitle); |
|
102 | + } else { |
|
103 | + //$nodetitleDisplay = sprintf('<span class="publishedNode%s">%s</span>', $protectedClass, $nodetitle); |
|
104 | + } |
|
105 | + |
|
106 | + if($row['id'] == $hereid) { |
|
107 | + $treeNodeClass .= ' current'; |
|
108 | + } |
|
109 | + |
|
110 | + $weblinkDisplay = $row['type'] == 'reference' ? sprintf(' %s', $_style['tree_linkgo']) : ''; |
|
111 | + $pageIdDisplay = '<small>(' . ($modx_textdir ? '‏' : '') . $row['id'] . ')</small>'; |
|
112 | + |
|
113 | + // Prepare displaying user-locks |
|
114 | + $lockedByUser = ''; |
|
115 | + $rowLock = $modx->elementIsLocked(7, $row['id'], true); |
|
116 | + if($rowLock && $modx->hasPermission('display_locks')) { |
|
117 | + if($rowLock['sid'] == $modx->sid) { |
|
118 | + $title = $modx->parseText($_lang["lock_element_editing"], array( |
|
119 | + 'element_type' => $_lang["lock_element_type_7"], |
|
120 | + 'lasthit_df' => $rowLock['lasthit_df'] |
|
121 | + )); |
|
122 | + $lockedByUser = '<span title="' . $title . '" class="editResource">' . $_style['tree_preview_resource'] . '</span>'; |
|
123 | + } else { |
|
124 | + $title = $modx->parseText($_lang["lock_element_locked_by"], array( |
|
125 | + 'element_type' => $_lang["lock_element_type_7"], |
|
126 | + 'username' => $rowLock['username'], |
|
127 | + 'lasthit_df' => $rowLock['lasthit_df'] |
|
128 | + )); |
|
129 | + if($modx->hasPermission('remove_locks')) { |
|
130 | + $lockedByUser = '<span onclick="modx.tree.unlockElement(7, ' . $row['id'] . ', this);return false;" title="' . $title . '" class="lockedResource">' . $_style['icons_secured'] . '</span>'; |
|
131 | + } else { |
|
132 | + $lockedByUser = '<span title="' . $title . '" class="lockedResource">' . $_style['icons_secured'] . '</span>'; |
|
133 | + } |
|
134 | + } |
|
135 | + } |
|
136 | + |
|
137 | + $url = $modx->makeUrl($row['id']); |
|
138 | + |
|
139 | + $title = ''; |
|
140 | + if(isDateNode($nodeNameSource)) { |
|
141 | + $title = $_lang['pagetitle'] . ': ' . $row['pagetitle'] . '[+lf+]'; |
|
142 | + } |
|
143 | + $title .= $_lang['id'] . ': ' . $row['id']; |
|
144 | + $title .= '[+lf+]' . $_lang['resource_opt_menu_title'] . ': ' . $row['menutitle']; |
|
145 | + $title .= '[+lf+]' . $_lang['resource_opt_menu_index'] . ': ' . $row['menuindex']; |
|
146 | + $title .= '[+lf+]' . $_lang['alias'] . ': ' . (!empty($row['alias']) ? $row['alias'] : '-'); |
|
147 | + $title .= '[+lf+]' . $_lang['template'] . ': ' . $row['templatename']; |
|
148 | + $title .= '[+lf+]' . $_lang['publish_date'] . ': ' . $modx->toDateFormat($row['pub_date']); |
|
149 | + $title .= '[+lf+]' . $_lang['unpublish_date'] . ': ' . $modx->toDateFormat($row['unpub_date']); |
|
150 | + $title .= '[+lf+]' . $_lang['page_data_web_access'] . ': ' . ($row['privateweb'] ? $_lang['private'] : $_lang['public']); |
|
151 | + $title .= '[+lf+]' . $_lang['page_data_mgr_access'] . ': ' . ($row['privatemgr'] ? $_lang['private'] : $_lang['public']); |
|
152 | + $title .= '[+lf+]' . $_lang['resource_opt_richtext'] . ': ' . ($row['richtext'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
153 | + $title .= '[+lf+]' . $_lang['page_data_searchable'] . ': ' . ($row['searchable'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
154 | + $title .= '[+lf+]' . $_lang['page_data_cacheable'] . ': ' . ($row['cacheable'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
155 | + $title = $modx->htmlspecialchars($title); |
|
156 | + $title = str_replace('[+lf+]', ' ', $title); // replace line-breaks with empty space as fall-back |
|
157 | + |
|
158 | + $data = array( |
|
159 | + 'id' => $row['id'], |
|
160 | + 'pagetitle' => $row['pagetitle'], |
|
161 | + 'longtitle' => $row['longtitle'], |
|
162 | + 'menutitle' => $row['menutitle'], |
|
163 | + 'parent' => $parent, |
|
164 | + 'isfolder' => $row['isfolder'], |
|
165 | + 'published' => $row['published'], |
|
166 | + 'deleted' => $row['deleted'], |
|
167 | + 'type' => $row['type'], |
|
168 | + 'menuindex' => $row['menuindex'], |
|
169 | + 'donthit' => $row['donthit'], |
|
170 | + 'hidemenu' => $row['hidemenu'], |
|
171 | + 'alias' => $row['alias'], |
|
172 | + 'contenttype' => $row['contentType'], |
|
173 | + 'privateweb' => $row['privateweb'], |
|
174 | + 'privatemgr' => $row['privatemgr'], |
|
175 | + 'hasAccess' => $row['hasAccess'], |
|
176 | + 'template' => $row['template'], |
|
177 | + 'nodetitle' => $nodetitle, |
|
178 | + 'url' => $url, |
|
179 | + 'title' => $title, |
|
180 | + 'nodetitleDisplay' => $nodetitleDisplay, |
|
181 | + 'weblinkDisplay' => $weblinkDisplay, |
|
182 | + 'pageIdDisplay' => $pageIdDisplay, |
|
183 | + 'lockedByUser' => $lockedByUser, |
|
184 | + 'treeNodeClass' => $treeNodeClass, |
|
185 | + 'treeNodeSelected' => $row['id'] == $hereid ? ' treeNodeSelected' : '', |
|
186 | + 'tree_page_click' => $modx->config['tree_page_click'], |
|
187 | + 'showChildren' => 1, |
|
188 | + 'openFolder' => 1, |
|
189 | + 'contextmenu' => '', |
|
190 | + 'tree_minusnode' => $_style['tree_minusnode'], |
|
191 | + 'tree_plusnode' => $_style['tree_plusnode'], |
|
192 | + 'spacer' => $spacer, |
|
193 | + 'subMenuState' => '', |
|
194 | + 'level' => $level, |
|
195 | + 'isPrivate' => 0, |
|
196 | + 'roles' => ($row['roles'] ? $row['roles'] : '') |
|
197 | + ); |
|
198 | + |
|
199 | + $ph = $data; |
|
200 | + $ph['nodetitle_esc'] = addslashes($nodetitle); |
|
201 | + $ph['indent'] = $indent + 1; |
|
202 | + $ph['expandAll'] = $expandAll; |
|
203 | + $ph['isPrivate'] = ($row['privateweb'] || $row['privatemgr']) ? 1 : 0; |
|
204 | + |
|
205 | + if(!$row['isfolder']) { |
|
206 | + $tpl = getTplSingleNode(); |
|
207 | + switch($row['id']) { |
|
208 | + case $modx->config['site_start'] : |
|
209 | + $icon = $_style['tree_page_home']; |
|
210 | + break; |
|
211 | + case $modx->config['error_page'] : |
|
212 | + $icon = $_style['tree_page_404']; |
|
213 | + break; |
|
214 | + case $modx->config['site_unavailable_page'] : |
|
215 | + $icon = $_style['tree_page_hourglass']; |
|
216 | + break; |
|
217 | + case $modx->config['unauthorized_page'] : |
|
218 | + $icon = $_style['tree_page_info']; |
|
219 | + break; |
|
220 | + default: |
|
221 | + if(isset($icons[$row['contentType']])) { |
|
222 | + $icon = $icons[$row['contentType']]; |
|
223 | + } else { |
|
224 | + $icon = $_style['tree_page']; |
|
225 | + } |
|
226 | + } |
|
227 | + $ph['icon'] = $icon; |
|
228 | + |
|
229 | + // invoke OnManagerNodePrerender event |
|
230 | + $prenode = $modx->invokeEvent("OnManagerNodePrerender", array('ph' => $ph)); |
|
231 | + if(is_array($prenode)) { |
|
232 | + $phnew = array(); |
|
233 | + foreach($prenode as $pnode) { |
|
234 | + $phnew = array_merge($phnew, unserialize($pnode)); |
|
235 | + } |
|
236 | + $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
237 | + } |
|
238 | + |
|
239 | + if($ph['contextmenu']) { |
|
240 | + $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
241 | + } |
|
242 | + |
|
243 | + if($_SESSION['tree_show_only_folders']) { |
|
244 | + if($row['parent'] == 0) { |
|
245 | + $node .= $modx->parseText($tpl, $ph); |
|
246 | + } else { |
|
247 | + $node .= ''; |
|
248 | + } |
|
249 | + } else { |
|
250 | + $node .= $modx->parseText($tpl, $ph); |
|
251 | + } |
|
252 | + |
|
253 | + } else { |
|
254 | + $ph['icon_folder_open'] = $_style['tree_folderopen_new']; |
|
255 | + $ph['icon_folder_close'] = $_style['tree_folder_new']; |
|
256 | + |
|
257 | + if($_SESSION['tree_show_only_folders']) { |
|
258 | + $tpl = getTplFolderNodeNotChildren(); |
|
259 | + $checkFolders = checkIsFolder($row['id'], 1) ? 1 : 0; // folders |
|
260 | + $checkDocs = checkIsFolder($row['id'], 0) ? 1 : 0; // no folders |
|
261 | + $ph['tree_page_click'] = 3; |
|
262 | + |
|
263 | + // expandAll: two type for partial expansion |
|
264 | + if($expandAll == 1 || ($expandAll == 2 && in_array($row['id'], $opened))) { |
|
265 | + if($expandAll == 1) { |
|
266 | + $opened2[] = $row['id']; |
|
267 | + } |
|
268 | + $ph['icon'] = $ph['icon_folder_open']; |
|
269 | + $ph['icon_node_toggle'] = $ph['tree_minusnode']; |
|
270 | + $ph['node_toggle'] = 1; |
|
271 | + $ph['subMenuState'] = ' open'; |
|
272 | + |
|
273 | + if(($checkDocs && !$checkFolders) || (!$checkDocs && !$checkFolders)) { |
|
274 | + $ph['showChildren'] = 1; |
|
275 | + $ph['icon_node_toggle'] = ''; |
|
276 | + $ph['icon'] = $ph['icon_folder_close']; |
|
277 | + } elseif(!$checkDocs && $checkFolders) { |
|
278 | + $ph['showChildren'] = 0; |
|
279 | + $ph['openFolder'] = 2; |
|
280 | + } else { |
|
281 | + $ph['openFolder'] = 2; |
|
282 | + } |
|
283 | + |
|
284 | + // invoke OnManagerNodePrerender event |
|
285 | + $prenode = $modx->invokeEvent("OnManagerNodePrerender", array( |
|
286 | + 'ph' => $ph, |
|
287 | + 'opened' => '1' |
|
288 | + )); |
|
289 | + if(is_array($prenode)) { |
|
290 | + $phnew = array(); |
|
291 | + foreach($prenode as $pnode) { |
|
292 | + $phnew = array_merge($phnew, unserialize($pnode)); |
|
293 | + } |
|
294 | + $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
295 | + } |
|
296 | + |
|
297 | + if($ph['contextmenu']) { |
|
298 | + $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
299 | + } |
|
300 | + |
|
301 | + $node .= $modx->parseText($tpl, $ph); |
|
302 | + if($checkFolders) { |
|
303 | + $node .= makeHTML($indent + 1, $row['id'], $expandAll, $theme, $hereid); |
|
304 | + } |
|
305 | + $node .= '</div></div>'; |
|
306 | + } else { |
|
307 | + $closed2[] = $row['id']; |
|
308 | + $ph['icon'] = $ph['icon_folder_close']; |
|
309 | + $ph['icon_node_toggle'] = $ph['tree_plusnode']; |
|
310 | + $ph['node_toggle'] = 0; |
|
311 | + |
|
312 | + if(($checkDocs && !$checkFolders) || (!$checkDocs && !$checkFolders)) { |
|
313 | + $ph['showChildren'] = 1; |
|
314 | + $ph['icon_node_toggle'] = ''; |
|
315 | + } elseif(!$checkDocs && $checkFolders) { |
|
316 | + $ph['showChildren'] = 0; |
|
317 | + $ph['openFolder'] = 2; |
|
318 | + } else { |
|
319 | + $ph['openFolder'] = 2; |
|
320 | + } |
|
321 | + |
|
322 | + // invoke OnManagerNodePrerender event |
|
323 | + $prenode = $modx->invokeEvent("OnManagerNodePrerender", array( |
|
324 | + 'ph' => $ph, |
|
325 | + 'opened' => '0' |
|
326 | + )); |
|
327 | + if(is_array($prenode)) { |
|
328 | + $phnew = array(); |
|
329 | + foreach($prenode as $pnode) { |
|
330 | + $phnew = array_merge($phnew, unserialize($pnode)); |
|
331 | + } |
|
332 | + $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
333 | + } |
|
334 | + |
|
335 | + if($ph['contextmenu']) { |
|
336 | + $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
337 | + } |
|
338 | + |
|
339 | + $node .= $modx->parseText($tpl, $ph); |
|
340 | + $node .= '</div></div>'; |
|
341 | + } |
|
342 | + } else { |
|
343 | + $tpl = getTplFolderNode(); |
|
344 | + // expandAll: two type for partial expansion |
|
345 | + if($expandAll == 1 || ($expandAll == 2 && in_array($row['id'], $opened))) { |
|
346 | + if($expandAll == 1) { |
|
347 | + $opened2[] = $row['id']; |
|
348 | + } |
|
349 | + $ph['icon'] = $ph['icon_folder_open']; |
|
350 | + $ph['icon_node_toggle'] = $ph['tree_minusnode']; |
|
351 | + $ph['node_toggle'] = 1; |
|
352 | + $ph['subMenuState'] = ' open'; |
|
353 | + |
|
354 | + if($ph['donthit'] == 1) { |
|
355 | + $ph['tree_page_click'] = 3; |
|
356 | + $ph['icon_node_toggle'] = ''; |
|
357 | + $ph['icon'] = $ph['icon_folder_close']; |
|
358 | + $ph['showChildren'] = 0; |
|
359 | + } |
|
360 | + |
|
361 | + // invoke OnManagerNodePrerender event |
|
362 | + $prenode = $modx->invokeEvent("OnManagerNodePrerender", array( |
|
363 | + 'ph' => $ph, |
|
364 | + 'opened' => '1' |
|
365 | + )); |
|
366 | + if(is_array($prenode)) { |
|
367 | + $phnew = array(); |
|
368 | + foreach($prenode as $pnode) { |
|
369 | + $phnew = array_merge($phnew, unserialize($pnode)); |
|
370 | + } |
|
371 | + $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
372 | + if($ph['showChildren'] == 0) { |
|
373 | + unset($opened2[$row['id']]); |
|
374 | + $ph['node_toggle'] = 0; |
|
375 | + $ph['subMenuState'] = ''; |
|
376 | + } |
|
377 | + } |
|
378 | + |
|
379 | + if($ph['showChildren'] == 0) { |
|
380 | + $ph['icon_node_toggle'] = ''; |
|
381 | + $ph['donthit'] = 1; |
|
382 | + $ph['icon'] = $ph['icon_folder_close']; |
|
383 | + $tpl = getTplFolderNodeNotChildren(); |
|
384 | + } |
|
385 | + |
|
386 | + if($ph['contextmenu']) { |
|
387 | + $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
388 | + } |
|
389 | + |
|
390 | + $node .= $modx->parseText($tpl, $ph); |
|
391 | + if($ph['donthit'] == 0) { |
|
392 | + $node .= makeHTML($indent + 1, $row['id'], $expandAll, $theme, $hereid); |
|
393 | + } |
|
394 | + $node .= '</div></div>'; |
|
395 | + } else { |
|
396 | + $closed2[] = $row['id']; |
|
397 | + $ph['icon'] = $ph['icon_folder_close']; |
|
398 | + $ph['icon_node_toggle'] = $ph['tree_plusnode']; |
|
399 | + $ph['node_toggle'] = 0; |
|
400 | + |
|
401 | + if($ph['donthit'] == 1) { |
|
402 | + $ph['tree_page_click'] = 3; |
|
403 | + $ph['icon_node_toggle'] = ''; |
|
404 | + $ph['icon'] = $ph['icon_folder_close']; |
|
405 | + $ph['showChildren'] = 0; |
|
406 | + } |
|
407 | + |
|
408 | + // invoke OnManagerNodePrerender event |
|
409 | + $prenode = $modx->invokeEvent("OnManagerNodePrerender", array( |
|
410 | + 'ph' => $ph, |
|
411 | + 'opened' => '0' |
|
412 | + )); |
|
413 | + if(is_array($prenode)) { |
|
414 | + $phnew = array(); |
|
415 | + foreach($prenode as $pnode) { |
|
416 | + $phnew = array_merge($phnew, unserialize($pnode)); |
|
417 | + } |
|
418 | + $ph = (count($phnew) > 0) ? $phnew : $ph; |
|
419 | + } |
|
420 | + |
|
421 | + if($ph['showChildren'] == 0) { |
|
422 | + $ph['icon_node_toggle'] = ''; |
|
423 | + $ph['donthit'] = 1; |
|
424 | + $ph['icon'] = $ph['icon_folder_close']; |
|
425 | + $tpl = getTplFolderNodeNotChildren(); |
|
426 | + } |
|
427 | + |
|
428 | + if($ph['contextmenu']) { |
|
429 | + $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
430 | + } |
|
431 | + |
|
432 | + $node .= $modx->parseText($tpl, $ph); |
|
433 | + $node .= '</div></div>'; |
|
434 | + } |
|
435 | + } |
|
436 | + } |
|
437 | + |
|
438 | + // invoke OnManagerNodeRender event |
|
439 | + $data['node'] = $node; |
|
440 | + $evtOut = $modx->invokeEvent('OnManagerNodeRender', $data); |
|
441 | + if(is_array($evtOut)) { |
|
442 | + $evtOut = implode("\n", $evtOut); |
|
443 | + } |
|
444 | + if($evtOut != '') { |
|
445 | + $node = trim($evtOut); |
|
446 | + } |
|
447 | + |
|
448 | + $output .= $node; |
|
449 | + } |
|
450 | + |
|
451 | + return $output; |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | /** |
@@ -456,30 +456,30 @@ discard block |
||
456 | 456 | * @return array |
457 | 457 | */ |
458 | 458 | function getIconInfo($_style) { |
459 | - if(!isset($_style['tree_page_gif'])) { |
|
460 | - $_style['tree_page_gif'] = $_style['tree_page']; |
|
461 | - } |
|
462 | - if(!isset($_style['tree_page_jpg'])) { |
|
463 | - $_style['tree_page_jpg'] = $_style['tree_page']; |
|
464 | - } |
|
465 | - if(!isset($_style['tree_page_png'])) { |
|
466 | - $_style['tree_page_png'] = $_style['tree_page']; |
|
467 | - } |
|
468 | - $icons = array( |
|
469 | - 'text/html' => $_style['tree_page_html'], |
|
470 | - 'text/plain' => $_style['tree_page'], |
|
471 | - 'text/xml' => $_style['tree_page_xml'], |
|
472 | - 'text/css' => $_style['tree_page_css'], |
|
473 | - 'text/javascript' => $_style['tree_page_js'], |
|
474 | - 'application/rss+xml' => $_style['tree_page_rss'], |
|
475 | - 'application/pdf' => $_style['tree_page_pdf'], |
|
476 | - 'application/vnd.ms-word' => $_style['tree_page_word'], |
|
477 | - 'application/vnd.ms-excel' => $_style['tree_page_excel'], |
|
478 | - 'image/gif' => $_style['tree_page_gif'], |
|
479 | - 'image/jpg' => $_style['tree_page_jpg'], |
|
480 | - 'image/png' => $_style['tree_page_png'] |
|
481 | - ); |
|
482 | - return $icons; |
|
459 | + if(!isset($_style['tree_page_gif'])) { |
|
460 | + $_style['tree_page_gif'] = $_style['tree_page']; |
|
461 | + } |
|
462 | + if(!isset($_style['tree_page_jpg'])) { |
|
463 | + $_style['tree_page_jpg'] = $_style['tree_page']; |
|
464 | + } |
|
465 | + if(!isset($_style['tree_page_png'])) { |
|
466 | + $_style['tree_page_png'] = $_style['tree_page']; |
|
467 | + } |
|
468 | + $icons = array( |
|
469 | + 'text/html' => $_style['tree_page_html'], |
|
470 | + 'text/plain' => $_style['tree_page'], |
|
471 | + 'text/xml' => $_style['tree_page_xml'], |
|
472 | + 'text/css' => $_style['tree_page_css'], |
|
473 | + 'text/javascript' => $_style['tree_page_js'], |
|
474 | + 'application/rss+xml' => $_style['tree_page_rss'], |
|
475 | + 'application/pdf' => $_style['tree_page_pdf'], |
|
476 | + 'application/vnd.ms-word' => $_style['tree_page_word'], |
|
477 | + 'application/vnd.ms-excel' => $_style['tree_page_excel'], |
|
478 | + 'image/gif' => $_style['tree_page_gif'], |
|
479 | + 'image/jpg' => $_style['tree_page_jpg'], |
|
480 | + 'image/png' => $_style['tree_page_png'] |
|
481 | + ); |
|
482 | + return $icons; |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | /** |
@@ -487,30 +487,30 @@ discard block |
||
487 | 487 | * @return array |
488 | 488 | */ |
489 | 489 | function getPrivateIconInfo($_style) { |
490 | - if(!isset($_style['tree_page_gif_secure'])) { |
|
491 | - $_style['tree_page_gif_secure'] = $_style['tree_page_secure']; |
|
492 | - } |
|
493 | - if(!isset($_style['tree_page_jpg_secure'])) { |
|
494 | - $_style['tree_page_jpg_secure'] = $_style['tree_page_secure']; |
|
495 | - } |
|
496 | - if(!isset($_style['tree_page_png_secure'])) { |
|
497 | - $_style['tree_page_png_secure'] = $_style['tree_page_secure']; |
|
498 | - } |
|
499 | - $iconsPrivate = array( |
|
500 | - 'text/html' => $_style['tree_page_html_secure'], |
|
501 | - 'text/plain' => $_style['tree_page_secure'], |
|
502 | - 'text/xml' => $_style['tree_page_xml_secure'], |
|
503 | - 'text/css' => $_style['tree_page_css_secure'], |
|
504 | - 'text/javascript' => $_style['tree_page_js_secure'], |
|
505 | - 'application/rss+xml' => $_style['tree_page_rss_secure'], |
|
506 | - 'application/pdf' => $_style['tree_page_pdf_secure'], |
|
507 | - 'application/vnd.ms-word' => $_style['tree_page_word_secure'], |
|
508 | - 'application/vnd.ms-excel' => $_style['tree_page_excel_secure'], |
|
509 | - 'image/gif' => $_style['tree_page_gif_secure'], |
|
510 | - 'image/jpg' => $_style['tree_page_jpg_secure'], |
|
511 | - 'image/png' => $_style['tree_page_png_secure'] |
|
512 | - ); |
|
513 | - return $iconsPrivate; |
|
490 | + if(!isset($_style['tree_page_gif_secure'])) { |
|
491 | + $_style['tree_page_gif_secure'] = $_style['tree_page_secure']; |
|
492 | + } |
|
493 | + if(!isset($_style['tree_page_jpg_secure'])) { |
|
494 | + $_style['tree_page_jpg_secure'] = $_style['tree_page_secure']; |
|
495 | + } |
|
496 | + if(!isset($_style['tree_page_png_secure'])) { |
|
497 | + $_style['tree_page_png_secure'] = $_style['tree_page_secure']; |
|
498 | + } |
|
499 | + $iconsPrivate = array( |
|
500 | + 'text/html' => $_style['tree_page_html_secure'], |
|
501 | + 'text/plain' => $_style['tree_page_secure'], |
|
502 | + 'text/xml' => $_style['tree_page_xml_secure'], |
|
503 | + 'text/css' => $_style['tree_page_css_secure'], |
|
504 | + 'text/javascript' => $_style['tree_page_js_secure'], |
|
505 | + 'application/rss+xml' => $_style['tree_page_rss_secure'], |
|
506 | + 'application/pdf' => $_style['tree_page_pdf_secure'], |
|
507 | + 'application/vnd.ms-word' => $_style['tree_page_word_secure'], |
|
508 | + 'application/vnd.ms-excel' => $_style['tree_page_excel_secure'], |
|
509 | + 'image/gif' => $_style['tree_page_gif_secure'], |
|
510 | + 'image/jpg' => $_style['tree_page_jpg_secure'], |
|
511 | + 'image/png' => $_style['tree_page_png_secure'] |
|
512 | + ); |
|
513 | + return $iconsPrivate; |
|
514 | 514 | } |
515 | 515 | |
516 | 516 | /** |
@@ -519,49 +519,49 @@ discard block |
||
519 | 519 | * @return string |
520 | 520 | */ |
521 | 521 | function getNodeTitle($nodeNameSource, $row) { |
522 | - global $modx; |
|
523 | - |
|
524 | - switch($nodeNameSource) { |
|
525 | - case 'menutitle': |
|
526 | - $nodetitle = $row['menutitle'] ? $row['menutitle'] : $row['pagetitle']; |
|
527 | - break; |
|
528 | - case 'alias': |
|
529 | - $nodetitle = $row['alias'] ? $row['alias'] : $row['id']; |
|
530 | - if(strpos($row['alias'], '.') === false) { |
|
531 | - if($row['isfolder'] != 1 || $modx->config['make_folders'] != 1) { |
|
532 | - $nodetitle .= $modx->config['friendly_url_suffix']; |
|
533 | - } |
|
534 | - } |
|
535 | - $nodetitle = $modx->config['friendly_url_prefix'] . $nodetitle; |
|
536 | - break; |
|
537 | - case 'pagetitle': |
|
538 | - $nodetitle = $row['pagetitle']; |
|
539 | - break; |
|
540 | - case 'longtitle': |
|
541 | - $nodetitle = $row['longtitle'] ? $row['longtitle'] : $row['pagetitle']; |
|
542 | - break; |
|
543 | - case 'createdon': |
|
544 | - case 'editedon': |
|
545 | - case 'publishedon': |
|
546 | - case 'pub_date': |
|
547 | - case 'unpub_date': |
|
548 | - $doc = $modx->getDocumentObject('id', $row['id']); |
|
549 | - $date = $doc[$nodeNameSource]; |
|
550 | - if(!empty($date)) { |
|
551 | - $nodetitle = $modx->toDateFormat($date); |
|
552 | - } else { |
|
553 | - $nodetitle = '- - -'; |
|
554 | - } |
|
555 | - break; |
|
556 | - default: |
|
557 | - $nodetitle = $row['pagetitle']; |
|
558 | - } |
|
559 | - $nodetitle = $modx->htmlspecialchars(str_replace(array( |
|
560 | - "\r\n", |
|
561 | - "\n", |
|
562 | - "\r" |
|
563 | - ), ' ', $nodetitle), ENT_COMPAT); |
|
564 | - return $nodetitle; |
|
522 | + global $modx; |
|
523 | + |
|
524 | + switch($nodeNameSource) { |
|
525 | + case 'menutitle': |
|
526 | + $nodetitle = $row['menutitle'] ? $row['menutitle'] : $row['pagetitle']; |
|
527 | + break; |
|
528 | + case 'alias': |
|
529 | + $nodetitle = $row['alias'] ? $row['alias'] : $row['id']; |
|
530 | + if(strpos($row['alias'], '.') === false) { |
|
531 | + if($row['isfolder'] != 1 || $modx->config['make_folders'] != 1) { |
|
532 | + $nodetitle .= $modx->config['friendly_url_suffix']; |
|
533 | + } |
|
534 | + } |
|
535 | + $nodetitle = $modx->config['friendly_url_prefix'] . $nodetitle; |
|
536 | + break; |
|
537 | + case 'pagetitle': |
|
538 | + $nodetitle = $row['pagetitle']; |
|
539 | + break; |
|
540 | + case 'longtitle': |
|
541 | + $nodetitle = $row['longtitle'] ? $row['longtitle'] : $row['pagetitle']; |
|
542 | + break; |
|
543 | + case 'createdon': |
|
544 | + case 'editedon': |
|
545 | + case 'publishedon': |
|
546 | + case 'pub_date': |
|
547 | + case 'unpub_date': |
|
548 | + $doc = $modx->getDocumentObject('id', $row['id']); |
|
549 | + $date = $doc[$nodeNameSource]; |
|
550 | + if(!empty($date)) { |
|
551 | + $nodetitle = $modx->toDateFormat($date); |
|
552 | + } else { |
|
553 | + $nodetitle = '- - -'; |
|
554 | + } |
|
555 | + break; |
|
556 | + default: |
|
557 | + $nodetitle = $row['pagetitle']; |
|
558 | + } |
|
559 | + $nodetitle = $modx->htmlspecialchars(str_replace(array( |
|
560 | + "\r\n", |
|
561 | + "\n", |
|
562 | + "\r" |
|
563 | + ), ' ', $nodetitle), ENT_COMPAT); |
|
564 | + return $nodetitle; |
|
565 | 565 | } |
566 | 566 | |
567 | 567 | /** |
@@ -569,16 +569,16 @@ discard block |
||
569 | 569 | * @return bool |
570 | 570 | */ |
571 | 571 | function isDateNode($nodeNameSource) { |
572 | - switch($nodeNameSource) { |
|
573 | - case 'createdon': |
|
574 | - case 'editedon': |
|
575 | - case 'publishedon': |
|
576 | - case 'pub_date': |
|
577 | - case 'unpub_date': |
|
578 | - return true; |
|
579 | - default: |
|
580 | - return false; |
|
581 | - } |
|
572 | + switch($nodeNameSource) { |
|
573 | + case 'createdon': |
|
574 | + case 'editedon': |
|
575 | + case 'publishedon': |
|
576 | + case 'pub_date': |
|
577 | + case 'unpub_date': |
|
578 | + return true; |
|
579 | + default: |
|
580 | + return false; |
|
581 | + } |
|
582 | 582 | } |
583 | 583 | |
584 | 584 | /** |
@@ -587,9 +587,9 @@ discard block |
||
587 | 587 | * @return int |
588 | 588 | */ |
589 | 589 | function checkIsFolder($parent = 0, $isfolder = 1) { |
590 | - global $modx; |
|
590 | + global $modx; |
|
591 | 591 | |
592 | - return (int) $modx->db->getValue($modx->db->query('SELECT count(*) FROM ' . $modx->getFullTableName('site_content') . ' WHERE parent=' . $parent . ' AND isfolder=' . $isfolder . ' ')); |
|
592 | + return (int) $modx->db->getValue($modx->db->query('SELECT count(*) FROM ' . $modx->getFullTableName('site_content') . ' WHERE parent=' . $parent . ' AND isfolder=' . $isfolder . ' ')); |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | /** |
@@ -597,19 +597,19 @@ discard block |
||
597 | 597 | * @return string |
598 | 598 | */ |
599 | 599 | function _htmlentities($array) { |
600 | - global $modx; |
|
600 | + global $modx; |
|
601 | 601 | |
602 | - $array = json_encode($array, JSON_UNESCAPED_UNICODE); |
|
603 | - $array = htmlentities($array, ENT_COMPAT, $modx->config['modx_charset']); |
|
602 | + $array = json_encode($array, JSON_UNESCAPED_UNICODE); |
|
603 | + $array = htmlentities($array, ENT_COMPAT, $modx->config['modx_charset']); |
|
604 | 604 | |
605 | - return $array; |
|
605 | + return $array; |
|
606 | 606 | } |
607 | 607 | |
608 | 608 | /** |
609 | 609 | * @return string |
610 | 610 | */ |
611 | 611 | function getTplSingleNode() { |
612 | - return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
|
612 | + return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
|
613 | 613 | onclick="modx.tree.treeAction(event,[+id+]);" |
614 | 614 | oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');" |
615 | 615 | data-id="[+id+]" |
@@ -636,7 +636,7 @@ discard block |
||
636 | 636 | * @return string |
637 | 637 | */ |
638 | 638 | function getTplFolderNode() { |
639 | - return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
|
639 | + return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
|
640 | 640 | onclick="modx.tree.treeAction(event,[+id+]);" |
641 | 641 | oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');" |
642 | 642 | data-id="[+id+]" |
@@ -675,7 +675,7 @@ discard block |
||
675 | 675 | * @return string |
676 | 676 | */ |
677 | 677 | function getTplFolderNodeNotChildren() { |
678 | - return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
|
678 | + return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
|
679 | 679 | onclick="modx.tree.treeAction(event,[+id+]);" |
680 | 680 | oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');" |
681 | 681 | data-id="[+id+]" |
@@ -711,10 +711,10 @@ discard block |
||
711 | 711 | * @param bool $flag |
712 | 712 | */ |
713 | 713 | function dbug($str, $flag = false) { |
714 | - print('<pre>'); |
|
715 | - print_r($str); |
|
716 | - print('</pre>'); |
|
717 | - if($flag) { |
|
718 | - exit; |
|
719 | - } |
|
714 | + print('<pre>'); |
|
715 | + print_r($str); |
|
716 | + print('</pre>'); |
|
717 | + if($flag) { |
|
718 | + exit; |
|
719 | + } |
|
720 | 720 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
3 | 3 | die('<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.'); |
4 | 4 | } |
5 | 5 | |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * @param string $hereid |
12 | 12 | * @return string |
13 | 13 | */ |
14 | -function makeHTML($indent, $parent, $expandAll, $theme, $hereid = '') { |
|
14 | +function makeHTML($indent, $parent, $expandAll, $theme, $hereid = ''){ |
|
15 | 15 | global $modx; |
16 | 16 | global $icons, $iconsPrivate, $_style; |
17 | 17 | global $_lang, $opened, $opened2, $closed2; //added global vars |
@@ -22,35 +22,35 @@ discard block |
||
22 | 22 | // setup spacer |
23 | 23 | $level = 0; |
24 | 24 | $spacer = '<span class="indent">'; |
25 | - for($i = 2; $i <= $indent; $i++) { |
|
25 | + for ($i = 2; $i <= $indent; $i++) { |
|
26 | 26 | $spacer .= '<i></i>'; |
27 | 27 | $level++; |
28 | 28 | } |
29 | 29 | $spacer .= '</span>'; |
30 | 30 | |
31 | 31 | // manage order-by |
32 | - if(!isset($_SESSION['tree_sortby']) && !isset($_SESSION['tree_sortdir'])) { |
|
32 | + if (!isset($_SESSION['tree_sortby']) && !isset($_SESSION['tree_sortdir'])) { |
|
33 | 33 | // This is the first startup, set default sort order |
34 | 34 | $_SESSION['tree_sortby'] = 'menuindex'; |
35 | 35 | $_SESSION['tree_sortdir'] = 'ASC'; |
36 | 36 | } |
37 | 37 | |
38 | - switch($_SESSION['tree_sortby']) { |
|
38 | + switch ($_SESSION['tree_sortby']) { |
|
39 | 39 | case 'createdon': |
40 | 40 | case 'editedon': |
41 | 41 | case 'publishedon': |
42 | 42 | case 'pub_date': |
43 | 43 | case 'unpub_date': |
44 | - $sortby = sprintf('CASE WHEN %s IS NULL THEN 1 ELSE 0 END, %s', 'sc.' . $_SESSION['tree_sortby'], 'sc.' . $_SESSION['tree_sortby']); |
|
44 | + $sortby = sprintf('CASE WHEN %s IS NULL THEN 1 ELSE 0 END, %s', 'sc.'.$_SESSION['tree_sortby'], 'sc.'.$_SESSION['tree_sortby']); |
|
45 | 45 | break; |
46 | 46 | default: |
47 | - $sortby = 'sc.' . $_SESSION['tree_sortby']; |
|
47 | + $sortby = 'sc.'.$_SESSION['tree_sortby']; |
|
48 | 48 | }; |
49 | 49 | |
50 | - $orderby = $modx->db->escape($sortby . ' ' . $_SESSION['tree_sortdir']); |
|
50 | + $orderby = $modx->db->escape($sortby.' '.$_SESSION['tree_sortdir']); |
|
51 | 51 | |
52 | 52 | // Folder sorting gets special setup ;) Add menuindex and pagetitle |
53 | - if($_SESSION['tree_sortby'] == 'isfolder') { |
|
53 | + if ($_SESSION['tree_sortby'] == 'isfolder') { |
|
54 | 54 | $orderby .= ', menuindex ASC, pagetitle'; |
55 | 55 | } |
56 | 56 | |
@@ -60,12 +60,12 @@ discard block |
||
60 | 60 | // get document groups for current user |
61 | 61 | $docgrp = (isset($_SESSION['mgrDocgroups']) && is_array($_SESSION['mgrDocgroups'])) ? implode(',', $_SESSION['mgrDocgroups']) : ''; |
62 | 62 | $showProtected = false; |
63 | - if(isset ($modx->config['tree_show_protected'])) { |
|
63 | + if (isset ($modx->config['tree_show_protected'])) { |
|
64 | 64 | $showProtected = (boolean) $modx->config['tree_show_protected']; |
65 | 65 | } |
66 | 66 | $mgrRole = (isset ($_SESSION['mgrRole']) && (string) $_SESSION['mgrRole'] === '1') ? '1' : '0'; |
67 | - if($showProtected == false) { |
|
68 | - $access = "AND (1={$mgrRole} OR sc.privatemgr=0" . (!$docgrp ? ')' : " OR dg.document_group IN ({$docgrp}))"); |
|
67 | + if ($showProtected == false) { |
|
68 | + $access = "AND (1={$mgrRole} OR sc.privatemgr=0".(!$docgrp ? ')' : " OR dg.document_group IN ({$docgrp}))"); |
|
69 | 69 | } else { |
70 | 70 | $access = ''; |
71 | 71 | } |
@@ -75,13 +75,13 @@ discard block |
||
75 | 75 | $from = "{$tblsc} AS sc LEFT JOIN {$tbldg} dg on dg.document = sc.id LEFT JOIN {$tblst} st on st.id = sc.template"; |
76 | 76 | $where = "(parent={$parent}) {$access} GROUP BY sc.id"; |
77 | 77 | $result = $modx->db->select($field, $from, $where, $orderby); |
78 | - if($modx->db->getRecordCount($result) == 0) { |
|
78 | + if ($modx->db->getRecordCount($result) == 0) { |
|
79 | 79 | $output .= sprintf('<div><a class="empty">%s%s <span class="empty">%s</span></a></div>', $spacer, $_style['tree_deletedpage'], $_lang['empty_folder']); |
80 | 80 | } |
81 | 81 | |
82 | 82 | $nodeNameSource = $_SESSION['tree_nodename'] == 'default' ? $modx->config['resource_tree_node_name'] : $_SESSION['tree_nodename']; |
83 | 83 | |
84 | - while($row = $modx->db->getRow($result)) { |
|
84 | + while ($row = $modx->db->getRow($result)) { |
|
85 | 85 | $node = ''; |
86 | 86 | |
87 | 87 | $nodetitle = getNodeTitle($nodeNameSource, $row); |
@@ -90,46 +90,46 @@ discard block |
||
90 | 90 | $treeNodeClass = 'node'; |
91 | 91 | $treeNodeClass .= $row['hasAccess'] == 0 ? ' protected' : ''; |
92 | 92 | |
93 | - if($row['deleted'] == 1) { |
|
93 | + if ($row['deleted'] == 1) { |
|
94 | 94 | $treeNodeClass .= ' deleted'; |
95 | 95 | //$nodetitleDisplay = sprintf('<span class="deletedNode">%s</span>', $nodetitle); |
96 | - } elseif($row['published'] == 0) { |
|
96 | + } elseif ($row['published'] == 0) { |
|
97 | 97 | $treeNodeClass .= ' unpublished'; |
98 | 98 | //$nodetitleDisplay = sprintf('<span class="unpublishedNode">%s</span>', $nodetitle); |
99 | - } elseif($row['hidemenu'] == 1) { |
|
99 | + } elseif ($row['hidemenu'] == 1) { |
|
100 | 100 | $treeNodeClass .= ' hidemenu'; |
101 | 101 | //$nodetitleDisplay = sprintf('<span class="notInMenuNode%s">%s</span>', $protectedClass, $nodetitle); |
102 | 102 | } else { |
103 | 103 | //$nodetitleDisplay = sprintf('<span class="publishedNode%s">%s</span>', $protectedClass, $nodetitle); |
104 | 104 | } |
105 | 105 | |
106 | - if($row['id'] == $hereid) { |
|
106 | + if ($row['id'] == $hereid) { |
|
107 | 107 | $treeNodeClass .= ' current'; |
108 | 108 | } |
109 | 109 | |
110 | 110 | $weblinkDisplay = $row['type'] == 'reference' ? sprintf(' %s', $_style['tree_linkgo']) : ''; |
111 | - $pageIdDisplay = '<small>(' . ($modx_textdir ? '‏' : '') . $row['id'] . ')</small>'; |
|
111 | + $pageIdDisplay = '<small>('.($modx_textdir ? '‏' : '').$row['id'].')</small>'; |
|
112 | 112 | |
113 | 113 | // Prepare displaying user-locks |
114 | 114 | $lockedByUser = ''; |
115 | 115 | $rowLock = $modx->elementIsLocked(7, $row['id'], true); |
116 | - if($rowLock && $modx->hasPermission('display_locks')) { |
|
117 | - if($rowLock['sid'] == $modx->sid) { |
|
116 | + if ($rowLock && $modx->hasPermission('display_locks')) { |
|
117 | + if ($rowLock['sid'] == $modx->sid) { |
|
118 | 118 | $title = $modx->parseText($_lang["lock_element_editing"], array( |
119 | 119 | 'element_type' => $_lang["lock_element_type_7"], |
120 | 120 | 'lasthit_df' => $rowLock['lasthit_df'] |
121 | 121 | )); |
122 | - $lockedByUser = '<span title="' . $title . '" class="editResource">' . $_style['tree_preview_resource'] . '</span>'; |
|
122 | + $lockedByUser = '<span title="'.$title.'" class="editResource">'.$_style['tree_preview_resource'].'</span>'; |
|
123 | 123 | } else { |
124 | 124 | $title = $modx->parseText($_lang["lock_element_locked_by"], array( |
125 | 125 | 'element_type' => $_lang["lock_element_type_7"], |
126 | 126 | 'username' => $rowLock['username'], |
127 | 127 | 'lasthit_df' => $rowLock['lasthit_df'] |
128 | 128 | )); |
129 | - if($modx->hasPermission('remove_locks')) { |
|
130 | - $lockedByUser = '<span onclick="modx.tree.unlockElement(7, ' . $row['id'] . ', this);return false;" title="' . $title . '" class="lockedResource">' . $_style['icons_secured'] . '</span>'; |
|
129 | + if ($modx->hasPermission('remove_locks')) { |
|
130 | + $lockedByUser = '<span onclick="modx.tree.unlockElement(7, '.$row['id'].', this);return false;" title="'.$title.'" class="lockedResource">'.$_style['icons_secured'].'</span>'; |
|
131 | 131 | } else { |
132 | - $lockedByUser = '<span title="' . $title . '" class="lockedResource">' . $_style['icons_secured'] . '</span>'; |
|
132 | + $lockedByUser = '<span title="'.$title.'" class="lockedResource">'.$_style['icons_secured'].'</span>'; |
|
133 | 133 | } |
134 | 134 | } |
135 | 135 | } |
@@ -137,23 +137,23 @@ discard block |
||
137 | 137 | $url = $modx->makeUrl($row['id']); |
138 | 138 | |
139 | 139 | $title = ''; |
140 | - if(isDateNode($nodeNameSource)) { |
|
141 | - $title = $_lang['pagetitle'] . ': ' . $row['pagetitle'] . '[+lf+]'; |
|
140 | + if (isDateNode($nodeNameSource)) { |
|
141 | + $title = $_lang['pagetitle'].': '.$row['pagetitle'].'[+lf+]'; |
|
142 | 142 | } |
143 | - $title .= $_lang['id'] . ': ' . $row['id']; |
|
144 | - $title .= '[+lf+]' . $_lang['resource_opt_menu_title'] . ': ' . $row['menutitle']; |
|
145 | - $title .= '[+lf+]' . $_lang['resource_opt_menu_index'] . ': ' . $row['menuindex']; |
|
146 | - $title .= '[+lf+]' . $_lang['alias'] . ': ' . (!empty($row['alias']) ? $row['alias'] : '-'); |
|
147 | - $title .= '[+lf+]' . $_lang['template'] . ': ' . $row['templatename']; |
|
148 | - $title .= '[+lf+]' . $_lang['publish_date'] . ': ' . $modx->toDateFormat($row['pub_date']); |
|
149 | - $title .= '[+lf+]' . $_lang['unpublish_date'] . ': ' . $modx->toDateFormat($row['unpub_date']); |
|
150 | - $title .= '[+lf+]' . $_lang['page_data_web_access'] . ': ' . ($row['privateweb'] ? $_lang['private'] : $_lang['public']); |
|
151 | - $title .= '[+lf+]' . $_lang['page_data_mgr_access'] . ': ' . ($row['privatemgr'] ? $_lang['private'] : $_lang['public']); |
|
152 | - $title .= '[+lf+]' . $_lang['resource_opt_richtext'] . ': ' . ($row['richtext'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
153 | - $title .= '[+lf+]' . $_lang['page_data_searchable'] . ': ' . ($row['searchable'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
154 | - $title .= '[+lf+]' . $_lang['page_data_cacheable'] . ': ' . ($row['cacheable'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
143 | + $title .= $_lang['id'].': '.$row['id']; |
|
144 | + $title .= '[+lf+]'.$_lang['resource_opt_menu_title'].': '.$row['menutitle']; |
|
145 | + $title .= '[+lf+]'.$_lang['resource_opt_menu_index'].': '.$row['menuindex']; |
|
146 | + $title .= '[+lf+]'.$_lang['alias'].': '.(!empty($row['alias']) ? $row['alias'] : '-'); |
|
147 | + $title .= '[+lf+]'.$_lang['template'].': '.$row['templatename']; |
|
148 | + $title .= '[+lf+]'.$_lang['publish_date'].': '.$modx->toDateFormat($row['pub_date']); |
|
149 | + $title .= '[+lf+]'.$_lang['unpublish_date'].': '.$modx->toDateFormat($row['unpub_date']); |
|
150 | + $title .= '[+lf+]'.$_lang['page_data_web_access'].': '.($row['privateweb'] ? $_lang['private'] : $_lang['public']); |
|
151 | + $title .= '[+lf+]'.$_lang['page_data_mgr_access'].': '.($row['privatemgr'] ? $_lang['private'] : $_lang['public']); |
|
152 | + $title .= '[+lf+]'.$_lang['resource_opt_richtext'].': '.($row['richtext'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
153 | + $title .= '[+lf+]'.$_lang['page_data_searchable'].': '.($row['searchable'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
154 | + $title .= '[+lf+]'.$_lang['page_data_cacheable'].': '.($row['cacheable'] == 0 ? $_lang['no'] : $_lang['yes']); |
|
155 | 155 | $title = $modx->htmlspecialchars($title); |
156 | - $title = str_replace('[+lf+]', ' ', $title); // replace line-breaks with empty space as fall-back |
|
156 | + $title = str_replace('[+lf+]', ' ', $title); // replace line-breaks with empty space as fall-back |
|
157 | 157 | |
158 | 158 | $data = array( |
159 | 159 | 'id' => $row['id'], |
@@ -202,9 +202,9 @@ discard block |
||
202 | 202 | $ph['expandAll'] = $expandAll; |
203 | 203 | $ph['isPrivate'] = ($row['privateweb'] || $row['privatemgr']) ? 1 : 0; |
204 | 204 | |
205 | - if(!$row['isfolder']) { |
|
205 | + if (!$row['isfolder']) { |
|
206 | 206 | $tpl = getTplSingleNode(); |
207 | - switch($row['id']) { |
|
207 | + switch ($row['id']) { |
|
208 | 208 | case $modx->config['site_start'] : |
209 | 209 | $icon = $_style['tree_page_home']; |
210 | 210 | break; |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | $icon = $_style['tree_page_info']; |
219 | 219 | break; |
220 | 220 | default: |
221 | - if(isset($icons[$row['contentType']])) { |
|
221 | + if (isset($icons[$row['contentType']])) { |
|
222 | 222 | $icon = $icons[$row['contentType']]; |
223 | 223 | } else { |
224 | 224 | $icon = $_style['tree_page']; |
@@ -228,20 +228,20 @@ discard block |
||
228 | 228 | |
229 | 229 | // invoke OnManagerNodePrerender event |
230 | 230 | $prenode = $modx->invokeEvent("OnManagerNodePrerender", array('ph' => $ph)); |
231 | - if(is_array($prenode)) { |
|
231 | + if (is_array($prenode)) { |
|
232 | 232 | $phnew = array(); |
233 | - foreach($prenode as $pnode) { |
|
233 | + foreach ($prenode as $pnode) { |
|
234 | 234 | $phnew = array_merge($phnew, unserialize($pnode)); |
235 | 235 | } |
236 | 236 | $ph = (count($phnew) > 0) ? $phnew : $ph; |
237 | 237 | } |
238 | 238 | |
239 | - if($ph['contextmenu']) { |
|
240 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
239 | + if ($ph['contextmenu']) { |
|
240 | + $ph['contextmenu'] = ' data-contextmenu="'._htmlentities($ph['contextmenu']).'"'; |
|
241 | 241 | } |
242 | 242 | |
243 | - if($_SESSION['tree_show_only_folders']) { |
|
244 | - if($row['parent'] == 0) { |
|
243 | + if ($_SESSION['tree_show_only_folders']) { |
|
244 | + if ($row['parent'] == 0) { |
|
245 | 245 | $node .= $modx->parseText($tpl, $ph); |
246 | 246 | } else { |
247 | 247 | $node .= ''; |
@@ -254,15 +254,15 @@ discard block |
||
254 | 254 | $ph['icon_folder_open'] = $_style['tree_folderopen_new']; |
255 | 255 | $ph['icon_folder_close'] = $_style['tree_folder_new']; |
256 | 256 | |
257 | - if($_SESSION['tree_show_only_folders']) { |
|
257 | + if ($_SESSION['tree_show_only_folders']) { |
|
258 | 258 | $tpl = getTplFolderNodeNotChildren(); |
259 | 259 | $checkFolders = checkIsFolder($row['id'], 1) ? 1 : 0; // folders |
260 | 260 | $checkDocs = checkIsFolder($row['id'], 0) ? 1 : 0; // no folders |
261 | 261 | $ph['tree_page_click'] = 3; |
262 | 262 | |
263 | 263 | // expandAll: two type for partial expansion |
264 | - if($expandAll == 1 || ($expandAll == 2 && in_array($row['id'], $opened))) { |
|
265 | - if($expandAll == 1) { |
|
264 | + if ($expandAll == 1 || ($expandAll == 2 && in_array($row['id'], $opened))) { |
|
265 | + if ($expandAll == 1) { |
|
266 | 266 | $opened2[] = $row['id']; |
267 | 267 | } |
268 | 268 | $ph['icon'] = $ph['icon_folder_open']; |
@@ -270,11 +270,11 @@ discard block |
||
270 | 270 | $ph['node_toggle'] = 1; |
271 | 271 | $ph['subMenuState'] = ' open'; |
272 | 272 | |
273 | - if(($checkDocs && !$checkFolders) || (!$checkDocs && !$checkFolders)) { |
|
273 | + if (($checkDocs && !$checkFolders) || (!$checkDocs && !$checkFolders)) { |
|
274 | 274 | $ph['showChildren'] = 1; |
275 | 275 | $ph['icon_node_toggle'] = ''; |
276 | 276 | $ph['icon'] = $ph['icon_folder_close']; |
277 | - } elseif(!$checkDocs && $checkFolders) { |
|
277 | + } elseif (!$checkDocs && $checkFolders) { |
|
278 | 278 | $ph['showChildren'] = 0; |
279 | 279 | $ph['openFolder'] = 2; |
280 | 280 | } else { |
@@ -286,20 +286,20 @@ discard block |
||
286 | 286 | 'ph' => $ph, |
287 | 287 | 'opened' => '1' |
288 | 288 | )); |
289 | - if(is_array($prenode)) { |
|
289 | + if (is_array($prenode)) { |
|
290 | 290 | $phnew = array(); |
291 | - foreach($prenode as $pnode) { |
|
291 | + foreach ($prenode as $pnode) { |
|
292 | 292 | $phnew = array_merge($phnew, unserialize($pnode)); |
293 | 293 | } |
294 | 294 | $ph = (count($phnew) > 0) ? $phnew : $ph; |
295 | 295 | } |
296 | 296 | |
297 | - if($ph['contextmenu']) { |
|
298 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
297 | + if ($ph['contextmenu']) { |
|
298 | + $ph['contextmenu'] = ' data-contextmenu="'._htmlentities($ph['contextmenu']).'"'; |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | $node .= $modx->parseText($tpl, $ph); |
302 | - if($checkFolders) { |
|
302 | + if ($checkFolders) { |
|
303 | 303 | $node .= makeHTML($indent + 1, $row['id'], $expandAll, $theme, $hereid); |
304 | 304 | } |
305 | 305 | $node .= '</div></div>'; |
@@ -309,10 +309,10 @@ discard block |
||
309 | 309 | $ph['icon_node_toggle'] = $ph['tree_plusnode']; |
310 | 310 | $ph['node_toggle'] = 0; |
311 | 311 | |
312 | - if(($checkDocs && !$checkFolders) || (!$checkDocs && !$checkFolders)) { |
|
312 | + if (($checkDocs && !$checkFolders) || (!$checkDocs && !$checkFolders)) { |
|
313 | 313 | $ph['showChildren'] = 1; |
314 | 314 | $ph['icon_node_toggle'] = ''; |
315 | - } elseif(!$checkDocs && $checkFolders) { |
|
315 | + } elseif (!$checkDocs && $checkFolders) { |
|
316 | 316 | $ph['showChildren'] = 0; |
317 | 317 | $ph['openFolder'] = 2; |
318 | 318 | } else { |
@@ -324,16 +324,16 @@ discard block |
||
324 | 324 | 'ph' => $ph, |
325 | 325 | 'opened' => '0' |
326 | 326 | )); |
327 | - if(is_array($prenode)) { |
|
327 | + if (is_array($prenode)) { |
|
328 | 328 | $phnew = array(); |
329 | - foreach($prenode as $pnode) { |
|
329 | + foreach ($prenode as $pnode) { |
|
330 | 330 | $phnew = array_merge($phnew, unserialize($pnode)); |
331 | 331 | } |
332 | 332 | $ph = (count($phnew) > 0) ? $phnew : $ph; |
333 | 333 | } |
334 | 334 | |
335 | - if($ph['contextmenu']) { |
|
336 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
335 | + if ($ph['contextmenu']) { |
|
336 | + $ph['contextmenu'] = ' data-contextmenu="'._htmlentities($ph['contextmenu']).'"'; |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | $node .= $modx->parseText($tpl, $ph); |
@@ -342,8 +342,8 @@ discard block |
||
342 | 342 | } else { |
343 | 343 | $tpl = getTplFolderNode(); |
344 | 344 | // expandAll: two type for partial expansion |
345 | - if($expandAll == 1 || ($expandAll == 2 && in_array($row['id'], $opened))) { |
|
346 | - if($expandAll == 1) { |
|
345 | + if ($expandAll == 1 || ($expandAll == 2 && in_array($row['id'], $opened))) { |
|
346 | + if ($expandAll == 1) { |
|
347 | 347 | $opened2[] = $row['id']; |
348 | 348 | } |
349 | 349 | $ph['icon'] = $ph['icon_folder_open']; |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | $ph['node_toggle'] = 1; |
352 | 352 | $ph['subMenuState'] = ' open'; |
353 | 353 | |
354 | - if($ph['donthit'] == 1) { |
|
354 | + if ($ph['donthit'] == 1) { |
|
355 | 355 | $ph['tree_page_click'] = 3; |
356 | 356 | $ph['icon_node_toggle'] = ''; |
357 | 357 | $ph['icon'] = $ph['icon_folder_close']; |
@@ -363,32 +363,32 @@ discard block |
||
363 | 363 | 'ph' => $ph, |
364 | 364 | 'opened' => '1' |
365 | 365 | )); |
366 | - if(is_array($prenode)) { |
|
366 | + if (is_array($prenode)) { |
|
367 | 367 | $phnew = array(); |
368 | - foreach($prenode as $pnode) { |
|
368 | + foreach ($prenode as $pnode) { |
|
369 | 369 | $phnew = array_merge($phnew, unserialize($pnode)); |
370 | 370 | } |
371 | 371 | $ph = (count($phnew) > 0) ? $phnew : $ph; |
372 | - if($ph['showChildren'] == 0) { |
|
372 | + if ($ph['showChildren'] == 0) { |
|
373 | 373 | unset($opened2[$row['id']]); |
374 | 374 | $ph['node_toggle'] = 0; |
375 | 375 | $ph['subMenuState'] = ''; |
376 | 376 | } |
377 | 377 | } |
378 | 378 | |
379 | - if($ph['showChildren'] == 0) { |
|
379 | + if ($ph['showChildren'] == 0) { |
|
380 | 380 | $ph['icon_node_toggle'] = ''; |
381 | 381 | $ph['donthit'] = 1; |
382 | 382 | $ph['icon'] = $ph['icon_folder_close']; |
383 | 383 | $tpl = getTplFolderNodeNotChildren(); |
384 | 384 | } |
385 | 385 | |
386 | - if($ph['contextmenu']) { |
|
387 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
386 | + if ($ph['contextmenu']) { |
|
387 | + $ph['contextmenu'] = ' data-contextmenu="'._htmlentities($ph['contextmenu']).'"'; |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | $node .= $modx->parseText($tpl, $ph); |
391 | - if($ph['donthit'] == 0) { |
|
391 | + if ($ph['donthit'] == 0) { |
|
392 | 392 | $node .= makeHTML($indent + 1, $row['id'], $expandAll, $theme, $hereid); |
393 | 393 | } |
394 | 394 | $node .= '</div></div>'; |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | $ph['icon_node_toggle'] = $ph['tree_plusnode']; |
399 | 399 | $ph['node_toggle'] = 0; |
400 | 400 | |
401 | - if($ph['donthit'] == 1) { |
|
401 | + if ($ph['donthit'] == 1) { |
|
402 | 402 | $ph['tree_page_click'] = 3; |
403 | 403 | $ph['icon_node_toggle'] = ''; |
404 | 404 | $ph['icon'] = $ph['icon_folder_close']; |
@@ -410,23 +410,23 @@ discard block |
||
410 | 410 | 'ph' => $ph, |
411 | 411 | 'opened' => '0' |
412 | 412 | )); |
413 | - if(is_array($prenode)) { |
|
413 | + if (is_array($prenode)) { |
|
414 | 414 | $phnew = array(); |
415 | - foreach($prenode as $pnode) { |
|
415 | + foreach ($prenode as $pnode) { |
|
416 | 416 | $phnew = array_merge($phnew, unserialize($pnode)); |
417 | 417 | } |
418 | 418 | $ph = (count($phnew) > 0) ? $phnew : $ph; |
419 | 419 | } |
420 | 420 | |
421 | - if($ph['showChildren'] == 0) { |
|
421 | + if ($ph['showChildren'] == 0) { |
|
422 | 422 | $ph['icon_node_toggle'] = ''; |
423 | 423 | $ph['donthit'] = 1; |
424 | 424 | $ph['icon'] = $ph['icon_folder_close']; |
425 | 425 | $tpl = getTplFolderNodeNotChildren(); |
426 | 426 | } |
427 | 427 | |
428 | - if($ph['contextmenu']) { |
|
429 | - $ph['contextmenu'] = ' data-contextmenu="' . _htmlentities($ph['contextmenu']) . '"'; |
|
428 | + if ($ph['contextmenu']) { |
|
429 | + $ph['contextmenu'] = ' data-contextmenu="'._htmlentities($ph['contextmenu']).'"'; |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | $node .= $modx->parseText($tpl, $ph); |
@@ -438,10 +438,10 @@ discard block |
||
438 | 438 | // invoke OnManagerNodeRender event |
439 | 439 | $data['node'] = $node; |
440 | 440 | $evtOut = $modx->invokeEvent('OnManagerNodeRender', $data); |
441 | - if(is_array($evtOut)) { |
|
441 | + if (is_array($evtOut)) { |
|
442 | 442 | $evtOut = implode("\n", $evtOut); |
443 | 443 | } |
444 | - if($evtOut != '') { |
|
444 | + if ($evtOut != '') { |
|
445 | 445 | $node = trim($evtOut); |
446 | 446 | } |
447 | 447 | |
@@ -455,14 +455,14 @@ discard block |
||
455 | 455 | * @param array $_style |
456 | 456 | * @return array |
457 | 457 | */ |
458 | -function getIconInfo($_style) { |
|
459 | - if(!isset($_style['tree_page_gif'])) { |
|
458 | +function getIconInfo($_style){ |
|
459 | + if (!isset($_style['tree_page_gif'])) { |
|
460 | 460 | $_style['tree_page_gif'] = $_style['tree_page']; |
461 | 461 | } |
462 | - if(!isset($_style['tree_page_jpg'])) { |
|
462 | + if (!isset($_style['tree_page_jpg'])) { |
|
463 | 463 | $_style['tree_page_jpg'] = $_style['tree_page']; |
464 | 464 | } |
465 | - if(!isset($_style['tree_page_png'])) { |
|
465 | + if (!isset($_style['tree_page_png'])) { |
|
466 | 466 | $_style['tree_page_png'] = $_style['tree_page']; |
467 | 467 | } |
468 | 468 | $icons = array( |
@@ -486,14 +486,14 @@ discard block |
||
486 | 486 | * @param array $_style |
487 | 487 | * @return array |
488 | 488 | */ |
489 | -function getPrivateIconInfo($_style) { |
|
490 | - if(!isset($_style['tree_page_gif_secure'])) { |
|
489 | +function getPrivateIconInfo($_style){ |
|
490 | + if (!isset($_style['tree_page_gif_secure'])) { |
|
491 | 491 | $_style['tree_page_gif_secure'] = $_style['tree_page_secure']; |
492 | 492 | } |
493 | - if(!isset($_style['tree_page_jpg_secure'])) { |
|
493 | + if (!isset($_style['tree_page_jpg_secure'])) { |
|
494 | 494 | $_style['tree_page_jpg_secure'] = $_style['tree_page_secure']; |
495 | 495 | } |
496 | - if(!isset($_style['tree_page_png_secure'])) { |
|
496 | + if (!isset($_style['tree_page_png_secure'])) { |
|
497 | 497 | $_style['tree_page_png_secure'] = $_style['tree_page_secure']; |
498 | 498 | } |
499 | 499 | $iconsPrivate = array( |
@@ -518,21 +518,21 @@ discard block |
||
518 | 518 | * @param array $row |
519 | 519 | * @return string |
520 | 520 | */ |
521 | -function getNodeTitle($nodeNameSource, $row) { |
|
521 | +function getNodeTitle($nodeNameSource, $row){ |
|
522 | 522 | global $modx; |
523 | 523 | |
524 | - switch($nodeNameSource) { |
|
524 | + switch ($nodeNameSource) { |
|
525 | 525 | case 'menutitle': |
526 | 526 | $nodetitle = $row['menutitle'] ? $row['menutitle'] : $row['pagetitle']; |
527 | 527 | break; |
528 | 528 | case 'alias': |
529 | 529 | $nodetitle = $row['alias'] ? $row['alias'] : $row['id']; |
530 | - if(strpos($row['alias'], '.') === false) { |
|
531 | - if($row['isfolder'] != 1 || $modx->config['make_folders'] != 1) { |
|
530 | + if (strpos($row['alias'], '.') === false) { |
|
531 | + if ($row['isfolder'] != 1 || $modx->config['make_folders'] != 1) { |
|
532 | 532 | $nodetitle .= $modx->config['friendly_url_suffix']; |
533 | 533 | } |
534 | 534 | } |
535 | - $nodetitle = $modx->config['friendly_url_prefix'] . $nodetitle; |
|
535 | + $nodetitle = $modx->config['friendly_url_prefix'].$nodetitle; |
|
536 | 536 | break; |
537 | 537 | case 'pagetitle': |
538 | 538 | $nodetitle = $row['pagetitle']; |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | case 'unpub_date': |
548 | 548 | $doc = $modx->getDocumentObject('id', $row['id']); |
549 | 549 | $date = $doc[$nodeNameSource]; |
550 | - if(!empty($date)) { |
|
550 | + if (!empty($date)) { |
|
551 | 551 | $nodetitle = $modx->toDateFormat($date); |
552 | 552 | } else { |
553 | 553 | $nodetitle = '- - -'; |
@@ -568,8 +568,8 @@ discard block |
||
568 | 568 | * @param string $nodeNameSource |
569 | 569 | * @return bool |
570 | 570 | */ |
571 | -function isDateNode($nodeNameSource) { |
|
572 | - switch($nodeNameSource) { |
|
571 | +function isDateNode($nodeNameSource){ |
|
572 | + switch ($nodeNameSource) { |
|
573 | 573 | case 'createdon': |
574 | 574 | case 'editedon': |
575 | 575 | case 'publishedon': |
@@ -586,17 +586,17 @@ discard block |
||
586 | 586 | * @param int $isfolder |
587 | 587 | * @return int |
588 | 588 | */ |
589 | -function checkIsFolder($parent = 0, $isfolder = 1) { |
|
589 | +function checkIsFolder($parent = 0, $isfolder = 1){ |
|
590 | 590 | global $modx; |
591 | 591 | |
592 | - return (int) $modx->db->getValue($modx->db->query('SELECT count(*) FROM ' . $modx->getFullTableName('site_content') . ' WHERE parent=' . $parent . ' AND isfolder=' . $isfolder . ' ')); |
|
592 | + return (int) $modx->db->getValue($modx->db->query('SELECT count(*) FROM '.$modx->getFullTableName('site_content').' WHERE parent='.$parent.' AND isfolder='.$isfolder.' ')); |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | /** |
596 | 596 | * @param mixed $array |
597 | 597 | * @return string |
598 | 598 | */ |
599 | -function _htmlentities($array) { |
|
599 | +function _htmlentities($array){ |
|
600 | 600 | global $modx; |
601 | 601 | |
602 | 602 | $array = json_encode($array, JSON_UNESCAPED_UNICODE); |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | /** |
609 | 609 | * @return string |
610 | 610 | */ |
611 | -function getTplSingleNode() { |
|
611 | +function getTplSingleNode(){ |
|
612 | 612 | return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
613 | 613 | onclick="modx.tree.treeAction(event,[+id+]);" |
614 | 614 | oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');" |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | /** |
636 | 636 | * @return string |
637 | 637 | */ |
638 | -function getTplFolderNode() { |
|
638 | +function getTplFolderNode(){ |
|
639 | 639 | return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
640 | 640 | onclick="modx.tree.treeAction(event,[+id+]);" |
641 | 641 | oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');" |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | /** |
675 | 675 | * @return string |
676 | 676 | */ |
677 | -function getTplFolderNodeNotChildren() { |
|
677 | +function getTplFolderNodeNotChildren(){ |
|
678 | 678 | return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
679 | 679 | onclick="modx.tree.treeAction(event,[+id+]);" |
680 | 680 | oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');" |
@@ -710,11 +710,11 @@ discard block |
||
710 | 710 | * @param int|string|array $str |
711 | 711 | * @param bool $flag |
712 | 712 | */ |
713 | -function dbug($str, $flag = false) { |
|
713 | +function dbug($str, $flag = false){ |
|
714 | 714 | print('<pre>'); |
715 | 715 | print_r($str); |
716 | 716 | print('</pre>'); |
717 | - if($flag) { |
|
717 | + if ($flag) { |
|
718 | 718 | exit; |
719 | 719 | } |
720 | 720 | } |
@@ -11,7 +11,8 @@ discard block |
||
11 | 11 | * @param string $hereid |
12 | 12 | * @return string |
13 | 13 | */ |
14 | -function makeHTML($indent, $parent, $expandAll, $theme, $hereid = '') { |
|
14 | +function makeHTML($indent, $parent, $expandAll, $theme, $hereid = '') |
|
15 | +{ |
|
15 | 16 | global $modx; |
16 | 17 | global $icons, $iconsPrivate, $_style; |
17 | 18 | global $_lang, $opened, $opened2, $closed2; //added global vars |
@@ -455,7 +456,8 @@ discard block |
||
455 | 456 | * @param array $_style |
456 | 457 | * @return array |
457 | 458 | */ |
458 | -function getIconInfo($_style) { |
|
459 | +function getIconInfo($_style) |
|
460 | +{ |
|
459 | 461 | if(!isset($_style['tree_page_gif'])) { |
460 | 462 | $_style['tree_page_gif'] = $_style['tree_page']; |
461 | 463 | } |
@@ -486,7 +488,8 @@ discard block |
||
486 | 488 | * @param array $_style |
487 | 489 | * @return array |
488 | 490 | */ |
489 | -function getPrivateIconInfo($_style) { |
|
491 | +function getPrivateIconInfo($_style) |
|
492 | +{ |
|
490 | 493 | if(!isset($_style['tree_page_gif_secure'])) { |
491 | 494 | $_style['tree_page_gif_secure'] = $_style['tree_page_secure']; |
492 | 495 | } |
@@ -518,7 +521,8 @@ discard block |
||
518 | 521 | * @param array $row |
519 | 522 | * @return string |
520 | 523 | */ |
521 | -function getNodeTitle($nodeNameSource, $row) { |
|
524 | +function getNodeTitle($nodeNameSource, $row) |
|
525 | +{ |
|
522 | 526 | global $modx; |
523 | 527 | |
524 | 528 | switch($nodeNameSource) { |
@@ -568,7 +572,8 @@ discard block |
||
568 | 572 | * @param string $nodeNameSource |
569 | 573 | * @return bool |
570 | 574 | */ |
571 | -function isDateNode($nodeNameSource) { |
|
575 | +function isDateNode($nodeNameSource) |
|
576 | +{ |
|
572 | 577 | switch($nodeNameSource) { |
573 | 578 | case 'createdon': |
574 | 579 | case 'editedon': |
@@ -586,7 +591,8 @@ discard block |
||
586 | 591 | * @param int $isfolder |
587 | 592 | * @return int |
588 | 593 | */ |
589 | -function checkIsFolder($parent = 0, $isfolder = 1) { |
|
594 | +function checkIsFolder($parent = 0, $isfolder = 1) |
|
595 | +{ |
|
590 | 596 | global $modx; |
591 | 597 | |
592 | 598 | return (int) $modx->db->getValue($modx->db->query('SELECT count(*) FROM ' . $modx->getFullTableName('site_content') . ' WHERE parent=' . $parent . ' AND isfolder=' . $isfolder . ' ')); |
@@ -596,7 +602,8 @@ discard block |
||
596 | 602 | * @param mixed $array |
597 | 603 | * @return string |
598 | 604 | */ |
599 | -function _htmlentities($array) { |
|
605 | +function _htmlentities($array) |
|
606 | +{ |
|
600 | 607 | global $modx; |
601 | 608 | |
602 | 609 | $array = json_encode($array, JSON_UNESCAPED_UNICODE); |
@@ -608,7 +615,8 @@ discard block |
||
608 | 615 | /** |
609 | 616 | * @return string |
610 | 617 | */ |
611 | -function getTplSingleNode() { |
|
618 | +function getTplSingleNode() |
|
619 | +{ |
|
612 | 620 | return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
613 | 621 | onclick="modx.tree.treeAction(event,[+id+]);" |
614 | 622 | oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');" |
@@ -635,7 +643,8 @@ discard block |
||
635 | 643 | /** |
636 | 644 | * @return string |
637 | 645 | */ |
638 | -function getTplFolderNode() { |
|
646 | +function getTplFolderNode() |
|
647 | +{ |
|
639 | 648 | return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
640 | 649 | onclick="modx.tree.treeAction(event,[+id+]);" |
641 | 650 | oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');" |
@@ -674,7 +683,8 @@ discard block |
||
674 | 683 | /** |
675 | 684 | * @return string |
676 | 685 | */ |
677 | -function getTplFolderNodeNotChildren() { |
|
686 | +function getTplFolderNodeNotChildren() |
|
687 | +{ |
|
678 | 688 | return '<div id="node[+id+]"><a class="[+treeNodeClass+]" |
679 | 689 | onclick="modx.tree.treeAction(event,[+id+]);" |
680 | 690 | oncontextmenu="modx.tree.showPopup(event,[+id+],\'[+nodetitle_esc+]\');" |
@@ -710,7 +720,8 @@ discard block |
||
710 | 720 | * @param int|string|array $str |
711 | 721 | * @param bool $flag |
712 | 722 | */ |
713 | -function dbug($str, $flag = false) { |
|
723 | +function dbug($str, $flag = false) |
|
724 | +{ |
|
714 | 725 | print('<pre>'); |
715 | 726 | print_r($str); |
716 | 727 | print('</pre>'); |