(empty log message)
@@ -0,0 +1,499 @@ | ||
1 | +<?php | |
2 | + check_php();//phpのバージョンチェック | |
3 | +ini_set("display_errors",1); | |
4 | + | |
5 | + $benchmark = true; | |
6 | + $source = false; | |
7 | + $cache = true; | |
8 | + include("scripts/trans.php"); | |
9 | + $ini_array = parse_ini_file("scripts/html.ini",true); | |
10 | + $document = document(); | |
11 | + $obj = new trans($document); | |
12 | + $content_name = "main"; | |
13 | + $documents = $obj->text2html(); | |
14 | + $source = $obj->source; | |
15 | + | |
16 | + | |
17 | + html_document1($ini_array,$documents.$source); | |
18 | + | |
19 | + | |
20 | +function document(){ | |
21 | +$document=<<<DOC | |
22 | + | |
23 | +<div> | |
24 | +引用:test | |
25 | +text2htmlをダウンロードいただきありがとうございます。¶ | |
26 | + | |
27 | +プラグインとしても、単体でも使える「記法アプリです。」¶ | |
28 | + | |
29 | +私は、何種類かのブログで読み書きしたりすることがあります。また、ブログアプリの変更も行います。 | |
30 | +同じような書き味で共通して書ける。「補助的なツールが必要になり、制作しました。」¶ | |
31 | + | |
32 | +編集する人が、必要とする機能だけを使えるようにしたり、カスタマイズが出来ます。¶ | |
33 | + | |
34 | +開発作業は、自家製のCMSを制作し、実際のWEBサイトを運営しながら、記法を制作し、開発しました。そのサイトは、現在でも稼動しております。¶ | |
35 | + | |
36 | +ドキュメント編集上のニーズは、そのサイトごとに変化すると思います。 | |
37 | + | |
38 | +変換の為のソースは、テキストファイル、xmlファイル、外部応答の3種が使えるようにしています。 | |
39 | +いままでの、記法プラグインになかったアイディアも盛り込んでいますから、実際に使ってみてください。¶ | |
40 | + | |
41 | +もちろん、記法とhtmlタグとを組み合わせて使用することも出来ます。phpとして解釈する記法も利用できます。¶ | |
42 | + | |
43 | +編集補助の為のアプリのため、常時フィルタプラグインとして利用すると、サーバに負荷がかかりますので、フィルタプラグインとして利用する場合は、キャッシュ等と組み合わせていただくと良いと思います。また、Frog CMS等のように、フィルタ変換後の結果をDBに保持するタイプのものを使っていただくのも良いかもしれません。¶ | |
44 | + | |
45 | +現在のところ、XOOPS (smarty pluginとして)MTOS(php pluginとして) WordPress(plugin) Frog(plugin) および単体。で動作することを確認しています。 ¶ | |
46 | +DEMOは、http://www.tenman.info/(tenman.info)に用意してありますので、興味のある方は、ご確認いただけますようお願いします。 | |
47 | + | |
48 | +==webmaster@tenman.info | |
49 | + | |
50 | + | |
51 | + | |
52 | +【2008-7-25】 | |
53 | +test | |
54 | +【/2008-7-25】 | |
55 | +【非表示】 | |
56 | +<div style="width:640px;"> | |
57 | +[カレンダーテンプレート] | |
58 | +</div> | |
59 | + | |
60 | +<br style="clear:both;" /> | |
61 | +qrcode>(test) | |
62 | +【/非表示】 | |
63 | + | |
64 | +[head_line] | |
65 | + | |
66 | +*準備 | |
67 | + | |
68 | +**変換機能を使うために必要なもの | |
69 | + | |
70 | +[strong| |PHP5,マルチバイト文字列関数] | |
71 | + | |
72 | +文字列を画像に変換する機能等が使えません。マルチバイト文字列関数は、必須です。 | |
73 | + | |
74 | +[strong| |GD2,PEAR Cache_Lite,PEAR Benchmark,] | |
75 | + | |
76 | +なくても使うことが出来ますが、何らかの方法で、キャッシュ等の工夫をしてください。 | |
77 | + | |
78 | +ベンチマークは、簡単に表示したり、非表示に出来るようにしてあります。 | |
79 | + | |
80 | +この変換プログラムは、ノロマですから、どの変換に時間がかかるか、検討できるようにしてあります。 | |
81 | + | |
82 | +allow_url_fopen が使えない場合には、名前付リンク、外部APIを利用した変換などは使えません。 | |
83 | + | |
84 | + | |
85 | +**使い方 | |
86 | +このプログラムは、単体でも、ブログのプラグインとしても、利用できます。 | |
87 | + | |
88 | +単体で利用する場合の一例です。 | |
89 | +code:<?php | |
90 | +code:ini_set("display_errors",1); | |
91 | +code:include("scripts/trans.php"); | |
92 | +code:\$ini_array = parse_ini_file("script/html.ini",true);《埋め込みスタイルや外部スタイルの指定》 | |
93 | +code:\$benchmark = true;《ベンチマークの表示非表示》 | |
94 | +code:\$source = true;《生成したソースの表示非表示》 | |
95 | +code:\$obj = new trans(\$document); | |
96 | +code:\$content_name = "main";《htmlブロック管理用グローバル変数》 | |
97 | +code:\$documents = \$obj->text2html(); | |
98 | +code:\$source = \$obj->source; | |
99 | +code:html_document1(\$ini_array,\$documents); | |
100 | + | |
101 | + | |
102 | +-trans.php | |
103 | +--このファイルが、変換を行います。これ以外の同梱ファイルは、必要なければ削除していただいてかまいません。 | |
104 | +-html.ini | |
105 | +--このファイルは、php.ini形式の 主にhtml共通で利用する情報を記述しておきます。例:外部スタイルのURL | |
106 | +-変数 \$benchmark | |
107 | +--text2htmlは、行頭などにつけた記号により、該当部分をhtmlに変換します。指定後との変換にどれ位の時間を要しているかを調べることが出来ます。サイトやブログなどを実際に公開する場合には、false を指定していただくと表示しません。 | |
108 | + | |
109 | +-変数 \$source | |
110 | +--記号により変換したhtmlのソースを表示します。正確に変換できているか調べるときに 使えます。通常は、false を指定します。 | |
111 | + | |
112 | +-変数 \$content_name | |
113 | +--単体で利用する場合、複数のインスタンスを必要とするときがあります。text2thmlは、idなどを自動付与しますから、それぞれのインスタンスごとに、idも変更する必要があります。この変数は、それらの名称の一部として使われます。 | |
114 | + | |
115 | + | |
116 | + | |
117 | +***ディレクトリとファイルのパーミッション | |
118 | + | |
119 | +images cache のディレクトリは、757にしてください。 | |
120 | + | |
121 | +images ディレクトリ内にある画像ファイルは、646にしてください。 | |
122 | + | |
123 | + | |
124 | +***wordpress frog 等のプラグインとして使う場合。 | |
125 | + | |
126 | +filter_text2html.php(frogの場合)やwordpress.phpを開いて、プラグインのルートパス。URLを直接記述してください。 | |
127 | +ディレクトリの位置がずれてしまいます。 | |
128 | +必要に応じて、imagesやcss import 等のディレクトリを、ご自身で指定してください。 | |
129 | + | |
130 | +sample: | |
131 | + | |
132 | +<del style="color:red">//\$url = "http://". \$_SERVER['HTTP_HOST'] . dirname(\$_SERVER['PHP_SELF']).'/';</del><br /> | |
133 | + | |
134 | +\$url = "http://127.0.0.1/frog/frog/plugins/text2html/";<br /> | |
135 | + | |
136 | + | |
137 | +<del style="color:red">//\$text2html_dir_path = dirname(dirname(__FILE__)).'/';</del><br /> | |
138 | +\$text2html_dir_path = "c:\\Apache\\htdocs\\frog\\frog\\plugins\\text2html\\"; | |
139 | + | |
140 | +**基本的な変換例 | |
141 | + | |
142 | + | |
143 | + | |
144 | +例えば現在時刻を | |
145 | + | |
146 | +[日付] | |
147 | + | |
148 | +code:[日付] | |
149 | +code: []は便宜上全角を利用。本来は半角です。 | |
150 | + | |
151 | + | |
152 | +また、必要により、phpの関数を実行させることも出来ます。 | |
153 | + | |
154 | +3X4/2=eval>[3*4/2] | |
155 | + | |
156 | +code:3X4/2=eval>[3*4/2] | |
157 | + | |
158 | +eval>[M_PI] | |
159 | +code:eval>[M_PI] | |
160 | + | |
161 | + | |
162 | +という記述も可能です。 | |
163 | + | |
164 | +htmlタグは自由に記述することも出来ます。 | |
165 | +但し、タグ内での改行は出来ません。 | |
166 | + | |
167 | + | |
168 | +記法は、使う人が、わかりやすくカスタマイズできないと、覚える手間がかかるのが難点です。 | |
169 | +記法だけではなく、htmlも使えるので、どちらともなく始まり、使うほどに、効率よい編集が出来るツールを目指しています。¶ | |
170 | + | |
171 | + | |
172 | + | |
173 | + | |
174 | + | |
175 | + | |
176 | + | |
177 | +例えば、 | |
178 | +<!----> | |
179 | +-画像記法を使用して、幅、高さを指定、alt属性も 記法で書くことが出来ます。 | |
180 | + | |
181 | +-画像は、gif png jpg だけでなく、midや、swfファイルも自動リンクします。 | |
182 | + | |
183 | + | |
184 | +-リストの階層制限はありません。 | |
185 | + | |
186 | +-YouTubeリンクの作成など、プラグイン関数を利用することが出来ます。 | |
187 | + | |
188 | +-htmlドキュメントの基本になる段落タグの扱いが、一般的な記法入力プログラムと異なります。《通常改行が2回入ると、段落タグで囲う形になっているケースが多いですが、そのために、編集時の行間が制限されましたが、htmlタグの記述や、記法マーカーの記述で段落を形成する扱いにしています。》 | |
189 | +-拡張機能として、文字列から、画像を生成することが出来ます。 | |
190 | + | |
191 | + | |
192 | +**サンプル | |
193 | + | |
194 | +以下にサンプルを示します。 | |
195 | + | |
196 | +***画像 | |
197 | + | |
198 | +http://www.tenman.info/images/pen.jpg?w=120h=120alt=サンプル | |
199 | + | |
200 | +code:http://www.tenman.info/images/pen.jpg?w=120h=120alt=サンプル | |
201 | + | |
202 | +***ショートクエリ | |
203 | +ショートクエリは、自身で、設定するものと、組み込み済みのものがあります。 | |
204 | +組み込み済みの機能を説明します。 | |
205 | + | |
206 | + | |
207 | +***ライブイメージフォント | |
208 | +この機能は、入力した文字列に対応する画像をWEB上で生成して、imageディレクトリに保存します。 | |
209 | +この文字列画像を、指定したタグの背景として、htmlを作成します。 | |
210 | +文字列は、指定したタグの子エレメント<span>内に記述します。spanは、スタイルの指定で | |
211 | +display:none;としていますから、スタイル適用時は、画像として、スタイルを適用しない場合はテキストとして、表示します。 | |
212 | +※ttf形式のフォントを別途用意する必要があります。 | |
213 | + | |
214 | +txt2img>(p:mikaP15:いろいろな文字を画像として、表現することが可能になります。) | |
215 | +txt2img>(p:mikaP15:フォントファイルを用意して、字体も選べます) | |
216 | +txt2img>(p:mikaP15:ABCDEFG) | |
217 | +txt2img>(p:mikaP15:ABCDEF) | |
218 | +txt2img>(p:mikaP15:ABCDEFGH) | |
219 | +txt2img>(p:mikaP9:しかし、画像は、背景としてセットされるので、htmlは、画像の読めないブラウザにも対応しています。) | |
220 | +txt2img>(p:mikaP9:自分らしい字体を使って、書きたいと思うことありませんか?) | |
221 | +code:txt2img>(p:mikaP_15:いろいろな文字を画像として、表現することが可能になります。) | |
222 | +code:txt2img>(p:mikaP_15:フォントファイルを用意して、字体も選べます) | |
223 | +code:txt2img>(p:mikaP15:ABCDEFG) | |
224 | +code:txt2img>(p:mikaP15:ABCDEF) | |
225 | +code:txt2img>(p:mikaP15:ABCDEFGH) | |
226 | +code:txt2img>(p:mikaP9:しかし、画像は、背景としてセットされるので、htmlは、画像の読めないブラウザにも対応しています。) | |
227 | +code:txt2img>(p:mikaP9:自分らしい字体を使って、書きたいと思うことありませんか) | |
228 | + | |
229 | +***画像リンクとサムネイルの自動作成 | |
230 | + | |
231 | +画像を参照する機会は、比較的多いと思います。WEB上の画像(コピーできれば)をコピーして、imageディレクトリにサムネイルを保存します。その上で、コピー元にリンクします。 | |
232 | +コピー元を記述したコメントタグを追加して、サムネイルを表示します。 | |
233 | + | |
234 | + | |
235 | +copy>(http://www.tenman.info/images/pen.jpg) | |
236 | +***trackback | |
237 | + | |
238 | +これは、サービスなどを表示する設定のサンプル事例になると思いますが、トラックバックを自由配置するための記法です。 | |
239 | + | |
240 | +トラックバックは、そのアイディアの良さを認めながら、汚染の問題から利用されないケースが多くあります。スローアウェイトラックバックなんちゃって。 | |
241 | + | |
242 | +trackback>(なんでも質問箱) | |
243 | + | |
244 | + | |
245 | +***h2-h6見出し記法 | |
246 | +見出しを記述します。アスタリスクのいやな人は、クラス内を変更して、別のものに差し替えることも出来ます。 | |
247 | + | |
248 | +***h2からh6まで記述できます。 | |
249 | +****h5 | |
250 | +*****h6 | |
251 | +****h5 | |
252 | + | |
253 | +code:***h4 | |
254 | +code:****h5 | |
255 | +code:*****h6 | |
256 | +code:****h5 | |
257 | + | |
258 | +***リスト記法 | |
259 | +リストは、-と+を行頭に記述することで、記述できます。 | |
260 | +-リスト | |
261 | +--リスト | |
262 | +--リスト | |
263 | +---リスト | |
264 | +---リスト | |
265 | +--リスト | |
266 | +-リスト | |
267 | ++リスト | |
268 | +++リスト | |
269 | +++リスト | |
270 | ++++リスト | |
271 | ++++リスト | |
272 | +++リスト | |
273 | ++リスト | |
274 | + | |
275 | +***引用記法 | |
276 | +引用は、>または、>の繰り返しで、入れ子で記述できます。 | |
277 | + | |
278 | +>http://www.sample.com/ | |
279 | +>>これは引用です | |
280 | +>http://www.another.com/ | |
281 | +>>これは引用です | |
282 | +>>>これは引用です | |
283 | +>>>これは引用です | |
284 | +>>>これは引用です | |
285 | + | |
286 | +>引用 | |
287 | + | |
288 | +***リンク記法 | |
289 | + | |
290 | +ハイパーリンクを簡単に作る記法です。 | |
291 | +-指定したURLのタイトルを取得して、リンクを作成。 | |
292 | +--http://www.yahoo.co.jp/(title) | |
293 | + | |
294 | +code:http//www.tenman.info/(title) | |
295 | +-指定したURLを指定したテキストでリンク | |
296 | +--http://www.tenman.info/(好きな名前でリンクする) | |
297 | +code:http://www.tenman.info/(好きな名前でリンクする) | |
298 | + | |
299 | + | |
300 | +-指定したURLを新しいページで開く。 | |
301 | +--http://www.tenman.info/(b:title) | |
302 | +code:http//www.tenman.info/(b:title) | |
303 | + | |
304 | +-指定したURLを画像クリックで(新しいページとして)開く。 | |
305 | +--http://www.tenman.info/(b:http://www.tenman.info/images/button.png?w=40h=40) | |
306 | +code:http//www.tenman.info/(b:http://www.…/images/button.png?w=40h=40) | |
307 | + | |
308 | + | |
309 | + | |
310 | +***ソースコード記法 | |
311 | +先頭にcode:をつけると、エスケープして表示します。<pre><code>…</code></pre> | |
312 | + | |
313 | + | |
314 | +code: <meta http-equiv='content-type' content='text/html\; charset=utf-8' /> | |
315 | +code: <meta http-equiv='content-script-type' content='text/javascript' /> | |
316 | +code: <meta http-equiv='content-style-type' content='text/css' /> | |
317 | +code: <meta name='author' content='' /> | |
318 | +code: <meta name='keywords' content='' /> | |
319 | +code: <meta name='description' content='' /> | |
320 | +code: <link rev='made' href='mailto:' /> | |
321 | +code: code: <meta http-equiv='content-type' content='text/html; charset=utf-8' /> | |
322 | +code: code: <meta http-equiv='content-script-type' content='text/javascript' /> | |
323 | +code: code: <meta http-equiv='content-style-type' content='text/css' /> | |
324 | +code: code: <meta name='author' content='' /> | |
325 | +code: code: <meta name='keywords' content='' /> | |
326 | +code: code: <meta name='description' content='' /> | |
327 | +code: code: <link rev='made' href='mailto:' /> | |
328 | + | |
329 | +***テーブル | |
330 | + | |
331 | +行頭にtr:と書くと、テーブルタグで整形します。 | |
332 | + | |
333 | +tr: table td |td |td | |
334 | + | |
335 | + | |
336 | +***差し込み記法 | |
337 | + | |
338 | +差し込み記法は、複雑に入れ子になったhtmlソース等に、値を差し込むために使用します。 | |
339 | + | |
340 | +差し込み記法は、定型ドキュメントをテンプレートとして、html部分と、実ドキュメント部分を分離することが出来ますから、htmlソースに触れることがなく、高度なドキュメントが作成できます。 | |
341 | + | |
342 | + | |
343 | +【2008-8-6】 | |
344 | + | |
345 | +本日の予定 | |
346 | + | |
347 | +【/2008-8-6】 | |
348 | + | |
349 | +<div style="width:640px;"> | |
350 | +[カレンダーテンプレート] | |
351 | +</div> | |
352 | +code:【2008-8-6】 | |
353 | +code:本日の予定 | |
354 | +code:【/2008-8-6】 | |
355 | +code:<div style="width:640px;"> | |
356 | +code:[カレンダーテンプレート] | |
357 | +code:</div> | |
358 | + | |
359 | +このカレンダーは、PHPスクリプトで万年カレンダーを表示する仕組みのテンプレートを使っています。 | |
360 | +枠線の高さをそろえる機能は、jQuery(javascript)で実現しています。 | |
361 | + | |
362 | + | |
363 | + | |
364 | +***webサービス | |
365 | +GETリクエストを送って、レスポンスをパースして表示するサービスはたくさんあります。 | |
366 | + | |
367 | +あなたが信頼できると判断できれば、それらの外部サービスを使って、自分だけの記法を手機能することも出来ます。 | |
368 | + | |
369 | +記法を適用して、いつでも、簡単に利用することが出来ます。 | |
370 | + | |
371 | +注意:相手のサービスに負荷をかけないように、キャッシュ等の工夫をお願いします。 | |
372 | + | |
373 | +***例えば、外部サービスと連携して、こんな事も可能です。 | |
374 | +グラフなどは、URLに、クエリ文字列を追加してやることで、画像として表示します。 | |
375 | + | |
376 | + | |
377 | +円グラフ>(text1=1&value1=30&text2=2&value2=20&text0=3&value0=40) | |
378 | + | |
379 | + | |
380 | +code:円グラフ>(text1=1&value1=30&text2=2&value2=20&text0=3&value0=40) | |
381 | + | |
382 | + | |
383 | +設定は、このようにします。 | |
384 | +code: "グラフ"=>array( | |
385 | +code: 'charset'=>'UTF-8', | |
386 | +code: 'type'=>'query', | |
387 | +code: "response"=>"<img src=\"http://choigraph.minorapi.jp/line?d:data=+++E_KEYWORD+++\" alt=\"+++KEYWORD+++\" />\\n"), | |
388 | + | |
389 | + | |
390 | +注釈記法と、simpleapi を組み合わせることで、以下のような記述も出来ます。 | |
391 | + | |
392 | +仙台市について《wikipedia>(仙台)》 | |
393 | + | |
394 | +code:仙台市について≪wikipedia>(仙台)≫ | |
395 | +code:二重山括弧は、便宜上全角を使いますが、入力時には、半角です。 | |
396 | + | |
397 | +wikipedia記法だけを使ってみる。 | |
398 | + | |
399 | +wikipedia>(日本) | |
400 | + | |
401 | + | |
402 | + | |
403 | + | |
404 | +xmlをパースする関数を作って、以下のように、郵便番号を送って、xmlを文字列に変換して表示することも出来ます。 | |
405 | + | |
406 | +[strong| style="color:#600"|ご自身の管理下にない外部ファイルを利用する場合には、信頼できるサービスかどうかを、十分検討してください。] | |
407 | +レスポンスの内容が、変化したり。クロスサイトスクリプトの標的にならないように十分な注意が必要です。 | |
408 | + | |
409 | +郵便番号>(9820823) | |
410 | +郵便番号>(0230402) | |
411 | + | |
412 | +code:郵便番号>(9820823) | |
413 | +code:郵便番号>(0230402) | |
414 | + | |
415 | +qrcode>(正常に表示されました) | |
416 | +goo_search>(yahoo) | |
417 | + | |
418 | +code:qrcode>(正常に表示されました) | |
419 | +code:goo_search>(yahoo) | |
420 | + | |
421 | + | |
422 | + | |
423 | + | |
424 | +[foot_note] | |
425 | + | |
426 | + | |
427 | + | |
428 | + | |
429 | + | |
430 | + | |
431 | + | |
432 | + | |
433 | + | |
434 | + | |
435 | +DOC; | |
436 | + | |
437 | +return $document; | |
438 | +} | |
439 | + | |
440 | +function check_php(){ | |
441 | +$result = ""; | |
442 | +$keyword = ''; | |
443 | +$version = phpversion(); | |
444 | + | |
445 | + if(!preg_match("/^5/",$version)){ | |
446 | + | |
447 | + $result .= "<p>PHP{$version}では、エラーが発生します。php5を使ってください。</p>"; | |
448 | + | |
449 | + $keyword .= 'php='.urlencode($version); | |
450 | + | |
451 | + echo<<<DOC | |
452 | +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html lang="ja" dir="ltr"><head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>Alart</title></head><body style="margin:0;"><div style="background:#fcc;padding:0.2em 3em;"><h1>てきでこ<span style="font-size:14px">text2html</span></h1><p>利用上の制約や、利用環境から、利用できないなどの問題がみつかりました。</p></div><div style="background:#fff;padding:0.2em 3em;">$result<div><div style="padding:2em;background:#eef;border:1px solid #aaf;"><a href="http://text2html.sourceforge.jp/skeleton.php?{$keyword}">もう少し詳しく</a></div></div><address><a href="http://text2html.sourceforge.jp/">http://text2html.sourceforge.jp/</a></address></div></body></html> | |
453 | +DOC; | |
454 | +exit; | |
455 | + } | |
456 | + | |
457 | + if(function_exists("gd_info")){ | |
458 | +$version = gd_info(); | |
459 | +$version = $version["GD Version"]; | |
460 | + | |
461 | + if(!preg_match("/\(2/",$version)){ | |
462 | + | |
463 | + $result .= "<p>GD{$version}は使えないかもしれません。GD2が使えるようにしてください。</p>"; | |
464 | + $keyword .= '&gd='.urlencode($version); | |
465 | + | |
466 | + | |
467 | + } | |
468 | + }else{ | |
469 | + $result .= "<p>GDが使えません。このプログラムはGD2が必要です。</p>"; | |
470 | + $keyword .= '&gd=none'; | |
471 | + | |
472 | + | |
473 | + } | |
474 | + | |
475 | + if(!function_exists("mb_convert_encoding")){ | |
476 | + | |
477 | + $result .= "<p>マルチバイト関数が使えないようです。残念ですが、この環境では利用できません。</p>"; | |
478 | + $keyword .= '&mb=none'; | |
479 | + } | |
480 | + | |
481 | + if(ini_get('allow_url_fopen') !== "1"){ | |
482 | + $result .= "<p>php.ini allow_url_fopenの設定がOffなので、使える機能が制限されます。</p>"; | |
483 | + $keyword .= '&urlfopen=off'; | |
484 | + | |
485 | + } | |
486 | +//$keyword = urlencode($keyword); | |
487 | +if(!empty($result)){ | |
488 | + | |
489 | + | |
490 | +echo<<<DOC | |
491 | +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html lang="ja" dir="ltr"><head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>Alart</title></head><body style="margin:0;"><div style="background:#fcc;padding:0.2em 3em;"><h1>てきでこ<span style="font-size:14px">text2html</span></h1><p>利用上の制約や、利用環境から、利用できないなどの問題がみつかりました。</p></div><div style="background:#fff;padding:0.2em 3em;">$result<div><div style="padding:2em;background:#eef;border:1px solid #aaf;"><a href="http://text2html.sourceforge.jp/skeleton.php?{$keyword}">もう少し詳しく</a></div></div><address><a href="http://text2html.sourceforge.jp/">http://text2html.sourceforge.jp/</a></address></div></body></html> | |
492 | +DOC; | |
493 | + | |
494 | + | |
495 | + return false; | |
496 | +} | |
497 | +return true; | |
498 | +} | |
499 | +?> | |
\ No newline at end of file |
@@ -0,0 +1,2415 @@ | ||
1 | +<?php | |
2 | +/*------------------------------------------------------------------------------+ | |
3 | + <meta http-equiv="Content-Type" content="text/php; charset=utf-8"> | |
4 | + | |
5 | + text2html てきでこ Akio Tenman. <http://text2html.sourceforge.jp/> | |
6 | + Copyright (C) 2008 Akio Tenman <tenman@users.sourceforge.jp> | |
7 | + | |
8 | + This program is free software: you can redistribute it and/or modify | |
9 | + it under the terms of the GNU General Public License as published by | |
10 | + the Free Software Foundation, either version 3 of the License, or | |
11 | + (at your option) any later version. | |
12 | + | |
13 | + This program is distributed in the hope that it will be useful, | |
14 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | + GNU General Public License for more details. | |
17 | + | |
18 | + You should have received a copy of the GNU General Public License | |
19 | + along with this program. If not, see <http://www.gnu.org/licenses/>. | |
20 | + +------------------------------------------------------------------------------*/ | |
21 | + //このアプリで、外部API等を参照する場合、allow_url_fopenはtrueである必要があります。 | |
22 | + | |
23 | + mb_language( 'Japanese' ); | |
24 | + | |
25 | + if(preg_match("/^[A-z]:.+/",__FILE__)){ | |
26 | + $separater = '\\'; | |
27 | + }else{ | |
28 | + $separater = '/'; | |
29 | + } | |
30 | + | |
31 | + if(!isset($text2html_url)){ | |
32 | + $text2html_url = "http://". $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']).'/'; | |
33 | + } | |
34 | + | |
35 | + if(!isset($text2html_dir_path)){ | |
36 | + $text2html_dir_path = dirname(dirname(__FILE__)).$separater; | |
37 | + } | |
38 | + | |
39 | + if(!isset($cache)){ | |
40 | + $cache = true; | |
41 | + | |
42 | + } | |
43 | +//スクリプトディレクトリ | |
44 | + | |
45 | + define("TEXTTOHTML_SCRIPTS_DIR_PATH",$text2html_dir_path."scripts{$separater}"); | |
46 | + | |
47 | +//主に、htmlパターン用のストック | |
48 | + define("TEXTTOHTML_DATA_DIR_PATH", $text2html_dir_path ."data{$separater}"); | |
49 | + define("TEXTTOHTML_CHANGE_TXT",TEXTTOHTML_DATA_DIR_PATH."change.txt"); | |
50 | + define("CHANGE_PATTERN_PATH",TEXTTOHTML_DATA_DIR_PATH."change.xml"); | |
51 | + | |
52 | +//画像保管用ディレクトリ | |
53 | + define("TEXTTOHTML_IMAGE_DIR_PATH", $text2html_dir_path."images{$separater}"); | |
54 | + define("TEXTTOHTML_IMAGE_DIR_URL", $text2html_url.'images/'); | |
55 | +//イメージコピー用スクリプト | |
56 | + define("TEXTTOHTML_COPY_IMG_WIDTH","100"); | |
57 | + define("IMAGE_IMPORT_PATH", $text2html_dir_path."import{$separater}"); | |
58 | + define("IMAGE_IMPORT_SVR", $text2html_url."import{$separater}image.php"); | |
59 | +//source true | |
60 | + define("TEXTTOHTML_CODE_WRAP_WIDTH",48); | |
61 | +//画像コピーディレクトリ | |
62 | + define("TEXTTOHTML_IMPORT_DIR_PATH","import{$separater}"); | |
63 | + | |
64 | + //トラックバックフォーム WEBサービス | |
65 | + //define("TEXTTOHTML_TRACKBACK_URL",""); | |
66 | + | |
67 | +//キャッシュディレクトリ | |
68 | + | |
69 | + define("CACHE_LITE_PATH","Cache{$separater}Lite.php"); | |
70 | + define("CACHE_DIR_PATH",$text2html_dir_path."cache{$separater}"); | |
71 | + define("CACHE_LIFE_TIME",3600); | |
72 | + define("CACHE_SWITCH",$cache); //falseキャッシュの破棄 | |
73 | + | |
74 | +//設定ファイル | |
75 | + define("HTML_RULE_CONFIG_FILE_PATH",TEXTTOHTML_SCRIPTS_DIR_PATH."html.ini"); | |
76 | + define("TEXTTOHTML_FONT_DIR_PATH",$text2html_dir_path."font{$separater}"); | |
77 | + define("TEXTTOHTML_FONTS_PATH",TEXTTOHTML_FONT_DIR_PATH."fonts.inc"); | |
78 | + | |
79 | + | |
80 | + | |
81 | +//MEMO | |
82 | +/*----------------------------------------------------------------------+ | |
83 | + * get_querys()で使用する配列の説明。 | |
84 | + | |
85 | + "tenki"=>array( | |
86 | + 'charset'=>'UTF-8', | |
87 | + 'type'=>'contents', | |
88 | + 'url'=>'http://www.odekake.biz/branch/?date=+++E_KEYWORD+++', | |
89 | + "response"=>"+++CONTENTS+++\n"), | |
90 | + | |
91 | + ['type'] | |
92 | + contents_rebuild | |
93 | + | |
94 | + 関数による処理を行ったうえでコンテンツとする。 | |
95 | + url function | |
96 | + クラス外部のメソッド | |
97 | + 必須 | |
98 | + contents | |
99 | + 単純なレスポンスをコンテンツとする URL必須 | |
100 | + link | |
101 | + a img用のURLとして | |
102 | +------------------------------------------------------------------------*/ | |
103 | + | |
104 | +class trans{ | |
105 | + | |
106 | + var $document; | |
107 | + var $source; | |
108 | + var $html; | |
109 | + var $header; | |
110 | + var $header_info = array(); | |
111 | + var $midasilist; | |
112 | + var $footNote = array(); | |
113 | + var $footNoteList; | |
114 | + var $content_no_h1; | |
115 | + var $content_no_h2; | |
116 | + var $content_no_h3; | |
117 | + var $content_no_h4; | |
118 | + var $content_no_h5; | |
119 | + var $content_no_h6; | |
120 | + | |
121 | + var $separator; | |
122 | + var $element; | |
123 | + var $wm; | |
124 | + var $content; | |
125 | + var $attr; | |
126 | + var $content_attr; | |
127 | + var $description; | |
128 | + var $copy_target; | |
129 | + var $copy_uri; | |
130 | + | |
131 | + | |
132 | + function trans($document){ | |
133 | + | |
134 | + $document = str_replace(array("\r"),"\n",$document); | |
135 | + $document = $this->tag_br($document); | |
136 | + $this->document = $this->tag_clear($document); | |
137 | + } | |
138 | + | |
139 | + function delete_break($matches){ | |
140 | + $result = ""; | |
141 | + | |
142 | + foreach($matches as $key=>$match){ | |
143 | + if($key==0){ | |
144 | + $result .= str_replace("\n","",$match); | |
145 | + } | |
146 | + } | |
147 | + | |
148 | + $result = preg_replace("/\s{2,}/"," ",$result); | |
149 | + | |
150 | + return $result; | |
151 | + } | |
152 | + | |
153 | + function tag_br($text){ | |
154 | + $text = str_replace("\r","",$text); | |
155 | + $text = preg_replace("/\s=/","=",$text); | |
156 | + $text = preg_replace_callback("/[^(code:)](<[^>]+\s{2,}[^>]+>)/usi",array($this, 'delete_break'),$text); | |
157 | + | |
158 | + return $text; | |
159 | + | |
160 | + } | |
161 | + | |
162 | + function get_querys($text){ | |
163 | + | |
164 | + if(ini_get("allow_url_fopen") == false){ | |
165 | + | |
166 | + return $text; | |
167 | + } | |
168 | + | |
169 | + //重複名の誤変換を避けるために、文字数の長い順にソート | |
170 | +$get_querys = array( | |
171 | +/*キー名は10文字未満*/ | |
172 | + "googlemaps"=>array( | |
173 | + 'charset'=>'UTF-8', | |
174 | + 'type'=>'link', | |
175 | + 'response'=>"<sup class=\"gmaps\"><a href=\"http://www.google.co.jp/maps?f=q&hl=ja&oe=UTF8&ie=UTF8&q=+++E_KEYWORD+++\" title=\"[ +++KEYWORD+++ 地図リンク]\">Map</a></sup>"), | |
176 | + | |
177 | + "qrcode"=>array( | |
178 | + 'charset'=>'SHIFT_JIS', | |
179 | + 'type'=>'link', | |
180 | + "response"=>"<img src=\"http://www.odekake.biz/images/qr/qr_img.php?s=3&v=0&e=m&d=+++E_KEYWORD+++\" alt=\"+++KEYWORD+++\" width=\"87\" height=\"87\" />"), | |
181 | + | |
182 | + "goo_search"=>array( | |
183 | + 'charset'=>'UTF-8', | |
184 | + 'type'=>'link', | |
185 | + "response"=>"<a href=\"http://search.goo.ne.jp/web.jsp?PT=bb_tp&from=query&MT=+++E_KEYWORD+++&web.x=54&web.y=13&DC=10\">goo検索+++KEYWORD+++</a>"), | |
186 | + | |
187 | + "pdf"=>array( | |
188 | + 'charset'=>'UTF-8', | |
189 | + 'type'=>'link', | |
190 | + "response"=>"<a href=\"http://html2pdf.biz/api?url=+++E_KEYWORD+++&ret=pdf\">+++KEYWORD+++PDF</a>"), | |
191 | + | |
192 | + "円グラフ"=>array( | |
193 | + 'charset'=>'UTF-8', | |
194 | + 'type'=>'query', | |
195 | + "response"=>"<img src=\"http://graph.heartrails.com/api/?+++E_KEYWORD+++\" alt=\"+++KEYWORD+++\" />\n"), | |
196 | + "郵便番号"=>array( | |
197 | + 'charset'=>'UTF-8', | |
198 | + 'type'=>'contents_rebuild', | |
199 | + 'function'=>'postal_code', | |
200 | + 'url'=>'http://zip.cgis.biz/xml/zip.php?zn=+++E_KEYWORD+++', | |
201 | + "response"=>"+++CONTENTS+++"), | |
202 | + "wikipedia"=>array( | |
203 | + 'charset'=>'UTF-8', | |
204 | + 'type'=>'contents_rebuild', | |
205 | + 'function'=>'simpleapi_wikipedia', | |
206 | + 'url'=>'http://wikipedia.simpleapi.net/api?keyword=+++E_KEYWORD+++&output=php', | |
207 | + "response"=>"+++CONTENTS+++"), | |
208 | + | |
209 | +"tenki"=>array( | |
210 | + 'charset'=>'UTF-8', | |
211 | + 'type'=>'contents', | |
212 | + 'url'=>'http://www.odekake.biz/branch/?date=+++E_KEYWORD+++', | |
213 | + "response"=>"+++CONTENTS+++\n"), | |
214 | + ); | |
215 | + | |
216 | + uksort($get_querys,"text2html_cmp"); | |
217 | + | |
218 | + if(isset($get_querys)){ | |
219 | + foreach($get_querys as $key=>$val){ | |
220 | + if(preg_match_all("/($key>\()([^\)]+)(\))/u", $text, $matches, PREG_SET_ORDER)){ | |
221 | + | |
222 | + foreach($matches as $key=>$match){ | |
223 | + | |
224 | + $cache = use_cache($matches[$key][0]); | |
225 | + if($cache[0]){ | |
226 | + | |
227 | + $text = str_replace($matches[$key][0],$cache[1],$text)."\n"; | |
228 | + }else{ | |
229 | + | |
230 | + $enc = mb_convert_encoding($match[2],$val['charset'],"auto"); | |
231 | + $no_enc = mb_convert_encoding($match[2],"UTF-8","auto"); | |
232 | + $no_enc = str_replace("\n","",$no_enc); | |
233 | + | |
234 | + switch($val['type']){ | |
235 | + | |
236 | + case('link'): | |
237 | + | |
238 | + $enc = urlencode($enc); | |
239 | + $replacement = mb_convert_encoding($val['response'],"UTF-8","auto"); | |
240 | + $replacement = str_replace(array("+++E_KEYWORD+++","+++KEYWORD+++"),array($enc,$no_enc),$val['response']); | |
241 | + $replacement = trim($replacement); | |
242 | + break; | |
243 | + | |
244 | + case('contents'): | |
245 | + | |
246 | + $enc = urlencode($enc); | |
247 | + $target = mb_convert_encoding($val['url'],"UTF-8","auto"); | |
248 | + $target = str_replace(array("+++E_KEYWORD+++","+++KEYWORD+++"),array($enc,$no_enc),$target); | |
249 | + $host = parse_url($target); | |
250 | + $host = $host['host']; | |
251 | + | |
252 | + try{ | |
253 | + | |
254 | + if(!$fp = fsockopen ($host, 80, $errno, $errstr, 5)){ | |
255 | + | |
256 | + throw new Exception('を、取得できません。サービスを停止してるかどうか確認してください。'); | |
257 | + } | |
258 | + | |
259 | + socket_set_timeout($fp, 3); | |
260 | + fputs ($fp, "GET / HTTP/1.0\r\nHost: ".$_SERVER['HTTP_HOST']."\r\n\r\n"); | |
261 | + $replacement = mb_convert_encoding(file_get_contents($target),"UTF-8","auto"); | |
262 | + $stat = socket_get_status($fp); | |
263 | + | |
264 | + if ($stat["timed_out"]) { | |
265 | + | |
266 | + throw new Exception('タイムアウトしました。'); | |
267 | + } | |
268 | + | |
269 | + fclose($fp); | |
270 | + | |
271 | + }catch (Exception $e) { | |
272 | + | |
273 | + $errstr = mb_convert_encoding($errstr,"UTF-8","auto"); | |
274 | + echo '<div style="text-align:left;padding:2em;background:#FF99FF;">例外: ',$target,$e->getMessage(), "\n</div>\n"; | |
275 | + } | |
276 | + | |
277 | + break; | |
278 | + | |
279 | + case('query'): | |
280 | + | |
281 | + $replacement = mb_convert_encoding($val['response'],"UTF-8","auto"); | |
282 | + $querys = explode("&",$enc); | |
283 | + $enc = ""; | |
284 | + | |
285 | + foreach($querys as $query){ | |
286 | + | |
287 | + preg_match("/([^=]+)(=)(.+)/", $query, $hit); | |
288 | + | |
289 | + if($hit){ | |
290 | + $enc .= '&'.urlencode($hit[1]).$hit[2].urlencode($hit[3]); | |
291 | + } | |
292 | + | |
293 | + } | |
294 | + | |
295 | + $enc = str_replace("\n","",$enc); | |
296 | + $no_enc = ""; | |
297 | + $replacement = str_replace(array("+++E_KEYWORD+++","+++KEYWORD+++"),array($enc,$no_enc),$val['response']); | |
298 | + | |
299 | + break; | |
300 | + | |
301 | + case('contents_rebuild'): | |
302 | + | |
303 | + $enc = urlencode($enc); | |
304 | + $replacement = mb_convert_encoding($val['response'],"UTF-8","auto"); | |
305 | + $target = str_replace(array("+++E_KEYWORD+++","+++KEYWORD+++"),array($enc,$no_enc),$val['url']); | |
306 | + | |
307 | + $host = parse_url($target); | |
308 | + $host = $host['host']; | |
309 | + | |
310 | + try{ | |
311 | + | |
312 | + if(!$fp = fsockopen ($host, 80, $errno, $errstr, 5)){ | |
313 | + | |
314 | + throw new Exception('を、取得できません。サービスを停止してるかどうか確認してください。'); | |
315 | + } | |
316 | + | |
317 | + socket_set_timeout($fp, 3); | |
318 | + fputs ($fp, "GET / HTTP/1.0\r\nHost: ".$_SERVER['HTTP_HOST']."\r\n\r\n"); | |
319 | + | |
320 | + $replacement = mb_convert_encoding(@file_get_contents($target),"UTF-8","auto"); | |
321 | + $function_name = $val['function']; | |
322 | + $replacement = $function_name($replacement); | |
323 | + | |
324 | + $stat = socket_get_status($fp); | |
325 | + | |
326 | + if ($stat["timed_out"]) { | |
327 | + | |
328 | + throw new Exception('タイムアウトしました。'); | |
329 | + } | |
330 | + | |
331 | + fclose($fp); | |
332 | + | |
333 | + | |
334 | + }catch (Exception $e) { | |
335 | + | |
336 | + $errstr = mb_convert_encoding($errstr,"UTF-8","auto"); | |
337 | + echo '<div style="text-align:left;padding:2em;background:#FF99FF;">例外: ',$target,$e->getMessage(), "\n</div>\n"; | |
338 | + } | |
339 | + break; | |
340 | + | |
341 | + } | |
342 | + | |
343 | + save_cache($matches[$key][0],$replacement); | |
344 | + | |
345 | + $text = str_replace($matches[$key][0],$replacement,$text)."\n"; | |
346 | + } | |
347 | + | |
348 | + } | |
349 | + | |
350 | + } | |
351 | + | |
352 | + } | |
353 | + } | |
354 | +return $text; | |
355 | +} | |
356 | + | |
357 | + function number(){ | |
358 | + static $int = 0; | |
359 | + | |
360 | + $int++; | |
361 | + return $int; | |
362 | + } | |
363 | + | |
364 | + function text2html(){ | |
365 | + | |
366 | + global $benchmark; | |
367 | + global $source; | |
368 | + global $content_name; | |
369 | + | |
370 | + $pear_file = ""; | |
371 | + $timer = false; | |
372 | + $buffer = $this->document; | |
373 | + $output_enc = "UTF-8"; | |
374 | + | |
375 | + if(isset($benchmark) and $benchmark == true){ | |
376 | + include_once ("Benchmark/Timer.php"); | |
377 | + $timer = true; | |
378 | + $oTimer =& new Benchmark_Timer(); | |
379 | + $oTimer->start (); | |
380 | + } | |
381 | + | |
382 | + if($timer){ $oTimer->setMarker( 'preset' );} | |
383 | + | |
384 | + $buffer = $this->change_word($buffer); | |
385 | + | |
386 | + if($timer){ $oTimer->setMarker( 'change_word' );} | |
387 | +//table | |
388 | + $buffer = $this->text2html_table($buffer,"\n","table","tr:","tr","","","table"); | |
389 | + | |
390 | + if($timer){ $oTimer->setMarker( 'text2html_table' );} | |
391 | +//blockquote | |
392 | + $buffer = $this->text2html_code($buffer,"\n","pre",'code:','code','','class="source"','souce'); | |
393 | + | |
394 | + if($timer){ $oTimer->setMarker( 'text2html_code' );} | |
395 | +//heading | |
396 | + $buffer = $this->text2html_element($buffer,"\n","h6",'\*\*\*\*\*','a','', 'href="#TOP"','h6'); | |
397 | + if($timer){$oTimer->setMarker( 'elementh6' );} | |
398 | + | |
399 | + $buffer = $this->text2html_element($buffer,"\n","h5",'\*\*\*\*','a','', 'href="#TOP"','h5'); | |
400 | + if($timer){ $oTimer->setMarker( 'elementh5' );} | |
401 | + | |
402 | + $buffer = $this->text2html_element($buffer,"\n","h4",'\*\*\*','a','', 'href="#TOP"','h4'); | |
403 | + if($timer){$oTimer->setMarker( 'elementh4' );} | |
404 | + | |
405 | + $buffer = $this->text2html_element($buffer,"\n","h3",'\*\*','a','', 'href="#TOP"','h3'); | |
406 | + if($timer){ $oTimer->setMarker( 'elementh3' );} | |
407 | + | |
408 | + $buffer = $this->text2html_element($buffer,"\n","h2",'\*','a','', 'href="#TOP"','h2'); | |
409 | + if($timer){ $oTimer->setMarker( 'elementh2' );} | |
410 | + | |
411 | + $buffer = $this->link_title($buffer); | |
412 | + if($timer){ $oTimer->setMarker( 'link_title' );} | |
413 | + | |
414 | +//vertical align | |
415 | + $buffer = $this->text2html_element($buffer,"\n","div",'==','p','', 'style="text-align:right;"','right'); | |
416 | + if($timer){$oTimer->setMarker( 'align:right' );} | |
417 | + | |
418 | + $buffer = $this->text2html_element($buffer,"\n","div",'=','p','', 'style="text-align:center;"','center'); | |
419 | + if($timer){$oTimer->setMarker( 'align:center' );} | |
420 | + | |
421 | + $buffer = $this->note($buffer,"\n"); | |
422 | + if($timer){$oTimer->setMarker( 'note' );} | |
423 | + | |
424 | +//見出しリスト | |
425 | + asort($this->header_info); | |
426 | + $this->midasilist = "<a name=\"TOP\" id=\"TOP\" >head line</a>\n"; | |
427 | + $kihou = ""; | |
428 | + | |
429 | + foreach($this->header_info as $key=>$link){ | |
430 | + | |
431 | + $kihou = str_repeat ('+', $link[1]-1); | |
432 | + $this->midasilist .= "$kihou<span><a href=\"#$link[2]\">$link[3]</a></span>\n"; | |
433 | + } | |
434 | + $this->midasilist = $this->text2html_list(trim($this->midasilist)."\n","\n","ol",'+','li','','','head-line'); | |
435 | + | |
436 | +//閉じタグチェック | |
437 | + preg_match_all("/(<ol><li>)/u",$this->midasilist,$start,PREG_SET_ORDER); | |
438 | + preg_match_all("/(<\/ol><\/li>)/u",$this->midasilist,$end,PREG_SET_ORDER); | |
439 | + | |
440 | + $rep = count($end)-count($start); | |
441 | + | |
442 | + switch(true){ | |
443 | + case(count($end) == count($start)): | |
444 | + | |
445 | + break; | |
446 | + | |
447 | + case(count($end) > count($start)): | |
448 | + //閉じタグが多い | |
449 | + $rep = $rep; | |
450 | + $rep = str_repeat("<\/ol><\/li>",$rep + 1); | |
451 | + $this->midasilist = preg_replace("/$rep<\/ol>$/m","</ol>",$this->midasilist); | |
452 | + | |
453 | + break; | |
454 | + | |
455 | + case(count($end) < count($start)): | |
456 | + //閉じタグが少ない | |
457 | + $rep = str_repeat('</ol></li>',abs($rep)-1); | |
458 | + $this->midasilist = preg_replace("/<\/ol>$/m","",$this->midasilist).$rep."</ol>"; | |
459 | + | |
460 | + break; | |
461 | + } | |
462 | + | |
463 | + $buffer = str_replace("[head_line]", $this->midasilist, $buffer); | |
464 | + if($timer){$oTimer->setMarker( 'head_line' );} | |
465 | + | |
466 | +//foot note | |
467 | + | |
468 | + foreach($this->footNote as $note){ | |
469 | + $this->footNoteList .= "<li><p><a href=\"#$note[1]\" name=\"$note[2]\" id=\"$note[2]\" >[".$note[0]."]</a>$note[3]</p></li>"; | |
470 | + } | |
471 | + | |
472 | + $this->footNoteList = "<ul class=\"foot-note-$content_name\">".$this->footNoteList."</ul>"; | |
473 | + $buffer = str_replace("[foot_note]",$this->footNoteList, $buffer); | |
474 | + | |
475 | +//etc | |
476 | + if($timer){$oTimer->setMarker( 'foot_note' );} | |
477 | + | |
478 | + $buffer = $this->keyword_change($buffer,"\n"); | |
479 | + if($timer){$oTimer->setMarker( 'keyword_change' );} | |
480 | + | |
481 | + $buffer = $this->read_php($buffer,"\n"); | |
482 | + if($timer){$oTimer->setMarker( 'read_php' );} | |
483 | + | |
484 | + $buffer = $this->keyword_change_inline($buffer,"\n");//ok | |
485 | + if($timer){$oTimer->setMarker( 'keyword_change_inline' );} | |
486 | + | |
487 | + $buffer = $this->inline_tag($buffer); | |
488 | + if($timer){$oTimer->setMarker( 'inline_tag' );} | |
489 | + | |
490 | + $buffer = $this->ruby($buffer);//これは、IE xthml1.1 | |
491 | + if($timer){$oTimer->setMarker( 'inline_tag' );} | |
492 | + | |
493 | + $buffer = $this->trackback($buffer,"\n"); | |
494 | + if($timer){$oTimer->setMarker( 'trackback' );} | |
495 | + | |
496 | + $buffer = $this->maillink($buffer,"\n"); | |
497 | + if($timer){$oTimer->setMarker( 'maillink' );} | |
498 | + | |
499 | + $buffer = $this->youtube($buffer,"\n"); | |
500 | + if($timer){$oTimer->setMarker( 'youtube' );} | |
501 | + | |
502 | + $buffer = $this->txt2img($buffer,"\n"); | |
503 | + if($timer){$oTimer->setMarker( 'text2image' );} | |
504 | + | |
505 | + $buffer = $this->sound($buffer,"\n"); | |
506 | + if($timer){$oTimer->setMarker( 'text2image' );} | |
507 | + | |
508 | + $buffer = $this->foma_movie($buffer,"\n"); | |
509 | + if($timer){$oTimer->setMarker( '3gp' );} | |
510 | + | |
511 | + $buffer = $this->swf($buffer,"\n"); | |
512 | + if($timer){$oTimer->setMarker( '3gp' );} | |
513 | + | |
514 | + $buffer = $this->encode_query($buffer,"\n"); | |
515 | + if($timer){$oTimer->setMarker( 'encode_query' );} | |
516 | + | |
517 | + $buffer = $this->img_copy($buffer,"\n"); | |
518 | + if($timer){$oTimer->setMarker( 'img_copy' );} | |
519 | + | |
520 | + $buffer = $this->image($buffer,"\n"); | |
521 | + if($timer){$oTimer->setMarker( 'image' );} | |
522 | + | |
523 | + $buffer = $this->clear_both($buffer,"\n"); | |
524 | + if($timer){$oTimer->setMarker( 'clear_both' );} | |
525 | + | |
526 | + $buffer = $this->get_querys($buffer,"\n"); | |
527 | + if($timer){$oTimer->setMarker( 'get_querys' );} | |
528 | + | |
529 | + $buffer = $this->text2html_list($buffer,"\n","ul","\-",'li','','','unorder'); | |
530 | + $buffer = $this->text2html_list($buffer,"\n","ol",'+','li','','','order'); | |
531 | + $buffer = $this->text2html_list($buffer,"\n","ul",'※','li','style="font:size:70%;color:#66f;"',"style=\"list-style-type:none;\"","caution"); | |
532 | + if($timer){$oTimer->setMarker( 'list' );} | |
533 | + | |
534 | + //$buffer = $this->text2html_list2($buffer,"\n","blockquote",'引用:','p','','','quote'); | |
535 | + //入れ子可 | |
536 | + $buffer = $this->text2html_list($buffer,"\n","blockquote",'>','p','','','quote'); | |
537 | + if($timer){$oTimer->setMarker( 'list_blockquote' );} | |
538 | + | |
539 | + $buffer = $this->paragraf($buffer,"\n\n"); | |
540 | + if($timer){$oTimer->setMarker( 'paragraph' );} | |
541 | + | |
542 | + $buffer = $this->repair_end($buffer,"\n"); | |
543 | + if($timer){$oTimer->setMarker( 'repair_end' );} | |
544 | + | |
545 | + $text = $this->result_encoding($buffer,"\n"); | |
546 | + if($timer){$oTimer->setMarker( 'result_encoding' );} | |
547 | + | |
548 | + if(isset($source) and $source == true){ | |
549 | + | |
550 | + $source = $this->my_wordwrap($text); | |
551 | + $source = str_replace("/",'/',$source); | |
552 | + | |
553 | + $this->source = '<div class="source_view">'. | |
554 | + $this->style_set($source)."\n</div>"; | |
555 | + }else{ | |
556 | + | |
557 | + $this->source = ""; | |
558 | + } | |
559 | + if($timer){$oTimer->setMarker( 'create_source' );} | |
560 | + | |
561 | + if($timer){ | |
562 | + $oTimer->setMarker( 'end' ); | |
563 | + $oTimer->stop (); | |
564 | + ob_start(); | |
565 | + $oTimer->display (); | |
566 | + $profile = ob_get_contents(); | |
567 | + ob_end_clean(); | |
568 | + | |
569 | + return $text.$profile; | |
570 | + } | |
571 | + return $text; | |
572 | + } | |
573 | + | |
574 | + function change_word($text){ | |
575 | + | |
576 | + if(!defined('TEXTTOHTML_CHANGE_TXT')){return $text;} | |
577 | + $file = TEXTTOHTML_CHANGE_TXT; | |
578 | + | |
579 | + if(file_exists($file)){ | |
580 | + | |
581 | + $chenge_words = file($file); | |
582 | + | |
583 | + foreach($chenge_words as $chenge_word){ | |
584 | + | |
585 | + $chenge_word = mb_convert_encoding($chenge_word, "UTF-8","auto"); | |
586 | + | |
587 | + if(strstr($chenge_word,"#")){ | |
588 | + list($before, $after) = explode("#", $chenge_word); | |
589 | + $text = str_replace($before , trim($after), $text); | |
590 | + } | |
591 | + } | |
592 | + | |
593 | + return $text; | |
594 | + }else{ | |
595 | + | |
596 | + return $text; | |
597 | + } | |
598 | + | |
599 | + } | |
600 | + | |
601 | + | |
602 | +function text2html_list($document = "", $separator = "\n",$element = "ul",$wm = '-',$content = 'li',$attr = '',$content_attr = '',$description = ''){ | |
603 | + | |
604 | + $lines = explode($separator,$document); | |
605 | + $running = false; | |
606 | + $result = ''; | |
607 | + $add_front = ''; | |
608 | + $add_tail = ''; | |
609 | + $add_end = ''; | |
610 | + $end =''; | |
611 | + $tag_before = ""; | |
612 | + $tag_after = ""; | |
613 | + $body = ""; | |
614 | + $content_no = 1; | |
615 | + $running = false; | |
616 | + $last_line = false; | |
617 | + $start_line = false; | |
618 | + $next_flag = false; | |
619 | + $diff_prev = 0; | |
620 | + $diff_next = 0; | |
621 | + $diff_count = 0; | |
622 | + $marker_length = 0; | |
623 | + $counter = ""; | |
624 | + | |
625 | + global $content_name; | |
626 | + | |
627 | + if(!empty($content_name) and !empty($description)){ | |
628 | + $description = $description.'-'.$content_name; | |
629 | + }else{ | |
630 | + $description = $description.$content_name; | |
631 | + } | |
632 | + | |
633 | + $start_element_set = "<$element><$content>"; | |
634 | + $end_element_set = "</$element></$content>"; | |
635 | + $start = true; | |
636 | + | |
637 | +foreach($lines as $key=>$line){ | |
638 | + | |
639 | + $line = $line."\n"; | |
640 | + if($current_flag = preg_match("/^([$wm]+)(.+)/u",$line,$current)){ | |
641 | + | |
642 | + $marker_length = @strlen($current[1]); | |
643 | + | |
644 | + | |
645 | + //リスト変換のオンオフ判定 | |
646 | + | |
647 | + if($marker_length > 0){$running =true;}else{$running = false;} | |
648 | + | |
649 | + | |
650 | + //前後する行との関係をマーカー数を数えて判定。 | |
651 | + | |
652 | + if($key > 0 ){ | |
653 | + | |
654 | + $prev_flag = preg_match("/^([$wm]+)(.+)/u",$lines[$key - 1],$prev); | |
655 | + | |
656 | + if(isset($prev[1])){ | |
657 | + | |
658 | + $prev_length = strlen($prev[1]); | |
659 | + $diff_prev = $marker_length - $prev_length ; | |
660 | + } | |
661 | + | |
662 | + }else{ | |
663 | + | |
664 | + $prev_flag = false; | |
665 | + } | |
666 | + | |
667 | + | |
668 | + if($running and !$next_flag){ | |
669 | + | |
670 | + $last_line = true; | |
671 | + } | |
672 | + | |
673 | + | |
674 | + if(isset($lines[$key + 1])){ | |
675 | + | |
676 | + $next_flag = preg_match("/^([$wm]+)(.+)/u",$lines[$key + 1],$next); | |
677 | + $next_length = @strlen($next[1]); | |
678 | + $diff = $marker_length - $next_length; | |
679 | + $diff_count = $marker_length - 1; | |
680 | + | |
681 | + } | |
682 | + if(isset($lines[$key + 2])){ | |
683 | + | |
684 | + $diff_next = $marker_length - $next_length; | |
685 | + | |
686 | + } | |
687 | + if(!empty($attr)){ | |
688 | + $attr = ' '.$attr; | |
689 | + } | |
690 | + | |
691 | + if(!empty($content_attr)){ | |
692 | + $content_attr = ' '.$content_attr; | |
693 | + } | |
694 | + | |
695 | + switch($running and !$prev_flag){ | |
696 | + | |
697 | + case(true): | |
698 | + | |
699 | + $id_name = ' '."id=\"$element-$description-".trim($content_no)."\""; | |
700 | + | |
701 | + if($diff_next > 0 or $marker_length > 1){ | |
702 | + | |
703 | + $start = str_repeat($start_element_set,abs($marker_length - 1 ))."<$element>"; | |
704 | + | |
705 | + $content_no++; | |
706 | + }else{ | |
707 | + | |
708 | + $start = "<$element>"; | |
709 | + | |
710 | + $content_no++; | |
711 | + } | |
712 | + | |
713 | + | |
714 | + break; | |
715 | + | |
716 | + case(false): | |
717 | + $start = ""; | |
718 | + | |
719 | + break; | |
720 | + | |
721 | + } | |
722 | + | |
723 | + | |
724 | + switch($running and $key < count($lines) - 1 ){ | |
725 | + | |
726 | + case(true): | |
727 | + | |
728 | + //前行とのマーカーの差 | |
729 | + | |
730 | + switch(true){ | |
731 | + | |
732 | + case($diff_prev > 0): | |
733 | + //下位 | |
734 | + | |
735 | + $tag_before = str_repeat($start_element_set,abs($diff_prev)); | |
736 | + $diff_count = $diff_count + $diff_prev; | |
737 | + $start = ""; | |
738 | + break; | |
739 | + | |
740 | + case($diff_prev < 0): | |
741 | + | |
742 | + //上位 | |
743 | + | |
744 | + $tag_before = "<$content>"; | |
745 | + $diff_count = $diff_count + $diff_prev; | |
746 | + | |
747 | + break; | |
748 | + case($diff_prev == 0): | |
749 | + | |
750 | + //同位 | |
751 | + | |
752 | + $tag_before = "<$content>"; | |
753 | + | |
754 | + break; | |
755 | + | |
756 | + case(false): | |
757 | + | |
758 | + $tag_before = "<$content>"; | |
759 | + | |
760 | + break; | |
761 | + | |
762 | + } | |
763 | + | |
764 | + //次行とのマーカーの差 | |
765 | + | |
766 | + switch(true){ | |
767 | + case($diff_next > 0): | |
768 | + | |
769 | + //上位 | |
770 | + | |
771 | + $tag_after = "</$content>"; | |
772 | + | |
773 | + $repeat = abs($diff_next); | |
774 | + $tag_after .= str_repeat($end_element_set,$repeat); | |
775 | + | |
776 | + if($next_flag !== 1){ | |
777 | + | |
778 | + $repeat = abs($diff_next) - 1; | |
779 | + | |
780 | + $tag_after = "</$content>"; | |
781 | + $tag_after .= str_repeat($end_element_set,$repeat); | |
782 | + $tag_after .= "</$element>"; | |
783 | + | |
784 | + } | |
785 | + | |
786 | + if(empty($tag_after)){ | |
787 | + $tag_after = "</$element>"; | |
788 | + } | |
789 | + | |
790 | + $diff_count = $diff_next + $diff_count; | |
791 | + | |
792 | + break; | |
793 | + case($diff_next < 0): | |
794 | + | |
795 | + //下位 | |
796 | + | |
797 | + $tag_after = ""; | |
798 | + $diff_count = $diff_next + $diff_count ; | |
799 | + | |
800 | + break; | |
801 | + | |
802 | + | |
803 | + case($diff_next == 0): | |
804 | + | |
805 | + //同位 | |
806 | + | |
807 | + $tag_after= "</$content>"; | |
808 | + | |
809 | + break; | |
810 | + } | |
811 | + break; | |
812 | + | |
813 | + case(false): | |
814 | + | |
815 | + $tag_after= "2</$content>"; | |
816 | + | |
817 | + | |
818 | + break; | |
819 | + } | |
820 | + | |
821 | + | |
822 | + if($running and !$prev_flag){ | |
823 | + | |
824 | + | |
825 | + $line = $start.$tag_before.$current[2].$tag_after; | |
826 | + | |
827 | + }elseif($running and $key < count($lines) - 2 ){ | |
828 | + | |
829 | + | |
830 | + | |
831 | + $line = $tag_before.$current[2].$tag_after; | |
832 | + | |
833 | + }elseif($last_line and !$next_flag){ | |
834 | + | |
835 | + $repeat = abs($diff_next) ; | |
836 | + | |
837 | + $tag_after = "</$content>"; | |
838 | + $tag_after .= str_repeat($end_element_set,$repeat); | |
839 | + $tag_after .= "</$element>"; | |
840 | + | |
841 | + $line = $tag_before.$current[2].$tag_after.$end; | |
842 | + | |
843 | + | |
844 | + | |
845 | + | |
846 | + } | |
847 | + | |
848 | + } | |
849 | + | |
850 | + | |
851 | + $result .= trim($line)."\n"; | |
852 | + unset($tag_before,$tag_afrer,$prev,$start); | |
853 | + $enc = ""; | |
854 | +} | |
855 | + $result = $result; | |
856 | + return $this->tag_clear($result)."\n\n"; | |
857 | +} | |
858 | + | |
859 | + | |
860 | +function check_element_count_list($html,$element="ul",$content="li"){ | |
861 | + | |
862 | + //閉じタグチェック | |
863 | + preg_match_all("/(<$element><$content>)/u",$html,$start,PREG_SET_ORDER); | |
864 | + preg_match_all("/(<\/$element><\/$content>)/u",$html,$end,PREG_SET_ORDER); | |
865 | + $rep = count($end)-count($start)-1; | |
866 | + | |
867 | + switch(true){ | |
868 | + | |
869 | + case(count($end) == count($start)): | |
870 | + | |
871 | + break; | |
872 | + | |
873 | + case(count($end) > count($start)): | |
874 | + //閉じタグが多い | |
875 | + $rep = str_repeat("<\/$element><\/$content>",$rep + 1); | |
876 | + $html = preg_replace("/$rep</$element>$/m","</$element>",$html); | |
877 | + | |
878 | + break; | |
879 | + | |
880 | + case(count($end) < count($start)): | |
881 | + //閉じタグが少ない | |
882 | + $rep = str_repeat("</$element></$content>",abs($rep) - 1); | |
883 | + $html = preg_replace("/<\/$element>$/m","",$html); | |
884 | + $html = $html.$rep."</$element>"; | |
885 | + | |
886 | + | |
887 | + break; | |
888 | + | |
889 | + | |
890 | + } | |
891 | + return $html; | |
892 | +} | |
893 | + | |
894 | +function text2html_list2($document, $separator = "\n",$element = "ul",$wm = '-',$content = 'li',$attr = '',$content_attr = '',$description = ''){ | |
895 | + | |
896 | + $this->separator = $separator; | |
897 | + $this->element = $element; | |
898 | + $this->wm = $wm; | |
899 | + $this->content = $content; | |
900 | + $this->attr = $attr; | |
901 | + $this->content_attr = $content_attr; | |
902 | + $this->description = $description; | |
903 | + | |
904 | + global $content_name; | |
905 | + | |
906 | + if(!empty($content_name) and !empty($description)){ | |
907 | + $description = $description.'-'.$content_name; | |
908 | + }else{ | |
909 | + $description = $description.$content_name; | |
910 | + } | |
911 | + | |
912 | + $lines = explode($separator,$document); | |
913 | + $start = true; | |
914 | + $this->content_no = 1; | |
915 | + $start_tag = "<{$element} $attr id=\"$element-$description-".$this->content_no."\">"; | |
916 | + $end_tag = ''; | |
917 | + $result = ""; | |
918 | + | |
919 | + foreach($lines as $list){ | |
920 | + | |
921 | + $list = $list. $separator; | |
922 | + | |
923 | + if(ereg("(^$wm{1})(.+)",$list,$regs) and !strpos($list,'-->')){ | |
924 | + | |
925 | + if(!empty($content)){ | |
926 | + | |
927 | + $start_content = "<$content>"; | |
928 | + $end_content = "</$content>\n"; | |
929 | + }else{ | |
930 | + | |
931 | + $start_content = ""; | |
932 | + $end_content = ""; | |
933 | + } | |
934 | + | |
935 | + $res = $this->text2html_list($regs[2],$this->separator,$this->element,$this->wm,$this->content,$this->attr,$this->content_attr,$this->description); | |
936 | + | |
937 | + $list = str_replace($regs[0],$start_tag.$start_content.trim($this->sublist($res)).$end_content,$list); | |
938 | + $start_tag = ""; | |
939 | + $end_tag = "</{$element}>"; | |
940 | + | |
941 | + }elseif(!empty($end_tag)){ | |
942 | + | |
943 | + $list = $end_tag."\n".$list; | |
944 | + $this->content_no++; | |
945 | + $end_tag = ''; | |
946 | + $start_tag = "<{$element} $attr id=\"$element-$description-".$this->content_no."\">"; | |
947 | + }else{ | |
948 | + | |
949 | + $start_tag = "<{$element} $attr id=\"$element-$description-".$this->content_no."\">"; | |
950 | + | |
951 | + } | |
952 | + | |
953 | + $result .= $list; | |
954 | + | |
955 | + } | |
956 | + | |
957 | + return $this->tag_clear($result); | |
958 | + } | |
959 | + | |
960 | + function sublist($document,$separator = "\n"){ | |
961 | + | |
962 | + $element = $this->element; | |
963 | + $wm = $this->wm; | |
964 | + $content = $this->content; | |
965 | + $start = true; | |
966 | + $lines = explode($separator,$document); | |
967 | + $end_tag = ""; | |
968 | + $result = ""; | |
969 | + $class = ""; | |
970 | + | |
971 | + foreach($lines as $key=>$list){ | |
972 | + | |
973 | + $list = $list. "\n"; | |
974 | + | |
975 | + if(ereg("(^$wm{1})(.+)",$list,$regs)){ | |
976 | + | |
977 | + if($start == false){$start_tag = "";}else{$start_tag = "<$element>";} | |
978 | + | |
979 | + if(!ereg("(^$wm{1})(.+)",$lines[$key+1])){$end_tag= "</$element>";}else{$end_tag= "";} | |
980 | + | |
981 | + if(!empty($content)){ | |
982 | + | |
983 | + $start_content = "<$content>"; | |
984 | + $end_content = "</$content>"; | |
985 | + }else{ | |
986 | + | |
987 | + $start_content = ""; | |
988 | + $end_content = ""; | |
989 | + } | |
990 | + | |
991 | + $list= str_replace($regs[0],$start_tag.$start_content.trim($this->sublist($regs[2]))."\n".$end_content,$list); | |
992 | + | |
993 | + $start = false; | |
994 | + | |
995 | + }elseif(!empty($end_tag)){ | |
996 | + | |
997 | + $list = $end_tag. "\n".$list; | |
998 | + } | |
999 | + $result .= $list; | |
1000 | + | |
1001 | + } | |
1002 | + | |
1003 | + return $this->tag_clear($result); | |
1004 | + } | |
1005 | + | |
1006 | +function text2html_code($document = "", $separator = "\n",$element = "pre",$wm = 'code:',$content = 'code',$attr = '',$content_attr = '',$description = ''){ | |
1007 | + | |
1008 | + $this->element = $element; | |
1009 | + $this->wm = $wm; | |
1010 | + $this->content = $content; | |
1011 | + | |
1012 | + global $content_name; | |
1013 | + | |
1014 | + if(!empty($content_name) and !empty($description)){ | |
1015 | + $description = $description.'-'.$content_name; | |
1016 | + }else{ | |
1017 | + $description = $description.$content_name; | |
1018 | + } | |
1019 | + | |
1020 | + $i = 0; | |
1021 | + $lines = explode($separator,$document); | |
1022 | + $start = true; | |
1023 | + $this->content_no = 1; | |
1024 | + $start_tag = "<{$element} $attr id=\"$element-$description-".trim($this->content_no)."\">"; | |
1025 | + $end_tag = ''; | |
1026 | + $result = ""; | |
1027 | + | |
1028 | + foreach($lines as $list){ | |
1029 | + | |
1030 | + $list = $list. "\n"; | |
1031 | + | |
1032 | + if(preg_match("/(^$wm{1})(.+)/um",$list,$regs)){ | |
1033 | + | |
1034 | + if(!empty($content)){ | |
1035 | + $i++; | |
1036 | + $start_content = "<$content title=\"line$i\">"; | |
1037 | + $end_content = "</$content>\n"; | |
1038 | + }else{ | |
1039 | + $start_content = ""; | |
1040 | + $end_content = "\n"; | |
1041 | + } | |
1042 | + | |
1043 | + $doc = $regs[2]; | |
1044 | + $doc = $this->my_wordwrap($doc); | |
1045 | + $doc = htmlspecialchars($doc); | |
1046 | + $doc = str_replace(array('/',"\t",'$','<'),array("/"," ",'$','&#lt'),$doc); | |
1047 | + $doc = str_replace("\n","</code><code>",$doc);//ワードラップは、改行だけ埋め込むので、タグを補充 | |
1048 | + $list = str_replace($regs[0],$start_tag.$start_content.trim($doc).$end_content,$list); | |
1049 | + $start_tag = ""; | |
1050 | + $end_tag = "</{$element}>"; | |
1051 | + | |
1052 | + }elseif(!empty($end_tag)){ | |
1053 | + | |
1054 | + $list = $end_tag."\n".$list; | |
1055 | + $this->content_no++; | |
1056 | + $end_tag = ''; | |
1057 | + $start_tag = "<{$element} $attr id=\"$element-$description-".trim($this->content_no)."\">"; | |
1058 | + $i = 0; | |
1059 | + }else{ | |
1060 | + | |
1061 | + $start_tag = "<{$element} $attr id=\"$element-$description-".trim($this->content_no)."\">"; | |
1062 | + $i =0; | |
1063 | + } | |
1064 | + | |
1065 | + $result .= $list; | |
1066 | + } | |
1067 | + | |
1068 | + return $this->tag_clear($result); | |
1069 | + } | |
1070 | + | |
1071 | +function text2html_table($document, $separator = "\n",$element = "table",$wm = 'tr:',$content = 'tr',$attr = '',$content_attr = '',$description = ''){ | |
1072 | + | |
1073 | + if(!preg_match("/$wm/si",$document)){ return $document;} | |
1074 | + | |
1075 | + $this->element = $element; | |
1076 | + $this->wm = $wm; | |
1077 | + $this->content = $content; | |
1078 | + $this->content_no = 1; | |
1079 | + $start = true; | |
1080 | + $end_tag = ''; | |
1081 | + $result = ""; | |
1082 | + $row_no = 1; | |
1083 | + global $content_name; | |
1084 | + | |
1085 | + if(!empty($content_name) and !empty($description)){ | |
1086 | + $description = $description.'-'.$content_name; | |
1087 | + }else{ | |
1088 | + $description = $description.$content_name; | |
1089 | + } | |
1090 | + | |
1091 | + $start_tag = "<{$element} $attr id=\"table-$description-".$this->content_no."\">"; | |
1092 | + $lines = explode($separator,$document); | |
1093 | + $group = "<colgroup><col /></colgroup>"; | |
1094 | + | |
1095 | + foreach($lines as $key=>$list){ | |
1096 | + | |
1097 | + $list = $list. $separator; | |
1098 | + $write_group = false; | |
1099 | + | |
1100 | + if(ereg("(^$wm{1})(.+)",$list,$regs)){ | |
1101 | + | |
1102 | + if(preg_match("/({$wm}summary:)(.+)/um",$list,$match)){ | |
1103 | + | |
1104 | + if($end_tag){ | |
1105 | + | |
1106 | + $start_tag = "</table>\n<{$element} $attr summary=\"$match[2]\" id=\"table-$description-".$this->content_no."\">"; | |
1107 | + | |
1108 | + }else{ | |
1109 | + | |
1110 | + $start_tag = "<{$element} $attr summary=\"$match[2]\" id=\"table-$description-".$this->content_no."\">"; | |
1111 | + } | |
1112 | + | |
1113 | + $write_group = true; | |
1114 | + unset($regs[2]); | |
1115 | + $list = ""; | |
1116 | + | |
1117 | + }else{ | |
1118 | + | |
1119 | + $ht_field = ""; | |
1120 | + | |
1121 | + if(isset($regs[2])){ | |
1122 | + | |
1123 | + $fields = explode('|',$regs[2]); | |
1124 | + $col_no =1; | |
1125 | + foreach($fields as $colkey=>$field){ | |
1126 | + | |
1127 | + $ht_field .= "<td class=\"col{$col_no} row{$row_no}\" id=\"tbl".$this->content_no."{$col_no}{$row_no}\">$field</td>"; | |
1128 | + $col_no++; | |
1129 | + | |
1130 | + } | |
1131 | + | |
1132 | + $row_no++; | |
1133 | + } | |
1134 | + | |
1135 | + $list = str_replace($regs[0],$start_tag."<$content>".$ht_field."</$content>\n",$list); | |
1136 | + $start_tag = ""; | |
1137 | + $end_tag = "</{$element}>\n"; | |
1138 | + | |
1139 | + if(!isset($lines[$key + 1]) or !ereg("(^$wm{1})(.+)",$lines[$key + 1])){ | |
1140 | + | |
1141 | + $list = str_replace($regs[0],$start_tag."<$content>".$ht_field."</$content>{$end_tag}\n",$list); | |
1142 | + $row_no = 1; | |
1143 | + } | |
1144 | + } | |
1145 | + }elseif($end_tag){ | |
1146 | + | |
1147 | + $list = $end_tag."\n".$list; | |
1148 | + $row_no = 1; | |
1149 | + | |
1150 | + $this->content_no++; | |
1151 | + | |
1152 | + $start_tag = "<{$element} $attr id=\"table-$description-".$this->content_no."\">"; | |
1153 | + $end_tag = false; | |
1154 | + }else{ | |
1155 | + | |
1156 | + $start_tag = "<{$element} $attr id=\"table-$description-".$this->content_no."\">"; | |
1157 | + } | |
1158 | + | |
1159 | + $result .= $list; | |
1160 | + } | |
1161 | + return $this->tag_clear($result); | |
1162 | +} | |
1163 | + | |
1164 | +function text2html_element($document, $separator = "\n",$element = "h2",$wm = '*',$content = 'span',$attr = '',$content_attr = '',$description = ''){ | |
1165 | + | |
1166 | + global $content_name; | |
1167 | + | |
1168 | + if(!empty($content_name) and !empty($description)){ | |
1169 | + $description = $description.'-'.$content_name; | |
1170 | + }else{ | |
1171 | + $description = $description.$content_name; | |
1172 | + } | |
1173 | + | |
1174 | + $lines = explode($separator,$document); | |
1175 | + $start = true; | |
1176 | + $end_tag = ''; | |
1177 | + $result = ""; | |
1178 | + $start_tag = "<{$element} $attr id=\"$element-$description-".$this->content_no."\" >"; | |
1179 | + $this->content_no = 1; | |
1180 | + | |
1181 | + foreach($lines as $key => $list){ | |
1182 | + | |
1183 | + $list = $list. "\n"; | |
1184 | + | |
1185 | + if(preg_match("/(^$wm{1})(.+)/um",$list,$regs)){ | |
1186 | + | |
1187 | + if(!empty($content)){ | |
1188 | + | |
1189 | + $content_start = "<$content $content_attr >"; | |
1190 | + $content_end = "</$content>"; | |
1191 | + }else{ | |
1192 | + | |
1193 | + $content_start = ""; | |
1194 | + $content_end = ""; | |
1195 | + } | |
1196 | + | |
1197 | + $list = str_replace($regs[0],$start_tag.$content_start.$regs[2].$content_end,$list); | |
1198 | + $start_tag = ""; | |
1199 | + $end_tag = "</{$element}>\n"; | |
1200 | + | |
1201 | + //見出しリスト | |
1202 | + | |
1203 | + if(ereg("h([1-6])",$element,$match)){ | |
1204 | + | |
1205 | + $list = str_replace("\n","",$list); | |
1206 | + array_push($this->header_info,array($key,trim($match[1]),"$element-$description-".$this->content_no,$regs[2])); | |
1207 | + } | |
1208 | + | |
1209 | + }elseif(!empty($end_tag)){ | |
1210 | + | |
1211 | + $list = $end_tag."\n".$list; | |
1212 | + $this->content_no++; | |
1213 | + $end_tag = ''; | |
1214 | + $start_tag = "<{$element} $attr id=\"$element-$description-".$this->content_no."\" >"; | |
1215 | + }else{ | |
1216 | + | |
1217 | + $start_tag = "<{$element} $attr id=\"$element-$description-".$this->content_no."\" >"; | |
1218 | + } | |
1219 | + $result .= $list; | |
1220 | + } | |
1221 | + | |
1222 | + return $this->tag_clear($result); | |
1223 | +} | |
1224 | + | |
1225 | +function paragraf($document, $separator = "\n\n",$element = "p",$wm = '',$content = '',$attr = '',$content_attr = '',$description = 'paragraph'){ | |
1226 | + | |
1227 | + global $content_name; | |
1228 | + | |
1229 | + if(!empty($content_name) and !empty($description)){ | |
1230 | + $description = $description.'-'.$content_name; | |
1231 | + }else{ | |
1232 | + $description = $description.$content_name; | |
1233 | + } | |
1234 | + | |
1235 | + $checks=array('dl','address','blockquote','form','fieldset','table','style','tr','code','div'); | |
1236 | + | |
1237 | + foreach($checks as $val){ | |
1238 | + | |
1239 | + $check[] = "<$val"; | |
1240 | + $check[] = "$val>"; | |
1241 | + $check[] = "</$val"; | |
1242 | + | |
1243 | + $replace[] = "\n\n<$val"; | |
1244 | + $replace[] = "$val>$separator"; | |
1245 | + $replace[] = "$separator</$val"; | |
1246 | + } | |
1247 | + | |
1248 | + | |
1249 | + $document = str_replace($check,$replace,$document); | |
1250 | + $document = $this->tag_clear($document); | |
1251 | + $document = ereg_replace("(\n{1})","\n\n",$document); | |
1252 | + $lines = explode($separator,$document); | |
1253 | + $start = true; | |
1254 | + $end_tag = ''; | |
1255 | + $result = ""; | |
1256 | + $this->content_no = 1; | |
1257 | + $start_tag = "<{$element} $attr id=\"$element-$description-".$this->content_no."\">"; | |
1258 | + //$wm = "[^(\*|+|<|\=|\n$|\s|code:| )]"; | |
1259 | + $blocks = true;//pをコンテンツに出来ないタグ内での変換を禁止 | |
1260 | + $wm = "[^(\*|\+|\=|\n$|\s| |\-|<)]"; | |
1261 | + $tags_block = "(dl|ol|ul|address|blockquote|form|fieldset|table|style|tr|p|code)"; | |
1262 | + $cdata_zone = false; | |
1263 | + | |
1264 | + foreach($lines as $key => $list){ | |
1265 | + | |
1266 | + $list = $list."\n\n"; | |
1267 | + | |
1268 | + if(preg_match("/(<!--|<!\[CDATA\[|<script|<style|<$tags_block)/iu",$list) and !preg_match("/(!--|\]\]>|\/script|\/style|<\/$tags_block)\s?\/?>/iu",$list)){ | |
1269 | + $cdata_zone = true; | |
1270 | + //テーブル間にタグを適用できなくなる | |
1271 | + } | |
1272 | + | |
1273 | + if(preg_match("/(^($wm).*)/um",$list,$regs) and $cdata_zone == false ){ | |
1274 | + | |
1275 | + $content_start = ""; | |
1276 | + | |
1277 | + if(isset($lines[$key + 1]) and $lines[$key + 1] == true){ | |
1278 | + | |
1279 | + $content_end = "<br />"; | |
1280 | + }else{ | |
1281 | + | |
1282 | + $content_end = ""; | |
1283 | + } | |
1284 | + | |
1285 | + $list = str_replace($regs[0],$start_tag.$content_start.trim($regs[1]).$content_end,$list); | |
1286 | + $start_tag = ""; | |
1287 | + $end_tag = "\n</{$element}>\n\n"; | |
1288 | + $paragraph_div = '¶'; | |
1289 | + | |
1290 | + if(eregi($paragraph_div,$list)){ | |
1291 | + | |
1292 | + $list = str_replace(array($paragraph_div.$content_end,$paragraph_div),$end_tag, $list); | |
1293 | + $end_tag = ''; | |
1294 | + $this->content_no++; | |
1295 | + $start_tag = "<{$element} $attr id=\"$element-$description-".$this->content_no."\">"; | |
1296 | + } | |
1297 | + | |
1298 | + }elseif(!empty($end_tag) ){ | |
1299 | + | |
1300 | + $list = $end_tag."\n".$list; | |
1301 | + $end_tag= ''; | |
1302 | + $this->content_no++; | |
1303 | + $start_tag = "<{$element} $attr id=\"$element-$description-".$this->content_no."\">"; | |
1304 | + | |
1305 | + }else{ | |
1306 | + | |
1307 | + $start_tag = "<{$element} $attr id=\"$element-$description-".$this->content_no."\">"; | |
1308 | + } | |
1309 | + | |
1310 | + | |
1311 | + if(preg_match("/(-->|\]\]>|<\/script|<\/style|<\/$tags_block)/iu",$list)){ | |
1312 | + | |
1313 | + $cdata_zone = false; | |
1314 | + } | |
1315 | + | |
1316 | + $result .= $list; | |
1317 | + } | |
1318 | + | |
1319 | + return $this->tag_clear($result); | |
1320 | +} | |
1321 | + | |
1322 | +function img_copy($buffer){ | |
1323 | + if(ini_get('allow_url_fopen') !== "1"){return $buffer;} | |
1324 | + if(!defined('TEXTTOHTML_IMAGE_DIR_PATH')){return $buffer;} | |
1325 | + | |
1326 | + $copy_width = TEXTTOHTML_COPY_IMG_WIDTH; | |
1327 | + | |
1328 | + if(preg_match_all("/(copy>\()([^\)]+)(\))/", $buffer, $matches, PREG_SET_ORDER)){ | |
1329 | + | |
1330 | + foreach($matches as $key=>$match){ | |
1331 | + | |
1332 | + $cache = use_cache($matches[$key][0],$buffer); | |
1333 | + | |
1334 | + if($cache[0]){ | |
1335 | + | |
1336 | + $buffer= str_replace($matches[$key][0],$cache[1],$buffer)."\n"; | |
1337 | + }else{ | |
1338 | + clearstatcache(); | |
1339 | + | |
1340 | + $copy_target = TEXTTOHTML_IMAGE_DIR_PATH.basename($match[2]); | |
1341 | + $copy_target_url = TEXTTOHTML_IMAGE_DIR_URL.basename($match[2]); | |
1342 | + $quote_comment = "<!--from:".$match[2]."--><a href=\"".$match[2]."\" class=\"quoted\">"; | |
1343 | + $size = getimagesize($match[2]); | |
1344 | + $uri = htmlspecialchars(trim($match[2])); | |
1345 | + | |
1346 | + if($size[0] > $copy_width){ | |
1347 | + $aspect = @round($size[1]/$size[0],2); | |
1348 | + $height = @round($copy_width * $aspect,0); | |
1349 | + }else{ | |
1350 | + $copy_width = $size[0]; | |
1351 | + $height = $size[1]; | |
1352 | + } | |
1353 | + | |
1354 | + $gdimg = imagecreatetruecolor($copy_width,$height); | |
1355 | + | |
1356 | + if($size[2] == 1) { | |
1357 | + | |
1358 | + if( $im = imagecreatefromgif($uri)){ | |
1359 | + imagecopyresized($gdimg,$im,0,0,0,0,$copy_width,$height,$size[0],$size[1]); | |
1360 | + @imagegif($gdimg,$copy_target); | |
1361 | + } | |
1362 | + } | |
1363 | + | |
1364 | + if($size[2] == 2 and $size) { | |
1365 | + | |
1366 | + if( $im = imagecreatefromjpeg($uri)){ | |
1367 | + imagecopyresized($gdimg,$im,0,0,0,0,$copy_width,$height,$size[0],$size[1]); | |
1368 | + @imagejpeg($gdimg,$copy_target); | |
1369 | + } | |
1370 | + } | |
1371 | + if($size[2] == 3) { | |
1372 | + | |
1373 | + if($im = imagecreatefrompng($uri)){ | |
1374 | + imagecopyresized($gdimg,$im,0,0,0,0,$copy_width,$height,$size[0],$size[1]); | |
1375 | + @imagepng($gdimg,$copy_target); | |
1376 | + } | |
1377 | + } | |
1378 | + if($size[2] == 15) { | |
1379 | + | |
1380 | + if($im = imagecreatefromwbmp($uri)){ | |
1381 | + imagecopyresized($gdimg,$im,0,0,0,0,$copy_width,$height,$size[0],$size[1]); | |
1382 | + @imagebmp($gdimg,$copy_target); | |
1383 | + } | |
1384 | + } | |
1385 | + | |
1386 | + $buffer= str_replace($matches[$key][0],$quote_comment."<img src=\"".$copy_target_url."\" width=\"$copy_width\" height=\"$height\" alt=\"copyed image\" /></a>",$buffer)."\n"; | |
1387 | + | |
1388 | + | |
1389 | + save_cache($matches[$key][0],$quote_comment."<img src=\"".$copy_target_url."\" width=\"$copy_width\" height=\"$height\" alt=\"copyed image\" /></a>"); | |
1390 | + } | |
1391 | + | |
1392 | + } | |
1393 | + | |
1394 | + } | |
1395 | +return $buffer; | |
1396 | +} | |
1397 | + | |
1398 | +function keyword_change($document){ | |
1399 | + | |
1400 | + $keyword_res = array(); | |
1401 | + $change_val_res = array(); | |
1402 | + | |
1403 | + if(phpversion('domDocument')){ | |
1404 | + | |
1405 | + $dom = new domDocument; | |
1406 | + $dom->load(CHANGE_PATTERN_PATH); | |
1407 | + $root = $dom->documentElement; | |
1408 | + $books = $root->childNodes; | |
1409 | + $keyword_res = array(); | |
1410 | + $change_val = array(); | |
1411 | + | |
1412 | + foreach ($books as $book) { | |
1413 | + | |
1414 | + if (@$book->nodeName == 'dl') { | |
1415 | + $content = $book->childNodes; | |
1416 | + | |
1417 | + foreach ($content as $elem) { | |
1418 | + if (@$elem->nodeName == 'dd') { | |
1419 | + $change_val[] = $elem->nodeValue; | |
1420 | + } | |
1421 | + if (@$elem->nodeName == 'dt') { | |
1422 | + $keyword[] = $elem->nodeValue; | |
1423 | + } | |
1424 | + } | |
1425 | + } | |
1426 | + } | |
1427 | + | |
1428 | + $result = str_replace($keyword , $change_val, $document); | |
1429 | + return $this->tag_clear($result); | |
1430 | + | |
1431 | + }else{ | |
1432 | + | |
1433 | + $data = file_get_contents(CHANGE_PATTERN_PATH); | |
1434 | + $dls = explode("<dl>",$data); | |
1435 | + | |
1436 | + foreach($dls as $dl){ | |
1437 | + | |
1438 | + ereg("(<dt>)([^<]+)(</dt>)",$dl,$keyword); | |
1439 | + array_push($keyword_res,$keyword[2]); | |
1440 | + ereg("(<dd>)([^<]+)(</dd>)",$dl,$change_val); | |
1441 | + array_push($change_val_res,$change_val[2]); | |
1442 | + } | |
1443 | + | |
1444 | + $keyword_res = str_replace(array(">","<","&","""),array(">","<",'&','"'),$keyword_res); | |
1445 | + $change_val_res = str_replace(array(">","<","&","""),array(">","<",'&','"'),$change_val_res); | |
1446 | + $res = str_replace($keyword_res,$change_val_res,$document); | |
1447 | + return $res; | |
1448 | + } | |
1449 | +} | |
1450 | + | |
1451 | + | |
1452 | + function keyword_change_inline($document, $separator = "\n"){ | |
1453 | + | |
1454 | + $before_start = "<!--%"; | |
1455 | + $before_end = "%-->"; | |
1456 | + $start_tag = '【'; | |
1457 | + $end_tag = '】'; | |
1458 | + | |
1459 | + $word = ""; | |
1460 | + $change = ""; | |
1461 | + $document_result = ""; | |
1462 | + $keyword_res = array(); | |
1463 | + $change_val_res = array(); | |
1464 | + $textdes = explode($separator, $document); | |
1465 | + $record = 0; | |
1466 | + | |
1467 | + foreach($textdes as $words){ | |
1468 | + $words = $words . "\n"; | |
1469 | + | |
1470 | + if($record == 0 and ereg("(^$start_tag)([^/]+)($end_tag)",$words,$keyword)){ | |
1471 | + | |
1472 | + $change = ""; | |
1473 | + $keyword = $before_start.$keyword[2].$before_end; | |
1474 | + $record = 1; | |
1475 | + }elseif($record == 1 and !ereg("(^$start_tag\/)(.+)($end_tag)",$words)){ | |
1476 | + | |
1477 | + $change .= $words . "\n"; | |
1478 | + }elseif($record == 1 and ereg("(^$start_tag\/)(.+)($end_tag)",$words)){ | |
1479 | + | |
1480 | + $record = 0; | |
1481 | + | |
1482 | + if(array_search($keyword,$keyword_res) == false and !empty($keyword) and !empty($change)){ | |
1483 | + | |
1484 | + array_push($keyword_res,$keyword); | |
1485 | + $change = str_replace(array("\r\n","\r","\n"),"<><>",$change); | |
1486 | + array_push($change_val_res,$change); | |
1487 | + $array_res[] = array($keyword=>$change); | |
1488 | + } | |
1489 | + }else{ | |
1490 | + | |
1491 | + $document_result .= $words; | |
1492 | + } | |
1493 | + } | |
1494 | + $document_result = str_replace($keyword_res,$change_val_res,$document_result); | |
1495 | + $result = str_replace(array("<><>","><"),array("\n",">\n<"),$document_result); | |
1496 | + | |
1497 | + return $this->tag_clear($result); | |
1498 | +} | |
1499 | + | |
1500 | + | |
1501 | +function inline_tag($text){ | |
1502 | + | |
1503 | +$tags_inline = "(a|abbr|acronym|area|b|base|bdo|big|body|button|caption|cite|code|colgroup|dd|del|dfn|dt|em|head|html|i|img|input|ins|kbd|label|legend|li|link|map|object|optgroup|option|param|q|samp|select|small|span|strong|sub|sup|tbody|td|textarea|tfoot|th|thead|title|tt|var)"; | |
1504 | + | |
1505 | + if(preg_match_all("/(\[)($tags_inline)(\|)([^\|]+)(\|)([^\]]+)(\])/", $text, $matches, PREG_SET_ORDER)){ | |
1506 | + foreach($matches as $key=>$match){ | |
1507 | + | |
1508 | + $element = mb_convert_encoding($match[2],"UTF-8","auto"); | |
1509 | + $attr = mb_convert_encoding($match[5],"UTF-8","auto"); | |
1510 | + $value = mb_convert_encoding($match[7],"UTF-8","auto"); | |
1511 | + $replacement = "<$element $attr>$value</$element>"; | |
1512 | + $text = str_replace($matches[$key][0],$replacement,$text)."\n"; | |
1513 | + } | |
1514 | + | |
1515 | + $code_hit = true; | |
1516 | + } | |
1517 | + | |
1518 | + return $text; | |
1519 | +} | |
1520 | + | |
1521 | + | |
1522 | +function ruby($text){ | |
1523 | + | |
1524 | + if(preg_match_all("/(ruby>\()([^:]+)(:)([^\)]+)(\))/", $text, $matches, PREG_SET_ORDER)){ | |
1525 | + | |
1526 | + foreach($matches as $key=>$match){ | |
1527 | + | |
1528 | + $word = mb_convert_encoding($match[2],"UTF-8","auto"); | |
1529 | + $kana = mb_convert_encoding($match[4],"UTF-8","auto"); | |
1530 | + $word = str_replace("\n","",$word); | |
1531 | + $kana = str_replace("\n","",$kana); | |
1532 | + $replacement = "<ruby><rb>$word</rb><rp>(</rp><rt>$kana</rt><rp>)</rp></ruby>"; | |
1533 | + $text = str_replace($matches[$key][0],$replacement,$text)."\n"; | |
1534 | + } | |
1535 | + | |
1536 | + $code_hit = true; | |
1537 | + } | |
1538 | + | |
1539 | + return $text; | |
1540 | +} | |
1541 | + | |
1542 | + | |
1543 | +function trackback($text){ | |
1544 | + | |
1545 | + if(!defined('TEXTTOHTML_TRACKBACK_URL')){return $text;} | |
1546 | + | |
1547 | + if(preg_match_all("/(trackback>\()([^\)]+)(\))/", $text, $matches, PREG_SET_ORDER)){ | |
1548 | + | |
1549 | + foreach($matches as $key=>$match){ | |
1550 | + | |
1551 | + $tabindex = $key + 1; | |
1552 | + | |
1553 | + switch ($key) { | |
1554 | + case 0: | |
1555 | + $accesskey = "a"; | |
1556 | + break; | |
1557 | + case 1: | |
1558 | + $accesskey = "b"; | |
1559 | + break; | |
1560 | + case 2: | |
1561 | + $accesskey = "c"; | |
1562 | + break; | |
1563 | + case 3: | |
1564 | + $accesskey = "d"; | |
1565 | + break; | |
1566 | + case 4: | |
1567 | + $accesskey = "e"; | |
1568 | + break; | |
1569 | + case 5: | |
1570 | + $accesskey = "f"; | |
1571 | + break; | |
1572 | + default: | |
1573 | + $accesskey = "g"; | |
1574 | + | |
1575 | + } | |
1576 | + | |
1577 | + $enc = mb_convert_encoding($match[2],"UTF-8","auto"); | |
1578 | + $enc = urlencode($enc); | |
1579 | + | |
1580 | + $replacement = "<div class=\"trackback\"><span>トラックバック:".$match[2]."</span><br />Track back URL:<input type=\"text\" value=\"".TEXTTOHTML_TRACKBACK_URL. $enc. "\" accesskey=\"$accesskey\" tabindex=\"".$tabindex."\" /><br /><script type=\"text/javascript\" src=\"".TEXTTOHTML_TRACKBACK_URL. $enc. "\"></script>\n</div>\n"; | |
1581 | + | |
1582 | + $text = str_replace($matches[$key][0],$replacement,$text)."\n"; | |
1583 | + } | |
1584 | + | |
1585 | + $code_hit = true; | |
1586 | + } | |
1587 | + return $text; | |
1588 | + | |
1589 | +} | |
1590 | +/*------------------------------------------------------------------------------+ | |
1591 | + *URL メールアドレスをリンクに置換 | |
1592 | + *------------------------------------------------------------------------------*/ | |
1593 | +function maillink($text){ | |
1594 | + | |
1595 | + if(preg_match_all("/(mail>\()([^@]+)@([^\)]+)(\))/", $text, $matches, PREG_SET_ORDER)){ | |
1596 | + foreach($matches as $key=>$match){ | |
1597 | + | |
1598 | + $enc = mb_convert_encoding($match[2]."@".$match[3],"UTF-8","auto"); | |
1599 | + $chenge_val = "<a href=\"mailto:$enc\">mailto:".$match[2]."</a>"; | |
1600 | + | |
1601 | + | |
1602 | + $text= str_replace($matches[$key][0],$chenge_val,$text)."\n"; | |
1603 | + | |
1604 | + | |
1605 | + } | |
1606 | + | |
1607 | + } | |
1608 | + | |
1609 | + return $text; | |
1610 | +} | |
1611 | + | |
1612 | + | |
1613 | + | |
1614 | + /*------------------------------------------------------------ | |
1615 | + * youtube link | |
1616 | + -------------------------------------------------------------*/ | |
1617 | + | |
1618 | +function youtube($text,$separator = "\n"){ | |
1619 | + global $copy_width; | |
1620 | + | |
1621 | + if(preg_match_all("/(youtube>\()([^\)]+)(\))/", $text, $matches, PREG_SET_ORDER)){ | |
1622 | + | |
1623 | + foreach($matches as $key=>$match){ | |
1624 | + | |
1625 | + $query = parse_url($match[2]); | |
1626 | + $query = str_replace("v=","",$query['query']); | |
1627 | + $copy_target = "http://img.youtube.com/vi/".$query."/default.jpg"; | |
1628 | + $quote_comment = "<a href=\"$match[2]\" target=\"blank\">"; | |
1629 | + | |
1630 | + if($size = getimagesize($match[2])){ | |
1631 | + $aspect = round($size[1]/$size[0],2); | |
1632 | + $height = $copy_width * $aspect; | |
1633 | + }else{ | |
1634 | + $copy_width = 130; | |
1635 | + $height = 97; | |
1636 | + } | |
1637 | + $text= str_replace($matches[$key][0],$quote_comment."{$copy_target}?w={$copy_width}h={$height}alt=YouTube </a>",$text)."\n"; | |
1638 | + } | |
1639 | + } | |
1640 | + | |
1641 | + return $text; | |
1642 | +} | |
1643 | +/*------------------------------------------------------------------------------+ | |
1644 | + * 文字列から、イメージの作成とコーディング処理 | |
1645 | + *------------------------------------------------------------------------------*/ | |
1646 | +function txt2img($buffer,$separator = "\n"){ | |
1647 | + | |
1648 | + global $default; | |
1649 | + | |
1650 | + if(!defined('TEXTTOHTML_FONTS_PATH') ){return $buffer;}else{ | |
1651 | + | |
1652 | + include(TEXTTOHTML_FONTS_PATH); | |
1653 | + $buffers = explode($separator,$buffer); | |
1654 | + $string = ""; | |
1655 | + | |
1656 | + foreach($buffers as $buffer){ | |
1657 | + | |
1658 | + if(preg_match_all("/(txt2img>\()([^\)]+)(\))/", $buffer, $matches, PREG_SET_ORDER)){ | |
1659 | + | |
1660 | + foreach($matches as $key=>$match){ | |
1661 | + | |
1662 | + if(ereg("(:)",$match[2])){ | |
1663 | + list($element,$val_name,$val) =explode(":",$match[2]); | |
1664 | + | |
1665 | + $replacement = $this->convert_image($val,$$val_name,$element); | |
1666 | + }else{ | |
1667 | + $replacement = $this->convert_image($match[2],$default,"p"); | |
1668 | + } | |
1669 | + | |
1670 | + $string .= str_replace($matches[$key][0],$replacement,$buffer); | |
1671 | + } | |
1672 | + | |
1673 | + | |
1674 | + }else{ | |
1675 | + | |
1676 | + $string .= $buffer."\n"; | |
1677 | + } | |
1678 | + } | |
1679 | + | |
1680 | + return $string; | |
1681 | + | |
1682 | + } | |
1683 | +} | |
1684 | + | |
1685 | +///////////////////////////////////////////////////////////// | |
1686 | + | |
1687 | +function convert_image( $string , $gd_set = array("gt200001","13","class=\"text2image\"","0"),$element = "p"){ | |
1688 | + | |
1689 | + if(!defined('TEXTTOHTML_IMAGE_DIR_URL')){return $string;} | |
1690 | + | |
1691 | + $file_name = md5($string.$gd_set[0].$gd_set[1]); | |
1692 | + $image_file_name = str_replace(array('=','"','\\'),array(""),$gd_set[1])."-".$file_name.'.png'; | |
1693 | + $image_file_name = TEXTTOHTML_IMAGE_DIR_URL.$image_file_name; | |
1694 | + $image_file_path = TEXTTOHTML_IMAGE_DIR_PATH.str_replace(array('=','"','\\'),array(""),$gd_set[1])."-".$file_name.'.png'; | |
1695 | + $cache = use_cache($file_name); | |
1696 | + | |
1697 | + if($cache[0]){ | |
1698 | + | |
1699 | + $result= $cache[1]."\n"; | |
1700 | + return $result; | |
1701 | + }else{ | |
1702 | + | |
1703 | + $font = TEXTTOHTML_FONT_DIR_PATH.$gd_set[0].'.ttf'; | |
1704 | + $string = mb_convert_encoding($string,"UTF-8","auto"); | |
1705 | + $len = mb_strlen($string); | |
1706 | + $fontsize = $gd_set[1]; | |
1707 | + $height = $fontsize * 2; | |
1708 | + $background_img = $gd_set[3]; | |
1709 | + $indent = 20; | |
1710 | + $marginRight = 20; | |
1711 | + $attribute = $gd_set[2]; | |
1712 | + | |
1713 | + switch(true){ | |
1714 | + | |
1715 | + case($background_img == "0"): //背景画像を使用しない | |
1716 | + | |
1717 | + $timg = imagecreate($fontsize * 2 * $len, $fontsize * 2); | |
1718 | + $background = ImageColorAllocate($timg, 255, 255, 255); | |
1719 | + ImageFill($timg, 0, 0, $background); | |
1720 | + $Color = ImageColorAllocate($timg, 0, 0, 0); | |
1721 | + break; | |
1722 | + | |
1723 | + default://背景画像を使用する。 | |
1724 | + | |
1725 | + $timg = imagecreatefrompng(TEXTTOHTML_FONT_DIR_PATH.$background_img); | |
1726 | + | |
1727 | + $Color = ImageColorAllocate($timg, 0, 0, 0); | |
1728 | + break; | |
1729 | + } | |
1730 | + | |
1731 | + $vertical_align = $fontsize * 1.5; | |
1732 | + $chr = mb_convert_encoding($string,"UTF-8","auto"); | |
1733 | + $box = ImageTTFText($timg, $fontsize, 0, $indent, $vertical_align, $Color, $font, $chr); | |
1734 | + $width = $box[2] + $marginRight; | |
1735 | + $timg_resized = ImageCreate($width, $fontsize * 2); | |
1736 | + | |
1737 | + imagecopy($timg_resized, $timg, 0, 0, 0, 0, $width, $fontsize * 2); | |
1738 | + imagepng($timg_resized,$image_file_path); | |
1739 | + | |
1740 | + if($timg_resized){ | |
1741 | + | |
1742 | + $result = "<{$element} $attribute style=\"height:{$height}px;width:{$width}px;background:url($image_file_name);background-repeat:no-repeat;\">\n\t<span style=\"display:none;font-size:{$fontsize}px;\">$string</span></{$element}>\n"; | |
1743 | + | |
1744 | + save_cache($file_name,$result); | |
1745 | + | |
1746 | + return $result; | |
1747 | + }else{ | |
1748 | + | |
1749 | + return $string; | |
1750 | + } | |
1751 | + | |
1752 | + } | |
1753 | +} | |
1754 | + | |
1755 | +/*------------------------------------------------------------------------------+ | |
1756 | + *サウンドファイル quicktime | |
1757 | + *------------------------------------------------------------------------------*/ | |
1758 | + | |
1759 | +function sound($text){ | |
1760 | + | |
1761 | + if(preg_match_all("/(quicktime>\()([^\)]+)(\))/", $text, $matches, PREG_SET_ORDER)){ | |
1762 | + foreach($matches as $key=>$match){ | |
1763 | + | |
1764 | + $enc = mb_convert_encoding($match[2],"UTF-8","auto"); | |
1765 | + | |
1766 | + $replacement = "<object classid=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\" width=\"176\" height=\"20\" codebase=\"http://www.apple.com/qtactivex/qtplugin.cab\"><param name=\"src\" value=\"$enc\" /><param name=\"autoplay\" value=\"false\" /><param name=\"controller\" value=\"true\" /><embed src=\"$enc\" width=\"176\" height=\"20\" autostart=\"false\" controller=\"true\" pluginspage=\"http://www.apple.com/quicktime/download/\"></embed>.</object>"; | |
1767 | + | |
1768 | + $text = str_replace($matches[$key][0],$replacement,$text)."\n"; | |
1769 | + } | |
1770 | + | |
1771 | + $code_hit = true; | |
1772 | + } | |
1773 | +return $text; | |
1774 | +} | |
1775 | +/*------------------------------------------------------------------------------+ | |
1776 | + * | |
1777 | + *------------------------------------------------------------------------------*/ | |
1778 | + //3gp foma 動画 | |
1779 | +function foma_movie($text){ | |
1780 | + | |
1781 | +$text = mb_eregi_replace("(https?|ftp)(://[[:alnum:]\+\$\;\?\.%,!#~*/:@&=_-]+\.(3gp))", "<object classid=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\" width=\"176\" height=\"160\" codebase=\"http://www.apple.com/qtactivex/qtplugin.cab\"><param name=\"src\" value=\"\\1\\2\" /><param name=\"autoplay\" value=\"false\" /><param name=\"controller\" value=\"true\" /><embed src=\"\\1\\2\" width=\"176\" height=\"160\" autostart=\"false\" controller=\"true\" pluginspage=\"http://www.apple.com/quicktime/download/\"></embed>.</object>\n",$text); | |
1782 | + | |
1783 | +return $text; | |
1784 | +} | |
1785 | +/*------------------------------------------------------------------------------+ | |
1786 | + * | |
1787 | + *------------------------------------------------------------------------------*/ | |
1788 | +function swf($text){ | |
1789 | + | |
1790 | +$text = mb_eregi_replace("(https?|ftp)(://[[:alnum:]\+\$\;\?\.%,!#~*/:@&=_-]+\.(swf))(\?w=)([0-9]{1,3})(h=)([0-9]{1,3})", "<object class= \"swf\" data=\"\\1\\2\" type=\"image/swf\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" height=\"\\7\" width=\"\\5\" classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" ><param name=\"allowscriptaccess\" value=\"samedomain\" /><param name=\"movie\" value=\"\\1\\2\" /><param name=\"quality\" value=\"high\" /><param name=\"bgcolor\" value=\"#ffffff\" /><embed src=\"\\1\\2\" width=\"\\5\" height=\"\\7\" bgcolor=\"#ffffff\" loop=\"false\" quality=\"high\" pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?p1_prod_version=shockwaveflash\" type=\"application/x-shockwave-flash\"></embed></object>\n",$text); | |
1791 | + | |
1792 | + | |
1793 | +return $text; | |
1794 | +} | |
1795 | + | |
1796 | +/*------------------------------------------------------------------------------+ | |
1797 | + *指定部分をURLENCODE | |
1798 | + *------------------------------------------------------------------------------*/ | |
1799 | + | |
1800 | +function encode_query($text){ | |
1801 | + | |
1802 | + if(preg_match_all("/(query>\()([^\)]+)(\))/", $text, $matches, PREG_SET_ORDER)){ | |
1803 | + | |
1804 | + foreach($matches as $key=>$match){ | |
1805 | + | |
1806 | + $enc = mb_convert_encoding($match[2],"UTF-8","auto"); | |
1807 | + $enc = urlencode($enc); | |
1808 | + $text= str_replace($matches[$key][0],$enc,$text)."\n"; | |
1809 | + } | |
1810 | + | |
1811 | + } | |
1812 | + return $text; | |
1813 | +} | |
1814 | + | |
1815 | +/*------------------------------------------------------------------------------+ | |
1816 | + *$show_img_tag 画像表示uriのみ class= "ins_img" | |
1817 | + *------------------------------------------------------------------------------*/ | |
1818 | + | |
1819 | +function image($text){ | |
1820 | + | |
1821 | + $allow_img_filetype = "(\.gif|\.png|\.jpe?g)"; | |
1822 | + | |
1823 | +$text = eregi_replace("(https?://[[:alnum:]\+\$\;\?\.%,!#~*/:@&=_-]+)($allow_img_filetype)(\?w=)([0-9]{1,3})(h=)([0-9]{1,3})(alt=)?([^([:space:]|<)]+)?", "<img src=\"\\1\\2\" width=\"\\5\" height=\"\\7\" class=\"picture\" alt=\"\\9\" />",$text); | |
1824 | + | |
1825 | +return $text; | |
1826 | +} | |
1827 | + | |
1828 | + | |
1829 | +//リンク名つきリンク | |
1830 | +function link_title($text){ | |
1831 | + | |
1832 | + if(preg_match_all("/(https?)(:\/\/[[:alnum:]\+\$\;\?\.%,!#~*\/:@&=_-]+)(\()(b:|t:|s:)?([^\)]+)(\))/", $text, $matches, PREG_SET_ORDER)){ | |
1833 | + | |
1834 | + foreach($matches as $key=>$match){ | |
1835 | + | |
1836 | + $cache = use_cache($matches[$key][0],$text); | |
1837 | + | |
1838 | + if($cache[0]){ | |
1839 | + | |
1840 | + $text = str_replace($matches[$key][0],$cache[1],$text)."\n"; | |
1841 | + }else{ | |
1842 | + | |
1843 | + switch($match[4]){ | |
1844 | + case('b:'): | |
1845 | + $attr = '_blank'; | |
1846 | + break; | |
1847 | + case('t:'): | |
1848 | + $attr = '_top'; | |
1849 | + break; | |
1850 | + case('s:'): | |
1851 | + $attr = '_self'; | |
1852 | + break; | |
1853 | + | |
1854 | + default: | |
1855 | + $attr = '_self'; | |
1856 | + | |
1857 | + break; | |
1858 | + } | |
1859 | + | |
1860 | + $attr = "onclick=\"this.target='$attr';\" onkeypress=\"this.target='$attr';\""; | |
1861 | + $link_name = mb_convert_encoding($match[5],"UTF-8","auto"); | |
1862 | + $url = $match[1].$match[2]; | |
1863 | + | |
1864 | + if(trim($link_name) == 'title'){ | |
1865 | + | |
1866 | + $cache = use_cache($matches[$key][0],$link_name); | |
1867 | + | |
1868 | + if(ini_get('allow_url_fopen') == "1"){ | |
1869 | + | |
1870 | + try{ | |
1871 | + if(!$data = mb_convert_encoding(file_get_contents($url),"UTF-8","auto")){ | |
1872 | + | |
1873 | + throw new Exception('リンクタイトルを取得できません'); | |
1874 | + } | |
1875 | + | |
1876 | + preg_match( "/<title.*?>(.*?)<\/title>/si", $data, $regs ); | |
1877 | + $linkname = trim(strip_tags($regs[1])); | |
1878 | + $link_name = htmlspecialchars($linkname); | |
1879 | + | |
1880 | + }catch (Exception $e) { | |
1881 | + $link_name = $url; | |
1882 | + echo '例外: ',$url, $e->getMessage(), "\n"; | |
1883 | + } | |
1884 | + }else{ | |
1885 | + $link_name = ""; | |
1886 | + } | |
1887 | + | |
1888 | + if(empty($link_name)){ $link_name = $url;} | |
1889 | + } | |
1890 | + | |
1891 | + $link = "<a href=\"".$url."\" $attr >".$link_name."</a>"; | |
1892 | + $text = str_replace($matches[$key][0],$link,$text)."\n"; | |
1893 | + } | |
1894 | + | |
1895 | + } | |
1896 | + | |
1897 | + } | |
1898 | + | |
1899 | + return $text; | |
1900 | +} | |
1901 | + | |
1902 | + | |
1903 | +function name_link($text){ | |
1904 | + | |
1905 | + $text = eregi_replace("(link>)(https?)(://[[:alnum:]\+\$\;\?\.%,!#~*/:@&=_-]+)", "<a href=\"\\2\\3\" title=\"\\2\\3\">\\2\\3</a>\n", $text); | |
1906 | + $text = mb_ereg_replace("(https?)(://[[:alnum:]\+\$\;\?\.%,!#~*/:@&=_-]+)(()([^)]+)())", "<a href=\"\\1\\2\" title=\"\\1\\2\">\\4</a>\n",$text); | |
1907 | + | |
1908 | +return $text; | |
1909 | +} | |
1910 | + | |
1911 | + | |
1912 | +function clear_both($text){ | |
1913 | + | |
1914 | +$text = str_replace("[クリア]", "<br style=\"clear:left;\" />", $text); | |
1915 | +$text = str_replace("[クリア]", "<br style=\"clear:left;\" />", $text); | |
1916 | + | |
1917 | +return $text; | |
1918 | +} | |
1919 | + | |
1920 | +/* | |
1921 | +function read_php2($text){ | |
1922 | + | |
1923 | + if(preg_match_all("/(eval>\[)([^\]]+)(\])/", $text, $matches, PREG_SET_ORDER)){ | |
1924 | + foreach($matches as $key=>$match){ | |
1925 | + | |
1926 | + $str = mb_convert_encoding($match[2],"UTF-8","auto"); | |
1927 | + eval("\$str = $str;"); | |
1928 | + $text= str_replace($matches[$key][0],$str,$text)."\n"; | |
1929 | + } | |
1930 | + | |
1931 | + } | |
1932 | +return $text; | |
1933 | +} | |
1934 | +*/ | |
1935 | +function read_php($text){ | |
1936 | + | |
1937 | + if(preg_match_all("/(eval>\[)([^\]]+)(\])/", $text, $matches, PREG_SET_ORDER)){ | |
1938 | + foreach($matches as $key=>$match){ | |
1939 | + | |
1940 | + $str = mb_convert_encoding($match[2],"UTF-8","auto"); | |
1941 | + if(isset($str) and !empty($str)){ | |
1942 | + | |
1943 | + if(ini_get('allow_url_fopen') == "1"){ | |
1944 | + | |
1945 | + try { | |
1946 | + | |
1947 | + $replacement = $this->script_on($str); | |
1948 | + | |
1949 | + $text= str_replace($matches[$key][0],$replacement,$text)."\n"; | |
1950 | + | |
1951 | + } catch (Exception $e) { | |
1952 | + echo '例外発生: ', $e->getMessage(), "\n"; | |
1953 | + } | |
1954 | + }else{ | |
1955 | + | |
1956 | + $text= str_replace($matches[$key][0],"<strong style=\"color:red\">変換できません</strong>",$text)."\n"; | |
1957 | + } | |
1958 | + | |
1959 | + | |
1960 | + } | |
1961 | + } | |
1962 | + } | |
1963 | +return $text; | |
1964 | +} | |
1965 | + | |
1966 | +function script_on($str){ | |
1967 | + | |
1968 | + if (eval("\$replacement = $str;") === false ){ | |
1969 | + throw new Exception(htmlspecialchars($str).' phpとして評価できません'); | |
1970 | + } | |
1971 | + | |
1972 | + return $replacement; | |
1973 | +} | |
1974 | + | |
1975 | + | |
1976 | +function repair_end($text){ | |
1977 | + $text = str_replace("<p>[block]</p>", "", $text); | |
1978 | + $text = str_replace("<p>[block]", "", $text); | |
1979 | + $text = str_replace("[block]\n</p>", "", $text); | |
1980 | + $text = preg_replace("/(<br \/>){2,}/", "<br />", $text); | |
1981 | + | |
1982 | + return $text; | |
1983 | + | |
1984 | +} | |
1985 | + | |
1986 | +function note($text,$separator = "\n"){ | |
1987 | + /* ------------------------------------------------------------ | |
1988 | + * フットノート | |
1989 | + *-------------------------------------------------------------*/ | |
1990 | + | |
1991 | + if(preg_match_all("/(《)([^》]+)(》)/su", $text, $matches, PREG_SET_ORDER)){ | |
1992 | + | |
1993 | + foreach($matches as $key=>$match){ | |
1994 | + | |
1995 | + $enc = mb_convert_encoding($match[2],"UTF-8","auto"); | |
1996 | + $replacement = "<a class=\"foot-note\" href=\"#foot-note-$key\" name=\"anchor-foot-note-$key\" id=\"anchor-foot-note-$key\" title=\"脚注へ移動\">[$key]</a>"; | |
1997 | + $text = str_replace($matches[$key][0],$replacement,$text)."\n"; | |
1998 | + | |
1999 | + array_push($this->footNote, array($key,"anchor-foot-note-$key","foot-note-$key",$enc)); | |
2000 | + } | |
2001 | + | |
2002 | + $code_hit = true; | |
2003 | + } | |
2004 | + | |
2005 | + return $text; | |
2006 | +} | |
2007 | + | |
2008 | +/*------------------------------------------------------------------------------+ | |
2009 | + * エンコーディング変更 $_GET['e']で切り替え | |
2010 | + *------------------------------------------------------------------------------*/ | |
2011 | + function result_encoding($text){ | |
2012 | + | |
2013 | + if(isset($_GET['e']) | |
2014 | + and ($_GET['e'] == "s" or | |
2015 | + $_GET['e'] == "e" or | |
2016 | + $_GET['e'] == "u" or | |
2017 | + $_GET['e'] == "j" )){ | |
2018 | + | |
2019 | + $e = $_GET['e']; | |
2020 | + switch ($e) { | |
2021 | + case "s": | |
2022 | + | |
2023 | + return mb_convert_encoding($text,"SHIFT_JIS","UTF-8"); | |
2024 | + | |
2025 | + break; | |
2026 | + case "e": | |
2027 | + return mb_convert_encoding($text,"UTF-8","UTF-8"); | |
2028 | + break; | |
2029 | + case "u": | |
2030 | + return $text; | |
2031 | + break; | |
2032 | + case "j": | |
2033 | + return mb_convert_encoding($text,"JIS","UTF-8"); | |
2034 | + break; | |
2035 | + | |
2036 | + default: | |
2037 | + return $text; | |
2038 | + } | |
2039 | + }else{ | |
2040 | + | |
2041 | + return $text; | |
2042 | + } | |
2043 | + } | |
2044 | + | |
2045 | + /* ------------------------------------------------------------ | |
2046 | + * 整形記号のチェック | |
2047 | + -------------------------------------------------------------*/ | |
2048 | + | |
2049 | + function basic_cleaner($buffer,$separator = "\n"){ | |
2050 | + | |
2051 | + global $parm; | |
2052 | + | |
2053 | + $buffer = mb_convert_encoding($buffer,"UTF-8","auto"); | |
2054 | + $file = explode($separator,$buffer); | |
2055 | + $text = ""; | |
2056 | + | |
2057 | + foreach($file as $key => $chk){ | |
2058 | + | |
2059 | + $chk = str_replace("\0", "", $chk); | |
2060 | + $chk = "\n$chk"; | |
2061 | + $chk = preg_replace("(^\s|\s{2,100}^\t| $| $|\.{2}\/)", "" , $chk); | |
2062 | + $chk = preg_replace("'([\r\n])[\s]+'", "\n", $chk); | |
2063 | + $chk = preg_replace("'([\r\n])[\s]+'", "\n", $chk); | |
2064 | + | |
2065 | + $text .= "\n$chk"; | |
2066 | + | |
2067 | + } | |
2068 | + | |
2069 | + return $text; | |
2070 | + } | |
2071 | +/*------------------------------------------------------------------------------+ | |
2072 | + * イメージサイズの検出 | |
2073 | + *------------------------------------------------------------------------------*/ | |
2074 | +function my_imagesize2($file, $wide ="width=\"200\"" ){ | |
2075 | + | |
2076 | + if(eregi("\.(gif|jpg|png|swc|psd|tiff|bmp|iff|jp2|jpx|jb2|jpc|xbm|wbmp)",$file)){ | |
2077 | + list($width, $height, $type, $attr) = getimagesize($file); | |
2078 | + return $attr; | |
2079 | + }else{ | |
2080 | + return $wide; | |
2081 | + } | |
2082 | +} | |
2083 | + | |
2084 | + | |
2085 | +/*------------------------------------------------------------------------------+ | |
2086 | + *ソースの表示 url等に、改行をはさんでオーバーフローを防止する。 | |
2087 | + *------------------------------------------------------------------------------*/ | |
2088 | + | |
2089 | +function my_wordwrap($str){ | |
2090 | + | |
2091 | + $wrap_width = TEXTTOHTML_CODE_WRAP_WIDTH; | |
2092 | + | |
2093 | + if(isset($wrap_width)){ | |
2094 | + $old = array(); | |
2095 | + $new = array(); | |
2096 | + preg_match_all("/([A-z0-9\/-_=\?:#;\.]+)/u", $str, $matches); | |
2097 | + $newtext = ""; | |
2098 | + $result = ""; | |
2099 | + foreach($matches as $match){ | |
2100 | + | |
2101 | + foreach($match as $line){ | |
2102 | + | |
2103 | + if(strlen($line) > $wrap_width){ | |
2104 | + $old[] = $line; | |
2105 | + $new[]= wordwrap($line, $wrap_width, "\n", 1); | |
2106 | + } | |
2107 | + } | |
2108 | + } | |
2109 | + | |
2110 | + $result = str_replace($old,$new,$str); | |
2111 | + | |
2112 | + return $this->tag_clear($result); | |
2113 | + }else{ | |
2114 | + | |
2115 | + return $str; | |
2116 | + } | |
2117 | +} | |
2118 | +/*------------------------------------------------------------------------------+ | |
2119 | + * ソースの簡易整形 | |
2120 | + *------------------------------------------------------------------------------*/ | |
2121 | +function style_set($str){ | |
2122 | + | |
2123 | + $tab = " "; | |
2124 | + $i = 0; | |
2125 | + $break = ""; | |
2126 | + $str = str_replace("<","@@@@@<",$str); | |
2127 | + $result =""; | |
2128 | + $lines = explode("@@@@@",$str); | |
2129 | + | |
2130 | + foreach($lines as $key=>$line){ | |
2131 | + | |
2132 | + if(preg_match("/(<\/?(xml|html|body))/mi",$line) ){ | |
2133 | + | |
2134 | + $i = 0; | |
2135 | + $space = str_repeat($tab,$i); | |
2136 | + $break = "<br />\n"; | |
2137 | + | |
2138 | + }elseif(preg_match("/(<\/?(xml|html|head|body|script|!doctype))/mi",$line) ){ | |
2139 | + | |
2140 | + $i = 2; | |
2141 | + $space = str_repeat($tab,$i); | |
2142 | + $break = "<br />\n"; | |
2143 | + }elseif(preg_match("/(<\/)/",$line) ){ | |
2144 | + | |
2145 | + if($i<0){ | |
2146 | + $i = 0; | |
2147 | + } | |
2148 | + | |
2149 | + $space = str_repeat($tab,$i); | |
2150 | + $break = "<br />\n"; | |
2151 | + $i--; | |
2152 | + }elseif(preg_match("/(\/>?)/",$line) ){ | |
2153 | + | |
2154 | + if($i<0){ | |
2155 | + $i = 0; | |
2156 | + } | |
2157 | + | |
2158 | + $space = str_repeat($tab,$i); | |
2159 | + $break = "<br />\n"; | |
2160 | + }else{ | |
2161 | + $break = "<br />\n"; | |
2162 | + | |
2163 | + if($i<0){ | |
2164 | + $i = 0; | |
2165 | + } | |
2166 | + | |
2167 | + $space = str_repeat($tab,$i); | |
2168 | + $i++; | |
2169 | + | |
2170 | + } | |
2171 | + | |
2172 | + $result .= $space.htmlspecialchars($line).$break; | |
2173 | + } | |
2174 | + | |
2175 | + return $this->tag_clear($result); | |
2176 | +} | |
2177 | + | |
2178 | + /* ------------------------------------------------------------ | |
2179 | + *タグ内の改行を削除 | |
2180 | + -------------------------------------------------------------*/ | |
2181 | + | |
2182 | +function tag_clear($text){ | |
2183 | + clearstatcache (); | |
2184 | + | |
2185 | +//行頭スペースを削除 全角スペース以外 | |
2186 | + $text = preg_replace("/(^[[:space:]]+)(.*)/m","\\2",$text); | |
2187 | + | |
2188 | +//複数の改行を、ひとつに。 | |
2189 | + $text = str_replace("\r","\n",$text); | |
2190 | + $text = preg_replace("/(\n){2,}/","\n\n",$text); | |
2191 | + | |
2192 | + return $text; | |
2193 | +} | |
2194 | + | |
2195 | +//end class | |
2196 | +} | |
2197 | + | |
2198 | + | |
2199 | +/////////////////////////////////////////////////////////////////////////////////// | |
2200 | +/////////////////////////////////////////////////////////////////////////////////// | |
2201 | + | |
2202 | +//配列キー文字数の多い順にソート uksort用 | |
2203 | + | |
2204 | + function text2html_cmp($a, $b){ | |
2205 | + $a = mb_strlen($a,"UTF-8"); | |
2206 | + $b = mb_strlen($b,"UTF-8"); | |
2207 | + | |
2208 | + //長い順 | |
2209 | + return strcasecmp($b,$a); | |
2210 | + } | |
2211 | + | |
2212 | + | |
2213 | +function postal_code($replacement){ | |
2214 | + | |
2215 | + $replacement = mb_convert_encoding($replacement,"UTF-8","auto"); | |
2216 | + if(preg_match("/(state=\")([^\"]+)/u",$replacement,$state) == 1){$state = $state[2];}else{$state = "";} | |
2217 | + | |
2218 | + if(preg_match("/(city=\")([^\"]+)/u",$replacement,$city) == 1){ | |
2219 | + $city = $city[2]; | |
2220 | + }else{ | |
2221 | + $city = ""; | |
2222 | + } | |
2223 | + if(preg_match("/(address=\")([^\"]+)/u",$replacement,$address) == 1){ | |
2224 | + $address = $address[2]; | |
2225 | + }else{ | |
2226 | + $address = ""; | |
2227 | + } | |
2228 | + if(preg_match("/(company=\")([^\"]+)/u",$replacement,$company) == 1){ | |
2229 | + $company = $company[2]; | |
2230 | + }else{ | |
2231 | + $company = ""; | |
2232 | + } | |
2233 | + | |
2234 | + if(preg_match("/(state_kana=\")([^\"]+)/u",$replacement,$state_kana) == 1){ | |
2235 | + $state_kana = $state_kana[2]; | |
2236 | + }else{ | |
2237 | + $state_kana = ""; | |
2238 | + } | |
2239 | + if(preg_match("/(city_kana=\")([^\"]+)/u",$replacement,$city_kana) == 1){ | |
2240 | + $city_kana = $city_kana[2]; | |
2241 | + }else{ | |
2242 | + $city_kana = ""; | |
2243 | + } | |
2244 | + if(preg_match("/(address_kana=\")([^\"]+)/u",$replacement,$address_kana) == 1){ | |
2245 | + $address_kana= $address_kana[2]; | |
2246 | + }else{ | |
2247 | + $address_kana= ""; | |
2248 | + } | |
2249 | + if(preg_match("/(company_kana=\")([^\"]+)/u",$replacement,$company_kana) == 1){ | |
2250 | + $company_kana= $company_kana[2]; | |
2251 | + }else{ | |
2252 | + $company_kana= ""; | |
2253 | + } | |
2254 | + | |
2255 | +$title = "title=\"".$state_kana.$city_kana.$address_kana.$company_kana."\""; | |
2256 | + | |
2257 | +return str_replace("none","","<span $title>".$state.$city.$address.$company."</span>"); | |
2258 | + | |
2259 | +} | |
2260 | + | |
2261 | + | |
2262 | +//wikipedia | |
2263 | + function simpleapi_wikipedia($replacement, $count = 1){ | |
2264 | + | |
2265 | + $result = unserialize($replacement); | |
2266 | + $results = "<div style=\"margin:1em;\">"; | |
2267 | + | |
2268 | + for($i=0;$i<$count;$i++){ | |
2269 | + | |
2270 | + $title = $result[$i]['title']; | |
2271 | + $body = $result[$i]['body']; | |
2272 | + $results .= "<strong>Wikipedia:{$title}</strong><blockquote>".nl2br($body)."</blockquote>"; | |
2273 | + } | |
2274 | + | |
2275 | + return str_replace(array("<br>","<br/>"),"<br />",$results)."\n</div>"; | |
2276 | + } | |
2277 | + | |
2278 | +//////////////////////////////////////////////////////////////////////////////////// | |
2279 | +function use_cache($name){ | |
2280 | + | |
2281 | + if(!defined('CACHE_LITE_PATH')){return array(false,"");} | |
2282 | + | |
2283 | + require_once(CACHE_LITE_PATH); | |
2284 | + | |
2285 | + $options = array( | |
2286 | + 'cacheDir' => CACHE_DIR_PATH, | |
2287 | + 'lifeTime' => CACHE_LIFE_TIME, | |
2288 | + ); | |
2289 | + | |
2290 | + $Cache_Lite = new Cache_Lite($options); | |
2291 | + | |
2292 | + if(!CACHE_SWITCH){ | |
2293 | + | |
2294 | + $Cache_Lite->clean(); | |
2295 | + return array(false,""); | |
2296 | + } | |
2297 | + | |
2298 | + $name = md5($name); | |
2299 | + | |
2300 | + if ($data = $Cache_Lite->get($name)){ | |
2301 | + $result = $data; | |
2302 | + $flag = true; | |
2303 | + }else { | |
2304 | + | |
2305 | + $flag = false; | |
2306 | + } | |
2307 | + | |
2308 | + return array($flag,$data); | |
2309 | +} | |
2310 | + | |
2311 | +function save_cache($name,$value){ | |
2312 | + | |
2313 | + if(!defined('CACHE_LITE_PATH')){return array(false,$value);} | |
2314 | + | |
2315 | + $name = md5($name); | |
2316 | + | |
2317 | + require_once(CACHE_LITE_PATH); | |
2318 | + | |
2319 | + $options = array( | |
2320 | + 'cacheDir' => CACHE_DIR_PATH, | |
2321 | + 'lifeTime' => CACHE_LIFE_TIME, | |
2322 | + ); | |
2323 | + | |
2324 | + $Cache_Lite = new Cache_Lite($options); | |
2325 | + | |
2326 | + if(!CACHE_SWITCH){ | |
2327 | + | |
2328 | + $Cache_Lite->clean(); | |
2329 | + return array(false,$value); | |
2330 | + } | |
2331 | + | |
2332 | + if ($data = $Cache_Lite->get($name)){ | |
2333 | + $result = $data; | |
2334 | + $flag = true; | |
2335 | + }else { | |
2336 | + | |
2337 | + $Cache_Lite->save($value,$name); | |
2338 | + //print_r($Cache_Lite); | |
2339 | + $result = $value; | |
2340 | + $flag = false; | |
2341 | + } | |
2342 | + | |
2343 | + return array($flag,$value); | |
2344 | +} | |
2345 | + | |
2346 | +function html_document1($ini_array,$documents,$navi="",$source = ""){ | |
2347 | + | |
2348 | + global $content_name; | |
2349 | + global $source; | |
2350 | + global $campany_data; | |
2351 | + | |
2352 | + $charset = $ini_array['html_header']['charset']; | |
2353 | + $author = $ini_array['html_header']['author']; | |
2354 | + $keyword = $ini_array['html_header']['keyword']; | |
2355 | + $description = $ini_array['html_header']['description']; | |
2356 | + $mail = $ini_array['html_header']['mail']; | |
2357 | + $stylesheet = $ini_array['html_header']['stylesheet']; | |
2358 | + $style_media = $ini_array['html_header']['style_media']; | |
2359 | + $navi_start = $ini_array['html_header']['start']; | |
2360 | + $navi_prev = $ini_array['html_header']['prev']; | |
2361 | + $navi_next = $ini_array['html_header']['next']; | |
2362 | + $navi_help = $ini_array['html_header']['help']; | |
2363 | + $title = $ini_array['html_header']['title']; | |
2364 | + $embed = $ini_array['html_header']['embed']; | |
2365 | + | |
2366 | +$html=<<<DOC | |
2367 | +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | |
2368 | + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
2369 | +<html lang="ja" xml:lang="ja" xmlns="http://www.w3.org/1999/xhtml"> | |
2370 | +<head> | |
2371 | + <meta http-equiv="content-type" content="text/html; charset=$charset" /> | |
2372 | + <meta http-equiv="content-script-type" content="text/javascript" /> | |
2373 | + <meta http-equiv="content-style-type" content="text/css" /> | |
2374 | + <meta name="author" content="$author" /> | |
2375 | + <meta name="keywords" content="$keyword" /> | |
2376 | + <meta name="description" content="$description" /> | |
2377 | + <link rev="made" href="mailto:$mail" /> | |
2378 | + <link rel="stylesheet" href="$stylesheet" media="$style_media" type="text/css" /> | |
2379 | + <link rel="start" href="$navi_start" /> | |
2380 | + <link rel="prev" href="$navi_prev" /> | |
2381 | + <link rel="next" href="$navi_next" /> | |
2382 | + <link rel="help" href="$navi_help" /> | |
2383 | + <title>$title</title> | |
2384 | + <script src="/js/jquery.js" type="text/javascript"></script> | |
2385 | + <script src="/js/jquery.flatheights.js" type="text/javascript"></script> | |
2386 | + <link rel="stylesheet" href="/js/ui.tabs.css" type="text/css" | |
2387 | + media="print, projection, screen" /> | |
2388 | + <link rel="stylesheet" type="text/css" href="/js/jquery.jcarousel.css" /> | |
2389 | + <link rel="stylesheet" type="text/css" href="/js/skins/tango/skin.css" /> | |
2390 | + $embed | |
2391 | +</head> | |
2392 | +<body id="top"> | |
2393 | +<div id="wrap"> | |
2394 | +<div id="header"> | |
2395 | +<h1>$title</h1> | |
2396 | +</div> | |
2397 | +<div id="common"> | |
2398 | +$navi | |
2399 | +$documents | |
2400 | +$source | |
2401 | +</div> | |
2402 | +<div id="footer"> | |
2403 | +2008©$title | |
2404 | +</div> | |
2405 | +</div> | |
2406 | +</body> | |
2407 | +</html> | |
2408 | +DOC; | |
2409 | + | |
2410 | +$html = str_replace(array("<br >","<br>"),"<br />",$html); | |
2411 | + | |
2412 | +echo $html; | |
2413 | +} | |
2414 | + | |
2415 | +?> | |
\ No newline at end of file |
@@ -0,0 +1,172 @@ | ||
1 | +;$buffer = $this->text2html_code($buffer,"\n","pre",'code:','code','','class="source"','souce') | |
2 | +;<meta http-equiv="content-type" content="text/html; charset=utf-8" /> | |
3 | + | |
4 | +[html_header] | |
5 | + | |
6 | +charset = "UTF-8" | |
7 | +title = "テキデコ text2html" | |
8 | +author = "Tenman" | |
9 | +keyword = "ddd" | |
10 | +description = "ddd" | |
11 | +mail = "tenman@users.sourceforge.jp" | |
12 | +stylesheet = "css/toppage.css" | |
13 | +style_media = "all" | |
14 | +start = "/" | |
15 | +prev = "prev.html" | |
16 | +next = "next.html" | |
17 | +help = "help.html" | |
18 | + | |
19 | +embed =""" | |
20 | +<style type='text/css'> | |
21 | +/*<![CDATA[*/ | |
22 | +body{ | |
23 | + text-align:center; | |
24 | + background:#eee; | |
25 | + margin:0; | |
26 | + padding:0; | |
27 | +} | |
28 | + | |
29 | + | |
30 | + | |
31 | +#common{ | |
32 | + text-align:left; | |
33 | + width:776px; | |
34 | + margin:0 auto; | |
35 | + background:#fff; | |
36 | + padding:30px; | |
37 | + | |
38 | +} | |
39 | + | |
40 | + | |
41 | +#head_line{ | |
42 | + padding:1em; | |
43 | + border:1px solid #aaf; | |
44 | + background:#eee; | |
45 | +} | |
46 | + | |
47 | + | |
48 | + | |
49 | + | |
50 | +/*table{ | |
51 | + width:100%; | |
52 | +} | |
53 | + | |
54 | + | |
55 | +td{ | |
56 | + background:#fff; | |
57 | + border:1px solid #aaf; | |
58 | +}*/ | |
59 | + | |
60 | + | |
61 | +blockquote{ | |
62 | + background:#eee; | |
63 | + border:1px solid #aaf; | |
64 | + padding:1em; | |
65 | +} | |
66 | + | |
67 | + | |
68 | +code{ | |
69 | + border:0px solid #ccc; | |
70 | + margin:0;padding:0; | |
71 | +} | |
72 | + | |
73 | + | |
74 | +pre{ | |
75 | + background:#eef; | |
76 | + padding:20px; | |
77 | + width:600px; | |
78 | + overflow:auto; | |
79 | + | |
80 | +} | |
81 | + | |
82 | + | |
83 | + | |
84 | +#TOP{ | |
85 | + /* height:0;display:none;*/ | |
86 | +} | |
87 | + | |
88 | + | |
89 | +#entry1{ | |
90 | + width:700px!important; | |
91 | + border:0px solid #ccc; | |
92 | +} | |
93 | + | |
94 | + | |
95 | +#navigation{ | |
96 | + float:left; | |
97 | + position:relative; | |
98 | + width:160px; | |
99 | +} | |
100 | + | |
101 | + | |
102 | +.entryes{ | |
103 | + margin-left:180px; | |
104 | + width:700px; | |
105 | + overflow:auto; | |
106 | +} | |
107 | + | |
108 | + | |
109 | + | |
110 | + | |
111 | +img{ | |
112 | + border:none;margin:0; | |
113 | +} | |
114 | + | |
115 | + | |
116 | +ul li{ | |
117 | + list-style-type:none; | |
118 | +} | |
119 | + | |
120 | + | |
121 | +.gmaps{ | |
122 | + display:inline; | |
123 | +} | |
124 | + | |
125 | + | |
126 | +div{ | |
127 | + border:0px solid #ccc; | |
128 | +} | |
129 | + | |
130 | + | |
131 | +.text2image{ | |
132 | + border:0px solid #000; | |
133 | +} | |
134 | + | |
135 | + | |
136 | + | |
137 | +#nav { | |
138 | + border-bottom:1px solid #ccc; | |
139 | + overflow:hidden; | |
140 | +} | |
141 | +#nav li{ | |
142 | + float:left; | |
143 | + margin:0 1px; | |
144 | + padding:3px 5px; | |
145 | + border:1px solid #ccc; | |
146 | + background:#fff; | |
147 | + | |
148 | +} | |
149 | + | |
150 | +#article{ | |
151 | + clear:both; | |
152 | +} | |
153 | +.calendar-layout{ | |
154 | + | |
155 | + | |
156 | +} | |
157 | +.calendar-layout{ | |
158 | + | |
159 | + | |
160 | +} | |
161 | +.calendar-layout li{ | |
162 | + | |
163 | + width:220px; | |
164 | + border:1px solid #000; | |
165 | + padding:10px; | |
166 | + float:left; | |
167 | + margin:10px; | |
168 | + overflow:hidden; | |
169 | + | |
170 | +} | |
171 | +/*]]>*/ | |
172 | +</style>""" |
@@ -0,0 +1,21 @@ | ||
1 | +text2html 「てきでこ」をダウンロードいただきありがとうございます。 | |
2 | + | |
3 | + | |
4 | +機能と要件 | |
5 | + | |
6 | +機能 テキストファイル、xmlファイル、外部API、編集エリア内でのインライン置換による、編集作業補完とその共有を主な機能とします。 | |
7 | +要件 必須:PHP5 マルチバイト文字列関数 推奨:GD2 PEAR Cache/Lite BenchMark | |
8 | +使用例とスクリーンショット | |
9 | +DEMOは、現在www.tenman.infoにて行っております。どのようなものか、簡単なドキュメントもありますので、よろしければ、ご覧ください。 | |
10 | + | |
11 | +ダウンロードしたファイルを、アップロードしていただき、httpでアクセスしてください。 | |
12 | +説明書ドキュメントが表示されます。 | |
13 | +不足する機能があるときには、説明書ドキュメントの代わりに、メッセージが出ます。 | |
14 | + | |
15 | +wordspress2.6 frog0.92は、それぞれのプラグインディレクトリにおいていただいて、通常のプラグインと同様に有効にしていただければ、動作します。 | |
16 | + | |
17 | +imagesディレクトリのパーミッションは、777または、707に設定してください。 | |
18 | + | |
19 | +詳細は、http://text2html.sourceforge.jp/にあるドキュメントを参照してください。 | |
20 | + | |
21 | +連絡先: tenman@users.sourceforge.jp |
@@ -0,0 +1,45 @@ | ||
1 | +<?php | |
2 | + | |
3 | +class text2html | |
4 | +{ | |
5 | + var $change_text = array(); | |
6 | + var $ini_array = array(); | |
7 | + | |
8 | + function apply($text){ | |
9 | + | |
10 | + //$text2html_url と $text2html_dir_pathは必ず設定してください。 | |
11 | + //このディレクトリまでの絶対パスとURL | |
12 | + | |
13 | + $text2html_url = ""; | |
14 | + | |
15 | + $text2html_dir_path = ""; | |
16 | + | |
17 | + include_once(CORE_ROOT."/plugins/text2html/scripts/trans.php"); | |
18 | + | |
19 | + $this->change_text = file(CORE_ROOT."/plugins/text2html/data/change.txt"); | |
20 | + | |
21 | + foreach($this->change_text as $loop){ | |
22 | + | |
23 | + if(strpos($loop,'#')){ | |
24 | + list($before,$after) = explode('#',$loop); | |
25 | + | |
26 | + $a[] = trim($after); | |
27 | + $b[] = $before; | |
28 | + } | |
29 | + | |
30 | + } | |
31 | + | |
32 | + $text = str_replace($b,$a,$text); | |
33 | + | |
34 | + | |
35 | + $ini_array = parse_ini_file(CORE_ROOT."/plugins/text2html/scripts/html.ini", true); | |
36 | + $benchmark = false; | |
37 | + $obj = new trans($text); | |
38 | + $documents = $obj->text2html(); | |
39 | + | |
40 | + return $documents; | |
41 | + | |
42 | + } | |
43 | +} | |
44 | + | |
45 | +?> | |
\ No newline at end of file |
@@ -0,0 +1,3 @@ | ||
1 | +[日付]#eval>[date("Y年m月d日");] | |
2 | +[議事録テンプレート00001]#eval>[file_get_contents("http://127.0.0.1/templates/gijiroku.html")] | |
3 | +[カレンダーテンプレート]#eval>[file_get_contents("http://tenman.s62.coreserver.jp/example/template/calendar/")] |
@@ -0,0 +1,10 @@ | ||
1 | +<?xml version="1.0" encoding="utf-8"?><change> | |
2 | +<dl> | |
3 | +<dt>[alert]</dt> | |
4 | +<dd><strong style="color:red">!</strong></dd> | |
5 | +</dl> | |
6 | +<dl> | |
7 | +<dt>[名簿]</dt> | |
8 | +<dd><table width="480" border="1" cellspacing="1" cellpadding="1" style="empty-cells: show; "><tr><td colspan="4"><nobr>フリガナ</nobr></td><td width="107" style="border-right:none"><!--%フリガナ姓%--></td><td colspan="2" style="border-left:none"><!--%フリガナ名%--></td><td width="28"> </td><td width="39">印</td><td width="106" rowspan="3"><!--%写真%--></td></tr><tr><td height="58" colspan="4"><nobr>氏名</nobr></td><td style="border-right:none"><!--%姓%--></td><td colspan="2" style="border-left:none"><!--%名%--></td><td colspan="2"> </td></tr><tr><td colspan="4"><nobr>生年月日</nobr></td><td><!--%生年月日%--></td><td width="83"> </td><td width="30"><nobr>性別</nobr></td><td colspan="2"><!--%性別%--></td></tr></table><table width="480" border="1" cellspacing="1" cellpadding="1" style="empty-cells: show; "><tr><td width="66"><nobr>フリガナ</nobr></td><td colspan="3"><!--%フリガナ住所%--></td><td width="117">TEL</td></tr><tr><td><nobr>現住所</nobr></td><td width="103">〒 <!--%郵便番号%--></td><td width="87"></td><td width="115"> </td><td><!--%TEL%--></td></tr><tr><td colspan="4"><!--%住所%--></td><td><nobr>FAX</nobr></td></tr><tr><td><nobr>携帯電話</nobr></td><td><!--%携帯電話%--></td><td width="43">メール</td><td width="123"><!--%メールアドレス%--></td><td><!--%FAX%--></td></tr></table><table width="480" border="1" cellspacing="1" cellpadding="1"><tr><td width="66">日付</td><td width="289">内容</td><td width="117">備考</td></tr><tr><td><!--%日付1%--></td><td><!--%内容1%--></td><td><!--%備考1%--></td></tr><tr><td><!--%日付2%--></td><td><!--%内容2%--></td><td><!--%備考2%--></td></tr><tr><td><!--%日付3%--></td><td><!--%内容3%--></td><td><!--%備考3%--></td></tr><tr><td><!--%日付4%--></td><td><!--%内容4%--></td><td><!--%備考4%--></td></tr><tr><td><!--%日付5%--></td><td><!--%内容5%--></td><td><!--%備考5%--></td></tr><tr><td><!--%日付6%--></td><td><!--%内容6%--></td><td><!--%備考6%--></td></tr><tr><td><!--%日付7%--></td><td><!--%内容7%--></td><td><!--%備考7%--></td></tr><tr><td><!--%日付8%--></td><td><!--%内容8%--></td><td><!--%備考8%--></td></tr><tr><td><!--%日付9%--></td><td><!--%内容9%--></td><td><!--%備考9%--></td></tr><tr><td><!--%日付10%--></td><td><!--%内容10%--></td><td><!--%備考10%--></td></tr><tr><td><!--%日付11%--></td><td><!--%内容11%--></td><td><!--%備考11%--></td></tr><tr><td><!--%日付12%--></td><td><!--%内容12%--></td><td><!--%備考12%--></td></tr></table></dd> | |
9 | +</dl> | |
10 | +</change> | |
\ No newline at end of file |
@@ -0,0 +1,18 @@ | ||
1 | +<?php | |
2 | +if(class_exists('Plugin')){ | |
3 | +Plugin::setInfos(array( | |
4 | + 'id' => 'text2html', | |
5 | + 'title' => 'text 2html', | |
6 | + 'description' => 'text2html', | |
7 | + 'version' => '1.0', | |
8 | + 'website' => 'http://www.tenman.info/') | |
9 | +); | |
10 | + | |
11 | +Filter::add('text2html', 'text2html/filter_text2html.php'); | |
12 | + | |
13 | +}else{ | |
14 | + | |
15 | +include("hello.php"); | |
16 | + | |
17 | +} | |
18 | +?> | |
\ No newline at end of file |
@@ -0,0 +1,69 @@ | ||
1 | +<?php | |
2 | +/* | |
3 | +Plugin Name: text2html-wordpress | |
4 | +Plugin URI: http://www.tenman.info/ | |
5 | +Description:text2html | |
6 | +Version: 1 | |
7 | +Author:akio tenman | |
8 | +Author URI: http://www.tenman.info/ | |
9 | +*/ | |
10 | + | |
11 | +/* wp-includes/formatting.php | |
12 | + * pタグをwordpress で 自動付与し内容に、許可を取り消す。 | |
13 | + *---------------------------------------------------------*/ | |
14 | +unset($allowedposttags['p']); | |
15 | +remove_filter ('the_content', 'wpautop'); | |
16 | +remove_filter ('the_content', 'wptexturize'); | |
17 | + | |
18 | +add_filter('the_content','apply'); | |
19 | +add_filter('the_excerpt','apply'); | |
20 | +add_filter('the_content_rss','apply'); | |
21 | + | |
22 | +add_filter ('the_content', 'wpautop'); | |
23 | +add_filter ('the_content', 'wptexturize'); | |
24 | + | |
25 | + | |
26 | +function apply($text){ | |
27 | + | |
28 | + $text2html_url = WP_PLUGIN_URL."/text2html/"; | |
29 | + $text2html_dir_path = WP_PLUGIN_DIR."/text2html/"; | |
30 | + //$text = mb_convert_encoding($text,"UTF-8","auto"); | |
31 | + | |
32 | +/* wp-includes/formatting.php | |
33 | + *$static_characters 変換対象が記法に影響する場合は、元に戻す。 | |
34 | + * | |
35 | + *eval>[date("ymd")]は、date(”ymd”)になり機能しません | |
36 | + *<<は< <に置換されますから、ワードプレスでは、記法として使えません。 | |
37 | + *---------------------------------------------------------*/ | |
38 | +$text = str_replace(array("—","–","”","<p>","</p>","<br />","\:",">"),array("---","--",'"',"","","\n",':','>'),$text); | |
39 | + | |
40 | + include_once($text2html_dir_path."scripts/trans.php"); | |
41 | + | |
42 | + $change_text = file($text2html_url."data/change.txt"); | |
43 | + | |
44 | + foreach($change_text as $loop){ | |
45 | + | |
46 | + if(strpos($loop,'#')){ | |
47 | + list($before,$after) = explode('#',$loop); | |
48 | + $a[] = $after; | |
49 | + $b[] = $before; | |
50 | + } | |
51 | + | |
52 | + } | |
53 | + $text = str_replace($b,$a,$text); | |
54 | + | |
55 | + $use_web_option = true; | |
56 | + $ini_array = parse_ini_file($text2html_dir_path."scripts/html.ini", true); | |
57 | + $ini_array =""; | |
58 | + $benchmark = false; | |
59 | + $source = false; | |
60 | + $obj = new trans($text); | |
61 | + $content_name = "main"; | |
62 | + $documents = $obj->text2html(); | |
63 | + | |
64 | + return $documents; | |
65 | + | |
66 | + } | |
67 | + | |
68 | + | |
69 | +?> | |
\ No newline at end of file |
@@ -0,0 +1,120 @@ | ||
1 | +body{ | |
2 | + text-align:center; | |
3 | + margin:0; | |
4 | + padding:0; | |
5 | + background:#eee; | |
6 | + color:#334; | |
7 | + | |
8 | + } | |
9 | +#header h1{color:navy;text-indent:1em;font-family:Geneva, Arial, Helvetica, sans-serif;display:block;background:none;padding-top:1em;} | |
10 | +#wrap{ | |
11 | +width:960px; | |
12 | + background:; | |
13 | + margin:0 auto; | |
14 | + background:#eee url('../images/page.png'); | |
15 | + | |
16 | +} | |
17 | +#common{ | |
18 | + margin:0 20px 20px 20px; | |
19 | + | |
20 | + | |
21 | +text-align:left; | |
22 | + | |
23 | + } | |
24 | +#header{ | |
25 | +height:100px; | |
26 | +background:#eee url('../images/logo.gif') no-repeat top left;background-repeat:no-repeat; | |
27 | +} | |
28 | + | |
29 | +#bread_crumb{ | |
30 | + padding:5px 30px; | |
31 | +} | |
32 | +#article{ | |
33 | + margin:2em; | |
34 | + | |
35 | +} | |
36 | +#company{ | |
37 | + margin:2em; | |
38 | + | |
39 | +} | |
40 | +#fragment-1{ | |
41 | + padding:30px; | |
42 | + | |
43 | +} | |
44 | +#fragment-2 table{ | |
45 | + width:100%; | |
46 | +} | |
47 | +#fragment-2 table *{ | |
48 | +border:0px solid #ccc; | |
49 | + | |
50 | +} | |
51 | +#footer{ | |
52 | + | |
53 | + clear:both; | |
54 | + text-align:center; | |
55 | + height:60px; | |
56 | + overflow:hidden; | |
57 | + padding:10px 30px; | |
58 | + | |
59 | + | |
60 | +} | |
61 | +.bar{ | |
62 | + height:60px; | |
63 | + color:#000; | |
64 | +} | |
65 | +#content{ | |
66 | +min-height:400px; | |
67 | + | |
68 | +margin:0 50px; | |
69 | + | |
70 | +} | |
71 | +#title{ | |
72 | + | |
73 | + /* position:absolute; | |
74 | + top:50%; | |
75 | + left:50%; | |
76 | + margin-top:-50px; | |
77 | + margin-left:-100px;*/ | |
78 | +} | |
79 | +table{ | |
80 | + | |
81 | +background#aaf; | |
82 | +} | |
83 | +ul{margin:10px 30px;} | |
84 | +.page{display:none;position:absolute;} | |
85 | +.ui-tabs-nav{background:inherit;} | |
86 | + | |
87 | + | |
88 | + | |
89 | +/** | |
90 | + * Overwrite for having a carousel with dynamic width. | |
91 | + */ | |
92 | +.jcarousel-skin-tango.jcarousel-container-horizontal { | |
93 | + width: 240px; | |
94 | + | |
95 | + /*外枠 -85px 補正*/ | |
96 | +} | |
97 | + | |
98 | +.jcarousel-skin-tango .jcarousel-clip-horizontal { | |
99 | + width: 100%; | |
100 | + /*うちわく*/ | |
101 | + | |
102 | +} | |
103 | + | |
104 | +#mycarousel a{display:none;} | |
105 | + | |
106 | +content-1,content-2,content-3,content-4,content-5{background:url(images/top-image.png);background-repeat:no-repeat;background-position:0 20px;} | |
107 | +#result{width:600px;min-height:375px;border:0px solid #ccc;float:right;} | |
108 | + | |
109 | +#news{ | |
110 | + | |
111 | + | |
112 | +} | |
113 | +#news li{ | |
114 | +list-style:none; | |
115 | + | |
116 | +} | |
117 | +h2{ | |
118 | +padding:4px 12px;background:inherit;border-bottom:1px solid #aaf; | |
119 | +font-size:125%; | |
120 | +} |