}
$sitemap = simplexml_load_string($this->former_sitemap);
- $sitemap->registerXPathNamespace('s', "http://www.sitemaps.org/schemas/sitemap/0.9");
- foreach ($sitemap->xpath('//s:loc') as $url) {
- $u = parse_url($url);
- $p = trim($u['path'], '/');
- if (!in_array($p, $froms)) {
- $change = true;
- $r[] = ['from' => $p, 'to' => ''];
+ if ($sitemap) {
+ $sitemap->registerXPathNamespace('s', "http://www.sitemaps.org/schemas/sitemap/0.9");
+ foreach ($sitemap->xpath('//s:loc') as $url) {
+ $u = parse_url($url);
+ $p = trim($u['path'], '/');
+ if (!in_array($p, $froms)) {
+ $change = true;
+ $r[] = ['from' => $p, 'to' => ''];
+ }
}
}
if ($change) {
public function onSaved(): bool
{
-
if ($this->publish_on_save) {
- $this->onPublish('auto');
+ $this->onPublish(!file_exists($this->getMirrorPath()) . 'index.html' ? 'force_webflow' : 'auto');
}
return parent::onSaved();
}
$imagesChanged = false;
- foreach ($seo[$mainLocale] as $page) {
+ if (isset($seo[$mainLocale])) {
+ foreach ($seo[$mainLocale] as $page) {
- if ($page['og_title_copied']) {
- $page['og_title'] = $page['seo_title'];
- }
- if ($page['og_description_copied']) {
- $page['og_description'] = $page['seo_description'];
- }
+ if ($page['og_title_copied']) {
+ $page['og_title'] = $page['seo_title'];
+ }
+ if ($page['og_description_copied']) {
+ $page['og_description'] = $page['seo_description'];
+ }
- if (isset($api['seo'][$page['id']]) && $api['seo'][$page['id']]['type'] !== 'page_html' && !$this->_compareArrays($api['seo'][$page['id']], $page)) {
- $api['seo'][$page['id']] = $page;
- $hasChanged = true;
- Webflow::savePageMeta($page);
+ if (isset($api['seo'][$page['id']]) && $api['seo'][$page['id']]['type'] !== 'page_html' && !$this->_compareArrays($api['seo'][$page['id']], $page)) {
+ $api['seo'][$page['id']] = $page;
+ $hasChanged = true;
+ Webflow::savePageMeta($page);
+ }
}
}
- foreach ($images[$mainLocale] as $id => $alt) {
- $apiAlt = $api['images'][$id]['alt'];
- if (str_starts_with($apiAlt, '__wf_')) {
- $apiAlt = '';
- }
- if (null === $alt) {
- $alt = '';
- }
- if ($apiAlt != $alt) {
- start_measure('saveImageAlt ' . $apiAlt . '!=' . $alt);
- $api['images'][$id]['alt'] = $alt;
- Webflow::saveImageAlt($id, $alt);
- $hasChanged = true;
- stop_measure('saveImageAlt ' . $apiAlt . '!=' . $alt);
- }
+ if (isset($images[$mainLocale])) {
- if ($alt) {
- foreach ($locales as $locale) {
- if ($locale === $mainLocale) {
- continue;
- }
- if (!$images[$locale][$id]) {
- $images[$locale][$id] = $translateAPI->translate($alt, $locale, $mainLocale);
- $imagesChanged = true;
- $hasChanged = true;
+ foreach ($images[$mainLocale] as $id => $alt) {
+ $apiAlt = $api['images'][$id]['alt'];
+ if (str_starts_with($apiAlt, '__wf_')) {
+ $apiAlt = '';
+ }
+ if (null === $alt) {
+ $alt = '';
+ }
+ if ($apiAlt != $alt) {
+ start_measure('saveImageAlt ' . $apiAlt . '!=' . $alt);
+ $api['images'][$id]['alt'] = $alt;
+ Webflow::saveImageAlt($id, $alt);
+ $hasChanged = true;
+ stop_measure('saveImageAlt ' . $apiAlt . '!=' . $alt);
+ }
+
+ if ($alt) {
+ foreach ($locales as $locale) {
+ if ($locale === $mainLocale) {
+ continue;
+ }
+ if (!$images[$locale][$id]) {
+ $images[$locale][$id] = $translateAPI->translate($alt, $locale, $mainLocale);
+ $imagesChanged = true;
+ $hasChanged = true;
+ }
}
}
}
$this->saveQuietly();
}
+
}
protected function _compareArrays($a, $b, $params = null)
public function listPages()
{
+ if (!$this->webflow) {
+ return;
+ }
$seo = $this->getEditableData()['seo'];
$res = [];
foreach ($seo as $s) {
protected function compileHTMLFile($f, $relative, $dest, $isMainLocale, $locale, $texts, $images, $seo, $env = 'dev')
{
+
+
$urlmaps = $this->getURLMaps();
$urlmap = $urlmaps[$locale];
$origRelative = $relative;
}
}
+
+
// Replace URL
foreach ($urlmap as $k => $v) {
$html = str_replace(ltrim($k, '/'), ltrim($v, '/'), $html);
}
+ $localeURL = '';
- $localeURL = "<script>";
- foreach ($this->getLocales() as $l) {
- $code = $l['locale'];
- if ($code === $locale) {
- continue;
+ $locales = $this->getLocales();
+ if (count($locales) > 1) {
+ $localeURL .= "<script>";
+ foreach ($locales as $l) {
+ $code = $l['locale'];
+ if ($code === $locale) {
+ continue;
+ }
+ $u = $urlmaps[$code][$origRelative] ?? $origRelative;
+ $d = $l[$env === 'dev' ? 'url' : 'prod'];
+ $localeURL .= 'var SWITCH_URL_' . $code . '="https://' . $d . $u . '";' . "\n";
}
- $u = $urlmaps[$code][$origRelative] ?? $origRelative;
- $d = $l[$env === 'dev' ? 'url' : 'prod'];
- $localeURL .= 'var SWITCH_URL_' . $code . '="https://' . $d . $u . '";' . "\n";
+ $localeURL .= "</script>";
}
- $localeURL .= "</script>";
- $html = str_replace('</head>', '<link href="/css/custom.css" rel="stylesheet">' . "\n" . '</head>', $html);
+ $html = str_replace('</head>', '<link href="/css/custom.css" rel="stylesheet">' ."\n". '</head>', $html);
$html = str_replace('</body>', $localeURL . '<script src="/js/custom.js"></script>' . "\n" . '</body>', $html);
- $html = preg_replace('/\s+lang=\"[a-zA-Z\-_]{2,6}\"/', ' lang="' . $locale . '"', $html);
+
+
+ $html = preg_replace('/\s+lang="[a-zA-Z\-_]{2,6}"/', ' lang="' . $locale . '"', $html);
+
// Texts
foreach ($texts as $text => $translation) {
$html = str_replace('>' . $text . '<', '>' . $translation . '<', $html);
$html = str_replace('>' . $text . ' <', '>' . $translation . ' <', $html);
}
-
// Images
+
// SEO
if (!$isMainLocale || $htmlPage) {
foreach ($seo as $s) {
$og_title = e($currentPage['og_title_copied'] ? $currentPage['seo_title'] : $currentPage['og_title']);
$og_desc = e($currentPage['og_description_copied'] ? $currentPage['seo_description'] : $currentPage['og_description']);
- $html = preg_replace('/\s*<meta(.*)(name="description"|property="(og|twitter):\w+")(.*)\/>\s*/', '', $html);
+ $html = preg_replace('/\s*<meta([^<]*)(name="description"|property="(og|twitter):\w+")(.*)\/>\s*/U', '', $html);
$meta = '
<meta content="' . e($currentPage['seo_description']) . '" name="description" />
<meta content="' . $og_title . '" property="og:title" />
public function onRetrieved(): bool
{
+ if (!$this->webflow) {
+ return parent::onRetrieved();
+ }
+
Webflow::setToken($this->webflow_api_token);
$lock = $this->getLock();
try {
},
{
"name": "cocur/slugify",
- "version": "v4.5.1",
+ "version": "v4.6.0",
"source": {
"type": "git",
"url": "https://github.com/cocur/slugify.git",
- "reference": "7c6e088228b9f082050876ae8b0cd287b117b840"
+ "reference": "1d674022e9cbefa80b4f51aa3e2375b6e3c14fdb"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/cocur/slugify/zipball/7c6e088228b9f082050876ae8b0cd287b117b840",
- "reference": "7c6e088228b9f082050876ae8b0cd287b117b840",
+ "url": "https://api.github.com/repos/cocur/slugify/zipball/1d674022e9cbefa80b4f51aa3e2375b6e3c14fdb",
+ "reference": "1d674022e9cbefa80b4f51aa3e2375b6e3c14fdb",
"shasum": ""
},
"require": {
"ext-mbstring": "*",
- "php": "~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0"
+ "php": "~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0"
},
"conflict": {
"symfony/config": "<3.4 || >=4,<4.3",
],
"support": {
"issues": "https://github.com/cocur/slugify/issues",
- "source": "https://github.com/cocur/slugify/tree/v4.5.1"
+ "source": "https://github.com/cocur/slugify/tree/v4.6.0"
},
- "time": "2023-09-17T07:26:20+00:00"
+ "time": "2024-09-10T14:09:25+00:00"
},
{
"name": "composer/package-versions-deprecated",
"source": {
"type": "git",
"url": "git://git.cubedesigners.com/cubedesigners_userdatabase.git",
- "reference": "49520520b567d68e6ccb298419aae252470572b1"
+ "reference": "3bb261ff5bf08ca0a684b6f21f9b48078307d5ab"
},
"dist": {
"type": "tar",
- "url": "https://composer.cubedesigners.com/dist/cubedesigners/userdatabase/cubedesigners-userdatabase-dev-master-411776.tar",
- "reference": "49520520b567d68e6ccb298419aae252470572b1",
- "shasum": "b31edb7ab289a57a3d13c13415eeef4897401fc7"
+ "url": "https://composer.cubedesigners.com/dist/cubedesigners/userdatabase/cubedesigners-userdatabase-dev-master-83f3c6.tar",
+ "reference": "3bb261ff5bf08ca0a684b6f21f9b48078307d5ab",
+ "shasum": "902f9ac393e0ce0f5b1954b17fbec41214e98410"
},
"require": {
"cubist/cms-back": "dev-master",
}
],
"description": "Cubedesigners common users database",
- "time": "2024-07-30T08:50:50+00:00"
+ "time": "2024-09-09T13:11:27+00:00"
},
{
"name": "cubist/azuretranslate",
"source": {
"type": "git",
"url": "git://git.cubedesigners.com/cubist_cms-back.git",
- "reference": "ca8a93553bd00620fad2f2f329735448544e584a"
+ "reference": "a5c754cd1afe85474abf5339476c0b0aa40a456c"
},
"dist": {
"type": "tar",
- "url": "https://composer.cubedesigners.com/dist/cubist/cms-back/cubist-cms-back-dev-master-1db34e.tar",
- "reference": "ca8a93553bd00620fad2f2f329735448544e584a",
- "shasum": "93f072e4e523da940bef534d51f989916107d59e"
+ "url": "https://composer.cubedesigners.com/dist/cubist/cms-back/cubist-cms-back-dev-master-95e503.tar",
+ "reference": "a5c754cd1afe85474abf5339476c0b0aa40a456c",
+ "shasum": "a4dcadd416662e7d393e2a7a49b1ce9b98ad7b0c"
},
"require": {
"backpack/backupmanager": "^v3.0.9",
}
],
"description": "Cubist Backpack extension",
- "time": "2024-06-03T14:53:25+00:00"
+ "time": "2024-09-16T13:50:18+00:00"
},
{
"name": "cubist/cms-front",
"source": {
"type": "git",
"url": "git://git.cubedesigners.com/cubist_net.git",
- "reference": "8d72260fe076601aa0e931af00b5817c4a90841e"
+ "reference": "9e806dd33e61656080742ece1f1fec4a27ec83f1"
},
"dist": {
"type": "tar",
- "url": "https://composer.cubedesigners.com/dist/cubist/net/cubist-net-dev-master-c5f47b.tar",
- "reference": "8d72260fe076601aa0e931af00b5817c4a90841e",
- "shasum": "7407f73f68a5dd929fb3cf15a7f223d405a59545"
+ "url": "https://composer.cubedesigners.com/dist/cubist/net/cubist-net-dev-master-8de656.tar",
+ "reference": "9e806dd33e61656080742ece1f1fec4a27ec83f1",
+ "shasum": "cb573ca10c1c2afe265612fab45e88a91c6f66fb"
},
"require": {
"cubist/util": "dev-master",
}
],
"description": "net cubist composer package",
- "time": "2024-07-30T13:32:45+00:00"
+ "time": "2024-09-17T09:04:42+00:00"
},
{
"name": "cubist/pdf",
"source": {
"type": "git",
"url": "git://git.cubedesigners.com/cubist_util.git",
- "reference": "5c932b5d0d2b648e09b029ec41172ebe3074fc52"
+ "reference": "59d40b831be36a4de00e2551e4da9b7ebc915826"
},
"dist": {
"type": "tar",
- "url": "https://composer.cubedesigners.com/dist/cubist/util/cubist-util-dev-master-a98892.tar",
- "reference": "5c932b5d0d2b648e09b029ec41172ebe3074fc52",
- "shasum": "d348bd1b4c65d69de1941f5c0442dcce7f259487"
+ "url": "https://composer.cubedesigners.com/dist/cubist/util/cubist-util-dev-master-3feebc.tar",
+ "reference": "59d40b831be36a4de00e2551e4da9b7ebc915826",
+ "shasum": "e41f5451e68c3c8285c0e5a4cdd748ad88d9d548"
},
"require": {
"cubist/net": "dev-master",
}
],
"description": "Utilities class",
- "time": "2024-08-21T15:48:28+00:00"
+ "time": "2024-09-12T08:51:47+00:00"
},
{
"name": "cviebrock/eloquent-sluggable",
"source": {
"type": "git",
"url": "git://git.cubedesigners.com/fluidbook_tools.git",
- "reference": "69cc53f0608c9001343f6903da7b6fefed8f4b92"
+ "reference": "73bb6cce228abe2b557339799fa21059d271f516"
},
"dist": {
"type": "tar",
- "url": "https://composer.cubedesigners.com/dist/fluidbook/tools/fluidbook-tools-dev-master-04a0b4.tar",
- "reference": "69cc53f0608c9001343f6903da7b6fefed8f4b92",
- "shasum": "f12ad27474ba234203909158dcedef1a808a8202"
+ "url": "https://composer.cubedesigners.com/dist/fluidbook/tools/fluidbook-tools-dev-master-80f061.tar",
+ "reference": "73bb6cce228abe2b557339799fa21059d271f516",
+ "shasum": "b02f39bfaf2ab18389bf89ee4629eba4f853c096"
},
"require": {
"barryvdh/laravel-debugbar": "*",
}
],
"description": "Fluidbook Tools",
- "time": "2024-08-22T10:19:18+00:00"
+ "time": "2024-09-04T07:41:56+00:00"
},
{
"name": "fpdf/fpdf",
},
{
"name": "laravel/framework",
- "version": "v10.48.20",
+ "version": "v10.48.22",
"source": {
"type": "git",
"url": "https://github.com/laravel/framework.git",
- "reference": "be2be342d4c74db6a8d2bd18469cd6d488ab9c98"
+ "reference": "c4ea52bb044faef4a103d7dd81746c01b2ec860e"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/laravel/framework/zipball/be2be342d4c74db6a8d2bd18469cd6d488ab9c98",
- "reference": "be2be342d4c74db6a8d2bd18469cd6d488ab9c98",
+ "url": "https://api.github.com/repos/laravel/framework/zipball/c4ea52bb044faef4a103d7dd81746c01b2ec860e",
+ "reference": "c4ea52bb044faef4a103d7dd81746c01b2ec860e",
"shasum": ""
},
"require": {
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
- "time": "2024-08-09T07:55:45+00:00"
+ "time": "2024-09-12T15:00:09+00:00"
},
{
"name": "laravel/prompts",
},
{
"name": "maximebf/debugbar",
- "version": "v1.22.5",
+ "version": "v1.22.6",
"source": {
"type": "git",
"url": "https://github.com/maximebf/php-debugbar.git",
- "reference": "1b5cabe0ce013134cf595bfa427bbf2f6abcd989"
+ "reference": "d7881b498f9e649610bf6ae91cdd6353859f75d2"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/1b5cabe0ce013134cf595bfa427bbf2f6abcd989",
- "reference": "1b5cabe0ce013134cf595bfa427bbf2f6abcd989",
+ "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/d7881b498f9e649610bf6ae91cdd6353859f75d2",
+ "reference": "d7881b498f9e649610bf6ae91cdd6353859f75d2",
"shasum": ""
},
"require": {
],
"support": {
"issues": "https://github.com/maximebf/php-debugbar/issues",
- "source": "https://github.com/maximebf/php-debugbar/tree/v1.22.5"
+ "source": "https://github.com/maximebf/php-debugbar/tree/v1.22.6"
},
- "time": "2024-09-09T08:05:55+00:00"
+ "time": "2024-09-16T11:47:59+00:00"
},
{
"name": "mews/purifier",
},
{
"name": "psr/log",
- "version": "3.0.1",
+ "version": "3.0.2",
"source": {
"type": "git",
"url": "https://github.com/php-fig/log.git",
- "reference": "79dff0b268932c640297f5208d6298f71855c03e"
+ "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/php-fig/log/zipball/79dff0b268932c640297f5208d6298f71855c03e",
- "reference": "79dff0b268932c640297f5208d6298f71855c03e",
+ "url": "https://api.github.com/repos/php-fig/log/zipball/f16e1d5863e37f8d8c2a01719f5b34baa2b714d3",
+ "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3",
"shasum": ""
},
"require": {
"psr-3"
],
"support": {
- "source": "https://github.com/php-fig/log/tree/3.0.1"
+ "source": "https://github.com/php-fig/log/tree/3.0.2"
},
- "time": "2024-08-21T13:31:24+00:00"
+ "time": "2024-09-11T13:17:53+00:00"
},
{
"name": "psr/simple-cache",
},
{
"name": "nikic/php-parser",
- "version": "v5.1.0",
+ "version": "v5.2.0",
"source": {
"type": "git",
"url": "https://github.com/nikic/PHP-Parser.git",
- "reference": "683130c2ff8c2739f4822ff7ac5c873ec529abd1"
+ "reference": "23c79fbbfb725fb92af9bcf41065c8e9a0d49ddb"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/683130c2ff8c2739f4822ff7ac5c873ec529abd1",
- "reference": "683130c2ff8c2739f4822ff7ac5c873ec529abd1",
+ "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/23c79fbbfb725fb92af9bcf41065c8e9a0d49ddb",
+ "reference": "23c79fbbfb725fb92af9bcf41065c8e9a0d49ddb",
"shasum": ""
},
"require": {
],
"support": {
"issues": "https://github.com/nikic/PHP-Parser/issues",
- "source": "https://github.com/nikic/PHP-Parser/tree/v5.1.0"
+ "source": "https://github.com/nikic/PHP-Parser/tree/v5.2.0"
},
- "time": "2024-07-01T20:03:41+00:00"
+ "time": "2024-09-15T16:40:33+00:00"
},
{
"name": "nunomaduro/collision",