Skip to content

Commit 5f8ff27

Browse files
committed
Update copyright and target blank #8
1 parent 38335f4 commit 5f8ff27

File tree

26 files changed

+410
-136
lines changed

26 files changed

+410
-136
lines changed

Api/MenuLinkManagementInterface.php

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
<?php
22
/**
3-
* A Magento 2 module named DevBera/CmsLinkToMenu
4-
* Copyright (C) 2019 Copyright 2019 © amitbera.com. All Rights Reserved
3+
* DevBera
54
*
6-
* This file included in DevBera/CmsLinkToMenu is licensed under OSL 3.0
7-
*
8-
* http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9-
* Please see LICENSE.txt for the full text of the OSL 3.0 license
5+
* @category DevBera
6+
* @package DevBera_CmsLinkToMenu
7+
* @author Amit Bera (dev.amitbera@gmail.com)
8+
* @copyright Copyright (c) 2020 Amit Bera (https://www.amitbera.com/)
9+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
1010
*/
1111

12-
1312
namespace DevBera\CmsLinkToMenu\Api;
1413

1514
interface MenuLinkManagementInterface
@@ -20,4 +19,14 @@ interface MenuLinkManagementInterface
2019
* @return void
2120
*/
2221
public function addLinks($subject, $position = 'left');
22+
23+
/**
24+
* @return string []
25+
*/
26+
public function getTargetBlanksLinks();
27+
/**
28+
* get open tab
29+
* @return int
30+
*/
31+
public function isOpenInTab();
2332
}

Block/Adminhtml/Form/Field/CmsPageCustomLinker.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<?php
2-
32
/**
4-
* A Magento 2 module named DevBera/CmsLinkToMenu
5-
* Copyright (C) 2019 Copyright 2019 © amitbera.com. All Rights Reserved
6-
*
7-
* This file included in DevBera/CmsLinkToMenu is licensed under OSL 3.0
3+
* DevBera
84
*
9-
* http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
10-
* Please see LICENSE.txt for the full text of the OSL 3.0 license
5+
* @category DevBera
6+
* @package DevBera_CmsLinkToMenu
7+
* @author Amit Bera (dev.amitbera@gmail.com)
8+
* @copyright Copyright (c) 2020 Amit Bera (https://www.amitbera.com/)
9+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
1110
*/
11+
1212
namespace DevBera\CmsLinkToMenu\Block\Adminhtml\Form\Field;
1313

1414
use Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray;

Block/Adminhtml/Form/Field/CmsPagesList.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
<?php
2-
32
/**
4-
* A Magento 2 module named DevBera/CmsLinkToMenu
5-
* Copyright (C) 2019 Copyright 2019 © amitbera.com. All Rights Reserved
6-
*
7-
* This file included in DevBera/CmsLinkToMenu is licensed under OSL 3.0
3+
* DevBera
84
*
9-
* http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
10-
* Please see LICENSE.txt for the full text of the OSL 3.0 license
5+
* @category DevBera
6+
* @package DevBera_CmsLinkToMenu
7+
* @author Amit Bera (dev.amitbera@gmail.com)
8+
* @copyright Copyright (c) 2020 Amit Bera (https://www.amitbera.com/)
9+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
1110
*/
1211

1312
namespace DevBera\CmsLinkToMenu\Block\Adminhtml\Form\Field;
@@ -29,7 +28,7 @@ public function __construct(
2928
parent::__construct($context, $data);
3029
$this->cmsPages = $cmsPages;
3130
}
32-
31+
3332
private function getCmsPagesRenderer()
3433
{
3534
if (!$this->cmsPagesRenderer) {

Block/Adminhtml/Form/Field/LinkTypes.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
<?php
2-
32
/**
4-
* A Magento 2 module named DevBera/CmsLinkToMenu
5-
* Copyright (C) 2019 Copyright amitbera.com. All Rights Reserved
6-
*
7-
* This file included in DevBera/CmsLinkToMenu is licensed under OSL 3.0
3+
* DevBera
84
*
9-
* http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
10-
* Please see LICENSE.txt for the full text of the OSL 3.0 license
5+
* @category DevBera
6+
* @package DevBera_CmsLinkToMenu
7+
* @author Amit Bera (dev.amitbera@gmail.com)
8+
* @copyright Copyright (c) 2020 Amit Bera (https://www.amitbera.com/)
9+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
1110
*/
1211

1312
namespace DevBera\CmsLinkToMenu\Block\Adminhtml\Form\Field;

Block/Adminhtml/Form/Field/Pages.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
<?php
2-
32
/**
4-
* A Magento 2 module named DevBera/CmsLinkToMenu
5-
* Copyright (C) 2019 Copyright 2019 © amitbera.com. All Rights Reserved
6-
*
7-
* This file included in DevBera/CmsLinkToMenu is licensed under OSL 3.0
3+
* DevBera
84
*
9-
* http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
10-
* Please see LICENSE.txt for the full text of the OSL 3.0 license
5+
* @category DevBera
6+
* @package DevBera_CmsLinkToMenu
7+
* @author Amit Bera (dev.amitbera@gmail.com)
8+
* @copyright Copyright (c) 2020 Amit Bera (https://www.amitbera.com/)
9+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
1110
*/
1211

1312

Block/Adminhtml/Form/Field/StaticLinks.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<?php
2-
32
/**
4-
* A Magento 2 module named DevBera/CmsLinkToMenu
5-
* Copyright (C) 2019 Copyright 2019 © amitbera.com. All Rights Reserved
6-
*
7-
* This file included in DevBera/CmsLinkToMenu is licensed under OSL 3.0
3+
* DevBera
84
*
9-
* http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
10-
* Please see LICENSE.txt for the full text of the OSL 3.0 license
5+
* @category DevBera
6+
* @package DevBera_CmsLinkToMenu
7+
* @author Amit Bera (dev.amitbera@gmail.com)
8+
* @copyright Copyright (c) 2020 Amit Bera (https://www.amitbera.com/)
9+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
1110
*/
11+
1212
namespace DevBera\CmsLinkToMenu\Block\Adminhtml\Form\Field;
1313

1414
use Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray;

Block/Adminhtml/System/Config/Form/Fieldset/Support.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
<?php
2+
/**
3+
* DevBera
4+
*
5+
* @category DevBera
6+
* @package DevBera_CmsLinkToMenu
7+
* @author Amit Bera (dev.amitbera@gmail.com)
8+
* @copyright Copyright (c) 2020 Amit Bera (https://www.amitbera.com/)
9+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
10+
*/
211

312
namespace DevBera\CmsLinkToMenu\Block\Adminhtml\System\Config\Form\Fieldset;
413

Block/Html/Topmenu/Js.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
namespace DevBera\CmsLinkToMenu\Block\Html\Topmenu;
3+
4+
use Magento\Framework\Serialize\Serializer\Json;
5+
use Magento\Framework\View\Element\Template;
6+
use Magento\Framework\View\Element\Template\Context;
7+
use DevBera\CmsLinkToMenu\Api\MenuLinkManagementInterface;
8+
9+
class Js extends Template
10+
{
11+
/**
12+
* @var MenuLinkManagementInterface
13+
*/
14+
private $menuLinkManagement;
15+
/**
16+
* @var Json
17+
*/
18+
private $jsonEncoder;
19+
20+
public function __construct(
21+
Context $context,
22+
MenuLinkManagementInterface $menuLinkManagement,
23+
Json $jsonEncoder,
24+
array $data = []
25+
) {
26+
parent::__construct($context, $data);
27+
$this->menuLinkManagement = $menuLinkManagement;
28+
$this->jsonEncoder = $jsonEncoder;
29+
}
30+
31+
/**
32+
* Get List of External Link list
33+
*
34+
* @return bool|false|string
35+
*/
36+
public function getJsonLinks()
37+
{
38+
return $this->jsonEncoder->serialize($this->menuLinkManagement->getTargetBlanksLinks());
39+
}
40+
41+
/**
42+
* Target Blank flag
43+
* @return int
44+
*/
45+
public function isOpenInNewTab()
46+
{
47+
return $this->menuLinkManagement->isOpenInTab();
48+
}
49+
}

Model/Config/Source/LinkTypes.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
<?php
2-
32
/**
4-
* A Magento 2 module named DevBera/CmsLinkToMenu
5-
* Copyright (C) 2019 Copyright 2019 © amitbera.com. All Rights Reserved
6-
*
7-
* This file included in DevBera/CmsLinkToMenu is licensed under OSL 3.0
3+
* DevBera
84
*
9-
* http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
10-
* Please see LICENSE.txt for the full text of the OSL 3.0 license
5+
* @category DevBera
6+
* @package DevBera_CmsLinkToMenu
7+
* @author Amit Bera (dev.amitbera@gmail.com)
8+
* @copyright Copyright (c) 2020 Amit Bera (https://www.amitbera.com/)
9+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
1110
*/
1211

1312
namespace DevBera\CmsLinkToMenu\Model\Config\Source;

Model/Config/Source/Pages.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
<?php
2-
32
/**
4-
* A Magento 2 module named DevBera/CmsLinkToMenu
5-
* Copyright (C) 2019 Copyright 2019 © amitbera.com. All Rights Reserved
6-
*
7-
* This file included in DevBera/CmsLinkToMenu is licensed under OSL 3.0
3+
* DevBera
84
*
9-
* http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
10-
* Please see LICENSE.txt for the full text of the OSL 3.0 license
5+
* @category DevBera
6+
* @package DevBera_CmsLinkToMenu
7+
* @author Amit Bera (dev.amitbera@gmail.com)
8+
* @copyright Copyright (c) 2020 Amit Bera (https://www.amitbera.com/)
9+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
1110
*/
1211

1312
namespace DevBera\CmsLinkToMenu\Model\Config\Source;

Model/LinkTypes.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
/**
3+
* DevBera
4+
*
5+
* @category DevBera
6+
* @package DevBera_CmsLinkToMenu
7+
* @author Amit Bera (dev.amitbera@gmail.com)
8+
* @copyright Copyright (c) 2020 Amit Bera (https://www.amitbera.com/)
9+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
10+
*/
11+
12+
namespace DevBera\CmsLinkToMenu\Model;
13+
14+
class LinkTypes
15+
{
16+
const TYPE_LEFT = 'left';
17+
const TYPE_RIGHT = 'right';
18+
}

Model/MenuLinkManagement.php

Lines changed: 69 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
<?php
2-
32
/**
4-
* A Magento 2 module named DevBera/CmsLinkToMenu
5-
* Copyright (C) 2019 Copyright 2019 © amitbera.com. All Rights Reserved
6-
*
7-
* This file included in DevBera/CmsLinkToMenu is licensed under OSL 3.0
3+
* DevBera
84
*
9-
* http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
10-
* Please see LICENSE.txt for the full text of the OSL 3.0 license
5+
* @category DevBera
6+
* @package DevBera_CmsLinkToMenu
7+
* @author Amit Bera (dev.amitbera@gmail.com)
8+
* @copyright Copyright (c) 2020 Amit Bera (https://www.amitbera.com/)
9+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
1110
*/
1211

1312
namespace DevBera\CmsLinkToMenu\Model;
@@ -23,6 +22,7 @@
2322
use Magento\Framework\UrlInterface;
2423
use Magento\Store\Model\ScopeInterface;
2524
use Magento\Store\Model\StoreManagerInterface;
25+
use DevBera\CmsLinkToMenu\Model\LinkTypes;
2626

2727
class MenuLinkManagement implements MenuLinkManagementInterface
2828
{
@@ -99,11 +99,7 @@ public function __construct(
9999

100100
public function addLinks($subject, $position = 'left')
101101
{
102-
$fieldValue = $this->scopeConfig->getValue(
103-
self::XML_PATH_PRE_CMS_CUSTOM_LINKS . '/' . $position,
104-
ScopeInterface::SCOPE_STORE
105-
);
106-
102+
$fieldValue = $this->getMenuConfigValue($position);
107103
$menuItems = $this->getLinksWithSortOrder($fieldValue);
108104

109105
if (!empty($menuItems) && is_array($menuItems)) {
@@ -282,4 +278,65 @@ private function getCmsPageUrl($page)
282278
}
283279
return $this->urlBuilder->getUrl(null, ['_direct' => $page->getIdentifier()]);
284280
}
281+
282+
private function getMenuConfigValue($position = 'left')
283+
{
284+
return $this->scopeConfig->getValue(
285+
self::XML_PATH_PRE_CMS_CUSTOM_LINKS . '/' . $position,
286+
ScopeInterface::SCOPE_STORE
287+
);
288+
}
289+
290+
/**
291+
* @return array
292+
*/
293+
public function getTargetBlanksLinks()
294+
{
295+
$leftMenuItems = [];
296+
$rightMenuItems = [];
297+
298+
$leftMenuItems = $this->getLinksWithSortOrder(
299+
$this->getMenuConfigValue(LinkTypes::TYPE_LEFT)
300+
);
301+
$rightMenuItems = $this->getLinksWithSortOrder(
302+
$this->getMenuConfigValue(LinkTypes::TYPE_RIGHT)
303+
);
304+
$leftMenuItems = (!empty($leftMenuItems) && is_array($leftMenuItems))?
305+
$leftMenuItems:[];
306+
307+
$rightMenuItems = (!empty($rightMenuItems) && is_array($rightMenuItems))?
308+
$rightMenuItems:[];
309+
$result = [];
310+
$result = $this->getOnlyLinks(array_merge($leftMenuItems, $rightMenuItems));
311+
312+
return $result;
313+
}
314+
315+
/**
316+
* @param array $links
317+
* @return array
318+
*
319+
*/
320+
private function getOnlyLinks($links = [])
321+
{
322+
$result = [];
323+
foreach ($links as $link) {
324+
if ($link['link_type'] == 3) {
325+
$result[] = $link;
326+
}
327+
}
328+
return $result;
329+
}
330+
331+
/**
332+
* get open tab
333+
* @return int
334+
*/
335+
public function isOpenInTab()
336+
{
337+
return (int) $this->scopeConfig->isSetFlag(
338+
self::XML_PATH_PRE_CMS_CUSTOM_LINKS . '/open_in_new_tab',
339+
ScopeInterface::SCOPE_STORE
340+
);
341+
}
285342
}

0 commit comments

Comments
 (0)