Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
pasquale95 committed Jan 31, 2021
2 parents a155cbd + 98a707a commit f2e2bad
Show file tree
Hide file tree
Showing 47 changed files with 3,072 additions and 553 deletions.
42 changes: 42 additions & 0 deletions Api/Data/OpenGraphInterface.php
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";
}
33 changes: 33 additions & 0 deletions Api/Data/SchemaOrgInterface.php
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();
}
60 changes: 4 additions & 56 deletions Api/Data/SocialMarkupInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,6 @@
*/
interface SocialMarkupInterface
{
/**
* Constants for the Resolver array
*/
const PROPERTY = "property";
const CONTENT = "content";

/**
* Constants defined for keys of array.
* OpenGraph based.
*/
const TYPE = "og:type";
const LOCALE = "og:locale";
const SITENAME = "og:site_name";
const URL = "og:url";
const TITLE = "og:title";
const DESCRIPTION = "og:description";
const IMAGE = "og:image";

/**
* Name for the db field where to store the
* image url.
Expand All @@ -45,43 +27,9 @@ interface SocialMarkupInterface
const PLACEHOLDER_FOLDER = "seo/socialMarkup/placeholder";

/**
* Constants for those values that don't change among the graphql calls
*/
const TYPE_VALUE = "website";
const SITENAME_VALUE = "example";

/**
* @param $type
*/
public function setType($type);

/**
* @param $locale
*/
public function setLocale($locale);

/**
* @param $sitename
*/
public function setSitename($sitename);

/**
* @param $url
*/
public function setUrl($url);

/**
* @param $title
*/
public function setTitle($title);

/**
* @param $description
*/
public function setDescription($description);

/**
* @param $image
* @param $item
* @param $store
* @return array
*/
public function setImage($image);
public function getTags($item, $store);
}
34 changes: 34 additions & 0 deletions Api/Data/TwitterCardInterface.php
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 Block/Adminhtml/System/Config/Form/Field/Column/CountryColumn.php
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 Block/Adminhtml/System/Config/Form/Field/Column/LanguageColumn.php
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);
}
}
Loading

0 comments on commit f2e2bad

Please sign in to comment.