1<?php
2
3require_once('./always.php');
4require_once('classEditor.php');
5require_once('classBrowser.php');
6include("DAViCalSession.php");
7$session->LoginRequired();
8
9require_once('AwlQuery.php');
10
11param_to_global('action', '{(edit|browse)}', 'action');
12param_to_global('component', '{[a-z0-9-_]+}', 't');
13param_to_global('id', '{[a-z0-9-_]+}', 'id');
14if ( ! $action || ! $component ) {
15    header('Location: index.php');
16    @ob_flush(); exit(0);
17}
18
19$c->stylesheets[] = 'css/'.$action.'.css';
20if ( $c->enable_row_linking ) {
21  $c->scripts[] = 'js/browse.js';
22}
23
24require_once('interactive-page.php');
25
26$page_elements = array();
27$code_file = sprintf( 'ui/%s-%s.php', $component, $action );
28if ( ! @include_once( $code_file ) ) {
29  $c->messages[] = sprintf(
30      'No page found to %s %s%s%s',
31      htmlspecialchars($action),
32      ($action == 'browse' ? '' : 'a '), $component,
33      ($action == 'browse' ? 's' : '')
34  );
35  include('page-header.php');
36  include('page-footer.php');
37  @ob_flush(); exit(0);
38}
39
40include('page-header.php');
41
42/**
43* Page elements could be an array of viewers, browsers or something else
44* that supports the Render() method... or a non-object which we assume is
45* just a string of text that we echo.
46*/
47$heading_level = null;
48foreach( $page_elements AS $k => $page_element ) {
49  if ( is_object($page_element) ) {
50    echo $page_element->Render($heading_level);
51    $heading_level = 'h2';
52  }
53  else {
54    echo $page_element;
55  }
56}
57
58if (function_exists("post_render_function")) {
59  post_render_function();
60}
61
62include('page-footer.php');
63