- <?php
-
- /*
- **************************************************
- Class: XMLConfig_Strategy.php
- **************************************************
- Author: Tsiavos Chris <jaames@freemail.gr>
- Date: October 2004
- **************************************************/
-
- /**
- *Includes:
- *-the ConfigStrategy Interface
- *-the ConfigData class, the common communication structure between
- *ConfigStrategy objects and ConfigParser
- */
- require_once("ConfigStrategy_Interface.php");
-
- /**
- *Strategy for importing configuration data from XML Files
- *@uses SimpleXML Extension
- *@author Tsiavos Chris <jaames@freemail.gr>
- *@license http://opensource.org/licenses/gpl-license.php GNU Public License
- */
- class XMLConfig_Strategy implements ConfigStrategy_Interface {
-
- private $XMLHandler;
-
- public function initialize($params=NULL)
- {
- $filename=$params["filename"];
-
- if (!file_exists($filename))
- throw new ConfigStrategy_Exception("XMLConfig_Strategy: File $filename not found");
-
- $this->XMLHandler=simplexml_load_file($filename);
- }
-
- public function readData($params=NULL)
- {
- $ConfigData=new ConfigData();
- $ConfigData->ImageWidth=(integer)$this->XMLHandler->ImageProperties->Width;
- $ConfigData->ImageHeight=(integer)$this->XMLHandler->ImageProperties->Height;
- $ConfigData->ImageOutputType=(string)$this->XMLHandler->ImageProperties->Output;
- $ConfigData->ImageColor_Start=(string)$this->XMLHandler->ImageProperties->ImageColor->StartColor;
- $ConfigData->ImageColor_Finish=(string)$this->XMLHandler->ImageProperties->ImageColor->FinishColor;
- $ConfigData->ImageColor_Alpha=(integer)$this->XMLHandler->ImageProperties->ImageColor['alpha'];
-
- $ConfigData->ChartTitle=(string)$this->XMLHandler->ChartProperties->Title;
- $ConfigData->ChartType=(string)$this->XMLHandler->ChartProperties->Type;
- $ConfigData->ChartUseBlending=(string)$this->XMLHandler->ChartProperties->Blending;
- $ConfigData->ChartUseAntialias=(string)$this->XMLHandler->ChartProperties->Antialiasing;
- $ConfigData->ChartHmargin=(integer)$this->XMLHandler->ChartProperties->Hmargin;
- $ConfigData->ChartVmargin=(integer)$this->XMLHandler->ChartProperties->Vmargin;
- $ConfigData->ChartUseStatus=(string)$this->XMLHandler->ChartProperties->StatusIndication;
- $ConfigData->ChartColor_Start=(string)$this->XMLHandler->ChartProperties->ChartColor->StartColor;
- $ConfigData->ChartColor_Finish=(string)$this->XMLHandler->ChartProperties->ChartColor->FinishColor;
- $ConfigData->ChartColor_Alpha=(integer)$this->XMLHandler->ChartProperties->ChartColor['alpha'];
- $ConfigData->ChartBgImage=(string)$this->XMLHandler->ChartProperties->BackgroundImage->FileLocation;
-
- $LegendColors=array();
- $LegendColors_Alpha=array();
-
- foreach ($this->XMLHandler->ChartProperties->Legend->Items->Item as $item) {
- array_push($LegendColors,(string)$item->StartColor.",".(string)$item->FinishColor);
- array_push($LegendColors_Alpha,(integer)$item['alpha']);
- }
-
- $ConfigData->LegendColors=$LegendColors;
- $ConfigData->LegendColors_Alpha=$LegendColors_Alpha;
-
- $ConfigData->FontFileLocation=(string)$this->XMLHandler->ChartProperties->Font->FileLocation;
- $ConfigData->FontColor=(string)$this->XMLHandler->ChartProperties->Font->Color;
- $ConfigData->FontWidth=(integer)$this->XMLHandler->ChartProperties->Font->Width;
- $ConfigData->FontHeight=(integer)$this->XMLHandler->ChartProperties->Font->Height;
- $ConfigData->FontSize=(integer)$this->XMLHandler->ChartProperties->Font->Size;
-
- $ConfigData->GridNum=(integer)$this->XMLHandler->GridProperties->NumGrids;
- $ConfigData->GridMinValue=(float)$this->XMLHandler->GridProperties->MinValue;
- $ConfigData->GridMaxValue=(float)$this->XMLHandler->GridProperties->MaxValue;
- $ConfigData->GridColor=(string)$this->XMLHandler->GridProperties->GridColor;
-
- return $ConfigData;
- }
-
- public function finalize()
- {
- return;
- }
-
-
- }