|
@@ -250,28 +250,125 @@ Plugin::addHook("menu_user", function(&$userMenu){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-function navigation_widget(&$widgets){
|
|
|
|
- global $myUser;
|
|
|
|
- require_once(PLUGIN_PATH.'dashboard'.SLASH.'DashboardWidget.class.php');
|
|
|
|
-
|
|
|
|
- $modelWidget = new DashboardWidget();
|
|
|
|
- $modelWidget->model = 'menu';
|
|
|
|
- $modelWidget->title = 'Menu';
|
|
|
|
- $modelWidget->icon = 'far fa-compass';
|
|
|
|
- $modelWidget->background = '#130f40';
|
|
|
|
- $modelWidget->load = 'action.php?action=navigation_widget_load';
|
|
|
|
- $modelWidget->js = [Plugin::url().'/js/widget.js?v=0'];
|
|
|
|
- $modelWidget->css = [Plugin::url().'/css/widget.css?v=0'];
|
|
|
|
- $modelWidget->configure = 'action.php?action=navigation_widget_configure';
|
|
|
|
- $modelWidget->configure_callback = 'navigation_widget_configure_save';
|
|
|
|
- $modelWidget->configure_init = 'navigation_widget_configure_init';
|
|
|
|
- $modelWidget->description = "Affiche un menu sélectionné";
|
|
|
|
- $widgets[] = $modelWidget;
|
|
|
|
-}
|
|
|
|
|
|
+// function navigation_widget(&$widgets){
|
|
|
|
+// global $myUser;
|
|
|
|
+// require_once(PLUGIN_PATH.'dashboard'.SLASH.'DashboardWidget.class.php');
|
|
|
|
+
|
|
|
|
+// $modelWidget = new DashboardWidget();
|
|
|
|
+// $modelWidget->model = 'menu';
|
|
|
|
+// $modelWidget->title = 'Menu';
|
|
|
|
+// $modelWidget->icon = 'far fa-compass';
|
|
|
|
+// $modelWidget->background = '#130f40';
|
|
|
|
+// $modelWidget->load = 'action.php?action=navigation_widget_load';
|
|
|
|
+// $modelWidget->js = [Plugin::url().'/js/widget.js?v=0'];
|
|
|
|
+// $modelWidget->css = [Plugin::url().'/css/widget.css?v=0'];
|
|
|
|
+// $modelWidget->configure = 'action.php?action=navigation_widget_configure';
|
|
|
|
+// $modelWidget->configure_callback = 'navigation_widget_configure_save';
|
|
|
|
+// $modelWidget->configure_init = 'navigation_widget_configure_init';
|
|
|
|
+// $modelWidget->description = "Affiche un menu sélectionné";
|
|
|
|
+// $widgets[] = $modelWidget;
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+Plugin::addHook('widget',function(&$models){
|
|
|
|
+
|
|
|
|
+ $model = new DashboardWidget();
|
|
|
|
+ $model->icon = 'far fa-compass';
|
|
|
|
+ $model->headerBackground = '#130f40';
|
|
|
|
+ $model->description = 'Affiche un menu sélectionné';
|
|
|
|
+ $model->label = 'Menu';
|
|
|
|
+ $model->width = 3;
|
|
|
|
+ $model->height = 3;
|
|
|
|
+ $model->model = 'menu';
|
|
|
|
+ $model->css = array(__DIR__.'/css/widget.css?v='.time());
|
|
|
|
+ $model->js = array(__DIR__.'/js/widget.js?v='.time());
|
|
|
|
+
|
|
|
|
+ $model->content = function(&$widget){
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ global $myUser;
|
|
|
|
+ User::check_access('navigation','read');
|
|
|
|
+ Plugin::need('dashboard/DashboardWidget');
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if(empty($widget->meta['label'])){
|
|
|
|
+ $widget->meta['label'] = 'Bloc Menu';
|
|
|
|
+ }else{
|
|
|
|
+ $widget->meta['label'] = '';
|
|
|
|
+ $widget->meta['icon'] = '';
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ if(empty($widget->meta['url'])) $widget->meta['url'] = '';
|
|
|
|
+ ob_start();
|
|
|
|
+
|
|
|
|
+ $icon = empty($widget->meta['icon']) ? 'far fa-bookmark' : $widget->meta['icon'];
|
|
|
|
+ $color = empty($widget->meta['color'])? '#ffffff': $widget->meta['color'];
|
|
|
|
+
|
|
|
|
+ $url = navigation_meta_link($widget->meta['url']);
|
|
|
|
+ $label = navigation_meta_link($widget->meta['label']);
|
|
|
|
+
|
|
|
|
+ ?>
|
|
|
|
+ <div style="background: <?php echo $color; ?>" class="widgetNavigationContainer">
|
|
|
|
+ <?php if(!empty($widget->meta['label'])): ?>
|
|
|
|
+ <a href="<?php echo $url; ?>" <?php if(!empty($widget->meta['redirect'])) echo 'target="_blank"'; ?> >
|
|
|
|
+ <i class="<?php echo $icon; ?>"></i>
|
|
|
|
+ <?php echo $label; ?>
|
|
|
|
+ </a>
|
|
|
|
+ <?php else: ?>
|
|
|
|
+ <h4 class="noContent"><i class="far fa-compass"></i> Aucun menu spécifié</h4>
|
|
|
|
+ <?php endif; ?>
|
|
|
|
+
|
|
|
|
+ </div>
|
|
|
|
+ <?php
|
|
|
|
+
|
|
|
|
+ $widget->content = ob_get_clean();
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ $model->configure = function($widget){
|
|
|
|
+ if(empty($widget->meta['label'])) $widget->meta['label'] = 'Bloc Menu';
|
|
|
|
+ if(empty($widget->meta['url'])) $widget->meta['url'] = '';
|
|
|
|
+ ?>
|
|
|
|
+ <div id="navigation-widget-form">
|
|
|
|
+ <label for="">Icone / Titre / Couleur :</label>
|
|
|
|
+ <div class="input-group mb-2">
|
|
|
|
+ <input class="form-control" type="text" data-type="icon" value="<?php echo empty($widget->meta['icon'])?'far fa-bookmark':$widget->meta['icon']; ?>" id="widget-icon">
|
|
|
|
+ <input class="form-control" type="text" value="<?php echo $widget->meta['label']; ?>" id="widget-label">
|
|
|
|
+ <input class="form-control" type="text" data-type="color" value="<?php echo empty($widget->meta['color'])?'#000000':$widget->meta['color']; ?>" id="widget-color">
|
|
|
|
+ </div>
|
|
|
|
+ <label for="">Adresse URL :</label>
|
|
|
|
+ <div class="input-group mb-2">
|
|
|
|
+ <div class="input-group-prepend">
|
|
|
|
+ <div class="input-group-text">
|
|
|
|
+ <label for="widget-redirect" class="pointer mb-0">Redirection</label>
|
|
|
|
+ <input data-type="checkbox" name="widget-redirect" id="widget-redirect" <?php echo $widget->meta['redirect'] ? 'checked' : ''; ?>>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ <input class="form-control text-success" type="text" value="<?php echo $widget->meta['url']; ?>" id="widget-url">
|
|
|
|
+ <div class="input-group-append">
|
|
|
|
+ <a href="<?php echo $widget->meta['url']; ?>" target="_blank" class="text-success text-decoration-none input-group-text"><i class="fas fa-globe"></i></a>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ <?php
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ $model->save = function($widget,$form){
|
|
|
|
+
|
|
|
|
+ $url = str_replace(ROOT_URL.'/','',$form['widget-url']);
|
|
|
|
+ $widget->meta['url'] = $url;
|
|
|
|
+ $widget->meta['redirect'] = $form['widget-redirect'];
|
|
|
|
+ $widget->meta['icon'] = $form['widget-icon'];
|
|
|
|
+ $widget->meta['label'] = $form['widget-label'];
|
|
|
|
+ $widget->meta['color'] = $form['widget-color'];
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ $widget->save();
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ $models[$model->model] = $model;
|
|
|
|
+});
|
|
|
|
|
|
//Mapping hook / fonctions
|
|
//Mapping hook / fonctions
|
|
-Plugin::addHook("widget", "navigation_widget");
|
|
|
|
|
|
+//Plugin::addHook("widget", "navigation_widget");
|
|
Plugin::addHook("install", "navigation_install");
|
|
Plugin::addHook("install", "navigation_install");
|
|
Plugin::addHook("uninstall", "navigation_uninstall");
|
|
Plugin::addHook("uninstall", "navigation_uninstall");
|
|
|
|
|