source: documentation/trunk/packages/templates/greenstone-monobook/bug49642.php@ 30114

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

Updated Greenstone customizations for Detritus, but rearranged to move into separate plugin. Initial checkin of plugins, template, special wiki pages.

File size: 6.4 KB
Line 
1<?php
2
3/**
4 * Helper to provide a workaround for PHP bug #49692
5 *
6 * Some PHP versions are not able to parse INI-files if "/" is used for INI
7 * keynames (known as bug #49692, see <http://bugs.php.net/bug.php?id=49692>).
8 * Therefore, DokuWiki is not able to parse monobook's style.ini and users don't
9 * get the needed CSS (but errors like "syntax error, unexpected '/' in
10 * ../../lib/tpl/monobook/style.ini on line XX" instead). To get things work in
11 * such environments, simply delete the "style.ini". Then the template uses
12 * this helper to get the CSS.
13 *
14 * Known disadvantages: A little bit more traffic compared to an environment
15 * without this bug and DokuWiki's "compress" feature enabled (cause this
16 * feature does not have any effect on monobook's CSS files when using this
17 * workaround, and therefore non-minimized and uncompressed CSS will be
18 * delivered).
19 *
20 *
21 * LICENSE: This file is open source software (OSS) and may be copied under
22 * certain conditions. See COPYING file for details or try to contact
23 * the author(s) of this file in doubt.
24 *
25 * @license GPLv2 (http://www.gnu.org/licenses/gpl2.html)
26 * @author Andreas Haerter <[email protected]>
27 * @link http://bugs.php.net/bug.php?id=49692
28 * @link http://forum.dokuwiki.org/thread/4827
29 * @link http://andreas-haerter.com/projects/dokuwiki-template-monobook
30 * @link http://www.dokuwiki.org/template:monobook
31 * @link http://www.dokuwiki.org/devel:css#styleini
32 */
33
34
35//workaround for PHP Bug #49692
36//If you are affected, simply delete monobook's style.ini to trigger the
37//template to use this workaround.
38
39//we are rebuilding a CSS file, send needed headers (otherwise, the browser
40//would interpret this as text/plain or XHTML)
41header("Content-Type: text/css");
42
43//define placeholders as they are known out of the style.ini
44$placeholder_names = array(//main text and background colors
45 "__text__",
46 "__background__",
47 //alternative text and background colors
48 "__text_alt__",
49 "__background_alt__",
50 //neutral text and background colors
51 "__text_neu__",
52 "__background_neu__",
53 //border color
54 "__border__",
55 //these are used for links
56 "__existing__",
57 "__missing__",
58 //highlighting search snippets
59 "__highlight__",
60 //starter template css base compatibility
61 "__site_width__",
62 "__sidebar_width__");
63$placeholder_values = array(//main text and background colors
64 "#000",
65 "#fff",
66 //alternative text and background colors
67 "#000",
68 "#dee7ec",
69 //neutral text and background colors
70 "#000",
71 "#fff",
72 //border color
73 "#8cacbb",
74 //these are used for links
75 "#002bb8", //use #090 for dokuwiki-green links
76 "#ba0000",
77 //highlighting search snippets
78 "#ff9",
79 //starter template css base compatibility
80 "64em",
81 "16em");
82
83//get needed file contents: screen media CSS
84$interim = trim(file_get_contents("./static/3rd/dokuwiki/_imgdetail.css"))."\n"
85 .trim(file_get_contents("./static/3rd/dokuwiki/_media_popup.css"))."\n"
86 .trim(file_get_contents("./static/3rd/dokuwiki/_media_fullscreen.css"))."\n"
87 .trim(file_get_contents("./static/3rd/dokuwiki/_fileuploader.css"))."\n"
88 .trim(file_get_contents("./static/3rd/dokuwiki/_tabs.css"))."\n"
89 .trim(file_get_contents("./static/3rd/dokuwiki/_links.css"))."\n"
90 .trim(file_get_contents("./static/3rd/dokuwiki/_toc.css"))."\n"
91 .trim(file_get_contents("./static/3rd/dokuwiki/_footnotes.css"))."\n"
92 .trim(file_get_contents("./static/3rd/dokuwiki/_search.css"))."\n"
93 .trim(file_get_contents("./static/3rd/dokuwiki/_recent.css"))."\n"
94 .trim(file_get_contents("./static/3rd/dokuwiki/_diff.css"))."\n"
95 .trim(file_get_contents("./static/3rd/dokuwiki/_edit.css"))."\n"
96 .trim(file_get_contents("./static/3rd/dokuwiki/_modal.css"))."\n"
97 .trim(file_get_contents("./static/3rd/dokuwiki/_forms.css"))."\n"
98 .trim(file_get_contents("./static/3rd/dokuwiki/_admin.css"))."\n"
99 .trim(file_get_contents("./static/3rd/monobook/main.css"))."\n"
100 .trim(file_get_contents("./static/css/screen.css"))."\n"
101 .trim(file_get_contents("./user/screen.css"))."\n";
102if (!empty($_GET["langdir"]) &&
103 $_GET["langdir"] === "rtl"){
104 $interim .= trim(file_get_contents("./static/3rd/dokuwiki/print.css"))."\n"
105 .trim(file_get_contents("./static/3rd/monobook/rtl.css"))."\n"
106 .trim(file_get_contents("./user/rtl.css"))."\n";
107}
108//replace the placeholders with the corresponding values and send the needed CSS
109echo "@media screen {\n".str_replace(//search
110 $placeholder_names,
111 //replace
112 $placeholder_values,
113 //haystack
114 $interim)."\n}\n\n";
115
116//get needed file contents: print media CSS
117$interim = trim(file_get_contents("./static/3rd/dokuwiki/print.css"))."\n"
118 .trim(file_get_contents("./static/3rd/wikipedia/commonPrint.css"))."\n"
119 .trim(file_get_contents("./static/css/print.css"))."\n"
120 .trim(file_get_contents("./user/print.css"))."\n";
121//replace the placeholders with the corresponding values and send the needed CSS
122echo "@media print {\n".str_replace(//search
123 $placeholder_names,
124 //replace
125 $placeholder_values,
126 //haystack
127 $interim)."\n}\n\n";
128
Note: See TracBrowser for help on using the repository browser.