• R/O
  • HTTP
  • SSH
  • HTTPS

pukiwiki: Commit


Commit MetaInfo

Revision29160f1743c28e607ad39e7604ec8075b05fcfeb (tree)
Time2016-02-01 23:43:42
Authorumorigu <umorigu@gmai...>
Commiterumorigu

Log Message

BugTrack2/374 Record timestamp and edit user as author info

author plugin (plugin/author.inc.php) outputs empty string
for HTML text.

Change Summary

Incremental Difference

--- a/lib/file.php
+++ b/lib/file.php
@@ -84,6 +84,7 @@ function page_write($page, $postdata, $notimestamp = FALSE)
8484 if (PKWK_READONLY) return; // Do nothing
8585
8686 $postdata = make_str_rules($postdata);
87+ $postdata = add_author_info(remove_author_info($postdata));
8788
8889 // Create and write diff
8990 $oldpostdata = is_page($page) ? join('', get_source($page)) : '';
@@ -158,6 +159,30 @@ function make_str_rules($source)
158159 return implode("\n", $lines);
159160 }
160161
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+
161186 // Generate ID
162187 function generate_fixed_heading_anchor_id($seed)
163188 {
--- /dev/null
+++ b/plugin/author.inc.php
@@ -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 ''; }
Show on old repository browser