2007-06-30 01:19:11 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class AliasEditorTheme extends Themelet {
|
2007-07-28 20:30:01 +00:00
|
|
|
/*
|
|
|
|
* Show a page of aliases:
|
|
|
|
*
|
|
|
|
* $aliases = an array of ($old_tag => $new_tag)
|
2012-02-07 15:15:18 +00:00
|
|
|
* $can_manage = whether things like "add new alias" should be shown
|
2007-07-28 20:30:01 +00:00
|
|
|
*/
|
2012-02-07 15:15:18 +00:00
|
|
|
public function display_aliases($aliases, $pageNumber, $totalPages) {
|
|
|
|
global $page, $user;
|
|
|
|
|
|
|
|
$can_manage = $user->can("manage_alias_list");
|
|
|
|
if($can_manage) {
|
2012-02-13 20:51:34 +00:00
|
|
|
$h_action = "<th width='10%'>Action</th>";
|
|
|
|
$h_add = "
|
2007-06-30 01:19:11 +00:00
|
|
|
<tr>
|
2010-09-22 11:56:19 +00:00
|
|
|
".make_form(make_link("alias/add"))."
|
2007-06-30 01:19:11 +00:00
|
|
|
<td><input type='text' name='oldtag'></td>
|
|
|
|
<td><input type='text' name='newtag'></td>
|
|
|
|
<td><input type='submit' value='Add'></td>
|
|
|
|
</form>
|
|
|
|
</tr>
|
|
|
|
";
|
|
|
|
}
|
|
|
|
else {
|
2012-02-13 20:51:34 +00:00
|
|
|
$h_action = "";
|
|
|
|
$h_add = "";
|
2007-06-30 01:19:11 +00:00
|
|
|
}
|
2009-01-04 19:18:37 +00:00
|
|
|
|
2007-06-30 01:19:11 +00:00
|
|
|
$h_aliases = "";
|
|
|
|
foreach($aliases as $old => $new) {
|
|
|
|
$h_old = html_escape($old);
|
2009-09-15 17:42:42 +00:00
|
|
|
$h_new = "<a href='".make_link("post/list/".url_escape($new)."/1")."'>".html_escape($new)."</a>";
|
2014-02-22 20:36:52 +00:00
|
|
|
|
2012-02-22 14:27:56 +00:00
|
|
|
$h_aliases .= "<tr><td>$h_old</td><td>$h_new</td>";
|
2012-02-07 15:15:18 +00:00
|
|
|
if($can_manage) {
|
2007-06-30 01:19:11 +00:00
|
|
|
$h_aliases .= "
|
|
|
|
<td>
|
2010-09-22 11:56:19 +00:00
|
|
|
".make_form(make_link("alias/remove"))."
|
2007-06-30 01:19:11 +00:00
|
|
|
<input type='hidden' name='oldtag' value='$h_old'>
|
|
|
|
<input type='submit' value='Remove'>
|
|
|
|
</form>
|
|
|
|
</td>
|
|
|
|
";
|
|
|
|
}
|
|
|
|
$h_aliases .= "</tr>";
|
|
|
|
}
|
|
|
|
$html = "
|
2012-02-13 20:51:34 +00:00
|
|
|
<table id='aliases' class='sortable zebra'>
|
|
|
|
<thead><tr><th>From</th><th>To</th>$h_action</tr></thead>
|
2009-01-17 04:53:11 +00:00
|
|
|
<tbody>$h_aliases</tbody>
|
2012-02-13 20:51:34 +00:00
|
|
|
<tfoot>$h_add</tfoot>
|
2007-06-30 01:19:11 +00:00
|
|
|
</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 = "
|
2013-07-05 22:12:25 +00:00
|
|
|
".make_form(make_link("alias/import"), 'post', true)."
|
2008-02-16 03:58:05 +00:00
|
|
|
<input type='file' name='alias_file'>
|
|
|
|
<input type='submit' value='Upload List'>
|
|
|
|
</form>
|
2007-06-30 01:19:11 +00:00
|
|
|
";
|
2009-01-04 19:18:37 +00:00
|
|
|
|
2007-06-30 01:19:11 +00:00
|
|
|
$page->set_title("Alias List");
|
|
|
|
$page->set_heading("Alias List");
|
|
|
|
$page->add_block(new NavBlock());
|
|
|
|
$page->add_block(new Block("Aliases", $html));
|
2012-02-07 15:15:18 +00:00
|
|
|
if($can_manage) {
|
2009-08-03 09:24:32 +00:00
|
|
|
$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);
|
2007-06-30 01:19:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|