/**
  * 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 install_permissions()
 {
     $ci = new ContentImporter();
     $ci->importContentFile(DIR_BASE_CORE . '/config/install/base/permissions.xml');
 }
 protected function addPermissions()
 {
     $this->output(t('Adding permissions...'));
     CacheLocal::delete('permission_keys', false);
     $ci = new ContentImporter();
     $ci->importContentFile(DIR_BASE_CORE . '/config/install/base/permissions.xml');
     CacheLocal::delete('permission_keys', false);
 }
Example #5
0
 protected function installXmlContent()
 {
     $pkg = Package::getByHandle($this->pkgHandle);
     $ci = new ContentImporter();
     $ci->importContentFile($pkg->getPackagePath() . '/install.xml');
 }
 public function install()
 {
     $pkg = parent::install();
     $ci = new ContentImporter();
     $ci->importContentFile($pkg->getPackagePath() . '/config/dashboard.xml');
 }
Example #7
0
 public function installContentFile($file)
 {
     $ci = new ContentImporter();
     $ci->importContentFile($this->getPackagePath() . DIRECTORY_SEPARATOR . $file);
 }
Example #8
0
 public function swapContent($options)
 {
     // Custom method to allow us to offer multiple starting points
     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();
         }
         // Overidden functionality to let us install selected starting point.... now we add in any files that this package has
         if (is_dir($this->getPackagePath() . '/starting_points/' . $this->startingPoint . '/content_files')) {
             $fh = new FileImporter();
             $contents = Core::make('helper/file')->getDirectoryContents($this->getPackagePath() . '/starting_points/' . $this->startingPoint . '/content_files');
             foreach ($contents as $filename) {
                 $f = $fh->import($this->getPackagePath() . '/starting_points/' . $this->startingPoint . '/content_files/' . $filename, $filename);
             }
         }
         // Install selected starting point.
         $ci = new ContentImporter();
         $ci->importContentFile($this->getPackagePath() . '/starting_points/' . $this->startingPoint . '/content.xml');
         // Set the default preset
         $pt = PageTheme::getByHandle($this->pkgHandle);
         if (is_object($pt) && $pt->isThemeCustomizable()) {
             $presets = $pt->getThemeCustomizableStylePresets();
             foreach ($presets as $preset) {
                 if ($preset->getPresetHandle() == $this->startingPoint) {
                     $styles = $pt->getThemeCustomizableStyleList();
                     $lessFile = $this->getPackagePath() . '/themes/' . $this->pkgHandle . '/css/presets/' . $this->startingPoint . '.less';
                     $vl = \Concrete\Core\StyleCustomizer\Style\ValueList::loadFromLessFile($lessFile);
                     $vl->save();
                     $pt->setCustomStyleObject($vl, $preset, false);
                 }
             }
         }
         \Core::make('cache/request')->enable();
     }
 }