内に追加するタグ
$head_tag = count($head_tags) ? join("\n",$head_tags)."\n" : '';
// 1.3.x compat
// ページの最終更新時刻(UNIX timestamp)
$fmt = $is_read ? get_filetime($_page) + LOCALZONE : 0;
//単語検索
if ($search_word_color and array_key_exists('word',$vars))
{
$body = '
'.$_msg_word.htmlspecialchars($vars['word'])."
$hr\n$body";
$words = array_flip(array_splice(preg_split('/\s+/',$vars['word'],-1,PREG_SPLIT_NO_EMPTY),0,10));
$keys = array();
foreach ($words as $word=>$id)
{
$keys[$word] = strlen($word);
}
arsort($keys,SORT_NUMERIC);
$keys = get_search_words(array_keys($keys),TRUE);
$id = 0;
foreach ($keys as $key=>$pattern)
{
$s_key = htmlspecialchars($key);
$pattern = "/<[^>]*>|($pattern)|&[^;]+;/";
$callback = create_function(
'$arr',
'return (count($arr) > 1) ? "{$arr[1]}" : $arr[0];'
);
$body = preg_replace_callback($pattern,$callback,$body);
$notes = preg_replace_callback($pattern,$callback,$notes);
}
}
$longtaketime = getmicrotime() - MUTIME;
$taketime = sprintf('%01.03f',$longtaketime);
if (!file_exists(SKIN_FILE)||!is_readable(SKIN_FILE))
{
die_message(SKIN_FILE.'(skin file) is not found.');
}
require(SKIN_FILE);
}
// インライン要素のパース (obsolete)
function inline($line,$remove=FALSE)
{
global $NotePattern;
$line = htmlspecialchars($line);
if ($remove)
{
$line = preg_replace($NotePattern,'',$line);
}
return $line;
}
// インライン要素のパース (リンク、見出し一覧) (obsolete)
function inline2($str)
{
return make_link($str);
}
// 編集フォームの表示
function edit_form($page,$postdata,$digest = 0,$b_template = TRUE)
{
global $script,$vars,$rows,$cols,$hr,$function_freeze;
global $_btn_addtop,$_btn_preview,$_btn_repreview,$_btn_update,$_btn_freeze,$_msg_help,$_btn_notchangetimestamp;
global $whatsnew,$_btn_template,$_btn_load,$non_list,$load_template_func;
$refer = $template = $addtag = $add_top = '';
if ($digest == 0) {
$digest = md5(join('',get_source($page)));
}
$checked_top = array_key_exists('add_top',$vars) ? ' checked="checked"' : '';
$checked_time = array_key_exists('notimestamp',$vars) ? ' checked="checked"' : '';
if(array_key_exists('add',$vars)) {
$addtag = '';
$add_top = "$_btn_addtop";
}
if($load_template_func and $b_template) {
$_pages = get_existpages();
$pages = array();
foreach($_pages as $_page) {
if ($_page == $whatsnew or preg_match("/$non_list/",$_page)) {
continue;
}
$s_page = htmlspecialchars($_page);
$pages[$_page] = " ";
}
ksort($pages);
$s_pages = join("\n",$pages);
$template = <<
$s_pages
EOD;
if (array_key_exists('refer',$vars) and $vars['refer'] != '') {
$refer = '[['.strip_bracket($vars['refer'])."]]\n\n";
}
}
$r_page = rawurlencode($page);
$s_page = htmlspecialchars($page);
$s_digest = htmlspecialchars($digest);
$s_postdata = htmlspecialchars($refer.$postdata);
$s_original = array_key_exists('original',$vars) ? htmlspecialchars($vars['original']) : $s_postdata;
$b_preview = array_key_exists('preview',$vars); // プレビュー中TRUE
$btn_preview = $b_preview ? $_btn_repreview : $_btn_preview;
$body = <<
$template
$addtag
$add_top
$_btn_notchangetimestamp
EOD;
if (array_key_exists('help', $vars)) {
$body .= $hr . catrule();
} else {
$body .=
"";
}
return $body;
}
// 関連するページ
function make_related($page,$tag='')
{
global $script,$vars,$related,$rule_related_str,$related_str,$non_list;
global $_ul_left_margin, $_ul_margin, $_list_pad_str;
$links = links_get_related($page);
if ($tag) {
ksort($links);
}
else {
arsort($links);
}
$_links = array();
foreach ($links as $page=>$lastmod)
{
if (preg_match("/$non_list/",$page))
{
continue;
}
$r_page = rawurlencode($page);
$s_page = htmlspecialchars($page);
$passage = get_passage($lastmod);
$_links[] = $tag ?
"$s_page" :
"$s_page$passage";
}
if (count($_links) == 0)
{
return '';
}
if ($tag == 'p') // 行頭から
{
$margin = $_ul_left_margin + $_ul_margin;
$style = sprintf($_list_pad_str,1,$margin,$margin);
$retval = "\n\n- ".join($rule_related_str,$_links)."
\n
\n";
}
else if ($tag)
{
$retval = join($rule_related_str,$_links);
}
else
{
$retval = join($related_str,$_links);
}
return $retval;
}
// ユーザ定義ルール(ソースは置換せずコンバート)
function make_line_rules($str)
{
global $line_rules;
static $pattern,$replace;
if (!isset($pattern))
{
$pattern = array_map(create_function('$a','return "/$a/";'),array_keys($line_rules));
$replace = array_values($line_rules);
unset($line_rules);
}
return preg_replace($pattern,$replace,$str);
}
// HTMLタグを取り除く
function strip_htmltag($str)
{
global $_symbol_noexists;
$noexists_pattern = '#([^<]*)]+>'.
preg_quote($_symbol_noexists,'#').
'#';
$str = preg_replace($noexists_pattern,'$1',$str);
//$str = preg_replace('/]+>\?<\/a>/','',$str);
return preg_replace('/<[^>]+>/','',$str);
}
// ページ名からページ名を検索するリンクを作成
function make_search($page)
{
global $script,$WikiName;
$s_page = htmlspecialchars($page);
$r_page = rawurlencode($page);
//WikiWikiWeb like...
//if(preg_match("/^$WikiName$/",$page))
// $name = preg_replace("/([A-Z][a-z]+)/","$1 ",$name);
return "$s_page ";
}
// 見出しを生成 (注釈やHTMLタグを除去)
function make_heading(&$str,$strip=TRUE)
{
global $NotePattern;
// 見出しの固有ID部を削除
$id = '';
if (preg_match('/^(\*{0,3})(.*?)\[#([A-Za-z][\w-]+)\](.*?)$/m',$str,$matches))
{
$str = $matches[2].$matches[4];
$id = $matches[3];
}
else
{
$str = preg_replace('/^\*{0,3}/','',$str);
}
if ($strip)
{
$str = strip_htmltag(make_link(preg_replace($NotePattern,'',$str)));
}
return $id;
}
?>