diff --git a/.README.md.swp b/.README.md.swp new file mode 100644 index 0000000..3b73818 --- /dev/null +++ b/.README.md.swp Binary files differ diff --git a/README.md b/README.md new file mode 100644 index 0000000..1643482 --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +* tabeleditor(Pukiwiki用プラグイン) † + + + * 使用方法(ブロックのみ): #tabeleditor(); + + - テーブルを、編集モードに入らなくても修正できるようになる。 + - テーブルの要素をクリックするとテキストフィールドになり入力できるようになる。 + - 新しい値を入力すると変更したものが赤くなり、tabeleditorを書いたところに送信ボタンが出現する。 + - テキストフィールド中でESCキーを押すと最初のテキストに戻る + - 送信ボタンを押すとwikiページの表が変更される。 + - 呼び出し箇所にtableをいじるJavaScriptを生成する。 + - 注意 上記理由からそこまでに出現しているテーブルしか修正できない。 + - 改行 &br;だけは対応しているけど、他何もしていない。きっと問題あるはず。 + - 誰か直し(ry + - たべれでぃたーで合ってます。TYPOじゃありません。 diff --git a/tabeleditor.inc.php b/tabeleditor.inc.php new file mode 100644 index 0000000..7b81228 --- /dev/null +++ b/tabeleditor.inc.php @@ -0,0 +1,175 @@ + "TableEditor", "Tabeleditor" + +function plugin_tabeleditor_action() +{ + global $vars, $now, $_title_updated, $_no_name; + global $_msg_tabeleditor_collided, $_title_tabetemas_collided; + global $_tabeleditor_plugin_fail_msg; + + if (PKWK_READONLY) die_message('PKWK_READONLY prohibits editing'); + + $head = ''; + $match = array(); + + + $tabeleditor_added = TRUE; + $cell_counter = 0; + foreach (get_source($vars['refer']) as $line) { + if (strpos($line, "|") === 0) { + preg_match("/([fh])$/", $line, $match); + $postamble = $match[1]; + $line = preg_replace("/^\\|(.*)\\|[fh]?$[^|]*/", "$1", $line); + $postdata .= "|"; + foreach(explode("|", $line) as $cell) { + if (strpos($cell,"~")===FALSE) { + $entry_name = "__buttons_" . $cell_counter; + //$postdata .= $cell_counter; + if ($vars[$entry_name]!==null) { + $postdata .= $vars[$entry_name] . "|"; + } else { + $postdata .= $cell . "|"; + } + $cell_counter++; + } else { + $postdata .= $cell . "|"; + } + } + $postdata .= "$postamble\n"; + } else { + $postdata .= $line; + } + } + + $title = $_title_updated; + $body = $postdata; + if ($tabeleditor_added) { + // new tabeleditor added + if (md5(get_source($vars['refer'], TRUE, TRUE)) !== $vars['digest']) { + $title = $_title_tabeleditor_collided; + $body = $_msg_tabeleditor_collided . make_pagelink($vars['refer']); + } + page_write($vars['refer'], $postdata); + } else { + // failed to add the tabeleditor + $title = $_title_tabeleditor_collided; + $body = $_tabeleditor_plugin_fail_msg . make_pagelink($vars['refer']); + } + $retvars['msg'] = $vars['name']; + $retvars['body'] = $vars['body']; + $vars['page'] = $vars['refer']; + return $retvars; +} + +function plugin_tabeleditor_convert() +{ + global $vars, $digest, $_btn_tabeleditor, $_btn_name, $_msg_tabetemas; + static $numbers = array(); + + if (PKWK_READONLY) return ''; // Show nothing + + $page = $vars['page']; + if (! isset($numbers[$page])) $numbers[$page] = 0; + $tabeleditor_no = $numbers[$page]++; + + $options = func_num_args() ? func_get_args() : array(); + + $script = get_script_uri(); + $s_page = htmlsc($page); + $string = << + .style_td input { + font-size: 100%; + background: linear-gradient(#6af 0%, #fef 10%, #dde 85%, #fff 100%); +} + + + +
+ + + + + +
+EOD; + + return $string; +} +