4 global $template_definition;
6 if (!isset($parameter)) {
7 // Get template details
8 if (!$template_id = user_info('template_id',$USER->ident
)) {
12 if (!is_array($parameter)) {
13 $template_id = (int) $parameter;
19 // Grab title, see if we can edit the template
21 if ($template_id == -1) {
22 $templatetitle = __gettext("Default Theme");
24 $templatestuff = get_record('templates','ident',$template_id);
25 $templatetitle = stripslashes($templatestuff->name
);
26 if ($templatestuff->owner
== $_SESSION['userid']) {
29 if (($templatestuff->owner
!= $_SESSION['userid']) && ($templatestuff->public != 'yes')) {
34 // Grab the template content
35 if ($template_id == -1) {
36 $current_template = $template;
38 if ($result = get_records('template_elements','template_id',$template_id)) {
39 foreach($result as $element) {
40 $current_template[stripslashes($element->name
)] = stripslashes($element->content
);
43 $current_template = $template;
47 $run_result .= <<< END
49 <form action
="" method
="post">
53 $run_result .= templates_draw(array(
54 'context' => 'databoxvertical',
55 'name' => __gettext("Theme Name"),
56 'contents' => display_input_field(array("templatetitle",$templatetitle,"text"))
60 foreach($template_definition as $element) {
62 if (isset($element['display']) && $element['display'] == 1) {
64 $name = "<b>" . $element['name'] . "</b><br /><i>" . $element['description'] . "</i>";
65 $glossary = __gettext("Glossary"); // gettext variable
67 if (sizeof($element['glossary']) > 0) {
68 $column1 = "<b>$glossary</b><br />";
69 foreach($element['glossary'] as $gloss_id => $gloss_descr) {
70 $column1 .= $gloss_id . " -- " . $gloss_descr . "<br />";
76 if (empty($current_template[$element['id']])) {
77 $current_template[$element['id']] = $template[$element['id']];
80 $column2 = display_input_field(array("template[" . $element['id'] . "]",$current_template[$element['id']],"longtext"));
82 $run_result .= templates_draw(array(
83 'context' => 'databox',
85 'column2' => $column1,
90 $run_result .= templates_draw(array(
91 'context' => 'databoxvertical',
93 'contents' => $column1 . "<br />" . $column2
101 $save = __gettext("Save"); // gettext variable
102 $run_result .= <<< END
105 <input type
="hidden" name
="action" value
="templates:save" />
106 <input type
="hidden" name
="save_template_id" value
="$template_id" />
107 <input type
="submit" value
="$save" />
112 $noEdit = __gettext("You may not edit this theme. To create a new, editable theme based on the default, go to <a href=\"index.php\">the main themes page</a>."); // gettext variable
113 $run_result .= <<< END
121 $run_result .= <<< END