• R/O
  • HTTP
  • SSH
  • HTTPS

nucleus-plugins: Commit

Nucleus CMS日本語版用プラグインのうち、日本語版開発者がサポートしているもの


Commit MetaInfo

Revisioneb5ab4511684a39a46c7a32f81e8c91c2eb76118 (tree)
Time2006-10-02 22:14:13
Authorshizuki <shizuki@1ca2...>
Commitershizuki

Log Message

temp

git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/plugin@398 1ca29b6e-896d-4ea0-84a5-967f57386b96

Change Summary

Incremental Difference

--- a/trunk/NP_Wikistyle/NP_Wikistyle.php
+++ b/trunk/NP_Wikistyle/NP_Wikistyle.php
@@ -1,30 +1,37 @@
11 <?php
22 // plugin needs to work on Nucleus versions <=2.0 as well
3-if (!function_exists('removeBreaks')){
4- function removeBreaks($var) { return preg_replace("/<br \/>([\r\n])/","$1",$var); }
3+if (!function_exists('removeBreaks')) {
4+ function removeBreaks($var)
5+ {
6+ return preg_replace("/<br \/>([\r\n])/", "$1", $var);
7+ }
58 }
69
710
811 class NP_Wikistyle extends NucleusPlugin {
912
10- function getName() { // name of plugin
13+ function getName()
14+ {
1115 return 'Wikistyle';
1216 }
1317
14- function getAuthor() { // author of plugin
15- return 'nakahara21';
18+ function getAuthor()
19+ {
20+ return 'nakahara21';
1621 }
1722
18- function getURL() { // an URL to the plugin website
19- return 'http://xx.nakahara21.net/';
23+ function getURL()
24+ {
25+ return 'http://nakahara21.com';
2026 }
2127
22- function getVersion() { // version of the plugin
23- return '0.5';
28+ function getVersion()
29+ {
30+ return '0.51';
2431 }
2532
26- // a description to be shown on the installed plugins listing
27- function getDescription() {
33+ function getDescription()
34+ {
2835 return 'convert WikiTag';
2936 }
3037
@@ -37,16 +44,24 @@ class NP_Wikistyle extends NucleusPlugin {
3744 }
3845 }
3946
40- function getEventList() { return array('PreItem'); }
47+ function getEventList()
48+ {
49+ return array(
50+ 'PreItem'
51+ );
52+ }
4153
42- function event_PreItem(&$data) {
43- $this->currentItem = &$data["item"];
44- $this->convert_wikitag($this->currentItem->body);
45- if($this->currentItem->more)
46- $this->convert_wikitag($this->currentItem->more);
54+ function event_PreItem(&$data)
55+ {
56+ $this->currentItem =& $data["item"];
57+ $this->convert_wikitag($this->currentItem->body);
58+ if ($this->currentItem->more) {
59+ $this->convert_wikitag($this->currentItem->more);
60+ }
4761 }
4862
49- function convert_wikitag(&$text) {
63+ function convert_wikitag(&$text)
64+ {
5065 $text = removeBreaks($text);
5166 $tmp_lines = explode("\n", $text);
5267 $tmp_lines[] = "&nbsp;";
@@ -55,7 +70,7 @@ class NP_Wikistyle extends NucleusPlugin {
5570 $templevel = array();
5671
5772 $endline = count($tmp_lines) - 1;
58- for($i=0;$i<=$endline;$i++){
73+ for ($i=0;$i<=$endline;$i++) {
5974 // $tmp_lines[$i] = trim($tmp_lines[$i]);
6075 $level = '';
6176 //__________
@@ -72,97 +87,109 @@ class NP_Wikistyle extends NucleusPlugin {
7287 '$this->createLinkCodeWiki("\\1", "\\3","mailto")'
7388 );
7489
75- if ($level[p] = preg_match('/^(https:\/\/|http:\/\/|www\.|ftp:\/\/|ftp\.|mailto:)/ie',$tmp_lines[$i]) ){
90+ if ($level[p] = preg_match('/^(https:\/\/|http:\/\/|www\.|ftp:\/\/|ftp\.|mailto:)/ie', $tmp_lines[$i])) {
7691 $tmp_lines[$i] = preg_replace($replaceFrom, $replaceTo, $tmp_lines[$i]);
77- $text .= $tmp_lines[$i]."<br />";
92+ $text .= $tmp_lines[$i] . '<br />';
7893 }
7994 //__________
80- if (($level[h] = strspn($tmp_lines[$i],'*')) > 6) {
95+ if (($level[h] = strspn($tmp_lines[$i], '*')) > 6) {
8196 $level[h] = 6; // limitation ;(
8297 }
83- if($level[h]){
84- $tmp_lines[$i] = ltrim(substr($tmp_lines[$i],$level[h]));
85- $text .= '<h'.$level[h].' class="wiki">'.$tmp_lines[$i].'</h'.$level[h].'>';
98+ if ($level[h]) {
99+ $tmp_lines[$i] = ltrim(substr($tmp_lines[$i], $level[h]));
100+ $text .= '<h' . intval($level[h]) . ' class="wiki">' . $tmp_lines[$i] . '</h' . intval($level[h]) . '>';
86101 }
87102 //__________
88- if (($level[u] = strspn($tmp_lines[$i],'-')) > 3){
103+ if (($level[u] = strspn($tmp_lines[$i], '-')) > 3) {
89104 $level[r] = 4;
90105 $level[u] = 3; // limitation ;(
91106 }
92- if($level[u] && !$level[r]){
93- $tmp_lines[$i] = ltrim(substr($tmp_lines[$i],$level[u]));
94-// $tmp_lines[$i] = '<li>'.$tmp_lines[$i].'</li>';
107+ if ($level[u] && !$level[r]) {
108+ $tmp_lines[$i] = ltrim(substr($tmp_lines[$i], $level[u]));
109+// $tmp_lines[$i] = '<li>' . $tmp_lines[$i] . '</li>';
95110 //_-------------
96- if($temptoplevel == 'u' && $templevel[o]){
97- $tmp_lines[$i] = str_repeat("</ol>\n",$templevel[o])."\n".'<li>'.$tmp_lines[$i].'</li>';
111+ if ($temptoplevel == 'u' && $templevel[o]) {
112+ $tmp_lines[$i] = str_repeat("</ol>\n",$templevel[o]) . "\n" . '<li>' . $tmp_lines[$i] . '</li>';
98113 $templevel[o] = 0;
99114 }else{
100- $tmp_lines[$i] = '<li>'.$tmp_lines[$i].'</li>';
115+ $tmp_lines[$i] = '<li>' . $tmp_lines[$i] . '</li>';
101116 }
102117 //_-------------
103118
104119 $difflevel = $level[u] - $templevel[u];
105- if($difflevel < 0)
106- $text .= str_repeat("</ul>\n",0-$difflevel);
107- if( $difflevel > 0)
108- $text .= str_repeat("<ul>\n",$difflevel);
120+ if ($difflevel < 0) {
121+ $text .= str_repeat("</ul>\n", 0 - $difflevel);
122+ }
123+ if ( $difflevel > 0) {
124+ $text .= str_repeat("<ul>\n", $difflevel);
125+ }
109126
110127 $text .= $tmp_lines[$i];
111- if(!array_sum($templevel))
128+ if (!array_sum($templevel)) {
112129 $temptoplevel = 'u';
130+ }
113131 $templevel[u] = $level[u];
114132 }
115133 //__________
116- if($level[r]){
117- $tmp_lines[$i] = ltrim(substr($tmp_lines[$i],$level[r]));
134+ if ($level[r]) {
135+ $tmp_lines[$i] = ltrim(substr($tmp_lines[$i], $level[r]));
118136 $text .= '<div class="hr"><hr /></div>';
119137 }
120138 //__________
121- if (($level[o] = strspn($tmp_lines[$i],'+')) > 3)
139+ if (($level[o] = strspn($tmp_lines[$i],'+')) > 3) {
122140 $level[o] = 3; // limitation ;(
123- if($level[o]){
124- $tmp_lines[$i] = ltrim(substr($tmp_lines[$i],$level[o]));
141+ }
142+ if ($level[o]) {
143+ $tmp_lines[$i] = ltrim(substr($tmp_lines[$i], $level[o]));
125144
126-// $tmp_lines[$i] = '<li>'.$tmp_lines[$i].'</li>';
145+// $tmp_lines[$i] = '<li>' . $tmp_lines[$i] . '</li>';
127146 //_-------------
128- if($temptoplevel == 'o' && $templevel[u]){
129- $tmp_lines[$i] = str_repeat("</ul>\n",$templevel[u])."\n".'<li>'.$tmp_lines[$i].'</li>';
147+ if ($temptoplevel == 'o' && $templevel[u]) {
148+ $tmp_lines[$i] = str_repeat("</ul>\n", $templevel[u]) . "\n" . '<li>' . $tmp_lines[$i] . '</li>';
130149 $templevel[u] = 0;
131- }else{
132- $tmp_lines[$i] = '<li>'.$tmp_lines[$i].'</li>';
150+ } else {
151+ $tmp_lines[$i] = '<li>' . $tmp_lines[$i] . '</li>';
133152 }
134153 //_-------------
135154
136155 $difflevel = $level[o] - $templevel[o];
137- if($difflevel < 0)
138- $text .= str_repeat("</ol>\n",0-$difflevel);
139- if( $difflevel > 0)
140- $text .= str_repeat("<ol>\n",$difflevel);
156+ if ($difflevel < 0) {
157+ $text .= str_repeat("</ol>\n", 0 - $difflevel);
158+ }
159+ if ( $difflevel > 0) {
160+ $text .= str_repeat("<ol>\n", $difflevel);
161+ }
141162
142163 $text .= $tmp_lines[$i];
143- if(!array_sum($templevel))
164+ if (!array_sum($templevel)) {
144165 $temptoplevel = 'o';
166+ }
145167 $templevel[o] = $level[o];
146168 }
147169 //__________
148- if(array_sum($level) == 0){
149- if(array_sum($templevel)){
150- if($templevel[u])
151- $text .= str_repeat("</ul>\n",$templevel[u]);
152- if($templevel[o])
153- $text .= str_repeat("</ol>\n",$templevel[o]);
170+ if (array_sum($level) == 0) {
171+ if (array_sum($templevel)) {
172+ if ($templevel[u]) {
173+ $text .= str_repeat("</ul>\n", $templevel[u]);
174+ }
175+ if ($templevel[o]) {
176+ $text .= str_repeat("</ol>\n", $templevel[o]);
177+ }
154178 $templevel = array();
155179 $temptoplevel = '';
156180 }
157- if($tmp_lines[$i] && $i != $endline)
181+ if ($tmp_lines[$i] && $i != $endline) {
158182 $text .= $tmp_lines[$i]."<br />";
183+ }
159184 }
160- if($tmp_lines[$i] && $i != $endline)
185+ if ($tmp_lines[$i] && $i != $endline) {
161186 $text .= "\n";
187+ }
162188 }
163189 }
164190
165- function createLinkCodeWiki($pre, $url, $protocol = 'http') {
191+ function createLinkCodeWiki($pre, $url, $protocol = 'http')
192+ {
166193 $post = '';
167194
168195 // it's possible that $url ends with an entities
@@ -172,17 +199,19 @@ class NP_Wikistyle extends NucleusPlugin {
172199 $url = substr($url, 0, strlen($url) - strlen($post));
173200 }
174201
175- if (!ereg('^'.$protocol.'://',$url))
202+ if (!ereg('^'.$protocol.'://',$url)) {
176203 $linkedUrl = $protocol . (($protocol == 'mailto') ? ':' : '://') . $url;
177- else
204+ } else {
178205 $linkedUrl = $url;
206+ }
179207
180208
181- if ($protocol != 'mailto')
209+ if ($protocol != 'mailto') {
182210 $displayedUrl = $linkedUrl;
183- else
211+ } else {
184212 $displayedUrl = $url;
185- return $pre . '<a href="'.$linkedUrl.'" target="_blank">'.$displayedUrl.'</a>' . $post;
213+ }
214+ return $pre . '<a href="' . htmlspecialchars($linkedUrl) . '" target="_blank">' . htmlspecialchars($displayedUrl) . '</a>' . $post;
186215 }
187216
188217
--- a/trunk/NP_Wtable/NP_Wtable.php
+++ b/trunk/NP_Wtable/NP_Wtable.php
@@ -2,24 +2,28 @@
22
33 class NP_Wtable extends NucleusPlugin {
44
5- function getName() { // name of plugin
6- return 'Convert table';
5+ function getName()
6+ {
7+ return 'Convert table';
78 }
8-
9- function getAuthor() { // author of plugin
10- return 'nakahara21';
9+
10+ function getAuthor()
11+ {
12+ return 'nakahara21';
1113 }
12-
13- function getURL() { // an URL to the plugin website
14- return 'http://xx.nakahara21.net/';
14+
15+ function getURL()
16+ {
17+ return 'http://nakahara21.com';
1518 }
1619
17- function getVersion() { // version of the plugin
18- return '0.2'; //tate array
20+ function getVersion()
21+ {
22+ return '0.21';
1923 }
20-
21- // a description to be shown on the installed plugins listing
22- function getDescription() {
24+
25+ function getDescription()
26+ {
2327 return 'Convert table';
2428 }
2529
@@ -32,13 +36,19 @@ class NP_Wtable extends NucleusPlugin {
3236 }
3337 }
3438
35- function getEventList() { return array('PreItem'); }
39+ function getEventList()
40+ {
41+ return array(
42+ 'PreItem'
43+ );
44+ }
3645
37- function event_PreItem(&$data) {
38- $this->currentItem = &$data["item"];
46+ function event_PreItem(&$data)
47+ {
48+ $this->currentItem =& $data["item"];
3949
4050 $this->currentItem->body = removeBreaks($this->currentItem->body);
41-// $this->currentItem->body = str_replace("\r\n","\n",$this->currentItem->body);
51+// $this->currentItem->body = str_replace("\r\n", "\n", $this->currentItem->body);
4252 $this->currentItem->body = preg_replace_callback("#\|(.*)\|\r\n#", array(&$this, 'list_table'), $this->currentItem->body);
4353 $this->currentItem->body = preg_replace_callback("#\!(.*)\!#", array(&$this, 'convert_table'), $this->currentItem->body);
4454 $this->currentItem->body = addBreaks($this->currentItem->body);
@@ -46,53 +56,55 @@ class NP_Wtable extends NucleusPlugin {
4656 $this->currentItem->more = preg_replace_callback("#\|(.*?)\|#", array(&$this, 'convert_table'), $this->currentItem->more);
4757 }
4858
49- function list_table($text) {
50- return "!".$text[1]."!";
59+ function list_table($text)
60+ {
61+ return "!" . $text[1] . "!";
5162 }
5263
53- function convert_table($text) {
54- $rows = explode('!!',$text[1]);
55- for($r =0; $r < count($rows); $r++){
56- $cell = explode('|',$rows["$r"]);
57- for($c = 0; $c < count($cell); $c++){
64+ function convert_table($text)
65+ {
66+ $rows = explode('!!', $text[1]);
67+ for ($r =0; $r < count($rows); $r++) {
68+ $cell = explode('|', $rows["$r"]);
69+ for ($c = 0; $c < count($cell); $c++) {
5870 $cols["$c"]["$r"] = $cell["$c"];
5971 }
6072 }
6173
62- for($c = 0; $c < count($cols); $c++){
74+ for ($c = 0; $c < count($cols); $c++) {
6375 $cols["$c"] = array_reverse ($cols["$c"], TRUE);
6476 $rowspan = 1;
6577 // print_r($cols["$c"]);
66- foreach($cols["$c"] as $key => $val){
67- if($val == '~'){
78+ foreach($cols["$c"] as $key => $val) {
79+ if ($val == '~') {
6880 $rowspan ++;
6981 $row["$key"]["$c"] = $val;
70- }elseif($val == '>'){
82+ } elseif($val == '>') {
7183 $row["$key"]["$c"] = $val;
72- }elseif($rowspan > 1){
73- $row["$key"]["$c"] = '<td rowspan="'.$rowspan.'">'.$val.'</td>';
84+ } elseif($rowspan > 1) {
85+ $row["$key"]["$c"] = '<td rowspan="' . intval($rowspan) . '">' . $val . '</td>';
7486 $rowspan = 1;
7587 }else{
76- $row["$key"]["$c"] = '<td>'.$val.'</td>';
88+ $row["$key"]["$c"] = '<td>' . $val . '</td>';
7789 }
7890 }
7991 }
8092 $row = array_reverse ($row, TRUE);
8193 // print_r($row);
8294
83- for($r = 0; $r < count($row); $r++){
95+ for ($r = 0; $r < count($row); $r++) {
8496 $out .= '<tr>';
8597 $colspan = 1;
86- for($c =0; $c < count($row["$r"]); $c++){
87- if($row["$r"]["$c"] == '~'){
98+ for ($c =0; $c < count($row["$r"]); $c++) {
99+ if ($row["$r"]["$c"] == '~') {
88100 $out .= '';
89- }elseif($row["$r"]["$c"] == '>'){
101+ } elseif ($row["$r"]["$c"] == '>') {
90102 $out .= '';
91103 $colspan ++;
92- }elseif($colspan >1){
93- $out .= str_replace('<td>','<td colspan="'.$colspan.'">',$row["$r"]["$c"]);
104+ } elseif ($colspan > 1) {
105+ $out .= str_replace('<td>', '<td colspan="' . intval($colspan) . '">', $row["$r"]["$c"]);
94106 $colspan = 1;
95- }else{
107+ } else {
96108 $out .= $row["$r"]["$c"];
97109 }
98110 }
@@ -100,7 +112,7 @@ class NP_Wtable extends NucleusPlugin {
100112 $out .= '</tr>';
101113 }
102114
103- return '<table border=1>'.$out.'</table>';
115+ return '<table border=1>' . $out . '</table>';
104116 }
105117 }
106118 ?>
\ No newline at end of file
Show on old repository browser