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

::xo::db::CrClass[i] ::xo::db::CrFolder

Class Hierarchy of ::xo::db::CrFolder

  • ::xotcl::Object[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]
      Methods for instances:
      db_1row, delete, initialize_loaded_object, insert, object_idC, object_titleC, save, save_new
      Methods to be applied on the class:
      Methods provided by the meta-class
      • ::xo::db::CrItem[i]
        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
This is a generic class that represents a "cr_folder" XoWiki specific methods are currently directly mixed into all instances of this class.
Defined in packages/xotcl-core/tcl/cr-procs.tcl

Class Relations

  • superclass: ::xo::db::CrItem[i]
::xo::db::CrClass create ::xo::db::CrFolder \
     -superclass ::xo::db::CrItem


  • proc fetch_object (public)

    ::xo::db::CrFolder[i] fetch_object -item_id item_id  \
        [ -revision_id revision_id ] -object object  \
        [ -initialize initialize ]
    We overwrite the default fetch_object method here. We join acs_objects, cr_items and cr_folders and fetch all attributes. The revision_id is completely ignored.

    -item_id (required)
    -revision_id (defaults to "0") (optional)
    -object (required)
    -initialize (defaults to "true") (optional)

    See Also:
    • CrClass fetch_object
    ::914660 proc fetch_object {-item_id:required {-revision_id 0} -object:required {-initialize true}} {
        if {![::xotcl::Object isobject $object]} {
          my create $object
        $object db_1row [my qn fetch_folder] "
            SELECT * FROM cr_folders
            JOIN cr_items on cr_folders.folder_id = cr_items.item_id
            JOIN acs_objects on cr_folders.folder_id = acs_objects.object_id
            WHERE folder_id = $item_id"
        if {$initialize} {$object initialize_loaded_object}
        return $object
  • proc get_instance_from_db (public)

    ::xo::db::CrFolder[i] get_instance_from_db [ -item_id item_id ] \
        [ -revision_id revision_id ]
    The "standard" get_instance_from_db methods return objects following the naming convention "::", e.g. ::1234 Usually, the id of the item that is fetched from the database is used. However, XoWiki's "folder objects" (i.e. an ::xowiki::Object instance that can be used to configure the respective instance) are created using the acs_object_id of the root folder of the xowiki instance, which is actually the id of another acs_object. Because of this, we cannot simply create the instances of CrFolder using the "standard naming convention". Instead we create them as ::cr_folder

    -item_id (defaults to "0") (optional)
    -revision_id (defaults to "0") (optional)
    ::914660 proc get_instance_from_db {{-item_id 0} {-revision_id 0}} {
        set object ::cr_folder$item_id
        if {![my isobject $object]} {
          my fetch_object -object $object -item_id $item_id
          $object destroy_on_cleanup
        return $object
  • proc instance_select_query (public)

    ::xo::db::CrFolder[i] instance_select_query \
        [ -select_attributes select_attributes ] [ -orderby orderby ] \
        [ -where_clause where_clause ] [ -from_clause from_clause ] \
        [ -with_subtypes on|off ] [ -with_children on|off ] \
        [ -publish_status publish_status ] [ -count on|off ] \
        [ -folder_id folder_id ] [ -parent_id parent_id ] \
        [ -page_size page_size ] [ -page_number page_number ] \
        [ -base_table base_table ]
    returns the SQL-query to select the CrItems of the specified object_type

    -select_attributes (optional)
    -orderby (optional)
    for ordering the solution set
    -where_clause (optional)
    clause for restricting the answer set
    -from_clause (optional)
    -with_subtypes (boolean) (defaults to "true") (optional)
    return subtypes as well
    -with_children (boolean) (defaults to "true") (optional)
    return immediate child objects of all objects as well
    -publish_status (optional)
    one of 'live', 'ready', or 'production'
    -count (boolean) (defaults to "false") (optional)
    return the query for counting the solutions
    -folder_id (optional)
    -parent_id (optional)
    -page_size (defaults to "20") (optional)
    -page_number (optional)
    -base_table (defaults to "cr_folders") (optional)
    typically automatic view, must contain title and revision_id
    sql query
    ::914660 proc instance_select_query {{-select_attributes ""} {-orderby ""} {-where_clause ""} {-from_clause ""} {-with_subtypes:boolean true} {-with_children:boolean true} -publish_status {-count:boolean false} -folder_id -parent_id {-page_size 20} {-page_number ""} {-base_table "cr_folders"}} {
        if {![info exists folder_id]} {my instvar folder_id}
        if {![info exists parent_id]} {set parent_id $folder_id}
        if {$base_table eq "cr_folders"} {
          set attributes [list ci.item_id ci.name ci.publish_status acs_objects.object_type] 
        } else {
          set attributes [list bt.item_id ci.name ci.publish_status bt.object_type] 
        foreach a $select_attributes {
          # if {$a eq "title"} {set a bt.title}
          lappend attributes $a
        # FIXME: This is dirty: We "fake" the base table for this function, so we can reuse the code
        set type_selection_clause [my type_selection_clause -base_table cr_revisions -with_subtypes false]
        #my log "type_selection_clause -with_subtypes $with_subtypes returns $type_selection_clause"
        if {$count} {
          set attribute_selection "count(*)"
          set orderby ""      ;# no need to order when we count
          set page_number  ""      ;# no pagination when count is used
        } else {
          set attribute_selection [join $attributes ,]
        set cond [list]
        if {$type_selection_clause ne ""} {lappend cond $type_selection_clause}
        if {$where_clause ne ""}          {lappend cond $where_clause}
        if {[info exists publish_status]} {lappend cond "ci.publish_status eq '$publish_status'"}
        if {$base_table eq "cr_folders"} {
          lappend cond "acs_objects.object_id = cf.folder_id and ci.item_id = cf.folder_id"
          set acs_objects_table "acs_objects, cr_items ci, "
        } else {
          lappend cond "ci.item_id = bt.item_id"
          set acs_objects_table ""
        if {$parent_id ne ""} {
          set parent_clause "ci.parent_id = $parent_id"
          if {$with_children} {
            lappend cond "ci.item_id in (
                    select children.item_id from cr_items parent, cr_items children
                    where children.tree_sortkey between parent.tree_sortkey and tree_right(parent.tree_sortkey)
                    and parent.item_id = $parent_id and parent.tree_sortkey <> children.tree_sortkey)"
          } else {
            lappend cond $parent_clause
        if {$page_number ne ""} {
          set limit $page_size
          set offset [expr {$page_size*($page_number-1)}]
        } else {
          set limit ""
          set offset ""
        set sql [::xo::db::sql select  -vars $attribute_selection  -from "$acs_objects_table cr_folders cf $from_clause"  -where [join $cond " and "]  -orderby $orderby  -limit $limit -offset $offset]
        return $sql
  • proc register_content_types (public)

    ::xo::db::CrFolder[i] register_content_types -folder_id folder_id  \
        [ -content_types content_types ]
    Register the specified content types for the folder. If a content_type ends with a *, include its subtypes

    -folder_id (required)
    -content_types (optional)
    ::914660 proc register_content_types {-folder_id:required {-content_types ""}} {
        foreach content_type $content_types {
          set with_subtypes [expr {[regexp {^(.*)[*]$} $content_type _ content_type] ? "t" : "f"}]
          ::xo::db::sql::content_folder register_content_type  -folder_id $folder_id  -content_type $content_type  -include_subtypes $with_subtypes
  • instproc save (public)

    <instance of ::xo::db::CrFolder[i]> save args [ args... ]

    ::914660 instproc save args {
        my instvar folder_id
        content::folder::update  -folder_id $folder_id  -attributes [list  [list name [my set name]]  [list label [my set label]]  [list description [my set description]] ]
        my get_context package_id user_id ip
        ::xo::db_1row _ "select acs_object__update_last_modified(:folder_id,$user,'$ip')"
  • instproc save_new (public)

    <instance of ::xo::db::CrFolder[i]> save_new \
        [ -creation_user creation_user ]

    -creation_user (optional)
    ::914660 instproc save_new -creation_user {
        my instvar parent_id package_id folder_id
        [my info class] get_context package_id creation_user creation_ip
        set folder_id [::xo::db::sql::content_folder new  -name [my name] -label [my label]  -description [my description]  -parent_id $parent_id  -package_id $package_id  -creation_user $creation_user  -creation_ip $creation_ip]
        #parent_s has_child_folders attribute could have become outdated
        if { [my isobject ::$parent_id] } {
          ::$parent_id set has_child_folders t
        # well, obtaining the allowed content_types this way is not very
        # straightforward, but since we currently create these folders via
        # ad_forms, and we have no form variable, this should be at least
        # robust.
        if {[[self class] exists allowed_content_types]} {
          ::xo::db::CrFolder register_content_types  -folder_id $folder_id  -content_types [[self class] set allowed_content_types]
        ::xo::clusterwide ns_cache flush xotcl_object_cache ::$parent_id
        # who is setting sub_folder_list?
        #db_flush_cache -cache_key_pattern sub_folder_list_*
        return $folder_id

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