12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- /**
- * Define a dashboardwidget.
- * @author Idleman
- * @category Plugin
- * @license copyright
- */
- class DashboardWidget extends Entity{
- public $id,$minified,$position,$model,$dashboard,$title,$icon,$background,$width,$load,$configure,$move,$delete,$options,$js,$css,$content,$data,$description;
- protected $TABLE_NAME = 'dashboard_dashboard_widget';
- public $fields =
- array(
- 'id' => 'key',
- 'model' => 'string',
- 'data' => 'longstring',
- 'position' => 'int',
- 'minified' => 'boolean',
- 'dashboard' => 'int'
- );
- function __construct(){
- parent::__construct();
- $this->options = array();
- $this->icon = 'fa-caret-right';
- $this->title = 'Sans titre';
- $this->width = 4;
- }
- function data($key=null,$value=null){
- $data = json_decode($this->data,true);
- if($key==null) return $data;
- if(is_array($key) && $value==null){
- foreach ($key as $k => $v) {
- $data[$k] = $v;
- $this->data = json_encode($data);
- }
- return true;
- }
- if($value==null) return isset($data[$key])?$data[$key]:'';
- $data[$key] = $value;
- $this->data = json_encode($data);
- return true;
- }
- public static function current(){
- global $_;
- $widget = new self();
- $widget->fromArray($_);
- $widget->data = self::getById($widget->id)->data;
- return $widget;
- }
- }
- ?>
|