]> _ Git - fluidbook-v3.git/commitdiff
fix #3180 @0.75
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Thu, 7 Nov 2019 14:54:54 +0000 (14:54 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Thu, 7 Nov 2019 14:54:54 +0000 (14:54 +0000)
framework/application/controllers/MaintenanceController.php

index 058109a6e2af96a11a5540dab04a2966e9c44868..3ebd74bfa2f15a5bdd120da0ef11f595053d6943 100644 (file)
@@ -2,78 +2,82 @@
 
 class MaintenanceController extends CubeIT_Controller_MaintenanceController
 {
-       protected function _filterURL($url)
-       {
-               if (null === $url || !$url || $url == 'http://') {
-                       return '';
-               }
-               return $url;
-       }
+    protected function _filterURL($url)
+    {
+        if (null === $url || !$url || $url == 'http://') {
+            return '';
+        }
+        return $url;
+    }
 
-       //      public function featuredCategories() {
-       //              $references = Fluidbook_Model_Reference::factory()->find();
-       //              foreach ($references as $reference) {
-       //                      if ($reference->getFeatured()) {
-       //                              $reference->setFeaturedCategories($reference->getCategories());
-       //                      }
-       //                      fb($reference->toArray());
-       //                      $reference->save();
-       //              }
-       //      }
+    // public function featuredCategories() {
+    //         $references = Fluidbook_Model_Reference::factory()->find();
+    //         foreach ($references as $reference) {
+    //                 if ($reference->getFeatured()) {
+    //                         $reference->setFeaturedCategories($reference->getCategories());
+    //                 }
+    //                 fb($reference->toArray());
+    //                 $reference->save();
+    //         }
+    // }
 
-       public function importReferences()
-       {
-               set_time_limit(0);
-               ignore_user_abort(true);
+    public function importReferences()
+    {
+        set_time_limit(0);
+        ignore_user_abort(true);
 
-               $ws = new CubeIT_Services_Fluidbook('vincent@cubedesigners.com', 'iquique');
-               $references = Fluidbook_Model_Reference::factory()->find();
+        $ws = new CubeIT_Services_Fluidbook('vincent@cubedesigners.com', 'iquique');
+        $references = Fluidbook_Model_Reference::factory()->find();
 
-               $fluidbooks = array();
-               foreach ($references as $reference) {
-                       $ids = $reference->getFluidbookId();
-                       foreach ($ids as $locale => $id) {
-                               if (!$id) {
-                                       continue;
-                               }
-                               $fluidbooks[] = $id;
-                       }
-               }
-               $fluidbooks = array_values(array_unique($fluidbooks));
+        $fluidbooks = array();
+        foreach ($references as $reference) {
+            $ids = $reference->getFluidbookId();
+            foreach ($ids as $locale => $id) {
+                if (!$id) {
+                    continue;
+                }
+                $fluidbooks[] = $id;
+            }
+        }
+        $fluidbooks = array_values(array_unique($fluidbooks));
 
-               $n = 0;
-               foreach ($fluidbooks as $fluidbook) {
-                       if ($n > 20) {
-                               break;
-                       }
-                       try {
-                               $meta = $ws->getMetadata($fluidbook);
-                               $dir = PUBLIC_PATH . '/references/' . $fluidbook . '-' . CubeIT_Text::str2URL(trim($meta->title));
+        $n = 0;
+        foreach ($fluidbooks as $fluidbook) {
+            if ($n > 20) {
+                break;
+            }
+            try {
+                $meta = $ws->getMetadata($fluidbook);
+                $dir = PUBLIC_PATH . '/references/' . $fluidbook . '-' . CubeIT_Text::str2URL(trim($meta->title));
 
-                               try {
-                                       $res = $ws->installBookIfNeeded($fluidbook, $dir, 'auto');
-                                       if ($res) {
-                                               $n++;
-                                       }
-                               } catch (exception $e) {
-                                       echo $e->getMessage() . '<br />';
-                                       exit;
-                               }
-                       } catch (exception $e) {
-                               echo $e->getMessage() . '<br />';
-                               exit;
-                       }
-               }
-       }
+                try {
+                    $res = $ws->installBookIfNeeded($fluidbook, $dir, 'auto');
+                    if ($res) {
+                        $n++;
+                    }
+                } catch (exception $e) {
+                    echo $e->getMessage() . '<br />';
+                    exit;
+                }
+            } catch (exception $e) {
+                echo $e->getMessage() . '<br />';
+                exit;
+            }
+        }
+    }
 
 
-       public static function importReference($id)
-       {
-               $ws = new CubeIT_Services_Fluidbook('vincent@cubedesigners.com', 'iquique');
-               $meta = $ws->getMetadata($id);
-               $dir = PUBLIC_PATH . '/references/' . $id . '-' . CubeIT_Text::str2URL(trim($meta->title));
-               $res = $ws->installBook($id, $dir);
+    public static function importReference($id)
+    {
+        $ws = new CubeIT_Services_Fluidbook('vincent@cubedesigners.com', 'iquique');
+        $meta = $ws->getMetadata($id);
+        $dir = PUBLIC_PATH . '/references/' . $id . '-' . CubeIT_Text::str2URL(trim($meta->title));
+        $res = $ws->installBook($id, $dir, 'online', 3, function () use ($id) {
+            $delete = PUBLIC_PATH . '/references/' . $id . '-*';
+            $deleteCmd = "rm -rf $delete !(*.temp)";
+            `$deleteCmd`;
+        });
 
-               echo $id . ' : ' . $dir . ' // ' . print_r($res);
-       }
+        echo $id . ' : ' . $dir . ' // ' . print_r($res);
+    }
 }