From: vincent@cubedesigners.com Date: Thu, 7 Nov 2019 14:54:54 +0000 (+0000) Subject: fix #3180 @0.75 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=ce2707080013ffff920ab0bc21a7e4b288bac17e;p=fluidbook-v3.git fix #3180 @0.75 --- diff --git a/framework/application/controllers/MaintenanceController.php b/framework/application/controllers/MaintenanceController.php index 058109a..3ebd74b 100644 --- a/framework/application/controllers/MaintenanceController.php +++ b/framework/application/controllers/MaintenanceController.php @@ -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() . '
'; - exit; - } - } catch (exception $e) { - echo $e->getMessage() . '
'; - exit; - } - } - } + try { + $res = $ws->installBookIfNeeded($fluidbook, $dir, 'auto'); + if ($res) { + $n++; + } + } catch (exception $e) { + echo $e->getMessage() . '
'; + exit; + } + } catch (exception $e) { + echo $e->getMessage() . '
'; + 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); + } }