123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 |
- <?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-dialog-scrollable 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 overflow-hidden">
- <div class="container-fluid py-0 h-100">
- <div class="row h-100">
- <div class="col-md-3 border-right px-0 overflow-auto h-100 dashboard-configure-menu" id="dashboard-configure-menu">
- <ul class="nav nav-tabs flex-column dashboard-configure-menu rounded-0 border-0" id="dashboard-configure-menu" role="tablist" aria-orientation="vertical">
- <li data-menu='model' class="nav-item border-bottom">
- <a class="nav-link border-0 rounded-0 active" id="model-tab" data-toggle="tab" href="#model" role="tab" aria-controls="model" aria-selected="true">
- <i class="far fa-window-maximize mr-1"></i>Modèle
- </a>
- </li>
- <li data-menu='properties' class="nav-item border-bottom">
- <a class="nav-link border-0 rounded-0" id="properties-tab" data-toggle="tab" href="#properties" role="tab" aria-controls="properties" aria-selected="false">
- <i class="fas fa-list-ul mr-1"></i>Propriétés
- </a>
- </li>
- <li data-menu='style' class="nav-item border-bottom">
- <a class="nav-link border-0 rounded-0" id="style-tab" data-toggle="tab" href="#style" role="tab" aria-controls="style" aria-selected="false">
- <i class="fas fa-palette mr-1"></i>Style
- </a>
- </li>
- </ul>
- </div>
- <template id="configure-model">
- <ul id="widget-models" class="widget-models bg-light">
- <li data-model="{{model}}" class="shadow-sm bg-white hidden">
- <h3><i class="{{icon}}"></i> {{label}}</h3>
- <p>{{description}}</p>
- <i onclick="e.stopPropagation();$(this).next().toggleClass('hidden')" title="plus d'information sur le widget" class="fas fa-info-circle widget-model-info"></i>
- <div class="hidden text-muted">{{description}}</div>
- </li>
- </ul>
- </template>
- <template id="configure-style">
- <div class="row">
- <div class="col">
- <table class="table" id="configure-style-table">
- <tbody>
- <tr>
- <th colspan="2" class="align-middle">En-tête</th>
- </tr>
- <tr>
- <td><input type="text" data-type="icon" id="widget-header-icon"></td>
- <td class="align-middle">Icône</td>
- </tr>
- <tr>
- <td><input type="text" data-type="color" id="widget-header-icon-color"></td>
- <td class="align-middle">Couleur Icône</td>
- </tr>
- <tr>
- <td><input type="text" data-type="color" id="widget-header-title-color"></td>
- <td class="align-middle">Couleur titre</td>
- </tr>
- <tr>
- <td><input type="text" data-type="color" id="widget-header-background"></td>
- <td class="align-middle">Couleur de fond</td>
- </tr>
- <tr>
- <th colspan="2" class="align-middle">Corps</th>
- </tr>
- <tr>
- <td><input type="text" data-type="color" id="widget-body-background"></td>
- <td class="align-middle">Couleur de fond</td>
- </tr>
- <tr>
- <td><input type="text" data-type="color" id="widget-body-color"></td>
- <td class="align-middle">Couleur texte</td>
- </tr>
- </tbody>
- </table>
- </div>
- <div class="col dashboard-container">
- <!-- -->
- <div class="dashboard-widget dashboard-widget-customizer widget-draggable widget-resizeable widget-removable ui-draggable">
- <div class="dashboard-widget-header" style="background-color: rgb(0, 123, 255);">
- <div class="widget-header-icon ui-draggable-handle"><i class="far fa-user"></i></div>
- <div class="widget-header-title ui-draggable-handle">Titre</div>
- <ul class="widget-header-options"><li class="widget-option-configure" title="Configurer"><i class="fas fa-ellipsis-v"></i></li><li class="widget-option-delete" title="Supprimer"><i class="fa fa-times"></i></li></ul>
- </div>
- <div class="dashboard-widget-content"><div class="text-center m-auto">Contenu</div></div>
- <div class="dashboard-widget-resize py-1 px-2"><i class="fas fa-chevron-right"></i></div>
- </div>
- <!-- -->
- </div>
- </div>
- </template>
- <div class="col-md-9 px-0 overflow-auto h-100 dashboard-configure-content" id="dashboard-configure-content">
-
- </div>
- </div>
- </div>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn">Fermer</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");
|