Revision | 29160f1743c28e607ad39e7604ec8075b05fcfeb (tree) |
---|---|
Time | 2016-02-01 23:43:42 |
Author | ![]() |
Commiter | umorigu |
BugTrack2/374 Record timestamp and edit user as author info
author plugin (plugin/author.inc.php) outputs empty string
for HTML text.
@@ -84,6 +84,7 @@ 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 | + $postdata = add_author_info(remove_author_info($postdata)); | |
87 | 88 | |
88 | 89 | // Create and write diff |
89 | 90 | $oldpostdata = is_page($page) ? join('', get_source($page)) : ''; |
@@ -158,6 +159,30 @@ function make_str_rules($source) | ||
158 | 159 | return implode("\n", $lines); |
159 | 160 | } |
160 | 161 | |
162 | +function add_author_info($wikitext) | |
163 | +{ | |
164 | + global $auth_user; | |
165 | + $author = preg_replace('/"/', '', $auth_user); | |
166 | + $displayname = preg_replace('/"/', '', $auth_user); | |
167 | + $author_text = sprintf('#author("%s","%s","%s")', | |
168 | + get_date_atom(UTIME + LOCALZONE), $author, $displayname) . "\n"; | |
169 | + return $author_text . $wikitext; | |
170 | +} | |
171 | + | |
172 | +function remove_author_info($wikitext) | |
173 | +{ | |
174 | + return preg_replace('/^\s*#author\([^\n]*(\n|$)/m', '', $wikitext); | |
175 | +} | |
176 | + | |
177 | +function get_date_atom($timestamp) | |
178 | +{ | |
179 | + // Compatible with DATE_ATOM format | |
180 | + // return date(DATE_ATOM, $timestamp); | |
181 | + $zmin = abs(LOCALZONE / 60); | |
182 | + return date('Y-m-d\TH:i:s', $timestamp) . sprintf('%s%02d:%02d', | |
183 | + (LOCALZONE < 0 ? '-' : '+') , $zmin / 60, $zmin % 60); | |
184 | +} | |
185 | + | |
161 | 186 | // Generate ID |
162 | 187 | function generate_fixed_heading_anchor_id($seed) |
163 | 188 | { |
@@ -0,0 +1,9 @@ | ||
1 | +<?php | |
2 | +// PukiWiki - Yet another WikiWikiWeb clone. | |
3 | +// author.inc.php | |
4 | +// Copyright: 2016 PukiWiki Development Team | |
5 | +// License: GPL v2 or (at your option) any later version | |
6 | +// | |
7 | +// author plugin | |
8 | + | |
9 | +function plugin_author_convert() { return ''; } |