[-] Classes: Tools::generateHtaccess() can be called without its arguments (use default configuration settings)
This commit is contained in:
+5
-52
@@ -185,16 +185,7 @@ class LanguageCore extends ObjectModel
|
|||||||
$resUpdateSQL = $this->loadUpdateSQL();
|
$resUpdateSQL = $this->loadUpdateSQL();
|
||||||
$resUpdateSQL = true;
|
$resUpdateSQL = true;
|
||||||
|
|
||||||
// If url_rewrite is not enabled, we don't need to regenerate .htaccess
|
return $resUpdateSQL && Tools::generateHtaccess();
|
||||||
if(!Configuration::get('PS_REWRITING_SETTINGS'))
|
|
||||||
return $resUpdateSQL;
|
|
||||||
|
|
||||||
return ($resUpdateSQL AND Tools::generateHtaccess(dirname(__FILE__).'/../.htaccess',
|
|
||||||
(int)(Configuration::get('PS_REWRITING_SETTINGS')),
|
|
||||||
(int)(Configuration::get('PS_HTACCESS_CACHE_CONTROL')),
|
|
||||||
'',
|
|
||||||
(int)Configuration::get('PS_HTACCESS_DISABLE_MULTIVIEWS')
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toggleStatus()
|
public function toggleStatus()
|
||||||
@@ -202,15 +193,7 @@ class LanguageCore extends ObjectModel
|
|||||||
if (!parent::toggleStatus())
|
if (!parent::toggleStatus())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// If url_rewrite is not enabled, we don't need to regenerate .htaccess
|
return Tools::generateHtaccess();
|
||||||
if(!Configuration::get('PS_REWRITING_SETTINGS'))
|
|
||||||
return true;
|
|
||||||
return (Tools::generateHtaccess(dirname(__FILE__).'/../.htaccess',
|
|
||||||
(int)(Configuration::get('PS_REWRITING_SETTINGS')),
|
|
||||||
(int)(Configuration::get('PS_HTACCESS_CACHE_CONTROL')),
|
|
||||||
'',
|
|
||||||
(int)Configuration::get('PS_HTACCESS_DISABLE_MULTIVIEWS')
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function checkFiles()
|
public function checkFiles()
|
||||||
@@ -470,16 +453,7 @@ class LanguageCore extends ObjectModel
|
|||||||
unlink(dirname(__FILE__).'/../img/l/'.$this->id.'.jpg');
|
unlink(dirname(__FILE__).'/../img/l/'.$this->id.'.jpg');
|
||||||
}
|
}
|
||||||
|
|
||||||
// If url_rewrite is not enabled, we don't need to regenerate .htaccess
|
return Tools::generateHtaccess();
|
||||||
if(!Configuration::get('PS_REWRITING_SETTINGS'))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return Tools::generateHtaccess(dirname(__FILE__).'/../.htaccess',
|
|
||||||
(int)(Configuration::get('PS_REWRITING_SETTINGS')),
|
|
||||||
(int)(Configuration::get('PS_HTACCESS_CACHE_CONTROL')),
|
|
||||||
'',
|
|
||||||
(int)Configuration::get('PS_HTACCESS_DISABLE_MULTIVIEWS')
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -495,17 +469,7 @@ class LanguageCore extends ObjectModel
|
|||||||
$result = $result AND $this->delete();
|
$result = $result AND $this->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
// If url_rewrite is not enabled, we don't need to regenerate .htaccess
|
Tools::generateHtaccess();
|
||||||
if(!Configuration::get('PS_REWRITING_SETTINGS'))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
Tools::generateHtaccess(dirname(__FILE__).'/../.htaccess',
|
|
||||||
(int)Configuration::get('PS_REWRITING_SETTINGS'),
|
|
||||||
(int)Configuration::get('PS_HTACCESS_CACHE_CONTROL'),
|
|
||||||
'',
|
|
||||||
(int)Configuration::get('PS_HTACCESS_DISABLE_MULTIVIEWS')
|
|
||||||
);
|
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -630,21 +594,10 @@ class LanguageCore extends ObjectModel
|
|||||||
|
|
||||||
public function update($nullValues = false)
|
public function update($nullValues = false)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
if (!parent::update($nullValues))
|
if (!parent::update($nullValues))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// If url_rewrite is not enabled, we don't need to regenerate .htaccess
|
return Tools::generateHtaccess();
|
||||||
if(!Configuration::get('PS_REWRITING_SETTINGS'))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return Tools::generateHtaccess(dirname(__FILE__).'/../.htaccess',
|
|
||||||
(int)(Configuration::get('PS_REWRITING_SETTINGS')),
|
|
||||||
(int)(Configuration::get('PS_HTACCESS_CACHE_CONTROL')),
|
|
||||||
'',
|
|
||||||
(int)Configuration::get('PS_HTACCESS_DISABLE_MULTIVIEWS')
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function checkAndAddLanguage($iso_code)
|
public static function checkAndAddLanguage($iso_code)
|
||||||
|
|||||||
+3
-18
@@ -124,12 +124,7 @@ class MetaCore extends ObjectModel
|
|||||||
if (!parent::update($nullValues))
|
if (!parent::update($nullValues))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return Tools::generateHtaccess(dirname(__FILE__).'/../.htaccess',
|
return Tools::generateHtaccess();
|
||||||
(int)Configuration::get('PS_REWRITING_SETTINGS'),
|
|
||||||
(int)Configuration::get('PS_HTACCESS_CACHE_CONTROL'),
|
|
||||||
'',
|
|
||||||
(int)Configuration::get('PS_HTACCESS_DISABLE_MULTIVIEWS')
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete()
|
public function delete()
|
||||||
@@ -137,12 +132,7 @@ class MetaCore extends ObjectModel
|
|||||||
if (!parent::delete())
|
if (!parent::delete())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return Tools::generateHtaccess(dirname(__FILE__).'/../.htaccess',
|
return Tools::generateHtaccess();
|
||||||
(int)Configuration::get('PS_REWRITING_SETTINGS'),
|
|
||||||
(int)Configuration::get('PS_HTACCESS_CACHE_CONTROL'),
|
|
||||||
'',
|
|
||||||
(int)Configuration::get('PS_HTACCESS_DISABLE_MULTIVIEWS')
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deleteSelection($selection)
|
public function deleteSelection($selection)
|
||||||
@@ -156,12 +146,7 @@ class MetaCore extends ObjectModel
|
|||||||
$result = $result AND $this->delete();
|
$result = $result AND $this->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Tools::generateHtaccess(dirname(__FILE__).'/../.htaccess',
|
return Tools::generateHtaccess();
|
||||||
(int)Configuration::get('PS_REWRITING_SETTINGS'),
|
|
||||||
(int)Configuration::get('PS_HTACCESS_CACHE_CONTROL'),
|
|
||||||
'',
|
|
||||||
(int)Configuration::get('PS_HTACCESS_DISABLE_MULTIVIEWS')
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getEquivalentUrlRewrite($new_id_lang, $id_lang, $url_rewrite)
|
public static function getEquivalentUrlRewrite($new_id_lang, $id_lang, $url_rewrite)
|
||||||
|
|||||||
+15
-2
@@ -1493,10 +1493,23 @@ class ToolsCore
|
|||||||
return self::getHttpHost();
|
return self::getHttpHost();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function generateHtaccess($path, $rewrite_settings, $cache_control, $specific = '', $disable_multiviews = false)
|
public static function generateHtaccess($path = null, $rewrite_settings = null, $cache_control = null, $specific = '', $disable_multiviews = null)
|
||||||
{
|
{
|
||||||
if (defined('PS_INSTALLATION_IN_PROGRESS'))
|
if (defined('PS_INSTALLATION_IN_PROGRESS'))
|
||||||
return;
|
return true;
|
||||||
|
|
||||||
|
if (!Configuration::get('PS_REWRITING_SETTINGS'))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Default values for parameters
|
||||||
|
if (is_null($path))
|
||||||
|
$path = _PS_ROOT_DIR_.'/.htaccess';
|
||||||
|
if (is_null($rewrite_settings))
|
||||||
|
$rewrite_settings = (int)Configuration::get('PS_REWRITING_SETTINGS');
|
||||||
|
if (is_null($cache_control))
|
||||||
|
$cache_control = (int)Configuration::get('PS_HTACCESS_CACHE_CONTROL');
|
||||||
|
if (is_null($disable_multiviews))
|
||||||
|
$disable_multiviews = (int)Configuration::get('PS_HTACCESS_DISABLE_MULTIVIEWS');
|
||||||
|
|
||||||
// Check current content of .htaccess and save all code outside of prestashop comments
|
// Check current content of .htaccess and save all code outside of prestashop comments
|
||||||
$specific_before = $specific_after = '';
|
$specific_before = $specific_after = '';
|
||||||
|
|||||||
@@ -31,9 +31,9 @@ class AdminGeneratorControllerCore extends AdminController
|
|||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->ht_file = dirname(__FILE__).'/../../.htaccess';
|
$this->ht_file = _PS_ROOT_DIR_.'/.htaccess';
|
||||||
$this->rb_file = dirname(__FILE__).'/../../robots.txt';
|
$this->rb_file = _PS_ROOT_DIR_.'/robots.txt';
|
||||||
$this->sm_file = dirname(__FILE__).'/../../sitemap.xml';
|
$this->sm_file = _PS_ROOT_DIR_.'/sitemap.xml';
|
||||||
$this->rb_data = $this->getRobotsContent();
|
$this->rb_data = $this->getRobotsContent();
|
||||||
|
|
||||||
return parent::__construct();
|
return parent::__construct();
|
||||||
@@ -68,11 +68,7 @@ class AdminGeneratorControllerCore extends AdminController
|
|||||||
Configuration::updateValue('PS_HTACCESS_CACHE_CONTROL', (int)Tools::getValue('PS_HTACCESS_CACHE_CONTROL'));
|
Configuration::updateValue('PS_HTACCESS_CACHE_CONTROL', (int)Tools::getValue('PS_HTACCESS_CACHE_CONTROL'));
|
||||||
Configuration::updateValue('PS_REWRITING_SETTINGS', (int)Tools::getValue('PS_REWRITING_SETTINGS'));
|
Configuration::updateValue('PS_REWRITING_SETTINGS', (int)Tools::getValue('PS_REWRITING_SETTINGS'));
|
||||||
Configuration::updateValue('PS_HTACCESS_DISABLE_MULTIVIEWS', (int)Tools::getValue('PS_HTACCESS_DISABLE_MULTIVIEWS'));
|
Configuration::updateValue('PS_HTACCESS_DISABLE_MULTIVIEWS', (int)Tools::getValue('PS_HTACCESS_DISABLE_MULTIVIEWS'));
|
||||||
if (Tools::generateHtaccess(
|
if (Tools::generateHtaccess($this->ht_file, null, null, '', Tools::getValue('PS_HTACCESS_DISABLE_MULTIVIEWS')))
|
||||||
$this->ht_file,
|
|
||||||
Configuration::get('PS_REWRITING_SETTINGS'),
|
|
||||||
Configuration::get('PS_HTACCESS_CACHE_CONTROL'), '',
|
|
||||||
Tools::getValue('PS_HTACCESS_DISABLE_MULTIVIEWS')))
|
|
||||||
Tools::redirectAdmin(self::$currentIndex.'&conf=4&token='.$this->token);
|
Tools::redirectAdmin(self::$currentIndex.'&conf=4&token='.$this->token);
|
||||||
$this->_errors[] = $this->l('Cannot write into file:').' <b>'.$this->ht_file.'</b><br />'.$this->l('Please check write permissions.');
|
$this->_errors[] = $this->l('Cannot write into file:').' <b>'.$this->ht_file.'</b><br />'.$this->l('Please check write permissions.');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -286,7 +286,7 @@ class AdminShopUrlControllerCore extends AdminController
|
|||||||
|
|
||||||
parent::processAdd($token);
|
parent::processAdd($token);
|
||||||
if (!$this->_errors)
|
if (!$this->_errors)
|
||||||
Tools::generateHtaccess(dirname(__FILE__).'/../../.htaccess', Configuration::get('PS_REWRITING_SETTINGS'), Configuration::get('PS_HTACCESS_CACHE_CONTROL'), '');
|
Tools::generateHtaccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function afterUpdate($object)
|
protected function afterUpdate($object)
|
||||||
|
|||||||
Reference in New Issue
Block a user