Esempio n. 1
0
 /**
  * Adds a new CSS rule to this media instance
  *
  * @param css_rule $newrule
  */
 public function add_rule(css_rule $newrule)
 {
     foreach ($newrule->split_by_selector() as $rule) {
         $hash = $rule->get_selector_hash();
         if (!array_key_exists($hash, $this->rules)) {
             $this->rules[$hash] = $rule;
         } else {
             $this->rules[$hash]->add_styles($rule->get_styles());
         }
     }
 }
 /**
  * This function processes the CSS declarations in $style and saves them in $properties
  * as key - value pairs, e.g. $properties ['color'] = 'red'. It also adjusts the values
  * for the ODT format and changes URLs to local paths if required, using $baseURL).
  *
  * @author LarsDW223
  * @param array $properties
  * @param $style
  * @param null $baseURL
  */
 public function _processCSSStyle(&$properties, $style, $baseURL = NULL)
 {
     if ($this->import == NULL) {
         $this->import = new helper_plugin_odt_cssimport();
         if ($this->import == NULL) {
             // Failed to create helper. Can't proceed.
             return;
         }
     }
     // Create rule with selector '*' (doesn't matter) and declarations as set in $style
     $rule = new css_rule('*', $style);
     $rule->getProperties($properties);
     foreach ($properties as $property => $value) {
         $properties[$property] = $this->adjustValueForODT($property, $value, 14);
     }
     if (!empty($properties['background-image'])) {
         if (!empty($baseURL)) {
             // Replace 'url(...)' with $baseURL
             $properties['background-image'] = $this->import->replaceURLPrefix($properties['background-image'], $baseURL);
         }
     }
 }