%3 ::xowiki::File ::xowiki::File build_name demarshall full_file_name html_content marshall pretty_name render_content render_icon search_render www-download ::xowiki::Page ::xowiki::Page → container_already_rendered → find_slot → get_tags → import → quoted_html_content → save_tags __debug_known_field_names add_computed_instance_attributes adp_subst anchor anchor_parent_id build_instance_attribute_map build_name can_be_linked can_contain can_link can_save category_export category_import changed_redirect_url check_adp_include_path check_unresolved_references condition=is_folder_page condition=match condition=regexp content_header_append content_header_get copy_content_vars create_form_field create_form_fields create_form_fields_from_form_constraints create_form_page_instance create_link create_raw_form_field css_class_name default_instance_attributes demarshall detail_link div edit_set_default_values edit_set_file_selector_folder error_during_render error_in_includelet evaluate_form_field_condition exists_form_parameter exists_query_parameter field_names find_slot footer form_field_exists form_field_flush_cache form_field_index form_parameter get_anchor_and_query get_content get_description get_folder get_form_data get_html_from_content get_ids_for_bulk_actions get_instance_attributes get_nls_language_from_lang get_parent_object get_property_from_link_page get_query_parameter_return_url get_rich_text_spec get_target_from_link_page htmlFooter include include_content initialize_loaded_object instantiate_includelet is_folder_page is_form is_link_page is_new_entry is_unprefixed item_ref lang lookup_cached_form_field lookup_form_field map_categories map_party marshall mutual_overwrite_occurred new_link normalize_internal_link_name notification_detail_link notification_notify notification_render notification_subject physical_item_id physical_package_id physical_parent_id pretty_link pretty_name query_parameter record_last_visited references references_update regsub_eval rename render render_content render_icon render_includelet reset_resolve_context resolve_included_page_name return_redirect_without_params reverse_map_party reverse_map_party_attribute save save_data save_new search_render self_link_ids serialize_relocatable set_content set_resolve_context show_fields stats_record_count stats_record_detail substitute_markup translate unescape unset_temporary_instance_variables update update_publish_status validate=form_constraints validate=form_input_fields validate=name validate=page_order www-autosave-attribute www-bulk-delete www-clipboard-add www-clipboard-clear www-clipboard-content www-clipboard-copy www-clipboard-export www-create-new www-create-or-use www-csv-dump www-delete www-delete-revision www-diff www-duplicate www-edit www-list www-make-live-revision www-popular-tags www-revisions www-save-attributes www-save-tags www-toggle-publish-status www-validate-attribute www-view ::xowiki::File->::xowiki::Page ::xowiki::PageTemplate ::xowiki::PageTemplate → count_usages count_usages update www-delete ::xowiki::PageTemplate->::xowiki::Page ::xowiki::PageInstance ::xowiki::PageInstance → get_list_from_form_constraints → get_short_spec_from_form_constraints adp_subst count_usages create_raw_form_field demarshall field_names_from_form_constraints get_field_label get_field_type get_form get_form_constraints get_from_template get_short_spec get_template_object render_content template_vars update widget_spec_from_folder_object www-use-template ::xowiki::PageInstance->::xowiki::Page ::xowiki::PlainPage ::xowiki::PlainPage render_content set_content substitute_markup unescape ::xowiki::PlainPage->::xowiki::Page ::xo::db::CrItem ::xo::db::CrItem ::xowiki::Page->::xo::db::CrItem ::xowiki::FormPage ::xowiki::FormPage → compute_filter_clauses → fetch_object → filter_expression → get_all_children → get_folder_children → get_form_entries → get_super_folders → get_table_form_fields → sql_value action_url adp_subst combine_data_and_form_field_default compute_link_properties condition=in_state condition=is_true configure_page=regression_test create_category_fields create_form_field create_form_fields create_form_fields_from_names demarshall exists_property extra_html_fields field_names field_names_from_form footer form_field_as_html form_fields_sanity_check get_anon_instances get_form_constraints get_form_value get_parameter get_property get_value group_assign group_require hstore_attributes include_header_info initialize initialize_loaded_object is_folder_page is_form is_link_page langstring lappend_property load_values_into_form_fields map_value map_values marshall new_link notification_render post_process_dom_tree post_process_form_fields pretty_name property render_content render_form_action_buttons render_icon render_thumbnails reverse_map_value reverse_map_values setCSSDefaults set_content set_form_data set_form_value set_live_revision set_property set_publish_status update update_attribute_from_slot update_item_index update_langstring_property www-edit www-file-upload www-toggle-modebutton ::xowiki::FormPage->::xowiki::PageInstance

Class ::xowiki::PageInstance

::xowiki::PageInstance[i] create ...

Class Relations

  • class: ::xo::db::CrClass[i]
  • superclass: ::xowiki::Page[i]
  • subclass: ::xowiki::FormPage[i]
::xo::db::CrClass create ::xowiki::PageInstance \
     -superclass ::xowiki::Page

Methods (to be applied on the object)

  • get_list_from_form_constraints (scripted)

    set spec [::xowiki::PageInstance get_short_spec_from_form_constraints  -name $name  -form_constraints $form_constraints]
    set result [list]
    foreach spec [split $spec ,] {
      if {[regexp {^([^=]+)=(.*)$} $spec _ attr value]} {
        lappend result $attr $value
      } else {
        :log "can't parse $spec in attribute and value; ignoring"
      }
    }
    return $result
  • get_short_spec_from_form_constraints (scripted)

    #
    # For the time being we cache the parsed form_constraints. Without
    # caching, the proc takes 87 microseconds, with chaching, it is
    # significantly faster.
    #
    # via ns_cache {6.153537846215379 microseconds per iteration}
    # via nsv {3.865795920407959 microseconds per iteration}
    #
    set varname ::__xo_[ns_md5 $form_constraints]
    set dict ""
    
    if {![nsv_get parsed_fcs $varname dict]} {
      #
      # Not parsed yet
      #
      foreach name_and_spec $form_constraints {
        set p [string first : $name_and_spec]
        if {$p > -1} {
          dict set dict  [string range $name_and_spec 0 $p-1]  [string range $name_and_spec $p+1 end]
        } else {
          ad_log warning "get_short_spec_from_form_constraints: name_and_spec <$name_and_spec> is invalid"
        }
      }
      nsv_set parsed_fcs $varname $dict
    }
    if {[dict exists $dict $name]} {
      return [dict get $dict $name]
    }
    return ""

Methods (to be applied on instances)

  • adp_subst (scripted)

    # initialize template variables (in case, new variables are added to template)
    # and add extra variables from instance attributes
    set __ia [dict merge [:template_vars $content${:instance_attributes}]
    
    foreach var [dict keys $__ia] {
      #:log "-- set $var [list $__ia($var)]"
      # TODO: just for the lookup, whether a field is a richt text field,
      # there should be a more efficient and easier way...
      if {[string match "richtext*" [:get_field_type $var text]]} {
        # ignore the text/html info from htmlarea
        set value [lindex [dict get $__ia $var] 0]
      } else {
        set value [dict get $__ia $var]
      }
      # the value might not be from the form attributes (e.g. title), don't clear it.
      if {$value eq "" && [info exists :$var]} continue
      set :$var [:get_field_label $var $value]
    }
    next
  • count_usages (scripted)

    return [::xowiki::PageTemplate count_usages -package_id $package_id  -parent_id $parent_id -item_id ${:item_id} -publish_status $publish_status]
  • create_raw_form_field (scripted)

    #
    # For workflows, we do not want to get the form constraints of the
    # page itself (i.e. the property of the generic workflow form) but
    # just the configured properties. Otherwise, we get for a wrong
    # results for e.g. "{{form-usages -form de:Thread.wf ...}}"  which
    # picks up the label for the _title from the generic Workflow.
    # So, when we have configured properties, we use it, use the
    # primitive one just on despair.  Not sure, what the best solution
    # is,... maybe an additional flag.
    #
    if { $omit_field_name_spec} {
      set short_spec ""
    } else {
      #
      # Get for the current page (self) the form-constraints and
      # return the spec for the specifiled name.
      #
      set short_spec [:get_short_spec -form_constraints $form_constraints $name]
      #:log "$name get_short_spec returns <$short_spec>"
    }
    
    #:log "$name '$name', spec '$spec' short_spec '$short_spec', slot=$slot"
    set spec_list [list]
    
    if {$spec ne ""}       {lappend spec_list $spec}
    if {$short_spec ne ""} {lappend spec_list $short_spec}
    #:log "$name: composed spec '[join $spec_list ,]'"
    
    set f [next  -name $name  -slot $slot  -spec [join $spec_list ,]  -configuration $configuration  -nls_language $nls_language  ]
    #:log "created form-field '$name' $f [$f info class] validator=[$f validator] p=[$f info precedence]"
    return $f
  • demarshall (scripted)

    # some older versions do not have anon_instances and no slots
    if {![info exists :anon_instances]} {
      set :anon_instances "f"
    }
    next
  • field_names_from_form_constraints (scripted)

    set form_constraints [:get_form_constraints]
    set result {}
    foreach name_and_spec $form_constraints {
      regexp {^([^:]+):} $name_and_spec _ name
      if {[string range $name 0 0] eq "@"} {
        # return no aggregated (pseudo) form field names
        continue
      }
      lappend result $name
    }
    return $result
  • get_field_label (scripted)

    set short_spec [:get_short_spec $name]
    if {$short_spec ne ""} {
      set f [::xowiki::formfield::FormField new -volatile -name $name -spec $short_spec]
      if {![$f exists show_raw_value]} {
        set value [$f field_value $value]
      }
    }
    return $value
  • get_field_type (scripted)

    #:log "--w"
    # get widget spec from folder (highest priority)
    set spec [:widget_spec_from_folder_object $name [${:page_template} set name]]
    if {$spec ne ""} {
      return $spec
    }
    # get widget spec from attribute definition
    set f [:create_raw_form_field -name $name -slot [:find_slot $name]]
    if {$f ne ""} {
      return [$f asWidgetSpec]
    }
    # use default widget spec
    return $default_spec
  • get_form (scripted)

    # get the (HTML) form of the ::xowiki::PageTemplates/::xowiki::Form
    return [:get_html_from_content [:get_from_template form]]
  • get_form_constraints (scripted)

    # PageInstances have no form_constraints
    return ""
  • get_from_template (scripted, public)

     <instance of xowiki::PageInstance[i]> get_from_template var \
        [ default ]

    Get a property from the parent object (template). The parent object might by either an ::xowiki::Form or an ::xowiki::FormPage

    Parameters:
    var
    default (optional)
    Returns:
    either the property value or a default value

    Partial Call Graph (max 5 caller/called nodes):
    %3 test_create_form_with_form_instance create_form_with_form_instance (test xowiki) xowiki::PageInstance instproc get_from_template xowiki::PageInstance instproc get_from_template test_create_form_with_form_instance->xowiki::PageInstance instproc get_from_template

    Testcases:
    create_form_with_form_instance
    set form_obj [:get_template_object]
    
    #:msg "get $var from template form_obj=$form_obj [$form_obj info class]"
    
    # The resulting page should be either a Form (PageTemplate) or
    # a FormPage (PageInstance)
    #
    #:msg "parent of self ${:name} is [$form_obj name] type [$form_obj info class]"
    #
    # If it is as well a PageInstance, we find the information in the
    # properties of this page. Note that we cannot distinguish here between
    # intrinsic (starting with _) and extension variables, since get_from
    # template does not know about the logic with "_" (just "property" does).
    #
    if {[$form_obj istype ::xowiki::PageInstance]} {
      #:msg "returning property $var from parent formpage $form_obj => '[$form_obj property $var $default]'"
      return [$form_obj property $var $default]
    }
    
    #
    # .... otherwise, it should be an instance variable ....
    #
    if {[$form_obj exists $var]} {
      #:msg "returning parent instvar [$form_obj set $var]"
      return [$form_obj set $var]
    }
    #
    # .... or, we try to resolve it against a local property.
    #
    # This case is currently needed in the workflow case, where
    # e.g. anon_instances is tried to be fetched from the first form,
    # which might not contain it, if e.g. the first form is a plain
    # wiki page.
    #
    #:msg "resolve local property $var=>[:exists_property $var]"
    if {[:istype ::xowiki::FormPage] && [:exists_property $var]} {
      #:msg "returning local property [:property $var]"
      return [:property $var]
    }
    #
    # if everything fails, return the default.
    #
    #:msg "returning the default <$default>, parent is of type [$form_obj info class]"
    return $default
  • get_short_spec (scripted)

    #
    # In case, the form_constraints are provided, get the short-spec
    # from there, otherwise compute form_constraints via
    # method "get_form_constraints".
    #
    if {$form_constraints eq ""} {
      set form_constraints [:get_form_constraints]
    }
    if {$form_constraints ne ""} {
      set s [::xowiki::PageInstance get_short_spec_from_form_constraints  -name $name -form_constraints $form_constraints]
      #:msg "get_short_spec $name c=$form_constraints => '$s'"
      return $s
    }
    return ""
  • get_template_object (scripted)

    set id ${:page_template}
    if {![nsf::is object ::$id]} {
      ::xo::db::CrClass get_instance_from_db -item_id $id
    }
    return ::$id
  • instance_attributes (setter)

  • mime_type (setter)

  • page_instance_id (setter)

  • page_template (setter)

  • render_content (scripted)

    set html [:get_html_from_content [:get_from_template text]]
    set html [:adp_subst $html]
    #
    # Transitional code, should be removed after the release of
    # OpenACS 5.10: In case we have a folder instances without the
    # "description" field set, and we use the new folder.form, and the
    # update script was not yet executed, folders might appear as
    # empty. In these cases, call child-resources manually.
    #
    if {$html eq "" && [:is_folder_page]} {
      ad_log_deprecated "folder page without a content" "[:item_id] '${:name}'"
      set html [:include child-resources]
    }
    
    return "<div class='[${:page_template} css_class_name -margin_form false]'>[:substitute_markup $html]</div>"
  • template_vars (scripted)

    set result [list]
    foreach {_ _ v} [regexp -inline -all [template::adp_variable_regexp$content] {
      lappend result $v ""
    }
    
    return $result
  • update (scripted)

    ::xo::dc transaction {
      next
      :instvar object_id page_template instance_attributes
      ::xo::dc dml update_xowiki_page_instance {update xowiki_page_instance
        set page_template = :page_template,instance_attributes = :instance_attributes where page_instance_id = :object_id
      }
    }
  • widget_spec_from_folder_object (scripted)

    # get the widget field specifications from the payload of the folder object
    # for a field with a specified name in a specified page template
    foreach {s widget_spec} [::${:package_id} get_parameter -check_query_parameter false WidgetSpecs] {
      lassign [split $s ,] template_name var_name
      #ns_log notice "--w template_name $template_name, given '$given_template_name' varname=$var_name name=$name"
      if {([string match $template_name $given_template_name] || $given_template_name eq "") &&
          [string match $var_name $name]} {
        #ns_log notice "--w using $widget_spec for $name"
        return $widget_spec
      }
    }
    return ""
  • www-use-template (scripted, public)

     <instance of xowiki::PageInstance[i]> www-use-template

    This web-callable method can be used to change the "template" of a PageInstance. The caller provides the "form" as query parameter which should be used in future for handling the instance parameters of the PageInstance. This method can be as well be used for changing the associated workflow of a workflow instance.

    Partial Call Graph (max 5 caller/called nodes):
    %3 ad_return_url ad_return_url (public) xowiki::PageInstance instproc www-use-template xowiki::PageInstance instproc www-use-template xowiki::PageInstance instproc www-use-template->ad_return_url

    Testcases:
    No testcase defined.
    set formName [:query_parameter "form" ""]
    if {$formName eq ""} {
      error "no form specified"
    }
    ::${:package_id} get_lang_and_name -default_lang [::xo::cc lang] -path $formName lang stripped_url
    set d [::${:package_id} item_ref -default_lang $lang -parent_id [::${:package_id} folder_id] $formName]
    set item_id [dict get $d item_id]
    if {$item_id == 0} {
      error "cannot lookup page $formName"
    }
    ::xo::db::CrClass get_instance_from_db -item_id $item_id
    if {![nsf::is object ::$item_id]
        || "::xowiki::PageTemplate" ni [::$item_id info precedence]} {
      error "OK $formName is not suited to be used as template. Should be a Form!"
    }
    if {${:page_template} == $item_id} {
      :msg "old page_template $item_id is already the same as the new one"
    } else {
      set msg "change template_id ${:page_template} to $item_id"
      :page_template $item_id
      :save
      #:msg "ok $msg"
    }
    ::${:package_id} returnredirect [ad_return_url]

Variables

::xowiki::PageInstance set __default_metaclass ::xotcl::Class
::xowiki::PageInstance set __default_superclass ::xotcl::Object
::xowiki::PageInstance set abstract_p f
::xowiki::PageInstance set auto_save false
::xowiki::PageInstance array set db_constraints {page_template {{references \
       {cr_items(item_id) DEFERRABLE INITIALLY DEFERRED}} {references \
       {cr_items(item_id) DEFERRABLE INITIALLY DEFERRED}}} instance_attributes {{default {}} \
       {default {}}}}
::xowiki::PageInstance array set db_slot \
       {page_template ::xowiki::PageInstance::slot::page_template page_order \
       ::xowiki::Page::slot::page_order creator ::xowiki::Page::slot::creator page_id \
       ::xowiki::Page::slot::page_id creation_date ::xo::db::Object::slot::creation_date \
       instance_attributes ::xowiki::PageInstance::slot::instance_attributes creation_user \
       ::xo::db::Object::slot::creation_user object_id ::xo::db::Object::slot::object_id description \
       ::xowiki::Page::slot::description text ::xowiki::Page::slot::text creation_ip \
       ::xo::db::Object::slot::creation_ip package_id ::xo::db::Object::slot::package_id \
       object_title ::xo::db::Object::slot::object_title nls_language \
       ::xo::db::CrItem::slot::nls_language name ::xo::db::CrItem::slot::name mime_type \
       ::xo::db::CrItem::slot::mime_type context_id ::xo::db::Object::slot::context_id \
       security_inherit_p ::xo::db::Object::slot::security_inherit_p title \
       ::xowiki::Page::slot::title revision_id ::xo::db::CrItem::slot::revision_id item_id \
       ::xo::db::CrItem::slot::item_id last_modified ::xo::db::Object::slot::last_modified \
       modifying_user ::xo::db::Object::slot::modifying_user publish_date \
       ::xowiki::Page::slot::publish_date page_instance_id \
       ::xowiki::PageInstance::slot::page_instance_id modifying_ip \
       ::xo::db::Object::slot::modifying_ip}
::xowiki::PageInstance set edit_form ::xowiki::PageInstanceEditForm
::xowiki::PageInstance set folder_id -100
::xowiki::PageInstance set form ::xowiki::PageInstanceForm
::xowiki::PageInstance set id_column page_instance_id
::xowiki::PageInstance array set long_text_slots \
       {instance_attributes ::xowiki::PageInstance::slot::instance_attributes}
::xowiki::PageInstance set mime_type text/plain
::xowiki::PageInstance set name_method {}
::xowiki::PageInstance set non_cached_instance_var_patterns __*
::xowiki::PageInstance set object_type ::xowiki::PageInstance
::xowiki::PageInstance set object_type_key 00000000000011110001100100000010
::xowiki::PageInstance set pretty_name {#xowiki.PageInstance_pretty_name#}
::xowiki::PageInstance set pretty_plural {#xowiki.PageInstance_pretty_plural#}
::xowiki::PageInstance set security_inherit_p t
::xowiki::PageInstance set sql_package_name ::xowiki::PageInstance
::xowiki::PageInstance set storage_type text
::xowiki::PageInstance set supertype content_revision
::xowiki::PageInstance set table_name xowiki_page_instance
::xowiki::PageInstance set with_table true