• R/O
  • HTTP
  • SSH
  • HTTPS

nucleus-jp-ancient: Commit

Nucleus CMS日本語版SVNをgit-svnしたもの。リポジトリの変換作業用


Commit MetaInfo

Revisionf834532102da41b12f4ebabd1760d346c04e4f97 (tree)
Zeit2009-03-21 23:42:13
Autorshizuki <shizuki@1ca2...>
Commitershizuki

Log Message

FIXED: When inclusion tried to do the special skin type by skin of error types, $skinid wasn't set.

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

Ändern Zusammenfassung

Diff

--- a/nucleus/documentation/history.html
+++ b/nucleus/documentation/history.html
@@ -64,6 +64,7 @@
6464 <li>CHANGED: NP_SkinFilesオプション用言語定義追加(NP_SkinFiles option word update via language file)(shizuki)</li>
6565 <li>UPDATED: NP_SkinFiles 2.03に差し替え(code:yama/commit:shizuki)(NP_SkinFiles update to 2.03)(code:yama,katsumi/commit:shizuki)</li>
6666 <li>FIXED: 「General」カテゴリのUPDATE漏れ修正(install.php)(preinstall default category name is not localize)(shizuki)</li>
67+ <li>FIXED: When inclusion tried to do the special skin type by skin of error types, $skinid wasn't set.(yu/shizuki)</li>
6768 <li>FIXED: Reduce PHP Notices caused by undefined variables and wrong offsets (shizuki, kaigreve)</li>
6869 <li>FIXED: additional changes in the language files english.php and english-utf8.php to reflect modifications since version 3.30 (kaigreve)</li>
6970 <li>FIXED: SQL error in MEMBER::write() where mautosave not forced to be integer. See <a href="http://forum.nucleuscms.org/viewtopic.php?t=18575">Problem with 3.40</a>. (ftruscot)
--- a/nucleus/libs/BaseActions.php
+++ b/nucleus/libs/BaseActions.php
@@ -21,304 +21,313 @@
2121 * @version $NucleusJP: BaseActions.php,v 1.2 2006/07/20 08:01:52 kimitake Exp $
2222 */
2323
24-class BaseActions {
25-
26- // depth level for includes (max. level is 3)
27- var $level;
28-
29- // array of evaluated conditions (true/false). The element at the end is the one for the most nested
30- // if block.
31- var $if_conditions;
32-
33- // in the "elseif" / "elseifnot" sequences, if one of the conditions become "true" remained conditions should not
34- // be tested. this variable (actually a stack) holds this information.
35- var $if_execute;
36-
37- // at all times, can be evaluated to either true if the current block needs to be displayed. This
38- // variable is used to decide to skip skinvars in parts that will never be outputted.
39- var $if_currentlevel;
40-
41- // contains a search string with keywords that need to be highlighted. These get parsed into $aHighlight
42- var $strHighlight;
43-
44- // array of keywords that need to be highlighted in search results (see the highlight()
45- // and parseHighlight() methods)
46- var $aHighlight;
47-
48- // reference to the parser object that is using this object as actions-handler
49- var $parser;
50-
51- function BaseActions() {
52- $this->level = 0;
53-
54- // if nesting level
55- $this->if_conditions = array(); // array on which condition values are pushed/popped
56- $this->if_execute = array(); // array on which condition values are pushed/popped
57- $this->if_currentlevel = 1; // 1 = current level is displayed; 0 = current level not displayed
58-
59- // highlights
60- $this->strHighlight = ''; // full highlight
61- $this->aHighlight = array(); // parsed highlight
62-
63- }
64-
65- // include file (no parsing of php)
66- function parse_include($filename) {
67- @readfile($this->getIncludeFileName($filename));
68- }
69-
70- // php-include file
71- function parse_phpinclude($filename) {
72- includephp($this->getIncludeFileName($filename));
73- }
74-
75- // parsed include
76- function parse_parsedinclude($filename) {
77- // check current level
78- if ($this->level > 3) return; // max. depth reached (avoid endless loop)
79- global $skinid;
80- $skin = new SKIN($skinid);
81- $file = $this->getIncludeFileName($filename);
82- if (!$skin->isValid && !file_exists($file)) {
83- return;
84- }
85- $parts = explode('|', $filename, 2);
86- if ($skin->getContent($parts[0])) {
87- $contents = $skin->getContent($parts[0]);
88- } else {
89- $filename = $this->getIncludeFileName($filename);
90- if (!file_exists($filename)) return '';
91-
92- $fsize = filesize($filename);
93-
94- // nothing to include
95- if ($fsize <= 0) return;
96-
97- $this->level = $this->level + 1;
98-
99- // read file
100- $fd = fopen ($filename, 'r');
101- $contents = fread ($fd, $fsize);
102- fclose ($fd);
103- }
104-
105- // parse file contents
106- $this->parser->parse($contents);
107-
108- $this->level = $this->level - 1;
109- }
110-
111- /**
112- * Returns the correct location of the file to be included, according to
113- * parser properties
114- *
115- * IF IncludeMode = 'skindir' => use skindir
116- */
117- function getIncludeFileName($filename) {
118- // leave absolute filenames and http urls as they are
119- if (
120- (substr($filename,0,1) == '/')
121- || (substr($filename,0,7) == 'http://')
122- || (substr($filename,0,6) == 'ftp://')
123- )
124- return $filename;
125-
126- $filename = PARSER::getProperty('IncludePrefix') . $filename;
127- if (PARSER::getProperty('IncludeMode') == 'skindir') {
128- global $DIR_SKINS;
129- return $DIR_SKINS . $filename;
130- } else {
131- return $filename;
132- }
133- }
134-
135- /**
136- * Inserts an url relative to the skindir (useful when doing import/export)
137- *
138- * e.g. <skinfile(default/myfile.sth)>
139- */
140- function parse_skinfile($filename) {
141- global $CONF;
142-
143- echo $CONF['SkinsURL'] . PARSER::getProperty('IncludePrefix') . $filename;
144- }
145-
146- /**
147- * Sets a property for the parser
148- */
149- function parse_set($property, $value) {
150- PARSER::setProperty($property, $value);
151- }
152-
153- /**
154- * Helper function: add if condition
155- */
156- function _addIfCondition($condition) {
157-
158- array_push($this->if_conditions,$condition);
159-
160- $this->_updateTopIfCondition();
161-
162- ob_start();
163- }
164-
165- function _updateTopIfCondition() {
166- if (sizeof($this->if_conditions) == 0)
167- $this->if_currentlevel = 1;
168- else
169- $this->if_currentlevel = $this->if_conditions[sizeof($this->if_conditions) - 1];
170- }
171-
172- /**
173- * Helper function for elseif / elseifnot
174- */
175- function _addIfExecute() {
176- array_push($this->if_execute, 0);
177- }
178-
179- /**
180- * Helper function for elseif / elseifnot
181- * @param string condition to be fullfilled
182- */
183- function _updateIfExecute($condition) {
184- $index = sizeof($this->if_execute) - 1;
185- $this->if_execute[$index] = $this->if_execute[$index] || $condition;
186- }
187-
188- /**
189- * returns the currently top if condition
190- */
191- function _getTopIfCondition() {
192- return $this->if_currentlevel;
193- }
194-
195- /**
196- * Sets the search terms to be highlighted
197- *
198- * @param $highlight
199- * A series of search terms
200- */
201- function setHighlight($highlight) {
202- $this->strHighlight = $highlight;
203- if ($highlight) {
204- $this->aHighlight = parseHighlight($highlight);
205- }
206- }
207-
208- /**
209- * Applies the highlight to the given piece of text
210- *
211- * @param &$data
212- * Data that needs to be highlighted
213- * @see setHighlight
214- */
215- function highlight(&$data) {
216- if ($this->aHighlight)
217- return highlight($data,$this->aHighlight,$this->template['SEARCH_HIGHLIGHT']);
218- else
219- return $data;
220- }
221-
222- /**
223- * Parses <%if%> statements
224- */
225- function parse_if() {
226- $this->_addIfExecute();
227-
228- $args = func_get_args();
229- $condition = call_user_func_array(array(&$this,'checkCondition'), $args);
230- $this->_addIfCondition($condition);
231- }
232-
233- /**
234- * Parses <%else%> statements
235- */
236- function parse_else() {
237- if (sizeof($this->if_conditions) == 0) return;
238- array_pop($this->if_conditions);
239- if ($this->if_currentlevel) {
240- ob_end_flush();
241- $this->_updateIfExecute(1);
242- $this->_addIfCondition(0);
243- } elseif ($this->if_execute[sizeof($this->if_execute) - 1]) {
244- ob_end_clean();
245- $this->_addIfCondition(0);
246- } else {
247- ob_end_clean();
248- $this->_addIfCondition(1);
249- }
250- }
251-
252- /**
253- * Parses <%elseif%> statements
254- */
255- function parse_elseif() {
256- if (sizeof($this->if_conditions) == 0) return;
257- array_pop($this->if_conditions);
258- if ($this->if_currentlevel) {
259- ob_end_flush();
260- $this->_updateIfExecute(1);
261- $this->_addIfCondition(0);
262- } elseif ($this->if_execute[sizeof($this->if_execute) - 1]) {
263- ob_end_clean();
264- $this->_addIfCondition(0);
265- } else {
266- ob_end_clean();
267- $args = func_get_args();
268- $condition = call_user_func_array(array(&$this,'checkCondition'), $args);
269- $this->_addIfCondition($condition);
270- }
271- }
272-
273- /**
274- * Parses <%ifnot%> statements
275- */
276- function parse_ifnot() {
277- $this->_addIfExecute();
278-
279- $args = func_get_args();
280- $condition = call_user_func_array(array(&$this,'checkCondition'), $args);
281- $this->_addIfCondition(!$condition);
282- }
283-
284- /**
285- * Parses <%elseifnot%> statements
286- */
287- function parse_elseifnot() {
288- if (sizeof($this->if_conditions) == 0) return;
289- array_pop($this->if_conditions);
290- if ($this->if_currentlevel) {
291- ob_end_flush();
292- $this->_updateIfExecute(1);
293- $this->_addIfCondition(0);
294- } elseif ($this->if_execute[sizeof($this->if_execute) - 1]) {
295- ob_end_clean();
296- $this->_addIfCondition(0);
297- } else {
298- ob_end_clean();
299- $args = func_get_args();
300- $condition = call_user_func_array(array(&$this,'checkCondition'), $args);
301- $this->_addIfCondition(!$condition);
302- }
303- }
304-
305- /**
306- * Ends a conditional if-block
307- * see e.g. ifcat (BLOG), ifblogsetting (PAGEFACTORY)
308- */
309- function parse_endif() {
310- // we can only close what has been opened
311- if (sizeof($this->if_conditions) == 0) return;
312-
313- if ($this->if_currentlevel) {
314- ob_end_flush();
315- } else {
316- ob_end_clean();
317- }
318- array_pop($this->if_conditions);
319- array_pop($this->if_execute);
320-
321- $this->_updateTopIfCondition();
322- }
323-}
24+class BaseActions {
25+
26+ // depth level for includes (max. level is 3)
27+ var $level;
28+
29+ // array of evaluated conditions (true/false). The element at the end is the one for the most nested
30+ // if block.
31+ var $if_conditions;
32+
33+ // in the "elseif" / "elseifnot" sequences, if one of the conditions become "true" remained conditions should not
34+ // be tested. this variable (actually a stack) holds this information.
35+ var $if_execute;
36+
37+ // at all times, can be evaluated to either true if the current block needs to be displayed. This
38+ // variable is used to decide to skip skinvars in parts that will never be outputted.
39+ var $if_currentlevel;
40+
41+ // contains a search string with keywords that need to be highlighted. These get parsed into $aHighlight
42+ var $strHighlight;
43+
44+ // array of keywords that need to be highlighted in search results (see the highlight()
45+ // and parseHighlight() methods)
46+ var $aHighlight;
47+
48+ // reference to the parser object that is using this object as actions-handler
49+ var $parser;
50+
51+ function BaseActions() {
52+ $this->level = 0;
53+
54+ // if nesting level
55+ $this->if_conditions = array(); // array on which condition values are pushed/popped
56+ $this->if_execute = array(); // array on which condition values are pushed/popped
57+ $this->if_currentlevel = 1; // 1 = current level is displayed; 0 = current level not displayed
58+
59+ // highlights
60+ $this->strHighlight = ''; // full highlight
61+ $this->aHighlight = array(); // parsed highlight
62+
63+ }
64+
65+ // include file (no parsing of php)
66+ function parse_include($filename) {
67+ @readfile($this->getIncludeFileName($filename));
68+ }
69+
70+ // php-include file
71+ function parse_phpinclude($filename) {
72+ includephp($this->getIncludeFileName($filename));
73+ }
74+
75+ // parsed include
76+ function parse_parsedinclude($filename) {
77+ // check current level
78+ if ($this->level > 3) return; // max. depth reached (avoid endless loop)
79+ global $skinid;
80+ if (!$skinid) {
81+ global $manager, $blogid;
82+ if (!$blogid) {
83+ global $CONF;
84+ $blogid = $CONF['DefaultBlog'];
85+ }
86+ $blog = &$manager->getBlog($blogid);
87+ $skinid = $blog->getDefaultSkin();
88+ }
89+ $skin = new SKIN($skinid);
90+ $file = $this->getIncludeFileName($filename);
91+ if (!$skin->isValid && !file_exists($file)) {
92+ return;
93+ }
94+ $parts = explode('|', $filename, 2);
95+ if ($skin->getContent($parts[0])) {
96+ $contents = $skin->getContent($parts[0]);
97+ } else {
98+ $filename = $this->getIncludeFileName($filename);
99+ if (!file_exists($filename)) return '';
100+
101+ $fsize = filesize($filename);
102+
103+ // nothing to include
104+ if ($fsize <= 0) return;
105+
106+ $this->level = $this->level + 1;
107+
108+ // read file
109+ $fd = fopen ($filename, 'r');
110+ $contents = fread ($fd, $fsize);
111+ fclose ($fd);
112+ }
113+
114+ // parse file contents
115+ $this->parser->parse($contents);
116+
117+ $this->level = $this->level - 1;
118+ }
119+
120+ /**
121+ * Returns the correct location of the file to be included, according to
122+ * parser properties
123+ *
124+ * IF IncludeMode = 'skindir' => use skindir
125+ */
126+ function getIncludeFileName($filename) {
127+ // leave absolute filenames and http urls as they are
128+ if (
129+ (substr($filename,0,1) == '/')
130+ || (substr($filename,0,7) == 'http://')
131+ || (substr($filename,0,6) == 'ftp://')
132+ )
133+ return $filename;
134+
135+ $filename = PARSER::getProperty('IncludePrefix') . $filename;
136+ if (PARSER::getProperty('IncludeMode') == 'skindir') {
137+ global $DIR_SKINS;
138+ return $DIR_SKINS . $filename;
139+ } else {
140+ return $filename;
141+ }
142+ }
143+
144+ /**
145+ * Inserts an url relative to the skindir (useful when doing import/export)
146+ *
147+ * e.g. <skinfile(default/myfile.sth)>
148+ */
149+ function parse_skinfile($filename) {
150+ global $CONF;
151+
152+ echo $CONF['SkinsURL'] . PARSER::getProperty('IncludePrefix') . $filename;
153+ }
154+
155+ /**
156+ * Sets a property for the parser
157+ */
158+ function parse_set($property, $value) {
159+ PARSER::setProperty($property, $value);
160+ }
161+
162+ /**
163+ * Helper function: add if condition
164+ */
165+ function _addIfCondition($condition) {
166+
167+ array_push($this->if_conditions,$condition);
168+
169+ $this->_updateTopIfCondition();
170+
171+ ob_start();
172+ }
173+
174+ function _updateTopIfCondition() {
175+ if (sizeof($this->if_conditions) == 0)
176+ $this->if_currentlevel = 1;
177+ else
178+ $this->if_currentlevel = $this->if_conditions[sizeof($this->if_conditions) - 1];
179+ }
180+
181+ /**
182+ * Helper function for elseif / elseifnot
183+ */
184+ function _addIfExecute() {
185+ array_push($this->if_execute, 0);
186+ }
187+
188+ /**
189+ * Helper function for elseif / elseifnot
190+ * @param string condition to be fullfilled
191+ */
192+ function _updateIfExecute($condition) {
193+ $index = sizeof($this->if_execute) - 1;
194+ $this->if_execute[$index] = $this->if_execute[$index] || $condition;
195+ }
196+
197+ /**
198+ * returns the currently top if condition
199+ */
200+ function _getTopIfCondition() {
201+ return $this->if_currentlevel;
202+ }
203+
204+ /**
205+ * Sets the search terms to be highlighted
206+ *
207+ * @param $highlight
208+ * A series of search terms
209+ */
210+ function setHighlight($highlight) {
211+ $this->strHighlight = $highlight;
212+ if ($highlight) {
213+ $this->aHighlight = parseHighlight($highlight);
214+ }
215+ }
216+
217+ /**
218+ * Applies the highlight to the given piece of text
219+ *
220+ * @param &$data
221+ * Data that needs to be highlighted
222+ * @see setHighlight
223+ */
224+ function highlight(&$data) {
225+ if ($this->aHighlight)
226+ return highlight($data,$this->aHighlight,$this->template['SEARCH_HIGHLIGHT']);
227+ else
228+ return $data;
229+ }
230+
231+ /**
232+ * Parses <%if%> statements
233+ */
234+ function parse_if() {
235+ $this->_addIfExecute();
236+
237+ $args = func_get_args();
238+ $condition = call_user_func_array(array(&$this,'checkCondition'), $args);
239+ $this->_addIfCondition($condition);
240+ }
241+
242+ /**
243+ * Parses <%else%> statements
244+ */
245+ function parse_else() {
246+ if (sizeof($this->if_conditions) == 0) return;
247+ array_pop($this->if_conditions);
248+ if ($this->if_currentlevel) {
249+ ob_end_flush();
250+ $this->_updateIfExecute(1);
251+ $this->_addIfCondition(0);
252+ } elseif ($this->if_execute[sizeof($this->if_execute) - 1]) {
253+ ob_end_clean();
254+ $this->_addIfCondition(0);
255+ } else {
256+ ob_end_clean();
257+ $this->_addIfCondition(1);
258+ }
259+ }
260+
261+ /**
262+ * Parses <%elseif%> statements
263+ */
264+ function parse_elseif() {
265+ if (sizeof($this->if_conditions) == 0) return;
266+ array_pop($this->if_conditions);
267+ if ($this->if_currentlevel) {
268+ ob_end_flush();
269+ $this->_updateIfExecute(1);
270+ $this->_addIfCondition(0);
271+ } elseif ($this->if_execute[sizeof($this->if_execute) - 1]) {
272+ ob_end_clean();
273+ $this->_addIfCondition(0);
274+ } else {
275+ ob_end_clean();
276+ $args = func_get_args();
277+ $condition = call_user_func_array(array(&$this,'checkCondition'), $args);
278+ $this->_addIfCondition($condition);
279+ }
280+ }
281+
282+ /**
283+ * Parses <%ifnot%> statements
284+ */
285+ function parse_ifnot() {
286+ $this->_addIfExecute();
287+
288+ $args = func_get_args();
289+ $condition = call_user_func_array(array(&$this,'checkCondition'), $args);
290+ $this->_addIfCondition(!$condition);
291+ }
292+
293+ /**
294+ * Parses <%elseifnot%> statements
295+ */
296+ function parse_elseifnot() {
297+ if (sizeof($this->if_conditions) == 0) return;
298+ array_pop($this->if_conditions);
299+ if ($this->if_currentlevel) {
300+ ob_end_flush();
301+ $this->_updateIfExecute(1);
302+ $this->_addIfCondition(0);
303+ } elseif ($this->if_execute[sizeof($this->if_execute) - 1]) {
304+ ob_end_clean();
305+ $this->_addIfCondition(0);
306+ } else {
307+ ob_end_clean();
308+ $args = func_get_args();
309+ $condition = call_user_func_array(array(&$this,'checkCondition'), $args);
310+ $this->_addIfCondition(!$condition);
311+ }
312+ }
313+
314+ /**
315+ * Ends a conditional if-block
316+ * see e.g. ifcat (BLOG), ifblogsetting (PAGEFACTORY)
317+ */
318+ function parse_endif() {
319+ // we can only close what has been opened
320+ if (sizeof($this->if_conditions) == 0) return;
321+
322+ if ($this->if_currentlevel) {
323+ ob_end_flush();
324+ } else {
325+ ob_end_clean();
326+ }
327+ array_pop($this->if_conditions);
328+ array_pop($this->if_execute);
329+
330+ $this->_updateTopIfCondition();
331+ }
332+}
324333 ?>
\ No newline at end of file
Show on old repository browser