array('type'=>'key', 'label' => 'Identifiant'), 'model' => array('type'=>'text','label' => 'Modèle'), 'type' => array('type'=>'list','label' => 'Type'), 'meta' => array('type'=>'textarea','label' => 'Meta'), 'column' => array('type'=>'integer','label' => 'Colonne'), 'row' => array('type'=>'integer','label' => 'Ligne'), 'width' => array('type'=>'integer','label' => 'Largeur'), 'height' => array('type'=>'integer','label' => 'Hauteur'), 'dashboard' => array('type'=>'integer','label' => 'Tableau de bord','link'=>'plugin/dashboard/Dashboard.class.php') ); //Colonnes indexées public $indexes = array(); public function __construct(){ $this->model = self::MODEL_NEW; parent::__construct(); } public function toArray($decoded=false){ return array_merge(array( 'icon' => $this->icon, 'headerBackground' => $this->headerBackground, 'description' => $this->description, 'label' => $this->label, 'content' => $this->content ),parent::toArray($decoded)); } function toData(){ $row = $this->toArray(); $model = DashboardWidget::model($this->model); $finalRow = $model->toArray(); foreach($row as $attribute=>$value){ if(isset($value)) $finalRow[$attribute] = $value; } return $finalRow; } //liste des Type possibles public static function types($key=null){ $items = array( 'widget' => array('label'=>'Widget'), 'model' => array('label'=>'Modèle de widget'), ); if(!isset($key)) return $items; return isset($items[$key]) ? $items[$key] : array('label'=>'Non définis'); } public static function model($slug = null){ $model = array(); Plugin::callHook('widget',array(&$models)); //@TODO: Placer en hook $clock = new DashboardWidget(); $clock->icon = 'far fa-user'; $clock->headerBackground = 'rgb(0, 123, 255)'; $clock->description = 'Une Horloge toute couillone'; $clock->label = 'Horloge'; $clock->content = '
13:37
'; $clock->width = 3; $clock->height = 3; $models['clock'] = $clock; $newModel = new DashboardWidget(); $newModel->icon = 'far fa-user'; $newModel->headerBackground = 'rgb(0, 123, 255)'; $newModel->description = 'Type de widget non défini'; $newModel->label = 'Nouveau widget'; $newModel->content = '
Cliquez sur l\'icone en haut à droite pour configurer votre widget
'; $newModel->width = 3; $newModel->height = 2; $models[self::MODEL_NEW] = $newModel; foreach($models as $model){ if(!isset($model->model)) continue; $models[$model->model] = $model; } if(!isset($slug)) return $models; return isset($models[$slug]) ? $models[$slug] : $model; } }