Index: openacs-4/contrib/packages/portal/tcl/element-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/tcl/element-procs.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/contrib/packages/portal/tcl/element-procs.tcl 22 Jan 2004 02:50:12 -0000 1.6 +++ openacs-4/contrib/packages/portal/tcl/element-procs.tcl 24 Jan 2004 01:22:47 -0000 1.7 @@ -382,7 +382,7 @@ } - ad_proc -private render_data { + ad_proc -private get_render_data { {-element_id:required} {-edit_p f} } { @@ -395,18 +395,24 @@ array set element [get -element_id $element_id] - if {!$edit_p} { - set element(shadeable_p) f - set element(hideable_p) f - } - set element(shaded_p) [ad_decode $element(state) shaded t f] + # Eventually we should be able to theme down to the element level, to allow, for + # instance, the common undecorated center column flanked by decorated left and + # right column format without kludging a special layout. array set theme [portal::theme::get \ -theme_id [portal::get_theme_id \ -portal_id [portal::page::get_portal_id -page_id $element(page_id)] \ ] \ ] + set element(filename) "[portal::www_path]/$theme(filename)" + set element(resource_dir) "/resources/portal/$theme(resource_dir)" + if {!$edit_p} { + set element(shadeable_p) f + set element(hideable_p) f + } + set element(shaded_p) [ad_decode $element(state) shaded t f] + set config [list \ shaded_p $element(shaded_p) \ shadeable_p $element(shadeable_p) \ @@ -427,8 +433,6 @@ set element(template_path) "/packages/$datasource(owner)/www/$datasource(template)" set element(config) $config - set element(filename) "[portal::www_path]/$theme(filename)" - set element(resource_dir) "/resources/portal/$theme(resource_dir)" return [array get element] Index: openacs-4/contrib/packages/portal/tcl/page-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/tcl/page-procs.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/contrib/packages/portal/tcl/page-procs.tcl 8 Jan 2004 02:12:19 -0000 1.3 +++ openacs-4/contrib/packages/portal/tcl/page-procs.tcl 24 Jan 2004 01:22:48 -0000 1.4 @@ -158,4 +158,24 @@ return [db_string select_visible_elements_p {} -default 0] } + ad_proc -private get_render_data { + {-page_id:required} + {-render_style individual} + } { + array set page [get -page_id $page_id] + set layout_id [get_layout_id -page_id $page_id] + db_1row layout_select {} + set page(layout_filename) "[portal::www_path]/$layout_filename" + + set page(element_src) "[portal::www_path]/render-styles/${render_style}/render-element" + db_foreach element_select {} -column_array entry { + lappend element_ids($entry(region)) $entry(element_id) + } if_no_rows { + set element_ids {} + } + + set page(element_list) [array get element_ids] + return [array get page] + } + } Index: openacs-4/contrib/packages/portal/tcl/page-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/tcl/page-procs.xql,v diff -u -r1.2 -r1.3 --- openacs-4/contrib/packages/portal/tcl/page-procs.xql 3 Jan 2004 01:42:57 -0000 1.2 +++ openacs-4/contrib/packages/portal/tcl/page-procs.xql 24 Jan 2004 01:22:48 -0000 1.3 @@ -59,4 +59,27 @@ + + + select portal_layouts.filename as layout_filename + from portal_layouts + where portal_layouts.layout_id = :layout_id + + + + + + select portal_elements.element_id, + portal_elements.region, + portal_elements.sort_key + from portal_elements + where portal_elements.page_id = :page_id + and portal_elements.page_id = portal_pages.page_id + and portal_elements.state != 'hidden' + order by portal_elements.region, + portal_elements.sort_key + + + + Index: openacs-4/contrib/packages/portal/tcl/portal-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/tcl/portal-procs.tcl,v diff -u -r1.8 -r1.9 --- openacs-4/contrib/packages/portal/tcl/portal-procs.tcl 22 Jan 2004 02:50:12 -0000 1.8 +++ openacs-4/contrib/packages/portal/tcl/portal-procs.tcl 24 Jan 2004 01:22:48 -0000 1.9 @@ -216,58 +216,18 @@ return [db_list select_page_ids {}] } - ad_proc -public render { + ad_proc -public get_render_data { {-portal_id:required} {-page_num 0} {-render_style individual} } { - returns a chunk of html that is a fully rendered portal + returns metadata needed to render a portal } { - permission::require_permission -privilege read -object_id $portal_id - set edit_p [permission::permission_p -object_id $portal_id -privilege write] - - set master_template [parameter::get -parameter master_template] - # get the portal and layout db_1row portal_select {} -column_array portal set page_id $portal(page_id) - - db_foreach element_select {} -column_array entry { - lappend element_ids($entry(region)) $entry(element_id) - } if_no_rows { - set element_ids {} - } - - set element_list [array get element_ids] - - # set up the template, it includes the layout template, - # which in turn includes the theme, then elements - if {[string match "" $element_list]} { - # The portal has no elements, show anyway (they can configure) - set template " - @portal.name@" - } else { - set element_src "[www_path]/render-styles/${render_style}/render-element" - set template " - @portal.name@ - " - } - - # necessary hack to work around the acs-templating system - set __adp_stub "[get_server_root][www_path]/." - set {master_template} \"master\" - - # compile and evaluate the template - set code [template::adp_compile -string $template] - - return [template::adp_eval code] + set portal(page_src) "[www_path]/render-styles/${render_style}/render-page" + return [array get portal] } ad_proc -private layout_elements { Index: openacs-4/contrib/packages/portal/tcl/portal-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/tcl/portal-procs.xql,v diff -u -r1.3 -r1.4 --- openacs-4/contrib/packages/portal/tcl/portal-procs.xql 13 Jan 2004 02:23:05 -0000 1.3 +++ openacs-4/contrib/packages/portal/tcl/portal-procs.xql 24 Jan 2004 01:22:48 -0000 1.4 @@ -36,40 +36,19 @@ - + select portals.name, portals.portal_id, portals.theme_id, - portal_layouts.layout_id, - portal_layouts.filename as layout_filename, portal_pages.page_id - from portals, - portal_pages, - portal_layouts - where portal_pages.sort_key = :page_num - and portal_pages.portal_id = :portal_id - and portal_pages.portal_id = portals.portal_id - and portal_pages.layout_id = portal_layouts.layout_id + from portals, portal_pages + where portals.portal_id = :portal_id + and portal_pages.sort_key = :page_num + and portal_pages.portal_id = :portal_id - - - select portal_elements.element_id, - portal_elements.region, - portal_elements.sort_key - from portal_elements, - portal_pages - where portal_pages.portal_id = :portal_id - and portal_elements.page_id = :page_id - and portal_elements.page_id = portal_pages.page_id - and portal_elements.state != 'hidden' - order by portal_elements.region, - portal_elements.sort_key - - - select portals.name, Index: openacs-4/contrib/packages/portal/www/render-styles/all-in-one/render-element.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/www/render-styles/all-in-one/Attic/render-element.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/contrib/packages/portal/www/render-styles/all-in-one/render-element.tcl 22 Jan 2004 02:50:12 -0000 1.2 +++ openacs-4/contrib/packages/portal/www/render-styles/all-in-one/render-element.tcl 24 Jan 2004 01:22:48 -0000 1.3 @@ -28,21 +28,20 @@ } # we get element_id, action_string, theme_id, region, portal_id, -# edit_p, return_url, page_id, and layout_id from the layout_template # Get all the good stuff we need to render this sucker -array set element [portal::element::render_data -element_id $element_id] +array set element [portal::element::get_render_data -element_id $element_id] # We call the template engine directly to render the element rather than use an "include" # statement in render-element.adp so we can catch the error and display a pretty # error message. -set include "" - with_catch errmsg { + set include "" set code [template::adp_compile -string $include] set element(content) [string trim [template::adp_eval code]] } { - ns_log error "portal::element::render error!\n\n$errmsg\n\n" + ns_log error "Error rendering portal element $element_id:\n\n$errmsg\n\n" set element(content) "application error" } +# edit_p, return_url, page_id, and layout_id from the layout_template Index: openacs-4/contrib/packages/portal/www/render-styles/individual/render-element.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/www/render-styles/individual/Attic/render-element.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/contrib/packages/portal/www/render-styles/individual/render-element.tcl 22 Jan 2004 02:50:12 -0000 1.3 +++ openacs-4/contrib/packages/portal/www/render-styles/individual/render-element.tcl 24 Jan 2004 01:22:48 -0000 1.4 @@ -23,27 +23,23 @@ @creation-date @cvs_id $Id$ -} -properties { - element_id:onevalue - region:onevalue } # we get element_id, action_string, theme_id, region, portal_id, # edit_p, return_url, page_id, and layout_id from the layout_template # Get all the good stuff we need to render this sucker -array set element [portal::element::render_data -element_id $element_id -edit_p $edit_p] +array set element [portal::element::get_render_data -element_id $element_id -edit_p $edit_p] # We call the template engine directly to render the element rather than use an "include" # statement in render-element.adp so we can catch the error and display a pretty # error message. -set include "" - with_catch errmsg { + set include "" set code [template::adp_compile -string $include] set element(content) [string trim [template::adp_eval code]] } { - ns_log error "portal::element::render error!\n\n$errmsg\n\n" + ns_log error "Error rendering portal element $element_id:\n\n$errmsg\n\n" set element(content) "application error" } Index: openacs-4/contrib/packages/portal/www/render-styles/individual/render-page.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/www/render-styles/individual/Attic/render-page.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/www/render-styles/individual/render-page.adp 24 Jan 2004 01:22:48 -0000 1.1 @@ -0,0 +1,9 @@ + + + Index: openacs-4/contrib/packages/portal/www/render-styles/individual/render-page.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/portal/www/render-styles/individual/Attic/render-page.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/portal/www/render-styles/individual/render-page.tcl 24 Jan 2004 01:22:48 -0000 1.1 @@ -0,0 +1,35 @@ +# +# Copyright (C) 2001, 2002 MIT +# +# This file is part of dotLRN. +# +# 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. +# +# 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. +# + +# render-page.tcl + +ad_page_contract { + + Render a portal page. + + This is intended to be included, not called directly, with the following parameters + defined: + + @param page_id The portal the page belongs to + + @author Don Baccus (dhogaza@pacifier.com) + @creation-date 2004/01/24 + @cvs_id $Id: render-page.tcl,v 1.1 2004/01/24 01:22:48 donb Exp $ + +} + +array set page [portal::page::get_render_data -page_id $page_id] +set elements_exist_p [expr {[llength $page(element_list)] > 0}]