Abstract List A list of anything.
[show modes: view add submit info edit manage]

[begin mode delete]
[msg_start()]
<p>This is the deletion page! There is no way to get a list back once it is deleted. All of its children will also be deleted. Do you really want to do this?</p>
<p><a href="/?id=[$_id]">No! This idea was bad and I should feel bad!</a></p>
<p><a href="/?id=[$_id]&mode=delete_submit">Yes! Kill it with fire!</a></p>
[msg_end()]
[end mode delete]

[begin mode delete_submit]
[children("delete", $_id);
$n = delete_page($_id);
if($n == "1") {
	<p><b>[$_title]</b> has been removed from 
	<b>[get_title($_parent)]</b>.</p>
} else {
	<p><b>[$_title]</b> could not be removed from 
	<b>[get_title($_parent)]</b> by you ([$_viewer.name]). If you 
	feel that should be able to do so, now might be a good time to
	<a href="mailto:[$_globals.ADMIN_EMAIL]?Subject=Can't delete 
	character on Pony Prospectus"> write a letter to 
	the administrator</a>.</p>
}]
<p><a href="/?id=[$_parent]">Return to [get_title($_parent)]</p>
[end mode delete_submit]

[begin mode first]
[
$sortby = "id DESC, title";
if(getv("alpha") != "") $sortby = "title";
$q = query({first_[$_id]}, 1, $sortby, "parent", $_id);
query_view("abbr", $q);

if(can_comment()) {
<p style="text-align: center"><a href="/?id=[$_id]&mode=add">Add new [get_title({[if(getv("template") == "") {[$_body]} else {[getv("template")]};]})]</a></p>
};
]
[end mode first]

[begin mode abbr]
[
iif(can_read(), {
    <li><a href="/?[$_title]">[$_title]</a></li>
    });
]
[end mode abbr]

[begin mode option]
<option value="[$_id]">[$_title]</option>
[end mode option]

[begin mode table]

<tr><th><a href="/?[$_title]">[$_title]</a>
<td>[$_subtitle]

[end mode table]

[begin mode include]
[
$sortby = "id DESC, title";
if(getv("alpha") != "") $sortby = "title";

$ps = getv("pagesize");
$q = query({include_[$_id]}, $ps, $sortby, "parent", $_id);
$c = query_count($q);
]
<h2>[$_title;]
[if(can_comment()) { &middot; 
<a href="/?id=[$_id]&mode=add">+</a> &middot; <a href="/?id=[$_id]&mode=manage">m</a>
};][
if($c > $pagesize) {[
	if($pagesize > 0) { &middot; <a href="/?id=[$_id]">...</a>};
]};
]</h2>

<span style="font-size: 12pt">
[
iif(can_read(), {[query_view("abbr", $q);]}, "No read permission! Go away!");]
</span>
[end mode include]

[begin mode view]
[
if(can_read()) {[
	$sortby = "id DESC, title";
	if(getv("alpha") != "") $sortby = "title";
	$q = query({view_[$_id]}, getv("pagesize"), $sortby, "parent", $_id);
	$c = query_view("abbr", $q);
	if(strpos($c, "<li>") == strpos($c, "<")) {<ul>[$c]</ul>} else $c;

	$ps = getv("pagesize");
	$z = query_count($q);
	if($z > $ps) {[
		if($ps != 0) {<center><br>[
			$np = next_page($q);
			$pp = previous_page($q);

			if($pp != "-1") {<a href="[$pp]">Previous</a> };
			]
			<div style="display: inline-block;">
			[page_list($q);]
			</div>
			[
			if($np != "-1") { <a href="[$np]">Next</a>};
		]<br></center>};
	]};

]} else {
	No read permission! Go away!
};
]
[if(can_comment()) {
<center><a href="/?id=[$_id]&mode=submit">Add new [get_title({[if(getv("template") == "") {[$_body]} else {[getv("template")]};]})]</a> (<a href="/?id=[$_id]&mode=add">with title</a>) | <a href="/?id=[$_id]&mode=manage">Manage List</a></center>
};]
[end mode view]

[begin mode add]
<form method="post" action="/" width="100%">
<input type="hidden" name="id" value="[$_id]">
<input type="hidden" name="mode" value="submit">
<table width="100%">
<tr><th>Title:</th><td><input type="text" class="textbox" name="title" value=""></td></tr>
<tr><th></th><td>
<span class="buttonbox"><input name="submitButton" class="submit" type="submit" value="Create"></span> <i>your permissions</i>: [$_viewer.permissions]</td></tr></table>
</form> 
[end mode add]

[begin mode submit]
[
$sb = $_params.title;
if($sb == "") $sb = {Untitled entry at [now()]};
$e = new_page($sb, $_id);
if($e > 0) {
    [
    set_template($e, {[if(getv("template") == "") {[$_body]} else {[getv("template")]};]});
    set_group($e, $_group);
    set_permissions($e, $_permissions);
    msg_start();
    page("edit", $e);
    msg_end();
    ]
} else {
    [msg_start();]
    Disaster. It failed! Maybe you should check the error log.
    [msg_end();]
};
]
[end mode submit]

[begin mode info]
[iif(can_read(), {
<table>
<tr><th>Title:
	<td>[info_display($_title)]
<tr><th>Subtitle:
	<td>[info_display($_subtitle)]
<tr><th>Parent:
	<td>[$_parent]
<tr><th>Permissions:
	<td>[$_permissions]
<tr><th>Author:
	<td>[$_author]
<tr><th>Group:
	<td>[$_group]
<tr><th>ID:
	<td>[$_id]
<tr><th>Template:
	<td>[$_template]
<tr><th>Children:
	<td>[
	$q = query("info", 0, "title", "parent", $_id);
	query_count($q);
]
<tr><th>Page Size:
	<td>[getv("pagesize");]
<tr><th>Child Template:
	<td>[getv("template");]
<tr><th>Alphabetical Sort:
	<td>[if(getv("alpha") != "") {Yes} else {No};]
</table>
}, "No permission. Please leave!");]
[end mode info]

[begin mode manage]
[iif(can_edit(), {
[children("edit", $_id);]
}, "No permission. Don't do that.");]
[if(can_comment()) {
<p><a href="/?id=[$_id]&mode=add">Add item</a></p>
};]
[end mode manage]

[begin mode edit]
[;
iif(can_edit(), {
<form method="post" action="/" width="100%">
<input type="hidden" name="id" value="[$_id]">
<input type="hidden" name="mode" value="edit_submit">
<table width="100%">
<tr><th>Title:
	<td><input type="text" name="title" value="[edit_display($_title)]" style="width: 100%">
<tr><th>Subtitle:
	<td><input type="text" name="subtitle" value="[edit_display($_subtitle)]" style="width: 100%">
<tr><th>Parent:
	<td><input type="text" name="parent" value="[$_parent]">
<tr><th>Permissions:
	<td><input type="text" name="permissions" value="[$_permissions]">
<tr><th>Author:
	<td><input type="text" name="author" value="[$_author]">
<tr><th>Group:
	<td><input type="text" name="group" value="[$_group]">
<tr><th>Priority:
	<td><input type="text" name="priority" value="[$_priority]">
<tr><th>Template:
	<td><input type="text" name="template" value="[$_template]">
<tr><th>Alphabetical:
	<td><input type="checkbox" name="alpha"[if(getv("alpha") != "") {checked}] value="1" id="alpha"> <label for="alpha">Sort alphabetically</label>
<tr><th>ID of Template for Children:
	<td><input type="text" name="c_template" value="[if(getv("template") == "") {[$_body]} else {[getv("template")]};]">
<tr><th>Entries per page:
	<td><input type="text" name="pagesize" value="[getv("pagesize")]">

<tr><td><td>
<span class="buttonbox"><input name="submitButton" class="submit" type="submit" value="Submit"></span> <i>your permissions</i>: [$_viewer.permissions]
</table>
</form>
}, "What are you doing? You don't even have edit permission.");]
[end mode edit]

[begin mode edit_submit]
[
	$_title = $_params.title;
	$_subtitle = $_params.subtitle;
	$_parent = $_params.parent;
	$_permissions = $_params.permissions;
	$_author = $_params.author;
	$_group = $_params.group;
	putv("template", $_params.c_template);
	putv("pagesize", $_params.pagesize);
	putv("alpha", $_params.alpha);
	$_priority = $_params.priority;
	$_template = $_params.template;
]
<h2>List updated.</h2>
<a href="/?[$_title]">Return to it.</a> 
[end mode edit_submit]