Файл: adultscript-2.0.3-pro/files/mobile/components/news.php
Строк: 94
<?php
class VComponent_mobile_news extends VMobile
{
public function __construct()
{
parent::__construct();
}
public function render()
{
if (!VModule::enabled('news')) {
$this->notfound();
}
$segment = VUri::request(1);
if ($segment == '' OR is_numeric($segment)) {
$component = 'browse';
} else {
$component = 'view';
}
$component_class = 'VComponent_mobile_news_'.$component;
try {
require BASE_DIR.'/mobile/components/news_'.$component.'.php';
$obj = new $component_class();
$obj->render();
} catch (Exception $e) {
throw new VException($e);
}
}
protected function get_archive()
{
$dates = array();
$this->db->query("SELECT add_date
FROM #__news
WHERE status = '1'
ORDER BY add_date ASC
LIMIT 1");
if ($this->db->affected_rows()) {
$data = $this->db->fetch_assoc();
$expl = explode(' ', $data['add_date']);
$expl = explode('-', $expl['0']);
$start_year = $expl['0'];
$start_month = $expl['1'];
} else {
return $dates;
}
$this->db->query("SELECT DATE_FORMAT(add_date, '%Y-%m') AS end_date
FROM #__news
WHERE status = '1'
ORDER BY add_date DESC
LIMIT 1");
if ($this->db->affected_rows()) {
$data = $this->db->fetch_assoc();
$expl = explode('-', $data['end_date']);
$end_year = $expl['0'];
$end_month = $expl['1'];
} else {
return $dates;
}
if ($start_year == $end_year) {
for ($month=$start_month; $month<=$end_month; $month++) {
$time = mktime(0, 0, 0, $month, 1, $start_year);
$dates[$time] = $start_year.'/'.sprintf('%02d', (int) $month);
}
} else {
for ($year=$start_year; $year<=$end_year; $year++) {
if ($year == $start_year) {
for ($month=$start_month; $month<=12; $month++) {
$time = mktime(0, 0, 0, $month, 1, $year);
$dates[$time] = $start_year.'/'.sprintf('%02d', (int) $month);
}
} elseif ($year == $end_year) {
for ($month=1; $month<=$end_month; $month++) {
$time = mktime(0, 0, 0, $month, 1, $year);
$dates[$time] = $start_year.'/'.sprintf('%02d', (int) $month);
}
} else {
for ($month=1; $month<=12; $month++) {
$time = mktime(0, 0, 0, $month, 1, $year);
$dates[$time] = $start_year.'/'.sprintf('%02d', (int) $month);
}
}
}
}
return $dates;
}
}