// 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, "\n# Disable Multiviews\nOptions -Multiviews\n\n");
|
||||||
|
|
||||||
fwrite($write_fd, "RewriteEngine on\n\n");
|
fwrite($write_fd, "RewriteEngine on\n\n");
|
||||||
if (Shop::isFeatureActive())
|
foreach ($domains as $domain => $list_uri)
|
||||||
{
|
foreach ($list_uri as $uri)
|
||||||
foreach ($domains as $domain => $list_uri)
|
// Rewrite virtual multishop uri
|
||||||
foreach ($list_uri as $uri)
|
if ($uri['virtual'])
|
||||||
// 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, 'RewriteCond %{HTTP_HOST} ^'.$domain.'$'."\n");
|
fwrite($write_fd, 'RewriteRule ^'.ltrim($uri['virtual'], '/').'(.*) '.$uri['physical']."$1 [L]\n\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
|
// Webservice
|
||||||
fwrite($write_fd, 'RewriteRule ^api/?(.*)$ '."webservice/dispatcher.php?url=$1 [QSA,L]\n\n");
|
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();
|
return parent::getFields();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getBaseURI()
|
||||||
|
{
|
||||||
|
return $this->physical_uri.$this->virtual_uri;
|
||||||
|
}
|
||||||
|
|
||||||
public function getURL($ssl = false)
|
public function getURL($ssl = false)
|
||||||
{
|
{
|
||||||
if (!$this->id)
|
if (!$this->id)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$url = ($ssl) ? 'https://'.$this->domain_ssl : 'http://'.$this->domain;
|
$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();
|
return parent::postProcess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function processSave($token)
|
||||||
|
{
|
||||||
|
$return = parent::processSave($token);
|
||||||
|
if (!$this->errors)
|
||||||
|
Tools::generateHtaccess();
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
public function processAdd($token)
|
public function processAdd($token)
|
||||||
{
|
{
|
||||||
$object = $this->loadObject(true);
|
$object = $this->loadObject(true);
|
||||||
if ($object->id && Tools::getValue('main'))
|
if ($object->id && Tools::getValue('main'))
|
||||||
$object->setMain();
|
$object->setMain();
|
||||||
|
|
||||||
if ($object->main && !Tools::getValue('main'))
|
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');
|
$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'))
|
if (($object->main || Tools::getValue('main')) && !Tools::getValue('active'))
|
||||||
$this->errors[] = Tools::displayError('You can\'t disable a main url');
|
$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')))
|
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');
|
$this->errors[] = Tools::displayError('A shop url that use this domain and uri already exists');
|
||||||
|
|
||||||
parent::processAdd($token);
|
parent::processAdd($token);
|
||||||
if (!$this->errors)
|
}
|
||||||
Tools::generateHtaccess();
|
|
||||||
|
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)
|
protected function afterUpdate($object)
|
||||||
{
|
{
|
||||||
if (Tools::getValue('main'))
|
if (Tools::getValue('main'))
|
||||||
$object->setMain();
|
$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