Commit 542826dd authored by Gregory Roussac's avatar Gregory Roussac

Merge branch 'guestisp-use-constants-for-api-urls' into 1.6

parents 2928bec1 0e25ccd8
......@@ -402,7 +402,7 @@ class CurrencyCore extends ObjectModel
public static function refreshCurrencies()
{
// Parse
if (!$feed = Tools::simplexml_load_file('http://api.prestashop.com/xml/currencies.xml'))
if (!$feed = Tools::simplexml_load_file(_PS_CURRENCY_FEED_URL_))
return Tools::displayError('Cannot parse feed.');
// Default feed currency (EUR)
......@@ -459,4 +459,4 @@ class CurrencyCore extends ObjectModel
{
return (Currency::countActiveCurrencies($id_shop) > 1);
}
}
\ No newline at end of file
}
......@@ -46,8 +46,6 @@ class TabCore extends ObjectModel
/** @var integer hide_host_mode */
public $hide_host_mode = false;
const TAB_MODULE_LIST_URL = 'api.prestashop.com/xml/tab_modules_list.xml';
/**
* @see ObjectModel::$definition
*/
......
......@@ -27,8 +27,8 @@
class UpgraderCore
{
const DEFAULT_CHECK_VERSION_DELAY_HOURS = 24;
public $rss_version_link = 'http://api.prestashop.com/xml/upgrader.xml';
public $rss_md5file_link_dir = 'http://api.prestashop.com/xml/md5/';
public $rss_version_link;
public $rss_md5file_link_dir;
/**
* @var boolean contains true if last version is not installed
*/
......@@ -52,6 +52,9 @@ class UpgraderCore
public function __construct($autoload = false)
{
$this->rss_version_link = _PS_API_URL_.'/xml/upgrader.xml';
$this->rss_md5file_link_dir = _PS_API_URL_.'/xml/md5/';
if ($autoload)
{
$this->loadFromConfig();
......
......@@ -1889,7 +1889,7 @@ class AdminControllerCore extends Controller
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'));
if (!$this->isFresh(Module::CACHE_FILE_TAB_MODULES_LIST, 604800))
$this->refresh(Module::CACHE_FILE_TAB_MODULES_LIST, 'http://'.Tab::TAB_MODULE_LIST_URL);
$this->refresh(Module::CACHE_FILE_TAB_MODULES_LIST, _PS_TAB_MODULE_LIST_URL_);
$this->tab_modules_list = Tab::getTabModulesList($this->id);
......
......@@ -25,59 +25,69 @@
*/
/* Theme URLs */
define('_PS_DEFAULT_THEME_NAME_', 'default-bootstrap');
define('_PS_THEME_DIR_', _PS_ROOT_DIR_.'/themes/'._THEME_NAME_.'/');
define('_THEMES_DIR_', __PS_BASE_URI__.'themes/');
define('_THEME_DIR_', _THEMES_DIR_._THEME_NAME_.'/');
define('_THEME_IMG_DIR_', _THEME_DIR_.'img/');
define('_THEME_CSS_DIR_', _THEME_DIR_.'css/');
define('_THEME_JS_DIR_', _THEME_DIR_.'js/');
define('_PS_THEME_OVERRIDE_DIR_', _PS_THEME_DIR_.'override/');
define('_PS_DEFAULT_THEME_NAME_', 'default-bootstrap');
define('_PS_THEME_DIR_', _PS_ROOT_DIR_.'/themes/'._THEME_NAME_.'/');
define('_THEMES_DIR_', __PS_BASE_URI__.'themes/');
define('_THEME_DIR_', _THEMES_DIR_._THEME_NAME_.'/');
define('_THEME_IMG_DIR_', _THEME_DIR_.'img/');
define('_THEME_CSS_DIR_', _THEME_DIR_.'css/');
define('_THEME_JS_DIR_', _THEME_DIR_.'js/');
define('_PS_THEME_OVERRIDE_DIR_', _PS_THEME_DIR_.'override/');
/* For mobile devices */
if (file_exists(_PS_THEME_DIR_.'mobile/'))
{
define('_PS_THEME_MOBILE_DIR_', _PS_THEME_DIR_.'mobile/');
define('_THEME_MOBILE_DIR_', _THEMES_DIR_._THEME_NAME_.'/mobile/');
define('_PS_THEME_MOBILE_DIR_', _PS_THEME_DIR_.'mobile/');
define('_THEME_MOBILE_DIR_', _THEMES_DIR_._THEME_NAME_.'/mobile/');
}
else
{
define('_PS_THEME_MOBILE_DIR_', _PS_ROOT_DIR_.'/themes/'._PS_DEFAULT_THEME_NAME_.'/mobile/');
define('_THEME_MOBILE_DIR_', __PS_BASE_URI__.'themes/'._PS_DEFAULT_THEME_NAME_.'/mobile/');
define('_PS_THEME_MOBILE_DIR_', _PS_ROOT_DIR_.'/themes/'._PS_DEFAULT_THEME_NAME_.'/mobile/');
define('_THEME_MOBILE_DIR_', __PS_BASE_URI__.'themes/'._PS_DEFAULT_THEME_NAME_.'/mobile/');
}
define('_PS_THEME_MOBILE_OVERRIDE_DIR_', _PS_THEME_MOBILE_DIR_.'override/');
define('_THEME_MOBILE_IMG_DIR_', _THEME_MOBILE_DIR_.'img/');
define('_THEME_MOBILE_CSS_DIR_', _THEME_MOBILE_DIR_.'css/');
define('_THEME_MOBILE_JS_DIR_', _THEME_MOBILE_DIR_.'js/');
define('_THEME_MOBILE_IMG_DIR_', _THEME_MOBILE_DIR_.'img/');
define('_THEME_MOBILE_CSS_DIR_', _THEME_MOBILE_DIR_.'css/');
define('_THEME_MOBILE_JS_DIR_', _THEME_MOBILE_DIR_.'js/');
/* For touch pad devices */
define('_PS_THEME_TOUCHPAD_DIR_', _PS_THEME_DIR_.'touchpad/');
define('_THEME_TOUCHPAD_DIR_', _THEMES_DIR_._THEME_NAME_.'/touchpad/');
define('_THEME_TOUCHPAD_CSS_DIR_', _THEME_TOUCHPAD_DIR_.'css/');
define('_THEME_TOUCHPAD_JS_DIR_', _THEME_TOUCHPAD_DIR_.'js/');
define('_PS_THEME_TOUCHPAD_DIR_', _PS_THEME_DIR_.'touchpad/');
define('_THEME_TOUCHPAD_DIR_', _THEMES_DIR_._THEME_NAME_.'/touchpad/');
define('_THEME_TOUCHPAD_CSS_DIR_', _THEME_TOUCHPAD_DIR_.'css/');
define('_THEME_TOUCHPAD_JS_DIR_', _THEME_TOUCHPAD_DIR_.'js/');
/* Image URLs */
define('_PS_IMG_', __PS_BASE_URI__.'img/');
define('_PS_ADMIN_IMG_', _PS_IMG_.'admin/');
define('_PS_TMP_IMG_', _PS_IMG_.'tmp/');
define('_THEME_CAT_DIR_', _PS_IMG_.'c/');
define('_THEME_PROD_DIR_', _PS_IMG_.'p/');
define('_THEME_MANU_DIR_', _PS_IMG_.'m/');
define('_THEME_SCENE_DIR_', _PS_IMG_.'scenes/');
define('_THEME_SCENE_THUMB_DIR_', _PS_IMG_.'scenes/thumbs');
define('_THEME_SUP_DIR_', _PS_IMG_.'su/');
define('_THEME_SHIP_DIR_', _PS_IMG_.'s/');
define('_THEME_STORE_DIR_', _PS_IMG_.'st/');
define('_THEME_LANG_DIR_', _PS_IMG_.'l/');
define('_THEME_COL_DIR_', _PS_IMG_.'co/');
define('_THEME_GENDERS_DIR_', _PS_IMG_.'genders/');
define('_SUPP_DIR_', _PS_IMG_.'su/');
define('_PS_PROD_IMG_', _PS_IMG_.'p/');
define('_PS_IMG_', __PS_BASE_URI__.'img/');
define('_PS_ADMIN_IMG_', _PS_IMG_.'admin/');
define('_PS_TMP_IMG_', _PS_IMG_.'tmp/');
define('_THEME_CAT_DIR_', _PS_IMG_.'c/');
define('_THEME_PROD_DIR_', _PS_IMG_.'p/');
define('_THEME_MANU_DIR_', _PS_IMG_.'m/');
define('_THEME_SCENE_DIR_', _PS_IMG_.'scenes/');
define('_THEME_SCENE_THUMB_DIR_', _PS_IMG_.'scenes/thumbs');
define('_THEME_SUP_DIR_', _PS_IMG_.'su/');
define('_THEME_SHIP_DIR_', _PS_IMG_.'s/');
define('_THEME_STORE_DIR_', _PS_IMG_.'st/');
define('_THEME_LANG_DIR_', _PS_IMG_.'l/');
define('_THEME_COL_DIR_', _PS_IMG_.'co/');
define('_THEME_GENDERS_DIR_', _PS_IMG_.'genders/');
define('_SUPP_DIR_', _PS_IMG_.'su/');
define('_PS_PROD_IMG_', _PS_IMG_.'p/');
/* Other URLs */
define('_PS_JS_DIR_', __PS_BASE_URI__.'js/');
define('_PS_CSS_DIR_', __PS_BASE_URI__.'css/');
define('_THEME_PROD_PIC_DIR_', __PS_BASE_URI__.'upload/');
define('_MAIL_DIR_', __PS_BASE_URI__.'mails/');
define('_MODULE_DIR_', __PS_BASE_URI__.'modules/');
define('_PS_JS_DIR_', __PS_BASE_URI__.'js/');
define('_PS_CSS_DIR_', __PS_BASE_URI__.'css/');
define('_THEME_PROD_PIC_DIR_', __PS_BASE_URI__.'upload/');
define('_MAIL_DIR_', __PS_BASE_URI__.'mails/');
define('_MODULE_DIR_', __PS_BASE_URI__.'modules/');
/* Define API URLs if not defined by customer */
define('_PS_API_DOMAIN_', 'api.prestashop.com');
define('_PS_API_URL_', 'http://'._PS_API_DOMAIN_);
define('_PS_API_SSL_URL_', 'https://'._PS_API_DOMAIN_);
define('_PS_TAB_MODULE_LIST_URL_', 'http://'._PS_API_DOMAIN_.'/xml/tab_modules_list.xml');
define('_PS_API_MODULES_LIST_16_', _PS_API_DOMAIN_.'/xml/modules_list_16.xml');
// Different name for currency url. customers could customize just this without affecting all other apis
define('_PS_CURRENCY_FEED_URL_', 'http://'._PS_API_DOMAIN_.'/xml/currencies.xml');
......@@ -227,7 +227,7 @@ class AdminDashboardControllerCore extends AdminController
//'translations' => $translations,
'action' => '#',
'warning' => $this->getWarningDomainName(),
'new_version_url' => Tools::getCurrentUrlProtocolPrefix().'api.prestashop.com/version/check_version.php?v='._PS_VERSION_.'&lang='.$this->context->language->iso_code.'&autoupgrade='.(int)(Module::isInstalled('autoupgrade') && Module::isEnabled('autoupgrade')).'&hosted_mode='.(int)defined('_PS_HOST_MODE_'),
'new_version_url' => Tools::getCurrentUrlProtocolPrefix()._PS_API_DOMAIN_.'/version/check_version.php?v='._PS_VERSION_.'&lang='.$this->context->language->iso_code.'&autoupgrade='.(int)(Module::isInstalled('autoupgrade') && Module::isEnabled('autoupgrade')).'&hosted_mode='.(int)defined('_PS_HOST_MODE_'),
'dashboard_use_push' => Configuration::get('PS_DASHBOARD_USE_PUSH'),
'calendar' => $calendar_helper->generate(),
'PS_DASHBOARD_SIMULATION' => Configuration::get('PS_DASHBOARD_SIMULATION'),
......@@ -343,7 +343,7 @@ class AdminDashboardControllerCore extends AdminController
{
$return = array('has_errors' => false, 'rss' => array());
if (!$this->isFresh('/config/xml/blog-'.$this->context->language->iso_code.'.xml', 86400))
if (!$this->refresh('/config/xml/blog-'.$this->context->language->iso_code.'.xml', 'https://api.prestashop.com/rss/blog/blog-'.$this->context->language->iso_code.'.xml'))
if (!$this->refresh('/config/xml/blog-'.$this->context->language->iso_code.'.xml', _PS_API_SSL_URL_.'/rss/blog/blog-'.$this->context->language->iso_code.'.xml'))
$return['has_errors'] = true;
if (!$return['has_errors'])
......
......@@ -162,7 +162,7 @@ class AdminInformationControllerCore extends AdminController
public function displayAjaxCheckFiles()
{
$this->file_list = array('missing' => array(), 'updated' => array());
$xml = @simplexml_load_file('http://api.prestashop.com/xml/md5/'._PS_VERSION_.'.xml');
$xml = @simplexml_load_file(_PS_API_URL_.'/xml/md5/'._PS_VERSION_.'.xml');
if (!$xml)
die(Tools::jsonEncode($this->file_list));
......@@ -194,4 +194,4 @@ class AdminInformationControllerCore extends AdminController
foreach ($dir->dir as $subdir)
$this->getListOfUpdatedFiles($subdir, $path.$subdir['name'].'/');
}
}
\ No newline at end of file
}
......@@ -176,7 +176,7 @@ class AdminLocalizationControllerCore extends AdminController
if (($iso_localization_pack = Tools::getValue('iso_localization_pack')) && Validate::isFileName($iso_localization_pack))
{
if (Tools::getValue('download_updated_pack') == '1' || defined('_PS_HOST_MODE_'))
$pack = @Tools::file_get_contents('http://api.prestashop.com/localization/'.$version.'/'.$iso_localization_pack.'.xml');
$pack = @Tools::file_get_contents(_PS_API_URL_.'/localization/'.$version.'/'.$iso_localization_pack.'.xml');
else
$pack = false;
......@@ -223,7 +223,7 @@ class AdminLocalizationControllerCore extends AdminController
$localizations_pack = false;
$this->tpl_option_vars['options_content'] = $this->renderOptions();
$xml_localization = Tools::simplexml_load_file('http://api.prestashop.com/rss/localization.xml');
$xml_localization = Tools::simplexml_load_file(_PS_API_URL_.'/rss/localization.xml');
if (!$xml_localization)
{
$localization_file = _PS_ROOT_DIR_.'/localization/localization.xml';
......@@ -245,7 +245,7 @@ class AdminLocalizationControllerCore extends AdminController
}
if (!$localizations_pack)
return $this->displayWarning($this->l('Cannot connect to prestashop.com'));
return $this->displayWarning($this->l('Cannot connect to '._PS_API_URL_));
// Add local localization .xml files to the list if they are not already there
foreach (scandir(_PS_ROOT_DIR_.'/localization/') as $entry)
......
......@@ -59,7 +59,7 @@ class AdminModulesControllerCore extends AdminController
protected $iso_default_country;
protected $filter_configuration = array();
protected $xml_modules_list = 'api.prestashop.com/xml/modules_list_16.xml';
protected $xml_modules_list = _PS_API_MODULES_LIST_16_;
/**
......
......@@ -1982,7 +1982,7 @@ class AdminThemesControllerCore extends AdminController
*/
private function getNativeModule($type = 0)
{
$xml = simplexml_load_string(Tools::file_get_contents('http://api.prestashop.com/xml/modules_list_16.xml'));
$xml = simplexml_load_string(Tools::file_get_contents(_PS_API_URL_.'/xml/modules_list_16.xml'));
if ($xml)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment