/** * 日記htmlコンテンツの作成 * * @param string $diary_row 日記配列 * @param string $encoding エンコーディング */ function create_diary_html($diary_row, $encoding = '') { $file_head = date("Ymd_His", ACSLib::convert_pg_date_to_timestamp($diary_row['post_date'])); $this->diary_file_names[$file_head]++; if ($this->diary_file_names[$file_head] > 1) { $file_head .= '_' . ($this->diary_file_names[$html_file] - 1); } $html_file = $file_head . '.html'; // 基本項目の置換 $contents = _ACSDIARYBACKUP_DIARY_FORMAT; $contents = mb_ereg_replace('@SUBJECT@', htmlspecialchars($diary_row['subject']), $contents); $contents = mb_ereg_replace('@POST_DATE@', htmlspecialchars(ACSLib::convert_pg_date_to_str($diary_row['post_date'])), $contents); $contents = mb_ereg_replace('@BODY@', nl2br(htmlspecialchars($diary_row['body'])), $contents); $contents = mb_ereg_replace('@OPEN_LEVEL_TITLE@', htmlspecialchars(ACSMsg::get_mdmsg(__FILE__, 'M001')), $contents); $contents = mb_ereg_replace('@OPEN_LEVEL_NAME@', htmlspecialchars($diary_row['open_level_name']), $contents); // イメージファイルがある場合 $image_file_id = $diary_row['file_id']; if ($image_file_id != '') { $file_obj = ACSFile::get_file_info_instance($image_file_id); // 拡張子の取得 mb_ereg("^.*(\\.[^\\.\\/]*)", $file_obj->get_display_file_name(), $matches); $ext = $matches[1]; // ファイル名の生成 $img_from = ACS_FOLDER_DIR . $file_obj->get_server_file_name(); $img_to = $this->img_dir . '/' . $file_head . $ext; $img_thumb_from = ACS_FOLDER_DIR . $file_obj->get_thumbnail_server_file_name(); $img_thumb_to = $this->img_dir . '/thumb_' . $file_head . '.jpg'; // URLの生成 $img_url = $this->diary_to_img_url . '/' . $file_head . $ext; $img_thumb_url = $this->diary_to_img_url . '/thumb_' . $file_head . '.jpg'; // イメージファイルの作成 @copy($img_from, $img_to); @copy($img_thumb_from, $img_thumb_to); // リンクタグの生成 $contents = mb_ereg_replace('@IMAGE@', '<div><a href="' . $img_url . '">' . '<img src="' . $img_thumb_url . '" border="0"></a></div><br>', $contents); } else { $contents = mb_ereg_replace('@IMAGE@', '', $contents); } // コメントの取得 $diary_comment_row_array = ACSDiary::get_diary_comment_row_array($diary_row['diary_id']); // コメント部分の生成 $comments = ""; foreach ($diary_comment_row_array as $diary_comment_row) { if ($diary_comment_row['diary_comment_delete_flag'] == 'f') { $comment_contents = _ACSDIARYBACKUP_DIARY_COMMENT_FORMAT; $comment_contents = mb_ereg_replace('@POST_DATE@', htmlspecialchars(ACSLib::convert_pg_date_to_str($diary_comment_row['post_date'])), $comment_contents); $comment_contents = mb_ereg_replace('@COMMUNITY_NAME@', htmlspecialchars($diary_comment_row['community_name']), $comment_contents); $comment_contents = mb_ereg_replace('@BODY@', nl2br(htmlspecialchars($diary_comment_row['body'])), $comment_contents); $comments .= $comment_contents; } } // コメントの置換 $contents = mb_ereg_replace('@COMMENTS@', $comments, $contents); // contents 自身の変換 if ($encoding != '') { $contents = mb_convert_encoding($contents, $encoding); } // ファイルへの出力 $fp = fopen($this->diary_dir . '/' . $html_file, "w"); fputs($fp, $contents); fclose($fp); return $html_file; }