2 // PukiWiki - Yet another WikiWikiWeb clone.
3 // $Id: tdiary.skin.php,v 1.11 2005/01/16 04:18:16 henoheno Exp $
8 if (! defined('TDIARY_THEME')) define('TDIARY_THEME', 'loose-leaf'); // Default
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
14 // 1 = Show reload URL
15 if (! defined('TDIARY_CALENDAR_DESIGN'))
16 define('TDIARY_CALENDAR_DESIGN', NULL); // NULL, 0, 1
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
24 // Prohibit direct access
25 if (! defined('UI_LANG')) die('UI_LANG is not set');
26 if (! isset($_LANG)) die('$_LANG is not set');
29 $theme = TDIARY_THEME;
30 if ($theme == '' || $theme == 'TDIARY_THEME') {
31 die('Theme is not specified. Set "TDIARY_THEME" correctly');
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/';
44 if (defined('TDIARY_SIDEBAR_POSITION')) {
45 $sidebar = TDIARY_SIDEBAR_POSITION;
47 // Themes including sidebar CSS < (AllTheme / 2)
48 // $ grep div.sidebar */*.css | cut -d: -f1 | cut -d/ -f1 | sort | uniq
50 // 75 list-sidebar.txt
52 $sidebar = 'another'; // Default: Show as an another page below
54 case '3minutes': /*FALLTHROUGH*/
64 case 'book2-feminine':
118 case 'smoking_black':
119 case 'smoking_white':
126 case 'tinybox_green':
129 $sidebar = 'bottom'; // This is the default position of tDiary's.
133 // Adjust sidebar's default position
134 switch(TDIARY_THEME){
136 // Assuming sidebar is above of the body
137 case 'autumn': /*FALLTHROUGH*/
139 case 'dice': // Sidebar text (white) seems unreadable
143 case 'paper': // Sidebar text (white) seems unreadable
145 case 'tinybox': // For MSIE with narrow window width, seems meanless
146 case 'tinybox_green': // The same
150 // Strict separation between sidebar and main contents needed
151 case '3minutes': /*FALLTHROUGH*/
169 case 'moo': // For MSIE, strict seems meanless
172 case 's-blue': // For MSIE, strict seems meanless
184 // They have sidevar-design, but can not show it at the 'side' of the contents
185 case 'babypink': /*FALLTHROUGH*/
195 case 'smoking_black':
196 $sidebar = 'another'; // Show as an another page below
200 // Check menu (sidebar) is ready and $menubar is there
201 $menu = (arg_check('read') && is_page($GLOBALS['menubar']) &&
202 exist_plugin_convert('menu'));
204 $menu_body = preg_replace('#<h2 ([^>]*)>(.*?)</h2>#',
205 '<h3 $1><span class="sanchor"></span> $2</h3>',
206 do_plugin_convert('menu'));
209 // Adjust reverse-link default design manually
210 $disable_reverse_link = FALSE;
211 switch(TDIARY_THEME){
212 case 'hatena': /*FALLTHROUGH*/
215 $disable_reverse_link = TRUE;
219 // Adjust DTD (between theme(=CSS) and MSIE bug)
221 // PukiWiki default: PKWK_DTD_XHTML_1_1
222 // tDiary's default: PKWK_DTD_HTML_4_01_STRICT
223 switch(TDIARY_THEME){
225 $pkwk_dtd = PKWK_DTD_HTML_4_01_STRICT; // or centering will be ignored via MSIE
229 $lang = & $_LANG['skin'];
232 // Decide charset for CSS
233 $css_charset = 'iso-8859-1';
235 case 'ja': $css_charset = 'Shift_JIS'; break;
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);
244 // Output HTML DTD, <html>, and receive content-type
245 if (isset($pkwk_dtd)) {
246 $meta_content_type = pkwk_output_dtd($pkwk_dtd);
248 $meta_content_type = pkwk_output_dtd();
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 } ?>
258 <title><?php echo "$title - $page_title" ?></title>
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 ?>&media=print" type="text/css" media="print" charset="<?php echo $css_charset ?>" />
265 <link rel="alternate" type="application/rss+xml" title="RSS" href="<?php echo $link['rss'] ?>" /><?php // RSS auto-discovery ?>
267 <?php if (PKWK_ALLOW_JAVASCRIPT && $trackback_javascript) { ?> <script type="text/javascript" src="skin/trackback.js"></script><?php } ?>
269 <?php echo $head_tag ?>
271 <body><!-- Theme:<?php echo htmlspecialchars($theme) . ' Sidebar:' . $sidebar ?> -->
273 <?php if ($menu && $sidebar == 'strict') { ?>
275 <div class="sidebar">
277 <?php echo $menu_body ?>
279 </div><!-- class="sidebar" -->
281 <div class="pkwk_body">
283 <?php } // if ($menu && $sidebar == 'strict') ?>
285 <!-- Navigation buttuns -->
286 <div id="navigator"></div>
287 <div class="adminmenu">
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 = '';
296 echo '<span class="adminmenu"><a href="' . $link[$key] . '" ' . $javascript . '>' .
297 (($value === '') ? $lang[$key] : $value) .
303 <?php _navigator('top') ?>
305 <?php if ($is_page) { ?>
306 <?php _navigator('edit') ?>
307 <?php if ($is_read && $function_freeze) { ?>
308 <?php (! $is_freeze) ? _navigator('freeze') : _navigator('unfreeze') ?>
310 <?php _navigator('diff') ?>
311 <?php if ($do_backup) { ?>
312 <?php _navigator('backup') ?>
314 <?php if ((bool)ini_get('file_uploads')) { ?>
315 <?php _navigator('upload') ?>
317 <?php _navigator('reload') ?>
321 <?php _navigator('new') ?>
322 <?php _navigator('list') ?>
323 <?php if (arg_check('list')) { ?>
324 <?php _navigator('filelist') ?>
326 <?php _navigator('search') ?>
327 <?php _navigator('recent') ?>
328 <?php _navigator('help') ?>
330 <?php if ($trackback) { ?>
331 <?php _navigator('trackback', $lang['trackback'] . '(' . tb_count($_page) . ')',
332 ($trackback_javascript == 1) ? 'onClick="OpenTrackback(this.href); return false"' : '') ?>
334 <?php if ($referer) { ?>
335 <?php _navigator('refer') ?>
339 <h1><?php echo $page_title ?></h1>
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>
346 <?php require_once(PLUGIN_DIR . 'topicpath.inc.php'); echo plugin_topicpath_inline(); ?>
352 <?php if ($menu && $sidebar == 'top') { ?>
353 <!-- Sidebar compat top -->
354 <div class="sidebar">
356 <?php echo $menu_body ?>
358 </div><!-- class="sidebar" -->
359 <?php } // if ($menu && $sidebar == 'top') ?>
362 <?php if ($menu && ($sidebar == 'top' || $sidebar == 'bottom')) { ?>
363 <div class="pkwk_body">
371 <h2><span class="date"></span> <span class="title"><?php
372 if ($disable_reverse_link === TRUE) {
374 echo htmlspecialchars($_page);
376 echo $page; // Search, or something message
382 echo htmlspecialchars($_page);
388 <div class="section">
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);
401 // Edit, preview, search, etc
402 echo preg_replace('/(<form) (action="' . preg_quote($script, '/') .
403 ')/', '$1 class="update" $2', $body);
407 </div><!-- class="body" -->
410 <?php if ($notes != '') { ?>
411 <div class="comment"><!-- Design for tDiary "Comments" -->
412 <div class="caption"> </div>
413 <div class="commentbody"><br/>
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);
425 <?php if ($attaches != '') { ?>
426 <div class="comment">
427 <div class="caption"> </div>
428 <div class="commentshort">
429 <?php echo $attaches ?>
434 <?php if ($related != '') { ?>
435 <div class="comment">
436 <div class="caption"> </div>
437 <div class="commentshort">
438 Link: <?php echo $related ?>
443 <!-- Design for tDiary "Today's referrer" -->
444 <div class="referer"><?php if ($lastmodified != '') echo 'Last-modified: ' . $lastmodified; ?></div>
446 </div><!-- class="day" -->
451 <?php if ($menu && $sidebar == 'another') { ?>
452 </div><!-- class="main" -->
453 </div><!-- class="pkwk_body" -->
455 <!-- Sidebar another -->
456 <div class="pkwk_body">
458 <div class="calendar"></div>
461 <h2><span class="date"></span><span class="title"> </span></h2>
463 <div class="section">
464 <?php echo $menu_body ?>
467 <div class="referer"></div>
470 </div><!-- class="pkwk_body" -->
472 <div class="pkwk_body">
474 <?php } // if ($menu && $sidebar == 'another') ?>
477 <?php if ($menu && ($sidebar == 'top' || $sidebar == 'bottom')) { ?>
478 </div><!-- class="main" -->
479 </div><!-- class="pkwk_body" -->
483 <?php if ($menu && $sidebar == 'bottom') { ?>
484 <!-- Sidebar compat bottom -->
485 <div class="sidebar">
487 <?php echo $menu_body ?>
489 </div><!-- class="sidebar" -->
490 <?php } // if ($menu && $sidebar == 'bottom') ?>
494 <?php if (PKWK_SKIN_SHOW_TOOLBAR) { ?>
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';
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; }
527 echo '<a href="' . $link[$key] . '">' .
528 '<img src="' . IMAGE_DIR . $image[$key] . '" width="' . $x . '" height="' . $y . '" ' .
529 'alt="' . $lang[$key] . '" title="' . $lang[$key] . '" />' .
534 <?php _toolbar('top') ?>
536 <?php if ($is_page) { ?>
538 <?php _toolbar('edit') ?>
539 <?php if ($is_read && $function_freeze) { ?>
540 <?php if (! $is_freeze) { _toolbar('freeze'); } else { _toolbar('unfreeze'); } ?>
542 <?php _toolbar('diff') ?>
543 <?php if ($do_backup) { ?>
544 <?php _toolbar('backup') ?>
546 <?php if ((bool)ini_get('file_uploads')) { ?>
547 <?php _toolbar('upload') ?>
549 <?php _toolbar('copy') ?>
550 <?php _toolbar('rename') ?>
551 <?php _toolbar('reload') ?>
554 <?php _toolbar('new') ?>
555 <?php _toolbar('list') ?>
556 <?php _toolbar('search') ?>
557 <?php _toolbar('recent') ?>
558 <?php _toolbar('help') ?>
559 <?php _toolbar('rss10', 36, 14) ?>
561 <?php } // PKWK_SKIN_SHOW_TOOLBAR ?>
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.
569 </div><!-- class="footer" -->
571 <?php if ($menu && ($sidebar != 'top' && $sidebar != 'bottom')) { ?>
572 </div><!-- class="main" -->
573 </div><!-- class="pkwk_body" -->