diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 531c750..0000000 --- a/.travis.yml +++ /dev/null @@ -1,14 +0,0 @@ -language: php -sudo: false -php: - - '5.3' - - '5.4' - - '5.5' - - '5.6' - - '7.0' - - hhvm - - nightly -matrix: - allow_failures: - - php: "hhvm" - diff --git a/conf/default.php b/conf/default.php index 9418c99..777161b 100755 --- a/conf/default.php +++ b/conf/default.php @@ -7,3 +7,4 @@ $conf['display_magnify'] = 'If necessary'; $conf['default_caption_style'] = 'Normal'; $conf['center_align'] = 1; +$conf['default_alignment'] = 'left'; \ No newline at end of file diff --git a/conf/metadata.php b/conf/metadata.php index 7bd135a..c835c3f 100755 --- a/conf/metadata.php +++ b/conf/metadata.php @@ -7,3 +7,4 @@ $meta['display_magnify'] = array('multichoice','_choices' => array('If necessary','Always','Never')); $meta['default_caption_style'] = array('multichoice','_choices' => array('Normal','Italic','Bold')); $meta['center_align'] = array('onoff'); +$meta['default_alignment'] = array('multichoice','_choices' => array('left','center','right')); diff --git a/lang/de-informal/lang.php b/lang/de-informal/lang.php index 750eabe..3fa6fe3 100644 --- a/lang/de-informal/lang.php +++ b/lang/de-informal/lang.php @@ -5,3 +5,4 @@ * @author FFTiger / myst6re */ $lang['enlarge'] = 'Vergrößern'; +$lang['invalid-image-file'] = 'ungültige Bild-Datei'; diff --git a/lang/de-informal/settings.php b/lang/de-informal/settings.php index 45a5405..3c111fa 100644 --- a/lang/de-informal/settings.php +++ b/lang/de-informal/settings.php @@ -5,6 +5,7 @@ * @author Rainbow_Spike rainbow_spike@derpy.ru */ // keys need to match the config setting name -$conf['display_magnify'] = 'Aktivieren Sie die Anzeige des symbols mit einer Lupe'; -$conf['default_caption_style'] = 'Standard-signaturstil'; -$conf['center_align'] = 'Signaturzentrierung erlauben'; +$conf['display_magnify'] = 'Zeige Lupensymbol neben Bildunterschrift'; +$conf['default_caption_style'] = 'Standard Untertitel-Stil'; +$conf['center_align'] = 'Erlaube zentrierte Ausrichtung.'; +$conf['default_alignment'] = 'Standard-Ausrichtung'; \ No newline at end of file diff --git a/lang/de/lang.php b/lang/de/lang.php index 750eabe..3fa6fe3 100755 --- a/lang/de/lang.php +++ b/lang/de/lang.php @@ -5,3 +5,4 @@ * @author FFTiger / myst6re */ $lang['enlarge'] = 'Vergrößern'; +$lang['invalid-image-file'] = 'ungültige Bild-Datei'; diff --git a/lang/de/settings.php b/lang/de/settings.php index 45a5405..ad7c60b 100644 --- a/lang/de/settings.php +++ b/lang/de/settings.php @@ -5,6 +5,7 @@ * @author Rainbow_Spike rainbow_spike@derpy.ru */ // keys need to match the config setting name -$conf['display_magnify'] = 'Aktivieren Sie die Anzeige des symbols mit einer Lupe'; -$conf['default_caption_style'] = 'Standard-signaturstil'; -$conf['center_align'] = 'Signaturzentrierung erlauben'; +$conf['display_magnify'] = 'Zeige Lupensymbol neben Bildunterschrift'; +$conf['default_caption_style'] = 'Standard Untertitel-Stil'; +$conf['center_align'] = 'Erlaube zentrierte Ausrichtung.'; +$conf['default_alignment'] = 'Standard-Ausrichtung für Bilder mit Bildunterschrift'; \ No newline at end of file diff --git a/lang/en/lang.php b/lang/en/lang.php index b26af35..e166dac 100755 --- a/lang/en/lang.php +++ b/lang/en/lang.php @@ -5,3 +5,4 @@ * @author FFTiger / myst6re */ $lang['enlarge'] = 'Enlarge'; +$lang['invalid-image-file'] = 'invalid image file'; \ No newline at end of file diff --git a/lang/en/settings.php b/lang/en/settings.php index ac37f8d..0babb0a 100644 --- a/lang/en/settings.php +++ b/lang/en/settings.php @@ -5,6 +5,7 @@ * @author Rainbow_Spike rainbow_spike@derpy.ru */ // keys need to match the config setting name -$lang['display_magnify'] = 'Enable displaying the icon with a magnifying glass'; -$lang['default_caption_style'] = 'Default signature style'; -$lang['center_align'] = 'Allow signature centering'; +$lang['display_magnify'] = 'Display magnifying glass in the caption'; +$lang['default_caption_style'] = 'Default caption style'; +$lang['center_align'] = 'Allow caption centering'; +$conf['default_alignment'] = 'Default alignment for images with caption'; \ No newline at end of file diff --git a/style.css b/style.css index 5bb4242..f8b57d9 100755 --- a/style.css +++ b/style.css @@ -1,67 +1,31 @@ -div.thumb2 { -margin-bottom:.5em; -padding-right:10px; -width:auto; -display:block +.imagebox{ + display: flex; + flex-direction: row; + gap: 10px; } -div.trien { -margin: .5em 1.4em .8em 0; +.imagebox.medialeft{ + margin:.2em 1em .2em 0; } - -div.tleft { -clear: left; -float: left; -margin: .5em 1.4em .8em 0; -} - -div.tright { -clear: right; -float: right; -margin: .5em 0 .8em 1.4em; +.imagebox.mediaright{ + margin:.2em 0 .2em 1em; } -div.tcenter { -clear:both; -text-align:center; -margin:.5em auto .8em +.imagebox.mediacenter{ + margin:.2em auto; + justify-content: center; } -div.thumb2 .thumbinner { -display: inline-block; -background-color: #F9F9F9; -border: 1px solid #CCC; -font-size: 94%; -overflow: hidden; -padding: 3px; +.imagebox figure{ + background-color: #F9F9F9; + border: 1px solid #CCC; + flex-flow: column; + padding: 5px; + margin: 0; } -div.thumb2 .mediabox2 { -background: #FFF none repeat scroll 0 0; -margin: 0; -} - -html .thumbcaption { -border: medium none; -font-size: 94%; -line-height: 1.4em; -padding: 3px; -text-align: left; -} - -div.thumb2 .magnify { -background: transparent none repeat scroll 0 0; -border: medium none !important; -float: right; -} -div.thumb2 .magnify a, -div.thumb2 .magnify img { -background: transparent none repeat scroll 0 0; -border: medium none !important; -display: block; -} - -div.thumb2 .interwiki { -background-position: 0 center; -padding-left: 17px; -} +.imagebox figcaption { + padding: 3px; + text-align: left; + margin: 0; +} \ No newline at end of file diff --git a/syntax.php b/syntax.php index 4b2dbed..4635cc7 100755 --- a/syntax.php +++ b/syntax.php @@ -22,9 +22,10 @@ function handle($match, $state, $pos, Doku_Handler $handler){ case DOKU_LEXER_ENTER: $match=Doku_Handler_Parse_Media(substr($match,3)); - $dispMagnify = ($match['width'] || $match['height']) && $this->getConf('display_magnify')=='If necessary' || $this->getConf('display_magnify')=='Always'; + $display_magnify = (isset($match['width']) || isset($match['height'])) && $this->getConf('display_magnify')=='If necessary' || $this->getConf('display_magnify')=='Always'; $image_size = false; + $mime_type = []; $result = explode('#',$match['src'],2); if (isset($result[0])){ @@ -37,22 +38,21 @@ function handle($match, $state, $pos, Doku_Handler $handler){ if(!empty($src)) { if ($match['type'] == 'internalmedia') { global $ID; + $exists = false; resolve_mediaid(getNS($ID), $src, $exists); - if ($dispMagnify) { - $match['detail'] = ml($src, array('id' => $ID, 'cache' => $match['cache']), ($match['linking'] == 'direct')); - if (isset($hash)) $match['detail'] .= '#' . $hash; - } - if ($exists){ + if ($display_magnify) { + $match['detail'] = ml($src, array('id' => $ID, 'cache' => $match['cache']), ($match['linking'] == 'direct')); + } + $image_size = @getImageSize(mediaFN($src)); $mime_type = explode('/',mime_content_type(mediaFN($src)),2); } } else { - if ($dispMagnify) { + if ($display_magnify) { $match['detail'] = ml($src, array('cache' => 'cache'), false); - if (isset($hash)) $match['detail'] .= '#' . $hash; } $image_size = @getImageSize($src); @@ -60,6 +60,9 @@ function handle($match, $state, $pos, Doku_Handler $handler){ } } + if (isset($hash)) $match['detail'] .= '#' . $hash; + + $match['exist'] = ($image_size!==false || (isset($mime_type[0]) && $mime_type[0] == "image")) ; if($match['exist']){ @@ -76,15 +79,22 @@ function handle($match, $state, $pos, Doku_Handler $handler){ } } - if(!$match['align'] /*|| $match['align']=='center'*/&&!$this->getConf('center_align')) - $match['align'] = 'rien'; + if(!isset($match['align'])){ + $match['align'] = $this->getConf('default_alignment'); + }else{ + if($match['align']=='center' && !$this->getConf('center_align')){ + $match['align'] = $this->getConf('default_alignment'); + }elseif($match['align']!='left' || $match['align']!='center' || $match['align']!='right'){ + $match['align'] = $this->getConf('default_alignment'); + } + } return array($state,$match); case DOKU_LEXER_UNMATCHED: - return array($state,$match); + return array($state,$match); case DOKU_LEXER_EXIT: - return array($state,$match); + return array($state,$match); } } @@ -102,6 +112,7 @@ function render($mode, Doku_Renderer $renderer, $data){ if(media_isexternal($src)) { $renderer->externalmedia($src, $match['title']); } else { + $exists = false; resolve_mediaid(getNS($ID), $src, $exists); $renderer->internalmedia($src, $match['title']); @@ -110,7 +121,6 @@ function render($mode, Doku_Renderer $renderer, $data){ unset($renderer->persistent['relation']['media'][$src]); } } - } } @@ -120,29 +130,34 @@ function render($mode, Doku_Renderer $renderer, $data){ switch($state){ case DOKU_LEXER_ENTER: - $renderer->doc.= '
'; - if($match['exist']) - $renderer->{$match['type']}($match['src'],$match['title'],'box2',$match['width'],$match['height'],$match['cache'],$match['linking']); - else - $renderer->doc.= 'Invalid Link'; - $renderer->doc.= '
'; - if(isset($match['detail'])) { - $renderer->doc.= ''; - } - break; - + $renderer->doc.= '
'; + $renderer->doc.= '
'; + if($match['exist']) { + $renderer->{$match['type']}($match['src'], $match['title'], 'box2', $match['width'], $match['height'], $match['cache'], $match['linking']); + }else{ + $renderer->doc.= $this->getLang('invalid-image-file'); + } + $renderer->doc.= '
'; + if(isset($match['detail'])) { + $renderer->doc.= ''; + } + break; case DOKU_LEXER_UNMATCHED: - $style=$this->getConf('default_caption_style'); - if($style=='Italic') $renderer->doc .= ''.$renderer->_xmlEntities($match).''; - elseif($style=='Bold') $renderer->doc .= ''.$renderer->_xmlEntities($match).''; - else $renderer->doc .= $renderer->_xmlEntities($match); - break; - + $style=$this->getConf('default_caption_style'); + if($style=='Italic'){ + $renderer->doc .= ''.$renderer->_xmlEntities($match).''; + } + elseif($style=='Bold'){ + $renderer->doc .= ''.$renderer->_xmlEntities($match).''; + }else{ + $renderer->doc .= $renderer->_xmlEntities($match); + } + break; case DOKU_LEXER_EXIT: - $renderer->doc.= '
'; + $renderer->doc.= '
'; break; } return true;