// cleaning

This commit is contained in:
Rémi Gaillard committed 2013-10-31 16:39:01 +01:00
1 parent ba28c5f527
commit a7ed5ee869
1 file changed
+117 -99
+117 -99
View File
@@ -1,10 +1,35 @@
<?php <?php
if (!defined('_PS_VERSION_')) { /*
* 2007-2013 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-2013 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
if (!defined('_PS_VERSION_'))
exit; exit;
}
class AddShareThis extends Module class AddShareThis extends Module
{ {
function __construct() public function __construct()
{ {
$this->name = 'addsharethis'; $this->name = 'addsharethis';
$this->author = 'Custom'; $this->author = 'Custom';
@@ -14,49 +39,45 @@ class AddShareThis extends Module
parent::__construct(); parent::__construct();
$this->displayName = $this->l('Add Sharethis'); $this->displayName = $this->l('Add Sharethis');
$this->description = $this->l('Display social count button on the home page'); $this->description = $this->l('Display social count button on the home page');
} }
public function install() public function install()
{ {
Configuration::updateValue('CONF_ROW', 'ea22d519-9f98-4018-99a9-5b5f1b100fa8'); return (
Configuration::updateValue('ADDTHISSHARE_TWITTER',1); parent::install() &&
Configuration::updateValue('ADDTHISSHARE_GOOGLE',1); $this->registerHook('Extraright') &&
Configuration::updateValue('ADDTHISSHARE_PINTEREST',1); $this->registerHook('header') &&
Configuration::updateValue('ADDTHISSHARE_FACEBOOK',1); Configuration::updateValue('CONF_ROW', 'ea22d519-9f98-4018-99a9-5b5f1b100fa8') &&
if (!parent::install() OR Configuration::updateValue('ADDTHISSHARE_TWITTER', 1) &&
Configuration::updateValue('ADDTHISSHARE_GOOGLE', 1) &&
!$this->registerHook('Extraright') OR Configuration::updateValue('ADDTHISSHARE_PINTEREST', 1) &&
!$this->registerHook('header')) Configuration::updateValue('ADDTHISSHARE_FACEBOOK', 1)
return false; );
return true; }
}
public function uninstall() public function uninstall()
{ {
if (!parent::uninstall() OR return (
!Configuration::deleteByName('CONF_ROW') OR parent::uninstall() &&
!Configuration::deleteByName('ADDTHISSHARE_TWITTER') OR Configuration::deleteByName('CONF_ROW') &&
!Configuration::deleteByName('ADDTHISSHARE_GOOGLE') OR Configuration::deleteByName('ADDTHISSHARE_TWITTER') &&
!Configuration::deleteByName('ADDTHISSHARE_PINTEREST') OR Configuration::deleteByName('ADDTHISSHARE_GOOGLE') &&
!Configuration::deleteByName('ADDTHISSHARE_FACEBOOK') OR Configuration::deleteByName('ADDTHISSHARE_PINTEREST') &&
!$this->unregisterHook('Extraright') OR Configuration::deleteByName('ADDTHISSHARE_FACEBOOK') &&
!$this->unregisterHook('header')) $this->unregisterHook('Extraright') &&
return false; $this->unregisterHook('header')
else return true; );
} }
public function getContent()
{
public function getContent()
{
$this->_html .= '<h2>'.$this->displayName.'<span style=" float:right;"></span></h2><div class="clear"></div>'; $this->_html .= '<h2>'.$this->displayName.'<span style=" float:right;"></span></h2><div class="clear"></div>';
if (isset($_POST['submitCog'])) $this->updateCog();
if (Tools::isSubmit('submitCog')) if (Tools::isSubmit('submitCog'))
{ {
$conf_row = Tools::getValue('conf_row'); $this->updateCog();
Configuration::updateValue('CONF_ROW', $conf_row); Configuration::updateValue('CONF_ROW', Tools::getValue('conf_row'));
}
}
$this->_html .= ' $this->_html .= '
<fieldset class="space" id="cogField"> <fieldset class="space" id="cogField">
<legend><img src="'.$this->_path.'logo.png" alt="" title="" /> '.$this->l('Configuration').'</legend> <legend><img src="'.$this->_path.'logo.png" alt="" title="" /> '.$this->l('Configuration').'</legend>
@@ -66,23 +87,23 @@ public function getContent()
<div class="clearfix"></div><br/><br/> <div class="clearfix"></div><br/><br/>
<label>'.$this->l('Publisher Pub Key:').'</label> <label>'.$this->l('Publisher Pub Key:').'</label>
<div class="margin-form"> <div class="margin-form">
<input type="text" name="conf_row" id="conf_row" size="60" value="'.Tools::getValue('conf_row', Configuration::get('CONF_ROW')).'" /> <input type="text" name="conf_row" value="1" id="conf_row" size="60" value="'.Tools::safeOutput(Tools::getValue('conf_row', Configuration::get('CONF_ROW'))).'" />
</div><br/><br/> </div><br/><br/>
<div class="margin-form"> <div class="margin-form">
<input style="margin:-8px 20px 0 0;" type="checkbox" name="Twitter" id="Twitter" '.( (Configuration::get('ADDTHISSHARE_TWITTER') == 1) ? 'checked="checked"' : '').' /> <input style="margin:-8px 20px 0 0;" value="1" type="checkbox" name="Twitter" id="Twitter"'.(Configuration::get('ADDTHISSHARE_TWITTER') ? ' checked="checked"' : '').' />
<img src="'.($this->_path).'img/twitter.gif" /> <img src="'.$this->_path.'img/twitter.gif" />
</div> </div>
<div class="margin-form"> <div class="margin-form">
<input style="margin:-8px 20px 0 0;" type="checkbox" name="Google" id="Google" '.( (Configuration::get('ADDTHISSHARE_GOOGLE') == 1) ? 'checked="checked"' : '').' /> <input style="margin:-8px 20px 0 0;" value="1" type="checkbox" name="Google" id="Google"'.(Configuration::get('ADDTHISSHARE_GOOGLE') ? ' checked="checked"' : '').' />
<img src="'.($this->_path).'img/google.gif" /> <img src="'.$this->_path.'img/google.gif" />
</div> </div>
<div class="margin-form"> <div class="margin-form">
<input style="margin:-8px 20px 0 0;" type="checkbox" name="Pinterest" id="Pinterest" '.( (Configuration::get('ADDTHISSHARE_PINTEREST') == 1) ? 'checked="checked"' : '').' /> <input style="margin:-8px 20px 0 0;" value="1" type="checkbox" name="Pinterest" id="Pinterest" '.(Configuration::get('ADDTHISSHARE_PINTEREST') ? ' checked="checked"' : '').' />
<img src="'.($this->_path).'img/pinterest.gif" /> <img src="'.$this->_path.'img/pinterest.gif" />
</div> </div>
<div class="margin-form"> <div class="margin-form">
<input style="margin:-8px 20px 0 0;" type="checkbox" name="Facebook" id="Facebook" '.( (Configuration::get('ADDTHISSHARE_FACEBOOK') == 1) ? 'checked="checked"' : '').' /> <input style="margin:-8px 20px 0 0;" value="1" type="checkbox" name="Facebook" id="Facebook"'.(Configuration::get('ADDTHISSHARE_FACEBOOK') ? ' checked="checked"' : '').' />
<img src="'.($this->_path).'img/facebook.gif" /> <img src="'.$this->_path.'img/facebook.gif" />
</div> </div>
<br/><br/><div class="margin-form"> <br/><br/><div class="margin-form">
<input type="submit" class="button" name="submitCog" id="submitCog" value="'.$this->l('Save').'" /> <input type="submit" class="button" name="submitCog" id="submitCog" value="'.$this->l('Save').'" />
@@ -93,96 +114,93 @@ public function getContent()
return $this->_html; return $this->_html;
} }
public function updateCog() public function updateCog()
{ {
Configuration::updateValue('ADDTHISSHARE_TWITTER', (isset($_POST['Twitter']) ? 1 : 0)); Configuration::updateValue('ADDTHISSHARE_TWITTER', (int)Tools::getValue('Twitter'));
Configuration::updateValue('ADDTHISSHARE_GOOGLE', (isset($_POST['Google']) ? 1 : 0)); Configuration::updateValue('ADDTHISSHARE_GOOGLE', (int)Tools::getValue('Google'));
Configuration::updateValue('ADDTHISSHARE_PINTEREST', (isset($_POST['Pinterest']) ? 1 : 0)); Configuration::updateValue('ADDTHISSHARE_PINTEREST', (int)Tools::getValue('Pinterest'));
Configuration::updateValue('ADDTHISSHARE_FACEBOOK', (isset($_POST['Facebook']) ? 1 : 0)); Configuration::updateValue('ADDTHISSHARE_FACEBOOK', (int)Tools::getValue('Facebook'));
} }
public function hookDisplayHeader($params)
function hookDisplayHeader($params)
{ {
global $smarty, $cookie; $id_lang = (int)$this->context->language->id;
global $link; $product = new Product((int)Tools::getValue('id_product'), false, $id_lang);
$product = new Product((int)Tools::getValue('id_product'), false, (int)$cookie->id_lang); $productLink = $this->context->link->getProductLink($product);
$productLink = $link->getProductLink($product); $images = $product->getImages((int)$id_lang);
$images = $product->getImages((int)$cookie->id_lang);
foreach ($images AS $k => $image) foreach ($images AS $k => $image)
if ($image['cover']) if ($image['cover'])
{ {
$cover['id_image'] = (int)$product->id.'-'.(int)$image['id_image']; $cover['id_image'] = (int)$product->id.'-'.(int)$image['id_image'];
$cover['legend'] = $image['legend']; $cover['legend'] = $image['legend'];
break;
} }
if (!isset($cover)) if (!isset($cover))
$cover = array('id_image' => Language::getIsoById((int)$cookie->id_lang).'-default', 'legend' => 'No picture'); $cover = array('id_image' => Language::getIsoById((int)$id_lang).'-default', 'legend' => 'No picture');
$this->context->smarty->assign(array(
$this->context->smarty->assign(array(
'cover' => $cover, 'cover' => $cover,
'product' => $product, 'product' => $product,
'productLink' => $productLink, 'productLink' => $productLink,
'this_path' => $this->_path 'this_path' => $this->_path
)); )
);
return $this->display(__FILE__, 'addsharethis_header.tpl'); return $this->display(__FILE__, 'addsharethis_header.tpl');
} }
public function hookExtraRight($params) public function hookExtraRight($params)
{ {
global $smarty, $cookie, $link; if (Configuration::get('ADDTHISSHARE_TWITTER'))
$conf_row = Configuration::get('CONF_ROW');
$this->context->smarty->assign(array(
'conf_row' => $conf_row,
));
if (Configuration::get('ADDTHISSHARE_TWITTER') == 1)
$data['twitter'] = '<span class="st_twitter_hcount sharebtn" displayText="Tweet"></span>'; $data['twitter'] = '<span class="st_twitter_hcount sharebtn" displayText="Tweet"></span>';
if (Configuration::get('ADDTHISSHARE_GOOGLE') == 1)
{ if (Configuration::get('ADDTHISSHARE_GOOGLE'))
$data['google'] = '<span class="st_googleplus_hcount" displayText="Google +"></span>'; $data['google'] = '<span class="st_googleplus_hcount" displayText="Google +"></span>';
}
if (Configuration::get('ADDTHISSHARE_PINTEREST') == 1) if (Configuration::get('ADDTHISSHARE_PINTEREST'))
$data['pinterest'] = '<span class="st_pinterest_hcount sharebtn" displayText="Pinterest"></span>'; $data['pinterest'] = '<span class="st_pinterest_hcount sharebtn" displayText="Pinterest"></span>';
if (Configuration::get('ADDTHISSHARE_FACEBOOK') == 1) if (Configuration::get('ADDTHISSHARE_FACEBOOK'))
$data['facebook'] = '<span class="st_facebook_hcount sharebtn" displayText="Facebook"></span>'; $data['facebook'] = '<span class="st_facebook_hcount sharebtn" displayText="Facebook"></span>';
$smarty->assign('addsharethis_data', $data); $this->context->smarty->assign(array(
'addsharethis_data' => $data,
'conf_row' => Configuration::get('CONF_ROW')
)
);
return $this->display(__FILE__, 'addsharethis.tpl'); return $this->display(__FILE__, 'addsharethis.tpl');
} }
function hookLeftColumn($params) public function hookLeftColumn($params)
{ {
return $this->hookExtraRight($params); return $this->hookExtraRight($params);
} }
function hookFooter($params) public function hookFooter($params)
{ {
return $this->hookExtraRight($params); return $this->hookExtraRight($params);
} }
function hookHome($params) public function hookHome($params)
{ {
return $this->hookExtraRight($params); return $this->hookExtraRight($params);
} }
function hookExtraleft($params) public function hookExtraleft($params)
{ {
return $this->hookExtraRight($params); return $this->hookExtraRight($params);
} }
function hookProductActions($params)
public function hookProductActions($params)
{ {
return $this->hookExtraRight($params); return $this->hookExtraRight($params);
} }
function hookProductFooter($params) public function hookProductFooter($params)
{ {
return $this->hookExtraRight($params); return $this->hookExtraRight($params);
} }
}
}
?>