Index: openacs-4/packages/xowiki/tcl/package-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/package-procs.tcl,v diff -u -r1.30 -r1.31 --- openacs-4/packages/xowiki/tcl/package-procs.tcl 7 Jan 2007 21:42:03 -0000 1.30 +++ openacs-4/packages/xowiki/tcl/package-procs.tcl 27 Jan 2007 17:29:57 -0000 1.31 @@ -134,14 +134,63 @@ return $value } + # + # conditional links + # + Package instproc make_link {-privilege -url object method args} { + my instvar id + + if {[info exists privilege]} { + set granted [expr {$privilege eq "public" ? 1 : + [permission::permission_p \ + -object_id $id -privilege $privilege \ + -party_id [::xo::cc user_id]] }] + } else { + # determine privilege from policy + set granted [my permission_p $object $method] + #my log "--p $id permission_p $object $method ==> $granted" + } + if {$granted} { + if {[$object istype ::xowiki::Package]} { + set base [my package_url] + if {[info exists url]} { + return [uplevel export_vars -base [list $base$url] [list $args]] + } else { + lappend args [list $method 1] + return [uplevel export_vars -base [list $base] [list $args]] + } + } elseif {[$object istype ::xowiki::Page]} { + if {[info exists url]} { + set base $url + } else { + set base [my url] + } + lappend args [list m $method] + return [uplevel export_vars -base [list $base] [list $args]] + } + } + return "" + } + + Package instproc invoke {-method} { my set mime_type text/html my set delivery ns_return set page [my resolve_page [my set object] method] if {$page ne ""} { return [my call $page $method] } else { - return [my error_msg "No page '[my set object]' available."] + my instvar id + my get_name_and_lang_from_path [my set object] lang local_name + set name ${lang}:$local_name + set object_type ::xowiki::Page ;# for the time being; maybe a parameter? + set new_link [my make_link $id edit-new object_type return_url name] + if {$new_link ne ""} { + set edit_snippet "
Do you want to create page $name new?" + } else { + set edit_snippet "" + } + return [my error_msg "Page '[my set object]' is not available. $edit_snippet"] } } Package instproc reply_to_user {text} { @@ -249,6 +298,24 @@ } Package instforward permission_p {%my set policy} %proc + Package instproc get_name_and_lang_from_path {path vlang vlocal_name} { + my upvar $vlang lang $vlocal_name local_name + if {[regexp {^pages/(..)/(.*)$} $path _ lang local_name]} { + } elseif {[regexp {^(..)/(.*)$} $path _ lang local_name]} { + } elseif {[regexp {^(..):(.*)$} $path _ lang local_name]} { + } elseif {[regexp {^(file|image)/(.*)$} $path _ lang local_name]} { + } else { + set key queryparm(lang) + if {[info exists $key]} { + set lang [set $key] + } else { + # we can't determine lang from name, or query parameter, so take default + set lang [my default_language] + } + set local_name $path + } + } + Package instproc resolve_request {-path} { my instvar folder_id #my log "--u [self args]" @@ -261,20 +328,7 @@ my log "--try $path -> $item_id" if {$item_id == 0} { - if {[regexp {^pages/(..)/(.*)$} $path _ lang local_name]} { - } elseif {[regexp {^(..)/(.*)$} $path _ lang local_name]} { - } elseif {[regexp {^(..):(.*)$} $path _ lang local_name]} { - } elseif {[regexp {^(file|image)/(.*)$} $path _ lang local_name]} { - } else { - set key queryparm(lang) - if {[info exists $key]} { - set lang [set $key] - } else { - # we can't determine lang from name, or query parameter, so take default - set lang [my default_language] - } - set local_name $path - } + my get_name_and_lang_from_path $path lang local_name set name ${lang}:$local_name set item_id [::Generic::CrItem lookup -name $name -parent_id $folder_id] my log "--try $name -> $item_id" Index: openacs-4/packages/xowiki/tcl/xowiki-portlet-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/Attic/xowiki-portlet-procs.tcl,v diff -u -r1.22 -r1.23 --- openacs-4/packages/xowiki/tcl/xowiki-portlet-procs.tcl 25 Jan 2007 10:02:26 -0000 1.22 +++ openacs-4/packages/xowiki/tcl/xowiki-portlet-procs.tcl 27 Jan 2007 17:29:57 -0000 1.23 @@ -1,4 +1,10 @@ +ad_library { + XoWiki - define various kind of includelets + @creation-date 2006-10-10 + @author Gustaf Neumann + @cvs-id $Id$ +} namespace eval ::xowiki::portlet { Class create ::xowiki::Portlet \ -superclass ::xo::Context \ @@ -895,7 +901,7 @@ set p [::Generic::CrItem instantiate -item_id 0 -revision_id $page_id] $p destroy_on_cleanup set p_link [$package_id pretty_link $name] - set edit_link [$p make_link -url $p_link $p edit return_url] + set edit_link [$package_id make_link -url $p_link $p edit return_url] if {$edit_link ne ""} { set edit_markup "
" } else { Index: openacs-4/packages/xowiki/tcl/xowiki-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/xowiki-procs.tcl,v diff -u -r1.71 -r1.72 --- openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 12 Jan 2007 13:58:34 -0000 1.71 +++ openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 27 Jan 2007 17:29:57 -0000 1.72 @@ -492,45 +492,6 @@ } # - # conditional links, could go into package as well... - # - - Page instproc make_link {-privilege -url object method args} { - my instvar package_id - - if {[info exists privilege]} { - set granted [expr {$privilege eq "public" ? 1 : - [permission::permission_p \ - -object_id $package_id -privilege $privilege \ - -party_id [::xo::cc user_id]] }] - } else { - # determine privilege from policy - set granted [$package_id permission_p $object $method] - #my log "--p $package_id permission_p $object $method ==> $granted" - } - if {$granted} { - if {[$object istype ::xowiki::Package]} { - set base [$package_id package_url] - if {[info exists url]} { - return [uplevel export_vars -base [list $base$url] [list $args]] - } else { - lappend args [list $method 1] - return [uplevel export_vars -base [list $base] [list $args]] - } - } elseif {[$object istype ::xowiki::Page]} { - if {[info exists url]} { - set base $url - } else { - set base [$package_id url] - } - lappend args [list m $method] - return [uplevel export_vars -base [list $base] [list $args]] - } - } - return "" - } - - # # tag management, get_tags works on instance or gobally # @@ -975,7 +936,7 @@ File instproc get_content {} { my instvar name mime_type description parent_id package_id creation_user # don't require permissions here, such that rss can present the link - set page_link [my make_link -privilege public [self] download ""] + set page_link [$package_id make_link -privilege public [self] download ""] #my log "--F page_link=$page_link ---- " set t [TableWidget new -volatile \ -columns { Index: openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl,v diff -u -r1.31 -r1.32 --- openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl 27 Jan 2007 16:28:06 -0000 1.31 +++ openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl 27 Jan 2007 17:29:57 -0000 1.32 @@ -1,5 +1,6 @@ ad_library { - XoWiki - form classes + XoWiki - www procs. These procs are the methods called on xowiki objects via + the web interface. @creation-date 2006-04-10 @author Gustaf Neumann @@ -177,14 +178,14 @@ if {$master} { set context [list $title] set object_type [my info class] - set rev_link [my make_link [self] revisions] - set edit_link [my make_link [self] edit return_url] - set delete_link [my make_link [self] delete return_url] - set new_link [my make_link $package_id edit-new object_type return_url] - set admin_link [my make_link -privilege admin -url admin/ $package_id {} {}] - set index_link [my make_link -privilege public -url "" $package_id {} {}] - set save_tag_link [my make_link [self] save-tags] - set popular_tags_link [my make_link [self] popular-tags] + set rev_link [$package_id make_link [self] revisions] + set edit_link [$package_id make_link [self] edit return_url] + set delete_link [$package_id make_link [self] delete return_url] + set new_link [$package_id make_link $package_id edit-new object_type return_url] + set admin_link [$package_id make_link -privilege admin -url admin/ $package_id {} {}] + set index_link [$package_id make_link -privilege public -url "" $package_id {} {}] + set save_tag_link [$package_id make_link [self] save-tags] + set popular_tags_link [$package_id make_link [self] popular-tags] my log "--after context delete_link=$delete_link " set template [$folder_id get_payload template] @@ -291,14 +292,14 @@ ::xowiki::f1 instvar edit_form_page_title context formTemplate if {[info exists item_id]} { - set rev_link [my make_link [self] revisions] - set view_link [my make_link [self] view] + 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 [my make_link -privilege public -url "" $package_id {} {}] + set index_link [$package_id make_link -privilege public -url "" $package_id {} {}] set html [$package_id return_page -adp /packages/xowiki/www/edit \ -form f1 \ -variables {item_id edit_form_page_title context formTemplate