slitaz-doc-wiki-data rev 14
Add note plugin.
author | Christopher Rogers <slaxemulator@gmail.com> |
---|---|
date | Mon Feb 28 08:27:54 2011 +0000 (2011-02-28) |
parents | a16cbb9788f2 |
children | df9950c99d41 |
files | plugins/note/images/important.png plugins/note/images/note.png plugins/note/images/tb_important.png plugins/note/images/tb_note.png plugins/note/images/tb_tip.png plugins/note/images/tb_warning.png plugins/note/images/tip.png plugins/note/images/warning.png plugins/note/info.txt plugins/note/script.js plugins/note/style.css plugins/note/syntax.php |
line diff
1.1 Binary file plugins/note/images/important.png has changed
2.1 Binary file plugins/note/images/note.png has changed
3.1 Binary file plugins/note/images/tb_important.png has changed
4.1 Binary file plugins/note/images/tb_note.png has changed
5.1 Binary file plugins/note/images/tb_tip.png has changed
6.1 Binary file plugins/note/images/tb_warning.png has changed
7.1 Binary file plugins/note/images/tip.png has changed
8.1 Binary file plugins/note/images/warning.png has changed
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 9.2 +++ b/plugins/note/info.txt Mon Feb 28 08:27:54 2011 +0000 9.3 @@ -0,0 +1,8 @@ 9.4 +# General Plugin Info do not edit 9.5 + 9.6 +author Olivier Cortès / Eric Hameleers / Christopher Smith / Aurélien Bompard 9.7 +email olive@deep-ocean.net 9.8 +date 2009-06-15 9.9 +name Note Plugin 9.10 +desc Add Note/Important/Tip/Warning Capability (DIV+CSS box) 9.11 +url http://www.dokuwiki.org/plugin:note
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 10.2 +++ b/plugins/note/script.js Mon Feb 28 08:27:54 2011 +0000 10.3 @@ -0,0 +1,36 @@ 10.4 +/* Add Note buttons to the toolbar */ 10.5 +/* from http://wiki.splitbrain.org/wiki:tips:toolbarbutton */ 10.6 + 10.7 +/* Disabled because this does not allow to select a text and turn it into a note like the type:format does 10.8 +var notes_arr = new Array(); // key = insertion string , value = icon filename. 10.9 +notes_arr['<note></note>\\n']='tb_note.png'; 10.10 +notes_arr['<note tip></note>\\n']='tb_tip.png'; 10.11 +notes_arr['<note important></note>\\n']='tb_important.png'; 10.12 +notes_arr['<note warning></note>\\n']='tb_warning.png'; 10.13 + 10.14 +toolbar[toolbar.length] = {"type":"picker", 10.15 + "title":"Notes", 10.16 + "icon":"../../plugins/note/images/tb_note.png", 10.17 + "key":"", 10.18 + "list": notes_arr, 10.19 + "icobase":"../plugins/note/images"}; 10.20 +*/ 10.21 + 10.22 +if(toolbar){ 10.23 + toolbar[toolbar.length] = {"type":"format", "title":"note", "key":"", 10.24 + "icon":"../../plugins/note/images/tb_note.png", 10.25 + "open":"<note>", "close":"</note>" 10.26 + }; 10.27 + toolbar[toolbar.length] = {"type":"format", "title":"tip", "key":"", 10.28 + "icon":"../../plugins/note/images/tb_tip.png", 10.29 + "open":"<note tip>", "close":"</note>" 10.30 + }; 10.31 + toolbar[toolbar.length] = {"type":"format", "title":"important", "key":"", 10.32 + "icon":"../../plugins/note/images/tb_important.png", 10.33 + "open":"<note important>", "close":"</note>" 10.34 + }; 10.35 + toolbar[toolbar.length] = {"type":"format", "title":"warning", "key":"", 10.36 + "icon":"../../plugins/note/images/tb_warning.png", 10.37 + "open":"<note warning>", "close":"</note>" 10.38 + }; 10.39 +}
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 11.2 +++ b/plugins/note/style.css Mon Feb 28 08:27:54 2011 +0000 11.3 @@ -0,0 +1,41 @@ 11.4 +.noteclassic, .noteimportant, .notewarning, .notetip { 11.5 + margin: 2em; 11.6 + margin-left: auto; 11.7 + margin-right: auto; 11.8 + width: 70% !important; 11.9 + min-height: 40px; 11.10 + clear: both; 11.11 + text-align: justify; 11.12 + vertical-align: middle; 11.13 + border-collapse: collapse; 11.14 + padding: 15px 20px 15px 80px; 11.15 + background-position: 20px 50%; 11.16 + background-repeat: no-repeat; 11.17 + -moz-border-radius: 20px; 11.18 + -khtml-border-radius: 20px; 11.19 + border-radius: 20px; 11.20 +} 11.21 + 11.22 +.noteclassic { 11.23 + /*border: 1px solid #99D;*/ 11.24 + background-color: #eef; 11.25 + background-image: url(images/note.png); 11.26 +} 11.27 + 11.28 +.noteimportant { 11.29 + /*border: 1px solid #ff0;*/ 11.30 + background-color: #ffc; 11.31 + background-image: url(images/important.png); 11.32 +} 11.33 + 11.34 +.notewarning { 11.35 + /*border: 1px solid #d99;*/ 11.36 + background-color: #fdd; 11.37 + background-image: url(images/warning.png); 11.38 +} 11.39 + 11.40 +.notetip { 11.41 + /*border: 1px solid #9d9;*/ 11.42 + background-color: #dfd; 11.43 + background-image: url(images/tip.png); 11.44 +}
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 12.2 +++ b/plugins/note/syntax.php Mon Feb 28 08:27:54 2011 +0000 12.3 @@ -0,0 +1,191 @@ 12.4 +<?php 12.5 +/** 12.6 + * Add Note capability to dokuwiki 12.7 + * 12.8 + * <note>This is note</note> 12.9 + * <note classic>This is note</note> 12.10 + * <note important>This is an important note</note> 12.11 + * <note warning>This is a big warning</note> 12.12 + * <note tip>This is a tip</note> 12.13 + * 12.14 + * by Olivier Cortès <olive@deep-ocean.net> 12.15 + * under the terms of the GNU GPL v2. 12.16 + * 12.17 + * Originaly derived from the work of : 12.18 + * Stephane Chamberland <stephane.chamberland@ec.gc.ca> (Side Notes PlugIn) 12.19 + * Carl-Christian Salvesen <calle@ioslo.net> (Graphviz plugin) 12.20 + * 12.21 + * Contributions by Eric Hameleers <alien [at] slackware [dot] com> : 12.22 + * use <div> instead of <table>, 12.23 + * contain the images and stylesheet inside the plugin, 12.24 + * permit nesting of notes, 12.25 + * 12.26 + * Contributed by Christopher Smith <chris [at] jalakai [dot] co [dot] uk> 12.27 + * fix some parsing problems and a security hole. 12.28 + * make note types case independent 12.29 + * simplify code reading 12.30 + * modernise the plugin for changes/fixes/improvements to the underlying Dokuwiki plugin class, 12.31 + * improve efficiency. 12.32 + * 12.33 + * Contributed by Aurélien Bompard <aurelien [at] bompard [dot] org> 12.34 + * support for the ODT output format. 12.35 + * 12.36 + * @license GNU_GPL_v2 12.37 + * @author Olivier Cortes <olive@deep-ocean.net> 12.38 + */ 12.39 + 12.40 +if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); 12.41 +if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 12.42 +require_once(DOKU_PLUGIN.'syntax.php'); 12.43 + 12.44 + 12.45 +class syntax_plugin_note extends DokuWiki_Syntax_Plugin { 12.46 + 12.47 + var $notes = array( 12.48 + 'noteimportant' => array('important', 'importante'), 12.49 + 'notewarning' => array('warning','bloquante','critique'), 12.50 + 'notetip' => array('tip','tuyau','idée'), 12.51 + 'noteclassic' => array('','classic','classique') 12.52 + ); 12.53 + 12.54 + var $default = 'noteclassic'; 12.55 + 12.56 + function getInfo(){ 12.57 + return confToHash(dirname(__FILE__).'/info.txt'); 12.58 + } 12.59 + 12.60 + 12.61 + function getType(){ return 'container'; } 12.62 + function getPType(){ return 'normal'; } 12.63 + function getAllowedTypes() { 12.64 + return array('container','substition','protected','disabled','formatting','paragraphs'); 12.65 + } 12.66 + function getSort(){ return 195; } 12.67 + 12.68 + // override default accepts() method to allow nesting 12.69 + // - ie, to get the plugin accepts its own entry syntax 12.70 + function accepts($mode) { 12.71 + if ($mode == substr(get_class($this), 7)) return true; 12.72 + return parent::accepts($mode); 12.73 + } 12.74 + 12.75 + function connectTo($mode) { 12.76 + $this->Lexer->addEntryPattern('<note.*?>(?=.*?</note>)',$mode,'plugin_note'); 12.77 + } 12.78 + function postConnect() { 12.79 + $this->Lexer->addExitPattern('</note>','plugin_note'); 12.80 + } 12.81 + 12.82 + function handle($match, $state, $pos, &$handler){ 12.83 + 12.84 + switch ($state) { 12.85 + 12.86 + case DOKU_LEXER_ENTER : 12.87 + $note = strtolower(trim(substr($match,5,-1))); 12.88 + 12.89 + foreach( $this->notes as $class => $names ) { 12.90 + if (in_array($note, $names)) 12.91 + return array($state, $class); 12.92 + } 12.93 + 12.94 + return array($state, $this->default); 12.95 + 12.96 + case DOKU_LEXER_UNMATCHED : 12.97 + return array($state, $match); 12.98 + 12.99 + default: 12.100 + return array($state); 12.101 + } 12.102 + } 12.103 + 12.104 + function render($mode, &$renderer, $indata) { 12.105 + 12.106 + if($mode == 'xhtml'){ 12.107 + 12.108 + list($state, $data) = $indata; 12.109 + 12.110 + switch ($state) { 12.111 + case DOKU_LEXER_ENTER : 12.112 + $renderer->doc .= '<p><div class="'.$data.'">'; 12.113 + break; 12.114 + 12.115 + case DOKU_LEXER_UNMATCHED : 12.116 + $renderer->doc .= $renderer->_xmlEntities($data); 12.117 + break; 12.118 + 12.119 + case DOKU_LEXER_EXIT : 12.120 + $renderer->doc .= "\n</div></p>"; 12.121 + break; 12.122 + } 12.123 + return true; 12.124 + 12.125 + } elseif ($mode == 'odt'){ 12.126 + 12.127 + list($state, $data) = $indata; 12.128 + 12.129 + switch ($state) { 12.130 + case DOKU_LEXER_ENTER : 12.131 + $type = substr($data, 4); 12.132 + if ($type == "classic") { 12.133 + $type = "note"; // the icon for classic notes is named note.png 12.134 + } 12.135 + $colors = array("note"=>"#eeffff", "warning"=>"#ffdddd", "important"=>"#ffffcc", "tip"=>"#ddffdd"); 12.136 + $renderer->autostyles["pluginnote"] = ' 12.137 + <style:style style:name="pluginnote" style:family="table"> 12.138 + <style:table-properties style:width="15cm" table:align="center" style:shadow="#808080 0.18cm 0.18cm"/> 12.139 + </style:style>'; 12.140 + $renderer->autostyles["pluginnote.A"] = ' 12.141 + <style:style style:name="pluginnote.A" style:family="table-column"> 12.142 + <style:table-column-properties style:column-width="1.5cm"/> 12.143 + </style:style>'; 12.144 + $renderer->autostyles["pluginnote.B"] = ' 12.145 + <style:style style:name="pluginnote.B" style:family="table-column"> 12.146 + <style:table-column-properties style:column-width="13.5cm"/> 12.147 + </style:style>'; 12.148 + $renderer->autostyles["pluginnote".$type.".A1"] = ' 12.149 + <style:style style:name="pluginnote'.$type.'.A1" style:family="table-cell"> 12.150 + <style:table-cell-properties style:vertical-align="middle" fo:padding="0.1cm" fo:border-left="0.002cm solid #000000" fo:border-right="none" fo:border-top="0.002cm solid #000000" fo:border-bottom="0.002cm solid #000000" fo:background-color="'.$colors[$type].'"/> 12.151 + </style:style>'; 12.152 + $renderer->autostyles["pluginnote".$type.".B1"] = ' 12.153 + <style:style style:name="pluginnote'.$type.'.B1" style:family="table-cell"> 12.154 + <style:table-cell-properties style:vertical-align="middle" fo:padding="0.3cm" fo:border-left="none" fo:border-right="0.002cm solid #000000" fo:border-top="0.002cm solid #000000" fo:border-bottom="0.002cm solid #000000" fo:background-color="'.$colors[$type].'"/> 12.155 + </style:style>'; 12.156 + // Content 12.157 + $renderer->p_close(); 12.158 + $renderer->doc .= '<table:table table:name="" table:style-name="pluginnote">'; 12.159 + $renderer->doc .= '<table:table-column table:style-name="pluginnote.A"/>'; 12.160 + $renderer->doc .= '<table:table-column table:style-name="pluginnote.B"/>'; 12.161 + $renderer->doc .= '<table:table-row>'; 12.162 + $renderer->doc .= '<table:table-cell table:style-name="pluginnote'.$type.'.A1" office:value-type="string">'; 12.163 + // Don't use p_open, as it's not the same style-name 12.164 + $renderer->doc .= '<text:p text:style-name="Table_20_Contents">'; 12.165 + $src = DOKU_PLUGIN."note/images/".$type.".png"; 12.166 + $renderer->_odtAddImage($src); 12.167 + $renderer->doc .= '</text:p>'; 12.168 + $renderer->doc .= '</table:table-cell>'; 12.169 + $renderer->doc .= '<table:table-cell table:style-name="pluginnote'.$type.'.B1" office:value-type="string">'; 12.170 + $renderer->p_open(); 12.171 + break; 12.172 + 12.173 + case DOKU_LEXER_UNMATCHED : 12.174 + $renderer->cdata($data); 12.175 + break; 12.176 + 12.177 + case DOKU_LEXER_EXIT : 12.178 + $renderer->p_close(); 12.179 + $renderer->doc .= '</table:table-cell>'; 12.180 + $renderer->doc .= '</table:table-row>'; 12.181 + $renderer->doc .= '</table:table>'; 12.182 + $renderer->p_open(); 12.183 + break; 12.184 + } 12.185 + return true; 12.186 + } 12.187 + 12.188 + // unsupported $mode 12.189 + return false; 12.190 + } 12.191 +} 12.192 + 12.193 +//Setup VIM: ex: et ts=4 enc=utf-8 : 12.194 +?>