[+] BO : added new cool feature

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@16619 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
vAugagneur
2012-07-31 09:30:30 +00:00
parent b37a36eba5
commit 62c3e09cc6
4 changed files with 81 additions and 28 deletions
+1 -1
View File
@@ -232,6 +232,7 @@ form#product, form#access_form{ background-color:#ebedf4; border:1px solid #cc
#moduleContainer .moduleDesc p.desc { color:#666; font-size:12px; display:block; clear:both;}
#moduleContainer .setup {background-color:#6db300; font-size:10px; color:#fff; text-transform:uppercase; position:relative; left:10px; padding:0px 4px; display: inline-block; border-radius:3px;}
#moduleContainer .setup.non-install { background-color:#ec7000;}
#moduleContainer .setup.top-ranking { background-color: #ec2b25;}
#moduleContainer .setup.off{ background-color:#ccc;}
#moduleContainer .row-actions-module span { padding-right:5px;}
#moduleContainer .row-actions-module span a { font-size:12px;}
@@ -243,7 +244,6 @@ form#product, form#access_form{ background-color:#ebedf4; border:1px solid #cc
#moduleContainer .moduleName {font-size:12px; color:#3A6EA7;font-weight:bold;}
#moduleContainer .moduleFavDesc { font-family:Georgia; font-style:italic; color:#666;}
/*FOOTER*/
#footer {height:40px; font-size:12px;clear:both;font-size:0.9em;color:#666666}
#footer .footer_link, #footer .footer_link:hover {color:#D41958;}
@@ -48,7 +48,16 @@
<td><img class="imgm" alt="" src="{if isset($module->image)}{$module->image}{else}../modules/{$module->name}/{$module->logo}{/if}"></td>
<td>
<div class="moduleDesc" id="anchor{$module->name|ucfirst}">
<h3>{$module->displayName}{if isset($module->id) && $module->id gt 0}<span class="setup{if isset($module->active) && $module->active eq 0} off{/if}">{l s='Installed'}</span>{else}<span class="setup non-install">{l s='Not installed'}</span>{/if}</h3>
<h3>{$module->displayName}
{if isset($module->id) && $module->id gt 0}
<span class="setup{if isset($module->active) && $module->active eq 0} off{/if}">{l s='Installed'}</span>
{else}
<span class="setup non-install">{l s='Not installed'}</span>
{/if}
{if isset($module->type) && $module->type == 'addonsTopRanking'}
<span class="setup top-ranking">{l s='Top Ranking'}</span>
{/if}
</h3>
<div class="metadata">
{if isset($module->author) && !empty($module->author)}
<dl class="">
@@ -76,12 +85,20 @@
</td>
<td>
<ul id="list-action-button">
{if $module->id && isset($module->version_addons) && $module->version_addons}
<li><a href="{$module->options.update_url}" class="button updated"><span>{l s='Update it!'}</span></a></li>
{/if}
<li>
<a {if isset($module->id) && $module->id gt 0 && !empty($module->options.uninstall_onclick)}onclick="{$module->options.uninstall_onclick}"{/if} href="{if isset($module->id) && $module->id gt 0}{$module->options.uninstall_url}{else}{$module->options.install_url}{/if}" class="button installed"><span>{if isset($module->id) && $module->id gt 0}{l s='Uninstall'}{else}{l s='Install'}{/if}</span></a>
</li>
{if isset($module->type) && $module->type == 'addonsTopRanking'}
<li>
<a href="{$module->addons_buy_url}" target="_blank" class="button updated"><span>{l s='Buy it'} - {displayPrice price=$module->price currency=$module->id_currency}</span></a>
</li>
{else}
{if $module->id && isset($module->version_addons) && $module->version_addons}
<li><a href="{$module->options.update_url}" class="button updated"><span>{l s='Update it!'}</span></a></li>
{/if}
<li>
<a {if isset($module->id) && $module->id gt 0 && !empty($module->options.uninstall_onclick)}onclick="{$module->options.uninstall_onclick}"{/if} href="{if isset($module->id) && $module->id gt 0}{$module->options.uninstall_url}{else}{$module->options.install_url}{/if}" class="button installed">
<span>{if isset($module->id) && $module->id gt 0}{l s='Uninstall'}{else}{l s='Install'}{/if}</span>
</a>
</li>
{/if}
</ul>
</td>
</tr>
+28 -4
View File
@@ -118,7 +118,16 @@ abstract class ModuleCore
/** @var Smarty_Data */
protected $smarty;
const CACHE_FILE_MODULES_LIST = '/config/xml/modules_list.xml';
const CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST = '/config/xml/default_country_modules_list.xml';
const CACHE_FILE_CUSTOMER_MODULES_LIST = '/config/xml/customer_modules_list.xml';
const CACHE_FILE_TOP_RANKING_MODULES_LIST = '/config/xml/top_ranking_modules_list.xml';
/**
* Constructor
*
@@ -1077,8 +1086,9 @@ abstract class ModuleCore
// Get Default Country Modules and customer module
$files_list = array(
array('type' => 'addonsNative', 'file' => _PS_ROOT_DIR_.'/config/xml/default_country_modules_list.xml', 'loggedOnAddons' => 0),
array('type' => 'addonsBought', 'file' => _PS_ROOT_DIR_.'/config/xml/customer_modules_list.xml', 'loggedOnAddons' => 1),
array('type' => 'addonsNative', 'file' => _PS_ROOT_DIR_.self::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, 'loggedOnAddons' => 0),
array('type' => 'addonsBought', 'file' => _PS_ROOT_DIR_.self::CACHE_FILE_CUSTOMER_MODULES_LIST, 'loggedOnAddons' => 1),
array('type' => 'addonsTopRanking', 'file' => _PS_ROOT_DIR_.self::CACHE_FILE_TOP_RANKING_MODULES_LIST, 'loggedOnAddons' => 0),
);
foreach ($files_list as $f)
if (file_exists($f['file']) && ($f['loggedOnAddons'] == 0 || $loggedOnAddons))
@@ -1125,6 +1135,20 @@ abstract class ModuleCore
if (file_exists('../img/tmp/'.md5($modaddons->name).'.jpg'))
$item->image = '../img/tmp/'.md5($modaddons->name).'.jpg';
}
if ($item->type == 'addonsTopRanking')
{
$item->addons_buy_url = strip_tags((string)$modaddons->url);
$prices = (array)$modaddons->price;
$id_default_currency = Configuration::get('PS_CURRENCY_DEFAULT');
foreach ($prices as $currency => $price)
if ($id_currency = Currency::getIdByIsoCode($currency))
if ($id_default_currency == $id_currency)
{
$item->price = (float)$price;
$item->id_currency = (int)$id_currency;
}
}
$module_list[] = $item;
}
}
@@ -1193,7 +1217,7 @@ abstract class ModuleCore
{
$db = Db::getInstance();
$module_list_xml = _PS_ROOT_DIR_.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'xml'.DIRECTORY_SEPARATOR.'modules_list.xml';
$module_list_xml = _PS_ROOT_DIR_.self::CACHE_FILE_MODULES_LIST;
$native_modules = simplexml_load_file($module_list_xml);
$native_modules = $native_modules->modules;
foreach ($native_modules as $native_modules_type)
+28 -16
View File
@@ -57,9 +57,6 @@ class AdminModulesControllerCore extends AdminController
protected $xml_modules_list = 'api.prestashop.com/xml/modules_list_15.xml';
protected $addons_url = 'api.addons.prestashop.com';
protected $logged_on_addons = false;
protected $cache_file_modules_list = '/config/xml/modules_list.xml';
protected $cache_file_default_country_modules_list = '/config/xml/default_country_modules_list.xml';
protected $cache_file_customer_modules_list = '/config/xml/customer_modules_list.xml';
/**
* Admin Modules Controller Constructor
@@ -114,8 +111,8 @@ class AdminModulesControllerCore extends AdminController
// Load cache file modules list (natives and partners modules)
$xmlModules = false;
if (file_exists(_PS_ROOT_DIR_.$this->cache_file_modules_list))
$xmlModules = @simplexml_load_file(_PS_ROOT_DIR_.$this->cache_file_modules_list);
if (file_exists(_PS_ROOT_DIR_.Module::CACHE_FILE_MODULES_LIST))
$xmlModules = @simplexml_load_file(_PS_ROOT_DIR_.Module::CACHE_FILE_MODULES_LIST);
if ($xmlModules)
foreach ($xmlModules->children() as $xmlModule)
foreach ($xmlModule->children() as $module)
@@ -170,6 +167,12 @@ class AdminModulesControllerCore extends AdminController
$protocolsList = array('https://' => 443, 'http://' => 80);
$postData = 'version='._PS_VERSION_.'&method=listing&action=native&iso_code='.strtolower(Configuration::get('PS_LOCALE_COUNTRY')).'&iso_lang='.strtolower(Context::getContext()->language->iso_code);
}
if ($request == 'top_ranking')
{
// Define protocol accepted and post data values for this request
$protocolsList = array('https://' => 443, 'http://' => 80);
$postData = 'version='._PS_VERSION_.'&method=listing&action=top_ranking&iso_code='.strtolower(Configuration::get('PS_LOCALE_COUNTRY')).'&iso_lang='.strtolower(Context::getContext()->language->iso_code);
}
if ($request == 'customer')
{
// Define protocol accepted and post data values for this request
@@ -224,11 +227,11 @@ class AdminModulesControllerCore extends AdminController
public function ajaxProcessRefreshModuleList()
{
// Refresh modules_list.xml every week
if (!$this->isFresh($this->cache_file_modules_list, 604800))
if (!$this->isFresh(Module::CACHE_FILE_MODULES_LIST, 604800))
{
if ($this->refresh($this->cache_file_modules_list, 'https://'.$this->xml_modules_list))
if ($this->refresh(Module::CACHE_FILE_MODULES_LIST, 'https://'.$this->xml_modules_list))
$this->status = 'refresh';
else if ($this->refresh($this->cache_file_modules_list, 'http://'.$this->xml_modules_list))
else if ($this->refresh(Module::CACHE_FILE_MODULES_LIST, 'http://'.$this->xml_modules_list))
$this->status = 'refresh';
else
$this->status = 'error';
@@ -240,9 +243,19 @@ class AdminModulesControllerCore extends AdminController
// If logged to Addons Webservices, refresh default country native modules list every day
if ($this->status != 'error')
{
if (!$this->isFresh($this->cache_file_default_country_modules_list, 86400))
if (!$this->isFresh(Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, 86400))
{
if (file_put_contents(_PS_ROOT_DIR_.$this->cache_file_default_country_modules_list, $this->addonsRequest('native')))
if (file_put_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, $this->addonsRequest('native')))
$this->status = 'refresh';
else
$this->status = 'error';
}
else
$this->status = 'cache';
if (!$this->isFresh(Module::CACHE_FILE_TOP_RANKING_MODULES_LIST, 86400))
{
if (file_put_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_TOP_RANKING_MODULES_LIST, $this->addonsRequest('top_ranking')))
$this->status = 'refresh';
else
$this->status = 'error';
@@ -254,9 +267,9 @@ class AdminModulesControllerCore extends AdminController
// If logged to Addons Webservices, refresh customer modules list every day
if ($this->logged_on_addons && $this->status != 'error')
{
if (!$this->isFresh($this->cache_file_customer_modules_list, 60))
if (!$this->isFresh(Module::CACHE_FILE_CUSTOMER_MODULES_LIST, 60))
{
if (file_put_contents(_PS_ROOT_DIR_.$this->cache_file_customer_modules_list, $this->addonsRequest('customer')))
if (file_put_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_CUSTOMER_MODULES_LIST, $this->addonsRequest('customer')))
$this->status = 'refresh';
else
$this->status = 'error';
@@ -642,8 +655,8 @@ class AdminModulesControllerCore extends AdminController
if (!is_dir('../modules/'.$name.'/'))
{
$filesList = array(
array('type' => 'addonsNative', 'file' => $this->cache_file_default_country_modules_list, 'loggedOnAddons' => 0),
array('type' => 'addonsBought', 'file' => $this->cache_file_customer_modules_list, 'loggedOnAddons' => 1),
array('type' => 'addonsNative', 'file' => Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, 'loggedOnAddons' => 0),
array('type' => 'addonsBought', 'file' => Module::CACHE_FILE_CUSTOMER_MODULES_LIST, 'loggedOnAddons' => 1),
);
foreach ($filesList as $f)
if (file_exists(_PS_ROOT_DIR_.$f['file']))
@@ -1050,7 +1063,6 @@ class AdminModulesControllerCore extends AdminController
$modules = Module::getModulesOnDisk(true, $this->logged_on_addons, $this->id_employee);
$this->initModulesList($modules);
$this->nb_modules_total = count($modules);
$module_errors = array();
$module_success = array();
@@ -1195,4 +1207,4 @@ class AdminModulesControllerCore extends AdminController
}
$smarty->assign($tpl_vars);
}
}
}