diff --git a/ODT/ODTImport.php b/ODT/ODTImport.php index 1df4fc1..ecb7d48 100644 --- a/ODT/ODTImport.php +++ b/ODT/ODTImport.php @@ -292,13 +292,13 @@ static protected function importOrderedListStyles(ODTInternalParams $params, css $paddingLeft = 0; if ( isset($properties ['padding-left']) ) { $paddingLeft = $params->units->toCentimeters($properties ['padding-left'], 'y'); - $paddingLeft = substr($paddingLeft, 0, -2); + $paddingLeft = trim($paddingLeft, 'cm'); } } $marginLeft = 1; if ( isset($li_properties ['margin-left']) ) { $marginLeft = $params->units->toCentimeters($li_properties ['margin-left'], 'y'); - $marginLeft = substr($marginLeft, 0, -2); + $marginLeft = trim($marginLeft, 'cm'); } // Set list params. $params->document->setOrderedListParams($level, $listAlign, $paddingLeft, $marginLeft); @@ -308,7 +308,7 @@ static protected function importOrderedListStyles(ODTInternalParams $params, css // (see replaceURLPrefixes) $file = $properties ['list-style-image']; - $this->setListStyleImage ($params, $style, $level, $file); + self::setListStyleImage ($params, $style, $level, $file); } // Workaround for ODT format: @@ -433,13 +433,13 @@ static protected function importUnorderedListStyles(ODTInternalParams $params, c $paddingLeft = 0; if (isset($properties ['padding-left'])) { $paddingLeft = $params->units->toCentimeters($properties ['padding-left'], 'y'); - $paddingLeft = substr($paddingLeft, 0, -2); + $paddingLeft = trim($paddingLeft, 'cm'); } } $marginLeft = 1; if (isset($li_properties ['margin-left'])) { $marginLeft = $params->units->toCentimeters($li_properties ['margin-left'], 'y'); - $marginLeft = substr($marginLeft, 0, -2); + $marginLeft = trim($marginLeft, 'cm'); } // Set list params. $params->document->setUnorderedListParams($level, $listAlign, $paddingLeft, $marginLeft); @@ -455,7 +455,7 @@ static protected function importUnorderedListStyles(ODTInternalParams $params, c } $file = $media_path.$file;*/ - $this->setListStyleImage ($params, $style, $level, $file); + self::setListStyleImage ($params, $style, $level, $file); } // Workaround for ODT format: @@ -529,17 +529,18 @@ static protected function importTableStyles(ODTInternalParams $params, cssdocume // If the style imported is a table adjust some properties if ($style->getFamily() == 'table') { // Move 'width' to 'rel-width' if it is relative - $width = $properties ['width']; - if (isset($width)) { + if (isset($properties ['width'])) { + $width = $properties ['width']; if (!isset($properties ['align'])) { // If width is set but align not, changing the width // will not work. So we set it here if not done by the user. $properties ['align'] = 'center'; } - } - if ($width [strlen($width)-1] == '%') { - $properties ['rel-width'] = $width; - unset ($properties ['width']); + + if ($width [strlen($width)-1] == '%') { + $properties ['rel-width'] = $width; + unset ($properties ['width']); + } } // Convert property 'border-model' to ODT diff --git a/ODT/ODTUtility.php b/ODT/ODTUtility.php index 3fd03ea..18c5b43 100644 --- a/ODT/ODTUtility.php +++ b/ODT/ODTUtility.php @@ -198,7 +198,7 @@ public static function getImageSize($src, $maxwidth=NULL, $maxheight=NULL){ $info = getimagesize($src); } else { // FIXME: Add cache support for downloaded images. - $fetch = (new DokuHTTPClient())->get($src); + $fetch = @(new DokuHTTPClient())->get($src); if(!$fetch) { return array(0, 0); } diff --git a/ODT/css/cssimportnew.php b/ODT/css/cssimportnew.php index 9efde6e..a091692 100644 --- a/ODT/css/cssimportnew.php +++ b/ODT/css/cssimportnew.php @@ -70,61 +70,63 @@ public function matches (array $attributes=NULL) { // Attribute should be present return isset($attributes) && array_key_exists($this->attribute, $attributes); } else { - switch ($this->operator) { - case '=': - // Attribute should have exactly the value $this->value - if (isset($attributes[$this->attribute]) && $attributes[$this->attribute] == $this->value) { - return true; - } else { - return false; - } - break; - - case '~=': - // Attribute value should contain the word $this->value - $words = preg_split ('/\s/', $attributes [$this->attribute]); - if (array_search($this->value, $words) !== false) { - return true; - } else { - return false; - } - break; - - case '|=': - // Attribute value should contain the word $this->value - // or a word starting with $this->value.'-' - $with_hypen = $this->value.'-'; - $length = strlen ($with_hypen); - if ($attributes [$this->attribute] == $this->value || - strncmp($attributes [$this->attribute], $with_hypen, $length) == 0) { - return true; - } - break; - - case '^=': - // Attribute value should contain - // a word starting with $this->value - $length = strlen ($this->value); - if (strncmp($attributes [$this->attribute], $this->value, $length) == 0) { - return true; - } - break; - - case '$=': - // Attribute value should contain - // a word ending with $this->value - $length = -1 * strlen ($this->value); - if (substr($attributes [$this->attribute], $length) == $this->value) { - return true; - } - break; - - case '*=': - // Attribute value should include $this->value - if (isset($attributes[$this->attribute]) && strpos($attributes [$this->attribute], $this->value) !== false) { - return true; - } - break; + if(isset($attributes[$this->attribute])) { + switch ($this->operator) { + case '=': + // Attribute should have exactly the value $this->value + if ($attributes[$this->attribute] == $this->value) { + return true; + } else { + return false; + } + break; + + case '~=': + // Attribute value should contain the word $this->value + $words = preg_split ('/\s/', $attributes [$this->attribute]); + if (array_search($this->value, $words) !== false) { + return true; + } else { + return false; + } + break; + + case '|=': + // Attribute value should contain the word $this->value + // or a word starting with $this->value.'-' + $with_hypen = $this->value.'-'; + $length = strlen ($with_hypen); + if ($attributes [$this->attribute] == $this->value || + strncmp($attributes [$this->attribute], $with_hypen, $length) == 0) { + return true; + } + break; + + case '^=': + // Attribute value should contain + // a word starting with $this->value + $length = strlen ($this->value); + if (strncmp($attributes [$this->attribute], $this->value, $length) == 0) { + return true; + } + break; + + case '$=': + // Attribute value should contain + // a word ending with $this->value + $length = -1 * strlen ($this->value); + if (substr($attributes [$this->attribute], $length) == $this->value) { + return true; + } + break; + + case '*=': + // Attribute value should include $this->value + if (strpos($attributes [$this->attribute], $this->value) !== false) { + return true; + } + break; + } } } return false; @@ -1439,4 +1441,4 @@ public function replaceURLPrefixes ($callback) { $rule->replaceURLPrefixes ($callback); } } -} \ No newline at end of file +} diff --git a/helper/dwcssloader.php b/helper/dwcssloader.php index 3eb26bb..481b4e3 100644 --- a/helper/dwcssloader.php +++ b/helper/dwcssloader.php @@ -61,8 +61,13 @@ public function load($plugin_name, $format, $template) { $styleini = css_styleini($template); } else { // Greebo functionality - $styleUtils = new \dokuwiki\StyleUtils(); - $styleini = $styleUtils->cssStyleini($template); + $this->config = plugin_load('helper', 'odt_config'); + if($this->config->getParam('css_usage') !== "off (plugins only)") { + $styleUtils = new \dokuwiki\StyleUtils($template); + } else { + $styleUtils = new \dokuwiki\StyleUtils(); + } + $styleini = $styleUtils->cssStyleini($template); // older versions need still the template } $template_files = array();