Fixing a small css issue in the user class.
[elgg.git] / units / templates / templates_edit.php
blob56ddd036b9c161fca7641fe8df76b00f20b77621
1 <?php
3 global $template;
4 global $template_definition;
6 if (!isset($parameter)) {
7 // Get template details
8 if (!$template_id = user_info('template_id',$USER->ident)) {
9 $template_id = -1;
11 } else {
12 if (!is_array($parameter)) {
13 $template_id = (int) $parameter;
14 } else {
15 $template_id = -1;
19 // Grab title, see if we can edit the template
20 $editable = 0;
21 if ($template_id == -1) {
22 $templatetitle = __gettext("Default Theme");
23 } else {
24 $templatestuff = get_record('templates','ident',$template_id);
25 $templatetitle = stripslashes($templatestuff->name);
26 if ($templatestuff->owner == $_SESSION['userid']) {
27 $editable = 1;
29 if (($templatestuff->owner != $_SESSION['userid']) && ($templatestuff->public != 'yes')) {
30 $template_id = -1;
34 // Grab the template content
35 if ($template_id == -1) {
36 $current_template = $template;
37 } else {
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);
42 } else {
43 $current_template = $template;
47 $run_result .= <<< END
49 <form action="" method="post">
51 END;
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 />";
72 } else {
73 $column1 = "";
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"));
81 /*
82 $run_result .= templates_draw(array(
83 'context' => 'databox',
84 'name' => $name,
85 'column2' => $column1,
86 'column1' => $column2
90 $run_result .= templates_draw(array(
91 'context' => 'databoxvertical',
92 'name' => $name,
93 'contents' => $column1 . "<br />" . $column2
100 if ($editable) {
101 $save = __gettext("Save"); // gettext variable
102 $run_result .= <<< END
104 <p align="center">
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" />
108 </p>
110 END;
111 } else {
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
116 $noEdit
117 </p>
119 END;
121 $run_result .= <<< END
123 </form>
125 END;