more alias list things
git-svn-id: file:///home/shish/svn/shimmie2/trunk@159 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
parent
c6661ce84b
commit
b87c304ed9
1 changed files with 55 additions and 39 deletions
|
@ -15,34 +15,37 @@ class AliasEditor extends Extension {
|
|||
public function receive_event($event) {
|
||||
if(is_a($event, 'PageRequestEvent') && ($event->page == "alias")) {
|
||||
global $user;
|
||||
if($user->is_admin()) {
|
||||
if($event->get_arg(0) == "add") {
|
||||
if($event->get_arg(0) == "add") {
|
||||
if($user->is_admin()) {
|
||||
if(isset($_POST['oldtag']) && isset($_POST['newtag'])) {
|
||||
send_event(new AddAliasEvent($_POST['oldtag'], $_POST['newtag']));
|
||||
}
|
||||
}
|
||||
else if($event->get_arg(0) == "remove") {
|
||||
}
|
||||
else if($event->get_arg(0) == "remove") {
|
||||
if($user->is_admin()) {
|
||||
if(isset($_POST['oldtag'])) {
|
||||
global $database;
|
||||
$database->Execute("DELETE FROM aliases WHERE oldtag=?", array($_POST['oldtag']));
|
||||
|
||||
|
||||
global $page;
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("admin"));
|
||||
}
|
||||
}
|
||||
else if($event->get_arg(0) == "list") {
|
||||
global $page;
|
||||
$page->set_title("Alias List");
|
||||
$page->set_heading("Alias List");
|
||||
$page->add_main_block(new Block("Aliases", $this->build_aliases()));
|
||||
}
|
||||
else if($event->get_arg(0) == "export") {
|
||||
global $page;
|
||||
$page->set_mode("data");
|
||||
$page->set_type("text/plain");
|
||||
$page->set_data($this->get_alias_csv());
|
||||
}
|
||||
}
|
||||
else if($event->get_arg(0) == "list") {
|
||||
global $page;
|
||||
$page->set_title("Alias List");
|
||||
$page->set_heading("Alias List");
|
||||
$page->add_side_block(new NavBlock());
|
||||
$page->add_main_block(new Block("Aliases", $this->build_aliases()));
|
||||
}
|
||||
else if($event->get_arg(0) == "export") {
|
||||
global $page;
|
||||
$page->set_mode("data");
|
||||
$page->set_type("text/plain");
|
||||
$page->set_data($this->get_alias_csv());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,28 +68,11 @@ class AliasEditor extends Extension {
|
|||
// admin page HTML {{{
|
||||
private function build_aliases() {
|
||||
global $database;
|
||||
$h_aliases = "";
|
||||
$aliases = $database->db->GetAssoc("SELECT oldtag, newtag FROM aliases");
|
||||
foreach($aliases as $old => $new) {
|
||||
$h_old = html_escape($old);
|
||||
$h_new = html_escape($new);
|
||||
$h_aliases .= "
|
||||
<tr>
|
||||
<td>$h_old</td>
|
||||
<td>$h_new</td>
|
||||
<td>
|
||||
<form action='".make_link("alias/remove")."' method='POST'>
|
||||
<input type='hidden' name='oldtag' value='$h_old'>
|
||||
<input type='submit' value='Remove'>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
";
|
||||
}
|
||||
$html = "
|
||||
<table border='1'>
|
||||
<thead><td>From</td><td>To</td><td>Action</td></thead>
|
||||
$h_aliases
|
||||
|
||||
global $user;
|
||||
if($user->is_admin()) {
|
||||
$action = "<td>Action</td>";
|
||||
$add = "
|
||||
<tr>
|
||||
<form action='".make_link("alias/add")."' method='POST'>
|
||||
<td><input type='text' name='oldtag'></td>
|
||||
|
@ -94,8 +80,38 @@ class AliasEditor extends Extension {
|
|||
<td><input type='submit' value='Add'></td>
|
||||
</form>
|
||||
</tr>
|
||||
";
|
||||
}
|
||||
else {
|
||||
$action = "";
|
||||
$add = "";
|
||||
}
|
||||
|
||||
$h_aliases = "";
|
||||
$aliases = $database->db->GetAssoc("SELECT oldtag, newtag FROM aliases");
|
||||
foreach($aliases as $old => $new) {
|
||||
$h_old = html_escape($old);
|
||||
$h_new = html_escape($new);
|
||||
$h_aliases .= "<tr><td>$h_old</td><td>$h_new</td>";
|
||||
if($user->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 = "
|
||||
<table border='1'>
|
||||
<thead><td>From</td><td>To</td>$action</thead>
|
||||
$h_aliases
|
||||
$add
|
||||
</table>
|
||||
<p><a href='".make_link("alias/export")."'>Export</a>
|
||||
<p><a href='".make_link("alias/export")."'>Export</a></p>
|
||||
";
|
||||
return $html;
|
||||
}
|
||||
|
|
Reference in a new issue