%3 ::xowiki::formfield::event ::xowiki::formfield::event convert_to_internal get_compound_value initialize pretty_value ::xowiki::formfield::CalendarField ::xowiki::formfield::CalendarField update_calendar ::xowiki::formfield::event->::xowiki::formfield::CalendarField ::xowiki::formfield::time_span ::xowiki::formfield::time_span initialize ::xowiki::formfield::time_span->::xowiki::formfield::CalendarField ::xowiki::formfield::CompoundField ::xowiki::formfield::CompoundField add_component add_statistics check=compound convert_to_external convert_to_internal create_components exists_named_sub_component generate_fieldnames get_component get_compound_value get_named_sub_component get_named_sub_component_value has_instance_variable leaf_components make_correct named_sub_components object pretty_value render_input reset_on_validation_error same_value set_compound_value set_disabled set_is_repeat_template specs_unmodified validate value ::xowiki::formfield::CalendarField->::xowiki::formfield::CompoundField ::xowiki::formfield::FormField ::xowiki::formfield::FormField ::xowiki::formfield::CompoundField->::xowiki::formfield::FormField

Class ::xowiki::formfield::event

::xowiki::formfield::event[i] create ...

Class Relations

  • class: ::xotcl::Class[i]
  • superclass: ::xowiki::formfield::CalendarField[i]
::xotcl::Class create ::xowiki::formfield::event \
     -superclass ::xowiki::formfield::CalendarField

Methods (to be applied on instances)

  • convert_to_internal (scripted)

    if {[info exists :calendar]} {
      #
      # Check, if the calendar package is available
      #
      if {[info commands ::calendar::item::new] eq ""} {
        error "the calendar package is not available"
      }
    
      #
      # Check, if the calendar_id can be determined
      #
      set calendar_id ""
      if {[nsf::is integer ${:calendar}]} {
        set calendar_id ${:calendar}
        if {[calendar::name $calendar_id] eq ""} {
          set calendar_id ""
        }
      }
      if {$calendar_id eq ""} {
        error "calendar '${:calendar} has no valid calendar_id"
      }
    
      #
      # Get the values for the calendar item
      #
      set dtstart_val [[:get_component dtstart] value]
      set dtend_val   [[:get_component dtend]   value]
      set title_val   [[:get_component title]   value]
      set title_val   [[:get_component title]   value]
      set summary_val [[:get_component summary] value]
      set cal_item_id [[:get_component cal_item_id] value]
    
      #
      # Check, if the cal_item_id is valid. If not, ignore it
      #
      if {$cal_item_id ne ""} {
        # if the object does not exist, it was probably deleted manually
        if {![acs_object::object_p -id $cal_item_id]} {
          set cal_item_id ""
        } else {
          acs_object::get -object_id $cal_item_id -array row
          if {$row(object_type) ne "cal_item"} {
            ns_log warning "event: the associated entry $cal_item_id is not a calendar item, ignore the old association"
            set cal_item_id ""
          }
        }
      }
    
      #
      # update values via transaction queue
      #
      set queue ::__xowiki__transaction_queue([${:object} item_id])
      lappend $queue [list [self] update_calendar -cal_item_id $cal_item_id -calendar_id $calendar_id  -start $dtstart_val -end $dtend_val -name $title_val -description $summary_val]
    }
    
    next
  • get_compound_value (scripted)

    if {![info exists :__initialized]} {
      return ""
    }
    set dtstart  [:get_component dtstart]
    set dtend    [:get_component dtend]
    
    if {!${:multiday}} {
      # If the event is not a multi-day-event, the end_day is not
      # given by the dtend widget, but is taken from dtstart.
      set end_day  [lindex [$dtstart value] 0]
      set end_time [lindex [$dtend value] 1]
      $dtend value "$end_day $end_time"
      #:msg "[$dtend name] set to '$end_day $end_time' ==> $dtend, [$dtend value]"
    }
    next
  • initialize (scripted)

    #:log "event initialize [info exists :__initialized], multi=${:multiday} state=${:__state}"
    if {${:__state} ne "after_specs"} return
    set :widget_type event
    if {${:multiday}} {
      set dtend_format DD_MONTH_YYYY_#xowiki.event-hour_prefix#_HH24_MI
      set dtend_display_format %Q_%X
    } else {
      set dtend_format HH24_MI
      set dtend_display_format %X
    }
    :create_components [subst {
      {title {text,label=#xowiki.event-title_of_event#}}
      {summary {richtext,height=150px,label=#xowiki.event-summary_of_event#}}
      {dtstart {date,required,format=DD_MONTH_YYYY_#xowiki.event-hourprefix#_HH24_MI,
        default=now,label=#xowiki.event-start_of_event#,display_format=%Q_%X}}
      {dtend   date,format=$dtend_format,default=now,label=#xowiki.event-end_of_event#,display_format=$dtend_display_format}
      {location text,label=#xowiki.event-location#}
      {cal_item_id hidden}
    }]
    set :__initialized 1
  • pretty_value (scripted)

    #array set {} [:value]
    set dtstart [:get_component dtstart]
    set dtstart_val [$dtstart value]
    set dtstart_iso [::xo::ical clock_to_iso [clock scan $dtstart_val]]
    set dtstart_pretty [$dtstart pretty_value $dtstart_val]
    
    set dtend [:get_component dtend]
    set dtend_val [$dtend value]
    set dtend_txt ""
    if {$dtend_val ne ""} {
      set dtend_iso [::xo::ical clock_to_iso [clock scan $dtend_val]]
      set dtend_txt " - <time class='dt-end' title='$dtend_iso'>[$dtend pretty_value $dtend_val]</time>"
    }
    
    set time_label [:time_label]
    if {[regexp {^#([a-zA-Z0-9_:-]+\.[a-zA-Z0-9_:-]+)#$} $time_label _ msg_key]} {
      set time_label [lang::message::lookup [:locale] $msg_key]
    }
    
    set title_val   [[:get_component title] value]
    if {$title_val eq ""} {
      set title_val [${:object} property _title]
    }
    set summary_val [[:get_component summary] value]
    
    set location [:get_component location]
    set location_val [$location value]
    set location_txt ""
    if {$location_val ne ""} {
      set location_label [$location label]
      if {[regexp {^#(.+)#$} $location_label _ msg_key]} {
        set location_label [lang::message::lookup [:locale] $msg_key]
      }
      set location_txt "<tr><td>$location_label:</td><td><span class='p-location'>$location_val</span></td></tr>"
    }
    
    append result \n "<div class='h-event'>" \n "<h1 class=p-name>$title_val</h1>" \n "<p class='p-summary'>$summary_val</p>" "<br> " \n "<table>" \n "<tr><td>$time_label:</td><td><time class='dt-start' datetime='$dtstart_iso'>$dtstart_pretty</time> $dtend_txt</td></tr>" \n $location_txt \n "</table>" \n "</div>" \n
    return $result