* @copyright 2007-2011 PrestaShop SA * @version Release: $Revision: 6594 $ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ if (!defined('_CAN_LOAD_FILES_')) exit; class GraphVisifire extends ModuleGraphEngine { private $_xml; private $_values = NULL; private $_legend = NULL; private $_titles = NULL; function __construct($type = null) { if ($type != null) { $this->_xml = '_xml .= ' Theme="Theme1" View3D="True"'; else $this->_xml .= ' Theme="Theme2" ColorSet="Visifire2" UniqueColors="True"'; $this->_xml .= '>'; parent::__construct($type); } else { $this->name = 'graphvisifire'; $this->tab = 'administration'; $this->version = 1.0; $this->author = 'PrestaShop'; $this->need_instance = 0; Module::__construct(); $this->displayName = $this->l('Visifire'); $this->description = $this->l('Visifire is a set of open source data visualization components - powered by Microsoft Silverlight 2 beta 2.'); } } function install() { return (parent::install() AND $this->registerHook('GraphEngine')); } public static function hookGraphEngine($params, $drawer) { static $divid = 1; return '
'; } public function createValues($values) { $this->_values = array(); if (!is_array($values[array_rand($values)])) foreach ($values as $value) $this->_values[] = $value; else { foreach ($values as $i => $layerValue) { $this->_values[$i] = array(); foreach ($layerValue as $value) $this->_values[$i][] = $value; } } } public function setSize($width, $height) { // Unavailable } public function setLegend($legend) { $this->_legend = array(); if (!is_array($legend[array_rand($legend)])) foreach ($legend as $label) $this->_legend[] = $label; else { foreach ($legend as $i => $layerlabel) { $this->_legend[$i] = array(); foreach ($layerlabel as $label) $this->_legend[$i][] = $label; } } } public function setTitles($titles) { $this->_titles = $titles; if (isset($titles['main']) && !is_array($titles['main'])) $this->_xml .= ''; if (is_array($titles['main']) && isset($titles['main'][0])) $this->_xml .= ''; if (isset($titles['x'])) $this->_xml .= ''; if (isset($titles['y'])) $this->_xml .= ''; } public function draw() { header('content-type: text/xml'); if ($this->_values != NULL && $this->_legend != NULL) { if (!isset($this->_values[0]) || !is_array($this->_values[0])) $size = sizeof($this->_values); else $size = sizeof($this->_values[0]); if ($size == sizeof($this->_legend)) { if (!is_array($this->_values[array_rand($this->_values)])) { $this->_xml .= ''; for ($i = 0; $i < $size; $i++) { $this->_xml .= '_xml .= 'AxisLabel=" '.str_replace('<', '<', str_replace('>', '>', str_replace('&', '&', str_replace('"', "'", $this->_legend[$i])))).'" '; $this->_xml .= 'YValue="'.$this->_values[$i].'"'; if ($this->_type == 'pie') $this->_xml .= ' ExplodeOffset="0.2"'; $this->_xml .= '/>'; } $this->_xml .= ''; } else { foreach ($this->_values as $layer => $values) { $this->_xml .= ''; foreach ($values as $i => $value) { $this->_xml .= '_xml .= 'AxisLabel=" '.str_replace('<', '<', str_replace('>', '>', str_replace('&', '&', str_replace('"', "'", $this->_legend[$i])))).'" '; $this->_xml .= 'YValue="'.$value.'"'; if ($this->_type == 'pie') $this->_xml .= ' ExplodeOffset="0.2"'; $this->_xml .= '/>'; } $this->_xml .= ''; } } } } $this->_xml .= '
'; echo $this->_xml; exit(1); } }