* @copyright 2007-2011 PrestaShop SA * @version Release: $Revision: 7541 $ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ /** * Statistics * @category stats * * @author PrestaShop * @copyright PrestaShop * @license http://www.opensource.org/licenses/afl-3.0.php Open-source licence 3.0 * @version 1.4 */ if (!defined('_CAN_LOAD_FILES_')) exit; class GraphXmlSwfCharts extends ModuleGraphEngine { private $_xml; private $_values = NULL; private $_legend = NULL; private $_legend_more = ''; private $_titles = ''; function __construct($type = null) { if ($type != null) { $this->_xml = ''; parent::__construct($type); } else { $this->name = 'graphxmlswfcharts'; $this->tab = 'administration'; $this->version = 1.0; $this->author = 'PrestaShop'; $this->need_instance = 0; Module::__construct(); $this->displayName = $this->l('XML/SWF Charts'); $this->description = $this->l('XML/SWF Charts is a simple, yet powerful tool using Adobe Flash to create attractive web charts and graphs from dynamic data.'); } } function install() { return (parent::install() AND $this->registerHook('GraphEngine')); } public static function hookGraphEngine($params, $drawer) { return ' '; } private function drawColumn() { $this->_xml .= ' '; } private function drawLine() { $this->drawColumn(); $this->_xml .= 'A3B6DAC3413C5A6C83CA9A515B775155AA26FF2398427FC3 '; } private function drawPie($counter) { $this->_xml .= ' 427FC3 C3413C 5A6C83 CA9A51 5B7751 55AA26 FF2398 '; for ($i = 0; $i < $counter; $i++) $this->_xml .= '9'; $this->_xml .= ''; $this->_legend_more = ' bullet="circle"'; } public function createValues($values) { $this->_values = $values; $this->_xml .= ''.$this->_type.''; switch ($this->_type) { case 'pie': $this->drawPie(sizeof($values)); break; case 'line': $this->drawLine(); break; case 'column': default: $this->drawColumn(); $this->_xml .= 'A3B6DAC3413C5A6C83CA9A515B775155AA26FF2398427FC3'; break; } } public function setSize($width, $height) { if (isset($width) && !empty($width)) $this->_width = $width; else $this->_width = 550; if (isset($height) && !empty($height)) $this->_height = $height; else $this->_height = 270; } public function setLegend($legend) { $this->_legend = $legend; $this->_xml .= '_legend_more.' layout="horizontal" font="arial" bold="true" size="13" color="000000" alpha="85" shadow="low" transition="dissolve" delay="0.5" duration="0.25" fill_color="D4D4D4" fill_alpha="0" line_color="D4D4D4" line_alpha="0" line_thickness="0" />'; } public function setTitles($titles) { $this->_titles = $titles; $this->_xml .= ''; if (isset($titles['main'])) { if ($this->_type == 'pie') $this->_xml .= ''.$titles['main'].''; } if ($this->_type != 'pie' AND isset($titles['x']) AND isset($titles['y'])) { $this->_xml .= ''.$titles['x'].''; $this->_xml .= ''.$titles['y'].''; } $this->_xml .= ''; } public function draw() { header('content-type: text/xml'); $this->_xml .= ''; foreach ($this->_legend as $value) $this->_xml .= ''.$value.''; $this->_xml .= ''; if (!isset($this->_values[0]) || !is_array($this->_values[0])) { $this->_xml .= ''.$this->_titles['main'].''; foreach ($this->_values as $value) $this->_xml .= ''. (($value > 0) ? $value : -$value) .''; //si jamais la valeur est n�gative... logiquement ne devrait jamais arriver $this->_xml .= ''; } else { $i = 1; foreach ($this->_values as $value) { $this->_xml .= ''; if (isset($this->_titles['main'][$i])) $this->_xml .= ''.$this->_titles['main'][$i].''; foreach ($value as $val) $this->_xml .= ''.$val.''; $this->_xml .= ''; $i++; } } $this->_xml .= ''; $this->_xml .= ''; echo $this->_xml; } }