<?php
-/////////////////////////////////////////////////
// PukiWiki - Yet another WikiWikiWeb clone.
+// $Id: freeze.inc.php,v 1.12 2011/01/25 15:01:01 henoheno Exp $
+// Copyright: 2003-2004, 2007 PukiWiki Developers Team
+// License: GPL v2 or (at your option) any later version
//
-// $Id: freeze.inc.php,v 1.8 2004/12/16 13:09:48 henoheno Exp $
-//
-// Åà·ë
-function plugin_freeze_convert()
-{
- return '';
-}
+// Freeze(Lock) plugin
+
+// Reserve 'Do nothing'. '^#freeze' is for internal use only.
+function plugin_freeze_convert() { return ''; }
function plugin_freeze_action()
{
global $_msg_invalidpass, $_msg_freezing, $_btn_freeze;
$page = isset($vars['page']) ? $vars['page'] : '';
-
- if (!$function_freeze or !is_page($page))
+ if (! $function_freeze || ! is_page($page))
return array('msg' => '', 'body' => '');
$pass = isset($vars['pass']) ? $vars['pass'] : NULL;
+ $msg = $body = '';
if (is_freeze($page)) {
- return array(
- 'msg' => $_title_isfreezed,
- 'body' => str_replace('$1', htmlspecialchars(strip_bracket($page)), $_title_isfreezed)
- );
+ // Freezed already
+ $msg = & $_title_isfreezed;
+ $body = str_replace('$1', htmlsc(strip_bracket($page)),
+ $_title_isfreezed);
+
} else if ($pass !== NULL && pkwk_login($pass)) {
+ // Freeze
$postdata = get_source($page);
array_unshift($postdata, "#freeze\n");
- $postdata = join('', $postdata);
-
- file_write(DATA_DIR,$page, $postdata, TRUE);
+ file_write(DATA_DIR, $page, join('', $postdata), TRUE);
+ // Update
is_freeze($page, TRUE);
$vars['cmd'] = 'read';
- return array('msg' => $_title_freezed, 'body' => '');
- }
- // Åà·ë¥Õ¥©¡¼¥à¤òɽ¼¨
- $s_page = htmlspecialchars($page);
-
- $body = ($pass === NULL) ? '' : "<p><strong>$_msg_invalidpass</strong></p>\n";
- $body .= <<<EOD
+ $msg = & $_title_freezed;
+ $body = '';
+
+ } else {
+ // Show a freeze form
+ $msg = & $_title_freeze;
+ $s_page = htmlsc($page);
+ $body = ($pass === NULL) ? '' : "<p><strong>$_msg_invalidpass</strong></p>\n";
+ $body .= <<<EOD
<p>$_msg_freezing</p>
<form action="$script" method="post">
<div>
</div>
</form>
EOD;
+ }
- return array('msg'=>$_title_freeze, 'body'=>$body);
+ return array('msg'=>$msg, 'body'=>$body);
}
?>