Skip to content

Commit f2e2bad

Browse files
committed
Merge branch 'develop' into main
2 parents a155cbd + 98a707a commit f2e2bad

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+3072
-553
lines changed

Api/Data/OpenGraphInterface.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
/**
3+
* @author: Pasquale Convertini <pasqualeconvertini95@gmail.com>
4+
* @github: @Pasquale95
5+
*
6+
* This file is subject to the terms and conditions defined in
7+
* file 'LICENSE', which is part of this source code package.
8+
*/
9+
10+
namespace Paskel\Seo\Api\Data;
11+
12+
/**
13+
* Interface OpenGraphInterface
14+
* @package Paskel\Seo\Api\Data
15+
*/
16+
interface OpenGraphInterface extends SocialMarkupInterface
17+
{
18+
/**
19+
* Constants for the html tags used to
20+
* crate an Open Graph meta tag
21+
*/
22+
const TAG_PROPERTY = "property";
23+
const TAG_CONTENT = "content";
24+
25+
/**
26+
* Constants defined for keys of array.
27+
* OpenGraph based.
28+
*/
29+
const TYPE = "og:type";
30+
const LOCALE = "og:locale";
31+
const SITE = "og:site_name";
32+
const URL = "og:url";
33+
const TITLE = "og:title";
34+
const DESCRIPTION = "og:description";
35+
const IMAGE = "og:image";
36+
37+
/**
38+
* Constants for those values that don't change among the graphql calls
39+
*/
40+
const TYPE_VALUE = "website";
41+
const SITENAME_VALUE = "example";
42+
}

Api/Data/SchemaOrgInterface.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
/**
3+
* @author: Pasquale Convertini <pasqualeconvertini95@gmail.com>
4+
* @github: @Pasquale95
5+
*
6+
* This file is subject to the terms and conditions defined in
7+
* file 'LICENSE', which is part of this source code package.
8+
*/
9+
10+
namespace Paskel\Seo\Api\Data;
11+
12+
/**
13+
* Interface SchemaOrgInterface
14+
* @package Paskel\Seo\Api\Data
15+
*/
16+
interface SchemaOrgInterface
17+
{
18+
const SCHEMA_CONTEXT = "https://schema.org";
19+
20+
/**
21+
* Returns the schema type.
22+
*
23+
* @return string
24+
*/
25+
public function getType();
26+
27+
/**
28+
* Populate the schema.org script.
29+
*
30+
* @return string
31+
*/
32+
public function getScript();
33+
}

Api/Data/SocialMarkupInterface.php

Lines changed: 4 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,6 @@
1515
*/
1616
interface SocialMarkupInterface
1717
{
18-
/**
19-
* Constants for the Resolver array
20-
*/
21-
const PROPERTY = "property";
22-
const CONTENT = "content";
23-
24-
/**
25-
* Constants defined for keys of array.
26-
* OpenGraph based.
27-
*/
28-
const TYPE = "og:type";
29-
const LOCALE = "og:locale";
30-
const SITENAME = "og:site_name";
31-
const URL = "og:url";
32-
const TITLE = "og:title";
33-
const DESCRIPTION = "og:description";
34-
const IMAGE = "og:image";
35-
3618
/**
3719
* Name for the db field where to store the
3820
* image url.
@@ -45,43 +27,9 @@ interface SocialMarkupInterface
4527
const PLACEHOLDER_FOLDER = "seo/socialMarkup/placeholder";
4628

4729
/**
48-
* Constants for those values that don't change among the graphql calls
49-
*/
50-
const TYPE_VALUE = "website";
51-
const SITENAME_VALUE = "example";
52-
53-
/**
54-
* @param $type
55-
*/
56-
public function setType($type);
57-
58-
/**
59-
* @param $locale
60-
*/
61-
public function setLocale($locale);
62-
63-
/**
64-
* @param $sitename
65-
*/
66-
public function setSitename($sitename);
67-
68-
/**
69-
* @param $url
70-
*/
71-
public function setUrl($url);
72-
73-
/**
74-
* @param $title
75-
*/
76-
public function setTitle($title);
77-
78-
/**
79-
* @param $description
80-
*/
81-
public function setDescription($description);
82-
83-
/**
84-
* @param $image
30+
* @param $item
31+
* @param $store
32+
* @return array
8533
*/
86-
public function setImage($image);
34+
public function getTags($item, $store);
8735
}

Api/Data/TwitterCardInterface.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
/**
3+
* @author: Pasquale Convertini <pasqualeconvertini95@gmail.com>
4+
* @github: @Pasquale95
5+
*
6+
* This file is subject to the terms and conditions defined in
7+
* file 'LICENSE', which is part of this source code package.
8+
*/
9+
10+
namespace Paskel\Seo\Api\Data;
11+
12+
/**
13+
* Interface TwitterCardInterface
14+
* @package Paskel\Seo\Api\Data
15+
*/
16+
interface TwitterCardInterface extends SocialMarkupInterface
17+
{
18+
/**
19+
* Constants for the html tags used to
20+
* crate an Open Graph meta tag
21+
*/
22+
const TAG_NAME = "name";
23+
const TAG_CONTENT = "content";
24+
25+
/**
26+
* Constants defined for keys of array.
27+
* OpenGraph based.
28+
*/
29+
const CARD = "twitter:card";
30+
const SITE = "twitter:site";
31+
const TITLE = "twitter:title";
32+
const DESCRIPTION = "twitter:description";
33+
const IMAGE = "twitter:image";
34+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?php
2+
/**
3+
* @author: Pasquale Convertini <pasqualeconvertini95@gmail.com>
4+
* @github: @Pasquale95
5+
*
6+
* This file is subject to the terms and conditions defined in
7+
* file 'LICENSE', which is part of this source code package.
8+
*/
9+
10+
namespace Paskel\Seo\Block\Adminhtml\System\Config\Form\Field\Column;
11+
12+
use Magento\Framework\View\Element\Html\Select;
13+
use Magento\Framework\View\Element\Context;
14+
use Magento\Directory\Model\Config\Source\Country;
15+
16+
/**
17+
* Class CountryColumn
18+
* @package Paskel\Seo\Block\Adminhtml\System\Config\Form\Field\Column
19+
*/
20+
class CountryColumn extends Select
21+
{
22+
/**
23+
* @var Country
24+
*/
25+
protected $optionsProvider;
26+
27+
/**
28+
* CountryColumn constructor.
29+
* @param Context $context
30+
* @param Country $optionsProvider
31+
* @param array $data
32+
*/
33+
public function __construct(
34+
Context $context,
35+
Country $optionsProvider,
36+
array $data = []
37+
) {
38+
$this->optionsProvider = $optionsProvider;
39+
parent::__construct($context, $data);
40+
}
41+
42+
/**
43+
* Set "name" for <select> element
44+
*
45+
* @param string $value
46+
* @return $this
47+
*/
48+
public function setInputName($value)
49+
{
50+
return $this->setName($value);
51+
}
52+
53+
/**
54+
* Set "id" for <select> element
55+
*
56+
* @param $value
57+
* @return $this
58+
*/
59+
public function setInputId($value)
60+
{
61+
return $this->setId($value);
62+
}
63+
64+
/**
65+
* Render block HTML
66+
*
67+
* @return string
68+
*/
69+
public function _toHtml()
70+
{
71+
if (!$this->getOptions()) {
72+
$this->setOptions($this->getSourceOptions());
73+
}
74+
return parent::_toHtml();
75+
}
76+
77+
/**
78+
* Get option for select
79+
*
80+
* @return array
81+
*/
82+
private function getSourceOptions()
83+
{
84+
return $this->optionsProvider->toOptionArray();
85+
}
86+
}
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
<?php
2+
/**
3+
* @author: Pasquale Convertini <pasqualeconvertini95@gmail.com>
4+
* @github: @Pasquale95
5+
*
6+
* This file is subject to the terms and conditions defined in
7+
* file 'LICENSE', which is part of this source code package.
8+
*/
9+
10+
namespace Paskel\Seo\Block\Adminhtml\System\Config\Form\Field\Column;
11+
12+
use Magento\Framework\View\Element\Html\Select;
13+
use Magento\Framework\View\Element\Context;
14+
use Magento\Config\Model\Config\Source\Locale;
15+
16+
/**
17+
* Class LanguageColumn
18+
* @package Paskel\Seo\Block\Adminhtml\System\Config\Form\Field\Column
19+
*/
20+
class LanguageColumn extends Select
21+
{
22+
/**
23+
* @var Locale
24+
*/
25+
protected $optionsProvider;
26+
27+
/**
28+
* LocaleColumn constructor.
29+
* @param Context $context
30+
* @param Locale $optionsProvider
31+
* @param array $data
32+
*/
33+
public function __construct(
34+
Context $context,
35+
Locale $optionsProvider,
36+
array $data = []
37+
) {
38+
$this->optionsProvider = $optionsProvider;
39+
parent::__construct($context, $data);
40+
}
41+
42+
/**
43+
* Set "name" for <select> element
44+
*
45+
* @param string $value
46+
* @return $this
47+
*/
48+
public function setInputName($value)
49+
{
50+
return $this->setName($value);
51+
}
52+
53+
/**
54+
* Set "id" for <select> element
55+
*
56+
* @param $value
57+
* @return $this
58+
*/
59+
public function setInputId($value)
60+
{
61+
return $this->setId($value);
62+
}
63+
64+
/**
65+
* Render block HTML
66+
*
67+
* @return string
68+
*/
69+
public function _toHtml()
70+
{
71+
if (!$this->getOptions()) {
72+
$this->setOptions($this->getSourceOptions());
73+
}
74+
return parent::_toHtml();
75+
}
76+
77+
/**
78+
* Get option for select
79+
*
80+
* @return array
81+
*/
82+
private function getSourceOptions()
83+
{
84+
$locales = $this->optionsProvider->toOptionArray();
85+
$languages = [];
86+
foreach ($locales as $locale) {
87+
$value = $this->removeCountryCode($locale['value']);
88+
$label = $this->removeCountryName($locale['label']);
89+
if (!array_key_exists($value,$languages)) {
90+
$languages[$value] = $label;
91+
}
92+
}
93+
return $languages;
94+
}
95+
96+
/**
97+
* Removes the ending part of the locale, which corresponds
98+
* to the country code.
99+
*
100+
* @param $value
101+
* @return string
102+
*/
103+
protected function removeCountryCode($value) {
104+
return preg_replace("/_.*$/", "", $value);
105+
}
106+
107+
/**
108+
* Removes the countries between round brackets.
109+
*
110+
* @param $value
111+
* @return string
112+
*/
113+
protected function removeCountryName($value) {
114+
return preg_replace("/\(.*\)/", "", $value);
115+
}
116+
}

0 commit comments

Comments
 (0)