Index: openacs-4/packages/xowiki-portlet/tcl/xowiki-admin-portlet-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki-portlet/tcl/xowiki-admin-portlet-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/xowiki-portlet/tcl/xowiki-admin-portlet-procs.tcl 31 Jan 2007 10:52:48 -0000 1.1 +++ openacs-4/packages/xowiki-portlet/tcl/xowiki-admin-portlet-procs.tcl 27 Feb 2008 09:22:00 -0000 1.2 @@ -1,85 +1,198 @@ +ad_library { + Procedures to supports xowiki admin portlets. + + @creation-date 2008-02-26 + @author Gustaf Neumann + @cvs-id $Id$ +} + # -# Copyright (C) 2001, 2002 MIT +# This is the first approach to make the portlet-procs # -# This file is part of dotLRN. +# (a) in an oo-style (the object below contains everything +# for the management of the portlet) and +# (b) independent from the database layer +# (supposed to work under postgres and Oracle) # -# dotLRN is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. +# In the next steps, it would make sense to define a ::dotlrn::Portlet +# class, which provides some of the the common behaviour defined here... # -# dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -# details. -# -ad_library { +Object xowiki_admin_portlet +xowiki_admin_portlet proc name {} { + return "xowiki-admin-portlet" +} - Procedures to support the xowiki ADMIN portlet +xowiki_admin_portlet proc pretty_name {} { + return [parameter::get_from_package_key \ + -package_key [my package_key] \ + -parameter xowiki_admin_portlet_pretty_name] +} - @author arjun@openforce.net - @cvs-id $Id$ +xowiki_admin_portlet proc package_key {} { + return "xowiki-portlet" } -namespace eval xowiki_admin_portlet { +xowiki_admin_portlet proc link {} { + return "" +} - ad_proc -private get_my_name { - } { - return "xowiki_admin_portlet" - } +xowiki_admin_portlet ad_proc add_self_to_page { + {-portal_id:required} + {-package_id:required} +} { + Adds a xowiki admin PE to the given portal +} { + return [portal::add_element_parameters \ + -portal_id $portal_id \ + -portlet_name [my name] \ + -key package_id \ + -value $package_id \ + ] + ns_log notice "end of add_self_to_page" +} - ad_proc -public get_pretty_name { - } { - return [parameter::get_from_package_key \ - -package_key [my_package_key] \ - -parameter xowiki_admin_portlet_pretty_name] - } +xowiki_admin_portlet ad_proc remove_self_from_page { + {-portal_id:required} +} { + Removes xowiki admin PE from the given page +} { + # This is easy since there's one and only one instace_id + portal::remove_element \ + -portal_id $portal_id \ + -portlet_name [my name] +} - ad_proc -private my_package_key { - } { - return "xowiki-portlet" - } +xowiki_admin_portlet ad_proc show { + cf +} { + Display the xowiki admin PE +} { + portal::show_proc_helper \ + -package_key [my package_key] \ + -config_list $cf \ + -template_src "xowiki-admin-portlet" +} - ad_proc -public link { - } { - return "" - } +xowiki_admin_portlet proc install {} { + my log "--portlet calling [self proc]" + set name [my name] + db_transaction { - ad_proc -public add_self_to_page { - {-portal_id:required} - {-package_id:required} + # + # create the datasource + # + set ds_id [::xo::db::sql::portal_datasource new -name $name \ + -css_dir "" \ + -description "Displays the admin interface for the xowiki data portlets"] + + # default configuration + + ::xo::db::sql::portal_datasource set_def_param -datasource_id $ds_id \ + -config_required_p t -configured_p t \ + -key "shadeable_p" -value f + + ::xo::db::sql::portal_datasource set_def_param -datasource_id $ds_id \ + -config_required_p t -configured_p t \ + -key "shaded_p" -value f + + ::xo::db::sql::portal_datasource set_def_param -datasource_id $ds_id \ + -config_required_p t -configured_p t \ + -key "hideable_p" -value t + + ::xo::db::sql::portal_datasource set_def_param -datasource_id $ds_id \ + -config_required_p t -configured_p t \ + -key "user_editable_p" -value f + + ::xo::db::sql::portal_datasource set_def_param -datasource_id $ds_id \ + -config_required_p t -configured_p t \ + -key "link_hideable_p" -value t + + # xowiki-admin-specific procs + + # package_id must be configured + ::xo::db::sql::portal_datasource set_def_param -datasource_id $ds_id \ + -config_required_p t -configured_p f \ + -key "package_id" -value "" + + + # + # service contract managemet + # + # create the implementation + ::xo::db::sql::acs_sc_impl new \ + -impl_contract_name "portal_datasource" -impl_name $name \ + -impl_pretty_name "" -impl_owner_name $name + + # add the operations + foreach {operation call} { + GetMyName "xowiki_admin_portlet name" + GetPrettyName "xowiki_admin_portlet pretty_name" + Link "xowiki_admin_portlet link" + AddSelfToPage "xowiki_admin_portlet add_self_to_page" + Show "xowiki_admin_portlet show" + Edit "xowiki_admin_portlet edit" + RemoveSelfFromPage "xowiki_admin_portlet remove_self_from_page" } { - Adds a xowiki admin PE to the given portal - } { - return [portal::add_element_parameters \ - -portal_id $portal_id \ - -portlet_name [get_my_name] \ - -key package_id \ - -value $package_id - ] - ns_log notice "end of add_self_to_page" + ::xo::db::sql::acs_sc_impl_alias new \ + -impl_contract_name "portal_datasource" -impl_name $name \ + -impl_operation_name $operation -impl_alias $call \ + -impl_pl "TCL" } + + # Add the binding + ::xo::db::sql::acs_sc_binding new \ + -contract_name "portal_datasource" -impl_name $name + } + my log "--portlet end of [self proc]" +} - ad_proc -public remove_self_from_page { - {-portal_id:required} - } { - Removes xowiki PE from the given page - } { - # This is easy since there's one and only one instace_id - portal::remove_element \ - -portal_id $portal_id \ - -portlet_name [get_my_name] - } +xowiki_admin_portlet proc uninstall {} { + my log "--portlet calling [self proc]" + # + # completely identical to "xowiki_portlet uninstall" + # + set name [my name] + db_transaction { - ad_proc -public show { - cf + # + # get the datasource + # + set ds_id [db_string dbqd..get_ds_id { + select datasource_id from portal_datasources where name = :name + } -default "0"] + + if {$ds_id == 0} { + error "No datasource id found for $name" + } + # + # drop the datasource + # + ::xo::db::sql::portal_datasource delete -datasource_id $ds_id + # + # drop the operation + # + foreach operation { + GetMyName GetPrettyName Link AddSelfToPage + Show Edit RemoveSelfFromPage } { - Display the PE - } { - portal::show_proc_helper \ - -package_key [my_package_key] \ - -config_list $cf \ - -template_src "xowiki-admin-portlet" + ::xo::db::sql::acs_sc_impl_alias delete \ + -impl_contract_name "portal_datasource" -impl_name $name \ + -impl_operation_name $operation } - + # + # drop the binding + # + ::xo::db::sql::acs_sc_binding delete \ + -contract_name "portal_datasource" -impl_name $name + # + # drop the implementation + # + ::xo::db::sql::acs_sc_impl delete \ + -impl_contract_name "portal_datasource" -impl_name $name + } + my log "--portlet end of [self proc]" } + + + +