Revision | cf248491642cd12c26362a763aea6ccb53fce238 (tree) |
---|---|
Zeit | 2017-08-27 11:16:10 |
Autor | umorigu <umorigu@gmai...> |
Commiter | umorigu |
BugTrack/2256 edit: Handle template loading button
@@ -19,8 +19,10 @@ function plugin_edit_action() | ||
19 | 19 | |
20 | 20 | check_editable($page, true, true); |
21 | 21 | |
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(); | |
24 | 26 | } else if (isset($vars['write'])) { |
25 | 27 | return plugin_edit_write(); |
26 | 28 | } else if (isset($vars['cancel'])) { |
@@ -33,25 +35,40 @@ function plugin_edit_action() | ||
33 | 35 | return array('msg'=>$_title_edit, 'body'=>edit_form($page, $postdata)); |
34 | 36 | } |
35 | 37 | |
36 | -// Preview | |
37 | -function plugin_edit_preview() | |
38 | +/** | |
39 | + * Preview with template | |
40 | + */ | |
41 | +function plugin_edit_preview_with_template() | |
38 | 42 | { |
39 | 43 | global $vars; |
40 | - global $_title_preview, $_msg_preview, $_msg_preview_delete; | |
41 | - | |
44 | + $msg = ''; | |
42 | 45 | $page = isset($vars['page']) ? $vars['page'] : ''; |
43 | - | |
44 | 46 | // Loading template |
45 | 47 | $template_page; |
46 | 48 | if (isset($vars['template_page']) && is_page($template_page = $vars['template_page'])) { |
47 | 49 | 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)); | |
49 | 51 | // 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); | |
51 | 53 | } |
52 | 54 | } |
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; | |
55 | 72 | |
56 | 73 | if (isset($vars['add']) && $vars['add']) { |
57 | 74 | if (isset($vars['add_top']) && $vars['add_top']) { |
@@ -72,7 +89,7 @@ function plugin_edit_preview() | ||
72 | 89 | $postdata = drop_submit(convert_html($postdata)); |
73 | 90 | $body .= '<div id="preview">' . $postdata . '</div>' . "\n"; |
74 | 91 | } |
75 | - $body .= edit_form($page, $vars['msg'], $vars['digest'], FALSE); | |
92 | + $body .= edit_form($page, $msg, $vars['digest'], FALSE); | |
76 | 93 | |
77 | 94 | return array('msg'=>$_title_preview, 'body'=>$body); |
78 | 95 | } |
@@ -92,7 +109,7 @@ function plugin_edit_inline() | ||
92 | 109 | // {label}. Strip anchor tags only |
93 | 110 | $s_label = strip_htmltag(array_pop($args), FALSE); |
94 | 111 | |
95 | - $page = array_shift($args); | |
112 | + $page = array_shift($args); | |
96 | 113 | if ($page === NULL) $page = ''; |
97 | 114 | $_noicon = $_nolabel = FALSE; |
98 | 115 | foreach($args as $arg){ |