Top/Net/pukiwiki/plugin

plugin tips

paraedit.inc.php 0.8

pukiwiki 1.5.1 への組み込み方

  1. DL
  2. lib/pukiwiki.php の編集
    1. メイン処理(// Main)の直前に次の二行を追加。(paraedit 0.6以降)
      include_once(PLUGIN_DIR . 'paraedit.inc.php');
      $post["msg"] = _plugin_paraedit_parse_postmsg($post["msg_before"], $post["msg"], $post["msg_after"]);
  3. skin (skin/pukiwiki.skin.ja.php) の書換え
    • skin/pukiwiki.skin.php内の二箇所を書き換え
    1. 1ヵ所目
      • 変更前
        <?php echo $body ?>
      • 変更後
        <?php include_once 'plugin/paraedit.inc.php'; echo _plugin_paraedit_mkeditlink($body); ?>
      • (注意) InputHelper と ParaEdit を併用する場合は下記の様にして下さい。
        php include_once 'plugin/input_helper.inc.php'; include_once 'plugin/input_helper.inc.php';
        echo plugin_input_helper_echo( _plugin_paraedit_mkeditlink($body) );
    2. 2ヵ所目
      pkwk_common_headers();
      の直前あたりに
      // ParaEdit
      if(exist_plugin('paraedit')) {
         $body = _plugin_paraedit_mkeditlink($body);
      }
      を追加。↑のもinclude_onceよりexist_pluginの方がスマートな気が。
  4. lib/convert_html.php の編集。 class Heading extends Element 内にある、
    	function toString()
    	{
    		return $this->msg_top .  $this->wrap(parent::toString(),
    			'h' . $this->level, ' id="' . $this->id . '"');
    	}
    を、次のように書き変える。
    	function toString()
    	{
     		// paraedit.inc.php 用の変更
    		// for enable paraedit.inc.php on pukiwiki 1.5.0 or later
    		$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 . '"');
    
    		/*
    		return $this->msg_top .  $this->wrap(parent::toString(),
    			'h' . $this->level, ' id="' . $this->id . '"');
    		*/
    	}
    • ちょっと補足:改変3行目の後ろの方にあるid=の一文字前は半角の空白が一つあります。空白を入れ忘れると、通常ページのh2やh3等のタグが機能しなくなってしまいます・・ (T-T
  5. paraedit.inc.php 自体への変更
    • pukiwiki1.5.1, PHP7 以降では、以下の変更が必要
    1. 2箇所ある split() を explode() に変更
      1. 1箇所目
        	// $vars[msg] を分割
        	$msg_before; $msg_now; $msg_after; // 編集行とその前後
        	$part = $vars['parnum'];
        	$index_num = 0;
        	$is_first_line = 1;
        
        	// for pukiwiki 1.5.0 or later
        	//  foreach (split ("\n", $postdata) as $line) {
            foreach (explode ("\n", $postdata) as $line) {
      2. 2箇所目
        function _plugin_paraedit_mkeditlink($body)
        {
        	// [edit]リンクの作成
        	global $script, $get, $post, $vars;
        	// for pukiwiki 1.5.0 or later
        	// $lines = split("\n", $body);
        	$lines = explode("\n", $body);

トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2019-06-09 (日) 16:59:05