PukiWiki/1.4/ちょっと便利に/タグ入力支援フォーム
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
*ちょっと便利に-タグ入力支援フォーム [#u45ad177]
-sonots さんの [[tag.inc.php>sonots:tag.inc.php]] の入力...
-おなじく sonots さんの [[enull.inc.php>sonots:enull.inc....
-enull.inc.php を使うときは、PKWKEXP_DISABLE_MULTILINE_PL...
-本文が空っぽでタグだけあるときは、ページ削除の動作に。
-special thanks to [[sonots]] さん :)
-----
#contents
**改造法 [#o990359f]
@/lib/html.php - l.237
// jidaikobo start - tag input form
// edit.inc.php とセット
// confirm pukiwiki.ini.php
// 処理とiniでの規定値確認
global $taginput_edit;
$tag_ini_flag['edit'] = (isset($taginput_edit['form'])) ...
$tag_ini_flag['position'] = (isset($taginput_edit['posit...
$tag_ini_flag['ask'] = (isset($taginput_edit['ask'])) ? ...
// existent plugin in plugin folder - tag.inc.php
// プラグインの存在確認 - tag.inc.php
$tag_plugin = PLUGIN_DIR . 'tag.inc.php';
$tag_tag_flag = (file_exists($tag_plugin)) ? '1' : '';
if($tag_ini_flag['edit'] == 1 && $tag_tag_flag == 1){
// existent plugin in plugin folder - enull.inc.php
// プラグインの存在確認 - enull.inc.php
$enull_plugin = PLUGIN_DIR . 'enull.inc.php';
$tag_enull_flag = (file_exists($enull_plugin)) ? '1' : ...
// existent tags in CACHE_DIR
// サイト内の既存タグの確認 - stolen from tag.inc.php b...
$cache = CACHE_DIR . 'tagcloud.tag';
if (file_exists($cache)){
$lines = file($cache);
if($lines != null){
foreach ($lines as $k => $v) {
list($tag_cache[], $count_cache[]) = explode("\t", $...
}
}else{
$tag_cache = array();
}
}else{
$tag_cache = array();
}
// prepare html and items
// HTML と選択肢の準備
$tag_html = '';
$tag_checked = ' checked="checked"';
// prepare item
// cache と既存入力値から選択肢を準備
preg_match("/&tag\((.*?)\);[[:space:]]/",$s_postdat...
$tag_each = explode(',',$tags[1]);
$tag_each_temp = array_pop($tag_each);
if($tag_each_temp != ''){
$tag_each[] = $tag_each_temp;
}
$tag = $tag_cache + $tag_each;
$tag = array_merge($tag_cache, $tag_each);
$tag = array_unique($tag);
// check tag position in page
// タグの位置確認
if(isset($tags)){
$s_postdata_line = explode("\n",$s_postdata);
// get line number
// 行数取得
foreach($s_postdata_line as $k => $v){
if(strpos($v,'&tag(') === 0){
$tag_position_strpos = $k;
$tag_pos_prev_k = $k - 1;
$tag_pos_prev = $s_postdata_line[$tag_pos_prev_k];
}
if(isset($tag_position_strpos) && $k > $tag_position_...
if(preg_match("/.+/",$v)) $not_bottom = true;
}
}
// head or bottom
// 先頭か末尾のときだけ特別扱い
$num_lines = count($s_postdata_line);
if(isset($not_bottom) && $tag_position_strpos == 0 || ...
$tag_position = 'head';
$tag_position_strpos = 0;
}elseif( ! isset($not_bottom)){
$tag_position = 'bottom';
}
}
// generate html
// タグ選択肢生成
foreach($tag as $k => $v){
$checked = '';
foreach($tag_each as $kk => $vv){
if($v == $vv){
$checked = $tag_checked;
}
}
$tag_html .= "\t".'<li style="display:inline;padding-r...
}
$tag_html = "\n".'<ul style="list-style:none;margin:0;p...
$tag_html = '<fieldset style="margin-bottom:10px;">'."\...
$tag_html .= "\t".'<li style="display:inline;padding-ri...
// enull existent check
// enull の存在確認
if(preg_match("/#enull{{\n*&tag/",$s_postdata)||$ta...
$check_enull = $tag_checked;
}
// deletion tag data from $s_postdata
// 入力欄からタグ関連データを一旦削除
$invisible_enul = "/\n*#enull{{\n*&tag\((.*?)\);\n*...
$invisible_tag = "/\n*&tag\((.*?)\);\n*/";
$s_postdata = preg_replace($invisible_enul,"\n",$s_post...
$s_postdata = preg_replace($invisible_tag,"\n",$s_postd...
// positioning tag
// tag の位置設定
if($tag_position == 'head' && ! $tag_ini_flag['position...
$check_head = $tag_checked;
}elseif($tag_position == 'bottom' || $tag_ini_flag['pos...
$check_bottom = $tag_checked;
}else{
$check_line = $tag_checked;
}
if($tag_ini_flag['ask'] === 1){
$tag_html .= <<<EOD
<hr />
<dl>
<dt style="display:inline;margin:0;padding-right:15px;">...
<dd style="display:inline;margin:0;padding-right:15px;"...
<dd style="display:inline;margin:0;padding-right:15px;"...
<dd style="display:inline;margin:0;padding-right:15px;"...
EOD;
// enull plugin check
// enull プラグインがあれば、チェックを表示
if($tag_enull_flag == '1'){
$tag_html .= "\n\t".'<dd style="display:inline;margin...
}
}else{
// default value of hidden position control
// タグ位置編集欄を非表示の際の規定値
if($check_head){
$tag_html .= '<input type="hidden" name="tag_position...
}else{
$tag_html .= '<input type="hidden" name="tag_position...
}
if($tag_enull_flag == '0' && $tag_ini_flag['position']...
$tag_html .= '<p><strong>Cannot control visibility by...
}elseif($check_enull){
$tag_html .= '<input type="hidden" name="tag_hidden" ...
}
}
$tag_html .= "\n</fieldset>";
}
// overwrite error message
// タグ入力支援許可しつつプラグインがない場合のエラー
if($tag_ini_flag['edit'] == 1 && $tag_tag_flag != 1){
$tag_html = '<p><strong>install tag.inc.php into plugin...
}
// jidaikobo end - tag input form
// attention: put $body into $tag_html after textarea
// $body のヒヤドキュメントに $tag_html を入れること
@/plugin/edit.inc.php - l.64
$postdata = $vars['msg'] = plugin_edit_tag($postdata); ...
@/plugin/edit.inc.php - l.189
$msg = plugin_edit_tag($msg); //jidaikobo
@/plugin/edit.inc.php - さいご
function plugin_edit_tag($msg){
// tags include values
global $vars;
if($msg != ''){
$tag_hidden = isset($vars['tag_hidden']) ? '1' : '';
$tag_add = ($vars['tag_add'] != '') ? $vars['tag_a...
$tag_position = isset($vars['tag_position']) ? $vars['t...
$tag_line = isset($vars['tag_pos_line']) ? $vars['t...
$tags = isset($vars['tag']) ? implode(',',$vars...
}
// tags include
if(isset($vars['tag'])||isset($vars['tag_add']) && $var...
$tags = (isset($tags)) ? $tags.','.$tag_add : $tag_add ;
$tags = '&tag('.htmlspecialchars($tags,ENT_QUOTES).');';
if(isset($vars['tag_hidden'])){
$tags = "#enull{{\n".$tags."\n}}\n";
}
if($tag_position == 'head'){
$msg = $tags."\n\n".$msg;
}elseif($tag_position == 'bottom'){
$msg = $msg."\n\n".$tags;
}elseif($tag_position == 'line'){
$msg_temp = explode("\n",$msg);
array_splice($msg_temp, $tag_line, 0,"\n".$tags."\n");
$msg = implode("\n",$msg_temp);
}
}
return $msg;
}
@pukiwiki.ini.php - どこでも
////////////////////////////////////////jidaikobo
// タグ用編集窓の追加(1:add or 0:remove)
$taginput_edit['form'] = 1;
// タグ位置の規定値(head, bottom, hidden)
$taginput_edit['position'] = 'hidden';
// タグ編集の可視設定(1:ask or 0:don't ask)
$taginput_edit['ask'] = 0;
***オマケ - タグの一覧 [#i2c0f56e]
@skinのてきとうなところ
//prepare tag
$cache = CACHE_DIR . 'tagcloud.tag';
if (file_exists($cache)){
$lines = file($cache);
if($lines != null){
foreach ($lines as $k => $v) {
list($tag_cache[], $count_cache[]) = explode("\t", $v);
}
}else{
$tag_cache = array();
$count_cache = array();
}
}else{
$tag_cache = array();
$count_cache = array();
}
$tag_cache=str_replace("%22",'',$tag_cache);
$count_cache=str_replace("\n",'',$count_cache);
//html - change heading level as you like
$tag_skin = "<h3>tag categories</h3>\n";
$tag_skin.= "<ul>\n";
foreach($tag_cache as $k => $v){
$tag_skin.= "\t".'<li><a href="'.$script.'?cmd=lsx&...
}
$tag_skin.= "</ul>\n";
**コメント [#k8fb2f40]
- これって実際導入するとどんな感じになるのかみてみたいん...
-- Do it yourselfが基本ですので、もし反応がない時はやって...
-- 反応遅れました。バージョンは 1.4.7 でした。この仕組み...
終了行:
*ちょっと便利に-タグ入力支援フォーム [#u45ad177]
-sonots さんの [[tag.inc.php>sonots:tag.inc.php]] の入力...
-おなじく sonots さんの [[enull.inc.php>sonots:enull.inc....
-enull.inc.php を使うときは、PKWKEXP_DISABLE_MULTILINE_PL...
-本文が空っぽでタグだけあるときは、ページ削除の動作に。
-special thanks to [[sonots]] さん :)
-----
#contents
**改造法 [#o990359f]
@/lib/html.php - l.237
// jidaikobo start - tag input form
// edit.inc.php とセット
// confirm pukiwiki.ini.php
// 処理とiniでの規定値確認
global $taginput_edit;
$tag_ini_flag['edit'] = (isset($taginput_edit['form'])) ...
$tag_ini_flag['position'] = (isset($taginput_edit['posit...
$tag_ini_flag['ask'] = (isset($taginput_edit['ask'])) ? ...
// existent plugin in plugin folder - tag.inc.php
// プラグインの存在確認 - tag.inc.php
$tag_plugin = PLUGIN_DIR . 'tag.inc.php';
$tag_tag_flag = (file_exists($tag_plugin)) ? '1' : '';
if($tag_ini_flag['edit'] == 1 && $tag_tag_flag == 1){
// existent plugin in plugin folder - enull.inc.php
// プラグインの存在確認 - enull.inc.php
$enull_plugin = PLUGIN_DIR . 'enull.inc.php';
$tag_enull_flag = (file_exists($enull_plugin)) ? '1' : ...
// existent tags in CACHE_DIR
// サイト内の既存タグの確認 - stolen from tag.inc.php b...
$cache = CACHE_DIR . 'tagcloud.tag';
if (file_exists($cache)){
$lines = file($cache);
if($lines != null){
foreach ($lines as $k => $v) {
list($tag_cache[], $count_cache[]) = explode("\t", $...
}
}else{
$tag_cache = array();
}
}else{
$tag_cache = array();
}
// prepare html and items
// HTML と選択肢の準備
$tag_html = '';
$tag_checked = ' checked="checked"';
// prepare item
// cache と既存入力値から選択肢を準備
preg_match("/&tag\((.*?)\);[[:space:]]/",$s_postdat...
$tag_each = explode(',',$tags[1]);
$tag_each_temp = array_pop($tag_each);
if($tag_each_temp != ''){
$tag_each[] = $tag_each_temp;
}
$tag = $tag_cache + $tag_each;
$tag = array_merge($tag_cache, $tag_each);
$tag = array_unique($tag);
// check tag position in page
// タグの位置確認
if(isset($tags)){
$s_postdata_line = explode("\n",$s_postdata);
// get line number
// 行数取得
foreach($s_postdata_line as $k => $v){
if(strpos($v,'&tag(') === 0){
$tag_position_strpos = $k;
$tag_pos_prev_k = $k - 1;
$tag_pos_prev = $s_postdata_line[$tag_pos_prev_k];
}
if(isset($tag_position_strpos) && $k > $tag_position_...
if(preg_match("/.+/",$v)) $not_bottom = true;
}
}
// head or bottom
// 先頭か末尾のときだけ特別扱い
$num_lines = count($s_postdata_line);
if(isset($not_bottom) && $tag_position_strpos == 0 || ...
$tag_position = 'head';
$tag_position_strpos = 0;
}elseif( ! isset($not_bottom)){
$tag_position = 'bottom';
}
}
// generate html
// タグ選択肢生成
foreach($tag as $k => $v){
$checked = '';
foreach($tag_each as $kk => $vv){
if($v == $vv){
$checked = $tag_checked;
}
}
$tag_html .= "\t".'<li style="display:inline;padding-r...
}
$tag_html = "\n".'<ul style="list-style:none;margin:0;p...
$tag_html = '<fieldset style="margin-bottom:10px;">'."\...
$tag_html .= "\t".'<li style="display:inline;padding-ri...
// enull existent check
// enull の存在確認
if(preg_match("/#enull{{\n*&tag/",$s_postdata)||$ta...
$check_enull = $tag_checked;
}
// deletion tag data from $s_postdata
// 入力欄からタグ関連データを一旦削除
$invisible_enul = "/\n*#enull{{\n*&tag\((.*?)\);\n*...
$invisible_tag = "/\n*&tag\((.*?)\);\n*/";
$s_postdata = preg_replace($invisible_enul,"\n",$s_post...
$s_postdata = preg_replace($invisible_tag,"\n",$s_postd...
// positioning tag
// tag の位置設定
if($tag_position == 'head' && ! $tag_ini_flag['position...
$check_head = $tag_checked;
}elseif($tag_position == 'bottom' || $tag_ini_flag['pos...
$check_bottom = $tag_checked;
}else{
$check_line = $tag_checked;
}
if($tag_ini_flag['ask'] === 1){
$tag_html .= <<<EOD
<hr />
<dl>
<dt style="display:inline;margin:0;padding-right:15px;">...
<dd style="display:inline;margin:0;padding-right:15px;"...
<dd style="display:inline;margin:0;padding-right:15px;"...
<dd style="display:inline;margin:0;padding-right:15px;"...
EOD;
// enull plugin check
// enull プラグインがあれば、チェックを表示
if($tag_enull_flag == '1'){
$tag_html .= "\n\t".'<dd style="display:inline;margin...
}
}else{
// default value of hidden position control
// タグ位置編集欄を非表示の際の規定値
if($check_head){
$tag_html .= '<input type="hidden" name="tag_position...
}else{
$tag_html .= '<input type="hidden" name="tag_position...
}
if($tag_enull_flag == '0' && $tag_ini_flag['position']...
$tag_html .= '<p><strong>Cannot control visibility by...
}elseif($check_enull){
$tag_html .= '<input type="hidden" name="tag_hidden" ...
}
}
$tag_html .= "\n</fieldset>";
}
// overwrite error message
// タグ入力支援許可しつつプラグインがない場合のエラー
if($tag_ini_flag['edit'] == 1 && $tag_tag_flag != 1){
$tag_html = '<p><strong>install tag.inc.php into plugin...
}
// jidaikobo end - tag input form
// attention: put $body into $tag_html after textarea
// $body のヒヤドキュメントに $tag_html を入れること
@/plugin/edit.inc.php - l.64
$postdata = $vars['msg'] = plugin_edit_tag($postdata); ...
@/plugin/edit.inc.php - l.189
$msg = plugin_edit_tag($msg); //jidaikobo
@/plugin/edit.inc.php - さいご
function plugin_edit_tag($msg){
// tags include values
global $vars;
if($msg != ''){
$tag_hidden = isset($vars['tag_hidden']) ? '1' : '';
$tag_add = ($vars['tag_add'] != '') ? $vars['tag_a...
$tag_position = isset($vars['tag_position']) ? $vars['t...
$tag_line = isset($vars['tag_pos_line']) ? $vars['t...
$tags = isset($vars['tag']) ? implode(',',$vars...
}
// tags include
if(isset($vars['tag'])||isset($vars['tag_add']) && $var...
$tags = (isset($tags)) ? $tags.','.$tag_add : $tag_add ;
$tags = '&tag('.htmlspecialchars($tags,ENT_QUOTES).');';
if(isset($vars['tag_hidden'])){
$tags = "#enull{{\n".$tags."\n}}\n";
}
if($tag_position == 'head'){
$msg = $tags."\n\n".$msg;
}elseif($tag_position == 'bottom'){
$msg = $msg."\n\n".$tags;
}elseif($tag_position == 'line'){
$msg_temp = explode("\n",$msg);
array_splice($msg_temp, $tag_line, 0,"\n".$tags."\n");
$msg = implode("\n",$msg_temp);
}
}
return $msg;
}
@pukiwiki.ini.php - どこでも
////////////////////////////////////////jidaikobo
// タグ用編集窓の追加(1:add or 0:remove)
$taginput_edit['form'] = 1;
// タグ位置の規定値(head, bottom, hidden)
$taginput_edit['position'] = 'hidden';
// タグ編集の可視設定(1:ask or 0:don't ask)
$taginput_edit['ask'] = 0;
***オマケ - タグの一覧 [#i2c0f56e]
@skinのてきとうなところ
//prepare tag
$cache = CACHE_DIR . 'tagcloud.tag';
if (file_exists($cache)){
$lines = file($cache);
if($lines != null){
foreach ($lines as $k => $v) {
list($tag_cache[], $count_cache[]) = explode("\t", $v);
}
}else{
$tag_cache = array();
$count_cache = array();
}
}else{
$tag_cache = array();
$count_cache = array();
}
$tag_cache=str_replace("%22",'',$tag_cache);
$count_cache=str_replace("\n",'',$count_cache);
//html - change heading level as you like
$tag_skin = "<h3>tag categories</h3>\n";
$tag_skin.= "<ul>\n";
foreach($tag_cache as $k => $v){
$tag_skin.= "\t".'<li><a href="'.$script.'?cmd=lsx&...
}
$tag_skin.= "</ul>\n";
**コメント [#k8fb2f40]
- これって実際導入するとどんな感じになるのかみてみたいん...
-- Do it yourselfが基本ですので、もし反応がない時はやって...
-- 反応遅れました。バージョンは 1.4.7 でした。この仕組み...
ページ名: