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

Source for file XMLData_Strategy.php

Documentation is available at XMLData_Strategy.php

  1. <?php
  2.  
  3. /*
  4. **************************************************
  5. Class: XMLData_Strategy.php
  6. **************************************************
  7. Author: Tsiavos Chris <jaames@freemail.gr>
  8. Date: October 2004
  9. **************************************************/
  10.  
  11. /**
  12. *Includes the DataStrategy Interface
  13. */
  14. require_once("DataStrategy_Interface.php");
  15.  
  16. /**
  17. *Strategy for importing chart data from XML files
  18. *@author Tsiavos Chris <jaames@freemail.gr>
  19. *@uses SimpleXML Extension
  20. *@license http://opensource.org/licenses/gpl-license.php GNU Public License
  21. */
  22.  
  23. class XMLData_Strategy implements DataStrategy_Interface {
  24.  
  25. private $XMLHandler;
  26. public function initialize($params=NULL) {
  27. $filename=$params["filename"];
  28. if (!file_exists($filename))
  29. throw new DataStrategy_Exception("DataStrategy: Filename $filename not found");
  30. $this->XMLHandler=simplexml_load_file($filename);
  31. }
  32. public function perform($params=NULL) {
  33. $Groups=array();
  34. foreach ($this->XMLHandler->group as $group) {
  35. array_push($Groups,new Group());
  36. $CurrentGroup=count($Groups)-1;
  37. $Groups[$CurrentGroup]->GroupName=(string)$group['name'];
  38. foreach ($group->item as $item) {
  39. array_push($Groups[$CurrentGroup]->GroupItems,new GroupItem());
  40. $CurrentGroupItem=count($Groups[$CurrentGroup]->GroupItems)-1;
  41. $Groups[$CurrentGroup]->GroupItems[$CurrentGroupItem]->ItemName=(string)$item->name;
  42. $Groups[$CurrentGroup]->GroupItems[$CurrentGroupItem]->ItemValue=(float)$item->value;
  43. }
  44. }
  45. return $Groups;
  46. }
  47. public function finalize() {
  48. return;
  49. }
  50. }

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