frio: events - work on event_form.tpl + datetime.php

This commit is contained in:
rabuzarus 2016-06-13 10:19:38 +02:00
parent 0af572ffba
commit 5e98f27fcd
4 changed files with 63 additions and 25 deletions

View file

@ -202,7 +202,7 @@ function dob($dob) {
* @return string Parsed HTML output. * @return string Parsed HTML output.
*/ */
function datesel($format, $min, $max, $default, $id = 'datepicker') { function datesel($format, $min, $max, $default, $id = 'datepicker') {
return datetimesel($format,$min,$max,$default,$id,true,false, '',''); return datetimesel($format,$min,$max,$default,'',$id,true,false, '','');
} }
/** /**
@ -220,7 +220,7 @@ function datesel($format, $min, $max, $default, $id = 'datepicker') {
* @return string Parsed HTML output. * @return string Parsed HTML output.
*/ */
function timesel($format, $h, $m, $id='timepicker') { function timesel($format, $h, $m, $id='timepicker') {
return datetimesel($format,new DateTime(),new DateTime(),new DateTime("$h:$m"),$id,false,true); return datetimesel($format,new DateTime(),new DateTime(),new DateTime("$h:$m"),'',$id,false,true);
} }
/** /**
@ -251,7 +251,7 @@ function timesel($format, $h, $m, $id='timepicker') {
* @todo Once browser support is better this could probably be replaced with * @todo Once browser support is better this could probably be replaced with
* native HTML5 date picker. * native HTML5 date picker.
*/ */
function datetimesel($format, $min, $max, $default, $id = 'datetimepicker', $pickdate = true, $picktime = true, $minfrom = '', $maxfrom = '', $required = false) { function datetimesel($format, $min, $max, $default, $label, $id = 'datetimepicker', $pickdate = true, $picktime = true, $minfrom = '', $maxfrom = '', $required = false) {
// First day of the week (0 = Sunday) // First day of the week (0 = Sunday)
$firstDay = get_pconfig(local_user(),'system','first_day_of_week'); $firstDay = get_pconfig(local_user(),'system','first_day_of_week');
@ -283,9 +283,9 @@ function datetimesel($format, $min, $max, $default, $id = 'datetimepicker', $pic
$extra_js = ''; $extra_js = '';
$pickers .= ",dayOfWeekStart: ".$firstDay.",lang:'".$lang."'"; $pickers .= ",dayOfWeekStart: ".$firstDay.",lang:'".$lang."'";
if($minfrom != '') if($minfrom != '')
$extra_js .= "\$('#$minfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#$id').data('xdsoft_datetimepicker').setOptions({minDate: currentDateTime})}})"; $extra_js .= "\$('id_#$minfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#id_$id').data('xdsoft_datetimepicker').setOptions({minDate: currentDateTime})}})";
if($maxfrom != '') if($maxfrom != '')
$extra_js .= "\$('#$maxfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#$id').data('xdsoft_datetimepicker').setOptions({maxDate: currentDateTime})}})"; $extra_js .= "\$('#id_$maxfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#id_$id').data('xdsoft_datetimepicker').setOptions({maxDate: currentDateTime})}})";
$readable_format = $dateformat; $readable_format = $dateformat;
$readable_format = str_replace('Y','yyyy',$readable_format); $readable_format = str_replace('Y','yyyy',$readable_format);
@ -294,10 +294,14 @@ function datetimesel($format, $min, $max, $default, $id = 'datetimepicker', $pic
$readable_format = str_replace('H','HH',$readable_format); $readable_format = str_replace('H','HH',$readable_format);
$readable_format = str_replace('i','MM',$readable_format); $readable_format = str_replace('i','MM',$readable_format);
$o .= "<div class='date'><input type='text' placeholder='$readable_format' name='$id' id='$id' $input_text />"; $tpl = get_markup_template('field_input.tpl');
$o .= '</div>'; $o .= replace_macros($tpl,array(
'$field' => array($id, $label, $input_text, '', (($required) ? '*' : ''), 'placeholder="' . $readable_format . '" '),
));
// $o .= "<div class='date'><input type='text' placeholder='$readable_format' name='$id' id='$id' $input_text />";
// $o .= '</div>';
$o .= "<script type='text/javascript'>"; $o .= "<script type='text/javascript'>";
$o .= "\$(function () {var picker = \$('#$id').datetimepicker({step:5,format:'$dateformat' $minjs $maxjs $pickers $defaultdatejs}); $extra_js})"; $o .= "\$(function () {var picker = \$('#id_$id').datetimepicker({step:5,format:'$dateformat' $minjs $maxjs $pickers $defaultdatejs}); $extra_js})";
$o .= "</script>"; $o .= "</script>";
return $o; return $o;

View file

@ -561,11 +561,11 @@ function events_content(&$a) {
'$title' => t('Event details'), '$title' => t('Event details'),
'$desc' => t('Starting date and Title are required.'), '$desc' => t('Starting date and Title are required.'),
'$s_text' => t('Event Starts:') . ' <span class="required" title="' . t('Required') . '">*</span>', '$s_text' => t('Event Starts:') . ' <span class="required" title="' . t('Required') . '">*</span>',
'$s_dsel' => datetimesel($f,new DateTime(),DateTime::createFromFormat('Y',$syear+5),DateTime::createFromFormat('Y-m-d H:i',"$syear-$smonth-$sday $shour:$sminute"),'start_text',true,true,'','',true), '$s_dsel' => datetimesel($f,new DateTime(),DateTime::createFromFormat('Y',$syear+5),DateTime::createFromFormat('Y-m-d H:i',"$syear-$smonth-$sday $shour:$sminute"),t('Event Starts:'),'start_text',true,true,'','',true),
'$n_text' => t('Finish date/time is not known or not relevant'), '$n_text' => t('Finish date/time is not known or not relevant'),
'$n_checked' => $n_checked, '$n_checked' => $n_checked,
'$f_text' => t('Event Finishes:'), '$f_text' => t('Event Finishes:'),
'$f_dsel' => datetimesel($f,new DateTime(),DateTime::createFromFormat('Y',$fyear+5),DateTime::createFromFormat('Y-m-d H:i',"$fyear-$fmonth-$fday $fhour:$fminute"),'finish_text',true,true,'start_text'), '$f_dsel' => datetimesel($f,new DateTime(),DateTime::createFromFormat('Y',$fyear+5),DateTime::createFromFormat('Y-m-d H:i',"$fyear-$fmonth-$fday $fhour:$fminute"),t('Event Finishes:'),'finish_text',true,true,'start_text'),
'$a_text' => t('Adjust for viewer timezone'), '$a_text' => t('Adjust for viewer timezone'),
'$a_checked' => $a_checked, '$a_checked' => $a_checked,
'$d_text' => t('Description:'), '$d_text' => t('Description:'),
@ -574,8 +574,11 @@ function events_content(&$a) {
'$l_orig' => $l_orig, '$l_orig' => $l_orig,
'$t_text' => t('Title:') . ' <span class="required" title="' . t('Required') . '">*</span>', '$t_text' => t('Title:') . ' <span class="required" title="' . t('Required') . '">*</span>',
'$t_orig' => $t_orig, '$t_orig' => $t_orig,
'$summary' => array('summary', t('Title:'), $t_orig, '', '*'),
'$sh_text' => t('Share this event'), '$sh_text' => t('Share this event'),
'$sh_checked' => $sh_checked, '$sh_checked' => $sh_checked,
'$nofinish' => array('nofinish', t('Finish date/time is not known or not relevant'), $n_checked),
'$adjust' => array('adjust', t('Adjust for viewer timezone'), $a_checked),
'$preview' => t('Preview'), '$preview' => t('Preview'),
'$acl' => $acl, '$acl' => $acl,
'$submit' => t('Submit') '$submit' => t('Submit')

View file

@ -12,28 +12,59 @@
<input type="hidden" name="uri" value="{{$uri}}" /> <input type="hidden" name="uri" value="{{$uri}}" />
<input type="hidden" name="preview" id="event-edit-preview" value="0" /> <input type="hidden" name="preview" id="event-edit-preview" value="0" />
<div id="event-start-text">{{$s_text}}</div>
{{$s_dsel}} {{$s_dsel}}
<div id="event-finish-text">{{$f_text}}</div>
{{$f_dsel}} {{$f_dsel}}
<div id="event-datetime-break"></div> {{include file="field_checkbox.tpl" field=$nofinish}}
<input type="checkbox" name="nofinish" value="1" id="event-nofinish-checkbox" {{$n_checked}} /> <div id="event-nofinish-text">{{$n_text}}</div> {{include file="field_checkbox.tpl" field=$adjust}}
<div id="event-nofinish-break"></div> {{include file="field_input.tpl" field=$summary}}
<input type="checkbox" name="adjust" value="1" id="event-adjust-checkbox" {{$a_checked}} /> <div id="event-adjust-text">{{$a_text}}</div> <div class="form-group">
<div id="event-desc-text"><b>{{$d_text}}</b></div>
<textarea id="comment-edit-text-desc" class="form-control" name="desc" >{{$d_orig}}</textarea>
<ul id="event-desc-text-edit-bb" class="comment-edit-bb comment-icon-list nav nav-pills hidden-xs pull-left">
<li>
<a class="icon" style="cursor: pointer;" title="{{$edimg|escape:'html'}}" data-role="insert-formatting" data-comment=" " data-bbcode="img" data-id="desc">
<i class="fa fa-picture-o"></i>
</a>
</li>
<li>
<a class="icon bb-url" style="cursor: pointer;" title="{{$edurl|escape:'html'}}" data-role="insert-formatting" data-comment=" " data-bbcode="url" data-id="desc">
<i class="fa fa-link"></i>
</a>
</li>
<li>
<a class="icon bb-video" style="cursor: pointer;" title="{{$edvideo|escape:'html'}}" data-role="insert-formatting" data-comment=" " data-bbcode="video" data-id="desc">
<i class="fa fa-video-camera"></i>
</a>
</li>
<div id="event-adjust-break"></div> <li>
<a class="icon underline" style="cursor: pointer;" title="{{$eduline|escape:'html'}}" data-role="insert-formatting" data-comment=" " data-bbcode="u" data-id="desc">
<div id="event-summary-text">{{$t_text}}</div> <i class="fa fa-underline"></i>
<input type="text" id="event-summary" name="summary" value="{{$t_orig|escape:'html'}}" /> </a>
</li>
<li>
<div id="event-desc-text">{{$d_text}}</div> <a class="icon italic" style="cursor: pointer;" title="{{$editalic|escape:'html'}}" data-role="insert-formatting" data-comment=" " data-bbcode="i" data-id="desc">
<textarea id="event-desc-textarea" name="desc">{{$d_orig}}</textarea> <i class="fa fa-italic"></i>
</a>
</li>
<li>
<a class="icon bold" style="cursor: pointer;" title="{{$edbold|escape:'html'}}" data-role="insert-formatting" data-comment=" " data-bbcode="b" data-id="desc">
<i class="fa fa-bold"></i>
</a>
</li>
<li>
<a class="icon quote" style="cursor: pointer;" title="{{$edquote|escape:'html'}}" data-role="insert-formatting" data-comment=" " data-bbcode="quote" data-id="desc">
<i class="fa fa-quote-left"></i>
</a>
</li>
</ul>
<div class="clear"></div>
</div>
<div id="event-location-text">{{$l_text}}</div> <div id="event-location-text">{{$l_text}}</div>

View file

@ -1,7 +1,7 @@
<div class="generic-page-wrapper"> <div class="generic-page-wrapper">
{{$tabs}} {{$tabs}}
{{include file="section_title.tpl" title=$title}} {{include file="section_title.tpl" title=$title}}
<div id="new-event-link"><a href="{{$new_event.0}}" >{{$new_event.1}}</a></div>
<div id="new-event-link"><a onclick="addToModal('{{$new_event.0}}')" >{{$new_event.1}}</a></div> <div id="new-event-link"><a onclick="addToModal('{{$new_event.0}}')" >{{$new_event.1}}</a></div>
<div id="fc-header"> <div id="fc-header">