タグを生成する) $INDEX_PHP = $ary_configini["INDEX_PHP"]."?prid="; $HTML_SERVER_DIR = $ary_configini["HTML_SERVER_DIR"]; // --- ナビゲーション表示部分 リンクのためのパス (http://host/[_HERE_]/XXXX.html) ----- $LINK_PATH = $ary_configini["LINK_PATH"]; // ----- GET URL PARAMETERS ----- // usage as "./index.php?prid=1234567" $prid = $HTTP_GET_VARS["prid"]; // pridが取得できない時は,トップページのpridを設定する if ($prid == "") { $prid = $DefaultIndexPage; } // get a prid-valuable, trimmimg 7 characters from the head $prid= substr($prid, 0, 7); // --- コンテンツhtmlファイルの取得 (拡張子は「htm」とする) --- //$contents_html_src_file = $ary_configini["HTML_SERVER_DIR"] . $prid . ".htm"; // 同階層にコンテンツファイルがない場合 (YGサーバーでは動作未確認) $contents_html_src_file = $prid . ".htm"; // 同階層にコンテンツファイルがある設定の場合 // --- Check if the file exist or not. --- if(!(file_exists($contents_html_src_file))){ FuncShowErrMsg("ファイルが見つかりません"); exit; } // --- インデックス(トップ)ページフラグ --- if ($prid == $DefaultIndexPage){ $this_is_toppage = 1; } //------------------------------------------------------------------------- // コンテンツhtmlファイルのソース取得 ここから $flg_extracting_src = 0; $str_CONT_SRC = ""; $f1 = fopen($contents_html_src_file, "r"); // HTMLソース中,Navitool用のセパレタ(Head, Foot)を探し,ソースを抽出 while(!feof($f1)){ $line_str_CONT_SRC = fgets($f1); if( mb_strpos($line_str_CONT_SRC, "--Navitool_Head--")){ $flg_extracting_src = 1; } if( mb_strpos($line_str_CONT_SRC, "--Navitool_Foot--")){ $flg_extracting_src = 0; break; } //ソースとして抽出する if($flg_extracting_src == 1){ $str_CONT_SRC = $str_CONT_SRC . $line_str_CONT_SRC; } } fclose($f1); // もしHTMLソース中に,Navitool用のセパレタ(Head, Foot)が無い場合 if ($str_CONT_SRC == ""){ $str_CONT_SRC = file_get_contents($contents_html_src_file); // print("Cannot find Navitool Separater!
"); } // コンテンツhtmlファイルのソース取得 ここまで //------------------------------------------------------------------------- $str_CONT_SRC = mb_convert_encoding($str_CONT_SRC, "SJIS","UTF-8"); // テンプレートhtmlファイルのソース取得 ここまで //------------------------------------------------------------------------- // ===== Get Contents Template html Data Source ===== $str_INDEX_TPL_HTMLData = file_get_contents($ary_configini["INDEX_TPL_FILE_NAME"]); $str_INDEX_TPL_HTMLData = mb_convert_encoding($str_INDEX_TPL_HTMLData, "SJIS","UTF-8"); // ---------------------------------------------------------------------------------------- // ナビゲーション・バーの生成 // ---------------------------------------------------------------------------------------- $n_item = sizeof($ary_NaviData); $tbl_tmp2 = ""; //レコード配列のMARGINも空白除去して数値化 for ($i=1; $i<$n_item; $i++){ $ary_NaviData[$i][MARGIN] = trim($ary_NaviData[$i][MARGIN]); } //指定されたファイルの階層をゲット // この階層以下は表示しない $target_margin = 0; for ($i=1; $i<$n_item; $i++){ if ($ary_NaviData[$i][PRID] == $prid){ // ターゲットのmargin取得 $target_margin = $ary_NaviData[$i][MARGIN]; // ターゲットのrec_no取得 $target_rec_no = $i; break; } } // ---------------------------------------------------------------------- // 階層トップへのナビ生成(margin01) リンクは決定済み if ($DefaultIndexPage == $prid){ $tbl_itm = $tbl_itm_tpl_margin01B; }else{ $tbl_itm = $tbl_itm_tpl_margin01A; } $tbl_itm = str_replace("#LOCAL_IMG_DIR#", $ary_configini["LOCAL_IMG_DIR"], $tbl_itm); $tbl_itm = str_replace("#LINK_URL#", "$LINK_PATH$INDEX_PHP$DefaultIndexPage", $tbl_itm); $tbl_itm = str_replace("#LINK_TITLE#", $PageLinkTitle, $tbl_itm); $tbl_tmp2 = $tbl_tmp2 . $tbl_itm; // ---------------------------------------------------------------------- // 2行目からのナビデータ・表示リスト新規作成 $ary_tobeshow_navi = array(); for ($i=1; $i<$n_item; $i++){ //大分類項目(2)のものを配列する if ($ary_NaviData[$i][MARGIN] == 2){ array_push($ary_tobeshow_navi, $i); } } //---------------------------------------------------- // $target_rec_noから上に逆向きサーチ ナビデータ・表示リスト選抜 $target_margin2 = $target_margin; $ary_tobeshow_deep1 = array($target_rec_no); for($i=$target_rec_no; $i>0; $i--){ if($ary_NaviData[$i][MARGIN] < $target_margin2){ array_push($ary_tobeshow_deep1, $i); $target_margin2 = $target_margin2-1; } if($target_margin2 == 2){ break; } } //---------------------------------------------------- // $target_rec_noから下に向かってサーチ ナビデータ・表示リスト選抜 $target_margin2 = $target_margin; $ary_tobeshow_deep2 = array(); for($i=($target_rec_no+1); $i<$n_item; $i++){ if($ary_NaviData[$i][MARGIN] == $target_margin2+1){ array_push($ary_tobeshow_deep2, $i); } if($ary_NaviData[$i][MARGIN] == $target_margin2){ break; } } //---------------------------------------------------- //配列の連結 foreach($ary_tobeshow_deep1 as $item){ array_unshift($ary_tobeshow_deep2, $item); } // ary_tobeshow_navi2に,ary_tobeshow_naviとary_tobeshow_deepを連結 $ary_tobeshow_navi2 = array(); foreach($ary_tobeshow_navi as $item1){ if($item1 == $ary_tobeshow_deep2[0]){ foreach($ary_tobeshow_deep2 as $item2){ array_push($ary_tobeshow_navi2, $item2); } }else{ array_push($ary_tobeshow_navi2, $item1); } } array_unique($ary_tobeshow_navi2); // ---------------------------------------------------------------------- // 2行目からのナビデータ・表示リスト選抜 foreach ($ary_tobeshow_navi2 as $i){ // 見出しがある場合にのみナビ項目を作成 if ($ary_NaviData[$i][LINK_TITLE] != "") { // ページが被表示コンテンツの場合 if ($ary_NaviData[$i][PRID] == $prid){ if ($ary_NaviData[$i][MARGIN] == 2){ $tbl_itm = $tbl_itm_tpl_margin02B; } else if ($ary_NaviData[$i][MARGIN] == 3){ $tbl_itm = $tbl_itm_tpl_margin03B; } else if ($ary_NaviData[$i][MARGIN] == 4){ $tbl_itm = $tbl_itm_tpl_margin04B; } else if ($ary_NaviData[$i][MARGIN] == 5){ $tbl_itm = $tbl_itm_tpl_margin05B; } $tbl_itm = str_replace("#LOCAL_IMG_DIR#", $ary_configini["LOCAL_IMG_DIR"], $tbl_itm); $tbl_itm = str_replace("#LINK_URL#", $LINK_PATH.$INDEX_PHP.$ary_NaviData[$i][LINK_URL], $tbl_itm); $tbl_itm = str_replace("#LINK_TITLE#", trim($ary_NaviData[$i][LINK_TITLE]), $tbl_itm); } // ページが被表示コンテンツでない場合 if ($ary_NaviData[$i][PRID] != $prid){ if ($ary_NaviData[$i][MARGIN] == 2){ $tbl_itm = $tbl_itm_tpl_margin02A; $tbl_itm = str_replace("#LOCAL_IMG_DIR#", $ary_configini["LOCAL_IMG_DIR"], $tbl_itm); $tbl_itm = str_replace("#LINK_URL#", $LINK_PATH.$INDEX_PHP.$ary_NaviData[$i][LINK_URL], $tbl_itm); $tbl_itm = str_replace("#LINK_TITLE#", $ary_NaviData[$i][LINK_TITLE], $tbl_itm); }else if ($ary_NaviData[$i][MARGIN] == 3){ $tbl_itm = $tbl_itm_tpl_margin03A; $tbl_itm = str_replace("#LOCAL_IMG_DIR#", $ary_configini["LOCAL_IMG_DIR"], $tbl_itm); $tbl_itm = str_replace("#LINK_URL#", $LINK_PATH.$INDEX_PHP.$ary_NaviData[$i][LINK_URL], $tbl_itm); $tbl_itm = str_replace("#LINK_TITLE#", $ary_NaviData[$i][LINK_TITLE], $tbl_itm); }else if ($ary_NaviData[$i][MARGIN] == 4){ $tbl_itm = $tbl_itm_tpl_margin04A; $tbl_itm = str_replace("#LOCAL_IMG_DIR#", $ary_configini["LOCAL_IMG_DIR"], $tbl_itm); $tbl_itm = str_replace("#LINK_URL#", $LINK_PATH.$INDEX_PHP.$ary_NaviData[$i][LINK_URL], $tbl_itm); $tbl_itm = str_replace("#LINK_TITLE#", $ary_NaviData[$i][LINK_TITLE], $tbl_itm); }else if ($ary_NaviData[$i][MARGIN] == 5){ $tbl_itm = $tbl_itm_tpl_margin05A; $tbl_itm = str_replace("#LOCAL_IMG_DIR#", $ary_configini["LOCAL_IMG_DIR"], $tbl_itm); $tbl_itm = str_replace("#LINK_URL#", $LINK_PATH.$INDEX_PHP.$ary_NaviData[$i][LINK_URL], $tbl_itm); $tbl_itm = str_replace("#LINK_TITLE#", $ary_NaviData[$i][LINK_TITLE], $tbl_itm); }else{ $tbl_itm = ""; } } $tbl_tmp2 = $tbl_tmp2 . $tbl_itm; } } $str_NAVI_TBL3 = str_replace("###_REPLACED_BY_ITEM_###", $tbl_tmp2, $navi_tpl); $str_NAVI_TBL3 = mb_convert_encoding($str_NAVI_TBL3, "SJIS","UTF-8"); // ---------------------------------------------------------------------- // ----- Replace the title ----- // ---------------------------------------------------------------------- //タイトルの置換 if ($this_is_toppage){ if ($PageHeaderTitle == "") { $PageHeaderTitle = "タイトルが設定されていません"; } $tmp_utf8 = mb_convert_encoding($PageHeaderTitle, "SJIS","auto"); $str_INDEX_TPL_HTMLData = str_replace("###_html_title_###", $tmp_utf8, $str_INDEX_TPL_HTMLData); }else{ $tmp_utf8 = mb_convert_encoding($ary_NaviData[$target_rec_no][HTML_TITLE], "SJIS","auto"); $str_INDEX_TPL_HTMLData = str_replace("###_html_title_###", $tmp_utf8, $str_INDEX_TPL_HTMLData); } // デスクリプション(引数によらず,index.phpに一つ)の置換 if ($PageHeaderDescription == "") { $PageHeaderDescription = "ディスクリプションが設定されていません"; } $PageHeaderDescription = mb_convert_encoding($PageHeaderDescription, "SJIS","auto"); $str_INDEX_TPL_HTMLData = str_replace("###_html_description_###", $PageHeaderDescription, $str_INDEX_TPL_HTMLData); // ---------------------------------------------------------------------- // --- final generation of streaming --- // ---------------------------------------------------------------------- $str_INDEX_TPL_HTMLData = str_replace("###_REPLACED_BY_CONTENTS_###", $str_CONT_SRC, $str_INDEX_TPL_HTMLData); $str_INDEX_TPL_HTMLData = str_replace("###_REPLACED_BY_NAVI_###", $str_NAVI_TBL3, $str_INDEX_TPL_HTMLData); // --- http response --- $str_INDEX_TPL_HTMLData = mb_convert_encoding($str_INDEX_TPL_HTMLData, "UTF-8", "SJIS"); // 「?」の除去作業 (May 2005, YGサーバーPHPの,文字変換関数の問題) //if ((substr($str_INDEX_TPL_HTMLData, 0) == "?")){ $str_INDEX_TPL_HTMLData = substr($str_INDEX_TPL_HTMLData, 1); //} header("Content-Type: text/html;charset=UTF-8"); print ($str_INDEX_TPL_HTMLData); exit; ?>