Index: openacs-4/packages/new-portal/new-portal.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/new-portal/new-portal.info,v diff -u -r1.29.2.2 -r1.29.2.3 --- openacs-4/packages/new-portal/new-portal.info 20 Jan 2007 23:35:50 -0000 1.29.2.2 +++ openacs-4/packages/new-portal/new-portal.info 12 Mar 2007 03:00:13 -0000 1.29.2.3 @@ -8,14 +8,14 @@ t portal - + OpenACS Portals. 2006-12-31 OpenACS New Portal Package aka NPP. Portals are used to aggregate content from different sources within a single page. Props to Ian Baker for "Portal". - + Index: openacs-4/packages/new-portal/sql/oracle/api-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/new-portal/sql/oracle/api-create.sql,v diff -u -r1.42 -r1.42.2.1 --- openacs-4/packages/new-portal/sql/oracle/api-create.sql 8 Aug 2006 21:26:58 -0000 1.42 +++ openacs-4/packages/new-portal/sql/oracle/api-create.sql 12 Mar 2007 03:00:13 -0000 1.42.2.1 @@ -509,6 +509,7 @@ datasource_id in portal_datasources.datasource_id%TYPE default null, name in portal_datasources.name%TYPE default null, description in portal_datasources.description%TYPE default null, + css_dir in portal_datasources.css_dir%TYPE default null, object_type in acs_object_types.object_type%TYPE default 'portal_datasource', creation_date in acs_objects.creation_date%TYPE default sysdate, creation_user in acs_objects.creation_user%TYPE default null, @@ -539,6 +540,7 @@ datasource_id in portal_datasources.datasource_id%TYPE default null, name in portal_datasources.name%TYPE default null, description in portal_datasources.description%TYPE default null, + css_dir in portal_datasources.css_dir%TYPE default null, object_type in acs_object_types.object_type%TYPE default 'portal_datasource', creation_date in acs_objects.creation_date%TYPE default sysdate, creation_user in acs_objects.creation_user%TYPE default null, @@ -559,9 +561,9 @@ ); insert into portal_datasources - (datasource_id, name, description) + (datasource_id, name, description, css_dir) values - (v_datasource_id, name, description); + (v_datasource_id, name, description, css_dir); return v_datasource_id; Index: openacs-4/packages/new-portal/sql/oracle/portal-core-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/new-portal/sql/oracle/portal-core-create.sql,v diff -u -r1.46 -r1.46.2.1 --- openacs-4/packages/new-portal/sql/oracle/portal-core-create.sql 8 Aug 2006 21:26:58 -0000 1.46 +++ openacs-4/packages/new-portal/sql/oracle/portal-core-create.sql 12 Mar 2007 03:00:13 -0000 1.46.2.1 @@ -46,7 +46,8 @@ name varchar(200) constraint p_datasources_name_nn not null, - pretty_name varchar(200) + pretty_name varchar(200), + css_dir varchar(200) ); -- A default configuration for a ds will be stored here, to be copied Fisheye: Tag 1.1 refers to a dead (removed) revision in file `openacs-4/packages/new-portal/sql/oracle/upgrade/upgrade-2.3.0d2-2.3.0d3.sql'. Fisheye: No comparison available. Pass `N' to diff? Index: openacs-4/packages/new-portal/sql/postgresql/api-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/new-portal/sql/postgresql/api-create.sql,v diff -u -r1.14 -r1.14.2.1 --- openacs-4/packages/new-portal/sql/postgresql/api-create.sql 8 Aug 2006 21:26:59 -0000 1.14 +++ openacs-4/packages/new-portal/sql/postgresql/api-create.sql 12 Mar 2007 03:00:13 -0000 1.14.2.1 @@ -491,19 +491,20 @@ return 0; end;' language 'plpgsql'; -select define_function_args('portal_datasource__new','datasource_id,name,description,object_type;portal_datasource,creation_date,creation_user,creation_ip,context_id'); +select define_function_args('portal_datasource__new','datasource_id,name,description,css_dir,object_type;portal_datasource,creation_date,creation_user,creation_ip,context_id'); -create function portal_datasource__new (integer,varchar,varchar,varchar,timestamptz,integer,varchar,integer) +create function portal_datasource__new (integer,varchar,varchar,varchar,varchar,timestamptz,integer,varchar,integer) returns integer as ' declare p_datasource_id alias for $1; -- default null p_name alias for $2; -- default null p_description alias for $3; -- default null - p_object_type alias for $4; -- default ''portal_datasource'' - p_creation_date alias for $5; -- default now() - p_creation_user alias for $6; -- default null - p_creation_ip alias for $7; -- default null - p_context_id alias for $8; -- default null + p_css_dir alias for $4; + p_object_type alias for $5; -- default ''portal_datasource'' + p_creation_date alias for $6; -- default now() + p_creation_user alias for $7; -- default null + p_creation_ip alias for $8; -- default null + p_context_id alias for $9; -- default null v_datasource_id portal_datasources.datasource_id%TYPE; begin @@ -518,14 +519,43 @@ ); insert into portal_datasources - (datasource_id, name, description) + (datasource_id, name, description, css_dir) values - (v_datasource_id, p_name, p_description); + (v_datasource_id, p_name, p_description, p_css_dir); return v_datasource_id; end;' language 'plpgsql'; +create function portal_datasource__new (integer,varchar,varchar,varchar,timestamptz,integer,varchar,integer) +returns integer as ' +declare + p_datasource_id alias for $1; -- default null + p_name alias for $2; -- default null + p_description alias for $3; -- default null + p_object_type alias for $4; -- default ''portal_datasource'' + p_creation_date alias for $5; -- default now() + p_creation_user alias for $6; -- default null + p_creation_ip alias for $7; -- default null + p_context_id alias for $8; -- default null + v_datasource_id portal_datasources.datasource_id%TYPE; +begin + + v_datasource_id := portal_datasource__new(null, + p_name, + p_description, + null, + p_object_type, + p_creation_date, + p_creation_user, + p_creation_ip, + p_context_id); + + return v_datasource_id; + +end;' language 'plpgsql'; + + create function portal_datasource__new (varchar,varchar) returns integer as ' declare @@ -537,6 +567,7 @@ v_datasource_id := portal_datasource__new(null, p_name, p_description, + null, ''portal_datasource'', now(), null, @@ -547,6 +578,29 @@ end;' language 'plpgsql'; +create function portal_datasource__new (varchar,varchar,varchar) +returns integer as ' +declare + p_name alias for $1; -- default null + p_description alias for $2; -- default null + p_css_dir alias for $3; + v_datasource_id portal_datasources.datasource_id%TYPE; +begin + + v_datasource_id := portal_datasource__new(null, + p_name, + p_description, + p_css_dir, + ''portal_datasource'', + now(), + null, + null, + null); + + return v_datasource_id; + +end;' language 'plpgsql'; + select define_function_args('portal_datasource__delete','datasource_id'); create function portal_datasource__delete (integer) Index: openacs-4/packages/new-portal/sql/postgresql/portal-core-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/new-portal/sql/postgresql/portal-core-create.sql,v diff -u -r1.5 -r1.5.2.1 --- openacs-4/packages/new-portal/sql/postgresql/portal-core-create.sql 8 Aug 2006 21:26:59 -0000 1.5 +++ openacs-4/packages/new-portal/sql/postgresql/portal-core-create.sql 12 Mar 2007 03:00:14 -0000 1.5.2.1 @@ -43,7 +43,8 @@ name varchar(200) constraint p_datasources_name_nn not null, - pretty_name varchar(200) + pretty_name varchar(200), + css_dir varchar(200) ); -- A default configuration for a ds will be stored here, to be copied Fisheye: Tag 1.1 refers to a dead (removed) revision in file `openacs-4/packages/new-portal/sql/postgresql/upgrade/upgrade-2.3.0d2-2.3.0d3.sql'. Fisheye: No comparison available. Pass `N' to diff? Index: openacs-4/packages/new-portal/tcl/apm-callback-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/new-portal/tcl/apm-callback-procs.tcl,v diff -u -r1.1.2.1 -r1.1.2.2 --- openacs-4/packages/new-portal/tcl/apm-callback-procs.tcl 20 Jan 2007 23:35:51 -0000 1.1.2.1 +++ openacs-4/packages/new-portal/tcl/apm-callback-procs.tcl 12 Mar 2007 03:00:14 -0000 1.1.2.2 @@ -26,6 +26,6 @@ db_dml update_type {} - } - } + } + } } Index: openacs-4/packages/new-portal/tcl/portal-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/new-portal/tcl/portal-procs.tcl,v diff -u -r1.179.2.5 -r1.179.2.6 --- openacs-4/packages/new-portal/tcl/portal-procs.tcl 11 Mar 2007 01:04:31 -0000 1.179.2.5 +++ openacs-4/packages/new-portal/tcl/portal-procs.tcl 12 Mar 2007 03:00:14 -0000 1.179.2.6 @@ -146,7 +146,7 @@ set page_name_list [list "Page 1"] set layout_name_list [list "#new-portal.simple_2column_layout_name#"] - + if {![empty_string_p $csv_list]} { set page_name_and_layout_list [split [string trimright $csv_list ";"] ";"] set page_name_list [list] @@ -217,7 +217,7 @@ } { Get the name of this portal } { - return [lang::util::localize [util_memoize "portal::get_name_not_cached -portal_id $portal_id"]] + return [lang::util::localize [util_memoize "portal::get_name_not_cached -portal_id $portal_id"]] } ad_proc -private get_name_not_cached { @@ -343,7 +343,7 @@ ad_proc -public configure { {-referer ""} {-template_p f} - {-allow_theme_change_p 1} + {-allow_theme_change_p 1} portal_id return_url } { @@ -427,18 +427,18 @@ } append theme_chunk "" - if {$allow_theme_change_p} { + if {$allow_theme_change_p} { append template "$theme_chunk" - } + } # # Per-page template chunks # set list_of_page_ids [list_pages_tcl_list -portal_id $portal_id] - set last_page [lindex $list_of_page_ids [expr [llength $list_of_page_ids] - 1]] - ns_log warning "last_page is $last_page" + set last_page [lindex $list_of_page_ids [expr [llength $list_of_page_ids] - 1]] + ns_log warning "last_page is $last_page" foreach page_id $list_of_page_ids { set first_page_p [portal::first_page_p -portal_id $portal_id -page_id $page_id] @@ -457,7 +457,7 @@ # Page rename chunk # set page_name_chunk " - + - " + + " append template "$page_name_chunk" @@ -529,18 +529,18 @@ # Remove page chunk - don't allow removal of the first page # - - if {! $first_page_p } { - - append template "" - - - + + if {! $first_page_p } { + + append template "" + + + append template " " - } + } # # Layout change chunk - only shown when there are no visible elements on the page @@ -610,21 +610,21 @@ set new_page_num [expr [page_count -portal_id $portal_id] + 1] append template " -

+

$page_name

$page_name

@@ -474,8 +474,8 @@
-
@@ -552,7 +552,7 @@
-

[_ new-portal.Create_a_new_page]

- +
+
-
+
-
+ " # # Revert page chunk @@ -633,31 +633,31 @@ if {![empty_string_p [get_portal_template_id $portal_id]]} { append template "

-
+

[_ new-portal.lt_Revert_the_entire_por]

-
+
-
" + " } - if { [db_string sub_portals {}] } { - # Portal has other portals using it as a template + if { [db_string sub_portals {}] } { + # Portal has other portals using it as a template append template "

-
+

[_ new-portal.lt_Revert_all_portals_us]

-
+

[_ new-portal.lt_Note_Please_be_patien]
-
" - } + " + } # # Templating system hacks @@ -719,27 +719,27 @@ # revert pages - # Roel - 03-10-2005, fix for revert problems - # This fix tries to match the target portal with the - # template before the revert via the pages' sort keys - - # First, create source pages that aren't in the target portal - db_foreach revert_source_pages {} { - if { ! [db_0or1row revert_get_target_page_id {}] } { + # Roel - 03-10-2005, fix for revert problems + # This fix tries to match the target portal with the + # template before the revert via the pages' sort keys + + # First, create source pages that aren't in the target portal + db_foreach revert_source_pages {} { + if { ! [db_0or1row revert_get_target_page_id {}] } { set pretty_name "portal revert dummy page $sort_key" - set page_id [page_create \ - -pretty_name $pretty_name \ - -portal_id $portal_id] - - # Now set the page's sort_key - db_dml revert_set_target_page_sort_key {} - } - } - - # Second, delete target pages that aren't in the source - # portal - db_foreach revert_target_pages {} { - if { ! [db_0or1row revert_get_source_page_id {}] } { + set page_id [page_create \ + -pretty_name $pretty_name \ + -portal_id $portal_id] + + # Now set the page's sort_key + db_dml revert_set_target_page_sort_key {} + } + } + + # Second, delete target pages that aren't in the source + # portal + db_foreach revert_target_pages {} { + if { ! [db_0or1row revert_get_source_page_id {}] } { set move_to_page_id [db_string revert_min_page_id_select {}] db_foreach revert_move_elements_for_del {} { @@ -750,45 +750,45 @@ } page_delete -page_id $page_id - } - } + } + } # now that they have the same number of pages, get to it foreach source_page_id \ [list_pages_tcl_list -portal_id $template_id] { - - db_1row revert_get_source_page_info {} + + db_1row revert_get_source_page_info {} - set target_page_id [db_string revert_get_target_page_id {}] - - db_dml revert_page_update {} - - # First, hide all elements. - # If there are new content portlets that are not - # in the default template, this will ensure they don't come - # up. + set target_page_id [db_string revert_get_target_page_id {}] + + db_dml revert_page_update {} + + # First, hide all elements. + # If there are new content portlets that are not + # in the default template, this will ensure they don't come + # up. - db_dml hide_all_elements { - update portal_element_map - set state = 'hidden' - where page_id = :target_page_id - } + db_dml hide_all_elements { + update portal_element_map + set state = 'hidden' + where page_id = :target_page_id + } - # revert elements in two steps like "swap" - db_foreach revert_get_source_elements {} { - # the element might not be on the target page... - set target_element_id \ + # revert elements in two steps like "swap" + db_foreach revert_get_source_elements {} { + # the element might not be on the target page... + set target_element_id \ [db_string revert_get_target_element {} -default {}] - - # now, lets check if this is one new applet - # added, that was not originally mapped - # usually with custom portlets - - if ![empty_string_p $target_element_id] { - db_dml revert_element_update {} - } - } - } + + # now, lets check if this is one new applet + # added, that was not originally mapped + # usually with custom portlets + + if ![empty_string_p $target_element_id] { + db_dml revert_element_update {} + } + } + } } elseif { ![empty_string_p [ns_set get $form "op_rename"]] } { portal::update_name $portal_id [ns_set get $form new_name] @@ -1067,7 +1067,7 @@ {-link_all 0} {-extra_td_html ""} {-table_html_args ""} - {-extra_td_selected_p 0} + {-extra_td_selected_p 0} } { Wraps portal::dimensional to create a dotlrn navbar @@ -1091,7 +1091,7 @@ -pre_html $pre_html \ -post_html $post_html \ -extra_td_html $extra_td_html \ - -extra_td_selected_p $extra_td_selected_p \ + -extra_td_selected_p $extra_td_selected_p \ -table_html_args $table_html_args \ $ad_dim_struct \ $link] @@ -1439,7 +1439,7 @@ db_dml update {} - util_memoize_flush "portal::element_params_not_cached $element_id" + util_memoize_flush "portal::element_params_not_cached $element_id" # ns_log notice "aks81 [get_element_param $element_id $key]" return 1 @@ -1483,7 +1483,7 @@ } { db_dml insert {} - util_memoize_flush "portal::element_params_not_cached $element_id" + util_memoize_flush "portal::element_params_not_cached $element_id" } @@ -1497,7 +1497,7 @@ db_dml delete {} # DRB: Remove the cached copy of this element, too. - util_memoize_flush "portal::element_params_not_cached $element_id" + util_memoize_flush "portal::element_params_not_cached $element_id" } @@ -1528,9 +1528,9 @@ } ad_proc -private element_params_not_cached element_id { - Return a list of lists of key value pairs for this portal element. + Return a list of lists of key value pairs for this portal element. } { - return [db_list_of_lists params_select {}] + return [db_list_of_lists params_select {}] } ad_proc -private get_element_id_from_unique_param { @@ -1569,13 +1569,13 @@ db_1row element_select {} -column_array element # get the element's params - set element_params [util_memoize "portal::element_params_not_cached $element_id" 86400] - if [llength $element_params] { - foreach param $element_params { - set key [lindex $param 0] - set value [lindex $param 1] - lappend config($key) $value - } + set element_params [util_memoize "portal::element_params_not_cached $element_id" 86400] + if [llength $element_params] { + foreach param $element_params { + set key [lindex $param 0] + set value [lindex $param 1] + lappend config($key) $value + } } else { # this element has no config, set up some defaults set config(shaded_p) "f" @@ -2067,7 +2067,7 @@ if {[llength $element_id_list] == 0} { db_transaction { - # Tell portal to add this element to the page + # Tell portal to add this element to the page set element_id [add_element \ -portal_id $portal_id \ -portlet_name $portlet_name \ @@ -2270,10 +2270,10 @@ {-td_align "center"} {-extra_td_html ""} {-table_html_args "border=0 cellspacing=0 cellpadding=3 width=100%"} - {-class_html ""} + {-class_html ""} {-pre_html ""} {-post_html ""} - {-extra_td_selected_p 0} + {-extra_td_selected_p 0} option_list {url {}} {options_set ""} @@ -2284,53 +2284,53 @@ if {[empty_string_p $option_list]} { return } - + if {[empty_string_p $options_set]} { set options_set [ns_getform] } - + if {[empty_string_p $url]} { set url [ad_conn url] } - + set html "\n\n" - + if {!$no_header_p} { foreach option $option_list { append html "\n" } } append html " \n" - + foreach option $option_list { - + if {!$no_bars_p} { append html "\[" } - - - if { $names_in_cells_p } { - set pre_td_html "" - set end_html "" - set break_html "" - set post_selected_html "$post_html" - } else { - append html " " + set end_html "" + set break_html "" + set post_selected_html "$post_html" + } else { + append html " \n$end_html
[lindex $option 1]
" - set pre_selected_td_html "" - set post_html "$post_html" - set td_html "" - set pre_selected_td_html "" - set post_selected_html "$post_html" - set end_html "" - set td_html "" - post_html "$post_html" - if {!$no_bars_p} { - set break_html " | " - } else { - append break_html "   " - } - } + + + if { $names_in_cells_p } { + set pre_td_html "" + set pre_selected_td_html "" + set post_html "$post_html" + set td_html "" + set pre_selected_td_html "" + set post_selected_html "$post_html" + set end_html "" + set td_html "" + post_html "$post_html" + if {!$no_bars_p} { + set break_html " | " + } else { + append break_html "   " + } + } # find out what the current option value is. # check if a default is set otherwise the first value is used @@ -2342,7 +2342,7 @@ set option_val $options_set_val } } - + set first_p 1 foreach option_value [lindex $option 3] { set thisoption_name [lindex $option_value 0] @@ -2356,10 +2356,10 @@ if {$first_p} { set first_p 0 - } else { - append html $break_html + } else { + append html $break_html } - + if {([string equal $option_val $thisoption_name] == 1 && !$link_all) || !$thisoption_link_p} { append html "${pre_selected_td_html}${pre_html}${thisoption_value}${post_selected_html}\n" } else { @@ -2370,12 +2370,12 @@ if {!$no_bars_p} { append html "\]" } - if {$extra_td_selected_p} { - append html "${pre_selected_td_html}${pre_html}$extra_td_html${post_html}\n" - } else { - append html "${pre_td_html}$extra_td_html${post_html}\n" - } + if {$extra_td_selected_p} { + append html "${pre_selected_td_html}${pre_html}$extra_td_html${post_html}\n" + } else { + append html "${pre_td_html}$extra_td_html${post_html}\n" } + } append html "
\n" } @@ -2393,27 +2393,29 @@ The basic idea is that since CSS must appear in the HEAD portion of a document, it is safe to link to any CSS file needed by a portal page. This includes - all CSS files found in the previously unused layout resource_dir, and CSS - files returned by the poge's datasource's get CSS operation. + all CSS files found in the previously unused layout resource_dir, and the + new datasource css_dir column. The code assumes the layout's resource_dir (which is a misnomer, they've always been resource URLs - check the use of the theme resource_dir coiumn) and portlet - CSS files are either relative or in proper "/resources/package-key" form. - - (the existing code for the theme resource_dir only supports the relative form) + CSS files are either relative or in proper "/resources/package-key" form. + } { set header_stuff "" - db_1row get_resource_dir {} - if { [string first /resources/ $resource_dir] == 0 } { - set l [split $resource_dir /] - set path [acs_package_root_dir [lindex $l 2]]/www/resources/[join [lrange $l 3 end] /] - } else { - set path [acs_package_root_dir new-portal]/www/$resource_dir + foreach resource_dir [db_list \ + -cache_key portal::get_page_header_stuff_$portal_id \ + get_resource_dirs {}] { + if { [string first /resources/ $resource_dir] == 0 } { + set l [split $resource_dir /] + set path [acs_package_root_dir [lindex $l 2]]/www/resources/[join [lrange $l 3 end] /] + } else { + set path [acs_package_root_dir new-portal]/www/$resource_dir + } + foreach file [file tail [glob -nocomplain -directory $path *.css]] { + append header_stuff " + " + } } - foreach file [file tail [glob -nocomplain -directory $path *.css]] { - append header_stuff " -" - } return $header_stuff } } Index: openacs-4/packages/new-portal/tcl/portal-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/new-portal/tcl/portal-procs.xql,v diff -u -r1.45.2.3 -r1.45.2.4 --- openacs-4/packages/new-portal/tcl/portal-procs.xql 5 Mar 2007 02:48:33 -0000 1.45.2.3 +++ openacs-4/packages/new-portal/tcl/portal-procs.xql 12 Mar 2007 03:00:14 -0000 1.45.2.4 @@ -828,13 +828,21 @@ - + select l.resource_dir from portal_pages p, portal_layouts l where p.portal_id = :portal_id and p.sort_key = :page_num and l.layout_id = p.layout_id + union + select distinct(pd.css_dir) + from portal_element_map pem, portal_datasources pd, portal_pages pp + where pp.portal_id = :portal_id + and pp.sort_key = :page_num + and pem.page_id = pp.page_id + and pem.datasource_id = pd.datasource_id + and pd.css_dir is not null