From 22cfb77173b1093028c1706f6c513a040ad89967 Mon Sep 17 00:00:00 2001 From: Fabio Comuni Date: Tue, 14 Feb 2012 16:19:48 +0100 Subject: events: first test for full-javascript events calendar --- mod/events.php | 138 +++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 99 insertions(+), 39 deletions(-) (limited to 'mod') diff --git a/mod/events.php b/mod/events.php index 5da8f17fc..731b824de 100755 --- a/mod/events.php +++ b/mod/events.php @@ -1,5 +1,6 @@ page['htmlhead'] .= replace_macros($htpl,array('$baseurl' => $a->get_baseurl())); + $o =""; // tabs - $o .= profile_tabs($a, True); + $tabs = profile_tabs($a, True); - $o .= '

' . t('Events') . '

'; $mode = 'view'; @@ -138,6 +142,8 @@ function events_content(&$a) { } if($mode == 'view') { + + $thisyear = datetime_convert('UTC',date_default_timezone_get(),'now','Y'); $thismonth = datetime_convert('UTC',date_default_timezone_get(),'now','m'); if(! $y) @@ -167,11 +173,16 @@ function events_content(&$a) { $prevmonth = 12; $prevyear --; } - $dim = get_dim($y,$m); $start = sprintf('%d-%d-%d %d:%d:%d',$y,$m,1,0,0,0); $finish = sprintf('%d-%d-%d %d:%d:%d',$y,$m,$dim,23,59,59); + + + if ($a->argv[1] === 'json'){ + if (x($_GET,'start')) $start = date("Y-m-d h:i:s", $_GET['start']); + if (x($_GET,'end')) $finish = date("Y-m-d h:i:s", $_GET['end']); + } $start = datetime_convert('UTC','UTC',$start); $finish = datetime_convert('UTC','UTC',$finish); @@ -180,17 +191,26 @@ function events_content(&$a) { $adjust_finish = datetime_convert('UTC', date_default_timezone_get(), $finish); - $r = q("SELECT `event`.*, `item`.`id` AS `itemid`,`item`.`plink`, - `item`.`author-name`, `item`.`author-avatar`, `item`.`author-link` FROM `event` LEFT JOIN `item` ON `item`.`event-id` = `event`.`id` - WHERE `event`.`uid` = %d - AND (( `adjust` = 0 AND `start` >= '%s' AND `start` <= '%s' ) - OR ( `adjust` = 1 AND `start` >= '%s' AND `start` <= '%s' )) ", - intval(local_user()), - dbesc($start), - dbesc($finish), - dbesc($adjust_start), - dbesc($adjust_finish) - ); + if (x($_GET,'id')){ + $r = q("SELECT `event`.*, `item`.`id` AS `itemid`,`item`.`plink`, + `item`.`author-name`, `item`.`author-avatar`, `item`.`author-link` FROM `event` LEFT JOIN `item` ON `item`.`event-id` = `event`.`id` + WHERE `event`.`uid` = %d AND `event`.`id` = %d", + intval(local_user()), + intval($_GET['id']) + ); + } else { + $r = q("SELECT `event`.*, `item`.`id` AS `itemid`,`item`.`plink`, + `item`.`author-name`, `item`.`author-avatar`, `item`.`author-link` FROM `event` LEFT JOIN `item` ON `item`.`event-id` = `event`.`id` + WHERE `event`.`uid` = %d + AND (( `adjust` = 0 AND `start` >= '%s' AND `start` <= '%s' ) + OR ( `adjust` = 1 AND `start` >= '%s' AND `start` <= '%s' )) ", + intval(local_user()), + dbesc($start), + dbesc($finish), + dbesc($adjust_start), + dbesc($adjust_finish) + ); + } $links = array(); @@ -204,17 +224,7 @@ function events_content(&$a) { } - $o .= ''; - $o .= '
'; - - $o .= ''; - $o .= cal($y,$m,$links, ' eventcal'); - - $o .= ''; - $o .= '
'; - $o .= '
'; - - + $events=array(); $last_date = ''; $fmt = t('l, F j'); @@ -222,25 +232,75 @@ function events_content(&$a) { if(count($r)) { $r = sort_by_date($r); foreach($r as $rr) { + + $j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'j') : datetime_convert('UTC','UTC',$rr['start'],'j')); $d = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], $fmt) : datetime_convert('UTC','UTC',$rr['start'],$fmt)); $d = day_translate($d); - if($d !== $last_date) - $o .= '
' . $d . '
'; - $last_date = $d; - if($rr['author-name']) { - $o .= '' . $rr['author-name'] . ''; + + $start = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'c') : datetime_convert('UTC','UTC',$rr['start'],'c')); + if ($rr['nofinish']){ + $end = null; + $allday=true; + } else { + $end = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['finish'], 'c') : datetime_convert('UTC','UTC',$rr['finish'],'c')); + $allday=false; } - $o .= format_event_html($rr); - $o .= ((! $rr['cid']) ? '' : ''); - if($rr['plink']) - $o .= ''; + + + $is_first = ($d !== $last_date); + + $last_date = $d; + $edit = ((! $rr['cid']) ? array($a->get_baseurl().'/events/event/'.$rr['id'],t('Edit event'),'','') : null); + + $events[] = array( + 'id'=>$rr['id'], + 'start'=> $start, + 'end' => $end, + 'allDay' => $allday, + 'title' => strip_tags(bbcode($rr['desc'])), + + 'j' => $j, + 'd' => $d, + 'edit' => $edit, + 'is_first'=>$is_first, + 'item'=>$rr, + 'html'=>format_event_html($rr), + 'plink' => array($rr['plink'],t('link to source'),'',''), + ); - $o .= '
'; } } + + if ($a->argv[1] === 'json'){ + echo json_encode($events); killme(); + } + + // links: array('href', 'text', 'extra css classes', 'title') + if (x($_GET,'id')){ + $tpl = get_markup_template("event.tpl"); + } else { + $tpl = get_markup_template("events.tpl"); + } + $o = replace_macros($tpl, array( + '$baseurl' => $a->get_baseurl(), + '$tabs' => $tabs, + '$title' => t('Events'), + '$new_event'=> array($a->get_baseurl().'/events/new',t('Create New Event'),'',''), + '$previus' => array($a->get_baseurl()."/events/$prevyear/$prevmonth",t('Previous'),'',''), + '$next' => array($a->get_baseurl()."/events/$nextyear/$nextmonth",t('Next'),'',''), + '$calendar' => cal($y,$m,$links, ' eventcal'), + + '$events' => $events, + + + )); + + if (x($_GET,'id')){ echo $o; killme(); } + return $o; + } if($mode === 'edit' && $event_id) { @@ -271,8 +331,7 @@ function events_content(&$a) { if($cid) $sh_checked .= ' disabled="disabled" '; - $htpl = get_markup_template('event_head.tpl'); - $a->page['htmlhead'] .= replace_macros($htpl,array('$baseurl' => $a->get_baseurl())); + $tpl = get_markup_template('event_form.tpl'); @@ -311,8 +370,9 @@ function events_content(&$a) { '$eid' => $eid, '$cid' => $cid, '$uri' => $uri, - '$e_text' => t('Event details'), - '$e_desc' => sprintf( t('Format is %s %s. Starting date and Description are required.'),$dateformat,$timeformat), + '$title' => t('Event details'), + '$desc' => sprintf( t('Format is %s %s. Starting date and Description are required.'),$dateformat,$timeformat), + '$s_text' => t('Event Starts:') . ' * ', '$s_dsel' => datesel($f,'start',$syear+5,$syear,false,$syear,$smonth,$sday), '$s_tsel' => timesel('start',$shour,$sminute), -- cgit v1.2.3 From 7140e56d1f01ce8448fa432411c10b9212fc8a66 Mon Sep 17 00:00:00 2001 From: Fabio Comuni Date: Tue, 14 Feb 2012 16:48:34 +0100 Subject: events js: pass only first line of desc as title; item.desc and item.location as html --- mod/events.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'mod') diff --git a/mod/events.php b/mod/events.php index 731b824de..e10f508dd 100755 --- a/mod/events.php +++ b/mod/events.php @@ -241,10 +241,8 @@ function events_content(&$a) { $start = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'c') : datetime_convert('UTC','UTC',$rr['start'],'c')); if ($rr['nofinish']){ $end = null; - $allday=true; } else { $end = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['finish'], 'c') : datetime_convert('UTC','UTC',$rr['finish'],'c')); - $allday=false; } @@ -253,26 +251,31 @@ function events_content(&$a) { $last_date = $d; $edit = ((! $rr['cid']) ? array($a->get_baseurl().'/events/event/'.$rr['id'],t('Edit event'),'','') : null); + list($title, $_trash) = explode("$rr['id'], 'start'=> $start, 'end' => $end, - 'allDay' => $allday, - 'title' => strip_tags(bbcode($rr['desc'])), + 'allDay' => false, + 'title' => $title, 'j' => $j, 'd' => $d, 'edit' => $edit, 'is_first'=>$is_first, 'item'=>$rr, - 'html'=>format_event_html($rr), + 'html'=>$html, 'plink' => array($rr['plink'],t('link to source'),'',''), ); } } - + if ($a->argv[1] === 'json'){ echo json_encode($events); killme(); } -- cgit v1.2.3 From 73bee08ac2ce4e89ab365d23f431f5e0c465abd6 Mon Sep 17 00:00:00 2001 From: Fabio Comuni Date: Wed, 15 Feb 2012 12:47:50 +0100 Subject: enable ajax calendar with $a->config['experimentals']['new_calendar']=1 --- mod/events.php | 6 +++++- mod/settings.php | 7 +++++-- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'mod') diff --git a/mod/events.php b/mod/events.php index e10f508dd..0906d16c2 100755 --- a/mod/events.php +++ b/mod/events.php @@ -284,7 +284,11 @@ function events_content(&$a) { if (x($_GET,'id')){ $tpl = get_markup_template("event.tpl"); } else { - $tpl = get_markup_template("events.tpl"); + if (get_config('experimentals','new_calendar')==1){ + $tpl = get_markup_template("events-js.tpl"); + } else { + $tpl = get_markup_template("events.tpl"); + } } $o = replace_macros($tpl, array( '$baseurl' => $a->get_baseurl(), diff --git a/mod/settings.php b/mod/settings.php index b4cd2e608..57a4e6db0 100755 --- a/mod/settings.php +++ b/mod/settings.php @@ -734,8 +734,11 @@ function settings_content(&$a) { if($files) { foreach($files as $file) { $f = basename($file); - $theme_name = ((file_exists($file . '/experimental')) ? sprintf("%s - \x28Experimental\x29", $f) : $f); - $themes[$f]=$theme_name; + $is_experimental = file_exists($file . '/experimental'); + if (!$is_experimental or ($is_experimental && (get_config('experimentals','exp_themes')==1 or get_config('experimentals','exp_themes')===false))){ + $theme_name = (($is_experimental) ? sprintf("%s - \x28Experimental\x29", $f) : $f); + $themes[$f]=$theme_name; + } } } $theme_selected = (!x($_SESSION,'theme')? $default_theme : $_SESSION['theme']); -- cgit v1.2.3