year; $month = $this->month; $last = $this->_get_last_slideshow(date("Y"), date("n")); 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) { if ($last > 0) { $month = date("n"); } else { $month = date("n", mktime(0, 0, 0, date("n") - 1, 1, date("Y"))); } } if (mktime(0, 0, 0, 5, 1, 2014) > mktime(0, 0, 0, $month, 1, $year)) { $year = date("Y"); if ($last > 0) { $month = date("n"); } else { $month = date("n", mktime(0, 0, 0, date("n") - 1, 1, date("Y"))); } } $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 ($last > 0) { if (mktime(0, 0, 0, $i, 1, $year) > $time) { break; } } else { if (mktime(0, 0, 0, $i + 1, 1, $year) > $time) { break; } } if (($year == 2014) && ($i < 5)) { } else { if ($i == $month) { $this->month_list[] = $i . "月"; } else { $this->month_list[] = '' . $i . '月'; } } } $this->slideshow = $this->_get_slideshow($year, $month); if (count($this->slideshow) == 0) { } $this->year = $year; $this->month = $month; return $this->render('s/slideshow/index'); } /*---------------------------------------------------------- スライドショー単ページ ----------------------------------------------------------*/ function executeDetail() { $slideshow = $this->_getSlideshowDetail($this->id); if (!isset($slideshow['seq'])) { return $this->render('s/slideshow/index'); exit; } $this->slideshow = $slideshow; return $this->render('s/slideshow/detail'); } // --------------------------------------------- // スライドショー取得 // --------------------------------------------- function _get_slideshow($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 slideshow WHERE "; $sql .= "switch IS TRUE AND publish_date >= ? AND publish_date < ? AND publish_date <= NOW() ORDER BY publish_date DESC, sort ASC;"; $slideshow = $this->db->getAll($sql, $param); return $slideshow; } // --------------------------------------------- // スライドショー最新月件数取得 // --------------------------------------------- function _get_last_slideshow($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 COUNT(*) FROM slideshow WHERE "; $sql .= "switch IS TRUE AND publish_date >= ? AND publish_date < ? AND publish_date <= NOW();"; $slideshow = $this->db->getRow($sql, $param); return $slideshow['count']; } // --------------------------------------------- // スライドショー取得 // --------------------------------------------- function _getSlideshowDetail($seq) { $sql = "SELECT * FROM slideshow WHERE switch IS TRUE AND publish_date <= NOW() AND seq = ?"; $slideshow = $this->db->getRow($sql, array($seq)); return $slideshow; } // --------------------------------------------- // お知らせ取得 // --------------------------------------------- function _getAllSlideshow ( ) { $sql = "SELECT to_char(publish_date,'YYYY') AS publish_date_year FROM slideshow WHERE switch IS TRUE AND publish_date <= NOW() ORDER BY publish_date DESC, sort ASC "; $slideshow = $this->db->getAll($sql, array()); return $slideshow; } /*---------------------------------------------------------- 設定フィルター ----------------------------------------------------------*/ 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;