Commit MetaInfo

修订版cf248491642cd12c26362a763aea6ccb53fce238 (tree)
时间2017-08-27 11:16:10
作者umorigu <umorigu@gmai...>
Commiterumorigu

Log Message

BugTrack/2256 edit: Handle template loading button

更改概述

差异

--- a/plugin/edit.inc.php
+++ b/plugin/edit.inc.php
@@ -19,8 +19,10 @@ function plugin_edit_action()
1919
2020 check_editable($page, true, true);
2121
22- if (isset($vars['preview']) || ($load_template_func && isset($vars['template']))) {
23- return plugin_edit_preview();
22+ if (isset($vars['preview'])) {
23+ return plugin_edit_preview($vars['msg']);
24+ } else if ($load_template_func && isset($vars['template'])) {
25+ return plugin_edit_preview_with_template();
2426 } else if (isset($vars['write'])) {
2527 return plugin_edit_write();
2628 } else if (isset($vars['cancel'])) {
@@ -33,25 +35,40 @@ function plugin_edit_action()
3335 return array('msg'=>$_title_edit, 'body'=>edit_form($page, $postdata));
3436 }
3537
36-// Preview
37-function plugin_edit_preview()
38+/**
39+ * Preview with template
40+ */
41+function plugin_edit_preview_with_template()
3842 {
3943 global $vars;
40- global $_title_preview, $_msg_preview, $_msg_preview_delete;
41-
44+ $msg = '';
4245 $page = isset($vars['page']) ? $vars['page'] : '';
43-
4446 // Loading template
4547 $template_page;
4648 if (isset($vars['template_page']) && is_page($template_page = $vars['template_page'])) {
4749 if (is_page_readable($template_page)) {
48- $vars['msg'] = remove_author_info(get_source($vars['template_page'], TRUE, TRUE));
50+ $msg = remove_author_info(get_source($vars['template_page'], TRUE, TRUE));
4951 // Cut fixed anchors
50- $vars['msg'] = preg_replace('/^(\*{1,3}.*)\[#[A-Za-z][\w-]+\](.*)$/m', '$1$2', $vars['msg']);
52+ $msg = preg_replace('/^(\*{1,3}.*)\[#[A-Za-z][\w-]+\](.*)$/m', '$1$2', $msg);
5153 }
5254 }
53- $vars['msg'] = preg_replace(PLUGIN_EDIT_FREEZE_REGEX, '', $vars['msg']);
54- $postdata = $vars['msg'];
55+ return plugin_edit_preview($msg);
56+}
57+
58+/**
59+ * Preview
60+ *
61+ * @param msg preview target
62+ */
63+function plugin_edit_preview($msg)
64+{
65+ global $vars;
66+ global $_title_preview, $_msg_preview, $_msg_preview_delete;
67+
68+ $page = isset($vars['page']) ? $vars['page'] : '';
69+
70+ $msg = preg_replace(PLUGIN_EDIT_FREEZE_REGEX, '', $msg);
71+ $postdata = $msg;
5572
5673 if (isset($vars['add']) && $vars['add']) {
5774 if (isset($vars['add_top']) && $vars['add_top']) {
@@ -72,7 +89,7 @@ function plugin_edit_preview()
7289 $postdata = drop_submit(convert_html($postdata));
7390 $body .= '<div id="preview">' . $postdata . '</div>' . "\n";
7491 }
75- $body .= edit_form($page, $vars['msg'], $vars['digest'], FALSE);
92+ $body .= edit_form($page, $msg, $vars['digest'], FALSE);
7693
7794 return array('msg'=>$_title_preview, 'body'=>$body);
7895 }
@@ -92,7 +109,7 @@ function plugin_edit_inline()
92109 // {label}. Strip anchor tags only
93110 $s_label = strip_htmltag(array_pop($args), FALSE);
94111
95- $page = array_shift($args);
112+ $page = array_shift($args);
96113 if ($page === NULL) $page = '';
97114 $_noicon = $_nolabel = FALSE;
98115 foreach($args as $arg){
Show on old repository browser