お知らせ

お知らせ一覧

'; echo 'alert('.json_encode($data).')'; echo ''; } function console_log($data){ echo ''; } ?> タグのhrefに指定されているファイルを保持する配列 $hrefFileList = array(); foreach($years as $year) { // ファイルポインタをオープン $file = fopen("../../shared/inc/inc_information.html", "r"); if ($file) { // 出力用フラグ $isRead = false; $yearflg = false; // 更新アイコン初期化 $renewIco = 0; //
とを格納する一時バッファ $tempBuffer = array(); // 最終更新日保持変数 $lastUpdated = ""; while ($line = fgets($file)) { // 文字列の後ろの改行(\n)を削除 $line = trim($line); // 先頭#の文章又は空行を飛ばす if (preg_match('/^#.*/', $line) || $line == "" ) { continue; } // コメント開始検知 if (preg_match('//', $line) ) { // コメントフラグOFF $commentOut = false; } // コメントフラグONの際にコメントを飛ばす if ($commentOut == true) { continue; } // renew-ico01又はrenew-ico02が含まれており、「$year」を含む場合は、それ以降の$lineを出力する // コロナ関連のお知らせではない if (strpos ($line, " corona-switch") == false) { if (strpos ($line, " renew-ico01") !== false || strpos ($line, "renew-ico02") !== false) { if (strpos ($line, " renew-ico01") !== false) { //重要アイコン $renewIco = 1; } if (strpos ($line, " renew-ico02") !== false) { //お知らせアイコン $renewIco = 2; } // 出力ON $isRead = true; //
を格納する一時バッファを初期化 $tempBuffer = array(); //array_push($tempBuffer, $line); } } if(strpos($line, "
タグの場合 if (preg_match('/^
.*/', $line)) { // href="xxx/yyy/zzz.html" の xxx/yyy/zzz.html を取得する // →$matches[1] に xxx/yyy/zzz.html が格納される preg_match("/href=\"?(.+?)\"/", $line, $matches); // $matches[1] に値がある場合 if (isset($matches[1])) { // herfのリンクファイルを取得 $hrefFile = $matches[1]; // 初回検出の場合 if (!in_array($hrefFile, $hrefFileList)) { // 追加 array_push($hrefFileList, $hrefFile); // 2回目以降検出の場合 } else { // $hrefFile が / で終わっている場合は、index.htmlを付ける if (preg_match('/^.+\/$/', $hrefFile)) { $hrefFile = $hrefFile . "index.html"; } // 対象ファイル $targetFile = $_SERVER['DOCUMENT_ROOT'] . $hrefFile; // ファイルが存在する場合 if (file_exists($targetFile)) { // 該当ファイルのタイムスタンプ文言を取得する $lastUpdated = "(最終更新日:". date("Y/m/d", filemtime($targetFile)).")"; } } } } //
タグの場合で、最終更新日保持変数に値が設定されている場合 if (preg_match('/^.*<\/dd>$/', $line) && $lastUpdated != "") { // タグの前にタイムスタンプ文言を差し込む $line = str_replace("", $lastUpdated . "", $line); // 最終更新日保持変数を初期化 $lastUpdated = ""; } // $lineをバッファに格納 array_push($tempBuffer, $line); } // 出力ON時に を検出した場合 if ($isRead && $line == "") { // 出力OFF $isRead = false; $yearflg = false; // $tempBufferには
タグと
タグとタグが格納されているので // HTML格納用バッファに格納する if (!empty($tempBuffer)) { // 更新アイコンが「重要」の場合 if ($renewIco == 1) { $buffer = array_merge($buffer, array('
'), $tempBuffer, array('
')); // 更新アイコンが「お知らせ」の場合 } elseif ($renewIco == 2) { $buffer = array_merge($buffer, array('
'), $tempBuffer, array('
')); } else { // 更新アイコンなしの場合 $buffer = array_merge($buffer, $tempBuffer); } } // 更新アイコン初期化 $renewIco = 0; } } // ファイルポインタをクローズ fclose($file); // その年のHTML取得 $result = implode("\n", $buffer); // 出力 if (count($buffer) > 0) { echo <<

{$year}年

{$result}
HTML; } // HTML格納用バッファ初期化 $buffer = array(); } } ?>