$val) { $parts[$key] = (int)$val; } list($this->sel_year, $this->sel_mounth, $this->sel_day) = $parts; $sel_ts = mktime(0,0,0,$this->sel_mounth, 1 , $this->sel_year); $this->week_day = date('w', $sel_ts); $this->no_days = date('t', $sel_ts); if(is_callable($callback)) { $this->check_date_callback = $callback; } else { die('Functia de validare a datei nu exista!'); } } function build() { $prev_year=$this->sel_year-1; $prev_mounth=$this->sel_mounth-1; $next_year=$this->sel_year+1; $next_mounth=$this->sel_mounth+1; $ts = mktime(0,0,0,$this->sel_mounth, $this->sel_day, $this->sel_year); $prev_year_exists = call_user_func($this->year_callback, $this->sel_year-1); $prev_month_exists = call_user_func($this->month_callback, $this->sel_year-($this->sel_mounth-1 == 0 ? 1:0), $this->sel_mounth-1 == 0 ? 12:$this->sel_mounth-1); $next_year_exists = call_user_func($this->year_callback, $this->sel_year+1); $next_month_exists = call_user_func($this->month_callback, $this->sel_year+($this->sel_mounth+1 > 12 ? 1:0), $this->sel_mounth+1 > 12 ? 1:$this->sel_mounth+1); $all_years = call_user_func($this->all_years_callback); $this->cal_str .= ''."\n"; // prev year // $this->cal_str .= $prev_year_exists ? ''."\n" : ''; // prev mounth // $this->cal_str .= $prev_month_exists ?''."\n" : ''; // title // $this->cal_str .= ''."\n" : ''; // next year // $this->cal_str .= $next_year_exists ? ''."\n":''; $this->cal_str .= ''."\n"; $this->cal_str .= ''; // zilele din sapt // for($i = 1; $i <= 7; $i++) { $this->cal_str .=''."\n"; } $this->cal_str .= ''; $e = $this->week_day == 0 ? $this->week_day=7 : $this->week_day; // ziua zero este ziua 7 - conversie din cal us in ro for($j=1; $j < $e; $j++) { $this->cal_str .=''."\n"; } for($i=1; $i <= $this->no_days; $i++) { $date_exists = call_user_func($this->check_date_callback, $this->sel_year.'-'.str_pad($this->sel_mounth,2,0,STR_PAD_LEFT).'-'.str_pad($i,2,0,STR_PAD_LEFT)); $this->cal_str .= '"."\n"; if($j == 7) { $this->cal_str .= ''; $j=0; } $j++; } while($j <= 7 && $j > 1) { $this->cal_str .=''."\n"; $j++; } $this->cal_str .="
««' . "\n"; $this->cal_str .= '
' . "\n"; $this->cal_str .= ''. "\n"; $this->cal_str .= ''. "\n"; $this->cal_str .= ''. "\n"; $this->cal_str .= '
'. "\n"; // next mounth // $this->cal_str .= $next_month_exists ? '
»»
' . $this->str_days[$i] . '
 '."\n"; if($i==$this->sel_day) { $this->cal_str .= $i; } else { if($date_exists) { // // Aceasta data este disponibila in calendar // $this->cal_str .= ''.$i.''; } else { // // Aceasta data nu este in calendar, deci nu pun href // $this->cal_str .= $i; } } $this->cal_str .-"
 
"."\n"; } function get_calendar() { return $this->cal_str; } } // // cache-ul pt luni // $available_days=array(); // // Callback-ul pentru validarea datei X // nota: selectul se face o singura data - 1 query per luna, nu la fiecare data verificata!!! // function check_date($data) { global $sql, $available_days; if (empty($available_days)) { $available_days = array(); } $sql->SetFetchType(FETCH_ASSOC); if(empty($available_days)) { if(preg_match('@^([0-9]{4})-([0-9]{2})-[0-9]{2}$@', $data, $match)){ $year = $match[1]; $mounth = $match[2]; $ts_start = mktime(0,0,0,$mounth,0,$year); $ts_end = mktime(0,0,0,$mounth+1,0,$year); $query="SELECT DISTINCT(FROM_UNIXTIME(added_ts, '%Y-%m-%d')) as data FROM `tidings` WHERE (added_ts between $ts_start AND $ts_end) AND added_ts < unix_timestamp()"; // $query="SELECT DISTINCT(FROM_UNIXTIME(added_ts, '%Y-%m-%d')) as data FROM `tidings` WHERE added_ts < unix_timestamp()"; if($sql->Query($query)) { for($i=0; $i<$sql->rows; $i++) { $sql->GetRow($i); $available_days[]=$sql->data['data']; } } } } $sql->SetFetchType(FETCH_OBJ); if(in_array($data, $available_days)) { return true; } return false; } function year_exists($year) { global $sql; $ts_start = mktime(0,0,0,0,0,$year); $ts_end = mktime(0,0,0,0,0,$year+1); $query="SELECT count(1) FROM tidings WHERE added_ts between $ts_start AND $ts_end"; return $sql->QueryItem($query) > 0 ? true:false; } function month_exists($year, $month) { global $sql; $ts_start = mktime(0,0,0,$month,0,$year); $ts_end = mktime(0,0,0,$month+1,0,$year); $query="SELECT count(1) FROM tidings WHERE added_ts between $ts_start AND $ts_end"; return $sql->QueryItem($query) > 0 ? true:false; } function all_years(){ global $sql; $years = array(); $query="SELECT DISTINCT(FROM_UNIXTIME(added_ts, '%Y')) as year FROM tidings WHERE added_ts > 0"; if ($sql->Query($query)) { for ($i=0; $i < $sql->rows; $i++) { $sql->GetRow($i); $years[] = $sql->data->year; } } return $years; } /* $data = isset($_GET['data']) ? $_GET['data'] : date('Y-m-d'); $calendar = new calendar($_SERVER['SCRIPT_URI'].'?'.$_SERVER['QUERY_STRING'], $data, 'check_date'); $calendar->build(); echo $calendar->get_calendar(); */ ?>
Fatal error: Class 'Calendar' not found in /d2/www/presaonline.com/controllers/tidings.php on line 847