-
Notifications
You must be signed in to change notification settings - Fork 140
Expand file tree
/
Copy pathPlugin.php
More file actions
181 lines (170 loc) · 5.89 KB
/
Copy pathPlugin.php
File metadata and controls
181 lines (170 loc) · 5.89 KB
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
175
176
177
178
179
180
181
<?php namespace RainLab\Blog;
use Event;
use Backend;
use System\Classes\PluginBase;
use RainLab\Blog\Models\Post;
use RainLab\Blog\Models\Category;
/**
* Plugin registration for Blog
*/
class Plugin extends PluginBase
{
/**
* pluginDetails
*/
public function pluginDetails()
{
return [
'name' => "Blog",
'description' => "A robust blogging platform.",
'author' => 'Alexey Bobkov, Samuel Georges',
'icon' => 'icon-pencil',
'homepage' => 'https://github.com/rainlab/blog-plugin'
];
}
/**
* boot the module events.
*/
public function boot()
{
$this->bootPageManagerLookups();
}
/**
* registerComponents
*/
public function registerComponents()
{
return [
\RainLab\Blog\Components\Post::class => 'blogPost',
\RainLab\Blog\Components\Posts::class => 'blogPosts',
\RainLab\Blog\Components\Categories::class => 'blogCategories',
\RainLab\Blog\Components\RssFeed::class => 'blogRssFeed',
];
}
/**
* registerPermissions
*/
public function registerPermissions()
{
return [
'rainlab.blog.manage_settings' => [
'tab' => "Blog",
'label' => "Manage blog settings",
],
'rainlab.blog.access_posts' => [
'tab' => "Blog",
'label' => "Manage the blog posts",
],
'rainlab.blog.access_categories' => [
'tab' => "Blog",
'label' => "Manage the blog categories",
],
'rainlab.blog.access_other_posts' => [
'tab' => "Blog",
'label' => "Manage other users blog posts",
],
'rainlab.blog.access_import_export' => [
'tab' => "Blog",
'label' => "Allowed to import and export posts",
],
'rainlab.blog.access_publish' => [
'tab' => "Blog",
'label' => "Allowed to publish posts",
],
];
}
/**
* registerNavigation
*/
public function registerNavigation()
{
return [
'blog' => [
'label' => "Blog",
'url' => Backend::url('rainlab/blog/posts'),
'icon' => 'icon-pencil',
'iconSvg' => 'plugins/rainlab/blog/assets/images/blog-icon.svg',
'permissions' => ['rainlab.blog.*'],
'order' => 300,
'sideMenu' => [
'new_post' => [
'label' => "New Post",
'icon' => 'icon-plus',
'url' => Backend::url('rainlab/blog/posts/create'),
'permissions' => ['rainlab.blog.access_posts'],
],
'posts' => [
'label' => "Posts",
'icon' => 'icon-copy',
'url' => Backend::url('rainlab/blog/posts'),
'permissions' => ['rainlab.blog.access_posts'],
],
'categories' => [
'label' => "Categories",
'icon' => 'icon-list-ul',
'url' => Backend::url('rainlab/blog/categories'),
'permissions' => ['rainlab.blog.access_categories'],
],
],
],
];
}
/**
* registerSettings
*/
public function registerSettings()
{
return [
'blog' => [
'label' => "Blog Settings",
'description' => "Manage blog settings",
'category' => "Blog",
'icon' => 'icon-pencil',
'class' => \RainLab\Blog\Models\Setting::class,
'order' => 500,
'keywords' => 'blog post category',
'permissions' => ['rainlab.blog.manage_settings'],
],
];
}
/**
* bootPageManagerLookups registers menu items for the RainLab.Pages plugin
*/
protected function bootPageManagerLookups()
{
Event::listen('cms.pageLookup.listTypes', function() {
return [
'blog-category' => "Blog Category",
'all-blog-categories' => ["All Blog Categories", true],
'blog-post' => "Blog Post",
'all-blog-posts' => ["All Blog Posts", true],
'category-blog-posts' => ["Blog Category Posts", true],
];
});
Event::listen('pages.menuitem.listTypes', function() {
return [
'blog-category' => "Blog Category",
'all-blog-categories' => "All Blog Categories",
'blog-post' => "Blog Post",
'all-blog-posts' => "All Blog Posts",
'category-blog-posts' => "Blog Category Posts",
];
});
Event::listen(['cms.pageLookup.getTypeInfo', 'pages.menuitem.getTypeInfo'], function($type) {
if ($type === 'blog-category' || $type === 'all-blog-categories') {
return Category::getMenuTypeInfo($type);
}
elseif ($type === 'blog-post' || $type === 'all-blog-posts' || $type === 'category-blog-posts') {
return Post::getMenuTypeInfo($type);
}
});
Event::listen(['cms.pageLookup.resolveItem', 'pages.menuitem.resolveItem'], function($type, $item, $url, $theme) {
if ($type === 'blog-category' || $type === 'all-blog-categories') {
return Category::resolveMenuItem($item, $url, $theme);
}
elseif ($type === 'blog-post' || $type === 'all-blog-posts' || $type === 'category-blog-posts') {
return Post::resolveMenuItem($item, $url, $theme);
}
});
}
}