source: documentation/trunk/packages/dokuwiki-2011-05-25a/data/pages/wiki/development.txt@ 30100

Last change on this file since 30100 was 30100, checked in by jmt12, 9 years ago

Updating the development page with the lastest changes (which appear to be a fix for a weird problem where the string preference was being replaced with CSS randomly, so I changed the style name to preftitle)

File size: 40.4 KB
Line 
1====== Development ======
2
3===== Frequently Asked Questions =====
4
5==== Q. How do you enable login to wiki using Greenstone registration? ====
6
7The code changes to allow for Greenstone registration integration should already be present in the dokuwiki retrieved from Greenstone's SVN. To configure the dokuwiki for login follow these instructions:
8 - Copy ''<dokuwiki>/conf/mysql.conf.php.example'' to ''<dokuwiki>/conf/mysql.conf.php''
9 - Edit the ''mysql.conf.php'' file to have the correct details:<code>$conf['auth']['mysql']['server'] = 'localhost';
10$conf['auth']['mysql']['user'] = 'greenstonewiki';
11$conf['auth']['mysql']['password'] = '********';
12$conf['auth']['mysql']['database'] = 'gs_services';</code>
13 - While still in the conf directory, create a file ''local.protected.php'' with the content:<code><?php
14require_once('mysql.conf.php');
15?></code>
16 - Edit the file ''local.php'' and ammend/add the line:<code>...
17$conf['authtype'] = 'mysql';
18...</code>
19 - Ensure the permissions for all three files you've edited are correct as to be readble by the //nzdl// group
20 - Disable Dokuwiki's built-in register and email new password abilities by editing ''<dokuwiki>/conf/local.php'' and adding (or updating):<code>$conf['disableactions'] = 'register,resendpwd';</code>Alternatively, you can set these in the "Configuration Settings" page within the "Admin" page. **Note** a later customization step will add back in links to the global Greenstone registration system.
21
22==== Q. How do I create a page? ====
23
24The easiest way is to use the search box in the left navigation to search for a page that isn't already created. Include in the search any path/namespace as required. For instance, we (originally) created this page by searching for:<code>faq</code>but we could have included a path like so:<code>Manuals:User:Section1</code>which would create a ''Manuals'' folder, with a ''User'' folder within it, and finally the ''Section1'' page within that.
25
26When you search for a page that isn't there, the result page will helpfully suggest //"If you didn't find what you were looking for, you can create or edit the page named after your query with the appropriate button."// However, instead of a button, in this page template you'll need to click the tab at the top of the search results page labelled ''create this page''. If it all works you should find yourself in a textarea editor entering content for the page. Click ''Preview'' to review your content for formatting etc, and ''Save'' to commit changes to the page.
27
28===== Installation =====
29
30 - Checkout the ''gsdl-docs'' package out of SVN
31 - Go to ''<gsdl-docs>/lib/dokuwiki/'' and untar the [[http://www.dokuwiki.org/dokuwiki|dokuwiki]] tarball (currently the stable version [[http://www.splitbrain.org/_media/projects/dokuwiki/dokuwiki-2011-05-25a.tgz|Ricewind]])
32 - Go back up to ''<gsdl-docs>/'' and create a symlink to the folder you just unpacked called just ''dokuwiki'':<code>ln -s ./lib/dokuwiki/dokuwiki-<version> ./dokuwiki</code>
33 - Copy all of the archive files in ''<gsdl-docs>/lib/dokuwiki/plugins/'' into ''<gsdl-docs>/dokuwiki/lib/plugins/'', then unpack
34 * **note** you may need to rename the plugin folders---you'll find Dokuwiki will complain about incorrectly named folders at startup
35 - Similarly, copy the ''monobook'' template archive from ''<gsdl-docs>/lib/dokuwiki/templates'' to ''<gsdl-docs>/dokuwiki/lib/tpl/'' and unpack
36 - Setup your webserver (as needed) so you can access this dokuwiki directory and run the PHP scripts therein
37 - Visit the dokuwiki installer page in a web browser. For example, if you're webserver is running on ''localhost'', at port ''8080'', and the path to ''<gsdl-docs>/'' //is// ''/gsdl-docs'', then visit:<code>http://localhost:8080/gsdl-docs/dokuwiki/install.php</code>
38 - Follow the setup instructions, and then follow the recommended [[http://www.dokuwiki.org/security|security settings]] for Dokuwiki, including renaming the ''install.php'' file
39 - Overwrite the default configuration by copying the file ''<gsdl-docs>/lib/dokuwiki/conf/local.php'' to ''<gsdl-docs>/dokuwiki/conf/'' overwriting the existing file
40 - Recursively copy the starting pages file into place, overwriting existing files if prompted<code>cp -r <gsdl-docs>/lib/dokuwiki/pages/ <gsdl-docs>/dokuwiki/data/pages/</code>
41 * **note** there is a copy of these instructions in the starting files, located at [[wiki:development]]
42 - Enter ''<gsdl-docs>/lib/php/''
43 - Run each of these commands in order to transform the manual's XML files into Dokuwiki pages:<code>php gs-manuals-import.php -m user
44php gs-manuals-import.php -m install
45php gs-manuals-import.php -m develop
46php gs-manuals-import.php -m paper</code>
47 * **note** these require a command line version of PHP to be available on the path
48 - Enter the wiki again, log in using the administrator account you created when installing, and then visit each manual wiki page, 'edit' it and click approve
49===== Required Plugins =====
50
51 * [[http://www.dokuwiki.org/plugin:captcha|Captcha]] - Use a CAPTCHA challenge to protect DokuWiki against automated spam
52 * [[http://wiki.splitbrain.org/plugin:code2|Code2]] - Enhanced code syntax highlighting with line numbering
53 * [[http://wiki.splitbrain.org/plugin:htmlcomment|HTMLComment]] - allows HTML comments to be retained in the output
54 * [[http://wiki.splitbrain.org/plugin:ifauth|IFAuth]] - so content only for specific groups and/or users
55 * [[http://wiki.splitbrain.org/plugin:imagereference|ImageReference]] - create image references like latex is doing with figures
56 * [[http://dokuwiki.org/plugin:orphanswanted|OrphansWanted]] - provide macros to list orphan pages and wanted pages
57 * [[http://www.dokuwiki.org/plugin:publish|Publish]] - integrate a publishing process into DokuWiki (differentiating between draft and approved copies of pages)
58 * [[http://www.dokuwiki.org/plugin:tablewidth|TableWidth]] - allows the width of tables and table cells to be defined
59 * [[:wiki:development#custom_plugins|SimpleTabs]] - as explained below.
60
61===== Customizations =====
62
63**Note:** The diffs regarding the main Dokuwiki code are against the stable release 2011-05-25a "Rincewind".
64==== Dokuwiki ====
65
66=== inc/common.php ===
67
68^ File ^ Changes ^
69^ inc/common.php | Allow for 'no change' submissions as long as the Approve flag is ticked (see documentation for [[http://www.dokuwiki.org/plugin:publish|plugin:publish]]) |
70| <code diff u>
71--- dokuwiki-2011-05-25a/inc/common.php 2011-06-15 07:58:53.000000000 +1200
72+++ dokuwiki/inc/common.php 2012-01-17 13:53:12.860063701 +1300
73@@ -973,7 +973,8 @@
74 global $lang;
75 global $REV;
76 // ignore if no changes were made
77- if($text == rawWiki($id,'')){
78+ // - [jmt12] unless the approved checkbox is set
79+ if(!$_POST['approved'] && $text == rawWiki($id,'')){
80 return;
81 }
82</code> ||
83
84=== inc/html.php ===
85
86^ File ^ Changes ^
87^ inc/html.php | Add id attributes to the table of contents list items so we can hide the ones on currently hidden tabs. Allow for a 'reset' header to be specified by the user in order to 'break out of' the current TOC nesting (for instance, at the end of a tabbed area to prevent following headings being grouped under Tab area headings). |
88| <code diff u>
89--- html.original.php 2014-03-13 11:16:37.000000000 +1300
90+++ html.php 2014-03-13 11:13:34.000000000 +1300
91@@ -758,9 +758,28 @@ function html_li_index($item){
92 *
93 * @author Andreas Gohr <[email protected]>
94 */
95+// In order to alter the TOC when a user changes a tab, we
96+// need some way to uniquely identify what titles lurk in
97+// what tabs. Dokuwiki automagically labels headers with
98+// <a name=""> tags - so if I use the same information here
99+// they should match (and be unique etc)
100+// - jmt12
101+// At some stage the traditional 'link' attribute was (some-
102+// times) replaced with information in 'hid'
103+// - jmt12 2014MAR13
104 function html_li_default($item)
105 {
106- return '<li class="level' . $item['level'] . '">';
107+ $link = $item['link'];
108+ if (isset($item['hid']) && !empty($item['hid']))
109+ {
110+ $link = $item['hid'];
111+ }
112+ $hash_pos = strpos($link, '#');
113+ if ($hash_pos !== false)
114+ {
115+ $link = substr($link, $hash_pos + 1);
116+ }
117+ return '<li id="toc_' . $link . '" class="level' . $item['level'] . '">';
118 }
119
120 /**
121@@ -784,7 +803,24 @@ function html_buildlist($data,$class,$fu
122 $ret = '';
123
124 foreach ($data as $item){
125- if( $item['level'] > $level ){
126+ // A reset closes all TOC items, all the way back to the top
127+ if ($item['title'] == '#')
128+ {
129+ //close last item
130+ $ret .= "</li>\n";
131+ while( $level > 0 && $open > 0 ){
132+ //close higher lists
133+ $ret .= "</ul>\n</li>\n";
134+ $level--;
135+ $open--;
136+ }
137+ // open a dummy item list, although we don't output a list item
138+ $ret .= "<li class=\"clear\">\n<ul class=\"$class\">\n<li class=\"clear\">";
139+ $level++;
140+ $open++;
141+ // skip to next item
142+ continue;
143+ }elseif( $item['level'] > $level ){
144 //open new list
145 for($i=0; $i<($item['level'] - $level); $i++){
146 if ($i) $ret .= "<li class=\"clear\">\n";
147</code>||
148
149
150=== inc/lang/en/login.txt ===
151
152^ File ^ Changes ^
153^ inc/lang/en/login.txt | Add a link to the global Greenstone registration / password reset page (because we have disabled Dokuwiki's built-in user stuff at the top of this page). |
154| <code diff u>
155--- dokuwiki-2011-05-25a/inc/lang/en/login.txt 2012-02-09 10:17:32.000000000 +1300
156+++ greenstone-wiki/inc/lang/en/login.txt 2013-10-24 12:12:14.000000000 +1300
157@@ -2,3 +2,4 @@
158
159 You are currently not logged in! Enter your authentication credentials below to log in. You need to have cookies enabled to log in.
160
161+Don't have an account? [[http://www.greenstone.org/users?&returnto=GreenstoneWiki|Create an account or email new password]].
162</code>||
163=== inc/parserutils.php ===
164
165^ File ^ Changes ^
166^ inc/parserutils.php | Add a check to an introspective call to ensure that the function called exists in the class //before// calling it - otherwise the logs fill up with warnings from classes that don't (i.e. ''Doku_Renderer_metadata'') |
167| <code diff u>
168--- /greenstone/greenstone-documentation/packages/dokuwiki-2011-05-25a/inc/parserutils.php 2012-02-01 16:03:06.000000000 +1300
169+++ parserutils.php 2013-09-19 10:46:58.000000000 +1200
170@@ -522,7 +522,12 @@ function p_render_metadata($id, $orig){
171 // loop through the instructions
172 foreach ($instructions as $instruction){
173 // execute the callback against the renderer
174- call_user_func_array(array(&$renderer, $instruction[0]), (array) $instruction[1]);
175+ // - check we can, first, otherwise logs fill up with warnings
176+ $handler = array(&$renderer, $instruction[0]);
177+ if (is_callable($handler))
178+ {
179+ call_user_func_array($handler, (array) $instruction[1]);
180+ }
181 }
182
183 $evt->result = array('current'=>&$renderer->meta,'persistent'=>&$renderer->persistent);
184</code>||
185=== inc/parser/handler.php ===
186
187^ File ^ Changes ^
188^ inc/parser/handler.php | Hide HTML comments (namely text ids) in headings |
189| <code diff u>
190--- dokuwiki-2011-05-25a/inc/parser/handler.php 2011-06-15 07:58:54.000000000 +1200
191+++ dokuwiki/inc/parser/handler.php 2011-12-16 11:37:45.036066485 +1300
192@@ -97,6 +97,9 @@
193 $title = trim($title,'=');
194 $title = trim($title);
195
196+ // Hide HTML comments [jmt12]
197+ $title = preg_replace('/<\!--[^>]*-->/','',$title);
198+
199 if ($this->status['section']) $this->_addCall('section_close',array(),$pos);
200
201 $this->_addCall('header',array($title,$level,$pos), $pos);
202</code> ||
203
204=== inc/parser/xhtml.php ===
205
206^ File ^ Changes ^
207^ inc/parser/xhtml.php | Hide the reset header (whose content is simply "#"). Heavily altered //_highlight()// in order to allow the id specifying HTML comments to remain hidden. Added macro to external urls to allow for links to pages on the same host. |
208| <code diff u>
209--- dokuwiki-2011-05-25a/inc/parser/xhtml.php 2011-06-15 07:58:54.000000000 +1200
210+++ dokuwiki/inc/parser/xhtml.php 2012-01-23 13:16:49.317187175 +1300
211@@ -170,6 +170,12 @@
212 }
213 $this->lastlevel = $level;
214
215+ // Hide the 'reset' header
216+ if ($text == '#')
217+ {
218+ return;
219+ }
220+
221 if ($level <= $conf['maxseclevel'] &&
222 count($this->sectionedits) > 0 &&
223 $this->sectionedits[count($this->sectionedits) - 1][2] === 'section') {
224
225@@ -449,19 +449,24 @@
226 $text = substr($text, 0, -1);
227 }
228
229+ // - code HTML is now temporarily stored in a local string so we can
230+ // restore specific HTML comments [jmt12]
231+ $code_text = '';
232 if ( is_null($language) ) {
233- $this->doc .= '<pre class="'.$type.'">'.$this->_xmlEntities($text).'</pre>'.DOKU_LF;
234+ $code_text = '<pre class="'.$type.'">'.$this->_xmlEntities($text).'</pre>'.DOKU_LF; // [jmt12]
235 } else {
236 $class = 'code'; //we always need the code class to make the syntax highlighting apply
237 if($type != 'code') $class .= ' '.$type;
238
239- $this->doc .= "<pre class=\"$class $language\">".p_xhtml_cached_geshi($text, $language, '').'</pre>'.DOKU_LF;
240+ $code_text = "<pre class=\"$class $language\">".p_xhtml_cached_geshi($text, $language, '').'</pre>'.DOKU_LF; // [jmt12]
241 }
242+ // - restore id comments! [jmt12]
243+ $code_text = preg_replace('/\&lt\;\!\-\-\s+id\:([^\s]+)\s+\-\-\&gt\;/','<!-- id:\1 -->', $code_text);
244+ $this->doc .= $code_text; // [jmt12]
245
246 if($filename){
247 $this->doc .= '</dd></dl>'.DOKU_LF;
248 }
249
250 $this->_codeblock++;
251 }
252
253@@ -665,6 +670,16 @@
254 $class='media';
255 }
256
257+ // [jmt12] Replace the macro ~~localhost~~ with the hostname (and port
258+ // number if necessary) of the current host
259+ if (preg_match('/^http:\/\/~~baseurl~~(\/.*)$/', $url, $matches))
260+ {
261+ $host = $_SERVER['HTTP_HOST'];
262+ $path = substr($_SERVER['REQUEST_URI'], 0, strrpos($_SERVER['REQUEST_URI'], '/'));
263+ $url = 'http://' . $host . $path . $matches[1];
264+ }
265+ // [jmt12]
266+
267 //prepare for formating
268 $link['target'] = $conf['target']['extern'];
269 $link['style'] = '';
270</code> ||
271===== Plugins =====
272
273==== Custom Plugins ====
274
275=== SimpleTabs ===
276
277Support for simple tabbed areas (as compared to the existing complicated tabbed area plugins ala [[https://www.dokuwiki.org/plugin:tabinclude|TabInclude]]) is provided through a custom-built plugin. To reinstall:
278 * download {{:wiki:simpletabs-2014dec05.tgz|SimpleTabs}} (5.5K)
279 * extract to ''<dokuwiki>/lib/plugins/''
280The syntax looks like this:<code><TABAREA tabs="comma,separated,list">
281<TAB>content for 'comma' //including// wiki <del>magic</del> formatting</TAB>
282<TAB>content for 'separated' and a [[:playground|link]]</TAB>
283<TAB>content for 'list'</TAB>
284</TABAREA></code>
285
286Older versions: {{:wiki:simpletabs-2013sep18.tgz|2013SEP18}} (5.0K) {{:wiki:simpletabs-2013aug02.tgz|2013AUG02}} (4.3K)
287==== Code ====
288
289Diff against [[http://wiki.splitbrain.org/plugin:code2|code2]] plugin dated 2008-07-22.
290
291^ File ^ Changes ^
292^ syntax.php | Restore the HTML comments containing text fragment ids to be proper hidden comments. |
293| <code diff u>
294--- dokuwiki-2011-05-25a/lib/plugins/code/syntax.php 2012-01-23 11:16:05.033314469 +1300
295+++ dokuwiki/lib/plugins/code/syntax.php 2012-01-23 11:16:19.122156271 +1300
296@@ -226,6 +226,8 @@
297 function &_entities(&$aString) {
298 $aString = str_replace(array('&', '<', '>'),
299 array('&#38;', '&#60;', '&#62;'), $aString);
300+ // [jmt12] Restore the hidden ids to normal HTML comments
301+ $aString = preg_replace('/&#60;!-- id:(.*?) --&#62;/','<!-- id:\1 -->', $aString);
302 return $aString;
303 } // _entities()
304</code> ||
305==== HTMLComment ====
306
307Diff against [[http://wiki.splitbrain.org/plugin:htmlcomment|htmlcomment]] plugin dated 2005-10-08.
308
309^ File ^ Changes ^
310^ syntax.php | Added code to allow the use of an alternate HTML comment block (prefix %!--, suffix --%) that is automagically rendered using entities to appear verbatim in text (so appears as <!-- ... --> rather than being hidden). |
311| <code diff u>
312--- dokuwiki-2011-05-25a/lib/plugins/htmlcomment/syntax.php 2005-10-09 11:31:47.000000000 +1300
313+++ dokuwiki/lib/plugins/htmlcomment/syntax.php 2012-01-20 14:03:27.078084422 +1300
314@@ -41,15 +41,24 @@
315 }
316
317 function connectTo($mode) {
318- $this->Lexer->addSpecialPattern("<\!--.*?-->", $mode,
319- 'plugin_htmlcomment');
320+ $this->Lexer->addSpecialPattern("<\!--.*?-->", $mode, 'plugin_htmlcomment');
321+ $this->Lexer->addSpecialPattern("%\!--.*?--%", $mode, 'plugin_htmlcomment');
322+ $this->Lexer->addSpecialPattern("<br/>", $mode, 'plugin_htmlcomment');
323 }
324
325 function handle($match, $state, $pos, &$handler) {
326 if ($state == DOKU_LEXER_SPECIAL) {
327- // strip <!-- from start and --> from end
328- $match = substr($match,4,-3);
329- return array($state, $match);
330+ if ($match == '<br/>')
331+ {
332+ return array('newline',$match);
333+ }
334+ if (strpos($match, '%!--') !== false)
335+ {
336+ $state = 'displaycomment';
337+ }
338+ // strip <!-- from start and --> from end
339+ $match = substr($match,4,-3);
340+ return array($state, $match);
341 }
342 return array();
343 }
344@@ -57,14 +66,31 @@
345 function render($mode, &$renderer, $data) {
346 if ($mode == 'xhtml') {
347 list($state, $match) = $data;
348- if ($state == DOKU_LEXER_SPECIAL) {
349- $renderer->doc .= '<!--';
350- if (HTMLCOMMENT_SAFE) {
351- $renderer->doc .= $renderer->_xmlEntities($match);
352- } else {
353- $renderer->doc .= $match;
354- }
355- $renderer->doc .= '-->';
356+ if ($state == 'newline')
357+ {
358+ $renderer->doc .= $match;
359+ return true;
360+ }
361+ if ($state == 'displaycomment')
362+ {
363+ $renderer->doc .= '&lt;!--';
364+ }
365+ else
366+ {
367+ $renderer->doc .= '<!--';
368+ }
369+ if (HTMLCOMMENT_SAFE) {
370+ $renderer->doc .= $renderer->_xmlEntities($match);
371+ } else {
372+ $renderer->doc .= $match;
373+ }
374+ if ($state == 'displaycomment')
375+ {
376+ $renderer->doc .= '--&gt;';
377+ }
378+ else
379+ {
380+ $renderer->doc .= '-->';
381 }
382 return true;
383 }
384</code> ||
385==== ImageReference ====
386
387Diff against [[http://wiki.splitbrain.org/plugin:imagereference|imagereference]] plugin dated 2008-05-30.
388
389^ File ^ Changes ^
390^ script.js | More tests to prevent trying to access null objects |
391| <code diff u>
392--- dokuwiki-2011-05-25a/lib/plugins/imagereference/script.js 2009-01-07 21:48:25.000000000 +1300
393+++ dokuwiki/lib/plugins/imagereference/script.js 2011-12-16 11:40:42.128166685 +1300
394@@ -3,7 +3,8 @@
395 var divs=document.getElementsByTagName("DIV");
396
397 for (var i=0;i<divs.length;i++) {
398- if (divs[i].className == "imgcaption" || divs[i].className == "imgcaptionleft" || divs[i].className == "imgcaptionright") {
399+ // adding in more checks to ensure elements exist [jmt12]
400+ if (divs[i] && divs[i].childNodes[0] && divs[i].childNodes[0].childNodes[0] && (divs[i].className == "imgcaption" || divs[i].className == "imgcaptionleft" || divs[i].className == "imgcaptionright")) {
401
402 var children = divs[i].getElementsByTagName("IMG");
403 // check if there is a link encapsulating the image
404@@ -13,12 +14,16 @@
405 else {
406 // we have link and we can build the link image
407 var innerElements = divs[i];
408- var iLink = innerElements.childNodes[1].childNodes[2];
409- var iSpan = iLink.childNodes[0];
410- // set the href of the link to the image link
411- iLink.href= innerElements.childNodes[0].href;
412- // show the link image
413- iSpan.style.display="inline";
414+ // adding in more checks to ensure elements exist [jmt12]
415+ if (innerElements && innerElements.childNodes[0] && innerElements.childNodes[1])
416+ {
417+ var iLink = innerElements.childNodes[1].childNodes[2];
418+ var iSpan = iLink.childNodes[0];
419+ // set the href of the link to the image link
420+ iLink.href= innerElements.childNodes[0].href;
421+ // show the link image
422+ iSpan.style.display="inline";
423+ }
424 }
425 //var tmpLink = divs[i].childNodes[0];
426 divs[i].style.width=(tmpImg.width + 8)+"px";
427</code> ||
428^ style.css | Altering colours to make caption bars fit in better with Monobook template |
429| <code diff u>
430--- dokuwiki-2011-05-25a/lib/plugins/imagereference/style.css 2008-09-11 02:56:24.000000000 +1200
431+++ dokuwiki/lib/plugins/imagereference/style.css 2012-01-16 10:48:34.558129586 +1300
432@@ -7,15 +7,17 @@
433
434
435 div.imgcaption {
436- border: 1px solid #ccc;
437+ border: 0px solid #000;
438 padding: 3px !important;
439- background-color: #f9f9f9;
440- font-size: 94%;
441+ /*background-color: #113355;*/
442+ background-color: #777777;
443+ /*font-size: 94%;*/
444 text-align: center;
445 width: auto;
446 overflow: hidden;
447 margin: 1px auto;
448 float: none;
449+ font-weight: bold;
450 }
451
452 div.imgcaptionleft {
453@@ -62,7 +64,8 @@
454 }
455
456 div.dokuwiki .undercaption a:hover {
457- text-decoration:none;
458+ color: #002BB8 !important;
459+ text-decoration:underline;
460 }
461
462 div.dokuwiki .undercaption span {
463</code> ||
464^ syntax.php | Rewrote large chunks of this code to; a) allow for table captions too, b) preserve formatting (italics) in the captions, c) allow specially formatted 'HTML comments' to be inserted but not display (to allow capture and retention of explicit text ids) and d) fix minor bugs (looks like some things were in a state of change from strings to arrays - some bits of the code were expecting the other) |
465| <code diff u>
466--- dokuwiki-2011-05-25a/lib/plugins/imagereference/syntax.php 2008-09-11 18:29:12.000000000 +1200
467+++ dokuwiki/lib/plugins/imagereference/syntax.php 2012-01-19 11:03:52.285067251 +1300
468@@ -22,6 +22,7 @@
469
470 var $_figure_name_array = array("");
471 var $_figure_map = array();
472+ var $_captions = array();
473
474
475 /**
476@@ -80,13 +81,17 @@
477 * @see render()
478 */
479 function connectTo($mode) {
480+
481 $this->Lexer->addSpecialPattern('<imgref\s[^\r\n]*?>',$mode, 'plugin_imagereference');
482- $this->Lexer->addEntryPattern('<imgcaption\s[^\r\n\|]*?>(?=.*?</imgcaption.*?>)',$mode,'plugin_imagereference');
483- $this->Lexer->addEntryPattern('<imgcaption\s[^\r\n\|]*?\|(?=[^\r\n]*>.*?</imgcaption.*>)',$mode,'plugin_imagereference');
484+ $this->Lexer->addSpecialPattern('<tblref\s[^\r\n]*?>',$mode, 'plugin_imagereference');
485+
486+ $this->Lexer->addEntryPattern('<imgcaption\s[^\|]+\|[^>]+(?=>.*?</imgcaption>)',$mode,'plugin_imagereference');
487+ $this->Lexer->addEntryPattern('<tblcaption\s[^\|]+\|[^>]+(?=>.*?</tblcaption>)',$mode,'plugin_imagereference');
488 }
489-
490+
491 function postConnect() {
492 $this->Lexer->addExitPattern('</imgcaption>', 'plugin_imagereference');
493+ $this->Lexer->addExitPattern('</tblcaption>', 'plugin_imagereference');
494 }
495
496
497@@ -120,24 +125,39 @@
498 * @static
499 */
500 function handle($match, $state, $pos, &$handler){
501-
502 switch ($state) {
503 // =========================================================
504 case DOKU_LEXER_ENTER : {
505- /* --------------------------------------------------- */
506- $refLabel = trim(substr($match, 11, -1));
507+
508+ /* --------------------------------------------------- */
509+ $refLabel = ''; //trim(substr($match, 11, -1));
510+ $caption = '';
511+ if (preg_match('/<(?:img|tbl)caption\s+([^\|]+)\|([^>]+)/', $match, $matches))
512+ {
513+ $refLabel = $matches[1];
514+ $caption = $matches[2];
515+ }
516 // -----------------------------------------------------
517 $parsedInput = $this->_parseParam($refLabel);
518-
519+
520 // ------------------------------------------------------
521 //$data = $this->_imgstart($parsedInput);
522 // store the figure name from imgcaption
523 array_push($this->_figure_name_array, $parsedInput[0]);
524-
525- $this->_figure_map[$parsedInput[0]] = "";
526-
527+
528+ $this->_figure_map[$parsedInput[0]] = '';
529+
530+ $this->_captions[$parsedInput[0]] = $caption;
531+
532+ ///cho '<p>refLabel:' . $refLabel . '</p>';
533+ ///cho '<p>parsedInput:' . print_r($parsedInput, true) . '</p>';
534+ ///cho '<p>figure_name_array: ' . print_r($this->_figure_name_array, true) . '</p>';
535+ ///cho '<p>figure_map: ' . print_r($this->_figure_map, true) . '</p>';
536+ ///cho '<p>captions: ' . print_r($this->_captions, true). '</p>';
537+
538 return array('caption_open', $parsedInput); // image anchor label
539 /* --------------------------------------------------- */
540+ //}
541 }
542 // =========================================================
543 case DOKU_LEXER_UNMATCHED : {
544@@ -191,7 +211,6 @@
545 * @see handle()
546 */
547 function render($mode, &$renderer, $indata) {
548-
549 list($case, $data) = $indata;
550 if($mode == 'xhtml'){
551 // ---------------------------------------------
552@@ -200,8 +219,14 @@
553 /* --------------------------------------- */
554 $refNumber = array_search($data, $this->_figure_name_array);
555 if ($refNumber == null || $refNumber == "")
556- $refNumber = "##";
557- $str = "<a href=\"#".$data."\">".$this->getLang('figure').$refNumber." </a>";
558+ {
559+ $refNumber = "##";
560+ }
561+ if (strpos($data,'#') === false)
562+ {
563+ $data = "#" . $data;
564+ }
565+ $str = "<a class=\"wikilink1\" href=\"".$data."\">".$this->getLang('figure').$refNumber."</a>";
566 $renderer->doc .= $str; break;
567 // $renderer->_xmlEntities($str);break;
568 /* --------------------------------------- */
569@@ -210,10 +235,26 @@
570 case 'caption_close' : {
571 // -------------------------------------------------------
572 list($name, $number, $caption) = $data;
573- $layout = "<div class=\"undercaption\">".$this->getLang('fig').$number.":
574- <a name=\"".$name."\">".$caption."</a><a href=\" \"><span></span></a>
575- </div></div>";
576- $renderer->doc .= $layout; break;
577+ // - retrieve the caption separately
578+ $caption = $this->_captions[$name];
579+ // - special case for 'hidden' tables
580+ $layout = '';
581+ if ($caption != '##HIDDEN##')
582+ {
583+ // - manual do any formatting (as leaving it to the
584+ // parser (to foobar) is why we had to do this in
585+ // the first place
586+ $caption = preg_replace('/\/\/%%(.+?)%%\/\//','<i>\1</i>',$caption);
587+ $caption = preg_replace('/\/\/(.+?)\/\//','<i>\1</i>',$caption);
588+ $caption = preg_replace('/\*\*(.+?)\*\*/','<b>\1</b>',$caption);
589+ $caption = str_replace('%!--', '<!--', $caption);
590+ $caption = str_replace('--%', '-->', $caption);
591+ // - special case: nested image ref (we can't really resolve these)
592+ $caption = preg_replace('/<imgref\s+([^>]+)><\/imgref>/','\1',$caption);
593+ $layout = "<div class=\"undercaption\">".$this->getLang('fig').$number.": <a name=\"".$name."\"></a>".$caption."</div>";
594+ }
595+ $layout .= "</div>";
596+ $renderer->doc .= $layout; break;
597 }
598 // -------------------------------------------------------
599 // data is mostly empty!!!
600@@ -284,7 +325,7 @@
601
602 function _imgstart($str) {
603 // ============================================ //
604- if (!strlen($str)) return array();
605+ if (empty($str)) return '';
606
607 $layout = "<div class=\"imgcaption";
608 //$layout = "<div><div class=\"imgcaption";
609@@ -304,6 +345,8 @@
610 * @return array(imagename, image number, image caption)
611 */
612 function _imgend($str) {
613+ // [jmt12] I think this function is unused!
614+
615 // ===================================================== //
616 $figureName = end($this->_figure_name_array);
617 // get the position of the figure in the array
618@@ -311,8 +354,9 @@
619
620 return array($figureName, $refNumber, $str);
621
622+
623 $layout = "<div class=\"undercaption\">".$this->getLang('fig').$refNumber.":
624- <a name=\"".end($this->_figure_name_array)."\">".$str."</a></div>";
625+ <a name=\"".end($this->_figure_name_array)."\"></a>".$str."</div>";
626
627 //$layout = "<div id=\"undercaption\">Fig. ".$refNumber.":
628 //<a name=\"".end($this->_figure_name_array)."\">".$str."</a></div></div></div>";
629</code> ||
630^ lang/en/lang.php | Changed the strings |
631| <code diff u>
632--- /dokuwiki-2011-05-25a/lib/plugins/imagereference/lang/en/lang.php 2008-09-11 02:56:24.000000000 +1200
633+++ dokuwiki/lib/plugins/imagereference/lang/en/lang.php 2011-12-12 11:24:57.668503137 +1300
634@@ -3,5 +3,5 @@
635 * english language file
636 */
637
638-$lang['fig'] = 'Fig. ';
639-$lang['figure'] = 'figure';
640\ No newline at end of file
641+$lang['fig'] = 'Figure ';
642+$lang['figure'] = 'figure';
643</code> ||
644==== Publish ====
645
646Diff against [[http://www.dokuwiki.org/plugin:publish|publish]] plugin dated 2011-10-02.
647
648^ File ^ Changes ^
649^ action.php | Never display "previous version" span - you can always look under old revisions anyway. In fact, try to hide the 'publish state' message unless the user is looking at a draft or if they are an editor (whereupon they may be interested in when a page was last approved etc) |
650| <code diff u>
651--- dokuwiki-2011-05-25a/lib/plugins/publish/action.php 2011-10-16 03:55:40.000000000 +1300
652+++ dokuwiki/lib/plugins/publish/action.php 2012-01-24 10:34:18.115128733 +1300
653@@ -147,10 +147,14 @@
654 if($approver && !$most_recent_approved) { $strings[] = 'yes'; } else { $strings[] = 'no'; }
655 $strings[] = '">';
656
657+ # [jmt12] We may not display the message at all
658+ $display_message = false;
659+
660 if($most_recent_draft) {
661 $strings[] = '<span class="approval_latest_draft">';
662 $strings[] = sprintf($this->getLang('apr_recent_draft'), wl($ID, 'force_rev=1'));
663 $strings[] = $this->difflink($ID, null, $REV) . '</span>';
664+ $display_message = true;
665 }
666
667 if($most_recent_approved) {
668@@ -160,6 +164,7 @@
669 $strings[] = '<span class="approval_outdated">';
670 $strings[] = sprintf($this->getLang('apr_outdated'), wl($ID, 'rev=' . $userrev));
671 $strings[] = $this->difflink($ID, $userrev, $REV) . '</span>';
672+ $display_message = true;
673 }
674
675 if(!$approver) {
676@@ -168,28 +173,27 @@
677 $strings[] = sprintf($this->getLang('apr_draft'),
678 '<span class="approval_date">' . $longdate . '</span>');
679 $strings[] = '</span>';
680+ $display_message = true;
681 }
682
683- if($approver) {
684+ // [jmt12] Only display this notice to editors
685+ if($approver && $INFO['perm'] >= AUTH_EDIT) {
686 # Approved
687 $strings[] = '<span class="approval_approved">';
688 $strings[] = sprintf($this->getLang('apr_approved'),
689 '<span class="approval_date">' . $longdate . '</span>',
690 editorinfo($approver));
691 $strings[] = '</span>';
692- }
693-
694- if($previous_approved) {
695- $strings[] = '<span class="approval_previous">';
696- $strings[] = sprintf($this->getLang('apr_previous'),
697- wl($ID, 'rev=' . $previous_approved),
698- dformat($previous_approved));
699- $strings[] = $this->difflink($ID, $previous_approved, $REV) . '</span>';
700+ $display_message = true;
701 }
702
703 $strings[] = '</div>';
704
705- ptln(implode($strings));
706+ // [jmt12] if there is no message content, hide empty div
707+ if ($display_message)
708+ {
709+ ptln(implode($strings));
710+ }
711 return true;
712 }
713
714</code> ||
715^ style.css | Making the message bubbles at the top of pages a little smaller (it was taking up about 2 inches of vertical real-estate, which was expensive even on my wide screen---small screen users would have suffered greatly) |
716| <code diff u>
717--- dokuwiki-2011-05-25a/lib/plugins/publish/style.css 2011-10-16 03:55:40.000000000 +1300
718+++ dokuwiki/lib/plugins/publish/style.css 2012-01-17 13:47:35.324065886 +1300
719@@ -3,7 +3,7 @@
720 margin-left: auto;
721 margin-right: auto;
722 width: 70% !important;
723- min-height: 40px;
724+ min-height: 20px;
725 clear: both;
726 text-align: justify;
727 vertical-align: middle;
728</code> ||
729===== Templates =====
730
731==== Monobook ====
732
733Diff against [[https://www.dokuwiki.org/template:monobook|monobook]] template dated 2011-12-10.
734
735^ File ^ Changes ^
736^ main.php | Removed positioning test so that the hierarchy navigation appears at both the top and bottom of pages (rather than one or the other) |
737| <code diff u>
738--- dokuwiki-2011-05-25a/lib/tpl/monobook/main.php 2012-01-23 13:37:25.353131918 +1300
739+++ dokuwiki/lib/tpl/monobook/main.php 2013-10-24 12:22:48.000000000 +1300
740@@ -613,8 +613,8 @@
741 $ACT !== "media" && //var comes from DokuWiki
742 (empty($conf["useacl"]) || //are there any users?
743 $loginname !== "" || //user is logged in?
744- !tpl_getConf("monobook_closedwiki")) &&
745- tpl_getConf("monobook_youarehere_position") === "top"){
746+ !tpl_getConf("monobook_closedwiki"))){// &&
747+ // tpl_getConf("monobook_youarehere_position") === "top"){
748 echo "\n <div class=\"catlinks noprint\"><p>\n ";
749 tpl_youarehere();
750 echo "\n </p></div>\n";
751@@ -665,8 +665,8 @@
752 $ACT !== "media" && //var comes from DokuWiki
753 (empty($conf["useacl"]) || //are there any users?
754 $loginname !== "" || //user is logged in?
755- !tpl_getConf("monobook_closedwiki")) &&
756- tpl_getConf("monobook_youarehere_position") === "bottom"){
757+ !tpl_getConf("monobook_closedwiki"))){ // &&
758+ // tpl_getConf("monobook_youarehere_position") === "bottom"){
759 echo "\n <div class=\"catlinks noprint\"><p>\n ";
760 tpl_youarehere();
761 echo "\n </p></div>\n";
762@@ -698,7 +698,7 @@
763 //default
764 echo "style=\"background-image:url(".DOKU_TPL."static/3rd/dokuwiki/logo.png);\"";
765 }
766- echo " accesskey=\"h\" title=\"[ALT+H]\"></a>\n";
767+ echo " accesskey=\"h\" title=\"Back to start [ALT+H]\"></a>\n";
768 ?>
769 </div>
770 <?php
771@@ -733,7 +733,7 @@
772 echo " <li id=\"pt-mytalk\">".html_wikilink(tpl_getConf("monobook_discuss_ns").ltrim(tpl_getConf("monobook_userpage_ns"), ":").$loginname, hsc($lang["monobook_tab_mytalk"]))."</li>";
773 }
774 //profile
775- echo " <li id=\"pt-preferences\"><a href=\"".wl(cleanID(getId()), array("do" => "profile"))."\" rel=\"nofollow\">".hsc($lang["btn_profile"])."</a></li>\n"; //language comes from DokuWiki core
776+ echo " <li id=\"pt-preferences\"><a href=\"http://www.greenstone.org/users/change.php\" rel=\"nofollow\">".hsc($lang["btn_profile"])."</a></li>\n"; //language comes from DokuWiki core
777 //logout
778 echo " <li id=\"pt-logout\"><a href=\"".wl(cleanID(getId()), array("do" => "logout"))."\" rel=\"nofollow\">".hsc($lang["btn_logout"])."</a></li>\n"; //language comes from DokuWiki core
779 }
780</code> ||
781^ static/css/screen.css | Restrict the width of code blocks - otherwise they'll push out past the 1000px limit anyway - and set them to use scrollbars for any overflow. Making h5 different (I can't remember why). Two little fixes for the new simple tabbed area where there are extra pixels sneaking in between the tabs and the tab content areas. |
782| <code diff u>
783--- screen.css.original 2012-12-13 12:54:13.000000000 +1300
784+++ screen.css 2013-08-02 12:00:08.000000000 +1200
785@@ -535,10 +535,12 @@ div#content .dokuwiki h1 a,
786 div#content .dokuwiki h2 a,
787 div#content .dokuwiki h3 a,
788 div#content .dokuwiki h4 a,
789-div#content .dokuwiki h5 a,
790 div#content .dokuwiki h6 a {
791 color: __text__;
792 }
793+div#content .dokuwiki h5 a {
794+ color: __background__;
795+}
796 div#content .dokuwiki h1 a:hover,
797 div#content .dokuwiki h2 a:hover,
798 div#content .dokuwiki h3 a:hover,
799@@ -571,6 +573,7 @@ div#content .dokuwiki h4 {
800 }
801 div#content .dokuwiki h5 {
802 font-size: 100%;
803+ color: __background__;
804 }
805 div#content .dokuwiki h6 {
806 font-size: 80%;
807@@ -629,7 +632,7 @@ div.dokuwiki li.closed {
808
809 div#content div.dokuwiki li {
810 margin-left: 0;
811- margin-bottom: 1px;
812+ margin-bottom: 0;
813 }
814
815 /* quotes */
816@@ -678,6 +678,8 @@
817 line-height: 1.2em;
818 padding: 0.5em;
819 border-style: dashed;
820+ overflow: scroll;
821+ width: 800px;
822 }
823 div#content .dokuwiki dl.file,
824 div#content .dokuwiki dl.file dd {
825@@ -1338,3 +1343,7 @@ textarea,
826 #font-weight: bold;
827 #border-left: 1px dashed __background__; /* invisible border triggers IE to render the stuff */
828 }
829+
830+div.tab {
831+ margin-top:-1px;
832+}
833</code> ||
834^ static/3rd/dokuwiki/_tabs.css | Remove the override of foreground and background colours. |
835| <code diff u>
836--- _tabs.css.original 2013-08-02 12:07:12.000000000 +1200
837+++ _tabs.css 2013-08-02 12:07:36.000000000 +1200
838@@ -19,8 +19,6 @@
839 float: left;
840 padding: .3em .8em;
841 margin: 0 .3em 0 0;
842- background-color: __background_neu__;
843- color: __text__;
844 border-radius: .5em .5em 0 0;
845 }
846 .dokuwiki ul.tabs li strong {
847</code> ||
848^ static/3rd/monobook/main.css | Reduce the text area to around 1000px by centring main div and other absolute divs (logo and top navigation). Rename the style "preferences" to "preftitle" to prevent CSS being randomly injected where-ever you end up with an anchor tag that just happens to have the word preferences in it (happens surprisingly often in instruction manuals). I can't actually find where this style is used anyway. |
849| <code diff u>
850--- dokuwiki-2011-05-25a/lib/tpl/monobook/static/3rd/monobook/main.css 2012-01-23 13:41:54.253064506 +1300
851+++ dokuwiki/lib/tpl/monobook/static/3rd/monobook/main.css 2012-01-23 11:45:42.674067707 +1300
852@@ -27,7 +27,7 @@
853 background: white;
854 color: black;
855 border: 1px solid #aaa;
856- border-right: none;
857+ /*border-right: none;*/
858 line-height: 1.5em;
859 position: relative;
860 z-index: 2;
861@@ -54,6 +54,8 @@
862 /* scale back up to a sane default */
863 #globalWrapper {
864 font-size: 127%;
865+ width: 1024px;
866+ margin: 0 auto;
867 padding: 0;
868 }
869 .visualClear {
870@@ -702,7 +704,7 @@
871 z-index: 3;
872 position: absolute; /*needed to use z-index */
873 top: 0;
874- left: 0;
875+ /*left: 0;*/
876 height: 155px;
877 width: 12em;
878 overflow: visible;
879@@ -858,9 +860,10 @@
880 #p-cactions {
881 position: absolute;
882 top: 1.3em;
883- left: 11.5em;
884+ /*left: 11.5em;*/
885 margin: 0;
886 white-space: nowrap;
887+ width: 1024px;
888 line-height: 1.1em;
889 overflow: visible;
890 background: none;
891@@ -1034,7 +1037,7 @@
892 padding-top: 2em;
893 clear: both;
894 }
895-#preferences {
896+#preftitle {
897 margin: 0;
898 border: 1px solid #aaa;
899 clear: both;
900</code> ||
Note: See TracBrowser for help on using the repository browser.