Initial commit

This commit is contained in:
2020-10-07 10:37:15 +02:00
commit ce5f440392
28157 changed files with 4429172 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
2014-04-22 18:58:39 +0200 // Changelog updated
2014-04-17 11:58:28 +0200 [-] MO : graphnvd3 - Fix 1.5 ps_version_compliancy issue
2014-03-24 15:21:45 +0100 / MO graphnvd3 : ps_versions_compliancy added
2014-03-20 14:33:52 +0100 Initial commit

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>graphnvd3</name>
<displayName><![CDATA[NVD3 Charts]]></displayName>
<version><![CDATA[2.0.1]]></version>
<description><![CDATA[]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[administration]]></tab>
<is_configurable>0</is_configurable>
<need_instance>0</need_instance>
<limited_countries></limited_countries>
</module>

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>graphnvd3</name>
<displayName><![CDATA[Graphiques NVD3]]></displayName>
<version><![CDATA[2.0.1]]></version>
<description><![CDATA[]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[administration]]></tab>
<is_configurable>0</is_configurable>
<need_instance>0</need_instance>
<limited_countries></limited_countries>
</module>

View File

@@ -0,0 +1,181 @@
<?php
/*
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2016 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
if (!defined('_PS_VERSION_'))
exit;
class GraphNvD3 extends ModuleGraphEngine
{
private $_width;
private $_height;
private $_values;
private $_legend;
private $_titles;
function __construct($type = null)
{
if ($type !== null)
return parent::__construct($type);
$this->name = 'graphnvd3';
$this->tab = 'administration';
$this->version = '2.0.1';
$this->author = 'PrestaShop';
$this->need_instance = 0;
Module::__construct();
$this->displayName = $this->trans('NVD3 Charts', array(), 'Modules.Graphnvd3.Admin');
$this->description = '';
$this->ps_versions_compliancy = array('min' => '1.7.1.0', 'max' => _PS_VERSION_);
}
function install()
{
return (parent::install() && $this->registerHook('GraphEngine') && $this->registerHook('actionAdminControllerSetMedia'));
}
public function hookActionAdminControllerSetMedia($params)
{
$admin_webpath = str_ireplace(_PS_ROOT_DIR_, '', _PS_ADMIN_DIR_);
$admin_webpath = preg_replace('/^'.preg_quote(DIRECTORY_SEPARATOR, '/').'/', '', $admin_webpath);
$this->context->controller->addJS(array(
_PS_JS_DIR_.'vendor/d3.v3.min.js',
__PS_BASE_URI__.$admin_webpath.'/themes/'.$this->context->employee->bo_theme.'/js/vendor/nv.d3.min.js',
));
$this->context->controller->addCSS(__PS_BASE_URI__.$admin_webpath.'/themes/'.$this->context->employee->bo_theme.'/css/vendor/nv.d3.css');
}
public static function hookGraphEngine($params, $drawer)
{
static $divid = 1;
if (strpos($params['width'], '%') !== false)
$params['width'] = (int)preg_replace('/\s*%\s*/', '', $params['width']).'%';
else
$params['width'] = (int)$params['width'].'px';
$nvd3_func = array(
'line' => '
nv.models.lineChart()',
'pie' => '
nv.models.pieChart()
.x(function(d) { return d.label; })
.y(function(d) { return d.value; })
.showLabels(true)
.showLegend(false)'
);
return '
<div id="nvd3_chart_'.$divid.'" class="chart with-transitions">
<svg style="width:'.$params['width'].';height:'.(int)$params['height'].'px"></svg>
</div>
<script>
$.ajax({
url: "'.addslashes($drawer).'",
dataType: "json",
type: "GET",
cache: false,
headers: {"cache-control": "no-cache"},
success: function(jsonData){
nv.addGraph(function(){
var chart = '.$nvd3_func[$params['type']].';
if (jsonData.axisLabels.xAxis != null)
chart.xAxis.axisLabel(jsonData.axisLabels.xAxis);
if (jsonData.axisLabels.yAxis != null)
chart.yAxis.axisLabel(jsonData.axisLabels.yAxis);
d3.select("#nvd3_chart_'.($divid++).' svg")
.datum(jsonData.data)
.transition().duration(500)
.call(chart);
nv.utils.windowResize(chart.update);
return chart;
});
}
});
</script>';
}
public function createValues($values)
{
$this->_values = $values;
}
public function setSize($width, $height)
{
$this->_width = $width;
$this->_height = $height;
}
public function setLegend($legend)
{
$this->_legend = $legend;
}
public function setTitles($titles)
{
$this->_titles = $titles;
}
public function draw()
{
$array = array(
'axisLabels' => array('xAxis' => $this->_titles['x'], 'yAxis' => $this->_titles['y']),
'data' => array()
);
if (!isset($this->_values[0]) || !is_array($this->_values[0]))
{
$nvd3_values = array();
if (Tools::getValue('type') == 'pie')
{
foreach ($this->_values as $x => $y)
$nvd3_values[] = array('label' => $this->_legend[$x], 'value' => $y);
$array['data'] = $nvd3_values;
}
else
{
foreach ($this->_values as $x => $y)
$nvd3_values[] = array('x' => $x, 'y' => $y);
$array['data'][] = array('values' => $nvd3_values, 'key' => $this->_titles['main']);
}
}
else
foreach ($this->_values as $layer => $gross_values)
{
$nvd3_values = array();
foreach ($gross_values as $x => $y)
$nvd3_values[] = array('x' => $x, 'y' => $y);
$array['data'][] = array('values' => $nvd3_values, 'key' => $this->_titles['main'][$layer]);
}
echo preg_replace('/"([0-9]+)"/', '$1', Tools::jsonEncode($array));
}
}

View File

@@ -0,0 +1,35 @@
<?php
/*
* 2007-2016 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2016 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

BIN
modules/graphnvd3/logo.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 924 B

BIN
modules/graphnvd3/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 629 B