ページへ戻る

− Links

 印刷 

MyTextSanitizer (まい・てきすと・さにたいざぁ) :: XOOPS マニア

xpwiki:keyword/MyTextSanitizer


ページ内コンテンツ
  • MyTextSanitizer (まい・てきすと・さにたいざぁ)
    • XOOPS Cube Legacy 2.1.x 〜 2.2.0 用
    • XOOPS 2.0.16a JP 用
  • Wikiヘルパーをテキストエリアに表示する方法
    • まずはじめに
      • 選択その1 (ブロックの配置)
      • 選択その2

MyTextSanitizer (まい・てきすと・さにたいざぁ) anchor.png[4]

XOOPS[5], XOOPS[5] Cube Legacy において、登録されたテキストを整形し表示するクラス。

このクラスに変更を加えることで、その XOOPS[5] 全体に渡り、テキスト整形のルールを変更することができる。

ここ XOOPS[5]マニア のサイトでは、xpWiki[6] のWikiレンダリング機能を使って、テキスト整形するように変更が加えられています。

Page Top

XOOPS[5] Cube Legacy 2.1.x 〜 2.2.0 用 anchor.png[7]

XOOPS[5] Cube Legacy 2.2.1 beta3 以降では、HypCommonFunc[8] に含まれている HypConf(HypCommonの設定) モジュールの「xpWiki[6]レンダラー設定」で 「xpWiki[6] レンダラー」にて利用したい xpWiki[6] を選択するだけで有効にできるようになりました。

あわせて HypConf モジュールでは、サイトワイド Wiki ヘルパーの設定もできるようになっています。

XOOPS[5] Cube Legacy 用には、本来ならプリロードだけで完結するようにすべきだとは思いますが、X2用モジュールとの互換性を保つために、module.textsanitizer.php を書き換える方法にしました。

XOOPS_ROOT_PATH[9]/class/module.textsanitizer.php を置き換え、XOOPS_ROOT_PATH[9]/preload/SetupHyp_TextFilter.class.php を配置してください。

Cube に対応させるために、XUGJ にて Marijuana さんにいろいろ教えていただきました。[10] :ok:

  • fileXOOPS_ROOT_PATH/class/module.textsanitizer.php[11] (2.1.x 用)
  • fileXOOPS_ROOT_PATH/class/module.textsanitizer.php[12] (2.2.x 用)
    • 変更箇所のみ
       1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      22
      23
      24
      25
      26
      27
      28
      29
      30
      31
      32
      33
      34
      35
      36
      
          /**
           * Filters textarea form data in DB for display
           *
           * @param   string  $text
           * @param   bool    $html   allow html?
           * @param   bool    $smiley allow smileys?
           * @param   bool    $xcode  allow xoopscode?
           * @param   bool    $image  allow inline images?
           * @param   bool    $br     convert linebreaks?
           * @return  string
           **/
          function &displayTarea($text, $html = 0, $smiley = 1, $xcode = 1, $image = 1, $br = 1)
          {
              //$text = $this->_ToShowTarea($text, $html, $smiley, $xcode, $image, $br);
              $text = $this->mTextFilter->ToShowTarea($text, $html, $smiley, $xcode, $image, $br, true, 1);
              return $text;
          }
       
          /**
           * Filters textarea form data submitted for preview
           *
           * @param   string  $text
           * @param   bool    $html   allow html?
           * @param   bool    $smiley allow smileys?
           * @param   bool    $xcode  allow xoopscode?
           * @param   bool    $image  allow inline images?
           * @param   bool    $br     convert linebreaks?
           * @return  string
           **/
          function &previewTarea($text, $html = 0, $smiley = 1, $xcode = 1, $image = 1, $br = 1)
          {
              $text =& $this->stripSlashesGPC($text);
              //$text = $this->_ToShowTarea($text, $html, $smiley, $xcode, $image, $br);
              $text = $this->mTextFilter->ToShowTarea($text, $html, $smiley, $xcode, $image, $br, true, 0);
              return $text;
          }
  • fileXOOPS_ROOT_PATH/preload/SetupHyp_TextFilter.class.php[13]
    • 2008/1/26 に修正しました。(BBコードの[siteurl]に対応。要 xpWiki[6] 3.59 以上)
    • 2008/4/30 と 5/3 に修正しました。(BBコードの[img]が正常に変換できないことがある問題を修正)
    • 2008/5/30 に修正しました。(BBコードの siteimage, fig が正常に動作するようにした)
    • 2008/5/31 に typo 修正しました。参考スレッド[14]
    • 2008/10/9 xpWiki[6] のディレクトリ名指定を定数 XPWIKI_RENDERER_DIR を使う方式としました。
      • xpWiki[6] Ver 3.71.83 で搭載された画面変遷のないファイル添付とファイル名挿入に対応した。
    • 2008/10/11 10/9 の修正でCSSが効かなくなっていたのを修正しました。
    • 2008/12/22 PHP 4 環境で Warning エラーが出ていたのを修正しました。 (thx nonn50[15])
    • 2009/5/3 [quote]を使用した場合に、HTML構造が不正になることがある問題を修正しました。
    • 2009/5/12 5/3 の修正が原因で、レンダリング内容によっては、PHPがエラーで止まってしまうことがある問題を修正しました。(thx azumi)
      fileSetupHyp_TextFilter.class.php[16]
        1
        2
        3
        4
        5
        6
        7
        8
        9
       10
       11
       12
       13
       14
       15
       16
       17
       18
       19
       20
       21
       22
       23
       24
       25
       26
       27
       28
       29
       30
       31
       32
       33
       34
       35
       36
       37
       38
       39
       40
       41
       42
       43
       44
       45
       46
       47
       48
       49
       50
       51
       52
       53
       54
       55
       56
       57
       58
       59
       60
       61
       62
       63
       64
       65
       66
       67
       68
       69
       70
       71
       72
       73
       74
       75
       76
       77
       78
       79
       80
       81
       82
       83
       84
       85
       86
       87
       88
       89
       90
       91
       92
       93
       94
       95
       96
       97
       98
       99
      100
      101
      102
      103
      104
      105
      106
      107
      108
      109
      110
      111
      112
      113
      114
      115
      116
      117
      118
      119
      120
      121
      122
      123
      124
      125
      126
      127
      128
      129
      130
      131
      132
      133
      134
      135
      136
      137
      138
      139
      140
      141
      142
      143
      144
      145
      146
      147
      148
      149
      150
      151
      152
      153
      154
      155
      156
      157
      158
      159
      160
      161
      162
      163
      164
      165
      166
      167
      168
      169
      170
      171
      172
      173
      174
      175
      176
      177
      178
      179
      180
      181
      182
      183
      184
      185
      186
      187
      188
      189
      190
      191
      192
      193
      194
      195
      196
      197
      198
      199
      200
      201
      202
      203
      204
      205
      206
      207
      208
      209
      
      <?php
       
      if (!defined('XOOPS_ROOT_PATH[9]')) exit();
       
      // xpWiki[6] wikirenderer dirctory name
      define('XPWIKI_RENDERER_DIR', 'xpwiki[6]');
       
      class SetupHyp_TextFilter extends XCube_ActionFilter
      {
          function preFilter()
          {
              $this->mController->mSetupTextFilter->add('Hyp_TextFilter::getInstance', XCUBE_DELEGATE_PRIORITY_FINAL-2);
          }
      }
       
      class Hyp_TextFilter extends Legacy_TextFilter
      {
          function Hyp_TextFilter() {
              parent::Legacy_TextFilter();
              $this->mMakeXCodeConvertTable->add('Hyp_TextFilter::makeXCodeConvertTable', XCUBE_DELEGATE_PRIORITY_3);
          }
       
          function makeXCodeConvertTable(& $patterns, & $replacements) {
              if ($key = array_search('/\[quote\]/sU', $patterns)) {
                  $replacements[0][$key] = $replacements[1][$key] = '<div class="paragraph">'._QUOTEC.'<div class="xoopsQuote"><blockquote>';
              }
              if ($key = array_search('/\[\/quote\]/sU', $patterns)) {
                  $replacements[0][$key] = $replacements[1][$key] = '</blockquote></div></div>';
              }
              $patterns[] = "/\[quote sitecite=([^\"'<>]*)\]/sU";
              $replacements[0][] = $replacements[1][] = '<div class="paragraph">'._QUOTEC.'<div class="xoopsQuote"><blockquote cite="'.XOOPS_URL.'/\\1">';
          }
          
          // Over write
          function getInstance(&$instance) {
              if (empty($instance)) {
                  $instance = new Hyp_TextFilter();
              }
          }
          
          // Over write
          function toShowTarea($text, $html = 0, $smiley = 1, $xcode = 1, $image = 1, $br = 1, $x2comat = false, $cache = 1) {
              if ($html != 1) {
                  $text = $this->renderWikistyle($text, $html, $smiley, $xcode, $image, $br, $cache);
              } else {
                  $text = $this->preConvertXCode($text, $xcode);
                  $text = $this->makeClickable($text);
                  if ($smiley != 0) $text = $this->smiley($text);
              }
              if ($xcode != 0) $text = $this->convertXCode($text, $image);
              if (!$html) {
                  $text = $this->renderWikistyleFinsher($text);
              }
              if ($html && $br != 0) $text = $this->nl2Br($text);
              if ($html) $text = $this->postConvertXCode($text, $xcode, $image);
              return $text;
          }
       
          // Original function
          function renderWiki_getEscTags () {
              return array('quote', 'color', 'font', 'size', 'b', 'c', 'd', 'i', 'u');
          }
       
          // Original function
          function renderWiki_getBypassTags () {
              return array('siteimg', 'fig', 'img');
          }
       
          // Original function
          function &renderWikistyle($text, $html = 0, $smiley = 1, $xcode = 1, $image = 1, $br = 1, $use_cache = 0)
          {
              static $pat = array();
              static $rep = array();
              
              $className = get_class($this);
              
              $br = ($br)? 1 : 0;
              $use_cache = ($use_cache)? 1 : 0;
              $smiley = ($smiley)? 1 : 0;
              $image = ($image)? 1 : 0;
              
              // xpWiki[6]
              if (! class_exists('XpWiki[6]')) {
                  include XOOPS_TRUST_PATH[17] . '/modules/xpwiki[6]/include.php';
              }
       
              $render = XpWiki[6]::getSingleton(XPWIKI_RENDERER_DIR);
              
              // pukiwiki.ini.php[18] setting
              $render->setIniRoot('line_break', $br);
              $render->setIniRoot('render_use_cache', $use_cache);
              $render->setIniRoot('use_extra_facemark', 1);
              $render->setIniRoot('usefacemark', $smiley);
              $render->setIniRoot('render_cache_min', 1440); // 1day
              $render->setIniRoot('link_target', '_blank');
              $render->setIniRoot('nowikiname', 1);
              $render->setIniRoot('show_passage', 0);
              $render->setIniRoot('no_slashes_commentout', 1);
       
              if ($xcode) {
                  if (! isset($pat[$className][$image])) {
                      // BB Code code
                      $pat[$className][$image][] = '/(?:\r\n|\r|\n)?\[code](?:\r\n|\r|\n)?(.*)(?:\r\n|\r|\n)?\[\/code\](?:\r\n|\r|\n)?/sUS';
                      $rep[$className][$image][] = "\n".'#code(){{{'."\n".'$1'."\n".'}}}'."\n";
       
                      // BB Code email
                      $pat[$className][$image][] = '/\[email](.+?)\[\/email]/iS';
                      $rep[$className][$image][] = '$1';
       
                      // BB Code url
                      $pat[$className][$image][] = '/\[url=([\'"]?)((?:ht|f)tp[s]?:\/\/[!~*\'();\/?:\@&=+\$,%#\w.-]+)\\1\](.+)\[\/url\]/esUS';
                      $rep[$className][$image][] = '\'[[\'.Hyp_TextFilter::renderWiki_ret2br(\'$3\').\':$2]]\'';
       
                      $pat[$className][$image][] = '/\[url=([\'"]?)([!~*\'();\/?:\@&=+\$,%#\w.-]+)\\1\](.+)\[\/url\]/esUS';
                      $rep[$className][$image][] = '\'[[\'.Hyp_TextFilter::renderWiki_ret2br(\'$3\').\':http://$2]]\'';
       
                      $pat[$className][$image][] = '/\[siteurl=([\'"]?)([!~*\'();\/?:\@&=+\$,%#\w.-]+)\\1\](.+)\[\/siteurl\]/esUS';
                      $rep[$className][$image][] = '\'[[\'.Hyp_TextFilter::renderWiki_ret2br(\'$3\').\':http:///$2]]\'';
       
                      // BB Code quote
                      $pat[$className][$image][] = '/(\[quote[^\]]*])(?:\r\n|\r|\n)(?![<>*|,#: \t+-])/S';
                      $rep[$className][$image][] = "\n\n$1";
                      $pat[$className][$image][] = '/(?:\r\n|\r|\n)*\[\/quote\]/S';
                      $rep[$className][$image][] = '[/quote]'."\n\n";
       
                      if ($image) {
                          // BB Code image with align
                          $pat[$className][$image][] = '/\[img\s+align=([\'"]?)(left|center|right)\\1]([!~*\'();\/?:\@&=+\$,%#\w.-]+)\[\/img\]/US';
                          $rep[$className][$image][] = '&ref($3,$2);';
       
                          // BB Code image normal
                          $pat[$className][$image][] = '/\[img]([!~*\'();\/?:\@&=+\$,%#\w.-]+)\[\/img\]/US';
                          $rep[$className][$image][] = '&ref($1);';
                      }
       
                      // Some BB Code Tags, Contents allows xpWiki[6] rendering.
                      if ($_reg = join('|', $this->renderWiki_getEscTags())) {
                          $pat[$className][$image][] = '/\[\/?(?:' . $_reg . ')(?:(?: |=)[^\]]+)?\]/eS';
                          $rep[$className][$image][] = '\'[ b 6 4 ]\' . base64_encode(\'$0\') . \'[ / b 6 4 ]\'';
                      }
       
                      // Other or Unknown BB Code Tags, All part escapes.
                      if ($_reg = join('|', $this->renderWiki_getBypassTags())) {
                          $pat[$className][$image][] = '/\[(' . $_reg . ')(?:\s[^\]]+)?].+\[\/\\1\]/esUS';
                          $rep[$className][$image][] = '\'[ b 6 4 ]\' . base64_encode(\'$0\') . \'[ / b 6 4 ]\'';
                      }
       
                  }
       
                  $text = preg_replace($pat[$className][$image], $rep[$className][$image], $text);
       
              }
              
              if ($text = $render->transform($text, XPWIKI_RENDERER_DIR)) {
                  if (isset($pat[$className])) {
                      // BB Code decode
                      $text = preg_replace(
                              '/\[ b 6 4 ](.+?)\[ \/ b 6 4 ]/eS',
                              'Hyp_TextFilter::renderWiki_base64decode(\'$1\',\''.$render->root->word_breaker.'\')',
                              $text);
                  }
                  
                  // XOOPS[5] Quote style
                  $text = str_replace(
                      array('<blockquote>','</blockquote>'),
                      array('<div class="paragraph">'._QUOTEC.'<div class="xoopsQuote"><blockquote>','</blockquote></div></div>'),$text
                  );
              }
              
              return $text;
          }
       
          // Original function
          function renderWiki_ret2br($text)
          {
              $text = str_replace('\\"', '"', $text);
              return str_replace(array("\r\n", "\r", "\n"), '&br;', $text);
          }
       
          // Original function
          function renderWiki_base64decode($text, $word_breaker) {
              return str_replace(array('<','>','\\"'),array('&lt;','&gt;','"'),base64_decode(strip_tags(str_replace($word_breaker, '', $text))));
          }
       
          // Original function
          function renderWikistyleFinsher($input) {
              //$input = str_replace(array("\x07", "\x08"), array('<div>', '</div>'), $this->renderWikistyleParagraphRegularize($input));
              $input = $this->renderWikistyleParagraphRegularize($input);
              return $input;
          }
       
          // Original function
          function renderWikistyleParagraphRegularize($input) {
              // remove <p> include block elements.
              $regex = '#<p>((?:[^<]+|<(?!/?p[^>]*?>)|(?R))+)</p>#';
              if (is_array($input)) {
                  if (preg_match('/<(?:div|p|pre|code)/i', $input[1])) {
                      //$input = '<div>' . $input[1] . '</div>';
                      //$input = "\x07" . $input[1]. "\x08";
                      $input = $input[1];
                  } else {
                      return $input[0];
                  }
              }
              return preg_replace_callback($regex, array(& $this, 'renderWikistyleParagraphRegularize'), $input);
          }
      }
       
      ?>
    • xpWiki[6]xpwiki[6] という名前以外でインストール[19]している場合は、6行目の 'xpwiki[6]' を適宜変更してください。
      5
      6
      
      // xpWiki[6] wikirenderer dirctory name
      define('XPWIKI_RENDERER_DIR', 'xpwiki[6]');
Page Top

XOOPS[5] 2.0.16a JP 用 anchor.png[20]

  • fileXOOPS_ROOT_PATH/class/module.textsanitizer.php[21]
    • 2008/1/26 に修正しました。(BBコードの[siteurl]に対応。要 xpWiki[6] 3.59 以上)
    • 2008/4/30 と 5/3 に修正しました。(BBコードの[img]が正常に変換できないことがある問題を修正)
    • 2008/5/30 に修正しました。(BBコードの siteimage, fig が正常に動作するようにした)
    • 2008/5/31 に typo 修正しました。参考スレッド[14]
    • 2008/10/9 xpWiki[6] のディレクトリ名指定を定数 XPWIKI_RENDERER_DIR を使う方式としました。
      • xpWiki[6] Ver 3.71.83 で搭載された画面変遷のないファイル添付とファイル名挿入に対応した。
    • 2008/10/11 10/9 の修正でCSSが効かなくなっていたのを修正しました。
    • 2008/12/22 PHP 4 環境で Warning エラーが出ていたのを修正しました。 (thx nonn50[15])
    • 2009/5/3 [quote]を使用した場合に、HTML構造が不正になることがある問題を修正しました。
    • 2009/5/12 5/3 の修正が原因で、レンダリング内容によっては、PHPがエラーで止まってしまうことがある問題を修正しました。(thx azumi)
      filemodule.textsanitizer.php[22]
        1
        2
        3
        4
        5
        6
        7
        8
        9
       10
       11
       12
       13
       14
       15
       16
       17
       18
       19
       20
       21
       22
       23
       24
       25
       26
       27
       28
       29
       30
       31
       32
       33
       34
       35
       36
       37
       38
       39
       40
       41
       42
       43
       44
       45
       46
       47
       48
       49
       50
       51
       52
       53
       54
       55
       56
       57
       58
       59
       60
       61
       62
       63
       64
       65
       66
       67
       68
       69
       70
       71
       72
       73
       74
       75
       76
       77
       78
       79
       80
       81
       82
       83
       84
       85
       86
       87
       88
       89
       90
       91
       92
       93
       94
       95
       96
       97
       98
       99
      100
      101
      102
      103
      104
      105
      106
      107
      108
      109
      110
      111
      112
      113
      114
      115
      116
      117
      118
      119
      120
      121
      122
      123
      124
      125
      126
      127
      128
      129
      130
      131
      132
      133
      134
      135
      136
      137
      138
      139
      140
      141
      142
      143
      144
      145
      146
      147
      148
      149
      150
      151
      152
      153
      154
      155
      156
      157
      158
      159
      160
      161
      162
      163
      164
      165
      166
      167
      168
      169
      170
      171
      172
      173
      174
      175
      176
      177
      178
      179
      180
      181
      182
      183
      184
      185
      186
      187
      188
      189
      190
      191
      192
      193
      194
      195
      196
      197
      198
      199
      200
      201
      202
      203
      204
      205
      206
      207
      208
      209
      210
      211
      212
      213
      214
      215
      216
      217
      218
      219
      220
      221
      222
      223
      224
      225
      226
      227
      228
      229
      230
      231
      232
      233
      234
      235
      236
      237
      238
      239
      240
      241
      242
      243
      244
      245
      246
      247
      248
      249
      250
      251
      252
      253
      254
      255
      256
      257
      258
      259
      260
      261
      262
      263
      264
      265
      266
      267
      268
      269
      270
      271
      272
      273
      274
      275
      276
      277
      278
      279
      280
      281
      282
      283
      284
      285
      286
      287
      288
      289
      290
      291
      292
      293
      294
      295
      296
      297
      298
      299
      300
      301
      302
      303
      304
      305
      306
      307
      308
      309
      310
      311
      312
      313
      314
      315
      316
      317
      318
      319
      320
      321
      322
      323
      324
      325
      326
      327
      328
      329
      330
      331
      332
      333
      334
      335
      336
      337
      338
      339
      340
      341
      342
      343
      344
      345
      346
      347
      348
      349
      350
      351
      352
      353
      354
      355
      356
      357
      358
      359
      360
      361
      362
      363
      364
      365
      366
      367
      368
      369
      370
      371
      372
      373
      374
      375
      376
      377
      378
      379
      380
      381
      382
      383
      384
      385
      386
      387
      388
      389
      390
      391
      392
      393
      394
      395
      396
      397
      398
      399
      400
      401
      402
      403
      404
      405
      406
      407
      408
      409
      410
      411
      412
      413
      414
      415
      416
      417
      418
      419
      420
      421
      422
      423
      424
      425
      426
      427
      428
      429
      430
      431
      432
      433
      434
      435
      436
      437
      438
      439
      440
      441
      442
      443
      444
      445
      446
      447
      448
      449
      450
      451
      452
      453
      454
      455
      456
      457
      458
      459
      460
      461
      462
      463
      464
      465
      466
      467
      468
      469
      470
      471
      472
      473
      474
      475
      476
      477
      478
      479
      480
      481
      482
      483
      484
      485
      486
      487
      488
      489
      490
      491
      492
      493
      494
      495
      496
      497
      498
      499
      500
      501
      502
      503
      504
      505
      506
      507
      508
      509
      510
      511
      512
      513
      514
      515
      516
      517
      518
      519
      520
      521
      522
      523
      524
      525
      526
      527
      528
      529
      530
      531
      532
      533
      534
      535
      536
      537
      538
      539
      540
      541
      542
      543
      544
      545
      546
      547
      548
      549
      550
      551
      552
      553
      554
      555
      556
      557
      558
      559
      560
      561
      562
      563
      564
      565
      566
      567
      568
      569
      570
      571
      572
      573
      574
      575
      576
      577
      578
      579
      580
      581
      582
      583
      584
      585
      586
      587
      588
      589
      590
      591
      592
      593
      594
      595
      596
      597
      598
      599
      600
      601
      602
      603
      604
      605
      606
      607
      608
      609
      610
      611
      612
      613
      614
      615
      616
      617
      618
      619
      620
      621
      622
      623
      624
      625
      626
      627
      628
      629
      630
      631
      632
      633
      634
      635
      636
      637
      638
      639
      640
      641
      642
      643
      644
      645
      646
      647
      648
      649
      650
      651
      652
      653
      654
      655
      656
      657
      658
      659
      660
      661
      662
      663
      664
      665
      666
      667
      668
      669
      670
      671
      672
      673
      674
      675
      676
      677
      678
      679
      680
      681
      682
      683
      684
      685
      686
      687
      688
      689
      690
      691
      692
      693
      694
      695
      696
      697
      698
      699
      700
      701
      702
      703
      704
      705
      706
      707
      708
      709
      710
      711
      712
      713
      714
      715
      716
      717
      718
      719
      720
      721
      722
      
      <?php
      ///////////////////////////////////////////////////////////////////////////////
      // module.textsanitizer.php for xpWiki[6] renderer mode. by nao-pon[23] (hypweb.net)
      ///////////////////////////////////////////////////////////////////////////////
      // $Id: module.textsanitizer.php,v 1.8 2006/07/27 00:17:17 onokazu Exp $
      //  ------------------------------------------------------------------------ //
      //                XOOPS[5] - PHP Content Management System                      //
      //                    Copyright (c) 2000 XOOPS[5].org                           //
      //                       <http://www.xoops[5].org/>                             //
      //  ------------------------------------------------------------------------ //
      //  This program is free software; you can redistribute it and/or modify     //
      //  it under the terms of the GNU General Public License as published by     //
      //  the Free Software Foundation[24]; either version 2 of the License, or        //
      //  (at your option) any later version.                                      //
      //                                                                           //
      //  You may not change or alter any portion of this comment or credits       //
      //  of supporting developers from this source code or any supporting         //
      //  source code which is considered copyrighted (c) material of the          //
      //  original comment or credit authors.                                      //
      //                                                                           //
      //  This program is distributed in the hope that it will be useful,          //
      //  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
      //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
      //  GNU General Public License for more details.                             //
      //                                                                           //
      //  You should have received a copy of the GNU General Public License        //
      //  along with this program; if not, write to the Free Software              //
      //  Foundation[24], Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
      //  ------------------------------------------------------------------------ //
      // Author: Kazumi Ono (http://www.myweb.ne.jp/, http://jp.xoops[5].org/)        //
      //         Goghs Cheng (http://www.eqiao.com, http://www.devbeez.com/)       //
      // Project: The XOOPS[5] Project (http://www.xoops[5].org/)                        //
      // ------------------------------------------------------------------------- //
       
      // xpWiki[6] wikirenderer dirctory name
      define('XPWIKI_RENDERER_DIR', 'xpwiki[6]');
       
      /**
       * Class to "clean up" text for various uses
       *
       * <b>Singleton</b>
       *
       * @package     kernel
       * @subpackage  core
       *
       * @author      Kazumi Ono  <onokazu@xoops[5].org>
       * @author      Goghs Cheng
       * @copyright   (c) 2000-2003 The Xoops[5] Project - www.xoops[5].org
       */
      class MyTextSanitizer
      {
          /**
           * @var array
           */
          var $smileys = array();
       
          /**
           *
           */
          var $censorConf;
       
          /*
          * Constructor of this class
          *
          * Gets allowed html tags from admin config settings
          * <br> should not be allowed since nl2br will be used
          * when storing data.
          *
          * @access   private
          *
          * @todo Sofar, this does nuttin' ;-)
          */
          function MyTextSanitizer()
          {
       
          }
       
          /**
           * Access the only instance of this class
           *
           * @return  object
           *
           * @static
           * @staticvar   object
           */
          function &getInstance()
          {
              static $instance;
              if (!isset($instance)) {
                  $instance = new MyTextSanitizer();
              }
              return $instance;
          }
       
          /**
           * Get the smileys
           *
           * @return  array
           */
          function getSmileys()
          {
              return $this->smileys;
          }
       
          /**
           * Replace emoticons in the message with smiley images
           *
           * @param   string  $message
           *
           * @return  string
           */
          function &smiley($message)
          {
              $db =& Database::getInstance();
              if (count($this->smileys) == 0) {
                  if ($getsmiles = $db->query("SELECT * FROM ".$db->prefix("smiles"))){
                      while ($smiles = $db->fetchArray($getsmiles)) {
                          $message = str_replace($smiles['code'], '<img src="'.XOOPS_UPLOAD_URL.'/'.htmlspecialchars($smiles['smile_url']).'" alt="" />', $message);
                          array_push($this->smileys, $smiles);
                      }
                  }
              }
              elseif (is_array($this->smileys)) {
                  foreach ($this->smileys as $smile) {
                      $message = str_replace($smile['code'], '<img src="'.XOOPS_UPLOAD_URL.'/'.htmlspecialchars($smile['smile_url']).'" alt="" />', $message);
                  }
              }
              return $message;
          }
       
          /**
           * Make links in the text clickable
           *
           * @param   string  $text
           * @return  string
           **/
          function &makeClickable(&$text)
          {
              $patterns = array("/(^|[^]_a-z0-9-=\"'\/])([a-z]+?):\/\/([^, \r\n\"\(\)'<>]+)/i", "/(^|[^]_a-z0-9-=\"'\/])www\.([a-z0-9\-]+)\.([^, \r\n\"\(\)'<>]+)/i", "/(^|[^]_a-z0-9-=\"'\/])ftp\.([a-z0-9\-]+)\.([^, \r\n\"\(\)'<>]+)/i", "/(^|[^]_a-z0-9-=\"'\/:\.])([a-z0-9\-_\.]+?)@([^, \r\n\"\(\)'<>\[\]]+)/i");
              $replacements = array("\\1<a href=\"\\2://\\3\" target=\"_blank\">\\2://\\3</a>", "\\1<a href=\"http://www.\\2.\\3\" target=\"_blank\">www.\\2.\\3</a>", "\\1<a href=\"ftp://ftp.\\2.\\3\" target=\"_blank\">ftp.\\2.\\3</a>", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>");
              $ret = preg_replace($patterns, $replacements, $text);
              return $ret;
          }
       
          /**
           * Replace XoopsCodes with their equivalent HTML formatting
           *
           * @param   string  $text
           * @param   bool    $allowimage Allow images in the text?
           *                              On FALSE, uses links to images.
           * @return  string
           **/
          function &xoopsCodeDecode(&$text, $allowimage = 1)
          {
              $imgCallbackPattern = "/\[img( align=\w+)]([^\"\(\)\?\&'<>]*)\[\/img\]/sU";
              $text = preg_replace_callback($imgCallbackPattern, array($this, '_filterImgUrl'), $text);
       
              $patterns = array();
              $replacements = array();
              // RMV: added new markup for intrasite url (allows easier site moves)
              // TODO: automatically convert other URLs to this format if XOOPS_URL matches??
              $patterns[] = "/\[siteurl=(['\"]?)([^\"'<>]*)\\1](.*)\[\/siteurl\]/sU";
              $replacements[] = '<a href="'.XOOPS_URL.'/\\2" target="_blank">\\3</a>';
              $patterns[] = "/\[url=(['\"]?)(http[s]?:\/\/[^\"'<>]*)\\1](.*)\[\/url\]/sU";
              $replacements[] = '<a href="\\2" target="_blank">\\3</a>';
              $patterns[] = "/\[url=(['\"]?)(ftp?:\/\/[^\"'<>]*)\\1](.*)\[\/url\]/sU";
              $replacements[] = '<a href="\\2" target="_blank">\\3</a>';
              $patterns[] = "/\[url=(['\"]?)([^\"'<>]*)\\1](.*)\[\/url\]/sU";
              $replacements[] = '<a href="http://\\2" target="_blank">\\3</a>';
              $patterns[] = "/\[c(?:olor)?=(['\"]?)([a-zA-Z0-9]*)\\1](.*)\[\/c(?:olor)?\]/sU";
              $replacements[] = '<span style="color: #\\2;">\\3</span>';
              $patterns[] = "/\[size=(['\"]?)([a-z0-9-]*)\\1](.*)\[\/size\]/sU";
              $replacements[] = '<span style="font-size: \\2;">\\3</span>';
              $patterns[] = "/\[font=(['\"]?)([^;<>\*\(\)\"']*)\\1](.*)\[\/font\]/sU";
              $replacements[] = '<span style="font-family: \\2;">\\3</span>';
              $patterns[] = "/\[email]([^;<>\*\(\)\"']*)\[\/email\]/sU";
              $replacements[] = '<a href="mailto:\\1">\\1</a>';
              $patterns[] = "/\[b](.*)\[\/b\]/sU";
              $replacements[] = '<b>\\1</b>';
              $patterns[] = "/\[i](.*)\[\/i\]/sU";
              $replacements[] = '<i>\\1</i>';
              $patterns[] = "/\[u](.*)\[\/u\]/sU";
              $replacements[] = '<u>\\1</u>';
              $patterns[] = "/\[d](.*)\[\/d\]/sU";
              $replacements[] = '<del>\\1</del>';
              //$patterns[] = "/\[li](.*)\[\/li\]/sU";
              //$replacements[] = '<li>\\1</li>';
              $patterns[] = "/\[img align=(['\"]?)(left|center|right)\\1]([^\"\(\)\?\&'<>]*)\[\/img\]/sU";
              $patterns[] = "/\[img]([^\"\(\)\?\&'<>]*)\[\/img\]/sU";
              $patterns[] = "/\[img align=(['\"]?)(left|center|right)\\1 id=(['\"]?)([0-9]*)\\3]([^\"\(\)\?\&'<>]*)\[\/img\]/sU";
              $patterns[] = "/\[img id=(['\"]?)([0-9]*)\\1]([^\"\(\)\?\&'<>]*)\[\/img\]/sU";
              if ($allowimage != 1) {
                  $replacements[] = '<a href="\\3" target="_blank">\\3</a>';
                  $replacements[] = '<a href="\\1" target="_blank">\\1</a>';
                  $replacements[] = '<a href="'.XOOPS_URL.'/image.php?id=\\4" target="_blank">\\5</a>';
                  $replacements[] = '<a href="'.XOOPS_URL.'/image.php?id=\\2" target="_blank">\\3</a>';
              } else {
                  $replacements[] = '<img src="\\3" align="\\2" alt="" />';
                  $replacements[] = '<img src="\\1" alt="" />';
                  $replacements[] = '<img src="'.XOOPS_URL.'/image.php?id=\\4" align="\\2" alt="\\5" />';
                  $replacements[] = '<img src="'.XOOPS_URL.'/image.php?id=\\2" alt="\\3" />';
              }
              $patterns[] = "/\[quote]/sU";
              $replacements[] = '<div class="paragraph">'._QUOTEC.'<div class="xoopsQuote"><blockquote>';
              $patterns[] = "/\[\/quote]/sU";
              $replacements[] = '</blockquote></div></div>';
              // [quote sitecite=]
              $patterns[] = "/\[quote sitecite=([^\"'<>]*)\]/sU";
              $replacements[] = '<div class="paragraph">'._QUOTEC.'<div class="xoopsQuote"><blockquote cite="'.XOOPS_URL.'/\\1">';
              $patterns[] = "/javascript:/si";
              $replacements[] = "java script:";
              $patterns[] = "/about:/si";
              $replacements[] = "about :";
              $ret = preg_replace($patterns, $replacements, $text);
              return $ret;
          }
       
          /**
           * Filters out invalid strings included in URL, if any
           *
           * @param   array  $matches
           * @return  string
           */
          function _filterImgUrl($matches)
          {
              if ($this->checkUrlString($matches[2])) {
                  return $matches[0];
              } else {
                  return "";
              }
          }
       
          /**
           * Checks if invalid strings are included in URL
           *
           * @param   string  $text
           * @return  bool
           */
          function checkUrlString($text)
          {
              // Check control code
              if (preg_match("/[\\0-\\31]/", $text)) {
                  return false;
              }
              // check black pattern(deprecated)
              return !preg_match("/^(javascript|vbscript|about):/i", $text);
          }
       
          /**
           * Convert linebreaks to <br /> tags
           *
           * @param   string  $text
           *
           * @return  string
           */
          function &nl2Br($text)
          {
              $ret = preg_replace("/(\015\012)|(\015)|(\012)/","<br />",$text);
              return $ret;
          }
       
          /**
           * Add slashes to the text if magic_quotes_gpc is turned off.
           *
           * @param   string  $text
           * @return  string
           **/
          function &addSlashes($text)
          {
              if (!get_magic_quotes_gpc()) {
                  $text = addslashes($text);
              }
              return $text;
          }
          /*
          * if magic_quotes_gpc is on, stirip back slashes
          *
          * @param    string  $text
          *
          * @return   string
          */
          function &stripSlashesGPC($text)
          {
              if (get_magic_quotes_gpc()) {
                  $text = stripslashes($text);
              }
              return $text;
          }
       
          /*
          *  for displaying data in html textbox forms
          *
          * @param    string  $text
          *
          * @return   string
          */
          function &htmlSpecialChars($text)
          {
              //return preg_replace("/&amp;/i", '&', htmlspecialchars($text, ENT_QUOTES));
              $ret = preg_replace(array("/&amp;/i", "/&nbsp;/i"), array('&', '&amp;nbsp;'), htmlspecialchars($text, ENT_QUOTES));
              return $ret;
          }
       
          /**
           * Reverses {@link htmlSpecialChars()}
           *
           * @param   string  $text
           * @return  string
           **/
          function &undoHtmlSpecialChars(&$text)
          {
              return preg_replace(array("/&gt;/i", "/&lt;/i", "/&quot;/i", "/&#039;/i"), array(">", "<", "\"", "'"), $text);
          }
       
          // Original function
          function renderWiki_getEscTags () {
              return array('quote', 'color', 'font', 'size', 'b', 'c', 'd', 'i', 'u');
          }
       
          // Original function
          function renderWiki_getBypassTags () {
              return array('siteimg', 'fig', 'img');
          }
       
          // Original function
          function &renderWikistyle($text, $html = 0, $smiley = 1, $xcode = 1, $image = 1, $br = 1, $use_cache = 0)
          {
              static $pat = array();
              static $rep = array();
              
              $className = get_class($this);
              
              $br = ($br)? 1 : 0;
              $use_cache = ($use_cache)? 1 : 0;
              $smiley = ($smiley)? 1 : 0;
              $image = ($image)? 1 : 0;
              
              // xpWiki[6]
              if (! class_exists('XpWiki[6]')) {
                  include XOOPS_TRUST_PATH[17] . '/modules/xpwiki[6]/include.php';
              }
       
              $render = XpWiki[6]::getSingleton(XPWIKI_RENDERER_DIR);
       
              // pukiwiki.ini.php[18] setting
              $render->setIniRoot('line_break', $br);
              $render->setIniRoot('render_use_cache', $use_cache);
              $render->setIniRoot('use_extra_facemark', 1);
              $render->setIniRoot('usefacemark', $smiley);
              $render->setIniRoot('render_cache_min', 1440); // 1day
              $render->setIniRoot('link_target', '_blank');
              $render->setIniRoot('nowikiname', 1);
              $render->setIniRoot('show_passage', 0);
              $render->setIniRoot('no_slashes_commentout', 1);
       
              if ($xcode) {
                  if (! isset($pat[$className][$image])) {
                      // BB Code code
                      $pat[$className][$image][] = '/(?:\r\n|\r|\n)?\[code](?:\r\n|\r|\n)?(.*)(?:\r\n|\r|\n)?\[\/code\](?:\r\n|\r|\n)?/sUS';
                      $rep[$className][$image][] = "\n".'#code(){{{'."\n".'$1'."\n".'}}}'."\n";
       
                      // BB Code email
                      $pat[$className][$image][] = '/\[email](.+?)\[\/email]/iS';
                      $rep[$className][$image][] = '$1';
       
                      // BB Code url
                      $pat[$className][$image][] = '/\[url=([\'"]?)((?:ht|f)tp[s]?:\/\/[!~*\'();\/?:\@&=+\$,%#\w.-]+)\\1\](.+)\[\/url\]/esUS';
                      $rep[$className][$image][] = '\'[[\'.MyTextSanitizer::renderWiki_ret2br(\'$3\').\':$2]]\'';
       
                      $pat[$className][$image][] = '/\[url=([\'"]?)([!~*\'();\/?:\@&=+\$,%#\w.-]+)\\1\](.+)\[\/url\]/esUS';
                      $rep[$className][$image][] = '\'[[\'.MyTextSanitizer::renderWiki_ret2br(\'$3\').\':http://$2]]\'';
       
                      $pat[$className][$image][] = '/\[siteurl=([\'"]?)([!~*\'();\/?:\@&=+\$,%#\w.-]+)\\1\](.+)\[\/siteurl\]/esUS';
                      $rep[$className][$image][] = '\'[[\'.MyTextSanitizer::renderWiki_ret2br(\'$3\').\':http:///$2]]\'';
       
                      // BB Code quote
                      $pat[$className][$image][] = '/(\[quote[^\]]*])(?:\r\n|\r|\n)(?![<>*|,#: \t+-])/S';
                      $rep[$className][$image][] = "\n\n$1";
                      $pat[$className][$image][] = '/(?:\r\n|\r|\n)*\[\/quote\]/S';
                      $rep[$className][$image][] = '[/quote]'."\n\n";
       
                      if ($image) {
                          // BB Code image with align
                          $pat[$className][$image][] = '/\[img\s+align=([\'"]?)(left|center|right)\\1]([!~*\'();\/?:\@&=+\$,%#\w.-]+)\[\/img\]/US';
                          $rep[$className][$image][] = '&ref($3,$2);';
       
                          // BB Code image normal
                          $pat[$className][$image][] = '/\[img]([!~*\'();\/?:\@&=+\$,%#\w.-]+)\[\/img\]/US';
                          $rep[$className][$image][] = '&ref($1);';
                      }
       
                      // Some BB Code Tags, Contents allows xpWiki[6] rendering.
                      if ($_reg = join('|', $this->renderWiki_getEscTags())) {
                          $pat[$className][$image][] = '/\[\/?(?:' . $_reg . ')(?:(?: |=)[^\]]+)?\]/eS';
                          $rep[$className][$image][] = '\'[ b 6 4 ]\' . base64_encode(\'$0\') . \'[ / b 6 4 ]\'';
                      }
       
                      // Other or Unknown BB Code Tags, All part escapes.
                      if ($_reg = join('|', $this->renderWiki_getBypassTags())) {
                          $pat[$className][$image][] = '/\[(' . $_reg . ')(?:\s[^\]]+)?].+\[\/\\1\]/esUS';
                          $rep[$className][$image][] = '\'[ b 6 4 ]\' . base64_encode(\'$0\') . \'[ / b 6 4 ]\'';
                      }
       
                  }
       
                  $text = preg_replace($pat[$className][$image], $rep[$className][$image], $text);
       
              }
              
              if ($text = $render->transform($text, XPWIKI_RENDERER_DIR)) {
                  if (isset($pat[$className])) {
                      // BB Code decode
                      $text = preg_replace(
                              '/\[ b 6 4 ](.+?)\[ \/ b 6 4 ]/eS',
                              'MyTextSanitizer::renderWiki_base64decode(\'$1\',\''.$render->root->word_breaker.'\')',
                              $text);
                  }
                  
                  // XOOPS[5] Quote style
                  $text = str_replace(
                      array('<blockquote>','</blockquote>'),
                      array('<div class="paragraph">'._QUOTEC.'<div class="xoopsQuote"><blockquote>','</blockquote></div></div>'),$text
                  );
              }
              
              return $text;
          }
       
          // Original function
          function renderWiki_ret2br($text)
          {
              $text = str_replace('\\"', '"', $text);
              return str_replace(array("\r\n", "\r", "\n"), '&br;', $text);
          }
       
          // Original function
          function renderWiki_base64decode($text, $word_breaker) {
              return str_replace(array('<','>','\\"'),array('&lt;','&gt;','"'),base64_decode(strip_tags(str_replace($word_breaker, '', $text))));
          }
       
          // Original function
          function renderWikistyleFinsher($input) {
              //$input = str_replace(array("\x07", "\x08"), array('<div>', '</div>'), $this->renderWikistyleParagraphRegularize($input));
              $input = $this->renderWikistyleParagraphRegularize($input);
              return $input;
          }
       
          // Original function
          function renderWikistyleParagraphRegularize($input) {
              // remove <p> include block elements.
              $regex = '#<p>((?:[^<]+|<(?!/?p[^>]*?>)|(?R))+)</p>#';
              if (is_array($input)) {
                  if (preg_match('/<(?:div|p|pre|code)/i', $input[1])) {
                      $input = $input[1];
                  } else {
                      return $input[0];
                  }
              }
              return preg_replace_callback($regex, array(& $this, 'renderWikistyleParagraphRegularize'), $input);
          }
       
          /**
           * Filters textarea data for display
           * (This method makes overhead but needed for compatibility)
           *
           * @param   string  $text
           * @param   bool    $html   allow html?
           * @param   bool    $smiley allow smileys?
           * @param   bool    $xcode  allow xoopscode?
           * @param   bool    $image  allow inline images?
           * @param   bool    $br     convert linebreaks?
           * @return  string
           **/
          
          function _ToShowTarea($text, $html = 0, $smiley = 1, $xcode = 1, $image = 1, $br = 1, $use_cache = 0) {
              if ($html != 1) {
                  $text = $this->renderWikistyle($text, $html, $smiley, $xcode, $image, $br, $use_cache);
              } else {
                  $text = $this->codePreConv($text, $xcode);
                  $text = $this->makeClickable($text);
                  if ($smiley != 0) $text = $this->smiley($text);
              }
              if ($xcode != 0) $text = $this->xoopsCodeDecode($text, $image);
              if (!$html) {
                  $text = $this->renderWikistyleFinsher($text);
              }
              if ($html && $br != 0) $text = $this->nl2Br($text);
              if ($html) $text = $this->codeConv($text, $xcode, $image);
              return $text;
          }
       
          /**
           * Filters textarea form data in DB for display
           *
           * @param   string  $text
           * @param   bool    $html   allow html?
           * @param   bool    $smiley allow smileys?
           * @param   bool    $xcode  allow xoopscode?
           * @param   bool    $image  allow inline images?
           * @param   bool    $br     convert linebreaks?
           * @return  string
           **/
          function &displayTarea(&$text, $html = 0, $smiley = 1, $xcode = 1, $image = 1, $br = 1)
          {
              $text = $this->_ToShowTarea($text, $html, $smiley, $xcode, $image, $br, 1);
              return $text;
          }
       
          /**
           * Filters textarea form data submitted for preview
           *
           * @param   string  $text
           * @param   bool    $html   allow html?
           * @param   bool    $smiley allow smileys?
           * @param   bool    $xcode  allow xoopscode?
           * @param   bool    $image  allow inline images?
           * @param   bool    $br     convert linebreaks?
           * @return  string
           **/
          function &previewTarea(&$text, $html = 0, $smiley = 1, $xcode = 1, $image = 1, $br = 1)
          {
              $text =& $this->stripSlashesGPC($text);
              $text = $this->_ToShowTarea($text, $html, $smiley, $xcode, $image, $br, 0);
              return $text;
          }
       
          /**
           * Replaces banned words in a string with their replacements
           *
           * @param   string $text
           * @return  string
           *
           * @deprecated
           **/
          function &censorString(&$text)
          {
              if (!isset($this->censorConf)) {
                  $config_handler =& xoops_gethandler('config');
                  $this->censorConf =& $config_handler->getConfigsByCat(XOOPS_CONF_CENSOR);
              }
              if ($this->censorConf['censor_enable'] == 1) {
                  $replacement = $this->censorConf['censor_replace'];
                  foreach ($this->censorConf['censor_words'] as $bad) {
                      if ( !empty($bad) ) {
                          $bad = quotemeta($bad);
                          $patterns[] = "/(\s)".$bad."/siU";
                          $replacements[] = "\\1".$replacement;
                          $patterns[] = "/^".$bad."/siU";
                          $replacements[] = $replacement;
                          $patterns[] = "/(\n)".$bad."/siU";
                          $replacements[] = "\\1".$replacement;
                          $patterns[] = "/]".$bad."/siU";
                          $replacements[] = "]".$replacement;
                          $text = preg_replace($patterns, $replacements, $text);
                      }
                  }
              }
              return $text;
          }
       
       
          /**#@+
           * Sanitizing of [code] tag
           */
          function codePreConv($text, $xcode = 1) {
              if($xcode != 0){
                  $patterns = "/\[code](.*)\[\/code\]/esU";
                  $replacements = "'[code]'.base64_encode('$1').'[/code]'";
                  $text =  preg_replace($patterns, $replacements, $text);
              }
              return $text;
          }
       
          function codeConv($text, $xcode = 1, $image = 1){
              if($xcode != 0){
                  $patterns = "/\[code](.*)\[\/code\]/esU";
                  if ($image != 0) {
                      // image allowed
                      $replacements = "'<div class=\"xoopsCode\"><pre><code>'.MyTextSanitizer::codeSanitizer('$1').'</code></pre></div>'";
                      //$text =& $this->xoopsCodeDecode($text);
                  } else {
                      // image not allowed
                      $replacements = "'<div class=\"xoopsCode\"><pre><code>'.MyTextSanitizer::codeSanitizer('$1', 0).'</code></pre></div>'";
                      //$text =& $this->xoopsCodeDecode($text, 0);
                  }
                  $text =  preg_replace($patterns, $replacements, $text);
              }
              return $text;
          }
       
          function codeSanitizer($str, $image = 1){
              if($image != 0){
                  $str = $this->xoopsCodeDecode(
                      $this->htmlSpecialChars(str_replace('\"', '"', base64_decode($str)))
                      );
              }else{
                  $str = $this->xoopsCodeDecode(
                      $this->htmlSpecialChars(str_replace('\"', '"', base64_decode($str))),0
                      );
              }
              return $str;
          }
       
       
          /**#@-*/
       
       
      ##################### Deprecated Methods ######################
       
          /**#@+
           * @deprecated
           */
          function sanitizeForDisplay($text, $allowhtml = 0, $smiley = 1, $bbcode = 1)
          {
              $text =& displayTarea($text, $allowhtml, $smiley, $bbcode, 1, 1);
              return $text;
          }
       
          function sanitizeForPreview($text, $allowhtml = 0, $smiley = 1, $bbcode = 1)
          {
              $text =& previewTarea($text, $allowhtml, $smiley, $bbcode, 1, 1);
              return $text;
          }
       
          function makeTboxData4Save($text)
          {
              //$text = $this->undoHtmlSpecialChars($text);
              return $this->addSlashes($text);
          }
       
          function makeTboxData4Show($text, $smiley=0)
          {
              $text = $this->htmlSpecialChars($text);
              return $text;
          }
       
          function makeTboxData4Edit($text)
          {
              return $this->htmlSpecialChars($text);
          }
       
          function makeTboxData4Preview($text, $smiley=0)
          {
              $text = $this->stripSlashesGPC($text);
              $text = $this->htmlSpecialChars($text);
              return $text;
          }
       
          function makeTboxData4PreviewInForm($text)
          {
              $text = $this->stripSlashesGPC($text);
              return $this->htmlSpecialChars($text);
          }
       
          function makeTareaData4Save($text)
          {
              return $this->addSlashes($text);
          }
       
          function &makeTareaData4Show(&$text, $html=1, $smiley=1, $xcode=1)
          {
              $ret = $this->displayTarea($text, $html, $smiley, $xcode);
              return $ret;
          }
       
          function makeTareaData4Edit($text)
          {
              return $this->htmlSpecialChars($text);
          }
       
          function &makeTareaData4Preview(&$text, $html=1, $smiley=1, $xcode=1)
          {
              $ret = $this->previewTarea($text, $html, $smiley, $xcode);
              return $ret;
          }
       
          function makeTareaData4PreviewInForm($text)
          {
              //if magic_quotes_gpc is on, do stipslashes
              $text = $this->stripSlashesGPC($text);
              return $this->htmlSpecialChars($text);
          }
       
          function makeTareaData4InsideQuotes($text)
          {
              return $this->htmlSpecialChars($text);
          }
       
          function &oopsStripSlashesGPC($text)
          {
              $ret = $this->stripSlashesGPC($text);
              return $ret;
          }
       
          function &oopsStripSlashesRT($text)
          {
              if (get_magic_quotes_runtime()) {
                  $text =& stripslashes($text);
              }
              return $text;
          }
       
          function &oopsAddSlashes($text)
          {
              $ret = $this->addSlashes($text);
              return $ret;
          }
       
          function &oopsHtmlSpecialChars($text)
          {
              $ret = $this->htmlSpecialChars($text);
              return $ret;
          }
       
          function &oopsNl2Br($text)
          {
              $ret = $this->nl2br($text);
              return $ret;
          }
          /**#@-*/
      }
      ?>
    • xpWiki[6]xpwiki[6] という名前以外でインストール[19]している場合は、36行目の 'xpwiki[6]' を適宜変更してください。
      35
      36
      
      // xpWiki[6] wikirenderer dirctory name
      define('XPWIKI_RENDERER_DIR', 'xpwiki[6]');
Page Top

Wikiヘルパーをテキストエリアに表示する方法 anchor.png[25]

JavaScriptによる「Wikiヘルパー」(IE と FireFox に対応)をテキストエリアに適用させたい場合は、HypCommonFunc[8] に含まれている hypconf モジュールの設定の「サイトワイド Wiki ヘルパー」を有効にすると、サイト全体に渡り、「Wikiヘルパー」が使えるようになります。

また、hypconf モジュールを使用しない場合は次の方法があります。どちらの方法でも構いません。

Page Top

まずはじめに anchor.png[26]

  1. html側xpWiki[6]モジュールディレクトリ/private/ini/pukiwiki.ini.php[18] に以下の内容を記述する。
    1
    2
    
    // Show the Wiki Helper on the site wide.
    $root->render_UseWikihelperAtAll = 1;
Page Top

選択その1 (ブロックの配置) anchor.png[27]

  1. "xpWiki[6]のページ表示ブロック" 又は "XOOPS[5]のカスタムブロックの自動フォーマットタイプ" をすべてのページに配置する。ブロックに表示するページや内容は、どのような内容でも構いません。
    このサイトでは、左ブロックの「サイト内 Wiki」がそれにあたります。
Page Top

選択その2 anchor.png[28]

  1. XOOPS[5] テーマの theme.html の <head> 内 <{$xoops_module_header}> の下にJavaScriptを挿入して以下のようにする。
    Everything is expanded.Everything is shortened.
     
     
    
    <{$xoops_module_header}>
    <script type="text/javascript" src="<{$xoops_url}>/modules/xpwiki[6]/skin/loader.php?src=wikihelper_loader.js"></script>


Last-modified: 2012-05-28 (月) 13:16:24 (JST) (4351d) by nao-pon