オープンソース・ソフトウェアの開発とダウンロード

CVS リポジトリの参照

Diff of /hypweb/XOOPS_TRUST/class/hyp_common/xc_classes/Hyp_TextFilter.php

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.2 by nao-pon, Sun Nov 27 05:51:58 2011 UTC revision 1.3 by nao-pon, Tue Dec 13 07:15:29 2011 UTC
# Line 6  Line 6 
6    
7  class Hyp_TextFilter extends Legacy_TextFilter  class Hyp_TextFilter extends Legacy_TextFilter
8  {  {
9        var $hypInternalTags = array('email', 'siteimg', 'img', 'siteurl', 'url');
10        var $hypEscTags      = array('quote', 'color', 'font', 'size', 'b', 'c', 'd', 'i', 'u');
11        var $hypBypassTags   = array('fig');
12    
13      function Hyp_TextFilter() {      function Hyp_TextFilter() {
14          parent::Legacy_TextFilter();          parent::Legacy_TextFilter();
15          $this->mMakeXCodeConvertTable->add('Hyp_TextFilter::makeXCodeConvertTable', XCUBE_DELEGATE_PRIORITY_3);          $this->mMakeXCodeConvertTable->add('Hyp_TextFilter::makeXCodeConvertTable', XCUBE_DELEGATE_PRIORITY_3);
16            $this->mMakeXCodeConvertTable->add(array(& $this, 'getXcodeBBcode'), XCUBE_DELEGATE_PRIORITY_FINAL);
17      }      }
18    
19      function makeXCodeConvertTable(& $patterns, & $replacements) {      function makeXCodeConvertTable(& $patterns, & $replacements) {
# Line 22  class Hyp_TextFilter extends Legacy_Text Line 27  class Hyp_TextFilter extends Legacy_Text
27          $replacements[0][] = $replacements[1][] = '<div class="paragraph">'._QUOTEC.'<div class="xoopsQuote"><blockquote cite="'.XOOPS_URL.'/\\1">';          $replacements[0][] = $replacements[1][] = '<div class="paragraph">'._QUOTEC.'<div class="xoopsQuote"><blockquote cite="'.XOOPS_URL.'/\\1">';
28      }      }
29    
30        function getXcodeBBcode($patterns, $replacements) {
31            $_arr = $this->hypBypassTags;
32            foreach($patterns as $_pat) {
33                    if (preg_match('#^/\\\\\[([a-zA-Z0-9_-]+)\b#', $_pat, $_match)) {
34                                    $_arr[] = $_match[1];
35                    }
36            }
37            $this->hypBypassTags = array_unique(array_diff($_arr, $this->hypEscTags, $this->hypInternalTags));
38        }
39    
40      // Over write      // Over write
41      function getInstance(&$instance) {      function getInstance(&$instance) {
42          if (empty($instance)) {          if (empty($instance)) {
# Line 54  class Hyp_TextFilter extends Legacy_Text Line 69  class Hyp_TextFilter extends Legacy_Text
69    
70      // Original function      // Original function
71      function renderWiki_getEscTags () {      function renderWiki_getEscTags () {
72          return array('quote', 'color', 'font', 'size', 'b', 'c', 'd', 'i', 'u');          rsort($this->hypEscTags);
73            return $this->hypEscTags;
74      }      }
75    
76      // Original function      // Original function
77      function renderWiki_getBypassTags () {      function renderWiki_getBypassTags () {
78          return array('siteimg', 'fig', 'img');          rsort($this->hypBypassTags);
79            return $this->hypBypassTags;
80      }      }
81    
82      // Original function      // Original function
# Line 121  class Hyp_TextFilter extends Legacy_Text Line 138  class Hyp_TextFilter extends Legacy_Text
138    
139                  if ($image) {                  if ($image) {
140                      // BB Code image with align                      // BB Code image with align
141                      $pat[$className][$image][] = '/\[img\s+align=([\'"]?)(left|center|right)\\1]([!~*\'();\/?:\@&=+\$,%#\w.-]+)\[\/img\]/US';                      $pat[$className][$image][] = '/\[img\s+align=([\'"]?)(left|center|right)\1(?:\s+title=([\'"]?)([^\'"][^\]\s]*?)\3)?(?:\s+w(?:idth)?=([\'"]?)([\d]+?)\5)?(?:\s+h(?:eight)?=([\'"]?)([\d]+?)\7)?]([!~*\'();\/?:\@&=+\$,%#\w.-]+)\[\/img\]/US';
142                      $rep[$className][$image][] = '&ref($3,$2);';                      $rep[$className][$image][] = '&ref($9,$2,"t:$4",mw:$6,mw:$8);';
143    
144                      // BB Code image normal                      // BB Code image normal
145                      $pat[$className][$image][] = '/\[img]([!~*\'();\/?:\@&=+\$,%#\w.-]+)\[\/img\]/US';                      $pat[$className][$image][] = '/\[img(?:\s+title=([\'"]?)([^\'"][^\]\s]*?)\1)?(?:\s+w(?:idth)?=([\'"]?)([\d]+?)\3)?(?:\s+h(?:eight)?=([\'"]?)([\d]+?)\5)?]([!~*\'();\/?:\@&=+\$,%#\w.-]+)\[\/img\]/US';
146                      $rep[$className][$image][] = '&ref($1);';                      $rep[$className][$image][] = '&ref($7,"t:$2",mw:$4,mw:$6);';
147                    } else {
148                        // BB Code image with align
149                        $pat[$className][$image][] = '/\[img\s+align=([\'"]?)(left|center|right)\1(?:\s+title=([\'"]?)([^\'"][^\]\s]*?)\3)?(?:\s+w(?:idth)?=([\'"]?)([\d]+?)\5)?(?:\s+h(?:eight)?=([\'"]?)([\d]+?)\7)?]([!~*\'();\/?:\@&=+\$,%#\w.-]+)\[\/img\]/US';
150                        $rep[$className][$image][] = '&ref($9,"t:$4",noimg);';
151    
152                        // BB Code image normal
153                        $pat[$className][$image][] = '/\[img(?:\s+title=([\'"]?)([^\'"][^\]\s]*?)\1)?(?:\s+w(?:idth)?=([\'"]?)([\d]+?)\3)?(?:\s+h(?:eight)?=([\'"]?)([\d]+?)\5)?]([!~*\'();\/?:\@&=+\$,%#\w.-]+)\[\/img\]/US';
154                        $rep[$className][$image][] = '&ref($7,"t:$2",noimg);';
155                  }                  }
156    
157                                    // BB Code siteimage with align
158                                    $pat[$className][$image][] = '/\[siteimg\s+align=([\'"]?)(left|center|right)\1(?:\s+title=([\'"]?)([^\'"][^\]\s]*?)\3)?(?:\s+w(?:idth)?=([\'"]?)([\d]+?)\5)?(?:\s+h(?:eight)?=([\'"]?)([\d]+?)\7)?]\/?([!~*\'();?\@&=+\$,%#\w.-][!~*\'();\/?\@&=+\$,%#\w.-]+?)\[\/siteimg\]/US';
159                                    $rep[$className][$image][] = '&ref('.XOOPS_URL.'/$9,$2,"t:$4",mw:$6,mw:$8);';
160    
161                                    // BB Code siteimage normal
162                                    $pat[$className][$image][] = '/\[siteimg(?:\s+title=([\'"]?)([^\'"][^\]\s]*?)\1)?(?:\s+w(?:idth)?=([\'"]?)([\d]+?)\3)?(?:\s+h(?:eight)?=([\'"]?)([\d]+?)\5)?]\/?([!~*\'();?\@&=+\$,%#\w.-][!~*\'();\/?\@&=+\$,%#\w.-]+?)\[\/siteimg\]/US';
163                                    $rep[$className][$image][] = '&ref('.XOOPS_URL.'/$7,"t:$2",mw:$4,mw:$6);';
164    
165                  // Some BB Code Tags, Contents allows xpWiki rendering.                  // Some BB Code Tags, Contents allows xpWiki rendering.
166                  if ($_reg = join('|', $this->renderWiki_getEscTags())) {                  if ($_reg = join('|', $this->renderWiki_getEscTags())) {
167                      $pat[$className][$image][] = '/\[\/?(?:' . $_reg . ')(?:(?: |=)[^\]]+)?\]/eS';                      $pat[$className][$image][] = '/\[\/?(?:' . $_reg . ')(?:(?: |=)[^\]]+)?\]/eS';
# Line 137  class Hyp_TextFilter extends Legacy_Text Line 170  class Hyp_TextFilter extends Legacy_Text
170    
171                  // Other or Unknown BB Code Tags, All part escapes.                  // Other or Unknown BB Code Tags, All part escapes.
172                  if ($_reg = join('|', $this->renderWiki_getBypassTags())) {                  if ($_reg = join('|', $this->renderWiki_getBypassTags())) {
173                      $pat[$className][$image][] = '/\[(' . $_reg . ')(?:\s[^\]]+)?].+\[\/\\1\]/esUS';                      $pat[$className][$image][] = '/\[(' . $_reg . ')(?:\b[^\]]+)?].+\[\/\\1\]/esUS';
174                      $rep[$className][$image][] = '\'[ b 6 4 ]\' . base64_encode(\'$0\') . \'[ / b 6 4 ]\'';                      $rep[$className][$image][] = '\'[ b 6 4 ]\' . base64_encode(\'$0\') . \'[ / b 6 4 ]\'';
175                  }                  }
176    

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26