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);
+ }
}