2 // PukiWiki - Yet another WikiWikiWeb clone.
3 // $Id: keitai.skin.php,v 1.16 2006/01/09 10:37:05 henoheno Exp $
4 // Copyright (C) 2003-2006 PukiWiki Developers Team
5 // License: GPL v2 or (at your option) any later version
7 // Skin for Embedded devices
10 // Prohibit direct access
11 if (! defined('UI_LANG')) die('UI_LANG is not set');
13 $pageno = (isset($vars['p']) && is_numeric($vars['p'])) ? $vars['p'] : 0;
14 $edit = (isset($vars['cmd']) && $vars['cmd'] == 'edit') ||
15 (isset($vars['plugin']) && $vars['plugin'] == 'edit');
17 global $max_size, $accesskey, $menubar, $_symbol_anchor;
18 $max_size = --$max_size * 1024; // Make 1KByte spare (for $navi, etc)
20 $rw = ! PKWK_READONLY;
26 $body = preg_replace('#<a[^>]+>' . preg_quote($_symbol_anchor, '#') . '</a>#', '', $body);
28 // Shrink IMG tags (= images) with character strings
30 $body = preg_replace('#(<div[^>]+>)?(<a[^>]+>)?<img[^>]*alt="([^"]+)"[^>]*>(?(2)</a>)(?(1)</div>)#i', '[$3]', $body);
32 $body = preg_replace('#(<div[^>]+>)?(<a[^>]+>)?<img[^>]+>(?(2)</a>)(?(1)</div>)#i', '[img]', $body);
36 // Check content volume, Page numbers, divided by this skin
37 $pagecount = ceil(strlen($body) / $max_size);
39 // Too large contents to edit
40 if ($edit && $pagecount > 1)
41 die('Unable to edit: Too large contents for your device');
44 $body = substr($body, $pageno * $max_size, $max_size);
47 // Top navigation (text) bar
50 $navi[] = '<a href="' . $link['top'] . '" ' . $accesskey . '="0">0.Top</a>';
52 $navi[] = '<a href="' . $link['new'] . '" ' . $accesskey . '="1">1.New</a>';
53 $navi[] = '<a href="' . $link['edit'] . '" ' . $accesskey . '="2">2.Edit</a>';
54 if ($is_read && $function_freeze) {
56 $navi[] = '<a href="' . $link['freeze'] . '" ' . $accesskey . '="3">3.Freeze</a>';
58 $navi[] = '<a href="' . $link['unfreeze'] . '" ' . $accesskey . '="3">3.Unfreeze</a>';
62 $navi[] = '<a href="' . $script . '?' . rawurlencode($menubar) . '" ' . $accesskey . '="4">4.Menu</a>';
63 $navi[] = '<a href="' . $link['recent'] . '" ' . $accesskey . '="5">5.Recent</a>';
65 // Previous / Next block
70 $navi[] = '<a href="' . $script . '?cmd=read&page=' . $r_page .
71 '&p=' . $prev . '" ' . $accesskey . '="7">7.Prev</a>';
73 $navi[] = $next . '/' . $pagecount . ' ';
74 if ($pageno < $pagecount - 1) {
75 $navi[] = '<a href="' . $script . '?cmd=read&page=' . $r_page .
76 '&p=' . $next . '" ' . $accesskey . '="8">8.Next</a>';
80 $navi = join(' | ', $navi);
83 // Output HTTP headers
86 // Force Shift JIS encode for Japanese embedded browsers and devices
87 header('Content-Type: text/html; charset=Shift_JIS');
88 $title = mb_convert_encoding($title, 'SJIS', SOURCE_ENCODING);
89 $body = mb_convert_encoding($body, 'SJIS', SOURCE_ENCODING);
91 header('Content-Type: text/html; charset=' . CONTENT_CHARSET);
95 ?><html><head><title><?php
97 ?></title></head><body><?php