]> _ Git - fluidbook-toolbox.git/commitdiff
wip #6946 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 6 Jun 2024 08:43:07 +0000 (10:43 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 6 Jun 2024 08:43:07 +0000 (10:43 +0200)
app/Fields/Webflow/WebflowPage.php
app/Models/ToolWebflow.php
app/Services/Webflow.php
composer.lock

index ff8f36db3ca55e918c82e6c29a3c9cdac0dd2b17..e6f146d8bed77a87fc210ab10fa91b8e2c2a020c 100644 (file)
@@ -2,9 +2,32 @@
 
 namespace App\Fields\Webflow;
 
+use App\Models\ToolWebflow;
 use Cubist\Backpack\Magic\Fields\SelectFromArray;
 
 class WebflowPage extends SelectFromArray
 {
+    protected static $_opts = [];
+
+    public function getOptions()
+    {
+        $params = \Route::current()->parameters();
+
+        $id =  // use the entity name to get the current entry
+            // this makes sure the ID is corrent even for nested resources
+            request()->input('tool-webflow') ??
+            // otherwise use the next to last parameter
+            array_values($params)[count($params) - 1] ??
+            // otherwise return false
+            false;
+
+        if (!isset(static::$_opts[$id])) {
+            static::$_opts[$id] = [];
+            static::$_opts[$id] = ToolWebflow::find($id)->listPages();
+        }
+
+        return static::$_opts[$id];
+    }
+
 
 }
index cc7037949e63d23678cbca4545e4477d1757b079..e2c0816f010b8eff344c141d228f390366137741 100644 (file)
@@ -3,6 +3,7 @@
 namespace App\Models;
 
 use App\Fields\Webflow\WebflowImages;
+use App\Fields\Webflow\WebflowPage;
 use App\Fields\Webflow\WebflowTexts;
 use App\Http\Controllers\Admin\Operations\Tools\StaticSiteUploader;
 use App\Http\Controllers\Admin\Operations\Tools\WebflowOperation;
@@ -11,7 +12,6 @@ use App\Models\Base\ToolboxTranslatableModel;
 use App\Services\Webflow;
 use App\SubForms\Webflow\Redirection;
 use App\SubForms\Webflow\SEOPage;
-use App\SubForms\Webflow\WebflowText;
 use Cubist\Azure\Translate\Api;
 use Cubist\Backpack\Magic\Fields\BunchOfFieldsMultiple;
 use Cubist\Backpack\Magic\Fields\Code;
@@ -25,7 +25,9 @@ use Cubist\Util\CommandLine;
 use Cubist\Util\Files\Files;
 use Cubist\Util\Json;
 use Illuminate\Contracts\Cache\Lock;
+use Illuminate\Contracts\Cache\LockTimeoutException;
 use Illuminate\Support\Facades\Cache;
+use Illuminate\Support\Facades\Session;
 
 // __('!! Outils')
 class ToolWebflow extends ToolboxTranslatableModel
@@ -287,6 +289,16 @@ class ToolWebflow extends ToolboxTranslatableModel
 
     }
 
+    public function listPages()
+    {
+        $seo = Webflow::getEditableData($this->webflow)['seo'];
+        $res = [];
+        foreach ($seo as $s) {
+            $res[$s['id']] = $s['url'];
+        }
+        return $res;
+    }
+
     public function compile()
     {
         $this->_parsePages();
@@ -359,6 +371,13 @@ class ToolWebflow extends ToolboxTranslatableModel
             if (is_string($locales)) {
                 $locales = json_decode($locales, true);
             }
+
+            $data = $this->getEditableData();
+            $pages = [];
+            foreach ($data['seo'] as $s) {
+                $pages[$s['id']] = $s['url'];
+            }
+
             Cache::put('webflow_' . $this->id . '_locales', $locales);
 
         } catch (LockTimeoutException $e) {
index 8af2a9ae3807ad5b174fcf8795651e43f04218b3..4cbf40fcf0a40c174d24e429b8d8a31a744fa6d4 100644 (file)
@@ -107,8 +107,12 @@ class Webflow
 
     public static function listSites()
     {
-        return self::request('sites')['sites'];
-    }
+        $sites = self::request('sites');
+        if (isset($sites['sites'])) {
+            return $sites['sites'];
+        }
+        return [];
+   }
 
     public static function getSiteId($shortname)
     {
@@ -117,6 +121,7 @@ class Webflow
                 return $s['id'];
             }
         }
+        return false;
     }
 
     public static function getPageMeta($shortname, $pageID, $fromAPI = false, $force = false)
index 48d0b19eba765fbd7fdb838b1890db1b63bb1708..f6396552b137950792a5b59633339fcaaec75246 100644 (file)
             "source": {
                 "type": "git",
                 "url": "git://git.cubedesigners.com/cubist_azuretranslation.git",
-                "reference": "96c398a7b3b02ffce5596ccec70f652c835a8f0f"
+                "reference": "b07c3277fa7b9be84f425292c30d99643fbe436a"
             },
             "dist": {
                 "type": "tar",
-                "url": "https://composer.cubedesigners.com/dist/cubist/azuretranslate/cubist-azuretranslate-dev-master-08a45c.tar",
-                "reference": "96c398a7b3b02ffce5596ccec70f652c835a8f0f",
-                "shasum": "e518821d744806b22e9203506a439ee4567eae5e"
+                "url": "https://composer.cubedesigners.com/dist/cubist/azuretranslate/cubist-azuretranslate-dev-master-b7efd9.tar",
+                "reference": "b07c3277fa7b9be84f425292c30d99643fbe436a",
+                "shasum": "984ce027af2efef4875ae33d224d68f63635e64f"
             },
             "require": {
                 "ext-json": "*",
                 }
             ],
             "description": "Azure Translate REST API",
-            "time": "2024-06-05T10:59:57+00:00"
+            "time": "2024-06-05T14:04:45+00:00"
         },
         {
             "name": "cubist/azuretts",