Esempio n. 1
0
 /**
  * Gets the style value list object for this preset.
  *
  * @return \Concrete\Core\StyleCustomizer\Style\ValueList
  */
 public function getStyleValueList()
 {
     if (!isset($this->styleValueList)) {
         $this->styleValueList = \Concrete\Core\StyleCustomizer\Style\ValueList::loadFromLessFile($this->file, $this->urlroot);
     }
     return $this->styleValueList;
 }
Esempio n. 2
0
 public function testCustomizableStyleSheetObjects()
 {
     $defaults = dirname(__FILE__) . '/fixtures/elemental.less';
     $list = \Concrete\Core\StyleCustomizer\Style\ValueList::loadFromLessFile($defaults);
     $env = Environment::get();
     $pt = new PageTheme();
     $pt->setThemeHandle('elemental');
     $pt->setThemeDirectory($env->getPath(DIRNAME_THEMES . '/elemental'));
     $pt->setThemeURL($env->getURL(DIRNAME_THEMES . '/elmental'));
     $sheets = $pt->getThemeCustomizableStyleSheets();
     $this->assertTrue(count($sheets) == 1);
     $this->assertTrue($sheets[0] instanceof \Concrete\Core\StyleCustomizer\Stylesheet);
     $css = $sheets[0]->getCss();
     $this->assertTrue(strpos($css, "background-image: url('/path/to/server/concrete/themes/elemental/images/background-slider-default.png')") !== false);
     $sheets[0]->setValueList($list);
     $css = $sheets[0]->getCss();
     $this->assertTrue(strpos($css, "background-image: url('/path/to/server/concrete/themes/elemental/images/testingit.jpg')") !== false);
     $this->assertTrue(strpos($css, 'font-family: "Testing Font Family"') !== false);
     $sheet = $pt->getStylesheetObject('typography.less');
     $sheet->setValueList($list);
     $this->assertTrue($sheet->getOutputPath() == DIR_BASE . '/application/files/cache/css/elemental/typography.css');
     $this->assertTrue($sheet->getOutputRelativePath() == DIR_REL . '/application/files/cache/css/elemental/typography.css');
 }
 public function testCustomizableStyleSheetObjects()
 {
     $defaults = dirname(__FILE__) . '/fixtures/greekyogurt.less';
     $list = \Concrete\Core\StyleCustomizer\Style\ValueList::loadFromLessFile($defaults);
     $env = Environment::get();
     $pt = new PageTheme();
     $pt->setThemeHandle('greek_yogurt');
     $pt->setThemeDirectory($env->getPath(DIRNAME_THEMES . '/greek_yogurt'));
     $pt->setThemeURL($env->getURL(DIRNAME_THEMES . '/greek_yogurt'));
     $sheets = $pt->getThemeCustomizableStyleSheets();
     $this->assertTrue(count($sheets) == 1);
     $this->assertTrue($sheets[0] instanceof \Concrete\Core\StyleCustomizer\Stylesheet);
     $css = $sheets[0]->getCss();
     $r = preg_match('/background-image: url\\(\'(.+)\'\\);/i', $css, $matches);
     $this->assertTrue(trim($matches[1]) == '/concrete/themes/greek_yogurt/images/spacer.gif');
     $sheets[0]->setValueList($list);
     $css = $sheets[0]->getCss();
     $r = preg_match('/background-image: url\\(\'(.+)\'\\);/i', $css, $matches);
     $this->assertTrue(trim($matches[1]) == '/concrete/themes/greek_yogurt/images/testingit.jpg');
     $sheet = $pt->getStylesheetObject('typography.less');
     $sheet->setValueList($list);
     $this->assertTrue($sheet->getOutputPath() == DIR_BASE . '/application/files/cache/css/greek_yogurt/typography.css');
     $this->assertTrue($sheet->getOutputRelativePath() == DIR_REL . '/application/files/cache/css/greek_yogurt/typography.css');
 }
Esempio n. 4
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();
     }
 }