This repository has been archived on 2024-09-05. You can view files and clone it, but cannot push or open issues or pull requests.
shimmie2/ext/alias_editor/theme.php

81 lines
2.1 KiB
PHP
Raw Normal View History

<?php
class AliasEditorTheme extends Themelet {
/*
* Show a page of aliases:
*
* $aliases = an array of ($old_tag => $new_tag)
* $is_admin = whether things like "add new alias" should be shown
*/
2009-08-25 01:36:00 +00:00
public function display_aliases(Page $page, $aliases, $is_admin, $pageNumber, $totalPages) {
if($is_admin) {
2009-01-17 04:24:43 +00:00
$action = "<th width='10%'>Action</th>";
$add = "
<tr>
<form action='".make_link("alias/add")."' method='POST'>
<td><input type='text' name='oldtag'></td>
<td><input type='text' name='newtag'></td>
<td><input type='submit' value='Add'></td>
</form>
</tr>
";
}
else {
$action = "";
$add = "";
}
2009-01-04 19:18:37 +00:00
$h_aliases = "";
2009-01-17 04:24:43 +00:00
$n = 0;
foreach($aliases as $old => $new) {
$h_old = html_escape($old);
$h_new = html_escape($new);
2009-01-17 04:24:43 +00:00
$oe = ($n++ % 2 == 0) ? "even" : "odd";
$h_aliases .= "<tr class='$oe'><td>$h_old</td><td>$h_new</td>";
if($is_admin) {
$h_aliases .= "
<td>
<form action='".make_link("alias/remove")."' method='POST'>
<input type='hidden' name='oldtag' value='$h_old'>
<input type='submit' value='Remove'>
</form>
</td>
";
}
$h_aliases .= "</tr>";
}
$html = "
2009-07-07 12:42:34 +00:00
<script>
$(document).ready(function() {
$(\"#aliases\").tablesorter();
});
</script>
<table id='aliases' class='zebra'>
<thead><tr><th>From</th><th>To</th>$action</tr></thead>
2009-01-17 04:53:11 +00:00
<tbody>$h_aliases</tbody>
<tfoot>$add</tfoot>
</table>
<p><a href='".make_link("alias/export/aliases.csv")."'>Download as CSV</a></p>
2009-08-03 09:24:32 +00:00
";
$bulk_html = "
<form enctype='multipart/form-data' action='".make_link("alias/import")."' method='POST'>
<input type='file' name='alias_file'>
<input type='submit' value='Upload List'>
</form>
";
2009-01-04 19:18:37 +00:00
$page->set_title("Alias List");
$page->set_heading("Alias List");
$page->add_block(new NavBlock());
$page->add_block(new Block("Aliases", $html));
2009-08-03 09:24:32 +00:00
if($is_admin) {
$page->add_block(new Block("Bulk Upload", $bulk_html, "main", 51));
}
2009-08-25 01:36:00 +00:00
$this->display_paginator($page, "alias/list", null, $pageNumber, $totalPages);
}
}
?>