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::Page

Class Hierarchy of ::xowiki::Page

  • ::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

Class Relations

  • superclass: ::xo::db::CrItem[i]
  • subclass: ::xowiki::File[i], ::xowiki::PageInstance[i], ::xowiki::PageTemplate[i], ::xowiki::PlainPage[i]
::xo::db::CrClass create ::xowiki::Page \
     -superclass ::xo::db::CrItem \
     -parameter {{absolute_links 0} {do_substitutions 1} {render_adp 1}}

Methods

  • instproc get_form_data (public)

    <instance of ::xowiki::Page[i]> get_form_data \
        [ -field_names field_names ] form_fields
    Get the values from the form and store it in the form fields and finally as instance attributes. If the field names are not specified, all form parameters are used.

    Switches:
    -field_names (optional)
    Parameters:
    form_fields
    ::247094 instproc get_form_data {-field_names form_fields} {
        set validation_errors 0
        set category_ids [list]
        array set containers [list]
        my instvar __ia package_id
        set cc [$package_id context]
        if {[my exists instance_attributes]} {
          array unset __ia
          array set __ia [my set instance_attributes]
        }
    
        if {![info exists field_names]} {
          set field_names [$cc array names form_parameter]
          #my log "form-params=[$cc array get form_parameter]"
        }
        #my msg "fields $field_names // $form_fields"
        #foreach f $form_fields { my msg "... $f [$f name]" }
        #
        # We have a form and get all form input from the fields of the
        # from into form field objects.
        #
        foreach att $field_names {
          #my msg "getting att=$att"
          set processed($att) 1
          switch -glob -- $att {
            __category_* {
              set f [my lookup_form_field -name $att $form_fields]
              set value [$f value [$cc form_parameter $att]]
              foreach v $value {lappend category_ids $v}
            }
            __* {
              # other internal variables (like __object_name) are ignored
            }
             _* {
               # instance attribute fields
               set f     [my lookup_form_field -name $att $form_fields]
               set value [$f value [string trim [$cc form_parameter $att]]]
               set varname [string range $att 1 end]
               # get rid of strange utf-8 characters hex C2AD (firefox bug?)
               # ns_log notice "FORM_DATA var=$varname, value='$value' s=$s"
               if {$varname eq "text"} {regsub -all "­" $value "" value}
               #ns_log notice "FORM_DATA var=$varname, value='$value'"
               if {![string match *.* $att]} {my set $varname $value}
             }
            default {
               # user form content fields
              if {[regexp {^(.+)[.](tmpfile|content-type)} $att _ file field]} {
                set f [my lookup_form_field -name $file $form_fields]
                $f $field [string trim [$cc form_parameter $att]]
                #my msg "[$f name]: [list $f $field [string trim [$cc form_parameter $att]]]"
              } else {
                set f     [my lookup_form_field -name $att $form_fields]
                set value [$f value [string trim [$cc form_parameter $att]]]
                #my msg "value of $att ($f) = '$value' exists=[$cc exists_form_parameter $att]" 
                if {![string match *.* $att]} {set __ia($att) $value}
                if {[$f exists is_category_field]} {foreach v $value {lappend category_ids $v}}
              }
            }
          }
          if {[string match *.* $att]} {
            foreach {container component} [split $att .] break
            lappend containers($container) $component
          }
        }
        
        #my msg "containers = [array names containers]"
        #my msg "ia=[array get __ia]"
        #
        # In a second iteration, combine the values from the components 
        # of a container to the value of the container.
        #
        foreach c [array names containers] {
          switch -glob -- $c {
            __* {}
            _* {
              set f  [my lookup_form_field -name $c $form_fields]
              set processed($c) 1
              my set [string range $c 1 end] [$f value]
            }
            default {
              set f  [my lookup_form_field -name $c $form_fields]
              set processed($c) 1
              #my msg "container $c: compute value of $c [$f info class]"
              set __ia($c) [$f value]
              #my msg "container $c: __ia($c) is set to '$__ia($c)'"
            }
          }
        }
        
        #
        # The first round was a processing based on the transmitted input
        # fields of the forms. Now we use the formfields to complete the
        # data and to validate it.
        #
        foreach f $form_fields {
          #my msg "validate $f [$f name] [info exists processed([$f name])]"
          set att [$f name]
     
          # Certain form field types (e.g. checkboxes) are not transmitted, if not
          # checked. Therefore, we have not processed these fields above and
          # have to do it now.
          
          if {![info exists processed($att)]} {
    	#my msg "form field $att not yet processed"
    	switch -glob -- $att {
    	  __* {
    	    # other internal variables (like __object_name) are ignored
    	  }
    	  _* {
    	    # instance attribute fields
    	    set varname [string range $att 1 end]
                set default ""
                if {[my exists $varname]} {set default [my set $varname]}
                set v [$f value_if_nothing_is_returned_from_form $default]
                set value [$f value $v]
                if {$v ne $default} {
                  if {![string match *.* $att]} {my set $varname $value}
                }
    	  }
    	  default {
    	    # user form content fields
                set default ""
                # The reason, why we set in the next line the default to
                # the old value is due to "show-solution" in the qti
                # use-case. Maybe one should alter this use-case to
                # simplify the semantics here.
                if {[info exists __ia($att)]} {set default $__ia($att)}
                set v [$f value_if_nothing_is_returned_from_form $default]
                #my msg "value_if_nothing_is_returned_from_form '$default' => '$v' (type=[$f info class])"
                set value [$f value $v]
                if {![string match *.* $att]} {set __ia($att) $value}
    	  }
            }
          }
          
          #
          # Run validators
          #
          set validation_error [$f validate [self]]
          if {$validation_error ne ""} {
    	#my msg "validation of $f [$f name] with value '[$f value]' returns '$validation_error'"
            $f error_msg $validation_error
            incr validation_errors
          }
        }
        #my msg "validation returns $validation_errors errors"
        set current_revision_id [::xo::cc form_parameter __current_revision_id ""]
        if {$validation_errors == 0 && $current_revision_id ne "" && $current_revision_id != [my revision_id]} {
          set validation_errors [my mutual_overwrite_occurred]
        }
    
        if {$validation_errors == 0} {
          #
          # Postprocess based on form fields based on form-fields methods.
          #
          foreach f $form_fields {
    	$f convert_to_internal
          }
        } else {
          my log validation_errors=$validation_errors
    
          # There were validation erros.  Reset the value for form-fields
          # of type "file" to avoid confusions, since a file-name was
          # provided, but the file was not uploaded due to the validation
          # error. If we would not reset the value, the provided name
          # would cause an interpretation of an uploaded empty file. Maybe
          # a new method "reset-to-default" would be a good idea.
          foreach f $form_fields {
    	if {[$f type] eq "file"} {
    	  $f set value ""
            }
          }
        }
    
        my instance_attributes [array get __ia]
        #my msg category_ids=$category_ids
        return [list $validation_errors [lsort -unique $category_ids]]
      }
    
  • instproc include (public)

    <instance of ::xowiki::Page[i]> include [ -configure configure ] \
        arg
    Include the html of the includelet. The method generates an includelet object (might be an other xowiki page) and renders it and returns either html or an error message.

    Switches:
    -configure (optional)
    Parameters:
    arg
    ::247094 instproc include {-configure arg} {
        set page [my instantiate_includelet $arg]
        if {$page eq ""} {
          # The variable 'page_name' is required by the message key
          set page_name $arg
          return [my error_during_render [_ xowiki.error-includelet-unknown]]
        }
        if {[$page istype ::xowiki::Page]} {
          set package_id [$page package_id]
          set allowed [[$package_id set policy] check_permissions  -package_id $package_id  -user_id [::xo::cc set untrusted_user_id]  $page view]
          if {!$allowed} {
            return "<div class='errorMsg'>Unsufficient priviledges to view content of [$page name].</div>"
          }
        }
        if {[info exists configure]} {
          eval $page configure $configure
        }
        return [my render_includelet $page]
      }
    
  • instproc resolve_included_page_name (public)

    <instance of ::xowiki::Page[i]> resolve_included_page_name \
        page_name
    Determine the page object for the specified page name. The specified page name might have the form //some_other_instance/page_name, in which case the page is resolved from some other package instance. If the page_name does not contain a language prefix, the language prefix of the including page is used.

    Parameters:
    page_name
    ::247094 instproc resolve_included_page_name page_name {
        if {$page_name ne ""} {
          set page [[my package_id] resolve_page_name_and_init_context -lang [my lang] $page_name]
          if {$page eq ""} {
            error "Cannot find page '$page_name' to be included in page '[my name]'"
          }
        } else {
          set page [self]
        }
        return $page
      }
    
  • instproc save-attributes (public)

    <instance of ::xowiki::Page[i]> save-attributes
    The method save-attributes is typically callable over the REST interface. It allows to save attributes of a page without adding a new revision.

    ::247094 instproc save-attributes {} {
        my instvar package_id
        set field_names [my field_names]
        set form_fields [list]
        set query_field_names [list]
    
        set validation_errors 0
        foreach field_name $field_names {
          if {[::xo::cc exists_form_parameter $field_name]} {
            lappend form_fields [my create_form_field $field_name]
            lappend query_field_names $field_name
          }
        }
        #my show_fields $form_fields
        foreach {validation_errors category_ids}  [my get_form_data -field_names $query_field_names $form_fields] break
    
        if {$validation_errors == 0} {
          #
          # we have no validation errors, so we can save the content
          #
          set update_without_revision [$package_id query_parameter replace 0]
    
          foreach form_field $form_fields {
            # fix richtext content in accordance with oacs conventions
            if {[$form_field istype ::xowiki::formfield::richtext]} {
              $form_field value [list [$form_field value] text/html]
            }
          }
          if {$update_without_revision} {
            # field-wise update without revision
            set update_instance_attributes 0
            foreach form_field $form_fields {
              set s [$form_field slot]
              if {$s eq ""} {
                # empty slot means that we have an instance_attribute; 
                # we save all in one statement below
                set update_instance_attributes 1
              } else {
                error "Not implemented yet"
                my update_attribute_from_slot $s [$form_field value]
              }
            }
            if {$update_instance_attributes} {
              set s [my find_slot instance_attributes]
              my update_attribute_from_slot $s [my instance_attributes]
            }
          } else {
            #
            # perform standard update (with revision)
            # 
            my save_data  -use_given_publish_date [expr {[lsearch $field_names _publish_date] > -1}]  [::xo::cc form_parameter __object_name ""] $category_ids
          }
          $package_id returnredirect  [my query_parameter "return_url" [my pretty_link]]
          return
        } else {
          # todo: handle errors in a user friendly way
          my log "we have $validation_errors validation_errors"
        }
        $package_id returnredirect  [my query_parameter "return_url" [my pretty_link]]
      }
    

Variables

::xowiki::Page array set RE {include {{{([^<]+?)}}([&<\s]|$)} clean2 { <br */?> *(<div)} anchor \
       {\\\[\\\[([^\]]+?)\\\]\\\]} div {&gt;&gt;([^&<]*?)&lt;&lt;([ \n]*)?} clean \
       {[\\](\{\{|&gt;&gt;|\[\[)}}
::xowiki::Page set __default_metaclass ::xotcl::Class
::xowiki::Page set __default_superclass ::xotcl::Object
::xowiki::Page set abstract_p f
::xowiki::Page set auto_save false
::xowiki::Page array set db_slot \
       {page_order ::xowiki::Page::slot::page_order creator ::xowiki::Page::slot::creator page_id \
       ::xowiki::Page::slot::page_id object_id ::xo::db::Object::slot::object_id description \
       ::xo::db::CrItem::slot::description text ::xo::db::CrItem::slot::text object_title \
       ::xo::db::Object::slot::object_title nls_language ::xo::db::CrItem::slot::nls_language \
       mime_type ::xo::db::CrItem::slot::mime_type name ::xo::db::CrItem::slot::name title \
       ::xo::db::CrItem::slot::title revision_id ::xo::db::CrItem::slot::revision_id item_id \
       ::xo::db::CrItem::slot::item_id publish_date ::xo::db::CrItem::slot::publish_date}
::xowiki::Page set folder_id -100
::xowiki::Page set form ::xowiki::WikiForm
::xowiki::Page set id_column page_id
::xowiki::Page array set markupmap {unescape { {[[}  \{\{  {&gt;&gt;}} escape \
       {{\[[}  \\\{\{  {\&gt;&gt;} }}
::xowiki::Page set mime_type text/html
::xowiki::Page set name_method {}
::xowiki::Page set object_type ::xowiki::Page
::xowiki::Page set object_type_key 68870471744
::xowiki::Page set pretty_name {XoWiki Page}
::xowiki::Page set pretty_plural {Wiki Pages}
::xowiki::Page set recursion_count 0
::xowiki::Page set security_inherit_p t
::xowiki::Page set sql_package_name ::xowiki::Page
::xowiki::Page set storage_type text
::xowiki::Page set supertype content_revision
::xowiki::Page set table_name xowiki_page
::xowiki::Page set with_table true

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