-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
174 lines (150 loc) · 7.45 KB
/
index.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<?php
namespace amteich\helpsection;
use Kirby;
\Kirby::plugin('amteich/helpsection', [
'options' => [
'icon' => 'question',
],
'routes' => function ($kirby) {
return [
[
'pattern' => $kirby->option('amteich.helpsection.contentfolder', 'helpsection'),
'action' => function () {
return false;
}
]
];
},
'api' => include __DIR__ . '/includes/api.php',
'templates' => [
'doc' => __DIR__ . '/templates/doc.php',
'docindex' => __DIR__ . '/templates/docindex.php',
],
'blueprints' => [
'pages/docindex' => __DIR__ . '/blueprints/docindex.yml'
],
'translations' => require __DIR__ . '/includes/translations.php',
'areas' => [
'helpsection' => function () {
return [
// label for the menu and the breadcrumb
'label' => 'Hilfe',
// icon for the menu and breadcrumb
'icon' => 'amteichhelpsection',
// show / hide from the menu
'menu' => true,
// link to the main area view
'link' => 'helpsection',
// views
'views' => [
[
'pattern' => 'helpsection',
'action' => function () {
// view routes return a simple array,
// which will be injected into our Vue app;
// the array can control the loaded Vue component,
// props for the component and settings for the current view
// (like breadcrumb, title, active search type etc.)
$slug = option('amteich.helpsection.contentfolder', 'helpsection');
$pages = [];
$page = page($slug);
if ($page == null) {
return [
'status' => 'failed',
'error' => "Please create a new content-folder <code>$slug</code> to show it here.",
];
}
foreach (page($slug)->children()->listed() as $page) {
$pagedata = [
'title' => (string)$page->title(),
'id' => (string)$page->id(),
];
if ($page->hasListedChildren()) {
$children = $page->children()->listed();
$childrendata = [];
foreach ($children as $child) {
$childrendata[] = [
'title' => (string)$child->title(),
'id' => (string)$child->id(),
'slug' => (string)$child->id(),
'hasChildren' => (bool)$child->hasChildren(),
'rendered' => (string)$child->render(),
];
}
$pagedata['children'] = $childrendata;
}
$pages[] = $pagedata;
}
return [
// the Vue component can be defined in the
// `index.js` of your plugin
'component' => 'k-helpsection-view',
// the document title for the current view
'title' => 'Hilfe',
// the breadcrumb can be just an array or a callback
// function for more complex breadcrumb logic
// 'breadcrumb' => function () {
// // each item in the breadcrumb array
// // has a label and a link attribute
// return [
// [
// 'label' => 'Buy some milk',
// 'link' => '/todos/123'
// ]
// ];
// },
// props will be directly available in the
// Vue component. It's a super convenient way
// to send backend data to the Panel
'props' => [
'pages' => $pages,
],
// we can preset the search type with the
// search attribute
'search' => 'pages'
];
}
],
[
'pattern' => 'helpsection/(:all)',
'action' => function ($slug) {
// view routes return a simple array,
// which will be injected into our Vue app;
// the array can control the loaded Vue component,
// props for the component and settings for the current view
// (like breadcrumb, title, active search type etc.)
return [
// the Vue component can be defined in the
// `index.js` of your plugin
'component' => 'k-helpsection-view',
// the document title for the current view
'title' => 'Hilfe',
// the breadcrumb can be just an array or a callback
// function for more complex breadcrumb logic
// 'breadcrumb' => function () {
// // each item in the breadcrumb array
// // has a label and a link attribute
// return [
// [
// 'label' => 'Buy some milk',
// 'link' => '/todos/123'
// ]
// ];
// },
// props will be directly available in the
// Vue component. It's a super convenient way
// to send backend data to the Panel
'props' => [
'slug' => $slug,
],
// we can preset the search type with the
// search attribute
'search' => 'pages'
];
}
],
]
];
}
]
]);