[ class tree: phpchartPlus ] [ index: phpchartPlus ] [ all elements ]

Source for file XMLConfig_Strategy.php

Documentation is available at XMLConfig_Strategy.php

  1. <?php
  2.  
  3. /*
  4. **************************************************
  5. Class: XMLConfig_Strategy.php
  6. **************************************************
  7. Author: Tsiavos Chris <jaames@freemail.gr>
  8. Date: October 2004
  9. **************************************************/
  10.  
  11. /**
  12. *Includes:
  13. *-the ConfigStrategy Interface
  14. *-the ConfigData class, the common communication structure between
  15. *ConfigStrategy objects and ConfigParser
  16. */
  17. require_once("ConfigStrategy_Interface.php");
  18.  
  19. /**
  20. *Strategy for importing configuration data from XML Files
  21. *@uses SimpleXML Extension
  22. *@author Tsiavos Chris <jaames@freemail.gr>
  23. *@license http://opensource.org/licenses/gpl-license.php GNU Public License
  24. */
  25. class XMLConfig_Strategy implements ConfigStrategy_Interface {
  26.  
  27. private $XMLHandler;
  28.  
  29. public function initialize($params=NULL)
  30. {
  31. $filename=$params["filename"];
  32. if (!file_exists($filename))
  33. throw new ConfigStrategy_Exception("XMLConfig_Strategy: File $filename not found");
  34. $this->XMLHandler=simplexml_load_file($filename);
  35. }
  36. public function readData($params=NULL)
  37. {
  38. $ConfigData=new ConfigData();
  39. $ConfigData->ImageWidth=(integer)$this->XMLHandler->ImageProperties->Width;
  40. $ConfigData->ImageHeight=(integer)$this->XMLHandler->ImageProperties->Height;
  41. $ConfigData->ImageOutputType=(string)$this->XMLHandler->ImageProperties->Output;
  42. $ConfigData->ImageColor_Start=(string)$this->XMLHandler->ImageProperties->ImageColor->StartColor;
  43. $ConfigData->ImageColor_Finish=(string)$this->XMLHandler->ImageProperties->ImageColor->FinishColor;
  44. $ConfigData->ImageColor_Alpha=(integer)$this->XMLHandler->ImageProperties->ImageColor['alpha'];
  45. $ConfigData->ChartTitle=(string)$this->XMLHandler->ChartProperties->Title;
  46. $ConfigData->ChartType=(string)$this->XMLHandler->ChartProperties->Type;
  47. $ConfigData->ChartUseBlending=(string)$this->XMLHandler->ChartProperties->Blending;
  48. $ConfigData->ChartUseAntialias=(string)$this->XMLHandler->ChartProperties->Antialiasing;
  49. $ConfigData->ChartHmargin=(integer)$this->XMLHandler->ChartProperties->Hmargin;
  50. $ConfigData->ChartVmargin=(integer)$this->XMLHandler->ChartProperties->Vmargin;
  51. $ConfigData->ChartUseStatus=(string)$this->XMLHandler->ChartProperties->StatusIndication;
  52. $ConfigData->ChartColor_Start=(string)$this->XMLHandler->ChartProperties->ChartColor->StartColor;
  53. $ConfigData->ChartColor_Finish=(string)$this->XMLHandler->ChartProperties->ChartColor->FinishColor;
  54. $ConfigData->ChartColor_Alpha=(integer)$this->XMLHandler->ChartProperties->ChartColor['alpha'];
  55. $ConfigData->ChartBgImage=(string)$this->XMLHandler->ChartProperties->BackgroundImage->FileLocation;
  56. $LegendColors=array();
  57. $LegendColors_Alpha=array();
  58. foreach ($this->XMLHandler->ChartProperties->Legend->Items->Item as $item) {
  59. array_push($LegendColors,(string)$item->StartColor.",".(string)$item->FinishColor);
  60. array_push($LegendColors_Alpha,(integer)$item['alpha']);
  61. }
  62. $ConfigData->LegendColors=$LegendColors;
  63. $ConfigData->LegendColors_Alpha=$LegendColors_Alpha;
  64. $ConfigData->FontFileLocation=(string)$this->XMLHandler->ChartProperties->Font->FileLocation;
  65. $ConfigData->FontColor=(string)$this->XMLHandler->ChartProperties->Font->Color;
  66. $ConfigData->FontWidth=(integer)$this->XMLHandler->ChartProperties->Font->Width;
  67. $ConfigData->FontHeight=(integer)$this->XMLHandler->ChartProperties->Font->Height;
  68. $ConfigData->FontSize=(integer)$this->XMLHandler->ChartProperties->Font->Size;
  69. $ConfigData->GridNum=(integer)$this->XMLHandler->GridProperties->NumGrids;
  70. $ConfigData->GridMinValue=(float)$this->XMLHandler->GridProperties->MinValue;
  71. $ConfigData->GridMaxValue=(float)$this->XMLHandler->GridProperties->MaxValue;
  72. $ConfigData->GridColor=(string)$this->XMLHandler->GridProperties->GridColor;
  73. return $ConfigData;
  74. }
  75.  
  76. public function finalize()
  77. {
  78. return;
  79. }
  80.  
  81.  
  82. }

Documentation generated on Sun, 3 Oct 2004 14:59:36 +0300 by phpDocumentor 1.3.0RC3