<?php
// PukiWiki - Yet another WikiWikiWeb clone
-// $Id: pcomment.inc.php,v 1.48 2011/01/25 15:01:01 henoheno Exp $
+// pcomment.inc.php
+// Copyright 2002-2017 PukiWiki Development Team
+// License: GPL v2 or (at your option) any later version
//
// pcomment plugin - Show/Insert comments into specified (another) page
-//
+
// Usage: #pcomment([page][,max][,options])
//
// page -- An another page-name that holds comments
// reply -- Show radio buttons allow to specify where to reply
// Default recording page name (%s = $vars['page'] = original page name)
-switch (LANG) {
-case 'ja': define('PLUGIN_PCOMMENT_PAGE', '[[コメント/%s]]'); break;
-default: define('PLUGIN_PCOMMENT_PAGE', '[[Comments/%s]]'); break;
-}
+define('PLUGIN_PCOMMENT_PAGE', '[[Comments/%s]]');
+define('PLUGIN_PCOMMENT_PAGE_COMPATIBLE', '[[コメント/%s]]'); // for backword compatible of 'ja' pcomment
define('PLUGIN_PCOMMENT_NUM_COMMENTS', 10); // Default 'latest N posts'
define('PLUGIN_PCOMMENT_DIRECTION_DEFAULT', 1); // 1: above 0: below
}
pkwk_headers_sent();
- header('Location: ' . get_script_uri() . '?' . rawurlencode($refer));
+ header('Location: ' . get_page_uri($refer, PKWK_URI_ROOT));
exit;
}
plugin_pcomment_check_arg($arg, $params);
$vars_page = isset($vars['page']) ? $vars['page'] : '';
- $page = (isset($params['_args'][0]) && $params['_args'][0] != '') ? $params['_args'][0] :
- sprintf(PLUGIN_PCOMMENT_PAGE, strip_bracket($vars_page));
+ if (isset($params['_args'][0]) && $params['_args'][0] != '') {
+ $page = $params['_args'][0];
+ } else {
+ $raw_vars_page = strip_bracket($vars_page);
+ $page = sprintf(PLUGIN_PCOMMENT_PAGE, $raw_vars_page);
+ $raw_page = strip_bracket($page);
+ if (!is_page($raw_page)) {
+ // If the page doesn't exist, search backward-compatible page
+ // If only compatible page exists, set the page as comment target
+ $page_compat = sprintf(PLUGIN_PCOMMENT_PAGE_COMPATIBLE, $raw_vars_page);
+ if (is_page(strip_bracket($page_compat))) {
+ $page = $page_compat;
+ }
+ }
+ }
$count = isset($params['_args'][1]) ? intval($params['_args'][1]) : 0;
if ($count == 0) $count = PLUGIN_PCOMMENT_NUM_COMMENTS;
return array($comments, $digest);
}
-?>