From 68656728cf13ee1317e9082ae3705ca7bb7a1392 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ctibor=20Bran=C4=8D=C3=ADk?= Date: Wed, 23 Mar 2016 20:43:48 +0100 Subject: Add imagebox and note plugins. --- lib/plugins/imagebox/conf/default.php | 4 + lib/plugins/imagebox/conf/metadata.php | 4 + lib/plugins/imagebox/lang/ar/lang.php | 2 + lib/plugins/imagebox/lang/bg/lang.php | 2 + lib/plugins/imagebox/lang/ca/lang.php | 2 + lib/plugins/imagebox/lang/cs/lang.php | 2 + lib/plugins/imagebox/lang/da/lang.php | 2 + lib/plugins/imagebox/lang/de/lang.php | 2 + lib/plugins/imagebox/lang/el/lang.php | 2 + lib/plugins/imagebox/lang/en/lang.php | 2 + lib/plugins/imagebox/lang/eo/lang.php | 2 + lib/plugins/imagebox/lang/es/lang.php | 2 + lib/plugins/imagebox/lang/et/lang.php | 2 + lib/plugins/imagebox/lang/eu/lang.php | 2 + lib/plugins/imagebox/lang/fi/lang.php | 2 + lib/plugins/imagebox/lang/fo/lang.php | 2 + lib/plugins/imagebox/lang/fr/lang.php | 2 + lib/plugins/imagebox/lang/gl/lang.php | 2 + lib/plugins/imagebox/lang/he/lang.php | 2 + lib/plugins/imagebox/lang/hr/lang.php | 2 + lib/plugins/imagebox/lang/hu/lang.php | 2 + lib/plugins/imagebox/lang/id/lang.php | 2 + lib/plugins/imagebox/lang/it/lang.php | 2 + lib/plugins/imagebox/lang/ja/lang.php | 2 + lib/plugins/imagebox/lang/ko/lang.php | 2 + lib/plugins/imagebox/lang/ku/lang.php | 2 + lib/plugins/imagebox/lang/lt/lang.php | 2 + lib/plugins/imagebox/lang/lv/lang.php | 2 + lib/plugins/imagebox/lang/mg/lang.php | 2 + lib/plugins/imagebox/lang/nl/lang.php | 2 + lib/plugins/imagebox/lang/no/lang.php | 2 + lib/plugins/imagebox/lang/pl/lang.php | 2 + lib/plugins/imagebox/lang/pt/lang.php | 2 + lib/plugins/imagebox/lang/ro/lang.php | 2 + lib/plugins/imagebox/lang/ru/lang.php | 2 + lib/plugins/imagebox/lang/sk/lang.php | 2 + lib/plugins/imagebox/lang/sl/lang.php | 2 + lib/plugins/imagebox/lang/sr/lang.php | 2 + lib/plugins/imagebox/lang/sv/lang.php | 2 + lib/plugins/imagebox/lang/tr/lang.php | 2 + lib/plugins/imagebox/lang/uk/lang.php | 2 + lib/plugins/imagebox/lang/vi/lang.php | 2 + lib/plugins/imagebox/lang/zh/lang.php | 2 + lib/plugins/imagebox/magnify-clip.png | Bin 0 -> 267 bytes lib/plugins/imagebox/style.css | 60 ++++++++++ lib/plugins/imagebox/syntax.php | 119 +++++++++++++++++++ lib/plugins/note/.gitignore | 1 + lib/plugins/note/images/important.png | Bin 0 -> 2250 bytes lib/plugins/note/images/note.png | Bin 0 -> 2520 bytes lib/plugins/note/images/tb_important.png | Bin 0 -> 1366 bytes lib/plugins/note/images/tb_note.png | Bin 0 -> 1461 bytes lib/plugins/note/images/tb_tip.png | Bin 0 -> 1441 bytes lib/plugins/note/images/tb_warning.png | Bin 0 -> 1870 bytes lib/plugins/note/images/tip.png | Bin 0 -> 2909 bytes lib/plugins/note/images/warning.png | Bin 0 -> 3249 bytes lib/plugins/note/info.txt | 8 ++ lib/plugins/note/script.js | 36 ++++++ lib/plugins/note/style.css | 41 +++++++ lib/plugins/note/syntax.php | 191 +++++++++++++++++++++++++++++++ 59 files changed, 546 insertions(+) create mode 100755 lib/plugins/imagebox/conf/default.php create mode 100755 lib/plugins/imagebox/conf/metadata.php create mode 100755 lib/plugins/imagebox/lang/ar/lang.php create mode 100755 lib/plugins/imagebox/lang/bg/lang.php create mode 100755 lib/plugins/imagebox/lang/ca/lang.php create mode 100755 lib/plugins/imagebox/lang/cs/lang.php create mode 100755 lib/plugins/imagebox/lang/da/lang.php create mode 100755 lib/plugins/imagebox/lang/de/lang.php create mode 100755 lib/plugins/imagebox/lang/el/lang.php create mode 100755 lib/plugins/imagebox/lang/en/lang.php create mode 100755 lib/plugins/imagebox/lang/eo/lang.php create mode 100755 lib/plugins/imagebox/lang/es/lang.php create mode 100755 lib/plugins/imagebox/lang/et/lang.php create mode 100755 lib/plugins/imagebox/lang/eu/lang.php create mode 100755 lib/plugins/imagebox/lang/fi/lang.php create mode 100755 lib/plugins/imagebox/lang/fo/lang.php create mode 100755 lib/plugins/imagebox/lang/fr/lang.php create mode 100755 lib/plugins/imagebox/lang/gl/lang.php create mode 100755 lib/plugins/imagebox/lang/he/lang.php create mode 100755 lib/plugins/imagebox/lang/hr/lang.php create mode 100755 lib/plugins/imagebox/lang/hu/lang.php create mode 100755 lib/plugins/imagebox/lang/id/lang.php create mode 100755 lib/plugins/imagebox/lang/it/lang.php create mode 100755 lib/plugins/imagebox/lang/ja/lang.php create mode 100755 lib/plugins/imagebox/lang/ko/lang.php create mode 100755 lib/plugins/imagebox/lang/ku/lang.php create mode 100755 lib/plugins/imagebox/lang/lt/lang.php create mode 100755 lib/plugins/imagebox/lang/lv/lang.php create mode 100755 lib/plugins/imagebox/lang/mg/lang.php create mode 100755 lib/plugins/imagebox/lang/nl/lang.php create mode 100755 lib/plugins/imagebox/lang/no/lang.php create mode 100755 lib/plugins/imagebox/lang/pl/lang.php create mode 100755 lib/plugins/imagebox/lang/pt/lang.php create mode 100755 lib/plugins/imagebox/lang/ro/lang.php create mode 100755 lib/plugins/imagebox/lang/ru/lang.php create mode 100755 lib/plugins/imagebox/lang/sk/lang.php create mode 100755 lib/plugins/imagebox/lang/sl/lang.php create mode 100755 lib/plugins/imagebox/lang/sr/lang.php create mode 100755 lib/plugins/imagebox/lang/sv/lang.php create mode 100755 lib/plugins/imagebox/lang/tr/lang.php create mode 100755 lib/plugins/imagebox/lang/uk/lang.php create mode 100755 lib/plugins/imagebox/lang/vi/lang.php create mode 100755 lib/plugins/imagebox/lang/zh/lang.php create mode 100755 lib/plugins/imagebox/magnify-clip.png create mode 100755 lib/plugins/imagebox/style.css create mode 100755 lib/plugins/imagebox/syntax.php create mode 100644 lib/plugins/note/.gitignore create mode 100644 lib/plugins/note/images/important.png create mode 100644 lib/plugins/note/images/note.png create mode 100644 lib/plugins/note/images/tb_important.png create mode 100644 lib/plugins/note/images/tb_note.png create mode 100644 lib/plugins/note/images/tb_tip.png create mode 100644 lib/plugins/note/images/tb_warning.png create mode 100644 lib/plugins/note/images/tip.png create mode 100644 lib/plugins/note/images/warning.png create mode 100644 lib/plugins/note/info.txt create mode 100644 lib/plugins/note/script.js create mode 100644 lib/plugins/note/style.css create mode 100644 lib/plugins/note/syntax.php diff --git a/lib/plugins/imagebox/conf/default.php b/lib/plugins/imagebox/conf/default.php new file mode 100755 index 000000000..9d8a2655c --- /dev/null +++ b/lib/plugins/imagebox/conf/default.php @@ -0,0 +1,4 @@ + array('If necessary','Always','Never')); +$meta['center_align'] = array('onoff'); +$meta['default_caption_style'] = array('multichoice','_choices' => array('Normal','Italic','Bold')); \ No newline at end of file diff --git a/lib/plugins/imagebox/lang/ar/lang.php b/lib/plugins/imagebox/lang/ar/lang.php new file mode 100755 index 000000000..54c0c801b --- /dev/null +++ b/lib/plugins/imagebox/lang/ar/lang.php @@ -0,0 +1,2 @@ +, myst6re + */ + +if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); +if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); +require_once(DOKU_PLUGIN.'syntax.php'); + +class syntax_plugin_imagebox extends DokuWiki_Syntax_Plugin { + + function getInfo(){ + return array( + 'author' => 'FFTiger / myst6re', + 'email' => 'myst6re@wikisquare.com', + 'date' => '2010-05-30', + 'name' => 'Imagebox Plugin', + 'desc' => 'Entoure les images avec un cadre de décoration.', + 'url' => 'http://www.wikisquare.com/', + ); + } + + function getType(){ return 'protected'; } + function getAllowedTypes() { return array('substition','protected','disabled','formatting'); } + function getSort(){ return 315; } + function getPType(){ return 'block'; } + function connectTo($mode) { $this->Lexer->addEntryPattern('\[\{\{[^\|\}]+\|*(?=[^\}]*\}\}\])',$mode,'plugin_imagebox'); } + function postConnect() { $this->Lexer->addExitPattern('\}\}\]','plugin_imagebox'); } + + function handle($match, $state, $pos, &$handler){ + switch($state){ + case DOKU_LEXER_ENTER: + $match=Doku_Handler_Parse_Media(substr($match,3)); + $match['w'] = $match['width']; + $dispMagnify = ($match['w'] || $match['height']) && $this->getConf('display_magnify')=='If necessary' || $this->getConf('display_magnify')=='Always'; + + $gimgs = false; + list($src,$hash) = explode('#',$match['src'],2); + + 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($hash) $match['detail'] .= '#'.$hash; + } + + if($exists) $gimgs = @getImageSize(mediaFN($src)); + } + else { + if($dispMagnify) { + $match['detail'] = ml($src,array('cache'=>'cache'),false); + if($hash) $match['detail'] .= '#'.$hash; + } + + $gimgs = @getImageSize($src); + } + + $match['exist'] = $gimgs!==false; + + if(!$match['w'] && $match['exist']){ + ($match['height'])? + $match['w'] = $match['height']*$gimgs[0]/$gimgs[1]: + $match['w'] = $gimgs[0]; + } + + if(!$match['align'] || $match['align']=='center'&&!$this->getConf('center_align')) + $match['align'] = 'rien'; + return array($state,$match); + + case DOKU_LEXER_UNMATCHED: + return array($state,$match); + + case DOKU_LEXER_EXIT: + return array($state,$match); + } + } + + function render($mode, &$renderer, $data){ + if($mode == 'xhtml'){ + list($state,$match) = $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($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; + + case DOKU_LEXER_EXIT: + $renderer->doc.= '
'; + break; + } + return true; + } + return false; + } +} + +//Setup VIM: ex: et ts=4 enc=utf-8 : diff --git a/lib/plugins/note/.gitignore b/lib/plugins/note/.gitignore new file mode 100644 index 000000000..f3c7a7c5d --- /dev/null +++ b/lib/plugins/note/.gitignore @@ -0,0 +1 @@ +Makefile diff --git a/lib/plugins/note/images/important.png b/lib/plugins/note/images/important.png new file mode 100644 index 000000000..dc8c8a457 Binary files /dev/null and b/lib/plugins/note/images/important.png differ diff --git a/lib/plugins/note/images/note.png b/lib/plugins/note/images/note.png new file mode 100644 index 000000000..df1e0a926 Binary files /dev/null and b/lib/plugins/note/images/note.png differ diff --git a/lib/plugins/note/images/tb_important.png b/lib/plugins/note/images/tb_important.png new file mode 100644 index 000000000..d853518de Binary files /dev/null and b/lib/plugins/note/images/tb_important.png differ diff --git a/lib/plugins/note/images/tb_note.png b/lib/plugins/note/images/tb_note.png new file mode 100644 index 000000000..f5c931603 Binary files /dev/null and b/lib/plugins/note/images/tb_note.png differ diff --git a/lib/plugins/note/images/tb_tip.png b/lib/plugins/note/images/tb_tip.png new file mode 100644 index 000000000..f127e91c5 Binary files /dev/null and b/lib/plugins/note/images/tb_tip.png differ diff --git a/lib/plugins/note/images/tb_warning.png b/lib/plugins/note/images/tb_warning.png new file mode 100644 index 000000000..892c83393 Binary files /dev/null and b/lib/plugins/note/images/tb_warning.png differ diff --git a/lib/plugins/note/images/tip.png b/lib/plugins/note/images/tip.png new file mode 100644 index 000000000..2000f2085 Binary files /dev/null and b/lib/plugins/note/images/tip.png differ diff --git a/lib/plugins/note/images/warning.png b/lib/plugins/note/images/warning.png new file mode 100644 index 000000000..3c8a37df5 Binary files /dev/null and b/lib/plugins/note/images/warning.png differ diff --git a/lib/plugins/note/info.txt b/lib/plugins/note/info.txt new file mode 100644 index 000000000..5226345f4 --- /dev/null +++ b/lib/plugins/note/info.txt @@ -0,0 +1,8 @@ +# General Plugin Info do not edit + +author Olivier Cortès / Eric Hameleers / Christopher Smith / Aurélien Bompard +email olive@deep-ocean.net +date 2009-06-15 +name Note Plugin +desc Add Note/Important/Tip/Warning Capability (DIV+CSS box) +url http://www.dokuwiki.org/plugin:note diff --git a/lib/plugins/note/script.js b/lib/plugins/note/script.js new file mode 100644 index 000000000..c21120727 --- /dev/null +++ b/lib/plugins/note/script.js @@ -0,0 +1,36 @@ +/* Add Note buttons to the toolbar */ +/* from http://wiki.splitbrain.org/wiki:tips:toolbarbutton */ + +/* Disabled because this does not allow to select a text and turn it into a note like the type:format does +var notes_arr = new Array(); // key = insertion string , value = icon filename. +notes_arr['\\n']='tb_note.png'; +notes_arr['\\n']='tb_tip.png'; +notes_arr['\\n']='tb_important.png'; +notes_arr['\\n']='tb_warning.png'; + +toolbar[toolbar.length] = {"type":"picker", + "title":"Notes", + "icon":"../../plugins/note/images/tb_note.png", + "key":"", + "list": notes_arr, + "icobase":"../plugins/note/images"}; +*/ + +if(toolbar){ + toolbar[toolbar.length] = {"type":"format", "title":"note", "key":"", + "icon":"../../plugins/note/images/tb_note.png", + "open":"", "close":"" + }; + toolbar[toolbar.length] = {"type":"format", "title":"tip", "key":"", + "icon":"../../plugins/note/images/tb_tip.png", + "open":"", "close":"" + }; + toolbar[toolbar.length] = {"type":"format", "title":"important", "key":"", + "icon":"../../plugins/note/images/tb_important.png", + "open":"", "close":"" + }; + toolbar[toolbar.length] = {"type":"format", "title":"warning", "key":"", + "icon":"../../plugins/note/images/tb_warning.png", + "open":"", "close":"" + }; +} diff --git a/lib/plugins/note/style.css b/lib/plugins/note/style.css new file mode 100644 index 000000000..8b97dea06 --- /dev/null +++ b/lib/plugins/note/style.css @@ -0,0 +1,41 @@ +.noteclassic, .noteimportant, .notewarning, .notetip { + margin: 2em; + margin-left: auto; + margin-right: auto; + width: 70% !important; + min-height: 40px; + clear: both; + text-align: justify; + vertical-align: middle; + border-collapse: collapse; + padding: 15px 20px 15px 80px; + background-position: 20px 50%; + background-repeat: no-repeat; + -moz-border-radius: 20px; + -khtml-border-radius: 20px; + border-radius: 20px; +} + +.noteclassic { + /*border: 1px solid #99D;*/ + background-color: #eef; + background-image: url(images/note.png); +} + +.noteimportant { + /*border: 1px solid #ff0;*/ + background-color: #ffc; + background-image: url(images/important.png); +} + +.notewarning { + /*border: 1px solid #d99;*/ + background-color: #fdd; + background-image: url(images/warning.png); +} + +.notetip { + /*border: 1px solid #9d9;*/ + background-color: #dfd; + background-image: url(images/tip.png); +} diff --git a/lib/plugins/note/syntax.php b/lib/plugins/note/syntax.php new file mode 100644 index 000000000..368d0d412 --- /dev/null +++ b/lib/plugins/note/syntax.php @@ -0,0 +1,191 @@ +This is note + * This is note + * This is an important note + * This is a big warning + * This is a tip + * + * by Olivier Cortès + * under the terms of the GNU GPL v2. + * + * Originaly derived from the work of : + * Stephane Chamberland (Side Notes PlugIn) + * Carl-Christian Salvesen (Graphviz plugin) + * + * Contributions by Eric Hameleers : + * use
instead of , + * contain the images and stylesheet inside the plugin, + * permit nesting of notes, + * + * Contributed by Christopher Smith + * fix some parsing problems and a security hole. + * make note types case independent + * simplify code reading + * modernise the plugin for changes/fixes/improvements to the underlying Dokuwiki plugin class, + * improve efficiency. + * + * Contributed by Aurélien Bompard + * support for the ODT output format. + * + * @license GNU_GPL_v2 + * @author Olivier Cortes + */ + +if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); +if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); +require_once(DOKU_PLUGIN.'syntax.php'); + + +class syntax_plugin_note extends DokuWiki_Syntax_Plugin { + + var $notes = array( + 'noteimportant' => array('important', 'importante'), + 'notewarning' => array('warning','bloquante','critique'), + 'notetip' => array('tip','tuyau','idée'), + 'noteclassic' => array('','classic','classique') + ); + + var $default = 'noteclassic'; + + function getInfo(){ + return confToHash(dirname(__FILE__).'/info.txt'); + } + + + function getType(){ return 'container'; } + function getPType(){ return 'normal'; } + function getAllowedTypes() { + return array('container','substition','protected','disabled','formatting','paragraphs'); + } + function getSort(){ return 195; } + + // override default accepts() method to allow nesting + // - ie, to get the plugin accepts its own entry syntax + function accepts($mode) { + if ($mode == substr(get_class($this), 7)) return true; + return parent::accepts($mode); + } + + function connectTo($mode) { + $this->Lexer->addEntryPattern('(?=.*?)',$mode,'plugin_note'); + } + function postConnect() { + $this->Lexer->addExitPattern('','plugin_note'); + } + + function handle($match, $state, $pos, &$handler){ + + switch ($state) { + + case DOKU_LEXER_ENTER : + $note = strtolower(trim(substr($match,5,-1))); + + foreach( $this->notes as $class => $names ) { + if (in_array($note, $names)) + return array($state, $class); + } + + return array($state, $this->default); + + case DOKU_LEXER_UNMATCHED : + return array($state, $match); + + default: + return array($state); + } + } + + function render($mode, &$renderer, $indata) { + + if($mode == 'xhtml'){ + + list($state, $data) = $indata; + + switch ($state) { + case DOKU_LEXER_ENTER : + $renderer->doc .= '

'; + break; + + case DOKU_LEXER_UNMATCHED : + $renderer->doc .= $renderer->_xmlEntities($data); + break; + + case DOKU_LEXER_EXIT : + $renderer->doc .= "\n

"; + break; + } + return true; + + } elseif ($mode == 'odt'){ + + list($state, $data) = $indata; + + switch ($state) { + case DOKU_LEXER_ENTER : + $type = substr($data, 4); + if ($type == "classic") { + $type = "note"; // the icon for classic notes is named note.png + } + $colors = array("note"=>"#eeffff", "warning"=>"#ffdddd", "important"=>"#ffffcc", "tip"=>"#ddffdd"); + $renderer->autostyles["pluginnote"] = ' + + + '; + $renderer->autostyles["pluginnote.A"] = ' + + + '; + $renderer->autostyles["pluginnote.B"] = ' + + + '; + $renderer->autostyles["pluginnote".$type.".A1"] = ' + + + '; + $renderer->autostyles["pluginnote".$type.".B1"] = ' + + + '; + // Content + $renderer->p_close(); + $renderer->doc .= ''; + $renderer->doc .= ''; + $renderer->doc .= ''; + $renderer->doc .= ''; + $renderer->doc .= ''; + // Don't use p_open, as it's not the same style-name + $renderer->doc .= ''; + $src = DOKU_PLUGIN."note/images/".$type.".png"; + $renderer->_odtAddImage($src); + $renderer->doc .= ''; + $renderer->doc .= ''; + $renderer->doc .= ''; + $renderer->p_open(); + break; + + case DOKU_LEXER_UNMATCHED : + $renderer->cdata($data); + break; + + case DOKU_LEXER_EXIT : + $renderer->p_close(); + $renderer->doc .= ''; + $renderer->doc .= ''; + $renderer->doc .= ''; + $renderer->p_open(); + break; + } + return true; + } + + // unsupported $mode + return false; + } +} + +//Setup VIM: ex: et ts=4 enc=utf-8 : +?> -- cgit v1.2.3