-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsnippet.wayfinder_custom.php
134 lines (121 loc) · 5.21 KB
/
snippet.wayfinder_custom.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
/**
* Wayfinder_custom
*
* Completely template-driven and highly flexible menu builder
*
* @category snippet
* @version 2.1
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License (GPL)
* @internal @properties
* @internal @modx_category Navigation
* @internal @installset base, sample
* @documentation Official docs https://rtfm.modx.com/extras/evo/wayfinder
* @documentation Almost complete guide, Cheatsheet http://sottwell.com/links/wayfinder.html
* @documentation Almost complete guide Direct-Link https://drive.google.com/file/d/0B5y4Q9am5QDTOVpIa3Y0VVpjcFU/edit?usp=sharing
* @reportissues https://github.com/modxcms/evolution
* @author Kyle Jaebker http://muddydogpaws.com
* @author Ryan Thrash http://thrash.me
* @author and many others since 2006
* @lastupdate 15/06/2017
*/
if(!defined('MODX_BASE_PATH')) {
die('What are you doing? Get out of here!');
}
$wf_base_path = $modx->config['base_path'] . 'assets/snippets/wayfinder/';
$conf_path = "{$wf_base_path}configs/";
//Include a custom config file if specified
@include("{$conf_path}default.config.php");
$config = (!isset($config)) ? 'default' : trim($config);
$config = ltrim($config, '/');
if(substr($config, 0, 6) == '@CHUNK') {
eval('?>' . $modx->getChunk(trim(substr($config, 7))));
} elseif(substr($config, 0, 5) == '@FILE') {
include($modx->config['base_path'] . trim(substr($config, 6)));
} elseif($config != 'default' && is_file("{$conf_path}{$config}.config.php")) {
include("{$conf_path}{$config}.config.php");
} elseif(is_file("{$conf_path}{$config}")) {
include("{$conf_path}{$config}");
} elseif(is_file($modx->config['base_path'] . $config)) {
include($modx->config['base_path'] . $config);
}
include_once("{$wf_base_path}wayfinder_custom.inc.php");
if(class_exists('Wayfinder')) {
$wf = new Wayfinder();
} else {
return 'error: Wayfinder class not found';
}
$wf->_config = array(
'id' => isset($startId) ? $startId : $modx->documentIdentifier,
'level' => isset($level) ? intval($level) : 0,
'includeDocs' => isset($includeDocs) ? $includeDocs : 0,
'excludeDocs' => isset($excludeDocs) ? $excludeDocs : 0,
'where' => isset($where) ? $where : '',
'ph' => isset($ph) ? $ph : FALSE,
'debug' => isset($debug) ? TRUE : FALSE,
'ignoreHidden' => isset($ignoreHidden) ? $ignoreHidden : FALSE,
'hideSubMenus' => isset($hideSubMenus) ? $hideSubMenus : FALSE,
'useWeblinkUrl' => isset($useWeblinkUrl) ? $useWeblinkUrl : TRUE,
'fullLink' => isset($fullLink) ? $fullLink : FALSE,
'nl' => isset($removeNewLines) ? '' : "\n",
'sortOrder' => isset($sortOrder) ? strtoupper($sortOrder) : 'ASC',
'sortBy' => isset($sortBy) ? $sortBy : 'menuindex',
'limit' => isset($limit) ? $limit : 0,
'cssTpl' => isset($cssTpl) ? $cssTpl : FALSE,
'jsTpl' => isset($jsTpl) ? $jsTpl : FALSE,
'rowIdPrefix' => isset($rowIdPrefix) ? $rowIdPrefix : FALSE,
'textOfLinks' => isset($textOfLinks) ? $textOfLinks : 'menutitle',
'titleOfLinks' => isset($titleOfLinks) ? $titleOfLinks : 'pagetitle',
'displayStart' => isset($displayStart) ? $displayStart : FALSE,
'showPrivate' => isset($showPrivate) ? $showPrivate : FALSE,
'entityEncode' => isset($entityEncode) ? $entityEncode : TRUE,
// for local references - use original document fields separated by comma (useful for set active if it is current, titles, link attr, etc)
'useReferenced' => isset($useReferenced) ? $useReferenced : "id",
'hereId' => isset($hereId) ? intval($hereId) : $modx->documentIdentifier
);
//get user class definitions
$wf->_css = array(
'first' => isset($firstClass) ? $firstClass : '',
'last' => isset($lastClass) ? $lastClass : 'last',
'here' => isset($hereClass) ? $hereClass : 'active',
'parent' => isset($parentClass) ? $parentClass : '',
'row' => isset($rowClass) ? $rowClass : '',
'outer' => isset($outerClass) ? $outerClass : '',
'inner' => isset($innerClass) ? $innerClass : '',
'outerLevel' => isset($outerLevelClass) ? $outerLevelClass : '',
'level' => isset($levelClass) ? $levelClass : '',
'self' => isset($selfClass) ? $selfClass : '',
'weblink' => isset($webLinkClass) ? $webLinkClass : '',
);
//get user templates
$wf->_templates = array(
'outerTpl' => isset($outerTpl) ? $outerTpl : '',
'rowTpl' => isset($rowTpl) ? $rowTpl : '',
'parentRowTpl' => isset($parentRowTpl) ? $parentRowTpl : '',
'parentRowHereTpl' => isset($parentRowHereTpl) ? $parentRowHereTpl : '',
'hereTpl' => isset($hereTpl) ? $hereTpl : '',
'innerTpl' => isset($innerTpl) ? $innerTpl : '',
'innerRowTpl' => isset($innerRowTpl) ? $innerRowTpl : '',
'innerHereTpl' => isset($innerHereTpl) ? $innerHereTpl : '',
'activeParentRowTpl' => isset($activeParentRowTpl) ? $activeParentRowTpl : '',
'categoryFoldersTpl' => isset($categoryFoldersTpl) ? $categoryFoldersTpl : '',
'startItemTpl' => isset($startItemTpl) ? $startItemTpl : '',
'lastRowTpl' => isset($lastRowTpl) ? $lastRowTpl : '',
);
foreach ($modx->event->params as $key => $value) {
if (strpos($key, 'Tpl') !== false) {
$wf->_templates[$key] = $value;
}
}
//Process Wayfinder
$output = $wf->run();
if($wf->_config['debug'] && $modx->checkSession()) {
$modx->regClientHTMLBlock($wf->renderDebugOutput());
}
//Output Results
if($wf->_config['ph']) {
$modx->setPlaceholder($wf->_config['ph'], $output);
return;
} else {
return $output;
}