| |
215 |
215 |
} { |
| |
216 |
216 |
return [db_list select_page_ids {}] |
| |
217 |
217 |
} |
| |
218 |
218 |
|
| |
219 |
219 |
ad_proc -public render { |
| |
220 |
220 |
{-portal_id:required} |
| |
221 |
221 |
{-page_num 0} |
| |
222 |
222 |
{-render_style individual} |
| |
223 |
223 |
} { |
| |
224 |
224 |
returns a chunk of html that is a fully rendered portal |
| |
225 |
225 |
} { |
| |
226 |
226 |
permission::require_permission -privilege read -object_id $portal_id |
| |
227 |
227 |
set edit_p [permission::permission_p -object_id $portal_id -privilege write] |
| |
228 |
228 |
|
| |
229 |
229 |
set master_template [parameter::get -parameter master_template] |
| |
230 |
230 |
|
| |
231 |
231 |
# get the portal and layout |
| |
232 |
232 |
db_1row portal_select {} -column_array portal |
| |
233 |
233 |
set page_id $portal(page_id) |
| |
234 |
234 |
|
| |
235 |
|
set element_ids [list] |
| |
236 |
235 |
db_foreach element_select {} -column_array entry { |
| |
237 |
236 |
lappend element_ids($entry(region)) $entry(element_id) |
| |
|
237 |
} if_no_rows { |
| |
|
238 |
set element_ids {} |
| |
238 |
239 |
} |
| |
239 |
240 |
|
| |
240 |
241 |
set element_list [array get element_ids] |
| |
241 |
242 |
|
| |
242 |
243 |
# set up the template, it includes the layout template, |
| |
243 |
244 |
# which in turn includes the theme, then elements |
| |
244 |
|
if {[empty_string_p $element_list]} { |
| |
|
245 |
if {[string match "" $element_list]} { |
| |
245 |
246 |
# The portal has no elements, show anyway (they can configure) |
| |
246 |
247 |
set template "<master src=\"@master_template@\"> |
| |
247 |
248 |
<property name=\"title\">@portal.name@</property>" |
| |
248 |
249 |
} else { |
| |
249 |
250 |
set element_src "[www_path]/render-styles/${render_style}/render-element" |
| |
250 |
251 |
set template "<master src=\"@master_template@\"> |
| |
251 |
252 |
<property name=\"title\">@portal.name@</property> |
| |
252 |
253 |
<include src=\"@portal.layout_filename@\" |
| |
253 |
254 |
element_list=\"@element_list@\" |
| |
254 |
255 |
element_src=\"@element_src@\" |
| |
255 |
256 |
theme_id=@portal.theme_id@ |
| |
256 |
257 |
portal_id=@portal.portal_id@ |
| |
257 |
258 |
edit_p=@edit_p@ |
| |
258 |
259 |
page_id=@page_id@ |
| |
259 |
260 |
layout_id=@portal.layout_id@>" |
| |
260 |
261 |
} |
| |
261 |
262 |
|
| |
262 |
263 |
# necessary hack to work around the acs-templating system |
| |
263 |
264 |
set __adp_stub "[get_server_root][www_path]/." |
| |
264 |
265 |
set {master_template} \"master\" |
| |
265 |
266 |
|
| |
266 |
267 |
# compile and evaluate the template |
| |
267 |
268 |
set code [template::adp_compile -string $template] |
| |
|
269 |
|
| |
268 |
270 |
return [template::adp_eval code] |
| |
269 |
271 |
} |
| |
270 |
272 |
|
| |
271 |
273 |
ad_proc -private layout_elements { |
| |
272 |
274 |
element_list |
| |
273 |
275 |
{var_stub "element_ids"} |
| |
274 |
276 |
} { |
| |
275 |
277 |
Split a list up into a bunch of variables for inserting into a |
| |
276 |
278 |
layout template. This seems pretty kludgy (probably because it is), |
| |
277 |
279 |
but a template::multirow isn't really well suited to data of this |
| |
278 |
280 |
shape. It'll setup a set of variables, $var_stub_1 - $var_stub_8 |
| |
279 |
281 |
and $var_stub_i1- $var_stub_i8, each contining the portal_ids that |
| |
280 |
282 |
belong in that region. - Ian Baker |
| |
281 |
283 |
|
| |
282 |
284 |
@param element_id_list An [array get]'d array, keys are regions, \ |
| |
283 |
285 |
values are lists of element_ids. |
| |
284 |
286 |
@param var_stub A name upon which to graft the bits that will be \ |
| |
285 |
287 |
passed to the template. |
| |
286 |
288 |
} { |
| |
287 |
289 |
array set elements $element_list |