sId = $sId; $this->bRedrawNeeded = true; // By default: redraw each time a property changes $this->bFormRedrawNeeded = false; // By default: no need to redraw the form (independent fields) } public function FromDOMNode($oDOMNode) { } public function FromXml($sXml) { } public function FromParams($aParams) { } public function DoRender($oPage, $bEditMode = false, $aExtraParams = array()) { if ($bEditMode) { $sId = $this->GetID(); $oPage->add('
'); } else { $oPage->add('
'); } $this->Render($oPage, $bEditMode, $aExtraParams); $oPage->add('
'); if ($bEditMode) { $sClass = get_class($this); $oPage->add_ready_script( <<sId; } abstract public function Render($oPage, $bEditMode = false, $aExtraParams = array()); abstract public function GetPropertiesFields(DesignerForm $oForm); public function ToXml(DOMNode $oContainerNode) { } public function Update($aValues, $aUpdatedFields) { } public function IsRedrawNeeded() { return $this->bRedrawNeeded; } public function IsFormRedrawNeeded() { return $this->bFormRedrawNeeded; } static public function GetInfo() { return array( 'label' => '', 'icon' => '', 'description' => '', ); } public function GetForm($oPage, $bReturnHTML = false) { $oForm = new DesignerForm(); $oForm->SetPrefix("dashlet_". $this->GetID()); $oForm->SetParamsContainer('params'); $this->GetPropertiesFields($oForm); $oDashletClassField = new DesignerHiddenField('dashlet_class', '', get_class($this)); $oForm->AddField($oDashletClassField); $oDashletIdField = new DesignerHiddenField('dashlet_id', '', $this->GetID()); $oForm->AddField($oDashletIdField); return $oForm; } } class DashletHelloWorld extends Dashlet { protected $sText; public function __construct($sId) { parent::__construct($sId); $this->sText = 'Hello World'; } public function FromDOMNode($oDOMNode) { //$this->sText = 'Hello World!'; } public function FromXml($sXml) { //$this->sText = 'Hello World!'; } public function FromParams($aParams) { $this->sText = $aParams['text']; } public function Update($aValues, $aUpdatedFields) { foreach($aUpdatedFields as $sProp) { switch($sProp) { case 'text': $this->sText = $aValues['text']; break; } } } public function Render($oPage, $bEditMode = false, $aExtraParams = array()) { $oPage->add('
'.$this->sText.'
'); } public function GetPropertiesFields(DesignerForm $oForm) { $oField = new DesignerTextField('text', 'Text', $this->sText); $oForm->AddField($oField); } public function ToXml(DOMNode $oContainerNode) { $oNewNodeNode = $oContainerNode->ownerDocument->createElement('hello_world', 'test'); $oContainerNode->appendChild($oNewNodeNode); } static public function GetInfo() { return array( 'label' => 'Hello World', 'icon' => 'images/dashlet-text.png', 'description' => 'Hello World test Dashlet', ); } } class DashletFakeBarChart extends Dashlet { public function __construct($sId) { parent::__construct($sId); } public function FromDOMNode($oDOMNode) { } public function FromXml($sXml) { } public function FromParams($aParams) { } public function Render($oPage, $bEditMode = false, $aExtraParams = array()) { $oPage->add('
Fake Bar Chart
'); } public function GetPropertiesFields(DesignerForm $oForm, $oDashlet = null) { } public function ToXml(DOMNode $oContainerNode) { $oNewNodeNode = $oContainerNode->ownerDocument->createElement('fake_bar_chart', 'test'); $oContainerNode->appendChild($oNewNodeNode); } static public function GetInfo() { return array( 'label' => 'Bar Chart', 'icon' => 'images/dashlet-bar-chart.png', 'description' => 'Fake Bar Chart (for testing)', ); } } class DashletFakePieChart extends Dashlet { public function __construct($sId) { parent::__construct($sId); } public function FromDOMNode($oDOMNode) { } public function FromXml($sXml) { } public function FromParams($aParams) { } public function Render($oPage, $bEditMode = false, $aExtraParams = array()) { $oPage->add('
Fake Pie Chart
'); } public function GetPropertiesFields(DesignerForm $oForm, $oDashlet = null) { } public function ToXml(DOMNode $oContainerNode) { $oNewNodeNode = $oContainerNode->ownerDocument->createElement('fake_pie_chart', 'test'); $oContainerNode->appendChild($oNewNodeNode); } static public function GetInfo() { return array( 'label' => 'Pie Chart', 'icon' => 'images/dashlet-pie-chart.png', 'description' => 'Fake Pie Chart (for testing)', ); } }