Add 'plugi-core/' from commit '6c478c54d048ab2fd5af4e8e79074153fb594c16'

git-subtree-dir: plugi-core
git-subtree-mainline: d4c734cdbd
git-subtree-split: 6c478c54d0
This commit is contained in:
Paul Spenke
2023-06-13 07:27:11 +08:00
151 changed files with 46689 additions and 0 deletions
+162
View File
@@ -0,0 +1,162 @@
<?php
namespace Plugi;
use Plugi\Contracts\CacheContract;
class Cache implements CacheContract
{
public static $maxCacheDepth = 7;
public static $maxCachedPageVariants = 50;
/**
* Return the cached page content for the given relative URL.
*
* @param string $relativeUrl
* @return string|null
*/
public function getForUrl(string $relativeUrl)
{
$currentPageCacheFolder = $this->getPathForUrl($relativeUrl);
if (is_dir($currentPageCacheFolder)) {
if (! file_exists($currentPageCacheFolder . '/expires_at.txt')) {
$this->invalidate($relativeUrl);
return null;
}
$expiresAt = file_get_contents($currentPageCacheFolder . '/expires_at.txt');
if ($expiresAt < time()) {
$this->invalidate($relativeUrl);
return null;
}
return file_get_contents($currentPageCacheFolder . '/page.html');
}
return null;
}
/**
* Store the given page content for the given relative URL.
*
* @param string $relativeUrl
* @param string $pageContent
* @param int $cacheLifetime
*/
public function storeForUrl(string $relativeUrl, string $pageContent, int $cacheLifetime)
{
$currentPageCacheFolder = $this->getPathForUrl($relativeUrl, true);
if (! $this->cachePathCanBeUsed($currentPageCacheFolder)) {
return;
}
$currentPageCacheFolder = $this->relativeToFullCachePath($currentPageCacheFolder);
if (! is_dir($currentPageCacheFolder)) {
mkdir($currentPageCacheFolder, 0777, true);
}
file_put_contents($currentPageCacheFolder . '/page.html', $pageContent);
file_put_contents($currentPageCacheFolder . '/url.txt', $relativeUrl);
file_put_contents($currentPageCacheFolder . '/expires_at.txt', time() + (60 * $cacheLifetime));
}
/**
* Return the cache storage path for the given relative URL.
*
* @param string $relativeUrl
* @param bool $returnRelative
* @return string
*/
public function getPathForUrl(string $relativeUrl, bool $returnRelative = false): string
{
// map empty url to the - root folder
$relativeUrl = (empty($relativeUrl) || $relativeUrl === '/') ? '-' : $relativeUrl;
// use a cache path with folders based on the URL segments, to allow partial cache invalidation with a specific prefix
$relativeUrlWithoutQueryString = explode('?', $relativeUrl)[0];
$cachePath = phpb_slug($relativeUrlWithoutQueryString, true);
// suffix the cache path with a hash of the exact relative URL, to prevent returning wrong content due to slug collisions
$cachePath .= '/' . sha1($relativeUrl);
return $returnRelative ? $cachePath : $this->relativeToFullCachePath($cachePath);
}
protected function relativeToFullCachePath(string $relativeCachePath): string
{
$cacheFolder = phpb_config('cache.folder');
if (substr($relativeCachePath, 0, 1) !== '/') {
$cacheFolder .= '/';
}
return $cacheFolder . $relativeCachePath;
}
/**
* Analyse the given cache path to determine whether it can be used, without server/disk space issues.
* This prevents deep nested cache paths and large numbers of cached pages per path due to query string variations.
*
* @param string $cachePath
* @return bool
*/
public function cachePathCanBeUsed(string $cachePath): bool
{
if (sizeof(explode('/', $cachePath)) > static::$maxCacheDepth) {
return false;
}
$cachePathWithoutHash = dirname($this->relativeToFullCachePath($cachePath));
$numberOfCachedPageVariants = count(glob("{$cachePathWithoutHash}/*", GLOB_ONLYDIR));
if (is_dir($cachePathWithoutHash) && $numberOfCachedPageVariants >= static::$maxCachedPageVariants) {
return false;
}
return true;
}
/**
* Invalidate all variants stored for the given page route (i.e. a URL with * and {} placeholders).
*
* @param string $route
*/
public function invalidate(string $route)
{
$staticUrlPrefix1 = explode('*', $route)[0];
$staticUrlPrefix2 = explode('{', $route)[0];
$shortestPrefix = $staticUrlPrefix1;
if (strlen($staticUrlPrefix2) < strlen($staticUrlPrefix1)) {
$shortestPrefix = $staticUrlPrefix2;
}
$cachePathPrefix = dirname($this->getPathForUrl($shortestPrefix));
$this->removeDirectoryRecursive($cachePathPrefix);
}
/**
* Recursively remove the directory of the given path and all its contents.
*
* @param $path
* @return bool
*/
protected function removeDirectoryRecursive($path) {
// prevent removing data outside the cache folder
if (strpos($path, '..') !== false || strpos($path, phpb_config('cache.folder')) !== 0) {
return false;
}
if (! is_dir($path)) {
return false;
}
$path = substr($path, -1) === '/' ? $path : $path . '/';
$files = glob($path . '*', GLOB_MARK);
foreach ($files as $file) {
if (is_dir($file)) {
$this->removeDirectoryRecursive($file);
} else {
unlink($file);
}
}
rmdir($path);
return true;
}
}
+30
View File
@@ -0,0 +1,30 @@
<?php
namespace Plugi\Contracts;
interface AuthContract
{
/**
* Process the current GET or POST request and redirect or render the requested page.
*
* @param $action
*/
public function handleRequest($action);
/**
* Return whether the current request has an authenticated session.
*
* @return bool
*/
public function isAuthenticated();
/**
* If the current user is not authenticated, show the login form.
*/
public function requireAuth();
/**
* Render the login form.
*/
public function renderLoginForm();
}
@@ -0,0 +1,48 @@
<?php
namespace Plugi\Contracts;
interface CacheContract
{
/**
* Return the cached page content for the given relative URL.
*
* @param string $relativeUrl
* @return string|null
*/
public function getForUrl(string $relativeUrl);
/**
* Store the given page content for the given relative URL.
*
* @param string $relativeUrl
* @param string $pageContent
* @param int $cacheLifetime
*/
public function storeForUrl(string $relativeUrl, string $pageContent, int $cacheLifetime);
/**
* Return the cache storage path for the given relative URL.
*
* @param string $relativeUrl
* @param bool $returnRelative
* @return string
*/
public function getPathForUrl(string $relativeUrl, bool $returnRelative = false): string;
/**
* Analyse the given cache path to determine whether it can be to used, without server/disk space issues.
* This prevents deep nested cache paths and large numbers of cached pages per path due to query string variations.
*
* @param string $cachePath
* @return bool
*/
public function cachePathCanBeUsed(string $cachePath): bool;
/**
* Invalidate all variants stored for the given page route (i.e an URL with * and {} placeholders).
*
* @param string $route
*/
public function invalidate(string $route);
}
@@ -0,0 +1,29 @@
<?php
namespace Plugi\Contracts;
interface MenuRepositoryContract
{
/**
* Replace all menus by the given data.
*
* @param array $data
* @return bool|object|null
*/
public function updateMenus(array $data);
/**
* Get one hydrated menu with the given name.
*
* @param string $name
* @return object|null
*/
public function getHydratedMenu(string $name);
/**
* Get all hydrated menus with the given name.
*
* @return array
*/
public function getHydratedMenus();
}
@@ -0,0 +1,64 @@
<?php
namespace Plugi\Contracts;
interface PageBuilderContract
{
/**
* Process the current GET or POST request and redirect or render the requested page.
*
* @param $route
* @param $action
* @param PageContract|null $page
*/
public function handleRequest($route, $action, PageContract $page = null);
/**
* Render the given page inside the PageBuilder.
*
* @param PageContract $page
*/
public function renderPageBuilder(PageContract $page);
/**
* Render the given page.
*
* @param PageContract $page
* @param null $language
* @return string
*/
public function renderPage(PageContract $page, $language = null): string;
/**
* Update the given page with the given data (an array of html blocks)
*
* @param PageContract $page
* @param $data
* @return bool|object|null
*/
public function updatePage(PageContract $page, $data);
/**
* Get or set custom css for customizing layout of the page builder.
*
* @param string|null $css
* @return string
*/
public function customStyle(string $css = null);
/**
* Get or set custom scripts for customizing behaviour of the page builder.
*
* @param string $location head|body
* @param string|null $scripts
* @return string
*/
public function customScripts(string $location, string $scripts = null);
/**
* Set a theme for the page builder.
*
* @param ThemeContract $theme
*/
public function setTheme(ThemeContract $theme);
}
+93
View File
@@ -0,0 +1,93 @@
<?php
namespace Plugi\Contracts;
interface PageContract
{
/**
* Set the data stored for this page.
*
* @param array|null $data
* @param bool $fullOverwrite whether to fully overwrite or extend existing data
*/
public function setData($data, $fullOverwrite = true);
/**
* Set the translation data of this page.
*
* @param array|null $translationData
*/
public function setTranslations($translationData);
/**
* Return all data stored for this page (page builder data and other data set via setData).
*
* @return array|null
*/
public function getData();
/**
* Return the page builder data stored for this page.
*
* @return array|null
*/
public function getBuilderData();
/**
* Return the id of this page.
*
* @return string
*/
public function getId();
/**
* Return the layout (file name) of this page.
*
* @return string
*/
public function getLayout();
/**
* Return the name of this page.
*
* @return string
*/
public function getName();
/**
* Return the given language dependant setting for this page, in the current or in the given language.
*
* @param string $setting
* @param string|null $locale
* @return mixed|string|null
*/
public function getTranslation(string $setting, $locale = null);
/**
* Return the translated settings of this page.
*
* @return array
*/
public function getTranslations();
/**
* Return the route of this page, in the current or in the given language.
*
* @param string|null $locale
* @return mixed
*/
public function getRoute($locale = null);
/**
* Get the value of the given property of this Page.
*
* @param $property
* @return mixed|null
*/
public function get($property);
/**
* Invalidate all cached variants of this page.
*/
public function invalidateCache();
}
@@ -0,0 +1,23 @@
<?php
namespace Plugi\Contracts;
interface PageRepositoryContract
{
/**
* Create a new page.
*
* @param array $data
* @return bool|object
*/
public function create(array $data);
/**
* Update the given page with the given updated data.
*
* @param $page
* @param array $data
* @return bool|object|null
*/
public function update($page, array $data);
}
@@ -0,0 +1,13 @@
<?php
namespace Plugi\Contracts;
interface PageTranslationContract
{
/**
* Return the page this translation belongs to.
*
* @return PageContract
*/
public function getPage();
}
@@ -0,0 +1,7 @@
<?php
namespace Plugi\Contracts;
interface PageTranslationRepositoryContract
{
}
@@ -0,0 +1,41 @@
<?php
namespace Plugi\Contracts;
interface RouterContract
{
/**
* Return the page corresponding to the given URL.
*
* @param $url
* @return PageTranslationContract|null
*/
public function resolve($url);
/**
* Return the full page translation instance based on the given matched route or page translation id.
* (this method is helpful when extending a router to perform additional checks after a route has been matched)
*
* @param string $matchedRoute the matched route
* @param string $matchedPageTranslationId the page translation id corresponding to the matched route
* @return PageTranslationContract|null
*/
public function getMatchedPage(string $matchedRoute, string $matchedPageTranslationId);
/**
* Order the given routes into the order in which they need to be evaluated.
*
* @param $allRoutes
* @return array
*/
public function getRoutesInOrder($allRoutes);
/**
* Compare two given routes and return -1,0,1 indicating which route should be evaluated first.
*
* @param $route1
* @param $route2
* @return int
*/
public function routeOrderComparison($route1, $route2);
}
@@ -0,0 +1,23 @@
<?php
namespace Plugi\Contracts;
interface SettingContract
{
/**
* Return the value(s) of the given setting.
*
* @param string $key
* @return mixed|null
*/
public static function get(string $key);
/**
* Return whether the given setting exists and has the given value.
*
* @param string $key
* @param string $value
* @return bool
*/
public static function has(string $key, string $value);
}
@@ -0,0 +1,14 @@
<?php
namespace Plugi\Contracts;
interface SettingRepositoryContract
{
/**
* Replace all website settings by the given data.
*
* @param array $data
* @return bool|object|null
*/
public function updateSettings(array $data);
}
@@ -0,0 +1,27 @@
<?php
namespace Plugi\Contracts;
interface ThemeContract
{
/**
* Return all blocks of this theme.
*
* @return array array of ThemeBlock instances
*/
public function getThemeBlocks();
/**
* Return all layouts of this theme.
*
* @return array array of ThemeLayout instances
*/
public function getThemeLayouts();
/**
* Return the folder of this theme.
*
* @return mixed
*/
public function getFolder();
}
@@ -0,0 +1,36 @@
<?php
namespace Plugi\Contracts;
interface WebsiteManagerContract
{
/**
* Process the current GET or POST request and redirect or render the requested page.
*
* @param $route
* @param $action
*/
public function handleRequest($route, $action);
/**
* Render the website manager overview page.
*/
public function renderOverview();
/**
* Render the website manager page settings (add/edit page form).
*
* @param PageContract $page
*/
public function renderPageSettings(PageContract $page = null);
/**
* Render the website manager menu settings (add/edit menu form).
*/
public function renderMenuSettings();
/**
* Render the welcome page.
*/
public function renderWelcomePage();
}
+109
View File
@@ -0,0 +1,109 @@
<?php
namespace Plugi\Core;
use PDO;
/**
* Class DB
*
* A basic shell around PDO.
*
* @package Plugi\Core
*/
class DB
{
/**
* @var PDO $pdo
*/
protected $pdo;
/**
* DB constructor.
*
* @param array $config
*/
public function __construct(array $config)
{
$this->pdo = new PDO(
$config['driver'] . ':host=' . $config['host'] . ';dbname=' . $config['database'] . ";options='--client_encoding=" . $config['charset'] . "'",
$config['username'],
$config['password'],
[PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]
);
$this->pdo->exec("set names " . $config['charset']);
}
/**
* Return the id of the last inserted record.
*
* @return string
*/
public function lastInsertId()
{
return $this->pdo->lastInsertId();
}
/**
* Return all records of the given table and return instances of the given class.
*
* @param array|string $columns
* @param string $table
* @return array
*/
public function all(string $table, $columns = '*')
{
if (is_array($columns)) {
foreach ($columns as &$column) {
$column = preg_replace('/[^a-zA-Z_]*/', '', $column);
}
$columns = implode(',', $columns);
$stmt = $this->pdo->prepare("SELECT {$columns} FROM {$table}");
} else {
$stmt = $this->pdo->prepare("SELECT * FROM {$table}");
}
$stmt->execute();
return $stmt->fetchAll();
}
/**
* Return the first record of the given table as an instance of the given class.
*
* @param string $table
* @param $id
* @return mixed
*/
public function findWithId(string $table, $id)
{
$stmt = $this->pdo->prepare("SELECT * FROM {$table} WHERE id = ?");
$stmt->execute([$id]);
return $stmt->fetchAll();
}
/**
* Perform a custom select query with user input data passed as $parameters.
*
* @param string $query
* @param array $parameters
* @return array
*/
public function select(string $query, array $parameters)
{
$stmt = $this->pdo->prepare($query);
$stmt->execute($parameters);
return $stmt->fetchAll();
}
/**
* Perform a custom query with user input data passed as $parameters.
*
* @param string $query
* @param array $parameters
* @return bool
*/
public function query(string $query, array $parameters = [])
{
$stmt = $this->pdo->prepare($query);
return $stmt->execute($parameters);
}
}
+601
View File
@@ -0,0 +1,601 @@
<?php
use Plugi\Extensions;
if (! function_exists('phpb_e')) {
/**
* Encode HTML special characters in a string.
*
* @param string $value
* @param bool $doubleEncode
* @return string
*/
function phpb_e($value, $doubleEncode = true)
{
return htmlspecialchars($value, ENT_QUOTES, 'UTF-8', $doubleEncode);
}
}
if (! function_exists('phpb_encode_or_null')) {
/**
* Encode HTML special characters in a string, but preserve a null value if the passed input equals null.
*
* @param string $value
* @param bool $doubleEncode
* @return string
*/
function phpb_encode_or_null($value, $doubleEncode = true)
{
return is_null($value) ? null : phpb_e($value, $doubleEncode);
}
}
if (! function_exists('phpb_asset')) {
/**
* Return the public path of a Plugi asset.
*
* @param string $path
* @return string
*/
function phpb_asset($path)
{
$basePath = __DIR__ . '/../../dist/';
$distPath = realpath($basePath . $path);
$version = ($distPath && strpos($distPath, realpath($basePath)) === 0) ? filemtime($distPath) : '';
return phpb_full_url(phpb_config('general.assets_url') . '/' . $path) . '?v=' . $version;
}
}
if (! function_exists('phpb_theme_asset')) {
/**
* Return the public path of an asset of the current theme.
*
* @param string $path
* @return string
*/
function phpb_theme_asset($path)
{
$themeFolder = phpb_config('theme.folder_url') . '/' . phpb_config('theme.active_theme');
return phpb_full_url($themeFolder . '/' . $path);
}
}
if (! function_exists('phpb_flash')) {
/**
* Return the flash data with the given key (as dot-separated multidimensional array selector) or false if not set.
*
* @param $key
* @param bool $encode
* @return bool|mixed
*/
function phpb_flash($key, $encode = true)
{
global $phpb_flash;
// if no dot notation is used, return first dimension value or empty string
if (strpos($key, '.') === false) {
if (! isset($phpb_flash[$key])) {
return false;
}
return $encode ? phpb_e($phpb_flash[$key]) : $phpb_flash[$key];
}
// if dot notation is used, traverse config string
$segments = explode('.', $key);
$subArray = $phpb_flash;
foreach ($segments as $segment) {
if (isset($subArray[$segment])) {
$subArray = &$subArray[$segment];
} else {
return false;
}
}
// if the remaining sub array is a string, return this piece of flash data
if (is_string($subArray)) {
if ($encode) {
return phpb_e($subArray);
}
return $subArray;
}
return false;
}
}
if (! function_exists('phpb_config')) {
/**
* Return the configuration with the given key (as dot-separated multidimensional array selector).
*
* @param string $key
* @return mixed
*/
function phpb_config($key)
{
global $phpb_config;
// if no dot notation is used, return first dimension value or empty string
if (strpos($key, '.') === false) {
return $phpb_config[$key] ?? '';
}
// if dot notation is used, traverse config string
$segments = explode('.', $key);
$subArray = $phpb_config;
foreach ($segments as $segment) {
if (isset($subArray[$segment])) {
$subArray = &$subArray[$segment];
} else {
return '';
}
}
return $subArray;
}
}
if (! function_exists('phpb_trans')) {
/**
* Return the translation of the given key (as dot-separated multidimensional array selector).
*
* @param $key
* @param array $parameters
* @return string|array
*/
function phpb_trans($key, $parameters = [])
{
global $phpb_translations;
// if no dot notation is used, return first dimension value or empty string
if (strpos($key, '.') === false) {
return phpb_replace_placeholders($phpb_translations[$key] ?? '', $parameters);
}
// if dot notation is used, traverse translations string
$segments = explode('.', $key);
$subArray = $phpb_translations;
foreach ($segments as $segment) {
if (isset($subArray[$segment])) {
$subArray = &$subArray[$segment];
} else {
return '';
}
}
// if the remaining sub array is a non-empty string/array, return this translation or translations structure
if (! empty($subArray)) {
if (is_string($subArray)) {
return phpb_replace_placeholders($subArray, $parameters);
}
return $subArray;
}
return '';
}
}
if (! function_exists('phpb_replace_placeholders')) {
/**
* Replace in the given string the given parameter placeholders with corresponding values.
*
* @param $string
* @param array $parameters
* @return string
*/
function phpb_replace_placeholders($string, $parameters = [])
{
foreach ($parameters as $placeholder => $value) {
$string = str_replace(':' . $placeholder, $value, $string);
}
return $string;
}
}
if (! function_exists('phpb_full_url')) {
/**
* Give the full URL of a given URL which is relative to the base URL.
*
* @param string $urlRelativeToBaseUrl
* @return string
*/
function phpb_full_url($urlRelativeToBaseUrl)
{
// if the URL is already a full URL, do not alter the URL
if (strpos($urlRelativeToBaseUrl, 'http://') === 0 || strpos($urlRelativeToBaseUrl, 'https://') === 0) {
return $urlRelativeToBaseUrl;
}
$baseUrl = phpb_config('general.base_url');
return rtrim($baseUrl, '/') . $urlRelativeToBaseUrl;
}
}
if (! function_exists('phpb_url')) {
/**
* Give the full URL of a given public path.
*
* @param string $module
* @param array $parameters
* @param bool $fullUrl
* @return string
*/
function phpb_url($module, array $parameters = [], $fullUrl = true)
{
$url = $fullUrl ? phpb_full_url('') : '';
$url .= phpb_config($module . '.url');
if (! empty($parameters)) {
$url .= '?';
$pairs = [];
foreach ($parameters as $key => $value) {
$pairs[] = phpb_e($key) . '=' . phpb_e($value);
}
$url .= implode('&', $pairs);
}
return $url;
}
}
if (! function_exists('phpb_current_full_url')) {
/**
* Give the current full URL.
*
* @return string|null
*/
function phpb_current_full_url()
{
// return null when running form CLI
if (! isset($_SERVER['SERVER_NAME']) || ! isset($_SERVER['REQUEST_URI'])) {
return null;
}
$protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http");
$port = '';
if (isset($_SERVER['SERVER_PORT']) && ! in_array($_SERVER['SERVER_PORT'], [80, 443])) {
$port = ":" . $_SERVER['SERVER_PORT'];
}
$currentFullUrl = $protocol . "://" . $_SERVER['SERVER_NAME'] . $port . urldecode($_SERVER['REQUEST_URI']);
$currentFullUrl = rtrim($currentFullUrl, '/' . DIRECTORY_SEPARATOR);
return $currentFullUrl;
}
}
if (! function_exists('phpb_current_relative_url')) {
/**
* Give the current URL relative to the base directory (the website's index.php entry point).
* This omits any parent directories from the URL in which the project is installed.
*
* @return string
*/
function phpb_current_relative_url()
{
$baseUrl = phpb_config('general.base_url');
$baseUrl = rtrim($baseUrl, '/'. DIRECTORY_SEPARATOR);
$currentFullUrl = phpb_current_full_url();
$relativeUrl = substr($currentFullUrl, strlen($baseUrl));
$relativeUrl = ltrim($relativeUrl, '/'. DIRECTORY_SEPARATOR);
return '/' . $relativeUrl;
}
}
if (! function_exists('phpb_current_language')) {
/**
* Give the current language based on the current URL.
*
* @return string
*/
function phpb_current_language()
{
$urlComponents = explode('/', phpb_current_relative_url());
// remove empty values and reset array key numbering
$urlComponents = array_values(array_filter($urlComponents));
if (! empty($urlComponents)) {
foreach (phpb_active_languages() as $languageCode => $languageTranslation) {
if ($urlComponents[0] === $languageCode) {
return $languageCode;
}
}
}
$languageCode = phpb_config('general.language');
if (in_array($languageCode, array_keys(phpb_active_languages()))) {
return $languageCode;
}
if (in_array('en', array_keys(phpb_active_languages()))) {
return 'en';
}
return array_keys(phpb_active_languages())[0];
}
}
if (! function_exists('phpb_in_module')) {
/**
* Return whether we are currently accessing the given module.
*
* @param string $module
* @return bool
*/
function phpb_in_module($module)
{
$url = phpb_url($module, [], false);
$currentUrl = explode('?', phpb_current_relative_url(), 2)[0];
return $currentUrl === $url;
}
}
if (! function_exists('phpb_on_url')) {
/**
* Return whether we are currently on the given URL.
*
* @param string $module
* @param array $parameters
* @return bool
*/
function phpb_on_url($module, array $parameters = [])
{
$url = phpb_url($module, $parameters, false);
return phpb_current_relative_url() === $url;
}
}
if (! function_exists('phpb_set_in_editmode')) {
/**
* Set whether the current page is being load in edit mode (i.e. inside the page builder).
*
* @param bool $inEditMode
*/
function phpb_set_in_editmode($inEditMode = true)
{
global $phpb_in_editmode;
$phpb_in_editmode = $inEditMode;
}
}
if (! function_exists('phpb_in_editmode')) {
/**
* Return whether the current page is load in edit mode (i.e. inside the page builder).
*
* @return bool
*/
function phpb_in_editmode()
{
global $phpb_in_editmode;
return $phpb_in_editmode ?? false;
}
}
if (! function_exists('phpb_redirect')) {
/**
* Redirect to the given URL with optional session flash data.
*
* @param string $url
* @param array $flashData
* @param $statusCode
*/
function phpb_redirect($url, $flashData = [], $statusCode = 302)
{
if (! empty($flashData)) {
$_SESSION["phpb_flash"] = $flashData;
}
header('Location: ' . $url, true, $statusCode);
exit();
}
}
if (! function_exists('phpb_route_parameters')) {
/**
* Return the named route parameters resolved from the current URL.
*
* @return array|null
*/
function phpb_route_parameters()
{
global $phpb_route_parameters;
return $phpb_route_parameters ?? [];
}
}
if (! function_exists('phpb_route_parameter')) {
/**
* Return the value of the given named route parameter resolved from the current URL.
*
* @param string $parameter
* @return string|null
*/
function phpb_route_parameter($parameter)
{
global $phpb_route_parameters;
return $phpb_route_parameters[$parameter] ?? null;
}
}
if (! function_exists('phpb_field_value')) {
/**
* Return the posted value or the attribute value of the given instance, or null if no value was found.
*
* @param $attribute
* @param object $instance
* @return string|null
*/
function phpb_field_value($attribute, $instance = null)
{
if (isset($_POST[$attribute])) {
return phpb_encode_or_null($_POST[$attribute]);
}
if (isset($instance)) {
if (method_exists($instance, 'get')) {
return phpb_encode_or_null($instance->get($attribute));
} else {
return phpb_encode_or_null($instance->$attribute);
}
}
return null;
}
}
if (! function_exists('phpb_active_languages')) {
/**
* Return the list of all active languages.
*
* @return array
*/
function phpb_active_languages()
{
$configLanguageCode = phpb_config('general.language');
$languages = phpb_instance('setting')::get('languages') ?? [$configLanguageCode];
// if the array has numeric indices (which is the default), create a languageCode => languageTranslation structure
if (array_values($languages) === $languages) {
$newLanguagesStructure = [];
foreach ($languages as $languageCode) {
$newLanguagesStructure[$languageCode] = phpb_trans('languages')[$languageCode] ?? [];
}
$languages = $newLanguagesStructure;
}
if (! isset($languages[$configLanguageCode])) {
return $languages;
}
// sort languages, starting by the configured language
$languagesSorted[$configLanguageCode] = $languages[$configLanguageCode];
foreach ($languages as $languageCode => $languageTranslation) {
if ($languageCode !== $configLanguageCode) {
$languagesSorted[$languageCode] = $languageTranslation;
}
}
return $languagesSorted;
}
}
if (! function_exists('phpb_instance')) {
/**
* Return an instance of the given class as defined in config, or with the given namespace (which is potentially overridden and mapped to an alternative namespace).
*
* @param string $name the name of the config main section in which the class path is defined
* @param array $params
* @return object|null
*/
function phpb_instance(string $name, $params = [])
{
if (phpb_config($name . '.class')) {
$className = phpb_config($name . '.class');
return new $className(...$params);
}
if (class_exists($name)) {
if (phpb_config('class_replacements.' . $name)) {
$replacement = phpb_config('class_replacements.' . $name);
return new $replacement(...$params);
}
return new $name(...$params);
}
return null;
}
}
if (! function_exists('phpb_static')) {
/**
* Return a static reference of the given class as defined in config, or with the given namespace (which is potentially overridden and mapped to an alternative namespace).
*
* @param string $name the name of the config main section in which the class path is defined
* @return object|string|null
*/
function phpb_static(string $name)
{
if (phpb_config($name . '.class')) {
return phpb_config($name . '.class');
}
if (class_exists($name)) {
if (phpb_config('class_replacements.' . $name)) {
return phpb_config('class_replacements.' . $name);
}
return $name;
}
return null;
}
}
if (! function_exists('phpb_slug')) {
/**
* Create a slug (safe URL or path) of the given string.
*
* @param string $text
* @param false $allowSlashes
* @return string
*/
function phpb_slug(string $text, $allowSlashes = false)
{
if ($allowSlashes) {
return strtolower(trim(preg_replace('/[^A-Za-z0-9-\/]+/', '-', $text)));
} else {
return strtolower(trim(preg_replace('/[^A-Za-z0-9-]+/', '-', $text)));
}
}
}
if (! function_exists('phpb_autoload')) {
/**
* Autoload classes from the Plugi package.
*
* @param string $className
*/
function phpb_autoload($className)
{
// PSR-0 autoloader
$className = ltrim($className, '\\');
$fileName = '';
$namespace = '';
if ($lastNsPos = strripos($className, '\\')) {
$namespace = substr($className, 0, $lastNsPos);
$className = substr($className, $lastNsPos + 1);
$fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
}
$fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
// remove leading Plugi/ from the class path
$fileName = str_replace('Plugi' . DIRECTORY_SEPARATOR, '', $fileName);
// include class files starting in the src directory
require __DIR__ . '/../' . $fileName;
}
}
if (! function_exists('phpb_registered_assets')) {
/**
* Render all manually registered assets.
*
* @param $location
* @return void
*/
function phpb_registered_assets($location = 'header') {
$assets = [];
if($location === 'header'){
$assets = Extensions::getHeaderAssets();
}elseif($location === 'footer'){
$assets = Extensions::getFooterAssets();
}elseif($location === 'admin-header'){
$assets = Extensions::getAdminHeaderAssets();
}elseif($location === 'admin-footer'){
$assets = Extensions::getAdminFooterAssets();
}
foreach ($assets as $asset) {
$attributes = '';
foreach ($asset['attributes'] as $key => $value) {
$attributes .= ' ' . $key . '="' . $value . '"';
}
if ($asset['type'] == 'style') {
echo '<link rel="stylesheet" href="' . $asset['src'] . '" ' . $attributes . '/>';
} else {
echo '<script type="text/javascript" src="' . $asset['src'] . '" ' . $attributes . '></script>';
}
}
}
}
+252
View File
@@ -0,0 +1,252 @@
<?php
namespace Plugi;
class Extensions
{
/**
* Routes that can be added by plugins / composer packages.
*/
protected static $settings = [];
/**
* Extension-Configs that can be added by plugins / composer packages.
*/
protected static $configs = [];
/**
* Extension-Configs that can be added by plugins / composer packages.
*/
protected static $backends = [];
/**
* Routes that can be added by plugins / composer packages.
*/
protected static $routes = [];
/**
* Blocks that can be added by plugins / composer packages.
*/
protected static $blocks = [];
/**
* Layouts that can be added by plugins / composer packages.
*/
protected static $layouts = [];
protected static $assets = [
'header' => [],
'footer' => [],
'admin-header' => [],
'admin-footer' => [],
];
/**
* Register an asset.
* @param string $src
* @param string $type
* @param string $location
* @param array['$key' => '$value'] $attributes
*/
public static function registerAsset(string $src, string $type, string $location = 'header', array $attributes = []) {
self::$assets[$location][] = [
'src' => $src,
'type' => $type,
'attributes' => $attributes
];
}
/**
* Register a single extension-config.
* @param string $slug
* @param array $config
* @return void
*/
public static function registerConfig(string $slug, array $config) {
self::$configs[$slug] = $config;
}
/**
* Register a single extension-config.
* @param string $slug
* @param array $backend
* @return void
*/
public static function registerBackend(string $slug, array $backend) {
$backend['icon'] = $backend['icon'] ?: '<i class="ph ph-circles-three-plus"></i>';
self::$backends['ext--'.$slug] = $backend;
}
/**
* Register a single route.
* @param string $slug
* @param string $includePath
* @return void
*/
public static function registerRoute(string $slug, string $includePath) {
self::$routes[$slug] = $includePath;
}
/**
* Register multiple routes at once.
* @param array['$slug' => '$includePath'] $routes
* @return void
*/
public static function addRoutes(array $routes) {
self::$routes = array_merge(self::$routes, $routes);
}
/**
* Register multiple settings at once.
* @param array $settings
* @return void
*/
public static function addSettings(array $settings) {
self::$settings = array_merge(self::$settings, $settings);
}
/**
* Register a single block.
* @param string $slug
* @param string $directoryPath
*/
public static function registerBlock(string $slug, string $directoryPath) {
self::$blocks[$slug] = $directoryPath;
}
/**
* Register a single layout.
* @param string $slug
* @param string $directoryPath
*/
public static function registerLayout(string $slug, string $directoryPath) {
self::$layouts[$slug] = $directoryPath;
}
/**
* Register multiple blocks at once.
* @param array['$slug' => '$directoryPath'] $blocks
*/
public static function addBlocks(array $blocks) {
self::$blocks = array_merge(self::$blocks, $blocks);
}
/**
* Register multiple blocks at once.
* @param array['$slug' => '$directoryPath'] $layouts
*/
public static function addLayouts(array $layouts) {
self::$layouts = array_merge(self::$layouts, $layouts);
}
/**
* Get all routes.
*/
public static function getRoutes() : array {
return self::$routes;
}
/**
* Get all settings.
*/
public static function getSettings($ext = null) : array {
$settingIns = phpb_instance('setting');
$hydrSettings = [];
foreach (self::$settings as $setting) {
if($ext !== null && !str_starts_with($setting['key'], 'ext--'.$ext.'--')){
continue;
}
$setting['value'] = $settingIns::get($setting['key']) ?: $setting['default'];
$hydrSettings[] = $setting;
}
return $hydrSettings;
}
/**
* Get all blocks.
*/
public static function getBlocks() : array {
return self::$blocks;
}
/**
* Get all layouts.
*/
public static function getLayouts() : array {
return self::$layouts;
}
/**
* Get all backends.
*/
public static function getBackends() : array {
return self::$backends;
}
/**
* Get a single extension Config.
*/
public static function getConfig(string $id) {
return self::$configs[$id] ?? null;
}
/**
* Get all extension Configs.
*/
public static function getConfigs() {
return self::$configs;
}
/**
* Get a single route.
*/
public static function getRoute(string $id) {
return self::$routes[$id] ?? null;
}
/**
* Get a single block.
*/
public static function getBlock(string $id) {
return self::$blocks[$id] ?? null;
}
/**
* Get a single layout.
*/
public static function getLayout(string $id) {
return self::$layouts[$id] ?? null;
}
/**
* Get all header assets.
*/
public static function getHeaderAssets() {
return self::$assets['header'];
}
/**
* Get all footer assets.
*/
public static function getFooterAssets() {
return self::$assets['footer'];
}
/**
* Get all admin header assets.
*/
public static function getAdminHeaderAssets() {
return self::$assets['admin-header'];
}
/**
* Get all admin footer assets.
*/
public static function getAdminFooterAssets() {
return self::$assets['admin-footer'];
}
}
+63
View File
@@ -0,0 +1,63 @@
<?php
namespace Plugi\Modules\Auth;
use Plugi\Contracts\AuthContract;
class Auth implements AuthContract
{
/**
* Process the current GET or POST request and redirect or render the requested page.
*
* @param $action
*/
public function handleRequest($action)
{
if (phpb_in_module('auth')) {
if ($action === 'login' && isset($_POST['username']) && isset($_POST['password'])) {
if ($_POST['username'] === phpb_config('auth.username') && $_POST['password'] === phpb_config('auth.password')) {
$_SESSION['phpb_logged_in'] = true;
phpb_redirect(phpb_url('website_manager'));
} else {
phpb_redirect(phpb_url('website_manager'), [
'message-type' => 'warning',
'message' => phpb_trans('auth.invalid-credentials')
]);
}
} elseif ($action === 'logout') {
unset($_SESSION['phpb_logged_in']);
phpb_redirect(phpb_url('website_manager'));
}
}
}
/**
* Return whether the current request has an authenticated session.
*
* @return bool
*/
public function isAuthenticated()
{
return isset($_SESSION['phpb_logged_in']);
}
/**
* If the user is not authenticated, show the login form.
*/
public function requireAuth()
{
if (! $this->isAuthenticated()) {
$this->renderLoginForm();
exit();
}
}
/**
* Render the login form.
*/
public function renderLoginForm()
{
$viewFile = 'login-form';
require __DIR__ . '/resources/views/layout.php';
}
}
@@ -0,0 +1,24 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title><?= phpb_trans('auth.title') ?></title>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous">
<link href="<?= phpb_asset('WebsiteManager.css') ?>" rel="stylesheet">
</head>
<body>
<div class="container">
<?php
require __DIR__ . '/' . $viewFile . '.php';
?>
<footer class="my-5 pt-5 text-muted text-center text-small">
<p class="mb-1">Powered by <a href="https://github.com/deepDiverPaul/plugi" target="_blank">Plugi Page Builder</a></p>
</footer>
</div>
</body>
</html>
@@ -0,0 +1,20 @@
<div class="py-5 text-center">
<h2><?= phpb_trans('auth.title') ?></h2>
</div>
<form class="login-form mt-3 flex flex-col gap-3 items-center" method="post" action="<?= phpb_url('auth', ['action' => 'login']) ?>">
<?php
if (phpb_flash('message')):
?>
<div class="alert alert-<?= phpb_flash('message-type') ?>">
<?= phpb_flash('message') ?>
</div>
<?php
endif;
?>
<input type="text" name="username" class="input input-bordered w-full max-w-xs" placeholder="<?= phpb_trans('auth.username') ?>" required autofocus>
<input type="password" name="password" class="input input-bordered w-full max-w-xs" placeholder="<?= phpb_trans('auth.password') ?>" required>
<button class="btn btn-outline btn-primary w-full max-w-xs" type="submit"><?= phpb_trans('auth.login-button') ?></button>
</form>
@@ -0,0 +1,45 @@
<?php
namespace Plugi\Modules\GrapesJS\Block;
use Plugi\Contracts\PageContract;
class BaseController
{
/**
* @var BaseModel $model
*/
protected $model;
/**
* @var PageContract $page
*/
protected $page;
/**
* @var bool $forPageBuilder
*/
protected $forPageBuilder;
/**
* Pass essential data to this BaseController instance.
*
* @param BaseModel $model
* @param PageContract $page
* @param bool $forPageBuilder
*/
public function init(BaseModel $model, PageContract $page, $forPageBuilder = false)
{
$this->model = $model;
$this->page = $page;
$this->forPageBuilder = $forPageBuilder;
}
/**
* Handle the current request.
*/
public function handleRequest()
{
}
}
@@ -0,0 +1,99 @@
<?php
namespace Plugi\Modules\GrapesJS\Block;
use Plugi\Contracts\PageContract;
use Plugi\ThemeBlock;
class BaseModel
{
/**
* @var ThemeBlock $block
*/
protected $block;
/**
* @var array $data
*/
protected $data;
/**
* @var PageContract $page
*/
protected $page;
/**
* @var bool $forPageBuilder
*/
protected $forPageBuilder;
/**
* BaseModel constructor.
*
* @param ThemeBlock $block
* @param array $data
* @param PageContract|null $page
* @param bool $forPageBuilder
*/
public function __construct(ThemeBlock $block, $data = [], PageContract $page = null, $forPageBuilder = false)
{
$this->block = $block;
$this->data = is_array($data) ? $data : [];
$this->page = $page;
$this->forPageBuilder = $forPageBuilder;
if (phpb_in_editmode() && method_exists($this, 'initEdit')) {
$this->initEdit();
} else {
$this->init();
}
}
/**
* Initialize the model.
*/
protected function init()
{
}
/**
* Return the given setting stored for this block instance using the page builder.
*
* @param $setting
* @param bool $allowHtml
* @return string
*/
public function setting($setting, $allowHtml = false)
{
$value = $this->block->get('settings.' . $setting . '.value');
if (isset($this->data['settings']['attributes'][$setting])) {
$value = $this->data['settings']['attributes'][$setting];
}
return $allowHtml ? $value : phpb_e($value);
}
/**
* Return data of this block, passed as argument by a parent block.
*
* @param $key
* @return string
*/
public function data($key)
{
return $this->data[$key] ?? null;
}
/**
* Return data of the child block with the given relative ID.
*
* @param $childBlockId
* @return string
*/
public function childData($childBlockId)
{
return $this->data['blocks'][$childBlockId] ?? null;
}
}
@@ -0,0 +1,150 @@
<?php
namespace Plugi\Modules\GrapesJS\Block;
use Plugi\Modules\GrapesJS\PageRenderer;
use Plugi\ThemeBlock;
use Exception;
/**
* Class BlockAdapter
*
* Class for adapting a ThemeBlock into a JSON object understood by the GrapesJS page builder.
*
* @package Plugi\GrapesJS
*/
class BlockAdapter
{
/**
* @var PageRenderer $pageRenderer
*/
protected $pageRenderer;
/**
* @var ThemeBlock $block
*/
protected $block;
/**
* BlockAdapter constructor.
*
* @param PageRenderer $pageRenderer
* @param ThemeBlock $block
*/
public function __construct(PageRenderer $pageRenderer, ThemeBlock $block)
{
$this->pageRenderer = $pageRenderer;
$this->block = $block;
}
/**
* Return the slug identifying this type of theme block.
*
* @return string
*/
public function getSlug()
{
return $this->block->getSlug();
}
/**
* Return the visible title of this block.
*
* @return string
*/
public function getTitle()
{
if ($this->block->get('title')) {
return $this->block->get('title');
}
return str_replace('-', ' ', ucfirst($this->getSlug()));
}
/**
* Return the category this block belongs to.
*
* @return string|null
*/
public function getCategory()
{
if ($this->block->get('category')) {
return $this->block->get('category');
}
return phpb_trans('pagebuilder.default-category');
}
/**
* Return an array representation of the theme block, for adding as a block to GrapesJS.
*
* @return array
* @throws Exception
*/
public function getBlockManagerArray()
{
$content = $this->pageRenderer->renderBlock($this->block->getSlug());
$img = '';
if (file_exists($this->block->getThumbPath())) {
$img = '<div class="block-thumb" style="background-image: url(' . phpb_full_url($this->block->getThumbUrl()) . '); background-size: cover"></div>';
}
$data = [
'label' => $img . $this->getTitle(),
'category' => $this->getCategory(),
'content' => $content
];
if (! $img) {
$iconClass = 'fa fa-bars';
if ($this->block->get('icon')) {
$iconClass = $this->block->get('icon');
}
$data['attributes'] = ['class' => $iconClass];
}
return $data;
}
/**
* Return the array of settings of the theme block, for populating the settings tab in the GrapesJS sidebar.
*
* @return array
*/
public function getBlockSettingsArray()
{
$blockSettings = $this->block::getDynamicConfig($this->getSlug())['settings'] ?? $this->block->get('settings');
if ($this->block->isHtmlBlock() || ! is_array($blockSettings)) {
return [];
}
$settings = [];
foreach ($blockSettings as $name => $blockSetting) {
if (! isset($blockSetting['label'])) {
continue;
}
$type = $blockSetting['type'] ?? 'text';
$setting = [
'type' => $type,
'name' => $name,
'label' => $blockSetting['label'],
'default-value' => $blockSetting['value'] ?? '',
'placeholder' => $blockSetting['placeholder'] ?? '',
];
if ($type === 'select') {
$setting['options'] = $blockSetting['options'] ?? [];
} elseif ($type === 'yes_no') {
$setting['type'] = 'select';
$setting['options'] = [
['id' => 0, 'name' => phpb_trans('pagebuilder.no')],
['id' => 1, 'name' => phpb_trans('pagebuilder.yes')]
];
}
$settings[] = $setting;
}
return $settings;
}
}
@@ -0,0 +1,273 @@
<?php
namespace Plugi\Modules\GrapesJS\Block;
use Plugi\Contracts\PageContract;
use Plugi\Contracts\ThemeContract;
use Plugi\Extensions;
use Plugi\ThemeBlock;
class BlockRenderer
{
/**
* @var ThemeContract $theme
*/
protected $theme;
/**
* @var PageContract $page
*/
protected $page;
/**
* @var bool $forPageBuilder
*/
protected $forPageBuilder;
/**
* BlockRenderer constructor.
*
* @param ThemeContract $theme
* @param PageContract $page
* @param bool $forPageBuilder
*/
public function __construct(ThemeContract $theme, PageContract $page, $forPageBuilder = false)
{
$this->theme = $theme;
$this->page = $page;
$this->forPageBuilder = $forPageBuilder;
}
/**
* Change this BlockRenderer to render not editable blocks.
*
* @return $this
*/
public function notEditable()
{
$this->forPageBuilder = false;
return $this;
}
/**
* Change this BlockRenderer to render editable blocks.
*
* @return $this
*/
public function editable()
{
$this->forPageBuilder = true;
return $this;
}
/**
* Render a theme block with the given slug using the given block data.
*
* @param string $blockSlug
* @param array|null $blockData
* @param null $id id of the specific block instance
* @return string
*/
public function renderWithSlug(string $blockSlug, $blockData = null, $id = null)
{
$block = ($path = Extensions::getBlock($blockSlug))
? new ThemeBlock($this->theme, $path, true, $blockSlug)
: new ThemeBlock($this->theme, $blockSlug);
return $this->render($block, $blockData, $id);
}
/**
* Render the given theme block with the given stored block data.
*
* @param ThemeBlock $themeBlock
* @param array|null $blockData
* @param null $id id of the specific block instance
* @return string
*/
public function render(ThemeBlock $themeBlock, $blockData = null, $id = null)
{
$blockData = $blockData ?? [];
if ($themeBlock->isHtmlBlock()) {
$html = $this->renderHtmlBlock($themeBlock, $blockData);
} else {
$html = $this->renderDynamicBlock($themeBlock, $blockData);
}
$wrapperElement = $themeBlock->getWrapperElement();
if ($this->forPageBuilder) {
$id = $id ?? $themeBlock->getSlug();
$html = '<phpb-block block-slug="' . phpb_e($themeBlock->getSlug()) . '" block-id="' . phpb_e($id) . '" wrapper="' . $wrapperElement .'" is-html="' . ($themeBlock->isHtmlBlock() ? 'true' : 'false') . '">'
. $html . $this->renderBuilderScript($themeBlock)
. '</phpb-block>';
} else {
if (! $themeBlock->isHtmlBlock() && isset($blockData['settings']['attributes']['style-identifier'])) {
// add wrapper element around dynamic pagebuilder blocks, which receives the style identifier class if additional styling is added to the block via the pagebuilder
$html = '<' . $wrapperElement . ' class="' . phpb_e($blockData['settings']['attributes']['style-identifier']) . '">'
. $html . $this->renderScript($themeBlock)
. '</' . $wrapperElement . '>';
} else {
$html .= $this->renderScript($themeBlock);
}
}
return $html;
}
/**
* Render the pagebuilder script of the given block.
*
* @param ThemeBlock $themeBlock
* @return string
*/
public function renderBuilderScript(ThemeBlock $themeBlock)
{
$builderScriptFilePath = $themeBlock->getBuilderScriptFile();
if ($builderScriptFilePath) {
if (pathinfo($builderScriptFilePath)['extension'] === 'php') {
ob_start();
require $builderScriptFilePath;
$scriptHtmlString = ob_get_contents();
ob_end_clean();
} else {
$scriptHtmlString = file_get_contents($builderScriptFilePath);
}
return '<script>' . $this->removeWrappedScriptTags($scriptHtmlString) . '</script>';
}
// if no builder script was specified, fallback to using the general script (if provided)
return $this->renderScript($themeBlock, true);
}
/**
* Render the script of the given block for rendering the block on a publicly accessible web page.
*
* @param ThemeBlock $themeBlock
* @param bool $forPageBuilder
* @return string
*/
public function renderScript(ThemeBlock $themeBlock, bool $forPageBuilder = false)
{
$scriptFilePath = $themeBlock->getScriptFile();
if ($scriptFilePath) {
if (pathinfo($scriptFilePath)['extension'] === 'php') {
ob_start();
require $scriptFilePath;
$scriptHtmlString = ob_get_contents();
ob_end_clean();
} else {
$scriptHtmlString = file_get_contents($scriptFilePath);
}
$script = $this->removeWrappedScriptTags($scriptHtmlString);
if ($forPageBuilder) {
return '<script>' . $script . '</script>';
} else {
return $this->wrapScriptWithScopeAndContextData($script);
}
}
return '';
}
/**
* Remove script tags wrapped around to given JavaScript string, if they are present.
* This is necessary if the script is coming from a .html or .php file.
*
* @param $scriptHtmlString
* @return string
*/
protected function removeWrappedScriptTags($scriptHtmlString)
{
return str_replace('<script>', '', str_replace('</script>', '', $scriptHtmlString));
}
/**
* Wrap the given javascript with a script tag that has a unique id,
* add a scope around the script and add context data giving the script access to the exact block instance in the DOM.
*
* @param $script
* @return string
*/
protected function wrapScriptWithScopeAndContextData($script)
{
$scriptId = 'script' . rand(0, 10000000000);
$html = '<script type="text/javascript" class="' . $scriptId . '">';
$html .= 'document.getElementsByClassName("' . $scriptId . '")[0].addEventListener("run-script", function() {';
$html .= 'let inPageBuilder = false;';
$html .= 'let block = document.getElementsByClassName("' . $scriptId . '")[0].previousSibling;';
$html .= 'let blockSelector = "." + block.className;';
$html .= $script;
$html .= '});';
$html .= '</script>';
return $html;
}
/**
* Render the given html theme block with the given stored block data.
*
* @param ThemeBlock $themeBlock
* @param $blockData
* @return string
*/
protected function renderHtmlBlock(ThemeBlock $themeBlock, $blockData)
{
if ($themeBlock->getControllerFile()) {
require_once $themeBlock->getControllerFile();
$controllerClass = $themeBlock->getControllerClass();
$controller = new $controllerClass;
$model = new BaseModel($themeBlock, $blockData, $this->page, $this->forPageBuilder);
$controller->init($model, $this->page, $this->forPageBuilder);
$controller->handleRequest();
}
if (isset($blockData['html'])) {
$html = $blockData['html'];
} else {
$html = file_get_contents($themeBlock->getViewFile());
}
return $html;
}
/**
* Render the given dynamic theme block with the given stored block data.
*
* @param ThemeBlock $themeBlock
* @param $blockData
* @return string
*/
protected function renderDynamicBlock(ThemeBlock $themeBlock, $blockData)
{
$blockData = $blockData ?? [];
$controller = new BaseController;
$model = new BaseModel($themeBlock, $blockData, $this->page, $this->forPageBuilder);
if ($themeBlock->getModelFile()) {
require_once $themeBlock->getModelFile();
$modelClass = $themeBlock->getModelClass();
$model = new $modelClass($themeBlock, $blockData, $this->page, $this->forPageBuilder);
}
if ($themeBlock->getControllerFile()) {
require_once $themeBlock->getControllerFile();
$controllerClass = $themeBlock->getControllerClass();
$controller = new $controllerClass;
}
$controller->init($model, $this->page, $this->forPageBuilder);
$controller->handleRequest();
// init additional variables that should be accessible in the view
$renderer = $this;
$page = $this->page;
$block = $model;
// unset variables that should be inaccessible inside the view
unset($controller, $model, $blockData);
ob_start();
require $themeBlock->getViewFile();
$html = ob_get_contents();
ob_end_clean();
return $html;
}
}
@@ -0,0 +1,387 @@
<?php
namespace Plugi\Modules\GrapesJS;
use Plugi\Contracts\PageBuilderContract;
use Plugi\Contracts\PageContract;
use Plugi\Contracts\ThemeContract;
use Plugi\Modules\GrapesJS\Block\BlockAdapter;
use Plugi\Modules\GrapesJS\Thumb\ThumbGenerator;
use Plugi\Modules\GrapesJS\Upload\Uploader;
use Plugi\Repositories\PageRepository;
use Plugi\Repositories\UploadRepository;
use Exception;
class PageBuilder implements PageBuilderContract
{
/**
* @var ThemeContract $theme
*/
protected $theme;
/**
* @var array $scripts
*/
protected $scripts = [];
/**
* @var string $css
*/
protected $css;
/**
* PageBuilder constructor.
*/
public function __construct()
{
$this->theme = phpb_instance('theme', [
phpb_config('theme'),
phpb_config('theme.active_theme')
]);
}
/**
* Set the theme used while rendering pages in the page builder.
*
* @param ThemeContract $theme
*/
public function setTheme(ThemeContract $theme)
{
$this->theme = $theme;
}
/**
* Process the current GET or POST request and redirect or render the requested page.
*
* @param $route
* @param $action
* @param PageContract|null $page
* @return bool
* @throws Exception
*/
public function handleRequest($route, $action, PageContract $page = null)
{
phpb_set_in_editmode();
if ($route === 'thumb_generator') {
$thumbGenerator = new ThumbGenerator($this->theme);
return $thumbGenerator->handleThumbRequest($action);
}
if (is_null($page)) {
$pageId = $_GET['page'] ?? null;
$pageRepository = new PageRepository;
$page = $pageRepository->findWithId($pageId);
}
if (! ($page instanceof PageContract)) {
return false;
}
switch ($action) {
case null:
case 'edit':
$this->renderPageBuilder($page);
exit();
break;
case 'store':
if (isset($_POST) && isset($_POST['data'])) {
$data = json_decode($_POST['data'], true);
$this->updatePage($page, $data);
exit();
}
break;
case 'upload':
if (isset($_FILES)) {
$this->handleFileUpload();
}
break;
case 'upload_delete':
if (isset($_POST['id'])) {
$this->handleFileDelete();
}
break;
case 'renderBlock':
if (isset($_POST['language']) && isset($_POST['data']) && isset(phpb_active_languages()[$_POST['language']])) {
$this->renderPageBuilderBlock($page, $_POST['language'], json_decode($_POST['data'], true));
exit();
}
break;
case 'renderLanguageVariant':
if (isset($_POST['language']) && isset($_POST['data']) && isset(phpb_active_languages()[$_POST['language']])) {
$this->renderLanguageVariant($page, $_POST['language'], json_decode($_POST['data'], true));
exit();
}
break;
}
return false;
}
/**
* Handle uploading of the posted file.
*
* @throws Exception
*/
public function handleFileUpload()
{
$publicId = sha1(uniqid(rand(), true));
$uploader = phpb_instance(Uploader::class, ['files']);
$uploader
->file_name($publicId . '/' . str_replace(' ', '-', $uploader->file_src_name))
->upload_to(phpb_config('storage.uploads_folder') . '/')
->run();
if (! $uploader->was_uploaded) {
die("Upload error: {$uploader->error}");
} else {
$originalFile = str_replace(' ', '-', $uploader->file_src_name);
$originalMime = $uploader->file_src_mime;
$serverFile = $uploader->final_file_name;
$uploadRepository = new UploadRepository;
$uploadedFile = $uploadRepository->create([
'public_id' => $publicId,
'original_file' => $originalFile,
'mime_type' => $originalMime,
'server_file' => $serverFile
]);
echo json_encode([
'data' => [
'public_id' => $publicId,
'src' => $uploadedFile->getUrl(),
'type' => 'image'
]
]);
exit();
}
}
/**
* Handle deleting of the posted previously uploaded file.
*/
public function handleFileDelete()
{
$uploadRepository = new UploadRepository;
$uploadedFileResult = $uploadRepository->findWhere('public_id', $_POST['id']);
if (empty($uploadedFileResult)) {
echo json_encode([
'success' => false,
'message' => 'File not found'
]);
exit();
}
$uploadedFile = $uploadedFileResult[0];
$uploadRepository->destroy($uploadedFile->id);
$serverFilePath = realpath(phpb_config('storage.uploads_folder') . '/' . $uploadedFile->server_file);
if ($serverFilePath) {
unlink($serverFilePath);
}
$parentDirectory = realpath(phpb_config('storage.uploads_folder') . '/' . dirname($uploadedFile->server_file));
if ($parentDirectory && dirname($uploadedFile->server_file) !== '.') {
rmdir($parentDirectory);
}
echo json_encode([
'success' => true
]);
exit();
}
/**
* Render the PageBuilder for the given page.
*
* @param PageContract $page
* @throws Exception
*/
public function renderPageBuilder(PageContract $page)
{
phpb_set_in_editmode();
// init variables that should be accessible in the view
$pageBuilder = $this;
$pageRenderer = phpb_instance(PageRenderer::class, [$this->theme, $page, true]);
if (! empty($_SESSION['plugi_language'])) {
$pageRenderer->setLanguage($_SESSION['plugi_language']);
}
// create an array of theme blocks and theme block settings for in the page builder sidebar
$blocks = [];
$blockSettings = [];
foreach ($this->theme->getThemeBlocks() as $themeBlock) {
$slug = phpb_e($themeBlock->getSlug());
$adapter = phpb_instance(BlockAdapter::class, [$pageRenderer, $themeBlock]);
if ($themeBlock->get('hidden') !== true) {
$blocks[$slug] = $adapter->getBlockManagerArray();
}
$blockSettings[$slug] = $adapter->getBlockSettingsArray();
}
// create an array of all uploaded assets
$assets = [];
foreach ((new UploadRepository)->getAll() as $file) {
$assets[] = [
'src' => $file->getUrl(),
'public_id' => $file->public_id
];
}
require __DIR__ . '/resources/views/layout.php';
}
/**
* Render the given page.
*
* @param PageContract $page
* @param null $language
* @return string
*/
public function renderPage(PageContract $page, $language = null): string
{
$pageRenderer = phpb_instance(PageRenderer::class, [$this->theme, $page]);
if (! is_null($language)) {
$pageRenderer->setLanguage($language);
}
return $pageRenderer->render();
}
/**
* Render in context of the given page, the given block with the passed settings, for updating the page builder.
*
* @param PageContract $page
* @param string $language
* @param array $blockData
* @throws Exception
*/
public function renderPageBuilderBlock(PageContract $page, string $language, $blockData = [])
{
phpb_set_in_editmode();
$blockData = is_array($blockData) ? $blockData : [];
$page->setData(['data' => $blockData], false);
$pageRenderer = phpb_instance(PageRenderer::class, [$this->theme, $page, true]);
$pageRenderer->setLanguage($language);
echo $pageRenderer->parseShortcodes($blockData['html'], $blockData['blocks']);
}
/**
* Render the given page in the given language using the given block data.
*
* @param PageContract $page
* @param string $language
* @param array $blockData
* @throws Exception
*/
public function renderLanguageVariant(PageContract $page, string $language, $blockData = [])
{
phpb_set_in_editmode();
$_SESSION['plugi_language'] = $language;
$blockData = is_array($blockData) ? $blockData : [];
$page->setData(['data' => $blockData], false);
$pageRenderer = phpb_instance(PageRenderer::class, [$this->theme, $page, true]);
$pageRenderer->setLanguage($language);
echo json_encode([
'dynamicBlocks' => $pageRenderer->getPageBlocksData()[$language]
]);
}
/**
* Update the given page with the given data (an array of html blocks).
*
* @param PageContract $page
* @param $data
* @return bool|object|null
*/
public function updatePage(PageContract $page, $data)
{
$pageRepository = new PageRepository;
return $pageRepository->updatePageData($page, $data);
}
/**
* Return the list of all pages, used in CKEditor link editor.
*
* @return array
*/
public function getPages()
{
$pages = [];
$pageRepository = new PageRepository;
foreach ($pageRepository->getAll() as $page) {
$pages[] = [
phpb_e($page->getName()),
phpb_e($page->getId())
];
}
return $pages;
}
/**
* Return this page's components in the format passed to GrapesJS.
*
* @param PageContract $page
* @return array
*/
public function getPageComponents(PageContract $page)
{
$data = $page->getBuilderData();
$components = $data['components'] ?? [0 => []];
// backwards compatibility, components are now stored for each main container (@todo: remove this at the first mayor version)
if (isset($components[0]) && ! empty($components[0]) && ! isset($components[0][0])) {
$components = [0 => $components];
}
return $components;
}
/**
* Return this page's style in the format passed to GrapesJS.
*
* @param PageContract $page
* @return array
*/
public function getPageStyleComponents(PageContract $page)
{
$data = $page->getBuilderData();
if (isset($data['style'])) {
return $data['style'];
}
return [];
}
/**
* Get or set custom css for customizing layout of the page builder.
*
* @param string|null $css
* @return string
*/
public function customStyle(string $css = null)
{
if (! is_null($css)) {
$this->css = $css;
}
return $this->css;
}
/**
* Get or set custom scripts for customizing behaviour of the page builder.
*
* @param string $location head|body
* @param string|null $scripts
* @return string
*/
public function customScripts(string $location, string $scripts = null)
{
if (! is_null($scripts)) {
$this->scripts[$location] = $scripts;
}
return $this->scripts[$location] ?? '';
}
}
@@ -0,0 +1,325 @@
<?php
namespace Plugi\Modules\GrapesJS;
use Plugi\Contracts\PageContract;
use Plugi\Contracts\ThemeContract;
use Plugi\Modules\GrapesJS\Block\BlockRenderer;
use Plugi\ThemeBlock;
use Exception;
use Plugi\Extensions;
class PageRenderer
{
/**
* @var ThemeContract $theme
*/
protected $theme;
/**
* @var PageContract $page
*/
protected $page;
/**
* @var array $pageData
*/
protected $pageData;
/**
* @var array $pageBlocksData
*/
protected $pageBlocksData;
/**
* @var ShortcodeParser $shortcodeParser
*/
protected $shortcodeParser;
/**
* @var bool $forPageBuilder
*/
protected $forPageBuilder;
/**
* @var string $language
*/
protected $language;
/**
* @var bool $canBeCached
*/
public static $canBeCached;
/**
* The maximum number of minutes this page should be cached, one week by default.
*
* @var int $cacheLifetime
*/
public static $cacheLifetime = 7*24*60;
/**
* PageRenderer constructor.
*
* @param ThemeContract $theme
* @param PageContract $page
* @param bool $forPageBuilder
*/
public function __construct(ThemeContract $theme, PageContract $page, $forPageBuilder = false)
{
$this->theme = $theme;
$this->page = $page;
$this->pageData = $page->getBuilderData();
$this->shortcodeParser = phpb_instance(ShortcodeParser::class, [$this]);
$this->setLanguage(phpb_current_language());
$this->forPageBuilder = $forPageBuilder;
}
/**
* Set which page language variant to use while rendering.
*
* @param $language
*/
public function setLanguage($language)
{
// if the given language is unknown, default the set language to the first available language
$blockKeysAreLanguages = true;
$supportedLanguages = array_keys($this->pageData['blocks'] ?? []);
// check whether keys are valid languages (renderPageBuilderBlock uses pageData without language data)
foreach ($supportedLanguages as $supportedLanguage) {
if (strlen($supportedLanguage) > 5) {
$blockKeysAreLanguages = false;
break;
}
}
if ($blockKeysAreLanguages) {
if (! in_array($language, $supportedLanguages)) {
$language = $supportedLanguages[0] ?? $language;
}
}
$this->language = $language;
$this->pageBlocksData = $this->getStoredPageBlocksData();
$this->shortcodeParser->setLanguage($language);
}
/**
* Return the absolute path to the layout view of this page.
*
* @return string|null
*/
public function getPageLayoutPath()
{
$layout = basename($this->page->getLayout());
$layoutPath = $this->theme->getFolder() . '/layouts/' . $layout . '/view.php';
if ($path = Extensions::getLayout($layout)) {
$layoutPath = $path . '/view.php';
}
return file_exists($layoutPath) ? $layoutPath : null;
}
/**
* Set whether the currently rendered page can be cached.
*
* @param bool $canBeCached
* @param string|null $cacheLifetime
*/
public static function setCanBeCached(bool $canBeCached, $cacheLifetime = null)
{
if (! $canBeCached || ($cacheLifetime && intval($cacheLifetime) <= 0)) {
static::$canBeCached = false;
} elseif ($cacheLifetime) {
static::$cacheLifetime = min(static::$cacheLifetime, intval($cacheLifetime));
}
}
/**
* Return whether the rendered page can be cached.
* I.e. no blocks were encountered with content that varies per page load.
*
* @return bool
*/
public static function canBeCached(): bool
{
return static::$canBeCached ?? true;
}
/**
* Return the maximum number of minutes the rendered page should be cached.
*
* @return int
*/
public static function getCacheLifetime(): int
{
if (! static::canBeCached()) {
return 0;
}
return static::$cacheLifetime;
}
/**
* Return an array with for each block of this page the stored html and settings data.
*
* @return array
*/
public function getStoredPageBlocksData()
{
return $this->pageData['blocks'][$this->language] ?? $this->pageData['blocks'] ?? [];
}
/**
* Return the rendered version of the page.
*
* @return string
* @throws Exception
*/
public function render()
{
// init variables that should be accessible in the view
$renderer = $this;
$page = $this->page;
if ($this->forPageBuilder) {
$body = '<div phpb-content-container="true"></div>';
} else {
$body = $this->renderBody();
}
$layoutPath = $this->getPageLayoutPath();
if ($layoutPath) {
ob_start();
require $layoutPath;
$pageHtml = ob_get_contents();
ob_end_clean();
} else {
$pageHtml = $body;
}
// parse any shortcodes present in the page layout
$pageHtml = $this->parseShortcodes($pageHtml);
return $pageHtml;
}
/**
* Return the page body for display on the website.
* The body contains all blocks which are put into the selected layout.
*
* @param int $mainContainerIndex
* @return string
* @throws Exception
*/
public function renderBody($mainContainerIndex = 0)
{
$html = '';
$data = $this->pageData;
if (isset($data['html']) && is_array($data['html'])) {
$html = $this->parseShortcodes($data['html'][$mainContainerIndex]);
// render html for each content container, to ensure all rendered blocks are accessible in the pagebuilder
if (phpb_in_editmode()) {
foreach ($data['html'] as $contentContainerHtml) {
$this->parseShortcodes($contentContainerHtml);
}
}
}
// backwards compatibility, html stored for only one layout container (@todo: remove this at the first mayor version)
if (isset($data['html']) && is_string($data['html'])) {
$html = $this->parseShortcodes($data['html']);
}
// include any style changes made via the page builder
if (isset($data['css'])) {
$html .= '<style>' . $data['css'] . '</style>';
}
return $html;
}
/**
* Return a fully rendered theme block (including children blocks) with the given slug, data instance id and data context.
* This method is called while parsing shortcodes.
*
* @param $slug
* @param null $id the id with which data for this block is stored
* @param null $context
* @param int $maxDepth
* @return string
* @throws Exception
*/
public function renderBlock($slug, $id = null, $context = null, $maxDepth = 25)
{
$themeBlock = ($blockPath = Extensions::getBlock($slug))
? new ThemeBlock($this->theme, $blockPath, true, $slug)
: new ThemeBlock($this->theme, $slug);
$id = $id ?? $themeBlock->getSlug();
$context = $context[$id] ?? $this->pageBlocksData[$id] ?? [];
$blockRenderer = new BlockRenderer($this->theme, $this->page, $this->forPageBuilder);
$renderedBlock = $blockRenderer->render($themeBlock, $context ?? [], $id);
// determine the context for rendering nested blocks
// if the current block is a html block, the context starts again at full page data
// if the current block is a dynamic block, use the nested block data inside the current block's context
$context = $context['blocks'] ?? [];
if ($themeBlock->isHtmlBlock()) {
$context = $this->pageBlocksData;
}
return $this->shortcodeParser->doShortcodes($renderedBlock, $context, $maxDepth - 1);
}
/**
* Parse the given html with shortcodes to fully rendered html.
*
* @param string $htmlWithShortcodes
* @param array $context the data for each block to be used while parsing the shortcodes
* @return string
* @throws Exception
*/
public function parseShortcodes(string $htmlWithShortcodes, $context = null)
{
$context = $context ?? $this->pageBlocksData;
return $this->shortcodeParser->doShortcodes($htmlWithShortcodes, $context);
}
/**
* Return this page's blocks data to be loaded into the page edited inside GrapesJS.
*
* @return array
* @throws Exception
*/
public function getPageBlocksData()
{
$initialLanguage = $this->language;
// remove the already rendered blocks
$this->shortcodeParser->resetRenderedBlocks();
// create the structure of page blocks data for each language
$pageBlocks = [];
foreach (phpb_active_languages() as $languageCode => $languageTranslation) {
$this->setLanguage($languageCode);
// for the current language build up a structure of rendered versions and use the stored data for the other languages
if ($languageCode === $initialLanguage) {
$this->renderBody();
$pageBlocks[$languageCode] = $this->shortcodeParser->getRenderedBlocks()[$languageCode] ?? [];
} else {
$pageBlocks[$languageCode] = $this->pageBlocksData;
}
if (empty($pageBlocks[$languageCode])) {
$pageBlocks[$languageCode] = null;
}
}
// revert to initial language
$this->setLanguage($initialLanguage);
// return the rendered html and settings for each block
return $pageBlocks;
}
}
@@ -0,0 +1,276 @@
<?php
namespace Plugi\Modules\GrapesJS;
use Plugi\Repositories\PageRepository;
use Exception;
class ShortcodeParser
{
/**
* @var PageRenderer $pageRenderer
*/
protected $pageRenderer;
/**
* @var array $renderedBlocks
*/
protected $renderedBlocks;
/**
* @var array $pages
*/
protected $pages = [];
/**
* @var string $language
*/
protected $language;
/**
* ShortcodeParser constructor.
*
* @param PageRenderer $pageRenderer
*/
public function __construct(PageRenderer $pageRenderer)
{
$this->pageRenderer = $pageRenderer;
$this->renderedBlocks = [];
$pageRepository = new PageRepository;
foreach ($pageRepository->getAll(['id']) as $page) {
$this->pages[$page->getId()] = $page->getRoute();
}
}
/**
* Set the current language.
*
* @param $language
*/
public function setLanguage($language)
{
$this->language = $language;
}
/**
* Perform the tasks for all shortcodes in the given html string.
*
* @param $html
* @param array $context
* @param int $maxDepth
* @return mixed|string
* @throws Exception
*/
public function doShortcodes($html, array $context = [], $maxDepth = 25)
{
if ($maxDepth === 0) {
throw new Exception("Maximum doShortcodes depth has been reached, "
. "probably due to a circular shortcode reference in one of the theme blocks.");
}
$html = $this->doBlockShortcodes($html, $context, $maxDepth);
$html = $this->doPageShortcodes($html);
$html = $this->doThemeUrlShortcodes($html);
$html = $this->doBlocksContainerShortcodes($html);
return $html;
}
/**
* Render all blocks defined with shortcodes in the given html string.
*
* @param string $html
* @param array $context
* @param int $maxDepth
* @return string
* @throws Exception
*/
protected function doBlockShortcodes($html, array $context, $maxDepth)
{
$matches = self::findMatches('block', $html);
if (empty($matches)) {
return $html;
}
foreach ($matches as $match) {
if (! isset($match['attributes']['slug'])) {
continue;
}
$slug = $match['attributes']['slug'];
$id = $match['attributes']['id'] ?? $slug;
if (isset($context[$id]['settings']['attributes'])) {
foreach ($match['attributes'] as $attribute => $value) {
if (in_array($attribute, ['id', 'slug'])) {
continue;
}
$context[$id]['settings']['attributes'][$attribute] = $value;
}
}
$blockHtml = $this->pageRenderer->renderBlock($slug, $id, $context, $maxDepth);
// store rendered block in a structure used for outputting all blocks to the pagebuilder
if (phpb_in_editmode() && strpos($id, 'ID') === 0) {
$this->renderedBlocks[$this->language][$id] = $context[$id] ?? [];
$this->renderedBlocks[$this->language][$id]['html'] = $blockHtml;
}
// replace shortcode match with the $blockHtml (note: this replaces only the first match)
$pos = strpos($html, $match['shortcode']);
if ($pos !== false) {
$html = substr_replace($html, $blockHtml, $pos, strlen($match['shortcode']));
}
}
return $html;
}
/**
* Replace all page shortcodes for the corresponding absolute page url.
* @todo this currently replaces the shortcode with page route instead of URL
*
* @param $html
* @return mixed
*/
protected function doPageShortcodes($html)
{
if (phpb_in_editmode()) {
return $html;
}
$matches = self::findMatches('page', $html);
if (empty($matches)) {
return $html;
}
foreach ($matches as $match) {
if (! isset($match['attributes']['id'])) {
continue;
}
$pageId = $match['attributes']['id'];
$route = '';
if (isset($this->pages[$pageId])) {
$route = $this->pages[$pageId];
}
$html = str_replace($match['shortcode'], $route, $html);
}
return $html;
}
/**
* Replace all [theme-url] shortcodes for the absolute URL to the theme's public folder.
*
* @param $html
* @return mixed
*/
protected function doThemeUrlShortcodes($html)
{
$matches = self::findMatches('theme-url', $html);
if (empty($matches)) {
return $html;
}
foreach ($matches as $match) {
$themeUrl = phpb_config('theme.folder_url') . '/' . phpb_e(phpb_config('theme.active_theme'));
$html = str_replace($match['shortcode'], $themeUrl, $html);
}
return $html;
}
/**
* Replace all [blocks-container] shortcodes for a <div phpb-blocks-container></div>
*
* @param $html
* @return mixed
*/
protected function doBlocksContainerShortcodes($html)
{
$matches = self::findMatches('blocks-container', $html);
if (empty($matches)) {
return $html;
}
foreach ($matches as $match) {
$replacement = '<div phpb-blocks-container></div>';
$html = str_replace($match['shortcode'], $replacement, $html);
}
return $html;
}
/**
* Return all matches of the given shortcode in the given html string.
*
* @param $shortcode
* @param $html
* @return array an array with for each $shortcode occurrence an array of attributes
*/
public static function findMatches($shortcode, $html)
{
// RegEx: https://www.regextester.com/104625
$regex = '/\[' . $shortcode . '(\s.*?)?\](?:([^\[]+)?\[\/' . $shortcode . '\])?/';
preg_match_all($regex, $html, $pregMatchAll);
$fullMatches = $pregMatchAll[0];
$matchAttributeStrings = $pregMatchAll[1];
// loop through the attribute strings of each $shortcode instance and add the parsed variants to $matches
$matches = [];
foreach ($matchAttributeStrings as $i => $matchAttributeString) {
$matchAttributeString = trim($matchAttributeString);
// as long as there are attributes in the attributes string, add them to $attributes
$attributes = [];
while (strpos($matchAttributeString, '=') !== false) {
list($attribute, $remainingString) = explode('=', $matchAttributeString, 2);
$attribute = trim($attribute);
// if first char is " and at least two " exist, get attribute value between ""
if (strpos($remainingString, '"') === 0 && strpos($remainingString, '"', 1) !== false) {
list($empty, $value, $remainingString) = explode('"', $remainingString, 3);
$attributes[$attribute] = $value;
} else {
// attribute value was not between "", get value until next whitespace or until end of $remainingString
if (strpos($remainingString, ' ') !== false) {
list($value, $remainingString) = explode(' ', $remainingString, 2);
$attributes[$attribute] = $value;
} else {
$attributes[$attribute] = $remainingString;
$remainingString = '';
}
}
$matchAttributeString = $remainingString;
}
$matches[] = [
'shortcode' => $fullMatches[$i],
'attributes' => $attributes
];
}
return $matches;
}
/**
* Reset the structure of all rendered blocks.
*/
public function resetRenderedBlocks()
{
$this->renderedBlocks = [];
}
/**
* Return the array of all blocks rendered while parsing shortcodes.
*
* @return array
*/
public function getRenderedBlocks()
{
return $this->renderedBlocks;
}
}
@@ -0,0 +1,153 @@
<?php
namespace Plugi\Modules\GrapesJS\Thumb;
use Plugi\Contracts\ThemeContract;
use Plugi\Modules\GrapesJS\PageRenderer;
use Plugi\Page;
use Plugi\ThemeBlock;
use Exception;
class ThumbGenerator
{
/**
* @var ThemeContract $theme
*/
protected $theme;
/**
* ThumbGenerator constructor.
*
* @param ThemeContract $theme
*/
public function __construct(ThemeContract $theme)
{
$this->theme = $theme;
}
/**
* Handle requests to render and store block thumbnails.
*
* @param $action
* @return bool
* @throws Exception
*/
public function handleThumbRequest($action)
{
phpb_set_in_editmode();
if ($action === 'renderNextBlockThumb') {
$this->renderNextBlockThumb();
exit();
}
if ($action === 'upload' && isset($_POST) && isset($_POST['block']) && isset($_POST['data'])) {
foreach ($this->theme->getThemeBlocks() as $block) {
if ($_POST['block'] === $block->getSlug()) {
$this->r_mkdir(dirname($block->getThumbPath()));
$file = fopen($block->getThumbPath(), "wb");
fwrite($file, $this->getRawData($_POST['data']));
fclose($file);
exit();
}
}
}
return false;
}
/**
* Create directories recursively.
*
* @param string $path Path to create
* @param integer $mode Optional permissions
* @return boolean Success
*/
protected function r_mkdir($path, $mode = 0777) {
return is_dir($path) || ( $this->r_mkdir(dirname($path), $mode) && $this->_mkdir($path, $mode) );
}
/**
* Create directory.
*
* @param string $path Path to create
* @param integer $mode Optional permissions
* @return boolean Success
*/
protected function _mkdir($path, $mode = 0777) {
$old = umask(0);
$res = @mkdir($path, $mode);
umask($old);
return $res;
}
/**
* Return binary image data from the given base64 encoded string.
*
* @param $base64ImageData
* @return string
* @throws Exception
*/
protected function getRawData($base64ImageData)
{
if (preg_match('/^data:image\/(\w+);base64,/', $base64ImageData, $type)) {
$data = substr($base64ImageData, strpos($base64ImageData, ',') + 1);
$type = strtolower($type[1]);
if (! in_array($type, ['jpg', 'jpeg', 'png'])) {
throw new Exception('Invalid image type');
}
$data = base64_decode($data);
if ($data === false) {
throw new Exception('Decode failed');
}
return $data;
} else {
throw new Exception('Invalid data URI');
}
}
/**
* Render the next missing or outdated thumb of the given theme.
*
* @throws Exception
*/
public function renderNextBlockThumb()
{
foreach ($this->theme->getThemeBlocks() as $block) {
$this->renderThumbForBlock($block);
}
}
/**
* Render a thumbnail for the given block, if no thumb is present or if the thumb needs an update.
*
* @param ThemeBlock $block
* @throws Exception
*/
public function renderThumbForBlock(ThemeBlock $block)
{
phpb_set_in_editmode();
$thumbPath = $block->getThumbPath();
if (file_exists($thumbPath)) {
return;
}
$page = phpb_instance('page');
$page->setData([
'layout' => 'master',
'data' => [
'html' => [
0 => '[block slug="' . $block->getSlug() . '"]'
]
]
]);
$renderer = phpb_instance(PageRenderer::class, [$this->theme, $page]);
echo $renderer->render();
$blockSlug = $block->getSlug();
require __DIR__ . '/generator-view.php';
exit();
}
}
@@ -0,0 +1,38 @@
<style>
html, body {
padding: 0;
margin: 0;
}
/* hide block placeholders */
[phpb-hide-if-not-editable] {
display:none;
}
</style>
<script src="<?= phpb_asset('pagebuilder/html2canvas-v0.4.1.min.js') ?>"></script>
<script>
$(document).ready(function() {
html2canvas($("body"), {
allowTaint: false,
useCORS: true,
height: $("body").outerHeight(),
onrendered: function(canvas) {
let data = canvas.toDataURL();
//document.body.append(canvas);
$.ajax({
type: "POST",
url: "<?= phpb_url('pagebuilder', ['route' => 'thumb_generator', 'action' => 'upload']) ?>",
data: {
block: "<?= $blockSlug ?>",
data: data
},
success: function() {
window.parent.postMessage("thumb-saved", '*');
},
error: function() {
}
});
}
});
});
</script>
@@ -0,0 +1,236 @@
<?php
namespace Plugi\Modules\GrapesJS\Upload;
use Exception;
/**
* Class for resizing images.
*
* Credits: https://github.com/brunoribeiro94/php-upload
*
* Can resize to:
* - exact image size
* - max width size while maintaining aspect ratio
* - max height size while maintaining aspect ratio
* - automatic dimensions maintaining aspect ratio
*
* @package Plugi\Modules\GrapesJS\Upload
*/
class ResizeImage {
/**
* Image extension.
*
* @var string
*/
protected $ext;
/**
* Created image.
*
* @var string
*/
protected $image;
/**
* Name of new image.
*
* @var string
*/
protected $newImage;
/**
* Original image width.
*
* @var integer
*/
protected $origWidth;
/**
* Original image height.
*
* @var integer
*/
protected $origHeight;
/**
* New image width.
*
* @var integer
*/
protected $resizeWidth;
/**
* New image height.
*
* @var integer
*/
protected $resizeHeight;
/**
* Class constructor requires to send through the image filename.
*
* @param string $filename filename of the image you want to resize
* @throws Exception
*/
public function __construct($filename) {
if (file_exists($filename)) {
$this->setImage($filename);
} else {
throw new Exception('Image ' . $filename . ' can not be found, try another image.');
}
}
/**
* Set the image variable by using image create.
*
* @param string $filename the image filename
* @throws Exception
*/
protected function setImage($filename) {
$size = getimagesize($filename);
$this->ext = $size['mime'];
switch ($this->ext) {
// Image is a JPG
case 'image/jpg':
case 'image/jpeg':
// create a jpeg extension
$this->image = imagecreatefromjpeg($filename);
break;
// Image is a GIF
case 'image/gif':
$this->image = @imagecreatefromgif($filename);
break;
// Image is a PNG
case 'image/png':
$this->image = @imagecreatefrompng($filename);
break;
// Mime type not found
default:
throw new Exception("File is not an image, please use another file type.", 1);
}
$this->origWidth = imagesx($this->image);
$this->origHeight = imagesy($this->image);
}
/**
* Save the image as the image type the original image was.
*
* @param string $savePath the path to store the new image
* @param string $imageQuality the quality level of image to create
*/
public function saveImage($savePath, $imageQuality = "100") {
switch ($this->ext) {
case 'image/jpg':
case 'image/jpeg':
// Check PHP supports this file type
if (imagetypes() & IMG_JPG) {
imagejpeg($this->newImage, $savePath, $imageQuality);
}
break;
case 'image/gif':
// Check PHP supports this file type
if (imagetypes() & IMG_GIF) {
imagegif($this->newImage, $savePath);
}
break;
case 'image/png':
$invertScaleQuality = 9 - round(($imageQuality / 100) * 9);
// Check PHP supports this file type
if (imagetypes() & IMG_PNG) {
imagepng($this->newImage, $savePath, $invertScaleQuality);
}
break;
}
imagedestroy($this->newImage);
}
/**
* Resize the image to the given dimensions.
*
* @param integer $width max width of the image
* @param integer $height max height of the image
* @param string $resizeOption scale option for the image
*/
public function resizeTo($width, $height, $resizeOption = 'default') {
switch (strtolower($resizeOption)) {
case 'exact':
$this->resizeWidth = $width;
$this->resizeHeight = $height;
break;
case 'maxwidth':
$this->resizeWidth = $width;
$this->resizeHeight = $this->resizeHeightByWidth($width);
break;
case 'maxheight':
$this->resizeWidth = $this->resizeWidthByHeight($height);
$this->resizeHeight = $height;
break;
case 'proportionally':
$ratio_orig = $this->origWidth / $this->origHeight;
$this->resizeWidth = $width;
$this->resizeHeight = $height;
if ($width / $height > $ratio_orig)
$this->resizeWidth = $height * $ratio_orig;
else
$this->resizeHeight = $width / $ratio_orig;
break;
default:
if ($this->origWidth > $width || $this->origHeight > $height) {
if ($this->origWidth > $this->origHeight) {
$this->resizeHeight = $this->resizeHeightByWidth($width);
$this->resizeWidth = $width;
} else if ($this->origWidth < $this->origHeight) {
$this->resizeWidth = $this->resizeWidthByHeight($height);
$this->resizeHeight = $height;
} else {
$this->resizeWidth = $width;
$this->resizeHeight = $height;
}
} else {
$this->resizeWidth = $width;
$this->resizeHeight = $height;
}
break;
}
$this->newImage = imagecreatetruecolor($this->resizeWidth, $this->resizeHeight);
if ($this->ext == "image/gif" || $this->ext == "image/png") {
imagealphablending($this->newImage, false);
imagesavealpha($this->newImage, true);
$transparent = imagecolorallocatealpha($this->newImage, 255, 255, 255, 127);
imagefilledrectangle($this->newImage, 0, 0, $this->resizeWidth, $this->resizeHeight, $transparent);
}
imagecopyresampled($this->newImage, $this->image, 0, 0, 0, 0, $this->resizeWidth, $this->resizeHeight, $this->origWidth, $this->origHeight);
}
/**
* Get the resized height from the width maintaining aspect ratio.
*
* @param integer $width max image width
* @return float
*/
protected function resizeHeightByWidth($width) {
return floor(($this->origHeight / $this->origWidth) * $width);
}
/**
* Get the resized width from the height maintaining aspect ratio.
*
* @param int $height max image height
* @return float
*/
protected function resizeWidthByHeight($height) {
return floor(($this->origWidth / $this->origHeight) * $height);
}
}
@@ -0,0 +1,483 @@
<?php
namespace Plugi\Modules\GrapesJS\Upload;
use Exception;
/**
* File uploader class.
*
* Credits: https://github.com/brunoribeiro94/php-upload
*
* @version 0.6.2
* @package Plugi\Modules\GrapesJS\Upload
*/
class Uploader {
/**
* Indicates if the file has been uploaded properly.
*
* @var boolean
*/
public $was_uploaded = false;
/**
* Contains error message.
*
* @var string
*/
public $error;
/**
* Filename.
*
* @var string
*/
public $file_src_name;
/**
* File extension.
*
* @var string
*/
public $file_src_name_ext;
/**
* Uploaded file size, in bytes.
*
* @var double
*/
public $file_src_size;
/**
* Uploaded file size (in bytes).
*
* @var integer
*/
public $file_src_errors;
/**
* File source temp.
*
* @var string
*/
protected $file_src_temp;
/**
* Uploaded file MIME type.
*
* @access public
* @var string
*/
public $file_src_mime;
/**
* Final file name.
*
* @var string
*/
public $final_file_name;
/**
* File resolution width.
*
* @var integer
*/
public $file_width;
/**
* File resolution height.
*
* @var integer
*/
public $file_height;
/**
* Set this variable to change the maximum size in bytes for an uploaded file.
* Default value is the value upload_max_filesize from php.ini.
* Remember you can also set calling $Upload->file_max_size($value).
*
* @var double
*/
protected $get_file_max_size = 25000000;
/**
* Set auto replace if the file already exist.
* Remember you can also set calling $Upload->auto_replace($value_boolean).
*
* @var boolean
*/
protected $get_auto_replace = true;
/**
* Set auto create path if the folder not exist.
* Remember you can also set calling $Upload->auto_create_path($value_boolean).
*
* @var boolean
*/
protected $get_auto_create_path = true;
/**
* Allowed MIME types.
*
* @var array
*/
public $MIME_allowed = [
"application/arj",
"application/excel",
"application/gnutar",
"application/msword",
"application/mspowerpoint",
"application/octet-stream",
"application/pdf",
"application/powerpoint",
"application/postscript",
"application/plain",
"application/rtf",
"application/vnd.ms-excel",
"application/vocaltec-media-file",
"application/wordperfect",
"application/x-bzip",
"application/x-bzip2",
"application/x-compressed",
"application/x-excel",
"application/x-gzip",
"application/x-latex",
"application/x-midi",
"application/x-msexcel",
"application/x-rtf",
"application/x-sit",
"application/x-stuffit",
"application/x-shockwave-flash",
"application/x-troff-msvideo",
"application/x-zip-compressed",
"application/xml",
"application/zip",
"audio/aiff",
"audio/basic",
"audio/midi",
"audio/mod",
"audio/mpeg",
"audio/mpeg3",
"audio/wav",
"audio/x-aiff",
"audio/x-au",
"audio/x-mid",
"audio/x-midi",
"audio/x-mod",
"audio/x-mpeg-3",
"audio/x-wav",
"audio/xm",
"image/bmp",
"image/gif",
"image/jpeg",
"image/pjpeg",
"image/x-icon",
"image/png",
"image/x-png",
"image/tiff",
"image/x-tiff",
"image/x-windows-bmp",
"multipart/x-zip",
"multipart/x-gzip",
"music/crescendo",
"text/richtext",
"text/plain",
"text/xml",
"video/avi",
"video/mpeg",
"video/msvideo",
"video/quicktime",
"video/quicktime",
"video/x-mpeg",
"video/x-ms-wmv",
"video/x-ms-asf",
"video/x-ms-asf-plugin",
"video/x-msvideo",
"x-music/x-midi"
];
/**
* Uploader constructor.
*
* @param string|array $source image source
* @param boolean $fromFiles read from $_FILE
* @return boolean
*/
public function __construct($source, $fromFiles = true) {
$file = $fromFiles ? $_FILES[$source] : $source;
if (! isset($file)) {
return false;
}
// extract info from uploaded file
$this->file_src_name = $file["name"];
$this->file_src_temp = $file["tmp_name"];
$this->file_src_size = $file["size"];
$this->file_src_errors = $file['error'];
$this->file_src_mime = $file['type'];
$this->file_src_name_ext = pathinfo($file["name"], PATHINFO_EXTENSION);
$this->was_uploaded = true;
return true;
}
/**
* Run the uploader.
*
* @return bool
* @throws Exception
*/
public function run() {
// check whether the final name is in random mode
if ($this->file_name !== true) {
// preserve file extension if provided
if (! pathinfo($this->file_name, PATHINFO_EXTENSION)) {
$file = $this->file_name . '.' . $this->file_src_name_ext;
} else {
$file = $this->file_name;
}
$path = $this->upload_to . $file;
$this->upload_to = dirname($path);
} else {
$hash = md5(uniqid(rand(), true));
$file = $hash . '.' . $this->file_src_name_ext;
$path = $this->upload_to . $file;
}
$get_mime = isset($this->mime_check) ? true : false;
// check MIME type which are allowed
if ($get_mime && empty($this->file_src_mime)) {
$this->was_uploaded = false;
$this->error = "MIME type can't be detected!";
} elseif ($get_mime && !empty($this->file_src_mime) && !in_array($this->file_src_mime, $this->MIME_allowed)) {
$this->was_uploaded = false;
$this->error = "Incorrect type of file";
}
// check file maximum size
if ($this->file_src_size > $this->get_file_max_size) {
$this->error = 'File too big Original Size : ' . $this->file_src_size . ' File size limit : ' . $this->get_file_max_size;
$this->was_uploaded = false;
return false;
}
// check whether destination directory exists or attempt to create it
if ($this->get_auto_create_path) {
if (! $this->r_mkdir($this->upload_to)) {
$this->was_uploaded = false;
$this->error = "Destination directory can't be created. Can't carry on a process";
return false;
}
} elseif (! is_dir($this->upload_to)) {
$this->error = "Destination directory doesn't exist. Can't carry on a process";
return false;
}
// check whether file already exists or if are replacing it
if (file_exists($path)) {
if (! $this->get_auto_replace) {
$this->was_uploaded = false;
$this->error = $this->file_src_name . ' already exists. Please change the file name';
}
return false;
}
// check common error types
switch ($this->file_src_errors) {
case 0:
// all is OK
break;
case 1:
$this->was_uploaded = false;
$this->error = "File upload error (the uploaded file exceeds the upload_max_filesize directive in php.ini)";
break;
case 2:
$this->was_uploaded = false;
$this->error = "File upload error (the uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form)";
break;
case 3:
$this->was_uploaded = false;
$this->error = "File upload error (the uploaded file was only partially uploaded)";
break;
case 4:
$this->was_uploaded = false;
$this->error = "File upload error (no file was uploaded)";
break;
default:
$this->was_uploaded = false;
$this->error = "File upload error (unknown error code)";
}
// move file if successfully uploaded
if ($this->was_uploaded) {
if (move_uploaded_file($this->file_src_temp, $path)) {
$this->final_file_name = $file;
// extract image dimensions
list($w, $h) = getimagesize($path);
$this->file_width = $w;
$this->file_height = $h;
// resize image if necessary
if (isset($this->resize)) {
$resize = new ResizeImage($path);
$resize->resizeTo($this->image_x, $this->image_y, $this->resize_option);
$resize->saveImage($path);
}
return true;
} else {
$this->was_uploaded = false;
$this->error = 'Moving uploaded file failed.';
return false;
}
}
return false;
}
/**
* Create directories recursively.
*
* @param string $path Path to create
* @param integer $mode Optional permissions
* @return boolean Success
*/
protected function r_mkdir($path, $mode = 0777) {
return is_dir($path) || ( $this->r_mkdir(dirname($path), $mode) && $this->_mkdir($path, $mode) );
}
/**
* Create directory.
*
* @param string $path Path to create
* @param integer $mode Optional permissions
* @return boolean Success
*/
protected function _mkdir($path, $mode = 0777) {
$old = umask(0);
$res = @mkdir($path, $mode);
umask($old);
return $res;
}
/**
* Set the variable this function to define final name of the uploaded file.
* Use the value true for generate unique name (random name).
*
* @param boolean|string $file_name Final name of the file uploaded
* @return Uploader
*/
public function file_name($file_name) {
$this->file_name = $file_name;
return $this;
}
/**
* Set the variable this function to define auto replacement if the file already exist.
*
* @param boolean $bool
* @return Uploader
*/
public function auto_replace($bool) {
$this->get_auto_replace = $bool;
return $this;
}
/**
* Set the variable this function to define max size file is allowed.
*
* @param integer $size Maximum size in Bytes (1 000 000 bytes is equal to 1 MB)
* @return Uploader
*/
public function file_max_size($size) {
$this->get_file_max_size = (int) $size;
return $this;
}
/**
* Set the variable this function to false if you don't want to check the MIME against the allowed list.
* This variable is set to true by default for security reason.
*
* @param boolean $bool Set to false to not check
* @return Uploader
*/
public function mime_check($bool = true) {
$this->mime_check = $bool;
return $this;
}
/**
* Set the variable this function to choose a new path location for the image.
*
* @param string $path Path location of the uploaded file, with an ending slash
* @return Uploader
*/
public function upload_to($path) {
$this->upload_to = $path;
return $this;
}
/**
* Set the variable this function to true to resize the file if it is an image.
* You will probably want to set {@link image_x()} and {@link image_y()}, and maybe one of the ratio variables.
*
* @param boolean $bool Default value is false (no resizing)
* @return Uploader
*/
public function resize($bool = false) {
$this->resize = $bool;
return $this;
}
/**
* Set the variable this function to the wanted (or maximum/minimum) width for the processed image, in pixels.
*
* @param integer $width Default value is 150
* @return Uploader
*/
public function image_x($width) {
$this->image_x = $width;
return $this;
}
/**
* Set the variable this function to the wanted (or maximum/minimum) height for the processed image, in pixels.
*
* @param integer $height Default value is 150
* @return Uploader
*/
public function image_y($height = 150) {
$this->image_y = $height;
return $this;
}
/**
* Set the variable this function to choose the scale option for the image.
*
* @param string $option Default value is default, but you can use: exact, maxwidth, maxheight or proportional
* @return Uploader
*/
public function resize_option($option = 'default') {
$this->resize_option = $option;
return $this;
}
/**
* Alias for {@link resize()} instead of using both {@link image_x()} && {@link image_y()} && {@link resize_option()}.
*
* @param integer $width Max width of the image
* @param integer $height Max height of the image
* @param string $resizeOption Scale option for the image
* @return Uploader
*/
public function resize_to($width = 150, $height = 150, $resizeOption = 'default') {
self::resize(true);
self::image_x($width);
self::image_y($height);
self::resize_option($resizeOption);
return $this;
}
}
@@ -0,0 +1,4 @@
import './js/app.js'
import './js/page-injection.js'
@@ -0,0 +1,5 @@
import 'grapesjs/dist/css/grapes.min.css';
import './sass/app.scss'
import './sass/page-injection.scss'
import grapesjs from 'grapesjs';
window.grapesjs = grapesjs
@@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" id="flag-icon-css-de" viewBox="0 0 640 480">
<path fill="#ffce00" d="M0 320h640v160H0z"/>
<path d="M0 0h640v160H0z"/>
<path fill="#d00" d="M0 160h640v160H0z"/>
</svg>

After

Width:  |  Height:  |  Size: 213 B

@@ -0,0 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg" id="flag-icon-css-gb" viewBox="0 0 640 480">
<path fill="#012169" d="M0 0h640v480H0z"/>
<path fill="#FFF" d="M75 0l244 181L562 0h78v62L400 241l240 178v61h-80L320 301 81 480H0v-60l239-178L0 64V0h75z"/>
<path fill="#C8102E" d="M424 281l216 159v40L369 281h55zm-184 20l6 35L54 480H0l240-179zM640 0v3L391 191l2-44L590 0h50zM0 0l239 176h-60L0 42V0z"/>
<path fill="#FFF" d="M241 0v480h160V0H241zM0 160v160h640V160H0z"/>
<path fill="#C8102E" d="M0 193v96h640v-96H0zM273 0v480h96V0h-96z"/>
</svg>

After

Width:  |  Height:  |  Size: 538 B

@@ -0,0 +1,544 @@
<svg xmlns="http://www.w3.org/2000/svg" id="flag-icon-css-es" viewBox="0 0 640 480">
<path fill="#AA151B" d="M0 0h640v480H0z"/>
<path fill="#F1BF00" d="M0 120h640v240H0z"/>
<path fill="#ad1519" d="M127.3 213.3l-.8-.1-1-1-.7-.4-.6-.8s-.7-1.1-.4-2c.3-.9.9-1.2 1.4-1.5a12 12 0 011.5-.5l1-.4 1.3-.3.5-.3c.2 0 .7 0 1-.2l1-.2 1.6.1h4.8c.4 0 1.2.3 1.4.4a35 35 0 002 .7c.5.1 1.6.3 2.2.6.5.3.9.7 1.1 1l.5 1v1.1l-.5.8-.6 1-.8.6s-.5.5-1 .4c-.4 0-4.8-.8-7.6-.8s-7.3.9-7.3.9"/>
<path fill="none" stroke="#000" stroke-linejoin="round" stroke-width=".3" d="M127.3 213.3l-.8-.1-1-1-.7-.4-.6-.8s-.7-1.1-.4-2c.3-.9.9-1.2 1.4-1.5a12 12 0 011.5-.5l1-.4 1.3-.3.5-.3c.2 0 .7 0 1-.2l1-.2 1.6.1h4.8c.4 0 1.2.3 1.4.4a35 35 0 002 .7c.5.1 1.6.3 2.2.6.5.3.9.7 1.1 1l.5 1v1.1l-.5.8-.6 1-.8.6s-.5.5-1 .4c-.4 0-4.8-.8-7.6-.8s-7.3.9-7.3.9z"/>
<path fill="#c8b100" d="M133.3 207c0-1.3.6-2.3 1.3-2.3.8 0 1.4 1 1.4 2.4 0 1.3-.6 2.4-1.4 2.4s-1.3-1.1-1.3-2.5"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M133.3 207c0-1.3.6-2.3 1.3-2.3.8 0 1.4 1 1.4 2.4 0 1.3-.6 2.4-1.4 2.4s-1.3-1.1-1.3-2.5z"/>
<path fill="#c8b100" d="M134 207c0-1.2.3-2.1.7-2.1.3 0 .6 1 .6 2.1 0 1.3-.3 2.2-.6 2.2-.4 0-.6-1-.6-2.2"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M134 207c0-1.2.3-2.1.7-2.1.3 0 .6 1 .6 2.1 0 1.3-.3 2.2-.6 2.2-.4 0-.6-1-.6-2.2z"/>
<path fill="#c8b100" d="M133.8 204.5c0-.4.4-.8.8-.8s1 .4 1 .8c0 .5-.5.9-1 .9s-.8-.4-.8-.9"/>
<path fill="#c8b100" d="M135.3 204.2v.6h-1.4v-.6h.5V203h-.7v-.6h.7v-.5h.5v.5h.6v.6h-.6v1.2h.4"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M135.3 204.2v.6h-1.4v-.6h.5V203h-.7v-.6h.7v-.5h.5v.5h.6v.6h-.6v1.2h.4"/>
<path fill="#c8b100" d="M135.9 204.2v.6h-2.5v-.6h1V203h-.7v-.6h.7v-.5h.5v.5h.6v.6h-.6v1.2h1"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M135.9 204.2v.6h-2.5v-.6h1V203h-.7v-.6h.7v-.5h.5v.5h.6v.6h-.6v1.2h1"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M134.9 203.7c.4.1.6.4.6.8 0 .5-.4.9-.8.9s-1-.4-1-.9c0-.4.3-.7.7-.8"/>
<path fill="#c8b100" d="M134.7 213.2H130v-1.1l-.3-1.2-.2-1.5c-1.3-1.7-2.5-2.8-2.9-2.5.1-.3.2-.6.5-.7 1.1-.7 3.5 1 5.2 3.6l.5.7h3.8l.4-.7c1.8-2.7 4.1-4.3 5.2-3.6.3.1.4.4.5.7-.4-.3-1.6.8-2.9 2.5l-.2 1.5-.2 1.2-.1 1.1h-4.7"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M134.7 213.2H130v-1.1l-.3-1.2-.2-1.5c-1.3-1.7-2.5-2.8-2.9-2.5.1-.3.2-.6.5-.7 1.1-.7 3.5 1 5.2 3.6l.5.7h3.8l.4-.7c1.8-2.7 4.1-4.3 5.2-3.6.3.1.4.4.5.7-.4-.3-1.6.8-2.9 2.5l-.2 1.5-.2 1.2-.1 1.1h-4.7z"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M126.8 206.8c1-.5 3 1.1 4.6 3.6m11-3.6c-.8-.5-2.8 1.1-4.5 3.6"/>
<path fill="#c8b100" d="M127.8 215.3l-.5-1a27.3 27.3 0 0114.7 0l-.5.8a5.7 5.7 0 00-.3.8 22.9 22.9 0 00-6.6-.8c-2.6 0-5.2.3-6.5.8l-.3-.6"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M127.8 215.3l-.5-1a27.3 27.3 0 0114.7 0l-.5.8a5.7 5.7 0 00-.3.8 22.9 22.9 0 00-6.6-.8c-2.6 0-5.2.3-6.5.8l-.3-.6"/>
<path fill="#c8b100" d="M134.6 217.7c2.4 0 5-.4 5.9-.6.6-.2 1-.5 1-.8 0-.2-.2-.3-.4-.4-1.4-.5-4-.8-6.5-.8s-5 .3-6.4.8c-.2 0-.3.2-.4.3 0 .4.3.7 1 .9 1 .2 3.5.6 5.8.6"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M134.6 217.7c2.4 0 5-.4 5.9-.6.6-.2 1-.5 1-.8 0-.2-.2-.3-.4-.4-1.4-.5-4-.8-6.5-.8s-5 .3-6.4.8c-.2 0-.3.2-.4.3 0 .4.3.7 1 .9 1 .2 3.5.6 5.8.6z"/>
<path fill="#c8b100" d="M142.1 213.2l-.5-.5s-.6.3-1.3.2c-.6 0-.9-1-.9-1s-.7.7-1.3.7c-.7 0-1-.6-1-.6s-.7.5-1.3.4c-.6 0-1.2-.8-1.2-.8s-.6.8-1.2.8c-.6.1-1-.5-1-.5s-.4.6-1.1.7-1.4-.6-1.4-.6-.5.7-1 1c-.5 0-1.2-.4-1.2-.4l-.2.5-.3.1.2.5a27 27 0 017.2-.9c3 0 5.5.4 7.4 1l.2-.6"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M142.1 213.2l-.5-.5s-.6.3-1.3.2c-.6 0-.9-1-.9-1s-.7.7-1.3.7c-.7 0-1-.6-1-.6s-.7.5-1.3.4c-.6 0-1.2-.8-1.2-.8s-.6.8-1.2.8c-.6.1-1-.5-1-.5s-.4.6-1.1.7-1.4-.6-1.4-.6-.5.7-1 1c-.5 0-1.2-.4-1.2-.4l-.2.5-.3.1.2.5a27 27 0 017.2-.9c3 0 5.5.4 7.4 1l.2-.6z"/>
<path fill="#c8b100" d="M134.7 210.7h.2a1 1 0 000 .4c0 .6.4 1 1 1a1 1 0 001-.7l.2-.3v.4c.1.5.6.8 1.1.8.6 0 1-.4 1-1v-.1l.4-.4.2.5a.9.9 0 00-.1.4 1 1 0 001 1c.4 0 .7-.2.9-.5l.2-.2v.3c0 .3.1.6.4.7 0 0 .4 0 1-.4l.7-.7v.4s-.5.8-1 1c-.2.2-.5.4-.8.3-.3 0-.6-.3-.7-.6-.2.2-.4.2-.7.2-.6 0-1.2-.3-1.4-.8-.3.3-.7.5-1.1.5a1.6 1.6 0 01-1.2-.6 1.6 1.6 0 01-1 .4 1.6 1.6 0 01-1.3-.6 1.6 1.6 0 01-2.4.2 1.6 1.6 0 01-1.2.6 1.5 1.5 0 01-1.1-.5c-.2.5-.8.8-1.4.8-.2 0-.5 0-.7-.2-.1.3-.4.6-.7.6-.3 0-.6 0-.9-.2l-1-1 .1-.5.8.7c.5.4.9.4.9.4.3 0 .4-.4.4-.7v-.3l.2.2c.2.3.5.5.9.5a1 1 0 001-1 .9.9 0 000-.4v-.5l.4.4a.7.7 0 000 .1c0 .6.5 1 1 1 .6 0 1-.3 1.1-.9v-.3l.2.3c.2.4.6.7 1 .7.7 0 1.1-.4 1.1-1a1 1 0 000-.3h.3"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M134.7 210.7h.2a1 1 0 000 .4c0 .6.4 1 1 1a1 1 0 001-.7l.2-.3v.4c.1.5.6.8 1.1.8.6 0 1-.4 1-1v-.1l.4-.4.2.5a.9.9 0 00-.1.4 1 1 0 001 1c.4 0 .7-.2.9-.5l.2-.2v.3c0 .3.1.6.4.7 0 0 .4 0 1-.4l.7-.7v.4s-.5.8-1 1c-.2.2-.5.4-.8.3-.3 0-.6-.3-.7-.6-.2.2-.4.2-.7.2-.6 0-1.2-.3-1.4-.8-.3.3-.7.5-1.1.5a1.6 1.6 0 01-1.2-.6 1.6 1.6 0 01-1 .4 1.6 1.6 0 01-1.3-.6 1.6 1.6 0 01-2.4.2 1.6 1.6 0 01-1.2.6 1.5 1.5 0 01-1.1-.5c-.2.5-.8.8-1.4.8-.2 0-.5 0-.7-.2-.1.3-.4.6-.7.6-.3 0-.6 0-.9-.2l-1-1 .1-.5.8.7c.5.4.9.4.9.4.3 0 .4-.4.4-.7v-.3l.2.2c.2.3.5.5.9.5a1 1 0 001-1 .9.9 0 000-.4v-.5l.4.4a.7.7 0 000 .1c0 .6.5 1 1 1 .6 0 1-.3 1.1-.9v-.3l.2.3c.2.4.6.7 1 .7.7 0 1.1-.4 1.1-1a1 1 0 000-.3h.3z"/>
<path fill="#c8b100" d="M134.6 213.3c-2.9 0-5.5.4-7.3 1l-.3-.2.1-.3a27 27 0 017.5-1c3 0 5.7.4 7.6 1 0 0 .2.2.1.3l-.3.2a27.3 27.3 0 00-7.4-1"/>
<path fill="none" stroke="#000" stroke-linejoin="round" stroke-width=".3" d="M134.6 213.3c-2.9 0-5.5.4-7.3 1l-.3-.2.1-.3a27 27 0 017.5-1c3 0 5.7.4 7.6 1 0 0 .2.2.1.3l-.3.2a27.3 27.3 0 00-7.4-1z"/>
<path fill="#fff" d="M131.8 214.4c0-.3.2-.4.5-.4a.4.4 0 01.4.4c0 .2-.2.4-.4.4a.4.4 0 01-.5-.4"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M131.8 214.4c0-.3.2-.4.5-.4a.4.4 0 01.4.4c0 .2-.2.4-.4.4a.4.4 0 01-.5-.4z"/>
<path fill="#ad1519" d="M134.7 214.5h-1c-.1 0-.3 0-.3-.3l.3-.3h2a.3.3 0 01.2.3.3.3 0 01-.3.3h-1"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M134.7 214.5h-1c-.1 0-.3 0-.3-.3l.3-.3h2a.3.3 0 01.2.3.3.3 0 01-.3.3h-1"/>
<path fill="#058e6e" d="M130 214.9h-.7c-.1 0-.3 0-.3-.2a.3.3 0 01.2-.3l.7-.1.7-.1c.2 0 .3 0 .4.2a.3.3 0 01-.3.4h-.7"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M130 214.9h-.7c-.1 0-.3 0-.3-.2a.3.3 0 01.2-.3l.7-.1.7-.1c.2 0 .3 0 .4.2a.3.3 0 01-.3.4h-.7"/>
<path fill="#ad1519" d="M127.3 215.3l.3-.4h.7l-.4.6-.6-.2"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M127.3 215.3l.3-.4h.7l-.4.6-.6-.2"/>
<path fill="#fff" d="M136.6 214.4c0-.3.2-.4.4-.4a.4.4 0 01.5.4.4.4 0 01-.5.4.4.4 0 01-.4-.4"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M136.6 214.4c0-.3.2-.4.4-.4a.4.4 0 01.5.4.4.4 0 01-.5.4.4.4 0 01-.4-.4z"/>
<path fill="#058e6e" d="M139.3 214.9h.6a.3.3 0 00.4-.2.3.3 0 00-.3-.3l-.6-.1-.7-.1c-.2 0-.3 0-.4.2 0 .2.1.3.3.4h.7"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M139.3 214.9h.6a.3.3 0 00.4-.2.3.3 0 00-.3-.3l-.6-.1-.7-.1c-.2 0-.3 0-.4.2 0 .2.1.3.3.4h.7"/>
<path fill="#ad1519" d="M142 215.4l-.3-.5h-.7l.3.6.6-.1"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M142 215.4l-.3-.5h-.7l.3.6.6-.1"/>
<path fill="#ad1519" d="M134.6 217.1a25 25 0 01-6-.6 25.5 25.5 0 0112.1 0c-1.6.4-3.7.6-6 .6"/>
<path fill="none" stroke="#000" stroke-linejoin="round" stroke-width=".3" d="M134.6 217.1a25 25 0 01-6-.6 25.5 25.5 0 0112.1 0c-1.6.4-3.7.6-6 .6z"/>
<path fill="#c8b100" d="M142 212l-.1-.3c-.2 0-.3 0-.4.2 0 .2 0 .4.2.4 0 0 .2 0 .3-.3"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M142 212l-.1-.3c-.2 0-.3 0-.4.2 0 .2 0 .4.2.4 0 0 .2 0 .3-.3z"/>
<path fill="#c8b100" d="M137.3 211.2c0-.2 0-.4-.2-.4 0 0-.2.1-.2.3 0 .2 0 .4.2.4l.3-.3"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M137.3 211.2c0-.2 0-.4-.2-.4 0 0-.2.1-.2.3 0 .2 0 .4.2.4l.3-.3z"/>
<path fill="#c8b100" d="M132 211.2l.1-.4c.2 0 .3.1.3.3 0 .2 0 .4-.2.4l-.2-.3"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M132 211.2l.1-.4c.2 0 .3.1.3.3 0 .2 0 .4-.2.4l-.2-.3z"/>
<path fill="#c8b100" d="M127.3 212l.1-.3c.2 0 .3 0 .4.2 0 .2 0 .4-.2.4 0 0-.2 0-.3-.3"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M127.3 212l.1-.3c.2 0 .3 0 .4.2 0 .2 0 .4-.2.4 0 0-.2 0-.3-.3z"/>
<path fill="#c8b100" d="M134.6 208.5l-.8.5.6 1.3.2.1.2-.1.7-1.3-.9-.5"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M134.6 208.5l-.8.5.6 1.3.2.1.2-.1.7-1.3-.9-.5"/>
<path fill="#c8b100" d="M132.8 210.5l.4.5 1.3-.4.1-.2-.1-.2-1.3-.3-.4.6"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M132.8 210.5l.4.5 1.3-.4.1-.2-.1-.2-1.3-.3-.4.6"/>
<path fill="#c8b100" d="M136.4 210.5l-.3.5-1.3-.4-.2-.2.2-.2 1.3-.3.3.6"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M136.4 210.5l-.3.5-1.3-.4-.2-.2.2-.2 1.3-.3.3.6"/>
<path fill="#c8b100" d="M129.3 209l-.7.7.9 1 .2.1.1-.1.3-1.3-.8-.3"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M129.3 209l-.7.7.9 1 .2.1.1-.1.3-1.3-.8-.3"/>
<path fill="#c8b100" d="M128 211.2l.4.5 1.2-.6v-.2l-.1-.2-1.3-.1-.3.6"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M128 211.2l.4.5 1.2-.6v-.2l-.1-.2-1.3-.1-.3.6"/>
<path fill="#c8b100" d="M131.5 210.5l-.3.6H130l-.2-.2.1-.3 1.2-.6.5.5"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M131.5 210.5l-.3.6H130l-.2-.2.1-.3 1.2-.6.5.5"/>
<path fill="#c8b100" d="M126.6 211.4v.6l-1.4.2-.2-.1v-.2l1-.9.6.4"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M126.6 211.4v.6l-1.4.2-.2-.1v-.2l1-.9.6.4"/>
<path fill="#c8b100" d="M129.2 210.9c0-.3.2-.5.5-.5s.5.2.5.5a.5.5 0 01-.5.4.5.5 0 01-.5-.4"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M129.2 210.9c0-.3.2-.5.5-.5s.5.2.5.5a.5.5 0 01-.5.4.5.5 0 01-.5-.4z"/>
<path fill="#c8b100" d="M140 209l.7.7-.9 1-.2.1-.1-.1-.3-1.3.8-.3"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M140 209l.7.7-.9 1-.2.1-.1-.1-.3-1.3.8-.3"/>
<path fill="#c8b100" d="M141.4 211.2l-.5.5-1.2-.6v-.2l.1-.2 1.3-.1.3.6"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M141.4 211.2l-.5.5-1.2-.6v-.2l.1-.2 1.3-.1.3.6"/>
<path fill="#c8b100" d="M137.8 210.5l.3.6h1.3l.2-.2-.1-.3-1.2-.6-.5.5"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M137.8 210.5l.3.6h1.3l.2-.2-.1-.3-1.2-.6-.5.5"/>
<path fill="#c8b100" d="M142.5 211.4l.1.6 1.3.2.2-.1v-.2l-1-.9-.6.4"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M142.5 211.4l.1.6 1.3.2.2-.1v-.2l-1-.9-.6.4"/>
<path fill="#c8b100" d="M134.2 210.4a.5.5 0 01.4-.4c.3 0 .5.2.5.4a.5.5 0 01-.5.5.5.5 0 01-.4-.5"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M134.2 210.4a.5.5 0 01.4-.4c.3 0 .5.2.5.4a.5.5 0 01-.5.5.5.5 0 01-.4-.5z"/>
<path fill="#c8b100" d="M139.1 210.9c0-.3.3-.5.5-.5a.5.5 0 01.5.5.5.5 0 01-.5.4.5.5 0 01-.5-.4"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M139.1 210.9c0-.3.3-.5.5-.5a.5.5 0 01.5.5.5.5 0 01-.5.4.5.5 0 01-.5-.4z"/>
<path fill="#c8b100" d="M124.8 212.2l-.6-.7c-.2-.2-.7-.3-.7-.3 0-.1.3-.3.6-.3a.5.5 0 01.4.2v-.2s.3 0 .4.3v1"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M124.8 212.2l-.6-.7c-.2-.2-.7-.3-.7-.3 0-.1.3-.3.6-.3a.5.5 0 01.4.2v-.2s.3 0 .4.3v1z"/>
<path fill="#c8b100" d="M124.8 212c.1-.2.4-.2.5 0 .2.1.3.3.2.5l-.5-.1c-.2-.1-.3-.4-.2-.5"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M124.8 212c.1-.2.4-.2.5 0 .2.1.3.3.2.5l-.5-.1c-.2-.1-.3-.4-.2-.5z"/>
<path fill="#c8b100" d="M144.3 212.2l.6-.7c.2-.2.7-.3.7-.3 0-.1-.3-.3-.6-.3a.6.6 0 00-.4.2v-.2s-.3 0-.4.3v.7l.1.3"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M144.3 212.2l.6-.7c.2-.2.7-.3.7-.3 0-.1-.3-.3-.6-.3a.6.6 0 00-.4.2v-.2s-.3 0-.4.3v.7l.1.3z"/>
<path fill="#c8b100" d="M144.3 212c0-.2-.3-.2-.5 0-.2.1-.2.3-.1.5l.5-.1c.2-.1.2-.4.1-.5"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M144.3 212c0-.2-.3-.2-.5 0-.2.1-.2.3-.1.5l.5-.1c.2-.1.2-.4.1-.5z"/>
<path fill="#c8b100" d="M124 223h21.4v-5.5H124v5.6z"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M124 223h21.4v-5.5H124v5.6z"/>
<path fill="#c8b100" d="M126.2 226.8a1 1 0 01.4 0h16.5a1.4 1.4 0 01-1-1.2c0-.6.5-1.1 1-1.3a1.7 1.7 0 01-.4 0h-16a1.4 1.4 0 01-.5 0c.6.2 1 .7 1 1.3a1.3 1.3 0 01-1 1.2"/>
<path fill="none" stroke="#000" stroke-linejoin="round" stroke-width=".4" d="M126.2 226.8a1 1 0 01.4 0h16.5a1.4 1.4 0 01-1-1.2c0-.6.5-1.1 1-1.3a1.7 1.7 0 01-.4 0h-16a1.4 1.4 0 01-.5 0c.6.2 1 .7 1 1.3a1.3 1.3 0 01-1 1.2z"/>
<path fill="#c8b100" d="M126.6 226.8h16c.6 0 1 .3 1 .7 0 .4-.4.8-1 .8h-16c-.5 0-1-.4-1-.8s.5-.8 1-.8"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M126.6 226.8h16c.6 0 1 .3 1 .7 0 .4-.4.8-1 .8h-16c-.5 0-1-.4-1-.8s.5-.8 1-.8z"/>
<path fill="#c8b100" d="M126.6 223h16c.6 0 1 .4 1 .7 0 .4-.4.6-1 .6h-16c-.5 0-1-.2-1-.6 0-.3.5-.6 1-.6"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M126.6 223h16c.6 0 1 .4 1 .7 0 .4-.4.6-1 .6h-16c-.5 0-1-.2-1-.6 0-.3.5-.6 1-.6z"/>
<path fill="#005bbf" d="M149.6 317.4c-1.4 0-2.8-.3-3.7-.8a8.4 8.4 0 00-3.8-.8c-1.4 0-2.7.3-3.7.8a8.3 8.3 0 01-3.8.8c-1.5 0-2.8-.3-3.7-.8a8.4 8.4 0 00-3.7-.8 8 8 0 00-3.7.8 8.3 8.3 0 01-3.8.8v2.4c1.5 0 2.8-.4 3.8-.9a8.2 8.2 0 013.7-.8c1.4 0 2.7.3 3.7.8s2.2.9 3.7.9a8.4 8.4 0 003.8-.9c1-.5 2.3-.8 3.7-.8 1.5 0 2.8.3 3.8.8s2.2.9 3.7.9v-2.4"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M149.6 317.4c-1.4 0-2.8-.3-3.7-.8a8.4 8.4 0 00-3.8-.8c-1.4 0-2.7.3-3.7.8a8.3 8.3 0 01-3.8.8c-1.5 0-2.8-.3-3.7-.8a8.4 8.4 0 00-3.7-.8 8 8 0 00-3.7.8 8.3 8.3 0 01-3.8.8v2.4c1.5 0 2.8-.4 3.8-.9a8.2 8.2 0 013.7-.8c1.4 0 2.7.3 3.7.8s2.2.9 3.7.9a8.4 8.4 0 003.8-.9c1-.5 2.3-.8 3.7-.8 1.5 0 2.8.3 3.8.8s2.2.9 3.7.9v-2.4z"/>
<path fill="#ccc" d="M149.6 319.8a8 8 0 01-3.7-.9 8.3 8.3 0 00-3.8-.8c-1.4 0-2.7.3-3.7.8s-2.3.9-3.8.9-2.8-.4-3.7-.9a8.4 8.4 0 00-3.7-.8 8.2 8.2 0 00-3.7.8c-1 .5-2.3.9-3.8.9v2.3c1.5 0 2.8-.4 3.8-.9a8.1 8.1 0 013.7-.7c1.4 0 2.7.2 3.7.7a8.3 8.3 0 007.5 0 8.5 8.5 0 017.5.1 8.1 8.1 0 003.7.8v-2.3"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M149.6 319.8a8 8 0 01-3.7-.9 8.3 8.3 0 00-3.8-.8c-1.4 0-2.7.3-3.7.8s-2.3.9-3.8.9-2.8-.4-3.7-.9a8.4 8.4 0 00-3.7-.8 8.2 8.2 0 00-3.7.8c-1 .5-2.3.9-3.8.9v2.3c1.5 0 2.8-.4 3.8-.9a8.1 8.1 0 013.7-.7c1.4 0 2.7.2 3.7.7a8.3 8.3 0 007.5 0 8.5 8.5 0 017.5.1 8.1 8.1 0 003.7.8v-2.3"/>
<path fill="#005bbf" d="M149.6 322a7 7 0 01-3.7-.8 8.3 8.3 0 00-3.8-.7c-1.4 0-2.7.2-3.7.7-1 .6-2.3.9-3.8.9s-2.8-.4-3.7-.9a8.4 8.4 0 00-3.7-.8 8 8 0 00-3.7.8c-1 .5-2.3.9-3.8.9v2.3c1.5 0 2.8-.3 3.8-.9a10.2 10.2 0 017.4 0 7 7 0 003.7.9 8.4 8.4 0 003.8-.8c1-.5 2.3-.8 3.7-.8 1.5 0 2.8.3 3.8.8s2.2.8 3.7.8V322"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M149.6 322a7 7 0 01-3.7-.8 8.3 8.3 0 00-3.8-.7c-1.4 0-2.7.2-3.7.7-1 .6-2.3.9-3.8.9s-2.8-.4-3.7-.9a8.4 8.4 0 00-3.7-.8 8 8 0 00-3.7.8c-1 .5-2.3.9-3.8.9v2.3c1.5 0 2.8-.3 3.8-.9a10.2 10.2 0 017.4 0 7 7 0 003.7.9 8.4 8.4 0 003.8-.8c1-.5 2.3-.8 3.7-.8 1.5 0 2.8.3 3.8.8s2.2.8 3.7.8V322"/>
<path fill="#ccc" d="M149.6 326.7a8 8 0 01-3.7-.8c-1-.5-2.3-.8-3.7-.8a8.4 8.4 0 00-3.8.8c-1 .5-2.3.8-3.8.8a7 7 0 01-3.7-.9 8.4 8.4 0 00-3.7-.7c-1.4 0-2.7.3-3.7.8s-2.3.8-3.8.8v-2.3a8.3 8.3 0 003.8-.9 10.2 10.2 0 017.4 0 8 8 0 003.7.9 8.4 8.4 0 003.8-.8c1-.5 2.3-.8 3.8-.8 1.4 0 2.7.3 3.7.8s2.3.8 3.7.8v2.3"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M149.6 326.7a8 8 0 01-3.7-.8c-1-.5-2.3-.8-3.7-.8a8.4 8.4 0 00-3.8.8c-1 .5-2.3.8-3.8.8a7 7 0 01-3.7-.9 8.4 8.4 0 00-3.7-.7c-1.4 0-2.7.3-3.7.8s-2.3.8-3.8.8v-2.3a8.3 8.3 0 003.8-.9 10.2 10.2 0 017.4 0 8 8 0 003.7.9 8.4 8.4 0 003.8-.8c1-.5 2.3-.8 3.8-.8 1.4 0 2.7.3 3.7.8s2.3.8 3.7.8v2.3"/>
<path fill="#005bbf" d="M149.6 329a8.1 8.1 0 01-3.7-.8c-1-.5-2.3-.8-3.7-.8a8.4 8.4 0 00-3.8.8c-1 .5-2.3.8-3.8.8a7 7 0 01-3.7-.9 8.4 8.4 0 00-3.7-.7c-1.4 0-2.7.3-3.7.8s-2.3.8-3.8.8v-2.3a8.3 8.3 0 003.8-.8c1-.5 2.3-.8 3.7-.8 1.4 0 2.7.3 3.7.7a8.4 8.4 0 007.5 0c1-.4 2.3-.7 3.8-.7 1.4 0 2.7.3 3.7.8s2.2.8 3.7.8v2.3"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M149.6 329a8.1 8.1 0 01-3.7-.8c-1-.5-2.3-.8-3.7-.8a8.4 8.4 0 00-3.8.8c-1 .5-2.3.8-3.8.8a7 7 0 01-3.7-.9 8.4 8.4 0 00-3.7-.7c-1.4 0-2.7.3-3.7.8s-2.3.8-3.8.8v-2.3a8.3 8.3 0 003.8-.8c1-.5 2.3-.8 3.7-.8 1.4 0 2.7.3 3.7.7a8.4 8.4 0 007.5 0c1-.4 2.3-.7 3.8-.7 1.4 0 2.7.3 3.7.8s2.2.8 3.7.8v2.3z"/>
<path fill="#c8b100" d="M126.2 308l.2.5c0 1.5-1.3 2.6-2.7 2.6h22a2.7 2.7 0 01-2.7-2.6v-.5a1.3 1.3 0 01-.3 0h-16a1.4 1.4 0 01-.5 0"/>
<path fill="none" stroke="#000" stroke-linejoin="round" stroke-width=".4" d="M126.2 308l.2.5c0 1.5-1.3 2.6-2.7 2.6h22a2.7 2.7 0 01-2.7-2.6v-.5a1.3 1.3 0 01-.3 0h-16a1.4 1.4 0 01-.5 0z"/>
<path fill="#c8b100" d="M126.6 306.5h16c.6 0 1 .3 1 .8 0 .4-.4.7-1 .7h-16c-.5 0-1-.3-1-.8 0-.4.5-.7 1-.7"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M126.6 306.5h16c.6 0 1 .3 1 .8 0 .4-.4.7-1 .7h-16c-.5 0-1-.3-1-.8 0-.4.5-.7 1-.7z"/>
<path fill="#c8b100" d="M123.7 316.7h22V311h-22v5.6z"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M123.7 316.7h22V311h-22v5.6z"/>
<path fill="#ad1519" d="M122 286.7c-2.2 1.2-3.7 2.5-3.4 3.2 0 .6.8 1 1.8 1.6 1.5 1.1 2.5 3 1.7 4a5.5 5.5 0 00-.1-8.8"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M122 286.7c-2.2 1.2-3.7 2.5-3.4 3.2 0 .6.8 1 1.8 1.6 1.5 1.1 2.5 3 1.7 4a5.5 5.5 0 00-.1-8.8z"/>
<path fill="#ccc" d="M126.8 305.6h15.6V229h-15.6v76.5z"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M138 229.2v76.3m1.7-76.3v76.3m-12.9 0h15.6v-76.4h-15.6v76.5z"/>
<path fill="#ad1519" d="M158.4 257.7a49.6 49.6 0 00-23.3-2c-9.4 1.6-16.5 5.3-15.9 8.4v.2l-3.5-8.2c-.6-3.3 7.2-7.5 17.6-9.2a43 43 0 019.2-.7c6.6 0 12.4.8 15.8 2.1v9.4"/>
<path fill="none" stroke="#000" stroke-linejoin="round" stroke-width=".4" d="M158.4 257.7a49.6 49.6 0 00-23.3-2c-9.4 1.6-16.5 5.3-15.9 8.4v.2l-3.5-8.2c-.6-3.3 7.2-7.5 17.6-9.2a43 43 0 019.2-.7c6.6 0 12.4.8 15.8 2.1v9.4"/>
<path fill="#ad1519" d="M126.8 267.3c-4.3-.3-7.3-1.4-7.6-3.2-.3-1.5 1.2-3 3.8-4.5 1.2.1 2.5.3 3.8.3v7.4"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M126.8 267.3c-4.3-.3-7.3-1.4-7.6-3.2-.3-1.5 1.2-3 3.8-4.5 1.2.1 2.5.3 3.8.3v7.4"/>
<path fill="#ad1519" d="M142.5 261.5c2.7.4 4.7 1 5.7 1.9l.1.2c.5 1-1.9 3-5.9 5.4v-7.5"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M142.5 261.5c2.7.4 4.7 1 5.7 1.9l.1.2c.5 1-1.9 3-5.9 5.4v-7.5"/>
<path fill="#ad1519" d="M117.1 282c-.4-1.2 3.8-3.6 9.8-5.8l7.8-3.2c8.3-3.7 14.4-7.9 13.6-9.4v-.2c.4.4 1 8 1 8 .8 1.3-4.8 5.5-12.4 9.1-2.5 1.2-7.6 3-10 4-4.4 1.4-8.7 4.3-8.3 5.3l-1.5-7.7"/>
<path fill="none" stroke="#000" stroke-linejoin="round" stroke-width=".4" d="M117.1 282c-.4-1.2 3.8-3.6 9.8-5.8l7.8-3.2c8.3-3.7 14.4-7.9 13.6-9.4v-.2c.4.4 1 8 1 8 .8 1.3-4.8 5.5-12.4 9.1-2.5 1.2-7.6 3-10 4-4.4 1.4-8.7 4.3-8.3 5.3l-1.5-7.7z"/>
<path fill="#c8b100" d="M125.8 254c1.9-.6 3.1-1.5 2.5-3-.4-1-1.4-1-2.8-.6l-2.6 1 2.3 5.8.8-.3.8-.3-1-2.5zm-1.2-2.7l.7-.3c.5-.2 1.2.1 1.4.8.2.5.2 1-.5 1.5a4.4 4.4 0 01-.6.3l-1-2.3m7.3-2.5l-.9.3h-.8l1.3 6.1 4.3-.8-.2-.4v-.4l-2.5.6-1.2-5.3m8.4 5.2c.8-2.2 1.7-4.3 2.7-6.4a5.3 5.3 0 01-1 0 54.8 54.8 0 01-1.8 4.6l-2.4-4.3-1 .1h-1a131.4 131.4 0 013.5 6h1m8.8-4.7l.4-.9a3.4 3.4 0 00-1.7-.6c-1.7-.1-2.7.6-2.8 1.7-.2 2.1 3.2 2 3 3.4 0 .6-.7.9-1.4.8-.8 0-1.4-.5-1.4-1.2h-.3a7.3 7.3 0 01-.4 1.1 4 4 0 001.8.6c1.7.2 3-.5 3.2-1.7.2-2-3.3-2.1-3.1-3.4 0-.5.4-.8 1.3-.7.7 0 1 .4 1.2.9h.2"/>
<path fill="#ad1519" d="M277.9 211.6s-.7.8-1.3.9c-.5 0-1.1-.5-1.1-.5s-.5.5-1 .6c-.6.1-1.4-.6-1.4-.6l-1 1c-.6 0-1.1-.3-1.1-.3s-.3.4-.7.6h-.4l-.6-.4-.7-.7-.5-.3-.4-1v-.5c-.1-.6.8-1.4 2.2-1.7a3.9 3.9 0 012 0c.5-.5 1.7-.8 3-.8s2.4.3 3 .7a5.5 5.5 0 012.9-.7c1.3 0 2.5.3 3 .8.5-.2 1.2-.2 2 0 1.4.3 2.3 1 2.2 1.7v.5l-.4 1-.6.3-.6.7-.6.3s-.3.2-.4 0c-.4-.1-.7-.5-.7-.5s-.6.4-1 .2c-.5-.2-1-1-1-1s-.9.8-1.4.7c-.6-.1-1-.6-1-.6s-.7.6-1.2.5c-.5-.1-1.2-.9-1.2-.9"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M277.9 211.6s-.7.8-1.3.9c-.5 0-1.1-.5-1.1-.5s-.5.5-1 .6c-.6.1-1.4-.6-1.4-.6l-1 1c-.6 0-1.1-.3-1.1-.3s-.3.4-.7.6h-.4l-.6-.4-.7-.7-.5-.3-.4-1v-.5c-.1-.6.8-1.4 2.2-1.7a3.9 3.9 0 012 0c.5-.5 1.7-.8 3-.8s2.4.3 3 .7a5.5 5.5 0 012.9-.7c1.3 0 2.5.3 3 .8.5-.2 1.2-.2 2 0 1.4.3 2.3 1 2.2 1.7v.5l-.4 1-.6.3-.6.7-.6.3s-.3.2-.4 0c-.4-.1-.7-.5-.7-.5s-.6.4-1 .2c-.5-.2-1-1-1-1s-.9.8-1.4.7c-.6-.1-1-.6-1-.6s-.7.6-1.2.5c-.5-.1-1.2-.9-1.2-.9z"/>
<path fill="#c8b100" d="M276.5 207.6c0-1 .6-2 1.3-2 .8 0 1.3 1 1.3 2s-.5 1.8-1.3 1.8c-.7 0-1.3-.8-1.3-1.9"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M276.5 207.6c0-1 .6-2 1.3-2 .8 0 1.3 1 1.3 2s-.5 1.8-1.3 1.8c-.7 0-1.3-.8-1.3-1.9z"/>
<path fill="#c8b100" d="M277.3 207.6c0-1 .2-1.8.5-1.8.4 0 .7.8.7 1.8s-.3 1.7-.6 1.7c-.4 0-.6-.8-.6-1.8"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M277.3 207.6c0-1 .2-1.8.5-1.8.4 0 .7.8.7 1.8s-.3 1.7-.6 1.7c-.4 0-.6-.8-.6-1.8z"/>
<path fill="#c8b100" d="M271 215.3a4.5 4.5 0 00-.5-1 27.4 27.4 0 0114.8 0l-.6.8a5.2 5.2 0 00-.3.8 22.9 22.9 0 00-6.6-.8c-2.6 0-5.2.3-6.6.8l-.2-.6"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M271 215.3a4.5 4.5 0 00-.5-1 27.4 27.4 0 0114.8 0l-.6.8a5.2 5.2 0 00-.3.8 22.9 22.9 0 00-6.6-.8c-2.6 0-5.2.3-6.6.8l-.2-.6"/>
<path fill="#c8b100" d="M277.8 217.7c2.4 0 5-.4 5.9-.6.6-.2 1-.5 1-.8 0-.2-.2-.3-.4-.4a24.1 24.1 0 00-6.5-.8c-2.5 0-5 .3-6.4.8-.2 0-.3.2-.4.3 0 .4.3.7 1 .9 1 .2 3.5.6 5.8.6"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M277.8 217.7c2.4 0 5-.4 5.9-.6.6-.2 1-.5 1-.8 0-.2-.2-.3-.4-.4a24.1 24.1 0 00-6.5-.8c-2.5 0-5 .3-6.4.8-.2 0-.3.2-.4.3 0 .4.3.7 1 .9 1 .2 3.5.6 5.8.6z"/>
<path fill="#fff" d="M283.5 208.4c0-.2.2-.4.4-.4s.5.2.5.4-.2.4-.5.4a.4.4 0 01-.4-.4"/>
<path fill="none" stroke="#000" stroke-width=".2" d="M283.5 208.4c0-.2.2-.4.4-.4s.5.2.5.4-.2.4-.5.4a.4.4 0 01-.4-.4zm-.2-1.4a.4.4 0 01.4-.4c.2 0 .4.1.4.4s-.2.4-.4.4a.4.4 0 01-.4-.4zm-1.1-1c0-.2.2-.3.4-.3s.4.1.4.4c0 .2-.2.4-.4.4a.4.4 0 01-.4-.5zm-1.4-.4c0-.2.2-.4.4-.4.3 0 .5.2.5.4s-.2.4-.4.4-.5-.2-.5-.4zm-1.4 0c0-.2.2-.3.5-.3s.4.1.4.4c0 .2-.2.4-.4.4a.4.4 0 01-.5-.4z"/>
<path fill="none" stroke="#000" stroke-linecap="round" stroke-width=".3" d="M287.8 211.2l.2-1a2.7 2.7 0 00-2.7-2.8c-.5 0-1 .1-1.3.3"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M283 209.2l.2-.8c0-1.1-1.1-2-2.5-2-.6 0-1.2.2-1.6.4"/>
<path fill="none" stroke="#000" stroke-width=".2" d="M288.2 210c0-.3.2-.5.4-.5s.4.2.4.4c0 .3-.2.4-.4.4s-.4-.1-.4-.4zm-.2-1.6c0-.2.2-.4.4-.4a.4.4 0 01.5.4c0 .2-.2.4-.4.4-.3 0-.5-.2-.5-.4zm-1-1.1a.4.4 0 01.5-.4c.2 0 .4.1.4.4a.4.4 0 01-.4.4.4.4 0 01-.5-.4zm-1.3-.7c0-.2.2-.4.5-.4s.4.2.4.4c0 .3-.2.5-.4.5a.4.4 0 01-.5-.5zm-1.4.1c0-.2.2-.4.5-.4s.4.2.4.4-.2.4-.4.4-.5-.2-.5-.4z"/>
<path fill="#c8b100" d="M285.3 213.2l-.5-.5s-.6.3-1.3.2c-.6 0-.9-1-.9-1s-.7.7-1.3.7c-.7 0-1-.6-1-.6s-.7.5-1.3.4c-.6 0-1.2-.8-1.2-.8s-.6.8-1.2.8c-.6.1-1-.5-1-.5s-.3.6-1.1.7-1.4-.6-1.4-.6-.4.7-1 1c-.5 0-1.2-.4-1.2-.4l-.1.5-.3.1.1.5a27 27 0 017.3-.9c2.8 0 5.4.4 7.3 1l.2-.6"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M285.3 213.2l-.5-.5s-.6.3-1.3.2c-.6 0-.9-1-.9-1s-.7.7-1.3.7c-.7 0-1-.6-1-.6s-.7.5-1.3.4c-.6 0-1.2-.8-1.2-.8s-.6.8-1.2.8c-.6.1-1-.5-1-.5s-.3.6-1.1.7-1.4-.6-1.4-.6-.4.7-1 1c-.5 0-1.2-.4-1.2-.4l-.1.5-.3.1.1.5a27 27 0 017.3-.9c2.8 0 5.4.4 7.3 1l.2-.6z"/>
<path fill="#fff" d="M271.3 208.4c0-.2.2-.4.4-.4s.4.2.4.4a.4.4 0 01-.4.4.4.4 0 01-.4-.4"/>
<path fill="none" stroke="#000" stroke-width=".2" d="M271.3 208.4c0-.2.2-.4.4-.4s.4.2.4.4a.4.4 0 01-.4.4.4.4 0 01-.4-.4zm.2-1.4c0-.3.2-.4.4-.4s.5.1.5.4-.2.4-.5.4a.4.4 0 01-.4-.4zm1-1c0-.2.3-.3.5-.3s.5.1.5.4c0 .2-.2.4-.5.4a.4.4 0 01-.4-.5zm1.4-.4c0-.2.2-.4.5-.4s.4.2.4.4-.2.4-.4.4-.5-.2-.5-.4zm1.4 0c0-.2.2-.3.5-.3.2 0 .4.1.4.4 0 .2-.2.4-.4.4a.4.4 0 01-.5-.4z"/>
<path fill="none" stroke="#000" stroke-linecap="round" stroke-width=".3" d="M267.8 211.2a2.8 2.8 0 01-.2-1 2.7 2.7 0 012.7-2.8c.5 0 1 .1 1.4.3"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M272.7 209.2a1.7 1.7 0 01-.3-.8c0-1 1.2-2 2.6-2a3 3 0 011.5.4"/>
<path fill="none" stroke="#000" stroke-width=".2" d="M266.6 210c0-.3.2-.5.4-.5.3 0 .4.2.4.4a.4.4 0 01-.4.4c-.2 0-.4-.1-.4-.4zm.1-1.6c0-.2.3-.4.5-.4s.4.2.4.4-.2.4-.4.4-.4-.2-.4-.4zm1-1.1c0-.3.2-.4.5-.4a.4.4 0 01.4.4.4.4 0 01-.4.4.4.4 0 01-.5-.4zm1.3-.7c0-.2.2-.4.5-.4.2 0 .4.2.4.4 0 .3-.2.5-.4.5a.4.4 0 01-.5-.5zm1.4.1c0-.2.2-.4.5-.4a.4.4 0 01.4.4.4.4 0 01-.4.4c-.3 0-.5-.2-.5-.4z"/>
<path fill="#c8b100" d="M277.9 210.7h.2a1 1 0 000 .4c0 .6.5 1 1 1a1 1 0 001-.7l.2-.3v.4c.1.5.6.8 1.1.8.6 0 1-.4 1-1a.7.7 0 000-.1l.4-.4.2.5a1 1 0 00-.1.4 1 1 0 001 1c.4 0 .7-.2.9-.5l.2-.2v.3c0 .3.1.6.4.7 0 0 .4 0 1-.4s.7-.7.7-.7v.4s-.5.8-1 1c-.2.2-.5.4-.8.3-.3 0-.6-.3-.7-.6a1.5 1.5 0 01-.7.2c-.6 0-1.2-.3-1.4-.8a1.5 1.5 0 01-1.1.5c-.5 0-1-.2-1.2-.6a1.5 1.5 0 01-1 .4c-.6 0-1-.2-1.4-.6-.2.4-.7.6-1.2.6-.4 0-.8-.1-1-.4a1.6 1.6 0 01-1.3.6c-.4 0-.8-.2-1.1-.5-.2.5-.8.8-1.4.8-.2 0-.5 0-.7-.2-.1.3-.4.6-.7.6-.3 0-.6 0-.9-.2a4.2 4.2 0 01-1-1l.1-.5.8.7c.5.4.9.4.9.4.3 0 .4-.4.4-.7v-.3l.2.2c.2.3.5.5.9.5a1 1 0 001-1 1 1 0 000-.4v-.5l.4.4v.1c0 .6.5 1 1 1 .6 0 1-.3 1.1-.9v-.3l.2.3c.2.4.6.7 1 .7.6 0 1.1-.4 1.1-1a1 1 0 000-.3h.2"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M277.9 210.7h.2a1 1 0 000 .4c0 .6.5 1 1 1a1 1 0 001-.7l.2-.3v.4c.1.5.6.8 1.1.8.6 0 1-.4 1-1a.7.7 0 000-.1l.4-.4.2.5a1 1 0 00-.1.4 1 1 0 001 1c.4 0 .7-.2.9-.5l.2-.2v.3c0 .3.1.6.4.7 0 0 .4 0 1-.4s.7-.7.7-.7v.4s-.5.8-1 1c-.2.2-.5.4-.8.3-.3 0-.6-.3-.7-.6a1.5 1.5 0 01-.7.2c-.6 0-1.2-.3-1.4-.8a1.5 1.5 0 01-1.1.5c-.5 0-1-.2-1.2-.6a1.5 1.5 0 01-1 .4c-.6 0-1-.2-1.4-.6-.2.4-.7.6-1.2.6-.4 0-.8-.1-1-.4a1.6 1.6 0 01-1.3.6c-.4 0-.8-.2-1.1-.5-.2.5-.8.8-1.4.8-.2 0-.5 0-.7-.2-.1.3-.4.6-.7.6-.3 0-.6 0-.9-.2a4.2 4.2 0 01-1-1l.1-.5.8.7c.5.4.9.4.9.4.3 0 .4-.4.4-.7v-.3l.2.2c.2.3.5.5.9.5a1 1 0 001-1 1 1 0 000-.4v-.5l.4.4v.1c0 .6.5 1 1 1 .6 0 1-.3 1.1-.9v-.3l.2.3c.2.4.6.7 1 .7.6 0 1.1-.4 1.1-1a1 1 0 000-.3h.2z"/>
<path fill="#c8b100" d="M277.8 213.3c-2.9 0-5.5.4-7.3 1l-.3-.2.1-.3c2-.6 4.6-1 7.5-1 3 0 5.7.4 7.6 1 0 0 .2.2.1.3l-.3.2a27 27 0 00-7.4-1"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M277.8 213.3c-2.9 0-5.5.4-7.3 1l-.3-.2.1-.3c2-.6 4.6-1 7.5-1 3 0 5.7.4 7.6 1 0 0 .2.2.1.3l-.3.2a27 27 0 00-7.4-1z"/>
<path fill="#fff" d="M275 214.4c0-.3.2-.4.5-.4a.4.4 0 01.4.4.4.4 0 01-.4.4c-.3 0-.5-.2-.5-.4"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M275 214.4c0-.3.2-.4.5-.4a.4.4 0 01.4.4.4.4 0 01-.4.4c-.3 0-.5-.2-.5-.4z"/>
<path fill="#ad1519" d="M277.9 214.5h-1c-.1 0-.3 0-.3-.3l.3-.3h2a.3.3 0 01.2.3.3.3 0 01-.3.3h-1"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M277.9 214.5h-1c-.1 0-.3 0-.3-.3l.3-.3h2a.3.3 0 01.2.3.3.3 0 01-.3.3h-1"/>
<path fill="#058e6e" d="M273.2 214.9h-.6a.3.3 0 01-.4-.2.3.3 0 01.3-.3l.6-.1.7-.1c.2 0 .3 0 .4.2a.3.3 0 01-.3.4h-.7"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M273.2 214.9h-.6a.3.3 0 01-.4-.2.3.3 0 01.3-.3l.6-.1.7-.1c.2 0 .3 0 .4.2a.3.3 0 01-.3.4h-.7"/>
<path fill="#ad1519" d="M270.5 215.3l.3-.4h.7l-.4.6-.6-.2"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M270.5 215.3l.3-.4h.7l-.4.6-.6-.2"/>
<path fill="#fff" d="M279.8 214.4c0-.3.2-.4.4-.4.3 0 .5.1.5.4 0 .2-.2.4-.5.4a.4.4 0 01-.4-.4"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M279.8 214.4c0-.3.2-.4.4-.4.3 0 .5.1.5.4 0 .2-.2.4-.5.4a.4.4 0 01-.4-.4z"/>
<path fill="#058e6e" d="M282.5 214.9h.7a.3.3 0 00.3-.2.3.3 0 00-.2-.3l-.7-.1-.7-.1c-.2 0-.3 0-.4.2 0 .2.1.3.3.4h.7"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M282.5 214.9h.7a.3.3 0 00.3-.2.3.3 0 00-.2-.3l-.7-.1-.7-.1c-.2 0-.3 0-.4.2 0 .2.1.3.3.4h.7"/>
<path fill="#ad1519" d="M285.1 215.4l-.2-.5h-.7l.3.6.6-.1"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M285.1 215.4l-.2-.5h-.7l.3.6.6-.1"/>
<path fill="#ad1519" d="M277.8 217.1a25 25 0 01-6-.6 25.4 25.4 0 016-.7c2.4 0 4.5.3 6.1.7-1.6.4-3.7.6-6 .6"/>
<path fill="none" stroke="#000" stroke-linejoin="round" stroke-width=".3" d="M277.8 217.1a25 25 0 01-6-.6 25.4 25.4 0 016-.7c2.4 0 4.5.3 6.1.7-1.6.4-3.7.6-6 .6z"/>
<path fill="#c8b100" d="M285.2 212l-.1-.3c-.2 0-.3 0-.4.2l.1.4c.2 0 .3 0 .4-.3"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M285.2 212l-.1-.3c-.2 0-.3 0-.4.2l.1.4c.2 0 .3 0 .4-.3z"/>
<path fill="#c8b100" d="M280.6 211.2c0-.2-.1-.4-.3-.4 0 0-.2.1-.2.3 0 .2 0 .4.2.4l.3-.3"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M280.6 211.2c0-.2-.1-.4-.3-.4 0 0-.2.1-.2.3 0 .2 0 .4.2.4l.3-.3z"/>
<path fill="#c8b100" d="M275.2 211.2c0-.2 0-.4.2-.4l.3.3-.2.4c-.2 0-.3-.2-.3-.3"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M275.2 211.2c0-.2 0-.4.2-.4l.3.3-.2.4c-.2 0-.3-.2-.3-.3z"/>
<path fill="#c8b100" d="M270.5 212l.1-.3c.2 0 .3 0 .4.2l-.1.4c-.2 0-.3 0-.4-.3"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M270.5 212l.1-.3c.2 0 .3 0 .4.2l-.1.4c-.2 0-.3 0-.4-.3z"/>
<path fill="#c8b100" d="M277.8 208.5l-.8.5.6 1.3.2.1.3-.1.6-1.3-.9-.5"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M277.8 208.5l-.8.5.6 1.3.2.1.3-.1.6-1.3-.9-.5"/>
<path fill="#c8b100" d="M276 210.5l.4.5 1.3-.4.1-.2-.1-.2-1.3-.3-.4.6"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M276 210.5l.4.5 1.3-.4.1-.2-.1-.2-1.3-.3-.4.6"/>
<path fill="#c8b100" d="M279.6 210.5l-.3.5-1.3-.4-.1-.2v-.2l1.4-.3.4.6"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M279.6 210.5l-.3.5-1.3-.4-.1-.2v-.2l1.4-.3.4.6"/>
<path fill="#c8b100" d="M272.5 209l-.7.7.9 1 .2.1.2-.1.2-1.3-.8-.3"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M272.5 209l-.7.7.9 1 .2.1.2-.1.2-1.3-.8-.3"/>
<path fill="#c8b100" d="M271.1 211.2l.5.5 1.2-.6v-.2l-.1-.2-1.3-.1-.3.6"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M271.1 211.2l.5.5 1.2-.6v-.2l-.1-.2-1.3-.1-.3.6"/>
<path fill="#c8b100" d="M274.7 210.5l-.3.6h-1.3l-.2-.2.1-.3 1.2-.6.5.5"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M274.7 210.5l-.3.6h-1.3l-.2-.2.1-.3 1.2-.6.5.5"/>
<path fill="#c8b100" d="M269.8 211.4v.6l-1.4.2-.2-.1v-.2l1-.9.6.4"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M269.8 211.4v.6l-1.4.2-.2-.1v-.2l1-.9.6.4"/>
<path fill="#c8b100" d="M272.4 210.9c0-.3.2-.5.5-.5a.5.5 0 01.5.5.5.5 0 01-.5.4.5.5 0 01-.5-.4"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M272.4 210.9c0-.3.2-.5.5-.5a.5.5 0 01.5.5.5.5 0 01-.5.4.5.5 0 01-.5-.4z"/>
<path fill="#c8b100" d="M283.2 209l.7.7-.9 1-.2.1-.1-.1-.3-1.3.8-.3"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M283.2 209l.7.7-.9 1-.2.1-.1-.1-.3-1.3.8-.3"/>
<path fill="#c8b100" d="M284.6 211.2l-.5.5-1.2-.6v-.2l.1-.2 1.3-.1.3.6"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M284.6 211.2l-.5.5-1.2-.6v-.2l.1-.2 1.3-.1.3.6"/>
<path fill="#c8b100" d="M281 210.5l.3.6h1.3l.2-.2-.1-.3-1.2-.6-.5.5"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M281 210.5l.3.6h1.3l.2-.2-.1-.3-1.2-.6-.5.5"/>
<path fill="#c8b100" d="M285.7 211.4v.6l1.4.2.2-.1v-.2l-1-.9-.6.4"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M285.7 211.4v.6l1.4.2.2-.1v-.2l-1-.9-.6.4"/>
<path fill="#c8b100" d="M277.4 210.4c0-.2.2-.4.5-.4.2 0 .4.2.4.4 0 .3-.2.5-.4.5a.5.5 0 01-.5-.5"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M277.4 210.4c0-.2.2-.4.5-.4.2 0 .4.2.4.4 0 .3-.2.5-.4.5a.5.5 0 01-.5-.5z"/>
<path fill="#c8b100" d="M282.3 210.9c0-.3.3-.5.5-.5.3 0 .5.2.5.5s-.2.4-.5.4a.5.5 0 01-.5-.4"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M282.3 210.9c0-.3.3-.5.5-.5.3 0 .5.2.5.5s-.2.4-.5.4a.5.5 0 01-.5-.4z"/>
<path fill="#c8b100" d="M277 205.4c0-.5.4-.8.8-.8s1 .3 1 .8-.5.8-1 .8a.9.9 0 01-.8-.8"/>
<path fill="#c8b100" d="M278.5 205.1v.6H277v-.6h.4v-1.3h-.5v-.5h.5v-.6h.6v.6h.6v.6h-.6v1.2h.4"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M278.5 205.1v.6H277v-.6h.4v-1.3h-.5v-.5h.5v-.6h.6v.6h.6v.6h-.6v1.2h.4z"/>
<path fill="#c8b100" d="M279 205.1v.6h-2.4v-.6h1v-1.3h-.7v-.5h.6v-.6h.6v.6h.6v.6h-.6v1.2h1"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M278.1 204.6c.4 0 .6.4.6.8 0 .5-.4.8-.9.8a.9.9 0 01-.8-.8c0-.4.2-.7.6-.8"/>
<path fill="#c8b100" d="M268 212.2l-.6-.7a2.3 2.3 0 00-.7-.3c0-.1.3-.3.6-.3.2 0 .3 0 .4.2v-.2s.3 0 .4.3v1"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M268 212.2l-.6-.7a2.3 2.3 0 00-.7-.3c0-.1.3-.3.6-.3.2 0 .3 0 .4.2v-.2s.3 0 .4.3v1z"/>
<path fill="#c8b100" d="M268 212c.1-.2.4-.2.5 0 .2.1.3.3.1.5l-.5-.1c-.1-.1-.2-.4 0-.5"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M268 212c.1-.2.4-.2.5 0 .2.1.3.3.1.5l-.5-.1c-.1-.1-.2-.4 0-.5z"/>
<path fill="#c8b100" d="M287.5 212.2l.6-.7c.2-.2.7-.3.7-.3 0-.1-.3-.3-.6-.3a.6.6 0 00-.4.2v-.2s-.3 0-.4.3v.7l.1.3"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M287.5 212.2l.6-.7c.2-.2.7-.3.7-.3 0-.1-.3-.3-.6-.3a.6.6 0 00-.4.2v-.2s-.3 0-.4.3v.7l.1.3z"/>
<path fill="#c8b100" d="M287.5 212c-.1-.2-.3-.2-.5 0-.2.1-.2.3-.1.5l.5-.1c.2-.1.2-.4.1-.5"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M287.5 212c-.1-.2-.3-.2-.5 0-.2.1-.2.3-.1.5l.5-.1c.2-.1.2-.4.1-.5z"/>
<path fill="#c8b100" d="M267.2 223h21.4v-5.5h-21.4v5.6z"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M267.2 223h21.4v-5.5h-21.4v5.6z"/>
<path fill="#c8b100" d="M286.3 226.8a1 1 0 00-.4 0h-16.5c.6-.2 1-.7 1-1.2 0-.6-.4-1.1-1-1.3h17-.1c-.6.2-1 .7-1 1.3 0 .5.4 1 1 1.2"/>
<path fill="none" stroke="#000" stroke-linejoin="round" stroke-width=".4" d="M286.3 226.8a1 1 0 00-.4 0h-16.5c.6-.2 1-.7 1-1.2 0-.6-.4-1.1-1-1.3h17-.1c-.6.2-1 .7-1 1.3 0 .5.4 1 1 1.2z"/>
<path fill="#c8b100" d="M269.9 226.8h16c.6 0 1 .3 1 .7 0 .4-.4.8-1 .8h-16c-.6 0-1-.4-1-.8s.5-.8 1-.8"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M269.9 226.8h16c.6 0 1 .3 1 .7 0 .4-.4.8-1 .8h-16c-.6 0-1-.4-1-.8s.5-.8 1-.8z"/>
<path fill="#c8b100" d="M269.9 223h16c.6 0 1 .4 1 .7 0 .4-.4.6-1 .6h-16c-.6 0-1-.2-1-.6 0-.3.4-.6 1-.6"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M269.9 223h16c.6 0 1 .4 1 .7 0 .4-.4.6-1 .6h-16c-.6 0-1-.2-1-.6 0-.3.4-.6 1-.6z"/>
<path fill="#005bbf" d="M263 317.4c1.4 0 2.7-.3 3.7-.8a8.4 8.4 0 013.7-.8c1.4 0 2.8.3 3.8.8s2.3.8 3.7.8c1.5 0 2.8-.3 3.8-.8a8.4 8.4 0 013.6-.8 8 8 0 013.7.8c1 .5 2.4.8 3.8.8v2.4a8.3 8.3 0 01-3.8-.9 8.2 8.2 0 00-3.7-.8c-1.4 0-2.7.3-3.6.8-1 .5-2.3.9-3.8.9a8 8 0 01-3.7-.9 8.4 8.4 0 00-3.8-.8 8.3 8.3 0 00-3.7.8c-1 .5-2.3.9-3.8.9v-2.4"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M263 317.4c1.4 0 2.7-.3 3.7-.8a8.4 8.4 0 013.7-.8c1.4 0 2.8.3 3.8.8s2.3.8 3.7.8c1.5 0 2.8-.3 3.8-.8a8.4 8.4 0 013.6-.8 8 8 0 013.7.8c1 .5 2.4.8 3.8.8v2.4a8.3 8.3 0 01-3.8-.9 8.2 8.2 0 00-3.7-.8c-1.4 0-2.7.3-3.6.8-1 .5-2.3.9-3.8.9a8 8 0 01-3.7-.9 8.4 8.4 0 00-3.8-.8 8.3 8.3 0 00-3.7.8c-1 .5-2.3.9-3.8.9v-2.4z"/>
<path fill="#ccc" d="M263 319.8c1.4 0 2.7-.4 3.7-.9s2.3-.8 3.7-.8c1.4 0 2.8.3 3.8.8s2.3.9 3.7.9a8.2 8.2 0 003.8-.9 8.4 8.4 0 013.6-.8c1.5 0 2.8.3 3.7.8 1 .5 2.4.9 3.8.9v2.3a8.3 8.3 0 01-3.8-.9 8.1 8.1 0 00-3.7-.7c-1.4 0-2.7.2-3.6.7-1 .5-2.3.9-3.8.9a7 7 0 01-3.7-.9c-1-.4-2.3-.7-3.8-.7a8.3 8.3 0 00-3.7.7 8.1 8.1 0 01-3.8.9v-2.3"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M263 319.8c1.4 0 2.7-.4 3.7-.9s2.3-.8 3.7-.8c1.4 0 2.8.3 3.8.8s2.3.9 3.7.9a8.2 8.2 0 003.8-.9 8.4 8.4 0 013.6-.8c1.5 0 2.8.3 3.7.8 1 .5 2.4.9 3.8.9v2.3a8.3 8.3 0 01-3.8-.9 8.1 8.1 0 00-3.7-.7c-1.4 0-2.7.2-3.6.7-1 .5-2.3.9-3.8.9a7 7 0 01-3.7-.9c-1-.4-2.3-.7-3.8-.7a8.3 8.3 0 00-3.7.7 8.1 8.1 0 01-3.8.9v-2.3"/>
<path fill="#005bbf" d="M263 322c1.4 0 2.7-.2 3.7-.8 1-.4 2.3-.7 3.7-.7 1.4 0 2.8.2 3.8.7s2.3.9 3.7.9a8.2 8.2 0 003.8-.9 8.4 8.4 0 013.6-.8 8 8 0 013.7.8c1 .5 2.4.9 3.8.9v2.3a8.3 8.3 0 01-3.8-.9 8.2 8.2 0 00-3.7-.7c-1.4 0-2.7.3-3.6.7-1 .6-2.3.9-3.8.9-1.4 0-2.8-.3-3.7-.8a8.4 8.4 0 00-3.8-.8 8.3 8.3 0 00-3.7.8c-1 .5-2.3.8-3.8.8V322"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M263 322c1.4 0 2.7-.2 3.7-.8 1-.4 2.3-.7 3.7-.7 1.4 0 2.8.2 3.8.7s2.3.9 3.7.9a8.2 8.2 0 003.8-.9 8.4 8.4 0 013.6-.8 8 8 0 013.7.8c1 .5 2.4.9 3.8.9v2.3a8.3 8.3 0 01-3.8-.9 8.2 8.2 0 00-3.7-.7c-1.4 0-2.7.3-3.6.7-1 .6-2.3.9-3.8.9-1.4 0-2.8-.3-3.7-.8a8.4 8.4 0 00-3.8-.8 8.3 8.3 0 00-3.7.8c-1 .5-2.3.8-3.8.8V322"/>
<path fill="#ccc" d="M263 326.7a8 8 0 003.7-.8c1-.5 2.3-.8 3.7-.8 1.4 0 2.8.3 3.8.8s2.3.8 3.7.8c1.5 0 2.8-.3 3.8-.9a8.4 8.4 0 013.6-.7c1.5 0 2.8.3 3.7.8a8.3 8.3 0 003.8.8v-2.3a8.3 8.3 0 01-3.8-.9 8.2 8.2 0 00-3.7-.7c-1.4 0-2.7.3-3.6.7-1 .5-2.3.9-3.8.9-1.4 0-2.8-.3-3.7-.8a8.4 8.4 0 00-3.8-.8 8.3 8.3 0 00-3.7.8c-1 .5-2.3.8-3.8.8v2.3"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M263 326.7a8 8 0 003.7-.8c1-.5 2.3-.8 3.7-.8 1.4 0 2.8.3 3.8.8s2.3.8 3.7.8c1.5 0 2.8-.3 3.8-.9a8.4 8.4 0 013.6-.7c1.5 0 2.8.3 3.7.8a8.3 8.3 0 003.8.8v-2.3a8.3 8.3 0 01-3.8-.9 8.2 8.2 0 00-3.7-.7c-1.4 0-2.7.3-3.6.7-1 .5-2.3.9-3.8.9-1.4 0-2.8-.3-3.7-.8a8.4 8.4 0 00-3.8-.8 8.3 8.3 0 00-3.7.8c-1 .5-2.3.8-3.8.8v2.3"/>
<path fill="#005bbf" d="M263 329a8.1 8.1 0 003.7-.8c1-.5 2.3-.8 3.7-.8 1.4 0 2.8.3 3.8.8s2.3.8 3.7.8a8.2 8.2 0 003.8-.9 8.4 8.4 0 013.6-.7c1.5 0 2.8.3 3.7.8 1 .5 2.4.8 3.8.8v-2.3a8.3 8.3 0 01-3.8-.8 8.2 8.2 0 00-3.7-.8 8.4 8.4 0 00-3.6.7 8.2 8.2 0 01-3.8.9c-1.4 0-2.8-.3-3.7-.8-1-.5-2.3-.8-3.8-.8-1.4 0-2.7.3-3.7.8s-2.3.8-3.8.8v2.3"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M263 329a8.1 8.1 0 003.7-.8c1-.5 2.3-.8 3.7-.8 1.4 0 2.8.3 3.8.8s2.3.8 3.7.8a8.2 8.2 0 003.8-.9 8.4 8.4 0 013.6-.7c1.5 0 2.8.3 3.7.8 1 .5 2.4.8 3.8.8v-2.3a8.3 8.3 0 01-3.8-.8 8.2 8.2 0 00-3.7-.8 8.4 8.4 0 00-3.6.7 8.2 8.2 0 01-3.8.9c-1.4 0-2.8-.3-3.7-.8-1-.5-2.3-.8-3.8-.8-1.4 0-2.7.3-3.7.8s-2.3.8-3.8.8v2.3z"/>
<path fill="#c8b100" d="M286.3 308l-.1.5c0 1.5 1.2 2.6 2.7 2.6h-22c1.5 0 2.7-1.2 2.7-2.6l-.1-.5h16.8"/>
<path fill="none" stroke="#000" stroke-linejoin="round" stroke-width=".4" d="M286.3 308l-.1.5c0 1.5 1.2 2.6 2.7 2.6h-22c1.5 0 2.7-1.2 2.7-2.6l-.1-.5h16.8z"/>
<path fill="#c8b100" d="M269.9 306.5h16c.6 0 1 .3 1 .8 0 .4-.4.7-1 .7h-16c-.6 0-1-.3-1-.8 0-.4.5-.7 1-.7"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M269.9 306.5h16c.6 0 1 .3 1 .8 0 .4-.4.7-1 .7h-16c-.6 0-1-.3-1-.8 0-.4.5-.7 1-.7z"/>
<path fill="#c8b100" d="M266.9 316.7h22V311h-22v5.6z"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M266.9 316.7h22V311h-22v5.6z"/>
<path fill="#ad1519" d="M290.6 286.7c2.1 1.2 3.6 2.5 3.4 3.2-.1.6-.8 1-1.8 1.6-1.6 1.1-2.5 3-1.8 4a5.5 5.5 0 01.2-8.8"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M290.6 286.7c2.1 1.2 3.6 2.5 3.4 3.2-.1.6-.8 1-1.8 1.6-1.6 1.1-2.5 3-1.8 4a5.5 5.5 0 01.2-8.8z"/>
<path fill="#ccc" d="M270.1 305.6h15.6V229h-15.6v76.5z"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M281.4 229.1v76.3m1.8-76.3v76.3m-13 .2h15.5V229h-15.6v76.5z"/>
<path fill="#ad1519" d="M254.2 257.7a49.6 49.6 0 0123.3-2c9.3 1.6 16.4 5.3 15.9 8.4v.2l3.5-8.2c.6-3.3-7.3-7.5-17.6-9.2a53.5 53.5 0 00-9.2-.7c-6.7 0-12.4.8-15.9 2.1v9.4"/>
<path fill="none" stroke="#000" stroke-linejoin="round" stroke-width=".4" d="M254.2 257.7a49.6 49.6 0 0123.3-2c9.3 1.6 16.4 5.3 15.9 8.4v.2l3.5-8.2c.6-3.3-7.3-7.5-17.6-9.2a53.5 53.5 0 00-9.2-.7c-6.7 0-12.4.8-15.9 2.1v9.4"/>
<path fill="#ad1519" d="M285.7 267.3c4.4-.3 7.3-1.4 7.7-3.2.2-1.5-1.2-3-3.8-4.5-1.2.1-2.5.3-3.9.3v7.4"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M285.7 267.3c4.4-.3 7.3-1.4 7.7-3.2.2-1.5-1.2-3-3.8-4.5-1.2.1-2.5.3-3.9.3v7.4"/>
<path fill="#ad1519" d="M270 261.5a13 13 0 00-5.7 1.9v.2c-.5 1 1.8 3 5.8 5.4v-7.5"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M270 261.5a13 13 0 00-5.7 1.9v.2c-.5 1 1.8 3 5.8 5.4v-7.5"/>
<path fill="#ad1519" d="M295.4 282c.4-1.2-3.8-3.6-9.7-5.8-2.8-1-5-2-7.8-3.2-8.3-3.7-14.4-7.9-13.6-9.4v-.2c-.4.4-1 8-1 8-.8 1.3 4.8 5.5 12.4 9.1 2.4 1.2 7.6 3 10 4 4.3 1.4 8.7 4.3 8.3 5.3l1.4-7.7"/>
<path fill="none" stroke="#000" stroke-linejoin="round" stroke-width=".4" d="M295.4 282c.4-1.2-3.8-3.6-9.7-5.8-2.8-1-5-2-7.8-3.2-8.3-3.7-14.4-7.9-13.6-9.4v-.2c-.4.4-1 8-1 8-.8 1.3 4.8 5.5 12.4 9.1 2.4 1.2 7.6 3 10 4 4.3 1.4 8.7 4.3 8.3 5.3l1.4-7.7z"/>
<path fill="#c8b100" d="M263.9 254.4c.6-2.3 1.4-4.4 2.1-6.6h-.5a5.2 5.2 0 01-.5.1 52.8 52.8 0 01-1.4 4.8c-1-1.4-2-2.7-2.7-4.1l-1 .2h-1a131.3 131.3 0 014 5.7h.5l.5-.1m6-6.6h-1a8 8 0 01-.8 0v6.2h4.2v-.7h-2.6l.1-5.5m6.8 1l2 .3v-.7l-5.8-.5v.8a19.3 19.3 0 012 0l-.4 5.6h1.6l.5-5.4m2.4 6c.3 0 .5 0 .8.2l.8.2.7-2.9.6 1.2.8 2.1 1 .2c.4 0 .7.2 1 .3l-.3-.7c-.4-1-1-1.9-1.3-2.9 1 0 1.9-.3 2.1-1.2.1-.6 0-1-.7-1.5-.4-.3-1.2-.4-1.7-.5l-2.4-.5-1.4 6m3-5.2c.7.2 1.5.3 1.5 1v.5c-.3.9-1 1.2-2 .9l.5-2.4m8 7l-.2 2 .8.5.9.5.5-7a3.4 3.4 0 01-.7-.3l-6.1 3.8.5.3.4.2 1.7-1.2 2.3 1.3zm-1.7-1.5l2-1.4-.2 2.3-1.8-1"/>
<path fill="none" stroke="#000" stroke-width=".1" d="M182.2 192.4c0-1 1-2 2-2s2.2 1 2.2 2c0 1.1-1 2-2.1 2a2 2 0 01-2.1-2z"/>
<path fill="#ad1519" stroke="#000" stroke-width=".3" d="M205.7 175.4c6.3 0 12 1 15.7 2.4a31.7 31.7 0 0014.6 2.3c2.7 0 6.5.8 10.3 2.4a27.3 27.3 0 017.4 4.7l-1.5 1.4-.4 3.8-4.1 4.7-2 1.8-5 3.9-2.5.2-.7 2.1-31.6-3.7-31.7 3.7-.8-2.1-2.5-.2-4.9-4-2-1.7-4.1-4.7-.5-3.8-1.5-1.4a27.6 27.6 0 017.5-4.7 26 26 0 0110.2-2.4c2 .2 4.2.1 6.6-.2a30 30 0 008-2c3.7-1.5 9-2.5 15.5-2.5z"/>
<path fill="#c8b100" stroke="#000" stroke-width=".4" d="M206.2 217.1c-11.8 0-22.4-1.4-29.9-3.6a1.1 1.1 0 01-.8-1.2c0-.5.3-1 .8-1.2a109 109 0 0129.9-3.6c11.7 0 22.3 1.4 29.8 3.6a1.3 1.3 0 010 2.4c-7.5 2.2-18 3.6-29.8 3.6"/>
<path fill="#ad1519" d="M206.1 215.6c-10.6 0-20.2-1.2-27.5-3.1 7.3-2 16.9-3 27.5-3.1a115 115 0 0127.6 3c-7.3 2-17 3.2-27.6 3.2"/>
<path fill="none" stroke="#000" stroke-width=".1" d="M206.9 215.7v-6.3m-1.7 6.3v-6.3"/>
<path fill="none" stroke="#000" stroke-width=".2" d="M203.6 215.7v-6.3m-1.6 6.3v-6.3"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M200.6 215.7v-6.3m-2.8 5.9v-5.7m1.3 5.8v-6m-3.8 5.6v-5.2m1.3 5.4v-5.6"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M192 214.8V210m1 4.7V210m1.2 5v-5m-3.4 4.7v-4.5"/>
<path fill="none" stroke="#000" stroke-width=".5" d="M189.7 214.5v-4.2m-1.2 4.1v-4"/>
<path fill="none" stroke="#000" stroke-width=".6" d="M186 214v-3m1.3 3.2v-3.5m-2.5 3.1V211"/>
<path fill="none" stroke="#000" stroke-width=".7" d="M183.7 213.6v-2.3m-1.3 2v-1.8m-1.2 1.6v-1.3"/>
<path fill="none" stroke="#000" stroke-width=".9" d="M179.8 212.8v-.7"/>
<path fill="none" stroke="#000" stroke-width=".1" d="M213.7 215.3v-5.8m-2.9 6v-6.1m-2.1 6.2v-6.3"/>
<path fill="#c8b100" stroke="#000" stroke-width=".4" d="M206 207.4a108 108 0 00-30 3.9c.6-.3.5-1-.3-3-1-2.5-2.4-2.4-2.4-2.4 8.3-2.5 20-4 32.8-4a123 123 0 0133 4s-1.5-.1-2.5 2.3c-.8 2-.8 2.8-.2 3-7.5-2.2-18.4-3.7-30.3-3.7"/>
<path fill="#c8b100" stroke="#000" stroke-width=".4" d="M206.1 201.9c-12.9 0-24.5 1.5-32.8 4a1 1 0 01-1.3-.6 1 1 0 01.7-1.3 121 121 0 0133.4-4.2c13.2 0 25.2 1.7 33.5 4.2.6.2.9.8.7 1.3-.2.5-.8.8-1.3.6-8.4-2.5-20-4-32.9-4"/>
<path fill="none" stroke="#000" stroke-linejoin="round" stroke-width=".4" d="M206.1 215.6c-10.6 0-20.2-1.2-27.5-3.1 7.3-2 16.9-3 27.5-3.1a115 115 0 0127.6 3c-7.3 2-17 3.2-27.6 3.2z"/>
<path fill="#fff" stroke="#000" stroke-width=".4" d="M197 204.8c0-.5.4-1 1-1 .5 0 1 .5 1 1s-.4 1-1 1a1 1 0 01-1-1"/>
<path fill="#ad1519" stroke="#000" stroke-width=".4" d="M206.1 205.6H203a1 1 0 010-2h6.4c.5 0 1 .5 1 1s-.5 1-1 1h-3.2"/>
<path fill="#058e6e" stroke="#000" stroke-width=".4" d="M190.3 206.5l-2.3.2c-.6.1-1-.3-1.2-.8a1 1 0 011-1.1l2.2-.3 2.4-.3c.5 0 1 .3 1.1.9.1.5-.3 1-.9 1l-2.3.4"/>
<path fill="#fff" stroke="#000" stroke-width=".4" d="M181 206.7c0-.6.5-1 1.1-1 .6 0 1 .4 1 1 0 .5-.4 1-1 1a1 1 0 01-1-1"/>
<path fill="#ad1519" stroke="#000" stroke-width=".4" d="M174 208.5l1.2-1.6 3.3.4-2.6 2-1.8-.8"/>
<path fill="#058e6e" stroke="#000" stroke-width=".4" d="M222 206.5l2.3.2c.5.1 1-.3 1.1-.8a1 1 0 00-.9-1.1l-2.2-.3-2.4-.3a1 1 0 00-1.1.9c-.1.5.3 1 .9 1l2.3.4"/>
<path fill="#fff" stroke="#000" stroke-width=".4" d="M213.3 204.8c0-.5.4-1 1-1s1 .5 1 1-.4 1-1 1a1 1 0 01-1-1m15.8 1.9c0-.6.5-1 1-1 .6 0 1.1.4 1.1 1 0 .5-.4 1-1 1a1 1 0 01-1-1"/>
<path fill="#ad1519" stroke="#000" stroke-width=".4" d="M238.2 208.5l-1.1-1.6-3.3.4 2.6 2 1.8-.8"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M177.3 212.8c7.4-2.1 17.6-3.4 28.8-3.4 11.3 0 21.4 1.3 28.9 3.4"/>
<path fill="#c8b100" d="M182.3 183.8l1.4 1 2-3.2a7.4 7.4 0 01-3.6-7.2c.2-4.1 5.2-7.6 11.7-7.6 3.3 0 6.3 1 8.5 2.4 0-.6 0-1.2.2-1.8a17.4 17.4 0 00-8.7-2.1c-7.4 0-13.2 4.1-13.5 9.1a8.9 8.9 0 003 7.6l-1 1.8"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M182.3 183.8l1.4 1 2-3.2a7.4 7.4 0 01-3.6-7.2c.2-4.1 5.2-7.6 11.7-7.6 3.3 0 6.3 1 8.5 2.4 0-.6 0-1.2.2-1.8a17.4 17.4 0 00-8.7-2.1c-7.4 0-13.2 4.1-13.5 9.1a8.9 8.9 0 003 7.6l-1 1.8"/>
<path fill="#c8b100" d="M182.4 183.8a9.3 9.3 0 01-4-7.3c0-3.2 2-6.1 5.3-8a8.5 8.5 0 00-3.4 6.8 8.9 8.9 0 003 6.7l-.9 1.8"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M182.4 183.8a9.3 9.3 0 01-4-7.3c0-3.2 2-6.1 5.3-8a8.5 8.5 0 00-3.4 6.8 8.9 8.9 0 003 6.7l-.9 1.8"/>
<path fill="#c8b100" d="M160.1 187.1a8.8 8.8 0 01-2.3-5.9c0-1.3.3-2.6 1-3.8 2-4.2 8.4-7.2 16-7.2 2 0 4 .2 5.9.6l-1 1.4a25.5 25.5 0 00-4.9-.4c-7 0-12.8 2.7-14.5 6.3a7 7 0 00-.7 3.1 7.3 7.3 0 002.7 5.6l-2.6 4.1-1.3-1 1.7-2.8"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M160.1 187.1a8.8 8.8 0 01-2.3-5.9c0-1.3.3-2.6 1-3.8 2-4.2 8.4-7.2 16-7.2 2 0 4 .2 5.9.6l-1 1.4a25.5 25.5 0 00-4.9-.4c-7 0-12.8 2.7-14.5 6.3a7 7 0 00-.7 3.1 7.3 7.3 0 002.7 5.6l-2.6 4.1-1.3-1 1.7-2.8z"/>
<path fill="#c8b100" d="M162.7 173.3a10.5 10.5 0 00-4 4.1 8.6 8.6 0 00-.9 3.8c0 2.3.9 4.3 2.3 5.9l-1.5 2.5a10.4 10.4 0 01-2.3-6.5c0-4 2.5-7.5 6.4-9.8"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M162.7 173.3a10.5 10.5 0 00-4 4.1 8.6 8.6 0 00-.9 3.8c0 2.3.9 4.3 2.3 5.9l-1.5 2.5a10.4 10.4 0 01-2.3-6.5c0-4 2.5-7.5 6.4-9.8z"/>
<path fill="#c8b100" d="M206 164.4c1.7 0 3.2 1.1 3.5 2.6.3 1.4.4 2.9.4 4.5v1.1c.1 3.3.6 6.3 1.3 8.1l-5.2 5-5.2-5c.7-1.8 1.2-4.8 1.3-8.1v-1.1c0-1.6.2-3.1.4-4.5.3-1.5 1.8-2.6 3.5-2.6"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M206 164.4c1.7 0 3.2 1.1 3.5 2.6.3 1.4.4 2.9.4 4.5v1.1c.1 3.3.6 6.3 1.3 8.1l-5.2 5-5.2-5c.7-1.8 1.2-4.8 1.3-8.1v-1.1c0-1.6.2-3.1.4-4.5.3-1.5 1.8-2.6 3.5-2.6z"/>
<path fill="#c8b100" d="M206 166c1 0 1.7.6 1.8 1.4.2 1.2.4 2.6.4 4.2v1c.1 3.2.6 6 1.2 7.7l-3.4 3.2-3.4-3.2c.7-1.7 1.1-4.5 1.2-7.7v-1a28.1 28.1 0 01.4-4.2 2 2 0 011.8-1.4"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M206 166c1 0 1.7.6 1.8 1.4.2 1.2.4 2.6.4 4.2v1c.1 3.2.6 6 1.2 7.7l-3.4 3.2-3.4-3.2c.7-1.7 1.1-4.5 1.2-7.7v-1a28.1 28.1 0 01.4-4.2 2 2 0 011.8-1.4z"/>
<path fill="#c8b100" d="M229.7 183.8l-1.3 1-2-3.2a7.4 7.4 0 003.6-6.3 7 7 0 000-.9c-.2-4.1-5.3-7.6-11.7-7.6a15 15 0 00-8.5 2.4 23 23 0 00-.2-1.8 17.4 17.4 0 018.7-2.1c7.4 0 13.2 4.1 13.4 9.1a8.9 8.9 0 01-3 7.6l1 1.8"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M229.7 183.8l-1.3 1-2-3.2a7.4 7.4 0 003.6-6.3 7 7 0 000-.9c-.2-4.1-5.3-7.6-11.7-7.6a15 15 0 00-8.5 2.4 23 23 0 00-.2-1.8 17.4 17.4 0 018.7-2.1c7.4 0 13.2 4.1 13.4 9.1a8.9 8.9 0 01-3 7.6l1 1.8"/>
<path fill="#c8b100" d="M229.6 183.8a9.1 9.1 0 004.1-7.3c0-3.2-2.1-6.1-5.3-8a8.5 8.5 0 013.4 6.8 8.9 8.9 0 01-3.2 6.7l1 1.8"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M229.6 183.8a9.1 9.1 0 004.1-7.3c0-3.2-2.1-6.1-5.3-8a8.5 8.5 0 013.4 6.8 8.9 8.9 0 01-3.2 6.7l1 1.8"/>
<path fill="#c8b100" d="M252 187.1a8.8 8.8 0 002.2-5.9 8.7 8.7 0 00-.9-3.8c-2-4.2-8.4-7.2-16-7.2a29 29 0 00-6 .6l1 1.4a25.4 25.4 0 015-.4c7 0 12.8 2.7 14.4 6.3.5 1 .7 2 .7 3.1a7.3 7.3 0 01-2.6 5.6l2.5 4.1 1.3-1-1.7-2.8"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M252 187.1a8.8 8.8 0 002.2-5.9 8.7 8.7 0 00-.9-3.8c-2-4.2-8.4-7.2-16-7.2a29 29 0 00-6 .6l1 1.4a25.4 25.4 0 015-.4c7 0 12.8 2.7 14.4 6.3.5 1 .7 2 .7 3.1a7.3 7.3 0 01-2.6 5.6l2.5 4.1 1.3-1-1.7-2.8z"/>
<path fill="#c8b100" d="M249.3 173.3a10.6 10.6 0 014 4.1 8.7 8.7 0 01.9 3.8 8.8 8.8 0 01-2.3 5.9l1.6 2.5a10.4 10.4 0 002.3-6.5c0-4-2.6-7.5-6.5-9.8"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M249.3 173.3a10.6 10.6 0 014 4.1 8.7 8.7 0 01.9 3.8 8.8 8.8 0 01-2.3 5.9l1.6 2.5a10.4 10.4 0 002.3-6.5c0-4-2.6-7.5-6.5-9.8z"/>
<path fill="#fff" d="M204.2 181.4c0-1 .8-1.8 1.8-1.8s1.9.8 1.9 1.8-.9 1.7-1.9 1.7a1.8 1.8 0 01-1.8-1.7"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M204.2 181.4c0-1 .8-1.8 1.8-1.8s1.9.8 1.9 1.8-.9 1.7-1.9 1.7a1.8 1.8 0 01-1.8-1.7z"/>
<path fill="#fff" stroke="#000" stroke-width=".4" d="M204.2 178c0-1 .8-1.8 1.8-1.8s1.9.8 1.9 1.8-.9 1.7-1.9 1.7a1.8 1.8 0 01-1.8-1.7m.4-3.7c0-.7.6-1.3 1.4-1.3.8 0 1.5.6 1.5 1.3 0 .8-.7 1.4-1.5 1.4s-1.4-.6-1.4-1.4m.4-3.3c0-.5.4-1 1-1s1 .5 1 1-.4 1-1 1a1 1 0 01-1-1m.2-2.8c0-.5.4-.8.8-.8.5 0 .9.3.9.8 0 .4-.4.8-.9.8a.8.8 0 01-.8-.8"/>
<path fill="#c8b100" stroke="#000" stroke-width=".4" d="M206.2 191.8l1.2.2a4.6 4.6 0 004.5 6 4.7 4.7 0 004.4-3c.1 0 .5-1.7.7-1.7.2 0 .1 1.8.2 1.7.3 2.3 2.4 3.8 4.7 3.8a4.6 4.6 0 004.7-5l1.5-1.5.7 2a4 4 0 00-.4 1.9 4.4 4.4 0 004.5 4.2c1.6 0 3-.7 3.8-1.9l.9-1.2v1.5c0 1.5.6 2.8 2 3 0 0 1.7.1 4-1.6 2.1-1.7 3.3-3.1 3.3-3.1l.2 1.7s-1.8 2.8-3.8 4c-1 .6-2.7 1.3-4 1-1.4-.2-2.4-1.3-3-2.6a6.7 6.7 0 01-3.3 1 6.5 6.5 0 01-6.1-3.7 7 7 0 01-10.4-.3 7 7 0 01-4.6 1.8 6.9 6.9 0 01-5.7-3 6.9 6.9 0 01-5.7 3 7 7 0 01-4.7-1.8 7 7 0 01-10.4.3 6.5 6.5 0 01-6 3.7 6.7 6.7 0 01-3.4-1c-.6 1.3-1.5 2.4-3 2.7-1.2.2-2.9-.5-4-1.1-2-1.2-3.8-4-3.8-4l.2-1.7s1.2 1.4 3.4 3.1c2.2 1.8 3.9 1.6 3.9 1.6 1.4-.2 2-1.5 2-3v-1.5l1 1.2a4.6 4.6 0 003.7 2c2.5 0 4.5-2 4.5-4.3a4 4 0 00-.4-2l.8-1.9 1.5 1.5a4.4 4.4 0 000 .6c0 2.4 2 4.4 4.6 4.4 2.4 0 4.4-1.5 4.7-3.8 0 0 0-1.6.2-1.7.2 0 .6 1.7.7 1.6a4.7 4.7 0 004.5 3.1 4.6 4.6 0 004.5-6l1.2-.2"/>
<path fill="#fff" stroke="#000" stroke-width=".4" d="M238.6 197.7c.3-.8 0-1.6-.6-1.8-.5-.2-1.2.3-1.5 1.1-.3.8 0 1.6.6 1.8.5.2 1.2-.3 1.5-1.1m-20.5-4c0-.8-.3-1.6-1-1.6-.5-.1-1 .5-1.2 1.4-.1.8.3 1.5.9 1.6.6 0 1.2-.6 1.3-1.4m-23.9 0c0-.8.4-1.6 1-1.6.6-.1 1.1.5 1.2 1.4.1.8-.3 1.5-.9 1.6-.6 0-1.1-.6-1.2-1.4m-20.6 4c-.2-.8 0-1.6.6-1.8.6-.2 1.2.3 1.5 1.1.3.8 0 1.6-.5 1.8-.6.2-1.3-.3-1.6-1.1"/>
<path fill="#c8b100" stroke="#000" stroke-width=".4" d="M182.7 184a5.1 5.1 0 012.2 2.9s0-.3.6-.6 1-.3 1-.3l-.1 1.3-.3 2.2a7.4 7.4 0 01-.7 1.6 1.9 1.9 0 00-1.5-.4 1.8 1.8 0 00-1.2.9s-.7-.6-1.2-1.3l-1.1-2-.7-1.1s.5-.2 1.1 0c.6 0 .8.2.8.2a4.9 4.9 0 011-3.4m.4 9.8a1.8 1.8 0 01-.6-1c0-.5 0-.9.3-1.2 0 0-.9-.5-1.8-.7-.7-.2-2-.2-2.3-.2h-1l.2.5c.2.5.5.7.5.7a5 5 0 00-3 2 5.3 5.3 0 003.5 1l-.2.8v.6l1-.4c.3-.1 1.5-.5 2-1 .8-.4 1.5-1.1 1.5-1.1m2.7-.5a1.6 1.6 0 00.2-1.1 1.7 1.7 0 00-.6-1l1.4-1.3a10 10 0 012-.9l1.1-.4v.6a5.7 5.7 0 01-.2.8 5 5 0 013.4 1 5 5 0 01-2.9 2 6.4 6.4 0 00.7 1.2h-1c-.4 0-1.6 0-2.3-.2a11 11 0 01-1.8-.7"/>
<path fill="#ad1519" stroke="#000" stroke-width=".4" d="M182.2 192.4c0-1 1-2 2-2s2.2 1 2.2 2c0 1.1-1 2-2.1 2a2 2 0 01-2.1-2"/>
<path fill="#c8b100" stroke="#000" stroke-width=".4" d="M206.1 180.8a5.7 5.7 0 011.9 3.7s.2-.3.9-.5c.7-.3 1.2-.2 1.2-.2l-.5 1.4-.8 2.4a8.2 8.2 0 01-1 1.7 2.1 2.1 0 00-1.7-.7c-.6 0-1.2.3-1.6.7 0 0-.6-.7-1-1.7l-.8-2.4-.5-1.4 1.2.2c.7.2.9.5.9.5 0-1.4.8-2.8 1.8-3.7"/>
<path fill="#c8b100" stroke="#000" stroke-width=".4" d="M204.6 191.8a2 2 0 01-.5-1.2c0-.5.1-1 .4-1.3 0 0-.8-.7-1.8-1-.7-.4-2-.7-2.5-.7l-1.2-.2.2.6.4.9a5.9 5.9 0 00-3.7 1.7c1 .9 2.3 1.6 3.7 1.6l-.4 1-.2.6 1.2-.2c.4-.1 1.8-.4 2.5-.7 1-.4 1.9-1 1.9-1m3 0a1.9 1.9 0 00.1-2.6s.9-.7 1.8-1a8 8 0 012.5-.7l1.2-.3-.1.7-.4.9c1.4 0 2.7.8 3.6 1.7a5.9 5.9 0 01-3.6 1.6 6.9 6.9 0 00.5 1.6l-1.2-.2-2.5-.7c-1-.4-1.8-1-1.8-1m22-8a5.2 5.2 0 00-2.2 3l-.7-.6c-.6-.3-1-.3-1-.3l.2 1.3c0 .3 0 1.3.3 2.2.2 1 .6 1.6.6 1.6a2 2 0 011.5-.4c.6.1 1 .5 1.3.9l1.1-1.3c.6-.8 1-1.7 1.1-2l.7-1.1s-.4-.2-1 0c-.7 0-1 .2-1 .2a4.9 4.9 0 00-1-3.4m-.3 9.8c.3-.3.5-.6.6-1a1.6 1.6 0 00-.2-1.2s.8-.5 1.7-.7c.7-.2 2-.2 2.3-.2h1.1l-.3.5a6.2 6.2 0 01-.4.7 5 5 0 012.9 2 5.3 5.3 0 01-3.5 1l.2.8v.6l-1-.4c-.3-.1-1.4-.5-2-1-.8-.4-1.4-1.1-1.4-1.1m-2.8-.5a1.7 1.7 0 01-.2-1.1c0-.5.3-.8.6-1 0 0-.6-.8-1.4-1.3-.6-.4-1.7-.8-2-.9a171.4 171.4 0 01-1-.4v.6c0 .5.2.8.2.8a5.2 5.2 0 00-3.5 1c.7.9 1.7 1.7 3 2 0 0-.3.2-.5.7l-.3.5h1c.4 0 1.7 0 2.3-.2a11.1 11.1 0 001.8-.7"/>
<path fill="#ad1519" stroke="#000" stroke-width=".4" d="M226 192.4c0-1 1-2 2-2s2.1 1 2.1 2a2 2 0 01-2 2 2 2 0 01-2.1-2m23.2 4.4c-.4-.5-1.4-.4-2.2.2-.8.7-1 1.6-.5 2.2.5.5 1.5.4 2.3-.3.7-.6 1-1.6.5-2"/>
<path fill="#c8b100" stroke="#000" stroke-width=".4" d="M246.3 198l.7-1c.7-.6 1.8-.7 2.3-.2l.1.2s1-2 2.3-2.6c1.3-.7 3.4-.5 3.4-.5a2.8 2.8 0 00-2.9-2.8 3 3 0 00-2.4 1l-.2-1s-1.3.3-1.9 1.8c-.6 1.5 0 3.6 0 3.6s-.3-.9-.7-1.5a8 8 0 00-2.4-1.6l-1.3-.7-.1.5a5 5 0 000 .8 7.9 7.9 0 00-3.7.5 4.7 4.7 0 002.5 2.2l-.8.7a4 4 0 00-.4.5l1.3.2 2.5.2a14.5 14.5 0 001.7-.2m-80.3 0c0-.4-.3-.7-.7-1-.7-.7-1.7-.8-2.2-.3l-.2.3s-1-2-2.3-2.7c-1.2-.7-3.3-.5-3.3-.5a2.8 2.8 0 012.8-2.8c1 0 1.9.4 2.4 1l.2-1s1.3.3 2 1.8c.5 1.5-.1 3.6-.1 3.6s.3-.9.8-1.5a8 8 0 012.4-1.6l1.3-.7v1.3a7.9 7.9 0 013.7.5 4.7 4.7 0 01-2.5 2.2l.8.7.4.5-1.2.2-2.6.2a14.7 14.7 0 01-1.7-.2"/>
<path fill="#ad1519" stroke="#000" stroke-width=".4" d="M163 196.8c.6-.5 1.6-.4 2.4.3.7.6 1 1.5.4 2-.5.6-1.5.5-2.2-.2-.8-.6-1-1.6-.5-2m41-6.3c0-1.1.9-2 2-2s2.1.9 2.1 2c0 1-1 2-2 2a2 2 0 01-2.1-2"/>
<path fill="#005bbf" stroke="#000" stroke-width=".3" d="M201.8 160.6c0-2.2 1.9-4 4.3-4s4.2 1.8 4.2 4-1.9 4-4.3 4a4.1 4.1 0 01-4.2-4"/>
<path fill="#c8b100" stroke="#000" stroke-width=".3" d="M205 149.3v2.2h-2.4v2.2h2.3v6.3H202l-.2.6c0 .6.1 1.1.3 1.6h7.9c.2-.5.3-1 .3-1.6l-.2-.6h-2.8v-6.3h2.3v-2.2h-2.3v-2.2h-2.4z"/>
<path fill="#ccc" d="M206.5 330.6a82 82 0 01-35.5-8.2 22.7 22.7 0 01-12.8-20.4v-32h96.4v32a22.7 22.7 0 01-12.8 20.4 81 81 0 01-35.3 8.2"/>
<path fill="none" stroke="#000" stroke-width=".5" d="M206.5 330.6a82 82 0 01-35.5-8.2 22.7 22.7 0 01-12.8-20.4v-32h96.4v32a22.7 22.7 0 01-12.8 20.4 81 81 0 01-35.3 8.2z"/>
<path fill="#ccc" d="M206.3 270h48.3v-53.5h-48.3V270z"/>
<path fill="none" stroke="#000" stroke-width=".5" d="M206.3 270h48.3v-53.5h-48.3V270z"/>
<path fill="#ad1519" d="M206.3 302c0 12.6-10.7 22.9-24 22.9s-24.2-10.3-24.2-23v-32h48.2v32"/>
<path fill="#c8b100" stroke="#000" stroke-width=".5" d="M168.6 320.9c1.5.8 3.6 2 5.8 2.6l-.1-54.7h-5.7v52z"/>
<path fill="#c8b100" stroke="#000" stroke-linejoin="round" stroke-width=".5" d="M158 301.6a24.4 24.4 0 005.5 15v-47.5h-5.4v32.5z"/>
<path fill="#c7b500" stroke="#000" stroke-width=".5" d="M179.4 324.7a26.6 26.6 0 005.6 0v-55.9h-5.6v56z"/>
<path fill="#c8b100" stroke="#000" stroke-width=".5" d="M190 323.5a19 19 0 005.8-2.5v-52.2H190l-.1 54.7z"/>
<path fill="#ad1519" d="M158.1 270h48.2v-53.5H158V270z"/>
<path fill="none" stroke="#000" stroke-width=".5" d="M158.1 270h48.2v-53.5H158V270z"/>
<path fill="#c8b100" stroke="#000" stroke-width=".5" d="M201 316c2.4-2 4.6-6.8 5.4-12.2l.1-35H201l.1 47.3z"/>
<path fill="none" stroke="#000" stroke-width=".5" d="M206.3 302c0 12.6-10.7 22.9-24 22.9s-24.2-10.3-24.2-23v-32h48.2v32"/>
<path fill="#ad1519" d="M254.6 270v32c0 12.6-10.8 22.9-24.1 22.9s-24.2-10.3-24.2-23v-32h48.3"/>
<path fill="none" stroke="#000" stroke-width=".5" d="M254.6 270v32c0 12.6-10.8 22.9-24.1 22.9s-24.2-10.3-24.2-23v-32h48.3"/>
<path fill="#c8b100" d="M215.1 294.1l.1.5c0 .6-.5 1-1.1 1a1 1 0 01-1.1-1v-.5h-1.5a2.5 2.5 0 001.8 2.9v3.9h1.6V297a2.6 2.6 0 001.7-1.6h4.4v-1.2h-6m21.8 0v1.2h-4a2.5 2.5 0 01-.3.6l4.6 5.2-1.2 1-4.6-5.3-.2.1v8.7h-1.6V297h-.2l-4.8 5.2-1.2-1 4.7-5.3a2.1 2.1 0 01-.2-.4h-4V294h13zm2.6 0v1.2h4.4c.3.8.9 1.4 1.7 1.6v3.9h1.6V297a2.5 2.5 0 001.8-2.4 2 2 0 000-.5h-1.6l.1.5c0 .6-.5 1-1 1-.7 0-1.2-.4-1.2-1a1 1 0 01.1-.5h-5.9m-6.7 22.1a15.6 15.6 0 003.7-1l.8 1.4a17.6 17.6 0 01-4.3 1.2 2.6 2.6 0 01-2.6 2 2.6 2.6 0 01-2.5-2 17.5 17.5 0 01-4.6-1.2l.8-1.4c1.3.5 2.6.9 4 1a2.5 2.5 0 011.5-1.3v-6.7h1.6v6.7c.7.2 1.3.7 1.6 1.4zm-11-2.2l-.8 1.4a16.6 16.6 0 01-3.6-3.1c-.9.2-1.8 0-2.5-.5a2.4 2.4 0 01-.3-3.5l.1-.1a15.3 15.3 0 01-1.3-4.8h1.7a13.1 13.1 0 001 4c.5 0 1 0 1.4.2l4.1-4.5 1.3 1-4.1 4.5c.5.9.5 2-.1 2.8a15.2 15.2 0 003.1 2.6zm-6-4.8c.3-.4 1-.5 1.5 0s.5 1 .1 1.4a1.2 1.2 0 01-1.6.1 1 1 0 010-1.5zm-2.2-4.5l-1.6-.3-.3-4.3 1.7-.6v2.5c0 1 0 1.8.2 2.7zm1.4-5.3l1.7.4v2.2c0-.8.3 2.1.3 2.1l-1.7.6a14 14 0 01-.3-2.7v-2.6zm5.6 13.7a15.7 15.7 0 004.8 2.6l.4-1.6a13.7 13.7 0 01-4-2l-1.2 1m-.8 1.4a17.4 17.4 0 004.8 2.6l-1.2 1.1a18.7 18.7 0 01-4-2l.4-1.7m2.2-9.4l1.6.7 3-3.3-1-1.4-3.6 4m-1.3-1l-1-1.4 3-3.3 1.6.7-3.6 4m18.1 9.9l.8 1.4a16.7 16.7 0 003.6-3.1c.9.2 1.8 0 2.5-.5a2.4 2.4 0 00.3-3.5l-.1-.1a15 15 0 001.3-4.8h-1.7a13.3 13.3 0 01-1 4 3 3 0 00-1.4.2l-4.1-4.5-1.3 1 4.1 4.5a2.4 2.4 0 00.1 2.8 15 15 0 01-3.1 2.6zm6-4.8a1.2 1.2 0 00-1.5 0 1 1 0 00-.1 1.4 1.2 1.2 0 001.6.1 1 1 0 000-1.5zm2.2-4.5l1.6-.3.3-4.3-1.7-.6v2.5c0 1 0 1.9-.2 2.8zm-1.4-5.3l-1.7.4v2.2c0-.8-.3 2.1-.3 2.1l1.7.6.3-2.7v-2.6m-5.6 13.7a15.7 15.7 0 01-4.8 2.6l-.4-1.6a13.7 13.7 0 004-2l1.2 1m.8 1.4a17.4 17.4 0 01-4.8 2.6l1.2 1.1a18.6 18.6 0 004-2l-.4-1.7m-2.2-9.4l-1.6.7-2.9-3.3 1-1.4 3.5 4m1.3-1l1-1.4-3-3.3-1.6.7 3.6 4m-20.1-8.7l.5 1.6h4.5l.5-1.6h-5.5m21.1 0l-.5 1.6h-4.5l-.5-1.6h5.5m-11.6 21.9c0-.6.5-1 1.1-1a1 1 0 011.1 1c0 .6-.5 1-1 1a1.1 1.1 0 01-1.2-1zm1.9-7.8l1.7-.4v-4.3l-1.7-.5v5.2m-1.6 0l-1.7-.4v-4.3l1.7-.5v5.2"/>
<path fill="#c8b100" d="M211.5 294.2c.2-1 1-1.6 1.8-2V287h1.6v5.3c.8.3 1.5.9 1.7 1.6h4.4v.3h-6a1.2 1.2 0 00-1-.6c-.4 0-.7.3-1 .6h-1.5m12.2 0v-.3h4.1a2.4 2.4 0 01.2-.3l-5-5.7 1.2-1 5 5.6.2-.1V285h1.6v7.3h.3l4.9-5.5 1.2 1-4.9 5.5.3.6h4v.3h-13zm21.6 0a1.1 1.1 0 011-.6c.5 0 .8.3 1 .6h1.6c-.2-1-.9-1.6-1.8-2V287h-1.6v5.3c-.8.3-1.4.8-1.7 1.6h-4.4v.3h6m-30.2-15l6 6.8 1.3-1-6.1-6.7.3-.6h4.4V276h-4.4a2.6 2.6 0 00-2.5-1.7 2.6 2.6 0 00-2.7 2.5 2.5 2.5 0 001.8 2.4v5.2h1.6v-5.2h.3zm32 0v5.3h-1.7v-5.2a2.5 2.5 0 01-.4-.2l-6 6.8-1.3-1 6.2-6.9-.1-.3h-4.5V276h4.5a2.6 2.6 0 012.4-1.7 2.6 2.6 0 012.7 2.5 2.5 2.5 0 01-1.9 2.4zm-16.1 0v3.3h-1.7v-3.2a2.6 2.6 0 01-1.7-1.6h-4V276h4a2.6 2.6 0 012.5-1.7c1.2 0 2.2.7 2.5 1.7h4v1.6h-4a2.5 2.5 0 01-1.6 1.6zm-17.8 4l-1.7.4v4.3l1.7.5v-5.2m1.6 0l1.7.4v4.3l-1.7.5v-5.2m30.6 0l-1.7.4v4.3l1.7.5v-5.2m1.6 0l1.7.4v4.3l-1.7.5v-5.2m-25.5.8l1.6-.7 2.9 3.3-1 1.4-3.5-4m-1.3 1l-1 1.4 3 3.3 1.6-.7-3.6-4m18.5-1.1l-1.6-.7-3 3.3 1 1.4 3.6-4m1.2 1l1 1.4-3 3.3-1.5-.7 3.5-4m-20.3 9l.5-1.6h4.5l.5 1.6h-5.5m-6.7-17c0-.6.5-1 1.2-1a1 1 0 011 1c0 .6-.4 1-1 1a1.1 1.1 0 01-1.2-1zm12.1.8l-.5 1.6h-4.5l-.5-1.6h5.5m0-1.6l-.5-1.6h-4.5l-.5 1.6h5.5m15.7 17.8l-.5-1.6h-4.5l-.5 1.6h5.5m4.4-17c0-.6.5-1 1.1-1a1 1 0 011.1 1c0 .6-.5 1-1 1a1.1 1.1 0 01-1.2-1zm-16.1 0c0-.6.5-1 1.1-1a1 1 0 011.1 1c0 .6-.5 1-1.1 1a1.1 1.1 0 01-1.1-1zm6.2.8l.5 1.6h4.6l.5-1.6h-5.6m0-1.6l.5-1.6h4.6l.5 1.6h-5.6m-5.9 5l-1.7.5v4.3l1.7.5V281m1.7 0l1.6.5v4.3l-1.6.5V281"/>
<path fill="none" stroke="#c8b100" stroke-width=".3" d="M232.7 316.3a15.6 15.6 0 003.7-1.1l.8 1.4a17.6 17.6 0 01-4.3 1.2 2.6 2.6 0 01-2.6 2 2.6 2.6 0 01-2.5-2 17.5 17.5 0 01-4.6-1.2l.8-1.4c1.3.5 2.6.9 4 1a2.5 2.5 0 011.5-1.3v-6.7h1.6v6.7c.7.2 1.3.7 1.6 1.4zm-4.7-20.4a2.3 2.3 0 01-.2-.5h-4V294h4a2.6 2.6 0 01.2-.4l-5-5.6 1.2-1 5 5.5a2.2 2.2 0 01.2 0V285h1.7v7.3h.2l4.9-5.5 1.2 1-4.9 5.5.3.6h4v1.5h-4c0 .2-.2.4-.3.5l4.7 5.3-1.3 1-4.6-5.3-.2.1v8.7h-1.6V297l-.2-.1-4.8 5.3-1.2-1 4.7-5.3m-12.8-16.7l6 6.8 1.3-1-6.1-6.7.3-.6h4.4V276h-4.4a2.6 2.6 0 00-2.5-1.7 2.6 2.6 0 00-2.6 2.5 2.5 2.5 0 001.7 2.4v5.2h1.6v-5.2h.3zm6.5 34.8l-.8 1.4a16.6 16.6 0 01-3.6-3.1c-.9.2-1.8 0-2.5-.5a2.4 2.4 0 01-.3-3.5l.1-.1a15.3 15.3 0 01-1.2-4.8h1.6a13.1 13.1 0 001 4c.5 0 1 0 1.4.2l4.1-4.5 1.3 1-4.1 4.5c.6.9.5 2-.1 2.8a15.2 15.2 0 003.1 2.6zm-8.4-13.1V297a2.5 2.5 0 01-1.8-2.4c0-1 .8-2 1.8-2.4V287h1.6v5.3c.8.2 1.5.8 1.7 1.6h4.4v1.5h-4.4a2.6 2.6 0 01-1.6 1.6v3.9h-1.7m2.3 8.3c.4-.4 1.1-.5 1.6 0s.5 1 .1 1.4a1.2 1.2 0 01-1.6.1 1 1 0 010-1.5zm-2-4.5l-1.7-.3-.3-4.3 1.7-.6v2.5c0 1 0 1.8.3 2.7zm1.4-5.3l1.6.4v2.2c0-.8.3 2.1.3 2.1l-1.7.6-.3-2.7v-2.6zm5.5 13.7a15.7 15.7 0 004.8 2.6l.4-1.6a13.7 13.7 0 01-4-2l-1.2 1m-.8 1.4a17.4 17.4 0 004.8 2.6l-1.2 1.1a18.7 18.7 0 01-4-2l.4-1.7"/>
<path fill="none" stroke="#c8b100" stroke-width=".3" d="M221.9 305.1l1.6.7 3-3.3-1-1.4-3.6 4m-1.3-1l-1-1.4 3-3.3 1.6.7-3.6 4m-7.6-9.5c0-.6.5-1 1-1 .7 0 1.2.5 1.2 1 0 .6-.5 1.1-1.1 1.1a1 1 0 01-1.1-1zm25.7 19.4l.8 1.4a16.7 16.7 0 003.6-3.1c.9.2 1.8 0 2.6-.5a2.4 2.4 0 00.2-3.5l-.1-.1a15 15 0 001.3-4.8h-1.7a13.3 13.3 0 01-1 4 3 3 0 00-1.4.2l-4.1-4.5-1.3 1 4.1 4.5a2.4 2.4 0 00.1 2.8 15 15 0 01-3 2.6zm8.4-13.1V297a2.5 2.5 0 001.8-2.4c0-1-.7-2-1.8-2.4V287h-1.6v5.3c-.8.2-1.4.8-1.7 1.6h-4.4v1.5h4.4c.3.8.9 1.3 1.7 1.6v3.9h1.6zm-2.3 8.3a1.2 1.2 0 00-1.6 0 1 1 0 00-.1 1.4 1.2 1.2 0 001.6.1 1 1 0 000-1.5zm2-4.5l1.7-.3.3-4.3-1.7-.6v2.5c0 1 0 1.8-.2 2.7zm-1.3-5.3l-1.7.4v2.2c0-.8-.3 2.1-.3 2.1l1.7.6.3-2.7v-2.6m1.6-20.1v5.2h-1.6v-5.2a2.3 2.3 0 01-.4-.2l-6 6.8-1.2-1 6-7v-.2h-4.5V276h4.4a2.6 2.6 0 012.5-1.7 2.6 2.6 0 012.6 2.5 2.5 2.5 0 01-1.8 2.4zm-16 0v3.2h-1.7v-3.2a2.6 2.6 0 01-1.7-1.6h-4V276h4c.4-1 1.3-1.7 2.5-1.7s2.2.7 2.5 1.7h4v1.6h-4a2.5 2.5 0 01-1.6 1.6zm8.8 33.8a15.7 15.7 0 01-4.8 2.6l-.4-1.6a13.7 13.7 0 004-2l1.2 1m.8 1.4a17.4 17.4 0 01-4.8 2.6l1.2 1.1a18.7 18.7 0 004-2l-.4-1.7m-27.4-31.4l-1.7.5v4.3l1.7.5v-5.2m1.7 0l1.6.4v4.3l-1.6.5V283m30.5 0l-1.7.5v4.3l1.7.5V283"/>
<path fill="none" stroke="#c8b100" stroke-width=".3" d="M247.1 283.1l1.7.5v4.3l-1.7.5V283m-8.6 22l-1.6.7-2.9-3.3 1-1.4 3.5 4m1.3-1l1-1.4-3-3.3-1.6.7 3.6 4m-18.2-20l1.6-.7 3 3.3-1 1.4-3.6-4m-1.3 1l-1 1.4 3 3.3 1.6-.7-3.6-4m18.5-1.1l-1.6-.7-3 3.3 1 1.4 3.6-4m1.2 1l1 1.4-3 3.2-1.5-.6 3.5-4m-20.3 9l.5-1.6h4.5l.5 1.6h-5.5m0 1.5l.5 1.6h4.5l.5-1.6h-5.5M213 277c0-.6.5-1 1.2-1 .6 0 1 .4 1 1s-.4 1-1 1a1 1 0 01-1.2-1zm12.1.8l-.5 1.6h-4.5l-.5-1.6h5.5m0-1.6l-.5-1.6h-4.5l-.5 1.6h5.5m20.1 18.5c0-.5.5-1 1.1-1 .6 0 1.1.5 1.1 1 0 .6-.5 1.1-1 1.1a1 1 0 01-1.2-1zm-4.4-.7l-.5-1.6h-4.5l-.5 1.6h5.5m0 1.5l-.5 1.6h-4.5l-.5-1.6h5.5m-11.6 21.9c0-.6.5-1 1.1-1 .6 0 1.1.4 1.1 1s-.5 1-1 1a1.1 1.1 0 01-1.2-1zm1.9-7.8l1.7-.4v-4.3l-1.7-.5v5.2m-1.6 0l-1.7-.4v-4.3l1.7-.5v5.2m15.7-32.6c0-.6.5-1 1.1-1a1 1 0 011.1 1c0 .6-.5 1-1 1a1.1 1.1 0 01-1.2-1zm-16.1 0c0-.6.5-1 1.1-1a1 1 0 011.1 1c0 .6-.5 1-1 1a1.1 1.1 0 01-1.2-1zm6.2.8l.5 1.6h4.6l.5-1.6h-5.5m0-1.6l.4-1.6h4.6l.5 1.6h-5.5m-6 5l-1.6.5v4.3l1.6.5V281m1.7 0l1.6.5v4.3l-1.6.5V281"/>
<path fill="#058e6e" d="M227.7 294.7a2.6 2.6 0 012.6-2.5 2.6 2.6 0 012.6 2.5 2.6 2.6 0 01-2.6 2.4c-1.4 0-2.6-1-2.6-2.4"/>
<path fill="#db4446" d="M230.9 229.7v-.6l.1-.3-2.3-.1a5.9 5.9 0 01-2.3-1.2c-.8-.7-1.1-1-1.6-1.2-1.3-.2-2.3.4-2.3.4s1 .4 1.7 1.3 1.5 1.3 1.8 1.4c.6.2 2.6 0 3.1.1l1.8.2"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M230.9 229.7v-.6l.1-.3-2.3-.1a5.9 5.9 0 01-2.3-1.2c-.8-.7-1.1-1-1.6-1.2-1.3-.2-2.3.4-2.3.4s1 .4 1.7 1.3 1.5 1.3 1.8 1.4c.6.2 2.6 0 3.1.1l1.8.2z"/>
<path fill="#ed72aa" stroke="#000" stroke-width=".4" d="M238.1 227.5v1.4c.2.6-.1 1.2 0 1.5 0 .4.1.6.3.9l.2.9-.7-.5-.6-.4v1c.1.2.3.8.6 1.1l1 1.3c.2.5.1 1.4.1 1.4s-.4-.7-.8-.8l-1.2-.7s.7.8.7 1.5c0 .8-.3 1.6-.3 1.6s-.3-.7-.8-1.1l-1-.9s.4 1.2.4 2v2.3l-.9-1-1-.7c0-.2.5.6.6 1.1 0 .5.3 2.3 1.8 4.5 1 1.3 2.3 3.6 5.3 2.9 3-.8 1.9-4.8 1.3-6.7a16.8 16.8 0 01-1-4.6c0-.8.6-2.9.5-3.3a8 8 0 01.2-3.1c.4-1.3.7-1.8.9-2.3.2-.6.4-.9.4-1.3l.1-1.3.7 1.3.1 1.5s.1-1 1-1.6c.8-.6 1.8-1.1 2-1.4.3-.3.3-.5.3-.5s0 1.8-.6 2.6l-1.7 2s.7-.3 1.2-.3h.9s-.6.4-1.4 1.6c-.8 1-.5 1.2-1 2.1-.6 1-1 1-1.7 1.5-1 .8-.5 4.2-.4 4.7.2.5 2 4.5 2 5.5s.2 3.2-1.5 4.6c-1.1 1-3 1-3.4 1.2-.4.3-1.2 1.1-1.2 2.8 0 1.7.6 2 1 2.4.6.5 1.2.2 1.3.6.2.3.2.5.5.7.2.2.3.4.2.8 0 .3-.8 1.1-1.1 1.7l-.8 2.4c0 .2-.1 1 .1 1.3 0 0 .9 1 .3 1.2-.4.2-.8-.2-1-.2l-.9.5c-.3-.1-.3-.3-.4-.8l-.1-.7c-.2 0-.3.2-.4.5 0 .2 0 .8-.3.8-.2 0-.5-.4-.8-.5-.2 0-.8-.2-.8-.4 0-.3.4-.9.7-1 .4 0 .8-.3.5-.5s-.5-.2-.7 0-.8 0-.7-.2v-.8c0-.2-.4-.5.1-.8.6-.3.8.2 1.4.1.6 0 .8-.3 1-.6.2-.3.2-1-.2-1.4-.4-.5-.7-.5-.9-.8l-.3-.9v2.2l-.7-.8c-.3-.3-.6-1.3-.6-1.3v1.3c0 .4.3.7.2.8-.1.1-.8-.7-1-.8a3.7 3.7 0 01-1-1l-.4-1.4a4.2 4.2 0 010-1.5l.4-1h-1.4c-.7 0-1.2-.3-1.5.2-.3.5-.2 1.5.2 2.8.3 1.2.5 1.9.4 2.1a3 3 0 01-.7.8h-.9a2.5 2.5 0 00-1.2-.3h-1.3l-1.1-.3c-.3.1-.8.3-.6.7.2.6-.2.7-.5.7l-.9-.2c-.4-.1-.9 0-.8-.4 0-.4.2-.4.4-.7.2-.3.2-.5 0-.5h-.6c-.2.2-.5.5-.8.4-.2-.1-.4-.4-.4-1s-.7-1.2 0-1.1c.5 0 1.3.4 1.4 0 .2-.3 0-.4-.2-.7s-.8-.4-.3-.7l.7-.5c.1-.2.4-.8.7-.6.6.2 0 .7.6 1.3.6.7 1 1 2 .8 1 0 1.3-.2 1.3-.5l-.1-1v-1s-.4.3-.5.6l-.4.8v-2a8 8 0 00-.2-.8l-.3.9-.1 1s-.7-.5-.5-1.5c.1-.7-.1-1.6.1-2 .2-.3.7-1.5 2-1.6h2.6l2-.3s-2.8-1.4-3.5-1.9a9.5 9.5 0 01-2-2l-.6-1.6s-.5 0-1 .3a5 5 0 00-1.2 1l-.7 1 .1-1.2v-.8s-.4 1.2-1 1.7l-1.4 1v-.8l.2-1s-.4.8-1.1 1c-.7 0-1.8 0-1.9.4 0 .5.2 1 0 1.4 0 .3-.4.5-.4.5l-.8-.4c-.4 0-.7.2-.7.2s-.3-.4-.2-.7c.1-.2.7-.6.5-.8l-.8.2c-.3.1-.8.3-.8-.2 0-.4.2-.7 0-1 0-.3 0-.5.2-.6l1.2-.1c0-.2-.2-.5-.8-.6-.6-.1-.8-.5-.5-.8.3-.2.3-.3.5-.6.1-.2.2-.7.7-.5.5.3.4.8 1 1a4 4 0 002-.2l1.5-1 1.5-1-1-.8c-.3-.3-.7-.9-1-1a8.3 8.3 0 00-1.8-.6 9 9 0 01-1.7-.5l.8-.3c.2-.2.6-.6.8-.6h.3-1.4c-.3-.1-1-.6-1.3-.6l-.8.1s.8-.4 1.4-.5l1-.1s-.9-.3-1.1-.6l-.6-1c-.2-.1-.3-.5-.6-.5l-1 .3c-.4 0-.6-.2-.6-.6l-.1-.5c-.2-.3-.6-.8-.2-1h1.4c0-.2-.5-.6-.8-.8-.4-.2-1-.5-.7-.8l.8-.5c.2-.3.3-1 .7-.7.4.2.8 1.2 1.1 1.1.3 0 .3-.8.3-1 0-.4 0-1 .2-.9.3 0 .5.4 1 .5.4 0 1-.1 1 .2 0 .3-.3.7-.6 1-.3.3-.4 1-.3 1.4.2.5.7 1.2 1.2 1.4.4.3 1.2.5 1.7.9.5.3 1.7 1.2 2.1 1.3l.8.4s.5-.2 1.1-.2c.7 0 2.1 0 2.6-.2.6-.2 1.3-.6 1-1-.1-.6-1.3-1-1.2-1.4 0-.4.5-.4 1.2-.4.8 0 1.8.1 2-1 .2-1 .2-1.5-.8-1.8-1-.2-1.8-.2-2-1-.2-.7-.4-.9-.2-1.1.3-.2.6-.3 1.4-.4.8 0 1.6 0 1.9-.2.2-.2.3-.7.6-.9.3-.2 1.4-.4 1.4-.4s1.4.7 2.7 1.7a15 15 0 012.2 2.1"/>
<path d="M228.1 226.8l-.2-.6v-.3s.8 0 .7.3c0 .2-.2.2-.3.3l-.2.3"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M228.1 226.8l-.2-.6v-.3s.8 0 .7.3c0 .2-.2.2-.3.3l-.2.3z"/>
<path d="M232 225.4v-.4s.7 0 1 .3c.5.4.9 1 .9 1l-.8-.4h-.5l-.3-.1v-.3h-.3"/>
<path fill="none" stroke="#000" stroke-width=".1" d="M232 225.4v-.4s.7 0 1 .3c.5.4.9 1 .9 1l-.8-.4h-.5l-.3-.1v-.3h-.3z"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M237.3 231.3l-.4-.7a8 8 0 01-.3-.4"/>
<path fill="#db4446" d="M217.4 226.6s.5.4.8.4h.8s.2-.5.1-.8c-.2-1.2-1.2-1.4-1.2-1.4s.3.7.1 1a2 2 0 01-.6.8"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M217.4 226.6s.5.4.8.4h.8s.2-.5.1-.8c-.2-1.2-1.2-1.4-1.2-1.4s.3.7.1 1a2 2 0 01-.6.8z"/>
<path fill="#db4446" d="M215.2 227.6s-.4-.7-1.3-.6c-.8 0-1.4.8-1.4.8h1.2c.3.3.4 1 .4 1l.7-.6a7.2 7.2 0 00.4-.6"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M215.2 227.6s-.4-.7-1.3-.6c-.8 0-1.4.8-1.4.8h1.2c.3.3.4 1 .4 1l.7-.6a7.2 7.2 0 00.4-.6z"/>
<path fill="#db4446" d="M214.2 230.6s-.8.1-1.2.6c-.4.5-.3 1.3-.3 1.3s.4-.5.9-.5l1 .2-.1-.8-.3-.8"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M214.2 230.6s-.8.1-1.2.6c-.4.5-.3 1.3-.3 1.3s.4-.5.9-.5l1 .2-.1-.8-.3-.8z"/>
<path d="M228.2 230.5l.3-.5.3.5h-.7"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M228.2 230.5l.3-.5.3.5h-.7"/>
<path d="M229 230.5l.3-.5.4.5h-.8"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M229 230.5l.3-.5.4.5h-.8"/>
<path d="M228.6 227.3l.8.3-.7.4-.1-.6"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M228.6 227.3l.8.3-.7.4-.1-.6"/>
<path d="M229.5 227.6l.7.2-.5.4-.2-.6"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M229.5 227.6l.7.2-.5.4-.2-.6"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M224.2 233.7s-.7.2-1 .6c-.4.5-.3 1-.3 1s.6-.5 1.5-.3l1.2.3 1.3-.3s-.7.8-.7 1.3l.2 1.1c0 .7-.6 1.6-.6 1.6l1-.3a4.6 4.6 0 001.7-.8l.9-1s-.2 1 0 1.4l.2 1.6.8-.6c.2-.1.7-.4.9-.7l.3-1s0 .8.4 1.3l.6 1.6s.3-.8.6-1.1c.3-.4.7-.8.7-1a4.3 4.3 0 00-.1-.9l.4.8m-11 .6s.5-.8 1-1l1.1-.8.9-.4m1 5l1.3-.8a4 4 0 001-1"/>
<path fill="#db4446" d="M216.6 240.4s-.4-.5-1.1-.3c-.7 0-1.2.9-1.2.9s.6-.2 1-.1.6.4.6.4l.4-.4.3-.6"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M216.6 240.4s-.4-.5-1.1-.3c-.7 0-1.2.9-1.2.9s.6-.2 1-.1.6.4.6.4l.4-.4.3-.6z"/>
<path fill="#db4446" d="M215.8 243.2s-.6 0-1.1.3c-.5.4-.5 1.2-.5 1.2s.4-.4.8-.3l.9.2v-.6c.2-.4-.1-.8-.1-.8"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M215.8 243.2s-.6 0-1.1.3c-.5.4-.5 1.2-.5 1.2s.4-.4.8-.3l.9.2v-.6c.2-.4-.1-.8-.1-.8z"/>
<path fill="#db4446" d="M217.2 245.8s0 .8.3 1.3c.4.5 1.1.5 1.1.5l-.3-.7c0-.4.3-.8.3-.8s-.3-.3-.7-.3h-.7"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M217.2 245.8s0 .8.3 1.3c.4.5 1.1.5 1.1.5l-.3-.7c0-.4.3-.8.3-.8s-.3-.3-.7-.3h-.7zm16 1.3s2 1.2 1.9 2.2c0 1-1 2.3-1 2.3"/>
<path fill="#db4446" d="M224.2 252.6s-.4-.6-1.1-.6c-.7 0-1.4.7-1.4.7s.8-.1 1 .2l.5.6.5-.3.5-.6"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M224.2 252.6s-.4-.6-1.1-.6c-.7 0-1.4.7-1.4.7s.8-.1 1 .2l.5.6.5-.3.5-.6z"/>
<path fill="#db4446" d="M222.2 255.3s-1-.1-1.4.3c-.4.5-.4 1.3-.4 1.3s.6-.6 1-.5c.5 0 1 .3 1 .3v-.7l-.3-.7"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M222.2 255.3s-1-.1-1.4.3c-.4.5-.4 1.3-.4 1.3s.6-.6 1-.5c.5 0 1 .3 1 .3v-.7l-.3-.7z"/>
<path fill="#db4446" d="M224 258.1s-.3.7 0 1.1c.3.5 1 .8 1 .8s-.3-.4-.2-.8c.1-.3.7-.8.7-.8l-1.4-.2"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M224 258.1s-.3.7 0 1.1c.3.5 1 .8 1 .8s-.3-.4-.2-.8c.1-.3.7-.8.7-.8l-1.4-.2z"/>
<path fill="#db4446" d="M236 259.3s-.8-.2-1.2 0c-.5.3-.8 1.4-.8 1.4s.7-.6 1.2-.5c.5 0 1 .3 1 .3v-.8l-.2-.4"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M236 259.3s-.8-.2-1.2 0c-.5.3-.8 1.4-.8 1.4s.7-.6 1.2-.5c.5 0 1 .3 1 .3v-.8l-.2-.4z"/>
<path fill="#db4446" d="M236.4 262.2s-.6.6-.4 1.1l.6 1s0-.7.2-1l1-.3-.7-.5a15.8 15.8 0 01-.7-.3"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M236.4 262.2s-.6.6-.4 1.1l.6 1s0-.7.2-1l1-.3-.7-.5a15.8 15.8 0 01-.7-.3z"/>
<path fill="#db4446" d="M239.4 263s-.3.8.2 1.3c.6.5 1 .5 1 .5s-.3-.7-.2-1.1c.1-.5.5-.7.5-.7l-.8-.2-.7.3"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M239.4 263s-.3.8.2 1.3c.6.5 1 .5 1 .5s-.3-.7-.2-1.1c.1-.5.5-.7.5-.7l-.8-.2-.7.3z"/>
<path fill="#ffd691" stroke="#000" stroke-width=".5" d="M208.8 316.4c2 .6 3 2 3 3.8 0 2.3-2.2 4-5 4-3 0-5.3-1.7-5.3-4 0-1.7 1-3.6 3-3.8l-.2-.4-.7-.7h1.2l.8.5.5-.7c.3-.4.6-.5.6-.5l.6.6.3.5.7-.4.8-.3s0 .4-.2.7l-.1.7"/>
<path fill="#058e6e" stroke="#000" stroke-width=".5" d="M206.3 326.7s-3.8-2.6-5.5-3c-2-.4-4.5 0-5.5 0 0 0 1.2.8 1.8 1.4.5.5 2.3 1.5 3.3 1.8 3 .8 6-.2 6-.2m1 .2s2.4-2.5 5-2.9c3-.4 5 .3 6.2.6l-1.5.8c-.5.3-2 1.5-4 1.6-2 0-4.4-.3-4.8-.2l-.9.1"/>
<path fill="#ad1519" stroke="#000" stroke-width=".5" d="M206.7 323.8a4.8 4.8 0 010-7.1 4.8 4.8 0 011.5 3.5 4.9 4.9 0 01-1.5 3.6"/>
<path fill="#058e6e" stroke="#000" stroke-width=".5" d="M205.7 329s.6-1.5.6-2.7l-.1-2.1h.8s.3 1.1.3 2l-.1 2.4-.7.1-.8.3"/>
<path fill="#fff" d="M254 190.7c0-.5.5-1 1-1 .6 0 1.1.5 1.1 1 0 .6-.5 1-1 1a1 1 0 01-1-1"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M254 190.7c0-.5.5-1 1-1 .6 0 1.1.5 1.1 1 0 .6-.5 1-1 1a1 1 0 01-1-1z"/>
<path fill="#fff" d="M255.4 188.2c0-.6.5-1 1.1-1 .6 0 1 .4 1 1s-.4 1-1 1a1 1 0 01-1-1"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M255.4 188.2c0-.6.5-1 1.1-1 .6 0 1 .4 1 1s-.4 1-1 1a1 1 0 01-1-1z"/>
<path fill="#fff" d="M256.4 185.2c0-.5.5-1 1-1 .6 0 1.1.5 1.1 1s-.5 1-1 1a1 1 0 01-1.1-1"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M256.4 185.2c0-.5.5-1 1-1 .6 0 1.1.5 1.1 1s-.5 1-1 1a1 1 0 01-1.1-1z"/>
<path fill="#fff" d="M256.5 182c0-.5.5-1 1-1 .6 0 1.1.5 1.1 1 0 .6-.5 1-1 1a1 1 0 01-1-1"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M256.5 182c0-.5.5-1 1-1 .6 0 1.1.5 1.1 1 0 .6-.5 1-1 1a1 1 0 01-1-1z"/>
<path fill="#fff" d="M255.7 179c0-.6.5-1 1-1 .7 0 1.2.4 1.2 1s-.5 1-1.1 1a1 1 0 01-1-1"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M255.7 179c0-.6.5-1 1-1 .7 0 1.2.4 1.2 1s-.5 1-1.1 1a1 1 0 01-1-1z"/>
<path fill="#fff" d="M254.1 176.1c0-.5.5-1 1-1 .7 0 1.1.5 1.1 1s-.4 1-1 1a1 1 0 01-1-1"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M254.1 176.1c0-.5.5-1 1-1 .7 0 1.1.5 1.1 1s-.4 1-1 1a1 1 0 01-1-1z"/>
<path fill="#fff" d="M252 173.8c0-.6.4-1 1-1s1 .4 1 1-.4 1-1 1a1 1 0 01-1-1"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M252 173.8c0-.6.4-1 1-1s1 .4 1 1-.4 1-1 1a1 1 0 01-1-1z"/>
<path fill="#fff" d="M249.4 171.8c0-.5.5-1 1.1-1a1 1 0 010 2c-.6 0-1-.4-1-1"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M249.4 171.8c0-.5.5-1 1.1-1a1 1 0 010 2c-.6 0-1-.4-1-1z"/>
<path fill="#fff" d="M246.5 170.3c0-.6.4-1 1-1s1 .4 1 1-.4 1-1 1a1 1 0 01-1-1"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M246.5 170.3c0-.6.4-1 1-1s1 .4 1 1-.4 1-1 1a1 1 0 01-1-1z"/>
<path fill="#fff" d="M243.3 169.1c0-.5.5-1 1.1-1a1 1 0 010 2 1 1 0 01-1-1"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M243.3 169.1c0-.5.5-1 1.1-1a1 1 0 010 2 1 1 0 01-1-1z"/>
<path fill="#fff" d="M239.9 168.5c0-.5.4-1 1-1s1 .5 1 1-.4 1-1 1a1 1 0 01-1-1"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M239.9 168.5c0-.5.4-1 1-1s1 .5 1 1-.4 1-1 1a1 1 0 01-1-1z"/>
<path fill="#fff" d="M236.6 168.3c0-.5.4-1 1-1s1 .5 1 1-.4 1-1 1a1 1 0 01-1-1"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M236.6 168.3c0-.5.4-1 1-1s1 .5 1 1-.4 1-1 1a1 1 0 01-1-1z"/>
<path fill="#fff" d="M233.3 168.5c0-.6.5-1 1-1 .7 0 1.1.4 1.1 1s-.4 1-1 1a1 1 0 01-1-1"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M233.3 168.5c0-.6.5-1 1-1 .7 0 1.1.4 1.1 1s-.4 1-1 1a1 1 0 01-1-1z"/>
<path fill="#fff" d="M230.1 168.5c0-.6.5-1 1-1 .6 0 1.1.4 1.1 1s-.5 1-1 1a1 1 0 01-1.1-1"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M230.1 168.5c0-.6.5-1 1-1 .6 0 1.1.4 1.1 1s-.5 1-1 1a1 1 0 01-1.1-1z"/>
<path fill="#fff" stroke="#000" stroke-width=".4" d="M231.7 171.2c0-.5.5-1 1-1 .7 0 1.1.5 1.1 1s-.4 1-1 1a1 1 0 01-1-1m.6 3.1c0-.6.4-1 1-1s1 .4 1 1c0 .5-.4 1-1 1a1 1 0 01-1-1m0 3c0-.5.6-1 1.1-1a1 1 0 010 2 1 1 0 01-1-1m-1 2.8c0-.5.5-1 1-1 .7 0 1.1.5 1.1 1 0 .6-.4 1-1 1a1 1 0 01-1-1m-1.9 2.6c0-.5.5-1 1-1 .7 0 1.2.5 1.2 1s-.5 1-1.1 1c-.6 0-1-.4-1-1"/>
<path fill="#fff" d="M227.6 166.5c0-.5.5-1 1.1-1a1 1 0 010 2 1 1 0 01-1-1"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M227.6 166.5c0-.5.5-1 1.1-1a1 1 0 010 2 1 1 0 01-1-1z"/>
<path fill="#fff" d="M224.8 165c0-.6.4-1 1-1s1 .4 1 1-.4 1-1 1a1 1 0 01-1-1"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M224.8 165c0-.6.4-1 1-1s1 .4 1 1-.4 1-1 1a1 1 0 01-1-1z"/>
<path fill="#fff" d="M221.6 164c0-.6.5-1 1-1 .6 0 1.1.4 1.1 1 0 .5-.5 1-1 1-.6 0-1.1-.5-1.1-1"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M221.6 164c0-.6.5-1 1-1 .6 0 1.1.4 1.1 1 0 .5-.5 1-1 1-.6 0-1.1-.5-1.1-1z"/>
<path fill="#fff" d="M218.3 163.4c0-.5.5-1 1-1 .6 0 1.1.5 1.1 1s-.5 1-1 1a1 1 0 01-1.1-1"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M218.3 163.4c0-.5.5-1 1-1 .6 0 1.1.5 1.1 1s-.5 1-1 1a1 1 0 01-1.1-1z"/>
<path fill="#fff" d="M215 163.5c0-.6.5-1 1.1-1 .6 0 1 .4 1 1 0 .5-.4 1-1 1a1 1 0 01-1-1"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M215 163.5c0-.6.5-1 1.1-1 .6 0 1 .4 1 1 0 .5-.4 1-1 1a1 1 0 01-1-1z"/>
<path fill="#fff" d="M211.7 164c0-.5.5-1 1-1 .7 0 1.1.5 1.1 1s-.4 1-1 1a1 1 0 01-1-1"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M211.7 164c0-.5.5-1 1-1 .7 0 1.1.5 1.1 1s-.4 1-1 1a1 1 0 01-1-1z"/>
<path fill="#fff" d="M208.6 165.1c0-.5.5-1 1-1 .6 0 1.1.5 1.1 1s-.5 1-1 1a1 1 0 01-1.1-1"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M208.6 165.1c0-.5.5-1 1-1 .6 0 1.1.5 1.1 1s-.5 1-1 1a1 1 0 01-1.1-1z"/>
<path fill="#fff" d="M156 190.7c0-.5.4-1 1-1s1 .5 1 1c0 .6-.4 1-1 1a1 1 0 01-1-1"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M156 190.7c0-.5.4-1 1-1s1 .5 1 1c0 .6-.4 1-1 1a1 1 0 01-1-1z"/>
<path fill="#fff" d="M154.5 188.2c0-.6.5-1 1-1 .6 0 1 .4 1 1s-.4 1-1 1a1 1 0 01-1-1"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M154.5 188.2c0-.6.5-1 1-1 .6 0 1 .4 1 1s-.4 1-1 1a1 1 0 01-1-1z"/>
<path fill="#fff" d="M153.5 185.2c0-.5.5-1 1-1 .7 0 1.1.5 1.1 1s-.4 1-1 1a1 1 0 01-1-1"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M153.5 185.2c0-.5.5-1 1-1 .7 0 1.1.5 1.1 1s-.4 1-1 1a1 1 0 01-1-1z"/>
<path fill="#fff" d="M153.4 182c0-.5.5-1 1-1 .6 0 1.1.5 1.1 1 0 .6-.5 1-1 1a1 1 0 01-1-1"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M153.4 182c0-.5.5-1 1-1 .6 0 1.1.5 1.1 1 0 .6-.5 1-1 1a1 1 0 01-1-1z"/>
<path fill="#fff" d="M154.2 179c0-.6.5-1 1-1 .6 0 1 .4 1 1s-.4 1-1 1a1 1 0 01-1-1"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M154.2 179c0-.6.5-1 1-1 .6 0 1 .4 1 1s-.4 1-1 1a1 1 0 01-1-1z"/>
<path fill="#fff" d="M155.8 176.1c0-.5.5-1 1-1 .6 0 1.1.5 1.1 1s-.5 1-1 1a1 1 0 01-1-1"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M155.8 176.1c0-.5.5-1 1-1 .6 0 1.1.5 1.1 1s-.5 1-1 1a1 1 0 01-1-1z"/>
<path fill="#fff" d="M158 173.8c0-.6.4-1 1-1s1 .4 1 1-.4 1-1 1a1 1 0 01-1-1"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M158 173.8c0-.6.4-1 1-1s1 .4 1 1-.4 1-1 1a1 1 0 01-1-1z"/>
<path fill="#fff" d="M160.5 171.8c0-.5.4-1 1-1s1 .5 1 1-.4 1-1 1a1 1 0 01-1-1"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M160.5 171.8c0-.5.4-1 1-1s1 .5 1 1-.4 1-1 1a1 1 0 01-1-1z"/>
<path fill="#fff" d="M163.5 170.3c0-.6.4-1 1-1s1 .4 1 1-.4 1-1 1a1 1 0 01-1-1"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M163.5 170.3c0-.6.4-1 1-1s1 .4 1 1-.4 1-1 1a1 1 0 01-1-1z"/>
<path fill="#fff" d="M166.6 169.1c0-.5.5-1 1-1a1 1 0 010 2 1 1 0 01-1-1"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M166.6 169.1c0-.5.5-1 1-1a1 1 0 010 2 1 1 0 01-1-1z"/>
<path fill="#fff" d="M170 168.5c0-.5.5-1 1.1-1a1 1 0 010 2c-.6 0-1-.4-1-1"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M170 168.5c0-.5.5-1 1.1-1a1 1 0 010 2c-.6 0-1-.4-1-1z"/>
<path fill="#fff" d="M173.4 168.3c0-.5.4-1 1-1s1 .5 1 1-.4 1-1 1a1 1 0 01-1-1"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M173.4 168.3c0-.5.4-1 1-1s1 .5 1 1-.4 1-1 1a1 1 0 01-1-1z"/>
<path fill="#fff" d="M176.6 168.5c0-.6.5-1 1-1 .6 0 1.1.4 1.1 1s-.5 1-1 1a1 1 0 01-1.1-1"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M176.6 168.5c0-.6.5-1 1-1 .6 0 1.1.4 1.1 1s-.5 1-1 1a1 1 0 01-1.1-1z"/>
<path fill="#fff" d="M179.8 168.5c0-.6.5-1 1-1 .7 0 1.2.4 1.2 1s-.5 1-1.1 1a1 1 0 01-1-1"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M179.8 168.5c0-.6.5-1 1-1 .7 0 1.2.4 1.2 1s-.5 1-1.1 1a1 1 0 01-1-1z"/>
<path fill="#fff" stroke="#000" stroke-width=".4" d="M178.2 171.2c0-.5.5-1 1-1 .7 0 1.1.5 1.1 1s-.4 1-1 1a1 1 0 01-1-1m-.7 3.1c0-.6.4-1 1-1s1 .4 1 1c0 .5-.4 1-1 1a1 1 0 01-1-1m-.2 3c0-.5.5-1 1-1 .7 0 1.1.5 1.1 1s-.4 1-1 1a1 1 0 01-1-1m.9 2.8c0-.5.5-1 1-1 .6 0 1.1.5 1.1 1 0 .6-.5 1-1 1a1 1 0 01-1.1-1m1.8 2.6c0-.5.5-1 1-1a1 1 0 010 2 1 1 0 01-1-1"/>
<path fill="#fff" d="M182.3 166.5c0-.5.5-1 1-1a1 1 0 010 2 1 1 0 01-1-1"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M182.3 166.5c0-.5.5-1 1-1a1 1 0 010 2 1 1 0 01-1-1z"/>
<path fill="#fff" d="M185.2 165c0-.6.4-1 1-1s1 .4 1 1-.4 1-1 1a1 1 0 01-1-1"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M185.2 165c0-.6.4-1 1-1s1 .4 1 1-.4 1-1 1a1 1 0 01-1-1z"/>
<path fill="#fff" d="M188.3 164c0-.6.5-1 1-1 .7 0 1.1.4 1.1 1 0 .5-.4 1-1 1s-1-.5-1-1"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M188.3 164c0-.6.5-1 1-1 .7 0 1.1.4 1.1 1 0 .5-.4 1-1 1s-1-.5-1-1z"/>
<path fill="#fff" d="M191.6 163.4c0-.5.5-1 1-1 .7 0 1.1.5 1.1 1s-.4 1-1 1a1 1 0 01-1-1"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M191.6 163.4c0-.5.5-1 1-1 .7 0 1.1.5 1.1 1s-.4 1-1 1a1 1 0 01-1-1z"/>
<path fill="#fff" d="M194.9 163.5c0-.6.4-1 1-1s1 .4 1 1c0 .5-.4 1-1 1a1 1 0 01-1-1"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M194.9 163.5c0-.6.4-1 1-1s1 .4 1 1c0 .5-.4 1-1 1a1 1 0 01-1-1z"/>
<path fill="#fff" d="M198.2 164c0-.5.5-1 1-1 .7 0 1.1.5 1.1 1s-.4 1-1 1a1 1 0 01-1-1"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M198.2 164c0-.5.5-1 1-1 .7 0 1.1.5 1.1 1s-.4 1-1 1a1 1 0 01-1-1z"/>
<path fill="#fff" d="M201.3 165.1c0-.5.5-1 1-1 .7 0 1.1.5 1.1 1s-.4 1-1 1a1 1 0 01-1-1"/>
<path fill="none" stroke="#000" stroke-width=".4" d="M201.3 165.1c0-.5.5-1 1-1 .7 0 1.1.5 1.1 1s-.4 1-1 1a1 1 0 01-1-1z"/>
<path fill="#c8b100" stroke="#000" stroke-width=".4" d="M174.7 228.9h-1v-1h-1.5v3.6h1.6v2.5h-3.4v7h1.8v14.3h-3.5v7.3h27.2v-7.3h-3.5V241h1.8v-7h-3.4v-2.5h1.6V228h-1.6v.9h-.8v-1h-1.6v1h-1.1v-1h-1.6v3.6h1.6v2.5H184v-7.8h1.7v-3.5H184v.9h-1v-1h-1.5v1h-.9v-1H179v3.6h1.7v7.8h-3.3v-2.5h1.6V228h-1.6v.9h-.9v-1h-1.8v1zm-6 33.7H196m-27.3-1.8H196m-27.3-1.8H196m-27.3-1.7H196m-27.3-2H196m-23.8-1.6h20.2m-20.2-1.8h20.2m-20.2-2h20.2m-20.2-1.7h20.2m-20.2-1.8h20.2m-20.2-1.8h20.2m-20.2-1.7h20.2m-22-1.8h23.8m-23.8-1.8h23.8m-23.8-1.8h23.8m-23.8-1.8h23.8m-20.4-1.7h17m-10.2-1.8h3.4m-3.4-1.8h3.4m-3.4-1.8h3.4m-3.4-1.7h3.4m-5.1-2.2h6.8m-12 7.5h3.6m-5-2.2h6.6m-6.7 32.6v-1.8m0-1.8v-1.7m-1.8 1.7v1.8m3.4 0V259m1.7 3.6v-1.8m0-1.8v-1.7m0-2v-1.6m0-1.8v-2m-1.7 7.4v-2m-3.4 2v-2m7 0v2m1.5-2v-1.6m-5.1-1.8v1.8m3.5-1.8v1.8m3.3-1.8v1.8M179 252v-2m1.7-1.7v1.7m0-5.3v1.8m-1.7-3.6v1.8m1.7-3.5v1.7m-3.3-1.7v1.7m-3.5-1.7v1.7m-1.6-3.5v1.8m3.3-1.8v1.8m3.4-1.8v1.8m1.7-3.6v1.8m-3.3-1.8v1.8m-3.5-1.8v1.8m-1.6-3.6v1.8m6.7-1.8v1.8m-3.4-5.3v1.8m15.3-1.8h-3.5m5-2.2h-6.6m6.7 32.6v-1.8m0-1.8v-1.7m1.8 1.7v1.8m-3.4 0V259m-1.7 3.6v-1.8m0-1.8v-1.7m0-2v-1.6m0-1.8v-2m1.7 7.4v-2m3.4 2v-2m-7 0v2m-1.5-2v-1.6m5.1-1.8v1.8m-3.5-1.8v1.8m-3.3-1.8v1.8m1.7-1.8v-2m-1.7-1.7v1.7m0-5.3v1.8m1.7-3.6v1.8m-1.7-3.5v1.7m3.3-1.7v1.7m3.5-1.7v1.7m1.6-3.5v1.8m-3.3-1.8v1.8m-3.4-1.8v1.8m-1.7-3.6v1.8m3.3-1.8v1.8m3.5-1.8v1.8m1.6-3.6v1.8m-6.7-1.8v1.8m3.4-5.3v1.8m-7 18v-2m0-5.4v-1.8m0 5.4v-1.8m0-5.3v-1.8m0-1.8v-1.7m0-3.6v-1.8m0-1.7v-1.8m-8.3 4.6h3.5m3.3-5.3h3.4m3.3 5.3h3.5"/>
<path fill="#c8b100" stroke="#000" stroke-width=".4" d="M186.8 262.6v-4.7c0-.8-.4-3.5-4.6-3.5-4 0-4.4 2.7-4.4 3.5v4.7h9z"/>
<path fill="#c8b100" stroke="#000" stroke-width=".4" d="M179.3 258.2l-2.2-.3c0-.9.2-2.2.9-2.6l2 1.5c-.3.2-.7 1-.7 1.4zm6 0l2.2-.3c0-.9-.2-2.2-.9-2.6l-2 1.5c.3.2.7 1 .7 1.4zm-2.2-2.3l1-2a5.3 5.3 0 00-2-.4l-1.7.4 1.1 2h1.6zm-4.2-5.5v-4.9c0-1.3-1-2.4-2.5-2.4s-2.4 1-2.4 2.4v4.9h4.9zm6.8 0v-4.9c0-1.3 1-2.4 2.5-2.4s2.4 1 2.4 2.4v4.9h-4.9zm-1.7-12l.4-4.4h-4.2l.2 4.4h3.6zm3.3 0l-.4-4.4h4.4l-.5 4.4h-3.5zm-10 0l.2-4.4h-4.2l.5 4.4h3.5z"/>
<path fill="#0039f0" d="M185.3 262.6v-4c0-.7-.5-2.7-3.1-2.7-2.4 0-2.9 2-2.9 2.7v4h6zm-6.9-12.7v-4.2c0-1-.6-2.2-2-2.2s-2 1.1-2 2.2v4.3h4zm7.8 0v-4.2c0-1 .7-2.2 2-2.2s2 1.1 2 2.2v4.3h-4z"/>
<path fill="#ad1519" d="M190.8 269.8c0-9.7 7-17.6 15.6-17.6s15.6 7.9 15.6 17.6-7 17.5-15.6 17.5-15.6-7.8-15.6-17.5"/>
<path fill="none" stroke="#000" stroke-width=".6" d="M190.8 269.8c0-9.7 7-17.6 15.6-17.6s15.6 7.9 15.6 17.6-7 17.5-15.6 17.5-15.6-7.8-15.6-17.5z"/>
<path fill="#005bbf" d="M195.4 269.7c0-7 5-12.8 11-12.8s11 5.7 11 12.8c0 7.2-5 13-11 13s-11-5.8-11-13"/>
<path fill="none" stroke="#000" stroke-width=".6" d="M195.4 269.7c0-7 5-12.8 11-12.8s11 5.7 11 12.8c0 7.2-5 13-11 13s-11-5.8-11-13z"/>
<path fill="#c8b100" d="M201.2 260.9s-1.3 1.4-1.3 2.7a6 6 0 00.6 2.4c-.2-.5-.8-.8-1.4-.8-.8 0-1.4.6-1.4 1.3l.2.8.5.9c.1-.3.5-.5 1-.5s1 .4 1 1a.9.9 0 010 .2h-1.2v1h1l-.8 1.5 1-.4.8.9.8-.9 1 .4-.7-1.5h1v-1h-1.1a.9.9 0 010-.3 1 1 0 011-1c.4 0 .7.3 1 .6l.4-1 .2-.7a1.4 1.4 0 00-1.4-1.3c-.7 0-1.2.3-1.4.9 0 0 .6-1.2.6-2.5s-1.4-2.7-1.4-2.7"/>
<path fill="none" stroke="#000" stroke-linejoin="round" stroke-width=".3" d="M201.2 260.9s-1.3 1.4-1.3 2.7a6 6 0 00.6 2.4c-.2-.5-.8-.8-1.4-.8-.8 0-1.4.6-1.4 1.3l.2.8.5.9c.1-.3.5-.5 1-.5s1 .4 1 1a.9.9 0 010 .2h-1.2v1h1l-.8 1.5 1-.4.8.9.8-.9 1 .4-.7-1.5h1v-1h-1.1a.9.9 0 010-.3 1 1 0 011-1c.4 0 .7.3 1 .6l.4-1 .2-.7a1.4 1.4 0 00-1.4-1.3c-.7 0-1.2.3-1.4.9 0 0 .6-1.2.6-2.5s-1.4-2.7-1.4-2.7z"/>
<path fill="#c8b100" d="M199.2 269.9h4.1v-1h-4.1v1z"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M199.2 269.9h4.1v-1h-4.1v1z"/>
<path fill="#c8b100" d="M211.4 260.9s-1.3 1.4-1.3 2.7c0 1.3.6 2.4.6 2.4-.2-.5-.7-.8-1.4-.8-.8 0-1.4.6-1.4 1.3l.2.8.5.9c.2-.3.5-.5 1-.5a1 1 0 011 1 .9.9 0 010 .2h-1.2v1h1l-.8 1.5 1-.4.8.9.8-.9 1 .4-.7-1.5h1v-1h-1.1a.8.8 0 010-.3 1 1 0 011-1c.4 0 .8.3 1 .6l.4-1 .2-.7a1.4 1.4 0 00-1.4-1.3c-.6 0-1.2.3-1.4.9 0 0 .6-1.2.6-2.5s-1.4-2.7-1.4-2.7"/>
<path fill="none" stroke="#000" stroke-linejoin="round" stroke-width=".3" d="M211.4 260.9s-1.3 1.4-1.3 2.7c0 1.3.6 2.4.6 2.4-.2-.5-.7-.8-1.4-.8-.8 0-1.4.6-1.4 1.3l.2.8.5.9c.2-.3.5-.5 1-.5a1 1 0 011 1 .9.9 0 010 .2h-1.2v1h1l-.8 1.5 1-.4.8.9.8-.9 1 .4-.7-1.5h1v-1h-1.1a.8.8 0 010-.3 1 1 0 011-1c.4 0 .8.3 1 .6l.4-1 .2-.7a1.4 1.4 0 00-1.4-1.3c-.6 0-1.2.3-1.4.9 0 0 .6-1.2.6-2.5s-1.4-2.7-1.4-2.7z"/>
<path fill="#c8b100" d="M209.4 269.9h4.1v-1h-4.1v1z"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M209.4 269.9h4.1v-1h-4.1v1z"/>
<path fill="#c8b100" d="M206.3 269.6s-1.3 1.5-1.3 2.8.6 2.4.6 2.4c-.2-.5-.7-.9-1.4-.9-.8 0-1.4.6-1.4 1.4l.2.7.5 1c.1-.4.5-.6 1-.6a1 1 0 011 1 .9.9 0 010 .3h-1.2v1h1l-.8 1.5 1-.4.8.9.8-1 1 .5-.7-1.5h1v-1h-1.1a.9.9 0 010-.3 1 1 0 011-1c.4 0 .7.2.9.6l.5-1 .2-.7a1.4 1.4 0 00-1.4-1.4c-.7 0-1.2.4-1.4 1 0 0 .6-1.2.6-2.5s-1.4-2.7-1.4-2.7"/>
<path fill="none" stroke="#000" stroke-linejoin="round" stroke-width=".3" d="M206.3 269.6s-1.3 1.5-1.3 2.8.6 2.4.6 2.4c-.2-.5-.7-.9-1.4-.9-.8 0-1.4.6-1.4 1.4l.2.7.5 1c.1-.4.5-.6 1-.6a1 1 0 011 1 .9.9 0 010 .3h-1.2v1h1l-.8 1.5 1-.4.8.9.8-1 1 .5-.7-1.5h1v-1h-1.1a.9.9 0 010-.3 1 1 0 011-1c.4 0 .7.2.9.6l.5-1 .2-.7a1.4 1.4 0 00-1.4-1.4c-.7 0-1.2.4-1.4 1 0 0 .6-1.2.6-2.5s-1.4-2.7-1.4-2.7z"/>
<path fill="#c8b100" d="M204.3 278.6h4.1v-1h-4.1v1z"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M204.3 278.6h4.1v-1h-4.1v1z"/>
<path fill="#c8b100" d="M237.6 223.4h-.3a1.5 1.5 0 01-.3.4c-.2.2-.6.2-.8 0a.5.5 0 01-.1-.4.5.5 0 01-.5 0c-.3-.1-.3-.5-.1-.7v-.5h-.3l-.1.2c-.2.3-.5.3-.7.2a.6.6 0 010-.2h-.3c-.5.2-.7-1-.7-1.2l-.2.2s.2.7.1 1.2c0 .6-.3 1.2-.3 1.2a9 9 0 012.9 1.6 9 9 0 012.2 2.3l1.2-.5c.6-.2 1.3-.2 1.3-.2l.2-.2c-.3 0-1.5.1-1.5-.4v-.2a.7.7 0 01-.2 0c-.2-.2-.2-.4 0-.7l.2-.1v-.3h-.3l-.2.1c-.2.3-.6.3-.8 0a.4.4 0 01-.1-.4.6.6 0 01-.5 0c-.2-.2-.3-.5 0-.8l.2-.3v-.3"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M237.6 223.4h-.3a1.5 1.5 0 01-.3.4c-.2.2-.6.2-.8 0a.5.5 0 01-.1-.4.5.5 0 01-.5 0c-.3-.1-.3-.5-.1-.7v-.5h-.3l-.1.2c-.2.3-.5.3-.7.2a.6.6 0 010-.2h-.3c-.5.2-.7-1-.7-1.2l-.2.2s.2.7.1 1.2c0 .6-.3 1.2-.3 1.2a9 9 0 012.9 1.6 9 9 0 012.2 2.3l1.2-.5c.6-.2 1.3-.2 1.3-.2l.2-.2c-.3 0-1.5.1-1.5-.4v-.2a.7.7 0 01-.2 0c-.2-.2-.2-.4 0-.7l.2-.1v-.3h-.3l-.2.1c-.2.3-.6.3-.8 0a.4.4 0 01-.1-.4.6.6 0 01-.5 0c-.2-.2-.3-.5 0-.8l.2-.3v-.3z"/>
<path d="M235.4 224h.2v.3h-.1c-.1 0-.1-.2 0-.2"/>
<path fill="none" stroke="#000" stroke-width=".1" d="M235.4 224h.2v.3h-.1c-.1 0-.1-.2 0-.2z"/>
<path d="M236.3 224.8l-.3-.2v-.2h.1l.4.3.3.2v.2h-.2l-.3-.3"/>
<path fill="none" stroke="#000" stroke-width=".1" d="M236.3 224.8l-.3-.2v-.2h.1l.4.3.3.2v.2h-.2l-.3-.3"/>
<path d="M234.6 223.7l-.2-.2s-.1 0 0-.1l.3.1.3.1v.2h-.1l-.3-.1"/>
<path fill="none" stroke="#000" stroke-width=".1" d="M234.6 223.7l-.2-.2s-.1 0 0-.1l.3.1.3.1v.2h-.1l-.3-.1"/>
<path d="M233.7 223h.2v.2h-.2s-.1-.1 0-.2"/>
<path fill="none" stroke="#000" stroke-width=".1" d="M233.7 223h.2v.2h-.2s-.1-.1 0-.2z"/>
<path d="M237.3 225.5v-.2h-.3l.1.2h.2"/>
<path fill="none" stroke="#000" stroke-width=".1" d="M237.3 225.5v-.2h-.3l.1.2h.2z"/>
<path d="M237.9 226.2l.2.2h.1c.1 0 0-.1 0-.2l-.2-.2-.2-.2h-.1v.2l.2.2"/>
<path fill="none" stroke="#000" stroke-width=".1" d="M237.9 226.2l.2.2h.1c.1 0 0-.1 0-.2l-.2-.2-.2-.2h-.1v.2l.2.2"/>
<path d="M238.8 227v-.3h-.3v.2h.3"/>
<path fill="none" stroke="#000" stroke-width=".1" d="M238.8 227v-.3h-.3v.2h.3z"/>
<path fill="#c8b100" d="M236.2 221.1h-.6l-.1.9v.1h.2l.7-.5-.3-.5"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M236.2 221.1h-.6l-.1.9v.1h.2l.7-.5-.3-.5"/>
<path fill="#c8b100" d="M234.6 221.6v.5l.9.1h.1v-.2l-.5-.7-.5.3"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M234.6 221.6v.5l.9.1h.1v-.2l-.5-.7-.5.3"/>
<path fill="#c8b100" d="M236.4 222.6l-.4.3-.6-.7v-.1h1.1v.5"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M236.4 222.6l-.4.3-.6-.7v-.1h1.1v.5"/>
<path fill="#c8b100" d="M235.3 222a.3.3 0 01.4 0 .3.3 0 010 .3.3.3 0 01-.3 0 .3.3 0 01-.1-.3"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M235.3 222a.3.3 0 01.4 0 .3.3 0 010 .3.3.3 0 01-.3 0 .3.3 0 01-.1-.3z"/>
<path fill="#c8b100" d="M233.2 221.1l-.2-.7-.4-.4s.4-.2.8.1c.4.3 0 .9 0 .9l-.2.1"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M233.2 221.1l-.2-.7-.4-.4s.4-.2.8.1c.4.3 0 .9 0 .9l-.2.1z"/>
<path fill="#c8b100" d="M234.2 221.4l-.4.4-.6-.6v-.2h1v.4"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M234.2 221.4l-.4.4-.6-.6v-.2h1v.4"/>
<path fill="#c8b100" d="M233.1 221l.3-.1v.3c0 .2-.1.2-.2.2l-.1-.3"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M233.1 221l.3-.1v.3c0 .2-.1.2-.2.2l-.1-.3z"/>
<path fill="#c8b100" d="M238.3 222.5h-.5l-.3.7v.2h.2l.8-.4-.2-.5"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M238.3 222.5h-.5l-.3.7v.2h.2l.8-.4-.2-.5"/>
<path fill="#c8b100" d="M236.7 222.8v.5l.8.2h.1v-.2l-.4-.7-.5.2"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M236.7 222.8v.5l.8.2h.1v-.2l-.4-.7-.5.2"/>
<path fill="#c8b100" d="M238.4 224l-.5.2-.4-.7v-.2h.1l.9.2-.1.5"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M238.4 224l-.5.2-.4-.7v-.2h.1l.9.2-.1.5"/>
<path fill="#c8b100" d="M237.3 223.2h.4a.3.3 0 010 .4.3.3 0 01-.3 0 .3.3 0 010-.4"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M237.3 223.2h.4a.3.3 0 010 .4.3.3 0 01-.3 0 .3.3 0 010-.4z"/>
<path fill="#c8b100" d="M240.2 224.3l.1.5-.8.3h-.2v-.2l.4-.8.5.2"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M240.2 224.3l.1.5-.8.3h-.2v-.2l.4-.8.5.2"/>
<path fill="#c8b100" d="M240 225.8l-.5.1-.3-.8v-.1h.2l.8.3-.1.5"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M240 225.8l-.5.1-.3-.8v-.1h.2l.8.3-.1.5"/>
<path fill="#c8b100" d="M238.6 224.3l-.2.5.9.3h.1v-.1l-.3-.8-.5.1"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M238.6 224.3l-.2.5.9.3h.1v-.1l-.3-.8-.5.1"/>
<path fill="#c8b100" d="M239.5 225.2a.3.3 0 000-.3.3.3 0 00-.4 0 .3.3 0 000 .3.3.3 0 00.4 0"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M239.5 225.2a.3.3 0 000-.3.3.3 0 00-.4 0 .3.3 0 000 .3.3.3 0 00.4 0z"/>
<path fill="#c8b100" d="M240.8 227h.8l.5.3s.1-.4-.3-.7c-.3-.3-.8.2-.8.2l-.2.2"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M240.8 227h.8l.5.3s.1-.4-.3-.7c-.3-.3-.8.2-.8.2l-.2.2z"/>
<path fill="#c8b100" d="M240.3 226.1l-.3.5.8.5v-.1h.2l-.1-1-.6.1"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M240.3 226.1l-.3.5.8.5v-.1h.2l-.1-1-.6.1"/>
<path fill="#c8b100" d="M241 227s.1-.1 0-.2h-.3c-.2 0-.2.1-.1.2h.3"/>
<path fill="none" stroke="#000" stroke-width=".3" d="M241 227s.1-.1 0-.2h-.3c-.2 0-.2.1-.1.2h.3zm38-21.9v.6h-2.4v-.6h1v-1.3h-.7v-.5h.6v-.6h.6v.6h.6v.6h-.6v1.2h1"/>
<path fill="none" stroke="#000" stroke-width="0" d="M134.4 217.1v-1.2m-.4 1.2v-1.2m-.2 1.2v-1.2m-.3 1.2v-1.2"/>
<path fill="none" stroke="#000" stroke-width=".1" d="M133.2 217.1v-1.2m-.5 1.1v-1m.2 1v-1m-.7 1v-1m.2 1v-1m-.9 1v-1m.2 1v-1m.3 1v-1m-.7 1v-1m-.3.9v-.8m-.1.8v-.8m-.5.7v-.6m.2.6v-.6m-.4.5v-.5m-.2.5v-.4m-.3.3v-.3m-.3.3v-.2"/>
<path fill="none" stroke="#000" stroke-width=".2" d="M129.2 216.6v-.2"/>
<path fill="none" stroke="#000" stroke-width="0" d="M135.7 217v-1m-.5 1v-1m-.4 1.2V216m143 1.1V216m-.4 1.1V216m-.3 1.1V216m-.3 1.2V216"/>
<path fill="none" stroke="#000" stroke-width=".1" d="M276.6 217.1V216m-.6 1v-1m.3 1v-1m-.8 1v-1m.3 1v-1m-.9 1v-1m.2 1v-1m.2 1v-1m-.6 1v-1m-.3.9v-.8m-.2.8v-.8m-.4.7v-.6m.2.6v-.6m-.5.6v-.6m-.2.5v-.4m-.3.4v-.4m-.2.3v-.2"/>
<path fill="none" stroke="#000" stroke-width=".2" d="M272.6 216.6v-.2"/>
<path fill="none" stroke="#000" stroke-width="0" d="M279.1 217v-1m-.6 1v-1m-.4 1.1V216"/>
</svg>

After

Width:  |  Height:  |  Size: 89 KiB

@@ -0,0 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg" id="flag-icon-css-fr" viewBox="0 0 640 480">
<g fill-rule="evenodd" stroke-width="1pt">
<path fill="#fff" d="M0 0h640v480H0z"/>
<path fill="#00267f" d="M0 0h213.3v480H0z"/>
<path fill="#f31830" d="M426.7 0H640v480H426.7z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 292 B

@@ -0,0 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg" id="flag-icon-css-it" viewBox="0 0 640 480">
<g fill-rule="evenodd" stroke-width="1pt">
<path fill="#fff" d="M0 0h640v480H0z"/>
<path fill="#009246" d="M0 0h213.3v480H0z"/>
<path fill="#ce2b37" d="M426.7 0H640v480H426.7z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 292 B

@@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" id="flag-icon-css-nl" viewBox="0 0 640 480">
<path fill="#21468b" d="M0 0h640v480H0z"/>
<path fill="#fff" d="M0 0h640v320H0z"/>
<path fill="#ae1c28" d="M0 0h640v160H0z"/>
</svg>

After

Width:  |  Height:  |  Size: 224 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

@@ -0,0 +1,7 @@
import './pagebuilder';
import './block-search';
import './run-builder-scripts';
import './manage-editable-components';
import './save-page';
import './ckeditor-hyperlinks';
import './responsive';
@@ -0,0 +1,34 @@
$(document).on("input", "#block-search input", function() {
let term = $(this).val().toLowerCase();
$(".gjs-block-category").each(function() {
let atLeastOneMatch = false;
$(this).find(".gjs-block").each(function() {
if (! $(this).data('original-html')) {
$(this).data('original-html', $(this).html());
}
let label = $(this).text();
if (label.toLowerCase().includes(term)) {
$(this).removeClass("d-none");
atLeastOneMatch = true;
let regEx = new RegExp('(' + term + ')', "gi");
let highlightedText = label.replace(regEx, '<b>$1</b>');
$(this).find(".gjs-block-label").html(
$(this).data('original-html').replace(label.trim(), highlightedText)
);
} else {
$(this).addClass("d-none");
}
});
$(this).removeClass("d-none");
if (! atLeastOneMatch) {
$(this).addClass("d-none");
}
});
});
@@ -0,0 +1,127 @@
window.CKEDITOR.on('instanceReady', function (event) {
event.editor.on('paste', function (event) {
let result = event.data.dataValue;
// remove all not allowed tags
result = result.replace(/<(?!\/?(?:a|table|tr|td|th|thead|tbody|tfoot|caption|col|colgroup|p|ul|ol|li|br|strong|em|b|i|u|strike|sub|sup|h1|h2|h3|h4|h5|h6|blockquote|pre|hr)\b)[^>]+>/gm, '');
// remove all attributes of the allowed tags except from anchor
result = result.replace(/<(a|table|tr|td|th|thead|tbody|tfoot|caption|col|colgroup|p|ul|ol|li|br|strong|em|b|i|u|strike|sub|sup|h1|h2|h3|h4|h5|h6|blockquote|pre|hr)\b[^>]*>/gm, function(match, tag) {
// for anchor tags remove all attributes except href
if (tag === 'a') {
let href = match.match(/href="([^"]*)"/);
if (! href) {
return match;
}
return '<a href="' + href[1] + '">';
}
// allow styling on some tags
if ('|table|tr|td|th|thead|tbody|tfoot|'.includes('|' + tag + '|')) {
let style = match.match(/style="([^"]*)"/);
if (! style) {
return match;
}
return '<' + tag + ' style="' + style[1] + '">';
}
return '<' + tag + '>';
});
event.data.dataValue = result;
});
});
window.CKEDITOR.on('dialogDefinition', function(event) {
let dialogName = event.data.name;
let dialogDefinition = event.data.definition;
if (dialogName === 'link') {
let infoTab = dialogDefinition.getContents('info');
dialogDefinition.onLoad = function() {
let dialog = CKEDITOR.dialog.getCurrent();
dialog.getContentElement('info', 'linkType').getElement().hide();
dialog.getContentElement('info', 'protocol').getElement().hide();
dialog.getContentElement('info', 'url').getElement().hide();
};
infoTab.add({
type: 'select',
id: 'linktype-selector',
label: 'Linktype',
'default': '',
items: [
[window.translations['page'], "page"],
["URL", "url"]
],
onChange: function(obj) {
let dialog = CKEDITOR.dialog.getCurrent();
if (obj.data.value === 'page') {
dialog.getContentElement('info', 'page-selector').getElement().show();
dialog.getContentElement('info', 'url-field').getElement().hide();
} else {
dialog.getContentElement('info', 'page-selector').getElement().hide();
dialog.getContentElement('info', 'url-field').getElement().show();
dialog.getContentElement('info', 'url-field').setValue('');
}
},
setup: function(data) {
if (data.type === undefined) {
this.setValue('page');
} else if (data.type === 'url' && data.url.url.startsWith('[page id=')) {
this.setValue('page');
} else {
this.setValue(data.type);
}
}
});
infoTab.add({
type: 'select',
id: 'page-selector',
label: window.translations['page'],
'default': '',
items: window.pages,
onChange: function() {
let dialog = CKEDITOR.dialog.getCurrent();
let page = '[page id=' + this.getValue() + ']';
dialog.setValueOf('info', 'url', page);
dialog.setValueOf('info', 'protocol', '');
},
setup: function(dialog) {
this.allowOnChange = false;
let pageId = '';
if (dialog.url) {
pageId = dialog.url.url.substr(9, dialog.url.url.length - 10);
}
this.setValue(pageId);
this.allowOnChange = true;
}
});
infoTab.add({
type: 'text',
id: 'url-field',
label: 'URL',
'default': '',
onChange: function() {
let dialog = CKEDITOR.dialog.getCurrent();
let url = this.getValue();
dialog.setValueOf('info', 'url', url);
},
setup: function(dialog) {
this.allowOnChange = false;
let url = '';
if (dialog.url) {
url = dialog.url.url;
}
this.setValue(url);
this.allowOnChange = true;
}
});
}
});
@@ -0,0 +1,832 @@
/**
* After loading GrapesJS, add all theme blocks and activate the editable blocks in the main language.
*/
function afterGrapesJSLoaded() {
addThemeBlocks();
// add page injection script with page-loaded event to the end of the body tag of initialComponents,
// which contains the html structure of the used layout file. And add script that starts all external scripts
let scriptTag = document.createElement("script");
scriptTag.type = "text/javascript";
scriptTag.src = window.injectionScriptUrl;
let fullScript = scriptTag.outerHTML + '<script>' + startFirstScript.toString() + startFirstScript.name + '()</script>';
window.initialComponents = window.initialComponents.replace('</body>', fullScript + '</body>');
$.each(window.languages, (languageCode, languageTranslation) => {
if (window.pageBlocks[languageCode] === null) {
window.pageBlocks[languageCode] = {};
}
});
activateLanguage(window.currentLanguage);
}
/**
* GrapesJS wraps each external script with a start[number]Start() method,
* which needs to be called on switching language.
*/
function startFirstScript() {
let scriptTags = document.querySelectorAll("script");
for (let i = 0; i < scriptTags.length; i++) {
let node = scriptTags[i];
if (node.innerHTML.startsWith('var script')) {
let beforeEquals = node.innerHTML.split('=')[0];
let scriptNumber = parseInt(beforeEquals.replace('var script', ''));
if (Number.isInteger(scriptNumber)) {
let startScriptMethodName = 'script' + scriptNumber + 'Start';
if (typeof window[startScriptMethodName] === 'function') {
if (scriptNumber !== 0) {
window[startScriptMethodName]();
}
return false;
}
}
}
}
}
/**
* Add all theme blocks to GrapesJS blocks manager.
*/
function addThemeBlocks() {
for (let blockSlug in window.themeBlocks) {
let block = window.themeBlocks[blockSlug];
// remove whitespace from phpb-block-container elements, otherwise these components will become type=text,
// resulting in components dropped inside the container jumping to the dropped position - 1
let $blockHtml = $("<container>").append(block.content);
$blockHtml.find("[phpb-blocks-container]").each(function() {
if ($(this).html() !== '' && $(this).html().trim() === '') {
$(this).html('');
}
});
window.themeBlocks[blockSlug].content = $blockHtml.html();
block.content = $blockHtml.html();
editor.BlockManager.add(blockSlug, block);
}
}
/**
* Switch pagebuilder to another language variant on changing the language selector.
*/
$("#language-selector select").on("change", function() {
let selectedLanguage = $(this).find("option:selected").val();
window.switchLanguage(selectedLanguage, function() {
activateLanguage(selectedLanguage);
});
});
/**
* Activate the given language variant in the pagebuilder.
*
* @param newLanguage
*/
window.activateLanguage = function(newLanguage) {
window.currentLanguage = newLanguage;
// reset GrapesJS editor before loading the new language variant
window.editor.select();
window.editor.DomComponents.clear();
window.editor.DomComponents.componentsById = [];
window.editor.UndoManager.clear();
// remove any script tags from previous languages
window.editor.Canvas.getDocument().querySelectorAll("script").forEach(function(node) {
node.remove();
});
// load initial non-editable layout components
window.editor.setComponents(window.initialComponents);
denyAccessToLayoutElements(editor.getWrapper());
window.editor.getWrapper().find("[phpb-content-container]").forEach((container, index) => {
container.set('custom-name', window.translations['page-content']);
// reload components of this content container (adding all root phpb-block elements)
container.components(window.contentContainerComponents[index]);
// replace phpb-block elements with the server-side rendered version of each block
replacePlaceholdersForRenderedBlocks(container);
// apply the stored block settings to the server-side rendered html
applyBlockAttributesToComponents(container);
});
};
$(window).on('pagebuilder-page-loaded', function(event) {
window.editor.getWrapper().find("[phpb-content-container]").forEach(container => {
restrictEditAccess(container);
window.runScriptsOfComponentAndChildren(container);
});
window.setWaiting(false);
setTimeout(function() {
window.changesOffset = window.editor.getModel().get('changesCount');
window.afterInitialRendering = true;
}, 250);
});
/**
* Replace phpb-block elements with the server-side rendered version of each block.
*
* @param component
*/
function replacePlaceholdersForRenderedBlocks(component) {
let newComponent = component;
// if we encounter a pagebuilder block, replace it with the server-side rendered html
if (component.get('tagName') === 'phpb-block') {
let id = component.attributes.attributes.id;
if (window.pageBlocks[window.currentLanguage][id] !== undefined && window.pageBlocks[window.currentLanguage][id]['html'] !== undefined) {
newComponent = component.replaceWith(window.pageBlocks[window.currentLanguage][id]['html']);
window.pageBlocks[window.currentLanguage][id]['html'] = '';
}
}
// replace placeholders inside child components
newComponent.get('components').each(childComponent => replacePlaceholdersForRenderedBlocks(childComponent));
}
/**
* Function for denying edit access to this component and all children that belong to the layout.
*
* @param component
*/
function denyAccessToLayoutElements(component) {
if ('phpb-content-container' in component.attributes.attributes) return;
disableAllEditFunctionality(component);
// apply restrictions to child components
component.get('components').each(component => denyAccessToLayoutElements(component));
}
/**
* Component select handler.
*/
window.editor.on('component:selected', function(component) {
// if the component has settings, activate settings panel in pagebuilder sidebar
if (componentHasBlockSettings(component)) {
$(".gjs-pn-buttons .gjs-pn-btn:nth-of-type(2)").click();
}
else if (component.get('type') === '' && componentHasBackground(component)) {
// on selecting a default component without settings, with editable background, show background styling
$(".gjs-pn-buttons .gjs-pn-btn:nth-of-type(3)").click();
if ($("#gjs-sm-position").hasClass("gjs-sm-open")) {
$("#gjs-sm-position").find(".gjs-sm-title").click();
}
if (! $("#gjs-sm-background").hasClass("gjs-sm-open")) {
$("#gjs-sm-background").find(".gjs-sm-title").click();
}
}
// if component has no settings, add no settings text to settings panel in sidebar
if (! componentHasBlockSettings(component)) {
setTimeout(function() {
$(".gjs-trt-traits").html('<p class="no-settings">' + window.translations['trait-manager']['no-settings'] + '</p>');
}, 0);
}
// only show the toolbar buttons that are applicable
setTimeout(function() {
if (! component.attributes.removable) {
$(".gjs-toolbar .fa-trash-o.gjs-toolbar-item").hide();
}
if (! component.attributes.copyable) {
$(".gjs-toolbar .fa-clone.gjs-toolbar-item").hide();
}
if (! component.attributes.draggable) {
$(".gjs-toolbar .fa-arrows.gjs-toolbar-item").hide();
}
if (! component.attributes.removable && ! component.attributes.copyable && ! component.attributes.draggable) {
window.editor.select(component.parent());
}
let blockSlug = component.attributes['block-slug'];
if (blockSlug) {
let labelHtml = window.themeBlocks[blockSlug]['label'];
let labelTextParts = labelHtml.split("</div>");
if (labelTextParts.length > 1) {
$(".gjs-toolbar").attr('title', "Bloknaam: " + labelTextParts[1]);
}
}
}, 0);
});
/**
* Component clone handler.
*/
window.editor.on('component:clone', function(component) {
// if the clone is performed by the user, do not copy the block id and style identifier
if (! isCloningFromScript) {
let originalComponent = window.editor.getWrapper().find('.' + component.attributes['style-identifier'])[0];
if (component.attributes['style-identifier'] !== undefined && component.attributes['style-identifier'] !== '') {
component.removeClass(component.attributes['style-identifier']);
delete component.attributes['style-identifier'];
addUniqueClass(component);
}
component.attributes['block-id'] = component.attributes['block-slug'];
// pass a reference of the scripts of the original component to run on the cloned component
if (originalComponent && window.customBuilderScripts[originalComponent.attributes['block-id']] !== undefined) {
component.attributes['run-builder-script'] = originalComponent.attributes['block-id'];
}
}
});
/**
* Return whether the given component contains a CSS background, that should be editable.
*
* @param component
* @returns {boolean}
*/
function componentHasBackground(component) {
let hasBackground = false;
let componentElement = component.getEl();
if (componentElement && componentElement.style) {
let componentStyle = window.getComputedStyle(componentElement);
['background', 'background-image', 'background-color'].forEach(property => {
let value = componentStyle.getPropertyValue(property);
if (value !== undefined && value !== '' && ! value.includes('none') && ! value.includes('rgba(0, 0, 0, 0)')) {
hasBackground = true;
}
});
}
return hasBackground;
}
/**
* Return whether the given component has settings defined in its block config file.
*
* @param component
* @returns {boolean}
*/
function componentHasBlockSettings(component) {
return component.attributes.traits.length > 0;
}
/**
* On dropping a component on the canvas, apply attributes of the container phpb-block element with configuration passed
* from the server and restrict edit access to editable components.
*/
window.editor.on('block:drag:stop', function(droppedComponent) {
// ensure component drop was successful
if (! droppedComponent || ! droppedComponent.attributes || ! droppedComponent.attributes.attributes) return;
let draggedBlockId = generateId();
droppedComponent.attributes.attributes['dropped-component-id'] = draggedBlockId;
let parent = droppedComponent.parent();
applyBlockAttributesToComponents(droppedComponent);
// at this point droppedComponent is replaced in the DOM by the actual component (without the phpb-block element),
// so we need to find the dropped component again in the context of its parent
parent.components().each(function(child) {
if (child.attributes['dropped-component-id'] === draggedBlockId) {
delete child.attributes['dropped-component-id'];
droppedComponent = child;
}
});
restrictEditAccess(droppedComponent);
window.runScriptsOfComponentAndChildren(droppedComponent);
});
/**
* Apply the block attributes which are stored in <phpb-block> elements to the top-level html element inside the block.
* If the block starts with multiple top-level html elements, add a div element wrapping the block's top-level elements.
*
* @param component
*/
function applyBlockAttributesToComponents(component) {
if (component.attributes.tagName === 'phpb-block') {
let container = component.parent();
let clone = cloneComponent(component);
// since component is a <phpb-block> that should be removed and replaced by its children,
// the component's parent's child that has the id of the <phpb-block> component needs to be replaced
let blockRootComponent;
if (component.attributes.attributes['is-html'] === 'false') {
container.components().each(function(componentSibling) {
if (componentSibling.cid === component.cid) {
// replace the <phpb-block> by the actual component
// the component is wrapped with a wrapper element to allow block styling (via a unique .style-identifier selector)
let wrapperElement = ('wrapper' in component.attributes.attributes) ? component.attributes.attributes['wrapper'] : 'div';
blockRootComponent = component.replaceWith({tagName: wrapperElement});
blockRootComponent.attributes['is-style-wrapper'] = true;
clone.components().each(function(componentChild) {
blockRootComponent.append(cloneComponent(componentChild));
});
}
});
} else {
container.components().each(function(componentSibling) {
if (componentSibling.cid === component.cid) {
// if the <phpb-block> has one direct child, replace it by its only child
// else, replace it by a wrapper div to allow block styling (via a unique .style-identifier selector)
if (clone.components().length === 1) {
let firstChild = cloneComponent(clone.components().models[0]);
blockRootComponent = component.replaceWith(firstChild);
} else {
blockRootComponent = component.replaceWith({tagName: 'div'});
blockRootComponent.attributes['is-style-wrapper'] = true;
clone.components().each(function(componentChild) {
blockRootComponent.append(cloneComponent(componentChild));
});
}
}
});
}
component.remove();
copyAttributes(clone, blockRootComponent, true, false);
// add all settings of this component to the settings panel in the sidebar
addSettingsToSidebar(blockRootComponent);
// recursive call to find and replace <phpb-block> elements of nested blocks (loaded via shortcodes)
applyBlockAttributesToComponents(blockRootComponent);
} else {
component.components().each(function(childComponent) {
// recursive call to find and replace <phpb-block> elements of nested blocks (loaded via shortcodes)
applyBlockAttributesToComponents(childComponent);
});
}
}
/**
* Get the current setting values for the given component.
*
* @param component
*/
function getCurrentSettingValues(component) {
// Block settings are stored in window.pageBlocks in a structure starting with each root block (the first ancestor that does not have a dynamic parent itself).
// So, we need to find the root of the given component and store all block ids along the way, in order to traverse the pageBlocks structure to the settings of the given component.
// These block ids are only unique in the context of their parent (we can have multiple instances of the same nested block structure), so we call them relative IDs.
let relativeIds = [];
// get the root component of the given component (its first ancestor that does not have a dynamic parent itself or the block that is inside a blocks container)
let rootComponent = component;
let hasDynamicAncestor = false;
while (rootComponent.parent() &&
rootComponent.parent().attributes.attributes['phpb-blocks-container'] === undefined &&
rootComponent.parent().attributes['is-html'] !== 'true' &&
rootComponent.parent().attributes.attributes['phpb-content-container'] === undefined
) {
if (rootComponent.parent().attributes['is-html'] === 'false') {
hasDynamicAncestor = true;
}
if (rootComponent.attributes['block-id'] !== undefined) {
relativeIds.push(rootComponent.attributes['block-id']);
}
rootComponent = rootComponent.parent();
}
let rootId = component.attributes['block-id'];
if (hasDynamicAncestor) {
rootId = rootComponent.attributes['block-id'];
} else {
relativeIds = [];
}
// get the component settings by traversing the pageBlocks structure
let settings = window.pageBlocks[window.currentLanguage][rootId];
relativeIds.reverse().forEach(function(relativeId) {
if (settings === undefined || settings.blocks === undefined || settings.blocks[relativeId] === undefined) {
settings = {};
} else {
settings = settings.blocks[relativeId];
}
});
// return the values stored in the current component's settings structure
let settingsValues = {};
if (settings !== undefined && settings.settings !== undefined && settings.settings.attributes !== undefined) {
settingsValues = settings.settings.attributes;
}
return settingsValues;
}
/**
* Add all settings from the block's config file to the given component,
* to allow them to be changed in the settings side panel.
*
* @param component
*/
function addSettingsToSidebar(component) {
if (window.blockSettings[component.attributes['block-slug']] === undefined) {
return;
}
component.attributes.settings = {};
let settingValues = getCurrentSettingValues(component);
// set style identifier class to the block wrapper, if an identifier has been stored during earlier getDataInStorageFormat calls
if (settingValues['style-identifier'] !== undefined) {
component.addClass(settingValues['style-identifier']);
}
// for each setting add a trait to the settings sidebar panel with the earlier stored or default value
component.attributes['is-updating'] = true;
let settings = window.blockSettings[component.attributes['block-slug']];
settings.forEach(function(setting) {
let trait = component.addTrait(setting);
if (settingValues[setting['name']] !== undefined) {
trait[0].setTargetValue(settingValues[setting['name']]);
} else if (setting['default-value'] !== undefined) {
trait[0].setTargetValue(setting['default-value']);
}
});
component.attributes['is-updating'] = false;
}
/**
* On updating an attribute (block setting from the settings side panel), refresh dynamic block via Ajax.
*/
window.editor.on('component:update', function(component) {
if (window.isLoaded !== true ||
component.attributes['block-slug'] === undefined ||
component.attributes['is-updating'] ||
component.changed['attributes'] === undefined ||
$(".gjs-frame").contents().find("#" + component.ccid).length === 0
) {
return;
}
// dynamic pagebuilder blocks can depend on data passed by dynamic parent blocks,
// so we need to update the closest parent which does not have a dynamic parent itself or the block that is inside a blocks container.
// also keep track of all intermediate block ids, for re-selecting the currently selected component.
let relativeIds = [];
let ancestorToUpdate = component;
let hasDynamicAncestor = false;
while (ancestorToUpdate.parent() &&
ancestorToUpdate.parent().attributes.attributes['phpb-blocks-container'] === undefined &&
ancestorToUpdate.parent().attributes['is-html'] !== 'true' &&
ancestorToUpdate.parent().attributes.attributes['phpb-content-container'] === undefined
) {
if (ancestorToUpdate.parent().attributes['is-html'] === 'false') {
hasDynamicAncestor = true;
}
if (ancestorToUpdate.attributes['block-id'] !== undefined) {
relativeIds.push(ancestorToUpdate.attributes['block-id']);
}
ancestorToUpdate = ancestorToUpdate.parent();
}
if (hasDynamicAncestor) {
component = ancestorToUpdate;
} else {
relativeIds = [];
}
component.attributes['is-updating'] = true;
$(".gjs-frame").contents().find("#" + component.ccid).addClass('gjs-freezed');
let container = window.editor.getWrapper().find("#" + component.ccid)[0].parent();
let data = window.getComponentDataInStorageFormat(component);
// refresh component contents with updated version requested via ajax call
$.ajax({
type: "POST",
url: window.renderBlockUrl,
data: {
data: JSON.stringify(data),
language: window.currentLanguage
},
success: function(blockHtml) {
let blockId = $(blockHtml).attr('block-id');
// set the block settings for the updated component to the new values
window.pageBlocks[window.currentLanguage][blockId] = (data.blocks[blockId] === undefined) ? {} : data.blocks[blockId];
// replace old component for the rendered html returned by the server
component.replaceWith(blockHtml);
replacePlaceholdersForRenderedBlocks(container);
applyBlockAttributesToComponents(container);
restrictEditAccess(container, false, false);
// run builder scripts of the replaced component and all its children
let replacedComponent = findChildViaBlockIdsPath(container, [blockId]);
runScriptsOfComponentAndChildren(replacedComponent);
// select the component that was selected before the ajax call
relativeIds.push(blockId);
let componentToSelect = findChildViaBlockIdsPath(container, relativeIds.reverse());
window.editor.select(componentToSelect);
},
error: function() {
$(".gjs-frame").contents().find("#" + component.ccid).removeClass('gjs-freezed');
component.attributes['is-updating'] = false;
window.toastr.error(window.translations['toastr-component-update-failed']);
}
});
});
/**
* Traverse the children of the given component via the given path of block IDs
* and return the component with the last ID from the list.
*
* @param component
* @param blockIds
* @returns {null|*}
*/
function findChildViaBlockIdsPath(component, blockIds) {
// foobar
if (blockIds.length === 0) {
return component;
}
let result = null;
component.forEachChild(function(child) {
if (child.attributes['block-id'] === blockIds[0]) {
result = findChildViaBlockIdsPath(child, blockIds.slice(1));
return false;
}
});
component.forEachChild(function(child) {
let childResult = findChildViaBlockIdsPath(child, blockIds);
if (childResult !== null) {
result = childResult;
return false;
}
});
return result;
}
/**
* Clone the given component (while preserving all attributes, like IDs).
*
* @param component
*/
let isCloningFromScript = false;
window.cloneComponent = function(component) {
isCloningFromScript = true;
let clone = component.clone();
deepCopyAttributes(component, clone);
isCloningFromScript = false;
return clone;
};
/**
* Apply the attributes of the given component and its children to each corresponding component of the given clone.
*
* @param component
* @param clone
*/
function deepCopyAttributes(component, clone) {
// apply all attributes from component to clone
copyAttributes(component, clone, false, true);
// apply attributes from component's children to clone's children
for (let index = 0; index < component.components().length; index++) {
let componentChild = component.components().models[index];
let cloneChild = clone.components().models[index];
deepCopyAttributes(componentChild, cloneChild);
}
}
/**
* Apply the attributes of the given component to the given target component.
*
* @param component
* @param targetComponent
* @param copyGrapesAttributes whether all GrapesJS component attributes (like permissions) should be copied
* @param copyHtmlElementAttributes whether the html element attributes should be copied
*/
function copyAttributes(component, targetComponent, copyGrapesAttributes, copyHtmlElementAttributes) {
let componentAttributes = component.attributes.attributes;
for (let attribute in componentAttributes) {
if (copyHtmlElementAttributes) {
targetComponent.attributes.attributes[attribute] = componentAttributes[attribute];
}
if (copyGrapesAttributes) {
targetComponent.attributes[attribute] = componentAttributes[attribute];
}
}
}
/**
* Function for only allowing edit access on whitelisted components.
*
* @param component
* @param directlyInsideDynamicBlock
* @param allowEditableComponents
*/
function restrictEditAccess(component, directlyInsideDynamicBlock = false, allowEditableComponents = true) {
disableAllEditFunctionality(component);
if (component.attributes.attributes['phpb-content-container'] !== undefined) {
// the content container of the current page can receive other components
component.set({
droppable: true,
hoverable: true,
});
} else if (component.attributes['block-slug'] !== undefined) {
// change visibility of child elements that depend on whether this block is editable
component.find('[phpb-hide-if-not-editable]').forEach((element) => {
if (allowEditableComponents || window.afterInitialRendering) {
element.addClass('editable');
} else {
element.removeClass('editable');
}
});
// we just entered a new block, set default permissions
let permissions = {
selectable: true,
hoverable: true,
};
if (! directlyInsideDynamicBlock) {
// the block we entered is not located directly inside a dynamic block, hence this block can be removed, dragged, configured and styled
permissions = {
removable: true,
draggable: true,
copyable: true,
selectable: true,
hoverable: true,
stylable: true,
};
// for styling this particular block, the block needs to have a unique class
addUniqueClass(component);
}
if (component.attributes['is-html'] === 'true') {
// the block we just entered is an html block,
// the next layer of child blocks are not directly inside a dynamic block
directlyInsideDynamicBlock = false;
// in an html block, editing elements (based on their html tag) is allowed
allowEditableComponents = true;
} else {
// the block we just entered is dynamic,
// the next layer of child blocks are directly inside a dynamic block
directlyInsideDynamicBlock = true;
// in a dynamic block, editing elements (based on their html tag) is not allowed
allowEditableComponents = false;
// dynamic blocks do not have text-editable components, so remove text cursors
component.getEl().setAttribute('data-cursor', 'default');
}
component.set(permissions);
}
// for raw content components, set editable to true and ignore processing editability for any child component
if (component.attributes.attributes['data-raw-content'] !== undefined) {
component.set({editable: true});
return;
}
// set editable access based on tags, styling or html class attribute
if (allowEditableComponents) {
allowEditBasedOnComponentAttributes(component);
// if the component is made text-editable, re-add the raw html contents
// to ensure the text editor does not deal with elements with attributes added by GrapesJS
if (component.attributes['made-text-editable'] === 'true') {
component.attributes.attributes['data-raw-content'] = 'true';
// refresh the current component in order to switch its component type to raw-content.
// this disables GrapesJS parsing of any child elements, avoiding that any GrapesJS specific html attributes are added
let newComponent = component.replaceWith(component.toHTML());
// copy important attributes from the original component to the refreshed component
['block-id', 'block-slug', 'is-html', 'style-identifier'].forEach(attribute => {
newComponent.attributes[attribute] = component.attributes[attribute];
});
// apply block/component edit restrictions to the new raw-content type version of the component
restrictEditAccess(newComponent);
return;
}
}
// apply edit restrictions to child components
component.get('components').each(component => restrictEditAccess(component, directlyInsideDynamicBlock, allowEditableComponents));
}
/**
* Set the given component's editability based on which tag the component represents,
* which attributes are set or which styling is applied.
*
* @param component
* @returns {boolean}
*/
function allowEditBasedOnComponentAttributes(component) {
let htmlTag = component.get('tagName');
let textEditableTags = [
//'div','span', // needed for editable bootstrap alert, but cannot be used since divs (block containers) then cannot be removed
'h1','h2','h3','h4','h5','h6','h7',
'p','small','b','strong','i','em','label','button',
'ol', 'ul','li','table'
];
let otherEditableTags = [
'img'
];
let settings = {};
if ('phpb-blocks-container' in component.attributes.attributes) {
settings.hoverable = true;
settings.selectable = true;
settings.droppable = true;
}
if (textEditableTags.includes(htmlTag) || 'phpb-editable' in component.attributes.attributes) {
settings.editable = true;
component.attributes['made-text-editable'] = 'true';
} else if (otherEditableTags.includes(htmlTag)) {
settings.editable = true;
}
if (componentHasBackground(component)) {
settings.hoverable = true;
settings.selectable = true;
settings.stylable = true;
}
if (htmlTag === 'a') {
settings.hoverable = true;
settings.selectable = true;
settings.stylable = true;
settings.removable = true;
}
if (! $.isEmptyObject(settings)) {
component.set(settings);
if (settings.stylable !== undefined && settings.stylable) {
addUniqueClass(component);
}
}
}
/**
* Add a unique class to this component to ensure style only applies to this component instance.
*
* @param component
*/
function addUniqueClass(component) {
// get component identifier class if one is already added to the component's html when saving the pagebuilder previously
let componentIdentifier = false;
component.getClasses().forEach(componentClass => {
if (componentClass.startsWith('ID') && componentClass.length === 16) {
componentIdentifier = componentClass;
}
});
if (component.attributes['style-identifier'] === undefined) {
component.attributes['style-identifier'] = componentIdentifier ? componentIdentifier : generateId();
}
component.addClass(component.attributes['style-identifier']);
}
/**
* Disable all edit functionality on the given component.
*
* @param component
*/
function disableAllEditFunctionality(component) {
component.set({
removable: false,
draggable: false,
droppable: false,
badgable: false,
stylable: false,
highlightable: false,
copyable: false,
resizable: false,
editable: false,
layerable: false,
selectable: false,
hoverable: false
});
}
/**
* Generate a unique id string.
*
* Based on: https://gist.github.com/gordonbrander/2230317
*/
let counter = 0;
function generateId() {
return 'ID' + (Date.now().toString(36)
+ Math.random().toString(36).substr(2, 5) + counter++).toUpperCase();
}
/**
* Wait for GrapesJS to be fully loaded before trying to load the components in the page builder.
*/
function waitForGrapesToLoad() {
if (window.grapesJSLoaded) {
afterGrapesJSLoaded();
} else {
setTimeout(waitForGrapesToLoad, 100);
}
}
waitForGrapesToLoad();
@@ -0,0 +1,14 @@
/* disable ctrl + s, since this is handled in iframe parent */
window.addEventListener('keydown', function(e) {
if (e.ctrlKey && e.key === 's') {
e.preventDefault();
return false;
}
});
/* post message to iframe parent that page has been loaded */
window.parent.postMessage("page-loaded", '*');
document.addEventListener('touchstart', e => {
window.parent.postMessage("touch-start", '*');
});
@@ -0,0 +1,87 @@
$(".gjs-editor").append($("#toggle-sidebar"));
$(".gjs-pn-panels").prepend($("#sidebar-header"));
$(".gjs-pn-panels").append($("#sidebar-bottom-buttons"));
$("#toggle-sidebar").click(function() {
$("#gjs").toggleClass('sidebar-collapsed');
triggerEditorResize();
});
autoCollapseSidebar();
window.editor.on('run:open-sm', function(editor) {
$(".gjs-trt-traits").parent().parent().css('display', 'none');
$(".gjs-sm-sectors").parent().parent().css('display', 'block');
// move element classes editor to advanced section
$("#gjs-sm-advanced .gjs-sm-properties").append($(".gjs-clm-tags"));
});
window.editor.on('run:open-tm', function(editor) {
$(".gjs-sm-sectors").parent().parent().css('display', 'none');
$(".gjs-trt-traits").parent().parent().css('display', 'block');
});
window.editor.on('block:drag:start', function(block) {
autoCollapseSidebar();
});
window.editor.on('rteToolbarPosUpdate', function(toolbarPosition) {
if (! window.editor || ! window.editor.getSelected()) return;
let selectedDomComponent = window.editor.getSelected().getEl();
if (! selectedDomComponent) return;
setTimeout(function() {
let $toolbar = $(".gjs-rte-toolbar").first();
let toolbarInUpperHalf = $toolbar.offset().top < (toolbarPosition.elementTop + (0.5 * toolbarPosition.elementHeight));
if (toolbarInUpperHalf) {
let newTop = toolbarPosition.elementTop - $toolbar.height();
if (newTop > 0) {
$toolbar.css('top', newTop + 'px');
} else {
//$toolbar.css('top', (toolbarPosition.elementTop + toolbarPosition.elementHeight) + 'px');
}
}
}, 0);
});
function autoCollapseSidebar() {
if ($(window).width() < 1000) {
$("#gjs").addClass('sidebar-collapsed');
triggerEditorResize();
}
}
function triggerEditorResize() {
window.editor.trigger('change:canvasOffset canvasScroll');
}
// prevent exiting page builder with backspace button
let backspaceIsPressed = false;
$(document).keydown(function(event) {
if (event.which === 8) backspaceIsPressed = true;
}).keyup(function(event) {
if (event.which === 8) backspaceIsPressed = false;
});
$(window).on('beforeunload', function(event) {
if (backspaceIsPressed) event.preventDefault();
});
function addBlockSearch() {
$(".gjs-blocks-cs").prepend($("#block-search"));
}
// listen to messages from iframe
window.addEventListener("message", onMessage, false);
function onMessage(event) {
// if the page is loaded, remove loading element
if (event.data === 'page-loaded') {
$("#phpb-loading").addClass('loaded');
addBlockSearch();
window.isLoaded = true;
$(window).trigger('pagebuilder-page-loaded');
} else if(event.data === 'touch-start') {
window.touchStart();
}
}
@@ -0,0 +1,6 @@
window.touchStart = function() {
$("#gjs").addClass('sidebar-collapsed');
}
@@ -0,0 +1,107 @@
window.customBuilderScripts = {};
/**
* On instantiating the component model, before it is mounted in the canvas.
*/
window.editor.on('component:create', component => {
// extract the script tag of the given component (if it has one)
if (component.components().length) {
let lastChild = component.components().models[component.components().length - 1];
if (lastChild.attributes.type === 'script') {
let blockId = component.attributes.attributes['block-id'];
if (blockId === undefined) {
blockId = component.attributes.attributes['id'];
}
let rootComponent = lastChild;
let insideEditablePartOfPage = false;
while (rootComponent.parent()) {
rootComponent = rootComponent.parent();
if (rootComponent.attributes.attributes['phpb-content-container']) {
insideEditablePartOfPage = true;
break;
}
}
if (insideEditablePartOfPage) {
window.customBuilderScripts[blockId] = lastChild.toHTML();
lastChild.remove();
}
}
}
});
/**
* After mounting the component in the canvas.
*/
window.editor.on('component:add', function (component) {
// run the script that was set when creating this component
if (component.attributes['run-builder-script'] !== undefined) {
let originalCustomBuilderScripts = customBuilderScripts;
window.customBuilderScripts[component.attributes['block-id']] = customBuilderScripts[component.attributes['run-builder-script']];
runScriptsOfComponentAndChildren(component);
window.customBuilderScripts = originalCustomBuilderScripts;
delete component.attributes['run-builder-script'];
}
});
/**
* On ending a component order drag, re-run builder scripts on newly added HTMl.
*/
window.editor.on('sorter:drag:end', function(event) {
let component = event.modelToDrop;
if (component && component.attributes && (component.attributes['block-id'] || component.attributes['id'])) {
window.runScriptsOfComponentAndChildren(component);
}
// remove all existing CKEditors after dragging a block with active editor
for (let instanceName in CKEDITOR.instances) {
CKEDITOR.instances[instanceName].destroy(true);
}
});
/**
* Run the custom builder scripts of the given component and of all child components.
*
* @param component
*/
window.runScriptsOfComponentAndChildren = function(component) {
runComponentScript(component);
component.components().each(function(child) {
runScriptsOfComponentAndChildren(child);
});
}
/**
* Run the custom builder scripts of the given component.
*
* @param component
*/
function runComponentScript(component) {
let blockId = component.attributes['block-id'];
if (blockId === undefined) {
blockId = component.attributes.attributes['id'];
}
if (blockId && window.customBuilderScripts[blockId] !== undefined) {
let styleIdentifier = component.attributes["style-identifier"];
let $scriptTag = $("<container>").append(window.customBuilderScripts[blockId]);
// prepend block and blockSelector variables allowing the script to refer to this exact block instance
$scriptTag.find('script').prepend('let inPageBuilder = true;');
$scriptTag.find('script').prepend('let blockSelector = ".' + styleIdentifier + '";');
$scriptTag.find('script').prepend('let block = document.getElementsByClassName("' + styleIdentifier + '")[0];');
// wrap the script contents in a self-invoking function (to add a scope avoiding variable name collisions)
$scriptTag.find('script').prepend('(function(){');
$scriptTag.find('script').append('})();');
// execute the script in the page that is being edited
let scriptTag = document.createElement("script");
scriptTag.type = "text/javascript";
scriptTag.innerHTML = $scriptTag.find('script').html();
window.editor.Canvas.getDocument().body.appendChild(scriptTag);
}
}
@@ -0,0 +1,504 @@
window.pageData = {};
window.changesOffset = 0;
window.onbeforeunload = confirmExit;
function confirmExit() {
let changesCount = window.editor.getModel().get('changesCount') - window.changesOffset;
if (changesCount > 0) {
return "Are you sure? There are unsaved changes.";
}
}
/**
* Save page on clicking save button.
*/
$("#save-page").click(function() {
saveAllTranslationsToServer();
});
/**
* Save page on Ctrl + S.
*/
$(document).bind("keydown", function(e){
if(e.ctrlKey && e.which === 83) {
// text-editor updates are not applied until focus is lost, so force GrapesJS update
window.editor.store();
saveAllTranslationsToServer();
e.preventDefault();
return false;
}
});
/**
* Switch the pagebuilder to the given language.
* This stores the all data of the current language locally for later use and renders the given language variant on the server.
*
* @param newLanguage
* @param callback
*/
window.switchLanguage = function(newLanguage, callback) {
window.setWaiting(true);
saveCurrentTranslationLocally(function() {
applyChangesFromCurrentLanguageToNewLanguage(newLanguage);
let data = window.pageData;
data.blocks = {[newLanguage]: window.pageBlocks[newLanguage]};
// render the language variant server-side
$.ajax({
type: "POST",
url: window.renderLanguageVariantUrl,
data: {
data: JSON.stringify(data),
language: newLanguage
},
success: function(response) {
response = JSON.parse(response);
window.pageBlocks[newLanguage] = response.dynamicBlocks ? response.dynamicBlocks : {};
callback();
},
error: function(error) {
callback();
console.log(error);
let errorMessage = error.statusText + ' ' + error.status;
errorMessage = error.responseJSON.message ? (errorMessage + ': "' + error.responseJSON.message + '"') : errorMessage;
window.toastr.error(errorMessage);
window.toastr.error(window.translations['toastr-switching-language-failed']);
}
});
});
};
/**
* Copy new blocks of the current language to the new language or remove old blocks from the new language.
*
* @param newLanguage
*/
function applyChangesFromCurrentLanguageToNewLanguage(newLanguage) {
let newLanguageBlocks = window.pageBlocks[newLanguage];
let currentLanguageBlocks = window.pageBlocks[window.currentLanguage];
if (newLanguageBlocks === undefined) {
newLanguageBlocks = currentLanguageBlocks;
} else {
updateNestedBlocks(currentLanguageBlocks, newLanguageBlocks);
// copy missing blocks from the current language to the target language
for (let blockId in currentLanguageBlocks) {
if (newLanguageBlocks[blockId] === undefined) {
newLanguageBlocks[blockId] = currentLanguageBlocks[blockId];
}
}
}
// copy the content of blocks containers of the current language to the blocks containers of the new language
for (let blockId in currentLanguageBlocks) {
let $currentLanguageBlockHtmlDom = $("<container>" + currentLanguageBlocks[blockId]['html'] + "</container>");
let $newLanguageBlockHtmlDom = $("<container>" + newLanguageBlocks[blockId]['html'] + "</container>");
$currentLanguageBlockHtmlDom.find("[phpb-blocks-container]").each(function(index) {
let currentLanguageBlockContainerHtml = $(this).html();
$newLanguageBlockHtmlDom.find("[phpb-blocks-container]").eq(index).html(currentLanguageBlockContainerHtml);
});
newLanguageBlocks[blockId]['html'] = $newLanguageBlockHtmlDom.html();
}
window.pageBlocks[newLanguage] = newLanguageBlocks;
}
/**
* Replace phpb-blocks-container html snippets if a block of the current language already exists in the target language.
* This ensures all child blocks are present for all languages and they remain in the same order
*/
function updateNestedBlocks(currentLanguageBlocks, newLanguageBlocks) {
for (let blockId in currentLanguageBlocks) {
// skip if the parent block does not yet exist in the target language
if (newLanguageBlocks[blockId] === undefined) {
continue;
}
for (let subBlockId in currentLanguageBlocks[blockId].blocks) {
let updatedSubBlock = currentLanguageBlocks[blockId].blocks[subBlockId];
let oldSubBlock = newLanguageBlocks[blockId].blocks[subBlockId];
if (! updatedSubBlock || ! oldSubBlock) {
continue;
}
let updatedSubBlockMatches = updatedSubBlock.html.match(/phpb-blocks-container(.*)>(.*)</g);
let oldSubBlockMatches = oldSubBlock.html.match(/phpb-blocks-container(.*)>(.*)</g);
if (! updatedSubBlockMatches || ! oldSubBlockMatches) {
continue;
}
for (let i = 0; i < updatedSubBlockMatches.length; i++) {
newLanguageBlocks[blockId].blocks[subBlockId].html =
newLanguageBlocks[blockId].blocks[subBlockId].html.replace(oldSubBlockMatches[i], updatedSubBlockMatches[i]);
}
}
}
}
/**
* Store the all data of the current language locally for later use.
*
* @param callback
*/
function saveCurrentTranslationLocally(callback) {
// use timeout to ensure the waiting spinner is fully displayed before the page briefly freezes due to high JS workload
setTimeout(function() {
window.pageData = {
html: [],
components: [],
css: null,
style: null
};
window.pageBlocks[window.currentLanguage] = [];
// get the data of each page content container (so skip all layout blocks) and prepare data for being stored
window.editor.getWrapper().find("[phpb-content-container]").forEach((container, index) => {
let data = getContainerContentInStorageFormat(container);
window.pageData['css'] = data.css;
window.pageData['style'] = data.style;
window.pageData['html'][index] = data.html;
window.pageData['components'][index] = data.components;
window.pageBlocks[window.currentLanguage] = {...window.pageBlocks[window.currentLanguage], ...data.blocks};
window.contentContainerComponents[index] = data.components;
});
if (callback) {
callback();
}
}, 200);
}
/**
* Save the data of all translation variants on the server.
*/
function saveAllTranslationsToServer() {
toggleSaving();
saveCurrentTranslationLocally(function() {
// update all language variants with the latest data of the current language we just saved locally
$.each(window.languages, (languageCode, languageTranslation) => {
if (languageCode !== window.currentLanguage) {
applyChangesFromCurrentLanguageToNewLanguage(languageCode);
}
});
let data = window.pageData;
data.style = removeOldStyleSelectors(data.css, data.style);
data.blocks = window.pageBlocks;
$.ajax({
type: "POST",
url: $("#save-page").data('url'),
data: {
data: JSON.stringify(data)
},
success: function() {
toggleSaving();
window.toastr.success(window.translations['toastr-changes-saved']);
setTimeout(function() {
window.changesOffset = window.editor.getModel().get('changesCount');
}, 250);
},
error: function(error) {
toggleSaving();
console.log(error);
let errorMessage = error.statusText + ' ' + error.status;
errorMessage = error.responseJSON.message ? (errorMessage + ': "' + error.responseJSON.message + '"') : errorMessage;
window.toastr.error(errorMessage);
window.toastr.error(window.translations['toastr-saving-failed']);
}
});
});
}
/**
* Remove the style selectors that are not present in the given CSS string.
*/
function removeOldStyleSelectors(css, styleComponents) {
let updatedStyleComponents = [];
styleComponents.forEach(styleComponent => {
if (styleComponent.attributes.selectors.models.length) {
let selector = styleComponent.attributes.selectors.models[0].id;
if (css.includes(selector)) {
updatedStyleComponents.push(styleComponent);
}
}
});
return updatedStyleComponents;
}
/**
* Get the given component in storage format (in context of its container with all siblings removed).
*
* @param component
*/
window.getComponentDataInStorageFormat = function(component) {
// clone component's parent, enabling us to temporarily remove all component's siblings without updating the pagebuilder
let container = window.cloneComponent(component.parent());
console.log({
container: container,
componentParent: component.parent(),
})
// remove all component's siblings since we only want to return the given component in storage format
// container.get('components').reset();
// container.append(component);
const componentId = component.attributes['block-id']
console.log(component.attributes['block-id'])
container.components().forEach(c => {
console.log({c})
// console.log(c?.attributes['block-id'])
// console.log(c?.attributes['block-id'] !== componentId)
if(c?.attributes['block-id'] !== componentId) {
c?.remove()
}
})
console.log({
containerL: container.get('components').length,
componentParentL: component.parent().get('components').length,
})
return getContainerContentInStorageFormat(container);
};
/**
* Get the given container in storage format.
*
* @param container
*/
function getContainerContentInStorageFormat(container) {
// remove all existing references while cloning GrapesJS components,
// this prevents GrapesJS from changing our IDs due to ID collisions
let componentReferences = window.editor.DomComponents.componentsById;
window.editor.DomComponents.componentsById = [];
// we need to clone the container, since we will be replacing components with placeholders and we don't want to update the page builder
container = window.cloneComponent(container);
// replace each pagebuilder block for a shortcode and phpb-block element and return an array of all page blocks data
let blocksData = replaceDynamicBlocksWithPlaceholders(container).blocks;
let html = window.html_beautify(getContainerHtml(container));
let css = window.editor.getCss();
let style = window.editor.getStyle();
let components = JSON.parse(JSON.stringify(container.get('components')));
// switch back to original GrapesJS component references
window.editor.DomComponents.componentsById = componentReferences;
return {
html: html,
css: css,
components: components,
blocks: blocksData,
style: style,
}
}
/**
* Return the html representation of the contents of the given container.
*
* @param container
*/
function getContainerHtml(container) {
let html = '';
container.get('components').forEach(component => html += component.toHTML());
let htmlDom = $("<container>" + html + "</container>");
// replace phpb-block elements with shortcode
htmlDom.find('phpb-block').each(function() {
$(this).replaceWith('[block slug="' + $(this).attr('slug') + '" id="' + $(this).attr('id') + '"]');
});
return htmlDom.html();
}
/**
* Return the html representation of the given component.
*
* @param component
*/
function getComponentHtml(component) {
let htmlDom = $("<container>" + component.toHTML() + "</container>");
// replace phpb-block elements with shortcode
htmlDom.find('phpb-block').each(function() {
$(this).replaceWith('[block slug="' + $(this).attr('slug') + '" id="' + $(this).attr('id') + '"]');
});
return htmlDom.html();
}
/**
* Replace all blocks with is-html === false with a <phpb-block> component that contains all block attributes.
*
* @param component
* @param parentIsDynamic
* @param parentIsHtmlInsideDynamic
*/
function replaceDynamicBlocksWithPlaceholders(component, parentIsDynamic = false, parentIsHtmlInsideDynamic = false) {
// data structure to be filled with the data of nested blocks via recursive calls
let data = {
current_block: {settings: {}, blocks: {}, html: "", is_html: false},
blocks: {}
};
// update variables for passing context to the recursive calls on child components
let newParentIsDynamic = parentIsDynamic;
let newParentIsHtmlInsideDynamic = parentIsHtmlInsideDynamic;
if (component.attributes['block-id'] !== undefined) {
if (component.attributes['is-html'] === 'false') {
newParentIsDynamic = true;
newParentIsHtmlInsideDynamic = false;
} else if (parentIsDynamic) {
newParentIsDynamic = false;
newParentIsHtmlInsideDynamic = true;
}
}
// depth-first recursive call for replacing nested blocks (the deepest blocks are handled first)
component.get('components').forEach(function(childComponent) {
let childData = replaceDynamicBlocksWithPlaceholders(childComponent, newParentIsDynamic, newParentIsHtmlInsideDynamic);
// update data object with child data
for (let key in childData.current_block.blocks) { data.current_block.blocks[key] = childData.current_block.blocks[key]; }
for (let key in childData.blocks) { data.blocks[key] = childData.blocks[key]; }
});
// if the method is called with a cloned container (which does not have a parent), this top-level component does not need any changes
if (! component.parent()) {
return data;
}
// if the component is not a block, no replacements need to be done
if (component.attributes['block-id'] === undefined) {
return data;
}
// do the actual replacement of this component with a placeholder component
if (component.attributes['is-html'] === 'true') {
if (parentIsDynamic) {
// the full html content of html blocks directly inside a dynamic block should be stored in parent context using its block-id,
// this is important because a dynamic block defines block ids and this can collide with block ids hardcoded in other dynamic blocks
data.current_block['blocks'][component.attributes['block-id']] = {settings: {}, blocks: {}, html: window.html_beautify(getComponentHtml(component)), is_html: true};
} else {
// html blocks outside direct context of dynamic blocks should be stored as a block itself
// store the block's style-identifier
// this will be used as class in a wrapper around the dynamic block to give the block its styling
if (component.attributes['style-identifier'] !== undefined) {
data.current_block['settings']['attributes'] = {'style-identifier': component.attributes['style-identifier']};
}
// replace this html component by a shortcode with a unique id
let instanceId = component.attributes['block-id'];
if (! component.attributes['block-id'].startsWith('ID')) {
instanceId = generateId();
}
component.replaceWith({
tagName: 'phpb-block',
attributes: {
slug: component.attributes['block-slug'],
id: instanceId
}
});
// store the block data globally in the blocks array
data.blocks[instanceId] = {settings: data.current_block['settings'], blocks: {}, html: window.html_beautify(getComponentHtml(component)), is_html: true};
data.current_block = {settings: {}, blocks: {}, html: "", is_html: false};
}
} else {
// store the attributes set to this block using traits in the settings side panel
let attributes = {};
component.get('traits').each(function(trait) {
attributes[trait.get('name')] = trait.getTargetValue();
});
data.current_block['settings']['attributes'] = attributes;
// store the block's style-identifier
// this will be used as class in a wrapper around the dynamic block to give the block its styling
if (component.attributes['style-identifier'] !== undefined) {
data.current_block['settings']['attributes']['style-identifier'] = component.attributes['style-identifier'];
}
// replace this dynamic component by a shortcode with a unique id
let instanceId = component.attributes['block-id'];
if (! component.attributes['block-id'].startsWith('ID')) {
instanceId = generateId();
}
component.replaceWith({
tagName: 'phpb-block',
attributes: {
slug: component.attributes['block-slug'],
id: instanceId
}
});
// store data.current_block data inside data.blocks with the unique id we just generated
if (parentIsDynamic) {
// inside a dynamic block, the block data is passed to the context of its parent block (so current_block is used)
let currentBlockForParent = {settings: {}, blocks: {}, html: "", is_html: false};
currentBlockForParent['blocks'][component.attributes['block-id']] = data.current_block;
data.current_block = currentBlockForParent;
} else {
// outside dynamic blocks, the block data is globally stored in the blocks array
data.blocks[instanceId] = data.current_block;
data.current_block = {settings: {}, blocks: {}, html: "", is_html: false};
}
}
return data;
}
/**
* Generate a unique id string.
*
* Based on: https://gist.github.com/gordonbrander/2230317
*/
let counter = 0;
function generateId() {
return 'ID' + (Date.now().toString(36)
+ Math.random().toString(36).substr(2, 5) + counter++).toUpperCase();
}
/**
* Set the page builder waiting status.
*/
window.setWaiting = function(value) {
let wrapper = window.editor.DomComponents.getWrapper();
if (value) {
wrapper.addClass("gjs-waiting");
} else {
wrapper.removeClass("gjs-waiting");
}
};
/**
* Toggle the save button waiting status.
*/
function toggleSaving() {
let button = $("#save-page");
button.blur();
if (button.hasClass('waiting')) {
button.attr("disabled", false);
button.removeClass('waiting');
button.find('.spinner-border').addClass('d-none');
} else {
button.attr("disabled", true);
button.addClass('waiting');
button.find('.spinner-border').removeClass('d-none');
}
}
@@ -0,0 +1,2 @@
@import 'pagebuilder';
@import 'mobile-mode';
@@ -0,0 +1,58 @@
.gjs-am-assets-header {
display: none;
}
.gjs-am-assets-cont {
background: none;
padding-top: 0;
}
.gjs-am-assets {
height: 325px;
}
.gjs-am-asset {
-webkit-touch-callout: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.gjs-btn-prim {
display: inline-block;
margin-top: 10px;
padding: .375rem .75rem;
font-weight: 400;
text-align: center;
vertical-align: middle;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
font-size: 1rem;
line-height: 1.5;
border-radius: .25rem;
transition: color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out;
color: #fff;
border: 1px solid #0091d1;
background-color: #0091d1;
}
.gjs-am-add-asset {
button {
float: left;
width: auto;
}
.gjs-am-add-field {
width: 100%;
}
}
.gjs-am-file-uploader {
& > form {
background-color: rgba(195, 226, 236, 0.14);
border: 2px dashed rgb(189, 194, 200);
}
#gjs-am-title {
color: #7e8793;
text-shadow: none;
}
}
@@ -0,0 +1,16 @@
.cke_dialog_body {
.cke_dialog_ui_vbox_child {
padding: 0;
}
input.cke_dialog_ui_input_text,
input.cke_dialog_ui_input_password,
input.cke_dialog_ui_input_tel,
textarea.cke_dialog_ui_input_textarea,
div.cke_dialog_ui_input_select {
margin-bottom: 10px;
}
.cke_dialog_ui_input_select {
width: 100% !important;
}
}
@@ -0,0 +1,42 @@
.gjs-field {
background-color: #22272e;
}
.gjs-field select {
option {
background-color: #fff;
color: #000;
}
}
.gjs-input-unit {
color: #e1e1e1;
}
.gjs-field-arrows {
color: #e1e1e1;
}
.gjs-sm-field select.gjs-input-unit {
color: #e1e1e1;
option {
background-color: #22272e;
color: #fff;
}
}
.gjs-field-arrow-d {
border-top: 4px solid #e1e1e1;
}
.gjs-field-arrow-u {
border-bottom: 4px solid #e1e1e1;
}
.gjs-field-radio {
padding: 0 !important;
}
.gjs-radio-item .gjs-radio-item-label {
padding-top: 10px;
margin-bottom: 0;
padding-bottom: 10px;
width: 100%;
}
.gjs-radio-item input:checked + .gjs-radio-item-label {
background-color: #545d6c;
}
@@ -0,0 +1,21 @@
.sidebar-collapsed {
.gjs-cv-canvas {
width: calc(100% - 0px);
}
.gjs-pn-panels {
display: none;
}
.gjs-cv-canvas, .gjs-pn-devices-c {
left: 0;
}
#toggle-sidebar {
padding: 14px 18px;
font-size: 18px;
-webkit-box-shadow: 3px 7px 11px -4px rgba(0,0,0,0.03);
-moz-box-shadow: 3px 7px 11px -4px rgba(0,0,0,0.03);
box-shadow: 2px 3px 10px 2px rgba(0,0,0,0.3);
border-bottom-right-radius: 4px;
}
}
@@ -0,0 +1,70 @@
html, body {
overflow-x: initial !important;
}
form {
margin-block-end: 0;
}
[data-cursor="default"] {
cursor: default;
}
[data-cursor="text"] {
cursor: text;
}
span[draggable="true"] {
display: inline-flex;
}
[phpb-hide-if-not-editable] {
background: #fde3c17d;
border: 1px dashed #b98e577d;
padding: 7px;
font-size: 1.1rem;
font-style: italic;
font-weight: normal;
text-align: center;
color: #5e5e5e;
&:not(.editable) {
display: none;
}
}
[data-gjs-type].gjs-comp-selected {
outline: 1px solid #0091d1 !important;
outline-offset: 0 !important;
}
div[data-gjs-type].gjs-comp-selected {
outline: 1px solid #0091d1 !important;
outline-offset: -1px !important;
}
[phpb-content-container],
[phpb-blocks-container] {
min-height: 50px;
width: 100%;
}
[phpb-blocks-container] {
border: 1px dashed #0091d1;
}
html,
body {
::-webkit-scrollbar {
width: 11px;
height: 11px;
}
::-webkit-scrollbar-track {
background: #f5f5f5;
}
::-webkit-scrollbar-thumb {
background-color: #ccc;
&:hover {
background-color: #bbb;
}
}
}
.gjs-waiting {
opacity: 0.5;
pointer-events: none;
}
@@ -0,0 +1,573 @@
$sidebar-width: 325px;
$sidebar-bottom-buttons-height: 40px;
/* GENERAL */
html, body, #gjs {
height: 100% !important;
margin: 0;
overflow: hidden;
}
* {
-webkit-box-shadow: none !important;
-moz-box-shadow: none !important;
box-shadow: none !important;
}
.form-control, .form-control:focus {
color: #e1e1e1;
}
.cursor-pointer {
cursor: pointer;
}
.gjs-editor {
font-size: 0.9rem;
}
.toast {
opacity: 1 !important;
border: none;
right: 15px;
box-shadow: none;
&.toast-success {
background: #2dc837;
}
}
#phpb-loading {
position: absolute;
height: 100%;
width: 100%;
background-color: #fff;
z-index: 10000;
transition: opacity 0.3s, visibility 0.3s;
&.loaded {
visibility: hidden;
opacity: 0;
}
.circle {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
width: 150px;
height: 150px;
.text {
font-size: 20px;
margin: 0 -30px;
margin-top: 20px;
text-align: center;
color: #0091d1;
}
}
.loader {
width: calc(100% - 0px);
height: calc(100% - 0px);
border: 8px solid #0091d1;
border-top: 8px solid #004a6c;
border-radius: 50%;
animation: rotate 5s linear infinite;
}
@keyframes rotate {
100% {transform: rotate(360deg);}
}
}
.btn.focus, .btn:focus {
box-shadow: none;
}
.gjs-cv-canvas {
height: 100%;
top: 0;
width: calc(100% - #{$sidebar-width});
}
.gjs-toolbar {
z-index: 100 !important;
}
.gjs-pn-panel {
padding: 0;
.gjs-pn-buttons {
justify-content: center;
}
}
.gjs-pn-commands,
.gjs-pn-options,
.gjs-pn-devices-c {
display: none;
}
.gjs-devices-c {
padding: 0;
}
.gjs-one-bg {
background-color: #313844;
border-bottom: none;
color: #c4c7ce;
}
.gjs-two-color {
color: #e1e1e1;
}
.gjs-four-color {
color: #e1e1e1;
}
.gjs-four-color-h:hover {
color: #e1e1e1;
}
.gjs-pn-commands {
width: 100%;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
}
::-webkit-scrollbar {
width: 7px;
height: 7px;
}
::-webkit-scrollbar-track {
background: #313844 !important;
}
::-webkit-scrollbar-thumb {
background-color: #a5acb9 !important;
border-radius: 3px;
&:hover {
background-color: #0091d1 !important;
}
}
/* SIDEBAR */
.gjs-pn-views {
top: 40px;
.gjs-pn-btn {
width: 33.33%;
margin-right: 0;
padding: 16px 15px 16px 15px;
-webkit-border-radius: 0;
-moz-border-radius: 0;
border-radius: 0;
background: #3a3f4a;
color: #e3e3e3;
border-bottom: 1px solid #3a3f4a;
font-size: 16px;
&.gjs-pn-active {
padding: 15px;
background-color: #515664;
border-bottom-left-radius: unset;
border-bottom-right-radius: unset;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
color: #fff;
border-bottom: 3px solid #0091d1;
}
}
}
.gjs-pn-options {
right: 0;
}
.gjs-pn-views,
.gjs-pn-views-container {
left: 0;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
width: $sidebar-width;
padding-bottom: 0;
margin-bottom: 0;
margin-left: 0;
margin-right: 0;
padding-left: 0;
padding-right: 0;
}
.gjs-pn-views-container {
padding-top: 89px;
background: #22272e;
height: calc(100% - #{$sidebar-bottom-buttons-height});
overflow: hidden;
> div:first-of-type {
margin-top: 44px;
}
> div {
height: 100%;
overflow-y: auto;
}
> div > div {
background: #22272e;
border: none;
}
}
.gjs-cv-canvas,
.gjs-pn-devices-c {
left: $sidebar-width;
}
.gjs-pn-panel {
#gjs-sm-caret {
padding-right: 0 !important;
}
.fa-caret-down {
margin-right: 5px !important;
}
.fa-caret-right {
margin-right: 8px !important;
}
}
/* SIDEBAR FIELDS */
.gjs-three-bg {
background-color: #0091d1;
}
.gjs-clm-tags {
#gjs-clm-close,
#gjs-clm-checkbox {
color: #fff;
}
}
.gjs-field {
background-color: #22272e;
border-radius: 0;
padding: 2px;
input,
select,
textarea {
padding: 5px;
}
.gjs-d-s-arrow {
border-top: 4px solid rgb(100, 100, 100);
}
}
/* SIDEBAR HEADER */
#sidebar-header {
position: absolute;
box-shadow: none;
width: $sidebar-width;
padding-bottom: 0;
margin-bottom: 0;
margin-left: 0;
margin-right: 0;
padding-left: 0;
padding-right: 0;
background: #22272e;
height: 40px;
z-index: 100;
#language-selector {
float: right;
.dropdown-item.active,
.dropdown-item:active {
background: #22272e !important;
}
.dropdown-menu.show {
padding: 0;
}
.dropdown-toggle {
margin-top: 2px;
color: #fff !important;
background: none !important;
border: none;
box-shadow: none;
outline: none !important;
}
.flag-icon {
background-size: contain;
background-position: 50%;
background-repeat: no-repeat;
position: relative;
display: inline-block;
width: 1.33333333em;
height: 12px;
line-height: 1em;
}
}
}
#toggle-sidebar {
position: absolute;
left: 0;
top: 0;
z-index: 100;
color: #c4c7ce;
background: #22272e;
border-radius: 0;
transition-duration: unset;
}
/* BLOCKS PANEL VIEW */
#block-search {
position: fixed;
background: #22272e;
border-color: #3a3f4a;
border-radius: 0;
width: 325px;
margin-top: -44px;
i.fa-search {
position: absolute;
top: 14px;
left: 9px;
font-size: 15px;
color: #515664;
}
input {
background: #181b1e;
padding: 22px 20px 22px 30px;
border-radius: 0;
border: none;
&::placeholder {
color: #515664;
}
}
}
.gjs-block {
border: none;
box-shadow: none;
padding-bottom: 8px;
margin: 5px;
width: calc(50% - 10px);
&.fa {
padding: 8px;
}
&:hover {
color: #0091d1 !important;
}
.block-thumb {
height: 70px;
overflow: hidden;
margin-bottom: 5px;
opacity: 0.8;
img {
width: 100%;
}
}
}
.gjs-blocks-c {
background: #22272e;
padding: 4px;
}
.gjs-block-categories {
background: #22272e;
padding-bottom: 45px;
}
.gjs-block-label {
font-size: 0.8rem;
height: 100%;
display: grid;
b {
display: contents;
font-weight: 800;
}
}
.gjs-block-category {
background: #5a6371;
}
.gjs-block-category.gjs-open {
border-bottom: none !important;
margin-bottom: 10px;
}
.gjs-blocks-cs {
border-bottom: none !important;
}
/* LAYERS PANEL VIEW */
.gjs-layer .gjs-layer-title {
background: #5a6371 !important;
}
.gjs-layer.gjs-selected .gjs-layer-title {
background-color: #0091d1 !important;
}
.gjs-layer.gjs-hovered .gjs-layer-title {
background-color: #0091d170 !important
}
.gjs-category-title,
.gjs-sm-sector .gjs-sm-title,
.gjs-clm-tags .gjs-sm-title,
.gjs-block-category .gjs-title,
.gjs-layer-title {
background: #424853 !important;
border-bottom: 2px solid #363d48 !important;
letter-spacing: 0;
font-size: 16px;
font-weight: normal;
}
.gjs-sm-sector.gjs-sm-open .gjs-sm-title,
.gjs-clm-tags.gjs-open .gjs-sm-title,
.gjs-block-category.gjs-open .gjs-title {
background: #545d6c !important;
}
.gjs-layer-name {
padding-top: 2px;
padding-bottom: 13px;
}
.gjs-layer-count {
display: none;
}
.gjs-layer-vis {
padding-top: 11px
}
/* LAYERS PANEL VIEW */
.gjs-sm-sector.gjs-sm-open {
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}
/* TRAITS PANEL VIEW */
.gjs-trt-trait {
display: block;
}
.gjs-trt-header {
font-weight: normal;
}
.gjs-trt-trait .gjs-label,
.gjs-trt-trait .gjs-field {
width: 100%;
}
.gjs-field-checkbox {
height: 17px !important;
width: 17px !important;
}
.gjs-traits-label {
font-weight: normal;
font-size: 16px;
border-bottom: none;
}
.gjs-sm-sector #gjs-sm-caret,
.gjs-clm-tags #gjs-sm-caret {
font-size: initial;
}
.gjs-trt-traits .gjs-label-wrp {
width: 100%;
}
.gjs-trt-traits p.no-settings {
padding-top: 10px;
padding-bottom: 10px;
}
.gjs-trt-trait__wrp:first-of-type {
padding-top: 8px;
}
.gjs-trt-trait__wrp:last-of-type {
padding-bottom: 8px;
}
.gjs-trt-trait {
padding-bottom: 10px;
}
.gjs-trt-trait .gjs-field-image {
background: none;
padding: 0;
.image__preview-container {
text-align: center;
.image__remove-button {
position: absolute;
right: 0;
top: 0;
border-radius: 0;
background-color: #e9eef2;
border-color: #e9eef2;
color: #515664;
padding: 2px 6px;
}
img {
max-width: 100%;
max-height: 150px;
}
}
}
/* SIDEBAR BOTTOM BUTTONS */
#sidebar-bottom-buttons {
position: absolute;
left: 0;
bottom: 0;
height: $sidebar-bottom-buttons-height;
width: $sidebar-width;
margin: 0;
padding: 0;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
background: #474c57;
border-top: none;
button,
a {
float: right;
height: 100%;
width: 33.33%;
border-left: 1px solid #343944;
border-radius: 0;
color: #e3e3e3;
font-size: 15px;
padding: 8px 0;
&:hover {
background: #017eb5;
color: #fff;
}
&:last-child {
border-left: none;
}
}
button.waiting {
background: #0091d1;
color: #fff !important;
i.fa {
display: none;
}
}
#go-back:hover {
background: #b03541;
}
#save-page:hover {
background: #419147;
}
}
@import 'fields';
@import 'style-manager';
@import 'asset-manager';
@import 'ckeditor';
@@ -0,0 +1,68 @@
.gjs-sm-header, .gjs-trt-header {
font-weight: normal;
color: #8c909d;
}
.gjs-clm-tags {
width: 100%;
padding-top: 0;
padding-bottom: 0;
#gjs-clm-status-c,
#gjs-clm-sel-help {
display: none;
}
#gjs-clm-new {
color: #e1e1e1;
}
#gjs-clm-add-tag {
background-color: #0091d1;
border: none;
box-shadow: 1px 1px 0 rgba(255, 255, 255, 0.2) inset;
color: #fff;
&:hover {
background-color: #004a6c;
}
}
}
.gjs-sm-sectors {
.gjs-four-color,
.gjs-color-warn {
color: #e1e1e1;
}
.gjs-sm-field.gjs-sm-composite {
background-color: rgba(195, 226, 236, 0.14);
border: 1px solid rgba(121, 147, 155, 0.14);
}
.gjs-sm-layers {
background-color: #3a3f4a;
.gjs-sm-btn {
background: #fff;
color: #000;
text-shadow: none;
}
.gjs-field {
padding: 0;
background-color: #3a3f4a;
select {
color: #fff;
background: #424853;
}
}
}
.gjs-sm-stack #gjs-sm-add {
color: #fff;
&:hover {
color: #aaa;
}
}
}
@@ -0,0 +1,18 @@
<script type="text/javascript">
window.editor.on('asset:remove', function(asset) {
let assetId = asset.attributes.public_id;
$.ajax({
type: "POST",
url: "<?= phpb_url('pagebuilder', ['action' => 'upload_delete', 'page' => $page->getId()]) ?>",
data: {
id: assetId
},
success: function() {
},
error: function() {
}
});
});
</script>
@@ -0,0 +1,109 @@
<script type="text/javascript">
let linkType = editor.DomComponents.getType('link');
editor.DomComponents.addType('link', {
model: {
defaults: {
traits: [
{
type: 'text',
label: '<?= phpb_trans('pagebuilder.trait-manager.link.text') ?>',
name: 'content',
changeProp: 1,
},
{
type: 'text',
label: 'URL',
name: 'href',
},
{
type: 'text',
label: '<?= phpb_trans('pagebuilder.trait-manager.link.tooltip') ?>',
name: 'title',
},
{
type: 'select',
label: '<?= phpb_trans('pagebuilder.trait-manager.link.target') ?>',
name: 'target',
options: [
{value: '_blank', name: '<?= phpb_trans('pagebuilder.yes') ?>'},
{value: false, name: '<?= phpb_trans('pagebuilder.no') ?>'},
],
}
],
},
init() {
this.getTrait('content').setTargetValue(this.attributes.content.trim());
if (! this.attributes.attributes.target) {
this.getTrait('target').setTargetValue(false);
}
},
}
});
const textType = editor.DomComponents.getType('text');
editor.DomComponents.addType('text', {
model: {
defaults: {
traits: [],
attributes: {},
},
},
view: textType.view.extend({
events: {
click: 'onActive',
touchend: 'onActive'
},
}),
});
/**
* The raw-content type does not transform child elements into GrapesJS components.
* This is important to prevent the RTE editor from dealing with html elements modified by GrapesJS (for instance removed inline styling).
* Source: https://github.com/artf/grapesjs/issues/774#issuecomment-358963099
*/
editor.DomComponents.addType('raw-content', {
model: textType.model.extend({
},{
isComponent: function(el) {
if (el.hasAttribute && (el.hasAttribute('data-raw-content') || el.hasAttribute('phpb-editable'))) {
return {
type: 'raw-content',
content: el.innerHTML,
components: [] // avoid parsing children
};
}
}
}
),
view: textType.view
});
editor.DomComponents.addType('row', {
model: {
defaults: {
traits: [],
attributes: {},
},
},
});
editor.DomComponents.addType('cell', {
model: {
defaults: {
traits: [],
attributes: {},
},
},
});
editor.DomComponents.addType('default', {
model: {
defaults: {
traits: [],
attributes: {},
},
},
});
</script>
@@ -0,0 +1,114 @@
<?php
return [
'container' => '#gjs',
'noticeOnUnload' => false,
'avoidInlineStyle' => true,
'allowScripts' => true,
'storageManager' => [
'type' => 'local',
'autoload' => false,
'autosave' => false
],
'canvasCss' => 'body {height: auto;}', // prevent scrollbar jump on pasting in CKEditor
'assetManager' => [
'upload' => phpb_url('pagebuilder', ['action' => 'upload', 'page' => $page->getId()]),
'uploadName' => 'files',
'multiUpload' => false,
'assets' => $assets
],
'styleManager' => [
'sectors' => [[
'id' => 'position',
'name' => phpb_trans('pagebuilder.style-manager.sectors.position'),
'open' => true,
'buildProps' => ['width', 'height', 'min-width', 'min-height', 'max-width', 'max-height', 'padding', 'margin', 'text-align'],
'properties' => [[
'property' => 'text-align',
'list' => [
['value' => 'left', 'className' => 'fa fa-align-left'],
['value' => 'center', 'className' => 'fa fa-align-center'],
['value' => 'right', 'className' => 'fa fa-align-right'],
['value' => 'justify', 'className' => 'fa fa-align-justify'],
],
]]
], [
'id' => 'background',
'name' => phpb_trans('pagebuilder.style-manager.sectors.background'),
'open' => false,
'buildProps' => ['background-color', 'background']
]]
],
'selectorManager' => [
'label' => phpb_trans('pagebuilder.selector-manager.label'),
'statesLabel' => phpb_trans('pagebuilder.selector-manager.states-label'),
'selectedLabel' => phpb_trans('pagebuilder.selector-manager.selected-label'),
'states' => [
['name' => 'hover', 'label' => phpb_trans('pagebuilder.selector-manager.state-hover')],
['name' => 'active', 'label' => phpb_trans('pagebuilder.selector-manager.state-active')],
['name' => 'nth-of-type(2n)', 'label' => phpb_trans('pagebuilder.selector-manager.state-nth')]
],
],
'traitManager' => [
'labelPlhText' => '',
'labelPlhHref' => 'https://website.com'
],
'panels' => [
'defaults' => [
[
'id' => 'views',
'buttons' => [
[
'id' => 'open-blocks-button',
'className' => 'fa fa-th-large',
'command' => 'open-blocks',
'togglable' => 0,
'attributes' => ['title' => phpb_trans('pagebuilder.view-blocks')],
'active' => true,
],
[
'id' => 'open-settings-button',
'className' => 'fa fa-cog',
'command' => 'open-tm',
'togglable' => 0,
'attributes' => ['title' => phpb_trans('pagebuilder.view-settings')],
],
[
'id' => 'open-style-button',
'className' => 'fa fa-paint-brush',
'command' => 'open-sm',
'togglable' => 0,
'attributes' => ['title' => phpb_trans('pagebuilder.view-style-manager')],
]
]
],
]
],
'canvas' => [
'styles' => [
phpb_asset('pagebuilder/page-injection.css'),
],
],
'plugins' => ['grapesjs-touch', 'grapesjs-plugin-ckeditor'],
'pluginsOpts' => [
'grapesjs-plugin-ckeditor' => [
'position' => 'center',
'options' => [
'startupFocus' => true,
'allowedContent' => true,
//'forcePasteAsPlainText' => false, // when true does not copy UL, random JS errors while pasting
//'extraAllowedContent' => '*(*);*[*];ul ol li span', // allows classes, inline styles and certain elements
//'enterMode' => 'CKEDITOR.ENTER_BR', // issues on pasting in Chromes
'extraPlugins' => 'sourcedialog',
'toolbar' => [
['Bold', 'Italic', 'Underline', 'Strike', 'Undo', 'Redo'],
['Link', 'Unlink'],
['NumberedList', 'BulletedList'],
['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'],
['FontSize', 'TextColor'],
['Sourcedialog']
],
]
]
]
];
@@ -0,0 +1,32 @@
<script type="text/javascript">
let styleManager = editor.StyleManager;
styleManager.addSector('advanced',{
name: '<?= phpb_trans('pagebuilder.style-manager.sectors.advanced') ?>',
open: false,
properties: []
}, { at: 10 });
<?php
foreach (phpb_trans('pagebuilder.style-manager.properties') as $sector => $sectorProperties) {
foreach ($sectorProperties as $property => $data) {
if (is_array($data)) {
for ($i = 0; $i < sizeof($data['properties'] ?? []); $i++) {
$translation = $data['properties'][array_keys($data['properties'])[$i]];
?>
window.editor.StyleManager.getProperty('<?= phpb_e($sector) ?>', '<?= phpb_e($property) ?>').attributes.properties.models[<?= $i ?>].attributes.name = '<?= phpb_e($translation) ?>';
<?php
}
?>
window.editor.StyleManager.getProperty('<?= phpb_e($sector) ?>', '<?= phpb_e($property) ?>').set({ name: '<?= phpb_e($data['name']) ?>' });
<?php
} else {
?>
window.editor.StyleManager.getProperty('<?= phpb_e($sector) ?>', '<?= phpb_e($property) ?>').set({ name: '<?= phpb_e($data) ?>' });
<?php
}
}
}
?>
</script>
@@ -0,0 +1,46 @@
<script type="text/javascript">
editor.TraitManager.addType('image', {
createInput({ trait }) {
const previewImageUrl = '<?= phpb_asset('pagebuilder/images/image-placeholder-small.jpg') ?>';
const traitName = trait.attributes.name;
const el = document.createElement('div');
el.innerHTML = `
<div class="image__preview-container">
<img class="image__preview cursor-pointer" src="${previewImageUrl}">
<button class="btn btn-light btn-sm image__remove-button d-none" type="button">
<i class="fa fa-close"></i>
</button>
</div>
`;
const preview = el.querySelector('.image__preview');
const removeButton = el.querySelector('.image__remove-button');
const component = window.editor.getSelected();
if (component.attributes.attributes[traitName] !== undefined && component.attributes.attributes[traitName] !== '') {
preview.setAttribute('src', component.attributes.attributes[traitName]);
removeButton.classList.remove('d-none');
}
preview.addEventListener('click', event => {
window.editor.runCommand('open-assets', {
onSelect: asset => {
preview.setAttribute('src', asset.attributes.src);
removeButton.classList.remove('d-none');
// update component setting and trigger editor component:update event
component.addAttributes({[traitName]: asset.attributes.src});
}
});
});
removeButton.addEventListener('click', event => {
removeButton.classList.add('d-none');
preview.setAttribute('src', previewImageUrl);
component.addAttributes({[traitName]: ''});
});
return el;
}
});
</script>
@@ -0,0 +1,35 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>PageBuilder</title>
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9, user-scalable=no">
<script src="<?= phpb_asset('PageBuilderHead.js') ?>"></script>
<link rel="stylesheet" href="<?= phpb_asset('pagebuilder/bootstrap-v4.3.1.min.css') ?>">
<link rel="stylesheet" href="<?= phpb_asset('pagebuilder/bootstrap-select-v1.13.12.min.css') ?>">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="<?= phpb_asset('pagebuilder/toastr-v2.1.3.min.css') ?>">
<link rel="stylesheet" href="<?= phpb_asset('PageBuilderHead.css') ?>">
<?= $pageBuilder->customStyle(); ?>
<script src="<?= phpb_asset('pagebuilder/underscore-v1.9.1.min.js') ?>"></script>
<script src="<?= phpb_asset('pagebuilder/jquery-3.4.1.min.js') ?>"></script>
<script src="<?= phpb_asset('pagebuilder/popper-v1.12.9.min.js') ?>"></script>
<script src="<?= phpb_asset('pagebuilder/bootstrap-v4.3.1.min.js') ?>"></script>
<script src="<?= phpb_asset('pagebuilder/bootstrap-select-v1.13.12.min.js') ?>"></script>
<script src="<?= phpb_asset('pagebuilder/toastr-v2.1.3.min.js') ?>"></script>
<script src="<?= phpb_asset('pagebuilder/beautify-html-v1.10.2.min.js') ?>"></script>
<?= $pageBuilder->customScripts('head'); ?>
</head>
<body>
<?php
require __DIR__ . '/pagebuilder.php';
?>
<script src="<?= phpb_asset('PageBuilderBody.js') ?>"></script>
<?= $pageBuilder->customScripts('body'); ?>
</body>
</html>
@@ -0,0 +1,165 @@
<div id="phpb-loading">
<div class="circle">
<div class="loader">
<div class="loader">
<div class="loader">
<div class="loader"></div>
</div>
</div>
</div>
<div class="text">
<?= phpb_trans('pagebuilder.loading-text') ?>
</div>
</div>
</div>
<div id="gjs"></div>
<script type="text/javascript" src="https://cdn.ckeditor.com/4.21.0/full-all/ckeditor.js"></script>
<script type="text/javascript" src="<?= phpb_asset('pagebuilder/grapesjs-plugin-ckeditor-v0.0.10.min.js') ?>"></script>
<script type="text/javascript" src="<?= phpb_asset('pagebuilder/grapesjs-touch-v0.1.1.min.js') ?>"></script>
<script type="text/javascript">
CKEDITOR.dtd.$editable.a = 1;
CKEDITOR.dtd.$editable.b = 1;
CKEDITOR.dtd.$editable.em = 1;
CKEDITOR.dtd.$editable.button = 1;
CKEDITOR.dtd.$editable.strong = 1;
CKEDITOR.dtd.$editable.small = 1;
CKEDITOR.dtd.$editable.span = 1;
CKEDITOR.dtd.$editable.ol = 1;
CKEDITOR.dtd.$editable.ul = 1;
CKEDITOR.dtd.$editable.table = 1;
<?php
$currentLanguage = in_array(phpb_config('general.language'), phpb_active_languages()) ?
phpb_config('general.language') : array_keys(phpb_active_languages())[0];
if (! empty($_SESSION['plugi_language'])) {
$currentLanguage = $_SESSION['plugi_language'];
}
?>
window.languages = <?= json_encode(phpb_active_languages()) ?>;
window.currentLanguage = <?= json_encode($currentLanguage) ?>;
window.translations = <?= json_encode(phpb_trans('pagebuilder')) ?>;
window.contentContainerComponents = <?= json_encode($pageBuilder->getPageComponents($page)) ?>;
window.themeBlocks = <?= json_encode($blocks) ?>;
window.blockSettings = <?= json_encode($blockSettings) ?>;
window.pageBlocks = <?= json_encode($pageRenderer->getPageBlocksData()) ?>;
window.pages = <?= json_encode($pageBuilder->getPages()) ?>;
window.renderBlockUrl = '<?= phpb_url('pagebuilder', ['action' => 'renderBlock', 'page' => $page->getId()]) ?>';
window.injectionScriptUrl = '<?= phpb_asset('pagebuilder/page-injection.js') ?>';
window.renderLanguageVariantUrl = '<?= phpb_url('pagebuilder', ['action' => 'renderLanguageVariant', 'page' => $page->getId()]) ?>';
<?php
$config = require __DIR__ . '/grapesjs/config.php';
?>
let config = <?= json_encode($config) ?>;
if (window.customConfig !== undefined) {
config = $.extend(true, {}, window.customConfig, config);
}
window.initialComponents = <?= json_encode($pageRenderer->render()) ?>;
window.initialStyle = <?= json_encode($pageBuilder->getPageStyleComponents($page)) ?>;
window.grapesJSTranslations = {
<?= $currentLanguage ?>: {
styleManager: {
empty: '<?= phpb_trans('pagebuilder.style-no-element-selected') ?>'
},
traitManager: {
empty: '<?= phpb_trans('pagebuilder.trait-no-element-selected') ?>',
label: '<?= phpb_trans('pagebuilder.trait-settings') ?>',
traits: {
options: {
target: {
false: '<?= phpb_trans('pagebuilder.no') ?>',
_blank: '<?= phpb_trans('pagebuilder.yes') ?>'
}
}
}
},
assetManager: {
addButton: '<?= phpb_trans('pagebuilder.asset-manager.add-image') ?>',
inputPlh: 'http://path/to/the/image.jpg',
modalTitle: '<?= phpb_trans('pagebuilder.asset-manager.modal-title') ?>',
uploadTitle: '<?= phpb_trans('pagebuilder.asset-manager.drop-files') ?>'
}
}
};
window.grapesJSLoaded = false;
window.editor = window.grapesjs.init(config);
window.editor.on('load', function(editor) {
window.grapesJSLoaded = true;
});
window.editor.I18n.addMessages(window.grapesJSTranslations);
// load the default or earlier saved page css components
editor.setStyle(window.initialStyle);
</script>
<?php
require __DIR__ . '/grapesjs/asset-manager.php';
require __DIR__ . '/grapesjs/component-type-manager.php';
require __DIR__ . '/grapesjs/style-manager.php';
require __DIR__ . '/grapesjs/trait-manager.php';
?>
<button id="toggle-sidebar" class="btn">
<i class="fa fa-bars"></i>
</button>
<div id="sidebar-header">
<?php
if (sizeof(phpb_active_languages()) > 1):
?>
<div id="language-selector">
<select class="selectpicker" data-width="fit">
<?php
foreach (phpb_active_languages() as $languageCode => $languageTranslation):
?>
<option value="<?= phpb_e($languageCode) ?>" <?= $languageCode === $currentLanguage ? 'selected' : '' ?>
data-content='<span class="flag-icon flag-icon-<?= phpb_e($languageCode) ?>"></span><span class="language-name ml-1"><?= phpb_e($languageTranslation) ?></span>'>
>
<?= phpb_e($languageTranslation) ?>
</option>
<?php
endforeach;
?>
</select>
</div>
<?php
endif;
?>
<style>
<?php
foreach (phpb_active_languages() as $languageCode => $languageTranslation):
?>
.flag-icon-<?= $languageCode ?> {
background-image: url(<?= phpb_asset('pagebuilder/images/flags/' . $languageCode . '.svg') ?>);
}
<?php
endforeach;
?>
</style>
</div>
<div id="sidebar-bottom-buttons">
<button id="save-page" class="btn" data-url="<?= phpb_url('pagebuilder', ['action' => 'store', 'page' => $page->getId()]) ?>">
<span class="spinner-border spinner-border-sm d-none" role="status" aria-hidden="true"></span>
<i class="fa fa-save"></i>
<?= phpb_trans('pagebuilder.save-page') ?>
</button>
<a id="view-page" href="<?= phpb_e(phpb_full_url($page->getRoute())) ?>" target="_blank" class="btn">
<i class="fa fa-external-link"></i>
<?= phpb_trans('pagebuilder.view-page') ?>
</a>
<a id="go-back" href="<?= phpb_e(phpb_full_url(phpb_config('pagebuilder.actions.back'))) ?>" class="btn">
<i class="fa fa-arrow-circle-left"></i>
<?= phpb_trans('pagebuilder.go-back') ?>
</a>
</div>
<div id="block-search">
<i class="fa fa-search"></i>
<input type="text" class="form-control" placeholder="<?= phpb_trans('pagebuilder.filter-placeholder') ?>">
</div>
@@ -0,0 +1,200 @@
<?php
namespace Plugi\Modules\Router;
use Plugi\Contracts\PageContract;
use Plugi\Contracts\PageTranslationContract;
use Plugi\Contracts\RouterContract;
use Plugi\Repositories\PageRepository;
use Plugi\Repositories\PageTranslationRepository;
class DatabasePageRouter implements RouterContract
{
/**
* @var PageRepository $pageRepository
*/
protected $pageRepository;
/**
* @var PageTranslationRepository $pageTranslationRepository
*/
protected $pageTranslationRepository;
/**
* @var array $routeParameters
*/
protected $routeParameters;
/**
* @var array $routeToPageTranslationIdMapping
*/
protected $routeToPageTranslationIdMapping;
/**
* DatabasePageRouter constructor.
*/
public function __construct()
{
$this->pageRepository = new PageRepository;
$this->pageTranslationRepository = new PageTranslationRepository;
$this->routeParameters = [];
$this->routeToPageTranslationIdMapping = [];
}
/**
* Return the page from database corresponding to the given URL.
*
* @param $url
* @return PageTranslationContract|null
*/
public function resolve($url)
{
// strip URL query parameters
$url = explode('?', $url, 2)[0];
// split URL into segments using / as separator
$urlSegments = explode('/', $url);
// request all routes and convert each to its segments using / as separator
$pageTranslations = $this->pageTranslationRepository->getAll(['id', 'route']);
$routes = [];
foreach ($pageTranslations as $pageTranslation) {
$route = $pageTranslation->route;
$this->routeToPageTranslationIdMapping[$route] = $pageTranslation->id;
$routeSegments = explode('/', $route);
$routes[] = $routeSegments;
}
// sort routes into the order for evaluation
$orderedRoutes = $this->getRoutesInOrder($routes);
// match each route with current URL segments and return the corresponding page once we find a match
foreach ($orderedRoutes as $routeSegments) {
if ($this->onRoute($urlSegments, $routeSegments)) {
$fullRoute = implode('/', $routeSegments);
$matchedPage = $this->getMatchedPage($fullRoute, $this->routeToPageTranslationIdMapping[$fullRoute]);
if ($matchedPage) {
global $phpb_route_parameters;
$phpb_route_parameters = $this->routeParameters;
return $matchedPage;
}
}
}
return null;
}
/**
* Sort the given routes into the order in which they need to be evaluated.
*
* @param $allRoutes
* @return array
*/
public function getRoutesInOrder($allRoutes)
{
usort($allRoutes, [$this, "routeOrderComparison"]);
return $allRoutes;
}
/**
* Compare two given routes and return -1,0,1 indicating which route should be evaluated first.
*
* @param $route1
* @param $route2
* @return int
*/
public function routeOrderComparison($route1, $route2)
{
// routes with more segments should be evaluated first
if (sizeof($route1) > sizeof($route2)) {
return -1;
}
if (sizeof($route1) < sizeof($route2)) {
return 1;
}
// routes ending with (more) named parameters should be evaluated after exact matches, but before catch all
$namedParameterCountRoute1 = substr_count(implode('/', $route1), '{');
$namedParameterCountRoute2 = substr_count(implode('/', $route2), '{');
if ($namedParameterCountRoute1 < $namedParameterCountRoute2) {
return -1;
}
if ($namedParameterCountRoute1 > $namedParameterCountRoute2) {
return 1;
}
// routes ending with a wildcard should be evaluated last (after exact matches or named parameters)
if (array_slice($route1, -1)[0] === '*') {
return 1;
}
if (array_slice($route2, -1)[0] === '*') {
return -1;
}
// otherwise, the order is undetermined
return 0;
}
/**
* Return the full page translation instance based on the given matched route or page translation id.
* (this method is helpful when extending a router to perform additional checks after a route has been matched)
*
* @param string $matchedRoute the matched route
* @param string $matchedPageTranslationId the page translation id corresponding to the matched route
* @return PageTranslationContract|null
*/
public function getMatchedPage(string $matchedRoute, string $matchedPageTranslationId)
{
$pageTranslation = $this->pageTranslationRepository->findWithId($matchedPageTranslationId);
if ($pageTranslation instanceof PageTranslationContract) {
return $pageTranslation;
}
return null;
}
/**
* Return whether the given URL segments match with the given route segments.
*
* @param $urlSegments
* @param $routeSegments
* @return bool
*/
protected function onRoute($urlSegments, $routeSegments)
{
// URL does not match if segment counts don't match, except if the route ends with a *
if (sizeof($urlSegments) !== sizeof($routeSegments) && end($routeSegments) !== '*') {
return false;
}
// try matching each route segment with the same level URL segment
$routeParameters = [];
foreach ($routeSegments as $i => $routeSegment) {
if (! isset($urlSegments[$i])) {
return false;
}
$urlSegment = $urlSegments[$i];
// the URL segment matches if the route segment is a {parameter}
if (substr($routeSegment,0, 1) === '{' && substr($routeSegment, -1) === '}') {
$parameter = trim($routeSegment, '{}');
$routeParameters[$parameter] = $urlSegment;
continue;
}
// the URL fully matches if the route segment is a wildcard
if ($routeSegment === '*') {
break;
}
// the URL segment matches if equal to the route segment
if ($urlSegment === $routeSegment) {
continue;
}
// the URL segment and route segment did not match
return false;
}
$this->routeParameters = $routeParameters;
return true;
}
}
@@ -0,0 +1,236 @@
<?php
namespace Plugi\Modules\WebsiteManager;
use Plugi\Contracts\PageContract;
use Plugi\Contracts\WebsiteManagerContract;
use Plugi\Extensions;
use Plugi\Repositories\MenuRepository;
use Plugi\Repositories\PageRepository;
use Plugi\Repositories\PageTranslationRepository;
use Plugi\Repositories\SettingRepository;
use Plugi\Repositories\UploadRepository;
class WebsiteManager implements WebsiteManagerContract
{
/**
* Process the current GET or POST request and redirect or render the requested page.
*
* @param $route
* @param $action
*/
public function handleRequest($route, $action)
{
if (is_null($route)) {
$this->renderOverview();
exit();
}
if ($route === 'settings') {
if ($action === 'renderBlockThumbs') {
$this->renderBlockThumbs();
exit();
}
if ($action === 'update') {
$this->handleUpdateSettings();
exit();
}
}
if ($route === 'menus') {
if ($action === 'update') {
$this->handleUpdateMenus();
exit();
}
}
if ($route === 'page_settings') {
if ($action === 'create') {
$this->handleCreate();
exit();
}
$pageId = $_GET['page'] ?? null;
$pageRepository = new PageRepository;
$page = $pageRepository->findWithId($pageId);
if (! ($page instanceof PageContract)) {
phpb_redirect(phpb_url('website_manager'));
}
if ($action === 'edit') {
$this->handleEdit($page);
exit();
} else if ($action === 'destroy') {
$this->handleDestroy($page);
}
}
}
/**
* Handle requests for creating a new page.
*/
public function handleCreate()
{
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$pageRepository = new PageRepository;
$page = $pageRepository->create($_POST);
if ($page) {
phpb_redirect(phpb_url('website_manager'), [
'message-type' => 'success',
'message' => phpb_trans('website-manager.page-created')
]);
}
}
$this->renderPageSettings();
}
/**
* Handle requests for editing the given page.
*
* @param PageContract $page
*/
public function handleEdit(PageContract $page)
{
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$pageRepository = new PageRepository;
$success = $pageRepository->update($page, $_POST);
if ($success) {
phpb_redirect(phpb_url('website_manager'), [
'message-type' => 'success',
'message' => phpb_trans('website-manager.page-updated')
]);
}
}
$this->renderPageSettings($page);
}
/**
* Handle requests to destroy the given page.
*
* @param PageContract $page
*/
public function handleDestroy(PageContract $page)
{
$pageRepository = new PageRepository;
$pageRepository->destroy($page->getId());
phpb_redirect(phpb_url('website_manager'), [
'message-type' => 'success',
'message' => phpb_trans('website-manager.page-deleted')
]);
}
/**
* Handle requests for updating the website settings.
*/
public function handleUpdateSettings()
{
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$settingRepository = new SettingRepository;
$success = $settingRepository->updateSettings($_POST);
if ($success) {
phpb_redirect(phpb_url('website_manager', ['tab' => 'settings']), [
'message-type' => 'success',
'message' => phpb_trans('website-manager.settings-updated')
]);
}
}
}
/**
* Handle requests for updating the website menuss.
*/
public function handleUpdateMenus()
{
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$settingRepository = new MenuRepository;
$success = $settingRepository->updateMenus($_POST);
if ($success) {
phpb_redirect(phpb_url('website_manager', ['tab' => 'menus']), [
'message-type' => 'success',
'message' => phpb_trans('website-manager.menus-updated')
]);
}
}
}
/**
* Render the website manager overview page.
*/
public function renderOverview()
{
$pageRepository = new PageRepository;
$pages = $pageRepository->getAll();
uasort($pages, function ($a, $b){
return ($a->getRoute() < $b->getRoute()) ? -1 : 1;
});
$pageTranslationRepository = new PageTranslationRepository;
$pageTranslations = $pageTranslationRepository->getAll();
$filesRepository = new UploadRepository;
$files = $filesRepository->getAll();
$menuRepository = new MenuRepository;
$menus = $menuRepository->getHydratedMenus();
$menusJson = json_encode($menus);
$menuPages = [];
foreach ($pages as $page) {
$menuPages[] = [
'id' => $page->getId(),
'title' => $page->getName(),
'route' => $page->getRoute()
];
}
$menuPagesJson = json_encode($menuPages);
$viewFile = 'overview';
require __DIR__ . '/resources/layouts/master.php';
}
/**
* Render the website manager page settings (add/edit page form).
*
* @param PageContract $page
*/
public function renderPageSettings(PageContract $page = null)
{
$action = isset($page) ? 'edit' : 'create';
$theme = phpb_instance('theme', [
phpb_config('theme'),
phpb_config('theme.active_theme')
]);
$viewFile = 'page-settings';
require __DIR__ . '/resources/layouts/master.php';
}
/**
* Render the website manager menu settings (add/edit menu form).
*/
public function renderMenuSettings()
{
$viewFile = 'menu-settings';
require __DIR__ . '/resources/layouts/master.php';
}
/**
* Render a thumbnail for each theme block.
*/
public function renderBlockThumbs()
{
$viewFile = 'block-thumbs';
require __DIR__ . '/resources/layouts/master.php';
}
/**
* Render the website manager welcome page for installations without a homepage.
*/
public function renderWelcomePage()
{
$viewFile = 'welcome';
require __DIR__ . '/resources/layouts/empty.php';
}
}
@@ -0,0 +1,12 @@
import Alpine from "alpinejs"
import './sass/app.scss'
import './js/app.js'
import "@phosphor-icons/web/thin";
import "@phosphor-icons/web/light";
import "@phosphor-icons/web/regular";
import "@phosphor-icons/web/bold";
import "@phosphor-icons/web/fill";
import "@phosphor-icons/web/duotone";
Alpine.start()
@@ -0,0 +1,8 @@
window.addEventListener("message", onMessage, false);
function onMessage(event) {
if (event.data === 'thumb-saved') {
const itr = document.querySelector("iframe.thumb-renderer")
itr.attributes.src = `${itr.attributes.src}`
}
}
@@ -0,0 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
@@ -0,0 +1,21 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Plugi Page Builder</title>
<link href="<?= phpb_asset('WebsiteManager.css') ?>" rel="stylesheet">
</head>
<body class="bg-light">
<div class="container">
<?php
require __DIR__ . '/../views/' . $viewFile . '.php';
?>
</div>
<script src="<?= phpb_asset('WebsiteManager.js') ?>"></script>
</body>
</html>
@@ -0,0 +1,87 @@
<?php
use Plugi\Extensions;
$tabs = include __DIR__ . '/../views/tabs/config.php';
$tabs = array_merge($tabs, Extensions::getBackends());
$activeSlug = array_key_first($tabs);
if (isset($_GET['tab'])) {
$activeSlug = $_GET['tab'];
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title><?= phpb_trans('website-manager.title') ?></title>
<?= phpb_registered_assets('admin-header') ?>
<link href="<?= phpb_asset('WebsiteManager.css') ?>" rel="stylesheet">
</head>
<body>
<div class="drawer lg:drawer-open">
<input id="my-drawer-2" type="checkbox" class="drawer-toggle" />
<div class="drawer-content flex flex-col items-center justify-top">
<!-- Page content here -->
<div class="navbar bg-base-100 lg:hidden">
<div class="navbar-start">
<label for="my-drawer-2" class="btn btn-square btn-ghost drawer-button">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" class="inline-block w-5 h-5 stroke-current"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16"></path></svg>
</label>
</div>
<div class="navbar-center">
<span class="text-xl"><?= phpb_trans('website-manager.title') ?></span>
</div>
<div class="navbar-end">
<a href="<?= phpb_url('auth', ['action' => 'logout']) ?>" class="btn btn-square btn-ghost">
<i class="text-lg ph ph-sign-out"></i>
</a>
</div>
</div>
<?php
require __DIR__ . '/../views/' . $viewFile . '.php';
?>
<footer class="my-5 pt-5 text-muted text-center text-small">
<p class="mb-1">Powered by <a href="https://github.com/deepDiverPaul/plugi" target="_blank">Plugi Page Builder</a></p>
</footer>
</div>
<div class="drawer-side">
<label for="my-drawer-2" class="drawer-overlay"></label>
<ul class="menu p-4 w-80 h-full bg-base-200 text-base-content">
<!-- Sidebar content here -->
<div class="py-5 text-2xl text-center">
<h2><?= phpb_trans('website-manager.title') ?></h2>
</div>
<?php
foreach ($tabs as $slug => $tab) :
?>
<li class="mb-1">
<a class="<?= phpb_e($slug === $activeSlug ? 'bg-base-100' : '' ) ?>" href="?tab=<?= phpb_e($slug) ?>">
<?= $tab['icon'] ?: '<i class="ph ph-circles-four"></i>' ?> <?= phpb_e($tab['title']) ?>
</a>
</li>
<?php
endforeach;
?>
<?php
if (phpb_config('auth.use_login')):
?>
<li class="lg:flex hidden">
<a href="<?= phpb_url('auth', ['action' => 'logout']) ?>" class="">
<i class="ph ph-sign-out"></i> <?= phpb_trans('website-manager.logout') ?>
</a>
</li>
<?php
endif;
?>
</ul>
</div>
</div>
<script src="<?= phpb_asset('WebsiteManager.js') ?>"></script>
</body>
</html>
@@ -0,0 +1,30 @@
<?php
$pageUrlParam = '';
if (isset($page)) {
$pageUrlParam = '&page=' . phpb_e($page->getId());
}
?>
<div class="py-5 text-center">
<h2><?= phpb_trans('website-manager.title') ?></h2>
</div>
<div class="row">
<div class="col-12">
<div class="manager-panel">
<h4><?= phpb_trans('website-manager.render-thumbs') ?></h4>
<div class="main-spacing">
<iframe class="thumb-renderer" src="<?= phpb_url('pagebuilder', ['route' => 'thumb_generator', 'action' => 'renderNextBlockThumb']) ?>"></iframe>
</div>
<hr class="mb-3">
<a href="<?= phpb_url('website_manager') ?>" class="btn btn-light btn-sm mr-1">
<?= phpb_trans('website-manager.back') ?>
</a>
</div>
</div>
</div>
@@ -0,0 +1,10 @@
<div class="max-w-4xl p-8 mx-auto w-full">
<div class="text-center text-3xl font-bold mb-8 mt-2">
<?= phpb_e($tabs[$activeSlug]['title']) ?>
</div>
<div class="">
<?php
include $tabs[$activeSlug]['include'];
?>
</div>
</div>
@@ -0,0 +1,119 @@
<?php
$pageUrlParam = '';
if (isset($page)) {
$pageUrlParam = '&page=' . phpb_e($page->getId());
}
$pageTranslations = $page ? $page->getTranslations() : [];
?>
<div class="manager-panel p-8 w-full">
<form method="post" action="<?= phpb_url('website_manager', ['route' => 'page_settings', 'action' => $action]) ?><?= $pageUrlParam ?>">
<div class="text-center text-3xl font-bold mb-8 mt-2">
<?php
if ($action === 'create'):
echo phpb_trans('website-manager.add-new-page');
else:
echo phpb_trans('website-manager.edit-page');
endif;
?>
</div>
<div class="max-w-lg p-4 mx-auto">
<div class="form-control w-full mb-4">
<label class="label">
<span class="label-text"> <?= phpb_trans('website-manager.name') ?></span>
<span class="label-text-alt"><?= phpb_trans('website-manager.required') ?></span>
</label>
<input type="text" id="name" name="name" value="<?= phpb_field_value('name', $page) ?>" required class="input input-bordered w-full" />
<label class="label">
<span class="label-text-alt"><?= phpb_trans('website-manager.visible-in-page-overview') ?></span>
</label>
</div>
<div class="form-control w-full mb-4">
<label class="label">
<span class="label-text"><?= phpb_trans('website-manager.layout') ?></span>
<span class="label-text-alt"><?= phpb_trans('website-manager.required') ?></span> <!-- TODO add to lang -->
</label>
<select class="select select-bordered" id="layout" name="layout" required>
<?php
$value = phpb_field_value('layout', $page);
foreach ($theme->getThemeLayouts() as $layout):
if ($layout->getSlug() === $value):
echo '<option value="' . phpb_e($layout->getSlug()) . '" selected>' . phpb_e($layout->getTitle()) . '</option>';
else:
echo '<option value="' . phpb_e($layout->getSlug()) . '">' . phpb_e($layout->getTitle()) . '</option>';
endif;
endforeach;
?>
</select>
</div>
<?php
$firstLang = true;
foreach (phpb_active_languages() as $languageCode => $languageTranslation):
?>
<details class="collapse collapse-plus bg-base-200 mt-6" <?= phpb_e($firstLang ? 'open' : '') ?>>
<summary class="collapse-title text-xl font-medium"><?= phpb_trans('languages.' . $languageCode) ?></summary>
<div class="collapse-content">
<div class="">
<div class="form-control w-full mb-2">
<label class="label" for="<?= phpb_e($languageCode) ?>-page-title">
<span class="label-text"><?= phpb_trans('website-manager.page-title') ?></span>
<span class="label-text-alt"><?= phpb_trans('website-manager.required') ?></span>
</label>
<input type="text" class="input input-bordered w-full" id="<?= phpb_e($languageCode) ?>-page-title" name="title[<?= phpb_e($languageCode) ?>]" value="<?= phpb_e($pageTranslations[$languageCode]['title'] ?? '') ?>" required />
</div>
<div class="form-control w-full mb-2">
<label class="label" for="<?= phpb_e($languageCode) ?>-page-meta-title">
<span class="label-text"><?= phpb_trans('website-manager.page-meta-title') ?></span>
</label>
<input type="text" class="input input-bordered w-full" id="<?= phpb_e($languageCode) ?>-page-meta-title" name="meta_title[<?= phpb_e($languageCode) ?>]" value="<?= phpb_e($pageTranslations[$languageCode]['meta_title'] ?? '') ?>" />
</div>
<div class="form-control w-full mb-2">
<label class="label" for="<?= phpb_e($languageCode) ?>-page-meta-description">
<span class="label-text"><?= phpb_trans('website-manager.page-meta-description') ?></span>
</label>
<input type="text" class="input input-bordered w-full" id="<?= phpb_e($languageCode) ?>-page-meta-description" name="meta_description[<?= phpb_e($languageCode) ?>]" value="<?= phpb_e($pageTranslations[$languageCode]['meta_description'] ?? '') ?>" />
</div>
<div class="form-control w-full mb-2">
<label class="label" for="<?= phpb_e($languageCode) ?>-page-route">
<span class="label-text"><?= phpb_trans('website-manager.route') ?></span>
<span class="label-text-alt"><?= phpb_trans('website-manager.required') ?></span>
</label>
<input type="text" class="input input-bordered w-full" id="<?= phpb_e($languageCode) ?>-page-route" name="route[<?= phpb_e($languageCode) ?>]" value="<?= phpb_e($pageTranslations[$languageCode]['route'] ?? '') ?>" required />
</div>
</div>
</div>
</details>
<?php
$firstLang = false;
endforeach;
?>
<div class="text-center mt-8">
<a href="<?= phpb_url('website_manager') ?>" class="btn btn-light btn-sm mr-1">
<?= phpb_trans('website-manager.back') ?>
</a>
<button class="btn btn-primary btn-sm">
<?php
if ($action === 'create'):
echo phpb_trans('website-manager.add-new-page');
else:
echo phpb_trans('website-manager.save-changes');
endif;
?>
</button>
</div>
</div>
</form>
</div>
@@ -0,0 +1,29 @@
<?php
return [
'pages' => [
'title' => phpb_trans('website-manager.pages'),
'include' => __DIR__ . '/pages.php',
'icon' => '<i class="ph ph-file"></i>',
],
'menus' => [
'title' => phpb_trans('website-manager.menus'),
'include' => __DIR__ . '/menus.php',
'icon' => '<i class="ph ph-list"></i>',
],
'files' => [
'title' => phpb_trans('website-manager.files'),
'include' => __DIR__ . '/files.php',
'icon' => '<i class="ph ph-folder-notch-open"></i>',
],
'settings' => [
'title' => phpb_trans('website-manager.settings'),
'include' => __DIR__ . '/settings.php',
'icon' => '<i class="ph ph-gear"></i>',
],
'info' => [
'title' => phpb_trans('website-manager.info'),
'include' => __DIR__ . '/info.php',
'icon' => '<i class="ph ph-info"></i>',
],
];
@@ -0,0 +1,53 @@
<div class="mb-8 flex justify-center">
<input type="file" id="fileupload" class="file-input file-input-bordered file-input-primary w-full max-w-md" name="fileupload" onchange="uploadFile()" onselect="uploadFile()" />
</div>
<div class="flex flex-wrap justify-center gap-4">
<?php
foreach ($files as $file) :
?>
<div class="relative">
<img src="<?= phpb_e($file->getUrl()) ?>" alt="<?= phpb_e($file->public_id) ?>" class="h-40 rounded">
<div class="absolute top-1 right-1">
<button onclick="deleteFile('<?= phpb_e($file->public_id) ?>')" class="btn btn-error btn-circle btn-sm mb-2">
<i class="ph-duotone ph-trash"></i>
</button>
</div>
</div>
<?php
endforeach;
?>
<?php
if (count($files) === 0) :
?>
<div class="relative">
No files...
</div>
<?php
endif;
?>
</div>
<script>
async function uploadFile() {
let formData = new FormData();
const fileupload = document.getElementById('fileupload');
formData.append("files", fileupload.files[0]);
await fetch('<?= phpb_url('pagebuilder', ['action' => 'upload', 'page' => '1']) ?>', {
method: "POST",
body: formData
}).then(() => {
location.reload();
}).catch(() => {alert('An Error occured.')});
}
async function deleteFile(id) {
let formData = new FormData();
formData.append("id", id);
await fetch('<?= phpb_url('pagebuilder', ['action' => 'upload_delete', 'page' => '1']) ?>', {
method: "POST",
body: formData
}).then(() => {
location.reload();
}).catch(() => {alert('An Error occured.')});
}
</script>
@@ -0,0 +1,28 @@
<div class="overflow-x-auto">
<table class="table table-zebra">
<tbody>
<!-- row 1 -->
<tr>
<th class="w-60">PHP Version</th>
<td><?= phpversion() ?>n</td>
</tr>
<!-- row 2 -->
<tr>
<th class="align-top">Installed extensions</th>
<td>
<ul>
<?php
foreach (\Plugi\Extensions::getConfigs() as $ext) :
?>
<li>
<?= phpb_e($ext['title']) ?> (<?= phpb_e($ext['version']) ?>)
</li>
<?php
endforeach;
?>
</ul>
</td>
</tr>
</tbody>
</table>
</div>
@@ -0,0 +1,101 @@
<?php
use Plugi\Repositories\PageRepository;
$setting = phpb_instance('setting');
$pageRepository = new PageRepository;
$pages = $pageRepository->getAll();
?>
<form method="post" action="<?= phpb_url('website_manager', ['route' => 'menus', 'action' => 'update', 'tab' => 'menus']) ?>">
<div class="main-spacing" >
<?php
if (phpb_flash('message')):
?>
<div class="hidden alert-success"></div>
<div class="alert alert-<?= phpb_flash('message-type') ?> mb-6">
<i class="text-xl ph-duotone ph-info"></i>
<span><?= phpb_flash('message') ?></span>
</div>
<?php
endif;
?>
<div x-data="{menus: <?= phpb_e($menusJson) ?>, pages: <?= phpb_e($menuPagesJson) ?>}" class="flex flex-col gap-12">
<template x-for="menu in menus">
<div class="">
<div class="px-6 mb-4 flex justify-between">
<div class="text-2xl font-bold" x-text="menu.name"></div>
<div class="dropdown dropdown-end dropdown-hover" x-show="(menu.pages.length < pages.length)">
<label tabindex="0" class="btn btn-square btn-sm">
<i class=" text-2xl ph ph-list-plus"></i>
</label>
<ul tabindex="0" class="dropdown-content menu p-2 shadow bg-base-100 rounded-box w-52 z-10">
<template x-for="page in pages.filter(p=> !menu.pages.map(m=>m.id).includes(p.id))">
<li>
<a href="javascript:void(0)" @click="menu.pages.push(page)">
<span x-text="page.id" class="mr-3 font-bold"></span>
<span x-text="page.title"></span>
</a>
</li>
</template>
</ul>
</div>
</div>
<input type="hidden" :name="menu.name" :value="menu.pages.map(p=>p.id).join(',')">
<table class="table table-zebra w-full">
<thead>
<tr>
<th class="w-5">ID</th>
<th class="w-5/12"><?= phpb_trans('website-manager.name') ?></th>
<th><?= phpb_trans('website-manager.route') ?></th>
<th class="w-36"><?= phpb_trans('website-manager.actions') ?></th>
</tr>
</thead>
<tbody>
<template x-for="(page, index) in menu.pages">
<tr>
<th x-text="page.id"></th>
<td x-text="page.title"></td>
<td x-text="page.route"></td>
<td>
<button type="button" @click.stop.prevent="arraymove(menu.pages,index,index-1)" class="btn btn-outline btn-circle btn-sm" :disabled="index === 0">
<i class="ph-duotone ph-arrow-fat-up text-xl"></i>
</button>
<button type="button" @click.stop.prevent="arraymove(menu.pages,index,index+1)" class="btn btn-outline btn-circle btn-sm" :disabled="index === menu.pages.length - 1">
<i class="ph-duotone ph-arrow-fat-down text-xl"></i>
</button>
<button @click.stop.prevent="arraymove(menu.pages,index)" class="btn btn-outline btn-circle btn-error btn-sm">
<i class="ph-duotone ph-trash text-xl"></i>
</button>
</td>
</tr>
</template>
</tbody>
</table>
</div>
</template>
</div>
<div class="text-center mt-8">
<button class="btn btn-primary">
<?= phpb_trans('website-manager.save-menus'); ?>
</button>
</div>
</div>
</form>
<script>
function arraymove(arr, fromIndex, toIndex = false) {
console.log(arr)
const element = arr[fromIndex];
arr.splice(fromIndex, 1);
if(toIndex !== false){
arr.splice(toIndex, 0, element);
}
}
</script>
@@ -0,0 +1,66 @@
<?php
if (phpb_flash('message')):
?>
<div class="alert alert-<?= phpb_flash('message-type') ?> mb-6">
<i class="text-xl ph-duotone ph-info"></i>
<span><?= phpb_flash('message') ?></span>
</div>
<?php
endif;
?>
<table class="table table-zebra w-full">
<thead>
<tr>
<th class="w-5">ID</th>
<th><?= phpb_trans('website-manager.name') ?></th>
<th><?= phpb_trans('website-manager.route') ?></th>
<th class="w-44"><?= phpb_trans('website-manager.actions') ?></th>
</tr>
</thead>
<tbody>
<?php
foreach ($pages as $page):
?>
<tr>
<td>
<?= phpb_e($page->getId()) ?>
</td>
<td>
<?= phpb_e($page->getName()) ?>
</td>
<td>
<div class="hidden pl-4 pl-8"></div>
<div class="pl-<?= phpb_e((count(explode('/', $page->getRoute()))-2)*4) ?>">
<?= phpb_e($page->getRoute()) ?>
</div>
</td>
<td class="actions">
<a href="<?= phpb_e(phpb_full_url($page->getRoute())) ?>" title="<?= phpb_trans('website-manager.view') ?>" target="_blank" class="btn btn-light btn-outline btn-sm btn-circle">
<i class="text-xl ph-duotone ph-eye"></i>
</a>
<a href="<?= phpb_url('pagebuilder', ['page' => $page->getId()]) ?>" class="btn btn-primary btn-sm btn-circle" title="<?= phpb_trans('website-manager.edit') ?>">
<i class="text-xl ph-duotone ph-pencil-line"></i>
</a>
<a href="<?= phpb_url('website_manager', ['route' => 'page_settings', 'action' => 'edit', 'page' => $page->getId()]) ?>" title="<?= phpb_trans('website-manager.settings') ?>" class="btn btn-secondary btn-sm btn-circle">
<i class="text-xl ph-duotone ph-gear"></i>
</a>
<a href="<?= phpb_url('website_manager', ['route' => 'page_settings', 'action' => 'destroy', 'page' => $page->getId()]) ?>" title="<?= phpb_trans('website-manager.remove') ?>" class="btn btn-error btn-sm btn-circle">
<i class="text-xl ph-duotone ph-trash"></i>
</a>
</td>
</tr>
<?php
endforeach;
?>
</tbody>
</table>
<div class="text-center mt-8">
<a href="<?= phpb_url('website_manager', ['route' => 'page_settings', 'action' => 'create']) ?>" class="btn btn-primary">
<?= phpb_trans('website-manager.add-new-page') ?>
</a>
</div>
@@ -0,0 +1,99 @@
<?php
use Plugi\Extensions;
$settingIns = phpb_instance('setting');
?>
<form method="post" action="<?= phpb_url('website_manager', ['route' => 'settings', 'action' => 'update', 'tab' => 'settings']) ?>">
<div class="max-w-lg mx-auto text-center">
<?php
if (phpb_flash('message')):
?>
<div class="alert alert-<?= phpb_flash('message-type') ?> mb-6">
<i class="text-xl ph-duotone ph-info"></i>
<span><?= phpb_flash('message') ?></span>
</div>
<?php
endif;
?>
<div class="form-control w-full mb-6">
<label for="languages" class="label">
<span class="label-text"><?= phpb_trans('website-manager.website-languages') ?></span>
</label>
<select class="select select-bordered w-full" id="languages" name="languages[]" title="<?= phpb_trans('website-manager.languages-selector-placeholder') ?>" required multiple>
<?php
foreach (phpb_trans('languages') as $locale => $localeText):
?>
<option value="<?= phpb_e($locale) ?>" <?= phpb_e($settingIns::has('languages', $locale)) ? 'selected' : '' ?>><?= phpb_e($localeText) ?></option>
<?php
endforeach;
?>
</select>
</div>
<div class="flex flex-col gap-6">
<?php
foreach (Extensions::getConfigs() as $extKey => $config):
if(count(Extensions::getSettings($extKey)) === 0){
continue;
}
?>
<details class="collapse collapse-plus bg-base-200">
<summary class="collapse-title text-xl font-medium"><?= phpb_e($config['title']) ?></summary>
<div class="collapse-content">
<div class="">
<?php
foreach (Extensions::getSettings($extKey) as $setting):
?>
<?php
if ($setting['type'] === 'text'):
?>
<div class="form-control w-full">
<label class="label">
<span class="label-text"><?= phpb_e($setting['label'] ?: $setting['name']) ?></span>
</label>
<input type="text" name="<?= phpb_e($setting['key']) ?>" value="<?= phpb_e($setting['value']) ?>" class="input input-bordered w-full" />
</div>
<?php
endif;
?>
<?php
if ($setting['type'] === 'toggle'):
?>
<div class="form-control" x-data="{state: <?= phpb_e($setting['value']) ?>}">
<label class="label cursor-pointer">
<span class="label-text"><?= phpb_e($setting['label'] ?: $setting['name']) ?></span>
<input type='hidden' :value="state" name="<?= phpb_e($setting['key']) ?>">
<input type="checkbox" class="toggle" x-model="state" />
</label>
</div>
<?php
endif;
?>
<?php
endforeach;
?>
</div>
</div>
</details>
<?php
endforeach;
?>
</div>
<button class="btn btn-primary mt-8">
<?= phpb_trans('website-manager.save-settings'); ?>
</button>
<!-- <div class="mt-8">-->
<!-- --><?php //= phpb_trans('website-manager.pagebuilder-block-images') ?>
<!-- </div>-->
<!-- <a href="--><?php //= phpb_url('website_manager', ['route' => 'settings', 'action' => 'renderBlockThumbs']) ?><!--" class="btn btn-secondary btn-sm mr-1">-->
<!-- --><?php //= phpb_trans('website-manager.render-thumbs') ?>
<!-- </a>-->
</div>
</form>
@@ -0,0 +1,10 @@
<div id="welcome-page">
<h1 class="text-center">Welcome to Plugi Page Builder</h1>
<div class="text-center intro-links">
<a href="<?= phpb_url('website_manager') ?>">Get started</a>
<a href="https://github.com/deepDiverPaul/plugi" target="_blank"><i class="fab fa-github"></i> Visit GitHub</a>
</div>
</div>
+188
View File
@@ -0,0 +1,188 @@
<?php
namespace Plugi;
use Plugi\Contracts\PageContract;
use Plugi\Repositories\PageTranslationRepository;
class Page implements PageContract
{
/**
* @var array|null $attributes
*/
protected $attributes;
/**
* @var array|null $translations
*/
protected $translations;
/**
* Set the data stored for this page.
*
* @param array|null $data
* @param bool $fullOverwrite whether to fully overwrite or extend existing data
*/
public function setData($data, $fullOverwrite = true)
{
// if page builder data is set, try to decode json
if (isset($data['data']) && is_string($data['data'])) {
$data['data'] = json_decode($data['data'], true);
}
if ($fullOverwrite) {
$this->attributes = $data;
} elseif (is_array($data)) {
$this->attributes = is_null($this->attributes) ? [] : $this->attributes;
foreach ($data as $key => $value) {
$this->attributes[$key] = $value;
}
}
}
/**
* Set the translation data of this page.
*
* @param $translationData
*/
public function setTranslations($translationData)
{
$this->translations = $translationData;
}
/**
* Return all data stored for this page (page builder data and other data set via setData).
*
* @return array|null
*/
public function getData()
{
return $this->attributes;
}
/**
* Return the page builder data stored for this page.
*
* @return array|null
*/
public function getBuilderData()
{
return $this->attributes['data'] ?? [];
}
/**
* Return the id of this page.
*
* @return string
*/
public function getId()
{
return $this->get('id');
}
/**
* Return the name of this page.
*
* @return string
*/
public function getName()
{
return $this->get('name');
}
/**
* Return the layout (file name) of this page.
*
* @return string
*/
public function getLayout()
{
return $this->get('layout');
}
/**
* Return the translated settings of this page.
*
* @return array
*/
public function getTranslations()
{
if (is_null($this->translations)) {
$records = (new PageTranslationRepository)->findWhere(phpb_config('page.translation.foreign_key'), $this->getId());
$translations = [];
foreach ($records as $record) {
if (in_array($record->locale, array_keys(phpb_active_languages()))) {
$translations[$record->locale] = (array) $record;
}
}
$this->translations = $translations;
}
return $this->translations;
}
/**
* Return the given language dependant setting for this page, in the current or in the given language.
*
* @param string $setting
* @param string|null $locale
* @return mixed|string|null
*/
public function getTranslation(string $setting, $locale = null)
{
$translations = $this->getTranslations();
if (empty($translations)) {
return null;
}
$locale = $locale ?? phpb_config('general.language');
return $translations[$locale][$setting] ??
$translations['en'][$setting] ??
$translations[array_keys($translations)[0]][$setting] ??
null;
}
/**
* Return the route of this page.
*
* @param string|null $locale
* @return mixed|string|null
*/
public function getRoute($locale = null)
{
$routeTranslation = $this->getTranslation('route', $locale);
foreach (phpb_route_parameters() as $routeParameter => $value) {
$routeTranslation = str_replace('{' . $routeParameter . '}', $value, $routeTranslation);
}
return $routeTranslation;
}
/**
* Get the value of the given property of this Page.
*
* @param $property
* @return mixed|null
*/
public function get($property)
{
if (property_exists($this, $property)) {
return $this->$property;
}
if ($this->attributes && is_array($this->attributes)) {
return $this->attributes[$property] ?? null;
}
return null;
}
/**
* Invalidate all cached variants of this page.
*/
public function invalidateCache()
{
$cache = phpb_instance('cache');
foreach ($this->getTranslations() as $locale => $translationData) {
$languageRoute = $this->getRoute($locale);
$cache->invalidate($languageRoute);
}
}
}
+22
View File
@@ -0,0 +1,22 @@
<?php
namespace Plugi;
use Plugi\Contracts\PageContract;
use Plugi\Contracts\PageTranslationContract;
use Plugi\Repositories\PageRepository;
#[\AllowDynamicProperties]
class PageTranslation implements PageTranslationContract
{
/**
* Return the page this translation belongs to.
*
* @return PageContract
*/
public function getPage()
{
$foreignKey = phpb_config('page.translation.foreign_key');
return (new PageRepository)->findWithId($this->{$foreignKey});
}
}
+567
View File
@@ -0,0 +1,567 @@
<?php
namespace Plugi;
use DirectoryIterator;
use Plugi\Contracts\AuthContract;
use Plugi\Contracts\PageContract;
use Plugi\Contracts\PageTranslationContract;
use Plugi\Contracts\WebsiteManagerContract;
use Plugi\Contracts\PageBuilderContract;
use Plugi\Contracts\RouterContract;
use Plugi\Contracts\ThemeContract;
use Plugi\Modules\GrapesJS\PageRenderer;
use Plugi\Repositories\UploadRepository;
use Plugi\Core\DB;
use Plugi\Extensions;
class Plugi
{
/**
* @var AuthContract $auth
*/
protected $auth;
/**
* @var WebsiteManagerContract $websiteManager
*/
protected $websiteManager;
/**
* @var PageBuilderContract $pageBuilder
*/
protected $pageBuilder;
/**
* @var RouterContract $router
*/
protected $router;
/**
* @var ThemeContract $theme
*/
protected $theme;
/**
* Plugi constructor.
*
* @param array|null $config configuration in the format defined in config/config.example.php
*/
public function __construct($config = [])
{
// do nothing if no config is provided (e.g. during composer install)
if (empty($config)) {
return;
}
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
// if flash session data is set, set global session flash data and remove data
if (isset($_SESSION['phpb_flash'])) {
global $phpb_flash;
$phpb_flash = $_SESSION['phpb_flash'];
unset($_SESSION['phpb_flash']);
}
$this->setConfig($config);
// create database connection, if enabled
if (phpb_config('storage.use_database')) {
$this->setDatabaseConnection(phpb_config('storage.database'));
}
// init the default authentication, if enabled
if (phpb_config('auth.use_login')) {
$this->auth = phpb_instance('auth');
}
// init the default website manager, if enabled
if (phpb_config('website_manager.use_website_manager')) {
$this->websiteManager = phpb_instance('website_manager');
}
// init the default page builder, active theme and page router
$this->pageBuilder = phpb_instance('pagebuilder');
$this->theme = phpb_instance('theme', [
phpb_config('theme'),
phpb_config('theme.active_theme')
]);
$this->router = phpb_instance('router');
// load translations in the language that is currently active
$this->loadTranslations(phpb_current_language());
// load extensions
$this->loadExtensions();
}
/**
* Load translations of the given language into a global variable.
*
* @param $language
* @return array
*/
public function loadTranslations($language)
{
global $phpb_translations;
$phpbLanguageFile = __DIR__ . '/../lang/' . $language . '.php';
if (! file_exists($phpbLanguageFile)) {
$phpbLanguageFile = __DIR__ . '/../lang/en.php';
}
$phpb_translations = require $phpbLanguageFile;
// load default and current language translations of the current theme
$themeTranslationsFolder = phpb_config('theme.folder') . '/' . phpb_config('theme.active_theme') . '/translations';
if (file_exists($themeTranslationsFolder . '/en.php')) {
$phpb_translations = array_merge($phpb_translations, require $themeTranslationsFolder . '/en.php');
}
if (file_exists($themeTranslationsFolder . '/' . $language . '.php')) {
$phpb_translations = array_merge($phpb_translations, require $themeTranslationsFolder . '/' . $language . '.php');
}
return $phpb_translations;
}
/**
* Load extensions into a global variable.
*
* @return void
*/
public function loadExtensions()
{
if (file_exists('extensions') && is_dir('extensions')) {
$extensionsDirectory = new DirectoryIterator('extensions');
foreach ($extensionsDirectory as $entry) {
$extKey = $entry->getFilename();
$extensionFile = 'extensions/' . $extKey . '/extension.php';
$configFile = 'extensions/' . $extKey . '/config.php';
if ($entry->isDir() && ! $entry->isDot() && file_exists($extensionFile) && file_exists($configFile)) {
require $extensionFile;
$extConfig = include($configFile);
Extensions::registerConfig($extKey, $extConfig);
if(array_key_exists('settings', $extConfig) && is_array($extConfig['settings'])){
Extensions::addSettings(array_map(function ($setting) use($extKey){
$setting['key'] = 'ext--' . $extKey . '--' . $setting['name'];
return $setting;
}, $extConfig['settings']));
}
}
}
}
}
/**
* Set the Plugi configuration to the given array.
*
* @param array $config
*/
public function setConfig(array $config)
{
global $phpb_config;
$phpb_config = $config;
}
/**
* Set the Plugi database connection using the given array.
*
* @param array $config
*/
public function setDatabaseConnection(array $config)
{
global $phpb_db;
$phpb_db = new DB($config);
}
/**
* Set a custom auth.
*
* @param AuthContract $auth
*/
public function setAuth(AuthContract $auth)
{
$this->auth = $auth;
}
/**
* Set a custom website manager.
*
* @param WebsiteManagerContract $websiteManager
*/
public function setWebsiteManager(WebsiteManagerContract $websiteManager)
{
$this->websiteManager = $websiteManager;
}
/**
* Set a custom PageBuilder.
*
* @param PageBuilderContract $pageBuilder
*/
public function setPageBuilder(PageBuilderContract $pageBuilder)
{
$this->pageBuilder = $pageBuilder;
}
/**
* Set a custom router.
*
* @param RouterContract $router
*/
public function setRouter(RouterContract $router)
{
$this->router = $router;
}
/**
* Set a custom theme.
*
* @param ThemeContract $theme
*/
public function setTheme(ThemeContract $theme)
{
$this->theme = $theme;
if (isset($this->pageBuilder)) {
$this->pageBuilder->setTheme($theme);
}
}
/**
* Return the Auth instance of this Plugi.
*
* @return AuthContract
*/
public function getAuth()
{
return $this->auth;
}
/**
* Return the WebsiteManager instance of this Plugi.
*
* @return WebsiteManagerContract
*/
public function getWebsiteManager()
{
return $this->websiteManager;
}
/**
* Return the PageBuilder instance of this Plugi.
*
* @return PageBuilderContract
*/
public function getPageBuilder()
{
return $this->pageBuilder;
}
/**
* Return the Router instance of this Plugi.
*
* @return RouterContract
*/
public function getRouter()
{
return $this->router;
}
/**
* Return the Theme instance of this Plugi.
*
* @return ThemeContract
*/
public function getTheme()
{
return $this->theme;
}
/**
* Process the current GET or POST request and redirect or render the requested page.
*
* @param string|null $action
* @return bool
*/
public function handleRequest($action = null)
{
$route = $route ?? $_GET['route'] ?? null;
$action = $action ?? $_GET['action'] ?? null;
if (! phpb_config('auth.use_login') || ! phpb_config('website_manager.use_website_manager')) {
die('The Plugi Authentication module is disabled, but no alternative has been implemented (you are still calling the standard handleRequest() method).<br>'
. 'Implement a piece of code that checks whether the user is logged in. If logged in, call handleAuthenticatedRequest() or else call handlePublicRequest().');
}
// handle login and logout requests
$this->auth->handleRequest($action);
// handle website manager requests
if (phpb_in_module('website_manager')) {
$this->auth->requireAuth();
$this->websiteManager->handleRequest($route, $action);
header("HTTP/1.1 404 Not Found");
die('Plugi WebsiteManager page not found');
}
// handle page builder requests
if (phpb_in_module('pagebuilder')) {
$this->auth->requireAuth();
phpb_set_in_editmode();
$this->pageBuilder->handleRequest($route, $action);
header("HTTP/1.1 404 Not Found");
die('Plugi PageBuilder page not found');
}
// handle all requests that do not need authentication
if ($this->handlePublicRequest()) {
return true;
}
if (phpb_current_relative_url() === '/') {
$this->websiteManager->renderWelcomePage();
return true;
}
header("HTTP/1.1 404 Not Found");
die('Plugi page not found. Check your URL: <b>' . phpb_e(phpb_full_url(phpb_current_relative_url())) . '</b>');
}
/**
* Handle public requests, allowed without any authentication.
*
* @return bool
*/
public function handlePublicRequest()
{
// if we are on the URL of an upload, return uploaded file
// (note: this is a fallback option used if .htaccess does not whitelist direct access to the /uploads folder.
// allowing direct /uploads access via .htaccess is preferred since it gives faster loading time)
if (strpos(phpb_current_relative_url(), phpb_config('general.uploads_url') . '/') === 0) {
$this->handleUploadedFileRequest();
header("HTTP/1.1 404 Not Found");
exit();
}
// if we are on the URL of a Plugi asset, return the asset
if (strpos(phpb_current_relative_url(), phpb_config('general.assets_url') . '/') === 0) {
$this->handlePageBuilderAssetRequest();
header("HTTP/1.1 404 Not Found");
exit();
}
// try to find page in cache
$cache = phpb_instance('cache');
if (phpb_config('cache.enabled') &&
! isset($_GET['ignore_cache']) &&
! isset($_GET['refresh_cache']) &&
! isset($_COOKIE['ignore_cache']) &&
PageRenderer::canBeCached()
) {
$cachedContent = $cache->getForUrl(phpb_current_relative_url());
if ($cachedContent) {
echo $cachedContent;
return true;
}
}
if(Extensions::getRoute(phpb_current_relative_url())){
$ext = include Extensions::getRoutes()[phpb_current_relative_url()];
if($ext !== 'continue'){
return true;
}
}
// let the page router resolve the current URL
$page = null;
$pageTranslation = $this->resolvePageLanguageVariantFromUrl(phpb_current_relative_url());
if ($pageTranslation) {
$page = $pageTranslation->getPage();
}
// if the URL cannot be resolved, but the lowercase version of the URL can be resolved, redirect to the lowercase URL
if (($page->logic ?? '') === 'page-not-found' && phpb_current_relative_url() !== strtolower(phpb_current_relative_url())) {
$pageLowerCaseUrlTranslation = $this->resolvePageLanguageVariantFromUrl(strtolower(phpb_current_relative_url()));
if ($pageLowerCaseUrlTranslation) {
$pageLowerCaseUrl = $pageLowerCaseUrlTranslation->getPage();
if (($pageLowerCaseUrl->logic ?? '') !== 'page-not-found') {
header("HTTP/1.1 301 Moved Permanently");
header("Location: " . strtolower(phpb_current_relative_url()));
exit();
}
}
}
// render page if resolved
if ($page) {
$renderedContent = $this->pageBuilder->renderPage($page, $pageTranslation->locale);
if (strpos($pageTranslation->route, '/*') === false) {
$this->cacheRenderedPage($renderedContent);
}
echo $renderedContent;
return true;
}
return false;
}
/**
* Resolve a PageTranslation from the given URL.
*
* @param $url
* @return PageTranslationContract|null
*/
protected function resolvePageLanguageVariantFromUrl($url)
{
$pageTranslation = $this->router->resolve($url);
if ($pageTranslation instanceof PageTranslationContract) {
return $pageTranslation;
}
return null;
}
/**
* Cache the rendered page contents, if caching is enabled and the current page does not contain non-cacheable blocks.
*
* @param string $renderedContent
*/
protected function cacheRenderedPage(string $renderedContent)
{
if (! phpb_config('cache.enabled') || ! PageRenderer::canBeCached() || isset($_GET['ignore_cache'])) {
return;
}
// allow a forced cached page refresh, stored for the current URL but without the refresh parameter
$url = phpb_current_relative_url();
$url = str_replace('?refresh_cache&', '?', $url);
$url = str_replace('?refresh_cache', '', $url);
$url = str_replace('&refresh_cache', '', $url);
$cache = phpb_instance('cache');
$cache->storeForUrl($url, $renderedContent, phpb_static(PageRenderer::class)::getCacheLifetime());
}
/**
* Handle authenticated requests, this method assumes you have checked that the user is currently logged in.
*
* @param string|null $route
* @param string|null $action
*/
public function handleAuthenticatedRequest($route = null, $action = null)
{
$route = $route ?? $_GET['route'] ?? null;
$action = $action ?? $_GET['action'] ?? null;
// handle website manager requests
if (phpb_config('website_manager.use_website_manager') && phpb_in_module('website_manager')) {
$this->websiteManager->handleRequest($route, $action);
header("HTTP/1.1 404 Not Found");
exit();
}
// handle page builder requests
if (phpb_in_module('pagebuilder')) {
phpb_set_in_editmode();
$this->pageBuilder->handleRequest($route, $action);
header("HTTP/1.1 404 Not Found");
exit();
}
}
/**
* Handle uploaded file requests.
*/
public function handleUploadedFileRequest()
{
// get the requested file by stripping the configured uploads_url prefix from the current request URI
$file = substr(phpb_current_relative_url(), strlen(phpb_config('general.uploads_url')) + 1);
// $file is in the format {file id}/{file name}.{file extension}, so get file id as the part before /
$fileId = explode('/', $file)[0];
if (empty($fileId)) {
header("HTTP/1.1 404 Not Found");
exit();
}
$uploadRepository = new UploadRepository;
$uploadedFile = $uploadRepository->findWhere('public_id', $fileId);
if (! $uploadedFile) {
header("HTTP/1.1 404 Not Found");
exit();
}
$uploadedFile = $uploadedFile[0];
$serverFile = realpath(phpb_config('storage.uploads_folder') . '/' . $uploadedFile->server_file);
// add backwards compatibility for files uploaded with Plugi <= v0.12.0, stored as /uploads/{id}.{extension}
if (! $serverFile) $serverFile = realpath(phpb_config('storage.uploads_folder') . '/' . basename($uploadedFile->server_file));
if (! $serverFile) {
header("HTTP/1.1 404 Not Found");
exit();
}
header('Content-Type: ' . $uploadedFile->mime_type);
header('Content-Disposition: inline; filename="' . basename($uploadedFile->original_file) . '"');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Length: ' . filesize($serverFile));
readfile($serverFile);
exit();
}
/**
* Handle page builder asset requests.
*/
public function handlePageBuilderAssetRequest()
{
// get asset file path by stripping the configured assets_url prefix from the current request URI
$asset = substr(phpb_current_relative_url(), strlen(phpb_config('general.assets_url')) + 1);
$asset = explode('?', $asset)[0];
$distPath = realpath(__DIR__ . '/../dist/');
$requestedFile = realpath($distPath . '/' . $asset);
if (! $requestedFile) {
header("HTTP/1.1 404 Not Found");
exit();
}
// prevent path traversal by ensuring the requested file is inside the dist folder
if (strpos($requestedFile, $distPath) !== 0) {
header("HTTP/1.1 404 Not Found");
exit();
}
// only allow specific extensions
$ext = pathinfo($requestedFile, PATHINFO_EXTENSION);
if (! in_array($ext, ['js', 'css', 'jpg', 'png', 'svg'])) {
header("HTTP/1.1 404 Not Found");
exit();
}
$contentTypes = [
'js' => 'application/javascript; charset=utf-8',
'css' => 'text/css; charset=utf-8',
'png' => 'image/png',
'jpg' => 'image/jpeg',
'svg' => 'image/svg+xml'
];
header('Content-Type: ' . $contentTypes[$ext]);
header('Content-Disposition: inline; filename="' . basename($requestedFile) . '"');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Length: ' . filesize($requestedFile));
readfile($requestedFile);
exit();
}
/**
* Render the PageBuilder.
*
* @param PageContract $page
*/
public function renderPageBuilder(PageContract $page)
{
phpb_set_in_editmode();
$this->pageBuilder->renderPageBuilder($page);
}
}
@@ -0,0 +1,244 @@
<?php
namespace Plugi\Repositories;
use Plugi\Core\DB;
/**
* Class BaseRepository
*
* The base repository passes CRUD calls to DB and initialises class instances for records returned from DB.
*
* @package Plugi\Repositories
*/
class BaseRepository
{
/**
* @var DB $db
*/
protected $db;
/**
* The database table of this repository.
* Note: do not replace this value with user input.
*
* @var string
*/
protected $table;
/**
* The class that represents each record of this repository's table.
*
* @var string
*/
protected $class;
/**
* Repository constructor.
*/
public function __construct()
{
global $phpb_db;
$this->db = $phpb_db;
// apply the configured prefix to the table set in the superclass and remove non-alphanumeric characters
$this->table = phpb_config('storage.database.prefix') . $this->removeNonAlphaNumeric($this->table);
}
/**
* Create a new instance using the given data.
*
* @param array $data
* @return object|null
*/
protected function create(array $data)
{
$columns = array_keys($data);
foreach ($columns as &$column) {
$column = $this->removeNonAlphaNumeric($column);
}
$columns = implode(', ', $columns);
$questionMarks = implode(', ', array_fill(0, sizeof($data), '?'));
$this->db->query(
"INSERT INTO {$this->table} ({$columns}) VALUES ({$questionMarks})",
array_values($data)
);
$id = $this->db->lastInsertId();
if ($id) {
return $this->findWithId($id);
}
return null;
}
/**
* Update the record with the given id with the given updated data.
*
* @param $instance
* @param array $data
* @return bool
*/
protected function update($instance, array $data)
{
$set = '';
foreach ($data as $column => $value) {
if ($set !== '') {
$set .= ', ';
}
$set .= $this->removeNonAlphaNumeric($column) . '=?';
}
$values = array_values($data);
$values[] = $instance->id ?? $instance->getId();
return $this->db->query(
"UPDATE {$this->table} SET {$set} WHERE id=?",
$values
);
}
/**
* Remove the given instance from the database.
*
* @param $id
* @return bool
*/
public function destroy($id)
{
return $this->db->query(
"DELETE FROM {$this->table} WHERE id=?",
[$id]
);
}
/**
* Remove all instances from the database that satisfy the given condition.
*
* @param string $column
* @param $value
* @return bool
*/
public function destroyWhere(string $column, $value)
{
$column = $this->removeNonAlphaNumeric($column);
return $this->db->query(
"DELETE FROM {$this->table} WHERE {$column}=?",
[$value]
);
}
/**
* Remove all instances from the database.
*
* @return bool
*/
public function destroyAll()
{
return $this->db->query(
"DELETE FROM {$this->table}"
);
}
/**
* Return an array of all pages.
*
* @param array|string $columns
* @return array
*/
public function getAll($columns = '*')
{
if (is_array($columns)) {
foreach ($columns as &$column) {
$column = $this->removeNonAlphaNumeric($column);
}
}
return $this->createInstances($this->db->all($this->table, $columns));
}
/**
* Return the instance with the given id, or null.
*
* @param string $id
* @return object|null
*/
public function findWithId($id)
{
return $this->createInstance($this->db->findWithId($this->table, $id));
}
/**
* Return the instances for which the given condition holds.
*
* @param string $column do NOT pass user input here
* @param string $value
* @return array
*/
public function findWhere($column, $value)
{
$column = $this->removeNonAlphaNumeric($column);
return $this->createInstances($this->db->select(
"SELECT * FROM {$this->table} WHERE {$column} = ?",
[$value]
));
}
/**
* Remove any non-alphanumeric characters.
*
* @param string $string
* @return string|null
*/
protected function removeNonAlphaNumeric(string $string)
{
return preg_replace('/\W*/', '', $string);
}
/**
* Create an instance using the first record.
*
* @param array $records
* @return object|null
*/
protected function createInstance(array $records)
{
$instances = $this->createInstances($records);
if (empty($instances)) {
return null;
}
return $instances[0];
}
/**
* For each record create an instance.
*
* @param array $records
* @return array
*/
protected function createInstances(array $records)
{
$result = [];
if (empty($this->class)) {
return $records;
}
foreach ($records as $record) {
$instance = new $this->class;
if (method_exists($instance, 'setData')) {
$data = [];
foreach($record as $k => $v) {
$data[$k] = $v;
}
$instance->setData($data);
} else {
foreach($record as $k => $v) {
$instance->$k = $v;
}
}
$result[] = $instance;
}
return $result;
}
}
@@ -0,0 +1,83 @@
<?php
namespace Plugi\Repositories;
use Plugi\Contracts\MenuRepositoryContract;
class MenuRepository extends BaseRepository implements MenuRepositoryContract
{
/**
* The pages database table.
*
* @var string
*/
protected $table = 'menus';
/**
* Replace all website menus by the given data.
*
* @param array $data
* @return bool|object|null
*/
public function updateMenus(array $data)
{
$this->destroyAll();
foreach ($data as $key => $value) {
$this->create([
'name' => $key,
'pages' => $value,
]);
}
return true;
}
/**
* Get one hydrated menu with the given name.
*
* @param string $name
* @return array|null
*/
public function getHydratedMenu(string $name)
{
$pageRepository = new PageRepository;
$pages = $pageRepository->getAll();
$menu = $this->findWhere('name', $name)[0];
$menuPages = explode(',',$menu['pages']);
$hyMenuPages = [];
foreach ($pages as $page) {
$key = array_search($page->getId(), $menuPages);
if($key === false) continue;
$hyMenuPages[$key] = [
'id' => $page->getId(),
'title' => $page->getName(),
'route' => $page->getRoute()
];
}
ksort($hyMenuPages);
$hyMenu = [
'name' => $menu['name'],
'pageIds' => $menu['pages'],
'pages' => $hyMenuPages,
];
return $hyMenu;
}
/**
* Get all hydrated menus with the given name.
*
* @return array
*/
public function getHydratedMenus()
{
$menus = [];
foreach ($this->getAll() as $entry){
$menus[] = $this->getHydratedMenu($entry['name']);
}
return $menus;
}
}
@@ -0,0 +1,147 @@
<?php
namespace Plugi\Repositories;
use Plugi\Contracts\PageContract;
use Plugi\Contracts\PageRepositoryContract;
use Exception;
class PageRepository extends BaseRepository implements PageRepositoryContract
{
/**
* The pages database table.
*
* @var string
*/
protected $table;
/**
* The class that represents each page.
*
* @var string
*/
protected $class;
/**
* PageRepository constructor.
*/
public function __construct()
{
$this->table = empty(phpb_config('page.table')) ? 'pages' : phpb_config('page.table');
parent::__construct();
$this->class = phpb_instance('page');
}
/**
* Create a new page.
*
* @param array $data
* @return bool|object|null
* @throws Exception
*/
public function create(array $data)
{
foreach (['name', 'layout'] as $field) {
if (! isset($data[$field]) || ! is_string($data[$field])) {
return false;
}
}
$page = parent::create([
'name' => $data['name'],
'layout' => $data['layout'],
]);
if (! ($page instanceof PageContract)) {
throw new Exception("Page not of type PageContract");
}
return $this->replaceTranslations($page, $data);
}
/**
* Update the given page with the given updated data.
*
* @param $page
* @param array $data
* @return bool|object|null
*/
public function update($page, array $data)
{
foreach (['name', 'layout'] as $field) {
if (! isset($data[$field]) || ! is_string($data[$field])) {
return false;
}
}
$this->replaceTranslations($page, $data);
$updateResult = parent::update($page, [
'name' => $data['name'],
'layout' => $data['layout'],
]);
$page->invalidateCache();
return $updateResult;
}
/**
* Replace the translations of the given page by the given data.
*
* @param PageContract $page
* @param array $data
* @return bool
*/
protected function replaceTranslations(PageContract $page, array $data)
{
$activeLanguages = phpb_active_languages();
foreach (['title', 'meta_title', 'meta_description', 'route'] as $field) {
foreach ($activeLanguages as $languageCode => $languageTranslation) {
if (! isset($data[$field][$languageCode])) {
return false;
}
}
}
$pageTranslationRepository = new PageTranslationRepository;
$pageTranslationRepository->destroyWhere(phpb_config('page.translation.foreign_key'), $page->getId());
foreach ($activeLanguages as $languageCode => $languageTranslation) {
$pageTranslationRepository->create([
phpb_config('page.translation.foreign_key') => $page->getId(),
'locale' => $languageCode,
'title' => $data['title'][$languageCode],
'meta_title' => $data['meta_title'][$languageCode],
'meta_description' => $data['meta_description'][$languageCode],
'route' => $data['route'][$languageCode],
]);
}
return true;
}
/**
* Update the given page with the given updated page data.
*
* @param $page
* @param array $data
* @return bool|object|null
*/
public function updatePageData($page, array $data)
{
$updateResult = parent::update($page, [
'data' => json_encode($data),
]);
$page->invalidateCache();
return $updateResult;
}
/**
* Remove the given page from the database.
*
* @param $id
* @return bool
*/
public function destroy($id)
{
$this->findWithId($id)->invalidateCache();
return parent::destroy($id);
}
}
@@ -0,0 +1,32 @@
<?php
namespace Plugi\Repositories;
use Plugi\Contracts\PageTranslationRepositoryContract;
class PageTranslationRepository extends BaseRepository implements PageTranslationRepositoryContract
{
/**
* The page translations database table.
*
* @var string
*/
protected $table;
/**
* The class that represents each page translation.
*
* @var string
*/
protected $class;
/**
* PageTranslationRepository constructor.
*/
public function __construct()
{
$this->table = empty(phpb_config('page.translation.table')) ? 'page_translations' : phpb_config('page.translation.table');
parent::__construct();
$this->class = phpb_instance('page.translation');
}
}
@@ -0,0 +1,41 @@
<?php
namespace Plugi\Repositories;
use Plugi\Contracts\SettingRepositoryContract;
class SettingRepository extends BaseRepository implements SettingRepositoryContract
{
/**
* The pages database table.
*
* @var string
*/
protected $table = 'settings';
/**
* Replace all website settings by the given data.
*
* @param array $data
* @return bool|object|null
*/
public function updateSettings(array $data)
{
$this->destroyAll();
foreach ($data as $key => $value) {
$isArray = is_array($value) ? 1 : 0;
if ($isArray) {
$value = implode(',', $value);
}
$this->create([
'setting' => $key,
'value' => $value,
'is_array' => $isArray,
]);
}
return true;
}
}
@@ -0,0 +1,45 @@
<?php
namespace Plugi\Repositories;
use Plugi\UploadedFile;
class UploadRepository extends BaseRepository
{
/**
* The uploads database table.
*
* @var string
*/
protected $table = 'uploads';
/**
* The class that represents each uploaded file.
*
* @var string
*/
protected $class = UploadedFile::class;
/**
* Create a new uploaded file.
*
* @param array $data
* @return bool|object
*/
public function create(array $data)
{
$fields = ['public_id', 'original_file', 'mime_type', 'server_file'];
foreach ($fields as $field) {
if (! isset($data[$field]) || ! is_string($data[$field])) {
return false;
}
}
return parent::create([
'public_id' => $data['public_id'],
'original_file' => $data['original_file'],
'mime_type' => $data['mime_type'],
'server_file' => $data['server_file'],
]);
}
}
+64
View File
@@ -0,0 +1,64 @@
<?php
namespace Plugi;
use Plugi\Contracts\SettingContract;
use Plugi\Repositories\SettingRepository;
class Setting implements SettingContract
{
protected static $settings;
/**
* Load all settings from database.
*/
protected static function loadSettings()
{
self::$settings = [];
$settingsRepository = new SettingRepository;
foreach ($settingsRepository->getAll() as $setting) {
if ($setting['is_array'] === 1) {
self::$settings[$setting['setting']] = explode(',', $setting['value']);
} else {
self::$settings[$setting['setting']] = $setting['value'];
}
}
}
/**
* Return the value(s) of the given setting.
*
* @param string $key
* @return mixed|array|null
*/
public static function get(string $key)
{
if (is_null(self::$settings)) {
self::loadSettings();
}
if (isset(self::$settings[$key])) {
return self::$settings[$key];
}
return null;
}
/**
* Return whether the given setting exists and has the given value.
*
* @param string $key
* @param string $value
* @return bool
*/
public static function has(string $key, string $value)
{
if (is_null(self::$settings)) {
self::loadSettings();
}
return isset(self::$settings[$key]) && (
(is_array(self::$settings[$key]) && in_array($value, self::$settings[$key])) ||
(! is_array(self::$settings[$key]) && self::$settings[$key] === $value)
);
}
}
+192
View File
@@ -0,0 +1,192 @@
<?php
namespace Plugi;
use DirectoryIterator;
use Plugi\Contracts\ThemeContract;
class Theme implements ThemeContract
{
/**
* @var array $config
*/
protected $config;
/**
* @var string $themeSlug
*/
protected $themeSlug;
/**
* @var array $blocks
*/
protected $blocks;
/**
* @var array $layouts
*/
protected $layouts;
/**
* Theme constructor.
*
* @param array $config
* @param string $themeSlug
*/
public function __construct(array $config, string $themeSlug)
{
$this->config = $config;
$this->themeSlug = $themeSlug;
}
/**
* Load a single block entry
*/
protected function attemptBlockRegistration($entry) {
if ($entry->isDir() && ! $entry->isDot()) {
$blockSlug = $entry->getFilename();
$block = new ThemeBlock($this, $blockSlug);
$isActive = true;
foreach (($block->get('whitelist') ?? []) as $whitelistDomain) {
$isActive = false;
if (strpos(phpb_current_full_url(), $whitelistDomain) !== false) {
$isActive = true;
break;
}
}
if ($isActive) {
$this->blocks[$blockSlug] = $block;
}
}
}
/**
* Load a single extension block entry
*/
protected function attemptExtensionBlockRegistration($slug, $path) {
if ($slug && $path) {
$block = new ThemeBlock($this, $path, true, $slug);
$isActive = true;
foreach (($block->get('whitelist') ?? []) as $whitelistDomain) {
$isActive = false;
if (strpos(phpb_current_full_url(), $whitelistDomain) !== false) {
$isActive = true;
break;
}
}
if ($isActive) {
$this->blocks[$slug] = $block;
}
}
}
/**
* Load a single layout entry
*/
protected function attemptLayoutRegistration($entry) {
if ($entry->isDir() && ! $entry->isDot()) {
$layoutSlug = $entry->getFilename();
$layout = new ThemeLayout($this, $layoutSlug);
$this->layouts[$layoutSlug] = $layout;
}
}
/**
* Load a single layout entry
*/
protected function attemptExtensionLayoutRegistration($slug, $path) {
$layout = new ThemeLayout($this, $path, true, $slug);
$this->layouts[$slug] = $layout;
}
/**
* Load all blocks of the current theme.
*/
protected function loadThemeBlocks()
{
$this->blocks = [];
$folders = [
'',
'/archived',
'/elements',
'/php',
];
foreach ($folders as $folder) {
if (file_exists($this->getFolder() . '/blocks' . $folder)) {
$blocksDirectory = new DirectoryIterator($this->getFolder() . '/blocks' . $folder);
foreach ($blocksDirectory as $entry) {
// skip special subfolders containing blocks
if (in_array('/' . $entry, $folders)) {
continue;
}
$this->attemptBlockRegistration($entry);
}
}
}
foreach (Extensions::getBlocks() as $slug => $path) {
$this->attemptExtensionBlockRegistration($slug, $path);
}
}
/**
* Load all layouts of the current theme.
*/
protected function loadThemeLayouts()
{
$this->layouts = [];
if (file_exists($this->getFolder() . '/layouts')) {
$layoutsDirectory = new DirectoryIterator($this->getFolder() . '/layouts');
foreach ($layoutsDirectory as $entry) {
$this->attemptLayoutRegistration($entry);
}
}
foreach (Extensions::getLayouts() as $slug => $path) {
$this->attemptExtensionLayoutRegistration($slug, $path);
}
}
/**
* Return all blocks of this theme.
*
* @return array array of ThemeBlock instances
*/
public function getThemeBlocks()
{
$this->loadThemeBlocks();
return $this->blocks;
}
/**
* Return all layouts of this theme.
*
* @return array array of ThemeLayout instances
*/
public function getThemeLayouts()
{
$this->loadThemeLayouts();
return $this->layouts;
}
/**
* Return the absolute folder path of the theme passed to this Theme instance.
*
* @return string
*/
public function getFolder()
{
return $this->config['folder'] . '/' . basename($this->themeSlug);
}
}
+365
View File
@@ -0,0 +1,365 @@
<?php
namespace Plugi;
use Plugi\Contracts\ThemeContract;
use Plugi\Modules\GrapesJS\Block\BaseController;
use Plugi\Modules\GrapesJS\Block\BaseModel;
use Plugi\Modules\GrapesJS\PageRenderer;
class ThemeBlock
{
/**
* @var $config
*/
protected $config;
/**
* @var $dynamicConfig
*/
public static $dynamicConfig = [];
/**
* @var ThemeContract $theme
*/
protected $theme;
/**
* @var string $blockSlug
*/
protected $blockSlug;
/**
* @var bool $isExtension
* Determines if a block was registered by an extension.
*/
protected $isExtension;
/**
* @var bool $extensionSlug
* Custom slug in case of extension.
*/
protected $extensionSlug;
/**
* Theme constructor.
*
* @param ThemeContract $theme the theme this block belongs to
* @param string $blockSlug
* @param bool $isExtension
* @param string|null $extensionSlug
*/
public function __construct(ThemeContract $theme, string $blockSlug, bool $isExtension = false, string $extensionSlug = null)
{
$this->theme = $theme;
$this->blockSlug = $blockSlug;
$this->isExtension = $isExtension;
$this->extensionSlug = $extensionSlug;
$this->config = [];
if (file_exists($this->getFolder() . '/config.php')) {
$this->config = require $this->getFolder() . '/config.php';
}
PageRenderer::setCanBeCached(
boolval($this->config['cache'] ?? true),
$this->config['cache_lifetime'] ?? null
);
}
/**
* Return the absolute folder path of this theme block.
*
* @return string
*/
public function getFolder()
{
if ($this->isExtension) {
return $this->blockSlug;
}
$folder = $this->theme->getFolder() . '/blocks/archived/' . basename($this->blockSlug);
if (file_exists($folder)) {
return $folder;
}
$folder = $this->theme->getFolder() . '/blocks/elements/' . basename($this->blockSlug);
if (file_exists($folder)) {
return $folder;
}
$folder = $this->theme->getFolder() . '/blocks/php/' . basename($this->blockSlug);
if (file_exists($folder)) {
return $folder;
}
return $this->theme->getFolder() . '/blocks/' . basename($this->blockSlug);
}
/**
* Return the namespace to the folder of this theme block.
*
* @return string
*/
protected function getNamespace()
{
// return Namespace from the Config file of the Block if it is an extension. Used for Extensions.
if (isset( $this->config['namespace'])) {
return $this->config['namespace'];
}
// return Namespace from Config file if exists;
if (phpb_config('theme.namespace')) {
return phpb_config('theme.namespace');
}
// get namespace from directory structure if not provided:
$themesPath = phpb_config('theme.folder');
$themesFolderName = basename($themesPath);
$blockFolder = $this->getFolder();
$namespacePath = $themesFolderName . str_replace($themesPath, '', $blockFolder);
// convert each character after a - to uppercase
$namespace = implode('-', array_map('ucfirst', explode('-', $namespacePath)));
// convert each character after a _ to uppercase
$namespace = implode('_', array_map('ucfirst', explode('-', $namespace)));
// convert each character after a / to uppercase
$namespace = implode('/', array_map('ucfirst', explode('/', $namespace)));
// remove all dashes
$namespace = str_replace('-', '', $namespace);
// remove all underscores
$namespace = str_replace('_', '', $namespace);
// replace / by \
$namespace = str_replace('/', '\\', $namespace);
return $namespace;
}
/**
* Return the controller class of this theme block.
*
* @return string
*/
public function getControllerClass()
{
if (file_exists($this->getFolder() . '/controller.php')) {
return $this->getNamespace() . '\\Controller';
}
return BaseController::class;
}
/**
* Return the controller file of this theme block.
*
* @return string|null
*/
public function getControllerFile()
{
if (file_exists($this->getFolder() . '/controller.php')) {
return $this->getFolder() . '/controller.php';
}
return null;
}
/**
* Return the model class of this theme block.
*
* @return string
*/
public function getModelClass()
{
if (file_exists($this->getFolder() . '/model.php')) {
return $this->getNamespace() . '\\Model';
}
return BaseModel::class;
}
/**
* Return the model file of this theme block.
*
* @return string|null
*/
public function getModelFile()
{
if (file_exists($this->getFolder() . '/model.php')) {
return $this->getFolder() . '/model.php';
}
return null;
}
/**
* Return the view file of this theme block.
*
* @return string
*/
public function getViewFile()
{
if ($this->isPhpBlock()) {
return $this->getFolder() . '/view.php';
}
return $this->getFolder() . '/view.html';
}
/**
* Return the pagebuilder script file of this theme block.
* This script can be used to assist correct rendering of the block in the pagebuilder.
*
* @return string|null
*/
public function getBuilderScriptFile()
{
if (file_exists($this->getFolder() . '/builder-script.php')) {
return $this->getFolder() . '/builder-script.php';
} elseif (file_exists($this->getFolder() . '/builder-script.html')) {
return $this->getFolder() . '/builder-script.html';
} elseif (file_exists($this->getFolder() . '/builder-script.js')) {
return $this->getFolder() . '/builder-script.js';
}
return $this->getScriptFile();
}
/**
* Return the script file of this theme block.
* This script can be used to assist correct rendering of the block when used on a publicly accessed web page.
*
* @return string|null
*/
public function getScriptFile()
{
if (file_exists($this->getFolder() . '/script.php')) {
return $this->getFolder() . '/script.php';
} elseif (file_exists($this->getFolder() . '/script.html')) {
return $this->getFolder() . '/script.html';
} elseif (file_exists($this->getFolder() . '/script.js')) {
return $this->getFolder() . '/script.js';
}
return null;
}
/**
* Return the file path of the thumbnail of this block.
*
* @return string
*/
public function getThumbPath()
{
$blockThumbsFolder = $this->theme->getFolder() . '/public/block-thumbs/';
return $blockThumbsFolder . md5($this->blockSlug) . '/' . md5(file_get_contents($this->getViewFile())) . '.jpg';
}
public function getThumbUrl()
{
return phpb_theme_asset('block-thumbs/' . md5($this->blockSlug) . '/' . md5(file_get_contents($this->getViewFile())) . '.jpg');
}
/**
* Return the slug identifying this type of block.
*
* @return string
*/
public function getSlug()
{
return (! $this->isExtension) ? $this->blockSlug : $this->extensionSlug;
}
/**
* Return whether this block is a block containing/allowing PHP code.
*
* @return bool
*/
public function isPhpBlock()
{
return file_exists($this->getFolder() . '/view.php');
}
/**
* Return whether this block is a plain html block that does not contain/allow PHP code.
*
* @return bool
*/
public function isHtmlBlock()
{
return (! $this->isPhpBlock());
}
/**
* The wrapper element to be used in the pagebuilder and for carrying style in case this block is a PHP block.
*/
public function getWrapperElement()
{
return $this->config['wrapper'] ?? 'div';
}
/**
* Return configuration with the given key (as dot-separated multidimensional array selector).
*
* @param $key
* @return mixed
*/
public function get($key = null)
{
if (empty($key)) {
return $this->config;
}
// if no dot notation is used, return first dimension value or empty string
if (strpos($key, '.') === false) {
return $this->config[$key] ?? null;
}
// if dot notation is used, traverse config string
$segments = explode('.', $key);
$subArray = $this->config;
foreach ($segments as $segment) {
if (isset($subArray[$segment])) {
$subArray = &$subArray[$segment];
} else {
return null;
}
}
return $subArray;
}
/**
* Replace configuration at the given key (as dot-separated multidimensional array selector) by the given value.
*
* @param $slug
* @param $key
* @param $value
* @return void
*/
public static function set($slug, $key, $value)
{
if (empty($key)) {
self::$dynamicConfig[$slug] = $value;
return;
}
// if no dot notation is used, replace first dimension value or empty string
if (strpos($key, '.') === false) {
self::$dynamicConfig[$slug][$key] = $value;
return;
}
// if dot notation is used, traverse config and replace at the right depth
$segments = explode('.', $key);
$subArray = &self::$dynamicConfig[$slug];
foreach ($segments as $i => $segment) {
if (isset($subArray[$segment])) {
if ($i === count($segments) - 1) {
$subArray[$segment] = $value;
} else {
$subArray = &$subArray[$segment];
}
} else {
return;
}
}
}
/**
* Get all dynamic configuration of the block with the given slug.
*
* @param $slug
* @return mixed
*/
public static function getDynamicConfig($slug)
{
return self::$dynamicConfig[$slug] ?? null;
}
}
+121
View File
@@ -0,0 +1,121 @@
<?php
namespace Plugi;
use Plugi\Contracts\ThemeContract;
class ThemeLayout
{
/**
* @var $config
*/
protected $config;
/**
* @var ThemeContract $theme
*/
protected $theme;
/**
* @var string $layoutSlug
*/
protected $layoutSlug;
/**
* @var bool $isExtension
* Determines if a block was registered by an extension.
*/
protected $isExtension;
/**
* @var bool $extensionSlug
* Custom slug in case of extension.
*/
protected $extensionSlug;
/**
* Theme ThemeLayout.
*
* @param ThemeContract $theme the theme this layout belongs to
* @param string $layoutSlug
*/
public function __construct(ThemeContract $theme, string $layoutSlug, bool $isExtension = false, string $extensionSlug = null)
{
$this->theme = $theme;
$this->layoutSlug = $layoutSlug;
$this->isExtension = $isExtension;
$this->extensionSlug = $extensionSlug;
$this->config = [];
if (file_exists($this->getFolder() . '/config.php')) {
$this->config = include $this->getFolder() . '/config.php';
}
}
/**
* Return the absolute folder path of this theme layout.
*
* @return string
*/
public function getFolder()
{
return (! $this->isExtension) ? ($this->theme->getFolder() . '/layouts/' . $this->layoutSlug) : $this->layoutSlug;
}
/**
* Return the view file of this theme layout.
*
* @return string
*/
public function getViewFile()
{
return $this->getFolder() . '/view.php';
}
/**
* Return the slug identifying this type of layout.
*
* @return string
*/
public function getSlug()
{
return !$this->isExtension ? $this->layoutSlug : $this->extensionSlug;
}
/**
* Return the title of this theme layout.
*
* @return string
*/
public function getTitle()
{
return $this->get('title') ?? ucfirst($this->getSlug());
}
/**
* Return configuration with the given key (as dot-separated multidimensional array selector).
*
* @param $key
* @return mixed|string
*/
public function get($key)
{
// if no dot notation is used, return first dimension value or empty string
if (strpos($key, '.') === false) {
return $this->config[$key] ?? null;
}
// if dot notation is used, traverse config string
$segments = explode('.', $key);
$subArray = $this->config;
foreach ($segments as $segment) {
if (isset($subArray[$segment])) {
$subArray = &$subArray[$segment];
} else {
return null;
}
}
return $subArray;
}
}
+16
View File
@@ -0,0 +1,16 @@
<?php
namespace Plugi;
#[\AllowDynamicProperties]
class UploadedFile
{
/**
* Return the URL of this uploaded file.
*/
public function getUrl()
{
return phpb_full_url(phpb_config('general.uploads_url') . '/' . $this->public_id . '/' . $this->original_file);
}
}