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::PackageMgr[i] ::xowiki::Package

Class Hierarchy of ::xowiki::Package

  • ::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::Package[i]
        Meta-class:
        ::xo::PackageMgr[i]
        Parameter for instances:
        context (default "::xo::cc"), force_refresh_login (default "false"), id, package_url, url
        Methods for instances:
        default_localeC, exists_form_parameterC, exists_query_parameterC, form_parameterC, get_parameter, init, initialize, insert, instance_nameC, package_idC, package_keyC, query_parameterC, reply_to_user, require_root_folder, return_page, returnredirectC, save, set_url
        Methods to be applied on the class:
        Methods provided by the meta-class
        • ::xowiki::Package[i]
          Meta-class:
          ::xo::PackageMgr[i]
          Parameter for instances:
          folder_id (default "0"), force_refresh_login (default "false")
          Methods for instances:
          call, change-page-order, check_permissionsC, condition=has_class, condition=has_name, create_new_snippet, default_language, default_locale, delete, delete_revision, edit-category-tree, edit-new, error_msg, external_name, flush_name_cache, flush_page_fragment_cache, flush_references, folder_path, get_lang_and_name, get_package_id_from_page_name, get_page_from_item_or_revision_id, get_page_from_item_ref, get_page_from_name, get_page_from_super, get_parameter, get_parent_and_name, google-sitemap, google-sitemapindex, import, import-prototype-page, init, insert, invoke, item_info_from_id, item_info_from_url, item_ref, lookup, make_form_link, make_link, manage-categories, normalize_name, package_idC, package_path, prefixed_lookup, pretty_link, refresh-login, reindex, require_folder_object, require_root_folder, resolve_package_path, resolve_page, resolve_page_name, resolve_page_name_and_init_context, rss, show_page_order, simple_item_ref
          Methods to be applied on the class (in addition to the methods provided by the meta-class):
          get_package_id_from_page_id, get_site_wide_page, get_url_from_id, google-sitemapindex, import_prototype_page, instantiate_page_from_id, lookup_side_wide_page, require_site_wide_pages

Class Relations

  • superclass: ::xo::Package[i]
  • instmixin: ::xowiki::ParameterCache[i]
  • subclass: ::s5::Package[i], ::xowf::Package[i]
::xo::PackageMgr create ::xowiki::Package \
     -superclass ::xo::Package \
     -parameter {{folder_id 0} {force_refresh_login false}} \
     -instmixin ::xowiki::ParameterCache

Methods

  • proc get_package_id_from_page_id (public)

    ::xowiki::Package[i] get_package_id_from_page_id \
        [ -revision_id revision_id ] [ -item_id item_id ]
    Obtain the package_id from either the item_id or the revision_id of a page

    Switches:
    -revision_id (defaults to "0") (optional)
    -item_id (defaults to "0") (optional)
    ::1773708 proc get_package_id_from_page_id {{-revision_id 0} {-item_id 0}} {
        if {$revision_id} {
          set object_id $revision_id
        } elseif {$item_id} {
          set object_id $item_id
        } else {
    	error "Either item_id or revision_id must be provided"
        }
        return [::xo::db_string get_pid {select package_id from acs_objects where object_id = :object_id}]
      }
    
  • proc get_url_from_id (public)

    ::xowiki::Package[i] get_url_from_id [ -item_id item_id ] \
        [ -revision_id revision_id ]
    Get the full URL from a page in situations, where the context is not set up.

    Switches:
    -item_id (defaults to "0") (optional)
    -revision_id (defaults to "0") (optional)

    See Also:
    • instantiate_page_from_id
    ::1773708 proc get_url_from_id {{-item_id 0} {-revision_id 0}} {
        set page [::xowiki::Package instantiate_page_from_id  -item_id $item_id -revision_id $revision_id]
        return [::[$page package_id] url] 
      }
    
  • proc google-sitemapindex (public)

    ::xowiki::Package[i] google-sitemapindex [ -changefreq changefreq ] \
        [ -priority priority ]
    Provide a sitemap index of all xowiki instances in google site map format https://www.google.com/webmasters/sitemaps/docs/en/protocol.html

    Switches:
    -changefreq (defaults to "daily") (optional)
    changefreq as defined by google
    -priority (defaults to "priority") (optional)
    priority as defined by google
    ::1773708 proc google-sitemapindex {{-changefreq "daily"} {-priority "priority"}} {
      
        set content {<?xml version="1.0" encoding="UTF-8"?>
    <sitemapindex xmlns="http://www.google.com/schemas/sitemap/0.84">
    }
        foreach package_id  [::xowiki::Package instances] {
          if {![::xo::parameter get -package_id $package_id  -parameter include_in_google_sitemap_index -default 1]} {
    	continue
          } 
          set last_modified [::xo::db_string get_newest_modification_date  {select last_modified from acs_objects 
    			       where package_id = :package_id 
    			       order by last_modified desc limit 1}]
    
          set time [::xo::db::tcl_date $last_modified tz]
          set time "[clock format [clock scan $time] -format {%Y-%m-%dT%T}]${tz}:00"
    
          #my log "--site_node::get_from_object_id -object_id $package_id"
          array set info [site_node::get_from_object_id -object_id $package_id]
    
          append content <sitemap> \n <loc>[ad_url]$info(url)sitemap.xml</loc> \n <lastmod>$time</lastmod> \n </sitemap> 
        }
        append content </sitemapindex> \n
        #set t text/plain
        set t text/xml
        ns_return 200 $t $content
      }
    
  • proc instantiate_page_from_id (public)

    ::xowiki::Package[i] instantiate_page_from_id \
        [ -revision_id revision_id ] [ -item_id item_id ] \
        [ -user_id user_id ] [ -parameter parameter ]
    Instantiate a page in situations, where the context is not set up (e.g. we have no package object). This call is convenient when testing e.g. from the developer shell

    Switches:
    -revision_id (defaults to "0") (optional)
    -item_id (defaults to "0") (optional)
    -user_id (defaults to "-1") (optional)
    -parameter (optional)
    ::1773708 proc instantiate_page_from_id {{-revision_id 0} {-item_id 0} {-user_id -1} {-parameter ""}} {
        set package_id [my get_package_id_from_page_id  -item_id $item_id  -revision_id $revision_id]
        ::xo::Package initialize  -export_vars false  -package_id $package_id  -init_url false -actual_query ""  -parameter $parameter  -user_id $user_id
        set page [::xo::db::CrClass get_instance_from_db -item_id $item_id -revision_id $revision_id]
        ::$package_id set_url -url [$page pretty_link]
        return $page
      }
    
  • instproc change-page-order (public)

    <instance of ::xowiki::Package[i]> change-page-order
    Change Page Order for pages by renumbering and filling gaps.

    ::1773708 instproc change-page-order {} {
        my instvar folder_id
        set to    [string trim [my form_parameter to ""]]
        set from  [string trim [my form_parameter from ""]]
        set clean [string trim [my form_parameter clean ""]]  ;# only for inserts
    
        #set from {1.2 1.3 1.4}; set to {1.3 1.4 1.2}; set clean {...}
        #set from {1.2 1.3 1.4}; set to {1.3 1.4 2.1 1.2}; set clean {2.1}
        #set from {1 2}; set to {1 1.2 2}; set clean {1.2 1.3 1.4}
    
        if {$from eq "" || $to eq "" || [llength $to]-[llength $from] >1 || [llength $to]-[llength $from]<0} {
          my log "unreasonable request from='$from', to='$to'"
          return
        }
        my log "--cpo from=$from, to=$to, clean=$clean"
        set gap_renames [list]
        #
        # We distinguish two cases:
        # - pure reordering: length(to) == length(from)
        # - insert from another section: length(to) == length(from)+1
        #
        if {[llength $to] == [llength $from]} {
          my log "--cpo reorder"
        } elseif {[llength $clean] > 1} {
          my log "--cpo insert"
          #
          # We have to fill the gap. First, find the newly inserted
          # element in $to.
          #
          foreach e $to {
            if {[lsearch -exact $from $e] == -1} {
              set inserted $e
              break
            }
          }
          if {![info exists inserted]} {error "invalid 'to' list (no inserted element detected)"}
          # 
          # compute the remaining list
          #
          set remaining [list]
          foreach e $clean {if {$e ne $inserted} {lappend remaining $e}}
          #
          # compute rename rename commands for it
          #
          set gap_renames [::xowiki::utility page_order_renames -parent_id $folder_id  -start [lindex $clean 0] -from $remaining -to $remaining]
          foreach {page_id item_id name old_page_order new_page_order} $gap_renames {
            my log "--cpo gap $page_id (name) rename $old_page_order to $new_page_order"
          }
        }
        #
        # Compute the rename commands for the drop target
        #
        set drop_renames [::xowiki::utility page_order_renames -parent_id $folder_id  -start [lindex $from 0] -from $from -to $to]
        #my log "--cpo drops l=[llength $drop_renames]"
        foreach {page_id item_id name old_page_order new_page_order} $drop_renames {
          my log "--cpo drop $page_id ($name) rename $old_page_order to $new_page_order"
        }
    
        #
        # Perform the actual renames
        #
        set temp_obj [::xowiki::Page new -name dummy -volatile]
        set slot [$temp_obj find_slot page_order]
        db_transaction {
          foreach {page_id item_id name old_page_order new_page_order} [concat $drop_renames $gap_renames] {
            #my log "--cpo UPDATE $page_id new_page_order $new_page_order"
    	$temp_obj item_id $item_id
            $temp_obj update_attribute_from_slot -revision_id $page_id $slot $new_page_order
            ::xo::clusterwide ns_cache flush xotcl_object_cache ::$item_id
            ::xo::clusterwide ns_cache flush xotcl_object_cache ::$page_id
          }
        }
        #
        # Flush the page fragement caches (page fragments based on page_order might be sufficient)
        my flush_page_fragment_cache -scope agg
        ns_return 200 text/plain ok
      }
    
  • instproc external_name (public)

    <instance of ::xowiki::Package[i]> external_name \
        [ -parent_id parent_id ] name
    Generate a name with a potentially inserted parent name

    Switches:
    -parent_id (optional)
    parent_id (for now just for download)
    Parameters:
    name - name of the wiki page
    ::1773708 instproc external_name {{-parent_id ""} name} {
        set folder [my folder_path -parent_id $parent_id]
        if {$folder ne ""} {
          # Return the stripped name for sub-items, the parent has already
          # the language prefix
          #my get_lang_and_name -name $name lang stripped_name
          return $folder$name
        }
        return $name
    
      }
    
  • instproc get_parameter (public)

    <instance of ::xowiki::Package[i]> get_parameter \
        [ -check_query_parameter check_query_parameter ] [ -type type ] \
        attribute [ default ]
    resolves configurable parameters according to the following precedence: (1) values specifically set per page {{set-parameter ...}} (2) query parameter (3) form fields from the parameter_page FormPage (4) standard OpenACS package parameter

    Switches:
    -check_query_parameter (defaults to "true") (optional)
    -type (optional)
    Parameters:
    attribute
    default (optional)
    ::1773708 instproc get_parameter {{-check_query_parameter true} {-type ""} attribute {default {}}} {
        set value [::xo::cc get_parameter $attribute]
        if {$check_query_parameter && $value eq ""} {set value [string trim [my query_parameter $attribute]]}
        if {$value eq "" && $attribute ne "parameter_page"} {
          #
          # Try to get the parameter from the parameter_page.  We have to
          # be very cautious here to avoid recursive calls (e.g. when
          # resolve_page_name needs as well parameters such as
          # use_connection_locale or subst_blank_in_name, etc.).
          #
          set pp [my get_parameter parameter_page ""]
          if {$pp ne ""} {
            if {![regexp {/?..:} $pp]} {
              my log "Error: Name of parameter page '$pp' of package [my id] must contain a language prefix"
            } else {
              set page [::xo::cc cache [list [self] get_page_from_item_ref $pp]]
              if {$page eq ""} {
                my log "Error: Could not resolve parameter page '$pp' of package [my id]."
              }
              #my msg pp=$pp,page=$page-att=$attribute
    
              if {$page ne "" && [$page exists instance_attributes]} {
                array set __ia [$page set instance_attributes]
                if {[info exists __ia($attribute)]} {
                  set value $__ia($attribute)
                  #my log "got value='$value'"
                }
              }
            }
          }
        }
        #if {$value eq ""} {set value [::[my folder_id] get_payload $attribute]}
        if {$value eq ""} {set value [next $attribute $default]}
        if {$type ne ""} {
          # to be extended and generalized
          switch $type {
            word {if {[regexp {\W} $value]} {error "value '$value' contains invalid character"}}
            default {error "requested type unknown: $type"}
          }
        }
        #my log "           $attribute returns '$value'"
        return $value
      }
    
  • instproc google-sitemap (public)

    <instance of ::xowiki::Package[i]> google-sitemap \
        [ -max_entries max_entries ] [ -changefreq changefreq ] \
        [ -priority priority ]
    Report content of xowiki folder in google site map format https://www.google.com/webmasters/sitemaps/docs/en/protocol.html

    Switches:
    -max_entries (optional)
    -changefreq (defaults to "daily") (optional)
    changefreq as defined by google
    -priority (defaults to "0.5") (optional)
    priority as defined by google
    ::1773708 instproc google-sitemap {{-max_entries ""} {-changefreq "daily"} {-priority "0.5"}} {
        set package_id [my id]
        set folder_id [::$package_id folder_id]
       
        set timerange_clause ""
        
        set content {<?xml version="1.0" encoding="UTF-8"?>
    <urlset xmlns="http://www.google.com/schemas/sitemap/0.84"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://www.google.com/schemas/sitemap/0.84
    	http://www.google.com/schemas/sitemap/0.84/sitemap.xsd">
    }
    
        set sql [::xo::db::sql select  -vars "ci.parent_id, s.body, p.name, p.creator, p.title, p.page_id, p.object_type as content_type, p.last_modified, p.description"  -from "xowiki_pagex p, syndication s, cr_items ci"  -where "ci.parent_id = $folder_id and ci.live_revision = s.object_id  and s.object_id = p.page_id $timerange_clause"  -orderby "p.last_modified desc"  -limit $max_entries]
        #my log $sql
        db_foreach [my qn get_pages] $sql {
          #my log "--found $name"
          if {[string match "::*" $name]} continue
          if {$content_type eq "::xowiki::PageTemplate::"} continue
          
          set time [::xo::db::tcl_date $last_modified tz]
          set time "[clock format [clock scan $time] -format {%Y-%m-%dT%T}]${tz}:00"
    
          append content <url> \n <loc>[::$package_id pretty_link -absolute true -parent_id $parent_id $name]</loc> \n <lastmod>$time</lastmod> \n <changefreq>$changefreq</changefreq> \n <priority>$priority</priority> \n </url> \n
        }
        
        append content </urlset> \n
    
        #set t text/plain
        set t text/xml
        ns_return 200 $t $content
      }
    
  • instproc import (public)

    <instance of ::xowiki::Package[i]> import [ -user_id user_id ] \
        [ -parent_id parent_id ] [ -replace replace ] [ -objects objects ] \
        [ -create_user_ids create_user_ids ]
    import the specified pages into the xowiki instance

    Switches:
    -user_id (optional)
    -parent_id (defaults to "0") (optional)
    -replace (defaults to "0") (optional)
    -objects (optional)
    -create_user_ids (defaults to "0") (optional)
    ::1773708 instproc import {-user_id {-parent_id 0} {-replace 0} -objects {-create_user_ids 0}} {
        if {$parent_id == 0} {set parent_id  [my folder_id]}
        if {![info exists user_id]} {set user_id [::xo::cc user_id]}
        if {![info exists objects]} {set objects [::xowiki::Page allinstances]}
        set msg "processing objects: $objects<p>"
        set importer [Importer new -package_id [my id] -parent_id $parent_id -user_id $user_id]
        $importer import_all -replace $replace -objects $objects -create_user_ids $create_user_ids
        append msg [$importer report]
      }
    
  • instproc item_ref (public)

    <instance of ::xowiki::Package[i]> item_ref \
        [ -use_package_path use_package_path ] \
        [ -use_site_wide_pages use_site_wide_pages ] \
        [ -normalize_name normalize_name ] -default_lang default_lang  \
        -parent_id parent_id  link
    An item_ref refers to an item (existing or nonexisting) in the content repository relative to some parent_id. The item might be either a folder or some kind of "page" (e.g. a file). An item_ref might be complex, i.e. consist of a path of simple_item_refs, separated by "/". An item_ref stops at the first unknown part in the path and returns item_id == 0 and the appropriate parent_id (and name etc.) for insertion.

    Switches:
    -use_package_path (defaults to "false") (optional)
    -use_site_wide_pages (defaults to "false") (optional)
    -normalize_name (defaults to "true") (optional)
    -default_lang (required)
    -parent_id (required)
    Parameters:
    link
    Returns:
    item info containing link_type form prefix stripped_name item_id parent_id
    ::1773708 instproc item_ref {{-use_package_path false} {-use_site_wide_pages false} {-normalize_name true} -default_lang:required -parent_id:required link} {
        # A trailing slash says that the last element is a folder. We
        # substitute it to allow easy iteration over the slash separated
        # segments.
        if {[string match */ $link]} {
          set llink [string trimright $link /]\0
        } else {
          set llink $link
        }
    
        set elements [split $llink /]
        # Get start-page, if path is empty
        if {[llength $elements] == 0} {
          set link [my get_parameter index_page "index"]
          set elements [list $link]
        }
    
        # Iterate until the first unknown element appears in the path
        # (we can handle only one unknown at a time).
        set nr_elements [llength $elements]
        set n 0
        set ref_ids {}
        foreach element $elements {
          set (last_parent_id) $parent_id
          lappend ref_ids $parent_id
          array set "" [my simple_item_ref  -normalize_name $normalize_name  -use_package_path $use_package_path  -use_site_wide_pages $use_site_wide_pages  -default_lang $default_lang  -parent_id $parent_id  -assume_folder [expr {[incr n] < $nr_elements}]  $element]
          #my msg "simple_item_ref $element => [array get {}]"
          if {$(item_id) == 0} {
            set parent_id $(parent_id)
            break
          } else {
            set parent_id $(item_id)
          }
        }
    
        return [list link $link link_type $(link_type) form $(form)  prefix $(prefix) stripped_name $(stripped_name)  item_id $(item_id) parent_id $(parent_id) ref_ids $ref_ids]
      }
    
  • instproc make_link (public)

    <instance of ::xowiki::Package[i]> make_link \
        [ -with_entities with_entities ] [ -privilege privilege ] \
        [ -link link ] object method args
    Creates conditionally a link for use in xowiki. When the generated link will be activated, the specified method of the object will be invoked. make_link checks in advance, wether the actual user has enough rights to invoke the method. If not, this method returns empty.

    Switches:
    -with_entities (defaults to "0") (optional)
    -privilege (optional)
    -link (optional)
    Parameters:
    object
    method - Which method to use. This will be appended as "m=method" to the url. Examples for methods:
    • view: To view and existing page
    • edit: To edit an existing page
    • revisions: To view the revisions of an existing page

    args - List of attributes to be append to the link. Every element can be an attribute name, or a "name value" pair. Behaves like export_vars.
    Returns:
    The link or empty

    See Also:
    ::1773708 instproc make_link {{-with_entities 0} -privilege -link object method args} {
        my instvar id
    
        set computed_link ""
        #set msg "make_link obj=$object, [$object info class]"
        #if {[info exists link]} {append msg " link '$link'"}
        #if {"::xowiki::Page" in [$object info precedence]} {
        #  append msg " [$object name] [$object package_id] [$object physical_package_id]"
        #}
        #my msg $msg
        if {[$object istype ::xowiki::Package]} {
          set base  [my package_url]
          if {[info exists link]} {
            set computed_link [uplevel export_vars -base [list $base$link] [list $args]]
          } else {
            lappend args [list $method 1]
            set computed_link [uplevel export_vars -base [list $base] [list $args]]
            }
        } elseif {[$object istype ::xowiki::Page]} {
          if {[info exists link]} {
            set base $link
          } else {
            set base [my url]
            #my msg "base = '[my url]'"
          }
          lappend args [list m $method]
          set computed_link [uplevel export_vars -base [list $base] [list $args]]
          #my msg "computed_link = '$computed_link'"
        }
        if {$with_entities} {
          regsub -all & $computed_link "&amp;" computed_link
        }
    
        # provide links based in untrusted_user_id
        set party_id [::xo::cc set untrusted_user_id]
        if {[info exists privilege]} {
          #my log "-- checking priv $privilege for [self args] from id $id"
          set granted [expr {$privilege eq "public" ? 1 :
                             [::xo::cc permission -object_id $id -privilege $privilege -party_id $party_id] }]
        } else {
          # determine privilege from policy
          #my msg "-- check permissions from $id of object $object $method"
          if {[catch {
    	set granted [my check_permissions  -user_id $party_id  -package_id $id  -link $computed_link $object $method]
          } errorMsg ]} {
    	my log "error in check_permissions: $errorMsg"
    	set granted 0
          }
          #my msg "--p $id check_permissions $object $method ==> $granted"
        }
        #my log "granted=$granted $computed_link"
        if {$granted} {
          return $computed_link
        }
        return ""
      }
    
  • instproc pretty_link (public)

    <instance of ::xowiki::Package[i]> pretty_link [ -anchor anchor ] \
        [ -query query ] [ -absolute on|off ] [ -siteurl siteurl ] \
        [ -lang lang ] [ -parent_id parent_id ] [ -download download ] \
        [ -context_url context_url ] [ -folder_ids folder_ids ] name
    Generate a (minimal) link to a wiki page with the specified name. Pratically all links in the xowiki systems are generated through this function.

    Switches:
    -anchor (optional)
    anchor to be added to the link
    -query (optional)
    -absolute (boolean) (defaults to "false") (optional)
    make an absolute link (including protocol and host)
    -siteurl (optional)
    -lang (optional)
    use the specified 2 character language code (rather than computing the value)
    -parent_id (optional)
    parent_id (for now just for download)
    -download (defaults to "false") (optional)
    create download link (without m=download)
    -context_url (optional)
    -folder_ids (optional)
    Parameters:
    name - name of the wiki page
    ::1773708 instproc pretty_link {{-anchor ""} {-query ""} {-absolute:boolean false} {-siteurl ""} {-lang ""} {-parent_id ""} {-download false} {-context_url ""} {-folder_ids ""} name} {
        #my msg "input name=$name, lang=$lang parent_id=$parent_id"
        set default_lang [my default_language]
        
        my get_lang_and_name -default_lang $lang -name $name lang name
    
        set host [expr {$absolute ? ($siteurl ne "" ? $siteurl : [ad_url]) : ""}]
        if {$anchor ne ""} {set anchor \#$anchor}
        if {$query ne ""} {set query ?$query}
        #my log "--LINK $lang == $default_lang [expr {$lang ne $default_lang}] $name"
    
        set package_prefix [my get_parameter package_prefix [my package_url]]
        if {$package_prefix eq "/" && [string length $lang]>2} {
          # don't compact the the path for images etc. to avoid conflicts
          # with e.g. //../image/*
          set package_prefix [my package_url]
        }
        #my msg "lang=$lang, default_lang=$default_lang, name=$name, parent_id=$parent_id, package_prefix=$package_prefix"
    
        if {[ns_info name] eq "NaviServer"} {
          set encoded_name [ns_urlencode -part path -- $name]
        } else {
          set encoded_name [::xowiki::utility urlencode $name]
        }
        
        if {$parent_id eq -100} {
          # In case, we have a cr-toplevel entry, we assume, we can
          # resolve it at lease against the root folder of the current
          # package.
          set folder ""
        } else {
          set folder [my folder_path -parent_id $parent_id -folder_ids $folder_ids]
          set pkg [$parent_id package_id]
          set package_prefix [$pkg get_parameter package_prefix [$pkg package_url]]
        }
        #my msg "folder_path = $folder, -parent_id $parent_id -folder_ids $folder_ids // default_lang [my default_language]"
    
        # if {$folder ne ""} {
        #   # if folder has a different language than the content, we have to provide a prefix....
        #   regexp {^(..):} $folder _ default_lang
        # }
    
        #my log "h=${host}, prefix=${package_prefix}, folder=$folder, name=$encoded_name anchor=$anchor download=$download"
        #my msg folder=$folder,lang=$lang,default_lang=$default_lang
        if {$download} {
          #
          # use the special download (file) syntax
          #
          set url ${host}${package_prefix}download/file/$folder$encoded_name$query$anchor
        } elseif {$lang ne $default_lang || [[self class] exists www-file($name)]} {
          #
          # If files are physical files in the www directory, add the
          # language prefix
          #
          set url ${host}${package_prefix}${lang}/$folder$encoded_name$query$anchor
        } else {
          #
          # Use the short notation without language prefix
          #
          set url ${host}${package_prefix}$folder$encoded_name$query$anchor
        }
        #my msg "final url=$url"
        return $url
      }
    
  • instproc refresh-login (public)

    <instance of ::xowiki::Package[i]> refresh-login
    Force a refresh of a login and do a redict. Intended for use from ajax.

    ::1773708 instproc refresh-login {} {
        set return_url [my query_parameter return_url]
        if {[::xo::cc user_id] == 0} {
          set url [subsite::get_url]register
          ad_returnredirect [export_vars -base $url return_url]
        } else {
          ad_returnredirect $return_url
        }
      }
    
  • instproc reindex (public)

    <instance of ::xowiki::Package[i]> reindex
    reindex all items of this package

    ::1773708 instproc reindex {} {
        my instvar folder_id id
        set pages [::xo::db_list qn get_pages {
          select page_id,package_id from xowiki_page, cr_revisions r, cr_items ci, acs_objects o 
          where page_id = r.revision_id and ci.item_id = r.item_id and ci.live_revision = page_id
          and publish_status = 'ready'
          and page_id = o.object_id and o.package_id = :id
        }]
        #my log "--reindex returns <$pages>"
        foreach page_id $pages {
          #search::queue -object_id $page_id -event DELETE
          search::queue -object_id $page_id -event INSERT
        }
        ad_returnredirect .
      }
    
  • instproc require_root_folder (public)

    <instance of ::xowiki::Package[i]> require_root_folder \
        [ -parent_id parent_id ] [ -content_types content_types ] \
        -name name 
    Make sure, the root folder for the given package exists. If not, create it and register all allowed content types.

    Switches:
    -parent_id (defaults to "-100") (optional)
    -content_types (optional)
    -name (required)
    Returns:
    folder_id
    ::1773708 instproc require_root_folder {{-parent_id -100} {-content_types {}} -name:required} {
        my instvar id
    
        set folder_id [ns_cache eval xotcl_object_type_cache root_folder-$id {
          
          set folder_id [::xo::db::CrClass lookup -name $name -parent_id $parent_id]
          if {$folder_id == 0} {
            ::xowiki::Package require_site_wide_pages
            set form_id [::xowiki::Weblog instantiate_forms -forms en:folder.form -package_id $id]
            set f [FormPage new -destroy_on_cleanup  -name $name  -text ""  -package_id $id  -parent_id $parent_id  -nls_language en_US  -publish_status ready  -instance_attributes {}  -page_template $form_id]
            $f save_new
            set folder_id [$f item_id]
    
    	::xo::db::sql::acs_object set_attribute -object_id_in $folder_id  -attribute_name_in context_id -value_in $id
    
            my log "CREATED folder '$name' and parent $parent_id ==> $folder_id"
          }
    
          # register all specified content types
          #::xo::db::CrFolder register_content_types  #    -folder_id $folder_id  #    -content_types $content_types
          #my log "returning from cache folder_id $folder_id"
          return $folder_id
        }]
        #my log "returning from require folder_id $folder_id"
        return $folder_id
      }
    
  • instproc rss (public)

    <instance of ::xowiki::Package[i]> rss [ -maxentries maxentries ] \
        [ -name_filter name_filter ] [ -entries_of entries_of ] \
        [ -title title ] [ -days days ]
    Report content of xowiki folder in rss 2.0 format. The reporting order is descending by date. The title of the feed is taken from the title, the description is taken from the description field of the folder object.

    Switches:
    -maxentries (optional)
    maximum number of entries retrieved
    -name_filter (optional)
    -entries_of (optional)
    -title (optional)
    -days (optional)
    report entries changed in speficied last days
    ::1773708 instproc rss {-maxentries -name_filter -entries_of -title -days} {
        set package_id [my id]
        set folder_id [$package_id folder_id]
        if {![info exists name_filter]} {
          set name_filter [my get_parameter -type word name_filter ""]
        }
        if {![info exists entries_of]} {
          set entries_of [my get_parameter entries_of ""]
        }
        if {![info exists title]} {
          set title [my get_parameter PackageTitle [my instance_name]]
        }
        set description [my get_parameter PackageDescription ""]
    
        if {![info exists days] && 
            [regexp {[^0-9]*([0-9]+)d} [my query_parameter rss] _ days]} {
          # setting the variable days
        } else {
          set days 10
        }
        
        set r [RSS new -destroy_on_cleanup  -package_id [my id]  -parent_ids [my query_parameter parent_ids ""]  -name_filter $name_filter  -entries_of $entries_of  -title $title  -description $description  -days $days]
        
        #set t text/plain
        set t text/xml
        ns_return 200 $t [$r render]
      }
    

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