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

::xowiki::IncludeletClass[i] ::xowiki::includelet::folders

Class Hierarchy of ::xowiki::includelet::folders

  • ::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::Context[i]
      Parameter for instances:
      actual_query (default " "), locale, package_id (default "0"), parameter_declaration (default "")
      Methods for instances:
      exists_query_parameter, export_vars, get_all_query_parameter, get_parameters, initialize, original_url_and_query, process_query_parameter, query_parameter
      Methods to be applied on the class:
      Methods provided by the meta-class
      • ::xowiki::Includelet[i]
        Parameter for instances:
        __decoration (default "portlet"), id, name (default ""), parameter_declaration (default ""), title (default "")
        Methods for instances:
        category_clause, get_page_order, include_head_entries, initialize, js_name, resolve_page_name, screen_name
        Methods to be applied on the class (in addition to the methods provided by the meta-class):
        available_includelets, describe_includelets, glob_clause, html_encode, html_id, html_to_text, js_encode, js_name, listing, locale_clause, parent_id_clause, publish_status_clause, require_YUI_CSS, require_YUI_JS
        • ::xowiki::includelet::folders[i]
          Parameter for instances:
          __decoration (default "plain"), id (default "[xowiki::Includelet js_name [self]]"), parameter_declaration (default " {-show_full_tree false} {-context_tree_view false} ")
          Methods for instances:
          build_sub_tree, build_tree, collect_folders, include_head_entries, render
          Methods to be applied on the class:
          Methods provided by the meta-class

Class Relations

  • superclass: ::xowiki::Includelet[i]
::xowiki::IncludeletClass create ::xowiki::includelet::folders \
     -superclass ::xowiki::Includelet \
     -parameter {{__decoration plain} {id "[xowiki::Includelet js_name [self]]"} \
       {parameter_declaration {
          {-show_full_tree false}
          {-context_tree_view false}


  • instproc build_sub_tree

    ::2360969 instproc build_sub_tree {-node -folders} {
        my get_parameters
        my instvar current_folder_id
        set current_object [$node object]
        set current_item_id [$current_object item_id]
        set sub_folders [list]
        set remaining_folders [list]
        foreach f $folders {
          if {[$f parent_id] ne $current_item_id} {
    	lappend remaining_folders $f
          } else {
    	lappend sub_folders $f
        foreach c $sub_folders {
          set label [$c title]
          set object $c
          set folder_href [$c pretty_link]
          set is_current [expr {$current_folder_id eq [$c item_id]}]
          set is_open [expr {$is_current || $show_full_tree}]
          #regexp {^..:(.+)$} $label _ label
          set subnode [::xowiki::TreeNode new  -href $folder_href  -label $label  -object $c  -highlight $is_current  -expanded $is_open  -open_requests 1]
          $node add $subnode
          if {$is_current} {
    	$node open_tree
    	if {[info command ::__xowiki__MenuBar] ne "" 
    	    && [::__xowiki__MenuBar exists submenu_pages(folder)]} {
    	  set owner [::__xowiki__MenuBar set submenu_owner(folder)]
    	  $subnode add_pages -full true  -book_mode [$owner set book_mode]  -owner $owner  [::__xowiki__MenuBar set submenu_pages(folder)]
          my build_sub_tree -node $subnode -folders $remaining_folders
  • instproc build_tree

    ::2360969 instproc build_tree {} {
        my instvar current_folder current_folder_id folder_form_id link_form_id
        my get_parameters
        set page [my set __including_page]
        set package_id [::xo::cc package_id]
        set with_links [$package_id get_parameter "MenuBarSymLinks" 0]
        #my ds [::xo::cc serialize]
        set lang [::xo::cc lang]
        #set lang en
        set return_url [::xo::cc url]
        set nls_language [$page get_nls_language_from_lang $lang]
        set folder_form_id [::xowiki::Weblog instantiate_forms -forms en:folder.form  -package_id $package_id]
        set link_form_id   [::xowiki::Weblog instantiate_forms -forms en:link.form  -package_id $package_id]
        #my msg folder_form=$folder_form_id
        set current_folder [$page get_folder -folder_form_ids $folder_form_id]
        set current_folder_id [$current_folder item_id]
        #my msg "FOLDERS [$page name] package_id $package_id current_folder $current_folder [$current_folder name]"
        # Start with the "package's folder" as root folder
        set root_folder_id [::$package_id folder_id]
        set root_folder [::xo::db::CrClass get_instance_from_db -item_id $root_folder_id]
        set root_folder_is_current [expr {$current_folder_id == [$root_folder item_id]}]
        set mb [info command ::__xowiki__MenuBar]
        if {$mb ne ""} {
          # We have a menubar. Add folder-specific content to the
          # menubar. 
          if {$root_folder_is_current} {
    	# We do not want to see unneeded parent_ids in the links. When
    	# we insert to the root folder, set opt_parent_id to empty to
    	# make argument passing easy. "make_link" just checks for the
    	# existance of the variable, so we unset parent_id in this case.
            set opt_parent_id ""
    	set folder_link [$package_id package_url]
            if {[info exists parent_id]} {unset parent_id}
          } else {
    	set parent_id $current_folder_id
            set opt_parent_id $parent_id
            ::xo::db::CrClass get_instance_from_db -item_id $parent_id
    	set folder_link [$current_folder pretty_link]
          set return_url [::xo::cc url]
          set new_folder_link [$package_id make_form_link -form en:folder.form  -parent_id $opt_parent_id  -return_url $return_url]
          if {$with_links} {
    	set new_sym_link [$package_id make_form_link -form en:link.form  -parent_id $opt_parent_id  -nls_language $nls_language -return_url $return_url]
    #       set new_page_link [$package_id make_link -with_entities 0  #                              $package_id edit-new  #                              {object_type ::xowiki::Page}  #                              parent_id return_url autoname template_file]
          set new_page_link [$package_id make_form_link -form en:page.form  -parent_id $opt_parent_id  -return_url $return_url]
          set new_file_link [$package_id make_link -with_entities 0  $package_id edit-new  {object_type ::xowiki::File}  parent_id return_url autoname template_file]
          set new_form_link [$package_id make_link -with_entities 0  $package_id edit-new  {object_type ::xowiki::Form}  parent_id return_url autoname template_file]
          set import_link  [$package_id make_link -privilege admin  -link "admin/import" $package_id {} parent_id return_url]
          set import_archive_link [$package_id make_form_link -form en:import-archive.form  -parent_id $opt_parent_id]
          set index_link [$package_id make_link -link $folder_link $current_folder list]
          $mb add_menu_item -name Package.Startpage  -item [list text Index url $index_link]
          $mb add_menu_item -name New.Page  -item [list text New Page url $new_page_link]
          $mb add_menu_item -name New.File  -item [list text File url $new_file_link]
          $mb add_menu_item -name New.Folder  -item [list text Folder url $new_folder_link]
          if {$with_links} {
    	$mb add_menu_item -name New.SymLink     -item [list text SymLink url $new_sym_link]
          $mb add_menu_item -name New.Form  -item [list text Form url $new_form_link]
          $mb add_menu_item -name Package.ImportDump -item [list url $import_link]
          $mb add_menu_item -name Package.ImportArchive -item [list url $import_archive_link]
          if {[::xowiki::clipboard is_empty]} {
    	set clipboard_copy_link ""
    	set clipboard_export_link ""
    	set clipboard_content_link ""
    	set clipboard_clear_link ""
          } else {
    	# todo: check, whether the use is allowed to insert into the current folder
    	set clipboard_copy_link [$current_folder pretty_link]?m=clipboard-copy
    	set clipboard_export_link [$current_folder pretty_link]?m=clipboard-export
    	set clipboard_content_link [$current_folder pretty_link]?m=clipboard-content
    	set clipboard_clear_link [$current_folder pretty_link]?m=clipboard-clear
          # todo: we should check either, whether to user is allowed to
          # copy-to-clipboard from the current folder, and/or the user is
          # allowed to do this with certain items.... (the latter in
          # clipboad-add)
          $mb add_menu_item -name Clipboard.Add  -item [list url javascript:acs_ListBulkActionClick("objects","$folder_link?m=clipboard-add")]
          $mb add_menu_item -name Clipboard.Content     -item [list url $clipboard_content_link]
          $mb add_menu_item -name Clipboard.Clear       -item [list url $clipboard_clear_link]
          $mb add_menu_item -name Clipboard.Use.Copy    -item [list url $clipboard_copy_link]
          $mb add_menu_item -name Clipboard.Use.Export  -item [list url $clipboard_export_link]
          $mb update_items -package_id $package_id -parent_id $opt_parent_id  -return_url $return_url  -nls_language $nls_language  [concat  [$package_id get_parameter ExtraMenuEntries {}]  [$current_folder property extra_menu_entries]]
        set top_folder_of_tree $root_folder
        # Check, if the optional context tree view is activated
        if {$context_tree_view || [$package_id get_parameter FolderContextTreeView false]} {
          set parent_id [$current_folder parent_id]
          if {$parent_id ne -100} {
    	set top_folder_of_tree $parent_id
    	#my msg top_folder_of_tree=$top_folder_of_tree
        set parent_folder [$top_folder_of_tree parent_id]
        if {$top_folder_of_tree eq $root_folder || $parent_folder eq "-100"} {
          set href [::$package_id package_url]
          set label  [::$package_id instance_name]
          #my msg "use instance name"
        } else {
          set href [$top_folder_of_tree pretty_link]
          set label "[$top_folder_of_tree title] ..."
        set t [::xowiki::Tree new -id foldertree_[my id] ]
        set node [::xowiki::TreeNode new  -href $href  -label $label  -highlight [expr {$current_folder_id == [$top_folder_of_tree item_id]}]  -object $top_folder_of_tree  -expanded 1  -open_requests 1]
        $t add $node
        set folders [my collect_folders  -package_id $package_id  -folder_form_id $folder_form_id  -link_form_id $link_form_id]
        #my msg "folder [my set folder_form_id] has [llength $folders] entries"
        #foreach f $folders {lappend _ [$f item_id]}; my msg $_
        my build_sub_tree -node $node -folders $folders
        return $t
  • instproc collect_folders

    ::2360969 instproc collect_folders {-package_id:required -folder_form_id:required -link_form_id:required {-subtree_query ""} {-depth 3}} {
        set folders [list]
        # safety belt, for recursive structures
        if {$depth < 1} {return $folders}
        # get folders
        set folder_pages [::xowiki::FormPage get_form_entries  -base_item_ids $folder_form_id -form_fields ""  -extra_where_clause $subtree_query  -publish_status ready -package_id $package_id]
        # get links
        set links [::xowiki::FormPage get_form_entries  -base_item_ids $link_form_id -form_fields ""  -extra_where_clause $subtree_query  -publish_status ready -package_id $package_id]
        #my msg "[llength [$links children]] links"
        set folders [$folder_pages children]
        my instvar current_folder_id
        # filter links to folders.
        # links might be cross-package links
        foreach l [$links children] {
          set link_type [$l get_property_from_link_page link_type]
          set cross_package [$l get_property_from_link_page cross_package]
          if {$link_type ne "folder_link"} continue
          if {$cross_package} {
    	# we found a cross-package link. These kind of links require further queries
    	set target [$l get_target_from_link_page]
    	# the following clause needs an oracle counter-part
    	set tree_sortkey [::xo::db_string get_tree_sort_key  "select tree_sortkey from acs_objects where object_id = [$target item_id]"]
    	set extra_where "and bt.item_id in (select object_id from acs_objects  where tree_sortkey between '$tree_sortkey' and tree_right('$tree_sortkey')  and object_type = 'content_item')"
    	set sub_folders [my collect_folders -package_id [$target physical_package_id]  -folder_form_id $folder_form_id -link_form_id $link_form_id  -subtree_query $extra_where -depth [expr {$depth -1}]]
    	foreach f $sub_folders {
    	  #my msg "$f [$f name] is a folder-link pointing to $target [$target name] current $current_folder_id"
    	  if {[$f parent_id] eq [$target item_id]} {
    	    #my msg "1 found child [$f name] and reset parent_id from [$f parent_id] to [$l item_id], package_id [$l package_id]"
    	    # reset the current_folder if necessary
    	    if {$current_folder_id eq [$f parent_id]} {set current_folder_id [$l item_id]}
    	    # set the resolve_context
    	    $f set_resolve_context -package_id [$l package_id] -parent_id [$l item_id]
    	    # TODO we could save the double-fetch by collecing in
    	    # get_form_entries via item-ids, not via new-objects
    	    ::xo::db::CrClass get_instance_from_db -item_id [$f item_id]
    	    [$f item_id] set_resolve_context -package_id [$l package_id] -parent_id [$l item_id]
    	  } else {
    	    #my msg "2 found child [$f name] and reset parent_id from [$f parent_id] to [$f parent_id], package id [$l package_id]"
    	    $f set_resolve_context -package_id [$l package_id] -parent_id [$f parent_id]
    	    ::xo::db::CrClass get_instance_from_db -item_id [$f item_id]
    	    [$f item_id] set_resolve_context -package_id [$l package_id] -parent_id [$f parent_id]
    	  #my msg "including $f [$f name] [$f item_id]"
    	  lappend folders $f
          #my msg link=$link
          lappend folders $l
        return $folders
  • instproc include_head_entries

    ::2360969 instproc include_head_entries {} {
        ::xowiki::Tree include_head_entries -renderer yuitree -style folders
  • instproc render

    ::2360969 instproc render {} {
        my get_parameters
        set js "
          var [my js_name];
          YAHOO.util.Event.onDOMReady(function() {
             [my js_name] = new YAHOO.widget.TreeView('foldertree_[my id]'); 
             [my js_name].subscribe('clickEvent',function(oArgs) { 
                var m = /href=\"(\[^\"\]+)\"/.exec(oArgs.node.html);
                return false;
             [my js_name].render();
        set tree [my build_tree]
        return [$tree render -style yuitree -js $js]

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