toutpratique/override/classes/controller/AdminController.php
2015-08-13 12:41:23 +02:00

67 lines
2.2 KiB
PHP

<?php
class AdminController extends AdminControllerCore {
public function isFresh($file, $timeout = 604800) {
return true;
}
public function setMedia()
{
parent::setMedia();
$this->addJS(_PS_JS_DIR_.'admin/search.js');
}
public function refresh($file_to_refresh, $external_file)
{
if (self::$is_prestashop_up && $content = Tools::file_get_contents($external_file))
return (bool)@file_put_contents(_PS_ROOT_DIR_.$file_to_refresh, $content);
self::$is_prestashop_up = false;
return false;
}
protected function filterTabModuleList()
{
static $list_is_filtered = null;
if ($list_is_filtered !== null)
return;
if (!$this->isFresh(Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, 86400))
file_put_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, Tools::addonsRequest('native'));
if (!$this->isFresh(Module::CACHE_FILE_ALL_COUNTRY_MODULES_LIST, 86400))
file_put_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_ALL_COUNTRY_MODULES_LIST, Tools::addonsRequest('native_all'));
if (!$this->isFresh(Module::CACHE_FILE_MUST_HAVE_MODULES_LIST, 86400))
@file_put_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_MUST_HAVE_MODULES_LIST, Tools::addonsRequest('must-have'));
libxml_use_internal_errors(true);
$country_module_list = @file_get_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST);
$must_have_module_list = @file_get_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_MUST_HAVE_MODULES_LIST);
$all_module_list = array();
if (!empty($country_module_list) && $country_module_list_xml = simplexml_load_string($country_module_list))
{
$country_module_list_array = array();
if (is_object($country_module_list_xml->module))
foreach ($country_module_list_xml->module as $k => $m)
$all_module_list[] = (string)$m->name;
}
if (!empty($must_have_module_list) && $must_have_module_list_xml = simplexml_load_string($must_have_module_list))
{
$must_have_module_list_array = array();
if (is_object($country_module_list_xml->module))
foreach ($must_have_module_list_xml->module as $l => $mo)
$all_module_list[] = (string)$mo->name;
}
$this->tab_modules_list['slider_list'] = array_intersect($this->tab_modules_list['slider_list'], $all_module_list);
$list_is_filtered = true;
}
}
?>