OSDN Git Service

Correct $sidebar about dice, paper, blog, purple_sun.
[pukiwiki/pukiwiki.git] / skin / tdiary.skin.php
1 <?php
2 // PukiWiki - Yet another WikiWikiWeb clone.
3 // $Id: tdiary.skin.php,v 1.11 2005/01/16 04:18:16 henoheno Exp $
4 //
5 // tDiary-wrapper skin
6
7 // Select theme
8 if (! defined('TDIARY_THEME')) define('TDIARY_THEME', 'loose-leaf'); // Default
9
10 // Show link(s) at your choice, with <div class="calendar"> design
11 // NOTE: Some theme become looking worse with this!
12 //   NULL = Show nothing
13 //   0    = Show topicpath
14 //   1    = Show reload URL
15 if (! defined('TDIARY_CALENDAR_DESIGN'))
16         define('TDIARY_CALENDAR_DESIGN', NULL); // NULL, 0, 1
17
18 // Show toolbar at your choice, with <div class="footer"> design
19 // NOTE: Some theme become looking worse with this!
20 if (! defined('PKWK_SKIN_SHOW_TOOLBAR'))
21         define('PKWK_SKIN_SHOW_TOOLBAR', 0); // 0, 1
22
23 // --------
24 // Prohibit direct access
25 if (! defined('UI_LANG')) die('UI_LANG is not set');
26 if (! isset($_LANG)) die('$_LANG is not set');
27
28 // Check theme
29 $theme = TDIARY_THEME;
30 if ($theme == '' || $theme == 'TDIARY_THEME') {
31         die('Theme is not specified. Set "TDIARY_THEME" correctly');
32 } else {
33         $theme = rawurlencode($theme); // Supress all nasty letters
34         $theme_css = SKIN_DIR . 'theme/' . $theme . '/' . $theme . '.css';
35         if (! file_exists($theme_css)) {
36                 echo 'tDiary theme wrapper: ';
37                 echo 'Theme not found: ' . htmlspecialchars($theme_css) . '<br/>';
38                 echo 'You can get tdiary-theme from: ';
39                 echo 'http://sourceforge.net/projects/tdiary/';
40                 exit;
41          }
42 }
43
44 if (defined('TDIARY_SIDEBAR_POSITION')) {
45         $sidebar = TDIARY_SIDEBAR_POSITION;
46 } else {
47         // Themes including sidebar CSS < (AllTheme / 2)
48         // $ grep div.sidebar */*.css | cut -d: -f1 | cut -d/ -f1 | sort | uniq
49         // $ wc -l *.txt
50         //     75 list-sidebar.txt
51         //    193 list-all.txt
52         $sidebar = 'another'; // Default: Show as an another page below
53         switch(TDIARY_THEME){
54         case '3minutes':        /*FALLTHROUGH*/
55         case '3pink':
56         case 'aoikuruma':
57         case 'arrow':
58         case 'autumn':
59         case 'babypink':
60         case 'bill':
61         case 'bistro_menu':
62         case 'bluely':
63         case 'book':
64         case 'book2-feminine':
65         case 'book3-sky':
66         case 'bright-green':
67         case 'bubble':
68         case 'candy':
69         case 'cat':
70         case 'cherry':
71         case 'citrus':
72         case 'clover':
73         case 'cool_ice':
74         case 'cosmos':
75         case 'darkness-pop':
76         case 'diamond_dust':
77         case 'dice':
78         case 'emboss':
79         case 'flower':
80         case 'gear':
81         case 'germany':
82         case 'gray2':
83         case 'happa':
84         case 'hatena':
85         case 'himawari':
86         case 'kaeru':
87         case 'kotatsu':
88         case 'light-blue':
89         case 'loose-leaf':
90         case 'marguerite':
91         case 'matcha':
92         case 'mizu':
93         case 'momonga':
94         case 'mono':
95         case 'moo':
96         case 'nippon':
97         case 'note':
98         case 'old-pavement':
99         case 'pain':
100         case 'pale':
101         case 'paper':
102         case 'parabola':
103         case 'pettan':
104         case 'pink-border':
105         case 'plum':
106         case 'puppy':
107         case 'purple_sun':
108         case 'rainy-season':
109         case 'rectangle':
110         case 'repro':
111         case 'russet':
112         case 's-blue':
113         case 'sagegreen':
114         case 'savanna':
115         case 'scarlet':
116         case 'sepia':
117         case 'simple':
118         case 'smoking_black':
119         case 'smoking_white':
120         case 'spring':
121         case 'sunset':
122         case 'teacup':
123         case 'thin':
124         case 'tile':
125         case 'tinybox':
126         case 'tinybox_green':
127         case 'wine':
128         case 'yukon':
129                 $sidebar = 'bottom';    // This is the default position of tDiary's.
130                 break;
131         }
132
133         // Adjust sidebar's default position
134         switch(TDIARY_THEME){
135
136         // Assuming sidebar is above of the body
137         case 'autumn':  /*FALLTHROUGH*/
138         case 'cosmos':
139         case 'dice':    // Sidebar text (white) seems unreadable
140         case 'happa':
141         case 'kaeru':
142         case 'note':
143         case 'paper':   // Sidebar text (white) seems unreadable
144         case 'sunset':
145         case 'tinybox': // For MSIE with narrow window width, seems meanless
146         case 'tinybox_green':   // The same
147                 $sidebar = 'top';
148                 break;
149
150         // Strict separation between sidebar and main contents needed
151         case '3minutes':        /*FALLTHROUGH*/
152         case '3pink':
153         case 'aoikuruma':
154         case 'bill':
155         case 'candy':
156         case 'cat':
157         case 'clover':
158         case 'cool_ice':
159         case 'flower':
160         case 'germany':
161         case 'himawari':
162         case 'kotatsu':
163         case 'light-blue':
164         case 'loose-leaf':
165         case 'marguerite':
166         case 'matcha':
167         case 'mizu':
168         case 'mono':
169         case 'moo':     // For MSIE, strict seems meanless
170         case 'puppy':
171         case 'rainy-season':
172         case 's-blue':  // For MSIE, strict seems meanless
173         case 'sagegreen':
174         case 'savanna':
175         case 'scarlet':
176         case 'sepia':
177         case 'simple':
178         case 'spring':
179         case 'teacup':
180         case 'wine':
181                 $sidebar = 'strict';
182                 break;
183
184         // They have sidevar-design, but can not show it at the 'side' of the contents
185         case 'babypink':        /*FALLTHROUGH*/
186         case 'bubble':
187         case 'cherry':
188         case 'darkness-pop':
189         case 'diamond_dust':
190         case 'gear':
191         case 'pale':
192         case 'pink-border':
193         case 'rectangle':
194         case 'russet':
195         case 'smoking_black':
196                 $sidebar = 'another'; // Show as an another page below
197                 break;
198         }
199 }
200 // Check menu (sidebar) is ready and $menubar is there
201 $menu = (arg_check('read') && is_page($GLOBALS['menubar']) &&
202         exist_plugin_convert('menu'));
203 if ($menu) {
204         $menu_body = preg_replace('#<h2 ([^>]*)>(.*?)</h2>#',
205                 '<h3 $1><span class="sanchor"></span> $2</h3>',
206                 do_plugin_convert('menu'));
207 }
208
209 // Adjust reverse-link default design manually
210 $disable_reverse_link = FALSE;
211 switch(TDIARY_THEME){
212 case 'hatena':  /*FALLTHROUGH*/
213 case 'repro':
214 case 'yukon':
215         $disable_reverse_link = TRUE;
216         break;
217 }
218
219 // Adjust DTD (between theme(=CSS) and MSIE bug)
220 // NOTE:
221 //    PukiWiki default: PKWK_DTD_XHTML_1_1
222 //    tDiary's default: PKWK_DTD_HTML_4_01_STRICT
223 switch(TDIARY_THEME){
224 case 'christmas':
225         $pkwk_dtd = PKWK_DTD_HTML_4_01_STRICT; // or centering will be ignored via MSIE
226         break;
227 }
228
229 $lang  = & $_LANG['skin'];
230 $link  = & $_LINK;
231
232 // Decide charset for CSS
233 $css_charset = 'iso-8859-1';
234 switch(UI_LANG){
235         case 'ja': $css_charset = 'Shift_JIS'; break;
236 }
237
238 // Output HTTP headers
239 pkwk_common_headers();
240 header('Cache-control: no-cache');
241 header('Pragma: no-cache');
242 header('Content-Type: text/html; charset=' . CONTENT_CHARSET);
243
244 // Output HTML DTD, <html>, and receive content-type
245 if (isset($pkwk_dtd)) {
246         $meta_content_type = pkwk_output_dtd($pkwk_dtd);
247 } else {
248         $meta_content_type = pkwk_output_dtd();
249 }
250
251 ?>
252 <head>
253  <?php echo $meta_content_type ?>
254  <meta http-equiv="content-style-type" content="text/css" />
255 <?php if (! $is_read)  { ?> <meta name="robots" content="NOINDEX,NOFOLLOW" /><?php } ?>
256 <?php if (PKWK_ALLOW_JAVASCRIPT && isset($javascript)) { ?> <meta http-equiv="Content-Script-Type" content="text/javascript" /><?php } ?>
257
258  <title><?php echo "$title - $page_title" ?></title>
259
260  <link rel="stylesheet" href="skin/theme/base.css" type="text/css" media="all" />
261  <link rel="stylesheet" href="skin/theme/<?php echo $theme ?>/<?php echo $theme ?>.css" type="text/css" media="all" />
262  <link rel="stylesheet" href="skin/tdiary.css.php?charset=<?php echo $css_charset ?>" type="text/css" media="screen" charset="<?php echo $css_charset ?>" />
263  <link rel="stylesheet" href="skin/tdiary.css.php?charset=<?php echo $css_charset ?>&amp;media=print" type="text/css" media="print" charset="<?php echo $css_charset ?>" />
264
265  <link rel="alternate" type="application/rss+xml" title="RSS" href="<?php echo $link['rss'] ?>" /><?php // RSS auto-discovery ?>
266
267 <?php if (PKWK_ALLOW_JAVASCRIPT && $trackback_javascript) { ?> <script type="text/javascript" src="skin/trackback.js"></script><?php } ?>
268
269 <?php echo $head_tag ?>
270 </head>
271 <body><!-- Theme:<?php echo htmlspecialchars($theme) . ' Sidebar:' . $sidebar ?> -->
272
273 <?php if ($menu && $sidebar == 'strict') { ?>
274 <!-- Sidebar top -->
275 <div class="sidebar">
276         <div id="menubar">
277                 <?php echo $menu_body ?>
278         </div>
279 </div><!-- class="sidebar" -->
280
281 <div class="pkwk_body">
282 <div class="main">
283 <?php } // if ($menu && $sidebar == 'strict') ?>
284
285 <!-- Navigation buttuns -->
286 <div id="navigator"></div>
287 <div class="adminmenu">
288 <?php
289 function _navigator($key, $value = '', $javascript = ''){
290         $lang = $GLOBALS['_LANG']['skin'];
291         $link = $GLOBALS['_LINK'];
292         if (! isset($lang[$key])) { echo 'LANG NOT FOUND'; return FALSE; }
293         if (! isset($link[$key])) { echo 'LINK NOT FOUND'; return FALSE; }
294         if (! PKWK_ALLOW_JAVASCRIPT) $javascript = '';
295
296         echo '<span class="adminmenu"><a href="' . $link[$key] . '" ' . $javascript . '>' .
297                 (($value === '') ? $lang[$key] : $value) .
298                 '</a></span>';
299
300         return TRUE;
301 }
302 ?>
303  <?php _navigator('top') ?> &nbsp;
304
305 <?php if ($is_page) { ?>
306    <?php _navigator('edit')   ?>
307  <?php if ($is_read && $function_freeze) { ?>
308     <?php (! $is_freeze) ? _navigator('freeze') : _navigator('unfreeze') ?>
309  <?php } ?>
310    <?php _navigator('diff') ?>
311  <?php if ($do_backup) { ?>
312    <?php _navigator('backup') ?>
313  <?php } ?>
314  <?php if ((bool)ini_get('file_uploads')) { ?>
315    <?php _navigator('upload') ?>
316  <?php } ?>
317    <?php _navigator('reload')    ?>
318    &nbsp;
319 <?php } ?>
320
321    <?php _navigator('new')  ?>
322    <?php _navigator('list') ?>
323  <?php if (arg_check('list')) { ?>
324    <?php _navigator('filelist') ?>
325  <?php } ?>
326    <?php _navigator('search') ?>
327    <?php _navigator('recent') ?>
328    <?php _navigator('help')   ?>
329
330 <?php if ($trackback) { ?> &nbsp;
331    <?php _navigator('trackback', $lang['trackback'] . '(' . tb_count($_page) . ')',
332         ($trackback_javascript == 1) ? 'onClick="OpenTrackback(this.href); return false"' : '') ?>
333 <?php } ?>
334 <?php if ($referer)   { ?> &nbsp;
335    <?php _navigator('refer') ?>
336 <?php } ?>
337 </div>
338
339 <h1><?php echo $page_title ?></h1>
340
341 <div class="calendar">
342 <?php if ($is_page && TDIARY_CALENDAR_DESIGN !== NULL) { ?>
343         <?php if(TDIARY_CALENDAR_DESIGN) { ?>
344                 <a href="<?php echo $link['reload'] ?>"><span class="small"><?php echo $link['reload'] ?></span></a>
345         <?php } else { ?>
346                 <?php require_once(PLUGIN_DIR . 'topicpath.inc.php'); echo plugin_topicpath_inline(); ?>
347         <?php } ?>
348 <?php } ?>
349 </div>
350
351
352 <?php if ($menu && $sidebar == 'top') { ?>
353 <!-- Sidebar compat top -->
354 <div class="sidebar">
355         <div id="menubar">
356                 <?php echo $menu_body ?>
357         </div>
358 </div><!-- class="sidebar" -->
359 <?php } // if ($menu && $sidebar == 'top') ?>
360
361
362 <?php if ($menu && ($sidebar == 'top' || $sidebar == 'bottom')) { ?>
363 <div class="pkwk_body">
364 <div class="main">
365 <?php } ?>
366
367 <hr class="sep" />
368
369 <div class="day">
370
371 <h2><span class="date"></span> <span class="title"><?php
372 if ($disable_reverse_link === TRUE) {
373         if ($_page != '') {
374                 echo htmlspecialchars($_page);
375         } else {
376                 echo $page; // Search, or something message
377         }
378 } else {
379         if ($page != '') {
380                 echo $page;
381         } else {
382                 echo htmlspecialchars($_page);
383         }
384 }
385 ?></span></h2>
386
387 <div class="body">
388         <div class="section">
389 <?php
390         // For read and preview: tDiary have no <h2> inside body
391         $body = preg_replace('#<h2 ([^>]*)>(.*?)<a class="anchor_super" ([^>]*)>.*?</a></h2>#',
392                 '<h3 $1><a $3><span class="sanchor">_</span></a> $2</h3>', $body);
393         $body = preg_replace('#<h([34]) ([^>]*)>(.*?)<a class="anchor_super" ([^>]*)>.*?</a></h\1>#',
394                 '<h$1 $2><a $4>_</a> $3</h$1>', $body);
395         $body = preg_replace('#<h2 ([^>]*)>(.*?)</h2>#',
396                 '<h3 $1><span class="sanchor">_</span> $2</h3>', $body);
397         if ($is_read) {
398                 // Read
399                 echo $body;
400         } else {
401                 // Edit, preview, search, etc
402                 echo preg_replace('/(<form) (action="' . preg_quote($script, '/') .
403                         ')/', '$1 class="update" $2', $body);
404         }
405 ?>
406         </div>
407 </div><!-- class="body" -->
408
409
410 <?php if ($notes != '') { ?>
411 <div class="comment"><!-- Design for tDiary "Comments" -->
412         <div class="caption">&nbsp;</div>
413         <div class="commentbody"><br/>
414                 <?php
415                 $notes = preg_replace('#<span class="small">(.*?)</span>#', '<p>$1</p>', $notes);
416                 echo preg_replace('#<a (id="notefoot_[^>]*)>(.*?)</a>#',
417                         '<div class="commentator"><a $1><span class="canchor"></span> ' .
418                         '<span class="commentator">$2</span></a>' .
419                         '<span class="commenttime"></span></div>', $notes);
420                 ?>
421         </div>
422 </div>
423 <?php } ?>
424
425 <?php if ($attaches != '') { ?>
426 <div class="comment">
427         <div class="caption">&nbsp;</div>
428         <div class="commentshort">
429                 <?php echo $attaches ?>
430         </div>
431 </div>
432 <?php } ?>
433
434 <?php if ($related != '') { ?>
435 <div class="comment">
436         <div class="caption">&nbsp;</div>
437         <div class="commentshort">
438                 Link: <?php echo $related ?>
439         </div>
440 </div>
441 <?php } ?>
442
443 <!-- Design for tDiary "Today's referrer" -->
444 <div class="referer"><?php if ($lastmodified != '') echo 'Last-modified: ' . $lastmodified; ?></div>
445
446 </div><!-- class="day" -->
447
448 <hr class="sep" />
449
450
451 <?php if ($menu && $sidebar == 'another') { ?>
452 </div><!-- class="main" -->
453 </div><!-- class="pkwk_body" -->
454
455 <!-- Sidebar another -->
456 <div class="pkwk_body">
457         <h1>&nbsp;</h1>
458         <div class="calendar"></div>
459         <hr class="sep" />
460         <div class="day">
461                 <h2><span class="date"></span><span class="title">&nbsp;</span></h2>
462                 <div class="body">
463                         <div class="section">
464                                 <?php echo $menu_body ?>
465                         </div>
466                 </div>
467                 <div class="referer"></div>
468         </div>
469         <hr class="sep" />
470 </div><!-- class="pkwk_body" -->
471
472 <div class="pkwk_body">
473 <div class="main">
474 <?php } // if ($menu && $sidebar == 'another') ?>
475
476
477 <?php if ($menu && ($sidebar == 'top' || $sidebar == 'bottom')) { ?>
478 </div><!-- class="main" -->
479 </div><!-- class="pkwk_body" -->
480 <?php } ?>
481
482
483 <?php if ($menu && $sidebar == 'bottom') { ?>
484 <!-- Sidebar compat bottom -->
485 <div class="sidebar">
486         <div id="menubar">
487                 <?php echo $menu_body ?>
488         </div>
489 </div><!-- class="sidebar" -->
490 <?php } // if ($menu && $sidebar == 'bottom') ?>
491
492
493 <div class="footer">
494 <?php if (PKWK_SKIN_SHOW_TOOLBAR) { ?>
495 <!-- Toolbar -->
496 <?php
497
498 // Set toolbar-specific images
499 $_IMAGE['skin']['reload']   = 'reload.png';
500 $_IMAGE['skin']['new']      = 'new.png';
501 $_IMAGE['skin']['edit']     = 'edit.png';
502 $_IMAGE['skin']['freeze']   = 'freeze.png';
503 $_IMAGE['skin']['unfreeze'] = 'unfreeze.png';
504 $_IMAGE['skin']['diff']     = 'diff.png';
505 $_IMAGE['skin']['upload']   = 'file.png';
506 $_IMAGE['skin']['copy']     = 'copy.png';
507 $_IMAGE['skin']['rename']   = 'rename.png';
508 $_IMAGE['skin']['top']      = 'top.png';
509 $_IMAGE['skin']['list']     = 'list.png';
510 $_IMAGE['skin']['search']   = 'search.png';
511 $_IMAGE['skin']['recent']   = 'recentchanges.png';
512 $_IMAGE['skin']['backup']   = 'backup.png';
513 $_IMAGE['skin']['help']     = 'help.png';
514 $_IMAGE['skin']['rss']      = 'rss.png';
515 $_IMAGE['skin']['rss10']    = & $_IMAGE['skin']['rss'];
516 $_IMAGE['skin']['rss20']    = 'rss20.png';
517 $_IMAGE['skin']['rdf']      = 'rdf.png';
518
519 function _toolbar($key, $x = 20, $y = 20){
520         $lang  = & $GLOBALS['_LANG']['skin'];
521         $link  = & $GLOBALS['_LINK'];
522         $image = & $GLOBALS['_IMAGE']['skin'];
523         if (! isset($lang[$key]) ) { echo 'LANG NOT FOUND';  return FALSE; }
524         if (! isset($link[$key]) ) { echo 'LINK NOT FOUND';  return FALSE; }
525         if (! isset($image[$key])) { echo 'IMAGE NOT FOUND'; return FALSE; }
526
527         echo '<a href="' . $link[$key] . '">' .
528                 '<img src="' . IMAGE_DIR . $image[$key] . '" width="' . $x . '" height="' . $y . '" ' .
529                         'alt="' . $lang[$key] . '" title="' . $lang[$key] . '" />' .
530                 '</a>';
531         return TRUE;
532 }
533 ?>
534  <?php _toolbar('top') ?>
535
536 <?php if ($is_page) { ?>
537  &nbsp;
538  <?php _toolbar('edit') ?>
539  <?php if ($is_read && $function_freeze) { ?>
540   <?php if (! $is_freeze) { _toolbar('freeze'); } else { _toolbar('unfreeze'); } ?>
541  <?php } ?>
542  <?php _toolbar('diff') ?>
543 <?php if ($do_backup) { ?>
544   <?php _toolbar('backup') ?>
545 <?php } ?>
546  <?php if ((bool)ini_get('file_uploads')) { ?>
547   <?php _toolbar('upload') ?>
548  <?php } ?>
549  <?php _toolbar('copy') ?>
550  <?php _toolbar('rename') ?>
551  <?php _toolbar('reload') ?>
552 <?php } ?>
553  &nbsp;
554  <?php _toolbar('new')    ?>
555  <?php _toolbar('list')   ?>
556  <?php _toolbar('search') ?>
557  <?php _toolbar('recent') ?>
558  &nbsp; <?php _toolbar('help') ?>
559  &nbsp; <?php _toolbar('rss10', 36, 14) ?>
560  <br/>
561 <?php } // PKWK_SKIN_SHOW_TOOLBAR ?>
562
563 <!-- Copyright etc -->
564  Site admin: <a href="<?php echo $modifierlink ?>"><?php echo $modifier ?></a><p />
565  <?php echo S_COPYRIGHT ?>.
566  Powered by PHP <?php echo PHP_VERSION ?><br />
567  HTML convert time: <?php echo $taketime ?> sec.
568
569 </div><!-- class="footer" -->
570
571 <?php if ($menu && ($sidebar != 'top' && $sidebar != 'bottom')) { ?>
572 </div><!-- class="main" -->
573 </div><!-- class="pkwk_body" -->
574 <?php } ?>
575
576
577 </body>
578 </html>