Saltar al contenido principal
Inicio del contenido principal
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, __nextC, __timediff, abstract, ad_doc, ad_forward, ad_proc, appendC, arrayC, asHTML, autonameC, checkC, classC, cleanupC, configureC, contains, copy, db_1rowC, debug, defaultmethod, destroyC, destroy_on_cleanup, evalC, existsC, extractConfigureArg, filterC, filterguardC, filtersearchC, forwardC, hasclass, incrC, infoC, init, instvarC, invarC, isclassC, ismetaclassC, ismixinC, isobjectC, istypeC, lappendC, log, method, mixinC, mixinguardC, move, msg, noinitC, parametercmdC, procC, procsearchC, qn, requireNamespaceC, self, serialize, setC, substC, traceC, unsetC, uplevelC, upvarC, volatileC, vwaitC
    Methods to be applied on the class (in addition to the methods provided by the meta-class):
    __exitHandler, getExitHandler, setExitHandler, unsetExitHandler
    • ::xo::db::Object[i]
      Meta-class:
      ::xo::db::Class[i]
      Methods for instances:
      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"), lang (default "en"), render_adp (default "1")
          Methods for instances:
          adp_subst, anchor, build_instance_attribute_map, build_name, category_export, category_import, check_adp_include_path, condition=match, condition=regexp, copy_content_vars, create-new, create_form_field, create_form_fields, create_form_fields_from_form_constraints, create_raw_form_field, creation_userC, creatorC, default_instance_attributes, delete, delete-revision, demarshall, descripionC, diff, div, edit, error_during_render, error_in_includelet, exists_form_parameterC, exists_query_parameterC, field_names, find_slot, footer, form_field_index, form_parameterC, get_content, get_description, get_form_data, get_instance_attributes, get_rich_text_spec, htmlFooter, include, include_content, include_portlet, initialize_loaded_object, instantiate_includelet, is_new_entry, last_modifiedC, list, lookup_cached_form_field, lookup_form_field, make-live-revision, map_categories, map_party, marshall, mime_typeC, nameC, nls_languageC, page_idC, page_orderC, popular-tags, publish_dateC, query_parameterC, record_last_visited, regsub_eval, render, render_includelet, resolve_included_page_name, reverse_map_party, reverse_map_party_attribute, revisions, save, save-tags, save_attributes, save_data, save_new, set_content, show_fields, substitute_markup, textC, titleC, translate, unescape, unset_temporary_instance_variables, update_references, 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, get_tags, import, quoted_html_content, save_tags

Class Relations

  • superclass: ::xo::db::CrItem[i]
  • subclass: ::blocks::BlockPage[i], ::learning_content::ContentPage[i], ::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} {lang en} {render_adp 1}}

Methods

  • proc container_already_rendered

    ::xowiki::Page proc container_already_rendered field {
        if {![info exists ::xowiki_page_item_id_rendered]} {
          return ""
        }
        #my log "--OMIT and not $field in ([join $::xowiki_page_item_id_rendered ,])"
        return "and not $field in ([join $::xowiki_page_item_id_rendered ,])"
      }
  • proc get_tags

    ::xowiki::Page proc get_tags {-package_id:required -item_id -user_id} {
        if {[info exists item_id]} {
          if {[info exists user_id]} {
            # tags for item and user
            set tags [db_list [my qn get_tags]  "SELECT distinct tag from xowiki_tags  where user_id=$user_id and item_id=$item_id and package_id=$package_id"]
          } else {
            # all tags for this item 
            set tags [db_list [my qn get_tags]  "SELECT distinct tag from xowiki_tags  where item_id=$item_id and package_id=$package_id"]
          }
        } else {
          if {[info exists user_id]} {
            # all tags for this user
            set tags [db_list [my qn get_tags]  "SELECT distinct tag from xowiki_tags  where user_id=$user_id and package_id=$package_id"]
          } else {
            # all tags for the package
            set tags [db_list [my qn get_tags]  "SELECT distinct tag from xowiki_tags  where package_id=$package_id"]
          }
        }
        join $tags " "
      }
  • proc import

    ::xowiki::Page proc import {-user_id -package_id -folder_id {-replace 0} -objects} {
        my log "DEPRECATED"
        if {![info exists package_id]}  {set package_id  [::xo::cc package_id]}
        set cmd  [list $package_id import -replace $replace]
        
        if {[info exists user_id]}   {lappend cmd -user_id $user_id}
        if {[info exists objects]}   {lappend cmd -objects $objects}
        eval $cmd
      }
  • proc quoted_html_content

    ::xowiki::Page proc quoted_html_content text {
        list [ad_text_to_html $text] text/html
      }
  • proc save_tags

    ::xowiki::Page proc save_tags {-package_id:required -item_id:required -revision_id:required -user_id:required tags} {
        db_dml [my qn delete_tags]  "delete from xowiki_tags where item_id = $item_id and user_id = $user_id"
        foreach tag $tags {
          db_dml [my qn insert_tag]  "insert into xowiki_tags (item_id,package_id, user_id, tag, time)  values ($item_id, $package_id, $user_id, :tag, current_timestamp)"
        }
        search::queue -object_id $revision_id -event UPDATE
      }
  • instproc adp_subst

    ::xowiki::Page instproc adp_subst content {
        #my msg "--adp_subst in [my name] vars=[my info vars]"
        set __ignorelist [list RE __defaults name_method object_type_key db_slot]
        foreach __v [my info vars] {
          if {[info exists $__v]} continue
          my instvar $__v
        }
        foreach __v [[my info class] info vars] {
          if {[lsearch -exact $__ignorelist $__v]>-1} continue
          if {[info exists $__v]} continue
          [my info class] instvar $__v
        }
        set __ignorelist [list __v __vars __l __ignorelist __varlist  __last_includelet __unresolved_references  text item_id content lang_links]
    
        # set variable current_user to ease personalization
        set current_user [::xo::cc set untrusted_user_id]
    
        set __vars [info vars]
        regsub -all [template::adp_variable_regexp] $content {\1@\2;noquote@} content
        #my log "--adp before adp_eval '[template::adp_level]'"
        #
        # The adp buffer has limited size. For large pages, it might happen
        # that the buffer overflows. In Aolserver 4.5, we can increase the
        # buffer size. In 4.0.10, we are out of luck.
        #
        set __l [string length $content]
        if {[catch {set __bufsize [ns_adp_ctl bufsize]}]} {
          set __bufsize 0
        }
        if {$__bufsize > 0 && $__l > $__bufsize} {
          # we have aolserver 4.5, we can increase the bufsize
          ns_adp_ctl bufsize [expr {$__l + 1024}]
        }
        set template_code [template::adp_compile -string $content]
        set my_parse_level [template::adp_level]
        if {[catch {set template_value [template::adp_eval template_code]} __errMsg]} {
          # compute list of possible variables
          set __varlist [list]
          set __template_variables__ "<ul>\n"
          foreach __v [lsort $__vars] {
            if {[array exists $__v]} continue ;# don't report  arrays
            if {[lsearch -exact $__ignorelist $__v]>-1} continue
            lappend __varlist $__v
            append __template_variables__ "<li><b>$__v:</b> '[set $__v]'\n"
          }
          append __template_variables__ "</ul>\n"
          set ::template::parse_level $my_parse_level 
          #my log "--adp after adp_eval '[template::adp_level]' mpl=$my_parse_level"
          return "<div class='errorMsg'>Error in Page $name: $__errMsg</div>$content<p>Possible values are$__template_variables__"
        }
        return $template_value
      }
  • instproc anchor

    ::xowiki::Page instproc anchor arg {
        #my msg [self args]
        set label $arg
        set link $arg
        set options ""
        regexp {^([^|]+)[|](.*)$} $arg _ link label
        regexp {^([^|]+)[|](.*)$} $label _ label options
        set options [my unescape $options]
        if {[string match "http*//*" $link] 
            || [string match "ftp://*" $link]
            || [string match "//*" $link]
          } {
          if {[regsub {^//} $link / link]} {
    	#my msg t=[::xowiki::guesstype $link]
    	switch -glob -- [::xowiki::guesstype $link] {
    	  text/css {
    	    ::xo::Page requireCSS $link
    	    return ""
    	  }
    	  application/x-javascript {
    	    ::xo::Page requireJS $link
    	    return ""
    	  }
    	  image/* {
    	    Link create [self]::link  -page [self]  -type localimage -label $label  -href $link
    	    eval [self]::link configure $options
    	    return [[self]::link render]
    	  }
    	}
          }
          set l [ExternalLink new -label $label -href $link]
          eval $l configure $options
          set html [$l render]
          $l destroy
          return $html
        }
    
        set name ""
        my instvar parent_id package_id
        if {[regexp {^:(..):(.*)$} $link _ lang stripped_name]} {
          # language link (it starts with a ':')
          set link_type language
        } elseif {[regexp {^(file|image|js|css|swf):(.*)$} $link _  link_type stripped_name]} {
          # (typed) file links
          set lang ""
          set name file:$stripped_name
        } else {
          # do we have a typed link? more than two chars...
          if {[regexp {^([^:][^:][^:]+):((..):)?(.+)$} $link _  link_type _ lang  stripped_name]} {
            set name file:$stripped_name
          } else {
            # must be an untyped link; defaults, in case the second regexp does not match either
            set lang ""
            set stripped_name $link
    
            regexp {^(..):(.+)$} $link _ lang stripped_name
    	switch -glob -- [::xowiki::guesstype $link] {
    	  text/css {
    	    set link_type css
    	    set name file:$stripped_name
    	  }
    	  application/x-javascript {
    	    set link_type js
    	    set name file:$stripped_name
    	  }
    	  application/x-shockwave-flash {
    	    set link_type swf
    	    set name swf:$stripped_name; # not consistent, but backward compatible
    	  }
    	  image/* {
    	    set link_type image
    	    set name image:$stripped_name
    	  }
    	  default {
    	    set link_type link
    	    #set name $stripped_name
    	  }
    	}
          }
        }
    
        set anchor ""
        regexp {^([^#]+)(\#|%23)(.*)$} $stripped_name _ stripped_name . anchor
    
        #my msg name=$name,stripped_name=$stripped_name,link_type=$link_type,lang=$lang
        set normalized_name [::$package_id normalize_name $stripped_name]
    
        if {$lang  eq ""}   {set lang [my lang]}
        if {$name  eq ""}   {set name $lang:$normalized_name}
        if {$label eq $arg} {set label $stripped_name}
    
        Link create [self]::link  -page [self]  -type $link_type -name $name -lang $lang -anchor $anchor  -stripped_name $normalized_name -label $label  -parent_id $parent_id -package_id $package_id
        
        if {[catch {eval [self]::link configure $options} errorMsg]} {
          ns_log error "$errorMsg\n$::errorInfo"
          return "<div class='errorMsg'>Error during processing of options [list $options] of link of type [[self]::link info class]:<blockquote>$errorMsg</blockquote></div>"
        } else {
          return [[self]::link render]
        }
      }
  • instproc build_instance_attribute_map

    ::xowiki::Page instproc build_instance_attribute_map form_fields {
        #
        # Build the data structure for mapping internal values (IDs) into
        # string representations and vice versa. In particular, it builds
        # and maintains the __instance_attribute_map, which is an
        # associative list (attribute/value pairs) for form-field attributes.
        #
        #foreach f $form_fields {lappend fns [list [$f name] [$f info class]]}
        #my msg "page [my name] build_instance_attribute_map $fns"
        if {[my exists  __instance_attribute_map]} {
          array set cm [my set __instance_attribute_map]
        }
        foreach f $form_fields {
          set multiple [expr {[$f exists multiple] ? [$f set multiple] : 0}]
          #my msg "$f [$f name] cat_tree [$f exists category_tree] is fc: [$f exists is_category_field]"
          if {[$f exists category_tree] && [$f exists is_category_field]} {
            #my msg "page [my name] field [$f name] is a category_id from [$f category_tree]"
            set cm([$f name]) [list category [$f category_tree] $multiple]
            my category_export [$f category_tree]
          } elseif {[$f exists is_party_id]} {
            #my msg "page [my name] field [$f name] is a party_id"
            set cm([$f name]) [list party_id $multiple]
          }
        }
        if {[array exists cm]} {
          my set __instance_attribute_map [array get cm]
        }
      }
  • instproc build_name

    ::xowiki::Page instproc build_name {{-nls_language {}}} {
        #
        # Build the name of the page, based on the provided nls_language
        # This method strips existing language-prefixes and uses the
        # provided nls_language or the instance variable for the new name.
        # It handles as well anonymous pages, which are never equipped
        # with language prefixes. ::xowiki::File has its own method.
        #
        set name [my name]
        set stripped_name $name
        regexp {^..:(.*)$} $name _ stripped_name
    
        # prepend the language prefix only, if the entry is not empty
        if {$stripped_name ne ""} {
          #if {[my istype ::xowiki::PageInstance]} {
            #
            # Do not add a language prefix to anonymous pages
            #
            #set anon_instances [my get_from_template anon_instances f]
            #if {$anon_instances} {
            #  return $stripped_name
            #}
          #}
          if {$nls_language eq ""} {set nls_language [my nls_language]}
          set name [string range $nls_language 0 1]:$stripped_name
        }
        return $name
      }
  • instproc category_export

    ::xowiki::Page instproc category_export tree_name {
        #
        # Build a command to rebuild the category tree on imports
        # (__map_command). In addition this method builds and maintains a
        # category map, which maps internal IDs into symbolic values
        # (__category_map).
        #
        # Ignore locale in get_id for now, since it seems broken    
        set tree_ids [::xowiki::Category get_mapped_trees -object_id [my package_id]  -names [list $tree_name] -output tree_id]
        # Make sure to have only one tree_id, in case multiple trees are
        # mapped with the same name.
        set tree_id [lindex $tree_ids 0]
        array set data [category_tree::get_data $tree_id]
        set categories [list]
        if {[my exists __category_map]} {array set cm [my set __category_map]}
        foreach category [::xowiki::Category get_category_infos -tree_id $tree_id] {
          foreach {category_id category_name deprecated_p level} $category break
          lappend categories $level $category_name
          set names($level) $category_name
          set node_name $tree_name
          for {set l 1} {$l <= $level} {incr l} {append node_name /$names($l)}
          set cm($category_id) $node_name
        }
        set cmd [list my category_import  -name $tree_name -description $data(description)  -locale [lang::system::site_wide_locale]  -categories $categories]
        if {![my exists __map_command] || [string first $cmd [my set __map_command]] == -1} {
          my append __map_command \n $cmd
        }
        my set __category_map [array get cm]
        #my log "cmd=$cmd"
      }
  • instproc category_import

    ::xowiki::Page instproc category_import {-name -description -locale -categories} {
        # Execute the category import for every tree name only once per request
        set key ::__xowiki_category_import($name)
        if {[info exists $key]} return
    
        # ok, it is the first request
        #my msg "... catetegoy_import [self args]"
    
        # Do we have a tree with the specified named mapped?
        set tree_ids [::xowiki::Category get_mapped_trees -object_id [my package_id] -locale $locale  -names [list $name] -output tree_id]
        set tree_id [lindex $tree_ids 0]; # handle multiple mapped trees with same name
        if {$tree_id eq ""} {
          # The tree is not mapped, we import the category tree
          my log "...importing category tree $name"
          set tree_id [category_tree::import -name $name -description $description  -locale $locale -categories $categories]
          category_tree::map -tree_id $tree_id -object_id [my package_id]
        }
    
        #
        # build reverse category_map
        foreach category [::xowiki::Category get_category_infos -tree_id $tree_id] {
          foreach {category_id category_name deprecated_p level} $category break
          lappend categories $level $category_name
          set names($level) $category_name
          set node_name $name
          for {set l 1} {$l <= $level} {incr l} {append node_name /$names($l)}
          set ::__xowiki_reverse_category_map($node_name) $category_id
        }
        #my msg "... catetegoy_import reverse map [array names ::__xowiki_reverse_category_map]"
        # mark the tree with this name as already imported
        set $key 1
      }
  • instproc check_adp_include_path

    ::xowiki::Page instproc check_adp_include_path adp_fn {
        #
        # For security reasons, don't allow arbitrary paths to different
        # packages.  All allowed includelets must be made available
        # under xowiki/www (preferable xowiki/www/portlets/*). If the
        # provided path contains a admin/* admin rights are required.
        #
        if {[string match "admin/*" $adp_fn]} {
          set allowed [::xo::cc permission  -object_id [my package_id] -privilege admin  -party_id [::xo::cc user_id]]
          if {!$allowed} {
    	return [list allowed $allowed msg "Page can only be included by an admin!" fn ""]
          }
        }
        if {[string match "/*" $adp_fn] || [string match "../*" $adp_fn]} {
          # Never allow absolute paths.
          #
          # Alternatively, we could allow url-based includes, and then using
          # set node [site_node::get -url [ad_conn url]]
          # permission::require_permission -object_id $node(object_id) -privilege read
          # ... or admin/* based checks like in rp.
          #
          return [list allowed 0 msg "Invalid name for adp_include" fn ""]
        }
        return [list allowed 1 msg "" fn /packages/[[my package_id] package_key]/www/$adp_fn]
      }
  • instproc condition=match

    ::xowiki::Page instproc condition=match {query_context value} {
        #
        # Conditon for conditional checks in policy rules
        # The match condition is called with an attribute 
        # name and a pattern like in
        #
        #  edit {
        #     {{match {name {*weblog}}} package_id admin} 
        #     {package_id write}
        #  }
        #
        # This example specifies that for a page named
        # *weblog, the method "edit" is only allowed
        # for package admins.
        #
        #my msg "query_context='$query_context', value='$value'"
        if {[llength $value] != 2} {
          error "two arguments for match required, [llength $value] passed (arguments='$value')"
        }
        if {[catch {
          set success [string match [lindex $value 1] [my set [lindex $value 0]]]
        } errorMsg]} {
          my log "error during match: $errorMsg"
          set success 0
        }
        return $success
      }
  • instproc condition=regexp

    ::xowiki::Page instproc condition=regexp {query_context value} {
        #
        # Conditon for conditional checks in policy rules
        # The match condition is called with an attribute 
        # name and a pattern like in
        #
        #  edit               {
        #    {{regexp {name {(weblog|index)$}}} package_id admin} 
        #    {package_id write}
        #  }
        #
        # This example specifies that for a page ending with
        # weblog or index, the method "edit" is only allowed
        # for package admins.
        #
        #my msg "query_context='$query_context', value='$value'"
        if {[llength $value] != 2} {
          error "two arguments for regexp required, [llength $value] passed (arguments='$value')"
        }
        if {[catch {
          set success [regexp [lindex $value 1] [my set [lindex $value 0]]]
        } errorMsg]} {
          my log "error during regexp: $errorMsg"
          set success 0
        }
        return $success
      }
  • instproc copy_content_vars

    ::xowiki::Page instproc copy_content_vars -from_object:required {
        array set excluded_var {
          folder_id 1 package_id 1 absolute_links 1 lang_links 1 modifying_user 1
          publish_status 1 item_id 1 revision_id 1 last_modified 1
        }
        foreach var [$from_object info vars] {
          # don't copy vars starting with "__"
          if {[string match "__*" $var]} continue
          if {![info exists excluded_var($var)]} {
            my set $var [$from_object set $var]
          }
        }
      }
  • instproc create-new

    ::xowiki::Page instproc create-new {{-view_method edit}} {
        my instvar package_id
        set instance_attributes [my default_instance_attributes]
        set original_package_id $package_id
    
        if {[my exists_query_parameter "package_instance"]} {
          set package_instance [my query_parameter "package_instance"]
          #
          # Initialize the target package and set the local
          # variable package_id.
          #
          if {[catch {
            ::xowiki::Package initialize  -url $package_instance -user_id [::xo::cc user_id]  -actual_query ""} errorMsg]} {
            ns_log error "$errorMsg\n$::errorInfo"
            return [$original_package_id error_msg  "Page <b>'[my name]'</b> invalid provided package instance=$package_instance<p>$errorMsg</p>"]
          }
          my parent_id [$package_id folder_id]
        }
        set f [FormPage new -destroy_on_cleanup  -name ""  -package_id $package_id  -parent_id [my parent_id]  -nls_language [my nls_language]  -publish_status "production"  -instance_attributes $instance_attributes  -page_template [my item_id]]
    
        if {[my exists state]} {
          $f set state [my set state]
        }
    
        # Call the application specific initialization, when a FormPage is
        # initially created. This is used to control the life-cycle of
        # FormPages.
        $f initialize
    
        #
        # if we copy an item, we use source_item_id to provide defaults
        #
        set source_item_id [my query_parameter source_item_id ""]
        if {$source_item_id ne ""} {
          set source [FormPage get_instance_from_db -item_id $source_item_id]
          $f copy_content_vars -from_object $source
          set name "[::xowiki::autoname generate -parent_id $source_item_id -name [my name]]"
          $package_id get_lang_and_name -name $name lang name
          $f set name $name
          #my msg nls=[$f nls_language],source-nls=[$source nls_language]
        } else {
          #
          # set some default values from query parameters
          #
          foreach key {name title page_order last_page_id} {
    	if {[my exists_query_parameter $key]} {
    	  $f set $key [my query_parameter $key]
    	}
          }
        }
        $f set __title_prefix [my title]
    
        $f save_new
        if {[my exists_query_parameter "return_url"]} {
          set return_url [my query_parameter "return_url"]
        }
        if {[my exists_query_parameter "template_file"]} {
          set template_file [my query_parameter "template_file"]
        }
        foreach var {return_url template_file title detail_link text} {
          if {[my exists_query_parameter $var]} {
            set $var [my query_parameter $var]
          }
        }
    
        $package_id returnredirect  [export_vars -base [$package_id pretty_link [$f name]]  [list [list m $view_method] return_url name template_file title detail_link text]]
    
      }
  • instproc create_form_field

    ::xowiki::Page instproc create_form_field {{-cr_field_spec {}} {-field_spec {}} field_name} {
        switch -glob -- $field_name {
          __* {}
          _* {
            set varname [string range $field_name 1 end]
            return [my create_raw_form_field -name $field_name  -spec $cr_field_spec  -slot [my find_slot $varname]]
          }
          default {
            return [my create_raw_form_field -name $field_name  -spec $field_spec  -slot [my find_slot $field_name]]
          }
        }
      }
  • instproc create_form_fields

    ::xowiki::Page instproc create_form_fields field_names {
        set form_fields [my create_category_fields]
        foreach att $field_names {
          if {[string match "__*" $att]} continue
          lappend form_fields [my create_form_field $att]
        }
        return $form_fields
      }
  • instproc create_form_fields_from_form_constraints

    ::xowiki::Page instproc create_form_fields_from_form_constraints form_constraints {
        #
        # Create form-fields from form constraints.
        # Since create_raw_form_field uses destroy_on_cleanup, we do not
        # have to care here about destroying the objects.
        #
        set form_fields [list]
        foreach name_and_spec $form_constraints {
          regexp {^([^:]+):(.*)$} $name_and_spec _ spec_name short_spec
          if {[string match "@table*" $spec_name] || $spec_name eq "@categories"} continue
          
          #my msg "checking spec '$short_spec' for form field '$spec_name'"
          lappend form_fields [my create_raw_form_field  -name $spec_name  -slot [my find_slot $spec_name]  -spec $short_spec]
        }
        return $form_fields
      }
  • instproc create_raw_form_field

    ::xowiki::Page instproc create_raw_form_field {-name {-slot {}} {-spec {}} {-configuration {}}} {
        set save_slot $slot
        if {$slot eq ""} {
          # We have no slot, so create a minimal slot. This should only happen for instance attributes
          set slot [::xo::Attribute new -pretty_name $name -datatype text -volatile -noinit]
        }
    
        set spec_list [list]
        if {[$slot exists spec]} {lappend spec_list [$slot set spec]}
        if {$spec ne ""}         {lappend spec_list $spec}
        #my msg "[self args] spec_list $spec_list"
        #my msg "$name, spec_list = '[join $spec_list ,]'"
    
        if {[$slot exists pretty_name]} {
          set label [$slot set pretty_name]
        } else {
          set label $name
          my log "no pretty_name for variable $name in slot $slot"
        }
    
        if {[$slot exists default]} {
          #my msg "setting ff $name default = [$slot default]"
          set default [$slot default] 
        } else {
          set default ""
        }
        set f [::xowiki::formfield::FormField new -name $name  -id        [::xowiki::Includelet html_id F.[my name].$name]  -locale    [my nls_language]  -label     $label  -type      [expr {[$slot exists datatype]  ? [$slot set datatype]  : "text"}]  -help_text [expr {[$slot exists help_text] ? [$slot set help_text] : ""}]  -validator [expr {[$slot exists validator] ? [$slot set validator] : ""}]  -required  [expr {[$slot exists required]  ? [$slot set required]  : "false"}]  -default   $default  -spec      [join $spec_list ,]  -object    [self]  -slot      $save_slot  ]
    
        $f destroy_on_cleanup
        eval $f configure $configuration
        return $f
      }
  • instproc default_instance_attributes

    ::xowiki::Page instproc default_instance_attributes {} {
        #
        # Provide the default list of instance attributes to derived
        # FormPages.
        #
        # We want to be able to create FormPages from all pages.
        # by defining this method, we allow derived applications
        # to provide their own set of instance attributes
        return [list]
      }
  • instproc delete

    ::xowiki::Page instproc delete {} {
        my instvar package_id item_id name
    
        # delete always via package
        $package_id delete -item_id $item_id -name $name
    
        #[my info class] delete -item_id $item_id
        #::$package_id flush_references -item_id $item_id -name $name
        #::$package_id returnredirect  #	[my query_parameter "return_url" [$package_id package_url]]
      }
  • instproc delete-revision

    ::xowiki::Page instproc delete-revision {} {
        my instvar revision_id package_id item_id 
        db_1row [my qn get_revision] "select latest_revision,live_revision from cr_items where item_id = $item_id"
        # do real deletion via package
        $package_id delete_revision -revision_id $revision_id -item_id $item_id
        # Take care about UI specific stuff....
        set redirect [my query_parameter "return_url"  [export_vars -base [$package_id url] {{m revisions}}]]
        if {$live_revision == $revision_id} {
          # latest revision might have changed by delete_revision, so we have to fetch here
          db_1row [my qn get_revision] "select latest_revision from cr_items where item_id = $item_id"
          if {$latest_revision eq ""} {
            # we are out of luck, this was the final revision, delete the item
            my instvar package_id name
            $package_id delete -name $name -item_id $item_id
          } else {
            ::xo::db::sql::content_item set_live_revision -revision_id $latest_revision
          }
        }
        if {$latest_revision ne ""} {
          # otherwise, "delete" did already the redirect
          ::$package_id returnredirect [my query_parameter "return_url"  [export_vars -base [$package_id url] {{m revisions}}]]
        }
      }
  • instproc demarshall

    ::xowiki::Page instproc demarshall {-parent_id -package_id -creation_user {-create_user_ids 0}} {
        # this method is the counterpart of marshall
        my set parent_id $parent_id
        my set package_id $package_id 
        my reverse_map_party_attribute -attribute creation_user   -default_party $creation_user -create_user_ids $create_user_ids
        my reverse_map_party_attribute -attribute modifying_user  -default_party $creation_user -create_user_ids $create_user_ids
        # If we import from an old database without page_order, provide a
        # default value
        if {![my exists page_order]} {my set page_order ""}
        # in the general case, no more actions required
      }
  • instproc diff

    ::xowiki::Page instproc diff {} {
        my instvar package_id
    
        set compare_id [my query_parameter "compare_revision_id" 0]
        if {$compare_id == 0} {
          return ""
        }
        ::xo::Page requireCSS /resources/xowiki/xowiki.css
        set my_page [::xowiki::Package instantiate_page_from_id -revision_id [my revision_id]]
        $my_page volatile
    
        if {[catch {set html1 [$my_page render]} errorMsg]} {
          set html2 "Error rendering [my revision_id]: $errorMsg"
        }
        set text1 [ad_html_text_convert -from text/html -to text/plain -- $html1]
        set user1 [::xo::get_user_name [$my_page set creation_user]]
        set time1 [$my_page set creation_date]
        set revision_id1 [$my_page set revision_id]
        regexp {^([^.]+)[.]} $time1 _ time1
    
        set other_page [::xowiki::Package instantiate_page_from_id -revision_id $compare_id]
        $other_page volatile
        #$other_page absolute_links 1
    
        if {[catch {set html2 [$other_page render]} errorMsg]} {
          set html2 "Error rendering $compare_id: $errorMsg"
        }
        set text2 [ad_html_text_convert -from text/html -to text/plain -- $html2]
        set user2 [::xo::get_user_name [$other_page set creation_user]]
        set time2 [$other_page set creation_date]
        set revision_id2 [$other_page set revision_id]
        regexp {^([^.]+)[.]} $time2 _ time2
    
        set title "Differences for [my set name]"
        set context [list $title]
        
        # try util::html diff if it is available and works
        if {[catch {set content [::util::html_diff -old $html2 -new $html1 -show_old_p t]}]} {
          # otherwise, fall back to proven text based diff
          set content [::xowiki::html_diff $text2 $text1]
        }
    
        ::xo::Page set_property doc title $title
        array set property_doc [::xo::Page get_property doc]
        set header_stuff [::xo::Page header_stuff]
    
        $package_id return_page -adp /packages/xowiki/www/diff -variables {
          content title context header_stuff
          time1 time2 user1 user2 revision_id1 revision_id2 property_doc
        }
      }
  • instproc div

    ::xowiki::Page instproc div arg {
        if {$arg eq "content"} {
          return "<div id='content' class='column'>"
        } elseif {[string match "left-col*" $arg]  || [string match "right-col*" $arg]  || $arg eq "sidebar"} {
          return "<div id='$arg' class='column'>"
        } elseif {$arg eq "box"} {
          return "<div class='box'>"
        } elseif {$arg eq ""} {
          return "</div>"
        } else {
          return ""
        }
      }
  • instproc edit

    ::xowiki::Page instproc edit {{-new:boolean false} {-autoname:boolean false} {-validation_errors {}}} {
        my instvar package_id item_id revision_id
        $package_id instvar folder_id  ;# this is the root folder
    
        #my msg "--edit new=$new autoname=$autoname, valudation_errors=$validation_errors"
    
        # set some default values if they are provided
        foreach key {name title page_order last_page_id} {
          if {[$package_id exists_query_parameter $key]} {
            my set $key [$package_id query_parameter $key]
          }
        }
        # the following is handled by new-request of the wiki form
        #if {$new} {
          #my set creator [::xo::get_user_name [::xo::cc user_id]]
          #my set nls_language [ad_conn locale]
        #}
    
        set object_type [my info class]
        if {!$new && $object_type eq "::xowiki::Object" && [my set name] eq "::$folder_id"} {
          # if we edit the folder object, we have to do some extra magic here, 
          # since  the folder object has slightly different naming conventions.
          # ns_log notice "--editing folder object ::$folder_id, FLUSH $page"
          ::xo::clusterwide ns_cache flush xotcl_object_cache [self]
          ::xo::clusterwide ns_cache flush xotcl_object_cache ::$folder_id
          my move ::$folder_id
          set page ::$folder_id
          #ns_log notice "--move page=$page"
        } 
    
        #
        # setting up folder id for file selector (use community folder if available)
        #
        set fs_folder_id ""
        if {[info commands ::fs::get_root_folder] ne ""} {
          # ... we have dotlrn installed
          set cid [::dotlrn_community::get_community_id]
          if {$cid ne ""} {
            # ... we are inside of a community, use the community folder
            set fs_folder_id [fs::get_root_folder -package_id [dotlrn_community::get_package_id_from_package_key -package_key "file-storage" -community_id $cid]]
          }
        }
    
        # the following line is like [$package_id url], but works as well with renamed objects
        # set myurl [$package_id pretty_link [my form_parameter name]]
    
        if {[my exists_query_parameter "return_url"]} {
          set submit_link [my query_parameter "return_url" "."]
          set return_url $submit_link
        } else {
          set submit_link "."
        }
        #my log "--u submit_link=$submit_link qp=[my query_parameter return_url]"
    
        # We have to do template mangling here; ad_form_template writes
        # form variables into the actual parselevel, so we have to be in
        # our own level in order to access an pass these.
        variable ::template::parse_level
        lappend parse_level [info level]    
        set action_vars [expr {$new ? "{edit-new 1} object_type return_url" : "{m edit} return_url"}]
        #my log "--formclass=[$object_type getFormClass -data [self]] ot=$object_type"
    
        #
        # Determine the package_id of some mounted xowiki instance to find
        # the directory + URL, from where the scripts called from xinha
        # can be used.
        
        set class [$package_id info class]
        with_catch errmsg {
            set superclass [eval [$package_id info class] info superclass]
        } {
            set superclass $class
        }
        
        if {$class eq "::xowiki::Package" || $superclass eq "::xowiki::Package"} {
          # The actual instance is a plain xowiki instance, we can use it
          # set package_url [$package_id package_url]
          # FIXME: Ñapa para que apunte siempre al paquete xowiki en vez de a la instancia de xowiki de la comunidad
          set package_url "/xowiki"
        
          # FIXME:  Ñapa para el learning-content
          set cid [::dotlrn_community::get_community_id]
          # if {$class eq "::learning_content::Package" && $cid ne "" } {
              # set package_url [regsub -start [string length [dotlrn_community::get_community_url $cid]] {content} $package_url {xowiki}]            
          # }
          set folder_spec [list script_dir $package_url]
          
        } else {
          # The actual instance is not a plain xowiki instance, so, we try
          # to find one, where the current user has at least read
          # permissions.  This act is required for sub-packages, which
          # might not have the script dir.
          set first_instance_id [::xowiki::Package first_instance -party_id [::xo::cc user_id] -privilege read]
          if {$first_instance_id ne ""} {
            ::xowiki::Package require $first_instance_id
            set folder_spec [list script_dir [$first_instance_id package_url]]
          }
        }
    
        if {$fs_folder_id ne ""} {lappend folder_spec folder_id $fs_folder_id}
            
        [$object_type getFormClass -data [self]] create ::xowiki::f1 -volatile  -action  [export_vars -base [$package_id url] $action_vars]  -data [self]  -folderspec $folder_spec  -submit_link $submit_link  -autoname $autoname
    
        if {[info exists return_url]} {
          ::xowiki::f1 generate -export [list [list return_url $return_url]]
        } else {
          ::xowiki::f1 generate
        }
    
        ::xowiki::f1 instvar edit_form_page_title context formTemplate
        
        if {[info exists item_id]} {
          set rev_link    [$package_id make_link [self] revisions]
          set view_link   [$package_id make_link [self] view]
        }
        if {[info exists last_page_id]} {
          set back_link [$package_id url]
        }
    
        set index_link  [$package_id make_link -privilege public -link "" $package_id {} {}]
        ::xo::Page set_property doc title "[$package_id instance_name] - $edit_form_page_title"
    
        array set property_doc [::xo::Page get_property doc]
        set html [$package_id return_page -adp /packages/xowiki/www/edit  -form f1  -variables {item_id edit_form_page_title context formTemplate
                        view_link back_link rev_link index_link property_doc}]
        template::util::lpop parse_level
        #my log "--edit html length [string length $html]"
        return $html
      }
  • instproc error_during_render

    ::xowiki::Page instproc error_during_render msg {
        return "<div class='errorMsg'>$msg</div>"
      }
  • instproc error_in_includelet

    ::xowiki::Page instproc error_in_includelet {arg msg} {
        my instvar name
        return [my error_during_render "[_ xowiki.error_in_includelet]<br >\n$msg"]
      }
  • instproc field_names

    ::xowiki::Page instproc field_names {{-form {}}} {
        array set dont_modify [list item_id 1 revision_id 1 object_id 1 object_title 1 page_id 1 name 1]
        set field_names [list]
        foreach field_name [[my info class] array names db_slot] {
          if {[info exists dont_modify($field_name)]} continue
          lappend field_names _$field_name
        }
        #my msg field_names=$field_names
        return $field_names
      }
  • instproc find_slot

    ::xowiki::Page instproc find_slot {-start_class name} {
        if {![info exists start_class]} {
          set start_class [my info class]
        }
        foreach cl [concat $start_class [$start_class info heritage]] {
          set slotobj ${cl}::slot::$name
          if {[my isobject $slotobj]} {
            #my msg $slotobj
            return $slotobj
          }
        }
        return ""
      }
  • instproc footer

    ::xowiki::Page instproc footer {} {
        return ""
      }
  • instproc form_field_index

    ::xowiki::Page instproc form_field_index nodes {
        set marker ::__computed_form_field_names($nodes)
        if {[info exists $marker]} return
    
        foreach n $nodes {
          if {![$n istype ::xowiki::formfield::FormField]} continue
          set ::_form_field_names([$n name]) $n
          my form_field_index [$n info children]
        }
        set $marker 1
      }
  • instproc get_content

    ::xowiki::Page instproc get_content {} {
        #my log "--"
        set content [my set text]
        if {[my render_adp]} {set content [my adp_subst $content]}
        return [my substitute_markup $content]
      }
  • instproc get_description

    ::xowiki::Page instproc get_description {-nr_chars content} {
        my instvar revision_id
        set description [my set description]
        if {$description eq "" && $content ne ""} {
          set description [ad_html_text_convert -from text/html -to text/plain -- $content]
        }
        if {$description eq "" && $revision_id > 0} {
          set body [db_string [my qn get_description_from_syndication]  "select body from syndication where object_id = $revision_id"  -default ""]
          set description [ad_html_text_convert -from text/html -to text/plain -- $body]
        }
        if {[info exists nr_chars] && [string length $description] > $nr_chars} {
          set description [string range $description 0 $nr_chars]...
        }
        return $description
      }
  • 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 as instance attributes.

    Switches:
    -field_names (optional)
    Parameters:
    form_fields
    ::xowiki::Page instproc get_form_data {-field_names form_fields} {
        set validation_errors 0
        set category_ids [list]
        array set containers [list]
        if {[my exists instance_attributes]} {
          array set __ia [my set instance_attributes]
        }
        if {![info exists field_names]} {
          set field_names [::xo::cc array names form_parameter]
        }
        #my msg "fields [::xo::cc array get form_parameter]"
    
        # we have a form and get all form variables
        
        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 [::xo::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 [::xo::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' s=$s"
               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 [::xo::cc form_parameter $att]]
              } else {
                set f     [my lookup_form_field -name $att $form_fields]
                set value [$f value [string trim [::xo::cc form_parameter $att]]]
                #my msg "value of $att ($f) = '$value'" 
                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 "compute value of $c"
              set __ia($c) [$f value]
              #my msg "__ia($c) is set to '[$f value]'"
            }
          }
        }
        
        #
        # 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 preset ""
                if {[my exists $varname]} {set preset [my set $varname]}
                set v [$f value_if_nothing_is_returned_from_from $preset]
                set value [$f value $v]
                if {$v ne $preset} {
                  if {![string match *.* $att]} {my set $varname $value}
                }
    	  }
    	  default {
    	    # user form content fields
                set preset ""
                if {[info exists __ia($att)]} {set preset $__ia($att)}
                set v [$f value_if_nothing_is_returned_from_from $preset]
                set value [$f value $v]
                if {$v ne $preset} {
                  if {![string match *.* $att]} {set __ia($att) $value}
                }
    	  }
             }
          }
          
          #
          # Run validators
          #
          set validation_error [$f validate [self]]
          #my msg "validation of [$f name] with value '[$f value]' returns '$validation_error'"
          if {$validation_error ne ""} {
            $f error_msg $validation_error
            incr validation_errors
          }
        }
        
        if {$validation_errors == 0} {
          #
          # Postprocess based on form fields based on form-fields methods.
          # Postprocessing might force to refresh some values in __ia()
          #
          foreach f $form_fields {
            $f convert_to_internal
            if {[$f exists __refresh_instance_attributes]} {
              #my msg "refresh [$f set __refresh_instance_attributes]"
              foreach {att val} [$f set __refresh_instance_attributes] {
                set __ia($att) $val
              }
            }
          }
        }
    
        #my msg "--set instance attributes to [array get __ia]"
        my instance_attributes [array get __ia]
        my array set __ia [my instance_attributes]
        #my msg category_ids=$category_ids
        return [list $validation_errors [lsort -unique $category_ids]]
      }
  • instproc get_instance_attributes

    ::xowiki::Page instproc get_instance_attributes {} {
        if {[my exists instance_attributes]} {
          return [my set instance_attributes]
        }
        return ""
      }
  • instproc get_rich_text_spec

    ::xowiki::Page instproc get_rich_text_spec {field_name default} {
        my instvar package_id
        set spec ""
        foreach {s widget_spec} [$package_id get_parameter widget_specs] {
          foreach {page_name var_name} [split $s ,] break
          # in case we have no name (edit new page) we use the first value or the default.
          set name [expr {[my exists name] ? [my set name] : $page_name}]
          #my msg "--w T.name = '$name' var=$page_name ([string match $page_name $name]), $var_name $field_name ([string match $var_name $field_name])"
          if {[string match $page_name $name] &&
              [string match $var_name $field_name]} {
            set spec $widget_spec
    	#my msg "setting spec to $spec"
            break
          }
        }
        if {$spec eq ""} {return $default}
        return $field_name:$spec
      }
  • instproc htmlFooter

    ::xowiki::Page instproc htmlFooter {{-content {}}} {
        my instvar package_id
    
        if {[my exists __no_footer]} {return ""}
    
        set footer ""
        set description [my get_description $content]
        
        if {[ns_conn isconnected]} {
          set url         "[ns_conn location][::xo::cc url]"
          set package_url "[ns_conn location][$package_id package_url]"
        }
    
        if {[$package_id get_parameter "with_tags" 1] && 
            ![my exists_query_parameter no_tags] &&
            [::xo::cc user_id] != 0
          } {
          set tag_content [my include my-tags]
          set tag_includelet [my set __last_includelet]
          set tags [$tag_includelet set tags]
        } else {
          set tag_content ""
          set tags ""
        }
    
        if {[$package_id get_parameter "with_digg" 0] && [info exists url]} {
          append footer "<div style='float: right'>"  [my include [list digg -description $description -url $url]] "</div>\n"
        }
    
        if {[$package_id get_parameter "with_delicious" 0] && [info exists url]} {
          append footer "<div style='float: right; padding-right: 10px;'>"  [my include [list delicious -description $description -url $url -tags $tags]]  "</div>\n"
        }
    
        if {[$package_id get_parameter "with_yahoo_publisher" 0] && [info exists package_url]} {
          set publisher [$package_id get_parameter "my_yahoo_publisher"  [::xo::get_user_name [::xo::cc user_id]]]
          append footer "<div style='float: right; padding-right: 10px;'>"  [my include [list my-yahoo-publisher  -publisher $publisher  -rssurl "$package_url?rss"]]  "</div>\n"
        }
    
        append footer [my include my-references] 
        
        if {[$package_id get_parameter "show_per_object_categories" 1]} {
          set html [my include my-categories]
          if {$html ne ""} {
    	append footer $html <br>
          }
          set categories_includelet [my set __last_includelet]
        }
    
        append footer $tag_content
    
        if {[$package_id get_parameter "with_general_comments" 0] &&
            ![my exists_query_parameter no_gc]} {
          append footer [my include my-general-comments] 
        }
    
        if {$footer ne ""} {
          # make sure, the 
          append footer "<div class='visual-clear'><!-- --></div>"
        }
    
        return  "<div class='item-footer'>$footer</div>\n"
      }
  • 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
    ::xowiki::Page instproc include {-configure arg} {
        set page [my instantiate_includelet $arg]
        if {$page eq ""} {
          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 include_content

    ::xowiki::Page instproc include_content {arg ch2} {
        # make recursion depth a global variable to ease the deletion etc.
        if {[catch {incr ::xowiki_inclusion_depth}]} {
          set ::xowiki_inclusion_depth 1
        }
        if {$::xowiki_inclusion_depth > 10} {
          return [my error_in_includelet $arg [_ xowiki.error-includelet-nesting_to_deep]]
        }
        if {[regexp {^adp (.*)$} $arg _ adp]} {
          if {[catch {lindex $adp 0} errMsg]} {
            # there is something syntactically wrong
            incr ::xowiki_inclusion_depth -1
            return [my error_in_includelet $arg [_ xowiki.error-includelet-adp_syntax_invalid]]
          }
          set adp [string map {&nbsp; " "} $adp]
          #
          # Check the provided name of the adp file
          #
          array set "" [my check_adp_include_path [lindex $adp 0]]
          if {!$(allowed)} {
            return [my error_in_includelet $arg $(msg)]
          }
          set adp_fn $(fn)
          #
          # check the provided arguments
          #
          set adp_args [lindex $adp 1]
          if {[llength $adp_args] % 2 == 1} {
            incr ::xowiki_inclusion_depth -1
            set adp $adp_args
            return [my error_in_includelet $arg [_ xowiki.error-includelet-adp_syntax_invalid]]
          }
    
          lappend adp_args __including_page [self]
          set including_page_level [template::adp_level]
          if {[catch {set page [template::adp_include $adp_fn $adp_args]} errorMsg]} {
            ns_log error "$errorMsg\n$::errorInfo"
            # in case of error, reset the adp_level to the previous value
            set ::template::parse_level $including_page_level 
            incr ::xowiki_inclusion_depth -1
            return [my error_in_includelet $arg  [_ xowiki.error-includelet-error_during_adp_evaluation]]
          }
    
          return $page$ch2
        } else {
          # we have a direct (adp-less include)
          set html [my include [my unescape $arg]]
          #my log "--include includelet returns $html"
          incr ::xowiki_inclusion_depth -1
          return $html$ch2
        }
      }
  • instproc include_portlet

    ::xowiki::Page instproc include_portlet arg {
        my log "+++ method [self proc] of [self class] is deprecated"
        return [my include $arg]
      }
  • instproc initialize_loaded_object

    ::xowiki::Page instproc initialize_loaded_object {} {
        my instvar title
        if {[info exists title] && $title eq ""} {set title [my set name]}
        next
      }
  • instproc instantiate_includelet

    ::xowiki::Page instproc instantiate_includelet arg {
        # we want to use package_id as proc-local variable, since the 
        # cross package reference might alter it locally
        set package_id [my package_id]
    
        # do we have a wellformed list?
        if {[catch {set page_name [lindex $arg 0]} errMsg]} {
          # there must be something syntactically wrong
          return [my error_in_includelet $arg [_ xowiki.error-includelet-dash_syntax_invalid]]
        }
    
        # the include is either a includelet class, or a wiki page
        if {[my isclass ::xowiki::includelet::$page_name]} {
          # direct call, without page, not tailorable
          set page [::xowiki::includelet::$page_name new  -package_id $package_id  -name $page_name  -locale [::xo::cc locale]  -actual_query [::xo::cc actual_query]]
        } else {
          #
          # Include a wiki page, tailorable.
          #
          set page [my resolve_included_page_name $page_name]
          
          if {$page ne "" && ![$page exists __decoration]} {
    	# 
    	# we use as default decoration for included pages
    	# the "portlet" decoration
    	#
            $page set __decoration [$package_id get_parameter default-portlet-decoration portlet]
          }
        }
    
        if {$page ne ""} {
          $page set __caller_parameters [lrange $arg 1 end] 
          $page destroy_on_cleanup
          my set __last_includelet $page
          $page set __including_page [self]
          if {[$page istype ::xowiki::Includelet]} {
            $page initialize
          }
        }
        return $page
      }
  • instproc is_new_entry

    ::xowiki::Page instproc is_new_entry old_name {
        return [expr {[my publish_status] eq "production" && $old_name eq [my revision_id]}]
      }
  • instproc list

    ::xowiki::Page instproc list {} {
        # todo move me
        my view [my include [list form-usages -form_item_id [my item_id]]]
      }
  • instproc lookup_cached_form_field

    ::xowiki::Page instproc lookup_cached_form_field -name:required {
        set key ::_form_field_names($name)
        #my msg "FOUND($name)=[info exists $key]"
        if {[info exists $key]} {
          return [set $key]
        }
        error "No form field with name $name found"
      }
  • instproc lookup_form_field

    ::xowiki::Page instproc lookup_form_field {-name:required form_fields} {
        my form_field_index $form_fields
    
        set key ::_form_field_names($name)
        if {[info exists $key]} {
          return [set $key]
        }
        #
        # We have here a non-existing form-field. Maybe the entry in the
        # form was dynamically created, so we create it here on the fly...  
        #
        # For forms with variable numbers of entries, we allow wild-cards
        # in the field-names of the form constraints.
        #
        foreach name_and_spec [my get_form_constraints] {
          regexp {^([^:]+):(.*)$} $name_and_spec _ spec_name short_spec
          if {[string match $spec_name $name]} {
    	set f [my create_form_fields_from_form_constraints [list $name:$short_spec]]
    	set $key $f
    	return $f
          }
        }
        set names [list]
        foreach f $form_fields {lappend names [$f name]}
        error "No form field with name $name found (available fields: [lsort [array names ::_form_field_names]])"
      }
  • instproc make-live-revision

    ::xowiki::Page instproc make-live-revision {} {
        my instvar revision_id item_id package_id
        #my log "--M set_live_revision($revision_id)"
        ::xo::db::sql::content_item set_live_revision -revision_id $revision_id
        set page_id [my query_parameter "page_id"]
        ::xo::clusterwide ns_cache flush xotcl_object_cache ::$item_id
        ::$package_id returnredirect [my query_parameter "return_url"  [export_vars -base [$package_id url] {{m revisions}}]]
      }
  • instproc map_categories

    ::xowiki::Page instproc map_categories category_ids {
        # could be optimized, if we do not want to have categories (form constraints?)
        #my log "--category::map_object -remove_old -object_id [my item_id] <$category_ids>"
        category::map_object -remove_old -object_id [my item_id] $category_ids
      }
  • instproc map_party

    ::xowiki::Page instproc map_party party_id {
        #my log "+++ $party_id"
        # So far, we just handle users, but we should support parties in
        # the future as well.
        if {$party_id eq "" || $party_id == 0} {
          return $party_id
        }
        acs_user::get -user_id $party_id -array info
        set result [list]
        foreach a {username email first_names last_name screen_name url} {
          lappend result $a $info($a)
        }
        return $result
      }
  • instproc marshall

    ::xowiki::Page instproc marshall {} {
        my instvar name
        my unset_temporary_instance_variables
        set old_creation_user  [my creation_user]
        set old_modifying_user [my set modifying_user]
        my set creation_user   [my map_party $old_creation_user]
        my set modifying_user  [my map_party $old_modifying_user]
        if {[regexp {^..:[0-9]+$} $name] ||
            [regexp {^[0-9]+$} $name]} {
          #
          # for anonymous entries, names might clash in the target
          # instance. If we create on the target site for anonymous
          # entries always new instances, we end up with duplicates.
          # Therefore, we rename anonymous entries during export to
          #    ip_address:port/item_id
          #
          set old_name $name
          set server [ns_info server]
          set port [ns_config ns/server/${server}/module/nssock port]
          set name [ns_info address]:${port}-[my item_id]
          set content [my serialize]
          set name $old_name
        } else {
          set content [my serialize]
        }
        my set creation_user  $old_creation_user
        my set modifying_user $old_modifying_user
        return $content
      }
  • instproc popular-tags

    ::xowiki::Page instproc popular-tags {} {
        my instvar package_id item_id parent_id
        set limit       [my query_parameter "limit" 20]
        set weblog_page [$package_id get_parameter weblog_page weblog]
        set href        [$package_id pretty_link $weblog_page]?summary=1
    
        set entries [list]
        db_foreach [my qn get_popular_tags]  [::xo::db::sql select  -vars "count(*) as nr, tag"  -from "xowiki_tags"  -where "item_id=$item_id"  -groupby "tag"  -orderby "nr"  -limit $limit] {
               lappend entries "<a href='$href&ptag=[ad_urlencode $tag]'>$tag ($nr)</a>"
             }
        ns_return 200 text/html "[_ xowiki.popular_tags_label]: [join $entries {, }]"
      }
  • instproc record_last_visited

    ::xowiki::Page instproc record_last_visited -user_id {
        my instvar item_id package_id
        if {![info exists user_id]} {set user_id [ad_conn user_id]}
        if {$user_id > 0} {
          # only record information for authenticated users
          db_dml [my qn update_last_visisted]  "update xowiki_last_visited set time = current_timestamp, count = count + 1  where page_id = $item_id and user_id = $user_id"
          if {[db_resultrows] < 1} {
            db_dml [my qn insert_last_visisted]  "insert into xowiki_last_visited (page_id, package_id, user_id, count, time)  values ($item_id, $package_id, $user_id, 1, current_timestamp)"
          }
        }
      }
  • instproc regsub_eval

    ::xowiki::Page instproc regsub_eval {{-noquote:boolean false} re string cmd {prefix {}}} {
        if {$noquote} {
          set map { \[ \\[ \] \\] \$ \\$ \\ \\\\}
        } else {
          set map { \" \\\" \[ \\[ \] \\] \$ \\$ \\ \\\\}
        }
        if {0 && $prefix eq "1"} {
          my msg "re=$re, string=$string cmd=$cmd"
          set c [regsub -all $re [string map $map $string] "\[$cmd\]"]
          my msg c0=$c
          regsub -all {\\1([$]?)\\2} $c {\\\\\1} c1
          my msg c1=$c1
          set s [subst $c1]
          my msg s=$s
          return $s
        }
        uplevel [list subst [regsub -all $re [string map $map $string] "\[$cmd\]"]]
      }
  • instproc render

    ::xowiki::Page instproc render -update_references:switch {
        my instvar item_id revision_id references lang unresolved_references parent_id
        my array set lang_links {found "" undefined ""}
        #my log "-- my class=[my info class]"
        set name [my set name]
        regexp {^(..):(.*)$} $name _ lang name
        set references [list]
        set unresolved_references 0
        my set __unresolved_references [list]
        #my log "--W setting unresolved_references to 0  [info exists unresolved_references]"
        set content [my get_content]
        #my msg "we have the content, update=$update_references, unresolved=$unresolved_references"
        if {$update_references || $unresolved_references > 0} {
          my update_references $item_id [lsort -unique $references]
        }
        
        unset references
        if {[my set mime_type] eq "text/html"} {
          append content "<DIV class='content-chunk-footer'>"
          if {![my exists __no_footer] && ![::xo::cc get_parameter __no_footer 0]} {
            append content [my footer]
          }
          append content "</DIV>\n"
        }
        return $content
      }
  • instproc render_includelet

    ::xowiki::Page instproc render_includelet includelet {
        #
        # The passed includelet is either an instance of ::xowiki::Page or
        # of ::xowiki::Includelet
        #
        foreach {att value} [$includelet set __caller_parameters] {
          switch -- $att {
            -decoration {$includelet set __decoration $value}
            -title {$includelet set title $value}
          }
        }
        if {[$includelet exists __decoration] && [$includelet set __decoration] ne "none"} {
          $includelet mixin add ::xowiki::includelet::decoration=[$includelet set __decoration]
        }
    
        set c [$includelet info class]
        if {[$c exists cacheable] && [$c cacheable]} {
          $includelet mixin add ::xowiki::includelet::page_fragment_cache
        }
    
        if {[$includelet istype ::xowiki::Includelet]} {
          # call this always
          $includelet include_head_entries
        }
    
        # "render" might be cached
        if {[catch {set html [$includelet render]} errorMsg]} {
          ns_log error "$errorMsg\n$::errorInfo"
          set page_name [$includelet name]
          set html [my error_during_render [_ xowiki.error-includelet-error_during_render]]
        }
        #my log "--include includelet returns $html"
        return $html
      }
  • 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
    ::xowiki::Page 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 reverse_map_party

    ::xowiki::Page instproc reverse_map_party {-entry -default_party {-create_user_ids 0}} {
        # So far, we just handle users, but we should support parties in
        # the future as well.http://localhost:8003/nimawf/admin/export
    
        array set "" $entry
        if {$(email) ne ""} {
          set id [party::get_by_email -email $(email)]
          if {$id ne ""} { return $id }
        } 
        if {$(username) ne ""} {
          set id [acs_user::get_by_username -username $(username)]
          if {$id ne ""} { return $id }
        }
        if {$create_user_ids} {
          my log "+++ create a new user username=$(username), email=$(email)"
          array set status [auth::create_user -username $(username) -email $(email)  -first_names $(first_names) -last_name $(last_name)  -screen_name $(screen_name) -url $(url)]
          if {$status(creation_status) eq "ok"} {
    	return $status(user_id)
          }
          my log "+++ create user username=${username}, email=$(email) failed, reason=$status(creation_status)"
        }
        return $default_party
      }
  • instproc reverse_map_party_attribute

    ::xowiki::Page instproc reverse_map_party_attribute {-attribute {-default_party 0} {-create_user_ids 0}} {
        if {![my exists $attribute]} {
          my set $attribute $default_party
        } elseif {[llength [my set $attribute]] < 2} {
          my set $attribute $default_party
        } else {
          my set $attribute [my reverse_map_party  -entry [my set $attribute]  -default_party $default_party  -create_user_ids $create_user_ids]
        }
      }
  • instproc revisions

    ::xowiki::Page instproc revisions {} {
        my instvar package_id name item_id
        set context [list [list [$package_id url] $name ] [_ xotcl-core.revisions]]
        set title "[_ xotcl-core.revision_title] '$name'"
        ::xo::Page set_property doc title $title
        set content [next]
        array set property_doc [::xo::Page get_property doc]
        $package_id return_page -adp /packages/xowiki/www/revisions -variables {
          content context {page_id $item_id} title property_doc
        }
      }
  • instproc save

    ::xowiki::Page instproc save args {
        [my package_id] flush_page_fragment_cache
        next
      }
  • instproc save-tags

    ::xowiki::Page instproc save-tags {} {
        my instvar package_id item_id revision_id
        ::xowiki::Page save_tags  -user_id [::xo::cc user_id]  -item_id $item_id  -revision_id $revision_id  -package_id $package_id  [my form_parameter new_tags]
    
        ::$package_id returnredirect  [my query_parameter "return_url" [$package_id url]]
      }
  • instproc save_attributes

    ::xowiki::Page 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 erros, 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" [$package_id pretty_link [my name]]]
          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" [$package_id pretty_link [my name]]]
      }
  • instproc save_data

    ::xowiki::Page instproc save_data {{-use_given_publish_date:boolean false} old_name category_ids} {
        #my log "-- [self args]"
        my unset_temporary_instance_variables
    
        my instvar package_id name
    
        db_transaction {
          #
          # if the newly created item was in production mode, but ordinary entries
          # are not, change on the first save the status to ready
          #
          if {[my is_new_entry $old_name]} {
            if {![$package_id get_parameter production_mode 0]} {
              my set publish_status "ready"
            }
          }
          my map_categories $category_ids
    
          my save -use_given_publish_date $use_given_publish_date
          #my log "-- old_name $old_name, name $name"
          if {$old_name ne $name} {
            #my msg "do rename from $old_name to $name"
            $package_id flush_name_cache -name $old_name -parent_id [my parent_id]
            my rename -old_name $old_name -new_name $name
          }
        }
        return [my item_id]
      }
  • instproc save_new

    ::xowiki::Page instproc save_new args {
        [my package_id] flush_page_fragment_cache
        next
      }
  • instproc set_content

    ::xowiki::Page instproc set_content text {
        my text [list [string map [list >> "\n&gt;&gt;" << "&lt;&lt;\n"]  [string trim $text " \n"]] text/html]
      }
  • instproc show_fields

    ::xowiki::Page instproc show_fields form_fields {
        # this method is for debugging only
        set msg ""
        foreach f $form_fields { append msg "[$f name] [namespace tail [$f info class]], " }
        my msg $msg
        my log "XXX ff: $msg"
      }
  • instproc substitute_markup

    ::xowiki::Page instproc substitute_markup source {
        set baseclass [expr {[[my info class] exists RE] ? [my info class] : [self class]}]
        $baseclass instvar RE markupmap
        #my log "-- baseclass for RE = $baseclass"
        if {[my set mime_type] eq "text/enhanced"} {
          set source [ad_enhanced_text_to_html $source]
        }
        if {![my do_substitutions]} {return [lindex $source 0]}
        set content ""
        set l ""; 
        foreach l0 [split [lindex $source 0] \n] {
          append l [string map $markupmap(escape) $l0]
          if {[string first \{\{ $l] > -1 && [string first \}\} $l] == -1} {append l " "; continue}
          set l [my regsub_eval $RE(anchor)  $l {my anchor  "\1"} "1"]
          set l [my regsub_eval $RE(div)     $l {my div     "\1"}]
          set l [my regsub_eval $RE(include) $l {my include_content "\1" "\2"}]
          #regsub -all $RE(clean) $l {\1} l
          regsub -all $RE(clean2) $l { \1} l
          set l [string map $markupmap(unescape) $l]
          append content $l \n
          set l ""
        }
        #my log "--substitute_markup returns $content"
        return $content
      }
  • instproc translate

    ::xowiki::Page instproc translate {-from -to text} {
        set langpair $from|$to
        set ie UTF8
        #set url [export_vars -base http://translate.google.com/translate_t {langpair text}]
        #set r [xo::HttpRequest new -url $url]
        set r [xo::HttpRequest new -url http://translate.google.com/translate_t  -post_data [export_vars {langpair text ie}]  -content_type application/x-www-form-urlencoded]
        #my msg status=[$r set status]
        if {[$r set status] eq "finished"} {
          set data [$r set data]
          dom parse -simple -html $data doc
          $doc documentElement root
          set n [$root selectNodes {//div[@id="result_box"]}]
          #my msg "$text $from=>$to [$n asText]"
          return [$n asText]
        } else {
          util_user_message -message "Could not translate text,  status=[$r set status] reason=[$r set cancel_message]"
        }
      }
  • instproc unescape

    ::xowiki::Page instproc unescape string {
        # Some browsers change {{cmd -flag "..."}} into {{cmd -flag &quot;...&quot;}}
        # We have to change this back
        return [string map [list "&gt;" > "&lt;" < "&quot;" \" "&amp;" & "&semicolon;" {;} ] $string]
      }
  • instproc unset_temporary_instance_variables

    ::xowiki::Page instproc unset_temporary_instance_variables {} {
        # never save/cache __ia or __field_in_form
        my array unset __ia
        my array unset __field_in_form
      }
  • instproc update_references

    ::xowiki::Page instproc update_references {page_id references} {
        db_dml [my qn delete_references]  "delete from xowiki_references where page = $page_id"
        foreach ref $references {
          foreach {r link_type} $ref break
          db_dml [my qn insert_reference]  "insert into xowiki_references (reference, link_type, page)  values ($r,:link_type,$page_id)"
        }
       }
  • instproc validate=form_constraints

    ::xowiki::Page instproc validate=form_constraints form_constraints {
        #
        # First check for invalid meta characters for security reasons.
        #
        if {[regexp {[\[\]]} $form_constraints]} {
          my uplevel [list set errorMsg  [_ xowiki.error-form_constraint-invalid_characters]]
          return 0
        }
        #
        # Create from fields from all specs and report, if there are any errors
        #
        if {[catch {
          my create_form_fields_from_form_constraints $form_constraints
        } errorMsg]} {
          ns_log error "$errorMsg\n$::errorInfo"
          my uplevel [list set errorMsg $errorMsg]
          #my msg "ERROR: invalid spec '$short_spec' for form field '$spec_name' -- $errorMsg"
          return 0
        }
        return 1
      }
  • instproc validate=name

    ::xowiki::Page instproc validate=name name {
        upvar nls_language nls_language
        my set data [self]  ;# for the time being; change clobbering when validate_name becomes a method
        set success [::xowiki::validate_name]
        if {$success} {
          # set the instance variable with a potentially prefixed name
          # the classical validators do just an upvar
          my set name $name
        }
        return $success
      }
  • instproc validate=page_order

    ::xowiki::Page instproc validate=page_order value {
        if {[my exists page_order]} {
          set page_order [string trim $value " ."]
          my page_order $page_order
          return [expr {![regexp {[^0-9a-zA-Z_.]} $page_order]}]
        }
        return 1
      }
  • instproc view

    ::xowiki::Page instproc view {{content {}}} {
        # The method "view" is used primarily for the toplevel call, when
        # the xowiki page is viewed.  It is not intended for e.g. embedded
        # wiki pages (see include), since it contains full framing, etc.
        my instvar package_id item_id 
        $package_id instvar folder_id  ;# this is the root folder
        ::xowiki::Page set recursion_count 0
    
        set template_file [my query_parameter "template_file"  [::$package_id get_parameter template_file view-default]]
    
        if {[my isobject ::xowiki::$template_file]} {
          $template_file before_render [self]
        }
        
        # the content may be passed by other methods (e.g. edit) to 
        # make use of the same templating machinery below.
        if {$content eq ""} {
          set content [my render]
          #my log "--after render"
        }
    
        set footer [my htmlFooter -content $content]
        set top_includelets ""
        set vp [string trim [$package_id get_parameter "top_includelet" ""]]
        if {$vp ne ""} {
          set top_includelets [my include $vp]
        }
    
        if {[$package_id get_parameter "with_user_tracking" 1]} {
          my record_last_visited
        }
    
        # Deal with the views package (many thanks to Malte for this snippet!)
        if {[$package_id get_parameter with_views_package_if_available 1] 
    	&& [apm_package_installed_p "views"]} {
          views::record_view -object_id $item_id -viewer_id [::xo::cc user_id]
          array set views_data [views::get -object_id $item_id]
        }
    
        # import title, name and text into current scope
        my instvar title name text
    
        if {[my exists_query_parameter return_url]} {
          set return_url [my query_parameter return_url]
        }
        
        if {[$package_id get_parameter "with_notifications" 1]} {
          if {[::xo::cc user_id] != 0} { ;# notifications require login
            set notifications_return_url [expr {[info exists return_url] ? $return_url : [ad_return_url]}]
            set notification_type [notification::type::get_type_id -short_name xowiki_notif]
            set notification_text "Subscribe the XoWiki instance"
            set notification_subscribe_link  [export_vars -base /notifications/request-new  {{return_url $notifications_return_url}
                       {pretty_name $notification_text} 
                       {type_id $notification_type} 
                       {object_id $package_id}}]
            set notification_image  "<img style='border: 0px;' src='/resources/xowiki/email.png'  alt='$notification_text' title='$notification_text'>"
          }
        }
        #my log "--after notifications [info exists notification_image]"
    
        set master [$package_id get_parameter "master" 1]
        #if {[my exists_query_parameter "edit_return_url"]} {
        #  set return_url [my query_parameter "edit_return_url"]
        #}
        #my log "--after options master=$master"
    
        if {$master} {
          set context [list $title]
          ::xo::Page set_property doc title "[$package_id instance_name] - $title"
          set autoname    [$package_id get_parameter autoname 0]
          set object_type [$package_id get_parameter object_type [my info class]]
          set rev_link    [$package_id make_link -with_entities 0 [self] revisions]
          if {[$package_id query_parameter m ""] eq "edit"} {
            set view_link   [$package_id make_link -with_entities 0 [self] view return_url]
          } else {
            set edit_link   [$package_id make_link -with_entities 0 [self] edit return_url]
          }
          set delete_link [$package_id make_link -with_entities 0 [self] delete return_url]
          if {[my exists __link(new)]} {
            set new_link [my set __link(new)]
          } else {
            if {[my istype ::xowiki::FormPage]} {
              set template_id [my page_template]
              set form      [$package_id pretty_link [$template_id name]]
              set new_link  [$package_id make_link -with_entities 0 -link $form $template_id create-new return_url]
            } else {
              set new_link  [$package_id make_link -with_entities 0 $package_id edit-new object_type return_url autoname] 
            }
          }
          set admin_link  [$package_id make_link -privilege admin -link admin/ $package_id {} {}] 
          set index_link  [$package_id make_link -privilege public -link "" $package_id {} {}]
          set create_in_req_locale_link ""
    
          if {[$package_id get_parameter use_connection_locale 0]} {
            $package_id get_lang_and_name -path [$package_id set object] req_lang req_local_name
            set default_lang [$package_id default_language]
            if {$req_lang ne $default_lang} {
              set l [Link create new -destroy_on_cleanup  -page [self] -type language -stripped_name $req_local_name  -name ${default_lang}:$req_local_name -lang $default_lang  -label $req_local_name -parent_id $folder_id  -package_id $package_id -init  -return_only undefined]
              $l render
            }
          }
    
          #my log "--after context delete_link=$delete_link "
          set template [$folder_id get_payload template]
          set page [self]
    
          if {$template ne ""} {
            set __including_page $page
            set __adp_stub [acs_root_dir]/packages/xowiki/www/view-default
            set template_code [template::adp_compile -string $template]
            if {[catch {set content [template::adp_eval template_code]} errmsg]} {
              ns_return 200 text/html "Error in Page $name: $errmsg<br />$template"
            } else {
              ns_return 200 text/html $content
            }
          } else {
            # use adp file
            #my log "use adp"
            foreach css [$package_id get_parameter extra_css ""] {::xo::Page requireCSS -order 10 $css}
            # refetch it, since it might have been changed via set-parameter
            set template_file [my query_parameter "template_file"  [::$package_id get_parameter template_file view-default]]
    
    	# if the template_file does not have a path, assume it in xowiki/www
            if {![regexp {^[./]} $template_file]} {
              set template_file /packages/xowiki/www/$template_file
            }
    	
            set header_stuff [::xo::Page header_stuff]
    	if {[info command ::template::head::add_meta] ne ""} {
    	  template::head::add_meta -name language -content [my lang]
    	  template::head::add_meta -name description -content [my description]
    	  template::head::add_meta -name keywords -content [$package_id get_parameter keywords ""]
    	}
    
            #
            # pass variables for properties doc and body
            # example: ::xo::Page set_property body class "yui-skin-sam"
            #
            array set property_body [::xo::Page get_property body]
            array set property_doc  [::xo::Page get_property doc]
            # ns_log notice "XOWIKI body=[::xo::Page get_property body]"
            $package_id return_page -adp $template_file -variables {
              name title item_id context header_stuff return_url
              content footer package_id
              rev_link edit_link delete_link new_link admin_link index_link view_link
              notification_subscribe_link notification_image 
              top_includelets page
              views_data property_body property_doc
            }
          }
        } else {
          ns_return 200 [::xo::cc get_parameter content-type text/html] $content
        }
      }

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