X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=lib%2Fhtml.php;h=d1289727a368b7d4566c092fab8a57f9c3b6c115;hb=42880ef94a44ff5dc080bb3e239af620e42371bc;hp=c0a1ee16398d62875aa83b709a1f3855ac9259a4;hpb=796d52600effa44e0662cccb2232131cb443ca77;p=pukiwiki%2Fpukiwiki.git
diff --git a/lib/html.php b/lib/html.php
index c0a1ee1..d128972 100644
--- a/lib/html.php
+++ b/lib/html.php
@@ -1,8 +1,8 @@
; rel=\"canonical\"");
+ }
+
// Search words
if ($search_word_color && isset($vars['word'])) {
$body = '
' . $_msg_word . htmlsc($vars['word']) .
@@ -146,20 +190,58 @@ function catbody($title, $page, $body)
}
}
- $longtaketime = getmicrotime() - MUTIME;
- $taketime = sprintf('%01.03f', $longtaketime);
+ // Embed Scripting data
+ $html_scripting_data = get_html_scripting_data();
+
+ // Compat: 'HTML convert time' without time about MenuBar and skin
+ $taketime = elapsedtime();
require(SKIN_FILE);
}
+/**
+ * Get data used by JavaScript modules
+ */
+function get_html_scripting_data()
+{
+ global $ticket_link_sites;
+ if (!isset($ticket_link_sites) || !is_array($ticket_link_sites)) {
+ return '';
+ }
+ // Require: PHP 5.4+
+ if (!defined('JSON_UNESCAPED_UNICODE')) {
+ return '';
+ };
+ $text = '';
+ foreach ($ticket_link_sites as $s) {
+ if (!preg_match('/^([a-zA-Z0-9]+)([\.\-][a-zA-Z0-9]+)*$/', $s['key'])) {
+ continue;
+ }
+ $site_info_json = htmlsc(json_encode($s, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
+ $text .= <<
+EOS;
+ $text .= "\n";
+ }
+ $data = <<
+$text
+
+EOS;
+ return $data;
+}
+
// Show 'edit' form
function edit_form($page, $postdata, $digest = FALSE, $b_template = TRUE)
{
- global $script, $vars, $rows, $cols, $hr, $function_freeze;
+ global $vars, $rows, $cols, $hr, $function_freeze;
global $_btn_preview, $_btn_repreview, $_btn_update, $_btn_cancel, $_msg_help;
global $whatsnew, $_btn_template, $_btn_load, $load_template_func;
global $notimeupdate;
+ global $_title_list, $_label_template_pages;
+ global $rule_page;
+ $script = get_base_uri();
// Newly generate $digest or not
if ($digest === FALSE) $digest = md5(join('', get_source($page)));
@@ -179,20 +261,55 @@ function edit_form($page, $postdata, $digest = FALSE, $b_template = TRUE)
}
if($load_template_func && $b_template) {
- $pages = array();
+ $tpage_names = array(); // Pages marked as template
+ $template_page = ':config/Templates';
+ $page_max = 100;
+ foreach(get_source($template_page) as $_templates) {
+ $m = array();
+ if (! preg_match('#\-\s*\[\[([^\[\]]+)\]\]#', $_templates, $m)) continue;
+ $tpage = preg_replace('#^./#', "$template_page/", $m[1]);
+ if (! is_page($tpage)) continue;
+ $tpage_names[] = $tpage;
+ }
+ $page_names = array();
foreach(get_existpages() as $_page) {
- if ($_page == $whatsnew || check_non_list($_page))
+ if ($_page == $whatsnew || check_non_list($_page) ||
+ !is_page_readable($_page))
continue;
- $s_page = htmlsc($_page);
- $pages[$_page] = ' ';
+ if (preg_match('/template/i', $_page)) {
+ $tpage_names[] = $_page;
+ } else {
+ if (count($page_names) >= $page_max) continue;
+ $page_names[] = $_page;
+ }
+ }
+ $tpage_names2 = array_values(array_unique($tpage_names));
+ natcasesort($tpage_names2);
+ natcasesort($page_names);
+ $tpages = array(); // Template pages
+ $npages = array(); // Normal pages
+ foreach($tpage_names2 as $p) {
+ $ps = htmlsc($p);
+ $tpages[] = ' ';
+ }
+ foreach($page_names as $p) {
+ $ps = htmlsc($p);
+ $npages[] = ' ';
}
- ksort($pages, SORT_STRING);
- $s_pages = join("\n", $pages);
+ if (count($page_names) === $page_max) {
+ $npages[] = ' ';
+ }
+ $s_tpages = join("\n", $tpages);
+ $s_npages = join("\n", $npages);
$template = <<
-$s_pages
+
+
@@ -256,36 +373,32 @@ $template
EOD;
- if (isset($vars['help'])) {
- $body .= $hr . catrule();
- } else {
- $body .= '';
- }
-
+ $body .= '';
return $body;
}
// Related pages
function make_related($page, $tag = '')
{
- global $script, $vars, $rule_related_str, $related_str;
- global $_ul_left_margin, $_ul_margin, $_list_pad_str;
+ global $vars, $rule_related_str, $related_str;
+ $script = get_base_uri();
+ prepare_links_related($page);
$links = links_get_related($page);
if ($tag) {
- ksort($links, SORT_STRING);
+ ksort($links, SORT_STRING); // Page name, alphabetical order
} else {
- arsort($links);
+ arsort($links, SORT_NUMERIC); // Last modified date, newer
}
$_links = array();
foreach ($links as $page=>$lastmod) {
if (check_non_list($page)) continue;
- $r_page = rawurlencode($page);
+ $r_page = pagename_urlencode($page);
$s_page = htmlsc($page);
$passage = get_passage($lastmod);
$_links[] = $tag ?
@@ -297,8 +410,7 @@ function make_related($page, $tag = '')
if (empty($_links)) return ''; // Nothing
if ($tag == 'p') { // From the line-head
- $margin = $_ul_left_margin + $_ul_margin;
- $style = sprintf($_list_pad_str, 1, $margin, $margin);
+ $style = sprintf(pkwk_list_attrs_template(), 1, 1);
$retval = "\n" . '' . "\n" .
'- ' . join($rule_related_str, $_links) . '
' . "\n" .
'
' . "\n";
@@ -358,12 +470,9 @@ function strip_autolink($str)
// Make a backlink. searching-link of the page name, by the page name, for the page name
function make_search($page)
{
- global $script;
-
$s_page = htmlsc($page);
$r_page = rawurlencode($page);
-
- return '' . $s_page . ' ';
}
@@ -535,4 +644,10 @@ function pkwk_output_dtd($pkwk_dtd = PKWK_DTD_XHTML_1_1, $charset = CONTENT_CHAR
return '' . "\n";
}
}
-?>
+
+/**
+ * Get template of List (ul, ol, dl) attributes
+ */
+function pkwk_list_attrs_template() {
+ return ' class="list%d list-indent%d"';
+}