123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- <?php
- //Déclaration d'un item de menu dans le menu principal
- function dashboard_menu(&$menuItems){
- global $myUser;
- if(!$myUser->can('dashboard','read')) return;
- $menuItems[] = array(
- 'sort'=>3,
- 'url'=>'index.php?module=dashboard',
- 'label'=>'Dashboard',
- 'icon'=> 'far fa-object-ungroup',
- 'color'=> '#273c75'
- );
- }
- //Cette fonction va générer une page quand on clique sur Dashboard dans menu
- function dashboard_page(){
- global $_, $myUser;
- if(isset($_['module'])) return;
- $page = !isset($_['page']) ? 'list.dashboard' : $_['page'];
- $page = str_replace('..','',$page);
- $file = __DIR__.SLASH.'page.'.$page.'.php';
- if(!file_exists($file)) throw new Exception("Page ".$page." inexistante");
- require_once($file);
- }
- //Fonction executée lors de l'activation du plugin
- function dashboard_install($id){
- if($id != 'fr.core.dashboard') return;
- Entity::install(__DIR__);
- }
- //Fonction executée lors de la désactivation du plugin
- function dashboard_uninstall($id){
- if($id != 'fr.core.dashboard') return;
- Entity::uninstall(__DIR__);
- }
- //Déclaration des sections de droits du plugin
- Right::register('dashboard',array('label'=>'Gestion des droits sur le plugin Dashboard'));
- //Déclaration du menu de réglages
- function dashboard_menu_setting(&$settingMenu){
- global $myUser;
- if(!$myUser->can('dashboard','configure')) return;
- $settingMenu[]= array(
- 'sort' =>1,
- 'url' => 'setting.php?section=global.dashboard',
- 'icon' => 'fas fa-angle-right',
- 'label' => 'Dashboard'
- );
- }
- //Déclaration des pages de réglages
- function dashboard_content_setting(){
- global $_;
- if(file_exists(__DIR__.SLASH.'setting.'.$_['section'].'.php'))
- require_once(__DIR__.SLASH.'setting.'.$_['section'].'.php');
- }
- require_once(__DIR__.SLASH.'action.php');
- //Déclaration des settings de base
- //Types possibles : voir FieldType.class.php. Un simple string définit une catégorie.
- Configuration::setting('dashboard',array(
- "Général",
- //'dashboard_enable' => array("label"=>"Activer","type"=>"boolean"),
- ));
- function dashboard_application_bottom(){
- ?>
- <template id="dashboard-widget-template">
- <div class="dashboard-widget" data-id="{{id}}" data-width="{{width}}" data-height="{{height}}">
- <div class="dashboard-widget-header">
- <div class="widget-header-icon"><i class="fas fa-question"></i></div>
- <div class="widget-header-title">{{label}}</div>
- <ul class="widget-header-options"></ul>
- </div>
- <div class="dashboard-widget-content"></div>
- <div class="dashboard-widget-resize py-1 px-2"><i class="fas fa-chevron-right"></i></div>
- </div>
- </template>
- <!-- Modal Dashboard -->
- <div class="modal fade dashboard-modal" id="dashboard-modal" tabindex="-1" role="dialog" aria-hidden="true">
- <div class="modal-dialog modal-lg" role="document">
- <div class="modal-content">
- <div class="modal-header">
- <h5 class="modal-title" id="exampleModalLabel">Configuration</h5>
- <button type="button" class="close" data-dismiss="modal" aria-label="Close">
- <span aria-hidden="true">×</span>
- </button>
- </div>
- <div class="modal-body p-0">
- <div class="row">
- <div class="col-md-4">
- <ul class="list-group rounded-0 dashboard-configure-menu" id="dashboard-configure-menu">
- <li data-menu='type' class="list-group-item border-top-0 active"><i class="far fa-window-maximize text-muted"></i> Type</li>
- <li data-menu='properties' class="list-group-item"><i class="fas fa-list-ul text-muted"></i> Propriétés</li>
- <li data-menu='style' class="list-group-item border-bottom-0"><i class="fas fa-palette text-muted"></i> Style</li>
- </ul>
- </div>
- <div class="col-md-8">
- <ul id="widget-types" class="widget-types bg-light">
- <li data-id="{{id}}" class="shadow-sm bg-white">
- <h3><i class="{{icon}}"></i> {{label}}</h3>
- <p>{{description}}</p>
- <a>+ D'infos</a>
- <div class="btn btn-primary">Selectionner</div>
- </li>
- </ul>
- </div>
- </div>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-primary">Enregistrer</button>
- </div>
- </div>
- </div>
- </div>
- <?php
- }
- //Déclation des assets
- Plugin::addCss("/css/main.css");
- Plugin::addCss("/css/component.css");
- Plugin::addJs("/js/main.js");
- Plugin::addJs("/js/dashboard.js");
- Plugin::addJs("/js/component.js");
- //Mapping hook / fonctions
- Plugin::addHook("install", "dashboard_install");
- Plugin::addHook("uninstall", "dashboard_uninstall");
- Plugin::addHook("menu_main", "dashboard_menu");
- Plugin::addHook("page", "dashboard_page");
- Plugin::addHook("menu_setting", "dashboard_menu_setting");
- Plugin::addHook("content_setting", "dashboard_content_setting");
- Plugin::addHook("application_bottom", "dashboard_application_bottom");
|