svnno****@sourc*****
svnno****@sourc*****
2009年 3月 30日 (月) 20:53:40 JST
Revision: 18 http://svn.sourceforge.jp/view?root=frameworkspider&view=rev&rev=18 Author: m_nakashima Date: 2009-03-30 20:53:40 +0900 (Mon, 30 Mar 2009) Log Message: ----------- Modified Paths: -------------- current/DATA/lib/spider/tags/Charset.class.php current/DATA/lib/spider/tags/If.class.php current/DATA/lib/spider/tags/TagBase.class.php current/DATA/lib/spider/tags/UseSession.class.php current/DATA/lib/spider/tags/Write.class.php -------------- next part -------------- Modified: current/DATA/lib/spider/tags/Charset.class.php =================================================================== --- current/DATA/lib/spider/tags/Charset.class.php 2009-03-30 10:50:07 UTC (rev 17) +++ current/DATA/lib/spider/tags/Charset.class.php 2009-03-30 11:53:40 UTC (rev 18) @@ -116,7 +116,7 @@ $process_code .= "mb_language('".$language."');\n"; $process_code .= "mb_detect_order('".$detect_order."');\n"; $process_code .= "mb_internal_encoding('".$internal_charset."');\n"; - if( isset($build_information->preview_process_hash) + if( !isset($build_information->preview_process_hash) || !is_array($build_information->preview_process_hash) ){ $build_information->preview_process_hash = array(); } Modified: current/DATA/lib/spider/tags/If.class.php =================================================================== --- current/DATA/lib/spider/tags/If.class.php 2009-03-30 10:50:07 UTC (rev 17) +++ current/DATA/lib/spider/tags/If.class.php 2009-03-30 11:53:40 UTC (rev 18) @@ -95,7 +95,8 @@ // 下位互換の文字列変更 $strings = $this->oldCondition2NewCondition( $strings ); // ネイティブコードに変換 - return $this->tagCode2NativeCode( $strings ); + $attribute_name_array = array(); + return $this->tagCode2NativeCode( $strings, $attribute_name_array ); } /** * if条件文の式を解析する Modified: current/DATA/lib/spider/tags/TagBase.class.php =================================================================== --- current/DATA/lib/spider/tags/TagBase.class.php 2009-03-30 10:50:07 UTC (rev 17) +++ current/DATA/lib/spider/tags/TagBase.class.php 2009-03-30 11:53:40 UTC (rev 18) @@ -125,7 +125,7 @@ /** * タグコードをPHPコードに変換します */ - function tagCode2NativeCode( $strings ) { + function tagCode2NativeCode( $strings, & $attribute_name_array=array() ) { // 演算時の正規表現 $signiture_regx = '\\+\\-\\/\\*\\%\\=\\<\\>\\&\\|\\(\\)\\!\\,\\[\\]'; // 変換後文字列 @@ -189,9 +189,15 @@ } else if( $key > 2 && $element_array[$key-1] == '>' && $element_array[$key-2] == '-'){ // メソッドでなくて前の要素が->の場合オブジェクトメンバも変換(要検討...) $converted_strings .= '$GLOBALS[\''.$element_data.'\']'; + if( is_array($attribute_name_array) ) { + array_push( $attribute_name_array, $element_data ); + } } else { // それ以外は$GLOBALSへ変換 $converted_strings .= '$GLOBALS[\''.$element_data.'\']'; + if( is_array($attribute_name_array) ) { + array_push( $attribute_name_array, $element_data ); + } } } } else { Modified: current/DATA/lib/spider/tags/UseSession.class.php =================================================================== --- current/DATA/lib/spider/tags/UseSession.class.php 2009-03-30 10:50:07 UTC (rev 17) +++ current/DATA/lib/spider/tags/UseSession.class.php 2009-03-30 11:53:40 UTC (rev 18) @@ -26,7 +26,6 @@ * コンバートメソッド */ function convert( &$result_strings, &$build_information ){ - if( preg_match('/\\{use\\-session\\:[fF][aA][lL][sS][eE]\\}/', $result_strings ) > 0 || preg_match('/\\{use\\-session\\:[nN][oO]\\}/', $result_strings ) > 0 ) { // falseかnoが指定されているならセッションは開始しない @@ -43,15 +42,16 @@ . "}else{\n" . "session_start();\n}" ; - if( !is_array($build_information->preview_process_hash) ){ + if( !isset($build_information->preview_process_hash) + || !is_array($build_information->preview_process_hash) ){ $build_information->preview_process_hash = array(); } - if( !is_array($build_information->preview_process_hash[$this->priority]) ){ + if( !isset($build_information->preview_process_hash[$this->priority]) + || !is_array($build_information->preview_process_hash[$this->priority]) ){ $build_information->preview_process_hash[$this->priority] = array(); } array_push( $build_information->preview_process_hash[$this->priority], $process_code ); } - } } ?> \ No newline at end of file Modified: current/DATA/lib/spider/tags/Write.class.php =================================================================== --- current/DATA/lib/spider/tags/Write.class.php 2009-03-30 10:50:07 UTC (rev 17) +++ current/DATA/lib/spider/tags/Write.class.php 2009-03-30 11:53:40 UTC (rev 18) @@ -116,10 +116,19 @@ $ret_strings = 'urlencode('.$ret_strings.')'; } // ネイティブコード化 - $ret_strings = $this->tagCode2NativeCode( $ret_strings ); + $attribute_name_array = array(); + $ret_strings = $this->tagCode2NativeCode( $ret_strings, $attribute_name_array ); + $attribute_exist_confirm_array = array(); + foreach( $attribute_name_array as $attribute_name ) { + array_push( $attribute_exist_confirm_array, 'isset($GLOBALS[\''.$attribute_name.'\'])'); + } // 最後にecho - $ret_strings = '<?php echo '.$ret_strings.'; ?>'; - return $ret_strings; + $result_string = '<?php if( '; + $result_string .= implode(' && ', $attribute_exist_confirm_array ); + $result_string .= ' ) {'; + $result_string .= 'echo '.$ret_strings.';'; + $result_string .= '} ?>'; + return $result_string; } /** * 文字列解析