//Block advertising multishop
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@10280 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
1 parent
a24764b9b3
commit
c7310f3899
2 files changed
+67
-43
No files matched your search
@@ -474,10 +474,13 @@ class AdminModulesControllerCore extends AdminController
|
|||||||
// If we install a module, force temporary global context for multishop
|
// If we install a module, force temporary global context for multishop
|
||||||
if (Shop::isFeatureActive() && Context::shop() != Shop::CONTEXT_ALL)
|
if (Shop::isFeatureActive() && Context::shop() != Shop::CONTEXT_ALL)
|
||||||
{
|
{
|
||||||
Context::getContext()->tmpOldShop = clone(Context::getContext()->shop);
|
// If we install a module, force temporary global context for multishop
|
||||||
Context::getContext()->shop = new Shop();
|
if (Shop::isFeatureActive() && Context::shop() != Shop::CONTEXT_ALL && $method != 'getContent')
|
||||||
Configuration::updateValue('RSS_FEED_TITLE', 'lol');
|
{
|
||||||
}
|
Context::getContext()->tmpOldShop = clone(Context::getContext()->shop);
|
||||||
|
Context::getContext()->shop = new Shop();
|
||||||
|
Configuration::updateValue('RSS_FEED_TITLE', 'lol');
|
||||||
|
}
|
||||||
|
|
||||||
if (((method_exists($module, $method) && ($echo = $module->{$method}())) || ($echo = ' ')) AND $key == 'configure' AND Module::isInstalled($module->name))
|
if (((method_exists($module, $method) && ($echo = $module->{$method}())) || ($echo = ' ')) AND $key == 'configure' AND Module::isInstalled($module->name))
|
||||||
{
|
{
|
||||||
@@ -512,9 +515,11 @@ class AdminModulesControllerCore extends AdminController
|
|||||||
}
|
}
|
||||||
$toolbar .= '</table>';
|
$toolbar .= '</table>';
|
||||||
|
|
||||||
// Display configure page
|
if (Shop::isFeatureActive() && isset(Context::getContext()->tmpOldShop))
|
||||||
// TODO : MAKE SOMETHING CLEANER
|
{
|
||||||
$this->context->smarty->assign('module_content', $toolbar.'<div class="clear"> </div>'.$echo.'<div class="clear"> </div>'.$toolbar);
|
Context::getContext()->shop = clone(Context::getContext()->tmpOldShop);
|
||||||
|
unset(Context::getContext()->tmpOldShop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
elseif($echo)
|
elseif($echo)
|
||||||
$return = ($method == 'install' ? 12 : 13);
|
$return = ($method == 'install' ? 12 : 13);
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ class BlockAdvertising extends Module
|
|||||||
*/
|
*/
|
||||||
public $adv_img;
|
public $adv_img;
|
||||||
|
|
||||||
|
public $use_global = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* adv_imgname is the filename of the image to display
|
* adv_imgname is the filename of the image to display
|
||||||
* @TODO make it configurable for SEO, but need a function to clean filename
|
* @TODO make it configurable for SEO, but need a function to clean filename
|
||||||
@@ -56,7 +58,7 @@ class BlockAdvertising extends Module
|
|||||||
{
|
{
|
||||||
$this->name = 'blockadvertising';
|
$this->name = 'blockadvertising';
|
||||||
$this->tab = 'advertising_marketing';
|
$this->tab = 'advertising_marketing';
|
||||||
$this->version = 0.3;
|
$this->version = '0.4';
|
||||||
$this->author = 'PrestaShop';
|
$this->author = 'PrestaShop';
|
||||||
$this->need_instance = 0;
|
$this->need_instance = 0;
|
||||||
|
|
||||||
@@ -65,6 +67,25 @@ class BlockAdvertising extends Module
|
|||||||
$this->displayName = $this->l('Block advertising');
|
$this->displayName = $this->l('Block advertising');
|
||||||
$this->description = $this->l('Adds a block to display an advertisement.');
|
$this->description = $this->l('Adds a block to display an advertisement.');
|
||||||
|
|
||||||
|
if ($this->context->shop->getContextType() == Shop::CONTEXT_SHOP)
|
||||||
|
{
|
||||||
|
if (defined('_PS_ADMIN_DIR_') || file_exists(_PS_MODULE_DIR_.$this->name.'/'.$this->adv_imgname.'-'.(int)$this->context->shop->id.'.'.Configuration::get('BLOCKADVERT_IMG_EXT')))
|
||||||
|
{
|
||||||
|
$this->adv_imgname .= '-'.(int)$this->context->shop->id;
|
||||||
|
$this->use_global = false;
|
||||||
|
$advert_link = Configuration::get('BLOCKADVERT_LINK');
|
||||||
|
$advert_title = Configuration::get('BLOCKADVERT_TITLE');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$this->use_global = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->use_global)
|
||||||
|
{
|
||||||
|
$advert_link = Configuration::getGlobalValue('BLOCKADVERT_LINK');
|
||||||
|
$advert_title = Configuration::getGlobalValue('BLOCKADVERT_TITLE');
|
||||||
|
}
|
||||||
|
|
||||||
if (!file_exists(_PS_MODULE_DIR_.$this->name.'/'.$this->adv_imgname.'.'.Configuration::get('BLOCKADVERT_IMG_EXT')))
|
if (!file_exists(_PS_MODULE_DIR_.$this->name.'/'.$this->adv_imgname.'.'.Configuration::get('BLOCKADVERT_IMG_EXT')))
|
||||||
{
|
{
|
||||||
$this->adv_imgname = 'advertising';
|
$this->adv_imgname = 'advertising';
|
||||||
@@ -77,8 +98,8 @@ class BlockAdvertising extends Module
|
|||||||
if (!empty($this->adv_imgname))
|
if (!empty($this->adv_imgname))
|
||||||
$this->adv_img = Tools::getMediaServer($this->name)._MODULE_DIR_.$this->name.'/'.$this->adv_imgname.'.'.Configuration::get('BLOCKADVERT_IMG_EXT');
|
$this->adv_img = Tools::getMediaServer($this->name)._MODULE_DIR_.$this->name.'/'.$this->adv_imgname.'.'.Configuration::get('BLOCKADVERT_IMG_EXT');
|
||||||
|
|
||||||
$this->adv_link = htmlentities(Configuration::get('BLOCKADVERT_LINK'), ENT_QUOTES, 'UTF-8');
|
$this->adv_link = htmlentities($advert_link, ENT_QUOTES, 'UTF-8');
|
||||||
$this->adv_title = htmlentities(Configuration::get('BLOCKADVERT_TITLE'), ENT_QUOTES, 'UTF-8');
|
$this->adv_title = htmlentities($advert_title, ENT_QUOTES, 'UTF-8');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -99,7 +120,8 @@ class BlockAdvertising extends Module
|
|||||||
*/
|
*/
|
||||||
private function _deleteCurrentImg()
|
private function _deleteCurrentImg()
|
||||||
{
|
{
|
||||||
|
if ($this->adv_imgname == 'advertising')
|
||||||
|
return;
|
||||||
if (file_exists(_PS_MODULE_DIR_.$this->name.'/'.$this->adv_imgname.'.'.Configuration::get('BLOCKADVERT_IMG_EXT')))
|
if (file_exists(_PS_MODULE_DIR_.$this->name.'/'.$this->adv_imgname.'.'.Configuration::get('BLOCKADVERT_IMG_EXT')))
|
||||||
unlink(_PS_MODULE_DIR_.$this->name.'/'.$this->adv_imgname.'.'.Configuration::get('BLOCKADVERT_IMG_EXT'));
|
unlink(_PS_MODULE_DIR_.$this->name.'/'.$this->adv_imgname.'.'.Configuration::get('BLOCKADVERT_IMG_EXT'));
|
||||||
$this->adv_imgname = $this->adv_imgname == 'advertising_custom'?'advertising':'';
|
$this->adv_imgname = $this->adv_imgname == 'advertising_custom'?'advertising':'';
|
||||||
@@ -130,8 +152,7 @@ class BlockAdvertising extends Module
|
|||||||
$this->_deleteCurrentImg();
|
$this->_deleteCurrentImg();
|
||||||
$this->adv_imgname = 'advertising';
|
$this->adv_imgname = 'advertising';
|
||||||
$ext = substr($_FILES['adv_img']['name'], $dot_pos+1);
|
$ext = substr($_FILES['adv_img']['name'], $dot_pos+1);
|
||||||
$newname = 'advertising_custom';
|
$newname = 'advertising_custom'.'-'.(int)$this->context->shop->id;
|
||||||
|
|
||||||
if (!move_uploaded_file($_FILES['adv_img']['tmp_name'],_PS_MODULE_DIR_.$this->name.'/'.$newname.'.'.$ext))
|
if (!move_uploaded_file($_FILES['adv_img']['tmp_name'],_PS_MODULE_DIR_.$this->name.'/'.$newname.'.'.$ext))
|
||||||
$errors .= $this->l('Error move uploaded file');
|
$errors .= $this->l('Error move uploaded file');
|
||||||
else
|
else
|
||||||
@@ -141,7 +162,6 @@ class BlockAdvertising extends Module
|
|||||||
$this->adv_img = Tools::getMediaServer($this->name)._MODULE_DIR_.$this->name.'/'.$this->adv_imgname.'.'.Configuration::get('BLOCKADVERT_IMG_EXT');
|
$this->adv_img = Tools::getMediaServer($this->name)._MODULE_DIR_.$this->name.'/'.$this->adv_imgname.'.'.Configuration::get('BLOCKADVERT_IMG_EXT');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($link = Tools::getValue('adv_link'))
|
if ($link = Tools::getValue('adv_link'))
|
||||||
{
|
{
|
||||||
Configuration::updateValue('BLOCKADVERT_LINK', $link);
|
Configuration::updateValue('BLOCKADVERT_LINK', $link);
|
||||||
@@ -167,35 +187,34 @@ class BlockAdvertising extends Module
|
|||||||
{
|
{
|
||||||
|
|
||||||
$this->postProcess();
|
$this->postProcess();
|
||||||
$output = '';
|
$output = '<form action="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'" method="post" enctype="multipart/form-data">
|
||||||
$output .= '
|
<fieldset>
|
||||||
<form action="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'" method="post" enctype="multipart/form-data">
|
<legend>'.$this->l('Advertising block configuration').'</legend>
|
||||||
<fieldset><legend>'.$this->l('Advertising block configuration').'</legend>
|
<a href="'.$this->adv_link.'" target="_blank" title="'.$this->adv_title.'">';
|
||||||
<a href="'.$this->adv_link.'" target="_blank" title="'.$this->adv_title.'">';
|
if ($this->adv_img)
|
||||||
if ($this->adv_img)
|
{
|
||||||
{
|
$output .= '<img src="'.$this->context->link->protocol_content.$this->adv_img.'" alt="'.$this->adv_title.'" title="'.$this->adv_title.'" style="height:163px;margin-left: 100px;width:163px"/>';
|
||||||
$output .= '<img src="'.$this->context->link->protocol_content.$this->adv_img.'" alt="'.$this->adv_title.'" title="'.$this->adv_title.'" style="height:163px;margin-left: 100px;width:163px"/>';
|
$output .= '<input class="button" type="submit" name="submitDeleteImgConf" value="'.$this->l('Delete image').'" style=""/>';
|
||||||
$output .= '<input class="button" type="submit" name="submitDeleteImgConf" value="'.$this->l('Delete image').'" style=""/>';
|
}
|
||||||
}
|
else
|
||||||
else
|
$output .= '<div style="margin-left: 100px;width:163px;"/>'.$this->l('no image').'</div>';
|
||||||
$output .= '<div style="margin-left: 100px;width:163px;"/>'.$this->l('no image').'</div>';
|
$output .= '
|
||||||
$output .= '</a>';
|
</a>
|
||||||
$output .= '<br/>
|
<br/>
|
||||||
<br/>
|
<br/>
|
||||||
<label for="adv_img">'.$this->l('Change image').' </label><input id="adv_img" type="file" name="adv_img" />
|
<label for="adv_img">'.$this->l('Change image').' </label><input id="adv_img" type="file" name="adv_img" />
|
||||||
( '.$this->l('Image will be displayed as 155x163').' )
|
( '.$this->l('Image will be displayed as 155x163').' )
|
||||||
<br/>
|
<br/>
|
||||||
<br class="clear"/>
|
<br class="clear"/>
|
||||||
<label for="adv_link">'.$this->l('Image link').' </label><input id="adv_link" type="text" name="adv_link" value="'.$this->adv_link.'" />
|
<label for="adv_link">'.$this->l('Image link').' </label><input id="adv_link" type="text" name="adv_link" value="'.$this->adv_link.'" />
|
||||||
<br class="clear"/>
|
<br class="clear"/>
|
||||||
<br/>
|
<br/>
|
||||||
<label for="adv_title">'.$this->l('Title').' </label><input id="adv_title" type="text" name="adv_title" value="'.$this->adv_title.'" />
|
<label for="adv_title">'.$this->l('Title').' </label><input id="adv_title" type="text" name="adv_title" value="'.$this->adv_title.'" />
|
||||||
<br class="clear"/>
|
<br class="clear"/>
|
||||||
<br/>
|
<br/>
|
||||||
<input class="button" type="submit" name="submitAdvConf" value="'.$this->l('validate').'" style="margin-left: 200px;"/>
|
<input class="button" type="submit" name="submitAdvConf" value="'.$this->l('validate').'" style="margin-left: 200px;"/>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>';
|
||||||
';
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user