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

Source for file XMLFormat.php

Documentation is available at XMLFormat.php

  1. <?php
  2.  
  3.  /**
  4.  * XMLFormat class
  5.  *
  6.  * Description: Chart data export to XML
  7.  *
  8.  * @author
  9.  * @copyright (c) 1995-2008 by Steema Software SL. All Rights Reserved. <info@steema.com>
  10.  * @version 1.0
  11.  * @package TeeChartPHP
  12.  * @subpackage exports
  13.  * @link http://www.steema.com
  14.  */
  15.  
  16.  class XMLFormat extends DataExportFormat {
  17.  
  18.     // Interceptors
  19.     function __get$property {
  20.       $method ="get{$property}";
  21.       if method_exists$this$method ) ) {
  22.         return $this->$method();
  23.       }
  24.     }
  25.  
  26.     function __set $property,$value {
  27.       $method ="set{$property}";
  28.       if method_exists$this$method ) ) {
  29.         return $this->$method($value);
  30.       }
  31.     }
  32.  
  33.     public function XMLFormat($c{
  34.         parent::DataExportFormat($c);
  35.         
  36.         $this->setFileExtension("xml");
  37.     }
  38.  
  39.     public function getFilterFiles({
  40.         return "XMLFilter"// TODO $this->Language->getString("XMLFilter");
  41.     }
  42.  
  43.     private function get($aList$index{
  44.         return " " $aList->getName("=\"" . (string)($aList->getValue($index)) .
  45.                 "\"";
  46.     }
  47.  
  48.     // Not used.
  49.     protected function pointToString($index{
  50.         return "";
  51.     }
  52.  
  53.     private function getPointString($index$aSeries{
  54.  
  55.         $tmpResult new StringBuilder();
  56.         $tmpResult->append(($this->getIncludeIndex()) ?
  57.                          "index=\"" . (string)($index"\"" :
  58.                          "");
  59.  
  60.         // the point Label text, if exists
  61.         if ($this->hasLabels{
  62.             $labels=$aSeries->getLabels();
  63.             $tmpResult->append(" text=\"" $labels[$index.
  64.                              "\"");
  65.         }
  66.  
  67.         // the "X" point value, if exists
  68.         if ($this->hasNoMandatory{
  69.             $tmpResult->append($this->get($aSeries->getNotMandatory()$index));
  70.         }
  71.  
  72.         // the "Y" point value
  73.         $tmpResult->append($this->get($aSeries->getMandatory()$index));
  74.  
  75.         // write the rest of values (always)
  76.         for $tt 2$tt sizeof($aSeries->getValuesLists())$tt++{
  77.             $tmpResult->append($this->get($aSeries->getValueList($tt)$index));
  78.         }
  79.  
  80.         return $tmpResult->toString();
  81.     }
  82.  
  83.     private function seriesPoints($aSeries{
  84.          $tmpResult new StringBuilder()// capacity 1
  85.  
  86.         if ($aSeries->getCount(0{
  87.             for $t 0$t $aSeries->getCount()$t++{
  88.                 $tmpResult->append("<point " $this->getPointString($t$aSeries"/>" .
  89.                                  $this->getTextLineSeparator());
  90.             }
  91.         }
  92.  
  93.         return $tmpResult->toString();
  94.     }
  95.  
  96.     private function XMLSeries($aSeries{
  97.         return
  98.                 "<series title=\"" $aSeries->toString("\" type=\"" .
  99.                 get_class($aSeries.
  100.                 "\">" $this->getTextLineSeparator(.
  101.                 "<points count=\"" . (string)($aSeries->getCount()) .
  102.                 "\">" .
  103.                 $this->getTextLineSeparator(.
  104.                 $this->seriesPoints($aSeries.
  105.                 "</points>" $this->getTextLineSeparator(.
  106.                 "</series>" $this->getTextLineSeparator($this->getTextLineSeparator();
  107.     }
  108.  
  109.     protected function getContent({
  110.         $this->prepare();
  111.         $tmpResult new StringBuilder();
  112.  
  113.         if ($this->series != null{
  114.             $tmpResult->append($this->XMLSeries($this->series));
  115.         else {
  116.             $tmpResult->append("<chart>" $this->getTextLineSeparator());
  117.  
  118.             for $t 0$t $this->chart->getSeriesCount()$t++{
  119.                  $s $this->chart->getSeries($t);
  120.                 $tmpResult->append($this->XMLSeries($s));
  121.             }
  122.  
  123.             $tmpResult->append("</chart>");
  124.         }
  125.  
  126.         return $tmpResult->toString();
  127.     }
  128. }
  129.  
  130. ?>

Documentation generated on Wed, 16 Jun 2010 12:09:22 +0200 by phpDocumentor 1.4.1