public function testFilterBySet() { $fs = \FileSet::add('test'); $f = \File::getByID(1); $f2 = \File::getByID(4); $fs->addFileToSet($f); $fs->addFileToSet($f2); $fs2 = \FileSet::add('test2'); $fs2->addFiletoSet($f); $this->list->filterBySet($fs); $pagination = $this->list->getPagination(); $this->assertEquals(2, $pagination->getTotalResults()); $results = $this->list->getResults(); $this->assertEquals(2, count($results)); $this->assertEquals(4, $results[1]->getFileID()); $this->list->filterBySet($fs2); $results = $this->list->getResults(); $this->assertEquals(1, count($results)); $this->assertEquals(1, $results[0]->getFileID()); $nl = new \Concrete\Core\File\FileList(); $nl->ignorePermissions(); $nl->filterByNoSet(); $results = $nl->getResults(); $this->assertEquals(9, count($results)); }
/** * 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) { // 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(); } }
/** Returns a full array of results. */ public function getResults() { return parent::getResults(); }