OSDN Git Service

tdiary-theme-2.0.1 support -- Added be_r5, natrium, tdiarynet
[pukiwiki/pukiwiki.git] / skin / keitai.skin.php
1 <?php
2 // PukiWiki - Yet another WikiWikiWeb clone.
3 // $Id: keitai.skin.php,v 1.8 2005/02/13 03:12:47 henoheno Exp $
4 //
5 // Skin for Embedded devices
6
7 // ----
8 // Prohibit direct access
9 if (! defined('UI_LANG')) die('UI_LANG is not set');
10
11 global $max_size, $accesskey, $menubar;
12 $link = $_LINK;
13 $rw = ! PKWK_READONLY;
14
15 // Output HTTP headers
16 pkwk_headers_sent();
17 if(TRUE) {
18         // Force Shift JIS encode for Japanese embedded browsers and devices
19         header('Content-Type: text/html; charset=Shift_JIS');
20         $title = mb_convert_encoding($title, 'SJIS', SOURCE_ENCODING);
21         $body  = mb_convert_encoding($body,  'SJIS', SOURCE_ENCODING);
22 } else {
23         header('Content-Type: text/html; charset=' . CONTENT_CHARSET);
24 }
25
26 // Make 1KByte spare (for header, etc)
27 $max_size = --$max_size * 1024;
28
29 // Replace IMG tags (= images) with character strings
30 // With ALT option
31 $body = preg_replace('#(<div[^>]+>)?(<a[^>]+>)?<img[^>]*alt="([^"]+)"[^>]*>(?(2)</a>)(?(1)</div>)#i', '[$3]', $body);
32 // Without ALT option
33 $body = preg_replace('#(<div[^>]+>)?(<a[^>]+>)?<img[^>]+>(?(2)</a>)(?(1)</div>)#i', '[img]', $body);
34
35 // Page numbers, divided by this skin
36 $pageno = (isset($vars['p']) and is_numeric($vars['p'])) ? $vars['p'] : 0;
37 $pagecount = ceil(strlen($body) / $max_size);
38 $lastpage = $pagecount - 1;
39
40 // Top navigation (text) bar
41 $navi = array();
42 $navi[] = '<a href="' . $link['top']  . '" ' . $accesskey . '="0">0.Top</a>';
43 if ($rw) {
44         $navi[] = '<a href="' . $link['new']  . '" ' . $accesskey . '="1">1.New</a>';
45         $navi[] = '<a href="' . $link['edit'] . '" ' . $accesskey . '="2">2.Edit</a>';
46         if ($is_read and $function_freeze) {
47                 if (! $is_freeze) {
48                         $navi[] = '<a href="' . $link['freeze']   . '" ' . $accesskey . '="3">3.Freeze</a>';
49                 } else {
50                         $navi[] = '<a href="' . $link['unfreeze'] . '" ' . $accesskey . '="3">3.Unfreeze</a>';
51                 }
52         }
53 }
54 $navi[] = '<a href="' . $script . '?' . $menubar . '" ' . $accesskey . '="4">4.Menu</a>';
55 $navi[] = '<a href="' . $link['recent'] . '" ' . $accesskey . '="5">5.Recent</a>';
56
57 // Previous / Next block
58 if ($pagecount > 1) {
59         $prev = $pageno - 1;
60         $next = $pageno + 1;
61         if ($pageno > 0) {
62                 $navi[] = '<a href="' . $script . '?cmd=read&amp;page=' . $r_page . '&amp;p=' . $prev . '" ' . $accesskey . '="7">7.Prev</a>';
63         }
64         $navi[] = $next . '/' . $pagecount . ' ';
65         if ($pageno < $lastpage) {
66                 $navi[] = '<a href="' . $script . '?cmd=read&amp;page=' . $r_page . '&amp;p=' . $next . '" ' . $accesskey . '="8">8.Next</a>';
67         }
68 }
69
70 $navi = join(' | ', $navi);
71 $body = substr($body, $pageno * $max_size, $max_size);
72
73 // Output
74 ?><html><head><title><?php
75         echo $title
76 ?></title></head><body><?php
77         echo $navi
78 ?><hr><?php
79         echo $body
80 ?></body></html>