• R/O
  • HTTP
  • SSH
  • HTTPS

nucleus-plugins: Commit

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


Commit MetaInfo

Revisionfbb64ceb3e00d6d152f8c2aa15db4a2117b8e00d (tree)
Time2006-10-02 22:14:14
Author(no author) <(no author)@1ca2...>
Commiter(no author)

Log Message

This commit was manufactured by cvs2svn to create tag 't1'.

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

Change Summary

Incremental Difference

--- /dev/null
+++ b/tags/t1/NP_Wtable/NP_Wtable.php
@@ -0,0 +1,118 @@
1+<?php
2+
3+class NP_Wtable extends NucleusPlugin {
4+
5+ function getName()
6+ {
7+ return 'Convert table';
8+ }
9+
10+ function getAuthor()
11+ {
12+ return 'nakahara21';
13+ }
14+
15+ function getURL()
16+ {
17+ return 'http://nakahara21.com';
18+ }
19+
20+ function getVersion()
21+ {
22+ return '0.21';
23+ }
24+
25+ function getDescription()
26+ {
27+ return 'Convert table';
28+ }
29+
30+ function supportsFeature($what) {
31+ switch($what){
32+ case 'SqlTablePrefix':
33+ return 1;
34+ default:
35+ return 0;
36+ }
37+ }
38+
39+ function getEventList()
40+ {
41+ return array(
42+ 'PreItem'
43+ );
44+ }
45+
46+ function event_PreItem(&$data)
47+ {
48+ $this->currentItem =& $data["item"];
49+
50+ $this->currentItem->body = removeBreaks($this->currentItem->body);
51+// $this->currentItem->body = str_replace("\r\n", "\n", $this->currentItem->body);
52+ $this->currentItem->body = preg_replace_callback("#\|(.*)\|\r\n#", array(&$this, 'list_table'), $this->currentItem->body);
53+ $this->currentItem->body = preg_replace_callback("#\!(.*)\!#", array(&$this, 'convert_table'), $this->currentItem->body);
54+ $this->currentItem->body = addBreaks($this->currentItem->body);
55+
56+ $this->currentItem->more = preg_replace_callback("#\|(.*?)\|#", array(&$this, 'convert_table'), $this->currentItem->more);
57+ }
58+
59+ function list_table($text)
60+ {
61+ return "!" . $text[1] . "!";
62+ }
63+
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++) {
70+ $cols["$c"]["$r"] = $cell["$c"];
71+ }
72+ }
73+
74+ for ($c = 0; $c < count($cols); $c++) {
75+ $cols["$c"] = array_reverse ($cols["$c"], TRUE);
76+ $rowspan = 1;
77+// print_r($cols["$c"]);
78+ foreach($cols["$c"] as $key => $val) {
79+ if ($val == '~') {
80+ $rowspan ++;
81+ $row["$key"]["$c"] = $val;
82+ } elseif($val == '>') {
83+ $row["$key"]["$c"] = $val;
84+ } elseif($rowspan > 1) {
85+ $row["$key"]["$c"] = '<td rowspan="' . intval($rowspan) . '">' . $val . '</td>';
86+ $rowspan = 1;
87+ }else{
88+ $row["$key"]["$c"] = '<td>' . $val . '</td>';
89+ }
90+ }
91+ }
92+ $row = array_reverse ($row, TRUE);
93+// print_r($row);
94+
95+ for ($r = 0; $r < count($row); $r++) {
96+ $out .= '<tr>';
97+ $colspan = 1;
98+ for ($c =0; $c < count($row["$r"]); $c++) {
99+ if ($row["$r"]["$c"] == '~') {
100+ $out .= '';
101+ } elseif ($row["$r"]["$c"] == '>') {
102+ $out .= '';
103+ $colspan ++;
104+ } elseif ($colspan > 1) {
105+ $out .= str_replace('<td>', '<td colspan="' . intval($colspan) . '">', $row["$r"]["$c"]);
106+ $colspan = 1;
107+ } else {
108+ $out .= $row["$r"]["$c"];
109+ }
110+ }
111+
112+ $out .= '</tr>';
113+ }
114+
115+ return '<table border=1>' . $out . '</table>';
116+ }
117+}
118+?>
\ No newline at end of file
Show on old repository browser