Beispiel #1
0
 public function getValueFromList(\Concrete\Core\StyleCustomizer\Style\ValueList $list)
 {
     $type = static::getTypeFromClass($this);
     foreach ($list->getValues() as $value) {
         if ($value->getVariable() == $this->getVariable() && $type == static::getTypeFromClass($value, 'Value')) {
             return $value;
         }
     }
 }
Beispiel #2
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;
 }
Beispiel #3
0
 /**
  * {@inheritDoc}
  */
 public function getStyleValueList()
 {
     if (!isset($this->styleValueList)) {
         $this->styleValueList = StyleValueList::loadFromFile($this->file, $this->urlroot);
     }
     return $this->styleValueList;
 }
Beispiel #4
0
 public function setCustomStyleObject(\Concrete\Core\StyleCustomizer\Style\ValueList $valueList, $selectedPreset = false, CustomCssRecord $customCssRecord = null)
 {
     $db = Loader::db();
     $db->delete('PageThemeCustomStyles', ['pThemeID' => $this->getThemeID()]);
     $preset = false;
     if ($selectedPreset) {
         $preset = $selectedPreset->getPresetHandle();
     }
     $sccRecordID = 0;
     if ($customCssRecord !== null) {
         $sccRecordID = $customCssRecord->getRecordID();
     }
     $db->insert('PageThemeCustomStyles', ['pThemeID' => $this->getThemeID(), 'sccRecordID' => $sccRecordID, 'preset' => $preset, 'scvlID' => $valueList->getValueListID()]);
     // now we reset all cached css files in this theme
     $sheets = $this->getThemeCustomizableStyleSheets();
     foreach ($sheets as $s) {
         $s->clearOutputFile();
     }
     $scc = new \Concrete\Core\Page\CustomStyle();
     $scc->setThemeID($this->getThemeID());
     $scc->setValueListID($valueList->getValueListID());
     $scc->setPresetHandle($preset);
     $scc->setCustomCssRecordID($sccRecordID);
     return $scc;
 }
Beispiel #5
0
 public function setCustomStyleObject(\Concrete\Core\Page\Theme\Theme $pt, \Concrete\Core\StyleCustomizer\Style\ValueList $valueList, $selectedPreset = false, $customCssRecord = false)
 {
     $db = Database::get();
     $db->delete('CollectionVersionThemeCustomStyles', array('cID' => $this->getCollectionID(), 'cvID' => $this->getVersionID()));
     $sccRecordID = 0;
     if ($customCssRecord instanceof CustomCssRecord) {
         $sccRecordID = $customCssRecord->getRecordID();
     }
     $preset = false;
     if ($selectedPreset) {
         $preset = $selectedPreset->getPresetHandle();
     }
     if ($customCssRecord instanceof CustomCssRecord) {
         $sccRecordID = $customCssRecord->getRecordID();
     }
     $db->insert('CollectionVersionThemeCustomStyles', array('cID' => $this->getCollectionID(), 'cvID' => $this->getVersionID(), 'pThemeID' => $pt->getThemeID(), 'sccRecordID' => $sccRecordID, 'preset' => $preset, 'scvlID' => $valueList->getValueListID()));
     $scc = new \Concrete\Core\Page\CustomStyle();
     $scc->setThemeID($pt->getThemeID());
     $scc->setValueListID($valueList->getValueListID());
     $scc->setPresetHandle($preset);
     $scc->setCustomCssRecordID($sccRecordID);
     return $scc;
 }
Beispiel #6
0
 protected function getValueListFromRequest($pThemeID)
 {
     $pt = PageTheme::getByID($pThemeID);
     $styles = $pt->getThemeCustomizableStyleList();
     $vl = \Concrete\Core\StyleCustomizer\Style\ValueList::loadFromRequest($this->request->request, $styles);
     return $vl;
 }
Beispiel #7
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');
 }
Beispiel #9
0
 public function getValueList()
 {
     return ValueList::getByID($this->valueListID);
 }
Beispiel #10
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();
     }
 }