Vinoteca: wine shop on 1C-Bitrix (module, template, components, pages)
This commit is contained in:
commit
52795535ae
586 files changed
+27619
No files matched your search
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Jinove\Vinoteca;
|
||||
|
||||
class PageSchema
|
||||
{
|
||||
public static function translations(string $path, string $pageType): array
|
||||
{
|
||||
$relative = SITE_DIR !== "/" && str_starts_with($path, SITE_DIR) ? "/" . substr($path, strlen(SITE_DIR)) : $path;
|
||||
$nodes = [];
|
||||
foreach (Config::languages() as $language => $settings) {
|
||||
if ($language === LANGUAGE_ID) {
|
||||
continue;
|
||||
}
|
||||
$url = Config::host() . rtrim((string)$settings["dir"], "/") . $relative;
|
||||
$nodes[] = ["@type" => $pageType, "@id" => $url . "#webpage", "url" => $url, "inLanguage" => $language];
|
||||
}
|
||||
|
||||
return $nodes;
|
||||
}
|
||||
|
||||
public static function legalPage(string $path, string $name, string $description, string $modified): array
|
||||
{
|
||||
$url = Config::host() . $path;
|
||||
|
||||
return [
|
||||
"@context" => "https://schema.org",
|
||||
"@type" => "WebPage",
|
||||
"@id" => $url . "#webpage",
|
||||
"url" => $url,
|
||||
"name" => $name,
|
||||
"description" => $description,
|
||||
"inLanguage" => LANGUAGE_ID,
|
||||
"dateModified" => $modified,
|
||||
"workTranslation" => self::translations($path, "WebPage"),
|
||||
];
|
||||
}
|
||||
|
||||
public static function aboutPage(string $path, string $name, string $description, array $image): array
|
||||
{
|
||||
$url = Config::host() . $path;
|
||||
|
||||
return [
|
||||
"@context" => "https://schema.org",
|
||||
"@type" => "AboutPage",
|
||||
"@id" => $url . "#webpage",
|
||||
"url" => $url,
|
||||
"name" => $name,
|
||||
"description" => $description,
|
||||
"inLanguage" => LANGUAGE_ID,
|
||||
"mainEntity" => ["@id" => Config::host() . "/#store"],
|
||||
"primaryImageOfPage" => $image,
|
||||
"workTranslation" => self::translations($path, "AboutPage"),
|
||||
];
|
||||
}
|
||||
|
||||
public static function image(string $id, string $url, int $width, int $height): array
|
||||
{
|
||||
return [
|
||||
"@type" => "ImageObject",
|
||||
"@id" => $id,
|
||||
"url" => $url,
|
||||
"contentUrl" => $url,
|
||||
"width" => ["@type" => "QuantitativeValue", "value" => $width, "unitCode" => "E37"],
|
||||
"height" => ["@type" => "QuantitativeValue", "value" => $height, "unitCode" => "E37"],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user