OSDN Git Service

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