year;
$month = $this->month;
if (($year < 2014) && ($year > date("Y"))) {
$year = date("Y");
}
if (($this->month < 1) && ($this->month > 12)) {
$month = date("n");
} else if (mktime(0, 0, 0, $month, 1, $year) > $time) {
$month = date("n");
}
$this->year = array();
$this->month = array();
for ($i = 2014; $i <= date("Y"); $i++) {
if ($i == $year) {
$this->year_list[] = $i . "年";
} else {
$this->year_list[] = '' . $i . '年';
}
}
for ($i = 1; $i <= 12; $i++) {
if (mktime(0, 0, 0, $i, 1, $year) > $time) {
break;
}
$_check = $this->_get_gallery($year, $i);
if (count($_check) > 0) {
if ($i == $month) {
$this->month_list[] = $i . "月";
} else {
$this->month_list[] = '' . $i . '月';
}
}
}
$this->gallery = $this->_get_gallery($year, $month);
$this->year = $year;
$this->month = $month;
return $this->render('s/gallery/option');
}
// ---------------------------------------------
// ギャラリー取得
// ---------------------------------------------
function _get_gallery($year, $month) {
$start = date('Y-m-d', mktime(0, 0, 0, $month, 1, $year));
$end = date('Y-m-d', mktime(0, 0, 0, $month + 1, 1, $year));
$param = array($start, $end);
$sql = "SELECT * FROM main_gallery WHERE ";
$sql .= "switch IS TRUE AND publish_date >= ? AND publish_date < ? AND publish_date <= NOW() AND type = 1 ORDER BY publish_date DESC;";
$gallery = $this->db->getAll($sql, $param);
foreach ($gallery as $key => $val) {
$gallery[$key]['message'] = 0;
if (file_exists(MAIN_GALLERY_IMAGE_FULL_PATH . 'message_' . $val['photo'])) {
$gallery[$key]['message'] = 1;
}
}
return $gallery;
}
/*----------------------------------------------------------
設定フィルター
----------------------------------------------------------*/
function defaultSetBeforeFilter () {
parent::defaultSetBeforeFilter();
if (empty($this->year)) {
$this->year = date("Y");
}
if (empty($this->month)) {
$this->month = date("n");
}
}
}
$controller = new GalleryController();
$controller->process();
exit;