revisit mod cal
This commit is contained in:
parent
3bc214e544
commit
c9604eaabf
@ -1,6 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Zotlabs\Module;
|
namespace Zotlabs\Module;
|
||||||
|
|
||||||
|
|
||||||
|
use App;
|
||||||
|
use Zotlabs\Web\Controller;
|
||||||
|
|
||||||
require_once('include/conversation.php');
|
require_once('include/conversation.php');
|
||||||
require_once('include/bbcode.php');
|
require_once('include/bbcode.php');
|
||||||
require_once('include/datetime.php');
|
require_once('include/datetime.php');
|
||||||
@ -9,15 +13,13 @@ require_once('include/items.php');
|
|||||||
require_once('include/html2plain.php');
|
require_once('include/html2plain.php');
|
||||||
|
|
||||||
|
|
||||||
class Cal extends \Zotlabs\Web\Controller {
|
class Cal extends Controller {
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
if(observer_prohibited()) {
|
if(observer_prohibited()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$o = '';
|
|
||||||
|
|
||||||
if(argc() > 1) {
|
if(argc() > 1) {
|
||||||
$nick = argv(1);
|
$nick = argv(1);
|
||||||
|
|
||||||
@ -25,19 +27,21 @@ class Cal extends \Zotlabs\Web\Controller {
|
|||||||
|
|
||||||
$channelx = channelx_by_nick($nick);
|
$channelx = channelx_by_nick($nick);
|
||||||
|
|
||||||
if(! $channelx)
|
if(! $channelx) {
|
||||||
|
notice( t('Channel not found.') . EOL);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
\App::$data['channel'] = $channelx;
|
App::$data['channel'] = $channelx;
|
||||||
|
|
||||||
$observer = \App::get_observer();
|
$observer = App::get_observer();
|
||||||
\App::$data['observer'] = $observer;
|
App::$data['observer'] = $observer;
|
||||||
|
|
||||||
$observer_xchan = (($observer) ? $observer['xchan_hash'] : '');
|
$observer_xchan = (($observer) ? $observer['xchan_hash'] : '');
|
||||||
|
|
||||||
head_set_icon(\App::$data['channel']['xchan_photo_s']);
|
head_set_icon(App::$data['channel']['xchan_photo_s']);
|
||||||
|
|
||||||
\App::$page['htmlhead'] .= "<script> var profile_uid = " . ((\App::$data['channel']) ? \App::$data['channel']['channel_id'] : 0) . "; </script>" ;
|
App::$page['htmlhead'] .= "<script> var profile_uid = " . ((App::$data['channel']) ? App::$data['channel']['channel_id'] : 0) . "; </script>" ;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,17 +56,7 @@ class Cal extends \Zotlabs\Web\Controller {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$channel = null;
|
$channel = App::$data['channel'];
|
||||||
|
|
||||||
if(argc() > 1) {
|
|
||||||
$channel = channelx_by_nick(argv(1));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if(! $channel) {
|
|
||||||
notice( t('Channel not found.') . EOL);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// since we don't currently have an event permission - use the stream permission
|
// since we don't currently have an event permission - use the stream permission
|
||||||
|
|
||||||
@ -73,151 +67,38 @@ class Cal extends \Zotlabs\Web\Controller {
|
|||||||
|
|
||||||
nav_set_selected('Calendar');
|
nav_set_selected('Calendar');
|
||||||
|
|
||||||
$sql_extra = permissions_sql($channel['channel_id'],get_observer_hash(),'event');
|
head_add_css('/library/fullcalendar/packages/core/main.min.css');
|
||||||
|
head_add_css('/library/fullcalendar/packages/daygrid/main.min.css');
|
||||||
|
head_add_css('cdav_calendar.css');
|
||||||
|
|
||||||
|
head_add_js('/library/fullcalendar/packages/core/main.min.js');
|
||||||
|
head_add_js('/library/fullcalendar/packages/daygrid/main.min.js');
|
||||||
|
|
||||||
|
$sql_extra = permissions_sql($channel['channel_id'], get_observer_hash(), 'event');
|
||||||
|
|
||||||
|
if(! perm_is_allowed($channel['channel_id'], get_observer_hash(), 'view_contacts') || App::$profile['hide_friends'])
|
||||||
|
$sql_extra .= " and etype != 'birthday' ";
|
||||||
|
|
||||||
$first_day = feature_enabled($channel['channel_id'], 'events_cal_first_day');
|
$first_day = feature_enabled($channel['channel_id'], 'events_cal_first_day');
|
||||||
$first_day = (($first_day) ? $first_day : 0);
|
$first_day = (($first_day) ? $first_day : 0);
|
||||||
|
|
||||||
$htpl = get_markup_template('event_head.tpl');
|
$start = '';
|
||||||
\App::$page['htmlhead'] .= replace_macros($htpl,array(
|
$finish = '';
|
||||||
'$baseurl' => z_root(),
|
|
||||||
'$module_url' => '/cal/' . $channel['channel_address'],
|
|
||||||
'$modparams' => 2,
|
|
||||||
'$lang' => \App::$language,
|
|
||||||
'$timezone' => date_default_timezone_get(),
|
|
||||||
'$first_day' => $first_day
|
|
||||||
));
|
|
||||||
|
|
||||||
$o = '';
|
if (argv(2) === 'json') {
|
||||||
|
|
||||||
$mode = 'view';
|
|
||||||
$y = 0;
|
|
||||||
$m = 0;
|
|
||||||
$ignored = ((x($_REQUEST,'ignored')) ? " and dismissed = " . intval($_REQUEST['ignored']) . " " : '');
|
|
||||||
|
|
||||||
// logger('args: ' . print_r(\App::$argv,true));
|
|
||||||
|
|
||||||
if(argc() > 3 && intval(argv(2)) && intval(argv(3))) {
|
|
||||||
$mode = 'view';
|
|
||||||
$y = intval(argv(2));
|
|
||||||
$m = intval(argv(3));
|
|
||||||
}
|
|
||||||
if(argc() <= 3) {
|
|
||||||
$mode = 'view';
|
|
||||||
$event_id = argv(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if($mode == 'view') {
|
|
||||||
|
|
||||||
/* edit/create form */
|
|
||||||
if($event_id) {
|
|
||||||
$r = q("SELECT * FROM event WHERE event_hash = '%s' AND uid = %d LIMIT 1",
|
|
||||||
dbesc($event_id),
|
|
||||||
intval($channel['channel_id'])
|
|
||||||
);
|
|
||||||
if(count($r))
|
|
||||||
$orig_event = $r[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Passed parameters overrides anything found in the DB
|
|
||||||
if(!x($orig_event))
|
|
||||||
$orig_event = array();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$tz = date_default_timezone_get();
|
|
||||||
if(x($orig_event))
|
|
||||||
$tz = (($orig_event['adjust']) ? date_default_timezone_get() : 'UTC');
|
|
||||||
|
|
||||||
$syear = datetime_convert('UTC', $tz, $sdt, 'Y');
|
|
||||||
$smonth = datetime_convert('UTC', $tz, $sdt, 'm');
|
|
||||||
$sday = datetime_convert('UTC', $tz, $sdt, 'd');
|
|
||||||
$shour = datetime_convert('UTC', $tz, $sdt, 'H');
|
|
||||||
$sminute = datetime_convert('UTC', $tz, $sdt, 'i');
|
|
||||||
|
|
||||||
$stext = datetime_convert('UTC',$tz,$sdt);
|
|
||||||
$stext = substr($stext,0,14) . "00:00";
|
|
||||||
|
|
||||||
$fyear = datetime_convert('UTC', $tz, $fdt, 'Y');
|
|
||||||
$fmonth = datetime_convert('UTC', $tz, $fdt, 'm');
|
|
||||||
$fday = datetime_convert('UTC', $tz, $fdt, 'd');
|
|
||||||
$fhour = datetime_convert('UTC', $tz, $fdt, 'H');
|
|
||||||
$fminute = datetime_convert('UTC', $tz, $fdt, 'i');
|
|
||||||
|
|
||||||
$ftext = datetime_convert('UTC',$tz,$fdt);
|
|
||||||
$ftext = substr($ftext,0,14) . "00:00";
|
|
||||||
|
|
||||||
$type = ((x($orig_event)) ? $orig_event['etype'] : 'event');
|
|
||||||
|
|
||||||
$f = get_config('system','event_input_format');
|
|
||||||
if(! $f)
|
|
||||||
$f = 'ymd';
|
|
||||||
|
|
||||||
$catsenabled = feature_enabled($channel['channel_id'],'categories');
|
|
||||||
|
|
||||||
|
|
||||||
$show_bd = perm_is_allowed($channel['channel_id'], get_observer_hash(), 'view_contacts');
|
|
||||||
if(! $show_bd) {
|
|
||||||
$sql_extra .= " and event.etype != 'birthday' ";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$category = '';
|
|
||||||
|
|
||||||
$thisyear = datetime_convert('UTC',date_default_timezone_get(),'now','Y');
|
|
||||||
$thismonth = datetime_convert('UTC',date_default_timezone_get(),'now','m');
|
|
||||||
if(! $y)
|
|
||||||
$y = intval($thisyear);
|
|
||||||
if(! $m)
|
|
||||||
$m = intval($thismonth);
|
|
||||||
|
|
||||||
// Put some limits on dates. The PHP date functions don't seem to do so well before 1900.
|
|
||||||
// An upper limit was chosen to keep search engines from exploring links millions of years in the future.
|
|
||||||
|
|
||||||
if($y < 1901)
|
|
||||||
$y = 1900;
|
|
||||||
if($y > 2099)
|
|
||||||
$y = 2100;
|
|
||||||
|
|
||||||
$nextyear = $y;
|
|
||||||
$nextmonth = $m + 1;
|
|
||||||
if($nextmonth > 12) {
|
|
||||||
$nextmonth = 1;
|
|
||||||
$nextyear ++;
|
|
||||||
}
|
|
||||||
|
|
||||||
$prevyear = $y;
|
|
||||||
if($m > 1)
|
|
||||||
$prevmonth = $m - 1;
|
|
||||||
else {
|
|
||||||
$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 (argv(2) === 'json'){
|
|
||||||
if (x($_GET,'start')) $start = $_GET['start'];
|
if (x($_GET,'start')) $start = $_GET['start'];
|
||||||
if (x($_GET,'end')) $finish = $_GET['end'];
|
if (x($_GET,'end')) $finish = $_GET['end'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$start = datetime_convert('UTC','UTC',$start);
|
$start = datetime_convert('UTC','UTC',$start);
|
||||||
$finish = datetime_convert('UTC','UTC',$finish);
|
$finish = datetime_convert('UTC','UTC',$finish);
|
||||||
|
|
||||||
$adjust_start = datetime_convert('UTC', date_default_timezone_get(), $start);
|
$adjust_start = datetime_convert('UTC', date_default_timezone_get(), $start);
|
||||||
$adjust_finish = datetime_convert('UTC', date_default_timezone_get(), $finish);
|
$adjust_finish = datetime_convert('UTC', date_default_timezone_get(), $finish);
|
||||||
|
|
||||||
|
if (x($_GET, 'id')) {
|
||||||
if(! perm_is_allowed(\App::$profile['uid'],get_observer_hash(),'view_contacts'))
|
|
||||||
$sql_extra .= " and etype != 'birthday' ";
|
|
||||||
|
|
||||||
if (x($_GET,'id')){
|
|
||||||
$r = q("SELECT event.*, item.plink, item.item_flags, item.author_xchan, item.owner_xchan, item.id as item_id
|
$r = q("SELECT event.*, item.plink, item.item_flags, item.author_xchan, item.owner_xchan, item.id as item_id
|
||||||
from event left join item on resource_id = event_hash where resource_type = 'event' and event.uid = %d and event.id = %d $sql_extra limit 1",
|
from event left join item on item.resource_id = event.event_hash
|
||||||
|
where item.resource_type = 'event' and event.uid = %d and event.id = %d $sql_extra limit 1",
|
||||||
intval($channel['channel_id']),
|
intval($channel['channel_id']),
|
||||||
intval($_GET['id'])
|
intval($_GET['id'])
|
||||||
);
|
);
|
||||||
@ -227,12 +108,12 @@ class Cal extends \Zotlabs\Web\Controller {
|
|||||||
// There's still an issue if the finish date crosses the end of month.
|
// There's still an issue if the finish date crosses the end of month.
|
||||||
// Noting this for now - it will need to be fixed here and in Friendica.
|
// Noting this for now - it will need to be fixed here and in Friendica.
|
||||||
// Ultimately the finish date shouldn't be involved in the query.
|
// Ultimately the finish date shouldn't be involved in the query.
|
||||||
|
|
||||||
$r = q("SELECT event.*, item.plink, item.item_flags, item.author_xchan, item.owner_xchan, item.id as item_id
|
$r = q("SELECT event.*, item.plink, item.item_flags, item.author_xchan, item.owner_xchan, item.id as item_id
|
||||||
from event left join item on event.event_hash = item.resource_id
|
from event left join item on event.event_hash = item.resource_id
|
||||||
where item.resource_type = 'event' and event.uid = %d and event.uid = item.uid $ignored
|
where item.resource_type = 'event' and event.uid = %d and event.uid = item.uid
|
||||||
AND (( event.adjust = 0 AND ( event.dtend >= '%s' or event.nofinish = 1 ) AND event.dtstart <= '%s' )
|
AND (( event.adjust = 0 AND ( event.dtend >= '%s' or event.nofinish = 1 ) AND event.dtstart <= '%s' )
|
||||||
OR ( event.adjust = 1 AND ( event.dtend >= '%s' or event.nofinish = 1 ) AND event.dtstart <= '%s' )) ",
|
OR ( event.adjust = 1 AND ( event.dtend >= '%s' or event.nofinish = 1 ) AND event.dtstart <= '%s' ))
|
||||||
|
$sql_extra",
|
||||||
intval($channel['channel_id']),
|
intval($channel['channel_id']),
|
||||||
dbesc($start),
|
dbesc($start),
|
||||||
dbesc($finish),
|
dbesc($finish),
|
||||||
@ -241,125 +122,96 @@ class Cal extends \Zotlabs\Web\Controller {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$links = array();
|
|
||||||
|
|
||||||
if($r) {
|
if($r) {
|
||||||
xchan_query($r);
|
xchan_query($r);
|
||||||
$r = fetch_post_tags($r,true);
|
$r = fetch_post_tags($r,true);
|
||||||
|
|
||||||
$r = sort_by_date($r);
|
$r = sort_by_date($r);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($r) {
|
$events = [];
|
||||||
foreach($r as $rr) {
|
|
||||||
$j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['dtstart'], 'j') : datetime_convert('UTC','UTC',$rr['dtstart'],'j'));
|
|
||||||
if(! x($links,$j))
|
|
||||||
$links[$j] = z_root() . '/' . \App::$cmd . '#link-' . $j;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$events=array();
|
|
||||||
|
|
||||||
$last_date = '';
|
|
||||||
$fmt = t('l, F j');
|
|
||||||
|
|
||||||
if($r) {
|
if($r) {
|
||||||
|
|
||||||
foreach($r as $rr) {
|
foreach($r as $rr) {
|
||||||
|
|
||||||
$tz = get_iconfig($rr, 'event', 'timezone');
|
$tz = get_iconfig($rr, 'event', 'timezone');
|
||||||
|
|
||||||
if(! $tz)
|
if(! $tz)
|
||||||
$tz = 'UTC';
|
$tz = 'UTC';
|
||||||
|
|
||||||
$rr['timezone'] = $tz;
|
$start = (($rr['adjust']) ? datetime_convert($tz, date_default_timezone_get(), $rr['dtstart'], 'c') : datetime_convert('UTC', 'UTC', $rr['dtstart'], 'c'));
|
||||||
|
|
||||||
$j = (($rr['adjust']) ? datetime_convert($tz,date_default_timezone_get(),$rr['dtstart'], 'j') : datetime_convert('UTC','UTC',$rr['dtstart'],'j'));
|
|
||||||
$d = (($rr['adjust']) ? datetime_convert($tz,date_default_timezone_get(),$rr['dtstart'], $fmt) : datetime_convert('UTC','UTC',$rr['dtstart'],$fmt));
|
|
||||||
$d = day_translate($d);
|
|
||||||
|
|
||||||
$start = (($rr['adjust']) ? datetime_convert($tz,date_default_timezone_get(),$rr['dtstart'], 'c') : datetime_convert('UTC','UTC',$rr['dtstart'],'c'));
|
|
||||||
if ($rr['nofinish']){
|
if ($rr['nofinish']){
|
||||||
$end = null;
|
$end = null;
|
||||||
} else {
|
} else {
|
||||||
$end = (($rr['adjust']) ? datetime_convert($tz,date_default_timezone_get(),$rr['dtend'], 'c') : datetime_convert('UTC','UTC',$rr['dtend'],'c'));
|
$end = (($rr['adjust']) ? datetime_convert($tz, date_default_timezone_get(), $rr['dtend'], 'c') : datetime_convert('UTC', 'UTC', $rr['dtend'], 'c'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$html = '';
|
||||||
$is_first = ($d !== $last_date);
|
if (x($_GET,'id')) {
|
||||||
|
$rr['timezone'] = $tz;
|
||||||
$last_date = $d;
|
|
||||||
|
|
||||||
$edit = false;
|
|
||||||
|
|
||||||
$drop = false;
|
|
||||||
|
|
||||||
$title = strip_tags(html_entity_decode(bbcode($rr['summary']),ENT_QUOTES,'UTF-8'));
|
|
||||||
if(! $title) {
|
|
||||||
list($title, $_trash) = explode("<br",bbcode($rr['desc']),2);
|
|
||||||
$title = strip_tags(html_entity_decode($title,ENT_QUOTES,'UTF-8'));
|
|
||||||
}
|
|
||||||
$html = format_event_html($rr);
|
$html = format_event_html($rr);
|
||||||
$rr['desc'] = zidify_links(smilies(bbcode($rr['desc'])));
|
}
|
||||||
$rr['description'] = htmlentities(html2plain(bbcode($rr['description'])),ENT_COMPAT,'UTF-8',false);
|
|
||||||
$rr['location'] = zidify_links(smilies(bbcode($rr['location'])));
|
|
||||||
$events[] = array(
|
$events[] = array(
|
||||||
|
'calendar_id' => 'channel_calendar',
|
||||||
|
'rw' => true,
|
||||||
'id'=>$rr['id'],
|
'id'=>$rr['id'],
|
||||||
'hash' => $rr['event_hash'],
|
'uri' => $rr['event_hash'],
|
||||||
|
'timezone' => $tz,
|
||||||
'start'=> $start,
|
'start'=> $start,
|
||||||
'end' => $end,
|
'end' => $end,
|
||||||
'drop' => $drop,
|
'drop' => $drop,
|
||||||
'allDay' => (($rr['adjust']) ? 0 : 1),
|
'allDay' => (($rr['adjust']) ? 0 : 1),
|
||||||
'title' => $title,
|
'title' => htmlentities($rr['summary'], ENT_COMPAT, 'UTF-8', false),
|
||||||
|
'editable' => $edit ? true : false,
|
||||||
'j' => $j,
|
'item' => $rr,
|
||||||
'd' => $d,
|
'plink' => [$rr['plink'], t('Link to source')],
|
||||||
'edit' => $edit,
|
'description' => htmlentities($rr['description'], ENT_COMPAT, 'UTF-8', false),
|
||||||
'is_first'=>$is_first,
|
'location' => htmlentities($rr['location'], ENT_COMPAT, 'UTF-8', false),
|
||||||
'item'=>$rr,
|
'allow_cid' => expand_acl($rr['allow_cid']),
|
||||||
'html'=>$html,
|
'allow_gid' => expand_acl($rr['allow_gid']),
|
||||||
'plink' => array($rr['plink'],t('Link to Source'),'',''),
|
'deny_cid' => expand_acl($rr['deny_cid']),
|
||||||
|
'deny_gid' => expand_acl($rr['deny_gid']),
|
||||||
|
'html' => $html
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argv(2) === 'json'){
|
if (argv(2) === 'json') {
|
||||||
echo json_encode($events); killme();
|
echo json_encode($events);
|
||||||
|
killme();
|
||||||
}
|
}
|
||||||
|
|
||||||
// links: array('href', 'text', 'extra css classes', 'title')
|
if (x($_GET,'id')) {
|
||||||
if (x($_GET,'id')){
|
$o = replace_macros(get_markup_template("cal_event.tpl"), [
|
||||||
$tpl = get_markup_template("event_cal.tpl");
|
'$events' => $events
|
||||||
}
|
]);
|
||||||
else {
|
echo $o;
|
||||||
$tpl = get_markup_template("events_cal-js.tpl");
|
killme();
|
||||||
}
|
}
|
||||||
|
|
||||||
$nick = $channel['channel_address'];
|
$nick = $channel['channel_address'];
|
||||||
|
|
||||||
$o = replace_macros($tpl, array(
|
$sources = '{
|
||||||
'$baseurl' => z_root(),
|
id: \'channel_calendar\',
|
||||||
'$new_event' => array(z_root().'/cal',(($event_id) ? t('Edit Event') : t('Create Event')),'',''),
|
url: \'/cal/' . $nick . '/json/\',
|
||||||
'$previus' => array(z_root()."/cal/$nick/$prevyear/$prevmonth",t('Previous'),'',''),
|
color: \'#3a87ad\'
|
||||||
'$next' => array(z_root()."/cal/$nick/$nextyear/$nextmonth",t('Next'),'',''),
|
}';
|
||||||
'$export' => array(z_root()."/cal/$nick/$y/$m/export",t('Export'),'',''),
|
|
||||||
'$calendar' => cal($y,$m,$links, ' eventcal'),
|
$o = replace_macros(get_markup_template("cal_calendar.tpl"), [
|
||||||
'$events' => $events,
|
'$sources' => $sources,
|
||||||
'$upload' => t('Import'),
|
'$lang' => App::$language,
|
||||||
'$submit' => t('Submit'),
|
'$timezone' => date_default_timezone_get(),
|
||||||
|
'$first_day' => $first_day,
|
||||||
'$prev' => t('Previous'),
|
'$prev' => t('Previous'),
|
||||||
'$next' => t('Next'),
|
'$next' => t('Next'),
|
||||||
'$today' => t('Today'),
|
'$today' => t('Today'),
|
||||||
'$form' => $form,
|
'$title' => $title,
|
||||||
'$expandform' => ((x($_GET,'expandform')) ? true : false)
|
'$dtstart' => $dtstart,
|
||||||
));
|
'$dtend' => $dtend,
|
||||||
|
'$nick' => $nick
|
||||||
if (x($_GET,'id')){ echo $o; killme(); }
|
]);
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
105
view/tpl/cal_calendar.tpl
Executable file
105
view/tpl/cal_calendar.tpl
Executable file
@ -0,0 +1,105 @@
|
|||||||
|
<script>
|
||||||
|
var calendar;
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
var calendarEl = document.getElementById('calendar');
|
||||||
|
calendar = new FullCalendar.Calendar(calendarEl, {
|
||||||
|
plugins: [ 'dayGrid' ],
|
||||||
|
eventSources: [ {{$sources}} ],
|
||||||
|
|
||||||
|
timeZone: '{{$timezone}}',
|
||||||
|
|
||||||
|
locale: '{{$lang}}',
|
||||||
|
|
||||||
|
eventTextColor: 'white',
|
||||||
|
header: false,
|
||||||
|
|
||||||
|
height: 'auto',
|
||||||
|
|
||||||
|
firstDay: {{$first_day}},
|
||||||
|
|
||||||
|
monthNames: aStr['monthNames'],
|
||||||
|
monthNamesShort: aStr['monthNamesShort'],
|
||||||
|
dayNames: aStr['dayNames'],
|
||||||
|
dayNamesShort: aStr['dayNamesShort'],
|
||||||
|
allDayText: aStr['allday'],
|
||||||
|
|
||||||
|
eventClick: function(info) {
|
||||||
|
var event_id = info.event._def.extendedProps.item.id;
|
||||||
|
showEvent(event_id);
|
||||||
|
},
|
||||||
|
|
||||||
|
loading: function(isLoading, view) {
|
||||||
|
$('#events-spinner').show();
|
||||||
|
$('#today-btn > i').hide();
|
||||||
|
if(!isLoading) {
|
||||||
|
$('#events-spinner').hide();
|
||||||
|
$('#today-btn > i').show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
calendar.render();
|
||||||
|
|
||||||
|
$('#title').text(calendar.view.title);
|
||||||
|
|
||||||
|
$('#today-btn').on('click', function() {
|
||||||
|
calendar.today();
|
||||||
|
$('#title').text(calendar.view.title);
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#prev-btn').on('click', function() {
|
||||||
|
calendar.prev();
|
||||||
|
$('#title').text(calendar.view.title);
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#next-btn').on('click', function() {
|
||||||
|
calendar.next();
|
||||||
|
$('#title').text(calendar.view.title);
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on('click','#fullscreen-btn', updateSize);
|
||||||
|
$(document).on('click','#inline-btn', updateSize);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
function showEvent(event_id) {
|
||||||
|
$.get(
|
||||||
|
'cal/{{$nick}}?id='+event_id,
|
||||||
|
function(data){
|
||||||
|
$.colorbox({ scrolling: false, html: data, onComplete: function() { $.colorbox.resize(); }});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeView(action, viewName) {
|
||||||
|
calendar.changeView(viewName);
|
||||||
|
$('#title').text(calendar.view.title);
|
||||||
|
$('#view_selector').html(views[calendar.view.type]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateSize() {
|
||||||
|
calendar.updateSize();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="generic-content-wrapper">
|
||||||
|
<div class="section-title-wrapper">
|
||||||
|
<div class="float-right">
|
||||||
|
<div class="btn-group">
|
||||||
|
<button id="prev-btn" class="btn btn-outline-secondary btn-sm" title="{{$prev}}"><i class="fa fa-backward"></i></button>
|
||||||
|
<button id="today-btn" class="btn btn-outline-secondary btn-sm" title="{{$today}}"><div id="events-spinner" class="spinner s"></div><i class="fa fa-bullseye" style="display: none; width: 1rem;"></i></button>
|
||||||
|
<button id="next-btn" class="btn btn-outline-secondary btn-sm" title="{{$next}}"><i class="fa fa-forward"></i></button>
|
||||||
|
</div>
|
||||||
|
<button id="fullscreen-btn" type="button" class="btn btn-outline-secondary btn-sm" onclick="makeFullScreen();"><i class="fa fa-expand"></i></button>
|
||||||
|
<button id="inline-btn" type="button" class="btn btn-outline-secondary btn-sm" onclick="makeFullScreen(false);"><i class="fa fa-compress"></i></button>
|
||||||
|
</div>
|
||||||
|
<h2 id="title"></h2>
|
||||||
|
<div class="clear"></div>
|
||||||
|
</div>
|
||||||
|
<div class="section-content-wrapper-np">
|
||||||
|
<div id="calendar"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
Reference in New Issue
Block a user