From svnnotify @ sourceforge.jp Tue Mar 24 18:12:21 2009 From: svnnotify @ sourceforge.jp (svnnotify @ sourceforge.jp) Date: Tue, 24 Mar 2009 18:12:21 +0900 Subject: [Frameworkspider-svn] spider-commit [4] Message-ID: <1237885941.606762.32071.nullmailer@users.sourceforge.jp> Revision: 4 http://svn.sourceforge.jp/view?root=frameworkspider&view=rev&rev=4 Author: m_nakashima Date: 2009-03-24 18:12:21 +0900 (Tue, 24 Mar 2009) Log Message: ----------- Modified Paths: -------------- current/DATA/lib/spider/BuildInformation.class.php current/DATA/lib/spider/ExecutableFileCreator.class.php current/DATA/lib/spider/tags/Foreach.class.php current/DATA/lib/spider/tags/Module.class.php current/DATA/lib/spider/tags/PageTitle.class.php current/DATA/lib/spider/tags/TagBase.class.php current/DATA/lib/spider/tags/Widget.class.php current/DATA/lib/spider/tags/Write.class.php current/README.txt current/WWW_PUBLIC/index.php -------------- next part -------------- Modified: current/DATA/lib/spider/BuildInformation.class.php =================================================================== --- current/DATA/lib/spider/BuildInformation.class.php 2009-03-23 12:03:37 UTC (rev 3) +++ current/DATA/lib/spider/BuildInformation.class.php 2009-03-24 09:12:21 UTC (rev 4) @@ -169,11 +169,13 @@ function addExecModuleByString( $string ) { $string = trim( $string ); if( strlen($string) > 0 ) { - $info_array = explode(' ', $string); + $info_array = explode(' ', $string); // ひとつめの要素は必ずモジュール名 - $module_name = trim(array_shift($info_array)); - $info_hash = array(); - $info_hash['force'] = false; + $module_name = trim(array_shift($info_array)); + $info_hash = array(); + // モジュール名と強制実行パラメータを情報ハッシュに設定 + $info_hash['module_name'] = $module_name; + $info_hash['force'] = false; // 二つ目以降の要素を確認 foreach( $info_array as $info ) { $info = trim($info); @@ -201,7 +203,13 @@ } } } - $this->module_exec_info_hash[$module_name] = $info_hash; + // パラメータが異なる場合にキーを変更してハッシュに登録する。forceパラメータは参照しない + if( isset($info_hash['post']) || isset($info_hash['get']) || isset($info_hash['attribute_prefix'])) { + $keyname = implode('',$info_hash); + $this->module_exec_info_hash[$keyname] = $info_hash; + } else { + $this->module_exec_info_hash[$module_name] = $info_hash; + } } } /** Modified: current/DATA/lib/spider/ExecutableFileCreator.class.php =================================================================== --- current/DATA/lib/spider/ExecutableFileCreator.class.php 2009-03-23 12:03:37 UTC (rev 3) +++ current/DATA/lib/spider/ExecutableFileCreator.class.php 2009-03-24 09:12:21 UTC (rev 4) @@ -166,7 +166,8 @@ } // モジュール実行のスクリプト追加 - foreach( $build_information_object->module_exec_info_hash as $module_name => $info_hash ) { + foreach( $build_information_object->module_exec_info_hash as $key => $info_hash ) { + $module_name = $info_hash['module_name']; $force = 'false'; if( $info_hash['force'] ) { $force = 'true'; Modified: current/DATA/lib/spider/tags/Foreach.class.php =================================================================== --- current/DATA/lib/spider/tags/Foreach.class.php 2009-03-23 12:03:37 UTC (rev 3) +++ current/DATA/lib/spider/tags/Foreach.class.php 2009-03-24 09:12:21 UTC (rev 4) @@ -34,60 +34,169 @@ * コンストラクタ */ function spider_tags_Foreach() { + $this->tag_name = 'foreach'; } /** * コンバートメソッド */ function convert( &$result_strings, &$build_information ){ - $vars_tags_aray = array(); - preg_match_all( '/\\{foreach\\:[^\\}]*?}/' - , $result_strings - , $vars_tags_aray - , PREG_PATTERN_ORDER ); - $valiable_counter = 0; - foreach ( $vars_tags_aray as $vars_tags ) { - foreach ( $vars_tags as $vars_tag ) { - $var_name = preg_replace( '/\\{foreach\\:/','', $vars_tag ); - $var_name = preg_replace( '/\\}$/','', $var_name ); - $var_name = trim( $var_name ); - $var_name = str_replace( ' ',' ', $var_name ); - $var_name = str_replace( ' ',' ', $var_name ); - $at_name = null; - list( $var_name, $key_name, $val_name ) = explode( ' ', $var_name ); - if ( strpos( $var_name, '::' ) > 0 ) { - list( $var_name, $at_name ) = explode( '::', $var_name ); + parent::convert( $result_strings, $build_information ); + $result_strings = str_replace( '{end-foreach}', '', $result_strings ); + $result_strings = str_replace( '{/foreach}', '', $result_strings ); + } + /** + * 個々のタグ文字列の変換後文字列を取得します + */ + function getConvertedStrings( &$result_strings, &$build_information, $option_array=array(), $valiable_counter=0 ) { + // ループに必要なオプションを取り出し(順序固定) + $org_attribute_name = array_shift( $option_array ); + $loop_key_name = array_shift( $option_array ); + $loop_val_name = array_shift( $option_array ); + + // 属性名指定がない場合はエラー表示で返す + if( strlen( $org_attribute_name ) == 0 ) { + return 'echo \'[error: "foreach" need parameters!]\'; if(false){if(false) {'; + } + // ループのキー名と値名の取り出し + if ( strlen( $loop_key_name ) > 0 && strlen( $loop_val_name ) > 0 ) { + // キー名と値名の両方が指定されている場合には何もしない + } else if ( strlen( $loop_key_name ) > 0 ) { + // 片方しか入力がない場合、値名がひとつめでキー名は自動 + $loop_val_name = $loop_key_name; + $loop_key_name = 'key'; + } else { + // 両方とも入力がない場合はエラー表示 + return 'echo \'[error: "foreach" need parameters!]\'; if(false){if(false) {'; + } + + // ループカウンタ数字名の決定 + $counter_name = str_replace('::','_',str_replace('.','_',$org_attribute_name)).'_loop_counter'; + // 実際にループする変数名 + $real_loop_var_name = '$tmp_array_'.sprintf('%08d',$valiable_counter); + // 置換文字列作成 + $rep_string = '/',$org_attribute_name ) > 0 || preg_match('/\\[.+\\]/',$org_attribute_name) > 0 ) { + // オブジェクトや配列の指定子が含まれている場合 + $real_var_string = $this->getAvailableVarName( $org_attribute_name ); + $rep_string .= $real_loop_var_name.'='.$real_var_string.'; '; + } else if ( strpos( $org_attribute_name, '::' ) > 0 ) { + // 従来の記述 属性名を::で分岐 + list( $attribute_name, $member_name ) = explode( '::', $org_attribute_name ); + // 対象属性値 + $target_attribute_name = '$GLOBALS[\''.$attribute_name.'\']'; + $rep_string .= $real_loop_var_name.'='.$target_attribute_name.'[\''.$member_name.'\']; '; + if( strlen( $member_name ) > 0 ) { + // メンバ指定がある場合は属性値がオブジェクトか配列かで分岐処理 + $rep_string .= 'if( is_array('.$target_attribute_name.') ){ '; + $rep_string .= $real_loop_var_name.'='.$target_attribute_name.'[\''.$member_name.'\']; '; + if( preg_match('/^[a-zA-Z\\_][0-9a-zA-Z\\_]*?/',$member_name) > 0 ) { + $rep_string .= ' } else if( is_object('.$target_attribute_name.') ) {'; + $rep_string .= $real_loop_var_name.'='.$target_attribute_name.'->'.$member_name.'; '; } - $k_name = 'key'; - $v_name = 'value'; - if ( strlen( $key_name ) > 0 && strlen( $val_name ) > 0 ) { - $k_name = $key_name; - $v_name = $val_name; - } else if ( strlen( $key_name ) > 0 ) { - $v_name = $key_name; + $rep_string .= ' } '; + } + } else { + // 属性名を特に区切る必要がない場合は + $target_attribute_name = '$GLOBALS[\''.$org_attribute_name.'\']'; + $rep_string .= $real_loop_var_name.'='.$target_attribute_name.'; '; + } + $rep_string .= 'if( is_array('.$real_loop_var_name.') ) { '; + $rep_string .= '$GLOBALS[\''.$counter_name.'\']=0; '; + $rep_string .= 'foreach ( '.$real_loop_var_name + .' as $GLOBALS[\''.$loop_key_name.'\'] => $GLOBALS[\''.$loop_val_name.'\'] ) {'; + $rep_string .= '$GLOBALS[\''.$counter_name.'\']++; '; + // 下位互換の為ループごとに属性設定 + $rep_string .= '$request_object->setAttribute("'.$loop_key_name.'",$GLOBALS[\''.$loop_key_name.'\']); '; + $rep_string .= '$request_object->setAttribute("'.$loop_val_name.'",$GLOBALS[\''.$loop_val_name.'\']); '; + $rep_string .= '$request_object->setAttribute("'.$counter_name.'",$GLOBALS[\''.$counter_name.'\']); '; + // 置換文字列終了 + $rep_string .= ' ?>'; + + return $rep_string; + } + /** + * 第一引数のループ対象指定文字列をPHP実行コードに変換して返します。 + */ + function getAvailableVarName( $org_attribute_name ) { + if( strlen( $org_attribute_name ) > 0 ) { + // オブジェクトや配列の指定子が含まれている場合全ての属性値候補を取り出し + $attribute_proposed_array = $this->getReverseSortedProposeAttributeHash( $org_attribute_name ); + // 属性名候補を変換する + $real_var_string = $org_attribute_name; + foreach( $attribute_proposed_array as $attribute_name => $prev_char ) { + if( preg_match('/^[0-9]+$/',$attribute_name) > 0 ) { + // 属性名候補が数字のみの場合変換しない + continue; + } else if( preg_match('/^\\$[^0-9][.]*$/',$attribute_name) > 0 ) { + // 属性名候補が$で始まる変数名なら変換しない + continue; + } else if( preg_match('/^\\\'[^\\\']*\\\'$/',$attribute_name) > 0 + || preg_match('/^\\"[^\\"]*\\"$/',$attribute_name) > 0 ) { + // 属性名候補がクォーテーションで囲まれていたら + if( '>' == $prev_char ) { + // 直前の文字がオブジェクトメンバ指定子の場合クォーテーションを除去して確認 + $name = preg_replace('/^\\\'/','',$attribute_name); + $name = preg_replace('/\\\'$/','',$name); + $name = preg_replace('/^\\"/','',$name); + $name = preg_replace('/\\"$/','',$name); + if( preg_match('/^[^0-9][0-9a-zA-Z\\_]*$/', $name ) > 0 ) { + // メンバ名として有効そうであればクォーテーションを除去した文字列へ変換 + $real_var_string = str_replace($attribute_name,$name,$real_var_string); + } else { + // 暫定:有効なメンバでない場合使い方が正しくないのでPHPのコアエラーとし何もしない + continue; + } + } else { + // 直前の文字列がオブジェクトメンバ指定子でない場合は変換しない + continue; + } + } else { + // それ以外の場合はグローバル変数名として変換 + $replacew = '$GLOBALS[\''.$attribute_name.'\']'; + $real_var_string = str_replace($attribute_name,$replacew,$real_var_string); } - $counter_name = str_replace('.','_',$var_name)."_".$at_name."_loop_counter"; - $rep_string = "getAttribute( "'.$var_name.'" ); '; - $rep_string .= '$type = gettype($tmp_arry'.$valiable_counter.'); '; - if ( strlen( trim($at_name ) ) > 0 ) { - $rep_string .= 'if(\'array\'==$type) { $tmp_arry'.$valiable_counter.'=$tmp_arry'.$valiable_counter.'[\''.$at_name.'\']; } '; - $rep_string .= 'if(\'object\'==$type) { $tmp_arry'.$valiable_counter.'=$tmp_arry'.$valiable_counter.'->'.$at_name.'; } '; - $rep_string .= '$type = gettype($tmp_arry'.$valiable_counter.'); '; + } + return $real_var_string; + } + return ''; + } + /** + * 属性名が配列要素指定やオブジェクトメンバ指定子を含む場合に変換候補属性名文字列を + * 文字列長の長い順番にハッシュにして返します + */ + function getReverseSortedProposeAttributeHash( $org_attribute_name ) { + $attribute_sort_array = array(); + if( preg_match( '/\\-\\>/',$org_attribute_name ) > 0 || preg_match('/\\[.+\\]/',$org_attribute_name) > 0 ) { + $attribute_proposed_array = array(); + $pos=0; + for( $i=0; $i' == $char + || '(' == $char || ')' == $char + || '[' == $char || ']' == $char ) { + // 演算子が登場したらひとつ前までを文字列切り出し + $str = trim(substr( $org_attribute_name, $pos, $i-$pos )); + $pos = $i+1; + if( '(' != $char && strlen( $str ) > 0 ) { + // 関数名でなければ変換対象として評価 + $attribute_sort_array[$str] = strlen($str); + $attribute_proposed_array[$str] = $char; + } } - $rep_string .= 'if(\'array\'==$type) { ' - . '$'.$counter_name.'=0; ' - . 'foreach( $tmp_arry'.$valiable_counter.' as $' . $k_name . '=>$' . $v_name . ' ) { ' - . '$'.$counter_name.'++; ' - . '$request_object->setAttribute("'.$counter_name.'",$'.$counter_name.'); ' - . '$request_object->setAttribute("'.$k_name.'",$'.$k_name.'); ' - . '$request_object->setAttribute("'.$v_name.'",$'.$v_name.'); ?>' - ; - $result_strings = str_replace( $vars_tag, $rep_string, $result_strings ); - $result_strings = str_replace( '{end-foreach}', '', $result_strings ); - $result_strings = str_replace( '{/foreach}', '', $result_strings ); - $valiable_counter++; } + // ループ最後のポジションから最後の要素を切り出し + $str = trim(substr( $org_attribute_name, $pos, $i-$pos )); + if( strlen( $str ) > 0 ) { + $attribute_sort_array[$str] = strlen($str); + } + // 変数配列を文字列の長い順にソート + arsort($attribute_sort_array); + // 直前の文字を代入 + foreach( $attribute_sort_array as $key => $value ) { + $attribute_sort_array[$key] = $attribute_proposed_array[$key]; + } } + return $attribute_sort_array; } } ?> \ No newline at end of file Modified: current/DATA/lib/spider/tags/Module.class.php =================================================================== --- current/DATA/lib/spider/tags/Module.class.php 2009-03-23 12:03:37 UTC (rev 3) +++ current/DATA/lib/spider/tags/Module.class.php 2009-03-24 09:12:21 UTC (rev 4) @@ -43,28 +43,19 @@ */ function spider_tags_Module() { $this->priority = 10; + $this->tag_name = 'module'; } /** - * コンバートメソッド + * 個々のタグ文字列の変換後文字列を取得します */ - function convert( &$result_strings, &$build_information ){ - // モジュール読み込みタグ - $vars_tags_aray = array(); - if( preg_match_all( '/\\{module\\:[^\\}]*?}/' - , $result_strings - , $vars_tags_aray - , PREG_PATTERN_ORDER ) > 0 ) { - foreach ( $vars_tags_aray as $vars_tags ) { - foreach ( $vars_tags as $vars_tag ) { - $module_name = preg_replace( '/\\{module\\:/','', $vars_tag ); - $module_name = preg_replace( '/\\}$/','', $module_name ); - $build_information->addExecModuleByString( $module_name ); - $result_strings = str_replace( $vars_tag - , '' - , $result_strings ); - } - } + function getConvertedStrings( &$result_strings, &$build_information, $option_array=array(), $valiable_counter=0 ) { + // モジュール追加の場合はオプションも含めた文字列をそのまま設定 + $module_string = implode(' ', $option_array); + if( strlen($module_string) > 0 ) { + $build_information->addExecModuleByString( $module_string ); } + // モジュールタグは削除する為空文字列を返す + return ''; } } ?> \ No newline at end of file Modified: current/DATA/lib/spider/tags/PageTitle.class.php =================================================================== --- current/DATA/lib/spider/tags/PageTitle.class.php 2009-03-23 12:03:37 UTC (rev 3) +++ current/DATA/lib/spider/tags/PageTitle.class.php 2009-03-24 09:12:21 UTC (rev 4) @@ -39,9 +39,7 @@ } } } - // 互換の為creatorに設定 - $build_information->page_title = $page_title; - // 前処理追加:互換性の為ページタイトルをセット + // 前処理追加:ページタイトルを属性にセット $process_code = '$page_title="'.str_replace("'","\\'",$page_title).'";'."\n"; $process_code .= '$request_object->setAttribute("page_title",$page_title );'."\n"; if( !is_array($build_information->preview_process_hash) ){ Modified: current/DATA/lib/spider/tags/TagBase.class.php =================================================================== --- current/DATA/lib/spider/tags/TagBase.class.php 2009-03-23 12:03:37 UTC (rev 3) +++ current/DATA/lib/spider/tags/TagBase.class.php 2009-03-24 09:12:21 UTC (rev 4) @@ -34,6 +34,7 @@ $tag_regx = CharUtility::escape_regx_str('{'.$this->tag_name); $tag_search_regx = $tag_regx.'[^\\}]*?\\}'; $tag_strings_array = array(); + $valiable_counter = 0; while( preg_match_all( '/'.$tag_search_regx.'/' , $result_strings , $tag_strings_array @@ -45,11 +46,15 @@ if( strlen(trim($options_string)) == 0 ) { // タグが終了しているようならオプション無で処理 $option_array = array(); - $converted_strings = $this->getConvertedStrings( &$result_strings, &$build_information, $option_array ); + $converted_strings = $this->getConvertedStrings( &$result_strings, &$build_information, $option_array, $valiable_counter ); $result_strings = str_replace( $target_tag, $converted_strings, $result_strings ); } else if( preg_match('/^\\:/', $options_string) > 0 ) { // :で始まっているならオプション文字列なのでオプションを取り出して処理 $options_string = preg_replace('/^\\:/','',$options_string); + // 2文字以上連続のスペースは1文字に統一 + while( preg_match('/\\s\\s/',$options_string) > 0 ) { + $options_string = str_replace( ' ',' ', $options_string ); + } $param_array = explode(' ', $options_string); $option_array = array(); foreach( $param_array as $param ) { @@ -58,11 +63,12 @@ array_push( $option_array, $param ); } } - $converted_strings = $this->getConvertedStrings( &$result_strings, &$build_information, $option_array ); + $converted_strings = $this->getConvertedStrings( &$result_strings, &$build_information, $option_array, $valiable_counter ); $result_strings = str_replace( $target_tag, $converted_strings, $result_strings ); } else { // 終了でも:でもないなら違うタグなので処理しない } + $valiable_counter++; } } } @@ -71,7 +77,7 @@ * 個々のタグ文字列の変換後文字列を取得します * 必要に応じて拡張したタグクラスで実装してください。 */ - function getConvertedStrings( &$result_strings, &$build_information, $option_array=array() ) { + function getConvertedStrings( &$result_strings, &$build_information, $option_array=array(), $valiable_counter=0 ) { return ''; } } Modified: current/DATA/lib/spider/tags/Widget.class.php =================================================================== (Binary files differ) Modified: current/DATA/lib/spider/tags/Write.class.php =================================================================== --- current/DATA/lib/spider/tags/Write.class.php 2009-03-23 12:03:37 UTC (rev 3) +++ current/DATA/lib/spider/tags/Write.class.php 2009-03-24 09:12:21 UTC (rev 4) @@ -149,7 +149,6 @@ $var_name_array[trim($str)] = ''; } - // 変数一時格納配列 $temporary_valiable_getter_array = array(); @@ -160,6 +159,9 @@ if( is_numeric( $key ) ) { // 変数が数字なら変換対象としない $var_name_array[$key] = $key; + } else if( preg_match( '/^$[^0-9][.]*$/', $key ) > 0 ) { + // 変数名なら変換対象としない + $var_name_array[$key] = $key; } else { // 変数が文字列の場合 $tmp_name = '$____tw__' . sprintf('%03d',$prefix) . sprintf('%03d',$vcounter); Modified: current/README.txt =================================================================== --- current/README.txt 2009-03-23 12:03:37 UTC (rev 3) +++ current/README.txt 2009-03-24 09:12:21 UTC (rev 4) @@ -4,3 +4,42 @@ ** このファイルにはコミットごとに変更点とファイル名を記述します。 ** +-- 2009-03-24 +1) モジュール呼び出しタグでGET/POST値の一時上書き指定があった場合に、同じモジュールでも複数回 + 呼び出しを行うよう修正しました。 + 【修正ファイル】 + DATA/lib/spider/BuildInformation.class.php + DATA/lib/spider/ExecutableFileCreator.class.php + +2)モジュールタグクラスを新TagBaseの書式に合わせてスリム化しました。 + 【修正ファイル】 + DATA/lib/spider/tags/Module.class.php + +3)ページタイトルタグクラスで不要コードを削除しコメントを適正化 + 【修正ファイル】 + DATA/lib/spider/tags/PageTitle.class.php + +4) タグベースクラスのメソッドgetConvertedStringsの第4引数に$valiable_counterを追加 + 標準で、何回目に発見したタグかの回数を0からスタートして渡します。 + これに伴いModuleタグとWidgetタグに記述されていた該当メソッドも引数追加しました。 + ・オプションの複数連続スペースをひとつにするよう処理を追加しました。 + 【修正ファイル】 + DATA/lib/spider/tags/TagBase.class.php + DATA/lib/spider/tags/Module.class.php + DATA/lib/spider/tags/Widget.class.php + +5) foreachタグをリファクタリングし、機能を強化しました + ループ対象として従来の::指定で配列属性値の要素やオブジェクト属性値のメンバにアクセスできた機能はそのままに + 対象がオブジェクトとわかっている場合は->指定子で + 対象が配列やハッシュとわかっている場合には[添え字]で + 要素やメンバに指定することができるようになりました。 + ::によるアクセスは一階層まででしたが、この記述を行えばアクセス可能な階層に制限はありません。 + 【修正ファイル】 + DATA/lib/spider/tags/Foreach.class.php + +6) writeタグの機能追加 + writeタグでタグ内に記述された$から始まるPHP変数は変換対象としないように変更しました。 + これにより、ページ内で宣言・初期化された変数をwriteタグ内で利用できます。 + 【修正ファイル】 + DATA/lib/spider/tags/Write.class.php + Modified: current/WWW_PUBLIC/index.php =================================================================== --- current/WWW_PUBLIC/index.php 2009-03-23 12:03:37 UTC (rev 3) +++ current/WWW_PUBLIC/index.php 2009-03-24 09:12:21 UTC (rev 4) @@ -4,4 +4,4 @@ {module:example.Hello force post(a="afds) get() attribute_prefix(media)} {module:example.Hello force} {dynamic-page} -{output-html:lifetime=300} \ No newline at end of file +{output-html} \ No newline at end of file From svnnotify @ sourceforge.jp Tue Mar 24 19:30:59 2009 From: svnnotify @ sourceforge.jp (svnnotify @ sourceforge.jp) Date: Tue, 24 Mar 2009 19:30:59 +0900 Subject: [Frameworkspider-svn] spider-commit [5] Message-ID: <1237890659.847366.14250.nullmailer@users.sourceforge.jp> Revision: 5 http://svn.sourceforge.jp/view?root=frameworkspider&view=rev&rev=5 Author: m_nakashima Date: 2009-03-24 19:30:59 +0900 (Tue, 24 Mar 2009) Log Message: ----------- Modified Paths: -------------- current/DATA/lib/spider/tags/SetAttribute.class.php current/README.txt -------------- next part -------------- Modified: current/DATA/lib/spider/tags/SetAttribute.class.php =================================================================== --- current/DATA/lib/spider/tags/SetAttribute.class.php 2009-03-24 09:12:21 UTC (rev 4) +++ current/DATA/lib/spider/tags/SetAttribute.class.php 2009-03-24 10:30:59 UTC (rev 5) @@ -53,6 +53,7 @@ // 値がクォーテーションで囲まれている場合は中の値をそのまま登録する $rep_string .= '$tmp='.$var_value.'; '; $rep_string .= '$request_object->setAttribute( "' . $var_name . '",$tmp ); '; + $rep_string .= '$GLOBALS["' . $var_name . '"] =$tmp; '; } else { // 値がクォーテーションで囲まれていない場合は、スコープから変数を探して登録 if( preg_match('/\\:\\:/',$var_value) > 0 ) { @@ -140,6 +141,7 @@ $rep_string .= '$tmp = $request_object->getAttribute( "' . $var_value . '" ); '; } $rep_string .= '$request_object->setAttribute( "' . $var_name . '", $tmp ); '; + $rep_string .= '$GLOBALS["' . $var_name . '"] =$tmp; '; } $rep_string .= " ?>"; $result_strings = str_replace( $vars_tag, $rep_string, $result_strings ); Modified: current/README.txt =================================================================== --- current/README.txt 2009-03-24 09:12:21 UTC (rev 4) +++ current/README.txt 2009-03-24 10:30:59 UTC (rev 5) @@ -43,3 +43,6 @@ 【修正ファイル】 DATA/lib/spider/tags/Write.class.php +7) setタグにて属性だけでなく$GLOBALSにも同じ名前で登録するよう追加 + 【修正ファイル】 + DATA/lib/spider/tags/SetAttribute.class.php From svnnotify @ sourceforge.jp Tue Mar 24 22:15:43 2009 From: svnnotify @ sourceforge.jp (svnnotify @ sourceforge.jp) Date: Tue, 24 Mar 2009 22:15:43 +0900 Subject: [Frameworkspider-svn] spider-commit [6] Message-ID: <1237900543.549773.29263.nullmailer@users.sourceforge.jp> Revision: 6 http://svn.sourceforge.jp/view?root=frameworkspider&view=rev&rev=6 Author: m_nakashima Date: 2009-03-24 22:15:43 +0900 (Tue, 24 Mar 2009) Log Message: ----------- Modified Paths: -------------- current/DATA/lib/spider/tags/Widget.class.php current/README.txt -------------- next part -------------- Modified: current/DATA/lib/spider/tags/Widget.class.php =================================================================== (Binary files differ) Modified: current/README.txt =================================================================== --- current/README.txt 2009-03-24 10:30:59 UTC (rev 5) +++ current/README.txt 2009-03-24 13:15:43 UTC (rev 6) @@ -46,3 +46,9 @@ 7) setタグにて属性だけでなく$GLOBALSにも同じ名前で登録するよう追加 【修正ファイル】 DATA/lib/spider/tags/SetAttribute.class.php + +8) ウィジェットタグにリンク機能を追加しました。 + ウィジェットファイル内に{widget-link:参照したいウィジェットファイル名}のみ記述することで + ウィジェットファイル名のファイルを参照します。 + これにより、複数同じウィジェットを階層ごとに作成するようなケースを避けることができます。 + From svnnotify @ sourceforge.jp Wed Mar 25 10:44:36 2009 From: svnnotify @ sourceforge.jp (svnnotify @ sourceforge.jp) Date: Wed, 25 Mar 2009 10:44:36 +0900 Subject: [Frameworkspider-svn] =?utf-8?q?spider-commit_=5B7=5D__=E3=83=AA?= =?utf-8?b?44OV44Kh44Kv44K/44Oq44Oz44Kw44Gn44GZ44CC5qmf6IO944G444Gu5b2x?= =?utf-8?b?6Z+/44Gv44GC44KK44G+44Gb44KT44CC?= Message-ID: <1237945476.562611.27586.nullmailer@users.sourceforge.jp> Revision: 7 http://svn.sourceforge.jp/view?root=frameworkspider&view=rev&rev=7 Author: m_nakashima Date: 2009-03-25 10:44:36 +0900 (Wed, 25 Mar 2009) Log Message: ----------- リファクタリングです。機能への影響はありません。 Modified Paths: -------------- current/DATA/lib/spider/HttpOutput.class.php -------------- next part -------------- Modified: current/DATA/lib/spider/HttpOutput.class.php =================================================================== --- current/DATA/lib/spider/HttpOutput.class.php 2009-03-24 13:15:43 UTC (rev 6) +++ current/DATA/lib/spider/HttpOutput.class.php 2009-03-25 01:44:36 UTC (rev 7) @@ -33,10 +33,7 @@ // ビルド情報クラスの作成 $build_information_object = new spider_BuildInformation(); - // 実行ファイル作成オブジェクト - $creater_object = new spider_ExecutableFileCreator(); - - // ユーザーエージェントタイプをリクエストにセット + // ユーザーエージェント分類をリクエストにセット $request->setAttribute('spider.access_agent_class',$build_information_object->agent_class); // ビルドファイルパスを取得 @@ -95,6 +92,9 @@ } } + // 実行ファイル作成オブジェクト + $creater_object = new spider_ExecutableFileCreator(); + // 実行ファイル作成 $creater_object->createBinFile( $build_information_object ); $lock_obj->release(); From svnnotify @ sourceforge.jp Wed Mar 25 13:23:45 2009 From: svnnotify @ sourceforge.jp (svnnotify @ sourceforge.jp) Date: Wed, 25 Mar 2009 13:23:45 +0900 Subject: [Frameworkspider-svn] spider-commit [8] Message-ID: <1237955025.009638.26606.nullmailer@users.sourceforge.jp> Revision: 8 http://svn.sourceforge.jp/view?root=frameworkspider&view=rev&rev=8 Author: m_nakashima Date: 2009-03-25 13:23:44 +0900 (Wed, 25 Mar 2009) Log Message: ----------- Modified Paths: -------------- current/DATA/define.inc.php current/DATA/lib/spider/Controller.class.php current/DATA/spider_main.inc.php current/DATA/unique_setting.inc.php current/README.txt Added Paths: ----------- current/DATA/lib/util/File.class.php -------------- next part -------------- Modified: current/DATA/define.inc.php =================================================================== --- current/DATA/define.inc.php 2009-03-25 01:44:36 UTC (rev 7) +++ current/DATA/define.inc.php 2009-03-25 04:23:44 UTC (rev 8) @@ -62,7 +62,7 @@ * 基本定義 */ // ライブラリフォルダの絶対パス -define ( 'DIR_PATH_LIB', DIR_PATH_SPIDER_DATA.DIRECTORY_SEPARATOR.DIR_NAME_LIB ); +define( 'DIR_PATH_LIB', DIR_PATH_SPIDER_DATA.DIRECTORY_SEPARATOR.DIR_NAME_LIB ); // テンプレートディレクトリパス define( 'DIR_PATH_TEMPLATES', DIR_PATH_SPIDER_DATA.DIRECTORY_SEPARATOR.DIR_NAME_TEMPLATES ); // ウィジェットディレクトリパス Modified: current/DATA/lib/spider/Controller.class.php =================================================================== --- current/DATA/lib/spider/Controller.class.php 2009-03-25 01:44:36 UTC (rev 7) +++ current/DATA/lib/spider/Controller.class.php 2009-03-25 04:23:44 UTC (rev 8) @@ -25,11 +25,13 @@ /** * コンストラクタ */ - function Controller() { + function Controller( & $request_object, & $http_output_obj ) { $this->executed_module_info_array = array(); $this->executed_module_object_array = array(); $this->post_hash = $_POST; $this->get_hash = $_GET; + $this->request_object = & $request_object; + $this->http_output_object = & $http_output_obj; } /** @@ -39,8 +41,13 @@ */ function execute( & $request_object, & $http_output_obj ) { - $this->request_object = & $request_object; - $this->http_output_object = & $http_output_obj; + if( is_null($request_object) ) { + $this->request_object = & $request_object; + } + if( is_null($http_output_obj) ) { + $this->http_output_object = & $http_output_obj; + } + // グローバルエラーが存在したらエラーに追加 $global_errors = unserialize( $_SESSION['spider.global_errors'] ); if( is_array( $global_errors ) ) { Added: current/DATA/lib/util/File.class.php =================================================================== --- current/DATA/lib/util/File.class.php (rev 0) +++ current/DATA/lib/util/File.class.php 2009-03-25 04:23:44 UTC (rev 8) @@ -0,0 +1,52 @@ + \ No newline at end of file Modified: current/DATA/spider_main.inc.php =================================================================== --- current/DATA/spider_main.inc.php 2009-03-25 01:44:36 UTC (rev 7) +++ current/DATA/spider_main.inc.php 2009-03-25 04:23:44 UTC (rev 8) @@ -83,8 +83,19 @@ $base_path = APPLICATION_BASE_PATH; $GLOBALS['request_object']->setAttribute( 'spider.base_path', $base_path ); -// メイン処理 -$GLOBALS['controller'] = new Controller(); +// コントローラー +$GLOBALS['controller'] = new Controller( $GLOBALS['request_object'], $GLOBALS['output_object'] ); +// 前処理スクリプトの指定があるなら読み込む +if( is_array($GLOBALS['SPIDER_PREVIOUS_SCRIPT_FILE_PATH_ARRAY']) + && count($GLOBALS['SPIDER_PREVIOUS_SCRIPT_FILE_PATH_ARRAY']) > 0 ) { + foreach( $GLOBALS['SPIDER_PREVIOUS_SCRIPT_FILE_PATH_ARRAY'] as $script_path ) { + $script_path = trim( $script_path ); + if( strlen($script_path) > 0 && file_exists( $script_path) ) { + include_once( $script_path ); + } + } +} +// メイン処理実行 $GLOBALS['controller']->execute( $GLOBALS['request_object'], $GLOBALS['output_object'] ); die; Modified: current/DATA/unique_setting.inc.php =================================================================== --- current/DATA/unique_setting.inc.php 2009-03-25 01:44:36 UTC (rev 7) +++ current/DATA/unique_setting.inc.php 2009-03-25 04:23:44 UTC (rev 8) @@ -2,6 +2,17 @@ /* * framework-spider: アプリケーション固有のグローバル変数の定義用ファイル */ +/** + * 前処理スクリプトファイルパス配列 + * + * ビルドファイルを作成する前に処理したいプログラムを記述したスクリプトファイルを用意して + * 実行させることができます。このスクリプト読み込み実行はコマンドラインからの実行でない + * 限りビルドファイルのあるなしに関わらず事前に必ず実行されます。 + * スクリプトファイルの中で標準出力を行ってはいけません。 + * ページ表示というイベントに対するフックスクリプトのようなイメージで利用してください。 + */ +$GLOBALS['SPIDER_PREVIOUS_SCRIPT_FILE_PATH_ARRAY'] = array(); + /** 都道府県ハッシュ */ $GLOBALS['PREFECTURE_HASH'] = array( 1=>'北海道', Modified: current/README.txt =================================================================== --- current/README.txt 2009-03-25 01:44:36 UTC (rev 7) +++ current/README.txt 2009-03-25 04:23:44 UTC (rev 8) @@ -3,7 +3,23 @@ ** ** このファイルにはコミットごとに変更点とファイル名を記述します。 ** +-- 2009-03-25 +1)ビルドファイル作成前に行いたい処理スクリプトを指定する機能を追加しました。 + グローバル変数として配列$GLOBALS['SPIDER_PREVIOUS_SCRIPT_FILE_PATH_ARRAY']を定義し、 + スクリプトファイルの絶対パスを記述すれば、常にスクリプトを実行します。 + + この配列宣言はアプリケーションごとの指定の為、define.inc.phpではなく、unique_setting.inc.php内で記述してください。 + + スクリプトファイルの中で標準出力を行ってはいけません。 + ページ表示イベントに対するフックスクリプトのようなイメージで利用してください。 +2)1)に伴い、Controller.class.phpのコンストラクタに引数を追加し、リクエストとアウトプットオブジェクトを渡せるようにしました。 + フックスクリプトでControllerクラスのloadModuleメソッドを呼ぶことができます。 + コントローラオブジェクトは$GLOBALS['controller']で宣言されています。 + +3)utilライブラリにファイルシステム用ユーティリティメソッドクラスであるutil_Fileクラスを追加しました。 + クラスコードはDATA/util/File.class.phpに記述しています。 + -- 2009-03-24 1) モジュール呼び出しタグでGET/POST値の一時上書き指定があった場合に、同じモジュールでも複数回 呼び出しを行うよう修正しました。 From svnnotify @ sourceforge.jp Wed Mar 25 18:03:06 2009 From: svnnotify @ sourceforge.jp (svnnotify @ sourceforge.jp) Date: Wed, 25 Mar 2009 18:03:06 +0900 Subject: [Frameworkspider-svn] spider-commit [9] Message-ID: <1237971786.712647.23539.nullmailer@users.sourceforge.jp> Revision: 9 http://svn.sourceforge.jp/view?root=frameworkspider&view=rev&rev=9 Author: m_nakashima Date: 2009-03-25 18:03:06 +0900 (Wed, 25 Mar 2009) Log Message: ----------- Modified Paths: -------------- current/DATA/lib/spider/tags/Foreach.class.php current/README.txt -------------- next part -------------- Modified: current/DATA/lib/spider/tags/Foreach.class.php =================================================================== --- current/DATA/lib/spider/tags/Foreach.class.php 2009-03-25 04:23:44 UTC (rev 8) +++ current/DATA/lib/spider/tags/Foreach.class.php 2009-03-25 09:03:06 UTC (rev 9) @@ -84,7 +84,7 @@ list( $attribute_name, $member_name ) = explode( '::', $org_attribute_name ); // 対象属性値 $target_attribute_name = '$GLOBALS[\''.$attribute_name.'\']'; - $rep_string .= $real_loop_var_name.'='.$target_attribute_name.'[\''.$member_name.'\']; '; + $rep_string .= $real_loop_var_name.'='.$target_attribute_name.'; '; if( strlen( $member_name ) > 0 ) { // メンバ指定がある場合は属性値がオブジェクトか配列かで分岐処理 $rep_string .= 'if( is_array('.$target_attribute_name.') ){ '; Modified: current/README.txt =================================================================== --- current/README.txt 2009-03-25 04:23:44 UTC (rev 8) +++ current/README.txt 2009-03-25 09:03:06 UTC (rev 9) @@ -20,6 +20,8 @@ 3)utilライブラリにファイルシステム用ユーティリティメソッドクラスであるutil_Fileクラスを追加しました。 クラスコードはDATA/util/File.class.phpに記述しています。 +4)新しいforeachタグの作成する実行ファイルがPHP5.1.6にて動作不具合を起こす問題を修正 + -- 2009-03-24 1) モジュール呼び出しタグでGET/POST値の一時上書き指定があった場合に、同じモジュールでも複数回 呼び出しを行うよう修正しました。 From svnnotify @ sourceforge.jp Thu Mar 26 21:01:45 2009 From: svnnotify @ sourceforge.jp (svnnotify @ sourceforge.jp) Date: Thu, 26 Mar 2009 21:01:45 +0900 Subject: [Frameworkspider-svn] spider-commit [10] Message-ID: <1238068905.963087.9859.nullmailer@users.sourceforge.jp> Revision: 10 http://svn.sourceforge.jp/view?root=frameworkspider&view=rev&rev=10 Author: m_nakashima Date: 2009-03-26 21:01:45 +0900 (Thu, 26 Mar 2009) Log Message: ----------- Modified Paths: -------------- current/DATA/lib/spider/tags/If.class.php current/DATA/lib/spider/tags/OutputHtml.class.php current/DATA/lib/spider/tags/TagBase.class.php current/README.txt -------------- next part -------------- Modified: current/DATA/lib/spider/tags/If.class.php =================================================================== --- current/DATA/lib/spider/tags/If.class.php 2009-03-25 09:03:06 UTC (rev 9) +++ current/DATA/lib/spider/tags/If.class.php 2009-03-26 12:01:45 UTC (rev 10) @@ -43,6 +43,7 @@ * コンバートメソッド */ function convert( &$result_strings, &$build_information ){ + // ifの変換 $vars_tags_aray = array(); preg_match_all( '/\\{if\\:[^\\}]*?}/' , $result_strings @@ -51,19 +52,139 @@ $valiable_counter = 0; foreach ( $vars_tags_aray as $vars_tags ) { foreach ( $vars_tags as $vars_tag ) { - $var_name = preg_replace( '/\\{if\\:/','', $vars_tag ); - $var_name = preg_replace( '/\\}$/','', $var_name ); - $var_name = trim( $var_name ); - $repstr = $this->parseCondition( $var_name, $valiable_counter ); + $option_string = preg_replace( '/\\{if\\:/','', $vars_tag ); + $option_string = preg_replace( '/\\}$/','', $option_string ); + $option_string = trim( $option_string ); + // 下位互換の為::を含むなら旧ロジック + $repstr = ''; + if( preg_match('/\\:\\:/',$option_string) > 0 ) { + $repstr = $this->parseCondition( $option_string, $valiable_counter ); + } else { + $repstr = 'condition2code( $option_string ).' ) { ?>'; + } $result_strings = str_replace( $vars_tag, $repstr, $result_strings ); $valiable_counter++; } } + // else-ifの変換 + $vars_tags_aray = array(); + preg_match_all( '/\\{else\\-if\\:[^\\}]*?}/' + , $result_strings + , $vars_tags_aray + , PREG_PATTERN_ORDER ); + $valiable_counter = 0; + foreach ( $vars_tags_aray as $vars_tags ) { + foreach ( $vars_tags as $vars_tag ) { + $option_string = preg_replace( '/\\{else\\-if\\:/','', $vars_tag ); + $option_string = preg_replace( '/\\}$/','', $option_string ); + $option_string = trim( $option_string ); + $repstr = 'condition2code( $option_string ).' ) { ?>'; + $result_strings = str_replace( $vars_tag, $repstr, $result_strings ); + $valiable_counter++; + } + } + $result_strings = str_replace( '{else}', '', $result_strings ); $result_strings = str_replace( '{end-if}', '', $result_strings ); $result_strings = str_replace( '{/if}', '', $result_strings ); } /** + * ifタグ内の条件式を解析します。 + */ + function condition2code( $strings ) { + // 演算時の正規表現 + $signiture_regx = '\\+\\-\\/\\*\\%\\=\\<\\>\\&\\|\\(\\)\\!\\,\\[\\]'; + + // 2文字以上連続のスペースは1文字に統一 + while( preg_match('/\\s\\s/',$strings) > 0 ) { + $strings = str_replace( ' ',' ', $strings ); + } + + // 下位互換の為、and/orは演算子に置換する + $strings = str_replace(' and ', ' && ', $strings ); + $strings = str_replace(' or ', ' || ', $strings ); + // 下位互換の為、is null / is not nullを置換する + $strings = preg_replace('/(|\\s)([^\\s'.$signiture_regx.']*)\\sis\\snull/','$1is_null( $2 )',$strings); + $strings = preg_replace('/(|\\s)([^\\s'.$signiture_regx.']*)\\sis\\snot\\snull/','$1!is_null( $2 )',$strings); + // 下位互換の為inも置換する + $strings = preg_replace('/(|\\s)([^\\s]*)\\sin\\s([^\\s\\}'.$signiture_regx.']*)/','$1in_array( $2 )',$strings); + // 下位互換の為連続していない=は連続=に変換しておく(if文中で代入が利用できなくなる為要検討) + $strings = preg_replace('/([^\\+\\-\\/\\*\\%\\=\\<\\>])\\=([^\\=])/','$1==$2',$strings); + + $converted_strings = ''; + $element_array = preg_split('/([\\s'.$signiture_regx.'])/', $strings, -1, PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE ); + $element_data = ''; + $prev_data = ''; + foreach( $element_array as $key => $element ) { + $element_data .= $element; + if( preg_match('/^\\\'/',$element_data) > 0 && substr_count( $element_data, "'" ) % 2 == 1 ) { + // 'から始まって'の数が偶数個なら次のカラムとつなげる + continue; + } else if( preg_match('/^\\\'/',$element_data) > 0 && substr_count( $element_data, "'" ) % 2 == 1 ) { + // 'から始まって'の数が偶数個なら次のカラムとつなげる + continue; + } else { + if( preg_match('/([\\s'.$signiture_regx.'])/',$element_data) == 0 ) { + // 演算子でない場合のみ処理 + if( preg_match('/^\\$/',$element_data ) > 0 ) { + // $から始まるなら変換しないでそのまま追加 + $converted_strings .= $element_data; + } else if( preg_match('/^\\\'/',$element_data ) > 0 && preg_match('/\\\'$/',$element_data ) > 0 ) { + // クォートされているなら文字列 + if( $key > 2 && $element_array[$key-1] == '>' && $element_array[$key-2] == '-'){ + // 前の要素が->オブジェクトメンバ指定子の場合クォートを除去して追加 + $converted_strings .= preg_replace('/(^\'|\'$)/','',$element_data); + } else { + // ただの文字列の場合はそのまま追加 + $converted_strings .= $element_data; + } + } else if( preg_match('/^\\\"/',$element_data ) > 0 && preg_match('/\\\"$/',$element_data ) > 0 ) { + // クォートされているなら文字列 + if( $key > 2 && $element_array[$key-1] == '>' && $element_array[$key-2] == '-'){ + // 前の要素が->オブジェクトメンバ指定子の場合 + $converted_strings .= preg_replace('/(^\\"|\\"$)/','',$element_data); + } else { + // ただの文字列の場合はそのまま追加 + $converted_strings .= $element_data; + } + } else if( preg_match('/^[0-9]+$/',$element_data ) > 0 ) { + // 数字だけならそのまま追加 + $converted_strings .= $element_data; + } else { + // 次の演算子以外の要素が(なら関数なので次の空でない要素をチェック + $is_method = false; + for( $i=$key+1;$i 0 ) { + if( $val == '(' ) { + $is_method = true; + } + break; + } + } + if( $is_method ) { + // 関数名・メソッド名の場合はそのまま追加 + $converted_strings .= $element_data; + } else if( $key > 2 && $element_array[$key-1] == '>' && $element_array[$key-2] == '-'){ + // メソッドでなくて前の要素が->の場合オブジェクトメンバも変換(要検討...) + $converted_strings .= '$GLOBALS[\''.$element_data.'\']'; + } else { + // それ以外は$GLOBALSへ変換 + $converted_strings .= '$GLOBALS[\''.$element_data.'\']'; + } + } + } else { + // 演算子はそのまま追加 + $converted_strings .= $element_data; + } + $prev_data = $element_data; + $element_data = ''; + } + } + + return $converted_strings; + } + /** * if条件文の式を解析する * 定義済み文字列: and / or / = / != / > / < / + / - / * // is null /is not null/in */ Modified: current/DATA/lib/spider/tags/OutputHtml.class.php =================================================================== --- current/DATA/lib/spider/tags/OutputHtml.class.php 2009-03-25 09:03:06 UTC (rev 9) +++ current/DATA/lib/spider/tags/OutputHtml.class.php 2009-03-26 12:01:45 UTC (rev 10) @@ -78,6 +78,7 @@ // コード追加 $html_path = preg_replace('/\\.php$/','.html',$build_information->execute_file_path); $html_path = str_replace('"','\\"',$html_path); + $html_path = str_replace('\\','\\\\',$html_path); $process_code = 'if( !file_exists("'.$html_path.'") || time() - filemtime("'.$html_path.'") > '.$lifetime.' ){'."\n"; $process_code .= '$fp = fopen("'.$html_path.'","w");'."\n"; $process_code .= 'if($fp){'."\n"; Modified: current/DATA/lib/spider/tags/TagBase.class.php =================================================================== --- current/DATA/lib/spider/tags/TagBase.class.php 2009-03-25 09:03:06 UTC (rev 9) +++ current/DATA/lib/spider/tags/TagBase.class.php 2009-03-26 12:01:45 UTC (rev 10) @@ -27,6 +27,17 @@ * コンバートメソッド */ function convert( &$result_strings, &$build_information ){ + // デフォルト動作は設定済みタグ名称でのシングルタグ全変換 + $this->convertSingleTagAll( $result_strings, $build_information ); + } + /** + * 要素のみのシングルタグ変換を実行します + */ + function convertSingleTagAll( &$result_strings, &$build_information, $tag_name=null ) { + // タグ名称が渡された場合のみ設定 + if( !is_null($tag_name) && strlen($tag_name) > 0 ) { + $this->tag_name = $tag_name; + } // タグ名称が設定されていないなら処理をしない if( is_null($this->tag_name) || strlen($this->tag_name) == 0 ) { return; @@ -51,11 +62,7 @@ } else if( preg_match('/^\\:/', $options_string) > 0 ) { // :で始まっているならオプション文字列なのでオプションを取り出して処理 $options_string = preg_replace('/^\\:/','',$options_string); - // 2文字以上連続のスペースは1文字に統一 - while( preg_match('/\\s\\s/',$options_string) > 0 ) { - $options_string = str_replace( ' ',' ', $options_string ); - } - $param_array = explode(' ', $options_string); + $param_array = $this->splitOptionBySpace( $options_string ); $option_array = array(); foreach( $param_array as $param ) { $param = trim($param); @@ -72,6 +79,7 @@ } } } + return; } /** * 個々のタグ文字列の変換後文字列を取得します @@ -80,5 +88,39 @@ function getConvertedStrings( &$result_strings, &$build_information, $option_array=array(), $valiable_counter=0 ) { return ''; } + // + // タグ解析全般で利用するユーティリティメソッド + // + /** + * オプション文字列をオプション配列にします。 + */ + function splitOptionBySpace( $string ) { + // 2文字以上連続のスペースは1文字に統一 + while( preg_match('/\\s\\s/',$string) > 0 ) { + $string = str_replace( ' ',' ', $string ); + } + // 分割 + $column_array = explode(' ', $string); + // 最終的なオプション文字列配列 + $option_array = array(); + // クォートを維持してオプション文字列配列にいれる + $data = ''; + foreach( $column_array as $column ) { + $data .= $column; + if( preg_match('/^\\\'/',$data) > 0 && substr_count( $data, "'" ) % 2 == 1 ) { + // 'から始まって'の数が偶数個なら次のカラムとつなげる + continue; + } else if( preg_match('/^\\\"/',$data) > 0 && substr_count( $data, '"' ) % 2 == 1 ) { + // "から始まって"の数が偶数個なら次のカラムとつなげる + continue; + } else { + // そうでない場合はカラムがデータとして完結しているので配列に追加 + array_push( $option_array, $data ); + // 次のデータに備えてデータを空文字で新しく設定 + $data = ''; + } + } + return $option_array; + } } ?> \ No newline at end of file Modified: current/README.txt =================================================================== --- current/README.txt 2009-03-25 09:03:06 UTC (rev 9) +++ current/README.txt 2009-03-26 12:01:45 UTC (rev 10) @@ -3,6 +3,29 @@ ** ** このファイルにはコミットごとに変更点とファイル名を記述します。 ** +-- 2009-03-26 +1) OutputHtmlタグで出力するファイルパスがWindowsで不具合を起こす問題の修正 + +2) TagBaseクラスのリファクタリング + 今後に備え、デフォルト動作のシングルタグ用ロジックを別メソッドに切り分け + オプション文字列をスペース区切りクォート配慮して配列に分割するユーティリティメソッドsplitOptionBySpaceを追加 + +3) ifタグのリファクタリングと機能強化 + ifタグに新しい解析ロジックを導入。これにより{else-if:}機能を実装 + 新しいロジックでは[オブジェクト]::[メンバ名]もしくは[ハッシュ]::[要素名]での変数指定が行えない。 + オブジェクトの場合は->メンバ指定子で、ハッシュや配列の場合は[添え字]で指定する必要がある。 + この為、下位互換目的で::が条件文字列に含まれていると旧ロジックで解析するようにしてあります。 + + ::で要素やメンバ指定を行わない書式であれば + + ・ グローバル関数及びオブジェクトメソッド、オブジェクトメンバは自由に呼び出せます。 + ただし、オブジェクトメンバ変数を明示的に呼び出す場合は[オブジェクト]->'メンバ名'のように + メンバ変数名をシングルクォーテーションで囲む必要があります。 + ・ and,orの記述を、 &&,||に変更しました。and,orも使えますが推奨しません。 + ・ 一致の比較演算子=ひとつでOKでしたが、==で比較するよう変更することを推奨とします。 + ・ 固定文字列は''シングルクォートする必要があります。クォートしていないものは文字列として扱わず + request属性に登録されている属性名とみなします。 + -- 2009-03-25 1)ビルドファイル作成前に行いたい処理スクリプトを指定する機能を追加しました。 グローバル変数として配列$GLOBALS['SPIDER_PREVIOUS_SCRIPT_FILE_PATH_ARRAY']を定義し、 From svnnotify @ sourceforge.jp Thu Mar 26 21:09:16 2009 From: svnnotify @ sourceforge.jp (svnnotify @ sourceforge.jp) Date: Thu, 26 Mar 2009 21:09:16 +0900 Subject: [Frameworkspider-svn] spider-commit [11] Message-ID: <1238069356.327691.23946.nullmailer@users.sourceforge.jp> Revision: 11 http://svn.sourceforge.jp/view?root=frameworkspider&view=rev&rev=11 Author: m_nakashima Date: 2009-03-26 21:09:16 +0900 (Thu, 26 Mar 2009) Log Message: ----------- Modified Paths: -------------- current/DATA/lib/spider/tags/If.class.php current/DATA/lib/spider/tags/TagBase.class.php -------------- next part -------------- Modified: current/DATA/lib/spider/tags/If.class.php =================================================================== --- current/DATA/lib/spider/tags/If.class.php 2009-03-26 12:01:45 UTC (rev 10) +++ current/DATA/lib/spider/tags/If.class.php 2009-03-26 12:09:16 UTC (rev 11) @@ -92,97 +92,10 @@ * ifタグ内の条件式を解析します。 */ function condition2code( $strings ) { - // 演算時の正規表現 - $signiture_regx = '\\+\\-\\/\\*\\%\\=\\<\\>\\&\\|\\(\\)\\!\\,\\[\\]'; - - // 2文字以上連続のスペースは1文字に統一 - while( preg_match('/\\s\\s/',$strings) > 0 ) { - $strings = str_replace( ' ',' ', $strings ); - } - - // 下位互換の為、and/orは演算子に置換する - $strings = str_replace(' and ', ' && ', $strings ); - $strings = str_replace(' or ', ' || ', $strings ); - // 下位互換の為、is null / is not nullを置換する - $strings = preg_replace('/(|\\s)([^\\s'.$signiture_regx.']*)\\sis\\snull/','$1is_null( $2 )',$strings); - $strings = preg_replace('/(|\\s)([^\\s'.$signiture_regx.']*)\\sis\\snot\\snull/','$1!is_null( $2 )',$strings); - // 下位互換の為inも置換する - $strings = preg_replace('/(|\\s)([^\\s]*)\\sin\\s([^\\s\\}'.$signiture_regx.']*)/','$1in_array( $2 )',$strings); - // 下位互換の為連続していない=は連続=に変換しておく(if文中で代入が利用できなくなる為要検討) - $strings = preg_replace('/([^\\+\\-\\/\\*\\%\\=\\<\\>])\\=([^\\=])/','$1==$2',$strings); - - $converted_strings = ''; - $element_array = preg_split('/([\\s'.$signiture_regx.'])/', $strings, -1, PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE ); - $element_data = ''; - $prev_data = ''; - foreach( $element_array as $key => $element ) { - $element_data .= $element; - if( preg_match('/^\\\'/',$element_data) > 0 && substr_count( $element_data, "'" ) % 2 == 1 ) { - // 'から始まって'の数が偶数個なら次のカラムとつなげる - continue; - } else if( preg_match('/^\\\'/',$element_data) > 0 && substr_count( $element_data, "'" ) % 2 == 1 ) { - // 'から始まって'の数が偶数個なら次のカラムとつなげる - continue; - } else { - if( preg_match('/([\\s'.$signiture_regx.'])/',$element_data) == 0 ) { - // 演算子でない場合のみ処理 - if( preg_match('/^\\$/',$element_data ) > 0 ) { - // $から始まるなら変換しないでそのまま追加 - $converted_strings .= $element_data; - } else if( preg_match('/^\\\'/',$element_data ) > 0 && preg_match('/\\\'$/',$element_data ) > 0 ) { - // クォートされているなら文字列 - if( $key > 2 && $element_array[$key-1] == '>' && $element_array[$key-2] == '-'){ - // 前の要素が->オブジェクトメンバ指定子の場合クォートを除去して追加 - $converted_strings .= preg_replace('/(^\'|\'$)/','',$element_data); - } else { - // ただの文字列の場合はそのまま追加 - $converted_strings .= $element_data; - } - } else if( preg_match('/^\\\"/',$element_data ) > 0 && preg_match('/\\\"$/',$element_data ) > 0 ) { - // クォートされているなら文字列 - if( $key > 2 && $element_array[$key-1] == '>' && $element_array[$key-2] == '-'){ - // 前の要素が->オブジェクトメンバ指定子の場合 - $converted_strings .= preg_replace('/(^\\"|\\"$)/','',$element_data); - } else { - // ただの文字列の場合はそのまま追加 - $converted_strings .= $element_data; - } - } else if( preg_match('/^[0-9]+$/',$element_data ) > 0 ) { - // 数字だけならそのまま追加 - $converted_strings .= $element_data; - } else { - // 次の演算子以外の要素が(なら関数なので次の空でない要素をチェック - $is_method = false; - for( $i=$key+1;$i 0 ) { - if( $val == '(' ) { - $is_method = true; - } - break; - } - } - if( $is_method ) { - // 関数名・メソッド名の場合はそのまま追加 - $converted_strings .= $element_data; - } else if( $key > 2 && $element_array[$key-1] == '>' && $element_array[$key-2] == '-'){ - // メソッドでなくて前の要素が->の場合オブジェクトメンバも変換(要検討...) - $converted_strings .= '$GLOBALS[\''.$element_data.'\']'; - } else { - // それ以外は$GLOBALSへ変換 - $converted_strings .= '$GLOBALS[\''.$element_data.'\']'; - } - } - } else { - // 演算子はそのまま追加 - $converted_strings .= $element_data; - } - $prev_data = $element_data; - $element_data = ''; - } - } - - return $converted_strings; + // 下位互換の文字列変更 + $strings = $this->oldCondition2NewCondition( $strings ); + // ネイティブコードに変換 + return $this->tagCode2NativeCode( $strings ); } /** * if条件文の式を解析する @@ -383,5 +296,27 @@ return $strings; } + /** + * 記述の下位互換の為、条件式文字列を変換するメソッド + */ + function oldCondition2NewCondition( $strings ) { + // 演算時の正規表現 + $signiture_regx = '\\+\\-\\/\\*\\%\\=\\<\\>\\&\\|\\(\\)\\!\\,\\[\\]'; + // 2文字以上連続のスペースは1文字に統一 + while( preg_match('/\\s\\s/',$strings) > 0 ) { + $strings = str_replace( ' ',' ', $strings ); + } + // 下位互換の為、and/orは演算子に置換する + $strings = str_replace(' and ', ' && ', $strings ); + $strings = str_replace(' or ', ' || ', $strings ); + // 下位互換の為、is null / is not nullを置換する + $strings = preg_replace('/(|\\s)([^\\s'.$signiture_regx.']*)\\sis\\snull/','$1is_null( $2 )',$strings); + $strings = preg_replace('/(|\\s)([^\\s'.$signiture_regx.']*)\\sis\\snot\\snull/','$1!is_null( $2 )',$strings); + // 下位互換の為inも置換する + $strings = preg_replace('/(|\\s)([^\\s]*)\\sin\\s([^\\s\\}'.$signiture_regx.']*)/','$1in_array( $2 )',$strings); + // 下位互換の為連続していない=は連続=に変換しておく(if文中で代入が利用できなくなる為要検討) + $strings = preg_replace('/([^\\+\\-\\/\\*\\%\\=\\<\\>])\\=([^\\=])/','$1==$2',$strings); + return $strings; + } } ?> \ No newline at end of file Modified: current/DATA/lib/spider/tags/TagBase.class.php =================================================================== --- current/DATA/lib/spider/tags/TagBase.class.php 2009-03-26 12:01:45 UTC (rev 10) +++ current/DATA/lib/spider/tags/TagBase.class.php 2009-03-26 12:09:16 UTC (rev 11) @@ -122,5 +122,85 @@ } return $option_array; } + /** + * タグコードをPHPコードに変換します + */ + function tagCode2NativeCode( $strings ) { + // 演算時の正規表現 + $signiture_regx = '\\+\\-\\/\\*\\%\\=\\<\\>\\&\\|\\(\\)\\!\\,\\[\\]'; + // 変換後文字列 + $converted_strings = ''; + $element_array = preg_split('/([\\s'.$signiture_regx.'])/', $strings, -1, PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE ); + $element_data = ''; + $prev_data = ''; + foreach( $element_array as $key => $element ) { + $element_data .= $element; + if( preg_match('/^\\\'/',$element_data) > 0 && substr_count( $element_data, "'" ) % 2 == 1 ) { + // 'から始まって'の数が偶数個なら次のカラムとつなげる + continue; + } else if( preg_match('/^\\\'/',$element_data) > 0 && substr_count( $element_data, "'" ) % 2 == 1 ) { + // 'から始まって'の数が偶数個なら次のカラムとつなげる + continue; + } else { + if( preg_match('/([\\s'.$signiture_regx.'])/',$element_data) == 0 ) { + // 演算子でない場合のみ処理 + if( preg_match('/^\\$/',$element_data ) > 0 ) { + // $から始まるなら変換しないでそのまま追加 + $converted_strings .= $element_data; + } else if( preg_match('/^\\\'/',$element_data ) > 0 && preg_match('/\\\'$/',$element_data ) > 0 ) { + // クォートされているなら文字列 + if( $key > 2 && $element_array[$key-1] == '>' && $element_array[$key-2] == '-'){ + // 前の要素が->オブジェクトメンバ指定子の場合クォートを除去して追加 + $converted_strings .= preg_replace('/(^\'|\'$)/','',$element_data); + } else { + // ただの文字列の場合はそのまま追加 + $converted_strings .= $element_data; + } + } else if( preg_match('/^\\\"/',$element_data ) > 0 && preg_match('/\\\"$/',$element_data ) > 0 ) { + // クォートされているなら文字列 + if( $key > 2 && $element_array[$key-1] == '>' && $element_array[$key-2] == '-'){ + // 前の要素が->オブジェクトメンバ指定子の場合 + $converted_strings .= preg_replace('/(^\\"|\\"$)/','',$element_data); + } else { + // ただの文字列の場合はそのまま追加 + $converted_strings .= $element_data; + } + } else if( preg_match('/^[0-9]+$/',$element_data ) > 0 ) { + // 数字だけならそのまま追加 + $converted_strings .= $element_data; + } else { + // 次の演算子以外の要素が(なら関数なので次の空でない要素をチェック + $is_method = false; + for( $i=$key+1;$i 0 ) { + if( $val == '(' ) { + $is_method = true; + } + break; + } + } + if( $is_method ) { + // 関数名・メソッド名の場合はそのまま追加 + $converted_strings .= $element_data; + } else if( $key > 2 && $element_array[$key-1] == '>' && $element_array[$key-2] == '-'){ + // メソッドでなくて前の要素が->の場合オブジェクトメンバも変換(要検討...) + $converted_strings .= '$GLOBALS[\''.$element_data.'\']'; + } else { + // それ以外は$GLOBALSへ変換 + $converted_strings .= '$GLOBALS[\''.$element_data.'\']'; + } + } + } else { + // 演算子はそのまま追加 + $converted_strings .= $element_data; + } + $prev_data = $element_data; + $element_data = ''; + } + } + + return $converted_strings; + } } ?> \ No newline at end of file From svnnotify @ sourceforge.jp Fri Mar 27 10:09:33 2009 From: svnnotify @ sourceforge.jp (svnnotify @ sourceforge.jp) Date: Fri, 27 Mar 2009 10:09:33 +0900 Subject: [Frameworkspider-svn] spider-commit [12] Message-ID: <1238116173.062386.18943.nullmailer@users.sourceforge.jp> Revision: 12 http://svn.sourceforge.jp/view?root=frameworkspider&view=rev&rev=12 Author: m_nakashima Date: 2009-03-27 10:09:32 +0900 (Fri, 27 Mar 2009) Log Message: ----------- Modified Paths: -------------- current/DATA/lib/example/Hello.class.php current/DATA/lib/spider/Controller.class.php current/DATA/lib/spider/HttpOutput.class.php current/DATA/lib/spider/HttpRequest.class.php current/DATA/spider_main.inc.php current/README.txt Added Paths: ----------- current/DATA/lib/spider/Builder.class.php Removed Paths: ------------- current/DATA/lib/spider/ExecutableFileCreator.class.php -------------- next part -------------- Modified: current/DATA/lib/example/Hello.class.php =================================================================== --- current/DATA/lib/example/Hello.class.php 2009-03-26 12:09:16 UTC (rev 11) +++ current/DATA/lib/example/Hello.class.php 2009-03-27 01:09:32 UTC (rev 12) @@ -17,7 +17,7 @@ /** * execute method * you need override this method for your application! - * @param object HttpRequest + * @param object spider_HttpRequest * @see lib/spider/HttpRequest.class.php */ function execute( & $request ) { Added: current/DATA/lib/spider/Builder.class.php =================================================================== --- current/DATA/lib/spider/Builder.class.php (rev 0) +++ current/DATA/lib/spider/Builder.class.php 2009-03-27 01:09:32 UTC (rev 12) @@ -0,0 +1,330 @@ + http://www.md-systems.net/ + * @author Multimedia Digital Contents Systems.Co.,Ltd. m.nakashima + * @since PHP 4.3 + */ +class spider_Builder { + + /** 元の本文文字列 */ + var $org_body_strings; + /** 出力する本文文字列 */ + var $out_body_strings; + + /** + * コンストラクタ + */ + function spider_Builder() { + } + /** + * HTMLボディを生成する + */ + function convertBody( & $build_information_object ) { + $action_lines = file( $build_information_object->execute_file_path ); + $this->out_body_strings = implode( "", $action_lines ); + $this->org_body_strings = $this->out_body_strings; + + // 改行コード統一と連続改行の削除 + $this->out_body_strings = str_replace( "\r\n", "\n", $this->out_body_strings ); + $this->out_body_strings = str_replace( "\r", "\n", $this->out_body_strings ); + $this->out_body_strings = str_replace( "\n\n\n", "\n", $this->out_body_strings ); + $this->out_body_strings = str_replace( "\n\n", "\n", $this->out_body_strings ); + $this->out_body_strings = str_replace( "\n\n", "\n", $this->out_body_strings ); + + // cms.phpインクルード行を削除 + preg_match_all( '/include_once\\([^\\)]*?cms\\.php[^\\)]*?\\)\\;/' + , $this->out_body_strings + , $output_array + , PREG_PATTERN_ORDER ); + foreach ( $output_array as $output ) { + foreach ( $output as $target ) { + $this->out_body_strings = str_replace( $target, "", $this->out_body_strings ); + } + } + preg_match_all( '/require_once\\([^\\)]*?cms\\.php[^\\)]*?\\)\\;/' + , $this->out_body_strings + , $output_array + , PREG_PATTERN_ORDER ); + foreach ( $output_array as $output ) { + foreach ( $output as $target ) { + $this->out_body_strings = str_replace( $target, "", $this->out_body_strings ); + } + } + // spider.inc.phpインクルード行を削除 + preg_match_all( '/include_once\\([^\\)]*?spider\\.inc\\.php[^\\)]*?\\)\\;/' + , $this->out_body_strings + , $output_array + , PREG_PATTERN_ORDER ); + foreach ( $output_array as $output ) { + foreach ( $output as $target ) { + $this->out_body_strings = str_replace( $target, "", $this->out_body_strings ); + } + } + preg_match_all( '/require_once\\([^\\)]*?spider\\.inc\\.php[^\\)]*?\\)\\;/' + , $this->out_body_strings + , $output_array + , PREG_PATTERN_ORDER ); + foreach ( $output_array as $output ) { + foreach ( $output as $target ) { + $this->out_body_strings = str_replace( $target, "", $this->out_body_strings ); + } + } + + // 空PHP部分を削除 + $this->out_body_strings = preg_replace('/<\\?php[\\s]+\\?>/','',$this->out_body_strings); + + // フォルダデフォルトファイルの適用 + $folder_default_path = null; + $folder_path = dirname($build_information_object->execute_file_path); + while( strlen($folder_path) > strlen(APPLICATION_BASE_PATH) ) { + $folder_default_path = $folder_path.DIRECTORY_SEPARATOR.'.default'; + if( file_exists( $folder_default_path ) ) { + break; + } else { + $folder_default_path = null; + } + $folder_path = dirname($folder_path); + } + if( !is_null( $folder_default_path ) && file_exists($folder_default_path) ) { + $str = trim(file_get_contents($folder_default_path)); + $this->out_body_strings = $str.$this->out_body_strings; + } + + // 変換タグの読み込みと変換 + $tag_object_array = array(); + $dir_path_tags = dirname(__FILE__).DIRECTORY_SEPARATOR."tags".DIRECTORY_SEPARATOR; + if ( is_dir($dir_path_tags) ) { + if ( $dh = opendir( $dir_path_tags ) ) { + while ( ( $file_name = readdir($dh) ) !== false ) { + if( $file_name != "." && $file_name != ".." + && preg_match('/^[0-9a-zA-Z]+?\\.class\\.php$/',$file_name)) { + require_once( dirname(__FILE__).DIRECTORY_SEPARATOR + ."tags".DIRECTORY_SEPARATOR.$file_name ); + $tag_class_name = "spider_tags_".substr($file_name,0,strpos($file_name,".")); + $tag_class_obj = new $tag_class_name; + if( !is_array( $tag_object_array[$tag_class_obj->priority]) ) { + $tag_object_array[$tag_class_obj->priority] = array(); + } + array_push( $tag_object_array[$tag_class_obj->priority], $tag_class_obj ); + } + } + closedir($dh); + } else { + } + } else { + } + // 外部変換タグの読み込みと変換 + $external_tags_conf_file = dirname(__FILE__) + .DIRECTORY_SEPARATOR."tags".DIRECTORY_SEPARATOR."externals.conf"; + if( file_exists( $external_tags_conf_file ) ) { + $lines = file( $external_tags_conf_file ); + foreach( $lines as $line ) { + $line = trim($line); + $tag_class_name = $line; + $tag_class_file = DIR_PATH_LIB.DIRECTORY_SEPARATOR.str_replace('_',DIRECTORY_SEPARATOR,$line).'.class.php'; + if( file_exists($tag_class_file) ) { + require_once( $tag_class_file ); + $tag_class_obj = new $tag_class_name; + if( !is_array( $tag_object_array[$tag_class_obj->priority]) ) { + $tag_object_array[$tag_class_obj->priority] = array(); + } + array_push( $tag_object_array[$tag_class_obj->priority], $tag_class_obj ); + } + } + } + // 優先順にタグのコンバートメソッドを実行 + ksort($tag_object_array); + foreach( $tag_object_array as $key => $tag_array ) { + foreach($tag_array as $tag_obj ) { + $tag_obj->convert( $this->out_body_strings, $build_information_object ); + } + } + } + /** + * 実行ファイル実体を書き出す + * @param $bin_file_path 実行ファイルの出力パス + */ + function createBinFile( & $build_information_object ) { + + $bin_file_path = $build_information_object->getAgentPageBuildFilePath(); + + // 実行ファイルを解析 + $this->convertBody($build_information_object); + + // 表示前実行部分作成 + $string = "preview_process_hash as $code_array ) { + foreach( $code_array as $code ) { + $string .= $code."\n"; + } + } + + // モジュール実行のスクリプト追加 + foreach( $build_information_object->module_exec_info_hash as $key => $info_hash ) { + $module_name = $info_hash['module_name']; + $force = 'false'; + if( $info_hash['force'] ) { + $force = 'true'; + } + $attribute_prefix = $info_hash['attribute_prefix']; + $attribute_prefix = str_replace('"','\\"',$attribute_prefix); + $post_contents = $info_hash['post']; + $post_contents = str_replace('"','\\"',$post_contents); + $get_contents = $info_hash['get']; + $get_contents = str_replace('"','\\"',$get_contents); + $string .= '$controller->loadModule( "' . $module_name . '", '.$force.',"'.$attribute_prefix + .'","'.$get_contents.'", "'.$post_contents.'" );'."\n"; + } + + // モジュール実行結果による分岐処理を記述 + $string .= 'if ( $request_object->isError() ) {'."\n"; + $string .= '$is_error = true;'."\n"; + $string .= '$request_object->setAttribute("IS_ERROR", $is_error );'."\n"; + $string .= '$tmp_array = $request_object->errors;'."\n"; + $string .= '$request_object->setAttribute("errors", $tmp_array );'."\n"; + $string .= '} else {'."\n"; + $string .= '$is_error = false;'."\n"; + $string .= '$request_object->setAttribute("IS_ERROR", $is_error );'."\n"; + $string .= '}'."\n"; + + // リクエスト属性をグローバル変数に格納する + $string .= 'foreach( $request_object->attribute_array as $key => $value ) { '; + $string .= ' $GLOBALS[$key] = $value; '; + $string .= ' }'."\n"; + + // ファイルアウトプット機能の追加 + // リクエストオブジェクトに乗せられたヘッダ + $string .= 'if( count( $request_object->headers ) > 0 ) {'."\n"; + $string .= 'foreach( $request_object->headers as $hkey => $hval ) {'."\n"; + $string .= 'header("$hkey: $hval");'."\n"; + $string .= '}'."\n"; + $string .= '}'."\n"; + // 下位互換:http_outputに乗せられたヘッダ + $string .= 'if( count( $this->headers ) > 0 ) {'."\n"; + $string .= 'foreach( $this->headers as $hkey => $hval ) {'."\n"; + $string .= 'header("$hkey: $hval");'."\n"; + $string .= '}'."\n"; + $string .= '}'."\n"; + + // リダイレクトの場合 + $string .= 'if( !is_null( $request_object->redirect_url ) && strlen($request_object->redirect_url)> 0 ) {'."\n"; + $string .= 'header("Location: ".$request_object->redirect_url);'."\n"; + $string .= "die;\n"; + $string .= '}'; + // レスポンスファイルが指定されている場合 + $string .= 'else if( !is_null( $request_object->response_file_path ) && strlen( $request_object->response_file_path ) > 0 && file_exists( $request_object->response_file_path ) ){'."\n"; + $string .= 'readfile($request_object->response_file_path);'."\n"; + // レスポンスボディが指定されている場合 + $string .= '} else if( !is_null( $request_object->response_body ) && strlen( $request_object->response_body ) > 0 ) {'."\n"; + $string .= 'echo $request_object->response_body;'."\n"; + $string .= '}'; + // 下位互換:http_outputにレスポンスファイル + $string .= 'else if( !is_null( $this->response_file_path ) && strlen( $this->response_file_path ) > 0 && file_exists( $this->response_file_path ) ){'."\n"; + $string .= 'readfile($this->response_file_path);'."\n"; + // 下位互換:http_outputにレスポンスボディ + $string .= '} else if( !is_null( $this->response_body ) && strlen( $this->response_body ) > 0 ) {'."\n"; + $string .= 'echo $this->response_body;'; + // レスポンスが何も指定されていないなら継続処理 + $string .= "} else { \n\n?>"; + + // テキスト出力があるなら出力 + $string .= $this->out_body_strings; + + // 出力を文字列に取得する + $string .= "convert_view_process_hash as $code_array ) { + foreach( $code_array as $code ) { + $string .= $code."\n"; + } + } + + // 最終的にできた表示文字列をフラッシュする + $string .= "ob_start('".$build_information_object->output_handler."');\n"; + $string .= "ob_implicit_flush( false );\n"; + $string .= "mb_language('".$build_information_object->output_language."');\n"; + $string .= 'echo $outstr;'."\n"; + $string .= "mb_http_output('".$build_information_object->output_charset."');\n\n"; + $string .= 'ob_flush();'."\n"; + $string .= "}\n"; + + // 表示後実行コードを記述 + foreach( $build_information_object->postview_process_hash as $code_array ) { + foreach( $code_array as $code ) { + $string .= $code."\n"; + } + } + + // フラッシュ後にモジュール後処理の実行 + $string .= '$controller->post_process_all(); '; + $string .= "?>\n"; + + $fp = @fopen( $bin_file_path, "w" ); + if( $fp ) { + if (@flock($fp, LOCK_EX)) { + fwrite( $fp, $string ); + flock($fp, LOCK_UN); + @fclose( $fp ); + @chmod( $bin_file_path, 0666 ); + } else { + @fclose( $fp ); + @chmod( $bin_file_path, 0666 ); + die('Core Error: Can\'t create execute file!!'); + } + } else { + die('Core Error: Can\'t create execute file!!'); + } + + // ビルドタイムスタンプファイル作成 + $build_file_path = $bin_file_path.".build.php"; + $bin_file_path = str_replace('\\','\\\\',$bin_file_path ); + $string = "execute_file_path; + $target_file_path = str_replace('\\','\\\\',$target_file_path ); + $string .= 'if( file_exists("'.$target_file_path.'") ){if( filemtime("'.$bin_file_path.'") < filemtime("'.$target_file_path.'") ) { $build=true; }}'."\n"; + // 比較ファイルとのタイムスタンプ比較 + foreach( $build_information_object->compare_time_file_array as $compare_file_path ) { + $compare_file_path = str_replace('\\','\\\\',$compare_file_path); + $compare_file_path = str_replace('"','\\"',$compare_file_path); + // ファイルが存在する場合、ビルドファイルより更新日が新しいなら再ビルド、ファイルがなくなっていても再ビルド + $string .= 'if( file_exists("'.$compare_file_path.'") ){if( filemtime("'.$bin_file_path.'") < filemtime("'.$compare_file_path.'") ) { $build=true; }} else { $build=true; }'."\n"; + } + // 存在確認ファイル確認 + foreach( $build_information_object->confirm_exists_file_array as $compare_file_path ) { + if( strlen($compare_file_path) > 0 ) { + $compare_file_path = str_replace('\\','\\\\',$compare_file_path); + $compare_file_path = str_replace('"','\\"',$compare_file_path); + // ファイルができていたら再ビルド + $string .= 'if( file_exists("'.$compare_file_path.'") ){ $build=true; }'."\n"; + } + } + + $string .= "?>\n"; + + $fp = @fopen( $build_file_path, "w" ); + if( $fp ) { + if (@flock($fp, LOCK_EX)) { + fwrite( $fp, $string ); + flock($fp, LOCK_UN); + @fclose( $fp ); + @chmod( $build_file_path, 0666 ); + } else { + @fclose( $fp ); + @chmod( $build_file_path, 0666 ); + die('Core Error: Can\'t create build file!!'); + } + } else { + die('Core Error: Can\'t create build file!!'); + } + } +} +?> \ No newline at end of file Modified: current/DATA/lib/spider/Controller.class.php =================================================================== --- current/DATA/lib/spider/Controller.class.php 2009-03-26 12:09:16 UTC (rev 11) +++ current/DATA/lib/spider/Controller.class.php 2009-03-27 01:09:32 UTC (rev 12) @@ -10,7 +10,7 @@ * @author Multimedia Digital Contents Systems.Co.,Ltd. m.nakashima * @since PHP 4.3 */ -class Controller { +class spider_Controller { /** 実行モジュールのモジュール名+実行パラメータ文字列配列(実行した順) */ var $executed_module_info_array = array(); @@ -25,7 +25,7 @@ /** * コンストラクタ */ - function Controller( & $request_object, & $http_output_obj ) { + function spider_Controller( & $request_object, & $http_output_obj ) { $this->executed_module_info_array = array(); $this->executed_module_object_array = array(); $this->post_hash = $_POST; Deleted: current/DATA/lib/spider/ExecutableFileCreator.class.php =================================================================== --- current/DATA/lib/spider/ExecutableFileCreator.class.php 2009-03-26 12:09:16 UTC (rev 11) +++ current/DATA/lib/spider/ExecutableFileCreator.class.php 2009-03-27 01:09:32 UTC (rev 12) @@ -1,330 +0,0 @@ - http://www.md-systems.net/ - * @author Multimedia Digital Contents Systems.Co.,Ltd. m.nakashima - * @since PHP 4.3 - */ -class spider_ExecutableFileCreator { - - /** 元の本文文字列 */ - var $org_body_strings; - /** 出力する本文文字列 */ - var $out_body_strings; - - /** - * コンストラクタ - */ - function spider_ExecutableFileCreator() { - } - /** - * HTMLボディを生成する - */ - function convertBody( & $build_information_object ) { - $action_lines = file( $build_information_object->execute_file_path ); - $this->out_body_strings = implode( "", $action_lines ); - $this->org_body_strings = $this->out_body_strings; - - // 改行コード統一と連続改行の削除 - $this->out_body_strings = str_replace( "\r\n", "\n", $this->out_body_strings ); - $this->out_body_strings = str_replace( "\r", "\n", $this->out_body_strings ); - $this->out_body_strings = str_replace( "\n\n\n", "\n", $this->out_body_strings ); - $this->out_body_strings = str_replace( "\n\n", "\n", $this->out_body_strings ); - $this->out_body_strings = str_replace( "\n\n", "\n", $this->out_body_strings ); - - // cms.phpインクルード行を削除 - preg_match_all( '/include_once\\([^\\)]*?cms\\.php[^\\)]*?\\)\\;/' - , $this->out_body_strings - , $output_array - , PREG_PATTERN_ORDER ); - foreach ( $output_array as $output ) { - foreach ( $output as $target ) { - $this->out_body_strings = str_replace( $target, "", $this->out_body_strings ); - } - } - preg_match_all( '/require_once\\([^\\)]*?cms\\.php[^\\)]*?\\)\\;/' - , $this->out_body_strings - , $output_array - , PREG_PATTERN_ORDER ); - foreach ( $output_array as $output ) { - foreach ( $output as $target ) { - $this->out_body_strings = str_replace( $target, "", $this->out_body_strings ); - } - } - // spider.inc.phpインクルード行を削除 - preg_match_all( '/include_once\\([^\\)]*?spider\\.inc\\.php[^\\)]*?\\)\\;/' - , $this->out_body_strings - , $output_array - , PREG_PATTERN_ORDER ); - foreach ( $output_array as $output ) { - foreach ( $output as $target ) { - $this->out_body_strings = str_replace( $target, "", $this->out_body_strings ); - } - } - preg_match_all( '/require_once\\([^\\)]*?spider\\.inc\\.php[^\\)]*?\\)\\;/' - , $this->out_body_strings - , $output_array - , PREG_PATTERN_ORDER ); - foreach ( $output_array as $output ) { - foreach ( $output as $target ) { - $this->out_body_strings = str_replace( $target, "", $this->out_body_strings ); - } - } - - // 空PHP部分を削除 - $this->out_body_strings = preg_replace('/<\\?php[\\s]+\\?>/','',$this->out_body_strings); - - // フォルダデフォルトファイルの適用 - $folder_default_path = null; - $folder_path = dirname($build_information_object->execute_file_path); - while( strlen($folder_path) > strlen(APPLICATION_BASE_PATH) ) { - $folder_default_path = $folder_path.DIRECTORY_SEPARATOR.'.default'; - if( file_exists( $folder_default_path ) ) { - break; - } else { - $folder_default_path = null; - } - $folder_path = dirname($folder_path); - } - if( !is_null( $folder_default_path ) && file_exists($folder_default_path) ) { - $str = trim(file_get_contents($folder_default_path)); - $this->out_body_strings = $str.$this->out_body_strings; - } - - // 変換タグの読み込みと変換 - $tag_object_array = array(); - $dir_path_tags = dirname(__FILE__).DIRECTORY_SEPARATOR."tags".DIRECTORY_SEPARATOR; - if ( is_dir($dir_path_tags) ) { - if ( $dh = opendir( $dir_path_tags ) ) { - while ( ( $file_name = readdir($dh) ) !== false ) { - if( $file_name != "." && $file_name != ".." - && preg_match('/^[0-9a-zA-Z]+?\\.class\\.php$/',$file_name)) { - require_once( dirname(__FILE__).DIRECTORY_SEPARATOR - ."tags".DIRECTORY_SEPARATOR.$file_name ); - $tag_class_name = "spider_tags_".substr($file_name,0,strpos($file_name,".")); - $tag_class_obj = new $tag_class_name; - if( !is_array( $tag_object_array[$tag_class_obj->priority]) ) { - $tag_object_array[$tag_class_obj->priority] = array(); - } - array_push( $tag_object_array[$tag_class_obj->priority], $tag_class_obj ); - } - } - closedir($dh); - } else { - } - } else { - } - // 外部変換タグの読み込みと変換 - $external_tags_conf_file = dirname(__FILE__) - .DIRECTORY_SEPARATOR."tags".DIRECTORY_SEPARATOR."externals.conf"; - if( file_exists( $external_tags_conf_file ) ) { - $lines = file( $external_tags_conf_file ); - foreach( $lines as $line ) { - $line = trim($line); - $tag_class_name = $line; - $tag_class_file = DIR_PATH_LIB.DIRECTORY_SEPARATOR.str_replace('_',DIRECTORY_SEPARATOR,$line).'.class.php'; - if( file_exists($tag_class_file) ) { - require_once( $tag_class_file ); - $tag_class_obj = new $tag_class_name; - if( !is_array( $tag_object_array[$tag_class_obj->priority]) ) { - $tag_object_array[$tag_class_obj->priority] = array(); - } - array_push( $tag_object_array[$tag_class_obj->priority], $tag_class_obj ); - } - } - } - // 優先順にタグのコンバートメソッドを実行 - ksort($tag_object_array); - foreach( $tag_object_array as $key => $tag_array ) { - foreach($tag_array as $tag_obj ) { - $tag_obj->convert( $this->out_body_strings, $build_information_object ); - } - } - } - /** - * 実行ファイル実体を書き出す - * @param $bin_file_path 実行ファイルの出力パス - */ - function createBinFile( & $build_information_object ) { - - $bin_file_path = $build_information_object->getAgentPageBuildFilePath(); - - // 実行ファイルを解析 - $this->convertBody($build_information_object); - - // 表示前実行部分作成 - $string = "preview_process_hash as $code_array ) { - foreach( $code_array as $code ) { - $string .= $code."\n"; - } - } - - // モジュール実行のスクリプト追加 - foreach( $build_information_object->module_exec_info_hash as $key => $info_hash ) { - $module_name = $info_hash['module_name']; - $force = 'false'; - if( $info_hash['force'] ) { - $force = 'true'; - } - $attribute_prefix = $info_hash['attribute_prefix']; - $attribute_prefix = str_replace('"','\\"',$attribute_prefix); - $post_contents = $info_hash['post']; - $post_contents = str_replace('"','\\"',$post_contents); - $get_contents = $info_hash['get']; - $get_contents = str_replace('"','\\"',$get_contents); - $string .= '$controller->loadModule( "' . $module_name . '", '.$force.',"'.$attribute_prefix - .'","'.$get_contents.'", "'.$post_contents.'" );'."\n"; - } - - // モジュール実行結果による分岐処理を記述 - $string .= 'if ( $request_object->isError() ) {'."\n"; - $string .= '$is_error = true;'."\n"; - $string .= '$request_object->setAttribute("IS_ERROR", $is_error );'."\n"; - $string .= '$tmp_array = $request_object->errors;'."\n"; - $string .= '$request_object->setAttribute("errors", $tmp_array );'."\n"; - $string .= '} else {'."\n"; - $string .= '$is_error = false;'."\n"; - $string .= '$request_object->setAttribute("IS_ERROR", $is_error );'."\n"; - $string .= '}'."\n"; - - // リクエスト属性をグローバル変数に格納する - $string .= 'foreach( $request_object->attribute_array as $key => $value ) { '; - $string .= ' $GLOBALS[$key] = $value; '; - $string .= ' }'."\n"; - - // ファイルアウトプット機能の追加 - // リクエストオブジェクトに乗せられたヘッダ - $string .= 'if( count( $request_object->headers ) > 0 ) {'."\n"; - $string .= 'foreach( $request_object->headers as $hkey => $hval ) {'."\n"; - $string .= 'header("$hkey: $hval");'."\n"; - $string .= '}'."\n"; - $string .= '}'."\n"; - // 下位互換:http_outputに乗せられたヘッダ - $string .= 'if( count( $this->headers ) > 0 ) {'."\n"; - $string .= 'foreach( $this->headers as $hkey => $hval ) {'."\n"; - $string .= 'header("$hkey: $hval");'."\n"; - $string .= '}'."\n"; - $string .= '}'."\n"; - - // リダイレクトの場合 - $string .= 'if( !is_null( $request_object->redirect_url ) && strlen($request_object->redirect_url)> 0 ) {'."\n"; - $string .= 'header("Location: ".$request_object->redirect_url);'."\n"; - $string .= "die;\n"; - $string .= '}'; - // レスポンスファイルが指定されている場合 - $string .= 'else if( !is_null( $request_object->response_file_path ) && strlen( $request_object->response_file_path ) > 0 && file_exists( $request_object->response_file_path ) ){'."\n"; - $string .= 'readfile($request_object->response_file_path);'."\n"; - // レスポンスボディが指定されている場合 - $string .= '} else if( !is_null( $request_object->response_body ) && strlen( $request_object->response_body ) > 0 ) {'."\n"; - $string .= 'echo $request_object->response_body;'."\n"; - $string .= '}'; - // 下位互換:http_outputにレスポンスファイル - $string .= 'else if( !is_null( $this->response_file_path ) && strlen( $this->response_file_path ) > 0 && file_exists( $this->response_file_path ) ){'."\n"; - $string .= 'readfile($this->response_file_path);'."\n"; - // 下位互換:http_outputにレスポンスボディ - $string .= '} else if( !is_null( $this->response_body ) && strlen( $this->response_body ) > 0 ) {'."\n"; - $string .= 'echo $this->response_body;'; - // レスポンスが何も指定されていないなら継続処理 - $string .= "} else { \n\n?>"; - - // テキスト出力があるなら出力 - $string .= $this->out_body_strings; - - // 出力を文字列に取得する - $string .= "convert_view_process_hash as $code_array ) { - foreach( $code_array as $code ) { - $string .= $code."\n"; - } - } - - // 最終的にできた表示文字列をフラッシュする - $string .= "ob_start('".$build_information_object->output_handler."');\n"; - $string .= "ob_implicit_flush( false );\n"; - $string .= "mb_language('".$build_information_object->output_language."');\n"; - $string .= 'echo $outstr;'."\n"; - $string .= "mb_http_output('".$build_information_object->output_charset."');\n\n"; - $string .= 'ob_flush();'."\n"; - $string .= "}\n"; - - // 表示後実行コードを記述 - foreach( $build_information_object->postview_process_hash as $code_array ) { - foreach( $code_array as $code ) { - $string .= $code."\n"; - } - } - - // フラッシュ後にモジュール後処理の実行 - $string .= '$controller->post_process_all(); '; - $string .= "?>\n"; - - $fp = @fopen( $bin_file_path, "w" ); - if( $fp ) { - if (@flock($fp, LOCK_EX)) { - fwrite( $fp, $string ); - flock($fp, LOCK_UN); - @fclose( $fp ); - @chmod( $bin_file_path, 0666 ); - } else { - @fclose( $fp ); - @chmod( $bin_file_path, 0666 ); - die('Core Error: Can\'t create execute file!!'); - } - } else { - die('Core Error: Can\'t create execute file!!'); - } - - // ビルドタイムスタンプファイル作成 - $build_file_path = $bin_file_path.".build.php"; - $bin_file_path = str_replace('\\','\\\\',$bin_file_path ); - $string = "execute_file_path; - $target_file_path = str_replace('\\','\\\\',$target_file_path ); - $string .= 'if( file_exists("'.$target_file_path.'") ){if( filemtime("'.$bin_file_path.'") < filemtime("'.$target_file_path.'") ) { $build=true; }}'."\n"; - // 比較ファイルとのタイムスタンプ比較 - foreach( $build_information_object->compare_time_file_array as $compare_file_path ) { - $compare_file_path = str_replace('\\','\\\\',$compare_file_path); - $compare_file_path = str_replace('"','\\"',$compare_file_path); - // ファイルが存在する場合、ビルドファイルより更新日が新しいなら再ビルド、ファイルがなくなっていても再ビルド - $string .= 'if( file_exists("'.$compare_file_path.'") ){if( filemtime("'.$bin_file_path.'") < filemtime("'.$compare_file_path.'") ) { $build=true; }} else { $build=true; }'."\n"; - } - // 存在確認ファイル確認 - foreach( $build_information_object->confirm_exists_file_array as $compare_file_path ) { - if( strlen($compare_file_path) > 0 ) { - $compare_file_path = str_replace('\\','\\\\',$compare_file_path); - $compare_file_path = str_replace('"','\\"',$compare_file_path); - // ファイルができていたら再ビルド - $string .= 'if( file_exists("'.$compare_file_path.'") ){ $build=true; }'."\n"; - } - } - - $string .= "?>\n"; - - $fp = @fopen( $build_file_path, "w" ); - if( $fp ) { - if (@flock($fp, LOCK_EX)) { - fwrite( $fp, $string ); - flock($fp, LOCK_UN); - @fclose( $fp ); - @chmod( $build_file_path, 0666 ); - } else { - @fclose( $fp ); - @chmod( $build_file_path, 0666 ); - die('Core Error: Can\'t create build file!!'); - } - } else { - die('Core Error: Can\'t create build file!!'); - } - } -} -?> \ No newline at end of file Modified: current/DATA/lib/spider/HttpOutput.class.php =================================================================== --- current/DATA/lib/spider/HttpOutput.class.php 2009-03-26 12:09:16 UTC (rev 11) +++ current/DATA/lib/spider/HttpOutput.class.php 2009-03-27 01:09:32 UTC (rev 12) @@ -1,7 +1,7 @@ * @since PHP 4.3 */ -class HttpOutput { +class spider_HttpOutput { /** * コンストラクタ * @param $template_foler_path テンプレートファイルのルートディレクトリ */ - function HttpOutput() { + function spider_HttpOutput() { } /** * リクエストの出力 - * @param $controller モジュールを実行するControllerオブジェクト - * @param $request_object HttpRequestオブジェクト + * @param $controller モジュールを実行するspider_Controllerオブジェクト + * @param $request_object spider_HttpRequestオブジェクト */ function output( $controller, & $request ) { @@ -93,10 +93,10 @@ } // 実行ファイル作成オブジェクト - $creater_object = new spider_ExecutableFileCreator(); + $builder_object = new spider_Builder(); // 実行ファイル作成 - $creater_object->createBinFile( $build_information_object ); + $builder_object->createBinFile( $build_information_object ); $lock_obj->release(); // 実行ファイル実行 Modified: current/DATA/lib/spider/HttpRequest.class.php =================================================================== --- current/DATA/lib/spider/HttpRequest.class.php 2009-03-26 12:09:16 UTC (rev 11) +++ current/DATA/lib/spider/HttpRequest.class.php 2009-03-27 01:09:32 UTC (rev 12) @@ -11,7 +11,7 @@ * @since PHP 4.3 */ require_once(dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR.'util'.DIRECTORY_SEPARATOR.'CharUtility.class.php'); -class HttpRequest { +class spider_HttpRequest { /** Attributes */ var $attribute_array = array(); /** Errors */ @@ -32,7 +32,7 @@ /** * コンストラクタ */ - function HttpRequest() { + function spider_HttpRequest() { $this->attribute_array = array(); $this->errors = array(); } Modified: current/DATA/spider_main.inc.php =================================================================== --- current/DATA/spider_main.inc.php 2009-03-26 12:09:16 UTC (rev 11) +++ current/DATA/spider_main.inc.php 2009-03-27 01:09:32 UTC (rev 12) @@ -28,13 +28,13 @@ require_once( DIR_PATH_LIB . DIRECTORY_SEPARATOR . "spider" . DIRECTORY_SEPARATOR . "HttpRequest.class.php" ); -$GLOBALS['request_object'] = new HttpRequest(); +$GLOBALS['request_object'] = new spider_HttpRequest(); /* 出力クラス */ require_once( DIR_PATH_LIB . DIRECTORY_SEPARATOR . "spider" . DIRECTORY_SEPARATOR . "HttpOutput.class.php" ); -$GLOBALS['output_object'] = new HttpOutput(); +$GLOBALS['output_object'] = new spider_HttpOutput(); /* コントローラークラス */ require_once( DIR_PATH_LIB @@ -84,7 +84,7 @@ $GLOBALS['request_object']->setAttribute( 'spider.base_path', $base_path ); // コントローラー -$GLOBALS['controller'] = new Controller( $GLOBALS['request_object'], $GLOBALS['output_object'] ); +$GLOBALS['controller'] = new spider_Controller( $GLOBALS['request_object'], $GLOBALS['output_object'] ); // 前処理スクリプトの指定があるなら読み込む if( is_array($GLOBALS['SPIDER_PREVIOUS_SCRIPT_FILE_PATH_ARRAY']) && count($GLOBALS['SPIDER_PREVIOUS_SCRIPT_FILE_PATH_ARRAY']) > 0 ) { Modified: current/README.txt =================================================================== --- current/README.txt 2009-03-26 12:09:16 UTC (rev 11) +++ current/README.txt 2009-03-27 01:09:32 UTC (rev 12) @@ -3,6 +3,15 @@ ** ** このファイルにはコミットごとに変更点とファイル名を記述します。 ** +-- 2009-03-27 +1)この機会しかないと思ったのでクラス名の変更を行いました。 + ・ExecutableFileCreator.class.php -> Builder.class.php + ・Conttoller -> spider_Controller + ・HttpOutput -> spider_HttpOutput + ・HttpRequest -> spider_HttpRequest + + 内部的な変更なのでコアなプログラム変更を行っているユーザ以外には影響ありません。 + -- 2009-03-26 1) OutputHtmlタグで出力するファイルパスがWindowsで不具合を起こす問題の修正 From svnnotify @ sourceforge.jp Fri Mar 27 11:03:06 2009 From: svnnotify @ sourceforge.jp (svnnotify @ sourceforge.jp) Date: Fri, 27 Mar 2009 11:03:06 +0900 Subject: [Frameworkspider-svn] spider-commit [13] Message-ID: <1238119386.541445.28680.nullmailer@users.sourceforge.jp> Revision: 13 http://svn.sourceforge.jp/view?root=frameworkspider&view=rev&rev=13 Author: m_nakashima Date: 2009-03-27 11:03:06 +0900 (Fri, 27 Mar 2009) Log Message: ----------- Modified Paths: -------------- current/DATA/lib/spider/tags/TagBase.class.php -------------- next part -------------- Modified: current/DATA/lib/spider/tags/TagBase.class.php =================================================================== --- current/DATA/lib/spider/tags/TagBase.class.php 2009-03-27 01:09:32 UTC (rev 12) +++ current/DATA/lib/spider/tags/TagBase.class.php 2009-03-27 02:03:06 UTC (rev 13) @@ -168,6 +168,9 @@ } else if( preg_match('/^[0-9]+$/',$element_data ) > 0 ) { // 数字だけならそのまま追加 $converted_strings .= $element_data; + } else if( preg_match('/^(true|false)$/',$element_data ) > 0 ) { + // true/falseならそのまま追加 + $converted_strings .= $element_data; } else { // 次の演算子以外の要素が(なら関数なので次の空でない要素をチェック $is_method = false; From svnnotify @ sourceforge.jp Fri Mar 27 16:12:05 2009 From: svnnotify @ sourceforge.jp (svnnotify @ sourceforge.jp) Date: Fri, 27 Mar 2009 16:12:05 +0900 Subject: [Frameworkspider-svn] spider-commit [14] Message-ID: <1238137925.328769.23601.nullmailer@users.sourceforge.jp> Revision: 14 http://svn.sourceforge.jp/view?root=frameworkspider&view=rev&rev=14 Author: m_nakashima Date: 2009-03-27 16:12:05 +0900 (Fri, 27 Mar 2009) Log Message: ----------- Modified Paths: -------------- current/DATA/lib/spider/tags/TagBase.class.php current/DATA/lib/spider/tags/Write.class.php current/README.txt -------------- next part -------------- Modified: current/DATA/lib/spider/tags/TagBase.class.php =================================================================== --- current/DATA/lib/spider/tags/TagBase.class.php 2009-03-27 02:03:06 UTC (rev 13) +++ current/DATA/lib/spider/tags/TagBase.class.php 2009-03-27 07:12:05 UTC (rev 14) @@ -147,7 +147,7 @@ if( preg_match('/^\\$/',$element_data ) > 0 ) { // $から始まるなら変換しないでそのまま追加 $converted_strings .= $element_data; - } else if( preg_match('/^\\\'/',$element_data ) > 0 && preg_match('/\\\'$/',$element_data ) > 0 ) { + } else if( preg_match('/^\'/',$element_data ) > 0 && preg_match('/\'$/',$element_data ) > 0 ) { // クォートされているなら文字列 if( $key > 2 && $element_array[$key-1] == '>' && $element_array[$key-2] == '-'){ // 前の要素が->オブジェクトメンバ指定子の場合クォートを除去して追加 @@ -156,7 +156,7 @@ // ただの文字列の場合はそのまま追加 $converted_strings .= $element_data; } - } else if( preg_match('/^\\\"/',$element_data ) > 0 && preg_match('/\\\"$/',$element_data ) > 0 ) { + } else if( preg_match('/^"/',$element_data ) > 0 && preg_match('/"$/',$element_data ) > 0 ) { // クォートされているなら文字列 if( $key > 2 && $element_array[$key-1] == '>' && $element_array[$key-2] == '-'){ // 前の要素が->オブジェクトメンバ指定子の場合 Modified: current/DATA/lib/spider/tags/Write.class.php =================================================================== --- current/DATA/lib/spider/tags/Write.class.php 2009-03-27 02:03:06 UTC (rev 13) +++ current/DATA/lib/spider/tags/Write.class.php 2009-03-27 07:12:05 UTC (rev 14) @@ -67,14 +67,63 @@ $var_name = preg_replace( '/\\{write\\:/','', $vars_tag ); $var_name = preg_replace( '/\\}$/','', $var_name ); $var_name = trim( $var_name ); - $repstr = $this->parseString( $var_name, $valiable_counter ); + // 下位互換の為::を含むなら旧ロジック + $repstr = ''; + if( preg_match('/\\:\\:/',$var_name) > 0 ) { + $repstr = $this->parseString( $var_name, $valiable_counter ); + } else { + $repstr = $this->tagOption2code( $var_name ); + } $result_strings = str_replace( $vars_tag, $repstr, $result_strings ); $valiable_counter++; } } } /** + * + */ + function tagOption2code( $strings ) { + // 最初に文字列化コード + $ret_strings = 'print_r( '.$strings.', true )'; + // 出力オプション指定文字の処理 + if( strpos( $ret_strings, 'nl2null' ) !== false ) { + $ret_strings = 'str_replace("\\n","",str_replace("\\r","",str_replace("\\r\\n","",'.$ret_strings.')))'; + $ret_strings = str_replace('nl2null','',$ret_strings); + } + if( strpos( $ret_strings, 'escape-nl' ) !== false ) { + $ret_strings = 'str_replace("\\n","\\\n",str_replace("\\r","\\n",str_replace("\\r\\n","\\n",'.$ret_strings.')))'; + $ret_strings = str_replace('escape-nl','',$ret_strings); + } + if( strpos( $ret_strings, 'escape-sq' ) !== false ) { + $ret_strings = 'str_replace("\'","\\\'",'.$ret_strings.')'; + $ret_strings = str_replace('escape-sq','',$ret_strings); + } + if( strpos( $ret_strings, 'escape-dq' ) !== false ) { + $ret_strings = 'str_replace(\'"\',\'\\"\','.$ret_strings.')'; + $ret_strings = str_replace('escape-dq','',$ret_strings); + } + if( strpos( $ret_strings, 'noescape' ) !== false ) { + $ret_strings = str_replace('noescape','',$ret_strings); + } else { + $ret_strings = 'htmlspecialchars('.$ret_strings.')'; + } + if( strpos( $ret_strings, 'nl2br' ) !== false ) { + $ret_strings = str_replace('nl2br','',$ret_strings); + $ret_strings = 'nl2br('.$ret_strings.')'; + } + if( strpos( $ret_strings, 'urlencode' ) !== false ) { + $ret_strings = str_replace('urlencode','',$ret_strings); + $ret_strings = 'urlencode('.$ret_strings.')'; + } + // ネイティブコード化 + $ret_strings = $this->tagCode2NativeCode( $ret_strings ); + // 最後にecho + $ret_strings = ''; + return $ret_strings; + } + /** * 文字列解析 + * 旧バージョン互換::を利用できる */ function parseString( $strings, $prefix=1 ) { @@ -222,39 +271,39 @@ $retstring = ''; Modified: current/README.txt =================================================================== --- current/README.txt 2009-03-27 02:03:06 UTC (rev 13) +++ current/README.txt 2009-03-27 07:12:05 UTC (rev 14) @@ -12,6 +12,12 @@ 内部的な変更なのでコアなプログラム変更を行っているユーザ以外には影響ありません。 +2) TagBaseクラスでタグコードをネイティブコードに変更するメソッドを修正しました。 + +3) writeタグの修正をおこないました。::で配列要素やオブジェクトメンバを指定する場合をは旧ロジックで + 呼び出しを->メンバ名、['添え字']で指定する場合は、階層に関係なくPHPネイティブコードの許す限り記述できる + ように機能を変更しました。 + -- 2009-03-26 1) OutputHtmlタグで出力するファイルパスがWindowsで不具合を起こす問題の修正 From svnnotify @ sourceforge.jp Mon Mar 30 11:43:06 2009 From: svnnotify @ sourceforge.jp (svnnotify @ sourceforge.jp) Date: Mon, 30 Mar 2009 11:43:06 +0900 Subject: [Frameworkspider-svn] spider-commit [15] Message-ID: <1238380986.599067.30618.nullmailer@users.sourceforge.jp> Revision: 15 http://svn.sourceforge.jp/view?root=frameworkspider&view=rev&rev=15 Author: m_nakashima Date: 2009-03-30 11:43:06 +0900 (Mon, 30 Mar 2009) Log Message: ----------- Modified Paths: -------------- current/DATA/lib/example/Hello.class.php current/DATA/lib/spider/HttpRequest.class.php current/README.txt -------------- next part -------------- Modified: current/DATA/lib/example/Hello.class.php =================================================================== --- current/DATA/lib/example/Hello.class.php 2009-03-27 07:12:05 UTC (rev 14) +++ current/DATA/lib/example/Hello.class.php 2009-03-30 02:43:06 UTC (rev 15) @@ -30,6 +30,12 @@ // set hash example $message_hash = array( 'first_name' => 'Masanori', 'family_name' => 'Nakashima'); $request->setAttribute('message_hash', $message_hash ); + // set 2D hash example + $person_hash = array( + 'Masanori Nakashima' => array( 'sex' => 'male', 'country'=>'Japan', 'prefecture' => 'Saitama'), + 'Takeshi Kato' => array( 'sex' => 'male', 'country'=>'Japan', 'prefecture' => 'Tokyo'), + ); + $request->setAttribute('person_hash', $person_hash ); } } ?> \ No newline at end of file Modified: current/DATA/lib/spider/HttpRequest.class.php =================================================================== --- current/DATA/lib/spider/HttpRequest.class.php 2009-03-27 07:12:05 UTC (rev 14) +++ current/DATA/lib/spider/HttpRequest.class.php 2009-03-30 02:43:06 UTC (rev 15) @@ -58,6 +58,11 @@ // パッケージ名もクラス名も属性名に含まれないならクラスプレフィックスつけて登録 $reg_key = $caller_prefix.'.'.$reg_key; } + } else { + // lib内でない場合、下位互換の為、$GLOBALSにも登録する + $reg_key = 'page.'.$key; + $GLOBALS[$reg_key] = $value; + $GLOBALS[$key] = $value; } if( !is_null( $this->attribute_prefix ) && strlen($this->attribute_prefix) > 0 ) { $reg_key = $this->attribute_prefix.'.'.$reg_key; Modified: current/README.txt =================================================================== --- current/README.txt 2009-03-27 07:12:05 UTC (rev 14) +++ current/README.txt 2009-03-30 02:43:06 UTC (rev 15) @@ -3,6 +3,10 @@ ** ** このファイルにはコミットごとに変更点とファイル名を記述します。 ** +-- 2009-03-30 +1) ページ内で$request->setAttributeメソッドで値をセットした場合に$GLOBALSに設定しない為 + if/foreach/writeで問題が発生する不具合を修正 + -- 2009-03-27 1)この機会しかないと思ったのでクラス名の変更を行いました。 ・ExecutableFileCreator.class.php -> Builder.class.php From svnnotify @ sourceforge.jp Mon Mar 30 19:25:39 2009 From: svnnotify @ sourceforge.jp (svnnotify @ sourceforge.jp) Date: Mon, 30 Mar 2009 19:25:39 +0900 Subject: [Frameworkspider-svn] spider-commit [16] Message-ID: <1238408739.289057.24949.nullmailer@users.sourceforge.jp> Revision: 16 http://svn.sourceforge.jp/view?root=frameworkspider&view=rev&rev=16 Author: m_nakashima Date: 2009-03-30 19:25:39 +0900 (Mon, 30 Mar 2009) Log Message: ----------- Modified Paths: -------------- current/DATA/lib/spider/Builder.class.php current/DATA/lib/spider/Controller.class.php current/DATA/lib/spider/tags/Charset.class.php current/DATA/lib/spider/tags/OutputHtml.class.php current/DATA/lib/spider/tags/PageTitle.class.php current/DATA/lib/spider/tags/RewriteDocumentRoot.class.php current/DATA/lib/spider/tags/SetRequestParam.class.php current/DATA/lib/spider/tags/Widget.class.php current/README.txt current/WWW_PUBLIC/spider.inc.php -------------- next part -------------- Modified: current/DATA/lib/spider/Builder.class.php =================================================================== --- current/DATA/lib/spider/Builder.class.php 2009-03-30 02:43:06 UTC (rev 15) +++ current/DATA/lib/spider/Builder.class.php 2009-03-30 10:25:39 UTC (rev 16) @@ -106,7 +106,7 @@ ."tags".DIRECTORY_SEPARATOR.$file_name ); $tag_class_name = "spider_tags_".substr($file_name,0,strpos($file_name,".")); $tag_class_obj = new $tag_class_name; - if( !is_array( $tag_object_array[$tag_class_obj->priority]) ) { + if( !isset($tag_object_array[$tag_class_obj->priority]) || !is_array($tag_object_array[$tag_class_obj->priority]) ) { $tag_object_array[$tag_class_obj->priority] = array(); } array_push( $tag_object_array[$tag_class_obj->priority], $tag_class_obj ); @@ -172,12 +172,21 @@ if( $info_hash['force'] ) { $force = 'true'; } - $attribute_prefix = $info_hash['attribute_prefix']; - $attribute_prefix = str_replace('"','\\"',$attribute_prefix); - $post_contents = $info_hash['post']; - $post_contents = str_replace('"','\\"',$post_contents); - $get_contents = $info_hash['get']; - $get_contents = str_replace('"','\\"',$get_contents); + $attribute_prefix = ''; + if( isset($info_hash['attribute_prefix']) ) { + $attribute_prefix = $info_hash['attribute_prefix']; + $attribute_prefix = str_replace('"','\\"',$attribute_prefix); + } + $post_contents = ''; + if( isset($info_hash['post']) ) { + $post_contents = $info_hash['post']; + $post_contents = str_replace('"','\\"',$post_contents); + } + $get_contents = ''; + if( isset($info_hash['get']) ) { + $get_contents = $info_hash['get']; + $get_contents = str_replace('"','\\"',$get_contents); + } $string .= '$controller->loadModule( "' . $module_name . '", '.$force.',"'.$attribute_prefix .'","'.$get_contents.'", "'.$post_contents.'" );'."\n"; } @@ -205,12 +214,6 @@ $string .= 'header("$hkey: $hval");'."\n"; $string .= '}'."\n"; $string .= '}'."\n"; - // 下位互換:http_outputに乗せられたヘッダ - $string .= 'if( count( $this->headers ) > 0 ) {'."\n"; - $string .= 'foreach( $this->headers as $hkey => $hval ) {'."\n"; - $string .= 'header("$hkey: $hval");'."\n"; - $string .= '}'."\n"; - $string .= '}'."\n"; // リダイレクトの場合 $string .= 'if( !is_null( $request_object->redirect_url ) && strlen($request_object->redirect_url)> 0 ) {'."\n"; @@ -223,13 +226,6 @@ // レスポンスボディが指定されている場合 $string .= '} else if( !is_null( $request_object->response_body ) && strlen( $request_object->response_body ) > 0 ) {'."\n"; $string .= 'echo $request_object->response_body;'."\n"; - $string .= '}'; - // 下位互換:http_outputにレスポンスファイル - $string .= 'else if( !is_null( $this->response_file_path ) && strlen( $this->response_file_path ) > 0 && file_exists( $this->response_file_path ) ){'."\n"; - $string .= 'readfile($this->response_file_path);'."\n"; - // 下位互換:http_outputにレスポンスボディ - $string .= '} else if( !is_null( $this->response_body ) && strlen( $this->response_body ) > 0 ) {'."\n"; - $string .= 'echo $this->response_body;'; // レスポンスが何も指定されていないなら継続処理 $string .= "} else { \n\n?>"; Modified: current/DATA/lib/spider/Controller.class.php =================================================================== --- current/DATA/lib/spider/Controller.class.php 2009-03-30 02:43:06 UTC (rev 15) +++ current/DATA/lib/spider/Controller.class.php 2009-03-30 10:25:39 UTC (rev 16) @@ -49,11 +49,13 @@ } // グローバルエラーが存在したらエラーに追加 - $global_errors = unserialize( $_SESSION['spider.global_errors'] ); - if( is_array( $global_errors ) ) { - $this->request_object->errors = $global_errors; + if( isset($_SESSION) ) { + $global_errors = unserialize( $_SESSION['spider.global_errors'] ); + if( is_array( $global_errors ) ) { + $this->request_object->errors = $global_errors; + } + unset( $_SESSION['spider.global_errors'] ); } - unset( $_SESSION['spider.global_errors'] ); // リクエスト出力 $this->http_output_object->output( $this, $this->request_object ); // グローバルエラーが登録されていたらセッションに登録 @@ -89,7 +91,10 @@ } // 実行モジュールクラス名の取り出し $module_real_name = str_replace( ".", "_", $module_name ); - $module_obj = $this->executed_module_object_array[$module_name]; + $module_obj = null; + if( isset($this->executed_module_object_array[$module_name]) ) { + $module_obj = $this->executed_module_object_array[$module_name]; + } if( is_null( $module_obj ) ) { // モジュールがスタックにない場合は新規作成して実行 $module_obj = new $module_real_name; @@ -240,4 +245,4 @@ return $reterun_hash; } } -?> +?> \ No newline at end of file Modified: current/DATA/lib/spider/tags/Charset.class.php =================================================================== --- current/DATA/lib/spider/tags/Charset.class.php 2009-03-30 02:43:06 UTC (rev 15) +++ current/DATA/lib/spider/tags/Charset.class.php 2009-03-30 10:25:39 UTC (rev 16) @@ -116,19 +116,23 @@ $process_code .= "mb_language('".$language."');\n"; $process_code .= "mb_detect_order('".$detect_order."');\n"; $process_code .= "mb_internal_encoding('".$internal_charset."');\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 ); // 表示文字列に対する処理実行コードを記述 - if( !is_array($build_information->convert_view_process_hash) ){ + if( !isset($build_information->convert_view_process_hash) + || !is_array($build_information->convert_view_process_hash) ){ $build_information->convert_view_process_hash = array(); } - if( !is_array($build_information->convert_view_process_hash[$this->priority]) ){ + if( !isset($build_information->convert_view_process_hash[$this->priority]) + || !is_array($build_information->convert_view_process_hash[$this->priority]) ){ $build_information->convert_view_process_hash[$this->priority] = array(); } if( strlen( trim( $convert_kana ) ) > 0 ) { Modified: current/DATA/lib/spider/tags/OutputHtml.class.php =================================================================== --- current/DATA/lib/spider/tags/OutputHtml.class.php 2009-03-30 02:43:06 UTC (rev 15) +++ current/DATA/lib/spider/tags/OutputHtml.class.php 2009-03-30 10:25:39 UTC (rev 16) @@ -64,15 +64,20 @@ $option_values = explode(' ',$output_option); $option_hash = array(); foreach( $option_values as $option_value ) { - list( $name, $value ) = explode('=',$option_value); - $name = trim($name); - $value = trim($value); + $name = $option_value; + $value = $option_value; + if( preg_match('/\\=/',$option_value) > 0 ) { + list( $name, $value ) = explode('=',$option_value); + $name = trim($name); + $value = trim($value); + } $option_hash[$name] = $value; } // HTMLファイルのライフタイム(sec) - $lifetime = $option_hash['lifetime']; - if( preg_match('/^[0-9]{1-10}$/', $lifetime ) == 0 ) { - $lifetime = 3600; + $lifetime = 3600; + if( isset($option_hash['lifetime']) + && preg_match('/^[0-9]{1-10}$/', $option_hash['lifetime'] ) > 0 ) { + $lifetime = $option_hash['lifetime']; } // コード追加 @@ -90,10 +95,12 @@ $process_code .= '@chmod( "'.$html_path.'", 0666 );'."\n"; $process_code .= '}'."\n"; $process_code .= '}'."\n"; - if( !is_array($build_information->convert_view_process_hash) ){ + if( !isset($build_information->convert_view_process_hash) + || !is_array($build_information->convert_view_process_hash) ){ $build_information->convert_view_process_hash = array(); } - if( !is_array($build_information->convert_view_process_hash[$this->priority]) ){ + if( !isset($build_information->convert_view_process_hash[$this->priority]) + || !is_array($build_information->convert_view_process_hash[$this->priority]) ){ $build_information->convert_view_process_hash[$this->priority] = array(); } array_push( $build_information->convert_view_process_hash[$this->priority], $process_code ); Modified: current/DATA/lib/spider/tags/PageTitle.class.php =================================================================== --- current/DATA/lib/spider/tags/PageTitle.class.php 2009-03-30 02:43:06 UTC (rev 15) +++ current/DATA/lib/spider/tags/PageTitle.class.php 2009-03-30 10:25:39 UTC (rev 16) @@ -42,10 +42,12 @@ // 前処理追加:ページタイトルを属性にセット $process_code = '$page_title="'.str_replace("'","\\'",$page_title).'";'."\n"; $process_code .= '$request_object->setAttribute("page_title",$page_title );'."\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 ); Modified: current/DATA/lib/spider/tags/RewriteDocumentRoot.class.php =================================================================== --- current/DATA/lib/spider/tags/RewriteDocumentRoot.class.php 2009-03-30 02:43:06 UTC (rev 15) +++ current/DATA/lib/spider/tags/RewriteDocumentRoot.class.php 2009-03-30 10:25:39 UTC (rev 16) @@ -108,10 +108,12 @@ $process_code .= ' }'."\n"; $process_code .= '}}}'; - if( !is_array($build_information->convert_view_process_hash) ){ + if( !isset($build_information->convert_view_process_hash) + || !is_array($build_information->convert_view_process_hash) ){ $build_information->convert_view_process_hash = array(); } - if( !is_array($build_information->convert_view_process_hash[$this->priority]) ){ + if( !isset($build_information->convert_view_process_hash[$this->priority]) + || !is_array($build_information->convert_view_process_hash[$this->priority]) ){ $build_information->convert_view_process_hash[$this->priority] = array(); } array_push( $build_information->convert_view_process_hash[$this->priority], $process_code ); Modified: current/DATA/lib/spider/tags/SetRequestParam.class.php =================================================================== --- current/DATA/lib/spider/tags/SetRequestParam.class.php 2009-03-30 02:43:06 UTC (rev 15) +++ current/DATA/lib/spider/tags/SetRequestParam.class.php 2009-03-30 10:25:39 UTC (rev 16) @@ -48,10 +48,12 @@ $process_code .= 'foreach($_COOKIE as $key=>$value){'."\n"; $process_code .= '$request_object->setAttribute(\'cookie.\'.$key,$value);'."\n"; $process_code .= '}'."\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 ); Modified: current/DATA/lib/spider/tags/Widget.class.php =================================================================== (Binary files differ) Modified: current/README.txt =================================================================== --- current/README.txt 2009-03-30 02:43:06 UTC (rev 15) +++ current/README.txt 2009-03-30 10:25:39 UTC (rev 16) @@ -7,6 +7,9 @@ 1) ページ内で$request->setAttributeメソッドで値をセットした場合に$GLOBALSに設定しない為 if/foreach/writeで問題が発生する不具合を修正 +2) Noticeの修正 + PHP5のerror_reportingをE_ALLで実行した際にNoticeやWarningが出る箇所を修正 + -- 2009-03-27 1)この機会しかないと思ったのでクラス名の変更を行いました。 ・ExecutableFileCreator.class.php -> Builder.class.php Modified: current/WWW_PUBLIC/spider.inc.php =================================================================== --- current/WWW_PUBLIC/spider.inc.php 2009-03-30 02:43:06 UTC (rev 15) +++ current/WWW_PUBLIC/spider.inc.php 2009-03-30 10:25:39 UTC (rev 16) @@ -18,7 +18,7 @@ die( 'コントロールファイルです' ); } -if( !defined( $DIR_PATH_SPIDER_DATA ) || strlen( trim( $DIR_PATH_SPIDER_DATA ) ) == 0 ) { +if( !isset( $DIR_PATH_SPIDER_DATA ) || strlen( trim( $DIR_PATH_SPIDER_DATA ) ) == 0 ) { define ( "DIR_PATH_SPIDER_DATA", dirname(dirname( __FILE__ ) ).DIRECTORY_SEPARATOR."DATA" ); } else { define ( "DIR_PATH_SPIDER_DATA", $DIR_PATH_SPIDER_DATA ); @@ -28,9 +28,11 @@ $request_server_name = $_SERVER['SERVER_NAME']; $request_url = $_SERVER['REQUEST_URI']; $document_root = $_SERVER['DOCUMENT_ROOT']; -$request_https = $_SERVER['HTTPS']; - -if( strlen($SPIDER_DEFINE_BASE_URI) > 0 ) { +$is_ssl = false; +if( isset($_SERVER['HTTPS']) && preg_match('/[oO][fF][fF]/', $_SERVER['HTTPS'] ) == 0 ) { + $is_ssl = true; +} +if( isset($SPIDER_DEFINE_BASE_URI) && strlen($SPIDER_DEFINE_BASE_URI) > 0 ) { $spider_base_uri = $SPIDER_DEFINE_BASE_URI; } else { $spider_inc_path = str_replace( "\\", "/", __FILE__ ); @@ -41,7 +43,7 @@ } $prtcl = "http://"; -if( strlen(trim($request_https)) > 0 && preg_match('/[oO][fF][fF]/', $request_https ) == 0 ) { +if( $is_ssl ) { $prtcl = "https://"; } $target_port = ""; From svnnotify @ sourceforge.jp Mon Mar 30 19:50:07 2009 From: svnnotify @ sourceforge.jp (svnnotify @ sourceforge.jp) Date: Mon, 30 Mar 2009 19:50:07 +0900 Subject: [Frameworkspider-svn] spider-commit [17] Message-ID: <1238410207.561721.7522.nullmailer@users.sourceforge.jp> Revision: 17 http://svn.sourceforge.jp/view?root=frameworkspider&view=rev&rev=17 Author: m_nakashima Date: 2009-03-30 19:50:07 +0900 (Mon, 30 Mar 2009) Log Message: ----------- Modified Paths: -------------- current/DATA/lib/spider/tags/DynamicPage.class.php current/DATA/lib/spider/tags/If.class.php current/DATA/lib/spider/tags/Write.class.php -------------- next part -------------- Modified: current/DATA/lib/spider/tags/DynamicPage.class.php =================================================================== --- current/DATA/lib/spider/tags/DynamicPage.class.php 2009-03-30 10:25:39 UTC (rev 16) +++ current/DATA/lib/spider/tags/DynamicPage.class.php 2009-03-30 10:50:07 UTC (rev 17) @@ -93,7 +93,11 @@ $build_information->addConfirmFile( $page_file_path ); } // 代替ページファイルの確認 - $alt_agent = $GLOBALS['SPIDER_USER_AGENT_CLASS_ALT_HASH'][$build_information->agent_class]; + $alt_agent = null; + if( isset($GLOBALS['SPIDER_USER_AGENT_CLASS_ALT_HASH']) + && isset($GLOBALS['SPIDER_USER_AGENT_CLASS_ALT_HASH'][$build_information->agent_class]) ) { + $alt_agent = $GLOBALS['SPIDER_USER_AGENT_CLASS_ALT_HASH'][$build_information->agent_class]; + } if( !is_null($alt_agent) && strlen($alt_agent) > 0 ) { // 代替ユーザーエージェントが指定されているなら $page_file_path = $this->getAgentFile( $build_information, $alt_agent ); Modified: current/DATA/lib/spider/tags/If.class.php =================================================================== --- current/DATA/lib/spider/tags/If.class.php 2009-03-30 10:25:39 UTC (rev 16) +++ current/DATA/lib/spider/tags/If.class.php 2009-03-30 10:50:07 UTC (rev 17) @@ -241,7 +241,11 @@ $str = $tmp_name. '='.$key.';'."\n"; array_push( $temporary_valiable_getter_array, $str ); } else { - list( $vname, $vparam ) = explode('::',$key); + $vname = $key; + $vparam = ''; + if( strpos($key,'::') !== false ) { + list( $vname, $vparam ) = explode('::',$key); + } // 一時編集取得文字列作成 $str = $tmp_name. '=$request_object->getAttribute(\''.$vname.'\');'."\n"; $str .= 'if( !$request_object->existAttribute("'.$vname.'") ){'."\n"; @@ -269,7 +273,7 @@ // 変数配列を文字列の長い順にソート $order_array = array(); foreach( $var_name_array as $key => $value ) { - if( !is_array( $order_array[strlen($key)] ) ) { + if( !isset($order_array[strlen($key)]) || !is_array( $order_array[strlen($key)] ) ) { $order_array[strlen($key)] = array(); } array_push($order_array[strlen($key)],$key); Modified: current/DATA/lib/spider/tags/Write.class.php =================================================================== --- current/DATA/lib/spider/tags/Write.class.php 2009-03-30 10:25:39 UTC (rev 16) +++ current/DATA/lib/spider/tags/Write.class.php 2009-03-30 10:50:07 UTC (rev 17) @@ -248,7 +248,7 @@ // 変数配列を文字列の長い順にソート $order_array = array(); foreach( $var_name_array as $key => $value ) { - if( !is_array( $order_array[strlen($key)] ) ) { + if( !isset($order_array[strlen($key)]) || !is_array( $order_array[strlen($key)] ) ) { $order_array[strlen($key)] = array(); } array_push($order_array[strlen($key)],$key); From svnnotify @ sourceforge.jp Mon Mar 30 20:53:40 2009 From: svnnotify @ sourceforge.jp (svnnotify @ sourceforge.jp) Date: Mon, 30 Mar 2009 20:53:40 +0900 Subject: [Frameworkspider-svn] spider-commit [18] Message-ID: <1238414020.593000.7033.nullmailer@users.sourceforge.jp> 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 = ''; - return $ret_strings; + $result_string = ''; + return $result_string; } /** * 文字列解析 From svnnotify @ sourceforge.jp Tue Mar 31 10:01:45 2009 From: svnnotify @ sourceforge.jp (svnnotify @ sourceforge.jp) Date: Tue, 31 Mar 2009 10:01:45 +0900 Subject: [Frameworkspider-svn] spider-commit [19] Message-ID: <1238461305.633658.25807.nullmailer@users.sourceforge.jp> Revision: 19 http://svn.sourceforge.jp/view?root=frameworkspider&view=rev&rev=19 Author: m_nakashima Date: 2009-03-31 10:01:45 +0900 (Tue, 31 Mar 2009) Log Message: ----------- Modified Paths: -------------- current/DATA/lib/spider/tags/TagBase.class.php -------------- next part -------------- Modified: current/DATA/lib/spider/tags/TagBase.class.php =================================================================== --- current/DATA/lib/spider/tags/TagBase.class.php 2009-03-30 11:53:40 UTC (rev 18) +++ current/DATA/lib/spider/tags/TagBase.class.php 2009-03-31 01:01:45 UTC (rev 19) @@ -125,7 +125,7 @@ /** * タグコードをPHPコードに変換します */ - function tagCode2NativeCode( $strings, & $attribute_name_array=array() ) { + function tagCode2NativeCode( $strings, & $attribute_name_array ) { // 演算時の正規表現 $signiture_regx = '\\+\\-\\/\\*\\%\\=\\<\\>\\&\\|\\(\\)\\!\\,\\[\\]'; // 変換後文字列 From svnnotify @ sourceforge.jp Tue Mar 31 13:30:04 2009 From: svnnotify @ sourceforge.jp (svnnotify @ sourceforge.jp) Date: Tue, 31 Mar 2009 13:30:04 +0900 Subject: [Frameworkspider-svn] spider-commit [20] Message-ID: <1238473804.699103.31660.nullmailer@users.sourceforge.jp> Revision: 20 http://svn.sourceforge.jp/view?root=frameworkspider&view=rev&rev=20 Author: m_nakashima Date: 2009-03-31 13:30:04 +0900 (Tue, 31 Mar 2009) Log Message: ----------- Modified Paths: -------------- current/DATA/lib/spider/tags/TagBase.class.php current/WWW_PUBLIC/index.php -------------- next part -------------- Modified: current/DATA/lib/spider/tags/TagBase.class.php =================================================================== --- current/DATA/lib/spider/tags/TagBase.class.php 2009-03-31 01:01:45 UTC (rev 19) +++ current/DATA/lib/spider/tags/TagBase.class.php 2009-03-31 04:30:04 UTC (rev 20) @@ -57,7 +57,7 @@ if( strlen(trim($options_string)) == 0 ) { // タグが終了しているようならオプション無で処理 $option_array = array(); - $converted_strings = $this->getConvertedStrings( &$result_strings, &$build_information, $option_array, $valiable_counter ); + $converted_strings = $this->getConvertedStrings( $result_strings, $build_information, $option_array, $valiable_counter ); $result_strings = str_replace( $target_tag, $converted_strings, $result_strings ); } else if( preg_match('/^\\:/', $options_string) > 0 ) { // :で始まっているならオプション文字列なのでオプションを取り出して処理 @@ -70,7 +70,7 @@ array_push( $option_array, $param ); } } - $converted_strings = $this->getConvertedStrings( &$result_strings, &$build_information, $option_array, $valiable_counter ); + $converted_strings = $this->getConvertedStrings( $result_strings, $build_information, $option_array, $valiable_counter ); $result_strings = str_replace( $target_tag, $converted_strings, $result_strings ); } else { // 終了でも:でもないなら違うタグなので処理しない Modified: current/WWW_PUBLIC/index.php =================================================================== --- current/WWW_PUBLIC/index.php 2009-03-31 01:01:45 UTC (rev 19) +++ current/WWW_PUBLIC/index.php 2009-03-31 04:30:04 UTC (rev 20) @@ -1,6 +1,7 @@ {charset:UTF-8} {template:public_default.php} +{page-title:framework-sipder example page!} {module:example.Hello force post(a="afds) get() attribute_prefix(media)} {module:example.Hello force} {dynamic-page} From svnnotify @ sourceforge.jp Tue Mar 31 20:38:18 2009 From: svnnotify @ sourceforge.jp (svnnotify @ sourceforge.jp) Date: Tue, 31 Mar 2009 20:38:18 +0900 Subject: [Frameworkspider-svn] spider-commit [21] Message-ID: <1238499498.592319.21431.nullmailer@users.sourceforge.jp> Revision: 21 http://svn.sourceforge.jp/view?root=frameworkspider&view=rev&rev=21 Author: m_nakashima Date: 2009-03-31 20:38:18 +0900 (Tue, 31 Mar 2009) Log Message: ----------- Modified Paths: -------------- current/DATA/lib/spider/BuildInformation.class.php current/DATA/lib/spider/Builder.class.php current/DATA/lib/spider/tags/Charset.class.php current/DATA/lib/spider/tags/PageTitle.class.php current/DATA/lib/spider/tags/SetAttribute.class.php current/DATA/lib/spider/tags/SetRequestParam.class.php current/DATA/lib/spider/tags/TagBase.class.php current/DATA/lib/spider/tags/Template.class.php current/README.txt -------------- next part -------------- Modified: current/DATA/lib/spider/BuildInformation.class.php =================================================================== --- current/DATA/lib/spider/BuildInformation.class.php 2009-03-31 04:30:04 UTC (rev 20) +++ current/DATA/lib/spider/BuildInformation.class.php 2009-03-31 11:38:18 UTC (rev 21) @@ -21,7 +21,7 @@ var $compare_time_file_array = array(); /** ホットビルド機能:ファイル存在確認ファイル配列 */ var $confirm_exists_file_array = array(); - /** 表示前実行コードハッシュ */ + /** 処理開始前実行コードハッシュ */ var $preview_process_hash = array(); /** 表示後実行コードハッシュ */ var $postview_process_hash = array(); Modified: current/DATA/lib/spider/Builder.class.php =================================================================== --- current/DATA/lib/spider/Builder.class.php 2009-03-31 04:30:04 UTC (rev 20) +++ current/DATA/lib/spider/Builder.class.php 2009-03-31 11:38:18 UTC (rev 21) @@ -42,6 +42,8 @@ , PREG_PATTERN_ORDER ); foreach ( $output_array as $output ) { foreach ( $output as $target ) { + // 空行にならないよう前後が改行も削除 + $this->out_body_strings = str_replace( "\n".$target."\n", "", $this->out_body_strings ); $this->out_body_strings = str_replace( $target, "", $this->out_body_strings ); } } @@ -51,6 +53,8 @@ , PREG_PATTERN_ORDER ); foreach ( $output_array as $output ) { foreach ( $output as $target ) { + // 空行にならないよう前後が改行も削除 + $this->out_body_strings = str_replace( "\n".$target."\n", "", $this->out_body_strings ); $this->out_body_strings = str_replace( $target, "", $this->out_body_strings ); } } @@ -61,6 +65,8 @@ , PREG_PATTERN_ORDER ); foreach ( $output_array as $output ) { foreach ( $output as $target ) { + // 空行にならないよう前後が改行も削除 + $this->out_body_strings = str_replace( "\n".$target."\n", "", $this->out_body_strings ); $this->out_body_strings = str_replace( $target, "", $this->out_body_strings ); } } @@ -70,21 +76,27 @@ , PREG_PATTERN_ORDER ); foreach ( $output_array as $output ) { foreach ( $output as $target ) { + // 空行にならないよう前後が改行も削除 + $this->out_body_strings = str_replace( "\n".$target."\n", "", $this->out_body_strings ); $this->out_body_strings = str_replace( $target, "", $this->out_body_strings ); } } // 空PHP部分を削除 - $this->out_body_strings = preg_replace('/<\\?php[\\s]+\\?>/','',$this->out_body_strings); + $this->out_body_strings = preg_replace('/<\\?php[\\s]*\\?>\\n/','',$this->out_body_strings); + $this->out_body_strings = preg_replace('/<\\?php[\\s]*\\?>/','',$this->out_body_strings); // フォルダデフォルトファイルの適用 - $folder_default_path = null; - $folder_path = dirname($build_information_object->execute_file_path); + $folder_default_path = null; + $folder_path = dirname($build_information_object->execute_file_path); + // 存在しなかった場合の存在確認比較ファイルパス + $confirm_default_path_array = array(); while( strlen($folder_path) > strlen(APPLICATION_BASE_PATH) ) { $folder_default_path = $folder_path.DIRECTORY_SEPARATOR.'.default'; if( file_exists( $folder_default_path ) ) { break; } else { + array_push( $confirm_default_path_array, $folder_default_path ); $folder_default_path = null; } $folder_path = dirname($folder_path); @@ -92,6 +104,12 @@ if( !is_null( $folder_default_path ) && file_exists($folder_default_path) ) { $str = trim(file_get_contents($folder_default_path)); $this->out_body_strings = $str.$this->out_body_strings; + // フォルダデフォルトファイルをタイムスタンプ比較ファイルに追加 + $build_information_object->addCompareFile( $folder_default_path ); + } else if( count( $confirm_default_path_array ) > 0 ) { + foreach( $confirm_default_path_array as $path ) { + $build_information_object->addConfirmFile( $path ); + } } // 変換タグの読み込みと変換 @@ -158,7 +176,7 @@ // 表示前実行部分作成 $string = "preview_process_hash as $code_array ) { foreach( $code_array as $code ) { $string .= $code."\n"; Modified: current/DATA/lib/spider/tags/Charset.class.php =================================================================== --- current/DATA/lib/spider/tags/Charset.class.php 2009-03-31 04:30:04 UTC (rev 20) +++ current/DATA/lib/spider/tags/Charset.class.php 2009-03-31 11:38:18 UTC (rev 21) @@ -46,7 +46,9 @@ foreach ( $output as $target ) { $charset_strings = preg_replace( '/\\{charset\\:/','', $target ); $charset_strings = preg_replace( '/\\}/','', $charset_strings ); - $result_strings = str_replace( $target, "", $result_strings ); + // 空行にならないよう前後が改行も削除 + $result_strings = str_replace( "\n".$target."\n", "", $result_strings ); + $result_strings = str_replace( $target, "", $result_strings ); $charset_strings = trim($charset_strings); } } Modified: current/DATA/lib/spider/tags/PageTitle.class.php =================================================================== --- current/DATA/lib/spider/tags/PageTitle.class.php 2009-03-31 04:30:04 UTC (rev 20) +++ current/DATA/lib/spider/tags/PageTitle.class.php 2009-03-31 11:38:18 UTC (rev 21) @@ -34,6 +34,7 @@ foreach ( $output as $target ) { $page_title = preg_replace( '/\\{page\\-title\\:/','', $target ); $page_title = preg_replace( '/\\}/','', $page_title ); + $result_strings = str_replace( "\n".$target."\n", "", $result_strings ); $result_strings = str_replace( $target, "", $result_strings ); $page_title = trim($page_title); } Modified: current/DATA/lib/spider/tags/SetAttribute.class.php =================================================================== --- current/DATA/lib/spider/tags/SetAttribute.class.php 2009-03-31 04:30:04 UTC (rev 20) +++ current/DATA/lib/spider/tags/SetAttribute.class.php 2009-03-31 11:38:18 UTC (rev 21) @@ -25,7 +25,6 @@ * コンバートメソッド */ function convert( &$result_strings, &$build_information ){ - // 変数タグ $vars_tags_aray = array(); preg_match_all( '/\\{set\\:[^\\}]*?}/' , $result_strings @@ -150,6 +149,87 @@ } } } + + // presetタグの機能追加 + if( preg_match_all( '/\\{preset\\:[^\\}]*?\\}/' + , $result_strings + , $output_array + , PREG_PATTERN_ORDER ) > 0 ) { + foreach ( $output_array as $output ) { + foreach ( $output as $target ) { + $option_strings = preg_replace( '/\\{preset\\:/','', $target ); + $option_strings = preg_replace( '/\\}/','', $option_strings ); + $option_strings = trim($option_strings); + if( strpos($option_strings,' ') !== false ) { + // 空白が存在するなら分割して復元 + $option_array = $this->splitOptionBySpace( $option_strings ); + if( count($option_array) >= 2 ) { + // パラメータが2つ以上ならモジュール実行前コードを追加 + $this->createPresetCode( $build_information, $option_array ); + // タグ行の削除 + $result_strings = str_replace( "\n".$target."\n", "", $result_strings ); + $result_strings = str_replace( $target, "", $result_strings ); + } else { + // 空白が存在しないなら使い方が違うのでエラーメッセージを表示する + $result_strings = str_replace( $target, "[preset tag requre 2 parameters! ".$target."]", $result_strings ); + } + } else { + // 空白が存在しないなら使い方が違うのでエラーメッセージを表示する + $result_strings = str_replace( $target, "[preset tag requre 2 parameters! ".$target."]", $result_strings ); + } + } + } + } } + /** + * presetタグのパラメータを受け取って実行前コードを作成します + */ + function createPresetCode( &$build_information, $param_array ) { + $process_code = ''; + if( count( $param_array ) >= 2 ) { + $name = array_shift( $param_array ); + if( preg_match('/^\\\'[^\\\']+\\\'$/',$name) > 0 ) { + $name = preg_replace('/^\\\'/','',$name); + $name = preg_replace('/\\\'$/','',$name); + } + if( preg_match('/^\\"[^\\\']+\\"$/',$name) > 0 ) { + $name = preg_replace('/^\\"/','',$name); + $name = preg_replace('/\\"$/','',$name); + } + $value = array_shift( $param_array ); + if( preg_match('/^\\\'[^\\\']+\\\'$/',$value) > 0 ) { + $value = preg_replace('/^\\\'/','',$value); + $value = preg_replace('/\\\'$/','',$value); + } + if( preg_match('/^\\"[^\\\']+\\"$/',$value) > 0 ) { + $value = preg_replace('/^\\"/','',$value); + $value = preg_replace('/\\"$/','',$value); + } + $var_name = str_replace('.','_',$name); + $process_code .= '$'.$var_name.' = $request_object->getAttribute("'.$name.'");'."\n"; + $process_code .= 'if( is_array($'.$var_name.') ) { '."\n"; + $process_code .= 'array_push( $'.$var_name.', "'.$value.'" );'."\n"; + $process_code .= '$request_object->setAttribute("'.$name.'",$'.$var_name.' );'."\n"; + $process_code .= '} else if( is_null($'.$var_name.') || strlen($'.$var_name.') == 0 ) { '."\n"; + $process_code .= '$'.$var_name.' = "'.$value.'";'."\n"; + $process_code .= '$request_object->setAttribute("'.$name.'",$'.$var_name.' );'."\n"; + $process_code .= '} else {'."\n"; + // objectの場合の検討..現状オブジェクトが登録済みの場合は上書きしない(あり得ないので) + $process_code .= '}'."\n"; + // ビルド情報に実行コードを追加 + if( !isset($build_information->preview_process_hash) + || !is_array($build_information->preview_process_hash) ){ + $build_information->preview_process_hash = array(); + } + 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 ); + return true; + } else { + return false; + } + } } ?> \ No newline at end of file Modified: current/DATA/lib/spider/tags/SetRequestParam.class.php =================================================================== --- current/DATA/lib/spider/tags/SetRequestParam.class.php 2009-03-31 04:30:04 UTC (rev 20) +++ current/DATA/lib/spider/tags/SetRequestParam.class.php 2009-03-31 11:38:18 UTC (rev 21) @@ -34,11 +34,10 @@ // falseかnoが指定されているなら登録しない $result_strings = preg_replace( '/\\{set\\-request\\-param\\:[fF][aA][lL][sS][eE]\\}/' , "", $result_strings ); - } else { - // 明示的に否定していないなら暗黙的にパラメータを登録 - $result_strings = preg_replace( '/\\{set\\-request\\-param\\:[^\\}]*?\\}/' + $result_strings = preg_replace( '/\\{set\\-request\\-param\\:[fF][aA][lL][sS][eE]\\}/' , "", $result_strings ); - // cookie及びpost,getの値をリクエストに登録 + } else { + // 明示的に否定していないなら暗黙的にcookie及びpost,getの値をリクエストに登録 $process_code = 'foreach($_POST as $key=>$value){'."\n"; $process_code .= '$request_object->setAttribute(\'post.\'.$key,$value);'."\n"; $process_code .= '}'."\n"; Modified: current/DATA/lib/spider/tags/TagBase.class.php =================================================================== --- current/DATA/lib/spider/tags/TagBase.class.php 2009-03-31 04:30:04 UTC (rev 20) +++ current/DATA/lib/spider/tags/TagBase.class.php 2009-03-31 11:38:18 UTC (rev 21) @@ -71,6 +71,10 @@ } } $converted_strings = $this->getConvertedStrings( $result_strings, $build_information, $option_array, $valiable_counter ); + // 空行にならないよう前後が改行も削除 + if( strlen($converted_strings) == 0 ) { + $result_strings = str_replace( "\n".$target_tag."\n", $converted_strings, $result_strings ); + } $result_strings = str_replace( $target_tag, $converted_strings, $result_strings ); } else { // 終了でも:でもないなら違うタグなので処理しない @@ -95,30 +99,37 @@ * オプション文字列をオプション配列にします。 */ function splitOptionBySpace( $string ) { - // 2文字以上連続のスペースは1文字に統一 - while( preg_match('/\\s\\s/',$string) > 0 ) { - $string = str_replace( ' ',' ', $string ); - } - // 分割 - $column_array = explode(' ', $string); // 最終的なオプション文字列配列 $option_array = array(); - // クォートを維持してオプション文字列配列にいれる - $data = ''; - foreach( $column_array as $column ) { - $data .= $column; - if( preg_match('/^\\\'/',$data) > 0 && substr_count( $data, "'" ) % 2 == 1 ) { - // 'から始まって'の数が偶数個なら次のカラムとつなげる - continue; - } else if( preg_match('/^\\\"/',$data) > 0 && substr_count( $data, '"' ) % 2 == 1 ) { - // "から始まって"の数が偶数個なら次のカラムとつなげる - continue; - } else { - // そうでない場合はカラムがデータとして完結しているので配列に追加 - array_push( $option_array, $data ); - // 次のデータに備えてデータを空文字で新しく設定 - $data = ''; + $string = trim($string); + if( strpos($string,' ') !== false ) { + // 2文字以上連続のスペースは1文字に統一 + while( preg_match('/\\s\\s/',$string) > 0 ) { + $string = str_replace( ' ',' ', $string ); } + // 分割 + $column_array = explode(' ', $string); + // クォートを維持してオプション文字列配列にいれる + $data = ''; + foreach( $column_array as $column ) { + $data .= $column; + if( preg_match('/^\\\'/',$data) > 0 && substr_count( $data, "'" ) % 2 == 1 ) { + // 'から始まって'の数が偶数個なら次のカラムとつなげる + $data .= ' '; + continue; + } else if( preg_match('/^\\\"/',$data) > 0 && substr_count( $data, '"' ) % 2 == 1 ) { + // "から始まって"の数が偶数個なら次のカラムとつなげる + $data .= ' '; + continue; + } else { + // そうでない場合はカラムがデータとして完結しているので配列に追加 + array_push( $option_array, $data ); + // 次のデータに備えてデータを空文字で新しく設定 + $data = ''; + } + } + } else { + array_push( $option_array, $string ); } return $option_array; } Modified: current/DATA/lib/spider/tags/Template.class.php =================================================================== (Binary files differ) Modified: current/README.txt =================================================================== --- current/README.txt 2009-03-31 04:30:04 UTC (rev 20) +++ current/README.txt 2009-03-31 11:38:18 UTC (rev 21) @@ -3,6 +3,18 @@ ** ** このファイルにはコミットごとに変更点とファイル名を記述します。 ** +-- 2009-03-31 +1) .defaultファイルのタイムスタンプ比較及び存在確認がホットビルドから漏れていたので追加 + DATA/lib/spider/Builder.class.php + +2) presetタグをSetAttribute.class.phpに追加 + モジュール実行前処理として、固定文字列、固定数値をrequest属性に設定してページを実行できます。 + 例) {preset:database.name 'framework spider !'} + 固定文字列はシングルクォーテーションで囲ってください。 + +3) TagBase.class.phpのsplitOptionBySpaceメソッドでクォート文字列内の文字列連結時にスペースを + 復元していなかった問題の修正 + -- 2009-03-30 1) ページ内で$request->setAttributeメソッドで値をセットした場合に$GLOBALSに設定しない為 if/foreach/writeで問題が発生する不具合を修正