Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions ODT/ODTImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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:
Expand Down Expand Up @@ -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);
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ODT/ODTUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
114 changes: 58 additions & 56 deletions ODT/css/cssimportnew.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1439,4 +1441,4 @@ public function replaceURLPrefixes ($callback) {
$rule->replaceURLPrefixes ($callback);
}
}
}
}
9 changes: 7 additions & 2 deletions helper/dwcssloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down