|
|
|
ถามผู้รู้เรื่องของ event calendar ครับ ผมได้ไปหา code ของปฎิทินนัดหมายมาครับ ส่วนตัวผมว่ามันดีมากๆครับตอนทดลองดูมันก็ใช้ได้ดีมากครับ |
|
|
|
|
|
|
|
ผมได้ไปหา code ของปฎิทินนัดหมายมาครับ ส่วนตัวผมว่ามันดีมากๆครับตอนทดลองดูมันก็ใช้ได้ดีมากครับ ดังรูป
code ของตัวนี้ก็มี
test.php เป็นส่วนเรียกใช้งานครับ
Code (PHP)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=TIS-620">
<title>Dangcarry</title>
<style>
#calendar {
text-align:center;
font:normal 11px MS Sans Serif;
position:relative;
width:180px;
}
#calendar .calendarDetail {
border:1px solid #aaa;
margin:0 0 1em 0;
padding:0 0 0.3em 0;
width:100%;
color:#000;
background-color:#fff;
}
#calendar .calendarDetail .title td, #calendar .calendarDetail .title a {
font-weight:bold;
font-size:1.1em;
color:#fff;
background-color:#aaa;
padding:0.1em;
text-decoration:none;
}
#calendar .calendarDetail .title1 td {
border-bottom:1px dashed #ddd;
padding:0.2em;
}
#calendar .calendarDetail .week td, #calendar .calendarDetail .week a {
padding:0.2em;
text-decoration:none;
color:#000;
background-color:inherit;
}
#calendar .calendarDetail .week a:hover {
color:#000;
background-color:#eee;
}
#calendar .calendarDetail .lastMonth a, #calendar .calendarDetail .nextMonth a {
color:#aaa;
background-color:#eee;
}
#calendar .calendarDetail .weekend a {
color:#f00;
background-color:inherit;
}
#calendar .calendarDetail .event a {
font-weight:bold;
color:#87CEEB;
background-color:inherit;
text-decoration:underline;
}
#calendar .calendarDetail .today a {
color:#fff;
background-color:#808080;
font-weight:bold;
}
#calendar .calendarDetail .calendarEvent {
display:none;
margin:0;
padding:0.3em;
position:absolute;
width:180px;
color:#000;
background-color:#fff;
text-align:left;
border:1px solid #aaa;
font-weight:normal;
}
#calendar .calendarDetail .calendarEvent .date {
font-style:MS Sans Serif;
font-weight:bold;
color:#6699FF;
}
#calendar .calendarDetail .calendarEvent .edit {
float:right;
}
#calendar .calendarDetail .calendarEvent a {
font-weight:normal;
color:#000;
background-color:#fff;
}
#calendar .calendarDetail .calendarEvent li {
margin:0 0 1em 0;
list-style:disc inside none;
}
#calendar .calendarDetail td:hover > .calendarEvent {
display:block;
}
#calendarForm {
font:normal 11px MS Sans Serif;
background-color:#494949;
color:#fff;
}
#calendarForm .title {
text-align:center;
color:#eee;
background-color:#808080;
padding:0.3em;
margin:0 0 1em 0;
font-weight:bold;
}
#calendarForm .credit {
text-align:right;
margin:0;
padding:0 1em 0.5em 0;
color:#C0C0C0;
background-color:inherit;
}
#calendarForm .credit a {
color:#C0C0C0;
background-color:inherit;
text-decoration:underline;
}
#calendarForm .credit a:hover {
text-decoration:none;
}
#calendarForm form {
margin:0;
padding:0 0.5em;
color:#eee;
background-color:inherit;
}
#calendarForm form br {
clear:both;
}
#calendarForm input, #calendarForm select, #calendarForm textarea {
font:normal 11px MS Sans Serif;
margin:0 0 0.5em 0;
}
</style>
</head>
<body topmargin="0" leftmargin="0" bgcolor="#FFFFCC">
<center>
<?php
// ใส่ URL ของไฟล์ calendar.php
include('calendar.php');
$calendar = new WingedCalendar();
// บรรทัดด้านล่าง เลข 0 ทางซ้ายคือ จำนวนเดือนก่อนเดือนปัจจุบันที่จะให้แสดงออกมา
// บรรทัดด้านล่าง เลข 0 ทางขวาคือ จำนวนเดือนถัดจากเดือนปัจจุบันที่จะให้แสดงออกมา
// กรณีจะให้แสดงแค่เดือนปัจจุบัน ใส่ 0 ทั้งด้านซ้ายและขวา
$calendar->show_calendar(0,0);
?>
</center>
</body>
</html>
แต่พอผมลองเอาเรียกเป็น include "test.php" มาในหน้าเว็บที่ผมต้องการให้โชว์มันก็เป็นแบบนี้ครับ หรือแม้กระทั่งเอาส่วนของที่เป็น script ที่เป็น css ไปไว้บน header ของหัวเว็บของผมแล้วก็เอา
Code (PHP)
<?php
// ใส่ URL ของไฟล์ calendar.php
include('calendar.php');
$calendar = new WingedCalendar();
// บรรทัดด้านล่าง เลข 0 ทางซ้ายคือ จำนวนเดือนก่อนเดือนปัจจุบันที่จะให้แสดงออกมา
// บรรทัดด้านล่าง เลข 0 ทางขวาคือ จำนวนเดือนถัดจากเดือนปัจจุบันที่จะให้แสดงออกมา
// กรณีจะให้แสดงแค่เดือนปัจจุบัน ใส่ 0 ทั้งด้านซ้ายและขวา
$calendar->show_calendar(0,0);
?>
ไปใส่แทน include ก็ไม่มีอะไรเปลี่ยนแปลงครับ งงเหมือนกัน
ขนาดก็เปลี่ยนไป popup ที่โชว์ว่าวันนี้มีนัดหมายอะไรก็ไม่ขึ้น
ในส่วนของไฟล์ที่มีส่วนเกี่ยวข้องกับ code นี้ก็มี
calendar.php
Code (PHP)
<?
$cal_cfg = array();
$cal_cfg['path'] = str_replace('\\', '/', dirname(__FILE__));
include($cal_cfg['path'] . '/config.php');
class WingedCalendar {
var $templates;
var $months;
var $sunday_endweek;
var $datapath;
var $htpath;
var $password;
var $timezone;
function WingedCalendar() {
global $cal_cfg;
$this->templates = $cal_cfg['template'];
$this->password = $cal_cfg['password'];
$this->sunday_endweek = $cal_cfg['sunday_endweek'];
$this->months = $cal_cfg['month'];
$this->timezone = $cal_cfg['timezone'];
$this->datapath = $cal_cfg['path'] . '/data.txt';
$this->htpath = str_replace($cal_cfg['document_root'], '', $cal_cfg['path']);
}
function getDate($time=0) {
return $time==0? getdate(time() + $this->timezone*3600-intval(date('Z'))) : getdate($time + $this->timezone*3600-intval(date('Z')));
}
function getNumberOfDays($month, $year) {
$numday = 31;
if ($month==4 || $month==6 || $month==9 || $month==11) {
$numday = 30;
} else if ($month==2) {
$numday = $year%4!=0 || ($year%100==0 && $year%400!=0)? $numday = 28 : 29;
}
return $numday;
}
function getMonthDetails($month, $year) {
$details = array();
$details['mon'] = $month;
$details['year'] = $year;
$details['days'] = $this->getNumberOfDays($month, $year);
$details['month'] = $this->months[$month-1];
$tmp = $this->getDate(gmmktime(0, 0, 0, $month, 1, $year));
$details['first'] = $tmp['wday'];
$details['last']['mon'] = $month-1;
$details['last']['year'] = $year;
$details['next']['mon'] = $month+1;
$details['next']['year'] = $year;
if ($month==1) {
$details['last']['mon'] = 12;
$details['last']['year']--;
} else if ($month==12) {
$details['next']['mon'] = 1;
$details['next']['year']++;
}
$details['last']['days'] = $this->getNumberOfDays($details['last']['mon'], $details['last']['year']);
return $details;
}
function getEvent($id) {
$events = array();
$lines = file($this->datapath);
for ($i=0, $n=count($lines); $i<$n; $i++) {
if (trim($lines[$i])=='<event>') {
if (trim($lines[++$i])==$id) {
$events['id'] = $id;
list($events['day'], $events['month'], $events['year']) = explode('-', trim($lines[$i+1]));
list($events['hr'], $events['min']) = explode(':', trim($lines[$i+2]));
$events['message'] = '';
for ($i+=3;; $i++) {
if (trim($lines[$i])=='</event>') break;
$events['message'] .= $lines[$i];
}
$events['message'] = htmlspecialchars(stripslashes($events['message']), ENT_QUOTES);
break;
}
}
}
return $events;
}
function getMonthEvents($month, $year) {
$events = array();
$lines = file($this->datapath);
$k = 0;
$sorts = array();
for ($i=0, $n=count($lines); $i<$n; $i++) {
if (trim($lines[$i])=='<event>') {
list($d, $m, $y) = explode('-', trim($lines[$i+2]));
if (($m==$month || $m==0) && ($y==$year || $y==0)) {
$sorts[$k] = trim($lines[$i+3]);
list($h, $min) = explode(':', $sorts[$k]);
$events[$k]['id'] = trim($lines[$i+1]);
$events[$k]['day'] = $d;
$events[$k]['month'] = $m;
$events[$k]['year'] = $y;
$events[$k]['hr'] = $h;
$events[$k]['min'] = $min;
$events[$k]['message'] = '';
for ($i+=4;; $i++) {
if (trim($lines[$i])=='</event>') break;
$events[$k]['message'] .= $lines[$i];
}
$events[$k]['message'] = htmlspecialchars(stripslashes($events[$k]['message']), ENT_QUOTES);
$k++;
}
}
}
array_multisort($sorts, SORT_ASC, SORT_NUMERIC, $events);
return $events;
}
function displayMonth($dates) {
$keys['LAST_MON'] = $dates['last']['mon'];
$keys['LAST_YEAR'] = $dates['last']['year'];
$keys['NEXT_MON'] = $dates['next']['mon'];
$keys['NEXT_YEAR'] = $dates['next']['year'];
$keys['MONTH'] = $dates['month'];
$keys['YEAR'] = $dates['year'];
$keys['MON'] = $dates['mon'];
$events = $this->getMonthEvents($dates['mon'], $dates['year']);
$dayevents = array();
for ($count=0, $i=0, $n=count($events); $i<$n; $i++, $count++) {
$d = $events[$i]['day'];
$dayevents[$d][] = array (
'id' => $events[$i]['id'],
'message' => nl2br($events[$i]['message']),
'hr' => $events[$i]['hr']<10? $events[$i]['hr'] = '0' . $events[$i]['hr'] : $events[$i]['hr'],
'min' => $events[$i]['min']<10? $events[$i]['min'] = '0' . $events[$i]['min'] : $events[$i]['min']
);
}
$days = array();
$filled = 0;
$count = 0;
for ($i=$dates['last']['days']-$dates['first']+1; $filled<$dates['first']; $i++, $filled++) {
$days[$count]['DAY_' . $filled] = $i;
$days[$count]['WHICH_' . $filled] = 'lastMonth';
$days[$count]['EVENT_' . $filled] = '';
$days[$count]['ID_' . $filled] = 'c' . $i . '-' . $dates['last']['mon'] . '-' . $dates['last']['year'];
}
$todays = $this->getDate();
for ($i=1; $i<=$dates['days']; $i++, $filled++) {
if ($filled==7) {
$count++;
$filled = 0;
}
$days[$count]['DAY_' . $filled] = $i;
$days[$count]['WHICH_' . $filled] = '';
$days[$count]['EVENT_' . $filled] = '';
$days[$count]['ID_' . $filled] = 'd' . $i . '-' . $dates['mon'] . '-' . $dates['year'];
if ($filled==0 || $filled==6) {
$days[$count]['WHICH_' . $filled] .= ' weekend ';
}
if ($todays['mon']==$dates['mon'] && $todays['mday']==$i && $todays['year']==$dates['year']) {
$days[$count]['WHICH_' . $filled] .= ' today ';
}
if (array_key_exists($i, $dayevents)) {
$ids['DAY'] = $days[$count]['DAY_' . $filled];
$ids['MONTH'] = $dates['mon'];
$ids['YEAR'] = $dates['year'];
$days[$count]['WHICH_' . $filled] .= ' event ';
$days[$count]['EVENT_' . $filled] = $this->parseRecTemplate($this->parseTemplate($this->templates['event'], $ids), '<!-- BEGIN -->', '<!-- END -->', $dayevents[$i]);
}
}
for ($i=1; $filled<7; $i++, $filled++) {
$days[$count]['DAY_' . $filled] = $i;
$days[$count]['WHICH_' . $filled] = 'nextMonth';
$days[$count]['EVENT_' . $filled] = '';
$days[$count]['ID_' . $filled] = 'c' . $i . '-' . $dates['next']['mon'] . '-' . $dates['next']['year'];
}
if ($this->sunday_endweek) $this->swap($days);
return $this->parseRecTemplate($this->parseTemplate($this->templates['body'], $keys), '<!-- BEGIN -->', '<!-- END -->', $days);
}
function swap(&$days) {
$n = count($days)-1;
for ($i=0; $i<$n; $i++) {
$days[$i]['WHICH_0'] = $days[$i+1]['WHICH_0'];
$days[$i]['DAY_0'] = $days[$i+1]['DAY_0'];
$days[$i]['EVENT_0'] = $days[$i+1]['EVENT_0'];
}
$days[$n]['WHICH_0'] = 'nextMonth';
$days[$n]['DAY_0'] = $days[$n]['DAY_6']+1;
$days[$n]['EVENT_0'] = '';
}
function getForm($do, $id, $day, $month, $year, $hr, $minute, $message, $add, $edit) {
$max = $min = 5;
$keys['DAY'] = '';
$keys['MONTH'] = '';
$keys['YEAR'] = '';
$keys['HOUR'] = '';
$keys['MINUTE'] = '';
$keys['ID'] = $id;
$keys['DO'] = $do;
$keys['MESSAGE'] = $message;
$keys['ADD'] = $add;
$keys['EDIT'] = $edit;
for ($i=1; $i<=31; $i++) {
if ($i==$day) {
$keys['DAY'] .= '<option value="' . $i . '" selected >' . $i . '</option>';
} else {
$keys['DAY'] .= '<option value="' . $i . '">' . $i . '</option>';
}
}
for ($i=1; $i<=12; $i++) {
if ($i==$month) {
$keys['MONTH'] .= '<option value="' . $i . '" selected >' . $this->months[$i-1] . '</option>';
} else {
$keys['MONTH'] .= '<option value="' . $i . '">' . $this->months[$i-1] . '</option>';
}
}
$tmp = $this->getDate();
$year0 = $year>0? $year : $tmp['year'];
for ($i=$year0-$min, $n=$year0+$max; $i<=$n; $i++) {
if ($i==$year) {
$keys['YEAR'] .= '<option value="' . $i . '" selected >' . $i . '</option>';
} else {
$keys['YEAR'] .= '<option value="' . $i . '">' . $i . '</option>';
}
}
for ($i=0; $i<=23; $i++) {
$j = $i<10? '0' . $i : $i;
if ($i==$hr) {
$keys['HOUR'] .= '<option value="' . $i . '" selected >' . $j . '</option>';
} else {
$keys['HOUR'] .= '<option value="' . $i . '">' . $j . '</option>';
}
}
for ($i=0; $i<=59; $i++) {
$j = $i<10? '0' . $i : $i;
if ($i==$minute) {
$keys['MINUTE'] .= '<option value="' . $i . '" selected >' . $j . '</option>';
} else {
$keys['MINUTE'] .= '<option value="' . $i . '">' . $j . '</option>';
}
}
return $this->parseTemplate($this->templates['form'], $keys);
}
function addEvent($day, $month, $year, $hr, $min, $message, $input_id=null) {
$id = $input_id==null? time() : $input_id;
$handle = fopen($this->datapath, 'a') or exit('error1');
if (get_magic_quotes_gpc()==0) {
$message = addslashes($message);
}
$content = "\n<event>\n" . $id . "\n" . $day . '-' . $month . '-' . $year . "\n" . $hr . ':' . $min . "\n" . $message . "\n</event>";
if (fwrite($handle, $content)===false) {
fclose($handle);
exit('error2');
}
fclose($handle);
}
function delEvent($id) {
$content = '';
$lines = file($this->datapath);
for ($i=0, $n=count($lines); $i<$n; $i++) {
if (trim($lines[$i])=='<event>') {
if (trim($lines[$i+1])==$id) {
for ($i++;; $i++) {
if (trim($lines[$i])=='</event>') break;
}
} else {
for (;; $i++) {
$content .= $lines[$i];
if (trim($lines[$i])=='</event>') break;
}
}
}
}
$handle = fopen($this->datapath, 'w') or exit('error1');
if (fwrite($handle, $content)===false) {
fclose($handle);
exit('error2');
}
fclose($handle);
}
function show_calendar($last=0, $next=0) {
print '<div id="calendar">';
$today = $this->getDate();
for ($i=$last; $i>0; $i--) {
$month = $today['mon']-$i;
$year = $today['year'];
if ($month<0) {
$month = 12+$month;
$year--;
}
if (checkdate($month, 1, $year)) {
$this->show_month($month, $year);
}
}
for ($i=0; $i<=$next; $i++) {
$month = $today['mon']+$i;
$year = $today['year'];
if ($month>12) {
$month = $month-12;
$year++;
}
if (checkdate($month, 1, $year)) {
$this->show_month($month, $year);
}
}
print '</div>';
print $this->parseTemplate($this->templates['js'], array('HTPATH'=>$this->htpath));
}
function show_month($month, $year) {
$dates = $this->getMonthDetails($month, $year);
print $this->displayMonth($dates);
}
function checkDocumentRoot() {
return dirname($_SERVER['PHP_SELF'])==$this->htpath;
}
function parseTemplate($tpl, $keys) {
$content = '';
$vars = array_keys($keys);
for ($i=0, $n=count($vars); $i<$n; $i++) {
$vars[$i] = '{' . strtoupper($vars[$i]) . '}';
}
$content = str_replace($vars, $keys, $tpl);
return $content;
}
function parseRecTemplate($tpl, $begin, $end, $keys) {
$content = '';
$begin_pos = strpos($tpl, $begin) + strlen($begin);
$end_pos = strpos($tpl, $end);
$length = $end_pos - $begin_pos;
$subtpl = substr($tpl, $begin_pos, $length);
$num_key = count($keys);
$vars = $num_key>0? array_keys($keys[0]) : null;
for ($i=0, $n=count($vars); $i<$n; $i++) {
$vars[$i] = '{' . strtoupper($vars[$i]) . '}';
}
for ($i=0; $i<$num_key; $i++) {
$content .= str_replace($vars, $keys[$i], $subtpl);
}
return substr_replace($tpl, $content, $begin_pos, $length);
}
}
?>
calendar_handle.php
Code (PHP)
<?
include('calendar.php');
class CalendarHandler extends WingedCalendar {
function isAuthorised() {
return (isset($_POST['pass']) && $_POST['pass']==$this->password);
}
function printAddForm($day, $month, $year) {
print $this->getForm('add', '', $day, $month, $year, 0, 0, '', 'submit', 'hidden');
}
function printEditForm($id) {
$events = $this->getEvent($id);
if (!empty($events)) {
print $this->getForm('edit', $id, $events['day'], $events['month'], $events['year'], $events['hr'], $events['min'], $events['message'], 'hidden', 'submit');
}
}
function checkInput($day, $month, $year, $hr, $min, $message) {
return (
(checkdate($month, $day, $year) ||
($month==0 && checkdate(2, $day, $year)) ||
($year==0 && checkdate($month, $day, 2005)) ||
($year==0 && $month==0 && checkdate(2, $day, 2005))) &&
strpos($message, '</event>')===false && strpos($message, '<event>')===false &&
!empty($message) &&
$hr>=0 && $hr<24 && $min>=0 && $min<60
);
}
function printOut($action) {
global $cal_cfg;
if ($action=='access') {
print $this->parseTemplate($cal_cfg['popup']['js']['alert'], array('alert'=>$cal_cfg['popup']['notices']['access']));
} else if ($action=='invalid') {
print $this->parseTemplate($cal_cfg['popup']['js']['alert'], array('alert'=>$cal_cfg['popup']['notices']['invalid']));
} else if ($action=='add') {
print $this->parseTemplate($cal_cfg['popup']['js']['confirm'], array('confirm'=>$cal_cfg['popup']['notices']['add']));
} else if ($action=='edit') {
print $this->parseTemplate($cal_cfg['popup']['js']['confirm'], array('confirm'=>$cal_cfg['popup']['notices']['edit']));
} else if ($action=='del') {
print $this->parseTemplate($cal_cfg['popup']['js']['confirm'], array('confirm'=>$cal_cfg['popup']['notices']['del']));
} else if ($action=='header') {
print $cal_cfg['popup']['header'];
} else if ($action=='footer') {
print $cal_cfg['popup']['footer'];
} else if ($action=='form_script') {
print $cal_cfg['popup']['js']['form_script'];
}
}
}
$cal = new CalendarHandler();
if (isset($_GET['date'])) {
list($month, $year) = explode('-', $_GET['date']);
if (checkdate(intval($month), 1, intval($year))) {
$cal->show_month($month, $year);
}
} else if (isset($_GET['add'])) {
list($day, $month, $year) = explode('-', $_GET['add']);
if (checkdate(intval($month), intval($day), intval($year))) {
$cal->printOut('header');
$cal->printAddForm($day, $month, $year);
$cal->printOut('form_script');
$cal->printOut('footer');
}
} else if (isset($_GET['edit'])) {
$cal->printOut('header');
$cal->printEditForm($_GET['edit']);
$cal->printOut('form_script');
$cal->printOut('footer');
} else if (isset($_POST['do'])) {
$cal->printOut('header');
if ($_POST['do']=='add') {
if (!(isset($_POST['day']) && isset($_POST['month']) && isset($_POST['year']) && isset($_POST['hr']) && isset($_POST['min']) && isset($_POST['message']))) {
exit('error3');
}
if ($cal->isAuthorised()) {
$post_day = intval($_POST['day']);
$post_month = intval($_POST['month']);
$post_year = intval($_POST['year']);
$post_hr = intval($_POST['hr']);
$post_min = intval($_POST['min']);
$post_message = trim($_POST['message']);
if ($cal->checkInput($post_day, $post_month, $post_year, $post_hr, $post_min, $post_message)) {
$cal->addEvent($post_day, $post_month, $post_year, $post_hr, $post_min, $post_message);
$cal->printOut('add');
} else {
$cal->printOut('invalid');
}
} else {
$cal->printOut('access');
}
} else if ($_POST['do']=='edit') {
if (!(isset($_POST['day']) && isset($_POST['month']) && isset($_POST['year']) && isset($_POST['hr']) && isset($_POST['min']) && isset($_POST['message']) && isset($_POST['id']))) {
exit('error3');
}
if ($cal->isAuthorised()) {
if (isset($_POST['edit'])) {
$post_day = intval($_POST['day']);
$post_month = intval($_POST['month']);
$post_year = intval($_POST['year']);
$post_hr = intval($_POST['hr']);
$post_min = intval($_POST['min']);
$post_message = trim($_POST['message']);
if ($cal->checkInput($post_day, $post_month, $post_year, $post_hr, $post_min, $post_message)) {
$cal->delEvent($_POST['id']);
$cal->addEvent($post_day, $post_month, $post_year, $post_hr, $post_min, $post_message, $_POST['id']);
$cal->printOut('edit');
} else {
$cal->printOut('invalid');
}
} else if (isset($_POST['del'])) {
$cal->delEvent($_POST['id']);
$cal->printOut('del');
}
} else {
$cal->printOut('access');
}
}
$cal->printOut('footer');
}
?>
แล้วก็ config.php
Code (PHP)
<?
/*--------------------------
general information
----------------------------*/
//-- ใส่รหัสผ่านในการเข้าไปแก้ไขเหตุการณ์ด้านล่างนี้ --//
$cal_cfg['password'] = 'test';
//-- ใส่ URL ที่เก็บไฟล์ Script นี้ไว้ (ไม่ต้องมี / ปิดท้าย) --//
$urls = "ชื่อเว็บ";
//-- document root --//
$cal_cfg['document_root'] = $_SERVER['DOCUMENT_ROOT'];
//-- time zone (from -12 to 12) --//
$cal_cfg['timezone'] = 0;
//-- is sunday the last day of the week ? (TRUE/FALSE) --//
$cal_cfg['sunday_endweek'] = false;
//-- months --//
$cal_cfg['month'] = array(
'มกราคม',
'กุมภาพันธ์',
'มีนาคม',
'เมษายน',
'พฤษภาคม',
'มิถุนายน',
'กรกฎาคม',
'สิงหาคม',
'กันยายน',
'ตุลาคม',
'พฤศจิกายน',
'ธันวาคม'
);
/*----------------------
popup's template
------------------------*/
// -- header -- //
$cal_cfg['popup']['header'] = <<<EOT
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=TIS-620" />
<link rel="stylesheet" type="text/css" href="./style.css" />
<title>Winged Calendar</title>
<style type="text/css"><!--
body {background-color:#000; color:#fff; margin:0; padding:1em}
--></style>
</head>
<body>
EOT;
//-- footer --//
$cal_cfg['popup']['footer'] = '</body></html>';
//-- notices --//
$cal_cfg['popup']['notices'] = array (
'access' => 'คุณกรอกรหัสผ่านผิด',
'invalid' => 'ใส่ข้อมูลผิดพลาด',
'add' => 'ขณะนี้มีเหตุการณ์ถูกเพิ่ม \nคุณอยาก Reload หน้านี้ไหม ?',
'del' => 'ขณะนี้มีเหตุการณ์ถูกลบ \nคุณอยาก Reload หน้านี้ไหม ?',
'edit' => 'ขณะนี้มีเหตุการณ์ถูกแก้ไข \nคุณอยาก Reload หน้านี้ไหม ?'
);
//-- javascript stuff --//
$cal_cfg['popup']['js']['alert'] = <<<EOT
{ALERT}
<script type="text/javascript"><!--
opener.alert("{ALERT}");
window.close();
--></script>
EOT;
$cal_cfg['popup']['js']['confirm'] = <<<EOT
{CONFIRM}
<script type="text/javascript"><!--
var confirm = opener.confirm("{CONFIRM}");
if (confirm) {
reloadCalendar();
closing();
} else {
window.close();
}
function closing() {
if (!opener.calendarIsLoaded) {
setTimeout("closing()", 1000);
} else {
window.close();
}
}
function reloadCalendar() {
var rows = opener.document.getElementById("calendar").getElementsByTagName("tr");
for (var i=0; i<rows.length; i++) {
if (rows[i].className=="title") {
var dates = rows[i].getElementsByTagName("td")[1].id.substring(1).split("-");
opener.calendar(dates[0], dates[1]);
break;
}
}
}
--></script>
EOT;
$cal_cfg['popup']['js']['form_script'] = <<<EOT
<script type="text/javascript"><!--
document.getElementsByTagName("a")[0].onclick = function() {
opener.open(this.href, "_blank");
return false;
}
var inputs = document.getElementsByTagName("input");
for (var i=0; i<inputs.length; i++) {
if (inputs[i].name=="del") {
inputs[i].onclick = function() {
return confirm("คุณมั่นใจว่าจะลบเหตุการณ์นี้ทิ้งไหม ?");
}
break;
}
}
--></script>
EOT;
/*----------------
templates
------------------*/
//-- calendar body --//
$cal_cfg['template']['body'] = <<<EOT
<table class="calendarDetail" cellspacing="0" cellpadding="0">
<tr class="title">
<td id="l{LAST_MON}-{LAST_YEAR}"><a href="#" title="{LAST_MON}-{LAST_YEAR}">«</a></td>
<td id="c{MON}-{YEAR}" colspan="5"><a href="#" title="Reload เดือนนี้ใหม่">{MONTH} {YEAR}</a></td>
<td id="n{NEXT_MON}-{NEXT_YEAR}"><a href="#" title="{NEXT_MON}-{NEXT_YEAR}">»</a></td>
</tr>
<tr class="title1">
<td>Su</td><td>Mo</td><td>Tu</td><td>We</td><td>Th</td><td>Fr</td><td>Sa</td>
</tr>
<!-- BEGIN -->
<tr class="week">
<td id="{ID_0}" class="{WHICH_0}"><a href="#">{DAY_0}</a>{EVENT_0}</td>
<td id="{ID_1}" class="{WHICH_1}"><a href="#">{DAY_1}</a>{EVENT_1}</td>
<td id="{ID_2}" class="{WHICH_2}"><a href="#">{DAY_2}</a>{EVENT_2}</td>
<td id="{ID_3}" class="{WHICH_3}"><a href="#">{DAY_3}</a>{EVENT_3}</td>
<td id="{ID_4}" class="{WHICH_4}"><a href="#">{DAY_4}</a>{EVENT_4}</td>
<td id="{ID_5}" class="{WHICH_5}"><a href="#">{DAY_5}</a>{EVENT_5}</td>
<td id="{ID_6}" class="{WHICH_6}"><a href="#">{DAY_6}</a>{EVENT_6}</td>
</tr>
<!-- END -->
</table>
EOT;
//-- float event window --//
$cal_cfg['template']['event'] = <<<EOT
<br />
<ul class="calendarEvent" id="e{DAY}-{MONTH}
-{YEAR}">
<!-- BEGIN -->
<li>
<div class="date">{DAY}/{MONTH}/{YEAR} , {HR}:{MIN} น.</div>
<div class="edit"><a href="#" onclick="edit('{ID}'); return false">[edit]</a></div>
<textarea name="message" rows="3" cols="12" style="width:13em">{MESSAGE}</textarea>
</li>
<!-- END -->
</ul>
EOT;
//-- add/edit event form --//
$cal_cfg['template']['form'] = <<<EOT
<div id="calendarForm">
<div class="title">เพิ่ม / ลบ เหตุการณ์ในแต่ละวัน</div>
<form action="./calendar_handle.php" method="post">
<div>
<input type="hidden" name="do" value="{DO}" />
<input type="hidden" name="id" value="{ID}" />
<div style="float:left; width:6em">วันที่ :</div>
<select name="day">
{DAY}
</select> -
<select name="month">
<option value="0">Every month</option><option>-----------</option>
{MONTH}
</select> -
<select name="year">
<option value="0">Every year</option><option>-----------</option>
{YEAR}
</select><br />
<div style="float:left; width:6em">เวลา :</div>
<select name="hr">
{HOUR}
</select> .
<select name="min">
{MINUTE}
</select><br />
<div style="float:left; width:6em">ข้อความ :</div><textarea name="message" rows="5" cols="40" style="width:30em">{MESSAGE}</textarea><br />
<div style="float:left; width:6em">รหัสผ่าน :</div><input type="password" name="pass" style="width:30em" /><br />
<input type="{ADD}" name="add" value=" Add " />
<input type="{EDIT}" name="edit" value=" Edit " />
<input type="{EDIT}" name="del" value="Delete" />
</div>
</form>
<div class="credit">สนับสนุนโดย <a href="http://winged.info">Winged.info</a></div>
</div>
EOT;
//-- essential javascript stuff --//
$cal_cfg['template']['js'] = <<<EOT
<script type="text/javascript"><!--
var request;
var calendarIsLoaded;
function edit(id) {
var url = "$urls/calendar_handle.php?edit=" + id;
window.open(url, "Calendar", "width=500, height=300, scrollbars=1, resizable=1");
}
function calendar(month, year) {
request = false;
calendarIsLoaded = false;
if (window.XMLHttpRequest) {
try {
request = new XMLHttpRequest();
} catch (e) {
request = false;
}
} else if (window.ActiveXObject) {
try {
request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
request = new ActiveXOjbject("Microsoft.XMLHTTP");
} catch (e) {
request = false;
}
}
}
if (request) {
document.getElementById("calendar").innerHTML = "กำลัง Load ปฏิทินอยู่";
request.onreadystatechange = handleResponse;
request.open("GET", "$urls/calendar_handle.php?date=" + month + "-" + year, true);
request.send("");
} else {
alert("Tough luck. No AJAX supported.");
}
}
function handleResponse() {
if (request.readyState==4) {
if (request.status==200) {
calendarIsLoaded = true;
document.getElementById("calendar").innerHTML = request.responseText;
addListeners();
}
}
}
function addListeners() {
var isIE = navigator.userAgent.indexOf("MSIE 6")>-1 || navigator.userAgent.indexOf("MSIE 5")>-1;
var rows = document.getElementById("calendar").getElementsByTagName("tr");
for (var i=0; i<rows.length; i++) {
if (rows[i].className=="title") {
var cols = rows[i].getElementsByTagName("td");
for (var j=0; j<cols.length; j++) {
cols[j].getElementsByTagName("a")[0].onclick = function() {
var dates = this.parentNode.id.substring(1).split("-");
calendar(dates[0], dates[1]);
return false;
}
}
} else if (rows[i].className=="week") {
var cols = rows[i].getElementsByTagName("td");
for (var j=0; j<cols.length; j++) {
cols[j].getElementsByTagName("a")[0].onclick = function() {
var url = "$urls/calendar_handle.php?add=" + this.parentNode.id.substring(1);
window.open(url, "Calendar", "width=500, height=300, scrollbars=1, resizable=1");
return false;
}
var event = document.getElementById("e" + cols[j].id.substring(1));
if (isIE && event!=null) {
cols[j].onmouseover = function() {
document.getElementById("e" + this.id.substring(1)).style.display = "block";
}
cols[j].onmouseout = function() {
document.getElementById("e" + this.id.substring(1)).style.display = "none";
}
event.onmouseover = function() {
document.getElementById(this.id).style.display = "block";
}
event.onmouseout = function() {
document.getElementById(this.id).style.display = "none";
}
}
}
}
}
}
window.onload = addListeners;
--></script>
EOT;
?>
จึงอยากให้ผู้รู้ช่วยดูว่ามันผิดตรงไหนหรือว่าผมพลาดตรงไหนไปครับ ขอบคุณล่วงหน้าครับ
Tag : - - - -
|
|
|
|
|
|
Date :
2009-06-22 11:35:15 |
By :
domeawji |
View :
6542 |
Reply :
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอเพิ่มเติมอีกซักนิดนะครับ คือผมลองเปิดเว็บใน firefox กับ google chrome ปรากฎว่า popup ก็ขึ้นนะครับ แต่ทำไมเปิดใน IE ถึงไม่ขึ้นทั้งๆที่ตอนที่เปิดไฟล์ตัวอย่างที่ได้มาตอนโหลด code ใน IE มันก็ใช้ได้ พอจะแยกส่วนตามที่ในเว็บบอกแล้ว popup ไม่ขึ้นก็ไม่ทราบ
|
|
|
|
|
Date :
2009-06-22 13:02:08 |
By :
domeawji |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขนาดผมแก้ไขไ้ด้แล้วครับเหรอแค่ตรงที่ popup มันยังไม่ขึ้นอ่ะครับ ผู้รู้ช่วยผมหน่อยนะครับ
|
|
|
|
|
Date :
2009-06-22 14:05:36 |
By :
domeawji |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เหอะๆ ไม่มีใครตอบ ผมก็จะรอต่อไปครับ
|
|
|
|
|
Date :
2009-06-22 22:25:53 |
By :
domeawji |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
โอเคได้แล้วครับ
|
|
|
|
|
Date :
2009-06-23 09:45:55 |
By :
domeawji |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
สวัสดีค่ะ คุณdomeawji
อยากทราบขั้นตอนการทำปฏิทินแบบ นัดหมาย
(เพิ่งเริ่ม PHP) ช่วยสอนจะได้ไหมค่ะ
ขอบคุณค่ะ
นิด
|
|
|
|
|
Date :
2009-06-25 10:16:10 |
By :
นิด |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ได้ครับ ผมใช้ตัวนี้อยู่ครับ http://www.thamwebsite.com/cty/php/scripts/calendartxtdb.htm ทำตามวิธีในนั้นได้เลยครับ ที่ผมมีปัญหาเพราะผมวาง <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> ผิดตำแหน่งแค่นั้นครับ มีไรถามได้ครับ
|
|
|
|
|
Date :
2009-06-25 10:45:38 |
By :
domeawji |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณมากค่ะ
|
|
|
|
|
Date :
2009-06-25 10:51:34 |
By :
นิด |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Date :
2009-11-24 13:05:09 |
By :
bb |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณมากค่ะ
|
|
|
|
|
Date :
2010-12-12 14:08:34 |
By :
หวาน |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
อยากทราบ ว่ามันเปลี่ยนขนาดของปฏิทินได้ไหมคับอยากได้อันใหญ่ๆ อ่า
|
|
|
|
|
Date :
2011-01-05 12:46:21 |
By :
ฟหก |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ออ ได้ ละ คับ ลืม ดู CSS
|
|
|
|
|
Date :
2011-01-05 12:47:58 |
By :
asd |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
พี่ๆๆๆครับ คือว่าผมอยากได้ event calendar ที่เก็บข้อมูลไว้ใน DB เลยน่ะค๊าบ ม่ะช่ายเก็บไว้ใน text File น่ะค๊าบ พอจะแนะนำผมได้ป่ะค๊าบ
ขอบคุงน่ะค๊าบ
|
|
|
|
|
Date :
2011-09-10 00:09:05 |
By :
เฟี้ยงเงาะ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|