/**
  * Removes any existing pages, files, stacks, block and page types and installs content from the package.
  *
  * @param $options
  */
 public function swapContent(Package $package, $options)
 {
     if ($this->validateClearSiteContents($options)) {
         \Core::make('cache/request')->disable();
         $pl = new PageList();
         $pages = $pl->getResults();
         foreach ($pages as $c) {
             $c->delete();
         }
         $fl = new FileList();
         $files = $fl->getResults();
         foreach ($files as $f) {
             $f->delete();
         }
         // clear stacks
         $sl = new StackList();
         foreach ($sl->get() as $c) {
             $c->delete();
         }
         $home = \Page::getByID(HOME_CID);
         $blocks = $home->getBlocks();
         foreach ($blocks as $b) {
             $b->deleteBlock();
         }
         $pageTypes = Type::getList();
         foreach ($pageTypes as $ct) {
             $ct->delete();
         }
         // Set the page type of the home page to 0, because
         // if it has a type the type will be gone since we just
         // deleted it
         $home = Page::getByID(HOME_CID);
         $home->setPageType(null);
         // now we add in any files that this package has
         if (is_dir($package->getPackagePath() . '/content_files')) {
             $ch = new ContentImporter();
             $computeThumbnails = true;
             if ($package->contentProvidesFileThumbnails()) {
                 $computeThumbnails = false;
             }
             $ch->importFiles($package->getPackagePath() . '/content_files', $computeThumbnails);
         }
         // now we parse the content.xml if it exists.
         $ci = new ContentImporter();
         $ci->importContentFile($package->getPackagePath() . '/content.xml');
         \Core::make('cache/request')->enable();
     }
 }
 public function swapContent($options)
 {
     if ($this->validateClearSiteContents($options)) {
         \Core::make('cache/request')->disable();
         $pl = new PageList();
         $pages = $pl->getResults();
         foreach ($pages as $c) {
             $c->delete();
         }
         $fl = new FileList();
         $files = $fl->getResults();
         foreach ($files as $f) {
             $f->delete();
         }
         // clear stacks
         $sl = new StackList();
         foreach ($sl->get() as $c) {
             $c->delete();
         }
         $home = Page::getByID(HOME_CID);
         $blocks = $home->getBlocks();
         foreach ($blocks as $b) {
             $b->deleteBlock();
         }
         $pageTypes = PageType::getList();
         foreach ($pageTypes as $ct) {
             $ct->delete();
         }
         $path = $this->getPackagePath();
         // Import Files
         if (is_dir($path . '/files')) {
             $ch = new ContentImporter();
             $computeThumbnails = true;
             if ($this->contentProvidesFileThumbnails()) {
                 $computeThumbnails = false;
             }
             $ch->importFiles($path . '/files', $computeThumbnails);
         }
         // Install the starting point.
         if (is_file($path . '/content.xml')) {
             $ci = new ContentImporter();
             $ci->importContentFile($path . '/content.xml');
         }
         // Restore Cache
         \Core::make('cache/request')->enable();
     }
 }
 public function import_files()
 {
     $type = \Concrete\Core\File\StorageLocation\Type\Type::add('default', t('Default'));
     \Concrete\Core\File\StorageLocation\Type\Type::add('local', t('Local'));
     $configuration = $type->getConfigurationObject();
     $fsl = \Concrete\Core\File\StorageLocation\StorageLocation::add($configuration, t('Default'), true);
     $thumbnailType = new Type();
     $thumbnailType->requireType();
     $thumbnailType->setName(tc('ThumbnailTypeName', 'File Manager Thumbnails'));
     $thumbnailType->setHandle(Config::get('concrete.icons.file_manager_listing.handle'));
     $thumbnailType->setWidth(Config::get('concrete.icons.file_manager_listing.width'));
     $thumbnailType->setHeight(Config::get('concrete.icons.file_manager_listing.height'));
     $thumbnailType->save();
     $thumbnailType = new Type();
     $thumbnailType->requireType();
     $thumbnailType->setName(tc('ThumbnailTypeName', 'File Manager Detail Thumbnails'));
     $thumbnailType->setHandle(Config::get('concrete.icons.file_manager_detail.handle'));
     $thumbnailType->setWidth(Config::get('concrete.icons.file_manager_detail.width'));
     $thumbnailType->save();
     if (is_dir($this->getPackagePath() . '/files')) {
         $ch = new ContentImporter();
         $computeThumbnails = true;
         if ($this->contentProvidesFileThumbnails()) {
             $computeThumbnails = false;
         }
         $ch->importFiles($this->getPackagePath() . '/files', $computeThumbnails);
     }
 }