修訂 | fdfc7785f930f9c8e1893697aa07c8d6dc1f1f91 (tree) |
---|---|
時間 | 2016-12-05 05:36:37 |
作者 | umorigu <umorigu@gmai...> |
Commiter | umorigu |
BugTrack/2404 Add filetime as author attr on "Don't change timestamp"
@@ -84,8 +84,12 @@ function page_write($page, $postdata, $notimestamp = FALSE) | ||
84 | 84 | if (PKWK_READONLY) return; // Do nothing |
85 | 85 | |
86 | 86 | $postdata = make_str_rules($postdata); |
87 | + $timestamp_to_keep = null; | |
88 | + if ($notimestamp) { | |
89 | + $timestamp_to_keep = get_filetime($page); | |
90 | + } | |
87 | 91 | $text_without_author = remove_author_info($postdata); |
88 | - $postdata = add_author_info($text_without_author); | |
92 | + $postdata = add_author_info($text_without_author, $timestamp_to_keep); | |
89 | 93 | $is_delete = empty($text_without_author); |
90 | 94 | |
91 | 95 | // Do nothing when it has no changes |
@@ -167,7 +171,13 @@ function make_str_rules($source) | ||
167 | 171 | return implode("\n", $lines); |
168 | 172 | } |
169 | 173 | |
170 | -function add_author_info($wikitext) | |
174 | +/** | |
175 | + * Add author plugin text for wiki text body | |
176 | + * | |
177 | + * @param string $wikitext | |
178 | + * @param integer $timestamp_to_keep Set null when not to keep timestamp | |
179 | + */ | |
180 | +function add_author_info($wikitext, $timestamp_to_keep) | |
171 | 181 | { |
172 | 182 | global $auth_user, $auth_user_fullname; |
173 | 183 | $author = preg_replace('/"/', '', $auth_user); |
@@ -176,10 +186,14 @@ function add_author_info($wikitext) | ||
176 | 186 | // Fullname is empty, use $author as its fullname |
177 | 187 | $fullname = preg_replace('/^[^:]*:/', '', $author); |
178 | 188 | } |
189 | + $datetime_to_keep = ''; | |
190 | + if (!is_null($timestamp_to_keep)) { | |
191 | + $datetime_to_keep .= ';' . get_date_atom($timestamp_to_keep + LOCALZONE); | |
192 | + } | |
179 | 193 | $displayname = preg_replace('/"/', '', $fullname); |
180 | 194 | $user_prefix = get_auth_user_prefix(); |
181 | 195 | $author_text = sprintf('#author("%s","%s","%s")', |
182 | - get_date_atom(UTIME + LOCALZONE), | |
196 | + get_date_atom(UTIME + LOCALZONE) . $datetime_to_keep, | |
183 | 197 | ($author ? $user_prefix . $author : ''), |
184 | 198 | $displayname) . "\n"; |
185 | 199 | return $author_text . $wikitext; |