예제 #1
0
 /**
  * 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();
     }
 }
예제 #2
0
 public function getPackagePath()
 {
     return parent::getPackagePath();
 }