-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
47 changed files
with
3,072 additions
and
553 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
/** | ||
* @author: Pasquale Convertini <[email protected]> | ||
* @github: @Pasquale95 | ||
* | ||
* This file is subject to the terms and conditions defined in | ||
* file 'LICENSE', which is part of this source code package. | ||
*/ | ||
|
||
namespace Paskel\Seo\Api\Data; | ||
|
||
/** | ||
* Interface OpenGraphInterface | ||
* @package Paskel\Seo\Api\Data | ||
*/ | ||
interface OpenGraphInterface extends SocialMarkupInterface | ||
{ | ||
/** | ||
* Constants for the html tags used to | ||
* crate an Open Graph meta tag | ||
*/ | ||
const TAG_PROPERTY = "property"; | ||
const TAG_CONTENT = "content"; | ||
|
||
/** | ||
* Constants defined for keys of array. | ||
* OpenGraph based. | ||
*/ | ||
const TYPE = "og:type"; | ||
const LOCALE = "og:locale"; | ||
const SITE = "og:site_name"; | ||
const URL = "og:url"; | ||
const TITLE = "og:title"; | ||
const DESCRIPTION = "og:description"; | ||
const IMAGE = "og:image"; | ||
|
||
/** | ||
* Constants for those values that don't change among the graphql calls | ||
*/ | ||
const TYPE_VALUE = "website"; | ||
const SITENAME_VALUE = "example"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
/** | ||
* @author: Pasquale Convertini <[email protected]> | ||
* @github: @Pasquale95 | ||
* | ||
* This file is subject to the terms and conditions defined in | ||
* file 'LICENSE', which is part of this source code package. | ||
*/ | ||
|
||
namespace Paskel\Seo\Api\Data; | ||
|
||
/** | ||
* Interface SchemaOrgInterface | ||
* @package Paskel\Seo\Api\Data | ||
*/ | ||
interface SchemaOrgInterface | ||
{ | ||
const SCHEMA_CONTEXT = "https://schema.org"; | ||
|
||
/** | ||
* Returns the schema type. | ||
* | ||
* @return string | ||
*/ | ||
public function getType(); | ||
|
||
/** | ||
* Populate the schema.org script. | ||
* | ||
* @return string | ||
*/ | ||
public function getScript(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
/** | ||
* @author: Pasquale Convertini <[email protected]> | ||
* @github: @Pasquale95 | ||
* | ||
* This file is subject to the terms and conditions defined in | ||
* file 'LICENSE', which is part of this source code package. | ||
*/ | ||
|
||
namespace Paskel\Seo\Api\Data; | ||
|
||
/** | ||
* Interface TwitterCardInterface | ||
* @package Paskel\Seo\Api\Data | ||
*/ | ||
interface TwitterCardInterface extends SocialMarkupInterface | ||
{ | ||
/** | ||
* Constants for the html tags used to | ||
* crate an Open Graph meta tag | ||
*/ | ||
const TAG_NAME = "name"; | ||
const TAG_CONTENT = "content"; | ||
|
||
/** | ||
* Constants defined for keys of array. | ||
* OpenGraph based. | ||
*/ | ||
const CARD = "twitter:card"; | ||
const SITE = "twitter:site"; | ||
const TITLE = "twitter:title"; | ||
const DESCRIPTION = "twitter:description"; | ||
const IMAGE = "twitter:image"; | ||
} |
86 changes: 86 additions & 0 deletions
86
Block/Adminhtml/System/Config/Form/Field/Column/CountryColumn.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
/** | ||
* @author: Pasquale Convertini <[email protected]> | ||
* @github: @Pasquale95 | ||
* | ||
* This file is subject to the terms and conditions defined in | ||
* file 'LICENSE', which is part of this source code package. | ||
*/ | ||
|
||
namespace Paskel\Seo\Block\Adminhtml\System\Config\Form\Field\Column; | ||
|
||
use Magento\Framework\View\Element\Html\Select; | ||
use Magento\Framework\View\Element\Context; | ||
use Magento\Directory\Model\Config\Source\Country; | ||
|
||
/** | ||
* Class CountryColumn | ||
* @package Paskel\Seo\Block\Adminhtml\System\Config\Form\Field\Column | ||
*/ | ||
class CountryColumn extends Select | ||
{ | ||
/** | ||
* @var Country | ||
*/ | ||
protected $optionsProvider; | ||
|
||
/** | ||
* CountryColumn constructor. | ||
* @param Context $context | ||
* @param Country $optionsProvider | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
Context $context, | ||
Country $optionsProvider, | ||
array $data = [] | ||
) { | ||
$this->optionsProvider = $optionsProvider; | ||
parent::__construct($context, $data); | ||
} | ||
|
||
/** | ||
* Set "name" for <select> element | ||
* | ||
* @param string $value | ||
* @return $this | ||
*/ | ||
public function setInputName($value) | ||
{ | ||
return $this->setName($value); | ||
} | ||
|
||
/** | ||
* Set "id" for <select> element | ||
* | ||
* @param $value | ||
* @return $this | ||
*/ | ||
public function setInputId($value) | ||
{ | ||
return $this->setId($value); | ||
} | ||
|
||
/** | ||
* Render block HTML | ||
* | ||
* @return string | ||
*/ | ||
public function _toHtml() | ||
{ | ||
if (!$this->getOptions()) { | ||
$this->setOptions($this->getSourceOptions()); | ||
} | ||
return parent::_toHtml(); | ||
} | ||
|
||
/** | ||
* Get option for select | ||
* | ||
* @return array | ||
*/ | ||
private function getSourceOptions() | ||
{ | ||
return $this->optionsProvider->toOptionArray(); | ||
} | ||
} |
116 changes: 116 additions & 0 deletions
116
Block/Adminhtml/System/Config/Form/Field/Column/LanguageColumn.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
<?php | ||
/** | ||
* @author: Pasquale Convertini <[email protected]> | ||
* @github: @Pasquale95 | ||
* | ||
* This file is subject to the terms and conditions defined in | ||
* file 'LICENSE', which is part of this source code package. | ||
*/ | ||
|
||
namespace Paskel\Seo\Block\Adminhtml\System\Config\Form\Field\Column; | ||
|
||
use Magento\Framework\View\Element\Html\Select; | ||
use Magento\Framework\View\Element\Context; | ||
use Magento\Config\Model\Config\Source\Locale; | ||
|
||
/** | ||
* Class LanguageColumn | ||
* @package Paskel\Seo\Block\Adminhtml\System\Config\Form\Field\Column | ||
*/ | ||
class LanguageColumn extends Select | ||
{ | ||
/** | ||
* @var Locale | ||
*/ | ||
protected $optionsProvider; | ||
|
||
/** | ||
* LocaleColumn constructor. | ||
* @param Context $context | ||
* @param Locale $optionsProvider | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
Context $context, | ||
Locale $optionsProvider, | ||
array $data = [] | ||
) { | ||
$this->optionsProvider = $optionsProvider; | ||
parent::__construct($context, $data); | ||
} | ||
|
||
/** | ||
* Set "name" for <select> element | ||
* | ||
* @param string $value | ||
* @return $this | ||
*/ | ||
public function setInputName($value) | ||
{ | ||
return $this->setName($value); | ||
} | ||
|
||
/** | ||
* Set "id" for <select> element | ||
* | ||
* @param $value | ||
* @return $this | ||
*/ | ||
public function setInputId($value) | ||
{ | ||
return $this->setId($value); | ||
} | ||
|
||
/** | ||
* Render block HTML | ||
* | ||
* @return string | ||
*/ | ||
public function _toHtml() | ||
{ | ||
if (!$this->getOptions()) { | ||
$this->setOptions($this->getSourceOptions()); | ||
} | ||
return parent::_toHtml(); | ||
} | ||
|
||
/** | ||
* Get option for select | ||
* | ||
* @return array | ||
*/ | ||
private function getSourceOptions() | ||
{ | ||
$locales = $this->optionsProvider->toOptionArray(); | ||
$languages = []; | ||
foreach ($locales as $locale) { | ||
$value = $this->removeCountryCode($locale['value']); | ||
$label = $this->removeCountryName($locale['label']); | ||
if (!array_key_exists($value,$languages)) { | ||
$languages[$value] = $label; | ||
} | ||
} | ||
return $languages; | ||
} | ||
|
||
/** | ||
* Removes the ending part of the locale, which corresponds | ||
* to the country code. | ||
* | ||
* @param $value | ||
* @return string | ||
*/ | ||
protected function removeCountryCode($value) { | ||
return preg_replace("/_.*$/", "", $value); | ||
} | ||
|
||
/** | ||
* Removes the countries between round brackets. | ||
* | ||
* @param $value | ||
* @return string | ||
*/ | ||
protected function removeCountryName($value) { | ||
return preg_replace("/\(.*\)/", "", $value); | ||
} | ||
} |
Oops, something went wrong.