winter/modules/cms/ServiceProvider.php

132 lines
5.0 KiB
PHP
Raw Normal View History

<?php namespace Cms;
2014-05-14 23:24:20 +10:00
use Lang;
use Backend;
use BackendMenu;
use BackendAuth;
use Backend\Classes\WidgetManager;
use October\Rain\Support\ModuleServiceProvider;
2014-07-19 13:05:50 +11:00
use System\Classes\SettingsManager;
class ServiceProvider extends ModuleServiceProvider
{
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
parent::register('cms');
2014-05-14 23:24:20 +10:00
/*
* Register navigation
*/
BackendMenu::registerCallback(function($manager) {
$manager->registerMenuItems('October.Cms', [
'cms' => [
'label' => 'cms::lang.cms.menu_label',
'icon' => 'icon-magic',
'url' => Backend::url('cms'),
'permissions' => ['cms.*'],
'order' => 10,
'sideMenu' => [
'pages' => [
'label' => 'cms::lang.page.menu_label',
'icon' => 'icon-copy',
'url' => 'javascript:;',
'attributes' => ['data-menu-item'=>'pages'],
'permissions' => ['cms.manage_pages']
],
'partials' => [
'label' => 'cms::lang.partial.menu_label',
'icon' => 'icon-tags',
'url' => 'javascript:;',
'attributes' => ['data-menu-item'=>'partials'],
'permissions' => ['cms.manage_partials']
],
'layouts' => [
'label' => 'cms::lang.layout.menu_label',
'icon' => 'icon-th-large',
'url' => 'javascript:;',
'attributes' => ['data-menu-item'=>'layouts'],
'permissions' => ['cms.manage_layouts']
],
'content' => [
'label' => 'cms::lang.content.menu_label',
'icon' => 'icon-file-text-o',
'url' => 'javascript:;',
'attributes' => ['data-menu-item'=>'content'],
'permissions' => ['cms.manage_content']
],
'assets' => [
'label' => 'cms::lang.asset.menu_label',
'icon' => 'icon-picture-o',
'url' => 'javascript:;',
'attributes' => ['data-menu-item'=>'assets'],
'permissions' => ['cms.manage_assets']
],
'components' => [
'label' => 'cms::lang.component.menu_label',
'icon' => 'icon-puzzle-piece',
'url' => 'javascript:;',
'attributes' => ['data-menu-item'=>'components'],
'permissions' => ['cms.manage_pages', 'cms:manage_layouts']
]
]
]
]);
});
/*
* Register permissions
*/
BackendAuth::registerCallback(function($manager) {
$manager->registerPermissions('October.Cms', [
'cms.manage_content' => ['label' => 'Manage content', 'tab' => 'Cms'],
'cms.manage_assets' => ['label' => 'Manage assets', 'tab' => 'Cms'],
'cms.manage_pages' => ['label' => 'Manage pages', 'tab' => 'Cms'],
'cms.manage_layouts' => ['label' => 'Manage layouts', 'tab' => 'Cms'],
'cms.manage_partials' => ['label' => 'Manage partials', 'tab' => 'Cms'],
2014-07-19 13:05:50 +11:00
'cms.manage_themes' => ['label' => 'Manage themes', 'tab' => 'Cms']
2014-05-14 23:24:20 +10:00
]);
});
/*
* Register widgets
*/
WidgetManager::instance()->registerFormWidgets(function($manager){
$manager->registerFormWidget('Cms\FormWidgets\Components');
});
2014-07-19 13:05:50 +11:00
/*
* Register settings
*/
SettingsManager::instance()->registerCallback(function($manager){
$manager->registerSettingItems('October.Cms', [
'theme' => [
'label' => 'cms::lang.theme.settings_menu',
'description' => 'cms::lang.theme.settings_menu_description',
'category' => 'CMS',
'icon' => 'icon-picture-o',
'url' => Backend::URL('cms/theme'),
2014-07-19 15:51:43 +10:00
'order' => 200
2014-07-19 13:05:50 +11:00
]
]);
});
}
/**
* Bootstrap the module events.
*
* @return void
*/
public function boot()
{
parent::boot('cms');
}
2014-05-14 23:24:20 +10:00
}