| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
$user_template = db_query("select template_id from users where ident = " . $_SESSION['userid']); |
|---|
| 4 |
$user_template = $user_template[0]->template_id; |
|---|
| 5 |
|
|---|
| 6 |
$panel = <<< END |
|---|
| 7 |
|
|---|
| 8 |
<h2>Create / Edit / Delete templates</h2> |
|---|
| 9 |
<form action="" method="post"> |
|---|
| 10 |
<h3> |
|---|
| 11 |
Public templates |
|---|
| 12 |
</h3> |
|---|
| 13 |
<p> |
|---|
| 14 |
The following are templates that have been made available to you. You may preview and select them, but not edit and delete. |
|---|
| 15 |
</p> |
|---|
| 16 |
|
|---|
| 17 |
END; |
|---|
| 18 |
|
|---|
| 19 |
$template_list[] = array( |
|---|
| 20 |
'name' => 'Default Template', |
|---|
| 21 |
'id' => -1 |
|---|
| 22 |
); |
|---|
| 23 |
$templates = db_query("select * from templates where public = 'yes'"); |
|---|
| 24 |
if (sizeof($templates) > 0) { |
|---|
| 25 |
foreach($templates as $template) { |
|---|
| 26 |
$template_list[] = array( |
|---|
| 27 |
'name' => stripslashes($template->name), |
|---|
| 28 |
'id' => stripslashes($template->ident) |
|---|
| 29 |
); |
|---|
| 30 |
} |
|---|
| 31 |
} |
|---|
| 32 |
foreach($template_list as $template) { |
|---|
| 33 |
$name = "<input type='radio' name='selected_template' value='".$template['id']."' "; |
|---|
| 34 |
if ($template['id'] == $user_template) { |
|---|
| 35 |
$name .= "checked=\"checked\""; |
|---|
| 36 |
} |
|---|
| 37 |
$name .=" /> "; |
|---|
| 38 |
$column1 = "<b>" . $template['name'] . "</b>"; |
|---|
| 39 |
$column2 = "<a href=\"/_templates/preview.php?template_preview=".$template['id']."\" target=\"preview\">Preview</a>"; |
|---|
| 40 |
$panel .= run("templates:draw", array( |
|---|
| 41 |
'context' => 'databox', |
|---|
| 42 |
'name' => $name, |
|---|
| 43 |
'column1' => $column1, |
|---|
| 44 |
'column2' => $column2 |
|---|
| 45 |
) |
|---|
| 46 |
); |
|---|
| 47 |
} |
|---|
| 48 |
|
|---|
| 49 |
$templates = db_query("select * from templates where owner = " . $_SESSION['userid']); |
|---|
| 50 |
if (sizeof($templates) > 0) { |
|---|
| 51 |
$panel .= <<< END |
|---|
| 52 |
<h3> |
|---|
| 53 |
Personal templates |
|---|
| 54 |
</h3> |
|---|
| 55 |
<p> |
|---|
| 56 |
These are templates that you have created. |
|---|
| 57 |
</p> |
|---|
| 58 |
|
|---|
| 59 |
END; |
|---|
| 60 |
|
|---|
| 61 |
foreach($templates as $template) { |
|---|
| 62 |
$name = "<input type='radio' name='selected_template' value='".$template->ident."' "; |
|---|
| 63 |
if ($template->ident == $user_template) { |
|---|
| 64 |
$name .= "checked=\"checked\""; |
|---|
| 65 |
} |
|---|
| 66 |
$name .=" /> "; |
|---|
| 67 |
$column1 = "<b>" . stripslashes($template->name) . "</b>"; |
|---|
| 68 |
$column2 = "<a href=\"/_templates/preview.php?template_preview=".$template->ident."\" target=\"preview\">Preview</a>"; |
|---|
| 69 |
$column2 .= " | <a href=\"/_templates/edit.php?id=".$template->ident."\" >Edit</a>"; |
|---|
| 70 |
$column2 .= " | <a href=\"/_templates/?action=deletetemplate&delete_template_id=".$template->ident."\" onClick=\"return confirm('Are you sure you want to permanently remove this template?')\">Delete</a>"; |
|---|
| 71 |
$panel .= run("templates:draw", array( |
|---|
| 72 |
'context' => 'databox', |
|---|
| 73 |
'name' => $name, |
|---|
| 74 |
'column1' => $column1, |
|---|
| 75 |
'column2' => $column2 |
|---|
| 76 |
) |
|---|
| 77 |
); |
|---|
| 78 |
} |
|---|
| 79 |
} |
|---|
| 80 |
|
|---|
| 81 |
$panel .= <<< END |
|---|
| 82 |
|
|---|
| 83 |
<p> |
|---|
| 84 |
<input type="submit" value="Select new template" /> |
|---|
| 85 |
<input type="hidden" name="action" value="templates:select" /> |
|---|
| 86 |
</p> |
|---|
| 87 |
|
|---|
| 88 |
</form> |
|---|
| 89 |
|
|---|
| 90 |
END; |
|---|
| 91 |
|
|---|
| 92 |
$run_result .= $panel; |
|---|
| 93 |
|
|---|
| 94 |
?> |
|---|