paraeditの導入方法†
paraeditは ただpluginディレクトリに設置しただけでは動きません。以下の通りにファイルの修正が必要です。
当サイトで使用したparaeditのバージョンは1.0です。
paraeditの設置†
paraedit.inc.phpをpluginディレクトリに設置してください。参照先のサイトでは最後に設置するように書いてありますが 先に設置して問題ありません。多分・・・(汗
むしろ先に設置して 一つ一つファイルの修正の具合を確認しながら 修正を進めた方が良いように思います。
lib/pukiwiki.php†
lib/pukiwiki.php に次のコードを追加してください。
// メイン処理の直前に次の二行を追加。(paraedit 0.6以降) include_once('plugin/paraedit.inc.php'); $post["msg"] = _plugin_paraedit_parse_postmsg($post["msg_before"], $post["msg"], $post["msg_after"]); // main
バージョンによっては(1.4.7等、PLUGIN_DIRが定義されたバージョンでは)
include_once(PLUGIN_DIR . 'paraedit.inc.php'); $post["msg"] = _plugin_paraedit_parse_postmsg($post["msg_before"], $post["msg"], $post["msg_after"]);
skin/pukiwiki.skin.php†
pukiwiki 1.5.3では skin/pukiwiki.skin.phpの1箇所を書き換えて下さい。
変更前
<div id="body"><?php echo $body ?></div>
変更後
<div id="body"><?php include_once 'plugin/paraedit.inc.php'; echo _plugin_paraedit_mkeditlink($body); ?></div>
lib/convert_html†
lib/convert_html.phpを以下の様に編集してください。
pukiwiki Ver1.5.3の場合 class Heading extends Element 内にある、
return $this->msg_top . $this->wrap(parent::toString(), 'h' . $this->level, ' id="' . $this->id . '"');
上の二行を下の三行に置き換えてください。
$paraedit_flag = (preg_match("/^content_1_/", $this->id)) ? ' paraedit_flag=on' : ''; return $this->msg_top. $this->wrap(parent::toString(),'h'.$this->level," id=\"{$this->id}\"$paraedit_flag");
独自修正†
上記のlib/convert_html.phpを以下の様に修正すると 各ページの編集権限をチェックして 編集権限の無いページでは [edit]を表示しなくなります。
if( edit_auth($page, false, false ) ) { $paraedit_flag = (preg_match("/^content_1_/", $this->id)) ? ' paraedit_flag=on' : ''; return $this->msg_top. $this->wrap(parent::toString(),'h'.$this->level," id=\"{$this->id}\"$paraedit_flag"); } else { return $this->msg_top . $this->wrap(parent::toString(), 'h' . $this->level, ' id="' . $this->id . '"'); }
下のイメージの様にログイン中だけ[edit]マークを表示するようになります。