• R/O
  • HTTP
  • SSH
  • HTTPS

pukiwiki: Commit


Commit MetaInfo

Revision5270f6ceb8b162f2e559780a5b79cbea247740be (tree)
Time2016-01-18 01:49:12
Authorumorigu <umorigu@gmai...>
Commiterumorigu

Log Message

BugTrack2/370 Set same pcomment default target page for en/ja

* Default page: Comments/%s
* Compatible default page: コメント/%s

If only compatible page exist, use compatible page as a default comment
target.

Change Summary

Incremental Difference

--- a/plugin/pcomment.inc.php
+++ b/plugin/pcomment.inc.php
@@ -17,10 +17,8 @@
1717 // reply -- Show radio buttons allow to specify where to reply
1818
1919 // Default recording page name (%s = $vars['page'] = original page name)
20-switch (LANG) {
21-case 'ja': define('PLUGIN_PCOMMENT_PAGE', '[[コメント/%s]]'); break;
22-default: define('PLUGIN_PCOMMENT_PAGE', '[[Comments/%s]]'); break;
23-}
20+define('PLUGIN_PCOMMENT_PAGE', '[[Comments/%s]]');
21+define('PLUGIN_PCOMMENT_PAGE_COMPATIBLE', '[[コメント/%s]]'); // for backword compatible of 'ja' pcomment
2422
2523 define('PLUGIN_PCOMMENT_NUM_COMMENTS', 10); // Default 'latest N posts'
2624 define('PLUGIN_PCOMMENT_DIRECTION_DEFAULT', 1); // 1: above 0: below
@@ -80,8 +78,21 @@ function plugin_pcomment_convert()
8078 plugin_pcomment_check_arg($arg, $params);
8179
8280 $vars_page = isset($vars['page']) ? $vars['page'] : '';
83- $page = (isset($params['_args'][0]) && $params['_args'][0] != '') ? $params['_args'][0] :
84- sprintf(PLUGIN_PCOMMENT_PAGE, strip_bracket($vars_page));
81+ if (isset($params['_args'][0]) && $params['_args'][0] != '') {
82+ $page = $params['_args'][0];
83+ } else {
84+ $raw_vars_page = strip_bracket($vars_page);
85+ $page = sprintf(PLUGIN_PCOMMENT_PAGE, $raw_vars_page);
86+ $raw_page = strip_bracket($page);
87+ if (!is_page($raw_page)) {
88+ // If the page doesn't exist, search backward-compatible page
89+ // If only compatible page exists, set the page as comment target
90+ $page_compat = sprintf(PLUGIN_PCOMMENT_PAGE_COMPATIBLE, $raw_vars_page);
91+ if (is_page(strip_bracket($page_compat))) {
92+ $page = $page_compat;
93+ }
94+ }
95+ }
8596 $count = isset($params['_args'][1]) ? intval($params['_args'][1]) : 0;
8697 if ($count == 0) $count = PLUGIN_PCOMMENT_NUM_COMMENTS;
8798
Show on old repository browser