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(){ ?> icon = 'far fa-user'; $model->headerBackground = 'rgb(0, 123, 255)'; $model->description = 'Une Horloge toute couillone'; $model->label = 'Horloge'; $model->width = 3; $model->height = 3; $model->model = 'clock'; $model->css = array(__DIR__.'/css/widget-clock.css?v='.time()); $model->js = array(__DIR__.'/js/widget-clock.js?v='.time()); $model->content = function(&$widget){ if(empty($widget->meta['hour-format'])) $widget->meta['hour-format'] = 'H:i:s'; $widget->content = '
'.date($widget->meta['hour-format']).'
'; $widget->label = 'Horloge '.date($widget->meta['hour-format']); }; $model->configure = function($widget){ if(empty($widget->meta['hour-format'])) $widget->meta['hour-format'] = 'H:i:s'; ?> save = function($widget,$form){ $widget->meta['hour-format'] = $form['hour-format']; $widget->save(); }; $models[$model->model] = $model; }); //Déclation des assets Plugin::addCss("/css/main.css"); Plugin::addCss("/css/component.css?v=2"); Plugin::addJs("/js/main.js"); Plugin::addJs("/js/dashboard.js?v=2"); Plugin::addJs("/js/component.js?v=2"); //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");