/** * ダイアリーの親記事一覧を1月分だけ取得する * * @param $user_community_id ユーザコミュニティID * @param $year 年 * @param $month 月 * @return ダイアリー親記事の一覧 (連想配列の配列) */ static function get_diary_row_array_by_year_month($user_community_id, $year, $month) { $user_community_id = pg_escape_string($user_community_id); // 月の最終日を取得 $end_day = ACSLib::get_end_day($year, $month); // 年, 月 $year = sprintf("%04d", $year); $month = sprintf("%02d", $month); // 開始日 (YYYY/MM/DD) $start_date = "{$year}/{$month}/01"; // 終了日 (YYYY/MM/DD) $end_date = "{$year}/{$month}/{$end_day}"; $sql = "SELECT *, acs_get_diary_comment_num(diary.diary_id) as diary_comment_num, diary.diary_id as diary_id"; $sql .= " FROM diary LEFT OUTER JOIN diary_file USING(diary_id)"; $sql .= ", community as USER_COMMUNITY, user_info, open_level_master"; $sql .= " WHERE diary.community_id = '{$user_community_id}'"; $sql .= " AND diary.community_id = USER_COMMUNITY.community_id"; $sql .= " AND USER_COMMUNITY.community_id = user_info.user_community_id"; $sql .= " AND diary.open_level_code = open_level_master.open_level_code"; $sql .= " AND diary.diary_delete_flag = 'f'"; // post_dateの期間を指定する $sql .= " AND diary.post_date::DATE BETWEEN '{$start_date}'::DATE AND '{$end_date}'::DATE"; $sql .= " ORDER BY diary.post_date DESC"; $row_array = ACSDB::_get_row_array($sql); return $row_array; }
/** * 休日の計算を行います。 * (休日名もセットしていますが、現在は出力していません。) * * @param int $year * @param int $month */ function set_holiday($year, $month) { // その月の最初の月曜日が何日かを算出 $day = 1; while (date("w", mktime(0, 0, 0, $month, $day, $year)) != 1 && checkdate($month, $day, $year)) { $day++; } // 祝日をセット switch ($month) { case 1: // 元旦 $this->holiday[1] = 1; $this->holiday_name[1] = ACSMsg::get_mdmsg(__FILE__, 'M011'); // 成人の日 if ($year < 2000) { $this->holiday[15] = 1; $this->holiday_name[15] = ACSMsg::get_mdmsg(__FILE__, 'M012'); } else { $this->holiday[$day + 7] = 1; $this->holiday_name[$day + 7] = ACSMsg::get_mdmsg(__FILE__, 'M012'); } break; case 2: // 建国記念日 $this->holiday[11] = 1; $this->holiday_name[11] = "建国記念日"; break; case 3: // 春分の日 if ($year > 1979 && $year < 2100) { $tmp = floor(20.8431 + ($year - 1980) * 0.242194 - floor(($year - 1980) / 4)); $this->holiday[$tmp] = 1; $this->holiday_name[$tmp] = ACSMsg::get_mdmsg(__FILE__, 'M013'); } break; case 4: // 天皇誕生日 or みどりの日 $this->holiday[29] = 1; if ($year < 1989) { $this->holiday_name[29] = ACSMsg::get_mdmsg(__FILE__, 'M014'); } else { $this->holiday_name[29] = ACSMsg::get_mdmsg(__FILE__, 'M015'); } break; case 5: // 憲法記念日 $this->holiday[3] = 1; $this->holiday_name[3] = ACSMsg::get_mdmsg(__FILE__, 'M016'); // 子どもの日 $this->holiday[5] = 1; $this->holiday_name[5] = ACSMsg::get_mdmsg(__FILE__, 'M017'); break; case 7: // 海の日 if ($year > 2002) { $this->holiday[$day + 14] = 1; $this->holiday_name[$day + 14] = ACSMsg::get_mdmsg(__FILE__, 'M018'); } elseif ($year > 1994) { $this->holiday[21] = 1; $this->holiday_name[21] = ACSMsg::get_mdmsg(__FILE__, 'M018'); } break; case 9: // 敬老の日 if ($year < 2003) { $this->holiday[15] = 1; $this->holiday_name[15] = ACSMsg::get_mdmsg(__FILE__, 'M020'); } else { $this->holiday[$day + 14] = 1; $this->holiday_name[$day + 14] = ACSMsg::get_mdmsg(__FILE__, 'M020'); } // 秋分の日 if ($year > 1979 && $year < 2100) { $tmp = floor(23.2488 + ($year - 1980) * 0.242194 - floor(($year - 1980) / 4)); $this->holiday[$tmp] = 1; $this->holiday_name[$tmp] = ACSMsg::get_mdmsg(__FILE__, 'M022'); } break; case 10: // 体育の日 if ($year < 2000) { $this->holiday[10] = 1; $this->holiday_name[10] = ACSMsg::get_mdmsg(__FILE__, 'M023'); } else { $this->holiday[$day + 7] = 1; $this->holiday_name[$day + 7] = ACSMsg::get_mdmsg(__FILE__, 'M023'); } break; case 11: // 文化の日 $this->holiday[3] = 1; $this->holiday_name[3] = ACSMsg::get_mdmsg(__FILE__, 'M025'); // 勤労感謝の日 $this->holiday[23] = 1; $this->holiday_name[23] = ACSMsg::get_mdmsg(__FILE__, 'M026'); break; case 12: // 天皇誕生日 if ($year > 1988) { $this->holiday[23] = 1; $this->holiday_name[23] = ACSMsg::get_mdmsg(__FILE__, 'M014'); } break; } // 国民の休日をセット if ($year > 1985) { for ($i = 1; $i < ACSLib::get_end_day($year, $month); $i++) { if (isset($this->holiday[$i]) && isset($this->holiday[$i + 2])) { $this->holiday[$i + 1] = 1; $this->holiday_name[$i + 1] = ACSMsg::get_mdmsg(__FILE__, 'M028'); $i = $i + 3; } } } // 振り替え休日をセット $sday = $day - 1; if ($sday == 0) { $sday = 7; } for ($i = $sday; $i < ACSLib::get_end_day($year, $month); $i = $i + 7) { if (isset($this->holiday[$i])) { $this->holiday[$i + 1] = 1; $this->holiday_name[$i + 1] = ACSMsg::get_mdmsg(__FILE__, 'M029'); } } }