// Fix minor bug on shop urls #PSTEST-911
This commit is contained in:
+9
-12
@@ -1608,18 +1608,15 @@ class ToolsCore
|
||||
fwrite($write_fd, "\n# Disable Multiviews\nOptions -Multiviews\n\n");
|
||||
|
||||
fwrite($write_fd, "RewriteEngine on\n\n");
|
||||
if (Shop::isFeatureActive())
|
||||
{
|
||||
foreach ($domains as $domain => $list_uri)
|
||||
foreach ($list_uri as $uri)
|
||||
// Rewrite virtual multishop uri
|
||||
if ($uri['virtual'])
|
||||
{
|
||||
fwrite($write_fd, 'RewriteCond %{HTTP_HOST} ^'.$domain.'$'."\n");
|
||||
fwrite($write_fd, 'RewriteRule ^'.trim($uri['virtual'], '/').'/?$ '.$uri['physical'].$uri['virtual']."index.php [L,R]\n");
|
||||
fwrite($write_fd, 'RewriteRule ^'.ltrim($uri['virtual'], '/').'(.*) '.$uri['physical']."$1 [L]\n\n");
|
||||
}
|
||||
}
|
||||
foreach ($domains as $domain => $list_uri)
|
||||
foreach ($list_uri as $uri)
|
||||
// Rewrite virtual multishop uri
|
||||
if ($uri['virtual'])
|
||||
{
|
||||
fwrite($write_fd, 'RewriteCond %{HTTP_HOST} ^'.$domain.'$'."\n");
|
||||
fwrite($write_fd, 'RewriteRule ^'.trim($uri['virtual'], '/').'/?$ '.$uri['physical'].$uri['virtual']."index.php [L,R]\n");
|
||||
fwrite($write_fd, 'RewriteRule ^'.ltrim($uri['virtual'], '/').'(.*) '.$uri['physical']."$1 [L]\n\n");
|
||||
}
|
||||
|
||||
// Webservice
|
||||
fwrite($write_fd, 'RewriteRule ^api/?(.*)$ '."webservice/dispatcher.php?url=$1 [QSA,L]\n\n");
|
||||
|
||||
@@ -74,13 +74,18 @@ class ShopUrlCore extends ObjectModel
|
||||
return parent::getFields();
|
||||
}
|
||||
|
||||
public function getBaseURI()
|
||||
{
|
||||
return $this->physical_uri.$this->virtual_uri;
|
||||
}
|
||||
|
||||
public function getURL($ssl = false)
|
||||
{
|
||||
if (!$this->id)
|
||||
return;
|
||||
|
||||
$url = ($ssl) ? 'https://'.$this->domain_ssl : 'http://'.$this->domain;
|
||||
return $url.$this->physical_uri.$this->virtual_uri;
|
||||
return $url.$this->getBaseUri();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -276,30 +276,50 @@ class AdminShopUrlControllerCore extends AdminController
|
||||
return parent::postProcess();
|
||||
}
|
||||
|
||||
public function processSave($token)
|
||||
{
|
||||
$return = parent::processSave($token);
|
||||
if (!$this->errors)
|
||||
Tools::generateHtaccess();
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function processAdd($token)
|
||||
{
|
||||
$object = $this->loadObject(true);
|
||||
if ($object->id && Tools::getValue('main'))
|
||||
$object->setMain();
|
||||
$object = $this->loadObject(true);
|
||||
if ($object->id && Tools::getValue('main'))
|
||||
$object->setMain();
|
||||
|
||||
if ($object->main && !Tools::getValue('main'))
|
||||
$this->errors[] = Tools::displayError('You can\'t change a main url to a non main url, you have to set an other url as main url for selected shop');
|
||||
if ($object->main && !Tools::getValue('main'))
|
||||
$this->errors[] = Tools::displayError('You can\'t change a main url to a non main url, you have to set an other url as main url for selected shop');
|
||||
|
||||
if (($object->main || Tools::getValue('main')) && !Tools::getValue('active'))
|
||||
$this->errors[] = Tools::displayError('You can\'t disable a main url');
|
||||
if (($object->main || Tools::getValue('main')) && !Tools::getValue('active'))
|
||||
$this->errors[] = Tools::displayError('You can\'t disable a main url');
|
||||
|
||||
if ($object->canAddThisUrl(Tools::getValue('domain'), Tools::getValue('domain_ssl'), Tools::getValue('physical_uri'), Tools::getValue('virtual_uri')))
|
||||
$this->errors[] = Tools::displayError('A shop url that use this domain and uri already exists');
|
||||
if ($object->canAddThisUrl(Tools::getValue('domain'), Tools::getValue('domain_ssl'), Tools::getValue('physical_uri'), Tools::getValue('virtual_uri')))
|
||||
$this->errors[] = Tools::displayError('A shop url that use this domain and uri already exists');
|
||||
|
||||
parent::processAdd($token);
|
||||
if (!$this->errors)
|
||||
Tools::generateHtaccess();
|
||||
parent::processAdd($token);
|
||||
}
|
||||
|
||||
public function processUpdate($token)
|
||||
{
|
||||
$this->redirect_shop_url = false;
|
||||
$current_url = parse_url($_SERVER['REQUEST_URI']);
|
||||
if (trim(dirname(dirname($current_url['path'])), '/') == trim($this->object->getBaseURI(), '/'))
|
||||
$this->redirect_shop_url = true;
|
||||
|
||||
return parent::processUpdate($token);
|
||||
}
|
||||
|
||||
protected function afterUpdate($object)
|
||||
{
|
||||
if (Tools::getValue('main'))
|
||||
$object->setMain();
|
||||
|
||||
if ($this->redirect_shop_url)
|
||||
$this->redirect_after = $object->getBaseURI().basename(_PS_ADMIN_DIR_).'/'.$this->context->link->getAdminLink('AdminShopUrl');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user