@@ -18,197 +18,197 @@ |
||
18 | 18 | */ |
19 | 19 | class Html2Text { |
20 | 20 | |
21 | - // Private fields |
|
21 | + // Private fields |
|
22 | 22 | |
23 | - var $iCurrentLine = ""; |
|
24 | - var $iCurrentWord = ""; |
|
25 | - var $iCurrentWordArray; |
|
26 | - var $iCurrentWordIndex; |
|
27 | - var $iInScript; |
|
28 | - var $iListLevel = 0; |
|
29 | - var $iHtmlText; |
|
30 | - var $iMaxColumns; |
|
31 | - var $iHtmlParser; |
|
23 | + var $iCurrentLine = ""; |
|
24 | + var $iCurrentWord = ""; |
|
25 | + var $iCurrentWordArray; |
|
26 | + var $iCurrentWordIndex; |
|
27 | + var $iInScript; |
|
28 | + var $iListLevel = 0; |
|
29 | + var $iHtmlText; |
|
30 | + var $iMaxColumns; |
|
31 | + var $iHtmlParser; |
|
32 | 32 | |
33 | - // Constants |
|
33 | + // Constants |
|
34 | 34 | |
35 | - var $TOKEN_BR = 0; |
|
36 | - var $TOKEN_P = 1; |
|
37 | - var $TOKEN_LI = 2; |
|
38 | - var $TOKEN_AFTERLI = 3; |
|
39 | - var $TOKEN_UL = 4; |
|
40 | - var $TOKEN_ENDUL = 5; |
|
35 | + var $TOKEN_BR = 0; |
|
36 | + var $TOKEN_P = 1; |
|
37 | + var $TOKEN_LI = 2; |
|
38 | + var $TOKEN_AFTERLI = 3; |
|
39 | + var $TOKEN_UL = 4; |
|
40 | + var $TOKEN_ENDUL = 5; |
|
41 | 41 | |
42 | - function Html2Text ($aHtmlText, $aMaxColumns) { |
|
43 | - $this->iHtmlText = $aHtmlText; |
|
44 | - $this->iMaxColumns = $aMaxColumns; |
|
45 | - } |
|
42 | + function Html2Text ($aHtmlText, $aMaxColumns) { |
|
43 | + $this->iHtmlText = $aHtmlText; |
|
44 | + $this->iMaxColumns = $aMaxColumns; |
|
45 | + } |
|
46 | 46 | |
47 | - function convert() { |
|
48 | - $this->iHtmlParser = new HtmlParser($this->iHtmlText); |
|
49 | - $wholeText = ""; |
|
50 | - while (($line = $this->getLine()) !== false) { |
|
51 | - $wholeText .= ($line . "\r\n"); |
|
52 | - } |
|
53 | - return $wholeText; |
|
54 | - } |
|
47 | + function convert() { |
|
48 | + $this->iHtmlParser = new HtmlParser($this->iHtmlText); |
|
49 | + $wholeText = ""; |
|
50 | + while (($line = $this->getLine()) !== false) { |
|
51 | + $wholeText .= ($line . "\r\n"); |
|
52 | + } |
|
53 | + return $wholeText; |
|
54 | + } |
|
55 | 55 | |
56 | - function getLine() { |
|
57 | - while (true) { |
|
58 | - if (!$this->addWordToLine($this->iCurrentWord)) { |
|
59 | - $retvalue = $this->iCurrentLine; |
|
60 | - $this->iCurrentLine = ""; |
|
61 | - return $retvalue; |
|
62 | - } |
|
63 | - $word = $this->getWord(); |
|
64 | - if ($word === false) { |
|
65 | - if ($this->iCurrentLine == "") { |
|
66 | - break; |
|
67 | - } |
|
68 | - $retvalue = $this->iCurrentLine; |
|
69 | - $this->iCurrentLine = ""; |
|
70 | - $this->iInText = false; |
|
71 | - $this->iCurrentWord = ""; |
|
72 | - return $retvalue; |
|
73 | - } |
|
74 | - } |
|
75 | - return false; |
|
76 | - } |
|
56 | + function getLine() { |
|
57 | + while (true) { |
|
58 | + if (!$this->addWordToLine($this->iCurrentWord)) { |
|
59 | + $retvalue = $this->iCurrentLine; |
|
60 | + $this->iCurrentLine = ""; |
|
61 | + return $retvalue; |
|
62 | + } |
|
63 | + $word = $this->getWord(); |
|
64 | + if ($word === false) { |
|
65 | + if ($this->iCurrentLine == "") { |
|
66 | + break; |
|
67 | + } |
|
68 | + $retvalue = $this->iCurrentLine; |
|
69 | + $this->iCurrentLine = ""; |
|
70 | + $this->iInText = false; |
|
71 | + $this->iCurrentWord = ""; |
|
72 | + return $retvalue; |
|
73 | + } |
|
74 | + } |
|
75 | + return false; |
|
76 | + } |
|
77 | 77 | |
78 | - function addWordToLine ($word) { |
|
79 | - if ($this->iInScript) { |
|
80 | - return true; |
|
81 | - } |
|
82 | - $prevLine = $this->iCurrentLine; |
|
83 | - if ($word === $this->TOKEN_BR) { |
|
84 | - $this->iCurrentWord = ""; |
|
85 | - return false; |
|
86 | - } |
|
87 | - if ($word === $this->TOKEN_P) { |
|
88 | - $this->iCurrentWord = $this->TOKEN_BR; |
|
89 | - return false; |
|
90 | - } |
|
91 | - if ($word === $this->TOKEN_UL) { |
|
92 | - $this->iCurrentWord = $this->TOKEN_BR; |
|
93 | - return false; |
|
94 | - } |
|
95 | - if ($word === $this->TOKEN_ENDUL) { |
|
96 | - $this->iCurrentWord = $this->TOKEN_BR; |
|
97 | - return false; |
|
98 | - } |
|
99 | - if ($word === $this->TOKEN_LI) { |
|
100 | - $this->iCurrentWord = $this->TOKEN_AFTERLI; |
|
101 | - return false; |
|
102 | - } |
|
103 | - $toAdd = $word; |
|
104 | - if ($word === $this->TOKEN_AFTERLI) { |
|
105 | - $toAdd = ""; |
|
106 | - } |
|
107 | - if ($prevLine != "") { |
|
108 | - $prevLine .= " "; |
|
109 | - } |
|
110 | - else { |
|
111 | - $prevLine = $this->getIndentation($word === $this->TOKEN_AFTERLI); |
|
112 | - } |
|
113 | - $candidateLine = $prevLine . $toAdd; |
|
114 | - if (strlen ($candidateLine) > $this->iMaxColumns && $prevLine != "") { |
|
115 | - return false; |
|
116 | - } |
|
117 | - $this->iCurrentLine = $candidateLine; |
|
118 | - return true; |
|
119 | - } |
|
78 | + function addWordToLine ($word) { |
|
79 | + if ($this->iInScript) { |
|
80 | + return true; |
|
81 | + } |
|
82 | + $prevLine = $this->iCurrentLine; |
|
83 | + if ($word === $this->TOKEN_BR) { |
|
84 | + $this->iCurrentWord = ""; |
|
85 | + return false; |
|
86 | + } |
|
87 | + if ($word === $this->TOKEN_P) { |
|
88 | + $this->iCurrentWord = $this->TOKEN_BR; |
|
89 | + return false; |
|
90 | + } |
|
91 | + if ($word === $this->TOKEN_UL) { |
|
92 | + $this->iCurrentWord = $this->TOKEN_BR; |
|
93 | + return false; |
|
94 | + } |
|
95 | + if ($word === $this->TOKEN_ENDUL) { |
|
96 | + $this->iCurrentWord = $this->TOKEN_BR; |
|
97 | + return false; |
|
98 | + } |
|
99 | + if ($word === $this->TOKEN_LI) { |
|
100 | + $this->iCurrentWord = $this->TOKEN_AFTERLI; |
|
101 | + return false; |
|
102 | + } |
|
103 | + $toAdd = $word; |
|
104 | + if ($word === $this->TOKEN_AFTERLI) { |
|
105 | + $toAdd = ""; |
|
106 | + } |
|
107 | + if ($prevLine != "") { |
|
108 | + $prevLine .= " "; |
|
109 | + } |
|
110 | + else { |
|
111 | + $prevLine = $this->getIndentation($word === $this->TOKEN_AFTERLI); |
|
112 | + } |
|
113 | + $candidateLine = $prevLine . $toAdd; |
|
114 | + if (strlen ($candidateLine) > $this->iMaxColumns && $prevLine != "") { |
|
115 | + return false; |
|
116 | + } |
|
117 | + $this->iCurrentLine = $candidateLine; |
|
118 | + return true; |
|
119 | + } |
|
120 | 120 | |
121 | - function getWord() { |
|
122 | - while (true) { |
|
123 | - if ($this->iHtmlParser->iNodeType == NODE_TYPE_TEXT) { |
|
124 | - if (!$this->iInText) { |
|
125 | - $words = $this->splitWords($this->iHtmlParser->iNodeValue); |
|
126 | - $this->iCurrentWordArray = $words; |
|
127 | - $this->iCurrentWordIndex = 0; |
|
128 | - $this->iInText = true; |
|
129 | - } |
|
130 | - if ($this->iCurrentWordIndex < count($this->iCurrentWordArray)) { |
|
131 | - $this->iCurrentWord = $this->iCurrentWordArray[$this->iCurrentWordIndex++]; |
|
132 | - return $this->iCurrentWord; |
|
133 | - } |
|
134 | - else { |
|
135 | - $this->iInText = false; |
|
136 | - } |
|
137 | - } |
|
138 | - else if ($this->iHtmlParser->iNodeType == NODE_TYPE_ELEMENT) { |
|
139 | - if (strcasecmp ($this->iHtmlParser->iNodeName, "br") == 0) { |
|
140 | - $this->iHtmlParser->parse(); |
|
141 | - $this->iCurrentWord = $this->TOKEN_BR; |
|
142 | - return $this->iCurrentWord; |
|
143 | - } |
|
144 | - else if (strcasecmp ($this->iHtmlParser->iNodeName, "p") == 0) { |
|
145 | - $this->iHtmlParser->parse(); |
|
146 | - $this->iCurrentWord = $this->TOKEN_P; |
|
147 | - return $this->iCurrentWord; |
|
148 | - } |
|
149 | - else if (strcasecmp ($this->iHtmlParser->iNodeName, "script") == 0) { |
|
150 | - $this->iHtmlParser->parse(); |
|
151 | - $this->iCurrentWord = ""; |
|
152 | - $this->iInScript = true; |
|
153 | - return $this->iCurrentWord; |
|
154 | - } |
|
155 | - else if (strcasecmp ($this->iHtmlParser->iNodeName, "ul") == 0 || strcasecmp ($this->iHtmlParser->iNodeName, "ol") == 0) { |
|
156 | - $this->iHtmlParser->parse(); |
|
157 | - $this->iCurrentWord = $this->TOKEN_UL; |
|
158 | - $this->iListLevel++; |
|
159 | - return $this->iCurrentWord; |
|
160 | - } |
|
161 | - else if (strcasecmp ($this->iHtmlParser->iNodeName, "li") == 0) { |
|
162 | - $this->iHtmlParser->parse(); |
|
163 | - $this->iCurrentWord = $this->TOKEN_LI; |
|
164 | - return $this->iCurrentWord; |
|
165 | - } |
|
166 | - } |
|
167 | - else if ($this->iHtmlParser->iNodeType == NODE_TYPE_ENDELEMENT) { |
|
168 | - if (strcasecmp ($this->iHtmlParser->iNodeName, "script") == 0) { |
|
169 | - $this->iHtmlParser->parse(); |
|
170 | - $this->iCurrentWord = ""; |
|
171 | - $this->iInScript = false; |
|
172 | - return $this->iCurrentWord; |
|
173 | - } |
|
174 | - else if (strcasecmp ($this->iHtmlParser->iNodeName, "ul") == 0 || strcasecmp ($this->iHtmlParser->iNodeName, "ol") == 0) { |
|
175 | - $this->iHtmlParser->parse(); |
|
176 | - $this->iCurrentWord = $this->TOKEN_ENDUL; |
|
177 | - if ($this->iListLevel > 0) { |
|
178 | - $this->iListLevel--; |
|
179 | - } |
|
180 | - return $this->iCurrentWord; |
|
181 | - } |
|
182 | - } |
|
183 | - if (!$this->iHtmlParser->parse()) { |
|
184 | - break; |
|
185 | - } |
|
186 | - } |
|
187 | - return false; |
|
188 | - } |
|
121 | + function getWord() { |
|
122 | + while (true) { |
|
123 | + if ($this->iHtmlParser->iNodeType == NODE_TYPE_TEXT) { |
|
124 | + if (!$this->iInText) { |
|
125 | + $words = $this->splitWords($this->iHtmlParser->iNodeValue); |
|
126 | + $this->iCurrentWordArray = $words; |
|
127 | + $this->iCurrentWordIndex = 0; |
|
128 | + $this->iInText = true; |
|
129 | + } |
|
130 | + if ($this->iCurrentWordIndex < count($this->iCurrentWordArray)) { |
|
131 | + $this->iCurrentWord = $this->iCurrentWordArray[$this->iCurrentWordIndex++]; |
|
132 | + return $this->iCurrentWord; |
|
133 | + } |
|
134 | + else { |
|
135 | + $this->iInText = false; |
|
136 | + } |
|
137 | + } |
|
138 | + else if ($this->iHtmlParser->iNodeType == NODE_TYPE_ELEMENT) { |
|
139 | + if (strcasecmp ($this->iHtmlParser->iNodeName, "br") == 0) { |
|
140 | + $this->iHtmlParser->parse(); |
|
141 | + $this->iCurrentWord = $this->TOKEN_BR; |
|
142 | + return $this->iCurrentWord; |
|
143 | + } |
|
144 | + else if (strcasecmp ($this->iHtmlParser->iNodeName, "p") == 0) { |
|
145 | + $this->iHtmlParser->parse(); |
|
146 | + $this->iCurrentWord = $this->TOKEN_P; |
|
147 | + return $this->iCurrentWord; |
|
148 | + } |
|
149 | + else if (strcasecmp ($this->iHtmlParser->iNodeName, "script") == 0) { |
|
150 | + $this->iHtmlParser->parse(); |
|
151 | + $this->iCurrentWord = ""; |
|
152 | + $this->iInScript = true; |
|
153 | + return $this->iCurrentWord; |
|
154 | + } |
|
155 | + else if (strcasecmp ($this->iHtmlParser->iNodeName, "ul") == 0 || strcasecmp ($this->iHtmlParser->iNodeName, "ol") == 0) { |
|
156 | + $this->iHtmlParser->parse(); |
|
157 | + $this->iCurrentWord = $this->TOKEN_UL; |
|
158 | + $this->iListLevel++; |
|
159 | + return $this->iCurrentWord; |
|
160 | + } |
|
161 | + else if (strcasecmp ($this->iHtmlParser->iNodeName, "li") == 0) { |
|
162 | + $this->iHtmlParser->parse(); |
|
163 | + $this->iCurrentWord = $this->TOKEN_LI; |
|
164 | + return $this->iCurrentWord; |
|
165 | + } |
|
166 | + } |
|
167 | + else if ($this->iHtmlParser->iNodeType == NODE_TYPE_ENDELEMENT) { |
|
168 | + if (strcasecmp ($this->iHtmlParser->iNodeName, "script") == 0) { |
|
169 | + $this->iHtmlParser->parse(); |
|
170 | + $this->iCurrentWord = ""; |
|
171 | + $this->iInScript = false; |
|
172 | + return $this->iCurrentWord; |
|
173 | + } |
|
174 | + else if (strcasecmp ($this->iHtmlParser->iNodeName, "ul") == 0 || strcasecmp ($this->iHtmlParser->iNodeName, "ol") == 0) { |
|
175 | + $this->iHtmlParser->parse(); |
|
176 | + $this->iCurrentWord = $this->TOKEN_ENDUL; |
|
177 | + if ($this->iListLevel > 0) { |
|
178 | + $this->iListLevel--; |
|
179 | + } |
|
180 | + return $this->iCurrentWord; |
|
181 | + } |
|
182 | + } |
|
183 | + if (!$this->iHtmlParser->parse()) { |
|
184 | + break; |
|
185 | + } |
|
186 | + } |
|
187 | + return false; |
|
188 | + } |
|
189 | 189 | |
190 | - function splitWords ($text) { |
|
191 | - $words = split ("[ \t\r\n]+", $text); |
|
192 | - for ($idx = 0; $idx < count($words); $idx++) { |
|
193 | - $words[$idx] = $this->htmlDecode($words[$idx]); |
|
194 | - } |
|
195 | - return $words; |
|
196 | - } |
|
190 | + function splitWords ($text) { |
|
191 | + $words = split ("[ \t\r\n]+", $text); |
|
192 | + for ($idx = 0; $idx < count($words); $idx++) { |
|
193 | + $words[$idx] = $this->htmlDecode($words[$idx]); |
|
194 | + } |
|
195 | + return $words; |
|
196 | + } |
|
197 | 197 | |
198 | - function htmlDecode ($text) { |
|
199 | - // TBD |
|
200 | - return $text; |
|
201 | - } |
|
198 | + function htmlDecode ($text) { |
|
199 | + // TBD |
|
200 | + return $text; |
|
201 | + } |
|
202 | 202 | |
203 | - function getIndentation ($hasLI) { |
|
204 | - $indent = ""; |
|
205 | - $idx = 0; |
|
206 | - for ($idx = 0; $idx < ($this->iListLevel - 1); $idx++) { |
|
207 | - $indent .= " "; |
|
208 | - } |
|
209 | - if ($this->iListLevel > 0) { |
|
210 | - $indent = $hasLI ? ($indent . "- ") : ($indent . " "); |
|
211 | - } |
|
212 | - return $indent; |
|
213 | - } |
|
203 | + function getIndentation ($hasLI) { |
|
204 | + $indent = ""; |
|
205 | + $idx = 0; |
|
206 | + for ($idx = 0; $idx < ($this->iListLevel - 1); $idx++) { |
|
207 | + $indent .= " "; |
|
208 | + } |
|
209 | + if ($this->iListLevel > 0) { |
|
210 | + $indent = $hasLI ? ($indent . "- ") : ($indent . " "); |
|
211 | + } |
|
212 | + return $indent; |
|
213 | + } |
|
214 | 214 | } |
@@ -106,8 +106,7 @@ discard block |
||
106 | 106 | } |
107 | 107 | if ($prevLine != "") { |
108 | 108 | $prevLine .= " "; |
109 | - } |
|
110 | - else { |
|
109 | + } else { |
|
111 | 110 | $prevLine = $this->getIndentation($word === $this->TOKEN_AFTERLI); |
112 | 111 | } |
113 | 112 | $candidateLine = $prevLine . $toAdd; |
@@ -130,48 +129,40 @@ discard block |
||
130 | 129 | if ($this->iCurrentWordIndex < count($this->iCurrentWordArray)) { |
131 | 130 | $this->iCurrentWord = $this->iCurrentWordArray[$this->iCurrentWordIndex++]; |
132 | 131 | return $this->iCurrentWord; |
133 | - } |
|
134 | - else { |
|
132 | + } else { |
|
135 | 133 | $this->iInText = false; |
136 | 134 | } |
137 | - } |
|
138 | - else if ($this->iHtmlParser->iNodeType == NODE_TYPE_ELEMENT) { |
|
135 | + } else if ($this->iHtmlParser->iNodeType == NODE_TYPE_ELEMENT) { |
|
139 | 136 | if (strcasecmp ($this->iHtmlParser->iNodeName, "br") == 0) { |
140 | 137 | $this->iHtmlParser->parse(); |
141 | 138 | $this->iCurrentWord = $this->TOKEN_BR; |
142 | 139 | return $this->iCurrentWord; |
143 | - } |
|
144 | - else if (strcasecmp ($this->iHtmlParser->iNodeName, "p") == 0) { |
|
140 | + } else if (strcasecmp ($this->iHtmlParser->iNodeName, "p") == 0) { |
|
145 | 141 | $this->iHtmlParser->parse(); |
146 | 142 | $this->iCurrentWord = $this->TOKEN_P; |
147 | 143 | return $this->iCurrentWord; |
148 | - } |
|
149 | - else if (strcasecmp ($this->iHtmlParser->iNodeName, "script") == 0) { |
|
144 | + } else if (strcasecmp ($this->iHtmlParser->iNodeName, "script") == 0) { |
|
150 | 145 | $this->iHtmlParser->parse(); |
151 | 146 | $this->iCurrentWord = ""; |
152 | 147 | $this->iInScript = true; |
153 | 148 | return $this->iCurrentWord; |
154 | - } |
|
155 | - else if (strcasecmp ($this->iHtmlParser->iNodeName, "ul") == 0 || strcasecmp ($this->iHtmlParser->iNodeName, "ol") == 0) { |
|
149 | + } else if (strcasecmp ($this->iHtmlParser->iNodeName, "ul") == 0 || strcasecmp ($this->iHtmlParser->iNodeName, "ol") == 0) { |
|
156 | 150 | $this->iHtmlParser->parse(); |
157 | 151 | $this->iCurrentWord = $this->TOKEN_UL; |
158 | 152 | $this->iListLevel++; |
159 | 153 | return $this->iCurrentWord; |
160 | - } |
|
161 | - else if (strcasecmp ($this->iHtmlParser->iNodeName, "li") == 0) { |
|
154 | + } else if (strcasecmp ($this->iHtmlParser->iNodeName, "li") == 0) { |
|
162 | 155 | $this->iHtmlParser->parse(); |
163 | 156 | $this->iCurrentWord = $this->TOKEN_LI; |
164 | 157 | return $this->iCurrentWord; |
165 | 158 | } |
166 | - } |
|
167 | - else if ($this->iHtmlParser->iNodeType == NODE_TYPE_ENDELEMENT) { |
|
159 | + } else if ($this->iHtmlParser->iNodeType == NODE_TYPE_ENDELEMENT) { |
|
168 | 160 | if (strcasecmp ($this->iHtmlParser->iNodeName, "script") == 0) { |
169 | 161 | $this->iHtmlParser->parse(); |
170 | 162 | $this->iCurrentWord = ""; |
171 | 163 | $this->iInScript = false; |
172 | 164 | return $this->iCurrentWord; |
173 | - } |
|
174 | - else if (strcasecmp ($this->iHtmlParser->iNodeName, "ul") == 0 || strcasecmp ($this->iHtmlParser->iNodeName, "ol") == 0) { |
|
165 | + } else if (strcasecmp ($this->iHtmlParser->iNodeName, "ul") == 0 || strcasecmp ($this->iHtmlParser->iNodeName, "ol") == 0) { |
|
175 | 166 | $this->iHtmlParser->parse(); |
176 | 167 | $this->iCurrentWord = $this->TOKEN_ENDUL; |
177 | 168 | if ($this->iListLevel > 0) { |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | var $TOKEN_UL = 4; |
40 | 40 | var $TOKEN_ENDUL = 5; |
41 | 41 | |
42 | - function Html2Text ($aHtmlText, $aMaxColumns) { |
|
42 | + function Html2Text($aHtmlText, $aMaxColumns) { |
|
43 | 43 | $this->iHtmlText = $aHtmlText; |
44 | 44 | $this->iMaxColumns = $aMaxColumns; |
45 | 45 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | $this->iHtmlParser = new HtmlParser($this->iHtmlText); |
49 | 49 | $wholeText = ""; |
50 | 50 | while (($line = $this->getLine()) !== false) { |
51 | - $wholeText .= ($line . "\r\n"); |
|
51 | + $wholeText .= ($line."\r\n"); |
|
52 | 52 | } |
53 | 53 | return $wholeText; |
54 | 54 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | return false; |
76 | 76 | } |
77 | 77 | |
78 | - function addWordToLine ($word) { |
|
78 | + function addWordToLine($word) { |
|
79 | 79 | if ($this->iInScript) { |
80 | 80 | return true; |
81 | 81 | } |
@@ -110,8 +110,8 @@ discard block |
||
110 | 110 | else { |
111 | 111 | $prevLine = $this->getIndentation($word === $this->TOKEN_AFTERLI); |
112 | 112 | } |
113 | - $candidateLine = $prevLine . $toAdd; |
|
114 | - if (strlen ($candidateLine) > $this->iMaxColumns && $prevLine != "") { |
|
113 | + $candidateLine = $prevLine.$toAdd; |
|
114 | + if (strlen($candidateLine) > $this->iMaxColumns && $prevLine != "") { |
|
115 | 115 | return false; |
116 | 116 | } |
117 | 117 | $this->iCurrentLine = $candidateLine; |
@@ -136,42 +136,42 @@ discard block |
||
136 | 136 | } |
137 | 137 | } |
138 | 138 | else if ($this->iHtmlParser->iNodeType == NODE_TYPE_ELEMENT) { |
139 | - if (strcasecmp ($this->iHtmlParser->iNodeName, "br") == 0) { |
|
139 | + if (strcasecmp($this->iHtmlParser->iNodeName, "br") == 0) { |
|
140 | 140 | $this->iHtmlParser->parse(); |
141 | 141 | $this->iCurrentWord = $this->TOKEN_BR; |
142 | 142 | return $this->iCurrentWord; |
143 | 143 | } |
144 | - else if (strcasecmp ($this->iHtmlParser->iNodeName, "p") == 0) { |
|
144 | + else if (strcasecmp($this->iHtmlParser->iNodeName, "p") == 0) { |
|
145 | 145 | $this->iHtmlParser->parse(); |
146 | 146 | $this->iCurrentWord = $this->TOKEN_P; |
147 | 147 | return $this->iCurrentWord; |
148 | 148 | } |
149 | - else if (strcasecmp ($this->iHtmlParser->iNodeName, "script") == 0) { |
|
149 | + else if (strcasecmp($this->iHtmlParser->iNodeName, "script") == 0) { |
|
150 | 150 | $this->iHtmlParser->parse(); |
151 | 151 | $this->iCurrentWord = ""; |
152 | 152 | $this->iInScript = true; |
153 | 153 | return $this->iCurrentWord; |
154 | 154 | } |
155 | - else if (strcasecmp ($this->iHtmlParser->iNodeName, "ul") == 0 || strcasecmp ($this->iHtmlParser->iNodeName, "ol") == 0) { |
|
155 | + else if (strcasecmp($this->iHtmlParser->iNodeName, "ul") == 0 || strcasecmp($this->iHtmlParser->iNodeName, "ol") == 0) { |
|
156 | 156 | $this->iHtmlParser->parse(); |
157 | 157 | $this->iCurrentWord = $this->TOKEN_UL; |
158 | 158 | $this->iListLevel++; |
159 | 159 | return $this->iCurrentWord; |
160 | 160 | } |
161 | - else if (strcasecmp ($this->iHtmlParser->iNodeName, "li") == 0) { |
|
161 | + else if (strcasecmp($this->iHtmlParser->iNodeName, "li") == 0) { |
|
162 | 162 | $this->iHtmlParser->parse(); |
163 | 163 | $this->iCurrentWord = $this->TOKEN_LI; |
164 | 164 | return $this->iCurrentWord; |
165 | 165 | } |
166 | 166 | } |
167 | 167 | else if ($this->iHtmlParser->iNodeType == NODE_TYPE_ENDELEMENT) { |
168 | - if (strcasecmp ($this->iHtmlParser->iNodeName, "script") == 0) { |
|
168 | + if (strcasecmp($this->iHtmlParser->iNodeName, "script") == 0) { |
|
169 | 169 | $this->iHtmlParser->parse(); |
170 | 170 | $this->iCurrentWord = ""; |
171 | 171 | $this->iInScript = false; |
172 | 172 | return $this->iCurrentWord; |
173 | 173 | } |
174 | - else if (strcasecmp ($this->iHtmlParser->iNodeName, "ul") == 0 || strcasecmp ($this->iHtmlParser->iNodeName, "ol") == 0) { |
|
174 | + else if (strcasecmp($this->iHtmlParser->iNodeName, "ul") == 0 || strcasecmp($this->iHtmlParser->iNodeName, "ol") == 0) { |
|
175 | 175 | $this->iHtmlParser->parse(); |
176 | 176 | $this->iCurrentWord = $this->TOKEN_ENDUL; |
177 | 177 | if ($this->iListLevel > 0) { |
@@ -187,27 +187,27 @@ discard block |
||
187 | 187 | return false; |
188 | 188 | } |
189 | 189 | |
190 | - function splitWords ($text) { |
|
191 | - $words = split ("[ \t\r\n]+", $text); |
|
190 | + function splitWords($text) { |
|
191 | + $words = split("[ \t\r\n]+", $text); |
|
192 | 192 | for ($idx = 0; $idx < count($words); $idx++) { |
193 | 193 | $words[$idx] = $this->htmlDecode($words[$idx]); |
194 | 194 | } |
195 | 195 | return $words; |
196 | 196 | } |
197 | 197 | |
198 | - function htmlDecode ($text) { |
|
198 | + function htmlDecode($text) { |
|
199 | 199 | // TBD |
200 | 200 | return $text; |
201 | 201 | } |
202 | 202 | |
203 | - function getIndentation ($hasLI) { |
|
203 | + function getIndentation($hasLI) { |
|
204 | 204 | $indent = ""; |
205 | 205 | $idx = 0; |
206 | 206 | for ($idx = 0; $idx < ($this->iListLevel - 1); $idx++) { |
207 | 207 | $indent .= " "; |
208 | 208 | } |
209 | 209 | if ($this->iListLevel > 0) { |
210 | - $indent = $hasLI ? ($indent . "- ") : ($indent . " "); |
|
210 | + $indent = $hasLI ? ($indent."- ") : ($indent." "); |
|
211 | 211 | } |
212 | 212 | return $indent; |
213 | 213 | } |
@@ -75,6 +75,9 @@ discard block |
||
75 | 75 | return false; |
76 | 76 | } |
77 | 77 | |
78 | + /** |
|
79 | + * @param string $word |
|
80 | + */ |
|
78 | 81 | function addWordToLine ($word) { |
79 | 82 | if ($this->iInScript) { |
80 | 83 | return true; |
@@ -187,6 +190,9 @@ discard block |
||
187 | 190 | return false; |
188 | 191 | } |
189 | 192 | |
193 | + /** |
|
194 | + * @param string $text |
|
195 | + */ |
|
190 | 196 | function splitWords ($text) { |
191 | 197 | $words = split ("[ \t\r\n]+", $text); |
192 | 198 | for ($idx = 0; $idx < count($words); $idx++) { |
@@ -200,6 +206,9 @@ discard block |
||
200 | 206 | return $text; |
201 | 207 | } |
202 | 208 | |
209 | + /** |
|
210 | + * @param boolean $hasLI |
|
211 | + */ |
|
203 | 212 | function getIndentation ($hasLI) { |
204 | 213 | $indent = ""; |
205 | 214 | $idx = 0; |
@@ -129,8 +129,7 @@ discard block |
||
129 | 129 | $this->iNodeName = "Comment"; |
130 | 130 | $this->iNodeValue = "<" . $name . ">"; |
131 | 131 | $comment = true; |
132 | - } |
|
133 | - else { |
|
132 | + } else { |
|
134 | 133 | $rest = $this->skipToStringInTag ("-->"); |
135 | 134 | if ($rest != "") { |
136 | 135 | $this->iNodeType = NODE_TYPE_COMMENT; |
@@ -148,8 +147,7 @@ discard block |
||
148 | 147 | $this->iNodeValue = "<" . $name; |
149 | 148 | return true; |
150 | 149 | } |
151 | - } |
|
152 | - else { |
|
150 | + } else { |
|
153 | 151 | $this->iNodeType = NODE_TYPE_ELEMENT; |
154 | 152 | $this->iNodeValue = ""; |
155 | 153 | $this->iNodeName = $name; |
@@ -162,8 +160,7 @@ discard block |
||
162 | 160 | $this->skipBlanksInTag(); |
163 | 161 | $value = $this->readValueInTag(); |
164 | 162 | $this->iNodeAttributes[strtolower($attrName)] = $value; |
165 | - } |
|
166 | - else { |
|
163 | + } else { |
|
167 | 164 | $this->iNodeAttributes[strtolower($attrName)] = ""; |
168 | 165 | } |
169 | 166 | } |
@@ -204,13 +201,11 @@ discard block |
||
204 | 201 | $this->skipMaxInTag ("\"", 1); |
205 | 202 | $value = $this->skipToInTag ("\""); |
206 | 203 | $this->skipMaxInTag ("\"", 1); |
207 | - } |
|
208 | - else if ($ch == "'") { |
|
204 | + } else if ($ch == "'") { |
|
209 | 205 | $this->skipMaxInTag ("'", 1); |
210 | 206 | $value = $this->skipToInTag ("'"); |
211 | 207 | $this->skipMaxInTag ("'", 1); |
212 | - } |
|
213 | - else { |
|
208 | + } else { |
|
214 | 209 | $value = $this->skipToBlanksInTag(); |
215 | 210 | } |
216 | 211 | return $value; |
@@ -220,8 +215,7 @@ discard block |
||
220 | 215 | $this->iHtmlTextIndex = $index; |
221 | 216 | if ($index >= $this->iHtmlTextLength) { |
222 | 217 | $this->iCurrentChar = -1; |
223 | - } |
|
224 | - else { |
|
218 | + } else { |
|
225 | 219 | $this->iCurrentChar = $this->iHtmlText{$index}; |
226 | 220 | } |
227 | 221 | } |
@@ -230,8 +224,7 @@ discard block |
||
230 | 224 | if ($this->iHtmlTextIndex < $this->iHtmlTextLength) { |
231 | 225 | $this->setTextIndex ($this->iHtmlTextIndex + 1); |
232 | 226 | return true; |
233 | - } |
|
234 | - else { |
|
227 | + } else { |
|
235 | 228 | return false; |
236 | 229 | } |
237 | 230 | } |
@@ -30,336 +30,336 @@ |
||
30 | 30 | */ |
31 | 31 | class HtmlParser { |
32 | 32 | |
33 | - /** |
|
34 | - * Field iNodeType. |
|
35 | - * May be one of the NODE_TYPE_* constants above. |
|
36 | - */ |
|
37 | - var $iNodeType; |
|
33 | + /** |
|
34 | + * Field iNodeType. |
|
35 | + * May be one of the NODE_TYPE_* constants above. |
|
36 | + */ |
|
37 | + var $iNodeType; |
|
38 | 38 | |
39 | - /** |
|
40 | - * Field iNodeName. |
|
41 | - * For elements, it's the name of the element. |
|
42 | - */ |
|
43 | - var $iNodeName = ""; |
|
39 | + /** |
|
40 | + * Field iNodeName. |
|
41 | + * For elements, it's the name of the element. |
|
42 | + */ |
|
43 | + var $iNodeName = ""; |
|
44 | 44 | |
45 | - /** |
|
46 | - * Field iNodeValue. |
|
47 | - * For text nodes, it's the text. |
|
48 | - */ |
|
49 | - var $iNodeValue = ""; |
|
45 | + /** |
|
46 | + * Field iNodeValue. |
|
47 | + * For text nodes, it's the text. |
|
48 | + */ |
|
49 | + var $iNodeValue = ""; |
|
50 | 50 | |
51 | - /** |
|
52 | - * Field iNodeAttributes. |
|
53 | - * A string-indexed array containing attribute values |
|
54 | - * of the current node. Indexes are always lowercase. |
|
55 | - */ |
|
56 | - var $iNodeAttributes; |
|
51 | + /** |
|
52 | + * Field iNodeAttributes. |
|
53 | + * A string-indexed array containing attribute values |
|
54 | + * of the current node. Indexes are always lowercase. |
|
55 | + */ |
|
56 | + var $iNodeAttributes; |
|
57 | 57 | |
58 | - // The following fields should be |
|
59 | - // considered private: |
|
58 | + // The following fields should be |
|
59 | + // considered private: |
|
60 | 60 | |
61 | - var $iHtmlText; |
|
62 | - var $iHtmlTextLength; |
|
63 | - var $iHtmlTextIndex = 0; |
|
64 | - var $iHtmlCurrentChar; |
|
65 | - var $BOE_ARRAY; |
|
66 | - var $B_ARRAY; |
|
67 | - var $BOS_ARRAY; |
|
61 | + var $iHtmlText; |
|
62 | + var $iHtmlTextLength; |
|
63 | + var $iHtmlTextIndex = 0; |
|
64 | + var $iHtmlCurrentChar; |
|
65 | + var $BOE_ARRAY; |
|
66 | + var $B_ARRAY; |
|
67 | + var $BOS_ARRAY; |
|
68 | 68 | |
69 | - /** |
|
70 | - * Constructor. |
|
71 | - * Constructs an HtmlParser instance with |
|
72 | - * the HTML text given. |
|
73 | - */ |
|
74 | - function HtmlParser ($aHtmlText) { |
|
75 | - $this->iHtmlText = $aHtmlText; |
|
76 | - $this->iHtmlTextLength = strlen($aHtmlText); |
|
77 | - $this->iNodeAttributes = array(); |
|
78 | - $this->setTextIndex (0); |
|
69 | + /** |
|
70 | + * Constructor. |
|
71 | + * Constructs an HtmlParser instance with |
|
72 | + * the HTML text given. |
|
73 | + */ |
|
74 | + function HtmlParser ($aHtmlText) { |
|
75 | + $this->iHtmlText = $aHtmlText; |
|
76 | + $this->iHtmlTextLength = strlen($aHtmlText); |
|
77 | + $this->iNodeAttributes = array(); |
|
78 | + $this->setTextIndex (0); |
|
79 | 79 | |
80 | - $this->BOE_ARRAY = array (" ", "\t", "\r", "\n", "=" ); |
|
81 | - $this->B_ARRAY = array (" ", "\t", "\r", "\n" ); |
|
82 | - $this->BOS_ARRAY = array (" ", "\t", "\r", "\n", "/" ); |
|
83 | - } |
|
80 | + $this->BOE_ARRAY = array (" ", "\t", "\r", "\n", "=" ); |
|
81 | + $this->B_ARRAY = array (" ", "\t", "\r", "\n" ); |
|
82 | + $this->BOS_ARRAY = array (" ", "\t", "\r", "\n", "/" ); |
|
83 | + } |
|
84 | 84 | |
85 | - /** |
|
86 | - * Method parse. |
|
87 | - * Parses the next node. Returns false only if |
|
88 | - * the end of the HTML text has been reached. |
|
89 | - * Updates values of iNode* fields. |
|
90 | - */ |
|
91 | - function parse() { |
|
92 | - $text = $this->skipToElement(); |
|
93 | - if ($text != "") { |
|
94 | - $this->iNodeType = NODE_TYPE_TEXT; |
|
95 | - $this->iNodeName = "Text"; |
|
96 | - $this->iNodeValue = $text; |
|
97 | - return true; |
|
98 | - } |
|
99 | - return $this->readTag(); |
|
100 | - } |
|
85 | + /** |
|
86 | + * Method parse. |
|
87 | + * Parses the next node. Returns false only if |
|
88 | + * the end of the HTML text has been reached. |
|
89 | + * Updates values of iNode* fields. |
|
90 | + */ |
|
91 | + function parse() { |
|
92 | + $text = $this->skipToElement(); |
|
93 | + if ($text != "") { |
|
94 | + $this->iNodeType = NODE_TYPE_TEXT; |
|
95 | + $this->iNodeName = "Text"; |
|
96 | + $this->iNodeValue = $text; |
|
97 | + return true; |
|
98 | + } |
|
99 | + return $this->readTag(); |
|
100 | + } |
|
101 | 101 | |
102 | - function clearAttributes() { |
|
103 | - $this->iNodeAttributes = array(); |
|
104 | - } |
|
102 | + function clearAttributes() { |
|
103 | + $this->iNodeAttributes = array(); |
|
104 | + } |
|
105 | 105 | |
106 | - function readTag() { |
|
107 | - if ($this->iCurrentChar != "<") { |
|
108 | - $this->iNodeType = NODE_TYPE_DONE; |
|
109 | - return false; |
|
110 | - } |
|
111 | - $this->clearAttributes(); |
|
112 | - $this->skipMaxInTag ("<", 1); |
|
113 | - if ($this->iCurrentChar == '/') { |
|
114 | - $this->moveNext(); |
|
115 | - $name = $this->skipToBlanksInTag(); |
|
116 | - $this->iNodeType = NODE_TYPE_ENDELEMENT; |
|
117 | - $this->iNodeName = $name; |
|
118 | - $this->iNodeValue = ""; |
|
119 | - $this->skipEndOfTag(); |
|
120 | - return true; |
|
121 | - } |
|
122 | - $name = $this->skipToBlanksOrSlashInTag(); |
|
123 | - if (!$this->isValidTagIdentifier ($name)) { |
|
124 | - $comment = false; |
|
125 | - if (strpos($name, "!--") === 0) { |
|
126 | - $ppos = strpos($name, "--", 3); |
|
127 | - if (strpos($name, "--", 3) === (strlen($name) - 2)) { |
|
128 | - $this->iNodeType = NODE_TYPE_COMMENT; |
|
129 | - $this->iNodeName = "Comment"; |
|
130 | - $this->iNodeValue = "<" . $name . ">"; |
|
131 | - $comment = true; |
|
132 | - } |
|
133 | - else { |
|
134 | - $rest = $this->skipToStringInTag ("-->"); |
|
135 | - if ($rest != "") { |
|
136 | - $this->iNodeType = NODE_TYPE_COMMENT; |
|
137 | - $this->iNodeName = "Comment"; |
|
138 | - $this->iNodeValue = "<" . $name . $rest; |
|
139 | - $comment = true; |
|
140 | - // Already skipped end of tag |
|
141 | - return true; |
|
142 | - } |
|
143 | - } |
|
144 | - } |
|
145 | - if (!$comment) { |
|
146 | - $this->iNodeType = NODE_TYPE_TEXT; |
|
147 | - $this->iNodeName = "Text"; |
|
148 | - $this->iNodeValue = "<" . $name; |
|
149 | - return true; |
|
150 | - } |
|
151 | - } |
|
152 | - else { |
|
153 | - $this->iNodeType = NODE_TYPE_ELEMENT; |
|
154 | - $this->iNodeValue = ""; |
|
155 | - $this->iNodeName = $name; |
|
156 | - while ($this->skipBlanksInTag()) { |
|
157 | - $attrName = $this->skipToBlanksOrEqualsInTag(); |
|
158 | - if ($attrName != "" && $attrName != "/") { |
|
159 | - $this->skipBlanksInTag(); |
|
160 | - if ($this->iCurrentChar == "=") { |
|
161 | - $this->skipEqualsInTag(); |
|
162 | - $this->skipBlanksInTag(); |
|
163 | - $value = $this->readValueInTag(); |
|
164 | - $this->iNodeAttributes[strtolower($attrName)] = $value; |
|
165 | - } |
|
166 | - else { |
|
167 | - $this->iNodeAttributes[strtolower($attrName)] = ""; |
|
168 | - } |
|
169 | - } |
|
170 | - } |
|
171 | - } |
|
172 | - $this->skipEndOfTag(); |
|
173 | - return true; |
|
174 | - } |
|
106 | + function readTag() { |
|
107 | + if ($this->iCurrentChar != "<") { |
|
108 | + $this->iNodeType = NODE_TYPE_DONE; |
|
109 | + return false; |
|
110 | + } |
|
111 | + $this->clearAttributes(); |
|
112 | + $this->skipMaxInTag ("<", 1); |
|
113 | + if ($this->iCurrentChar == '/') { |
|
114 | + $this->moveNext(); |
|
115 | + $name = $this->skipToBlanksInTag(); |
|
116 | + $this->iNodeType = NODE_TYPE_ENDELEMENT; |
|
117 | + $this->iNodeName = $name; |
|
118 | + $this->iNodeValue = ""; |
|
119 | + $this->skipEndOfTag(); |
|
120 | + return true; |
|
121 | + } |
|
122 | + $name = $this->skipToBlanksOrSlashInTag(); |
|
123 | + if (!$this->isValidTagIdentifier ($name)) { |
|
124 | + $comment = false; |
|
125 | + if (strpos($name, "!--") === 0) { |
|
126 | + $ppos = strpos($name, "--", 3); |
|
127 | + if (strpos($name, "--", 3) === (strlen($name) - 2)) { |
|
128 | + $this->iNodeType = NODE_TYPE_COMMENT; |
|
129 | + $this->iNodeName = "Comment"; |
|
130 | + $this->iNodeValue = "<" . $name . ">"; |
|
131 | + $comment = true; |
|
132 | + } |
|
133 | + else { |
|
134 | + $rest = $this->skipToStringInTag ("-->"); |
|
135 | + if ($rest != "") { |
|
136 | + $this->iNodeType = NODE_TYPE_COMMENT; |
|
137 | + $this->iNodeName = "Comment"; |
|
138 | + $this->iNodeValue = "<" . $name . $rest; |
|
139 | + $comment = true; |
|
140 | + // Already skipped end of tag |
|
141 | + return true; |
|
142 | + } |
|
143 | + } |
|
144 | + } |
|
145 | + if (!$comment) { |
|
146 | + $this->iNodeType = NODE_TYPE_TEXT; |
|
147 | + $this->iNodeName = "Text"; |
|
148 | + $this->iNodeValue = "<" . $name; |
|
149 | + return true; |
|
150 | + } |
|
151 | + } |
|
152 | + else { |
|
153 | + $this->iNodeType = NODE_TYPE_ELEMENT; |
|
154 | + $this->iNodeValue = ""; |
|
155 | + $this->iNodeName = $name; |
|
156 | + while ($this->skipBlanksInTag()) { |
|
157 | + $attrName = $this->skipToBlanksOrEqualsInTag(); |
|
158 | + if ($attrName != "" && $attrName != "/") { |
|
159 | + $this->skipBlanksInTag(); |
|
160 | + if ($this->iCurrentChar == "=") { |
|
161 | + $this->skipEqualsInTag(); |
|
162 | + $this->skipBlanksInTag(); |
|
163 | + $value = $this->readValueInTag(); |
|
164 | + $this->iNodeAttributes[strtolower($attrName)] = $value; |
|
165 | + } |
|
166 | + else { |
|
167 | + $this->iNodeAttributes[strtolower($attrName)] = ""; |
|
168 | + } |
|
169 | + } |
|
170 | + } |
|
171 | + } |
|
172 | + $this->skipEndOfTag(); |
|
173 | + return true; |
|
174 | + } |
|
175 | 175 | |
176 | - function isValidTagIdentifier ($name) { |
|
177 | - return preg_match ("/^[A-Za-z0-9_\\-]+$/", $name); |
|
178 | - } |
|
176 | + function isValidTagIdentifier ($name) { |
|
177 | + return preg_match ("/^[A-Za-z0-9_\\-]+$/", $name); |
|
178 | + } |
|
179 | 179 | |
180 | - function skipBlanksInTag() { |
|
181 | - return "" != ($this->skipInTag ($this->B_ARRAY)); |
|
182 | - } |
|
180 | + function skipBlanksInTag() { |
|
181 | + return "" != ($this->skipInTag ($this->B_ARRAY)); |
|
182 | + } |
|
183 | 183 | |
184 | - function skipToBlanksOrEqualsInTag() { |
|
185 | - return $this->skipToInTag ($this->BOE_ARRAY); |
|
186 | - } |
|
184 | + function skipToBlanksOrEqualsInTag() { |
|
185 | + return $this->skipToInTag ($this->BOE_ARRAY); |
|
186 | + } |
|
187 | 187 | |
188 | - function skipToBlanksInTag() { |
|
189 | - return $this->skipToInTag ($this->B_ARRAY); |
|
190 | - } |
|
188 | + function skipToBlanksInTag() { |
|
189 | + return $this->skipToInTag ($this->B_ARRAY); |
|
190 | + } |
|
191 | 191 | |
192 | - function skipToBlanksOrSlashInTag() { |
|
193 | - return $this->skipToInTag ($this->BOS_ARRAY); |
|
194 | - } |
|
192 | + function skipToBlanksOrSlashInTag() { |
|
193 | + return $this->skipToInTag ($this->BOS_ARRAY); |
|
194 | + } |
|
195 | 195 | |
196 | - function skipEqualsInTag() { |
|
197 | - return $this->skipMaxInTag ("=", 1); |
|
198 | - } |
|
196 | + function skipEqualsInTag() { |
|
197 | + return $this->skipMaxInTag ("=", 1); |
|
198 | + } |
|
199 | 199 | |
200 | - function readValueInTag() { |
|
201 | - $ch = $this->iCurrentChar; |
|
202 | - $value = ""; |
|
203 | - if ($ch == "\"") { |
|
204 | - $this->skipMaxInTag ("\"", 1); |
|
205 | - $value = $this->skipToInTag ("\""); |
|
206 | - $this->skipMaxInTag ("\"", 1); |
|
207 | - } |
|
208 | - else if ($ch == "'") { |
|
209 | - $this->skipMaxInTag ("'", 1); |
|
210 | - $value = $this->skipToInTag ("'"); |
|
211 | - $this->skipMaxInTag ("'", 1); |
|
212 | - } |
|
213 | - else { |
|
214 | - $value = $this->skipToBlanksInTag(); |
|
215 | - } |
|
216 | - return $value; |
|
217 | - } |
|
200 | + function readValueInTag() { |
|
201 | + $ch = $this->iCurrentChar; |
|
202 | + $value = ""; |
|
203 | + if ($ch == "\"") { |
|
204 | + $this->skipMaxInTag ("\"", 1); |
|
205 | + $value = $this->skipToInTag ("\""); |
|
206 | + $this->skipMaxInTag ("\"", 1); |
|
207 | + } |
|
208 | + else if ($ch == "'") { |
|
209 | + $this->skipMaxInTag ("'", 1); |
|
210 | + $value = $this->skipToInTag ("'"); |
|
211 | + $this->skipMaxInTag ("'", 1); |
|
212 | + } |
|
213 | + else { |
|
214 | + $value = $this->skipToBlanksInTag(); |
|
215 | + } |
|
216 | + return $value; |
|
217 | + } |
|
218 | 218 | |
219 | - function setTextIndex ($index) { |
|
220 | - $this->iHtmlTextIndex = $index; |
|
221 | - if ($index >= $this->iHtmlTextLength) { |
|
222 | - $this->iCurrentChar = -1; |
|
223 | - } |
|
224 | - else { |
|
225 | - $this->iCurrentChar = $this->iHtmlText{$index}; |
|
226 | - } |
|
227 | - } |
|
219 | + function setTextIndex ($index) { |
|
220 | + $this->iHtmlTextIndex = $index; |
|
221 | + if ($index >= $this->iHtmlTextLength) { |
|
222 | + $this->iCurrentChar = -1; |
|
223 | + } |
|
224 | + else { |
|
225 | + $this->iCurrentChar = $this->iHtmlText{$index}; |
|
226 | + } |
|
227 | + } |
|
228 | 228 | |
229 | - function moveNext() { |
|
230 | - if ($this->iHtmlTextIndex < $this->iHtmlTextLength) { |
|
231 | - $this->setTextIndex ($this->iHtmlTextIndex + 1); |
|
232 | - return true; |
|
233 | - } |
|
234 | - else { |
|
235 | - return false; |
|
236 | - } |
|
237 | - } |
|
229 | + function moveNext() { |
|
230 | + if ($this->iHtmlTextIndex < $this->iHtmlTextLength) { |
|
231 | + $this->setTextIndex ($this->iHtmlTextIndex + 1); |
|
232 | + return true; |
|
233 | + } |
|
234 | + else { |
|
235 | + return false; |
|
236 | + } |
|
237 | + } |
|
238 | 238 | |
239 | - function skipEndOfTag() { |
|
240 | - while (($ch = $this->iCurrentChar) !== -1) { |
|
241 | - if ($ch == ">") { |
|
242 | - $this->moveNext(); |
|
243 | - return; |
|
244 | - } |
|
245 | - $this->moveNext(); |
|
246 | - } |
|
247 | - } |
|
239 | + function skipEndOfTag() { |
|
240 | + while (($ch = $this->iCurrentChar) !== -1) { |
|
241 | + if ($ch == ">") { |
|
242 | + $this->moveNext(); |
|
243 | + return; |
|
244 | + } |
|
245 | + $this->moveNext(); |
|
246 | + } |
|
247 | + } |
|
248 | 248 | |
249 | - function skipInTag ($chars) { |
|
250 | - $sb = ""; |
|
251 | - while (($ch = $this->iCurrentChar) !== -1) { |
|
252 | - if ($ch == ">") { |
|
253 | - return $sb; |
|
254 | - } else { |
|
255 | - $match = false; |
|
256 | - for ($idx = 0; $idx < count($chars); $idx++) { |
|
257 | - if ($ch == $chars[$idx]) { |
|
258 | - $match = true; |
|
259 | - break; |
|
260 | - } |
|
261 | - } |
|
262 | - if (!$match) { |
|
263 | - return $sb; |
|
264 | - } |
|
265 | - $sb .= $ch; |
|
266 | - $this->moveNext(); |
|
267 | - } |
|
268 | - } |
|
269 | - return $sb; |
|
270 | - } |
|
249 | + function skipInTag ($chars) { |
|
250 | + $sb = ""; |
|
251 | + while (($ch = $this->iCurrentChar) !== -1) { |
|
252 | + if ($ch == ">") { |
|
253 | + return $sb; |
|
254 | + } else { |
|
255 | + $match = false; |
|
256 | + for ($idx = 0; $idx < count($chars); $idx++) { |
|
257 | + if ($ch == $chars[$idx]) { |
|
258 | + $match = true; |
|
259 | + break; |
|
260 | + } |
|
261 | + } |
|
262 | + if (!$match) { |
|
263 | + return $sb; |
|
264 | + } |
|
265 | + $sb .= $ch; |
|
266 | + $this->moveNext(); |
|
267 | + } |
|
268 | + } |
|
269 | + return $sb; |
|
270 | + } |
|
271 | 271 | |
272 | - function skipMaxInTag ($chars, $maxChars) { |
|
273 | - $sb = ""; |
|
274 | - $count = 0; |
|
275 | - while (($ch = $this->iCurrentChar) !== -1 && $count++ < $maxChars) { |
|
276 | - if ($ch == ">") { |
|
277 | - return $sb; |
|
278 | - } else { |
|
279 | - $match = false; |
|
280 | - for ($idx = 0; $idx < count($chars); $idx++) { |
|
281 | - if ($ch == $chars[$idx]) { |
|
282 | - $match = true; |
|
283 | - break; |
|
284 | - } |
|
285 | - } |
|
286 | - if (!$match) { |
|
287 | - return $sb; |
|
288 | - } |
|
289 | - $sb .= $ch; |
|
290 | - $this->moveNext(); |
|
291 | - } |
|
292 | - } |
|
293 | - return $sb; |
|
294 | - } |
|
272 | + function skipMaxInTag ($chars, $maxChars) { |
|
273 | + $sb = ""; |
|
274 | + $count = 0; |
|
275 | + while (($ch = $this->iCurrentChar) !== -1 && $count++ < $maxChars) { |
|
276 | + if ($ch == ">") { |
|
277 | + return $sb; |
|
278 | + } else { |
|
279 | + $match = false; |
|
280 | + for ($idx = 0; $idx < count($chars); $idx++) { |
|
281 | + if ($ch == $chars[$idx]) { |
|
282 | + $match = true; |
|
283 | + break; |
|
284 | + } |
|
285 | + } |
|
286 | + if (!$match) { |
|
287 | + return $sb; |
|
288 | + } |
|
289 | + $sb .= $ch; |
|
290 | + $this->moveNext(); |
|
291 | + } |
|
292 | + } |
|
293 | + return $sb; |
|
294 | + } |
|
295 | 295 | |
296 | - function skipToInTag ($chars) { |
|
297 | - $sb = ""; |
|
298 | - while (($ch = $this->iCurrentChar) !== -1) { |
|
299 | - $match = $ch == ">"; |
|
300 | - if (!$match) { |
|
301 | - for ($idx = 0; $idx < count($chars); $idx++) { |
|
302 | - if ($ch == $chars[$idx]) { |
|
303 | - $match = true; |
|
304 | - break; |
|
305 | - } |
|
306 | - } |
|
307 | - } |
|
308 | - if ($match) { |
|
309 | - return $sb; |
|
310 | - } |
|
311 | - $sb .= $ch; |
|
312 | - $this->moveNext(); |
|
313 | - } |
|
314 | - return $sb; |
|
315 | - } |
|
296 | + function skipToInTag ($chars) { |
|
297 | + $sb = ""; |
|
298 | + while (($ch = $this->iCurrentChar) !== -1) { |
|
299 | + $match = $ch == ">"; |
|
300 | + if (!$match) { |
|
301 | + for ($idx = 0; $idx < count($chars); $idx++) { |
|
302 | + if ($ch == $chars[$idx]) { |
|
303 | + $match = true; |
|
304 | + break; |
|
305 | + } |
|
306 | + } |
|
307 | + } |
|
308 | + if ($match) { |
|
309 | + return $sb; |
|
310 | + } |
|
311 | + $sb .= $ch; |
|
312 | + $this->moveNext(); |
|
313 | + } |
|
314 | + return $sb; |
|
315 | + } |
|
316 | 316 | |
317 | - function skipToElement() { |
|
318 | - $sb = ""; |
|
319 | - while (($ch = $this->iCurrentChar) !== -1) { |
|
320 | - if ($ch == "<") { |
|
321 | - return $sb; |
|
322 | - } |
|
323 | - $sb .= $ch; |
|
324 | - $this->moveNext(); |
|
325 | - } |
|
326 | - return $sb; |
|
327 | - } |
|
317 | + function skipToElement() { |
|
318 | + $sb = ""; |
|
319 | + while (($ch = $this->iCurrentChar) !== -1) { |
|
320 | + if ($ch == "<") { |
|
321 | + return $sb; |
|
322 | + } |
|
323 | + $sb .= $ch; |
|
324 | + $this->moveNext(); |
|
325 | + } |
|
326 | + return $sb; |
|
327 | + } |
|
328 | 328 | |
329 | - /** |
|
330 | - * Returns text between current position and $needle, |
|
331 | - * inclusive, or "" if not found. The current index is moved to a point |
|
332 | - * after the location of $needle, or not moved at all |
|
333 | - * if nothing is found. |
|
334 | - */ |
|
335 | - function skipToStringInTag ($needle) { |
|
336 | - $pos = strpos ($this->iHtmlText, $needle, $this->iHtmlTextIndex); |
|
337 | - if ($pos === false) { |
|
338 | - return ""; |
|
339 | - } |
|
340 | - $top = $pos + strlen($needle); |
|
341 | - $retvalue = substr ($this->iHtmlText, $this->iHtmlTextIndex, $top - $this->iHtmlTextIndex); |
|
342 | - $this->setTextIndex ($top); |
|
343 | - return $retvalue; |
|
344 | - } |
|
329 | + /** |
|
330 | + * Returns text between current position and $needle, |
|
331 | + * inclusive, or "" if not found. The current index is moved to a point |
|
332 | + * after the location of $needle, or not moved at all |
|
333 | + * if nothing is found. |
|
334 | + */ |
|
335 | + function skipToStringInTag ($needle) { |
|
336 | + $pos = strpos ($this->iHtmlText, $needle, $this->iHtmlTextIndex); |
|
337 | + if ($pos === false) { |
|
338 | + return ""; |
|
339 | + } |
|
340 | + $top = $pos + strlen($needle); |
|
341 | + $retvalue = substr ($this->iHtmlText, $this->iHtmlTextIndex, $top - $this->iHtmlTextIndex); |
|
342 | + $this->setTextIndex ($top); |
|
343 | + return $retvalue; |
|
344 | + } |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | function HtmlParser_ForFile ($fileName) { |
348 | - return HtmlParser_ForURL($fileName); |
|
348 | + return HtmlParser_ForURL($fileName); |
|
349 | 349 | } |
350 | 350 | |
351 | 351 | function HtmlParser_ForURL ($url) { |
352 | - $fp = fopen ($url, "r"); |
|
353 | - $content = ""; |
|
354 | - while (true) { |
|
355 | - $data = fread ($fp, 8192); |
|
356 | - if (strlen($data) == 0) { |
|
357 | - break; |
|
358 | - } |
|
359 | - $content .= $data; |
|
360 | - } |
|
361 | - fclose ($fp); |
|
362 | - return new HtmlParser ($content); |
|
352 | + $fp = fopen ($url, "r"); |
|
353 | + $content = ""; |
|
354 | + while (true) { |
|
355 | + $data = fread ($fp, 8192); |
|
356 | + if (strlen($data) == 0) { |
|
357 | + break; |
|
358 | + } |
|
359 | + $content .= $data; |
|
360 | + } |
|
361 | + fclose ($fp); |
|
362 | + return new HtmlParser ($content); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | php?> |
@@ -10,12 +10,12 @@ discard block |
||
10 | 10 | * - Leo West (performance improvements) |
11 | 11 | */ |
12 | 12 | |
13 | -define ("NODE_TYPE_START",0); |
|
14 | -define ("NODE_TYPE_ELEMENT",1); |
|
15 | -define ("NODE_TYPE_ENDELEMENT",2); |
|
16 | -define ("NODE_TYPE_TEXT",3); |
|
17 | -define ("NODE_TYPE_COMMENT",4); |
|
18 | -define ("NODE_TYPE_DONE",5); |
|
13 | +define("NODE_TYPE_START", 0); |
|
14 | +define("NODE_TYPE_ELEMENT", 1); |
|
15 | +define("NODE_TYPE_ENDELEMENT", 2); |
|
16 | +define("NODE_TYPE_TEXT", 3); |
|
17 | +define("NODE_TYPE_COMMENT", 4); |
|
18 | +define("NODE_TYPE_DONE", 5); |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * Class HtmlParser. |
@@ -71,15 +71,15 @@ discard block |
||
71 | 71 | * Constructs an HtmlParser instance with |
72 | 72 | * the HTML text given. |
73 | 73 | */ |
74 | - function HtmlParser ($aHtmlText) { |
|
74 | + function HtmlParser($aHtmlText) { |
|
75 | 75 | $this->iHtmlText = $aHtmlText; |
76 | 76 | $this->iHtmlTextLength = strlen($aHtmlText); |
77 | 77 | $this->iNodeAttributes = array(); |
78 | - $this->setTextIndex (0); |
|
78 | + $this->setTextIndex(0); |
|
79 | 79 | |
80 | - $this->BOE_ARRAY = array (" ", "\t", "\r", "\n", "=" ); |
|
81 | - $this->B_ARRAY = array (" ", "\t", "\r", "\n" ); |
|
82 | - $this->BOS_ARRAY = array (" ", "\t", "\r", "\n", "/" ); |
|
80 | + $this->BOE_ARRAY = array(" ", "\t", "\r", "\n", "="); |
|
81 | + $this->B_ARRAY = array(" ", "\t", "\r", "\n"); |
|
82 | + $this->BOS_ARRAY = array(" ", "\t", "\r", "\n", "/"); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | return false; |
110 | 110 | } |
111 | 111 | $this->clearAttributes(); |
112 | - $this->skipMaxInTag ("<", 1); |
|
112 | + $this->skipMaxInTag("<", 1); |
|
113 | 113 | if ($this->iCurrentChar == '/') { |
114 | 114 | $this->moveNext(); |
115 | 115 | $name = $this->skipToBlanksInTag(); |
@@ -120,22 +120,22 @@ discard block |
||
120 | 120 | return true; |
121 | 121 | } |
122 | 122 | $name = $this->skipToBlanksOrSlashInTag(); |
123 | - if (!$this->isValidTagIdentifier ($name)) { |
|
123 | + if (!$this->isValidTagIdentifier($name)) { |
|
124 | 124 | $comment = false; |
125 | 125 | if (strpos($name, "!--") === 0) { |
126 | 126 | $ppos = strpos($name, "--", 3); |
127 | 127 | if (strpos($name, "--", 3) === (strlen($name) - 2)) { |
128 | 128 | $this->iNodeType = NODE_TYPE_COMMENT; |
129 | 129 | $this->iNodeName = "Comment"; |
130 | - $this->iNodeValue = "<" . $name . ">"; |
|
130 | + $this->iNodeValue = "<".$name.">"; |
|
131 | 131 | $comment = true; |
132 | 132 | } |
133 | 133 | else { |
134 | - $rest = $this->skipToStringInTag ("-->"); |
|
134 | + $rest = $this->skipToStringInTag("-->"); |
|
135 | 135 | if ($rest != "") { |
136 | 136 | $this->iNodeType = NODE_TYPE_COMMENT; |
137 | 137 | $this->iNodeName = "Comment"; |
138 | - $this->iNodeValue = "<" . $name . $rest; |
|
138 | + $this->iNodeValue = "<".$name.$rest; |
|
139 | 139 | $comment = true; |
140 | 140 | // Already skipped end of tag |
141 | 141 | return true; |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | if (!$comment) { |
146 | 146 | $this->iNodeType = NODE_TYPE_TEXT; |
147 | 147 | $this->iNodeName = "Text"; |
148 | - $this->iNodeValue = "<" . $name; |
|
148 | + $this->iNodeValue = "<".$name; |
|
149 | 149 | return true; |
150 | 150 | } |
151 | 151 | } |
@@ -173,42 +173,42 @@ discard block |
||
173 | 173 | return true; |
174 | 174 | } |
175 | 175 | |
176 | - function isValidTagIdentifier ($name) { |
|
177 | - return preg_match ("/^[A-Za-z0-9_\\-]+$/", $name); |
|
176 | + function isValidTagIdentifier($name) { |
|
177 | + return preg_match("/^[A-Za-z0-9_\\-]+$/", $name); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | function skipBlanksInTag() { |
181 | - return "" != ($this->skipInTag ($this->B_ARRAY)); |
|
181 | + return "" != ($this->skipInTag($this->B_ARRAY)); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | function skipToBlanksOrEqualsInTag() { |
185 | - return $this->skipToInTag ($this->BOE_ARRAY); |
|
185 | + return $this->skipToInTag($this->BOE_ARRAY); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | function skipToBlanksInTag() { |
189 | - return $this->skipToInTag ($this->B_ARRAY); |
|
189 | + return $this->skipToInTag($this->B_ARRAY); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | function skipToBlanksOrSlashInTag() { |
193 | - return $this->skipToInTag ($this->BOS_ARRAY); |
|
193 | + return $this->skipToInTag($this->BOS_ARRAY); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | function skipEqualsInTag() { |
197 | - return $this->skipMaxInTag ("=", 1); |
|
197 | + return $this->skipMaxInTag("=", 1); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | function readValueInTag() { |
201 | 201 | $ch = $this->iCurrentChar; |
202 | 202 | $value = ""; |
203 | 203 | if ($ch == "\"") { |
204 | - $this->skipMaxInTag ("\"", 1); |
|
205 | - $value = $this->skipToInTag ("\""); |
|
206 | - $this->skipMaxInTag ("\"", 1); |
|
204 | + $this->skipMaxInTag("\"", 1); |
|
205 | + $value = $this->skipToInTag("\""); |
|
206 | + $this->skipMaxInTag("\"", 1); |
|
207 | 207 | } |
208 | 208 | else if ($ch == "'") { |
209 | - $this->skipMaxInTag ("'", 1); |
|
210 | - $value = $this->skipToInTag ("'"); |
|
211 | - $this->skipMaxInTag ("'", 1); |
|
209 | + $this->skipMaxInTag("'", 1); |
|
210 | + $value = $this->skipToInTag("'"); |
|
211 | + $this->skipMaxInTag("'", 1); |
|
212 | 212 | } |
213 | 213 | else { |
214 | 214 | $value = $this->skipToBlanksInTag(); |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | return $value; |
217 | 217 | } |
218 | 218 | |
219 | - function setTextIndex ($index) { |
|
219 | + function setTextIndex($index) { |
|
220 | 220 | $this->iHtmlTextIndex = $index; |
221 | 221 | if ($index >= $this->iHtmlTextLength) { |
222 | 222 | $this->iCurrentChar = -1; |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | |
229 | 229 | function moveNext() { |
230 | 230 | if ($this->iHtmlTextIndex < $this->iHtmlTextLength) { |
231 | - $this->setTextIndex ($this->iHtmlTextIndex + 1); |
|
231 | + $this->setTextIndex($this->iHtmlTextIndex + 1); |
|
232 | 232 | return true; |
233 | 233 | } |
234 | 234 | else { |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | } |
247 | 247 | } |
248 | 248 | |
249 | - function skipInTag ($chars) { |
|
249 | + function skipInTag($chars) { |
|
250 | 250 | $sb = ""; |
251 | 251 | while (($ch = $this->iCurrentChar) !== -1) { |
252 | 252 | if ($ch == ">") { |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | return $sb; |
270 | 270 | } |
271 | 271 | |
272 | - function skipMaxInTag ($chars, $maxChars) { |
|
272 | + function skipMaxInTag($chars, $maxChars) { |
|
273 | 273 | $sb = ""; |
274 | 274 | $count = 0; |
275 | 275 | while (($ch = $this->iCurrentChar) !== -1 && $count++ < $maxChars) { |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | return $sb; |
294 | 294 | } |
295 | 295 | |
296 | - function skipToInTag ($chars) { |
|
296 | + function skipToInTag($chars) { |
|
297 | 297 | $sb = ""; |
298 | 298 | while (($ch = $this->iCurrentChar) !== -1) { |
299 | 299 | $match = $ch == ">"; |
@@ -332,34 +332,34 @@ discard block |
||
332 | 332 | * after the location of $needle, or not moved at all |
333 | 333 | * if nothing is found. |
334 | 334 | */ |
335 | - function skipToStringInTag ($needle) { |
|
336 | - $pos = strpos ($this->iHtmlText, $needle, $this->iHtmlTextIndex); |
|
335 | + function skipToStringInTag($needle) { |
|
336 | + $pos = strpos($this->iHtmlText, $needle, $this->iHtmlTextIndex); |
|
337 | 337 | if ($pos === false) { |
338 | 338 | return ""; |
339 | 339 | } |
340 | 340 | $top = $pos + strlen($needle); |
341 | - $retvalue = substr ($this->iHtmlText, $this->iHtmlTextIndex, $top - $this->iHtmlTextIndex); |
|
342 | - $this->setTextIndex ($top); |
|
341 | + $retvalue = substr($this->iHtmlText, $this->iHtmlTextIndex, $top - $this->iHtmlTextIndex); |
|
342 | + $this->setTextIndex($top); |
|
343 | 343 | return $retvalue; |
344 | 344 | } |
345 | 345 | } |
346 | 346 | |
347 | -function HtmlParser_ForFile ($fileName) { |
|
347 | +function HtmlParser_ForFile($fileName) { |
|
348 | 348 | return HtmlParser_ForURL($fileName); |
349 | 349 | } |
350 | 350 | |
351 | -function HtmlParser_ForURL ($url) { |
|
352 | - $fp = fopen ($url, "r"); |
|
351 | +function HtmlParser_ForURL($url) { |
|
352 | + $fp = fopen($url, "r"); |
|
353 | 353 | $content = ""; |
354 | 354 | while (true) { |
355 | - $data = fread ($fp, 8192); |
|
355 | + $data = fread($fp, 8192); |
|
356 | 356 | if (strlen($data) == 0) { |
357 | 357 | break; |
358 | 358 | } |
359 | 359 | $content .= $data; |
360 | 360 | } |
361 | - fclose ($fp); |
|
362 | - return new HtmlParser ($content); |
|
361 | + fclose($fp); |
|
362 | + return new HtmlParser($content); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | php?> |
@@ -173,6 +173,9 @@ discard block |
||
173 | 173 | return true; |
174 | 174 | } |
175 | 175 | |
176 | + /** |
|
177 | + * @param string $name |
|
178 | + */ |
|
176 | 179 | function isValidTagIdentifier ($name) { |
177 | 180 | return preg_match ("/^[A-Za-z0-9_\\-]+$/", $name); |
178 | 181 | } |
@@ -216,6 +219,9 @@ discard block |
||
216 | 219 | return $value; |
217 | 220 | } |
218 | 221 | |
222 | + /** |
|
223 | + * @param integer $index |
|
224 | + */ |
|
219 | 225 | function setTextIndex ($index) { |
220 | 226 | $this->iHtmlTextIndex = $index; |
221 | 227 | if ($index >= $this->iHtmlTextLength) { |
@@ -246,6 +252,9 @@ discard block |
||
246 | 252 | } |
247 | 253 | } |
248 | 254 | |
255 | + /** |
|
256 | + * @param string[] $chars |
|
257 | + */ |
|
249 | 258 | function skipInTag ($chars) { |
250 | 259 | $sb = ""; |
251 | 260 | while (($ch = $this->iCurrentChar) !== -1) { |
@@ -269,6 +278,10 @@ discard block |
||
269 | 278 | return $sb; |
270 | 279 | } |
271 | 280 | |
281 | + /** |
|
282 | + * @param string $chars |
|
283 | + * @param integer $maxChars |
|
284 | + */ |
|
272 | 285 | function skipMaxInTag ($chars, $maxChars) { |
273 | 286 | $sb = ""; |
274 | 287 | $count = 0; |
@@ -331,6 +344,7 @@ discard block |
||
331 | 344 | * inclusive, or "" if not found. The current index is moved to a point |
332 | 345 | * after the location of $needle, or not moved at all |
333 | 346 | * if nothing is found. |
347 | + * @param string $needle |
|
334 | 348 | */ |
335 | 349 | function skipToStringInTag ($needle) { |
336 | 350 | $pos = strpos ($this->iHtmlText, $needle, $this->iHtmlTextIndex); |
@@ -39,99 +39,99 @@ |
||
39 | 39 | */ |
40 | 40 | abstract class HTTP_Request2_Adapter |
41 | 41 | { |
42 | - /** |
|
43 | - * A list of methods that MUST NOT have a request body, per RFC 2616 |
|
44 | - * @var array |
|
45 | - */ |
|
46 | - protected static $bodyDisallowed = array('TRACE'); |
|
42 | + /** |
|
43 | + * A list of methods that MUST NOT have a request body, per RFC 2616 |
|
44 | + * @var array |
|
45 | + */ |
|
46 | + protected static $bodyDisallowed = array('TRACE'); |
|
47 | 47 | |
48 | - /** |
|
49 | - * Methods having defined semantics for request body |
|
50 | - * |
|
51 | - * Content-Length header (indicating that the body follows, section 4.3 of |
|
52 | - * RFC 2616) will be sent for these methods even if no body was added |
|
53 | - * |
|
54 | - * @var array |
|
55 | - * @link http://pear.php.net/bugs/bug.php?id=12900 |
|
56 | - * @link http://pear.php.net/bugs/bug.php?id=14740 |
|
57 | - */ |
|
58 | - protected static $bodyRequired = array('POST', 'PUT'); |
|
48 | + /** |
|
49 | + * Methods having defined semantics for request body |
|
50 | + * |
|
51 | + * Content-Length header (indicating that the body follows, section 4.3 of |
|
52 | + * RFC 2616) will be sent for these methods even if no body was added |
|
53 | + * |
|
54 | + * @var array |
|
55 | + * @link http://pear.php.net/bugs/bug.php?id=12900 |
|
56 | + * @link http://pear.php.net/bugs/bug.php?id=14740 |
|
57 | + */ |
|
58 | + protected static $bodyRequired = array('POST', 'PUT'); |
|
59 | 59 | |
60 | - /** |
|
61 | - * Request being sent |
|
62 | - * @var HTTP_Request2 |
|
63 | - */ |
|
64 | - protected $request; |
|
60 | + /** |
|
61 | + * Request being sent |
|
62 | + * @var HTTP_Request2 |
|
63 | + */ |
|
64 | + protected $request; |
|
65 | 65 | |
66 | - /** |
|
67 | - * Request body |
|
68 | - * @var string|resource|HTTP_Request2_MultipartBody |
|
69 | - * @see HTTP_Request2::getBody() |
|
70 | - */ |
|
71 | - protected $requestBody; |
|
66 | + /** |
|
67 | + * Request body |
|
68 | + * @var string|resource|HTTP_Request2_MultipartBody |
|
69 | + * @see HTTP_Request2::getBody() |
|
70 | + */ |
|
71 | + protected $requestBody; |
|
72 | 72 | |
73 | - /** |
|
74 | - * Length of the request body |
|
75 | - * @var integer |
|
76 | - */ |
|
77 | - protected $contentLength; |
|
73 | + /** |
|
74 | + * Length of the request body |
|
75 | + * @var integer |
|
76 | + */ |
|
77 | + protected $contentLength; |
|
78 | 78 | |
79 | - /** |
|
80 | - * Sends request to the remote server and returns its response |
|
81 | - * |
|
82 | - * @param HTTP_Request2 $request HTTP request message |
|
83 | - * |
|
84 | - * @return HTTP_Request2_Response |
|
85 | - * @throws HTTP_Request2_Exception |
|
86 | - */ |
|
87 | - abstract public function sendRequest(HTTP_Request2 $request); |
|
79 | + /** |
|
80 | + * Sends request to the remote server and returns its response |
|
81 | + * |
|
82 | + * @param HTTP_Request2 $request HTTP request message |
|
83 | + * |
|
84 | + * @return HTTP_Request2_Response |
|
85 | + * @throws HTTP_Request2_Exception |
|
86 | + */ |
|
87 | + abstract public function sendRequest(HTTP_Request2 $request); |
|
88 | 88 | |
89 | - /** |
|
90 | - * Calculates length of the request body, adds proper headers |
|
91 | - * |
|
92 | - * @param array &$headers associative array of request headers, this method |
|
93 | - * will add proper 'Content-Length' and 'Content-Type' |
|
94 | - * headers to this array (or remove them if not needed) |
|
95 | - */ |
|
96 | - protected function calculateRequestLength(&$headers) |
|
97 | - { |
|
98 | - $this->requestBody = $this->request->getBody(); |
|
89 | + /** |
|
90 | + * Calculates length of the request body, adds proper headers |
|
91 | + * |
|
92 | + * @param array &$headers associative array of request headers, this method |
|
93 | + * will add proper 'Content-Length' and 'Content-Type' |
|
94 | + * headers to this array (or remove them if not needed) |
|
95 | + */ |
|
96 | + protected function calculateRequestLength(&$headers) |
|
97 | + { |
|
98 | + $this->requestBody = $this->request->getBody(); |
|
99 | 99 | |
100 | - if (is_string($this->requestBody)) { |
|
101 | - $this->contentLength = strlen($this->requestBody); |
|
102 | - } elseif (is_resource($this->requestBody)) { |
|
103 | - $stat = fstat($this->requestBody); |
|
104 | - $this->contentLength = $stat['size']; |
|
105 | - rewind($this->requestBody); |
|
106 | - } else { |
|
107 | - $this->contentLength = $this->requestBody->getLength(); |
|
108 | - $headers['content-type'] = 'multipart/form-data; boundary=' . |
|
109 | - $this->requestBody->getBoundary(); |
|
110 | - $this->requestBody->rewind(); |
|
111 | - } |
|
100 | + if (is_string($this->requestBody)) { |
|
101 | + $this->contentLength = strlen($this->requestBody); |
|
102 | + } elseif (is_resource($this->requestBody)) { |
|
103 | + $stat = fstat($this->requestBody); |
|
104 | + $this->contentLength = $stat['size']; |
|
105 | + rewind($this->requestBody); |
|
106 | + } else { |
|
107 | + $this->contentLength = $this->requestBody->getLength(); |
|
108 | + $headers['content-type'] = 'multipart/form-data; boundary=' . |
|
109 | + $this->requestBody->getBoundary(); |
|
110 | + $this->requestBody->rewind(); |
|
111 | + } |
|
112 | 112 | |
113 | - if (in_array($this->request->getMethod(), self::$bodyDisallowed) |
|
114 | - || 0 == $this->contentLength |
|
115 | - ) { |
|
116 | - // No body: send a Content-Length header nonetheless (request #12900), |
|
117 | - // but do that only for methods that require a body (bug #14740) |
|
118 | - if (in_array($this->request->getMethod(), self::$bodyRequired)) { |
|
119 | - $headers['content-length'] = 0; |
|
120 | - } else { |
|
121 | - unset($headers['content-length']); |
|
122 | - // if the method doesn't require a body and doesn't have a |
|
123 | - // body, don't send a Content-Type header. (request #16799) |
|
124 | - unset($headers['content-type']); |
|
125 | - } |
|
126 | - } else { |
|
127 | - if (empty($headers['content-type'])) { |
|
128 | - $headers['content-type'] = 'application/x-www-form-urlencoded'; |
|
129 | - } |
|
130 | - // Content-Length should not be sent for chunked Transfer-Encoding (bug #20125) |
|
131 | - if (!isset($headers['transfer-encoding'])) { |
|
132 | - $headers['content-length'] = $this->contentLength; |
|
133 | - } |
|
134 | - } |
|
135 | - } |
|
113 | + if (in_array($this->request->getMethod(), self::$bodyDisallowed) |
|
114 | + || 0 == $this->contentLength |
|
115 | + ) { |
|
116 | + // No body: send a Content-Length header nonetheless (request #12900), |
|
117 | + // but do that only for methods that require a body (bug #14740) |
|
118 | + if (in_array($this->request->getMethod(), self::$bodyRequired)) { |
|
119 | + $headers['content-length'] = 0; |
|
120 | + } else { |
|
121 | + unset($headers['content-length']); |
|
122 | + // if the method doesn't require a body and doesn't have a |
|
123 | + // body, don't send a Content-Type header. (request #16799) |
|
124 | + unset($headers['content-type']); |
|
125 | + } |
|
126 | + } else { |
|
127 | + if (empty($headers['content-type'])) { |
|
128 | + $headers['content-type'] = 'application/x-www-form-urlencoded'; |
|
129 | + } |
|
130 | + // Content-Length should not be sent for chunked Transfer-Encoding (bug #20125) |
|
131 | + if (!isset($headers['transfer-encoding'])) { |
|
132 | + $headers['content-length'] = $this->contentLength; |
|
133 | + } |
|
134 | + } |
|
135 | + } |
|
136 | 136 | } |
137 | 137 | ?> |
@@ -105,7 +105,7 @@ |
||
105 | 105 | rewind($this->requestBody); |
106 | 106 | } else { |
107 | 107 | $this->contentLength = $this->requestBody->getLength(); |
108 | - $headers['content-type'] = 'multipart/form-data; boundary=' . |
|
108 | + $headers['content-type'] = 'multipart/form-data; boundary='. |
|
109 | 109 | $this->requestBody->getBoundary(); |
110 | 110 | $this->requestBody->rewind(); |
111 | 111 | } |
@@ -219,8 +219,8 @@ discard block |
||
219 | 219 | if(!$obj->email_address) $obj->email_address = ''; |
220 | 220 | if(!$isRestore) $obj->ipaddress = $_SERVER['REMOTE_ADDR']; |
221 | 221 | |
222 | - // can modify regdate only manager |
|
223 | - $grant = Context::get('grant'); |
|
222 | + // can modify regdate only manager |
|
223 | + $grant = Context::get('grant'); |
|
224 | 224 | if(!$grant->manager) |
225 | 225 | { |
226 | 226 | unset($obj->regdate); |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | if($obj->notify_message != 'Y') $obj->notify_message = 'N'; |
423 | 423 | |
424 | 424 | // can modify regdate only manager |
425 | - $grant = Context::get('grant'); |
|
425 | + $grant = Context::get('grant'); |
|
426 | 426 | if(!$grant->manager) |
427 | 427 | { |
428 | 428 | unset($obj->regdate); |
@@ -716,7 +716,7 @@ discard block |
||
716 | 716 | |
717 | 717 | /** |
718 | 718 | * Move the doc into the trash |
719 | - * @param object $obj |
|
719 | + * @param stdClass $obj |
|
720 | 720 | * @return object |
721 | 721 | */ |
722 | 722 | function moveDocumentToTrash($obj) |
@@ -1811,7 +1811,7 @@ discard block |
||
1811 | 1811 | * Occasionally the xml file is not generated after menu is configued on the admin page \n |
1812 | 1812 | * The administrator can manually update the file in this case \n |
1813 | 1813 | * Although the issue is not currently reproduced, it is unnecessay to remove. |
1814 | - * @return void |
|
1814 | + * @return BaseObject|null |
|
1815 | 1815 | */ |
1816 | 1816 | function procDocumentMakeXmlFile() |
1817 | 1817 | { |
@@ -24,19 +24,19 @@ discard block |
||
24 | 24 | */ |
25 | 25 | function procDocumentVoteUp() |
26 | 26 | { |
27 | - if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request'); |
|
27 | + if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request'); |
|
28 | 28 | |
29 | 29 | $document_srl = Context::get('target_srl'); |
30 | - if(!$document_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
30 | + if (!$document_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
31 | 31 | |
32 | 32 | $oDocumentModel = getModel('document'); |
33 | 33 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false); |
34 | 34 | $module_srl = $oDocument->get('module_srl'); |
35 | - if(!$module_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
35 | + if (!$module_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
36 | 36 | |
37 | 37 | $oModuleModel = getModel('module'); |
38 | - $document_config = $oModuleModel->getModulePartConfig('document',$module_srl); |
|
39 | - if($document_config->use_vote_up=='N') return new BaseObject(-1, 'msg_invalid_request'); |
|
38 | + $document_config = $oModuleModel->getModulePartConfig('document', $module_srl); |
|
39 | + if ($document_config->use_vote_up == 'N') return new BaseObject(-1, 'msg_invalid_request'); |
|
40 | 40 | |
41 | 41 | $point = 1; |
42 | 42 | $output = $this->updateVotedCount($document_srl, $point); |
@@ -69,19 +69,19 @@ discard block |
||
69 | 69 | */ |
70 | 70 | function procDocumentVoteDown() |
71 | 71 | { |
72 | - if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request'); |
|
72 | + if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request'); |
|
73 | 73 | |
74 | 74 | $document_srl = Context::get('target_srl'); |
75 | - if(!$document_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
75 | + if (!$document_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
76 | 76 | |
77 | 77 | $oDocumentModel = getModel('document'); |
78 | 78 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false); |
79 | 79 | $module_srl = $oDocument->get('module_srl'); |
80 | - if(!$module_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
80 | + if (!$module_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
81 | 81 | |
82 | 82 | $oModuleModel = getModel('module'); |
83 | - $document_config = $oModuleModel->getModulePartConfig('document',$module_srl); |
|
84 | - if($document_config->use_vote_down=='N') return new BaseObject(-1, 'msg_invalid_request'); |
|
83 | + $document_config = $oModuleModel->getModulePartConfig('document', $module_srl); |
|
84 | + if ($document_config->use_vote_down == 'N') return new BaseObject(-1, 'msg_invalid_request'); |
|
85 | 85 | |
86 | 86 | $point = -1; |
87 | 87 | $output = $this->updateVotedCount($document_srl, $point); |
@@ -95,10 +95,10 @@ discard block |
||
95 | 95 | */ |
96 | 96 | function procDocumentDeclare() |
97 | 97 | { |
98 | - if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request'); |
|
98 | + if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request'); |
|
99 | 99 | |
100 | 100 | $document_srl = Context::get('target_srl'); |
101 | - if(!$document_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
101 | + if (!$document_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
102 | 102 | |
103 | 103 | return $this->declaredDocument($document_srl); |
104 | 104 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | $args->history_srl = $history_srl; |
141 | 141 | $args->module_srl = $module_srl; |
142 | 142 | $args->document_srl = $document_srl; |
143 | - if(!$args->history_srl && !$args->module_srl && !$args->document_srl) return; |
|
143 | + if (!$args->history_srl && !$args->module_srl && !$args->document_srl) return; |
|
144 | 144 | executeQuery("document.deleteHistory", $args); |
145 | 145 | } |
146 | 146 | |
@@ -152,15 +152,15 @@ discard block |
||
152 | 152 | function triggerDeleteModuleDocuments(&$obj) |
153 | 153 | { |
154 | 154 | $module_srl = $obj->module_srl; |
155 | - if(!$module_srl) return new BaseObject(); |
|
155 | + if (!$module_srl) return new BaseObject(); |
|
156 | 156 | // Delete the document |
157 | 157 | $oDocumentAdminController = getAdminController('document'); |
158 | 158 | $output = $oDocumentAdminController->deleteModuleDocument($module_srl); |
159 | - if(!$output->toBool()) return $output; |
|
159 | + if (!$output->toBool()) return $output; |
|
160 | 160 | // Delete the category |
161 | 161 | $oDocumentController = getController('document'); |
162 | 162 | $output = $oDocumentController->deleteModuleCategory($module_srl); |
163 | - if(!$output->toBool()) return $output; |
|
163 | + if (!$output->toBool()) return $output; |
|
164 | 164 | // Delete extra key and variable, because module deleted |
165 | 165 | $this->deleteDocumentExtraKeys($module_srl); |
166 | 166 | |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | */ |
194 | 194 | function insertDocument($obj, $manual_inserted = false, $isRestore = false, $isLatest = true) |
195 | 195 | { |
196 | - if(!$manual_inserted && !checkCSRF()) |
|
196 | + if (!$manual_inserted && !checkCSRF()) |
|
197 | 197 | { |
198 | 198 | return new BaseObject(-1, 'msg_invalid_request'); |
199 | 199 | } |
@@ -202,32 +202,32 @@ discard block |
||
202 | 202 | $oDB = &DB::getInstance(); |
203 | 203 | $oDB->begin(); |
204 | 204 | // List variables |
205 | - if($obj->comment_status) $obj->commentStatus = $obj->comment_status; |
|
206 | - if(!$obj->commentStatus) $obj->commentStatus = 'DENY'; |
|
207 | - if($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj); |
|
208 | - if($obj->allow_trackback!='Y') $obj->allow_trackback = 'N'; |
|
209 | - if($obj->homepage) |
|
205 | + if ($obj->comment_status) $obj->commentStatus = $obj->comment_status; |
|
206 | + if (!$obj->commentStatus) $obj->commentStatus = 'DENY'; |
|
207 | + if ($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj); |
|
208 | + if ($obj->allow_trackback != 'Y') $obj->allow_trackback = 'N'; |
|
209 | + if ($obj->homepage) |
|
210 | 210 | { |
211 | 211 | $obj->homepage = escape($obj->homepage); |
212 | - if(!preg_match('/^[a-z]+:\/\//i',$obj->homepage)) |
|
212 | + if (!preg_match('/^[a-z]+:\/\//i', $obj->homepage)) |
|
213 | 213 | { |
214 | 214 | $obj->homepage = 'http://'.$obj->homepage; |
215 | 215 | } |
216 | 216 | } |
217 | 217 | |
218 | - if($obj->notify_message != 'Y') $obj->notify_message = 'N'; |
|
219 | - if(!$obj->email_address) $obj->email_address = ''; |
|
220 | - if(!$isRestore) $obj->ipaddress = $_SERVER['REMOTE_ADDR']; |
|
218 | + if ($obj->notify_message != 'Y') $obj->notify_message = 'N'; |
|
219 | + if (!$obj->email_address) $obj->email_address = ''; |
|
220 | + if (!$isRestore) $obj->ipaddress = $_SERVER['REMOTE_ADDR']; |
|
221 | 221 | |
222 | 222 | // can modify regdate only manager |
223 | 223 | $grant = Context::get('grant'); |
224 | - if(!$grant->manager) |
|
224 | + if (!$grant->manager) |
|
225 | 225 | { |
226 | 226 | unset($obj->regdate); |
227 | 227 | } |
228 | 228 | |
229 | 229 | // Serialize the $extra_vars, check the extra_vars type, because duplicate serialized avoid |
230 | - if(!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars); |
|
230 | + if (!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars); |
|
231 | 231 | // Remove the columns for automatic saving |
232 | 232 | unset($obj->_saved_doc_srl); |
233 | 233 | unset($obj->_saved_doc_title); |
@@ -235,34 +235,34 @@ discard block |
||
235 | 235 | unset($obj->_saved_doc_message); |
236 | 236 | // Call a trigger (before) |
237 | 237 | $output = ModuleHandler::triggerCall('document.insertDocument', 'before', $obj); |
238 | - if(!$output->toBool()) return $output; |
|
238 | + if (!$output->toBool()) return $output; |
|
239 | 239 | // Register it if no given document_srl exists |
240 | - if(!$obj->document_srl) $obj->document_srl = getNextSequence(); |
|
241 | - elseif(!$manual_inserted && !$isRestore && !checkUserSequence($obj->document_srl)) return new BaseObject(-1, 'msg_not_permitted'); |
|
240 | + if (!$obj->document_srl) $obj->document_srl = getNextSequence(); |
|
241 | + elseif (!$manual_inserted && !$isRestore && !checkUserSequence($obj->document_srl)) return new BaseObject(-1, 'msg_not_permitted'); |
|
242 | 242 | |
243 | 243 | $oDocumentModel = getModel('document'); |
244 | 244 | // Set to 0 if the category_srl doesn't exist |
245 | - if($obj->category_srl) |
|
245 | + if ($obj->category_srl) |
|
246 | 246 | { |
247 | 247 | $category_list = $oDocumentModel->getCategoryList($obj->module_srl); |
248 | - if(count($category_list) > 0 && !$category_list[$obj->category_srl]->grant) |
|
248 | + if (count($category_list) > 0 && !$category_list[$obj->category_srl]->grant) |
|
249 | 249 | { |
250 | 250 | return new BaseObject(-1, 'msg_not_permitted'); |
251 | 251 | } |
252 | - if(count($category_list) > 0 && !$category_list[$obj->category_srl]) $obj->category_srl = 0; |
|
252 | + if (count($category_list) > 0 && !$category_list[$obj->category_srl]) $obj->category_srl = 0; |
|
253 | 253 | } |
254 | 254 | // Set the read counts and update order. |
255 | - if(!$obj->readed_count) $obj->readed_count = 0; |
|
256 | - if($isLatest) $obj->update_order = $obj->list_order = $obj->document_srl * -1; |
|
255 | + if (!$obj->readed_count) $obj->readed_count = 0; |
|
256 | + if ($isLatest) $obj->update_order = $obj->list_order = $obj->document_srl * -1; |
|
257 | 257 | else $obj->update_order = $obj->list_order; |
258 | 258 | // Check the status of password hash for manually inserting. Apply hashing for otherwise. |
259 | - if($obj->password && !$obj->password_is_hashed) |
|
259 | + if ($obj->password && !$obj->password_is_hashed) |
|
260 | 260 | { |
261 | 261 | $obj->password = getModel('member')->hashPassword($obj->password); |
262 | 262 | } |
263 | 263 | // Insert member's information only if the member is logged-in and not manually registered. |
264 | 264 | $logged_info = Context::get('logged_info'); |
265 | - if(Context::get('is_logged') && !$manual_inserted && !$isRestore) |
|
265 | + if (Context::get('is_logged') && !$manual_inserted && !$isRestore) |
|
266 | 266 | { |
267 | 267 | $obj->member_srl = $logged_info->member_srl; |
268 | 268 | |
@@ -276,61 +276,61 @@ discard block |
||
276 | 276 | // If the tile is empty, extract string from the contents. |
277 | 277 | $obj->title = htmlspecialchars($obj->title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
278 | 278 | settype($obj->title, "string"); |
279 | - if($obj->title == '') $obj->title = cut_str(trim(strip_tags(nl2br($obj->content))),20,'...'); |
|
279 | + if ($obj->title == '') $obj->title = cut_str(trim(strip_tags(nl2br($obj->content))), 20, '...'); |
|
280 | 280 | // If no tile extracted from the contents, leave it untitled. |
281 | - if($obj->title == '') $obj->title = 'Untitled'; |
|
281 | + if ($obj->title == '') $obj->title = 'Untitled'; |
|
282 | 282 | // Remove XE's own tags from the contents. |
283 | 283 | $obj->content = preg_replace('!<\!--(Before|After)(Document|Comment)\(([0-9]+),([0-9]+)\)-->!is', '', $obj->content); |
284 | - if(Mobile::isFromMobilePhone() && $obj->use_editor != 'Y') |
|
284 | + if (Mobile::isFromMobilePhone() && $obj->use_editor != 'Y') |
|
285 | 285 | { |
286 | - if($obj->use_html != 'Y') |
|
286 | + if ($obj->use_html != 'Y') |
|
287 | 287 | { |
288 | 288 | $obj->content = htmlspecialchars($obj->content, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
289 | 289 | } |
290 | 290 | $obj->content = nl2br($obj->content); |
291 | 291 | } |
292 | 292 | // Remove iframe and script if not a top adminisrator in the session. |
293 | - if($logged_info->is_admin != 'Y') $obj->content = removeHackTag($obj->content); |
|
293 | + if ($logged_info->is_admin != 'Y') $obj->content = removeHackTag($obj->content); |
|
294 | 294 | // An error appears if both log-in info and user name don't exist. |
295 | - if(!$logged_info->member_srl && !$obj->nick_name) return new BaseObject(-1,'msg_invalid_request'); |
|
295 | + if (!$logged_info->member_srl && !$obj->nick_name) return new BaseObject(-1, 'msg_invalid_request'); |
|
296 | 296 | |
297 | 297 | $obj->lang_code = Context::getLangType(); |
298 | 298 | // Insert data into the DB |
299 | - if(!$obj->status) $this->_checkDocumentStatusForOldVersion($obj); |
|
299 | + if (!$obj->status) $this->_checkDocumentStatusForOldVersion($obj); |
|
300 | 300 | $output = executeQuery('document.insertDocument', $obj); |
301 | - if(!$output->toBool()) |
|
301 | + if (!$output->toBool()) |
|
302 | 302 | { |
303 | 303 | $oDB->rollback(); |
304 | 304 | return $output; |
305 | 305 | } |
306 | 306 | // Insert extra variables if the document successfully inserted. |
307 | 307 | $extra_keys = $oDocumentModel->getExtraKeys($obj->module_srl); |
308 | - if(count($extra_keys)) |
|
308 | + if (count($extra_keys)) |
|
309 | 309 | { |
310 | - foreach($extra_keys as $idx => $extra_item) |
|
310 | + foreach ($extra_keys as $idx => $extra_item) |
|
311 | 311 | { |
312 | 312 | $value = NULL; |
313 | - if(isset($obj->{'extra_vars'.$idx})) |
|
313 | + if (isset($obj->{'extra_vars'.$idx})) |
|
314 | 314 | { |
315 | 315 | $tmp = $obj->{'extra_vars'.$idx}; |
316 | - if(is_array($tmp)) |
|
316 | + if (is_array($tmp)) |
|
317 | 317 | $value = implode('|@|', $tmp); |
318 | 318 | else |
319 | 319 | $value = trim($tmp); |
320 | 320 | } |
321 | - else if(isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name}); |
|
322 | - if($value == NULL) continue; |
|
321 | + else if (isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name}); |
|
322 | + if ($value == NULL) continue; |
|
323 | 323 | |
324 | 324 | $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, $idx, $value, $extra_item->eid); |
325 | 325 | } |
326 | 326 | } |
327 | 327 | // Update the category if the category_srl exists. |
328 | - if($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl); |
|
328 | + if ($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl); |
|
329 | 329 | // Call a trigger (after) |
330 | - if($output->toBool()) |
|
330 | + if ($output->toBool()) |
|
331 | 331 | { |
332 | 332 | $trigger_output = ModuleHandler::triggerCall('document.insertDocument', 'after', $obj); |
333 | - if(!$trigger_output->toBool()) |
|
333 | + if (!$trigger_output->toBool()) |
|
334 | 334 | { |
335 | 335 | $oDB->rollback(); |
336 | 336 | return $trigger_output; |
@@ -341,12 +341,12 @@ discard block |
||
341 | 341 | $oDB->commit(); |
342 | 342 | |
343 | 343 | // return |
344 | - if(!$manual_inserted) |
|
344 | + if (!$manual_inserted) |
|
345 | 345 | { |
346 | 346 | $this->addGrant($obj->document_srl); |
347 | 347 | } |
348 | - $output->add('document_srl',$obj->document_srl); |
|
349 | - $output->add('category_srl',$obj->category_srl); |
|
348 | + $output->add('document_srl', $obj->document_srl); |
|
349 | + $output->add('category_srl', $obj->category_srl); |
|
350 | 350 | |
351 | 351 | return $output; |
352 | 352 | } |
@@ -362,41 +362,41 @@ discard block |
||
362 | 362 | { |
363 | 363 | $logged_info = Context::get('logged_info'); |
364 | 364 | |
365 | - if(!$manual_updated && !checkCSRF()) |
|
365 | + if (!$manual_updated && !checkCSRF()) |
|
366 | 366 | { |
367 | 367 | return new BaseObject(-1, 'msg_invalid_request'); |
368 | 368 | } |
369 | 369 | |
370 | - if(!$source_obj->document_srl || !$obj->document_srl) return new BaseObject(-1,'msg_invalied_request'); |
|
371 | - if(!$obj->status && $obj->is_secret == 'Y') $obj->status = 'SECRET'; |
|
372 | - if(!$obj->status) $obj->status = 'PUBLIC'; |
|
370 | + if (!$source_obj->document_srl || !$obj->document_srl) return new BaseObject(-1, 'msg_invalied_request'); |
|
371 | + if (!$obj->status && $obj->is_secret == 'Y') $obj->status = 'SECRET'; |
|
372 | + if (!$obj->status) $obj->status = 'PUBLIC'; |
|
373 | 373 | |
374 | 374 | // Call a trigger (before) |
375 | 375 | $output = ModuleHandler::triggerCall('document.updateDocument', 'before', $obj); |
376 | - if(!$output->toBool()) return $output; |
|
376 | + if (!$output->toBool()) return $output; |
|
377 | 377 | |
378 | 378 | // begin transaction |
379 | 379 | $oDB = &DB::getInstance(); |
380 | 380 | $oDB->begin(); |
381 | 381 | |
382 | 382 | $oModuleModel = getModel('module'); |
383 | - if(!$obj->module_srl) $obj->module_srl = $source_obj->get('module_srl'); |
|
383 | + if (!$obj->module_srl) $obj->module_srl = $source_obj->get('module_srl'); |
|
384 | 384 | $module_srl = $obj->module_srl; |
385 | 385 | $document_config = $oModuleModel->getModulePartConfig('document', $module_srl); |
386 | - if(!$document_config) |
|
386 | + if (!$document_config) |
|
387 | 387 | { |
388 | 388 | $document_config = new stdClass(); |
389 | 389 | } |
390 | - if(!isset($document_config->use_history)) $document_config->use_history = 'N'; |
|
390 | + if (!isset($document_config->use_history)) $document_config->use_history = 'N'; |
|
391 | 391 | $bUseHistory = $document_config->use_history == 'Y' || $document_config->use_history == 'Trace'; |
392 | 392 | |
393 | - if($bUseHistory) |
|
393 | + if ($bUseHistory) |
|
394 | 394 | { |
395 | 395 | $args = new stdClass; |
396 | 396 | $args->history_srl = getNextSequence(); |
397 | 397 | $args->document_srl = $obj->document_srl; |
398 | 398 | $args->module_srl = $module_srl; |
399 | - if($document_config->use_history == 'Y') $args->content = $source_obj->get('content'); |
|
399 | + if ($document_config->use_history == 'Y') $args->content = $source_obj->get('content'); |
|
400 | 400 | $args->nick_name = $source_obj->get('nick_name'); |
401 | 401 | $args->member_srl = $source_obj->get('member_srl'); |
402 | 402 | $args->regdate = $source_obj->get('last_update'); |
@@ -408,30 +408,30 @@ discard block |
||
408 | 408 | $obj->ipaddress = $source_obj->get('ipaddress'); |
409 | 409 | } |
410 | 410 | // List variables |
411 | - if($obj->comment_status) $obj->commentStatus = $obj->comment_status; |
|
412 | - if(!$obj->commentStatus) $obj->commentStatus = 'DENY'; |
|
413 | - if($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj); |
|
414 | - if($obj->allow_trackback!='Y') $obj->allow_trackback = 'N'; |
|
415 | - if($obj->homepage) |
|
411 | + if ($obj->comment_status) $obj->commentStatus = $obj->comment_status; |
|
412 | + if (!$obj->commentStatus) $obj->commentStatus = 'DENY'; |
|
413 | + if ($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj); |
|
414 | + if ($obj->allow_trackback != 'Y') $obj->allow_trackback = 'N'; |
|
415 | + if ($obj->homepage) |
|
416 | 416 | { |
417 | 417 | $obj->homepage = escape($obj->homepage); |
418 | - if(!preg_match('/^[a-z]+:\/\//i',$obj->homepage)) |
|
418 | + if (!preg_match('/^[a-z]+:\/\//i', $obj->homepage)) |
|
419 | 419 | { |
420 | 420 | $obj->homepage = 'http://'.$obj->homepage; |
421 | 421 | } |
422 | 422 | } |
423 | 423 | |
424 | - if($obj->notify_message != 'Y') $obj->notify_message = 'N'; |
|
424 | + if ($obj->notify_message != 'Y') $obj->notify_message = 'N'; |
|
425 | 425 | |
426 | 426 | // can modify regdate only manager |
427 | 427 | $grant = Context::get('grant'); |
428 | - if(!$grant->manager) |
|
428 | + if (!$grant->manager) |
|
429 | 429 | { |
430 | 430 | unset($obj->regdate); |
431 | 431 | } |
432 | 432 | |
433 | 433 | // Serialize the $extra_vars |
434 | - if(!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars); |
|
434 | + if (!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars); |
|
435 | 435 | // Remove the columns for automatic saving |
436 | 436 | unset($obj->_saved_doc_srl); |
437 | 437 | unset($obj->_saved_doc_title); |
@@ -440,23 +440,23 @@ discard block |
||
440 | 440 | |
441 | 441 | $oDocumentModel = getModel('document'); |
442 | 442 | // Set the category_srl to 0 if the changed category is not exsiting. |
443 | - if($source_obj->get('category_srl')!=$obj->category_srl) |
|
443 | + if ($source_obj->get('category_srl') != $obj->category_srl) |
|
444 | 444 | { |
445 | 445 | $category_list = $oDocumentModel->getCategoryList($obj->module_srl); |
446 | - if(!$category_list[$obj->category_srl]) $obj->category_srl = 0; |
|
446 | + if (!$category_list[$obj->category_srl]) $obj->category_srl = 0; |
|
447 | 447 | } |
448 | 448 | // Change the update order |
449 | 449 | $obj->update_order = getNextSequence() * -1; |
450 | 450 | // Hash the password if it exists |
451 | - if($obj->password) |
|
451 | + if ($obj->password) |
|
452 | 452 | { |
453 | 453 | $obj->password = getModel('member')->hashPassword($obj->password); |
454 | 454 | } |
455 | 455 | |
456 | 456 | // If an author is identical to the modifier or history is used, use the logged-in user's information. |
457 | - if(Context::get('is_logged') && !$manual_updated) |
|
457 | + if (Context::get('is_logged') && !$manual_updated) |
|
458 | 458 | { |
459 | - if($source_obj->get('member_srl')==$logged_info->member_srl) |
|
459 | + if ($source_obj->get('member_srl') == $logged_info->member_srl) |
|
460 | 460 | { |
461 | 461 | $obj->member_srl = $logged_info->member_srl; |
462 | 462 | $obj->user_name = htmlspecialchars_decode($logged_info->user_name); |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | } |
468 | 468 | |
469 | 469 | // For the document written by logged-in user however no nick_name exists |
470 | - if($source_obj->get('member_srl')&& !$obj->nick_name) |
|
470 | + if ($source_obj->get('member_srl') && !$obj->nick_name) |
|
471 | 471 | { |
472 | 472 | $obj->member_srl = $source_obj->get('member_srl'); |
473 | 473 | $obj->user_name = $source_obj->get('user_name'); |
@@ -478,24 +478,24 @@ discard block |
||
478 | 478 | // If the tile is empty, extract string from the contents. |
479 | 479 | $obj->title = htmlspecialchars($obj->title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
480 | 480 | settype($obj->title, "string"); |
481 | - if($obj->title == '') $obj->title = cut_str(strip_tags($obj->content),20,'...'); |
|
481 | + if ($obj->title == '') $obj->title = cut_str(strip_tags($obj->content), 20, '...'); |
|
482 | 482 | // If no tile extracted from the contents, leave it untitled. |
483 | - if($obj->title == '') $obj->title = 'Untitled'; |
|
483 | + if ($obj->title == '') $obj->title = 'Untitled'; |
|
484 | 484 | // Remove XE's own tags from the contents. |
485 | 485 | $obj->content = preg_replace('!<\!--(Before|After)(Document|Comment)\(([0-9]+),([0-9]+)\)-->!is', '', $obj->content); |
486 | - if(Mobile::isFromMobilePhone() && $obj->use_editor != 'Y') |
|
486 | + if (Mobile::isFromMobilePhone() && $obj->use_editor != 'Y') |
|
487 | 487 | { |
488 | - if($obj->use_html != 'Y') |
|
488 | + if ($obj->use_html != 'Y') |
|
489 | 489 | { |
490 | 490 | $obj->content = htmlspecialchars($obj->content, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
491 | 491 | } |
492 | 492 | $obj->content = nl2br($obj->content); |
493 | 493 | } |
494 | 494 | // Change not extra vars but language code of the original document if document's lang_code is different from author's setting. |
495 | - if($source_obj->get('lang_code') != Context::getLangType()) |
|
495 | + if ($source_obj->get('lang_code') != Context::getLangType()) |
|
496 | 496 | { |
497 | 497 | // Change not extra vars but language code of the original document if document's lang_code doesn't exist. |
498 | - if(!$source_obj->get('lang_code')) |
|
498 | + if (!$source_obj->get('lang_code')) |
|
499 | 499 | { |
500 | 500 | $lang_code_args->document_srl = $source_obj->get('document_srl'); |
501 | 501 | $lang_code_args->lang_code = Context::getLangType(); |
@@ -515,59 +515,59 @@ discard block |
||
515 | 515 | } |
516 | 516 | } |
517 | 517 | // Remove iframe and script if not a top adminisrator in the session. |
518 | - if($logged_info->is_admin != 'Y') |
|
518 | + if ($logged_info->is_admin != 'Y') |
|
519 | 519 | { |
520 | 520 | $obj->content = removeHackTag($obj->content); |
521 | 521 | } |
522 | 522 | // if temporary document, regdate is now setting |
523 | - if($source_obj->get('status') == $this->getConfigStatus('temp')) $obj->regdate = date('YmdHis'); |
|
523 | + if ($source_obj->get('status') == $this->getConfigStatus('temp')) $obj->regdate = date('YmdHis'); |
|
524 | 524 | |
525 | 525 | // Insert data into the DB |
526 | 526 | $output = executeQuery('document.updateDocument', $obj); |
527 | - if(!$output->toBool()) |
|
527 | + if (!$output->toBool()) |
|
528 | 528 | { |
529 | 529 | $oDB->rollback(); |
530 | 530 | return $output; |
531 | 531 | } |
532 | 532 | // Remove all extra variables |
533 | - if(Context::get('act')!='procFileDelete') |
|
533 | + if (Context::get('act') != 'procFileDelete') |
|
534 | 534 | { |
535 | 535 | $this->deleteDocumentExtraVars($source_obj->get('module_srl'), $obj->document_srl, null, Context::getLangType()); |
536 | 536 | // Insert extra variables if the document successfully inserted. |
537 | 537 | $extra_keys = $oDocumentModel->getExtraKeys($obj->module_srl); |
538 | - if(count($extra_keys)) |
|
538 | + if (count($extra_keys)) |
|
539 | 539 | { |
540 | - foreach($extra_keys as $idx => $extra_item) |
|
540 | + foreach ($extra_keys as $idx => $extra_item) |
|
541 | 541 | { |
542 | 542 | $value = NULL; |
543 | - if(isset($obj->{'extra_vars'.$idx})) |
|
543 | + if (isset($obj->{'extra_vars'.$idx})) |
|
544 | 544 | { |
545 | 545 | $tmp = $obj->{'extra_vars'.$idx}; |
546 | - if(is_array($tmp)) |
|
546 | + if (is_array($tmp)) |
|
547 | 547 | $value = implode('|@|', $tmp); |
548 | 548 | else |
549 | 549 | $value = trim($tmp); |
550 | 550 | } |
551 | - else if(isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name}); |
|
552 | - if($value == NULL) continue; |
|
551 | + else if (isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name}); |
|
552 | + if ($value == NULL) continue; |
|
553 | 553 | $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, $idx, $value, $extra_item->eid); |
554 | 554 | } |
555 | 555 | } |
556 | 556 | // Inert extra vars for multi-language support of title and contents. |
557 | - if($extra_content->title) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -1, $extra_content->title, 'title_'.Context::getLangType()); |
|
558 | - if($extra_content->content) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -2, $extra_content->content, 'content_'.Context::getLangType()); |
|
557 | + if ($extra_content->title) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -1, $extra_content->title, 'title_'.Context::getLangType()); |
|
558 | + if ($extra_content->content) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -2, $extra_content->content, 'content_'.Context::getLangType()); |
|
559 | 559 | } |
560 | 560 | // Update the category if the category_srl exists. |
561 | - if($source_obj->get('category_srl') != $obj->category_srl || $source_obj->get('module_srl') == $logged_info->member_srl) |
|
561 | + if ($source_obj->get('category_srl') != $obj->category_srl || $source_obj->get('module_srl') == $logged_info->member_srl) |
|
562 | 562 | { |
563 | - if($source_obj->get('category_srl') != $obj->category_srl) $this->updateCategoryCount($obj->module_srl, $source_obj->get('category_srl')); |
|
564 | - if($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl); |
|
563 | + if ($source_obj->get('category_srl') != $obj->category_srl) $this->updateCategoryCount($obj->module_srl, $source_obj->get('category_srl')); |
|
564 | + if ($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl); |
|
565 | 565 | } |
566 | 566 | // Call a trigger (after) |
567 | - if($output->toBool()) |
|
567 | + if ($output->toBool()) |
|
568 | 568 | { |
569 | 569 | $trigger_output = ModuleHandler::triggerCall('document.updateDocument', 'after', $obj); |
570 | - if(!$trigger_output->toBool()) |
|
570 | + if (!$trigger_output->toBool()) |
|
571 | 571 | { |
572 | 572 | $oDB->rollback(); |
573 | 573 | return $trigger_output; |
@@ -577,15 +577,15 @@ discard block |
||
577 | 577 | // commit |
578 | 578 | $oDB->commit(); |
579 | 579 | // Remove the thumbnail file |
580 | - FileHandler::removeDir(sprintf('files/thumbnails/%s',getNumberingPath($obj->document_srl, 3))); |
|
580 | + FileHandler::removeDir(sprintf('files/thumbnails/%s', getNumberingPath($obj->document_srl, 3))); |
|
581 | 581 | |
582 | - $output->add('document_srl',$obj->document_srl); |
|
582 | + $output->add('document_srl', $obj->document_srl); |
|
583 | 583 | //remove from cache |
584 | 584 | $oCacheHandler = CacheHandler::getInstance('object'); |
585 | - if($oCacheHandler->isSupport()) |
|
585 | + if ($oCacheHandler->isSupport()) |
|
586 | 586 | { |
587 | 587 | //remove document item from cache |
588 | - $cache_key = 'document_item:'. getNumberingPath($obj->document_srl) . $obj->document_srl; |
|
588 | + $cache_key = 'document_item:'.getNumberingPath($obj->document_srl).$obj->document_srl; |
|
589 | 589 | $oCacheHandler->delete($cache_key); |
590 | 590 | } |
591 | 591 | |
@@ -606,33 +606,33 @@ discard block |
||
606 | 606 | $trigger_obj = new stdClass(); |
607 | 607 | $trigger_obj->document_srl = $document_srl; |
608 | 608 | $output = ModuleHandler::triggerCall('document.deleteDocument', 'before', $trigger_obj); |
609 | - if(!$output->toBool()) return $output; |
|
609 | + if (!$output->toBool()) return $output; |
|
610 | 610 | |
611 | 611 | // begin transaction |
612 | 612 | $oDB = &DB::getInstance(); |
613 | 613 | $oDB->begin(); |
614 | 614 | |
615 | - if(!$isEmptyTrash) |
|
615 | + if (!$isEmptyTrash) |
|
616 | 616 | { |
617 | 617 | // get model object of the document |
618 | 618 | $oDocumentModel = getModel('document'); |
619 | 619 | // Check if the documnet exists |
620 | 620 | $oDocument = $oDocumentModel->getDocument($document_srl, $is_admin); |
621 | 621 | } |
622 | - else if($isEmptyTrash && $oDocument == null) return new BaseObject(-1, 'document is not exists'); |
|
622 | + else if ($isEmptyTrash && $oDocument == null) return new BaseObject(-1, 'document is not exists'); |
|
623 | 623 | |
624 | - if(!$oDocument->isExists() || $oDocument->document_srl != $document_srl) return new BaseObject(-1, 'msg_invalid_document'); |
|
624 | + if (!$oDocument->isExists() || $oDocument->document_srl != $document_srl) return new BaseObject(-1, 'msg_invalid_document'); |
|
625 | 625 | // Check if a permossion is granted |
626 | - if(!$oDocument->isGranted()) return new BaseObject(-1, 'msg_not_permitted'); |
|
626 | + if (!$oDocument->isGranted()) return new BaseObject(-1, 'msg_not_permitted'); |
|
627 | 627 | |
628 | 628 | //if empty trash, document already deleted, therefore document not delete |
629 | 629 | $args = new stdClass(); |
630 | 630 | $args->document_srl = $document_srl; |
631 | - if(!$isEmptyTrash) |
|
631 | + if (!$isEmptyTrash) |
|
632 | 632 | { |
633 | 633 | // Delete the document |
634 | 634 | $output = executeQuery('document.deleteDocument', $args); |
635 | - if(!$output->toBool()) |
|
635 | + if (!$output->toBool()) |
|
636 | 636 | { |
637 | 637 | $oDB->rollback(); |
638 | 638 | return $output; |
@@ -643,7 +643,7 @@ discard block |
||
643 | 643 | |
644 | 644 | $this->deleteDocumentHistory(null, $document_srl, null); |
645 | 645 | // Update category information if the category_srl exists. |
646 | - if($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl')); |
|
646 | + if ($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'), $oDocument->get('category_srl')); |
|
647 | 647 | // Delete a declared list |
648 | 648 | executeQuery('document.deleteDeclared', $args); |
649 | 649 | // Delete extra variable |
@@ -651,11 +651,11 @@ discard block |
||
651 | 651 | |
652 | 652 | //this |
653 | 653 | // Call a trigger (after) |
654 | - if($output->toBool()) |
|
654 | + if ($output->toBool()) |
|
655 | 655 | { |
656 | 656 | $trigger_obj = $oDocument->getObjectVars(); |
657 | 657 | $trigger_output = ModuleHandler::triggerCall('document.deleteDocument', 'after', $trigger_obj); |
658 | - if(!$trigger_output->toBool()) |
|
658 | + if (!$trigger_output->toBool()) |
|
659 | 659 | { |
660 | 660 | $oDB->rollback(); |
661 | 661 | return $trigger_output; |
@@ -667,16 +667,16 @@ discard block |
||
667 | 667 | $this->_deleteDocumentVotedLog($args); |
668 | 668 | |
669 | 669 | // Remove the thumbnail file |
670 | - FileHandler::removeDir(sprintf('files/thumbnails/%s',getNumberingPath($document_srl, 3))); |
|
670 | + FileHandler::removeDir(sprintf('files/thumbnails/%s', getNumberingPath($document_srl, 3))); |
|
671 | 671 | |
672 | 672 | // commit |
673 | 673 | $oDB->commit(); |
674 | 674 | |
675 | 675 | //remove from cache |
676 | 676 | $oCacheHandler = CacheHandler::getInstance('object'); |
677 | - if($oCacheHandler->isSupport()) |
|
677 | + if ($oCacheHandler->isSupport()) |
|
678 | 678 | { |
679 | - $cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl; |
|
679 | + $cache_key = 'document_item:'.getNumberingPath($document_srl).$document_srl; |
|
680 | 680 | $oCacheHandler->delete($cache_key); |
681 | 681 | } |
682 | 682 | |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | { |
724 | 724 | $trash_args = new stdClass(); |
725 | 725 | // Get trash_srl if a given trash_srl doesn't exist |
726 | - if(!$obj->trash_srl) $trash_args->trash_srl = getNextSequence(); |
|
726 | + if (!$obj->trash_srl) $trash_args->trash_srl = getNextSequence(); |
|
727 | 727 | else $trash_args->trash_srl = $obj->trash_srl; |
728 | 728 | // Get its module_srl which the document belongs to |
729 | 729 | $oDocumentModel = getModel('document'); |
@@ -732,12 +732,12 @@ discard block |
||
732 | 732 | $trash_args->module_srl = $oDocument->get('module_srl'); |
733 | 733 | $obj->module_srl = $oDocument->get('module_srl'); |
734 | 734 | // Cannot throw data from the trash to the trash |
735 | - if($trash_args->module_srl == 0) return false; |
|
735 | + if ($trash_args->module_srl == 0) return false; |
|
736 | 736 | // Data setting |
737 | 737 | $trash_args->document_srl = $obj->document_srl; |
738 | 738 | $trash_args->description = $obj->description; |
739 | 739 | // Insert member's information only if the member is logged-in and not manually registered. |
740 | - if(Context::get('is_logged')&&!$manual_inserted) |
|
740 | + if (Context::get('is_logged') && !$manual_inserted) |
|
741 | 741 | { |
742 | 742 | $logged_info = Context::get('logged_info'); |
743 | 743 | $trash_args->member_srl = $logged_info->member_srl; |
@@ -773,14 +773,14 @@ discard block |
||
773 | 773 | |
774 | 774 | $oTrashAdminController = getAdminController('trash'); |
775 | 775 | $output = $oTrashAdminController->insertTrash($oTrashVO); |
776 | - if(!$output->toBool()) |
|
776 | + if (!$output->toBool()) |
|
777 | 777 | { |
778 | 778 | $oDB->rollback(); |
779 | 779 | return $output; |
780 | 780 | } |
781 | 781 | |
782 | 782 | $output = executeQuery('document.deleteDocument', $trash_args); |
783 | - if(!$output->toBool()) |
|
783 | + if (!$output->toBool()) |
|
784 | 784 | { |
785 | 785 | $oDB->rollback(); |
786 | 786 | return $output; |
@@ -793,12 +793,12 @@ discard block |
||
793 | 793 | }*/ |
794 | 794 | |
795 | 795 | // update category |
796 | - if($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl')); |
|
796 | + if ($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'), $oDocument->get('category_srl')); |
|
797 | 797 | |
798 | 798 | // remove thumbnails |
799 | - FileHandler::removeDir(sprintf('files/thumbnails/%s',getNumberingPath($obj->document_srl, 3))); |
|
799 | + FileHandler::removeDir(sprintf('files/thumbnails/%s', getNumberingPath($obj->document_srl, 3))); |
|
800 | 800 | // Set the attachment to be invalid state |
801 | - if($oDocument->hasUploadedFiles()) |
|
801 | + if ($oDocument->hasUploadedFiles()) |
|
802 | 802 | { |
803 | 803 | $args = new stdClass(); |
804 | 804 | $args->upload_target_srl = $oDocument->document_srl; |
@@ -806,10 +806,10 @@ discard block |
||
806 | 806 | executeQuery('file.updateFileValid', $args); |
807 | 807 | } |
808 | 808 | // Call a trigger (after) |
809 | - if($output->toBool()) |
|
809 | + if ($output->toBool()) |
|
810 | 810 | { |
811 | 811 | $trigger_output = ModuleHandler::triggerCall('document.moveDocumentToTrash', 'after', $obj); |
812 | - if(!$trigger_output->toBool()) |
|
812 | + if (!$trigger_output->toBool()) |
|
813 | 813 | { |
814 | 814 | $oDB->rollback(); |
815 | 815 | return $trigger_output; |
@@ -821,9 +821,9 @@ discard block |
||
821 | 821 | |
822 | 822 | // Clear cache |
823 | 823 | $oCacheHandler = CacheHandler::getInstance('object'); |
824 | - if($oCacheHandler->isSupport()) |
|
824 | + if ($oCacheHandler->isSupport()) |
|
825 | 825 | { |
826 | - $cache_key = 'document_item:'. getNumberingPath($oDocument->document_srl) . $oDocument->document_srl; |
|
826 | + $cache_key = 'document_item:'.getNumberingPath($oDocument->document_srl).$oDocument->document_srl; |
|
827 | 827 | $oCacheHandler->delete($cache_key); |
828 | 828 | } |
829 | 829 | |
@@ -838,7 +838,7 @@ discard block |
||
838 | 838 | function updateReadedCount(&$oDocument) |
839 | 839 | { |
840 | 840 | // Pass if Crawler access |
841 | - if(isCrawler()) return false; |
|
841 | + if (isCrawler()) return false; |
|
842 | 842 | |
843 | 843 | $document_srl = $oDocument->document_srl; |
844 | 844 | $member_srl = $oDocument->get('member_srl'); |
@@ -846,19 +846,19 @@ discard block |
||
846 | 846 | |
847 | 847 | // Call a trigger when the read count is updated (before) |
848 | 848 | $trigger_output = ModuleHandler::triggerCall('document.updateReadedCount', 'before', $oDocument); |
849 | - if(!$trigger_output->toBool()) return $trigger_output; |
|
849 | + if (!$trigger_output->toBool()) return $trigger_output; |
|
850 | 850 | |
851 | 851 | // Pass if read count is increaded on the session information |
852 | - if($_SESSION['readed_document'][$document_srl]) return false; |
|
852 | + if ($_SESSION['readed_document'][$document_srl]) return false; |
|
853 | 853 | |
854 | 854 | // Pass if the author's IP address is as same as visitor's. |
855 | - if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) |
|
855 | + if ($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) |
|
856 | 856 | { |
857 | 857 | $_SESSION['readed_document'][$document_srl] = true; |
858 | 858 | return false; |
859 | 859 | } |
860 | 860 | // Pass ater registering sesscion if the author is a member and has same information as the currently logged-in user. |
861 | - if($member_srl && $logged_info->member_srl == $member_srl) |
|
861 | + if ($member_srl && $logged_info->member_srl == $member_srl) |
|
862 | 862 | { |
863 | 863 | $_SESSION['readed_document'][$document_srl] = true; |
864 | 864 | return false; |
@@ -874,7 +874,7 @@ discard block |
||
874 | 874 | |
875 | 875 | // Call a trigger when the read count is updated (after) |
876 | 876 | $trigger_output = ModuleHandler::triggerCall('document.updateReadedCount', 'after', $oDocument); |
877 | - if(!$trigger_output->toBool()) |
|
877 | + if (!$trigger_output->toBool()) |
|
878 | 878 | { |
879 | 879 | $oDB->rollback(); |
880 | 880 | return $trigger_output; |
@@ -883,15 +883,15 @@ discard block |
||
883 | 883 | $oDB->commit(); |
884 | 884 | |
885 | 885 | $oCacheHandler = CacheHandler::getInstance('object'); |
886 | - if($oCacheHandler->isSupport()) |
|
886 | + if ($oCacheHandler->isSupport()) |
|
887 | 887 | { |
888 | 888 | //remove document item from cache |
889 | - $cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl; |
|
889 | + $cache_key = 'document_item:'.getNumberingPath($document_srl).$document_srl; |
|
890 | 890 | $oCacheHandler->delete($cache_key); |
891 | 891 | } |
892 | 892 | |
893 | 893 | // Register session |
894 | - if(!$_SESSION['banned_document'][$document_srl]) |
|
894 | + if (!$_SESSION['banned_document'][$document_srl]) |
|
895 | 895 | { |
896 | 896 | $_SESSION['readed_document'][$document_srl] = true; |
897 | 897 | } |
@@ -914,21 +914,21 @@ discard block |
||
914 | 914 | */ |
915 | 915 | function insertDocumentExtraKey($module_srl, $var_idx, $var_name, $var_type, $var_is_required = 'N', $var_search = 'N', $var_default = '', $var_desc = '', $eid) |
916 | 916 | { |
917 | - if(!$module_srl || !$var_idx || !$var_name || !$var_type || !$eid) return new BaseObject(-1,'msg_invalid_request'); |
|
917 | + if (!$module_srl || !$var_idx || !$var_name || !$var_type || !$eid) return new BaseObject(-1, 'msg_invalid_request'); |
|
918 | 918 | |
919 | 919 | $obj = new stdClass(); |
920 | 920 | $obj->module_srl = $module_srl; |
921 | 921 | $obj->var_idx = $var_idx; |
922 | 922 | $obj->var_name = $var_name; |
923 | 923 | $obj->var_type = $var_type; |
924 | - $obj->var_is_required = $var_is_required=='Y'?'Y':'N'; |
|
925 | - $obj->var_search = $var_search=='Y'?'Y':'N'; |
|
924 | + $obj->var_is_required = $var_is_required == 'Y' ? 'Y' : 'N'; |
|
925 | + $obj->var_search = $var_search == 'Y' ? 'Y' : 'N'; |
|
926 | 926 | $obj->var_default = $var_default; |
927 | 927 | $obj->var_desc = $var_desc; |
928 | 928 | $obj->eid = $eid; |
929 | 929 | |
930 | 930 | $output = executeQuery('document.getDocumentExtraKeys', $obj); |
931 | - if(!$output->data) |
|
931 | + if (!$output->data) |
|
932 | 932 | { |
933 | 933 | $output = executeQuery('document.insertDocumentExtraKey', $obj); |
934 | 934 | } |
@@ -940,7 +940,7 @@ discard block |
||
940 | 940 | } |
941 | 941 | |
942 | 942 | $oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE); |
943 | - if($oCacheHandler->isSupport()) |
|
943 | + if ($oCacheHandler->isSupport()) |
|
944 | 944 | { |
945 | 945 | $object_key = 'module_document_extra_keys:'.$module_srl; |
946 | 946 | $cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); |
@@ -958,42 +958,42 @@ discard block |
||
958 | 958 | */ |
959 | 959 | function deleteDocumentExtraKeys($module_srl, $var_idx = null) |
960 | 960 | { |
961 | - if(!$module_srl) return new BaseObject(-1,'msg_invalid_request'); |
|
961 | + if (!$module_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
962 | 962 | $obj = new stdClass(); |
963 | 963 | $obj->module_srl = $module_srl; |
964 | - if(!is_null($var_idx)) $obj->var_idx = $var_idx; |
|
964 | + if (!is_null($var_idx)) $obj->var_idx = $var_idx; |
|
965 | 965 | |
966 | 966 | $oDB = DB::getInstance(); |
967 | 967 | $oDB->begin(); |
968 | 968 | |
969 | 969 | $output = $oDB->executeQuery('document.deleteDocumentExtraKeys', $obj); |
970 | - if(!$output->toBool()) |
|
970 | + if (!$output->toBool()) |
|
971 | 971 | { |
972 | 972 | $oDB->rollback(); |
973 | 973 | return $output; |
974 | 974 | } |
975 | 975 | |
976 | - if($var_idx != NULL) |
|
976 | + if ($var_idx != NULL) |
|
977 | 977 | { |
978 | 978 | $output = $oDB->executeQuery('document.updateDocumentExtraKeyIdxOrder', $obj); |
979 | - if(!$output->toBool()) |
|
979 | + if (!$output->toBool()) |
|
980 | 980 | { |
981 | 981 | $oDB->rollback(); |
982 | 982 | return $output; |
983 | 983 | } |
984 | 984 | } |
985 | 985 | |
986 | - $output = executeQuery('document.deleteDocumentExtraVars', $obj); |
|
987 | - if(!$output->toBool()) |
|
986 | + $output = executeQuery('document.deleteDocumentExtraVars', $obj); |
|
987 | + if (!$output->toBool()) |
|
988 | 988 | { |
989 | 989 | $oDB->rollback(); |
990 | 990 | return $output; |
991 | 991 | } |
992 | 992 | |
993 | - if($var_idx != NULL) |
|
993 | + if ($var_idx != NULL) |
|
994 | 994 | { |
995 | 995 | $output = $oDB->executeQuery('document.updateDocumentExtraVarIdxOrder', $obj); |
996 | - if(!$output->toBool()) |
|
996 | + if (!$output->toBool()) |
|
997 | 997 | { |
998 | 998 | $oDB->rollback(); |
999 | 999 | return $output; |
@@ -1003,7 +1003,7 @@ discard block |
||
1003 | 1003 | $oDB->commit(); |
1004 | 1004 | |
1005 | 1005 | $oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE); |
1006 | - if($oCacheHandler->isSupport()) |
|
1006 | + if ($oCacheHandler->isSupport()) |
|
1007 | 1007 | { |
1008 | 1008 | $object_key = 'module_document_extra_keys:'.$module_srl; |
1009 | 1009 | $cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key); |
@@ -1025,8 +1025,8 @@ discard block |
||
1025 | 1025 | */ |
1026 | 1026 | function insertDocumentExtraVar($module_srl, $document_srl, $var_idx, $value, $eid = null, $lang_code = '') |
1027 | 1027 | { |
1028 | - if(!$module_srl || !$document_srl || !$var_idx || !isset($value)) return new BaseObject(-1,'msg_invalid_request'); |
|
1029 | - if(!$lang_code) $lang_code = Context::getLangType(); |
|
1028 | + if (!$module_srl || !$document_srl || !$var_idx || !isset($value)) return new BaseObject(-1, 'msg_invalid_request'); |
|
1029 | + if (!$lang_code) $lang_code = Context::getLangType(); |
|
1030 | 1030 | |
1031 | 1031 | $obj = new stdClass; |
1032 | 1032 | $obj->module_srl = $module_srl; |
@@ -1052,10 +1052,10 @@ discard block |
||
1052 | 1052 | { |
1053 | 1053 | $obj = new stdClass(); |
1054 | 1054 | $obj->module_srl = $module_srl; |
1055 | - if(!is_null($document_srl)) $obj->document_srl = $document_srl; |
|
1056 | - if(!is_null($var_idx)) $obj->var_idx = $var_idx; |
|
1057 | - if(!is_null($lang_code)) $obj->lang_code = $lang_code; |
|
1058 | - if(!is_null($eid)) $obj->eid = $eid; |
|
1055 | + if (!is_null($document_srl)) $obj->document_srl = $document_srl; |
|
1056 | + if (!is_null($var_idx)) $obj->var_idx = $var_idx; |
|
1057 | + if (!is_null($lang_code)) $obj->lang_code = $lang_code; |
|
1058 | + if (!is_null($eid)) $obj->eid = $eid; |
|
1059 | 1059 | $output = executeQuery('document.deleteDocumentExtraVars', $obj); |
1060 | 1060 | return $output; |
1061 | 1061 | } |
@@ -1069,10 +1069,10 @@ discard block |
||
1069 | 1069 | */ |
1070 | 1070 | function updateVotedCount($document_srl, $point = 1) |
1071 | 1071 | { |
1072 | - if($point > 0) $failed_voted = 'failed_voted'; |
|
1072 | + if ($point > 0) $failed_voted = 'failed_voted'; |
|
1073 | 1073 | else $failed_voted = 'failed_blamed'; |
1074 | 1074 | // Return fail if session already has information about votes |
1075 | - if($_SESSION['voted_document'][$document_srl]) |
|
1075 | + if ($_SESSION['voted_document'][$document_srl]) |
|
1076 | 1076 | { |
1077 | 1077 | return new BaseObject(-1, $failed_voted); |
1078 | 1078 | } |
@@ -1080,7 +1080,7 @@ discard block |
||
1080 | 1080 | $oDocumentModel = getModel('document'); |
1081 | 1081 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false); |
1082 | 1082 | // Pass if the author's IP address is as same as visitor's. |
1083 | - if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) |
|
1083 | + if ($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) |
|
1084 | 1084 | { |
1085 | 1085 | $_SESSION['voted_document'][$document_srl] = true; |
1086 | 1086 | return new BaseObject(-1, $failed_voted); |
@@ -1091,10 +1091,10 @@ discard block |
||
1091 | 1091 | $member_srl = $oMemberModel->getLoggedMemberSrl(); |
1092 | 1092 | |
1093 | 1093 | // Check if document's author is a member. |
1094 | - if($oDocument->get('member_srl')) |
|
1094 | + if ($oDocument->get('member_srl')) |
|
1095 | 1095 | { |
1096 | 1096 | // Pass after registering a session if author's information is same as the currently logged-in user's. |
1097 | - if($member_srl && $member_srl == abs($oDocument->get('member_srl'))) |
|
1097 | + if ($member_srl && $member_srl == abs($oDocument->get('member_srl'))) |
|
1098 | 1098 | { |
1099 | 1099 | $_SESSION['voted_document'][$document_srl] = true; |
1100 | 1100 | return new BaseObject(-1, $failed_voted); |
@@ -1103,7 +1103,7 @@ discard block |
||
1103 | 1103 | |
1104 | 1104 | // Use member_srl for logged-in members and IP address for non-members. |
1105 | 1105 | $args = new stdClass; |
1106 | - if($member_srl) |
|
1106 | + if ($member_srl) |
|
1107 | 1107 | { |
1108 | 1108 | $args->member_srl = $member_srl; |
1109 | 1109 | } |
@@ -1114,7 +1114,7 @@ discard block |
||
1114 | 1114 | $args->document_srl = $document_srl; |
1115 | 1115 | $output = executeQuery('document.getDocumentVotedLogInfo', $args); |
1116 | 1116 | // Pass after registering a session if log information has vote-up logs |
1117 | - if($output->data->count) |
|
1117 | + if ($output->data->count) |
|
1118 | 1118 | { |
1119 | 1119 | $_SESSION['voted_document'][$document_srl] = true; |
1120 | 1120 | return new BaseObject(-1, $failed_voted); |
@@ -1130,7 +1130,7 @@ discard block |
||
1130 | 1130 | $trigger_obj->before_point = ($point < 0) ? $oDocument->get('blamed_count') : $oDocument->get('voted_count'); |
1131 | 1131 | $trigger_obj->after_point = $trigger_obj->before_point + $point; |
1132 | 1132 | $trigger_output = ModuleHandler::triggerCall('document.updateVotedCount', 'before', $trigger_obj); |
1133 | - if(!$trigger_output->toBool()) |
|
1133 | + if (!$trigger_output->toBool()) |
|
1134 | 1134 | { |
1135 | 1135 | return $trigger_output; |
1136 | 1136 | } |
@@ -1140,7 +1140,7 @@ discard block |
||
1140 | 1140 | $oDB->begin(); |
1141 | 1141 | |
1142 | 1142 | // Update the voted count |
1143 | - if($trigger_obj->update_target === 'blamed_count') |
|
1143 | + if ($trigger_obj->update_target === 'blamed_count') |
|
1144 | 1144 | { |
1145 | 1145 | $args->blamed_count = $trigger_obj->after_point; |
1146 | 1146 | $output = executeQuery('document.updateBlamedCount', $args); |
@@ -1150,16 +1150,16 @@ discard block |
||
1150 | 1150 | $args->voted_count = $trigger_obj->after_point; |
1151 | 1151 | $output = executeQuery('document.updateVotedCount', $args); |
1152 | 1152 | } |
1153 | - if(!$output->toBool()) return $output; |
|
1153 | + if (!$output->toBool()) return $output; |
|
1154 | 1154 | |
1155 | 1155 | // Leave logs |
1156 | 1156 | $args->point = $trigger_obj->point; |
1157 | 1157 | $output = executeQuery('document.insertDocumentVotedLog', $args); |
1158 | - if(!$output->toBool()) return $output; |
|
1158 | + if (!$output->toBool()) return $output; |
|
1159 | 1159 | |
1160 | 1160 | // Call a trigger (after) |
1161 | 1161 | $trigger_output = ModuleHandler::triggerCall('document.updateVotedCount', 'after', $trigger_obj); |
1162 | - if(!$trigger_output->toBool()) |
|
1162 | + if (!$trigger_output->toBool()) |
|
1163 | 1163 | { |
1164 | 1164 | $oDB->rollback(); |
1165 | 1165 | return $trigger_output; |
@@ -1168,10 +1168,10 @@ discard block |
||
1168 | 1168 | $oDB->commit(); |
1169 | 1169 | |
1170 | 1170 | $oCacheHandler = CacheHandler::getInstance('object'); |
1171 | - if($oCacheHandler->isSupport()) |
|
1171 | + if ($oCacheHandler->isSupport()) |
|
1172 | 1172 | { |
1173 | 1173 | //remove document item from cache |
1174 | - $cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl; |
|
1174 | + $cache_key = 'document_item:'.getNumberingPath($document_srl).$document_srl; |
|
1175 | 1175 | $oCacheHandler->delete($cache_key); |
1176 | 1176 | } |
1177 | 1177 | |
@@ -1180,7 +1180,7 @@ discard block |
||
1180 | 1180 | |
1181 | 1181 | // Return result |
1182 | 1182 | $output = new BaseObject(); |
1183 | - if($trigger_obj->update_target === 'voted_count') |
|
1183 | + if ($trigger_obj->update_target === 'voted_count') |
|
1184 | 1184 | { |
1185 | 1185 | $output->setMessage('success_voted'); |
1186 | 1186 | $output->add('voted_count', $trigger_obj->after_point); |
@@ -1202,13 +1202,13 @@ discard block |
||
1202 | 1202 | function declaredDocument($document_srl) |
1203 | 1203 | { |
1204 | 1204 | // Fail if session information already has a reported document |
1205 | - if($_SESSION['declared_document'][$document_srl]) return new BaseObject(-1, 'failed_declared'); |
|
1205 | + if ($_SESSION['declared_document'][$document_srl]) return new BaseObject(-1, 'failed_declared'); |
|
1206 | 1206 | |
1207 | 1207 | // Check if previously reported |
1208 | 1208 | $args = new stdClass(); |
1209 | 1209 | $args->document_srl = $document_srl; |
1210 | 1210 | $output = executeQuery('document.getDeclaredDocument', $args); |
1211 | - if(!$output->toBool()) return $output; |
|
1211 | + if (!$output->toBool()) return $output; |
|
1212 | 1212 | |
1213 | 1213 | $declared_count = ($output->data->declared_count) ? $output->data->declared_count : 0; |
1214 | 1214 | |
@@ -1218,7 +1218,7 @@ discard block |
||
1218 | 1218 | |
1219 | 1219 | // Call a trigger (before) |
1220 | 1220 | $trigger_output = ModuleHandler::triggerCall('document.declaredDocument', 'before', $trigger_obj); |
1221 | - if(!$trigger_output->toBool()) |
|
1221 | + if (!$trigger_output->toBool()) |
|
1222 | 1222 | { |
1223 | 1223 | return $trigger_output; |
1224 | 1224 | } |
@@ -1228,19 +1228,19 @@ discard block |
||
1228 | 1228 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false); |
1229 | 1229 | |
1230 | 1230 | // Pass if the author's IP address is as same as visitor's. |
1231 | - if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) { |
|
1231 | + if ($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) { |
|
1232 | 1232 | $_SESSION['declared_document'][$document_srl] = true; |
1233 | 1233 | return new BaseObject(-1, 'failed_declared'); |
1234 | 1234 | } |
1235 | 1235 | |
1236 | 1236 | // Check if document's author is a member. |
1237 | - if($oDocument->get('member_srl')) |
|
1237 | + if ($oDocument->get('member_srl')) |
|
1238 | 1238 | { |
1239 | 1239 | // Create a member model object |
1240 | 1240 | $oMemberModel = getModel('member'); |
1241 | 1241 | $member_srl = $oMemberModel->getLoggedMemberSrl(); |
1242 | 1242 | // Pass after registering a session if author's information is same as the currently logged-in user's. |
1243 | - if($member_srl && $member_srl == abs($oDocument->get('member_srl'))) |
|
1243 | + if ($member_srl && $member_srl == abs($oDocument->get('member_srl'))) |
|
1244 | 1244 | { |
1245 | 1245 | $_SESSION['declared_document'][$document_srl] = true; |
1246 | 1246 | return new BaseObject(-1, 'failed_declared'); |
@@ -1249,7 +1249,7 @@ discard block |
||
1249 | 1249 | |
1250 | 1250 | // Use member_srl for logged-in members and IP address for non-members. |
1251 | 1251 | $args = new stdClass; |
1252 | - if($member_srl) |
|
1252 | + if ($member_srl) |
|
1253 | 1253 | { |
1254 | 1254 | $args->member_srl = $member_srl; |
1255 | 1255 | } |
@@ -1262,7 +1262,7 @@ discard block |
||
1262 | 1262 | $output = executeQuery('document.getDocumentDeclaredLogInfo', $args); |
1263 | 1263 | |
1264 | 1264 | // Pass after registering a sesson if reported/declared documents are in the logs. |
1265 | - if($output->data->count) |
|
1265 | + if ($output->data->count) |
|
1266 | 1266 | { |
1267 | 1267 | $_SESSION['declared_document'][$document_srl] = true; |
1268 | 1268 | return new BaseObject(-1, 'failed_declared'); |
@@ -1273,23 +1273,23 @@ discard block |
||
1273 | 1273 | $oDB->begin(); |
1274 | 1274 | |
1275 | 1275 | // Add the declared document |
1276 | - if($declared_count > 0) $output = executeQuery('document.updateDeclaredDocument', $args); |
|
1276 | + if ($declared_count > 0) $output = executeQuery('document.updateDeclaredDocument', $args); |
|
1277 | 1277 | else $output = executeQuery('document.insertDeclaredDocument', $args); |
1278 | - if(!$output->toBool()) return $output; |
|
1278 | + if (!$output->toBool()) return $output; |
|
1279 | 1279 | // Leave logs |
1280 | 1280 | $output = executeQuery('document.insertDocumentDeclaredLog', $args); |
1281 | - if(!$output->toBool()) |
|
1281 | + if (!$output->toBool()) |
|
1282 | 1282 | { |
1283 | 1283 | $oDB->rollback(); |
1284 | 1284 | return $output; |
1285 | 1285 | } |
1286 | 1286 | |
1287 | - $this->add('declared_count', $declared_count+1); |
|
1287 | + $this->add('declared_count', $declared_count + 1); |
|
1288 | 1288 | |
1289 | 1289 | // Call a trigger (after) |
1290 | 1290 | $trigger_obj->declared_count = $declared_count + 1; |
1291 | 1291 | $trigger_output = ModuleHandler::triggerCall('document.declaredDocument', 'after', $trigger_obj); |
1292 | - if(!$trigger_output->toBool()) |
|
1292 | + if (!$trigger_output->toBool()) |
|
1293 | 1293 | { |
1294 | 1294 | $oDB->rollback(); |
1295 | 1295 | return $trigger_output; |
@@ -1319,16 +1319,16 @@ discard block |
||
1319 | 1319 | $args->document_srl = $document_srl; |
1320 | 1320 | $args->comment_count = $comment_count; |
1321 | 1321 | |
1322 | - if($comment_inserted) |
|
1322 | + if ($comment_inserted) |
|
1323 | 1323 | { |
1324 | - $args->update_order = -1*getNextSequence(); |
|
1324 | + $args->update_order = -1 * getNextSequence(); |
|
1325 | 1325 | $args->last_updater = $last_updater; |
1326 | 1326 | |
1327 | 1327 | $oCacheHandler = CacheHandler::getInstance('object'); |
1328 | - if($oCacheHandler->isSupport()) |
|
1328 | + if ($oCacheHandler->isSupport()) |
|
1329 | 1329 | { |
1330 | 1330 | //remove document item from cache |
1331 | - $cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl; |
|
1331 | + $cache_key = 'document_item:'.getNumberingPath($document_srl).$document_srl; |
|
1332 | 1332 | $oCacheHandler->delete($cache_key); |
1333 | 1333 | } |
1334 | 1334 | } |
@@ -1349,10 +1349,10 @@ discard block |
||
1349 | 1349 | $args->trackback_count = $trackback_count; |
1350 | 1350 | |
1351 | 1351 | $oCacheHandler = CacheHandler::getInstance('object'); |
1352 | - if($oCacheHandler->isSupport()) |
|
1352 | + if ($oCacheHandler->isSupport()) |
|
1353 | 1353 | { |
1354 | 1354 | //remove document item from cache |
1355 | - $cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl; |
|
1355 | + $cache_key = 'document_item:'.getNumberingPath($document_srl).$document_srl; |
|
1356 | 1356 | $oCacheHandler->delete($cache_key); |
1357 | 1357 | } |
1358 | 1358 | |
@@ -1367,14 +1367,14 @@ discard block |
||
1367 | 1367 | function insertCategory($obj) |
1368 | 1368 | { |
1369 | 1369 | // Sort the order to display if a child category is added |
1370 | - if($obj->parent_srl) |
|
1370 | + if ($obj->parent_srl) |
|
1371 | 1371 | { |
1372 | 1372 | // Get its parent category |
1373 | 1373 | $oDocumentModel = getModel('document'); |
1374 | 1374 | $parent_category = $oDocumentModel->getCategory($obj->parent_srl); |
1375 | 1375 | $obj->list_order = $parent_category->list_order; |
1376 | - $this->updateCategoryListOrder($parent_category->module_srl, $parent_category->list_order+1); |
|
1377 | - if(!$obj->category_srl) $obj->category_srl = getNextSequence(); |
|
1376 | + $this->updateCategoryListOrder($parent_category->module_srl, $parent_category->list_order + 1); |
|
1377 | + if (!$obj->category_srl) $obj->category_srl = getNextSequence(); |
|
1378 | 1378 | } |
1379 | 1379 | else |
1380 | 1380 | { |
@@ -1382,7 +1382,7 @@ discard block |
||
1382 | 1382 | } |
1383 | 1383 | |
1384 | 1384 | $output = executeQuery('document.insertCategory', $obj); |
1385 | - if($output->toBool()) |
|
1385 | + if ($output->toBool()) |
|
1386 | 1386 | { |
1387 | 1387 | $output->add('category_srl', $obj->category_srl); |
1388 | 1388 | $this->makeCategoryFile($obj->module_srl); |
@@ -1416,13 +1416,13 @@ discard block |
||
1416 | 1416 | { |
1417 | 1417 | // Create a document model object |
1418 | 1418 | $oDocumentModel = getModel('document'); |
1419 | - if(!$document_count) $document_count = $oDocumentModel->getCategoryDocumentCount($module_srl,$category_srl); |
|
1419 | + if (!$document_count) $document_count = $oDocumentModel->getCategoryDocumentCount($module_srl, $category_srl); |
|
1420 | 1420 | |
1421 | 1421 | $args = new stdClass; |
1422 | 1422 | $args->category_srl = $category_srl; |
1423 | 1423 | $args->document_count = $document_count; |
1424 | 1424 | $output = executeQuery('document.updateCategoryCount', $args); |
1425 | - if($output->toBool()) $this->makeCategoryFile($module_srl); |
|
1425 | + if ($output->toBool()) $this->makeCategoryFile($module_srl); |
|
1426 | 1426 | |
1427 | 1427 | return $output; |
1428 | 1428 | } |
@@ -1435,7 +1435,7 @@ discard block |
||
1435 | 1435 | function updateCategory($obj) |
1436 | 1436 | { |
1437 | 1437 | $output = executeQuery('document.updateCategory', $obj); |
1438 | - if($output->toBool()) $this->makeCategoryFile($obj->module_srl); |
|
1438 | + if ($output->toBool()) $this->makeCategoryFile($obj->module_srl); |
|
1439 | 1439 | return $output; |
1440 | 1440 | } |
1441 | 1441 | |
@@ -1452,32 +1452,32 @@ discard block |
||
1452 | 1452 | $category_info = $oDocumentModel->getCategory($category_srl); |
1453 | 1453 | // Display an error that the category cannot be deleted if it has a child |
1454 | 1454 | $output = executeQuery('document.getChildCategoryCount', $args); |
1455 | - if(!$output->toBool()) return $output; |
|
1456 | - if($output->data->count>0) return new BaseObject(-1, 'msg_cannot_delete_for_child'); |
|
1455 | + if (!$output->toBool()) return $output; |
|
1456 | + if ($output->data->count > 0) return new BaseObject(-1, 'msg_cannot_delete_for_child'); |
|
1457 | 1457 | // Delete a category information |
1458 | 1458 | $output = executeQuery('document.deleteCategory', $args); |
1459 | - if(!$output->toBool()) return $output; |
|
1459 | + if (!$output->toBool()) return $output; |
|
1460 | 1460 | |
1461 | 1461 | $this->makeCategoryFile($category_info->module_srl); |
1462 | 1462 | // remvove cache |
1463 | 1463 | $oCacheHandler = CacheHandler::getInstance('object'); |
1464 | - if($oCacheHandler->isSupport()) |
|
1464 | + if ($oCacheHandler->isSupport()) |
|
1465 | 1465 | { |
1466 | 1466 | $page = 0; |
1467 | - while(true) { |
|
1467 | + while (true) { |
|
1468 | 1468 | $args = new stdClass(); |
1469 | 1469 | $args->category_srl = $category_srl; |
1470 | 1470 | $args->list_count = 100; |
1471 | 1471 | $args->page = ++$page; |
1472 | 1472 | $output = executeQuery('document.getDocumentList', $args, array('document_srl')); |
1473 | 1473 | |
1474 | - if($output->data == array()) |
|
1474 | + if ($output->data == array()) |
|
1475 | 1475 | break; |
1476 | 1476 | |
1477 | - foreach($output->data as $val) |
|
1477 | + foreach ($output->data as $val) |
|
1478 | 1478 | { |
1479 | 1479 | //remove document item from cache |
1480 | - $cache_key = 'document_item:'. getNumberingPath($val->document_srl) . $val->document_srl; |
|
1480 | + $cache_key = 'document_item:'.getNumberingPath($val->document_srl).$val->document_srl; |
|
1481 | 1481 | $oCacheHandler->delete($cache_key); |
1482 | 1482 | } |
1483 | 1483 | } |
@@ -1524,18 +1524,18 @@ discard block |
||
1524 | 1524 | // Seek a full list of categories |
1525 | 1525 | $category_list = $oDocumentModel->getCategoryList($module_srl); |
1526 | 1526 | $category_srl_list = array_keys($category_list); |
1527 | - if(count($category_srl_list)<2) return new BaseObject(); |
|
1527 | + if (count($category_srl_list) < 2) return new BaseObject(); |
|
1528 | 1528 | |
1529 | 1529 | $prev_category = NULL; |
1530 | - foreach($category_list as $key => $val) |
|
1530 | + foreach ($category_list as $key => $val) |
|
1531 | 1531 | { |
1532 | - if($key==$category_srl) break; |
|
1532 | + if ($key == $category_srl) break; |
|
1533 | 1533 | $prev_category = $val; |
1534 | 1534 | } |
1535 | 1535 | // Return if the previous category doesn't exist |
1536 | - if(!$prev_category) return new BaseObject(-1,Context::getLang('msg_category_not_moved')); |
|
1536 | + if (!$prev_category) return new BaseObject(-1, Context::getLang('msg_category_not_moved')); |
|
1537 | 1537 | // Return if the selected category is the top level |
1538 | - if($category_srl_list[0]==$category_srl) return new BaseObject(-1,Context::getLang('msg_category_not_moved')); |
|
1538 | + if ($category_srl_list[0] == $category_srl) return new BaseObject(-1, Context::getLang('msg_category_not_moved')); |
|
1539 | 1539 | // Information of the selected category |
1540 | 1540 | $cur_args = new stdClass; |
1541 | 1541 | $cur_args->category_srl = $category_srl; |
@@ -1571,15 +1571,15 @@ discard block |
||
1571 | 1571 | // Seek a full list of categories |
1572 | 1572 | $category_list = $oDocumentModel->getCategoryList($module_srl); |
1573 | 1573 | $category_srl_list = array_keys($category_list); |
1574 | - if(count($category_srl_list)<2) return new BaseObject(); |
|
1574 | + if (count($category_srl_list) < 2) return new BaseObject(); |
|
1575 | 1575 | |
1576 | - for($i=0;$i<count($category_srl_list);$i++) |
|
1576 | + for ($i = 0; $i < count($category_srl_list); $i++) |
|
1577 | 1577 | { |
1578 | - if($category_srl_list[$i]==$category_srl) break; |
|
1578 | + if ($category_srl_list[$i] == $category_srl) break; |
|
1579 | 1579 | } |
1580 | 1580 | |
1581 | - $next_category_srl = $category_srl_list[$i+1]; |
|
1582 | - if(!$category_list[$next_category_srl]) return new BaseObject(-1,Context::getLang('msg_category_not_moved')); |
|
1581 | + $next_category_srl = $category_srl_list[$i + 1]; |
|
1582 | + if (!$category_list[$next_category_srl]) return new BaseObject(-1, Context::getLang('msg_category_not_moved')); |
|
1583 | 1583 | $next_category = $category_list[$next_category_srl]; |
1584 | 1584 | // Information of the selected category |
1585 | 1585 | $cur_args = new stdClass; |
@@ -1606,7 +1606,7 @@ discard block |
||
1606 | 1606 | { |
1607 | 1607 | $oDocumentModel = getModel('document'); |
1608 | 1608 | $extra_keys = $oDocumentModel->getExtraKeys($module_srl); |
1609 | - if(!count($extra_keys)) return; |
|
1609 | + if (!count($extra_keys)) return; |
|
1610 | 1610 | |
1611 | 1611 | $js_code = array(); |
1612 | 1612 | $js_code[] = '<script>//<![CDATA['; |
@@ -1616,16 +1616,16 @@ discard block |
||
1616 | 1616 | |
1617 | 1617 | $logged_info = Context::get('logged_info'); |
1618 | 1618 | |
1619 | - foreach($extra_keys as $idx => $val) |
|
1619 | + foreach ($extra_keys as $idx => $val) |
|
1620 | 1620 | { |
1621 | 1621 | $idx = $val->idx; |
1622 | - if($val->type == 'kr_zip') |
|
1622 | + if ($val->type == 'kr_zip') |
|
1623 | 1623 | { |
1624 | 1624 | $idx .= '[]'; |
1625 | 1625 | } |
1626 | 1626 | $name = str_ireplace(array('<script', '</script'), array('<scr" + "ipt', '</scr" + "ipt'), $val->name); |
1627 | 1627 | $js_code[] = sprintf('validator.cast("ADD_MESSAGE", ["extra_vars%s","%s"]);', $idx, $name); |
1628 | - if($val->is_required == 'Y') $js_code[] = sprintf('validator.cast("ADD_EXTRA_FIELD", ["extra_vars%s", { required:true }]);', $idx); |
|
1628 | + if ($val->is_required == 'Y') $js_code[] = sprintf('validator.cast("ADD_EXTRA_FIELD", ["extra_vars%s", { required:true }]);', $idx); |
|
1629 | 1629 | } |
1630 | 1630 | |
1631 | 1631 | $js_code[] = '})(jQuery);'; |
@@ -1643,12 +1643,12 @@ discard block |
||
1643 | 1643 | function procDocumentInsertCategory($args = null) |
1644 | 1644 | { |
1645 | 1645 | // List variables |
1646 | - if(!$args) $args = Context::gets('module_srl','category_srl','parent_srl','category_title','category_description','expand','group_srls','category_color','mid'); |
|
1646 | + if (!$args) $args = Context::gets('module_srl', 'category_srl', 'parent_srl', 'category_title', 'category_description', 'expand', 'group_srls', 'category_color', 'mid'); |
|
1647 | 1647 | $args->title = $args->category_title; |
1648 | 1648 | $args->description = $args->category_description; |
1649 | 1649 | $args->color = $args->category_color; |
1650 | 1650 | |
1651 | - if(!$args->module_srl && $args->mid) |
|
1651 | + if (!$args->module_srl && $args->mid) |
|
1652 | 1652 | { |
1653 | 1653 | $mid = $args->mid; |
1654 | 1654 | unset($args->mid); |
@@ -1659,28 +1659,28 @@ discard block |
||
1659 | 1659 | $columnList = array('module_srl', 'module'); |
1660 | 1660 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl, $columnList); |
1661 | 1661 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
1662 | - if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted'); |
|
1662 | + if (!$grant->manager) return new BaseObject(-1, 'msg_not_permitted'); |
|
1663 | 1663 | |
1664 | - if($args->expand !="Y") $args->expand = "N"; |
|
1665 | - if(!is_array($args->group_srls)) $args->group_srls = str_replace('|@|',',',$args->group_srls); |
|
1664 | + if ($args->expand != "Y") $args->expand = "N"; |
|
1665 | + if (!is_array($args->group_srls)) $args->group_srls = str_replace('|@|', ',', $args->group_srls); |
|
1666 | 1666 | else $args->group_srls = implode(',', $args->group_srls); |
1667 | - $args->parent_srl = (int)$args->parent_srl; |
|
1667 | + $args->parent_srl = (int) $args->parent_srl; |
|
1668 | 1668 | |
1669 | 1669 | $oDocumentModel = getModel('document'); |
1670 | 1670 | |
1671 | 1671 | $oDB = &DB::getInstance(); |
1672 | 1672 | $oDB->begin(); |
1673 | 1673 | // Check if already exists |
1674 | - if($args->category_srl) |
|
1674 | + if ($args->category_srl) |
|
1675 | 1675 | { |
1676 | 1676 | $category_info = $oDocumentModel->getCategory($args->category_srl); |
1677 | - if($category_info->category_srl != $args->category_srl) $args->category_srl = null; |
|
1677 | + if ($category_info->category_srl != $args->category_srl) $args->category_srl = null; |
|
1678 | 1678 | } |
1679 | 1679 | // Update if exists |
1680 | - if($args->category_srl) |
|
1680 | + if ($args->category_srl) |
|
1681 | 1681 | { |
1682 | 1682 | $output = $this->updateCategory($args); |
1683 | - if(!$output->toBool()) |
|
1683 | + if (!$output->toBool()) |
|
1684 | 1684 | { |
1685 | 1685 | $oDB->rollback(); |
1686 | 1686 | return $output; |
@@ -1690,7 +1690,7 @@ discard block |
||
1690 | 1690 | else |
1691 | 1691 | { |
1692 | 1692 | $output = $this->insertCategory($args); |
1693 | - if(!$output->toBool()) |
|
1693 | + if (!$output->toBool()) |
|
1694 | 1694 | { |
1695 | 1695 | $oDB->rollback(); |
1696 | 1696 | return $output; |
@@ -1729,11 +1729,11 @@ discard block |
||
1729 | 1729 | $columnList = array('module_srl', 'module'); |
1730 | 1730 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($source_category->module_srl, $columnList); |
1731 | 1731 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
1732 | - if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted'); |
|
1732 | + if (!$grant->manager) return new BaseObject(-1, 'msg_not_permitted'); |
|
1733 | 1733 | |
1734 | 1734 | // First child of the parent_category_srl |
1735 | 1735 | $source_args = new stdClass; |
1736 | - if($parent_category_srl > 0 || ($parent_category_srl == 0 && $target_category_srl == 0)) |
|
1736 | + if ($parent_category_srl > 0 || ($parent_category_srl == 0 && $target_category_srl == 0)) |
|
1737 | 1737 | { |
1738 | 1738 | $parent_category = $oDocumentModel->getCategory($parent_category_srl); |
1739 | 1739 | |
@@ -1742,30 +1742,30 @@ discard block |
||
1742 | 1742 | $args->parent_srl = $parent_category_srl; |
1743 | 1743 | $output = executeQuery('document.getChildCategoryMinListOrder', $args); |
1744 | 1744 | |
1745 | - if(!$output->toBool()) return $output; |
|
1746 | - $args->list_order = (int)$output->data->list_order; |
|
1747 | - if(!$args->list_order) $args->list_order = 0; |
|
1745 | + if (!$output->toBool()) return $output; |
|
1746 | + $args->list_order = (int) $output->data->list_order; |
|
1747 | + if (!$args->list_order) $args->list_order = 0; |
|
1748 | 1748 | $args->list_order--; |
1749 | 1749 | |
1750 | 1750 | $source_args->category_srl = $source_category_srl; |
1751 | 1751 | $source_args->parent_srl = $parent_category_srl; |
1752 | 1752 | $source_args->list_order = $args->list_order; |
1753 | 1753 | $output = $this->updateCategory($source_args); |
1754 | - if(!$output->toBool()) return $output; |
|
1754 | + if (!$output->toBool()) return $output; |
|
1755 | 1755 | // Sibling of the $target_category_srl |
1756 | 1756 | } |
1757 | - else if($target_category_srl > 0) |
|
1757 | + else if ($target_category_srl > 0) |
|
1758 | 1758 | { |
1759 | 1759 | $target_category = $oDocumentModel->getCategory($target_category_srl); |
1760 | 1760 | // Move all siblings of the $target_category down |
1761 | - $output = $this->updateCategoryListOrder($target_category->module_srl, $target_category->list_order+1); |
|
1762 | - if(!$output->toBool()) return $output; |
|
1761 | + $output = $this->updateCategoryListOrder($target_category->module_srl, $target_category->list_order + 1); |
|
1762 | + if (!$output->toBool()) return $output; |
|
1763 | 1763 | |
1764 | 1764 | $source_args->category_srl = $source_category_srl; |
1765 | 1765 | $source_args->parent_srl = $target_category->parent_srl; |
1766 | - $source_args->list_order = $target_category->list_order+1; |
|
1766 | + $source_args->list_order = $target_category->list_order + 1; |
|
1767 | 1767 | $output = $this->updateCategory($source_args); |
1768 | - if(!$output->toBool()) return $output; |
|
1768 | + if (!$output->toBool()) return $output; |
|
1769 | 1769 | } |
1770 | 1770 | // Re-generate the xml file |
1771 | 1771 | $xml_file = $this->makeCategoryFile($source_category->module_srl); |
@@ -1781,7 +1781,7 @@ discard block |
||
1781 | 1781 | function procDocumentDeleteCategory() |
1782 | 1782 | { |
1783 | 1783 | // List variables |
1784 | - $args = Context::gets('module_srl','category_srl'); |
|
1784 | + $args = Context::gets('module_srl', 'category_srl'); |
|
1785 | 1785 | |
1786 | 1786 | $oDB = &DB::getInstance(); |
1787 | 1787 | $oDB->begin(); |
@@ -1790,17 +1790,17 @@ discard block |
||
1790 | 1790 | $columnList = array('module_srl', 'module'); |
1791 | 1791 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl, $columnList); |
1792 | 1792 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
1793 | - if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted'); |
|
1793 | + if (!$grant->manager) return new BaseObject(-1, 'msg_not_permitted'); |
|
1794 | 1794 | |
1795 | 1795 | $oDocumentModel = getModel('document'); |
1796 | 1796 | // Get original information |
1797 | 1797 | $category_info = $oDocumentModel->getCategory($args->category_srl); |
1798 | - if($category_info->parent_srl) $parent_srl = $category_info->parent_srl; |
|
1798 | + if ($category_info->parent_srl) $parent_srl = $category_info->parent_srl; |
|
1799 | 1799 | // Display an error that the category cannot be deleted if it has a child node |
1800 | - if($oDocumentModel->getCategoryChlidCount($args->category_srl)) return new BaseObject(-1, 'msg_cannot_delete_for_child'); |
|
1800 | + if ($oDocumentModel->getCategoryChlidCount($args->category_srl)) return new BaseObject(-1, 'msg_cannot_delete_for_child'); |
|
1801 | 1801 | // Remove from the DB |
1802 | 1802 | $output = $this->deleteCategory($args->category_srl); |
1803 | - if(!$output->toBool()) |
|
1803 | + if (!$output->toBool()) |
|
1804 | 1804 | { |
1805 | 1805 | $oDB->rollback(); |
1806 | 1806 | return $output; |
@@ -1831,11 +1831,11 @@ discard block |
||
1831 | 1831 | $columnList = array('module_srl', 'module'); |
1832 | 1832 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList); |
1833 | 1833 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
1834 | - if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted'); |
|
1834 | + if (!$grant->manager) return new BaseObject(-1, 'msg_not_permitted'); |
|
1835 | 1835 | |
1836 | 1836 | $xml_file = $this->makeCategoryFile($module_srl); |
1837 | 1837 | // Set return value |
1838 | - $this->add('xml_file',$xml_file); |
|
1838 | + $this->add('xml_file', $xml_file); |
|
1839 | 1839 | } |
1840 | 1840 | |
1841 | 1841 | /** |
@@ -1846,9 +1846,9 @@ discard block |
||
1846 | 1846 | function makeCategoryFile($module_srl) |
1847 | 1847 | { |
1848 | 1848 | // Return if there is no information you need for creating a cache file |
1849 | - if(!$module_srl) return false; |
|
1849 | + if (!$module_srl) return false; |
|
1850 | 1850 | |
1851 | - $module_srl = (int)$module_srl; |
|
1851 | + $module_srl = (int) $module_srl; |
|
1852 | 1852 | |
1853 | 1853 | // Get module information (to obtain mid) |
1854 | 1854 | $oModuleModel = getModel('module'); |
@@ -1856,7 +1856,7 @@ discard block |
||
1856 | 1856 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList); |
1857 | 1857 | $mid = $module_info->mid; |
1858 | 1858 | |
1859 | - if(!is_dir('./files/cache/document_category')) FileHandler::makeDir('./files/cache/document_category'); |
|
1859 | + if (!is_dir('./files/cache/document_category')) FileHandler::makeDir('./files/cache/document_category'); |
|
1860 | 1860 | // Cache file's name |
1861 | 1861 | $xml_file = sprintf("./files/cache/document_category/%s.xml.php", $module_srl); |
1862 | 1862 | $php_file = sprintf("./files/cache/document_category/%s.php", $module_srl); |
@@ -1868,17 +1868,17 @@ discard block |
||
1868 | 1868 | |
1869 | 1869 | $category_list = $output->data; |
1870 | 1870 | |
1871 | - if(!is_array($category_list)) $category_list = array($category_list); |
|
1871 | + if (!is_array($category_list)) $category_list = array($category_list); |
|
1872 | 1872 | |
1873 | 1873 | $category_count = count($category_list); |
1874 | - for($i=0;$i<$category_count;$i++) |
|
1874 | + for ($i = 0; $i < $category_count; $i++) |
|
1875 | 1875 | { |
1876 | 1876 | $category_srl = $category_list[$i]->category_srl; |
1877 | - if(!preg_match('/^[0-9,]+$/', $category_list[$i]->group_srls)) $category_list[$i]->group_srls = ''; |
|
1877 | + if (!preg_match('/^[0-9,]+$/', $category_list[$i]->group_srls)) $category_list[$i]->group_srls = ''; |
|
1878 | 1878 | $list[$category_srl] = $category_list[$i]; |
1879 | 1879 | } |
1880 | 1880 | // Create the xml file without node data if no data is obtained |
1881 | - if(!$list) |
|
1881 | + if (!$list) |
|
1882 | 1882 | { |
1883 | 1883 | $xml_buff = "<root />"; |
1884 | 1884 | FileHandler::writeFile($xml_file, $xml_buff); |
@@ -1886,12 +1886,12 @@ discard block |
||
1886 | 1886 | return $xml_file; |
1887 | 1887 | } |
1888 | 1888 | // Change to an array if only a single data is obtained |
1889 | - if(!is_array($list)) $list = array($list); |
|
1889 | + if (!is_array($list)) $list = array($list); |
|
1890 | 1890 | // Create a tree for loop |
1891 | - foreach($list as $category_srl => $node) |
|
1891 | + foreach ($list as $category_srl => $node) |
|
1892 | 1892 | { |
1893 | 1893 | $node->mid = $mid; |
1894 | - $parent_srl = (int)$node->parent_srl; |
|
1894 | + $parent_srl = (int) $node->parent_srl; |
|
1895 | 1895 | $tree[$parent_srl][$category_srl] = $node; |
1896 | 1896 | } |
1897 | 1897 | // A common header to set permissions and groups of the cache file |
@@ -1965,13 +1965,13 @@ discard block |
||
1965 | 1965 | */ |
1966 | 1966 | function getXmlTree($source_node, $tree, $site_srl, &$xml_header_buff) |
1967 | 1967 | { |
1968 | - if(!$source_node) return; |
|
1968 | + if (!$source_node) return; |
|
1969 | 1969 | |
1970 | - foreach($source_node as $category_srl => $node) |
|
1970 | + foreach ($source_node as $category_srl => $node) |
|
1971 | 1971 | { |
1972 | 1972 | $child_buff = ""; |
1973 | 1973 | // Get data of the child nodes |
1974 | - if($category_srl && $tree[$category_srl]) $child_buff = $this->getXmlTree($tree[$category_srl], $tree, $site_srl, $xml_header_buff); |
|
1974 | + if ($category_srl && $tree[$category_srl]) $child_buff = $this->getXmlTree($tree[$category_srl], $tree, $site_srl, $xml_header_buff); |
|
1975 | 1975 | // List variables |
1976 | 1976 | $expand = ($node->expand) ? $node->expand : 'N'; |
1977 | 1977 | $group_srls = ($node->group_srls) ? $node->group_srls : ''; |
@@ -1981,27 +1981,27 @@ discard block |
||
1981 | 1981 | $color = ($node->color) ? $node->color : ''; |
1982 | 1982 | $description = ($node->description) ? $node->description : ''; |
1983 | 1983 | // If node->group_srls value exists |
1984 | - if($group_srls) $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))',$group_srls); |
|
1984 | + if ($group_srls) $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))', $group_srls); |
|
1985 | 1985 | else $group_check_code = "true"; |
1986 | 1986 | |
1987 | 1987 | $title = $node->title; |
1988 | 1988 | $oModuleAdminModel = getAdminModel('module'); |
1989 | 1989 | |
1990 | 1990 | $langs = $oModuleAdminModel->getLangCode($site_srl, $title); |
1991 | - if(count($langs)) |
|
1991 | + if (count($langs)) |
|
1992 | 1992 | { |
1993 | - foreach($langs as $key => $val) |
|
1993 | + foreach ($langs as $key => $val) |
|
1994 | 1994 | { |
1995 | - $xml_header_buff .= sprintf('$_titles[%d]["%s"] = %s; ', $category_srl, $key, var_export(str_replace('"','\\"',htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)), true)); |
|
1995 | + $xml_header_buff .= sprintf('$_titles[%d]["%s"] = %s; ', $category_srl, $key, var_export(str_replace('"', '\\"', htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)), true)); |
|
1996 | 1996 | } |
1997 | 1997 | } |
1998 | 1998 | |
1999 | 1999 | $langx = $oModuleAdminModel->getLangCode($site_srl, $description); |
2000 | - if(count($langx)) |
|
2000 | + if (count($langx)) |
|
2001 | 2001 | { |
2002 | - foreach($langx as $key => $val) |
|
2002 | + foreach ($langx as $key => $val) |
|
2003 | 2003 | { |
2004 | - $xml_header_buff .= sprintf('$_descriptions[%d]["%s"] = %s; ', $category_srl, $key, var_export(str_replace('"','\\"',htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)), true)); |
|
2004 | + $xml_header_buff .= sprintf('$_descriptions[%d]["%s"] = %s; ', $category_srl, $key, var_export(str_replace('"', '\\"', htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)), true)); |
|
2005 | 2005 | } |
2006 | 2006 | } |
2007 | 2007 | |
@@ -2014,7 +2014,7 @@ discard block |
||
2014 | 2014 | $category_srl, |
2015 | 2015 | $group_check_code, |
2016 | 2016 | $category_srl, |
2017 | - var_export(getUrl('','mid',$node->mid,'category',$category_srl), true), |
|
2017 | + var_export(getUrl('', 'mid', $node->mid, 'category', $category_srl), true), |
|
2018 | 2018 | var_export($expand, true), |
2019 | 2019 | var_export($color, true), |
2020 | 2020 | $group_check_code, |
@@ -2022,8 +2022,8 @@ discard block |
||
2022 | 2022 | $node->document_count |
2023 | 2023 | ); |
2024 | 2024 | |
2025 | - if($child_buff) $buff .= sprintf('<node %s>%s</node>', $attribute, $child_buff); |
|
2026 | - else $buff .= sprintf('<node %s />', $attribute); |
|
2025 | + if ($child_buff) $buff .= sprintf('<node %s>%s</node>', $attribute, $child_buff); |
|
2026 | + else $buff .= sprintf('<node %s />', $attribute); |
|
2027 | 2027 | } |
2028 | 2028 | return $buff; |
2029 | 2029 | } |
@@ -2042,13 +2042,13 @@ discard block |
||
2042 | 2042 | function getPhpCacheCode($source_node, $tree, $site_srl, &$php_header_buff) |
2043 | 2043 | { |
2044 | 2044 | $output = array("buff"=>"", "category_srl_list"=>array()); |
2045 | - if(!$source_node) return $output; |
|
2045 | + if (!$source_node) return $output; |
|
2046 | 2046 | |
2047 | 2047 | // Set to an arraty for looping and then generate php script codes to be included |
2048 | - foreach($source_node as $category_srl => $node) |
|
2048 | + foreach ($source_node as $category_srl => $node) |
|
2049 | 2049 | { |
2050 | 2050 | // Get data from child nodes first if exist. |
2051 | - if($category_srl && $tree[$category_srl]){ |
|
2051 | + if ($category_srl && $tree[$category_srl]) { |
|
2052 | 2052 | $child_output = $this->getPhpCacheCode($tree[$category_srl], $tree, $site_srl, $php_header_buff); |
2053 | 2053 | } else { |
2054 | 2054 | $child_output = array("buff"=>"", "category_srl_list"=>array()); |
@@ -2059,14 +2059,14 @@ discard block |
||
2059 | 2059 | $output['category_srl_list'] = array_merge($output['category_srl_list'], $child_output['category_srl_list']); |
2060 | 2060 | |
2061 | 2061 | // If node->group_srls value exists |
2062 | - if($node->group_srls) { |
|
2063 | - $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))',$node->group_srls); |
|
2062 | + if ($node->group_srls) { |
|
2063 | + $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))', $node->group_srls); |
|
2064 | 2064 | } else { |
2065 | 2065 | $group_check_code = "true"; |
2066 | 2066 | } |
2067 | 2067 | |
2068 | 2068 | // List variables |
2069 | - $selected = '"' . implode('","', $child_output['category_srl_list']) . '"'; |
|
2069 | + $selected = '"'.implode('","', $child_output['category_srl_list']).'"'; |
|
2070 | 2070 | $child_buff = $child_output['buff']; |
2071 | 2071 | $expand = $node->expand; |
2072 | 2072 | |
@@ -2075,32 +2075,32 @@ discard block |
||
2075 | 2075 | $oModuleAdminModel = getAdminModel('module'); |
2076 | 2076 | $langs = $oModuleAdminModel->getLangCode($site_srl, $title); |
2077 | 2077 | |
2078 | - if(count($langs)) |
|
2078 | + if (count($langs)) |
|
2079 | 2079 | { |
2080 | - foreach($langs as $key => $val) |
|
2080 | + foreach ($langs as $key => $val) |
|
2081 | 2081 | { |
2082 | 2082 | $val = htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
2083 | 2083 | $php_header_buff .= sprintf( |
2084 | 2084 | '$_titles[%d]["%s"] = %s; ', |
2085 | 2085 | $category_srl, |
2086 | 2086 | $key, |
2087 | - var_export(str_replace('"','\\"', $val), true) |
|
2087 | + var_export(str_replace('"', '\\"', $val), true) |
|
2088 | 2088 | ); |
2089 | 2089 | } |
2090 | 2090 | } |
2091 | 2091 | |
2092 | 2092 | $langx = $oModuleAdminModel->getLangCode($site_srl, $description); |
2093 | 2093 | |
2094 | - if(count($langx)) |
|
2094 | + if (count($langx)) |
|
2095 | 2095 | { |
2096 | - foreach($langx as $key => $val) |
|
2096 | + foreach ($langx as $key => $val) |
|
2097 | 2097 | { |
2098 | 2098 | $val = htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
2099 | 2099 | $php_header_buff .= sprintf( |
2100 | 2100 | '$_descriptions[%d]["%s"] = %s; ', |
2101 | 2101 | $category_srl, |
2102 | 2102 | $key, |
2103 | - var_export(str_replace('"','\\"', $val), true) |
|
2103 | + var_export(str_replace('"', '\\"', $val), true) |
|
2104 | 2104 | ); |
2105 | 2105 | } |
2106 | 2106 | } |
@@ -2124,7 +2124,7 @@ discard block |
||
2124 | 2124 | ); |
2125 | 2125 | |
2126 | 2126 | // Generate buff data |
2127 | - $output['buff'] .= sprintf('%s=>array(%s),', $node->category_srl, $attribute); |
|
2127 | + $output['buff'] .= sprintf('%s=>array(%s),', $node->category_srl, $attribute); |
|
2128 | 2128 | } |
2129 | 2129 | |
2130 | 2130 | return $output; |
@@ -2141,7 +2141,7 @@ discard block |
||
2141 | 2141 | function addDocumentPopupMenu($url, $str, $icon = '', $target = 'self') |
2142 | 2142 | { |
2143 | 2143 | $document_popup_menu_list = Context::get('document_popup_menu_list'); |
2144 | - if(!is_array($document_popup_menu_list)) $document_popup_menu_list = array(); |
|
2144 | + if (!is_array($document_popup_menu_list)) $document_popup_menu_list = array(); |
|
2145 | 2145 | |
2146 | 2146 | $obj = new stdClass(); |
2147 | 2147 | $obj->url = $url; |
@@ -2159,68 +2159,68 @@ discard block |
||
2159 | 2159 | */ |
2160 | 2160 | function procDocumentAddCart() |
2161 | 2161 | { |
2162 | - if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_permitted'); |
|
2162 | + if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_permitted'); |
|
2163 | 2163 | |
2164 | 2164 | // Get document_srl |
2165 | - $srls = explode(',',Context::get('srls')); |
|
2166 | - for($i = 0; $i < count($srls); $i++) |
|
2165 | + $srls = explode(',', Context::get('srls')); |
|
2166 | + for ($i = 0; $i < count($srls); $i++) |
|
2167 | 2167 | { |
2168 | 2168 | $srl = trim($srls[$i]); |
2169 | 2169 | |
2170 | - if(!$srl) continue; |
|
2170 | + if (!$srl) continue; |
|
2171 | 2171 | |
2172 | 2172 | $document_srls[] = $srl; |
2173 | 2173 | } |
2174 | - if(!count($document_srls)) return; |
|
2174 | + if (!count($document_srls)) return; |
|
2175 | 2175 | |
2176 | 2176 | // Get module_srl of the documents |
2177 | 2177 | $args = new stdClass; |
2178 | 2178 | $args->list_count = count($document_srls); |
2179 | - $args->document_srls = implode(',',$document_srls); |
|
2179 | + $args->document_srls = implode(',', $document_srls); |
|
2180 | 2180 | $args->order_type = 'asc'; |
2181 | 2181 | $output = executeQueryArray('document.getDocuments', $args); |
2182 | - if(!$output->data) return new BaseObject(); |
|
2182 | + if (!$output->data) return new BaseObject(); |
|
2183 | 2183 | |
2184 | 2184 | unset($document_srls); |
2185 | - foreach($output->data as $key => $val) |
|
2185 | + foreach ($output->data as $key => $val) |
|
2186 | 2186 | { |
2187 | 2187 | $document_srls[$val->module_srl][] = $val->document_srl; |
2188 | 2188 | } |
2189 | - if(!$document_srls || !count($document_srls)) return new BaseObject(); |
|
2189 | + if (!$document_srls || !count($document_srls)) return new BaseObject(); |
|
2190 | 2190 | |
2191 | 2191 | // Check if each of module administrators exists. Top-level administator will have a permission to modify every document of all modules.(Even to modify temporarily saved or trashed documents) |
2192 | 2192 | $oModuleModel = getModel('module'); |
2193 | 2193 | $module_srls = array_keys($document_srls); |
2194 | - for($i=0;$i<count($module_srls);$i++) |
|
2194 | + for ($i = 0; $i < count($module_srls); $i++) |
|
2195 | 2195 | { |
2196 | 2196 | $module_srl = $module_srls[$i]; |
2197 | 2197 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl); |
2198 | 2198 | $logged_info = Context::get('logged_info'); |
2199 | - if($logged_info->is_admin != 'Y') |
|
2199 | + if ($logged_info->is_admin != 'Y') |
|
2200 | 2200 | { |
2201 | - if(!$module_info) |
|
2201 | + if (!$module_info) |
|
2202 | 2202 | { |
2203 | 2203 | unset($document_srls[$module_srl]); |
2204 | 2204 | continue; |
2205 | 2205 | } |
2206 | 2206 | $grant = $oModuleModel->getGrant($module_info, $logged_info); |
2207 | - if(!$grant->manager) |
|
2207 | + if (!$grant->manager) |
|
2208 | 2208 | { |
2209 | 2209 | unset($document_srls[$module_srl]); |
2210 | 2210 | continue; |
2211 | 2211 | } |
2212 | 2212 | } |
2213 | 2213 | } |
2214 | - if(!count($document_srls)) return new BaseObject(); |
|
2214 | + if (!count($document_srls)) return new BaseObject(); |
|
2215 | 2215 | |
2216 | - foreach($document_srls as $module_srl => $documents) |
|
2216 | + foreach ($document_srls as $module_srl => $documents) |
|
2217 | 2217 | { |
2218 | 2218 | $cnt = count($documents); |
2219 | - for($i=0;$i<$cnt;$i++) |
|
2219 | + for ($i = 0; $i < $cnt; $i++) |
|
2220 | 2220 | { |
2221 | - $document_srl = (int)trim($documents[$i]); |
|
2222 | - if(!$document_srls) continue; |
|
2223 | - if($_SESSION['document_management'][$document_srl]) unset($_SESSION['document_management'][$document_srl]); |
|
2221 | + $document_srl = (int) trim($documents[$i]); |
|
2222 | + if (!$document_srls) continue; |
|
2223 | + if ($_SESSION['document_management'][$document_srl]) unset($_SESSION['document_management'][$document_srl]); |
|
2224 | 2224 | else $_SESSION['document_management'][$document_srl] = true; |
2225 | 2225 | } |
2226 | 2226 | } |
@@ -2233,9 +2233,9 @@ discard block |
||
2233 | 2233 | function procDocumentManageCheckedDocument() |
2234 | 2234 | { |
2235 | 2235 | @set_time_limit(0); |
2236 | - if(!Context::get('is_logged')) return new BaseObject(-1,'msg_not_permitted'); |
|
2236 | + if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_permitted'); |
|
2237 | 2237 | |
2238 | - if(!checkCSRF()) |
|
2238 | + if (!checkCSRF()) |
|
2239 | 2239 | { |
2240 | 2240 | return new BaseObject(-1, 'msg_invalid_request'); |
2241 | 2241 | } |
@@ -2243,45 +2243,45 @@ discard block |
||
2243 | 2243 | $type = Context::get('type'); |
2244 | 2244 | $target_module = Context::get('target_module_srl'); |
2245 | 2245 | $module_srl = Context::get('module_srl'); |
2246 | - if($target_module && !$module_srl) $module_srl = $target_module; |
|
2246 | + if ($target_module && !$module_srl) $module_srl = $target_module; |
|
2247 | 2247 | $category_srl = Context::get('target_category_srl'); |
2248 | 2248 | $message_content = strip_tags(Context::get('message_content')); |
2249 | - if($message_content) $message_content = nl2br($message_content); |
|
2249 | + if ($message_content) $message_content = nl2br($message_content); |
|
2250 | 2250 | |
2251 | 2251 | $cart = Context::get('cart'); |
2252 | 2252 | $document_srl_list = (!is_array($cart)) ? explode('|@|', $cart) : $cart; |
2253 | 2253 | |
2254 | - array_map(function ($value) { return (int)$value; }, $document_srl_list); |
|
2254 | + array_map(function($value) { return (int) $value; }, $document_srl_list); |
|
2255 | 2255 | |
2256 | 2256 | $document_srl_count = count($document_srl_list); |
2257 | 2257 | |
2258 | 2258 | $oDocumentModel = getModel('document'); |
2259 | 2259 | $document_items = array(); |
2260 | - foreach($document_srl_list as $document_srl) |
|
2260 | + foreach ($document_srl_list as $document_srl) |
|
2261 | 2261 | { |
2262 | 2262 | $oDocument = $oDocumentModel->getDocument($document_srl); |
2263 | 2263 | $document_items[] = $oDocument; |
2264 | - if(!$oDocument->isGranted()) return $this->stop('msg_not_permitted'); |
|
2264 | + if (!$oDocument->isGranted()) return $this->stop('msg_not_permitted'); |
|
2265 | 2265 | } |
2266 | 2266 | |
2267 | 2267 | // Send a message |
2268 | - if($message_content) |
|
2268 | + if ($message_content) |
|
2269 | 2269 | { |
2270 | 2270 | |
2271 | 2271 | $oCommunicationController = getController('communication'); |
2272 | 2272 | |
2273 | 2273 | $logged_info = Context::get('logged_info'); |
2274 | 2274 | |
2275 | - $title = cut_str($message_content,10,'...'); |
|
2275 | + $title = cut_str($message_content, 10, '...'); |
|
2276 | 2276 | $sender_member_srl = $logged_info->member_srl; |
2277 | 2277 | |
2278 | - foreach($document_items as $oDocument) |
|
2278 | + foreach ($document_items as $oDocument) |
|
2279 | 2279 | { |
2280 | - if(!$oDocument->get('member_srl') || $oDocument->get('member_srl')==$sender_member_srl) continue; |
|
2280 | + if (!$oDocument->get('member_srl') || $oDocument->get('member_srl') == $sender_member_srl) continue; |
|
2281 | 2281 | |
2282 | - if($type=='move') $purl = sprintf("<a href=\"%s\" target=\"_blank\">%s</a>", $oDocument->getPermanentUrl(), $oDocument->getPermanentUrl()); |
|
2282 | + if ($type == 'move') $purl = sprintf("<a href=\"%s\" target=\"_blank\">%s</a>", $oDocument->getPermanentUrl(), $oDocument->getPermanentUrl()); |
|
2283 | 2283 | else $purl = ""; |
2284 | - $content = sprintf("<div>%s</div><hr />%s<div style=\"font-weight:bold\">%s</div>%s",$message_content, $purl, $oDocument->getTitleText(), $oDocument->getContent(false, false, false)); |
|
2284 | + $content = sprintf("<div>%s</div><hr />%s<div style=\"font-weight:bold\">%s</div>%s", $message_content, $purl, $oDocument->getTitleText(), $oDocument->getContent(false, false, false)); |
|
2285 | 2285 | |
2286 | 2286 | $oCommunicationController->sendMessage($sender_member_srl, $oDocument->get('member_srl'), $title, $content, false); |
2287 | 2287 | } |
@@ -2291,54 +2291,54 @@ discard block |
||
2291 | 2291 | $oSpamController->setAvoidLog(); |
2292 | 2292 | |
2293 | 2293 | $oDocumentAdminController = getAdminController('document'); |
2294 | - if($type == 'move') |
|
2294 | + if ($type == 'move') |
|
2295 | 2295 | { |
2296 | - if(!$module_srl) return new BaseObject(-1, 'fail_to_move'); |
|
2296 | + if (!$module_srl) return new BaseObject(-1, 'fail_to_move'); |
|
2297 | 2297 | |
2298 | 2298 | $output = $oDocumentAdminController->moveDocumentModule($document_srl_list, $module_srl, $category_srl); |
2299 | - if(!$output->toBool()) return new BaseObject(-1, 'fail_to_move'); |
|
2299 | + if (!$output->toBool()) return new BaseObject(-1, 'fail_to_move'); |
|
2300 | 2300 | |
2301 | 2301 | $msg_code = 'success_moved'; |
2302 | 2302 | |
2303 | 2303 | } |
2304 | - else if($type == 'copy') |
|
2304 | + else if ($type == 'copy') |
|
2305 | 2305 | { |
2306 | - if(!$module_srl) return new BaseObject(-1, 'fail_to_move'); |
|
2306 | + if (!$module_srl) return new BaseObject(-1, 'fail_to_move'); |
|
2307 | 2307 | |
2308 | 2308 | $output = $oDocumentAdminController->copyDocumentModule($document_srl_list, $module_srl, $category_srl); |
2309 | - if(!$output->toBool()) return new BaseObject(-1, 'fail_to_move'); |
|
2309 | + if (!$output->toBool()) return new BaseObject(-1, 'fail_to_move'); |
|
2310 | 2310 | |
2311 | 2311 | $msg_code = 'success_copied'; |
2312 | 2312 | } |
2313 | - else if($type =='delete') |
|
2313 | + else if ($type == 'delete') |
|
2314 | 2314 | { |
2315 | 2315 | $oDB = &DB::getInstance(); |
2316 | 2316 | $oDB->begin(); |
2317 | - for($i=0;$i<$document_srl_count;$i++) |
|
2317 | + for ($i = 0; $i < $document_srl_count; $i++) |
|
2318 | 2318 | { |
2319 | 2319 | $document_srl = $document_srl_list[$i]; |
2320 | 2320 | $output = $this->deleteDocument($document_srl, true); |
2321 | - if(!$output->toBool()) return new BaseObject(-1, 'fail_to_delete'); |
|
2321 | + if (!$output->toBool()) return new BaseObject(-1, 'fail_to_delete'); |
|
2322 | 2322 | } |
2323 | 2323 | $oDB->commit(); |
2324 | 2324 | $msg_code = 'success_deleted'; |
2325 | 2325 | } |
2326 | - else if($type == 'trash') |
|
2326 | + else if ($type == 'trash') |
|
2327 | 2327 | { |
2328 | 2328 | $args = new stdClass(); |
2329 | 2329 | $args->description = $message_content; |
2330 | 2330 | |
2331 | 2331 | $oDB = &DB::getInstance(); |
2332 | 2332 | $oDB->begin(); |
2333 | - for($i=0;$i<$document_srl_count;$i++) { |
|
2333 | + for ($i = 0; $i < $document_srl_count; $i++) { |
|
2334 | 2334 | $args->document_srl = $document_srl_list[$i]; |
2335 | 2335 | $output = $this->moveDocumentToTrash($args); |
2336 | - if(!$output || !$output->toBool()) return new BaseObject(-1, 'fail_to_trash'); |
|
2336 | + if (!$output || !$output->toBool()) return new BaseObject(-1, 'fail_to_trash'); |
|
2337 | 2337 | } |
2338 | 2338 | $oDB->commit(); |
2339 | 2339 | $msg_code = 'success_trashed'; |
2340 | 2340 | } |
2341 | - else if($type == 'cancelDeclare') |
|
2341 | + else if ($type == 'cancelDeclare') |
|
2342 | 2342 | { |
2343 | 2343 | $args->document_srl = $document_srl_list; |
2344 | 2344 | $output = executeQuery('document.deleteDeclaredDocuments', $args); |
@@ -2360,27 +2360,27 @@ discard block |
||
2360 | 2360 | function procDocumentInsertModuleConfig() |
2361 | 2361 | { |
2362 | 2362 | $module_srl = Context::get('target_module_srl'); |
2363 | - if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl); |
|
2363 | + if (preg_match('/^([0-9,]+)$/', $module_srl)) $module_srl = explode(',', $module_srl); |
|
2364 | 2364 | else $module_srl = array($module_srl); |
2365 | 2365 | |
2366 | 2366 | $document_config = new stdClass(); |
2367 | 2367 | $document_config->use_history = Context::get('use_history'); |
2368 | - if(!$document_config->use_history) $document_config->use_history = 'N'; |
|
2368 | + if (!$document_config->use_history) $document_config->use_history = 'N'; |
|
2369 | 2369 | |
2370 | 2370 | $document_config->use_vote_up = Context::get('use_vote_up'); |
2371 | - if(!$document_config->use_vote_up) $document_config->use_vote_up = 'Y'; |
|
2371 | + if (!$document_config->use_vote_up) $document_config->use_vote_up = 'Y'; |
|
2372 | 2372 | |
2373 | 2373 | $document_config->use_vote_down = Context::get('use_vote_down'); |
2374 | - if(!$document_config->use_vote_down) $document_config->use_vote_down = 'Y'; |
|
2374 | + if (!$document_config->use_vote_down) $document_config->use_vote_down = 'Y'; |
|
2375 | 2375 | |
2376 | 2376 | $document_config->use_status = Context::get('use_status'); |
2377 | 2377 | |
2378 | 2378 | $oModuleController = getController('module'); |
2379 | - for($i=0;$i<count($module_srl);$i++) |
|
2379 | + for ($i = 0; $i < count($module_srl); $i++) |
|
2380 | 2380 | { |
2381 | 2381 | $srl = trim($module_srl[$i]); |
2382 | - if(!$srl) continue; |
|
2383 | - $output = $oModuleController->insertModulePartConfig('document',$srl,$document_config); |
|
2382 | + if (!$srl) continue; |
|
2383 | + $output = $oModuleController->insertModulePartConfig('document', $srl, $document_config); |
|
2384 | 2384 | } |
2385 | 2385 | $this->setError(-1); |
2386 | 2386 | $this->setMessage('success_updated', 'info'); |
@@ -2396,7 +2396,7 @@ discard block |
||
2396 | 2396 | function procDocumentTempSave() |
2397 | 2397 | { |
2398 | 2398 | // Check login information |
2399 | - if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_logged'); |
|
2399 | + if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_logged'); |
|
2400 | 2400 | $module_info = Context::get('module_info'); |
2401 | 2401 | $logged_info = Context::get('logged_info'); |
2402 | 2402 | |
@@ -2408,7 +2408,7 @@ discard block |
||
2408 | 2408 | unset($obj->is_notice); |
2409 | 2409 | |
2410 | 2410 | // Extract from beginning part of contents in the guestbook |
2411 | - if(!$obj->title) |
|
2411 | + if (!$obj->title) |
|
2412 | 2412 | { |
2413 | 2413 | $obj->title = cut_str(strip_tags($obj->content), 20, '...'); |
2414 | 2414 | } |
@@ -2419,13 +2419,13 @@ discard block |
||
2419 | 2419 | $oDocument = $oDocumentModel->getDocument($obj->document_srl, $this->grant->manager); |
2420 | 2420 | |
2421 | 2421 | // Update if already exists |
2422 | - if($oDocument->isExists() && $oDocument->document_srl == $obj->document_srl) |
|
2422 | + if ($oDocument->isExists() && $oDocument->document_srl == $obj->document_srl) |
|
2423 | 2423 | { |
2424 | - if($oDocument->get('module_srl') != $obj->module_srl) |
|
2424 | + if ($oDocument->get('module_srl') != $obj->module_srl) |
|
2425 | 2425 | { |
2426 | 2426 | return new BaseObject(-1, 'msg_invalid_request'); |
2427 | 2427 | } |
2428 | - if(!$oDocument->isGranted()) |
|
2428 | + if (!$oDocument->isGranted()) |
|
2429 | 2429 | { |
2430 | 2430 | return new BaseObject(-1, 'msg_invalid_request'); |
2431 | 2431 | } |
@@ -2443,7 +2443,7 @@ discard block |
||
2443 | 2443 | $oDocument = $oDocumentModel->getDocument($obj->document_srl, $this->grant->manager); |
2444 | 2444 | } |
2445 | 2445 | // Set the attachment to be invalid state |
2446 | - if($oDocument->hasUploadedFiles()) |
|
2446 | + if ($oDocument->hasUploadedFiles()) |
|
2447 | 2447 | { |
2448 | 2448 | $args = new stdClass; |
2449 | 2449 | $args->upload_target_srl = $oDocument->document_srl; |
@@ -2461,11 +2461,11 @@ discard block |
||
2461 | 2461 | */ |
2462 | 2462 | function procDocumentGetList() |
2463 | 2463 | { |
2464 | - if(!Context::get('is_logged')) return new BaseObject(-1,'msg_not_permitted'); |
|
2464 | + if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_permitted'); |
|
2465 | 2465 | $documentSrls = Context::get('document_srls'); |
2466 | - if($documentSrls) $documentSrlList = explode(',', $documentSrls); |
|
2466 | + if ($documentSrls) $documentSrlList = explode(',', $documentSrls); |
|
2467 | 2467 | |
2468 | - if(count($documentSrlList) > 0) |
|
2468 | + if (count($documentSrlList) > 0) |
|
2469 | 2469 | { |
2470 | 2470 | $oDocumentModel = getModel('document'); |
2471 | 2471 | $columnList = array('document_srl', 'title', 'nick_name', 'status'); |
@@ -2489,10 +2489,10 @@ discard block |
||
2489 | 2489 | */ |
2490 | 2490 | function _checkCommentStatusForOldVersion(&$obj) |
2491 | 2491 | { |
2492 | - if(!isset($obj->allow_comment)) $obj->allow_comment = 'N'; |
|
2493 | - if(!isset($obj->lock_comment)) $obj->lock_comment = 'N'; |
|
2492 | + if (!isset($obj->allow_comment)) $obj->allow_comment = 'N'; |
|
2493 | + if (!isset($obj->lock_comment)) $obj->lock_comment = 'N'; |
|
2494 | 2494 | |
2495 | - if($obj->allow_comment == 'Y' && $obj->lock_comment == 'N') $obj->commentStatus = 'ALLOW'; |
|
2495 | + if ($obj->allow_comment == 'Y' && $obj->lock_comment == 'N') $obj->commentStatus = 'ALLOW'; |
|
2496 | 2496 | else $obj->commentStatus = 'DENY'; |
2497 | 2497 | } |
2498 | 2498 | |
@@ -2503,8 +2503,8 @@ discard block |
||
2503 | 2503 | */ |
2504 | 2504 | function _checkDocumentStatusForOldVersion(&$obj) |
2505 | 2505 | { |
2506 | - if(!$obj->status && $obj->is_secret == 'Y') $obj->status = $this->getConfigStatus('secret'); |
|
2507 | - if(!$obj->status && $obj->is_secret != 'Y') $obj->status = $this->getConfigStatus('public'); |
|
2506 | + if (!$obj->status && $obj->is_secret == 'Y') $obj->status = $this->getConfigStatus('secret'); |
|
2507 | + if (!$obj->status && $obj->is_secret != 'Y') $obj->status = $this->getConfigStatus('public'); |
|
2508 | 2508 | } |
2509 | 2509 | |
2510 | 2510 | public function updateUploaedCount($documentSrlList) |
@@ -2512,10 +2512,10 @@ discard block |
||
2512 | 2512 | $oDocumentModel = getModel('document'); |
2513 | 2513 | $oFileModel = getModel('file'); |
2514 | 2514 | |
2515 | - if(is_array($documentSrlList)) |
|
2515 | + if (is_array($documentSrlList)) |
|
2516 | 2516 | { |
2517 | 2517 | $documentSrlList = array_unique($documentSrlList); |
2518 | - foreach($documentSrlList AS $key => $documentSrl) |
|
2518 | + foreach ($documentSrlList AS $key => $documentSrl) |
|
2519 | 2519 | { |
2520 | 2520 | $fileCount = $oFileModel->getFilesCount($documentSrl); |
2521 | 2521 | $args = new stdClass(); |
@@ -2536,14 +2536,14 @@ discard block |
||
2536 | 2536 | $oDocumentModel = getModel('document'); |
2537 | 2537 | $documentExtraKeys = $oDocumentModel->getExtraKeys($obj->originModuleSrl); |
2538 | 2538 | |
2539 | - if(is_array($documentExtraKeys) && is_array($obj->moduleSrlList)) |
|
2539 | + if (is_array($documentExtraKeys) && is_array($obj->moduleSrlList)) |
|
2540 | 2540 | { |
2541 | - $oDocumentController=getController('document'); |
|
2542 | - foreach($obj->moduleSrlList AS $key=>$value) |
|
2541 | + $oDocumentController = getController('document'); |
|
2542 | + foreach ($obj->moduleSrlList AS $key=>$value) |
|
2543 | 2543 | { |
2544 | - foreach($documentExtraKeys AS $extraItem) |
|
2544 | + foreach ($documentExtraKeys AS $extraItem) |
|
2545 | 2545 | { |
2546 | - $oDocumentController->insertDocumentExtraKey($value, $extraItem->idx, $extraItem->name, $extraItem->type, $extraItem->is_required , $extraItem->search , $extraItem->default , $extraItem->desc, $extraItem->eid) ; |
|
2546 | + $oDocumentController->insertDocumentExtraKey($value, $extraItem->idx, $extraItem->name, $extraItem->type, $extraItem->is_required, $extraItem->search, $extraItem->default, $extraItem->desc, $extraItem->eid); |
|
2547 | 2547 | } |
2548 | 2548 | } |
2549 | 2549 | } |
@@ -2555,9 +2555,9 @@ discard block |
||
2555 | 2555 | $documentConfig = $oModuleModel->getModulePartConfig('document', $obj->originModuleSrl); |
2556 | 2556 | |
2557 | 2557 | $oModuleController = getController('module'); |
2558 | - if(is_array($obj->moduleSrlList)) |
|
2558 | + if (is_array($obj->moduleSrlList)) |
|
2559 | 2559 | { |
2560 | - foreach($obj->moduleSrlList AS $key=>$moduleSrl) |
|
2560 | + foreach ($obj->moduleSrlList AS $key=>$moduleSrl) |
|
2561 | 2561 | { |
2562 | 2562 | $oModuleController->insertModulePartConfig('document', $moduleSrl, $documentConfig); |
2563 | 2563 | } |
@@ -24,19 +24,27 @@ discard block |
||
24 | 24 | */ |
25 | 25 | function procDocumentVoteUp() |
26 | 26 | { |
27 | - if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request'); |
|
27 | + if(!Context::get('is_logged')) { |
|
28 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
29 | + } |
|
28 | 30 | |
29 | 31 | $document_srl = Context::get('target_srl'); |
30 | - if(!$document_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
32 | + if(!$document_srl) { |
|
33 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
34 | + } |
|
31 | 35 | |
32 | 36 | $oDocumentModel = getModel('document'); |
33 | 37 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false); |
34 | 38 | $module_srl = $oDocument->get('module_srl'); |
35 | - if(!$module_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
39 | + if(!$module_srl) { |
|
40 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
41 | + } |
|
36 | 42 | |
37 | 43 | $oModuleModel = getModel('module'); |
38 | 44 | $document_config = $oModuleModel->getModulePartConfig('document',$module_srl); |
39 | - if($document_config->use_vote_up=='N') return new BaseObject(-1, 'msg_invalid_request'); |
|
45 | + if($document_config->use_vote_up=='N') { |
|
46 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
47 | + } |
|
40 | 48 | |
41 | 49 | $point = 1; |
42 | 50 | $output = $this->updateVotedCount($document_srl, $point); |
@@ -69,19 +77,27 @@ discard block |
||
69 | 77 | */ |
70 | 78 | function procDocumentVoteDown() |
71 | 79 | { |
72 | - if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request'); |
|
80 | + if(!Context::get('is_logged')) { |
|
81 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
82 | + } |
|
73 | 83 | |
74 | 84 | $document_srl = Context::get('target_srl'); |
75 | - if(!$document_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
85 | + if(!$document_srl) { |
|
86 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
87 | + } |
|
76 | 88 | |
77 | 89 | $oDocumentModel = getModel('document'); |
78 | 90 | $oDocument = $oDocumentModel->getDocument($document_srl, false, false); |
79 | 91 | $module_srl = $oDocument->get('module_srl'); |
80 | - if(!$module_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
92 | + if(!$module_srl) { |
|
93 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
94 | + } |
|
81 | 95 | |
82 | 96 | $oModuleModel = getModel('module'); |
83 | 97 | $document_config = $oModuleModel->getModulePartConfig('document',$module_srl); |
84 | - if($document_config->use_vote_down=='N') return new BaseObject(-1, 'msg_invalid_request'); |
|
98 | + if($document_config->use_vote_down=='N') { |
|
99 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
100 | + } |
|
85 | 101 | |
86 | 102 | $point = -1; |
87 | 103 | $output = $this->updateVotedCount($document_srl, $point); |
@@ -95,10 +111,14 @@ discard block |
||
95 | 111 | */ |
96 | 112 | function procDocumentDeclare() |
97 | 113 | { |
98 | - if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request'); |
|
114 | + if(!Context::get('is_logged')) { |
|
115 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
116 | + } |
|
99 | 117 | |
100 | 118 | $document_srl = Context::get('target_srl'); |
101 | - if(!$document_srl) return new BaseObject(-1, 'msg_invalid_request'); |
|
119 | + if(!$document_srl) { |
|
120 | + return new BaseObject(-1, 'msg_invalid_request'); |
|
121 | + } |
|
102 | 122 | |
103 | 123 | return $this->declaredDocument($document_srl); |
104 | 124 | } |
@@ -140,7 +160,9 @@ discard block |
||
140 | 160 | $args->history_srl = $history_srl; |
141 | 161 | $args->module_srl = $module_srl; |
142 | 162 | $args->document_srl = $document_srl; |
143 | - if(!$args->history_srl && !$args->module_srl && !$args->document_srl) return; |
|
163 | + if(!$args->history_srl && !$args->module_srl && !$args->document_srl) { |
|
164 | + return; |
|
165 | + } |
|
144 | 166 | executeQuery("document.deleteHistory", $args); |
145 | 167 | } |
146 | 168 | |
@@ -152,15 +174,21 @@ discard block |
||
152 | 174 | function triggerDeleteModuleDocuments(&$obj) |
153 | 175 | { |
154 | 176 | $module_srl = $obj->module_srl; |
155 | - if(!$module_srl) return new BaseObject(); |
|
177 | + if(!$module_srl) { |
|
178 | + return new BaseObject(); |
|
179 | + } |
|
156 | 180 | // Delete the document |
157 | 181 | $oDocumentAdminController = getAdminController('document'); |
158 | 182 | $output = $oDocumentAdminController->deleteModuleDocument($module_srl); |
159 | - if(!$output->toBool()) return $output; |
|
183 | + if(!$output->toBool()) { |
|
184 | + return $output; |
|
185 | + } |
|
160 | 186 | // Delete the category |
161 | 187 | $oDocumentController = getController('document'); |
162 | 188 | $output = $oDocumentController->deleteModuleCategory($module_srl); |
163 | - if(!$output->toBool()) return $output; |
|
189 | + if(!$output->toBool()) { |
|
190 | + return $output; |
|
191 | + } |
|
164 | 192 | // Delete extra key and variable, because module deleted |
165 | 193 | $this->deleteDocumentExtraKeys($module_srl); |
166 | 194 | |
@@ -202,10 +230,18 @@ discard block |
||
202 | 230 | $oDB = &DB::getInstance(); |
203 | 231 | $oDB->begin(); |
204 | 232 | // List variables |
205 | - if($obj->comment_status) $obj->commentStatus = $obj->comment_status; |
|
206 | - if(!$obj->commentStatus) $obj->commentStatus = 'DENY'; |
|
207 | - if($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj); |
|
208 | - if($obj->allow_trackback!='Y') $obj->allow_trackback = 'N'; |
|
233 | + if($obj->comment_status) { |
|
234 | + $obj->commentStatus = $obj->comment_status; |
|
235 | + } |
|
236 | + if(!$obj->commentStatus) { |
|
237 | + $obj->commentStatus = 'DENY'; |
|
238 | + } |
|
239 | + if($obj->commentStatus == 'DENY') { |
|
240 | + $this->_checkCommentStatusForOldVersion($obj); |
|
241 | + } |
|
242 | + if($obj->allow_trackback!='Y') { |
|
243 | + $obj->allow_trackback = 'N'; |
|
244 | + } |
|
209 | 245 | if($obj->homepage) |
210 | 246 | { |
211 | 247 | $obj->homepage = escape($obj->homepage); |
@@ -215,9 +251,15 @@ discard block |
||
215 | 251 | } |
216 | 252 | } |
217 | 253 | |
218 | - if($obj->notify_message != 'Y') $obj->notify_message = 'N'; |
|
219 | - if(!$obj->email_address) $obj->email_address = ''; |
|
220 | - if(!$isRestore) $obj->ipaddress = $_SERVER['REMOTE_ADDR']; |
|
254 | + if($obj->notify_message != 'Y') { |
|
255 | + $obj->notify_message = 'N'; |
|
256 | + } |
|
257 | + if(!$obj->email_address) { |
|
258 | + $obj->email_address = ''; |
|
259 | + } |
|
260 | + if(!$isRestore) { |
|
261 | + $obj->ipaddress = $_SERVER['REMOTE_ADDR']; |
|
262 | + } |
|
221 | 263 | |
222 | 264 | // can modify regdate only manager |
223 | 265 | $grant = Context::get('grant'); |
@@ -227,7 +269,9 @@ discard block |
||
227 | 269 | } |
228 | 270 | |
229 | 271 | // Serialize the $extra_vars, check the extra_vars type, because duplicate serialized avoid |
230 | - if(!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars); |
|
272 | + if(!is_string($obj->extra_vars)) { |
|
273 | + $obj->extra_vars = serialize($obj->extra_vars); |
|
274 | + } |
|
231 | 275 | // Remove the columns for automatic saving |
232 | 276 | unset($obj->_saved_doc_srl); |
233 | 277 | unset($obj->_saved_doc_title); |
@@ -235,10 +279,15 @@ discard block |
||
235 | 279 | unset($obj->_saved_doc_message); |
236 | 280 | // Call a trigger (before) |
237 | 281 | $output = ModuleHandler::triggerCall('document.insertDocument', 'before', $obj); |
238 | - if(!$output->toBool()) return $output; |
|
282 | + if(!$output->toBool()) { |
|
283 | + return $output; |
|
284 | + } |
|
239 | 285 | // Register it if no given document_srl exists |
240 | - if(!$obj->document_srl) $obj->document_srl = getNextSequence(); |
|
241 | - elseif(!$manual_inserted && !$isRestore && !checkUserSequence($obj->document_srl)) return new BaseObject(-1, 'msg_not_permitted'); |
|
286 | + if(!$obj->document_srl) { |
|
287 | + $obj->document_srl = getNextSequence(); |
|
288 | + } elseif(!$manual_inserted && !$isRestore && !checkUserSequence($obj->document_srl)) { |
|
289 | + return new BaseObject(-1, 'msg_not_permitted'); |
|
290 | + } |
|
242 | 291 | |
243 | 292 | $oDocumentModel = getModel('document'); |
244 | 293 | // Set to 0 if the category_srl doesn't exist |
@@ -249,12 +298,19 @@ discard block |
||
249 | 298 | { |
250 | 299 | return new BaseObject(-1, 'msg_not_permitted'); |
251 | 300 | } |
252 | - if(count($category_list) > 0 && !$category_list[$obj->category_srl]) $obj->category_srl = 0; |
|
301 | + if(count($category_list) > 0 && !$category_list[$obj->category_srl]) { |
|
302 | + $obj->category_srl = 0; |
|
303 | + } |
|
253 | 304 | } |
254 | 305 | // Set the read counts and update order. |
255 | - if(!$obj->readed_count) $obj->readed_count = 0; |
|
256 | - if($isLatest) $obj->update_order = $obj->list_order = $obj->document_srl * -1; |
|
257 | - else $obj->update_order = $obj->list_order; |
|
306 | + if(!$obj->readed_count) { |
|
307 | + $obj->readed_count = 0; |
|
308 | + } |
|
309 | + if($isLatest) { |
|
310 | + $obj->update_order = $obj->list_order = $obj->document_srl * -1; |
|
311 | + } else { |
|
312 | + $obj->update_order = $obj->list_order; |
|
313 | + } |
|
258 | 314 | // Check the status of password hash for manually inserting. Apply hashing for otherwise. |
259 | 315 | if($obj->password && !$obj->password_is_hashed) |
260 | 316 | { |
@@ -276,9 +332,13 @@ discard block |
||
276 | 332 | // If the tile is empty, extract string from the contents. |
277 | 333 | $obj->title = htmlspecialchars($obj->title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
278 | 334 | settype($obj->title, "string"); |
279 | - if($obj->title == '') $obj->title = cut_str(trim(strip_tags(nl2br($obj->content))),20,'...'); |
|
335 | + if($obj->title == '') { |
|
336 | + $obj->title = cut_str(trim(strip_tags(nl2br($obj->content))),20,'...'); |
|
337 | + } |
|
280 | 338 | // If no tile extracted from the contents, leave it untitled. |
281 | - if($obj->title == '') $obj->title = 'Untitled'; |
|
339 | + if($obj->title == '') { |
|
340 | + $obj->title = 'Untitled'; |
|
341 | + } |
|
282 | 342 | // Remove XE's own tags from the contents. |
283 | 343 | $obj->content = preg_replace('!<\!--(Before|After)(Document|Comment)\(([0-9]+),([0-9]+)\)-->!is', '', $obj->content); |
284 | 344 | if(Mobile::isFromMobilePhone() && $obj->use_editor != 'Y') |
@@ -290,13 +350,19 @@ discard block |
||
290 | 350 | $obj->content = nl2br($obj->content); |
291 | 351 | } |
292 | 352 | // Remove iframe and script if not a top adminisrator in the session. |
293 | - if($logged_info->is_admin != 'Y') $obj->content = removeHackTag($obj->content); |
|
353 | + if($logged_info->is_admin != 'Y') { |
|
354 | + $obj->content = removeHackTag($obj->content); |
|
355 | + } |
|
294 | 356 | // An error appears if both log-in info and user name don't exist. |
295 | - if(!$logged_info->member_srl && !$obj->nick_name) return new BaseObject(-1,'msg_invalid_request'); |
|
357 | + if(!$logged_info->member_srl && !$obj->nick_name) { |
|
358 | + return new BaseObject(-1,'msg_invalid_request'); |
|
359 | + } |
|
296 | 360 | |
297 | 361 | $obj->lang_code = Context::getLangType(); |
298 | 362 | // Insert data into the DB |
299 | - if(!$obj->status) $this->_checkDocumentStatusForOldVersion($obj); |
|
363 | + if(!$obj->status) { |
|
364 | + $this->_checkDocumentStatusForOldVersion($obj); |
|
365 | + } |
|
300 | 366 | $output = executeQuery('document.insertDocument', $obj); |
301 | 367 | if(!$output->toBool()) |
302 | 368 | { |
@@ -313,19 +379,25 @@ discard block |
||
313 | 379 | if(isset($obj->{'extra_vars'.$idx})) |
314 | 380 | { |
315 | 381 | $tmp = $obj->{'extra_vars'.$idx}; |
316 | - if(is_array($tmp)) |
|
317 | - $value = implode('|@|', $tmp); |
|
318 | - else |
|
319 | - $value = trim($tmp); |
|
382 | + if(is_array($tmp)) { |
|
383 | + $value = implode('|@|', $tmp); |
|
384 | + } else { |
|
385 | + $value = trim($tmp); |
|
386 | + } |
|
387 | + } else if(isset($obj->{$extra_item->name})) { |
|
388 | + $value = trim($obj->{$extra_item->name}); |
|
389 | + } |
|
390 | + if($value == NULL) { |
|
391 | + continue; |
|
320 | 392 | } |
321 | - else if(isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name}); |
|
322 | - if($value == NULL) continue; |
|
323 | 393 | |
324 | 394 | $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, $idx, $value, $extra_item->eid); |
325 | 395 | } |
326 | 396 | } |
327 | 397 | // Update the category if the category_srl exists. |
328 | - if($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl); |
|
398 | + if($obj->category_srl) { |
|
399 | + $this->updateCategoryCount($obj->module_srl, $obj->category_srl); |
|
400 | + } |
|
329 | 401 | // Call a trigger (after) |
330 | 402 | if($output->toBool()) |
331 | 403 | { |
@@ -367,27 +439,39 @@ discard block |
||
367 | 439 | return new BaseObject(-1, 'msg_invalid_request'); |
368 | 440 | } |
369 | 441 | |
370 | - if(!$source_obj->document_srl || !$obj->document_srl) return new BaseObject(-1,'msg_invalied_request'); |
|
371 | - if(!$obj->status && $obj->is_secret == 'Y') $obj->status = 'SECRET'; |
|
372 | - if(!$obj->status) $obj->status = 'PUBLIC'; |
|
442 | + if(!$source_obj->document_srl || !$obj->document_srl) { |
|
443 | + return new BaseObject(-1,'msg_invalied_request'); |
|
444 | + } |
|
445 | + if(!$obj->status && $obj->is_secret == 'Y') { |
|
446 | + $obj->status = 'SECRET'; |
|
447 | + } |
|
448 | + if(!$obj->status) { |
|
449 | + $obj->status = 'PUBLIC'; |
|
450 | + } |
|
373 | 451 | |
374 | 452 | // Call a trigger (before) |
375 | 453 | $output = ModuleHandler::triggerCall('document.updateDocument', 'before', $obj); |
376 | - if(!$output->toBool()) return $output; |
|
454 | + if(!$output->toBool()) { |
|
455 | + return $output; |
|
456 | + } |
|
377 | 457 | |
378 | 458 | // begin transaction |
379 | 459 | $oDB = &DB::getInstance(); |
380 | 460 | $oDB->begin(); |
381 | 461 | |
382 | 462 | $oModuleModel = getModel('module'); |
383 | - if(!$obj->module_srl) $obj->module_srl = $source_obj->get('module_srl'); |
|
463 | + if(!$obj->module_srl) { |
|
464 | + $obj->module_srl = $source_obj->get('module_srl'); |
|
465 | + } |
|
384 | 466 | $module_srl = $obj->module_srl; |
385 | 467 | $document_config = $oModuleModel->getModulePartConfig('document', $module_srl); |
386 | 468 | if(!$document_config) |
387 | 469 | { |
388 | 470 | $document_config = new stdClass(); |
389 | 471 | } |
390 | - if(!isset($document_config->use_history)) $document_config->use_history = 'N'; |
|
472 | + if(!isset($document_config->use_history)) { |
|
473 | + $document_config->use_history = 'N'; |
|
474 | + } |
|
391 | 475 | $bUseHistory = $document_config->use_history == 'Y' || $document_config->use_history == 'Trace'; |
392 | 476 | |
393 | 477 | if($bUseHistory) |
@@ -396,22 +480,31 @@ discard block |
||
396 | 480 | $args->history_srl = getNextSequence(); |
397 | 481 | $args->document_srl = $obj->document_srl; |
398 | 482 | $args->module_srl = $module_srl; |
399 | - if($document_config->use_history == 'Y') $args->content = $source_obj->get('content'); |
|
483 | + if($document_config->use_history == 'Y') { |
|
484 | + $args->content = $source_obj->get('content'); |
|
485 | + } |
|
400 | 486 | $args->nick_name = $source_obj->get('nick_name'); |
401 | 487 | $args->member_srl = $source_obj->get('member_srl'); |
402 | 488 | $args->regdate = $source_obj->get('last_update'); |
403 | 489 | $args->ipaddress = $_SERVER['REMOTE_ADDR']; |
404 | 490 | $output = executeQuery("document.insertHistory", $args); |
405 | - } |
|
406 | - else |
|
491 | + } else |
|
407 | 492 | { |
408 | 493 | $obj->ipaddress = $source_obj->get('ipaddress'); |
409 | 494 | } |
410 | 495 | // List variables |
411 | - if($obj->comment_status) $obj->commentStatus = $obj->comment_status; |
|
412 | - if(!$obj->commentStatus) $obj->commentStatus = 'DENY'; |
|
413 | - if($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj); |
|
414 | - if($obj->allow_trackback!='Y') $obj->allow_trackback = 'N'; |
|
496 | + if($obj->comment_status) { |
|
497 | + $obj->commentStatus = $obj->comment_status; |
|
498 | + } |
|
499 | + if(!$obj->commentStatus) { |
|
500 | + $obj->commentStatus = 'DENY'; |
|
501 | + } |
|
502 | + if($obj->commentStatus == 'DENY') { |
|
503 | + $this->_checkCommentStatusForOldVersion($obj); |
|
504 | + } |
|
505 | + if($obj->allow_trackback!='Y') { |
|
506 | + $obj->allow_trackback = 'N'; |
|
507 | + } |
|
415 | 508 | if($obj->homepage) |
416 | 509 | { |
417 | 510 | $obj->homepage = escape($obj->homepage); |
@@ -421,7 +514,9 @@ discard block |
||
421 | 514 | } |
422 | 515 | } |
423 | 516 | |
424 | - if($obj->notify_message != 'Y') $obj->notify_message = 'N'; |
|
517 | + if($obj->notify_message != 'Y') { |
|
518 | + $obj->notify_message = 'N'; |
|
519 | + } |
|
425 | 520 | |
426 | 521 | // can modify regdate only manager |
427 | 522 | $grant = Context::get('grant'); |
@@ -431,7 +526,9 @@ discard block |
||
431 | 526 | } |
432 | 527 | |
433 | 528 | // Serialize the $extra_vars |
434 | - if(!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars); |
|
529 | + if(!is_string($obj->extra_vars)) { |
|
530 | + $obj->extra_vars = serialize($obj->extra_vars); |
|
531 | + } |
|
435 | 532 | // Remove the columns for automatic saving |
436 | 533 | unset($obj->_saved_doc_srl); |
437 | 534 | unset($obj->_saved_doc_title); |
@@ -443,7 +540,9 @@ discard block |
||
443 | 540 | if($source_obj->get('category_srl')!=$obj->category_srl) |
444 | 541 | { |
445 | 542 | $category_list = $oDocumentModel->getCategoryList($obj->module_srl); |
446 | - if(!$category_list[$obj->category_srl]) $obj->category_srl = 0; |
|
543 | + if(!$category_list[$obj->category_srl]) { |
|
544 | + $obj->category_srl = 0; |
|
545 | + } |
|
447 | 546 | } |
448 | 547 | // Change the update order |
449 | 548 | $obj->update_order = getNextSequence() * -1; |
@@ -478,9 +577,13 @@ discard block |
||
478 | 577 | // If the tile is empty, extract string from the contents. |
479 | 578 | $obj->title = htmlspecialchars($obj->title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
480 | 579 | settype($obj->title, "string"); |
481 | - if($obj->title == '') $obj->title = cut_str(strip_tags($obj->content),20,'...'); |
|
580 | + if($obj->title == '') { |
|
581 | + $obj->title = cut_str(strip_tags($obj->content),20,'...'); |
|
582 | + } |
|
482 | 583 | // If no tile extracted from the contents, leave it untitled. |
483 | - if($obj->title == '') $obj->title = 'Untitled'; |
|
584 | + if($obj->title == '') { |
|
585 | + $obj->title = 'Untitled'; |
|
586 | + } |
|
484 | 587 | // Remove XE's own tags from the contents. |
485 | 588 | $obj->content = preg_replace('!<\!--(Before|After)(Document|Comment)\(([0-9]+),([0-9]+)\)-->!is', '', $obj->content); |
486 | 589 | if(Mobile::isFromMobilePhone() && $obj->use_editor != 'Y') |
@@ -500,8 +603,7 @@ discard block |
||
500 | 603 | $lang_code_args->document_srl = $source_obj->get('document_srl'); |
501 | 604 | $lang_code_args->lang_code = Context::getLangType(); |
502 | 605 | $output = executeQuery('document.updateDocumentsLangCode', $lang_code_args); |
503 | - } |
|
504 | - else |
|
606 | + } else |
|
505 | 607 | { |
506 | 608 | $extra_content = new stdClass; |
507 | 609 | $extra_content->title = $obj->title; |
@@ -520,7 +622,9 @@ discard block |
||
520 | 622 | $obj->content = removeHackTag($obj->content); |
521 | 623 | } |
522 | 624 | // if temporary document, regdate is now setting |
523 | - if($source_obj->get('status') == $this->getConfigStatus('temp')) $obj->regdate = date('YmdHis'); |
|
625 | + if($source_obj->get('status') == $this->getConfigStatus('temp')) { |
|
626 | + $obj->regdate = date('YmdHis'); |
|
627 | + } |
|
524 | 628 | |
525 | 629 | // Insert data into the DB |
526 | 630 | $output = executeQuery('document.updateDocument', $obj); |
@@ -543,25 +647,37 @@ discard block |
||
543 | 647 | if(isset($obj->{'extra_vars'.$idx})) |
544 | 648 | { |
545 | 649 | $tmp = $obj->{'extra_vars'.$idx}; |
546 | - if(is_array($tmp)) |
|
547 | - $value = implode('|@|', $tmp); |
|
548 | - else |
|
549 | - $value = trim($tmp); |
|
650 | + if(is_array($tmp)) { |
|
651 | + $value = implode('|@|', $tmp); |
|
652 | + } else { |
|
653 | + $value = trim($tmp); |
|
654 | + } |
|
655 | + } else if(isset($obj->{$extra_item->name})) { |
|
656 | + $value = trim($obj->{$extra_item->name}); |
|
657 | + } |
|
658 | + if($value == NULL) { |
|
659 | + continue; |
|
550 | 660 | } |
551 | - else if(isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name}); |
|
552 | - if($value == NULL) continue; |
|
553 | 661 | $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, $idx, $value, $extra_item->eid); |
554 | 662 | } |
555 | 663 | } |
556 | 664 | // Inert extra vars for multi-language support of title and contents. |
557 | - if($extra_content->title) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -1, $extra_content->title, 'title_'.Context::getLangType()); |
|
558 | - if($extra_content->content) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -2, $extra_content->content, 'content_'.Context::getLangType()); |
|
665 | + if($extra_content->title) { |
|
666 | + $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -1, $extra_content->title, 'title_'.Context::getLangType()); |
|
667 | + } |
|
668 | + if($extra_content->content) { |
|
669 | + $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -2, $extra_content->content, 'content_'.Context::getLangType()); |
|
670 | + } |
|
559 | 671 | } |
560 | 672 | // Update the category if the category_srl exists. |
561 | 673 | if($source_obj->get('category_srl') != $obj->category_srl || $source_obj->get('module_srl') == $logged_info->member_srl) |
562 | 674 | { |
563 | - if($source_obj->get('category_srl') != $obj->category_srl) $this->updateCategoryCount($obj->module_srl, $source_obj->get('category_srl')); |
|
564 | - if($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl); |
|
675 | + if($source_obj->get('category_srl') != $obj->category_srl) { |
|
676 | + $this->updateCategoryCount($obj->module_srl, $source_obj->get('category_srl')); |
|
677 | + } |
|
678 | + if($obj->category_srl) { |
|
679 | + $this->updateCategoryCount($obj->module_srl, $obj->category_srl); |
|
680 | + } |
|
565 | 681 | } |
566 | 682 | // Call a trigger (after) |
567 | 683 | if($output->toBool()) |
@@ -606,7 +722,9 @@ discard block |
||
606 | 722 | $trigger_obj = new stdClass(); |
607 | 723 | $trigger_obj->document_srl = $document_srl; |
608 | 724 | $output = ModuleHandler::triggerCall('document.deleteDocument', 'before', $trigger_obj); |
609 | - if(!$output->toBool()) return $output; |
|
725 | + if(!$output->toBool()) { |
|
726 | + return $output; |
|
727 | + } |
|
610 | 728 | |
611 | 729 | // begin transaction |
612 | 730 | $oDB = &DB::getInstance(); |
@@ -618,12 +736,17 @@ discard block |
||
618 | 736 | $oDocumentModel = getModel('document'); |
619 | 737 | // Check if the documnet exists |
620 | 738 | $oDocument = $oDocumentModel->getDocument($document_srl, $is_admin); |
739 | + } else if($isEmptyTrash && $oDocument == null) { |
|
740 | + return new BaseObject(-1, 'document is not exists'); |
|
621 | 741 | } |
622 | - else if($isEmptyTrash && $oDocument == null) return new BaseObject(-1, 'document is not exists'); |
|
623 | 742 | |
624 | - if(!$oDocument->isExists() || $oDocument->document_srl != $document_srl) return new BaseObject(-1, 'msg_invalid_document'); |
|
743 | + if(!$oDocument->isExists() || $oDocument->document_srl != $document_srl) { |
|
744 | + return new BaseObject(-1, 'msg_invalid_document'); |
|
745 | + } |
|
625 | 746 | // Check if a permossion is granted |
626 | - if(!$oDocument->isGranted()) return new BaseObject(-1, 'msg_not_permitted'); |
|
747 | + if(!$oDocument->isGranted()) { |
|
748 | + return new BaseObject(-1, 'msg_not_permitted'); |
|
749 | + } |
|
627 | 750 | |
628 | 751 | //if empty trash, document already deleted, therefore document not delete |
629 | 752 | $args = new stdClass(); |
@@ -643,7 +766,9 @@ discard block |
||
643 | 766 | |
644 | 767 | $this->deleteDocumentHistory(null, $document_srl, null); |
645 | 768 | // Update category information if the category_srl exists. |
646 | - if($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl')); |
|
769 | + if($oDocument->get('category_srl')) { |
|
770 | + $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl')); |
|
771 | + } |
|
647 | 772 | // Delete a declared list |
648 | 773 | executeQuery('document.deleteDeclared', $args); |
649 | 774 | // Delete extra variable |
@@ -723,8 +848,11 @@ discard block |
||
723 | 848 | { |
724 | 849 | $trash_args = new stdClass(); |
725 | 850 | // Get trash_srl if a given trash_srl doesn't exist |
726 | - if(!$obj->trash_srl) $trash_args->trash_srl = getNextSequence(); |
|
727 | - else $trash_args->trash_srl = $obj->trash_srl; |
|
851 | + if(!$obj->trash_srl) { |
|
852 | + $trash_args->trash_srl = getNextSequence(); |
|
853 | + } else { |
|
854 | + $trash_args->trash_srl = $obj->trash_srl; |
|
855 | + } |
|
728 | 856 | // Get its module_srl which the document belongs to |
729 | 857 | $oDocumentModel = getModel('document'); |
730 | 858 | $oDocument = $oDocumentModel->getDocument($obj->document_srl); |
@@ -732,7 +860,9 @@ discard block |
||
732 | 860 | $trash_args->module_srl = $oDocument->get('module_srl'); |
733 | 861 | $obj->module_srl = $oDocument->get('module_srl'); |
734 | 862 | // Cannot throw data from the trash to the trash |
735 | - if($trash_args->module_srl == 0) return false; |
|
863 | + if($trash_args->module_srl == 0) { |
|
864 | + return false; |
|
865 | + } |
|
736 | 866 | // Data setting |
737 | 867 | $trash_args->document_srl = $obj->document_srl; |
738 | 868 | $trash_args->description = $obj->description; |
@@ -793,7 +923,9 @@ discard block |
||
793 | 923 | }*/ |
794 | 924 | |
795 | 925 | // update category |
796 | - if($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl')); |
|
926 | + if($oDocument->get('category_srl')) { |
|
927 | + $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl')); |
|
928 | + } |
|
797 | 929 | |
798 | 930 | // remove thumbnails |
799 | 931 | FileHandler::removeDir(sprintf('files/thumbnails/%s',getNumberingPath($obj->document_srl, 3))); |
@@ -838,7 +970,9 @@ discard block |
||
838 | 970 | function updateReadedCount(&$oDocument) |
839 | 971 | { |
840 | 972 | // Pass if Crawler access |
841 | - if(isCrawler()) return false; |
|
973 | + if(isCrawler()) { |
|
974 | + return false; |
|
975 | + } |
|
842 | 976 | |
843 | 977 | $document_srl = $oDocument->document_srl; |
844 | 978 | $member_srl = $oDocument->get('member_srl'); |
@@ -846,10 +980,14 @@ discard block |
||
846 | 980 | |
847 | 981 | // Call a trigger when the read count is updated (before) |
848 | 982 | $trigger_output = ModuleHandler::triggerCall('document.updateReadedCount', 'before', $oDocument); |
849 | - if(!$trigger_output->toBool()) return $trigger_output; |
|
983 | + if(!$trigger_output->toBool()) { |
|
984 | + return $trigger_output; |
|
985 | + } |
|
850 | 986 | |
851 | 987 | // Pass if read count is increaded on the session information |
852 | - if($_SESSION['readed_document'][$document_srl]) return false; |
|
988 | + if($_SESSION['readed_document'][$document_srl]) { |
|
989 | + return false; |
|
990 | + } |
|
853 | 991 | |
854 | 992 | // Pass if the author's IP address is as same as visitor's. |
855 | 993 | if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) |
@@ -914,7 +1052,9 @@ discard block |
||
914 | 1052 | */ |
915 | 1053 | function insertDocumentExtraKey($module_srl, $var_idx, $var_name, $var_type, $var_is_required = 'N', $var_search = 'N', $var_default = '', $var_desc = '', $eid) |
916 | 1054 | { |
917 | - if(!$module_srl || !$var_idx || !$var_name || !$var_type || !$eid) return new BaseObject(-1,'msg_invalid_request'); |
|
1055 | + if(!$module_srl || !$var_idx || !$var_name || !$var_type || !$eid) { |
|
1056 | + return new BaseObject(-1,'msg_invalid_request'); |
|
1057 | + } |
|
918 | 1058 | |
919 | 1059 | $obj = new stdClass(); |
920 | 1060 | $obj->module_srl = $module_srl; |
@@ -931,8 +1071,7 @@ discard block |
||
931 | 1071 | if(!$output->data) |
932 | 1072 | { |
933 | 1073 | $output = executeQuery('document.insertDocumentExtraKey', $obj); |
934 | - } |
|
935 | - else |
|
1074 | + } else |
|
936 | 1075 | { |
937 | 1076 | $output = executeQuery('document.updateDocumentExtraKey', $obj); |
938 | 1077 | // Update the extra var(eid) |
@@ -958,10 +1097,14 @@ discard block |
||
958 | 1097 | */ |
959 | 1098 | function deleteDocumentExtraKeys($module_srl, $var_idx = null) |
960 | 1099 | { |
961 | - if(!$module_srl) return new BaseObject(-1,'msg_invalid_request'); |
|
1100 | + if(!$module_srl) { |
|
1101 | + return new BaseObject(-1,'msg_invalid_request'); |
|
1102 | + } |
|
962 | 1103 | $obj = new stdClass(); |
963 | 1104 | $obj->module_srl = $module_srl; |
964 | - if(!is_null($var_idx)) $obj->var_idx = $var_idx; |
|
1105 | + if(!is_null($var_idx)) { |
|
1106 | + $obj->var_idx = $var_idx; |
|
1107 | + } |
|
965 | 1108 | |
966 | 1109 | $oDB = DB::getInstance(); |
967 | 1110 | $oDB->begin(); |
@@ -1025,8 +1168,12 @@ discard block |
||
1025 | 1168 | */ |
1026 | 1169 | function insertDocumentExtraVar($module_srl, $document_srl, $var_idx, $value, $eid = null, $lang_code = '') |
1027 | 1170 | { |
1028 | - if(!$module_srl || !$document_srl || !$var_idx || !isset($value)) return new BaseObject(-1,'msg_invalid_request'); |
|
1029 | - if(!$lang_code) $lang_code = Context::getLangType(); |
|
1171 | + if(!$module_srl || !$document_srl || !$var_idx || !isset($value)) { |
|
1172 | + return new BaseObject(-1,'msg_invalid_request'); |
|
1173 | + } |
|
1174 | + if(!$lang_code) { |
|
1175 | + $lang_code = Context::getLangType(); |
|
1176 | + } |
|
1030 | 1177 | |
1031 | 1178 | $obj = new stdClass; |
1032 | 1179 | $obj->module_srl = $module_srl; |
@@ -1052,10 +1199,18 @@ discard block |
||
1052 | 1199 | { |
1053 | 1200 | $obj = new stdClass(); |
1054 | 1201 | $obj->module_srl = $module_srl; |
1055 | - if(!is_null($document_srl)) $obj->document_srl = $document_srl; |
|
1056 | - if(!is_null($var_idx)) $obj->var_idx = $var_idx; |
|
1057 | - if(!is_null($lang_code)) $obj->lang_code = $lang_code; |
|
1058 | - if(!is_null($eid)) $obj->eid = $eid; |
|
1202 | + if(!is_null($document_srl)) { |
|
1203 | + $obj->document_srl = $document_srl; |
|
1204 | + } |
|
1205 | + if(!is_null($var_idx)) { |
|
1206 | + $obj->var_idx = $var_idx; |
|
1207 | + } |
|
1208 | + if(!is_null($lang_code)) { |
|
1209 | + $obj->lang_code = $lang_code; |
|
1210 | + } |
|
1211 | + if(!is_null($eid)) { |
|
1212 | + $obj->eid = $eid; |
|
1213 | + } |
|
1059 | 1214 | $output = executeQuery('document.deleteDocumentExtraVars', $obj); |
1060 | 1215 | return $output; |
1061 | 1216 | } |
@@ -1069,8 +1224,11 @@ discard block |
||
1069 | 1224 | */ |
1070 | 1225 | function updateVotedCount($document_srl, $point = 1) |
1071 | 1226 | { |
1072 | - if($point > 0) $failed_voted = 'failed_voted'; |
|
1073 | - else $failed_voted = 'failed_blamed'; |
|
1227 | + if($point > 0) { |
|
1228 | + $failed_voted = 'failed_voted'; |
|
1229 | + } else { |
|
1230 | + $failed_voted = 'failed_blamed'; |
|
1231 | + } |
|
1074 | 1232 | // Return fail if session already has information about votes |
1075 | 1233 | if($_SESSION['voted_document'][$document_srl]) |
1076 | 1234 | { |
@@ -1106,8 +1264,7 @@ discard block |
||
1106 | 1264 | if($member_srl) |
1107 | 1265 | { |
1108 | 1266 | $args->member_srl = $member_srl; |
1109 | - } |
|
1110 | - else |
|
1267 | + } else |
|
1111 | 1268 | { |
1112 | 1269 | $args->ipaddress = $_SERVER['REMOTE_ADDR']; |
1113 | 1270 | } |
@@ -1144,18 +1301,21 @@ discard block |
||
1144 | 1301 | { |
1145 | 1302 | $args->blamed_count = $trigger_obj->after_point; |
1146 | 1303 | $output = executeQuery('document.updateBlamedCount', $args); |
1147 | - } |
|
1148 | - else |
|
1304 | + } else |
|
1149 | 1305 | { |
1150 | 1306 | $args->voted_count = $trigger_obj->after_point; |
1151 | 1307 | $output = executeQuery('document.updateVotedCount', $args); |
1152 | 1308 | } |
1153 | - if(!$output->toBool()) return $output; |
|
1309 | + if(!$output->toBool()) { |
|
1310 | + return $output; |
|
1311 | + } |
|
1154 | 1312 | |
1155 | 1313 | // Leave logs |
1156 | 1314 | $args->point = $trigger_obj->point; |
1157 | 1315 | $output = executeQuery('document.insertDocumentVotedLog', $args); |
1158 | - if(!$output->toBool()) return $output; |
|
1316 | + if(!$output->toBool()) { |
|
1317 | + return $output; |
|
1318 | + } |
|
1159 | 1319 | |
1160 | 1320 | // Call a trigger (after) |
1161 | 1321 | $trigger_output = ModuleHandler::triggerCall('document.updateVotedCount', 'after', $trigger_obj); |
@@ -1184,8 +1344,7 @@ discard block |
||
1184 | 1344 | { |
1185 | 1345 | $output->setMessage('success_voted'); |
1186 | 1346 | $output->add('voted_count', $trigger_obj->after_point); |
1187 | - } |
|
1188 | - else |
|
1347 | + } else |
|
1189 | 1348 | { |
1190 | 1349 | $output->setMessage('success_blamed'); |
1191 | 1350 | $output->add('blamed_count', $trigger_obj->after_point); |
@@ -1202,13 +1361,17 @@ discard block |
||
1202 | 1361 | function declaredDocument($document_srl) |
1203 | 1362 | { |
1204 | 1363 | // Fail if session information already has a reported document |
1205 | - if($_SESSION['declared_document'][$document_srl]) return new BaseObject(-1, 'failed_declared'); |
|
1364 | + if($_SESSION['declared_document'][$document_srl]) { |
|
1365 | + return new BaseObject(-1, 'failed_declared'); |
|
1366 | + } |
|
1206 | 1367 | |
1207 | 1368 | // Check if previously reported |
1208 | 1369 | $args = new stdClass(); |
1209 | 1370 | $args->document_srl = $document_srl; |
1210 | 1371 | $output = executeQuery('document.getDeclaredDocument', $args); |
1211 | - if(!$output->toBool()) return $output; |
|
1372 | + if(!$output->toBool()) { |
|
1373 | + return $output; |
|
1374 | + } |
|
1212 | 1375 | |
1213 | 1376 | $declared_count = ($output->data->declared_count) ? $output->data->declared_count : 0; |
1214 | 1377 | |
@@ -1252,8 +1415,7 @@ discard block |
||
1252 | 1415 | if($member_srl) |
1253 | 1416 | { |
1254 | 1417 | $args->member_srl = $member_srl; |
1255 | - } |
|
1256 | - else |
|
1418 | + } else |
|
1257 | 1419 | { |
1258 | 1420 | $args->ipaddress = $_SERVER['REMOTE_ADDR']; |
1259 | 1421 | } |
@@ -1273,9 +1435,14 @@ discard block |
||
1273 | 1435 | $oDB->begin(); |
1274 | 1436 | |
1275 | 1437 | // Add the declared document |
1276 | - if($declared_count > 0) $output = executeQuery('document.updateDeclaredDocument', $args); |
|
1277 | - else $output = executeQuery('document.insertDeclaredDocument', $args); |
|
1278 | - if(!$output->toBool()) return $output; |
|
1438 | + if($declared_count > 0) { |
|
1439 | + $output = executeQuery('document.updateDeclaredDocument', $args); |
|
1440 | + } else { |
|
1441 | + $output = executeQuery('document.insertDeclaredDocument', $args); |
|
1442 | + } |
|
1443 | + if(!$output->toBool()) { |
|
1444 | + return $output; |
|
1445 | + } |
|
1279 | 1446 | // Leave logs |
1280 | 1447 | $output = executeQuery('document.insertDocumentDeclaredLog', $args); |
1281 | 1448 | if(!$output->toBool()) |
@@ -1374,9 +1541,10 @@ discard block |
||
1374 | 1541 | $parent_category = $oDocumentModel->getCategory($obj->parent_srl); |
1375 | 1542 | $obj->list_order = $parent_category->list_order; |
1376 | 1543 | $this->updateCategoryListOrder($parent_category->module_srl, $parent_category->list_order+1); |
1377 | - if(!$obj->category_srl) $obj->category_srl = getNextSequence(); |
|
1378 | - } |
|
1379 | - else |
|
1544 | + if(!$obj->category_srl) { |
|
1545 | + $obj->category_srl = getNextSequence(); |
|
1546 | + } |
|
1547 | + } else |
|
1380 | 1548 | { |
1381 | 1549 | $obj->list_order = $obj->category_srl = getNextSequence(); |
1382 | 1550 | } |
@@ -1416,13 +1584,17 @@ discard block |
||
1416 | 1584 | { |
1417 | 1585 | // Create a document model object |
1418 | 1586 | $oDocumentModel = getModel('document'); |
1419 | - if(!$document_count) $document_count = $oDocumentModel->getCategoryDocumentCount($module_srl,$category_srl); |
|
1587 | + if(!$document_count) { |
|
1588 | + $document_count = $oDocumentModel->getCategoryDocumentCount($module_srl,$category_srl); |
|
1589 | + } |
|
1420 | 1590 | |
1421 | 1591 | $args = new stdClass; |
1422 | 1592 | $args->category_srl = $category_srl; |
1423 | 1593 | $args->document_count = $document_count; |
1424 | 1594 | $output = executeQuery('document.updateCategoryCount', $args); |
1425 | - if($output->toBool()) $this->makeCategoryFile($module_srl); |
|
1595 | + if($output->toBool()) { |
|
1596 | + $this->makeCategoryFile($module_srl); |
|
1597 | + } |
|
1426 | 1598 | |
1427 | 1599 | return $output; |
1428 | 1600 | } |
@@ -1435,7 +1607,9 @@ discard block |
||
1435 | 1607 | function updateCategory($obj) |
1436 | 1608 | { |
1437 | 1609 | $output = executeQuery('document.updateCategory', $obj); |
1438 | - if($output->toBool()) $this->makeCategoryFile($obj->module_srl); |
|
1610 | + if($output->toBool()) { |
|
1611 | + $this->makeCategoryFile($obj->module_srl); |
|
1612 | + } |
|
1439 | 1613 | return $output; |
1440 | 1614 | } |
1441 | 1615 | |
@@ -1452,11 +1626,17 @@ discard block |
||
1452 | 1626 | $category_info = $oDocumentModel->getCategory($category_srl); |
1453 | 1627 | // Display an error that the category cannot be deleted if it has a child |
1454 | 1628 | $output = executeQuery('document.getChildCategoryCount', $args); |
1455 | - if(!$output->toBool()) return $output; |
|
1456 | - if($output->data->count>0) return new BaseObject(-1, 'msg_cannot_delete_for_child'); |
|
1629 | + if(!$output->toBool()) { |
|
1630 | + return $output; |
|
1631 | + } |
|
1632 | + if($output->data->count>0) { |
|
1633 | + return new BaseObject(-1, 'msg_cannot_delete_for_child'); |
|
1634 | + } |
|
1457 | 1635 | // Delete a category information |
1458 | 1636 | $output = executeQuery('document.deleteCategory', $args); |
1459 | - if(!$output->toBool()) return $output; |
|
1637 | + if(!$output->toBool()) { |
|
1638 | + return $output; |
|
1639 | + } |
|
1460 | 1640 | |
1461 | 1641 | $this->makeCategoryFile($category_info->module_srl); |
1462 | 1642 | // remvove cache |
@@ -1471,8 +1651,9 @@ discard block |
||
1471 | 1651 | $args->page = ++$page; |
1472 | 1652 | $output = executeQuery('document.getDocumentList', $args, array('document_srl')); |
1473 | 1653 | |
1474 | - if($output->data == array()) |
|
1475 | - break; |
|
1654 | + if($output->data == array()) { |
|
1655 | + break; |
|
1656 | + } |
|
1476 | 1657 | |
1477 | 1658 | foreach($output->data as $val) |
1478 | 1659 | { |
@@ -1524,18 +1705,26 @@ discard block |
||
1524 | 1705 | // Seek a full list of categories |
1525 | 1706 | $category_list = $oDocumentModel->getCategoryList($module_srl); |
1526 | 1707 | $category_srl_list = array_keys($category_list); |
1527 | - if(count($category_srl_list)<2) return new BaseObject(); |
|
1708 | + if(count($category_srl_list)<2) { |
|
1709 | + return new BaseObject(); |
|
1710 | + } |
|
1528 | 1711 | |
1529 | 1712 | $prev_category = NULL; |
1530 | 1713 | foreach($category_list as $key => $val) |
1531 | 1714 | { |
1532 | - if($key==$category_srl) break; |
|
1715 | + if($key==$category_srl) { |
|
1716 | + break; |
|
1717 | + } |
|
1533 | 1718 | $prev_category = $val; |
1534 | 1719 | } |
1535 | 1720 | // Return if the previous category doesn't exist |
1536 | - if(!$prev_category) return new BaseObject(-1,Context::getLang('msg_category_not_moved')); |
|
1721 | + if(!$prev_category) { |
|
1722 | + return new BaseObject(-1,Context::getLang('msg_category_not_moved')); |
|
1723 | + } |
|
1537 | 1724 | // Return if the selected category is the top level |
1538 | - if($category_srl_list[0]==$category_srl) return new BaseObject(-1,Context::getLang('msg_category_not_moved')); |
|
1725 | + if($category_srl_list[0]==$category_srl) { |
|
1726 | + return new BaseObject(-1,Context::getLang('msg_category_not_moved')); |
|
1727 | + } |
|
1539 | 1728 | // Information of the selected category |
1540 | 1729 | $cur_args = new stdClass; |
1541 | 1730 | $cur_args->category_srl = $category_srl; |
@@ -1571,15 +1760,21 @@ discard block |
||
1571 | 1760 | // Seek a full list of categories |
1572 | 1761 | $category_list = $oDocumentModel->getCategoryList($module_srl); |
1573 | 1762 | $category_srl_list = array_keys($category_list); |
1574 | - if(count($category_srl_list)<2) return new BaseObject(); |
|
1763 | + if(count($category_srl_list)<2) { |
|
1764 | + return new BaseObject(); |
|
1765 | + } |
|
1575 | 1766 | |
1576 | 1767 | for($i=0;$i<count($category_srl_list);$i++) |
1577 | 1768 | { |
1578 | - if($category_srl_list[$i]==$category_srl) break; |
|
1769 | + if($category_srl_list[$i]==$category_srl) { |
|
1770 | + break; |
|
1771 | + } |
|
1579 | 1772 | } |
1580 | 1773 | |
1581 | 1774 | $next_category_srl = $category_srl_list[$i+1]; |
1582 | - if(!$category_list[$next_category_srl]) return new BaseObject(-1,Context::getLang('msg_category_not_moved')); |
|
1775 | + if(!$category_list[$next_category_srl]) { |
|
1776 | + return new BaseObject(-1,Context::getLang('msg_category_not_moved')); |
|
1777 | + } |
|
1583 | 1778 | $next_category = $category_list[$next_category_srl]; |
1584 | 1779 | // Information of the selected category |
1585 | 1780 | $cur_args = new stdClass; |
@@ -1606,7 +1801,9 @@ discard block |
||
1606 | 1801 | { |
1607 | 1802 | $oDocumentModel = getModel('document'); |
1608 | 1803 | $extra_keys = $oDocumentModel->getExtraKeys($module_srl); |
1609 | - if(!count($extra_keys)) return; |
|
1804 | + if(!count($extra_keys)) { |
|
1805 | + return; |
|
1806 | + } |
|
1610 | 1807 | |
1611 | 1808 | $js_code = array(); |
1612 | 1809 | $js_code[] = '<script>//<![CDATA['; |
@@ -1625,7 +1822,9 @@ discard block |
||
1625 | 1822 | } |
1626 | 1823 | $name = str_ireplace(array('<script', '</script'), array('<scr" + "ipt', '</scr" + "ipt'), $val->name); |
1627 | 1824 | $js_code[] = sprintf('validator.cast("ADD_MESSAGE", ["extra_vars%s","%s"]);', $idx, $name); |
1628 | - if($val->is_required == 'Y') $js_code[] = sprintf('validator.cast("ADD_EXTRA_FIELD", ["extra_vars%s", { required:true }]);', $idx); |
|
1825 | + if($val->is_required == 'Y') { |
|
1826 | + $js_code[] = sprintf('validator.cast("ADD_EXTRA_FIELD", ["extra_vars%s", { required:true }]);', $idx); |
|
1827 | + } |
|
1629 | 1828 | } |
1630 | 1829 | |
1631 | 1830 | $js_code[] = '})(jQuery);'; |
@@ -1643,7 +1842,9 @@ discard block |
||
1643 | 1842 | function procDocumentInsertCategory($args = null) |
1644 | 1843 | { |
1645 | 1844 | // List variables |
1646 | - if(!$args) $args = Context::gets('module_srl','category_srl','parent_srl','category_title','category_description','expand','group_srls','category_color','mid'); |
|
1845 | + if(!$args) { |
|
1846 | + $args = Context::gets('module_srl','category_srl','parent_srl','category_title','category_description','expand','group_srls','category_color','mid'); |
|
1847 | + } |
|
1647 | 1848 | $args->title = $args->category_title; |
1648 | 1849 | $args->description = $args->category_description; |
1649 | 1850 | $args->color = $args->category_color; |
@@ -1659,11 +1860,18 @@ discard block |
||
1659 | 1860 | $columnList = array('module_srl', 'module'); |
1660 | 1861 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl, $columnList); |
1661 | 1862 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
1662 | - if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted'); |
|
1863 | + if(!$grant->manager) { |
|
1864 | + return new BaseObject(-1,'msg_not_permitted'); |
|
1865 | + } |
|
1663 | 1866 | |
1664 | - if($args->expand !="Y") $args->expand = "N"; |
|
1665 | - if(!is_array($args->group_srls)) $args->group_srls = str_replace('|@|',',',$args->group_srls); |
|
1666 | - else $args->group_srls = implode(',', $args->group_srls); |
|
1867 | + if($args->expand !="Y") { |
|
1868 | + $args->expand = "N"; |
|
1869 | + } |
|
1870 | + if(!is_array($args->group_srls)) { |
|
1871 | + $args->group_srls = str_replace('|@|',',',$args->group_srls); |
|
1872 | + } else { |
|
1873 | + $args->group_srls = implode(',', $args->group_srls); |
|
1874 | + } |
|
1667 | 1875 | $args->parent_srl = (int)$args->parent_srl; |
1668 | 1876 | |
1669 | 1877 | $oDocumentModel = getModel('document'); |
@@ -1674,7 +1882,9 @@ discard block |
||
1674 | 1882 | if($args->category_srl) |
1675 | 1883 | { |
1676 | 1884 | $category_info = $oDocumentModel->getCategory($args->category_srl); |
1677 | - if($category_info->category_srl != $args->category_srl) $args->category_srl = null; |
|
1885 | + if($category_info->category_srl != $args->category_srl) { |
|
1886 | + $args->category_srl = null; |
|
1887 | + } |
|
1678 | 1888 | } |
1679 | 1889 | // Update if exists |
1680 | 1890 | if($args->category_srl) |
@@ -1686,8 +1896,7 @@ discard block |
||
1686 | 1896 | return $output; |
1687 | 1897 | } |
1688 | 1898 | // Insert if not exist |
1689 | - } |
|
1690 | - else |
|
1899 | + } else |
|
1691 | 1900 | { |
1692 | 1901 | $output = $this->insertCategory($args); |
1693 | 1902 | if(!$output->toBool()) |
@@ -1729,7 +1938,9 @@ discard block |
||
1729 | 1938 | $columnList = array('module_srl', 'module'); |
1730 | 1939 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($source_category->module_srl, $columnList); |
1731 | 1940 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
1732 | - if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted'); |
|
1941 | + if(!$grant->manager) { |
|
1942 | + return new BaseObject(-1,'msg_not_permitted'); |
|
1943 | + } |
|
1733 | 1944 | |
1734 | 1945 | // First child of the parent_category_srl |
1735 | 1946 | $source_args = new stdClass; |
@@ -1742,30 +1953,39 @@ discard block |
||
1742 | 1953 | $args->parent_srl = $parent_category_srl; |
1743 | 1954 | $output = executeQuery('document.getChildCategoryMinListOrder', $args); |
1744 | 1955 | |
1745 | - if(!$output->toBool()) return $output; |
|
1956 | + if(!$output->toBool()) { |
|
1957 | + return $output; |
|
1958 | + } |
|
1746 | 1959 | $args->list_order = (int)$output->data->list_order; |
1747 | - if(!$args->list_order) $args->list_order = 0; |
|
1960 | + if(!$args->list_order) { |
|
1961 | + $args->list_order = 0; |
|
1962 | + } |
|
1748 | 1963 | $args->list_order--; |
1749 | 1964 | |
1750 | 1965 | $source_args->category_srl = $source_category_srl; |
1751 | 1966 | $source_args->parent_srl = $parent_category_srl; |
1752 | 1967 | $source_args->list_order = $args->list_order; |
1753 | 1968 | $output = $this->updateCategory($source_args); |
1754 | - if(!$output->toBool()) return $output; |
|
1969 | + if(!$output->toBool()) { |
|
1970 | + return $output; |
|
1971 | + } |
|
1755 | 1972 | // Sibling of the $target_category_srl |
1756 | - } |
|
1757 | - else if($target_category_srl > 0) |
|
1973 | + } else if($target_category_srl > 0) |
|
1758 | 1974 | { |
1759 | 1975 | $target_category = $oDocumentModel->getCategory($target_category_srl); |
1760 | 1976 | // Move all siblings of the $target_category down |
1761 | 1977 | $output = $this->updateCategoryListOrder($target_category->module_srl, $target_category->list_order+1); |
1762 | - if(!$output->toBool()) return $output; |
|
1978 | + if(!$output->toBool()) { |
|
1979 | + return $output; |
|
1980 | + } |
|
1763 | 1981 | |
1764 | 1982 | $source_args->category_srl = $source_category_srl; |
1765 | 1983 | $source_args->parent_srl = $target_category->parent_srl; |
1766 | 1984 | $source_args->list_order = $target_category->list_order+1; |
1767 | 1985 | $output = $this->updateCategory($source_args); |
1768 | - if(!$output->toBool()) return $output; |
|
1986 | + if(!$output->toBool()) { |
|
1987 | + return $output; |
|
1988 | + } |
|
1769 | 1989 | } |
1770 | 1990 | // Re-generate the xml file |
1771 | 1991 | $xml_file = $this->makeCategoryFile($source_category->module_srl); |
@@ -1790,14 +2010,20 @@ discard block |
||
1790 | 2010 | $columnList = array('module_srl', 'module'); |
1791 | 2011 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl, $columnList); |
1792 | 2012 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
1793 | - if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted'); |
|
2013 | + if(!$grant->manager) { |
|
2014 | + return new BaseObject(-1,'msg_not_permitted'); |
|
2015 | + } |
|
1794 | 2016 | |
1795 | 2017 | $oDocumentModel = getModel('document'); |
1796 | 2018 | // Get original information |
1797 | 2019 | $category_info = $oDocumentModel->getCategory($args->category_srl); |
1798 | - if($category_info->parent_srl) $parent_srl = $category_info->parent_srl; |
|
2020 | + if($category_info->parent_srl) { |
|
2021 | + $parent_srl = $category_info->parent_srl; |
|
2022 | + } |
|
1799 | 2023 | // Display an error that the category cannot be deleted if it has a child node |
1800 | - if($oDocumentModel->getCategoryChlidCount($args->category_srl)) return new BaseObject(-1, 'msg_cannot_delete_for_child'); |
|
2024 | + if($oDocumentModel->getCategoryChlidCount($args->category_srl)) { |
|
2025 | + return new BaseObject(-1, 'msg_cannot_delete_for_child'); |
|
2026 | + } |
|
1801 | 2027 | // Remove from the DB |
1802 | 2028 | $output = $this->deleteCategory($args->category_srl); |
1803 | 2029 | if(!$output->toBool()) |
@@ -1831,7 +2057,9 @@ discard block |
||
1831 | 2057 | $columnList = array('module_srl', 'module'); |
1832 | 2058 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList); |
1833 | 2059 | $grant = $oModuleModel->getGrant($module_info, Context::get('logged_info')); |
1834 | - if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted'); |
|
2060 | + if(!$grant->manager) { |
|
2061 | + return new BaseObject(-1,'msg_not_permitted'); |
|
2062 | + } |
|
1835 | 2063 | |
1836 | 2064 | $xml_file = $this->makeCategoryFile($module_srl); |
1837 | 2065 | // Set return value |
@@ -1846,7 +2074,9 @@ discard block |
||
1846 | 2074 | function makeCategoryFile($module_srl) |
1847 | 2075 | { |
1848 | 2076 | // Return if there is no information you need for creating a cache file |
1849 | - if(!$module_srl) return false; |
|
2077 | + if(!$module_srl) { |
|
2078 | + return false; |
|
2079 | + } |
|
1850 | 2080 | |
1851 | 2081 | $module_srl = (int)$module_srl; |
1852 | 2082 | |
@@ -1856,7 +2086,9 @@ discard block |
||
1856 | 2086 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList); |
1857 | 2087 | $mid = $module_info->mid; |
1858 | 2088 | |
1859 | - if(!is_dir('./files/cache/document_category')) FileHandler::makeDir('./files/cache/document_category'); |
|
2089 | + if(!is_dir('./files/cache/document_category')) { |
|
2090 | + FileHandler::makeDir('./files/cache/document_category'); |
|
2091 | + } |
|
1860 | 2092 | // Cache file's name |
1861 | 2093 | $xml_file = sprintf("./files/cache/document_category/%s.xml.php", $module_srl); |
1862 | 2094 | $php_file = sprintf("./files/cache/document_category/%s.php", $module_srl); |
@@ -1868,13 +2100,17 @@ discard block |
||
1868 | 2100 | |
1869 | 2101 | $category_list = $output->data; |
1870 | 2102 | |
1871 | - if(!is_array($category_list)) $category_list = array($category_list); |
|
2103 | + if(!is_array($category_list)) { |
|
2104 | + $category_list = array($category_list); |
|
2105 | + } |
|
1872 | 2106 | |
1873 | 2107 | $category_count = count($category_list); |
1874 | 2108 | for($i=0;$i<$category_count;$i++) |
1875 | 2109 | { |
1876 | 2110 | $category_srl = $category_list[$i]->category_srl; |
1877 | - if(!preg_match('/^[0-9,]+$/', $category_list[$i]->group_srls)) $category_list[$i]->group_srls = ''; |
|
2111 | + if(!preg_match('/^[0-9,]+$/', $category_list[$i]->group_srls)) { |
|
2112 | + $category_list[$i]->group_srls = ''; |
|
2113 | + } |
|
1878 | 2114 | $list[$category_srl] = $category_list[$i]; |
1879 | 2115 | } |
1880 | 2116 | // Create the xml file without node data if no data is obtained |
@@ -1886,7 +2122,9 @@ discard block |
||
1886 | 2122 | return $xml_file; |
1887 | 2123 | } |
1888 | 2124 | // Change to an array if only a single data is obtained |
1889 | - if(!is_array($list)) $list = array($list); |
|
2125 | + if(!is_array($list)) { |
|
2126 | + $list = array($list); |
|
2127 | + } |
|
1890 | 2128 | // Create a tree for loop |
1891 | 2129 | foreach($list as $category_srl => $node) |
1892 | 2130 | { |
@@ -1965,13 +2203,17 @@ discard block |
||
1965 | 2203 | */ |
1966 | 2204 | function getXmlTree($source_node, $tree, $site_srl, &$xml_header_buff) |
1967 | 2205 | { |
1968 | - if(!$source_node) return; |
|
2206 | + if(!$source_node) { |
|
2207 | + return; |
|
2208 | + } |
|
1969 | 2209 | |
1970 | 2210 | foreach($source_node as $category_srl => $node) |
1971 | 2211 | { |
1972 | 2212 | $child_buff = ""; |
1973 | 2213 | // Get data of the child nodes |
1974 | - if($category_srl && $tree[$category_srl]) $child_buff = $this->getXmlTree($tree[$category_srl], $tree, $site_srl, $xml_header_buff); |
|
2214 | + if($category_srl && $tree[$category_srl]) { |
|
2215 | + $child_buff = $this->getXmlTree($tree[$category_srl], $tree, $site_srl, $xml_header_buff); |
|
2216 | + } |
|
1975 | 2217 | // List variables |
1976 | 2218 | $expand = ($node->expand) ? $node->expand : 'N'; |
1977 | 2219 | $group_srls = ($node->group_srls) ? $node->group_srls : ''; |
@@ -1981,8 +2223,11 @@ discard block |
||
1981 | 2223 | $color = ($node->color) ? $node->color : ''; |
1982 | 2224 | $description = ($node->description) ? $node->description : ''; |
1983 | 2225 | // If node->group_srls value exists |
1984 | - if($group_srls) $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))',$group_srls); |
|
1985 | - else $group_check_code = "true"; |
|
2226 | + if($group_srls) { |
|
2227 | + $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))',$group_srls); |
|
2228 | + } else { |
|
2229 | + $group_check_code = "true"; |
|
2230 | + } |
|
1986 | 2231 | |
1987 | 2232 | $title = $node->title; |
1988 | 2233 | $oModuleAdminModel = getAdminModel('module'); |
@@ -2022,8 +2267,11 @@ discard block |
||
2022 | 2267 | $node->document_count |
2023 | 2268 | ); |
2024 | 2269 | |
2025 | - if($child_buff) $buff .= sprintf('<node %s>%s</node>', $attribute, $child_buff); |
|
2026 | - else $buff .= sprintf('<node %s />', $attribute); |
|
2270 | + if($child_buff) { |
|
2271 | + $buff .= sprintf('<node %s>%s</node>', $attribute, $child_buff); |
|
2272 | + } else { |
|
2273 | + $buff .= sprintf('<node %s />', $attribute); |
|
2274 | + } |
|
2027 | 2275 | } |
2028 | 2276 | return $buff; |
2029 | 2277 | } |
@@ -2042,7 +2290,9 @@ discard block |
||
2042 | 2290 | function getPhpCacheCode($source_node, $tree, $site_srl, &$php_header_buff) |
2043 | 2291 | { |
2044 | 2292 | $output = array("buff"=>"", "category_srl_list"=>array()); |
2045 | - if(!$source_node) return $output; |
|
2293 | + if(!$source_node) { |
|
2294 | + return $output; |
|
2295 | + } |
|
2046 | 2296 | |
2047 | 2297 | // Set to an arraty for looping and then generate php script codes to be included |
2048 | 2298 | foreach($source_node as $category_srl => $node) |
@@ -2141,7 +2391,9 @@ discard block |
||
2141 | 2391 | function addDocumentPopupMenu($url, $str, $icon = '', $target = 'self') |
2142 | 2392 | { |
2143 | 2393 | $document_popup_menu_list = Context::get('document_popup_menu_list'); |
2144 | - if(!is_array($document_popup_menu_list)) $document_popup_menu_list = array(); |
|
2394 | + if(!is_array($document_popup_menu_list)) { |
|
2395 | + $document_popup_menu_list = array(); |
|
2396 | + } |
|
2145 | 2397 | |
2146 | 2398 | $obj = new stdClass(); |
2147 | 2399 | $obj->url = $url; |
@@ -2159,7 +2411,9 @@ discard block |
||
2159 | 2411 | */ |
2160 | 2412 | function procDocumentAddCart() |
2161 | 2413 | { |
2162 | - if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_permitted'); |
|
2414 | + if(!Context::get('is_logged')) { |
|
2415 | + return new BaseObject(-1, 'msg_not_permitted'); |
|
2416 | + } |
|
2163 | 2417 | |
2164 | 2418 | // Get document_srl |
2165 | 2419 | $srls = explode(',',Context::get('srls')); |
@@ -2167,11 +2421,15 @@ discard block |
||
2167 | 2421 | { |
2168 | 2422 | $srl = trim($srls[$i]); |
2169 | 2423 | |
2170 | - if(!$srl) continue; |
|
2424 | + if(!$srl) { |
|
2425 | + continue; |
|
2426 | + } |
|
2171 | 2427 | |
2172 | 2428 | $document_srls[] = $srl; |
2173 | 2429 | } |
2174 | - if(!count($document_srls)) return; |
|
2430 | + if(!count($document_srls)) { |
|
2431 | + return; |
|
2432 | + } |
|
2175 | 2433 | |
2176 | 2434 | // Get module_srl of the documents |
2177 | 2435 | $args = new stdClass; |
@@ -2179,14 +2437,18 @@ discard block |
||
2179 | 2437 | $args->document_srls = implode(',',$document_srls); |
2180 | 2438 | $args->order_type = 'asc'; |
2181 | 2439 | $output = executeQueryArray('document.getDocuments', $args); |
2182 | - if(!$output->data) return new BaseObject(); |
|
2440 | + if(!$output->data) { |
|
2441 | + return new BaseObject(); |
|
2442 | + } |
|
2183 | 2443 | |
2184 | 2444 | unset($document_srls); |
2185 | 2445 | foreach($output->data as $key => $val) |
2186 | 2446 | { |
2187 | 2447 | $document_srls[$val->module_srl][] = $val->document_srl; |
2188 | 2448 | } |
2189 | - if(!$document_srls || !count($document_srls)) return new BaseObject(); |
|
2449 | + if(!$document_srls || !count($document_srls)) { |
|
2450 | + return new BaseObject(); |
|
2451 | + } |
|
2190 | 2452 | |
2191 | 2453 | // Check if each of module administrators exists. Top-level administator will have a permission to modify every document of all modules.(Even to modify temporarily saved or trashed documents) |
2192 | 2454 | $oModuleModel = getModel('module'); |
@@ -2211,7 +2473,9 @@ discard block |
||
2211 | 2473 | } |
2212 | 2474 | } |
2213 | 2475 | } |
2214 | - if(!count($document_srls)) return new BaseObject(); |
|
2476 | + if(!count($document_srls)) { |
|
2477 | + return new BaseObject(); |
|
2478 | + } |
|
2215 | 2479 | |
2216 | 2480 | foreach($document_srls as $module_srl => $documents) |
2217 | 2481 | { |
@@ -2219,9 +2483,14 @@ discard block |
||
2219 | 2483 | for($i=0;$i<$cnt;$i++) |
2220 | 2484 | { |
2221 | 2485 | $document_srl = (int)trim($documents[$i]); |
2222 | - if(!$document_srls) continue; |
|
2223 | - if($_SESSION['document_management'][$document_srl]) unset($_SESSION['document_management'][$document_srl]); |
|
2224 | - else $_SESSION['document_management'][$document_srl] = true; |
|
2486 | + if(!$document_srls) { |
|
2487 | + continue; |
|
2488 | + } |
|
2489 | + if($_SESSION['document_management'][$document_srl]) { |
|
2490 | + unset($_SESSION['document_management'][$document_srl]); |
|
2491 | + } else { |
|
2492 | + $_SESSION['document_management'][$document_srl] = true; |
|
2493 | + } |
|
2225 | 2494 | } |
2226 | 2495 | } |
2227 | 2496 | } |
@@ -2233,7 +2502,9 @@ discard block |
||
2233 | 2502 | function procDocumentManageCheckedDocument() |
2234 | 2503 | { |
2235 | 2504 | @set_time_limit(0); |
2236 | - if(!Context::get('is_logged')) return new BaseObject(-1,'msg_not_permitted'); |
|
2505 | + if(!Context::get('is_logged')) { |
|
2506 | + return new BaseObject(-1,'msg_not_permitted'); |
|
2507 | + } |
|
2237 | 2508 | |
2238 | 2509 | if(!checkCSRF()) |
2239 | 2510 | { |
@@ -2243,10 +2514,14 @@ discard block |
||
2243 | 2514 | $type = Context::get('type'); |
2244 | 2515 | $target_module = Context::get('target_module_srl'); |
2245 | 2516 | $module_srl = Context::get('module_srl'); |
2246 | - if($target_module && !$module_srl) $module_srl = $target_module; |
|
2517 | + if($target_module && !$module_srl) { |
|
2518 | + $module_srl = $target_module; |
|
2519 | + } |
|
2247 | 2520 | $category_srl = Context::get('target_category_srl'); |
2248 | 2521 | $message_content = strip_tags(Context::get('message_content')); |
2249 | - if($message_content) $message_content = nl2br($message_content); |
|
2522 | + if($message_content) { |
|
2523 | + $message_content = nl2br($message_content); |
|
2524 | + } |
|
2250 | 2525 | |
2251 | 2526 | $cart = Context::get('cart'); |
2252 | 2527 | $document_srl_list = (!is_array($cart)) ? explode('|@|', $cart) : $cart; |
@@ -2261,7 +2536,9 @@ discard block |
||
2261 | 2536 | { |
2262 | 2537 | $oDocument = $oDocumentModel->getDocument($document_srl); |
2263 | 2538 | $document_items[] = $oDocument; |
2264 | - if(!$oDocument->isGranted()) return $this->stop('msg_not_permitted'); |
|
2539 | + if(!$oDocument->isGranted()) { |
|
2540 | + return $this->stop('msg_not_permitted'); |
|
2541 | + } |
|
2265 | 2542 | } |
2266 | 2543 | |
2267 | 2544 | // Send a message |
@@ -2277,10 +2554,15 @@ discard block |
||
2277 | 2554 | |
2278 | 2555 | foreach($document_items as $oDocument) |
2279 | 2556 | { |
2280 | - if(!$oDocument->get('member_srl') || $oDocument->get('member_srl')==$sender_member_srl) continue; |
|
2557 | + if(!$oDocument->get('member_srl') || $oDocument->get('member_srl')==$sender_member_srl) { |
|
2558 | + continue; |
|
2559 | + } |
|
2281 | 2560 | |
2282 | - if($type=='move') $purl = sprintf("<a href=\"%s\" target=\"_blank\">%s</a>", $oDocument->getPermanentUrl(), $oDocument->getPermanentUrl()); |
|
2283 | - else $purl = ""; |
|
2561 | + if($type=='move') { |
|
2562 | + $purl = sprintf("<a href=\"%s\" target=\"_blank\">%s</a>", $oDocument->getPermanentUrl(), $oDocument->getPermanentUrl()); |
|
2563 | + } else { |
|
2564 | + $purl = ""; |
|
2565 | + } |
|
2284 | 2566 | $content = sprintf("<div>%s</div><hr />%s<div style=\"font-weight:bold\">%s</div>%s",$message_content, $purl, $oDocument->getTitleText(), $oDocument->getContent(false, false, false)); |
2285 | 2567 | |
2286 | 2568 | $oCommunicationController->sendMessage($sender_member_srl, $oDocument->get('member_srl'), $title, $content, false); |
@@ -2293,24 +2575,30 @@ discard block |
||
2293 | 2575 | $oDocumentAdminController = getAdminController('document'); |
2294 | 2576 | if($type == 'move') |
2295 | 2577 | { |
2296 | - if(!$module_srl) return new BaseObject(-1, 'fail_to_move'); |
|
2578 | + if(!$module_srl) { |
|
2579 | + return new BaseObject(-1, 'fail_to_move'); |
|
2580 | + } |
|
2297 | 2581 | |
2298 | 2582 | $output = $oDocumentAdminController->moveDocumentModule($document_srl_list, $module_srl, $category_srl); |
2299 | - if(!$output->toBool()) return new BaseObject(-1, 'fail_to_move'); |
|
2583 | + if(!$output->toBool()) { |
|
2584 | + return new BaseObject(-1, 'fail_to_move'); |
|
2585 | + } |
|
2300 | 2586 | |
2301 | 2587 | $msg_code = 'success_moved'; |
2302 | 2588 | |
2303 | - } |
|
2304 | - else if($type == 'copy') |
|
2589 | + } else if($type == 'copy') |
|
2305 | 2590 | { |
2306 | - if(!$module_srl) return new BaseObject(-1, 'fail_to_move'); |
|
2591 | + if(!$module_srl) { |
|
2592 | + return new BaseObject(-1, 'fail_to_move'); |
|
2593 | + } |
|
2307 | 2594 | |
2308 | 2595 | $output = $oDocumentAdminController->copyDocumentModule($document_srl_list, $module_srl, $category_srl); |
2309 | - if(!$output->toBool()) return new BaseObject(-1, 'fail_to_move'); |
|
2596 | + if(!$output->toBool()) { |
|
2597 | + return new BaseObject(-1, 'fail_to_move'); |
|
2598 | + } |
|
2310 | 2599 | |
2311 | 2600 | $msg_code = 'success_copied'; |
2312 | - } |
|
2313 | - else if($type =='delete') |
|
2601 | + } else if($type =='delete') |
|
2314 | 2602 | { |
2315 | 2603 | $oDB = &DB::getInstance(); |
2316 | 2604 | $oDB->begin(); |
@@ -2318,12 +2606,13 @@ discard block |
||
2318 | 2606 | { |
2319 | 2607 | $document_srl = $document_srl_list[$i]; |
2320 | 2608 | $output = $this->deleteDocument($document_srl, true); |
2321 | - if(!$output->toBool()) return new BaseObject(-1, 'fail_to_delete'); |
|
2609 | + if(!$output->toBool()) { |
|
2610 | + return new BaseObject(-1, 'fail_to_delete'); |
|
2611 | + } |
|
2322 | 2612 | } |
2323 | 2613 | $oDB->commit(); |
2324 | 2614 | $msg_code = 'success_deleted'; |
2325 | - } |
|
2326 | - else if($type == 'trash') |
|
2615 | + } else if($type == 'trash') |
|
2327 | 2616 | { |
2328 | 2617 | $args = new stdClass(); |
2329 | 2618 | $args->description = $message_content; |
@@ -2333,12 +2622,13 @@ discard block |
||
2333 | 2622 | for($i=0;$i<$document_srl_count;$i++) { |
2334 | 2623 | $args->document_srl = $document_srl_list[$i]; |
2335 | 2624 | $output = $this->moveDocumentToTrash($args); |
2336 | - if(!$output || !$output->toBool()) return new BaseObject(-1, 'fail_to_trash'); |
|
2625 | + if(!$output || !$output->toBool()) { |
|
2626 | + return new BaseObject(-1, 'fail_to_trash'); |
|
2627 | + } |
|
2337 | 2628 | } |
2338 | 2629 | $oDB->commit(); |
2339 | 2630 | $msg_code = 'success_trashed'; |
2340 | - } |
|
2341 | - else if($type == 'cancelDeclare') |
|
2631 | + } else if($type == 'cancelDeclare') |
|
2342 | 2632 | { |
2343 | 2633 | $args->document_srl = $document_srl_list; |
2344 | 2634 | $output = executeQuery('document.deleteDeclaredDocuments', $args); |
@@ -2360,18 +2650,27 @@ discard block |
||
2360 | 2650 | function procDocumentInsertModuleConfig() |
2361 | 2651 | { |
2362 | 2652 | $module_srl = Context::get('target_module_srl'); |
2363 | - if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl); |
|
2364 | - else $module_srl = array($module_srl); |
|
2653 | + if(preg_match('/^([0-9,]+)$/',$module_srl)) { |
|
2654 | + $module_srl = explode(',',$module_srl); |
|
2655 | + } else { |
|
2656 | + $module_srl = array($module_srl); |
|
2657 | + } |
|
2365 | 2658 | |
2366 | 2659 | $document_config = new stdClass(); |
2367 | 2660 | $document_config->use_history = Context::get('use_history'); |
2368 | - if(!$document_config->use_history) $document_config->use_history = 'N'; |
|
2661 | + if(!$document_config->use_history) { |
|
2662 | + $document_config->use_history = 'N'; |
|
2663 | + } |
|
2369 | 2664 | |
2370 | 2665 | $document_config->use_vote_up = Context::get('use_vote_up'); |
2371 | - if(!$document_config->use_vote_up) $document_config->use_vote_up = 'Y'; |
|
2666 | + if(!$document_config->use_vote_up) { |
|
2667 | + $document_config->use_vote_up = 'Y'; |
|
2668 | + } |
|
2372 | 2669 | |
2373 | 2670 | $document_config->use_vote_down = Context::get('use_vote_down'); |
2374 | - if(!$document_config->use_vote_down) $document_config->use_vote_down = 'Y'; |
|
2671 | + if(!$document_config->use_vote_down) { |
|
2672 | + $document_config->use_vote_down = 'Y'; |
|
2673 | + } |
|
2375 | 2674 | |
2376 | 2675 | $document_config->use_status = Context::get('use_status'); |
2377 | 2676 | |
@@ -2379,7 +2678,9 @@ discard block |
||
2379 | 2678 | for($i=0;$i<count($module_srl);$i++) |
2380 | 2679 | { |
2381 | 2680 | $srl = trim($module_srl[$i]); |
2382 | - if(!$srl) continue; |
|
2681 | + if(!$srl) { |
|
2682 | + continue; |
|
2683 | + } |
|
2383 | 2684 | $output = $oModuleController->insertModulePartConfig('document',$srl,$document_config); |
2384 | 2685 | } |
2385 | 2686 | $this->setError(-1); |
@@ -2396,7 +2697,9 @@ discard block |
||
2396 | 2697 | function procDocumentTempSave() |
2397 | 2698 | { |
2398 | 2699 | // Check login information |
2399 | - if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_logged'); |
|
2700 | + if(!Context::get('is_logged')) { |
|
2701 | + return new BaseObject(-1, 'msg_not_logged'); |
|
2702 | + } |
|
2400 | 2703 | $module_info = Context::get('module_info'); |
2401 | 2704 | $logged_info = Context::get('logged_info'); |
2402 | 2705 | |
@@ -2434,8 +2737,7 @@ discard block |
||
2434 | 2737 | $output = $oDocumentController->updateDocument($oDocument, $obj); |
2435 | 2738 | $msg_code = 'success_updated'; |
2436 | 2739 | // Otherwise, get a new |
2437 | - } |
|
2438 | - else |
|
2740 | + } else |
|
2439 | 2741 | { |
2440 | 2742 | $output = $oDocumentController->insertDocument($obj); |
2441 | 2743 | $msg_code = 'success_registed'; |
@@ -2461,17 +2763,20 @@ discard block |
||
2461 | 2763 | */ |
2462 | 2764 | function procDocumentGetList() |
2463 | 2765 | { |
2464 | - if(!Context::get('is_logged')) return new BaseObject(-1,'msg_not_permitted'); |
|
2766 | + if(!Context::get('is_logged')) { |
|
2767 | + return new BaseObject(-1,'msg_not_permitted'); |
|
2768 | + } |
|
2465 | 2769 | $documentSrls = Context::get('document_srls'); |
2466 | - if($documentSrls) $documentSrlList = explode(',', $documentSrls); |
|
2770 | + if($documentSrls) { |
|
2771 | + $documentSrlList = explode(',', $documentSrls); |
|
2772 | + } |
|
2467 | 2773 | |
2468 | 2774 | if(count($documentSrlList) > 0) |
2469 | 2775 | { |
2470 | 2776 | $oDocumentModel = getModel('document'); |
2471 | 2777 | $columnList = array('document_srl', 'title', 'nick_name', 'status'); |
2472 | 2778 | $documentList = $oDocumentModel->getDocuments($documentSrlList, $this->grant->is_admin, false, $columnList); |
2473 | - } |
|
2474 | - else |
|
2779 | + } else |
|
2475 | 2780 | { |
2476 | 2781 | global $lang; |
2477 | 2782 | $documentList = array(); |
@@ -2489,11 +2794,18 @@ discard block |
||
2489 | 2794 | */ |
2490 | 2795 | function _checkCommentStatusForOldVersion(&$obj) |
2491 | 2796 | { |
2492 | - if(!isset($obj->allow_comment)) $obj->allow_comment = 'N'; |
|
2493 | - if(!isset($obj->lock_comment)) $obj->lock_comment = 'N'; |
|
2797 | + if(!isset($obj->allow_comment)) { |
|
2798 | + $obj->allow_comment = 'N'; |
|
2799 | + } |
|
2800 | + if(!isset($obj->lock_comment)) { |
|
2801 | + $obj->lock_comment = 'N'; |
|
2802 | + } |
|
2494 | 2803 | |
2495 | - if($obj->allow_comment == 'Y' && $obj->lock_comment == 'N') $obj->commentStatus = 'ALLOW'; |
|
2496 | - else $obj->commentStatus = 'DENY'; |
|
2804 | + if($obj->allow_comment == 'Y' && $obj->lock_comment == 'N') { |
|
2805 | + $obj->commentStatus = 'ALLOW'; |
|
2806 | + } else { |
|
2807 | + $obj->commentStatus = 'DENY'; |
|
2808 | + } |
|
2497 | 2809 | } |
2498 | 2810 | |
2499 | 2811 | /** |
@@ -2503,8 +2815,12 @@ discard block |
||
2503 | 2815 | */ |
2504 | 2816 | function _checkDocumentStatusForOldVersion(&$obj) |
2505 | 2817 | { |
2506 | - if(!$obj->status && $obj->is_secret == 'Y') $obj->status = $this->getConfigStatus('secret'); |
|
2507 | - if(!$obj->status && $obj->is_secret != 'Y') $obj->status = $this->getConfigStatus('public'); |
|
2818 | + if(!$obj->status && $obj->is_secret == 'Y') { |
|
2819 | + $obj->status = $this->getConfigStatus('secret'); |
|
2820 | + } |
|
2821 | + if(!$obj->status && $obj->is_secret != 'Y') { |
|
2822 | + $obj->status = $this->getConfigStatus('public'); |
|
2823 | + } |
|
2508 | 2824 | } |
2509 | 2825 | |
2510 | 2826 | public function updateUploaedCount($documentSrlList) |
@@ -12,204 +12,204 @@ |
||
12 | 12 | |
13 | 13 | $__dir = dirname(__FILE__); |
14 | 14 | |
15 | -require_once $__dir . '/HTMLPurifier.php'; |
|
16 | -require_once $__dir . '/HTMLPurifier/AttrCollections.php'; |
|
17 | -require_once $__dir . '/HTMLPurifier/AttrDef.php'; |
|
18 | -require_once $__dir . '/HTMLPurifier/AttrTransform.php'; |
|
19 | -require_once $__dir . '/HTMLPurifier/AttrTypes.php'; |
|
20 | -require_once $__dir . '/HTMLPurifier/AttrValidator.php'; |
|
21 | -require_once $__dir . '/HTMLPurifier/Bootstrap.php'; |
|
22 | -require_once $__dir . '/HTMLPurifier/Definition.php'; |
|
23 | -require_once $__dir . '/HTMLPurifier/CSSDefinition.php'; |
|
24 | -require_once $__dir . '/HTMLPurifier/ChildDef.php'; |
|
25 | -require_once $__dir . '/HTMLPurifier/Config.php'; |
|
26 | -require_once $__dir . '/HTMLPurifier/ConfigSchema.php'; |
|
27 | -require_once $__dir . '/HTMLPurifier/ContentSets.php'; |
|
28 | -require_once $__dir . '/HTMLPurifier/Context.php'; |
|
29 | -require_once $__dir . '/HTMLPurifier/DefinitionCache.php'; |
|
30 | -require_once $__dir . '/HTMLPurifier/DefinitionCacheFactory.php'; |
|
31 | -require_once $__dir . '/HTMLPurifier/Doctype.php'; |
|
32 | -require_once $__dir . '/HTMLPurifier/DoctypeRegistry.php'; |
|
33 | -require_once $__dir . '/HTMLPurifier/ElementDef.php'; |
|
34 | -require_once $__dir . '/HTMLPurifier/Encoder.php'; |
|
35 | -require_once $__dir . '/HTMLPurifier/EntityLookup.php'; |
|
36 | -require_once $__dir . '/HTMLPurifier/EntityParser.php'; |
|
37 | -require_once $__dir . '/HTMLPurifier/ErrorCollector.php'; |
|
38 | -require_once $__dir . '/HTMLPurifier/ErrorStruct.php'; |
|
39 | -require_once $__dir . '/HTMLPurifier/Exception.php'; |
|
40 | -require_once $__dir . '/HTMLPurifier/Filter.php'; |
|
41 | -require_once $__dir . '/HTMLPurifier/Generator.php'; |
|
42 | -require_once $__dir . '/HTMLPurifier/HTMLDefinition.php'; |
|
43 | -require_once $__dir . '/HTMLPurifier/HTMLModule.php'; |
|
44 | -require_once $__dir . '/HTMLPurifier/HTMLModuleManager.php'; |
|
45 | -require_once $__dir . '/HTMLPurifier/IDAccumulator.php'; |
|
46 | -require_once $__dir . '/HTMLPurifier/Injector.php'; |
|
47 | -require_once $__dir . '/HTMLPurifier/Language.php'; |
|
48 | -require_once $__dir . '/HTMLPurifier/LanguageFactory.php'; |
|
49 | -require_once $__dir . '/HTMLPurifier/Length.php'; |
|
50 | -require_once $__dir . '/HTMLPurifier/Lexer.php'; |
|
51 | -require_once $__dir . '/HTMLPurifier/PercentEncoder.php'; |
|
52 | -require_once $__dir . '/HTMLPurifier/PropertyList.php'; |
|
53 | -require_once $__dir . '/HTMLPurifier/PropertyListIterator.php'; |
|
54 | -require_once $__dir . '/HTMLPurifier/Strategy.php'; |
|
55 | -require_once $__dir . '/HTMLPurifier/StringHash.php'; |
|
56 | -require_once $__dir . '/HTMLPurifier/StringHashParser.php'; |
|
57 | -require_once $__dir . '/HTMLPurifier/TagTransform.php'; |
|
58 | -require_once $__dir . '/HTMLPurifier/Token.php'; |
|
59 | -require_once $__dir . '/HTMLPurifier/TokenFactory.php'; |
|
60 | -require_once $__dir . '/HTMLPurifier/URI.php'; |
|
61 | -require_once $__dir . '/HTMLPurifier/URIDefinition.php'; |
|
62 | -require_once $__dir . '/HTMLPurifier/URIFilter.php'; |
|
63 | -require_once $__dir . '/HTMLPurifier/URIParser.php'; |
|
64 | -require_once $__dir . '/HTMLPurifier/URIScheme.php'; |
|
65 | -require_once $__dir . '/HTMLPurifier/URISchemeRegistry.php'; |
|
66 | -require_once $__dir . '/HTMLPurifier/UnitConverter.php'; |
|
67 | -require_once $__dir . '/HTMLPurifier/VarParser.php'; |
|
68 | -require_once $__dir . '/HTMLPurifier/VarParserException.php'; |
|
69 | -require_once $__dir . '/HTMLPurifier/AttrDef/CSS.php'; |
|
70 | -require_once $__dir . '/HTMLPurifier/AttrDef/Clone.php'; |
|
71 | -require_once $__dir . '/HTMLPurifier/AttrDef/Enum.php'; |
|
72 | -require_once $__dir . '/HTMLPurifier/AttrDef/Integer.php'; |
|
73 | -require_once $__dir . '/HTMLPurifier/AttrDef/Lang.php'; |
|
74 | -require_once $__dir . '/HTMLPurifier/AttrDef/Switch.php'; |
|
75 | -require_once $__dir . '/HTMLPurifier/AttrDef/Text.php'; |
|
76 | -require_once $__dir . '/HTMLPurifier/AttrDef/URI.php'; |
|
77 | -require_once $__dir . '/HTMLPurifier/AttrDef/CSS/Number.php'; |
|
78 | -require_once $__dir . '/HTMLPurifier/AttrDef/CSS/AlphaValue.php'; |
|
79 | -require_once $__dir . '/HTMLPurifier/AttrDef/CSS/Background.php'; |
|
80 | -require_once $__dir . '/HTMLPurifier/AttrDef/CSS/BackgroundPosition.php'; |
|
81 | -require_once $__dir . '/HTMLPurifier/AttrDef/CSS/Border.php'; |
|
82 | -require_once $__dir . '/HTMLPurifier/AttrDef/CSS/Color.php'; |
|
83 | -require_once $__dir . '/HTMLPurifier/AttrDef/CSS/Composite.php'; |
|
84 | -require_once $__dir . '/HTMLPurifier/AttrDef/CSS/DenyElementDecorator.php'; |
|
85 | -require_once $__dir . '/HTMLPurifier/AttrDef/CSS/Filter.php'; |
|
86 | -require_once $__dir . '/HTMLPurifier/AttrDef/CSS/Font.php'; |
|
87 | -require_once $__dir . '/HTMLPurifier/AttrDef/CSS/FontFamily.php'; |
|
88 | -require_once $__dir . '/HTMLPurifier/AttrDef/CSS/Ident.php'; |
|
89 | -require_once $__dir . '/HTMLPurifier/AttrDef/CSS/ImportantDecorator.php'; |
|
90 | -require_once $__dir . '/HTMLPurifier/AttrDef/CSS/Length.php'; |
|
91 | -require_once $__dir . '/HTMLPurifier/AttrDef/CSS/ListStyle.php'; |
|
92 | -require_once $__dir . '/HTMLPurifier/AttrDef/CSS/Multiple.php'; |
|
93 | -require_once $__dir . '/HTMLPurifier/AttrDef/CSS/Percentage.php'; |
|
94 | -require_once $__dir . '/HTMLPurifier/AttrDef/CSS/TextDecoration.php'; |
|
95 | -require_once $__dir . '/HTMLPurifier/AttrDef/CSS/URI.php'; |
|
96 | -require_once $__dir . '/HTMLPurifier/AttrDef/HTML/Bool.php'; |
|
97 | -require_once $__dir . '/HTMLPurifier/AttrDef/HTML/Nmtokens.php'; |
|
98 | -require_once $__dir . '/HTMLPurifier/AttrDef/HTML/Class.php'; |
|
99 | -require_once $__dir . '/HTMLPurifier/AttrDef/HTML/Color.php'; |
|
100 | -require_once $__dir . '/HTMLPurifier/AttrDef/HTML/FrameTarget.php'; |
|
101 | -require_once $__dir . '/HTMLPurifier/AttrDef/HTML/ID.php'; |
|
102 | -require_once $__dir . '/HTMLPurifier/AttrDef/HTML/Pixels.php'; |
|
103 | -require_once $__dir . '/HTMLPurifier/AttrDef/HTML/Length.php'; |
|
104 | -require_once $__dir . '/HTMLPurifier/AttrDef/HTML/LinkTypes.php'; |
|
105 | -require_once $__dir . '/HTMLPurifier/AttrDef/HTML/MultiLength.php'; |
|
106 | -require_once $__dir . '/HTMLPurifier/AttrDef/URI/Email.php'; |
|
107 | -require_once $__dir . '/HTMLPurifier/AttrDef/URI/Host.php'; |
|
108 | -require_once $__dir . '/HTMLPurifier/AttrDef/URI/IPv4.php'; |
|
109 | -require_once $__dir . '/HTMLPurifier/AttrDef/URI/IPv6.php'; |
|
110 | -require_once $__dir . '/HTMLPurifier/AttrDef/URI/Email/SimpleCheck.php'; |
|
111 | -require_once $__dir . '/HTMLPurifier/AttrTransform/Background.php'; |
|
112 | -require_once $__dir . '/HTMLPurifier/AttrTransform/BdoDir.php'; |
|
113 | -require_once $__dir . '/HTMLPurifier/AttrTransform/BgColor.php'; |
|
114 | -require_once $__dir . '/HTMLPurifier/AttrTransform/BoolToCSS.php'; |
|
115 | -require_once $__dir . '/HTMLPurifier/AttrTransform/Border.php'; |
|
116 | -require_once $__dir . '/HTMLPurifier/AttrTransform/EnumToCSS.php'; |
|
117 | -require_once $__dir . '/HTMLPurifier/AttrTransform/ImgRequired.php'; |
|
118 | -require_once $__dir . '/HTMLPurifier/AttrTransform/ImgSpace.php'; |
|
119 | -require_once $__dir . '/HTMLPurifier/AttrTransform/Input.php'; |
|
120 | -require_once $__dir . '/HTMLPurifier/AttrTransform/Lang.php'; |
|
121 | -require_once $__dir . '/HTMLPurifier/AttrTransform/Length.php'; |
|
122 | -require_once $__dir . '/HTMLPurifier/AttrTransform/Name.php'; |
|
123 | -require_once $__dir . '/HTMLPurifier/AttrTransform/NameSync.php'; |
|
124 | -require_once $__dir . '/HTMLPurifier/AttrTransform/Nofollow.php'; |
|
125 | -require_once $__dir . '/HTMLPurifier/AttrTransform/SafeEmbed.php'; |
|
126 | -require_once $__dir . '/HTMLPurifier/AttrTransform/SafeObject.php'; |
|
127 | -require_once $__dir . '/HTMLPurifier/AttrTransform/SafeParam.php'; |
|
128 | -require_once $__dir . '/HTMLPurifier/AttrTransform/ScriptRequired.php'; |
|
129 | -require_once $__dir . '/HTMLPurifier/AttrTransform/TargetBlank.php'; |
|
130 | -require_once $__dir . '/HTMLPurifier/AttrTransform/Textarea.php'; |
|
131 | -require_once $__dir . '/HTMLPurifier/ChildDef/Chameleon.php'; |
|
132 | -require_once $__dir . '/HTMLPurifier/ChildDef/Custom.php'; |
|
133 | -require_once $__dir . '/HTMLPurifier/ChildDef/Empty.php'; |
|
134 | -require_once $__dir . '/HTMLPurifier/ChildDef/List.php'; |
|
135 | -require_once $__dir . '/HTMLPurifier/ChildDef/Required.php'; |
|
136 | -require_once $__dir . '/HTMLPurifier/ChildDef/Optional.php'; |
|
137 | -require_once $__dir . '/HTMLPurifier/ChildDef/StrictBlockquote.php'; |
|
138 | -require_once $__dir . '/HTMLPurifier/ChildDef/Table.php'; |
|
139 | -require_once $__dir . '/HTMLPurifier/DefinitionCache/Decorator.php'; |
|
140 | -require_once $__dir . '/HTMLPurifier/DefinitionCache/Null.php'; |
|
141 | -require_once $__dir . '/HTMLPurifier/DefinitionCache/Serializer.php'; |
|
142 | -require_once $__dir . '/HTMLPurifier/DefinitionCache/Decorator/Cleanup.php'; |
|
143 | -require_once $__dir . '/HTMLPurifier/DefinitionCache/Decorator/Memory.php'; |
|
144 | -require_once $__dir . '/HTMLPurifier/HTMLModule/Bdo.php'; |
|
145 | -require_once $__dir . '/HTMLPurifier/HTMLModule/CommonAttributes.php'; |
|
146 | -require_once $__dir . '/HTMLPurifier/HTMLModule/Edit.php'; |
|
147 | -require_once $__dir . '/HTMLPurifier/HTMLModule/Forms.php'; |
|
148 | -require_once $__dir . '/HTMLPurifier/HTMLModule/Hypertext.php'; |
|
149 | -require_once $__dir . '/HTMLPurifier/HTMLModule/Iframe.php'; |
|
150 | -require_once $__dir . '/HTMLPurifier/HTMLModule/Image.php'; |
|
151 | -require_once $__dir . '/HTMLPurifier/HTMLModule/Legacy.php'; |
|
152 | -require_once $__dir . '/HTMLPurifier/HTMLModule/List.php'; |
|
153 | -require_once $__dir . '/HTMLPurifier/HTMLModule/Name.php'; |
|
154 | -require_once $__dir . '/HTMLPurifier/HTMLModule/Nofollow.php'; |
|
155 | -require_once $__dir . '/HTMLPurifier/HTMLModule/NonXMLCommonAttributes.php'; |
|
156 | -require_once $__dir . '/HTMLPurifier/HTMLModule/Object.php'; |
|
157 | -require_once $__dir . '/HTMLPurifier/HTMLModule/Presentation.php'; |
|
158 | -require_once $__dir . '/HTMLPurifier/HTMLModule/Proprietary.php'; |
|
159 | -require_once $__dir . '/HTMLPurifier/HTMLModule/Ruby.php'; |
|
160 | -require_once $__dir . '/HTMLPurifier/HTMLModule/SafeEmbed.php'; |
|
161 | -require_once $__dir . '/HTMLPurifier/HTMLModule/SafeObject.php'; |
|
162 | -require_once $__dir . '/HTMLPurifier/HTMLModule/Scripting.php'; |
|
163 | -require_once $__dir . '/HTMLPurifier/HTMLModule/StyleAttribute.php'; |
|
164 | -require_once $__dir . '/HTMLPurifier/HTMLModule/Tables.php'; |
|
165 | -require_once $__dir . '/HTMLPurifier/HTMLModule/Target.php'; |
|
166 | -require_once $__dir . '/HTMLPurifier/HTMLModule/TargetBlank.php'; |
|
167 | -require_once $__dir . '/HTMLPurifier/HTMLModule/Text.php'; |
|
168 | -require_once $__dir . '/HTMLPurifier/HTMLModule/Tidy.php'; |
|
169 | -require_once $__dir . '/HTMLPurifier/HTMLModule/XMLCommonAttributes.php'; |
|
170 | -require_once $__dir . '/HTMLPurifier/HTMLModule/Tidy/Name.php'; |
|
171 | -require_once $__dir . '/HTMLPurifier/HTMLModule/Tidy/Proprietary.php'; |
|
172 | -require_once $__dir . '/HTMLPurifier/HTMLModule/Tidy/XHTMLAndHTML4.php'; |
|
173 | -require_once $__dir . '/HTMLPurifier/HTMLModule/Tidy/Strict.php'; |
|
174 | -require_once $__dir . '/HTMLPurifier/HTMLModule/Tidy/Transitional.php'; |
|
175 | -require_once $__dir . '/HTMLPurifier/HTMLModule/Tidy/XHTML.php'; |
|
176 | -require_once $__dir . '/HTMLPurifier/Injector/AutoParagraph.php'; |
|
177 | -require_once $__dir . '/HTMLPurifier/Injector/DisplayLinkURI.php'; |
|
178 | -require_once $__dir . '/HTMLPurifier/Injector/Linkify.php'; |
|
179 | -require_once $__dir . '/HTMLPurifier/Injector/PurifierLinkify.php'; |
|
180 | -require_once $__dir . '/HTMLPurifier/Injector/RemoveEmpty.php'; |
|
181 | -require_once $__dir . '/HTMLPurifier/Injector/RemoveSpansWithoutAttributes.php'; |
|
182 | -require_once $__dir . '/HTMLPurifier/Injector/SafeObject.php'; |
|
183 | -require_once $__dir . '/HTMLPurifier/Lexer/DOMLex.php'; |
|
184 | -require_once $__dir . '/HTMLPurifier/Lexer/DirectLex.php'; |
|
185 | -require_once $__dir . '/HTMLPurifier/Strategy/Composite.php'; |
|
186 | -require_once $__dir . '/HTMLPurifier/Strategy/Core.php'; |
|
187 | -require_once $__dir . '/HTMLPurifier/Strategy/FixNesting.php'; |
|
188 | -require_once $__dir . '/HTMLPurifier/Strategy/MakeWellFormed.php'; |
|
189 | -require_once $__dir . '/HTMLPurifier/Strategy/RemoveForeignElements.php'; |
|
190 | -require_once $__dir . '/HTMLPurifier/Strategy/ValidateAttributes.php'; |
|
191 | -require_once $__dir . '/HTMLPurifier/TagTransform/Font.php'; |
|
192 | -require_once $__dir . '/HTMLPurifier/TagTransform/Simple.php'; |
|
193 | -require_once $__dir . '/HTMLPurifier/Token/Comment.php'; |
|
194 | -require_once $__dir . '/HTMLPurifier/Token/Tag.php'; |
|
195 | -require_once $__dir . '/HTMLPurifier/Token/Empty.php'; |
|
196 | -require_once $__dir . '/HTMLPurifier/Token/End.php'; |
|
197 | -require_once $__dir . '/HTMLPurifier/Token/Start.php'; |
|
198 | -require_once $__dir . '/HTMLPurifier/Token/Text.php'; |
|
199 | -require_once $__dir . '/HTMLPurifier/URIFilter/DisableExternal.php'; |
|
200 | -require_once $__dir . '/HTMLPurifier/URIFilter/DisableExternalResources.php'; |
|
201 | -require_once $__dir . '/HTMLPurifier/URIFilter/DisableResources.php'; |
|
202 | -require_once $__dir . '/HTMLPurifier/URIFilter/HostBlacklist.php'; |
|
203 | -require_once $__dir . '/HTMLPurifier/URIFilter/MakeAbsolute.php'; |
|
204 | -require_once $__dir . '/HTMLPurifier/URIFilter/Munge.php'; |
|
205 | -require_once $__dir . '/HTMLPurifier/URIFilter/SafeIframe.php'; |
|
206 | -require_once $__dir . '/HTMLPurifier/URIScheme/data.php'; |
|
207 | -require_once $__dir . '/HTMLPurifier/URIScheme/file.php'; |
|
208 | -require_once $__dir . '/HTMLPurifier/URIScheme/ftp.php'; |
|
209 | -require_once $__dir . '/HTMLPurifier/URIScheme/http.php'; |
|
210 | -require_once $__dir . '/HTMLPurifier/URIScheme/https.php'; |
|
211 | -require_once $__dir . '/HTMLPurifier/URIScheme/mailto.php'; |
|
212 | -require_once $__dir . '/HTMLPurifier/URIScheme/news.php'; |
|
213 | -require_once $__dir . '/HTMLPurifier/URIScheme/nntp.php'; |
|
214 | -require_once $__dir . '/HTMLPurifier/VarParser/Flexible.php'; |
|
215 | -require_once $__dir . '/HTMLPurifier/VarParser/Native.php'; |
|
15 | +require_once $__dir.'/HTMLPurifier.php'; |
|
16 | +require_once $__dir.'/HTMLPurifier/AttrCollections.php'; |
|
17 | +require_once $__dir.'/HTMLPurifier/AttrDef.php'; |
|
18 | +require_once $__dir.'/HTMLPurifier/AttrTransform.php'; |
|
19 | +require_once $__dir.'/HTMLPurifier/AttrTypes.php'; |
|
20 | +require_once $__dir.'/HTMLPurifier/AttrValidator.php'; |
|
21 | +require_once $__dir.'/HTMLPurifier/Bootstrap.php'; |
|
22 | +require_once $__dir.'/HTMLPurifier/Definition.php'; |
|
23 | +require_once $__dir.'/HTMLPurifier/CSSDefinition.php'; |
|
24 | +require_once $__dir.'/HTMLPurifier/ChildDef.php'; |
|
25 | +require_once $__dir.'/HTMLPurifier/Config.php'; |
|
26 | +require_once $__dir.'/HTMLPurifier/ConfigSchema.php'; |
|
27 | +require_once $__dir.'/HTMLPurifier/ContentSets.php'; |
|
28 | +require_once $__dir.'/HTMLPurifier/Context.php'; |
|
29 | +require_once $__dir.'/HTMLPurifier/DefinitionCache.php'; |
|
30 | +require_once $__dir.'/HTMLPurifier/DefinitionCacheFactory.php'; |
|
31 | +require_once $__dir.'/HTMLPurifier/Doctype.php'; |
|
32 | +require_once $__dir.'/HTMLPurifier/DoctypeRegistry.php'; |
|
33 | +require_once $__dir.'/HTMLPurifier/ElementDef.php'; |
|
34 | +require_once $__dir.'/HTMLPurifier/Encoder.php'; |
|
35 | +require_once $__dir.'/HTMLPurifier/EntityLookup.php'; |
|
36 | +require_once $__dir.'/HTMLPurifier/EntityParser.php'; |
|
37 | +require_once $__dir.'/HTMLPurifier/ErrorCollector.php'; |
|
38 | +require_once $__dir.'/HTMLPurifier/ErrorStruct.php'; |
|
39 | +require_once $__dir.'/HTMLPurifier/Exception.php'; |
|
40 | +require_once $__dir.'/HTMLPurifier/Filter.php'; |
|
41 | +require_once $__dir.'/HTMLPurifier/Generator.php'; |
|
42 | +require_once $__dir.'/HTMLPurifier/HTMLDefinition.php'; |
|
43 | +require_once $__dir.'/HTMLPurifier/HTMLModule.php'; |
|
44 | +require_once $__dir.'/HTMLPurifier/HTMLModuleManager.php'; |
|
45 | +require_once $__dir.'/HTMLPurifier/IDAccumulator.php'; |
|
46 | +require_once $__dir.'/HTMLPurifier/Injector.php'; |
|
47 | +require_once $__dir.'/HTMLPurifier/Language.php'; |
|
48 | +require_once $__dir.'/HTMLPurifier/LanguageFactory.php'; |
|
49 | +require_once $__dir.'/HTMLPurifier/Length.php'; |
|
50 | +require_once $__dir.'/HTMLPurifier/Lexer.php'; |
|
51 | +require_once $__dir.'/HTMLPurifier/PercentEncoder.php'; |
|
52 | +require_once $__dir.'/HTMLPurifier/PropertyList.php'; |
|
53 | +require_once $__dir.'/HTMLPurifier/PropertyListIterator.php'; |
|
54 | +require_once $__dir.'/HTMLPurifier/Strategy.php'; |
|
55 | +require_once $__dir.'/HTMLPurifier/StringHash.php'; |
|
56 | +require_once $__dir.'/HTMLPurifier/StringHashParser.php'; |
|
57 | +require_once $__dir.'/HTMLPurifier/TagTransform.php'; |
|
58 | +require_once $__dir.'/HTMLPurifier/Token.php'; |
|
59 | +require_once $__dir.'/HTMLPurifier/TokenFactory.php'; |
|
60 | +require_once $__dir.'/HTMLPurifier/URI.php'; |
|
61 | +require_once $__dir.'/HTMLPurifier/URIDefinition.php'; |
|
62 | +require_once $__dir.'/HTMLPurifier/URIFilter.php'; |
|
63 | +require_once $__dir.'/HTMLPurifier/URIParser.php'; |
|
64 | +require_once $__dir.'/HTMLPurifier/URIScheme.php'; |
|
65 | +require_once $__dir.'/HTMLPurifier/URISchemeRegistry.php'; |
|
66 | +require_once $__dir.'/HTMLPurifier/UnitConverter.php'; |
|
67 | +require_once $__dir.'/HTMLPurifier/VarParser.php'; |
|
68 | +require_once $__dir.'/HTMLPurifier/VarParserException.php'; |
|
69 | +require_once $__dir.'/HTMLPurifier/AttrDef/CSS.php'; |
|
70 | +require_once $__dir.'/HTMLPurifier/AttrDef/Clone.php'; |
|
71 | +require_once $__dir.'/HTMLPurifier/AttrDef/Enum.php'; |
|
72 | +require_once $__dir.'/HTMLPurifier/AttrDef/Integer.php'; |
|
73 | +require_once $__dir.'/HTMLPurifier/AttrDef/Lang.php'; |
|
74 | +require_once $__dir.'/HTMLPurifier/AttrDef/Switch.php'; |
|
75 | +require_once $__dir.'/HTMLPurifier/AttrDef/Text.php'; |
|
76 | +require_once $__dir.'/HTMLPurifier/AttrDef/URI.php'; |
|
77 | +require_once $__dir.'/HTMLPurifier/AttrDef/CSS/Number.php'; |
|
78 | +require_once $__dir.'/HTMLPurifier/AttrDef/CSS/AlphaValue.php'; |
|
79 | +require_once $__dir.'/HTMLPurifier/AttrDef/CSS/Background.php'; |
|
80 | +require_once $__dir.'/HTMLPurifier/AttrDef/CSS/BackgroundPosition.php'; |
|
81 | +require_once $__dir.'/HTMLPurifier/AttrDef/CSS/Border.php'; |
|
82 | +require_once $__dir.'/HTMLPurifier/AttrDef/CSS/Color.php'; |
|
83 | +require_once $__dir.'/HTMLPurifier/AttrDef/CSS/Composite.php'; |
|
84 | +require_once $__dir.'/HTMLPurifier/AttrDef/CSS/DenyElementDecorator.php'; |
|
85 | +require_once $__dir.'/HTMLPurifier/AttrDef/CSS/Filter.php'; |
|
86 | +require_once $__dir.'/HTMLPurifier/AttrDef/CSS/Font.php'; |
|
87 | +require_once $__dir.'/HTMLPurifier/AttrDef/CSS/FontFamily.php'; |
|
88 | +require_once $__dir.'/HTMLPurifier/AttrDef/CSS/Ident.php'; |
|
89 | +require_once $__dir.'/HTMLPurifier/AttrDef/CSS/ImportantDecorator.php'; |
|
90 | +require_once $__dir.'/HTMLPurifier/AttrDef/CSS/Length.php'; |
|
91 | +require_once $__dir.'/HTMLPurifier/AttrDef/CSS/ListStyle.php'; |
|
92 | +require_once $__dir.'/HTMLPurifier/AttrDef/CSS/Multiple.php'; |
|
93 | +require_once $__dir.'/HTMLPurifier/AttrDef/CSS/Percentage.php'; |
|
94 | +require_once $__dir.'/HTMLPurifier/AttrDef/CSS/TextDecoration.php'; |
|
95 | +require_once $__dir.'/HTMLPurifier/AttrDef/CSS/URI.php'; |
|
96 | +require_once $__dir.'/HTMLPurifier/AttrDef/HTML/Bool.php'; |
|
97 | +require_once $__dir.'/HTMLPurifier/AttrDef/HTML/Nmtokens.php'; |
|
98 | +require_once $__dir.'/HTMLPurifier/AttrDef/HTML/Class.php'; |
|
99 | +require_once $__dir.'/HTMLPurifier/AttrDef/HTML/Color.php'; |
|
100 | +require_once $__dir.'/HTMLPurifier/AttrDef/HTML/FrameTarget.php'; |
|
101 | +require_once $__dir.'/HTMLPurifier/AttrDef/HTML/ID.php'; |
|
102 | +require_once $__dir.'/HTMLPurifier/AttrDef/HTML/Pixels.php'; |
|
103 | +require_once $__dir.'/HTMLPurifier/AttrDef/HTML/Length.php'; |
|
104 | +require_once $__dir.'/HTMLPurifier/AttrDef/HTML/LinkTypes.php'; |
|
105 | +require_once $__dir.'/HTMLPurifier/AttrDef/HTML/MultiLength.php'; |
|
106 | +require_once $__dir.'/HTMLPurifier/AttrDef/URI/Email.php'; |
|
107 | +require_once $__dir.'/HTMLPurifier/AttrDef/URI/Host.php'; |
|
108 | +require_once $__dir.'/HTMLPurifier/AttrDef/URI/IPv4.php'; |
|
109 | +require_once $__dir.'/HTMLPurifier/AttrDef/URI/IPv6.php'; |
|
110 | +require_once $__dir.'/HTMLPurifier/AttrDef/URI/Email/SimpleCheck.php'; |
|
111 | +require_once $__dir.'/HTMLPurifier/AttrTransform/Background.php'; |
|
112 | +require_once $__dir.'/HTMLPurifier/AttrTransform/BdoDir.php'; |
|
113 | +require_once $__dir.'/HTMLPurifier/AttrTransform/BgColor.php'; |
|
114 | +require_once $__dir.'/HTMLPurifier/AttrTransform/BoolToCSS.php'; |
|
115 | +require_once $__dir.'/HTMLPurifier/AttrTransform/Border.php'; |
|
116 | +require_once $__dir.'/HTMLPurifier/AttrTransform/EnumToCSS.php'; |
|
117 | +require_once $__dir.'/HTMLPurifier/AttrTransform/ImgRequired.php'; |
|
118 | +require_once $__dir.'/HTMLPurifier/AttrTransform/ImgSpace.php'; |
|
119 | +require_once $__dir.'/HTMLPurifier/AttrTransform/Input.php'; |
|
120 | +require_once $__dir.'/HTMLPurifier/AttrTransform/Lang.php'; |
|
121 | +require_once $__dir.'/HTMLPurifier/AttrTransform/Length.php'; |
|
122 | +require_once $__dir.'/HTMLPurifier/AttrTransform/Name.php'; |
|
123 | +require_once $__dir.'/HTMLPurifier/AttrTransform/NameSync.php'; |
|
124 | +require_once $__dir.'/HTMLPurifier/AttrTransform/Nofollow.php'; |
|
125 | +require_once $__dir.'/HTMLPurifier/AttrTransform/SafeEmbed.php'; |
|
126 | +require_once $__dir.'/HTMLPurifier/AttrTransform/SafeObject.php'; |
|
127 | +require_once $__dir.'/HTMLPurifier/AttrTransform/SafeParam.php'; |
|
128 | +require_once $__dir.'/HTMLPurifier/AttrTransform/ScriptRequired.php'; |
|
129 | +require_once $__dir.'/HTMLPurifier/AttrTransform/TargetBlank.php'; |
|
130 | +require_once $__dir.'/HTMLPurifier/AttrTransform/Textarea.php'; |
|
131 | +require_once $__dir.'/HTMLPurifier/ChildDef/Chameleon.php'; |
|
132 | +require_once $__dir.'/HTMLPurifier/ChildDef/Custom.php'; |
|
133 | +require_once $__dir.'/HTMLPurifier/ChildDef/Empty.php'; |
|
134 | +require_once $__dir.'/HTMLPurifier/ChildDef/List.php'; |
|
135 | +require_once $__dir.'/HTMLPurifier/ChildDef/Required.php'; |
|
136 | +require_once $__dir.'/HTMLPurifier/ChildDef/Optional.php'; |
|
137 | +require_once $__dir.'/HTMLPurifier/ChildDef/StrictBlockquote.php'; |
|
138 | +require_once $__dir.'/HTMLPurifier/ChildDef/Table.php'; |
|
139 | +require_once $__dir.'/HTMLPurifier/DefinitionCache/Decorator.php'; |
|
140 | +require_once $__dir.'/HTMLPurifier/DefinitionCache/Null.php'; |
|
141 | +require_once $__dir.'/HTMLPurifier/DefinitionCache/Serializer.php'; |
|
142 | +require_once $__dir.'/HTMLPurifier/DefinitionCache/Decorator/Cleanup.php'; |
|
143 | +require_once $__dir.'/HTMLPurifier/DefinitionCache/Decorator/Memory.php'; |
|
144 | +require_once $__dir.'/HTMLPurifier/HTMLModule/Bdo.php'; |
|
145 | +require_once $__dir.'/HTMLPurifier/HTMLModule/CommonAttributes.php'; |
|
146 | +require_once $__dir.'/HTMLPurifier/HTMLModule/Edit.php'; |
|
147 | +require_once $__dir.'/HTMLPurifier/HTMLModule/Forms.php'; |
|
148 | +require_once $__dir.'/HTMLPurifier/HTMLModule/Hypertext.php'; |
|
149 | +require_once $__dir.'/HTMLPurifier/HTMLModule/Iframe.php'; |
|
150 | +require_once $__dir.'/HTMLPurifier/HTMLModule/Image.php'; |
|
151 | +require_once $__dir.'/HTMLPurifier/HTMLModule/Legacy.php'; |
|
152 | +require_once $__dir.'/HTMLPurifier/HTMLModule/List.php'; |
|
153 | +require_once $__dir.'/HTMLPurifier/HTMLModule/Name.php'; |
|
154 | +require_once $__dir.'/HTMLPurifier/HTMLModule/Nofollow.php'; |
|
155 | +require_once $__dir.'/HTMLPurifier/HTMLModule/NonXMLCommonAttributes.php'; |
|
156 | +require_once $__dir.'/HTMLPurifier/HTMLModule/Object.php'; |
|
157 | +require_once $__dir.'/HTMLPurifier/HTMLModule/Presentation.php'; |
|
158 | +require_once $__dir.'/HTMLPurifier/HTMLModule/Proprietary.php'; |
|
159 | +require_once $__dir.'/HTMLPurifier/HTMLModule/Ruby.php'; |
|
160 | +require_once $__dir.'/HTMLPurifier/HTMLModule/SafeEmbed.php'; |
|
161 | +require_once $__dir.'/HTMLPurifier/HTMLModule/SafeObject.php'; |
|
162 | +require_once $__dir.'/HTMLPurifier/HTMLModule/Scripting.php'; |
|
163 | +require_once $__dir.'/HTMLPurifier/HTMLModule/StyleAttribute.php'; |
|
164 | +require_once $__dir.'/HTMLPurifier/HTMLModule/Tables.php'; |
|
165 | +require_once $__dir.'/HTMLPurifier/HTMLModule/Target.php'; |
|
166 | +require_once $__dir.'/HTMLPurifier/HTMLModule/TargetBlank.php'; |
|
167 | +require_once $__dir.'/HTMLPurifier/HTMLModule/Text.php'; |
|
168 | +require_once $__dir.'/HTMLPurifier/HTMLModule/Tidy.php'; |
|
169 | +require_once $__dir.'/HTMLPurifier/HTMLModule/XMLCommonAttributes.php'; |
|
170 | +require_once $__dir.'/HTMLPurifier/HTMLModule/Tidy/Name.php'; |
|
171 | +require_once $__dir.'/HTMLPurifier/HTMLModule/Tidy/Proprietary.php'; |
|
172 | +require_once $__dir.'/HTMLPurifier/HTMLModule/Tidy/XHTMLAndHTML4.php'; |
|
173 | +require_once $__dir.'/HTMLPurifier/HTMLModule/Tidy/Strict.php'; |
|
174 | +require_once $__dir.'/HTMLPurifier/HTMLModule/Tidy/Transitional.php'; |
|
175 | +require_once $__dir.'/HTMLPurifier/HTMLModule/Tidy/XHTML.php'; |
|
176 | +require_once $__dir.'/HTMLPurifier/Injector/AutoParagraph.php'; |
|
177 | +require_once $__dir.'/HTMLPurifier/Injector/DisplayLinkURI.php'; |
|
178 | +require_once $__dir.'/HTMLPurifier/Injector/Linkify.php'; |
|
179 | +require_once $__dir.'/HTMLPurifier/Injector/PurifierLinkify.php'; |
|
180 | +require_once $__dir.'/HTMLPurifier/Injector/RemoveEmpty.php'; |
|
181 | +require_once $__dir.'/HTMLPurifier/Injector/RemoveSpansWithoutAttributes.php'; |
|
182 | +require_once $__dir.'/HTMLPurifier/Injector/SafeObject.php'; |
|
183 | +require_once $__dir.'/HTMLPurifier/Lexer/DOMLex.php'; |
|
184 | +require_once $__dir.'/HTMLPurifier/Lexer/DirectLex.php'; |
|
185 | +require_once $__dir.'/HTMLPurifier/Strategy/Composite.php'; |
|
186 | +require_once $__dir.'/HTMLPurifier/Strategy/Core.php'; |
|
187 | +require_once $__dir.'/HTMLPurifier/Strategy/FixNesting.php'; |
|
188 | +require_once $__dir.'/HTMLPurifier/Strategy/MakeWellFormed.php'; |
|
189 | +require_once $__dir.'/HTMLPurifier/Strategy/RemoveForeignElements.php'; |
|
190 | +require_once $__dir.'/HTMLPurifier/Strategy/ValidateAttributes.php'; |
|
191 | +require_once $__dir.'/HTMLPurifier/TagTransform/Font.php'; |
|
192 | +require_once $__dir.'/HTMLPurifier/TagTransform/Simple.php'; |
|
193 | +require_once $__dir.'/HTMLPurifier/Token/Comment.php'; |
|
194 | +require_once $__dir.'/HTMLPurifier/Token/Tag.php'; |
|
195 | +require_once $__dir.'/HTMLPurifier/Token/Empty.php'; |
|
196 | +require_once $__dir.'/HTMLPurifier/Token/End.php'; |
|
197 | +require_once $__dir.'/HTMLPurifier/Token/Start.php'; |
|
198 | +require_once $__dir.'/HTMLPurifier/Token/Text.php'; |
|
199 | +require_once $__dir.'/HTMLPurifier/URIFilter/DisableExternal.php'; |
|
200 | +require_once $__dir.'/HTMLPurifier/URIFilter/DisableExternalResources.php'; |
|
201 | +require_once $__dir.'/HTMLPurifier/URIFilter/DisableResources.php'; |
|
202 | +require_once $__dir.'/HTMLPurifier/URIFilter/HostBlacklist.php'; |
|
203 | +require_once $__dir.'/HTMLPurifier/URIFilter/MakeAbsolute.php'; |
|
204 | +require_once $__dir.'/HTMLPurifier/URIFilter/Munge.php'; |
|
205 | +require_once $__dir.'/HTMLPurifier/URIFilter/SafeIframe.php'; |
|
206 | +require_once $__dir.'/HTMLPurifier/URIScheme/data.php'; |
|
207 | +require_once $__dir.'/HTMLPurifier/URIScheme/file.php'; |
|
208 | +require_once $__dir.'/HTMLPurifier/URIScheme/ftp.php'; |
|
209 | +require_once $__dir.'/HTMLPurifier/URIScheme/http.php'; |
|
210 | +require_once $__dir.'/HTMLPurifier/URIScheme/https.php'; |
|
211 | +require_once $__dir.'/HTMLPurifier/URIScheme/mailto.php'; |
|
212 | +require_once $__dir.'/HTMLPurifier/URIScheme/news.php'; |
|
213 | +require_once $__dir.'/HTMLPurifier/URIScheme/nntp.php'; |
|
214 | +require_once $__dir.'/HTMLPurifier/VarParser/Flexible.php'; |
|
215 | +require_once $__dir.'/HTMLPurifier/VarParser/Native.php'; |
@@ -6,6 +6,6 @@ |
||
6 | 6 | * without any other side-effects. |
7 | 7 | */ |
8 | 8 | |
9 | -set_include_path(dirname(__FILE__) . PATH_SEPARATOR . get_include_path() ); |
|
9 | +set_include_path(dirname(__FILE__).PATH_SEPARATOR.get_include_path()); |
|
10 | 10 | |
11 | 11 | // vim: et sw=4 sts=4 |
@@ -4,7 +4,7 @@ |
||
4 | 4 | * This is a stub include that automatically configures the include path. |
5 | 5 | */ |
6 | 6 | |
7 | -set_include_path(dirname(__FILE__) . PATH_SEPARATOR . get_include_path() ); |
|
7 | +set_include_path(dirname(__FILE__).PATH_SEPARATOR.get_include_path()); |
|
8 | 8 | require_once 'HTMLPurifier/Bootstrap.php'; |
9 | 9 | require_once 'HTMLPurifier.autoload.php'; |
10 | 10 |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | */ |
19 | 19 | function getInstance($opt = null) |
20 | 20 | { |
21 | - if(!$GLOBALS['__CacheApc__']) |
|
21 | + if (!$GLOBALS['__CacheApc__']) |
|
22 | 22 | { |
23 | 23 | $GLOBALS['__CacheApc__'] = new CacheApc(); |
24 | 24 | } |
@@ -56,12 +56,12 @@ discard block |
||
56 | 56 | */ |
57 | 57 | function put($key, $buff, $valid_time = 0) |
58 | 58 | { |
59 | - if($valid_time == 0) |
|
59 | + if ($valid_time == 0) |
|
60 | 60 | { |
61 | 61 | $valid_time = $this->valid_time; |
62 | 62 | } |
63 | 63 | |
64 | - return apc_store(md5(_XE_PATH_ . $key), array($_SERVER['REQUEST_TIME'], $buff), $valid_time); |
|
64 | + return apc_store(md5(_XE_PATH_.$key), array($_SERVER['REQUEST_TIME'], $buff), $valid_time); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -74,15 +74,15 @@ discard block |
||
74 | 74 | */ |
75 | 75 | function isValid($key, $modified_time = 0) |
76 | 76 | { |
77 | - $_key = md5(_XE_PATH_ . $key); |
|
77 | + $_key = md5(_XE_PATH_.$key); |
|
78 | 78 | $obj = apc_fetch($_key, $success); |
79 | - if(!$success || !is_array($obj)) |
|
79 | + if (!$success || !is_array($obj)) |
|
80 | 80 | { |
81 | 81 | return false; |
82 | 82 | } |
83 | 83 | unset($obj[1]); |
84 | 84 | |
85 | - if($modified_time > 0 && $modified_time > $obj[0]) |
|
85 | + if ($modified_time > 0 && $modified_time > $obj[0]) |
|
86 | 86 | { |
87 | 87 | $this->delete($key); |
88 | 88 | return false; |
@@ -101,14 +101,14 @@ discard block |
||
101 | 101 | */ |
102 | 102 | function get($key, $modified_time = 0) |
103 | 103 | { |
104 | - $_key = md5(_XE_PATH_ . $key); |
|
104 | + $_key = md5(_XE_PATH_.$key); |
|
105 | 105 | $obj = apc_fetch($_key, $success); |
106 | - if(!$success || !is_array($obj)) |
|
106 | + if (!$success || !is_array($obj)) |
|
107 | 107 | { |
108 | 108 | return false; |
109 | 109 | } |
110 | 110 | |
111 | - if($modified_time > 0 && $modified_time > $obj[0]) |
|
111 | + if ($modified_time > 0 && $modified_time > $obj[0]) |
|
112 | 112 | { |
113 | 113 | $this->delete($key); |
114 | 114 | return false; |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | */ |
126 | 126 | function delete($key) |
127 | 127 | { |
128 | - $_key = md5(_XE_PATH_ . $key); |
|
128 | + $_key = md5(_XE_PATH_.$key); |
|
129 | 129 | return apc_delete($_key); |
130 | 130 | } |
131 | 131 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
151 | -CacheApc::$isSupport = function_exists('apc_add'); |
|
151 | +CacheApc::$isSupport = function_exists('apc_add'); |
|
152 | 152 | |
153 | 153 | /* End of file CacheApc.class.php */ |
154 | 154 | /* Location: ./classes/cache/CacheApc.class.php */ |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | */ |
21 | 21 | function getInstance($opt = null) |
22 | 22 | { |
23 | - if(!$GLOBALS['__CacheWincache__']) |
|
23 | + if (!$GLOBALS['__CacheWincache__']) |
|
24 | 24 | { |
25 | 25 | $GLOBALS['__CacheWincache__'] = new CacheWincache(); |
26 | 26 | } |
@@ -59,11 +59,11 @@ discard block |
||
59 | 59 | */ |
60 | 60 | function put($key, $buff, $valid_time = 0) |
61 | 61 | { |
62 | - if($valid_time == 0) |
|
62 | + if ($valid_time == 0) |
|
63 | 63 | { |
64 | 64 | $valid_time = $this->valid_time; |
65 | 65 | } |
66 | - return wincache_ucache_set(md5(_XE_PATH_ . $key), array($_SERVER['REQUEST_TIME'], $buff), $valid_time); |
|
66 | + return wincache_ucache_set(md5(_XE_PATH_.$key), array($_SERVER['REQUEST_TIME'], $buff), $valid_time); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -76,15 +76,15 @@ discard block |
||
76 | 76 | */ |
77 | 77 | function isValid($key, $modified_time = 0) |
78 | 78 | { |
79 | - $_key = md5(_XE_PATH_ . $key); |
|
79 | + $_key = md5(_XE_PATH_.$key); |
|
80 | 80 | $obj = wincache_ucache_get($_key, $success); |
81 | - if(!$success || !is_array($obj)) |
|
81 | + if (!$success || !is_array($obj)) |
|
82 | 82 | { |
83 | 83 | return false; |
84 | 84 | } |
85 | 85 | unset($obj[1]); |
86 | 86 | |
87 | - if($modified_time > 0 && $modified_time > $obj[0]) |
|
87 | + if ($modified_time > 0 && $modified_time > $obj[0]) |
|
88 | 88 | { |
89 | 89 | $this->_delete($_key); |
90 | 90 | return false; |
@@ -103,14 +103,14 @@ discard block |
||
103 | 103 | */ |
104 | 104 | function get($key, $modified_time = 0) |
105 | 105 | { |
106 | - $_key = md5(_XE_PATH_ . $key); |
|
106 | + $_key = md5(_XE_PATH_.$key); |
|
107 | 107 | $obj = wincache_ucache_get($_key, $success); |
108 | - if(!$success || !is_array($obj)) |
|
108 | + if (!$success || !is_array($obj)) |
|
109 | 109 | { |
110 | 110 | return false; |
111 | 111 | } |
112 | 112 | |
113 | - if($modified_time > 0 && $modified_time > $obj[0]) |
|
113 | + if ($modified_time > 0 && $modified_time > $obj[0]) |
|
114 | 114 | { |
115 | 115 | $this->_delete($_key); |
116 | 116 | return false; |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | */ |
139 | 139 | function delete($key) |
140 | 140 | { |
141 | - $_key = md5(_XE_PATH_ . $key); |
|
141 | + $_key = md5(_XE_PATH_.$key); |
|
142 | 142 | $this->_delete($_key); |
143 | 143 | } |
144 | 144 |