OSDN Git Service

Added function pkwk_headers_sent() to care header()
[pukiwiki/pukiwiki.git] / skin / keitai.skin.php
1 <?php
2 /////////////////////////////////////////////////
3 // PukiWiki - Yet another WikiWikiWeb clone.
4 //
5 // $Id: keitai.skin.php,v 1.4 2004/12/06 13:10:59 henoheno Exp $
6 //
7
8 // Prohibit direct access
9 if (! defined('UI_LANG')) exit;
10
11 global $max_size, $accesskey, $menubar;
12 $link = $_LINK;
13
14 // Force Shift JIS encode for Japanese embedded browsers and devices
15 pkwk_headers_sent();
16 header('Content-Type: text/html; charset=Shift_JIS');
17 $title = mb_convert_encoding($title, 'SJIS', SOURCE_ENCODING);
18 $body  = mb_convert_encoding($body,  'SJIS', SOURCE_ENCODING);
19
20 // Make 1KByte spare (for header, etc)
21 $max_size = --$max_size * 1024;
22
23 // IMG ¥¿¥°(²èÁü)¤òʸ»úÎó¤ËÃÖ´¹
24 // With ALT option
25 $body = preg_replace('#(<div[^>]+>)?(<a[^>]+>)?<img[^>]*alt="([^"]+)"[^>]*>(?(2)</a>)(?(1)</div>)#i', '[$3]', $body);
26 // Without ALT option
27 $body = preg_replace('#(<div[^>]+>)?(<a[^>]+>)?<img[^>]+>(?(2)</a>)(?(1)</div>)#i', '[img]', $body);
28
29 // Page numbers, divided by this skin
30 $pageno = (isset($vars['p']) and is_numeric($vars['p'])) ? $vars['p'] : 0;
31 $pagecount = ceil(strlen($body) / $max_size);
32 $lastpage = $pagecount - 1;
33
34 // Top navigation (text) bar
35 $navi = array();
36 $navi[] = '<a href="' . $link['top']  . '" ' . $accesskey . '="0">0.Top</a>';
37 $navi[] = '<a href="' . $link['new']  . '" ' . $accesskey . '="1">1.New</a>';
38 $navi[] = '<a href="' . $link['edit'] . '" ' . $accesskey . '="2">2.Edit</a>';
39 if ($is_read and $function_freeze) {
40         if (! $is_freeze) {
41                 $navi[] = '<a href="' . $link['freeze']   . '" ' . $accesskey . '="3">3.Freeze</a>';
42         } else {
43                 $navi[] = '<a href="' . $link['unfreeze'] . '" ' . $accesskey . '="3">3.Unfreeze</a>';
44         }
45 }
46 $navi[] = '<a href="' . $script . '?' . $menubar . '" ' . $accesskey . '="4">4.Menu</a>';
47 $navi[] = '<a href="' . $link['recent'] . '" ' . $accesskey . '="5">5.Recent</a>';
48
49 // Á°/¼¡¤Î¥Ö¥í¥Ã¥¯
50 if ($pagecount > 1) {
51         $prev = $pageno - 1;
52         $next = $pageno + 1;
53         if ($pageno > 0) {
54                 $navi[] = "<a href=\"$script?cmd=read&amp;page=$r_page&amp;p=$prev\" $accesskey=\"7\">7.Prev</a>";
55         }
56         $navi[] = "$next/$pagecount ";
57         if ($pageno < $lastpage) {
58                 $navi[] = "<a href=\"$script?cmd=read&amp;page=$r_page&amp;p=$next\" $accesskey=\"8\">8.Next</a>";
59         }
60 }
61
62 $navi = join(' | ', $navi);
63 $body = substr($body, $pageno * $max_size, $max_size);
64
65 // Output
66 ?><html><head><title><?php
67         echo $title
68 ?></title></head><body><?php
69         echo $navi
70 ?><hr><?php
71         echo $body
72 ?></body></html>