[*] BO #PSFV-94 : Added AdminStatsConfController
This commit is contained in:
@@ -26,8 +26,6 @@
|
||||
*/
|
||||
|
||||
if (!defined('_PS_ADMIN_DIR_')) define('_PS_ADMIN_DIR_', getcwd().'/..');
|
||||
include_once(_PS_ADMIN_DIR_.'/../config/config.inc.php');
|
||||
include_once(_PS_ADMIN_DIR_.'/init.php');
|
||||
|
||||
if (Tools::getValue('token') == Tools::getAdminToken('AdminReferrers'.(int)(Tab::getIdFromClassName('AdminReferrers')).(int)(Tools::getValue('id_employee'))))
|
||||
{
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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/osl-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-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 6844 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
include_once(dirname(__FILE__).'/AdminStatsTab.php');
|
||||
include_once(_PS_ADMIN_DIR_.'/tabs/AdminPreferences.php');
|
||||
|
||||
class AdminStatsConf extends AdminPreferences
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$autocleanPeriod = array(
|
||||
array('value' => 'never', 'name' => $this->l('Never')),
|
||||
array('value' => 'week', 'name' => $this->l('Week')),
|
||||
array('value' => 'month', 'name' => $this->l('Month')),
|
||||
array('value' => 'year', 'name' => $this->l('Year')),
|
||||
);
|
||||
|
||||
$this->optionsList = array(
|
||||
'general' => array(
|
||||
'title' => $this->l('General'),
|
||||
'icon' => 'tab-preferences',
|
||||
'fields' => array(
|
||||
'PS_STATS_RENDER' => array('title' => $this->l('Graph engine'), 'validation' => 'isGenericName', 'cast' => 'strval', 'type' => 'selectEngine'),
|
||||
'PS_STATS_GRID_RENDER' => array('title' => $this->l('Grid engine'), 'validation' => 'isGenericName', 'cast' => 'strval', 'type' => 'selectGrid'),
|
||||
'PS_STATS_OLD_CONNECT_AUTO_CLEAN' => array('title' => $this->l('Auto-clean period'), 'validation' => 'isGenericName', 'type' => 'select', 'list' => $autocleanPeriod, 'identifier' => 'value'),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function displayOptionTypeSelectEngine($key, $field, $value)
|
||||
{
|
||||
$listEngineDescription = array();
|
||||
$listEngine = array();
|
||||
foreach (ModuleGraphEngine::getGraphEngines() as $k => $engine)
|
||||
{
|
||||
$listEngine[] = array(
|
||||
'name' => $engine[0],
|
||||
'value' => $k,
|
||||
);
|
||||
$listEngineDescription[$k] = $engine[1];
|
||||
}
|
||||
|
||||
$field['list'] = $listEngine;
|
||||
$field['identifier'] = 'value';
|
||||
$field['js'] = '$(\'#render_engine_description\').html(engineDescriptions[$(this).val()])';
|
||||
|
||||
echo '<script type="text/javascript">var engineDescriptions = '.Tools::jsonEncode($listEngineDescription).';</script>';
|
||||
$this->displayOptionTypeSelect($key, $field, $value);
|
||||
echo '<div id="render_engine_description">'.$listEngineDescription[$value].'</div>';
|
||||
}
|
||||
|
||||
public function displayOptionTypeSelectGrid($key, $field, $value)
|
||||
{
|
||||
$listEngineDescription = array();
|
||||
$listEngine = array();
|
||||
foreach (ModuleGridEngine::getGridEngines() as $k => $engine)
|
||||
{
|
||||
$listEngine[] = array(
|
||||
'name' => $engine[0],
|
||||
'value' => $k,
|
||||
);
|
||||
$listEngineDescription[$k] = $engine[1];
|
||||
}
|
||||
|
||||
$field['list'] = $listEngine;
|
||||
$field['identifier'] = 'value';
|
||||
$field['js'] = '$(\'#render_grid_description\').html(gridDescriptions[$(this).val()])';
|
||||
|
||||
echo '<script type="text/javascript">var gridDescriptions = '.Tools::jsonEncode($listEngineDescription).';</script>';
|
||||
$this->displayOptionTypeSelect($key, $field, $value);
|
||||
echo '<div id="render_grid_description">'.$listEngineDescription[$value].'</div>';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
{*
|
||||
* 2007-2011 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-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 9540 $
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*}
|
||||
|
||||
{extends file="helper/options/options.tpl"}
|
||||
|
||||
{block name="start_field_block"}
|
||||
<div class="margin-form">
|
||||
{if $field['type'] == 'selectEngine'}
|
||||
<script type="text/javascript">var engineDescriptions = {$list_engine_description_stats_js};</script>
|
||||
<select name="{$key}" {if isset($field['js']) === true} onchange="{$field['js']}"{/if} id="{$key}">
|
||||
{foreach $field.list as $k => $option}
|
||||
<option value="{if isset($option['cast'])}{$option[$field.identifier]}{else}{$option[$field['identifier']]}{/if}"
|
||||
{if $field.value == $option[$field['identifier']]} selected="selected"{/if}>
|
||||
{$option.name}
|
||||
</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
<div id="render_engine_description">{$list_engine_description_stats[$field.value]}</div>
|
||||
{elseif $field['type'] == 'selectGrid'}
|
||||
<script type="text/javascript">var gridDescriptions = {$list_engine_description_grid_js};</script>
|
||||
<select name="{$key}" {if isset($field['js']) === true} onchange="{$field['js']}"{/if} id="{$key}">
|
||||
{foreach $field.list as $k => $option}
|
||||
<option value="{if isset($option['cast'])}{$option[$field.identifier]}{else}{$option[$field['identifier']]}{/if}"
|
||||
{if $field.value == $option[$field['identifier']]} selected="selected"{/if}>
|
||||
{$option.name}
|
||||
</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
<div id="render_grid_description">{$list_engine_description_grid[$field.value]}</div>
|
||||
{/if}
|
||||
{/block}
|
||||
|
||||
{block name="end_field_block"}</div>{/block}
|
||||
@@ -73,6 +73,7 @@ class AdminControllerCore extends Controller
|
||||
|
||||
public $tpl_form_vars = array();
|
||||
public $tpl_list_vars = array();
|
||||
public $tpl_option_vars = array();
|
||||
public $tpl_view_vars = array();
|
||||
|
||||
public $fields_value = false;
|
||||
@@ -1439,6 +1440,7 @@ class AdminControllerCore extends Controller
|
||||
$helper->override_folder = $this->tpl_folder;
|
||||
$helper->id = $this->id;
|
||||
$helper->token = $this->token;
|
||||
$helper->tpl_vars = $this->tpl_option_vars;
|
||||
$helper->shopLinkType = $this->shopLinkType;
|
||||
$helper->table = $this->table;
|
||||
$helper->currentIndex = self::$currentIndex;
|
||||
|
||||
@@ -83,6 +83,8 @@ class HelperFormCore extends Helper
|
||||
$this->tpl->assign(array(
|
||||
'submit_action' => $this->submit_action,
|
||||
'toolbar_btn' => $this->toolbar_btn,
|
||||
'show_toolbar' => $this->show_toolbar,
|
||||
'toolbar_fix' => $this->toolbar_fix,
|
||||
'title' => $this->title,
|
||||
'firstCall' => $this->first_call,
|
||||
'current' => $this->currentIndex,
|
||||
@@ -102,8 +104,6 @@ class HelperFormCore extends Helper
|
||||
'iso' => file_exists(_PS_ROOT_DIR_.'/js/tiny_mce/langs/'.$iso.'.js') ? $iso : 'en',
|
||||
'path_css' => _THEME_CSS_DIR_,
|
||||
'ad' => dirname($_SERVER["PHP_SELF"]),
|
||||
'show_toolbar' => $this->show_toolbar,
|
||||
'toolbar_fix' => $this->toolbar_fix,
|
||||
|
||||
));
|
||||
return parent::generate();
|
||||
|
||||
@@ -158,9 +158,9 @@ class HelperOptionsCore extends Helper
|
||||
'option_list' => $option_list,
|
||||
'current_id_lang' => $this->context->language->id,
|
||||
'required_fields' => isset($required_fields) ? $required_fields : false,
|
||||
'languages' => isset($languages) ? $languages : null,
|
||||
'languages' => isset($languages) ? $languages : null
|
||||
));
|
||||
return $this->tpl->fetch();
|
||||
return parent::generate();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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/osl-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-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 6844 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class AdminStatsConfControllerCore extends AdminPreferencesControllerCore
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$autoclean_period = array(
|
||||
array('value' => 'never', 'name' => $this->l('Never')),
|
||||
array('value' => 'week', 'name' => $this->l('Week')),
|
||||
array('value' => 'month', 'name' => $this->l('Month')),
|
||||
array('value' => 'year', 'name' => $this->l('Year')),
|
||||
);
|
||||
|
||||
$list_engine_description_stats = array();
|
||||
$list_select_stats = array();
|
||||
foreach (ModuleGraphEngine::getGraphEngines() as $k => $engine)
|
||||
{
|
||||
$list_select_stats[] = array(
|
||||
'name' => $engine[0],
|
||||
'value' => $k,
|
||||
);
|
||||
$list_engine_description_stats[$k] = $engine[1];
|
||||
}
|
||||
|
||||
$list_engine_description_grid = array();
|
||||
$list_select_grid = array();
|
||||
foreach (ModuleGridEngine::getGridEngines() as $k => $engine)
|
||||
{
|
||||
$list_select_grid[] = array(
|
||||
'name' => $engine[0],
|
||||
'value' => $k,
|
||||
);
|
||||
$list_engine_description_grid[$k] = $engine[1];
|
||||
}
|
||||
|
||||
$this->options = array(
|
||||
'general' => array(
|
||||
'title' => $this->l('General'),
|
||||
'icon' => 'tab-preferences',
|
||||
'fields' => array(
|
||||
'PS_STATS_RENDER' => array(
|
||||
'title' => $this->l('Graph engine'),
|
||||
'validation' => 'isGenericName',
|
||||
'cast' => 'strval',
|
||||
'type' => 'selectEngine',
|
||||
'list' => $list_select_stats,
|
||||
'identifier' => 'value',
|
||||
'js' => '$(\'#render_engine_description\').html(engineDescriptions[$(this).val()])'
|
||||
),
|
||||
'PS_STATS_GRID_RENDER' => array(
|
||||
'title' => $this->l('Grid engine'),
|
||||
'validation' => 'isGenericName',
|
||||
'cast' => 'strval',
|
||||
'type' => 'selectGrid',
|
||||
'list' => $list_select_grid,
|
||||
'identifier' => 'value',
|
||||
'js' => '$(\'#render_engine_description\').html(engineDescriptions[$(this).val()])'
|
||||
),
|
||||
'PS_STATS_OLD_CONNECT_AUTO_CLEAN' => array(
|
||||
'title' => $this->l('Auto-clean period'),
|
||||
'validation' => 'isGenericName',
|
||||
'type' => 'select',
|
||||
'list' => $autoclean_period,
|
||||
'identifier' => 'value'
|
||||
)
|
||||
),
|
||||
'submit' => array()
|
||||
)
|
||||
);
|
||||
|
||||
$this->tpl_option_vars = array (
|
||||
'list_engine_description_stats_js' => Tools::jsonEncode($list_engine_description_stats),
|
||||
'list_engine_description_stats' => $list_engine_description_stats,
|
||||
'list_engine_description_grid_js' => Tools::jsonEncode($list_engine_description_grid),
|
||||
'list_engine_description_grid' => $list_engine_description_grid
|
||||
);
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,7 @@ abstract class AdminStatsTabControllerCore extends AdminPreferencesControllerCor
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
$this->toolbar_title = $this->l('Stats');
|
||||
if ($this->display == 'view')
|
||||
{
|
||||
// Some controllers use the view action without an object
|
||||
|
||||
@@ -66,7 +66,7 @@ class StatsForecast extends Module
|
||||
|
||||
public function hookAdminStatsModules()
|
||||
{
|
||||
$ru = AdminTab::$currentIndex.'&module='.$this->name.'&token='.Tools::getValue('token');
|
||||
$ru = AdminController::$currentIndex.'&module='.$this->name.'&token='.Tools::getValue('token');
|
||||
|
||||
$db = Db::getInstance();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user