344 lines
22 KiB
PHP
344 lines
22 KiB
PHP
<?php
|
||
/**
|
||
* Class Mediacom87
|
||
*
|
||
* @author Mediacom87 <support@mediacom87.net>
|
||
* @copyright 2008-today Mediacom87
|
||
* @license define in the module
|
||
*/
|
||
|
||
class GlsTrackingNumberClass extends Module
|
||
{
|
||
/**
|
||
* radioButton function.
|
||
*
|
||
* @access protected
|
||
* @param mixed $sauv
|
||
* @param mixed $ok
|
||
* @param mixed $ko
|
||
* @return void
|
||
*/
|
||
protected function radioButton($sauv, $ok, $ko)
|
||
{
|
||
if (!isset($this->conf[$sauv])) {
|
||
$this->conf[$sauv] = 0;
|
||
}
|
||
|
||
if (version_compare(_PS_VERSION_, '1.6.0.0', '<')) {
|
||
return '
|
||
<input type="radio" name="'.$sauv.'" id="'.$sauv.'_on" value="1" '.($this->conf[$sauv] ? 'checked="checked" ' : '').'/>
|
||
<label class="t" for="'.$sauv.'_on"> <img src="../img/admin/enabled.gif" alt="'.$ok.'" title="'.$ok.'" /></label>
|
||
<input type="radio" name="'.$sauv.'" id="'.$sauv.'_off" value="0" '.(!$this->conf[$sauv] ? 'checked="checked" ' : '').'/>
|
||
<label class="t" for="'.$sauv.'_off"> <img src="../img/admin/disabled.gif" alt="'.$ko.'" title="'.$ko.'" /></label>
|
||
';
|
||
} else {
|
||
return '
|
||
<span class="switch prestashop-switch fixed-width-lg">
|
||
<input type="radio" name="'.$sauv.'" id="'.$sauv.'_on" value="1" '.($this->conf[$sauv] ? 'checked="checked" ' : '').'/>
|
||
<label class="t" for="'.$sauv.'_on">'.$ok.'</label>
|
||
<input type="radio" name="'.$sauv.'" id="'.$sauv.'_off" value="0" '.(!$this->conf[$sauv] ? 'checked="checked" ' : '').'/>
|
||
<label class="t" for="'.$sauv.'_off">'.$ko.'</label>
|
||
<a class="slide-button btn"></a>
|
||
</span>
|
||
';
|
||
}
|
||
}
|
||
|
||
/**
|
||
* safeOutputLang function.
|
||
*
|
||
* @access protected
|
||
* @param mixed $string
|
||
* @return void
|
||
*/
|
||
protected function safeOutputLang($string)
|
||
{
|
||
$output = array();
|
||
if (get_magic_quotes_gpc()) {
|
||
$output = $string;
|
||
} else {
|
||
foreach ($string as $k => $text) {
|
||
$output[$k] = addslashes(strip_tags($text));
|
||
}
|
||
}
|
||
return $output;
|
||
}
|
||
|
||
/**
|
||
* selectElement function.
|
||
*
|
||
* @access protected
|
||
* @param mixed $name
|
||
* @param array $elements (default: array())
|
||
* @param mixed $conf
|
||
* @return void
|
||
*/
|
||
protected function selectElement($name, $conf, $elements = array())
|
||
{
|
||
if (!isset($conf[$name])) {
|
||
$conf[$name] = '';
|
||
}
|
||
$output = '<select id="'.$name.'" name="'.$name.'" class="form-control">';
|
||
foreach ($elements as $k => $v) {
|
||
$output .= '<option value="'.$k.'"'.($conf[$name] == $k ? ' selected="selected"' : '').'>'.$v.'</option>';
|
||
}
|
||
|
||
$output .= '</select>';
|
||
|
||
return $output;
|
||
}
|
||
|
||
/**
|
||
* displayInput function.
|
||
*
|
||
* @access protected
|
||
* @param mixed $name
|
||
* @param mixed $label_text
|
||
* @return void
|
||
*/
|
||
protected function displayInputCheckbox($name, $label_text)
|
||
{
|
||
return '
|
||
<label class="left"><input type="checkbox" name="'.$name.'" value="1"'.($this->conf[$name] ? ' checked' : '').'> '.$label_text.'</label>
|
||
';
|
||
}
|
||
|
||
/**
|
||
* displayInputGroup function.
|
||
*
|
||
* @access protected
|
||
* @param mixed $label
|
||
* @param mixed $name
|
||
* @param mixed $value
|
||
* @param bool $tooltips (default: false)
|
||
* @param int $size (default: false)
|
||
* @param bool $prefix (default: false)
|
||
* @param bool $suffix (default: false)
|
||
* @return void
|
||
*/
|
||
protected function displayInputGroup($label, $name, $value, $tooltips = false, $col = false, $size = false, $prefix = false, $suffix = false)
|
||
{
|
||
if (version_compare(_PS_VERSION_, '1.2.0.0', '>=')) {
|
||
if ($suffix || $prefix) {
|
||
$output = '
|
||
<div class="form-group">
|
||
<label class="control-label col-md-3" for="'.$name.'">
|
||
'.$label.($tooltips ? ' '.$this->displayHelpMessage($tooltips) : '').'
|
||
</label>
|
||
<div class="margin-form'.($col && $this->bootstrap ? ' '.$col : '').'">
|
||
<div class="input-group">
|
||
'.($prefix ? ($this->bootstrap ? '<div class="input-group-addon">'.$prefix.'</div>' : $prefix.' ') : '').'
|
||
<input type="text" name="'.$name.'" id="'.$name.'" value="'.$value.'"'.($size && !$this->bootstrap ? ' size="'.$size.'"' : '').' class="form-control" />
|
||
'.($suffix ? ($this->bootstrap ? '<div class="input-group-addon">'.$suffix.'</div>' : ' '.$suffix) : '').'
|
||
</div>
|
||
</div>
|
||
</div>
|
||
';
|
||
} else {
|
||
$output = '
|
||
<div class="form-group">
|
||
<label class="control-label col-md-3" for="'.$name.'">
|
||
'.$label.($tooltips ? ' '.$this->displayHelpMessage($tooltips) : '').'
|
||
</label>
|
||
<div class="margin-form'.($col && $this->bootstrap ? ' '.$col : '').'">
|
||
<input type="text" name="'.$name.'" id="'.$name.'" value="'.$value.'"'.$value.'"'.($size && !$this->bootstrap ? ' size="'.$size.'"' : '').' class="form-control" />
|
||
</div>
|
||
</div>
|
||
';
|
||
}
|
||
return $output;
|
||
}
|
||
}
|
||
|
||
/**
|
||
* displayInfoMessage function.
|
||
*
|
||
* @access protected
|
||
* @param mixed $message
|
||
* @return void
|
||
*/
|
||
protected function displayInfoMessage($message)
|
||
{
|
||
return '
|
||
<div class="'.(version_compare(_PS_VERSION_, '1.6.0.0', '<') ? 'info' : 'alert alert-info' ).'">
|
||
'.$message.'
|
||
</div>
|
||
';
|
||
}
|
||
|
||
/**
|
||
* displayWarningMessage function.
|
||
*
|
||
* @access protected
|
||
* @param mixed $message
|
||
* @return void
|
||
*/
|
||
protected function displayWarningMessage($message)
|
||
{
|
||
return '
|
||
<div class="'.(version_compare(_PS_VERSION_, '1.6.0.0', '<') ? 'warning warn' : 'alert alert-warning' ).'">
|
||
'.$message.'
|
||
</div>
|
||
';
|
||
}
|
||
|
||
protected function displayHelpMessage($message, $icon = 'fa-info-circle')
|
||
{
|
||
return '
|
||
<i class="fa '.$icon.' fa-lg tips" title="'.$message.'."></i>
|
||
';
|
||
}
|
||
|
||
/**
|
||
* isoCode function.
|
||
*
|
||
* @access protected
|
||
* @param bool $domain (default: false)
|
||
* @return void
|
||
*/
|
||
protected function isoCode($domain = false)
|
||
{
|
||
if (version_compare(_PS_VERSION_, '1.5.0.0', '<')) {
|
||
global $cookie; // old version compatibility
|
||
$language = new Language($cookie->id_lang);
|
||
$iso = $language->iso_code;
|
||
} else {
|
||
$iso = $this->context->language->iso_code;
|
||
}
|
||
|
||
if ($iso == 'fr') {
|
||
return 'fr';
|
||
} elseif ($domain) {
|
||
return 'com';
|
||
} else {
|
||
return 'en';
|
||
}
|
||
}
|
||
|
||
/**
|
||
* testDir function.
|
||
*
|
||
* @access protected
|
||
* @static
|
||
* @param mixed $dir
|
||
* @param bool $recursive (default: false)
|
||
* @return void
|
||
*/
|
||
protected function testDir($dir, $recursive = false)
|
||
{
|
||
if (!is_writable($dir) || !$dh = opendir($dir)) {
|
||
return false;
|
||
}
|
||
if ($recursive) {
|
||
while (($file = readdir($dh)) !== false) {
|
||
if (@filetype($dir.$file) == 'dir' && $file != '.' && $file != '..') {
|
||
if (!self::testDir($dir.$file, true)) {
|
||
return false;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
closedir($dh);
|
||
return true;
|
||
}
|
||
|
||
/**
|
||
* submitButton function.
|
||
*
|
||
* @access private
|
||
* @return void
|
||
*/
|
||
protected function submitButton($text, $name = 'save')
|
||
{
|
||
if (version_compare(_PS_VERSION_, '1.6.0.0', '<')) {
|
||
return '<p><input type="submit" class="button" name="'.$name.'" value="'.$text.'" /></p>';
|
||
} else {
|
||
return '
|
||
<div class="panel-footer">
|
||
<button class="btn btn-default" name="'.$name.'" type="submit"><i class="process-icon-save"></i> '.$text.'</button>
|
||
</div>';
|
||
}
|
||
}
|
||
|
||
/**
|
||
* panelHeading function.
|
||
*
|
||
* @access protected
|
||
* @param mixed $title
|
||
* @return void
|
||
*/
|
||
protected function panelHeading($title, $icon = false, $id = false, $hidden = false)
|
||
{
|
||
if (version_compare(_PS_VERSION_, '1.6.0.0', '<')) {
|
||
return '<fieldset class="space"'.($id ? ' id="'.$id.'"' : '').''.($hidden ? ' style="display:none"' : '').'><legend>'.($icon ? '<i class="fa '.$icon.'"></i> ' : '').''.$title.'</legend>';
|
||
} else {
|
||
return '<div class="panel"'.($id ? ' id="'.$id.'"' : '').''.($hidden ? ' style="display:none"' : '').'><div class="panel-heading">'.($icon ? '<i class="fa '.$icon.'"></i> ' : '').''.$title.'</div>';
|
||
}
|
||
}
|
||
|
||
/**
|
||
* panelEnding function.
|
||
*
|
||
* @access protected
|
||
* @return void
|
||
*/
|
||
protected function panelEnding()
|
||
{
|
||
if (version_compare(_PS_VERSION_, '1.6.0.0', '>=')) {
|
||
return '</div>';
|
||
} else {
|
||
return '</fieldset>';
|
||
}
|
||
}
|
||
|
||
/**
|
||
* addAsTrusted function.
|
||
*
|
||
* @return void
|
||
* @access protected
|
||
*/
|
||
protected function addAsTrusted()
|
||
{
|
||
if (defined('self::CACHE_FILE_TRUSTED_MODULES_LIST') == true) {
|
||
if (isset($this->context->controller->controller_name) && $this->context->controller->controller_name == 'AdminModules') {
|
||
$sxe = new SimpleXMLElement('<theme/>');
|
||
$modules = $sxe->addChild('modules');
|
||
$module = $modules->addChild('module');
|
||
$module->addAttribute('action', 'install');
|
||
$module->addAttribute('name', $this->name);
|
||
$trusted = $sxe->saveXML();
|
||
file_put_contents(_PS_ROOT_DIR_.'/config/xml/themes/'.$this->name.'.xml', $trusted);
|
||
if (is_file(_PS_ROOT_DIR_ . Module::CACHE_FILE_UNTRUSTED_MODULES_LIST)) {
|
||
Tools::deleteFile(_PS_ROOT_DIR_ . Module::CACHE_FILE_UNTRUSTED_MODULES_LIST);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* aboutUsTab function.
|
||
*
|
||
* @access protected
|
||
* @return void
|
||
*/
|
||
protected function aboutUsTab()
|
||
{
|
||
return $this->panelHeading($this->displayName).'
|
||
<p>'.$this->l('Thanks for installing this module on your website.', 'mediacom87').'</p>
|
||
<p>'.$this->description.'
|
||
<p>'.$this->l('Developped by', 'mediacom87'). ($this->addons_id ? ' <strong>Mediacom87</strong>' : ' <a class="redLink" href="http://www.mediacom87.fr/?utm_source=module&utm_medium=cpc&utm_campaign='.$this->name.'">Mediacom87</a>') . $this->l(', which helps you to grow your business.', 'mediacom87').'</p>'
|
||
.($this->addons_id ? '<p>'.$this->l('If you need support on this module:', 'mediacom87').' <a href="http://addons.prestashop.com/contact-community.php?id_product='.$this->addons_id.'" class="redLink">Support</a></p><p>'.$this->l('If you like this module, you will discover our other modules on', 'mediacom87').' <a href="http://addons.prestashop.com/en/2_community-developer?contributor=322" class="redLink">Prestashop Addons</a></p>' : '<p>'.$this->l('If you need support on this module:', 'mediacom87').' <a href="mailto:support@mediacom87.net?subject='.$this->l('Need help on this module:').' '.$this->name.' V.'.$this->version.' - PS.'._PS_VERSION_.'" class="redLink">support@mediacom87.net</a></p><p>'.$this->l('If you like this module, you will discover our other modules on', 'mediacom87').' <a href="http://www.prestatoolbox.'.$this->isoCode(true).'/1_mediacom87?utm_source=module&utm_medium=cpc&utm_campaign='.$this->name.'" class="redLink" target="_blank">Prestatoolbox</a></p>').$this->panelEnding();
|
||
}
|
||
|
||
/**
|
||
* licenceTab function.
|
||
*
|
||
* @access protected
|
||
* @return void
|
||
*/
|
||
protected function licenceTab()
|
||
{
|
||
return $this->panelHeading('License Summary').'<ul class="license"><li>License does not expire.</li><li>Can be used on 1 site, 1 server.</li><li>Source-code or binary products cannot be resold or distributed.</li><li>Commercial use allowed.</li><li>Cannot modify source-code for any purpose (cannot create derivative works).</li></ul>'.$this->panelEnding().$this->panelHeading('Terms and conditions').'<ol class="terms"><li><p><strong>Preamble:</strong> This Agreement, signed on Feb 11, 2014 [hereinafter: Effective Date] governs the relationship between You (hereinafter: Licensee) and '.$this->author.', a duly registered company in France whose principal place of business is 20 rue des Saulniers 17230 VILLEDOUX, France (Hereinafter: Licensor). This Agreement sets the terms, rights, restrictions and obligations on using ['.$this->name.'] (hereinafter: The Software) created and owned by Licensor, as detailed herein</p></li><li><p><strong>License Grant:</strong> Licensor hereby grants Licensee a Personal, Non-assignable & non-transferable, Commercial, Royalty free, Without the rights to create derivative works, Non-exclusive license, all with accordance with the terms set forth and other legal restrictions set forth in 3rd party software used while running Software.</p><ol><li><p><strong>Limited:</strong> Licensee may use Software for the purpose of:</p><ol><li><p>Running Software on Licensee’s Website[s] and Server[s];</p></li><li><p>Allowing 3rd Parties to run Software on Licensee’s Website[s] and Server[s];</p></li><li><p>Publishing Software’s output to Licensee and 3rd Parties;</p></li><li><p>Distribute verbatim copies of Software’s output (including compiled binaries);</p></li><li><p>Modify Software to suit Licensee’s needs and specifications.</p></li></ol></li><li><p><strong>Binary Restricted:</strong> Licensee may sublicense Software as a part of a larger work containing more than Software, distributed solely in Object or Binary form under a personal, non-sublicensable, limited license. Such redistribution shall be limited to unlimited codebases.</p></li><li><p><strong>Non Assignable & Non-Transferable:</strong> Licensee may not assign or transfer his rights and duties under this license.</p></li><li><p><strong>Commercial, Royalty Free:</strong> Licensee may use Software for any purpose, including paid-services, without any royalties</p></li></ol></li><li><p><strong>Term & Termination:</strong>The Term of this license shall be until terminated. Licensor may terminate this Agreement, including Licensee’s license in the case where Licensee :</p><ol><li><p>became insolvent or otherwise entered into any liquidation process; or</p></li><li><p>exported The Software to any jurisdiction where licensor may not enforce his rights under this agreements in; or</p></li><li><p>Licensee was in breach of any of this license\'s terms and conditions and such breach was not cured, immediately upon notification; or</p></li><li><p>Licensee in breach of any of the terms of clause 2 to this license; or</p></li><li><p>Licensee otherwise entered into any arrangement which caused Licensor to be unable to enforce his rights under this License.</p></li></ol></li><li><p><strong>Payment:</strong> In consideration of the License granted under clause 2, Licensee shall pay Licensor a fee, via Credit-Card, PayPal or any other mean which Licensor may deem adequate. Failure to perform payment shall construe as material breach of this Agreement.</p></li><li><p><strong>Upgrades, Updates and Fixes:</strong> Licensor may provide Licensee, from time to time, with Upgrades, Updates or Fixes, as detailed herein and according to his sole discretion. Licensee hereby warrants to keep The Software up-to-date and install all relevant updates and fixes, and may, at his sole discretion, purchase upgrades, according to the rates set by Licensor. Licensor shall provide any update or Fix free of charge; however, nothing in this Agreement shall require Licensor to provide Updates or Fixes.</p><ol><li><p><strong>Upgrades:</strong> for the purpose of this license, an Upgrade shall be a material amendment in The Software, which contains new features and or major performance improvements and shall be marked as a new version number. For example, should Licensee purchase The Software under version 1.X.X, an upgrade shall commence under number 2.0.0.</p></li><li><p><strong>Updates:</strong> for the purpose of this license, an update shall be a minor amendment in The Software, which may contain new features or minor improvements and shall be marked as a new sub-version number. For example, should Licensee purchase The Software under version 1.1.X, an upgrade shall commence under number 1.2.0.</p></li><li><p><strong>Fix:</strong> for the purpose of this license, a fix shall be a minor amendment in The Software, intended to remove bugs or alter minor features which impair the The Software\'s functionality. A fix shall be marked as a new sub-sub-version number. For example, should Licensee purchase Software under version 1.1.1, an upgrade shall commence under number 1.1.2.</p></li></ol></li><li><p><strong>Support:</strong> Software is provided under an AS-IS basis and without any support, updates or maintenance. Nothing in this Agreement shall require Licensor to provide Licensee with support or fixes to any bug, failure, mis-performance or other defect in The Software.</p><ol><li><p><strong>Bug Notification:</strong> Licensee may provide Licensor of details regarding any bug, defect or failure in The Software promptly and with no delay from such event; Licensee shall comply with Licensor\'s request for information regarding bugs, defects or failures and furnish him with information, screenshots and try to reproduce such bugs, defects or failures.</p></li><li><p><strong>Feature Request:</strong> Licensee may request additional features in Software, provided, however, that (i) Licensee shall waive any claim or right in such feature should feature be developed by Licensor; (ii) Licensee shall be prohibited from developing the feature, or disclose such feature request, or feature, to any 3rd party directly competing with Licensor or any 3rd party which may be, following the development of such feature, in direct competition with Licensor; (iii) Licensee warrants that feature does not infringe any 3rd party patent, trademark, trade-secret or any other intellectual property right; and (iv) Licensee developed, envisioned or created the feature solely by himself.</p></li></ol></li><li><p><strong>Liability:</strong> To the extent permitted under Law, The Software is provided under an AS-IS basis. Licensor shall never, and without any limit, be liable for any damage, cost, expense or any other payment incurred by Licensee as a result of Software’s actions, failure, bugs and/or any other interaction between The Software and Licensee’s end-equipment, computers, other software or any 3rd party, end-equipment, computer or services. Moreover, Licensor shall never be liable for any defect in source code written by Licensee when relying on The Software or using The Software’s source code.</p></li><li><p><strong>Warranty:</strong></p><ol><li><p><strong>Intellectual Property:</strong> Licensor hereby warrants that The Software does not violate or infringe any 3rd party claims in regards to intellectual property, patents and/or trademarks and that to the best of its knowledge no legal action has been taken against it for any infringement or violation of any 3rd party intellectual property rights.</p></li><li><p><strong>No-Warranty:</strong> The Software is provided without any warranty; Licensor hereby disclaims any warranty that The Software shall be error free, without defects or code which may cause damage to Licensee’s computers or to Licensee, and that Software shall be functional. Licensee shall be solely liable to any damage, defect or loss incurred as a result of operating software and undertake the risks contained in running The Software on License’s Server[s] and Website[s].</p></li><li><p><strong>Prior Inspection:</strong> Licensee hereby states that he inspected The Software thoroughly and found it satisfactory and adequate to his needs, that it does not interfere with his regular operation and that it does meet the standards and scope of his computer systems and architecture. Licensee found that The Software interacts with his development, website and server environment and that it does not infringe any of End User License Agreement of any software Licensee may use in performing his services. Licensee hereby waives any claims regarding The Software\'s incompatibility, performance, results and features, and warrants that he inspected the The Software.</p></li></ol></li><li><p><strong>No Refunds:</strong> Licensee warrants that he inspected The Software according to clause 7(c) and that it is adequate to his needs. Accordingly, as The Software is intangible goods, Licensee shall not be, ever, entitled to any refund, rebate, compensation or restitution for any reason whatsoever, even if The Software contains material flaws.</p></li><li><p><strong>Indemnification:</strong> Licensee hereby warrants to hold Licensor harmless and indemnify Licensor for any lawsuit brought against it in regards to Licensee’s use of The Software in means that violate, breach or otherwise circumvent this license, Licensor\'s intellectual property rights or Licensor\'s title in The Software. Licensor shall promptly notify Licensee in case of such legal action and request Licensee’s consent prior to any settlement in relation to such lawsuit or claim.</p></li><li><p><strong>Governing Law, Jurisdiction:</strong> Licensee hereby agrees not to initiate class-action lawsuits against Licensor in relation to this license and to compensate Licensor for any legal fees, cost or attorney fees should any claim brought by Licensee against Licensor be denied, in part or in full.</p></li></ol>'.$this->panelEnding();
|
||
}
|
||
}
|