Merge pull request #9 from AntoineMille/BOOM-290
Fix url insert on the top menu
This commit is contained in:
@@ -1072,6 +1072,7 @@ class Ps_MainMenu extends Module implements WidgetInterface
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->trans('Link', array(), 'Admin.Global'),
|
||||
'placeholder' => 'http://www.example.com',
|
||||
'name' => 'link',
|
||||
'lang' => true,
|
||||
),
|
||||
|
||||
@@ -67,6 +67,16 @@ class Ps_MenuTopLinks
|
||||
return array('link' => $link, 'label' => $label, 'new_window' => $new_window);
|
||||
}
|
||||
|
||||
public static function updateUrl($link)
|
||||
{
|
||||
for($i = 1; $i <= count($link); $i++) {
|
||||
if (substr($link[$i], 0, 7) !== "http://" && substr($link[$i], 0, 8) !== "https://") {
|
||||
$link[$i] = "http://" . $link[$i];
|
||||
}
|
||||
}
|
||||
return $link;
|
||||
}
|
||||
|
||||
public static function add($link, $label, $newWindow = 0, $id_shop)
|
||||
{
|
||||
if (!is_array($label)) {
|
||||
@@ -76,6 +86,7 @@ class Ps_MenuTopLinks
|
||||
return false;
|
||||
}
|
||||
|
||||
$link = self::updateUrl($link);
|
||||
Db::getInstance()->insert(
|
||||
'linksmenutop',
|
||||
array(
|
||||
@@ -112,6 +123,7 @@ class Ps_MenuTopLinks
|
||||
return false;
|
||||
}
|
||||
|
||||
$link = self::updateUrl($link);
|
||||
Db::getInstance()->update(
|
||||
'linksmenutop',
|
||||
array(
|
||||
@@ -134,7 +146,6 @@ class Ps_MenuTopLinks
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function remove($id_linksmenutop, $id_shop)
|
||||
{
|
||||
$result = true;
|
||||
|
||||
Reference in New Issue
Block a user