X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=plugin%2Fupdate_entities.inc.php;h=72a12c7fc6866c9c78a29f3de258f66c65b90741;hb=26896abedaa94b9c3b2af465f0d6c14fd2d076bc;hp=a2be4383ad87cfbee2ab9257f7fa636777fb5e9f;hpb=7a987716177604e45e01dfc37e0255321df1747b;p=pukiwiki%2Fpukiwiki.git diff --git a/plugin/update_entities.inc.php b/plugin/update_entities.inc.php index a2be438..72a12c7 100644 --- a/plugin/update_entities.inc.php +++ b/plugin/update_entities.inc.php @@ -1,37 +1,38 @@ array( - 'title_update' => '¥­¥ã¥Ã¥·¥å¹¹¿·', - 'msg_adminpass' => '´ÉÍý¼Ô¥Ñ¥¹¥ï¡¼¥É', - 'btn_submit' => '¼Â¹Ô', - 'msg_done' => '¥­¥ã¥Ã¥·¥å¤Î¹¹¿·¤¬´°Î»¤·¤Þ¤·¤¿¡£', + 'title_update' => 'キャッシュ更新', + 'msg_adminpass' => '管理者パスワード', + 'btn_submit' => '実行', + 'msg_done' => 'キャッシュの更新が完了しました。', 'msg_usage' => ' -* ½èÍýÆâÍÆ +* 処理内容 -:ʸ»ú¼ÂÂλ²¾È¤Ë¥Þ¥Ã¥Á¤¹¤ëÀµµ¬É½¸½¥Ñ¥¿¡¼¥ó¤Î¥­¥ã¥Ã¥·¥å¤ò¹¹¿·| -PHP¤Î»ý¤Ä¥Æ¡¼¥Ö¥ë¤ª¤è¤ÓW3C¤ÎDTD¤ò¥¹¥­¥ã¥ó¤·¤Æ¡¢¥­¥ã¥Ã¥·¥å¤Ëµ­Ï¿¤·¤Þ¤¹¡£ +:文字実体参照にマッチする正規表現パターンのキャッシュを更新| +PHPの持つテーブルおよびW3CのDTDをスキャンして、キャッシュに記録します。 -* ½èÍýÂÐ¾Ý -¡ÖCOLOR(red){not found.}¡×¤Èɽ¼¨¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¤Ï½èÍý¤µ¤ì¤Þ¤»¤ó¡£ +* 処理対象 +「COLOR(red){not found.}」と表示されたファイルは処理されません。 -%s -* ¼Â¹Ô -´ÉÍý¼Ô¥Ñ¥¹¥ï¡¼¥É¤òÆþÎϤ·¤Æ¡¢[¼Â¹Ô]¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤·¤Æ¤¯¤À¤µ¤¤¡£ +* 実行 +管理者パスワードを入力して、[実行]ボタンをクリックしてください。 ' - ) - ); + )); set_plugin_messages($messages); } @@ -40,84 +41,80 @@ function plugin_update_entities_action() global $script, $vars; global $_entities_messages; - if (empty($vars['action']) or empty($vars['adminpass']) or ! pkwk_login($vars['adminpass'])) - { + if (PKWK_READONLY) die_message('PKWK_READONLY prohibits this'); + + $msg = $body = ''; + if (empty($vars['action']) || empty($vars['adminpass']) || ! pkwk_login($vars['adminpass'])) { + $msg = & $_entities_messages['title_update']; $items = plugin_update_entities_create(); - $body = convert_html(sprintf($_entities_messages['msg_usage'],join("\n-",$items))); + $body = convert_html(sprintf($_entities_messages['msg_usage'], join("\n" . '-', $items))); $body .= << +
- {$_entities_messages['msg_adminpass']} - + +
EOD; - return array( - 'msg'=>$_entities_messages['title_update'], - 'body'=>$body - ); - } - else if ($vars['action'] == 'update') - { + } else if ($vars['action'] == 'update') { plugin_update_entities_create(TRUE); - return array( - 'msg'=>$_entities_messages['title_update'], - 'body'=>$_entities_messages['msg_done'] - ); + $msg = & $_entities_messages['title_update']; + $body = & $_entities_messages['msg_done' ]; + } else { + $msg = & $_entities_messages['title_update']; + $body = & $_entities_messages['err_invalid' ]; } + return array('msg'=>$msg, 'body'=>$body); +} - return array( - 'msg'=>$_entities_messages['title_update'], - 'body'=>$_entities_messages['err_invalid'] - ); +// Remove & => amp +function plugin_update_entities_strtr($entity){ + return strtr($entity, array('&'=>'', ';'=>'')); } -function plugin_update_entities_create($do=FALSE) +function plugin_update_entities_create($do = FALSE) { - $files = array('xhtml-lat1.ent','xhtml-special.ent','xhtml-symbol.ent'); - $entities = strtr( - array_values(get_html_translation_table(HTML_ENTITIES)), - array('&'=>'',';'=>'') - ); - $items = array('php:html_translation_table'); - foreach ($files as $file) - { - $source = file(W3C_XHTML_DTD_LOCATION.$file); -// or die_message('cannot receive '.W3C_XHTML_DTD_LOCATION.$file.'.'); - if (!is_array($source)) - { - $items[] = "w3c:$file COLOR(red):not found."; + $files = array('xhtml-lat1.ent', 'xhtml-special.ent', 'xhtml-symbol.ent'); + + $entities = array_map('plugin_update_entities_strtr', + array_values(get_html_translation_table(HTML_ENTITIES))); + $items = array('php:html_translation_table'); + $matches = array(); + foreach ($files as $file) { + $source = file(W3C_XHTML_DTD_LOCATION . $file); +// or die_message('cannot receive ' . W3C_XHTML_DTD_LOCATION . $file . '.'); + if (! is_array($source)) { + $items[] = 'w3c:' . $file . ' COLOR(red):not found.'; continue; } - $items[] = "w3c:$file"; + $items[] = 'w3c:' . $file; if (preg_match_all('/maybe permission is not writable or filename is too long'); - fwrite($fp,$pattern); + $pattern = "(?=[a-zA-Z0-9]\{$min,$max})" . + get_autolink_pattern_sub($entities, 0, count($entities), 0); + $fp = fopen(CACHE_DIR .'entities.dat', 'w') + or die_message('cannot write file ' . CACHE_DIR . 'entities.dat
' . "\n" . + 'maybe permission is not writable or filename is too long'); + fwrite($fp, $pattern); fclose($fp); return $items;