xotcl.wu-wien.ac.at
Begin main content
Methods: Source: Variables:
[All Methods | Documented Methods | Hide Methods] [Display Source | Hide Source] [Show Variables | Hide Variables]

::xo::db::CrClass[i] ::xowiki::PageInstance

Class Hierarchy of ::xowiki::PageInstance

  • ::xotcl::Object[i]
    Meta-class:
    ::xotcl::Class[i]
    Methods for instances:
    __api_make_doc, __api_make_forward_doc, __timediff, abstract, ad_doc, ad_forward, ad_proc, appendC, arrayC, asHTML, autonameC, check, classC, cleanupC, configureC, containsC, copyC, db_0or1rowC, db_1rowC, debug, defaultmethodC, destroyC, destroy_on_cleanup, ds, evalC, existsC, extractConfigureArg, filterC, filterguardC, filtersearch, forward, hasclass, incrC, infoC, init, instvarC, invarC, isclass, ismetaclass, ismixin, isobject, istype, lappendC, log, method, mixinC, mixinguardC, moveC, msg, noinitC, objectparameter, parametercmdC, proc, procsearch, qn, requireNamespaceC, residualargsC, self, serialize, setC, set_instance_vars_defaults, show-object, substC, traceC, unknown, unsetC, uplevelC, upvarC, volatileC, vwait
    Methods to be applied on the class (in addition to the methods provided by the meta-class):
    getExitHandler, setExitHandler, unsetExitHandler
    • ::xo::db::Object[i]
      Meta-class:
      ::xo::db::Class[i]
      Methods for instances:
      db_1row, delete, initialize_loaded_object, insert, object_idC, object_titleC, save, save_new
      Methods to be applied on the class:
      Methods provided by the meta-class
      • ::xo::db::CrItem[i]
        Meta-class:
        ::xo::db::CrClass[i]
        Parameter for instances:
        package_id, parent_id (default "-100"), publish_status (default "ready")
        Methods for instances:
        current_user_id, delete, descriptionC, fix_content, initialize_loaded_object, item_idC, mime_typeC, nameC, nls_languageC, privilege=creator, publish_dateC, rename, revision_idC, revisions, save, save_new, set_live_revision, textC, titleC, update_attribute_from_slot, update_content, update_revision
        Methods to be applied on the class:
        Methods provided by the meta-class
        • ::xowiki::Page[i]
          Meta-class:
          ::xo::db::CrClass[i]
          Parameter for instances:
          absolute_links (default "0"), do_substitutions (default "1"), render_adp (default "1")
          Methods for instances:
          adp_subst, anchor, build_instance_attribute_map, build_name, category_export, category_import, check_adp_include_path, clipboard-add, clipboard-clear, clipboard-content, clipboard-copy, clipboard-export, condition=match, condition=regexp, copy_content_vars, create-new, create-or-use, create_form_field, create_form_fields, create_form_fields_from_form_constraints, create_form_page_instance, create_link, create_raw_form_field, creation_userC, creatorC, css_class_name, csv-dump, default_instance_attributes, delete, delete-revision, demarshall, descriptionC, detail_link, diff, div, edit, edit_set_default_values, edit_set_file_selector_folder, error_during_render, error_in_includelet, exists_form_parameterC, exists_query_parameterC, field_names, find_slot, footer, form_field_index, form_parameterC, get_anchor_and_query, get_content, get_description, get_folder, get_form_data, get_html_from_content, get_instance_attributes, get_nls_language_from_lang, get_property_from_link_page, 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, item_refC, lang, last_modifiedC, list, lookup_cached_form_field, lookup_form_field, make-live-revision, map_categories, map_party, marshall, mime_typeC, mutual_overwrite_occurred, nameC, new_link, nls_languageC, normalize_internal_link_name, page_idC, page_orderC, physical_package_id, physical_parent_id, popular-tags, pretty_link, pretty_name, publish_dateC, query_parameterC, record_last_visited, references_update, regsub_eval, render, render_content, render_icon, render_includelet, reset_resolve_context, resolve_included_page_name, reverse_map_party, reverse_map_party_attribute, revisions, save, save-attributes, save-tags, save_data, save_new, search_render, set_content, set_resolve_context, show_fields, substitute_markup, textC, titleC, translate, unescape, unset_temporary_instance_variables, validate-attribute, validate=form_constraints, validate=name, validate=page_order, view
          Methods to be applied on the class (in addition to the methods provided by the meta-class):
          container_already_rendered, find_slot, get_tags, import, quoted_html_content, save_tags
          • ::xowiki::PageInstance[i]
            Meta-class:
            ::xo::db::CrClass[i]
            Methods for instances:
            adp_subst, count_usages, create_raw_form_field, demarshall, get_field_label, get_field_type, get_form, get_form_constraints, get_from_template, get_short_spec, get_template_object, instance_attributesC, mime_typeC, page_instance_idC, page_templateC, render_content, template_vars, use-template, widget_spec_from_folder_object
            Methods to be applied on the class (in addition to the methods provided by the meta-class):
            get_list_from_form_constraints, get_short_spec_from_form_constraints

Class Relations

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

Methods

  • proc get_list_from_form_constraints

    ::993022 proc get_list_from_form_constraints {-name -form_constraints} {
        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 {
            my log "can't parse $spec in attribute and value; ignoring"
          }
        }
        return $result
      }
    
  • proc get_short_spec_from_form_constraints

    ::993022 proc get_short_spec_from_form_constraints {-name -form_constraints} {
        # For the time being we cache the form_constraints per request as a global
        # variable, which is reclaimed at the end of the connection. 
        #
        # We have to take care, that the variable name does not contain namespace-prefixes
        regsub -all :: $form_constraints ":_:_" var_name_suffix
        
        set varname ::xowiki_$var_name_suffix
        if {![info exists $varname]} {
          foreach name_and_spec $form_constraints {
            regexp {^([^:]+):(.*)$} $name_and_spec _ spec_name short_spec
            set ${varname}($spec_name) $short_spec
          }
        }
        if {[info exists ${varname}($name)]} {
          return [set ${varname}($name)]
        }
        return ""
      }
    
  • instproc adp_subst

    ::993022 instproc adp_subst content {
        # initialize template variables (in case, new variables are added to template)
        array set __ia [my template_vars $content]
        # add extra variables as instance attributes
        array set __ia [my set instance_attributes]
    
        foreach var [array names __ia] {
          #my 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*" [my get_field_type $var text]]} {
            # ignore the text/html info from htmlarea
    	set value [lindex $__ia($var) 0]
          } else {
    	set value $__ia($var)
          }
          # the value might not be from the form attributes (e.g. title), don't clear it.
          if {$value eq "" && [my exists $var]} continue
          my set $var [my get_field_label $var $value]
        }
        next
      }
    
  • instproc count_usages

    ::993022 instproc count_usages {{-package_id 0} {-parent_id:integer 0} {-publish_status ready}} {
        return [::xowiki::PageTemplate count_usages -package_id $package_id  -parent_id $parent_id -item_id [my item_id] -publish_status $publish_status]
      }
    
  • instproc create_raw_form_field

    ::993022 instproc create_raw_form_field {-name {-slot ""} {-spec ""} {-configuration ""}} {
        set short_spec [my get_short_spec $name]
        #my msg "create form-field '$name', 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}
        #my msg "$name: short_spec '$short_spec', spec_list 1 = '[join $spec_list ,]'"
        set f [next -name $name -slot $slot -spec [join $spec_list ,] -configuration $configuration]
        #my msg "created form-field '$name' $f [$f info class] validator=[$f validator]" ;#p=[$f info precedence] 
        return $f
      }
    
  • instproc demarshall

    ::993022 instproc demarshall args {
        # some older versions do not have anon_instances and no slots
        if {![my exists anon_instances]} {
          my set anon_instances "f"
        }
        next
      }
    
  • instproc get_field_label

    ::993022 instproc get_field_label {name value} {
        set short_spec [my 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
      }
    
  • instproc get_field_type

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

    ::993022 instproc get_form {} {
        # get the (HTML) form of the ::xowiki::PageTemplates/::xowiki::Form
        return [my get_html_from_content [my get_from_template form]]
      }
    
  • instproc get_form_constraints

    ::993022 instproc get_form_constraints {{-trylocal false}} {
        # PageInstances have no form_constraints
        return ""
      }
    
  • instproc get_from_template (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
    ::993022 instproc get_from_template {var {default {}}} {
        set form_obj [my get_template_object]
        #my 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)
        #
        #my msg "parent of self [my 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]} {
          #my 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]} {
          #my 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 catched from the first form,
        # which might not contain it, if e.g. the first form is a plain
        # wiki page.
        #
        #my msg "resolve local property $var=>[my exists_property $var]"
        if {[my istype ::xowiki::FormPage] && [my exists_property $var]} {
          #my msg "returning local property [my property $var]"
          return [my property $var]
        }
        #
        # if everything fails, return the default.
        #
        #my msg "returning the default <$default>, parent is of type [$form_obj info class]"
        return $default
      }
    
  • instproc get_short_spec

    ::993022 instproc get_short_spec name {
        my instvar page_template
        #set form_constraints [my get_from_template form_constraints]
        set form_constraints [my get_form_constraints]
        #my msg "fc of [self] [my name] = $form_constraints"
        if {$form_constraints ne ""} {
          set s [::xowiki::PageInstance get_short_spec_from_form_constraints  -name $name -form_constraints $form_constraints]
          #my msg "get_short_spec $name c=$form_constraints => '$s'"
          return $s
        }
        return ""
      }
    
  • instproc get_template_object

    ::993022 instproc get_template_object {} {
        set id [my page_template]
        if {![my isobject ::$id]} {
          ::xo::db::CrClass get_instance_from_db -item_id $id
        }
        return ::$id
      }
    
  • instproc render_content

    ::993022 instproc render_content {} {
        set html [my get_html_from_content [my get_from_template text]]
        set html [my adp_subst $html]
        return "<div class='[[my page_template] css_class_name -margin_form false]'>[my substitute_markup $html]</div>"
      }
    
  • instproc template_vars

    ::993022 instproc template_vars content {
        set result [list]
        foreach {_ _ v} [regexp -inline -all [template::adp_variable_regexp] $content] {
          lappend result $v ""
        }
        return $result
      }
    
  • instproc use-template

    ::993022 instproc use-template {} {
        my instvar package_id
        set formName [my 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
        array set "" [$package_id item_ref -default_lang $lang -parent_id [$package_id folder_id] $formName]
        if {$(item_id) == 0} { error "cannot lookup page $formName" }
        ::xo::db::CrClass get_instance_from_db -item_id $(item_id)
        if {[info command ::$(item_id)] eq "" 
    	|| "::xowiki::PageTemplate" ni [$(item_id) info precedence]} {
          error "OK $formName is not suited to be used as template. Should be a Form!"
        }
        if {[my page_template] == $(item_id)} {
          my msg "old page_template $(item_id) is already the same as the new one"
        } else {
          set msg "change template_id [my page_template] to $(item_id)"
          my page_template $(item_id)
          my save
          my msg "ok $msg"
        }
        $package_id returnredirect [::xo::cc url]
      }
    
  • instproc widget_spec_from_folder_object

    ::993022 instproc widget_spec_from_folder_object {name given_template_name} {
        # get the widget field specifications from the payload of the folder object
        # for a field with a specified name in a specified page template
        my instvar package_id
        foreach {s widget_spec} [$package_id get_parameter WidgetSpecs] {
          foreach {template_name var_name} [split $s ,] break
          #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 ""
      }
    

Methods: Source: Variables:
[All Methods | Documented Methods | Hide Methods] [Display Source | Hide Source] [Show Variables | Hide Variables]