Index: openacs-4/packages/news-portlet/tcl/news-portlet-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/news-portlet/tcl/news-portlet-procs.tcl,v diff -u -r1.13 -r1.14 --- openacs-4/packages/news-portlet/tcl/news-portlet-procs.tcl 2 Apr 2002 06:13:47 -0000 1.13 +++ openacs-4/packages/news-portlet/tcl/news-portlet-procs.tcl 9 May 2002 23:59:53 -0000 1.14 @@ -14,24 +14,19 @@ # details. # -# news-portlet/tcl/news-portlet-procs.tcl - ad_library { -Procedures to support the news portlet + Procedures to support the news portlet -Copyright Openforce, Inc. -Licensed under GNU GPL v2 + @creation-date Nov 2001 + @author arjun@openforce.net + @cvs-id $Id$ -@creation-date Nov 2001 -@author arjun@openforce.net -@cvs-id $Id$ - } namespace eval news_portlet { - ad_proc -private my_name { + ad_proc -private get_my_name { } { return "news_portlet" } @@ -41,126 +36,59 @@ return "news-portlet" } - ad_proc -public get_pretty_name { } { - return "News" + return [ad_parameter "news_portlet_pretty_name" [my_package_key]] } ad_proc -public link { } { - return "news" + return "" } ad_proc -public add_self_to_page { portal_id instance_id } { - Adds a news PE to the given page with the community_id. + Adds a news PE to the given portal. - @return element_id The new element's id @param portal_id The page to add self to - @param community_id The community with the folder - @author arjun@openforce.net - @creation-date Sept 2001 + @param instance_id The community with the folder + @return element_id The new element's id } { - # Add some smarts to only add one portlet for now when it's added multiple times (ben) - # Find out if bboard already exists - set element_id_list [portal::get_element_ids_by_ds $portal_id [my_name]] + return [portal::add_element_or_append_id \ + -portal_id $portal_id \ + -portlet_name [get_my_name] \ + -value_id $instance_id \ + -force_region [ad_parameter "news_portlet_force_region" [my_package_key]] \ + -pretty_name [get_pretty_name] + ] + } - if {[llength $element_id_list] == 0} { - # Tell portal to add this element to the page - set element_id [portal::add_element \ - -pretty_name [get_pretty_name] \ - -force_region 1 \ - $portal_id \ - [my_name]] - - # There is already a value for the param which must be overwritten - portal::set_element_param $element_id community_id $instance_id - set package_id_list [list] - } else { - set element_id [lindex $element_id_list 0] - # There are existing values which should NOT be overwritten - portal::add_element_param_value \ - -element_id $element_id \ - -key community_id \ - -value $instance_id - } - - return $element_id + ad_proc -public remove_self_from_page { + portal_id + instance_id + } { + Removes a news PE from the given page or the instance_id of the + news pacakge from the portlet if there are others remaining + + @param portal_id The page to remove self from + @param instance_id + } { + portal::remove_element_or_remove_id \ + -portal_id $portal_id \ + -portlet_name [get_my_name] \ + -value_id $instance_id } ad_proc -public show { cf } { - Display the PE - - @return HTML string - @param cf A config array - @author arjun@openforce.net - @creation-date Sept 2001 } { - # no return call required with the helper proc portal::show_proc_helper \ -package_key [my_package_key] \ -config_list $cf \ -template_src "news-portlet" } - ad_proc -public edit { - } { - return "" - } - - ad_proc -public remove_self_from_page { - portal_id - community_id - } { - Removes a news PE from the given page - - @param portal_id The page to remove self from - @param community_id - @author arjun@openforce.net - @creation-date Sept 2001 - } { - # get the element IDs (could be more than one!) - set element_ids [portal::get_element_ids_by_ds $portal_id [my_name]] - - # remove all elements - db_transaction { - foreach element_id $element_ids { - portal::remove_element $element_id - } - } - } - - ad_proc -public make_self_available { - portal_id - } { - Wrapper for the portal:: proc - - @param portal_id - @author arjun@openforce.net - @creation-date Nov 2001 - } { - portal::make_datasource_available \ - $portal_id [portal::get_datasource_id [my_name]] - } - - ad_proc -public make_self_unavailable { - portal_id - } { - Wrapper for the portal:: proc - - @param portal_id - @author arjun@openforce.net - @creation-date Nov 2001 - } { - portal::make_datasource_unavailable \ - $portal_id [portal::get_datasource_id [my_name]] - } } - - -