public function inherit(AbstractTag $tag) { $group = $tag->getParentGroup(); if ($group) { $parent_style = $group->getStyle(); foreach ($parent_style as $_key => $_value) { if ($_value !== null) { $this->{$_key} = $_value; } } } }
public function fromStyleSheets(AbstractTag $tag, $attributes) { $class = isset($attributes["class"]) ? preg_split('/\\s+/', trim($attributes["class"])) : null; $stylesheets = $tag->getDocument()->getStyleSheets(); $styles = array(); foreach ($stylesheets as $_sc) { /** @var \Sabberworm\CSS\RuleSet\DeclarationBlock $_decl */ foreach ($_sc->getAllDeclarationBlocks() as $_decl) { /** @var \Sabberworm\CSS\Property\Selector $_selector */ foreach ($_decl->getSelectors() as $_selector) { $_selector = $_selector->getSelector(); // Match class name if ($class !== null) { foreach ($class as $_class) { if ($_selector === ".{$_class}") { /** @var \Sabberworm\CSS\Rule\Rule $_rule */ foreach ($_decl->getRules() as $_rule) { $styles[$_rule->getRule()] = $_rule->getValue() . ""; } break 2; } } } // Match tag name if ($_selector === $tag->tagName) { /** @var \Sabberworm\CSS\Rule\Rule $_rule */ foreach ($_decl->getRules() as $_rule) { $styles[$_rule->getRule()] = $_rule->getValue() . ""; } break; } } } } $this->fillStyles($styles); }
public function start($attributes) { parent::start($attributes); if (isset($attributes['x1'])) { $this->x1 = $attributes['x1']; } if (isset($attributes['y1'])) { $this->y1 = $attributes['y1']; } if (isset($attributes['x2'])) { $this->x2 = $attributes['x2']; } if (isset($attributes['y2'])) { $this->y2 = $attributes['y2']; } }