Initial commit

This commit is contained in:
2019-11-20 07:44:43 +01:00
commit 5bf49c4a81
41188 changed files with 5459177 additions and 0 deletions

View File

@@ -0,0 +1,240 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to a commercial license from SARL SMC
* Use, copy, modification or distribution of this source file without written
* license agreement from the SARL SMC is strictly forbidden.
* In order to obtain a license, please contact us: contact@common-services.com
* ...........................................................................
* INFORMATION SUR LA LICENCE D'UTILISATION
*
* L'utilisation de ce fichier source est soumise a une licence commerciale
* concedee par la societe SMC
* Toute utilisation, reproduction, modification ou distribution du present
* fichier source sans contrat de licence ecrit de la part de la SARL SMC est
* expressement interdite.
* Pour obtenir une licence, veuillez contacter Common-Services Co., Ltd. a l'adresse: contact@common-services.com
* ...........................................................................
*
* @author Debusschere A.
* @copyright Copyright (c) 2011-2015 Common Services Co Ltd - 90/25 Sukhumvit 81 - 10260 Bangkok - Thailand
* @package Shared
* @license Commercial license
*/
if (!defined('_PS_VERSION_')) {
exit;
}
/**
* Class generating configuration message
*/
class ConfigureMessage
{
const _MESSAGE_ = '<div class="%s">%s</div>';
const _DEBUG_ = '<div class="%s"><pre>%s</pre></div>';
const _CLASS_ERROR_15_ = 'error';
const _CLASS_WARNING_15_ = 'warn';
const _CLASS_SUCCESS_15_ = 'conf';
const _CLASS_INFO_15_ = 'info hint';
const _CLASS_ERROR_16_ = 'alert alert-danger';
const _CLASS_WARNING_16_ = 'alert alert-warning';
const _CLASS_SUCCESS_16_ = 'alert alert-success';
const _CLASS_INFO_16_ = 'alert alert-info';
protected static $msg_list = array();
protected static $has_error_msg = false;
protected static $has_warning_msg = false;
protected static $has_success_msg = false;
protected static $has_info_msg = false;
/**
* Generate the HTML code corresponding to an error message
*
* @param String $msg
* return void|null
*/
public static function error($msg = 'Error')
{
if (is_array($msg) && count($msg)) {
foreach ($msg as $ps_error) {
self::error($ps_error);
}
return null;
}
$error_msg = null;
if (version_compare(_PS_VERSION_, '1.6', '<')) {
$error_msg = sprintf(self::_MESSAGE_, self::_CLASS_ERROR_15_, $msg);
} else {
$error_msg = '<div class="bootstrap">'.sprintf(self::_MESSAGE_, self::_CLASS_ERROR_16_, $msg).'</div>';
}
self::$has_error_msg = true;
self::$msg_list[] = $error_msg;
}
/**
* Generate the HTML code corresponding to a warning message
*
* @param String $msg
*/
public static function warning($msg = 'Warning')
{
$warning_msg = null;
if (version_compare(_PS_VERSION_, '1.6', '<')) {
$warning_msg = sprintf(self::_MESSAGE_, self::_CLASS_WARNING_15_, $msg);
} else {
$warning_msg = '<div class="bootstrap">'.sprintf(self::_MESSAGE_, self::_CLASS_WARNING_16_, $msg).'</div>';
}
self::$has_warning_msg = true;
self::$msg_list[] = $warning_msg;
}
/**
* Generate the HTML code corresponding to a success message
*
* @param String $msg
*/
public static function success($msg = 'Success')
{
$success_msg = null;
if (version_compare(_PS_VERSION_, '1.6', '<')) {
$success_msg = sprintf(self::_MESSAGE_, self::_CLASS_SUCCESS_15_, $msg);
} else {
$success_msg = '<div class="bootstrap">'.sprintf(self::_MESSAGE_, self::_CLASS_SUCCESS_16_, $msg).'</div>';
}
self::$has_success_msg = true;
self::$msg_list[] = $success_msg;
}
/**
* Generate the HTML code corresponding to an information message
*
* @param String $msg
*/
public static function info($msg = 'Success')
{
$info_msg = null;
if (version_compare(_PS_VERSION_, '1.6', '<')) {
$info_msg = sprintf(self::_MESSAGE_, self::_CLASS_INFO_15_, $msg);
} else {
$info_msg = '<div class="bootstrap">'.sprintf(self::_MESSAGE_, self::_CLASS_INFO_16_, $msg).'</div>';
}
self::$has_info_msg = true;
self::$msg_list[] = $info_msg;
}
/**
* Generate the HTML code corresponding to a debug message
*
* @param String $msg
*/
public static function debug($msg = 'Debug')
{
$info_msg = null;
if (version_compare(_PS_VERSION_, '1.6', '<')) {
$info_msg = sprintf(self::_DEBUG_, self::_CLASS_INFO_15_, $msg);
} else {
$info_msg = '<div class="bootstrap">'.sprintf(self::_DEBUG_, self::_CLASS_INFO_16_, $msg).'</div>';
}
self::$msg_list[] = $info_msg;
}
/**
* Return the html code of all messages to be displayed
*
* @return String
*/
public static function display()
{
$html = '';
if (count(self::$msg_list)) {
foreach (self::$msg_list as $msg) {
$html .= $msg;
}
}
return ($html);
}
/**
* Return the list of message
*
* @return Array
*/
public static function getMessageList()
{
return (self::$msg_list);
}
/**
* Return true if the message list contain at least 1 error message
*
* @return Boolean
*/
public static function hasErrorMessage()
{
return (self::$has_error_msg);
}
/**
* Return true if the message list contain at least 1 warning message
*
* @return Boolean
*/
public static function hasWarningMessage()
{
return (self::$has_warning_msg);
}
/**
* Return true if the message list contain at least 1 success message
*
* @return Boolean
*/
public static function hasSuccessMessage()
{
return (self::$has_success_msg);
}
/**
* Return true if the message list contain at least 1 information message
*
* @return Boolean
*/
public static function hasInfoMessage()
{
return (self::$has_info_msg);
}
}

View File

@@ -0,0 +1,105 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to a commercial license from SARL SMC
* Use, copy, modification or distribution of this source file without written
* license agreement from the SARL SMC is strictly forbidden.
* In order to obtain a license, please contact us: contact@common-services.com
* ...........................................................................
* INFORMATION SUR LA LICENCE D'UTILISATION
*
* L'utilisation de ce fichier source est soumise a une licence commerciale
* concedee par la societe SMC
* Toute utilisation, reproduction, modification ou distribution du present
* fichier source sans contrat de licence ecrit de la part de la SARL SMC est
* expressement interdite.
* Pour obtenir une licence, veuillez contacter Common-Services Co., Ltd. a l'adresse: contact@common-services.com
* ...........................................................................
*
* @author Debusschere A.
* @copyright Copyright (c) 2011-2015 Common Services Co Ltd - 90/25 Sukhumvit 81 - 10260 Bangkok - Thailand
* @package Shared
* @license Commercial license
*/
if (!defined('_PS_VERSION_')) {
exit;
}
/**
* Class generating configuration tabs
*/
class ConfigureTab
{
public static function generateTabs($tab_list, $module_name = '')
{
// $protocol = Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://';
if (!Tools::strlen($module_name)) {
$module_name = self::getModuleName();
}
// commented out by O.B. on 2015-03-10: cause cross domain redirection issue
// $url = $protocol.htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').
// __PS_BASE_URI__.'modules/'.$module_name.'/';
$url = __PS_BASE_URI__.'modules/'.$module_name.'/';
$context = Context::getContext();
$context->smarty->assign(array(
'tab_list' => $tab_list,
'img_dir' => $url.'views/img/shared/tab/',
'module_url' => $url,
'module_name' => $module_name,
'ps16x' => version_compare(_PS_VERSION_, '1.6', '>='),
'ps15x' => version_compare(_PS_VERSION_, '1.5', '>='),
'has_line' => self::hasLine($tab_list),
'line_number' => self::getLineNumber($tab_list)
));
$html = $context->smarty->fetch(dirname(__FILE__).'/../../views/templates/admin/shared/tabs.tpl');
return ($html);
}
public static function getModuleName($addslash = false)
{
$e = new Exception();
$trace = $e->getTrace();
$caller = $trace[2];
if (!isset($caller['class'])) {
return (false);
}
return (Tools::strtolower($caller['class']).($addslash ? '/' : ''));
}
public static function hasLine($tab_list)
{
if (is_array($tab_list) && count($tab_list)) {
foreach ($tab_list as $tab) {
if (isset($tab['line']) && $tab['line']) {
return (true);
}
}
}
return (false);
}
public static function getLineNumber($tab_list)
{
$line_number = array();
if (is_array($tab_list) && count($tab_list)) {
foreach ($tab_list as $tab) {
if (isset($tab['line']) && $tab['line']) {
$line_number[$tab['line']] = 1;
}
}
}
return (count($line_number));
}
}

View File

@@ -0,0 +1,11 @@
<?php
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;

View File

@@ -0,0 +1,131 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to a commercial license from SARL SMC
* Use, copy, modification or distribution of this source file without written
* license agreement from the SARL SMC is strictly forbidden.
* In order to obtain a license, please contact us: contact@common-services.com
* ...........................................................................
* INFORMATION SUR LA LICENCE D'UTILISATION
*
* L'utilisation de ce fichier source est soumise a une licence commerciale
* concedee par la societe SMC
* Toute utilisation, reproduction, modification ou distribution du present
* fichier source sans contrat de licence ecrit de la part de la SARL SMC est
* expressement interdite.
* Pour obtenir une licence, veuillez contacter Common-Services Co., Ltd. a l'adresse: contact@common-services.com
* ...........................................................................
*
* @author Debusschere A.
* @copyright Copyright (c) 2011-2015 Common Services Co Ltd - 90/25 Sukhumvit 81 - 10260 Bangkok - Thailand
* @package Shared
* @license Commercial license
*/
/**
* Class generating module tabs
*/
class CommonServicesTab extends Tab
{
const ADD = 'a';
const REMOVE = 'd';
const UPDATE = 'u';
public static function setup($action, $class, $name, $parent, $debug = false)
{
switch ($action) {
case self::ADD:
if (!Tab::getIdFromClassName($class)) {
if (!self::installModuleTab($class, $name, $parent)) {
if ($debug) {
printf('%s(#%d): Unable to install: %s', basename(__FILE__), __LINE__, $class);
}
return false;
}
}
break;
case self::UPDATE:
if (self::Setup(self::REMOVE, $class, $name, $parent, $debug)) {
return (self::Setup(self::ADD, $class, $name, $parent, $debug));
}
break;
case self::REMOVE:
if (Tab::getIdFromClassName($class)) {
if (!self::uninstallModuleTab($class)) {
if ($debug) {
printf('%s(#%d): Unable to uninstall: %s', basename(__FILE__), __LINE__, $class);
}
return false;
}
}
break;
}
return true;
}
private static function installModuleTab($tabClass, $tabName, $tabParent)
{
$module = self::getModuleName();
$pass = true;
$tabNameLang = array();
foreach (Language::getLanguages() as $language) {
$tabNameLang[$language['id_lang']] = $tabName;
}
$tab = new Tab();
$tab->name = $tabNameLang;
$tab->class_name = $tabClass;
$tab->module = $module;
$tab->id_parent = Tab::getIdFromClassName($tabParent);
// For Prestashop 1.2
if (version_compare(_PS_VERSION_, '1.3', '<')) {
$pass = $tab->add();
} else {
$pass = $tab->save();
}
return ($pass);
}
public static function getModuleName()
{
$trace = debug_backtrace();
$caller = $trace[4];
if (!isset($caller['class'])) {
return (false);
} else {
return (Tools::strtolower($caller['class']));
}
}
private static function uninstallModuleTab($tabClass)
{
$pass = true;
$idTab = Tab::getIdFromClassName($tabClass);
// Big Bug PS 1.4 - cached entry is not removed on delete() ...
if (version_compare(_PS_VERSION_, '1.5.5', '<')) {
if (isset(Tab::$_getIdFromClassName[Tools::strtolower($tabClass)])) {
unset(Tab::$_getIdFromClassName[Tools::strtolower($tabClass)]);
}
if (isset(Tab::$_getIdFromClassName[($tabClass)])) {
unset(Tab::$_getIdFromClassName[($tabClass)]);
}
}
if ($idTab != 0) {
$tab = new Tab($idTab);
$pass = $tab->delete();
}
return ($pass);
}
}