public function parse() { $sl = new StyleList(); foreach ($this->root->set as $xset) { $set = $sl->addSet((string) $xset['name']); foreach ($xset->style as $xstyle) { $type = camelcase((string) $xstyle['type']); $style = Core::make('\\Concrete\\Core\\StyleCustomizer\\Style\\' . $type . 'Style'); $style->setName((string) $xstyle['name']); $style->setVariable((string) $xstyle['variable']); $set->addStyle($style); } } return $sl; }
public static function loadFromRequest(ParameterBag $request, \Concrete\Core\StyleCustomizer\StyleList $styles) { $vl = new static(); foreach ($styles->getSets() as $set) { foreach ($set->getStyles() as $style) { $value = $style->getValueFromRequest($request); if (is_object($value)) { $vl->addValue($value); } } } if ($request->has('preset-fonts-file')) { $bv = new BasicValue('preset-fonts-file'); $bv->setValue($request->get('preset-fonts-file')); $vl->addValue($bv); } return $vl; }
public function testStyles() { $definition = dirname(__FILE__) . '/fixtures/styles.xml'; $styleList = \Concrete\Core\StyleCustomizer\StyleList::loadFromXMLFile($definition); $sets = $styleList->getSets(); $styles = $sets[0]->getStyles(); $styles2 = $sets[2]->getStyles(); $this->assertTrue($styleList instanceof \Concrete\Core\StyleCustomizer\StyleList); $this->assertTrue(count($styleList->getSets()) == 3); $this->assertTrue($sets[2]->getName() == 'Spacing'); $this->assertTrue($styles[0]->getVariable() == 'background-color'); $this->assertTrue($styles[1]->getVariable() == 'top-header-bar-color'); $this->assertTrue($styles[0]->getName() == 'Background'); $this->assertTrue($styles[1]->getName() == 'Top Header Bar'); $this->assertTrue($styles[0] instanceof \Concrete\Core\StyleCustomizer\Style\ColorStyle); $this->assertTrue($styles2[0] instanceof \Concrete\Core\StyleCustomizer\Style\SizeStyle); $this->assertTrue($styles[0]->getFormElementPath() == DIR_FILES_ELEMENTS_CORE . '/' . DIRNAME_STYLE_CUSTOMIZER . '/' . DIRNAME_STYLE_CUSTOMIZER_TYPES . '/color.php', sprintf('Incorrect path: %s', $styles[0]->getFormElementPath())); $this->assertTrue($styles2[0]->getFormElementPath() == DIR_FILES_ELEMENTS_CORE . '/' . DIRNAME_STYLE_CUSTOMIZER . '/' . DIRNAME_STYLE_CUSTOMIZER_TYPES . '/size.php', sprintf('Incorrect path: %s', $styles2[0]->getFormElementPath())); }
/** * Gets the style list object for this theme. * * @return \Concrete\Core\StyleCustomizer\StyleList */ public function getThemeCustomizableStyleList() { if (!isset($this->styleList)) { $env = Environment::get(); $r = $env->getRecord(DIRNAME_THEMES . '/' . $this->getThemeHandle() . '/' . DIRNAME_CSS . '/' . FILENAME_STYLE_CUSTOMIZER_STYLES, $this->getPackageHandle()); $this->styleList = \Concrete\Core\StyleCustomizer\StyleList::loadFromXMLFile($r->file); } return $this->styleList; }