DashboardWidget.class.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * Define a dashboardwidget.
  4. * @author Idleman
  5. * @category Plugin
  6. * @license copyright
  7. */
  8. class DashboardWidget extends Entity{
  9. public $id,$minified,$position,$model,$dashboard,$title,$icon,$background,$width,$load,$configure,$move,$delete,$options,$js,$css,$content,$data,$description;
  10. protected $TABLE_NAME = 'dashboard_dashboard_widget';
  11. public $fields =
  12. array(
  13. 'id' => 'key',
  14. 'model' => 'string',
  15. 'data' => 'longstring',
  16. 'position' => 'int',
  17. 'minified' => 'boolean',
  18. 'dashboard' => 'int'
  19. );
  20. function __construct(){
  21. parent::__construct();
  22. $this->options = array();
  23. $this->icon = 'fa-caret-right';
  24. $this->title = 'Sans titre';
  25. $this->width = 4;
  26. }
  27. function data($key=null,$value=null){
  28. $data = json_decode($this->data,true);
  29. if($key==null) return $data;
  30. if(is_array($key) && $value==null){
  31. foreach ($key as $k => $v) {
  32. $data[$k] = $v;
  33. $this->data = json_encode($data);
  34. }
  35. return true;
  36. }
  37. if($value==null) return isset($data[$key])?$data[$key]:'';
  38. $data[$key] = $value;
  39. $this->data = json_encode($data);
  40. return true;
  41. }
  42. public static function current(){
  43. global $_;
  44. $widget = new self();
  45. $widget->fromArray($_);
  46. $widget->data = self::getById($widget->id)->data;
  47. return $widget;
  48. }
  49. }
  50. ?>