forked from Cavemanon/cavepaintings
PSR-2. I'm not a huge fan, but ugly consistency beats no consistency...
This commit is contained in:
@@ -10,155 +10,156 @@
|
||||
* site admins can edit it, other people can view and download it
|
||||
*/
|
||||
|
||||
class AddAliasEvent extends Event {
|
||||
/** @var string */
|
||||
public $oldtag;
|
||||
/** @var string */
|
||||
public $newtag;
|
||||
class AddAliasEvent extends Event
|
||||
{
|
||||
/** @var string */
|
||||
public $oldtag;
|
||||
/** @var string */
|
||||
public $newtag;
|
||||
|
||||
public function __construct(string $oldtag, string $newtag) {
|
||||
$this->oldtag = trim($oldtag);
|
||||
$this->newtag = trim($newtag);
|
||||
}
|
||||
public function __construct(string $oldtag, string $newtag)
|
||||
{
|
||||
$this->oldtag = trim($oldtag);
|
||||
$this->newtag = trim($newtag);
|
||||
}
|
||||
}
|
||||
|
||||
class AddAliasException extends SCoreException {}
|
||||
|
||||
class AliasEditor extends Extension {
|
||||
public function onPageRequest(PageRequestEvent $event) {
|
||||
global $config, $database, $page, $user;
|
||||
|
||||
if($event->page_matches("alias")) {
|
||||
if($event->get_arg(0) == "add") {
|
||||
if($user->can("manage_alias_list")) {
|
||||
if(isset($_POST['oldtag']) && isset($_POST['newtag'])) {
|
||||
try {
|
||||
$aae = new AddAliasEvent($_POST['oldtag'], $_POST['newtag']);
|
||||
send_event($aae);
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("alias/list"));
|
||||
}
|
||||
catch(AddAliasException $ex) {
|
||||
$this->theme->display_error(500, "Error adding alias", $ex->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if($event->get_arg(0) == "remove") {
|
||||
if($user->can("manage_alias_list")) {
|
||||
if(isset($_POST['oldtag'])) {
|
||||
$database->execute("DELETE FROM aliases WHERE oldtag=:oldtag", array("oldtag" => $_POST['oldtag']));
|
||||
log_info("alias_editor", "Deleted alias for ".$_POST['oldtag'], "Deleted alias");
|
||||
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("alias/list"));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if($event->get_arg(0) == "list") {
|
||||
$page_number = $event->get_arg(1);
|
||||
if(is_null($page_number) || !is_numeric($page_number)) {
|
||||
$page_number = 0;
|
||||
}
|
||||
else if ($page_number <= 0) {
|
||||
$page_number = 0;
|
||||
}
|
||||
else {
|
||||
$page_number--;
|
||||
}
|
||||
|
||||
$alias_per_page = $config->get_int('alias_items_per_page', 30);
|
||||
|
||||
$query = "SELECT oldtag, newtag FROM aliases ORDER BY newtag ASC LIMIT :limit OFFSET :offset";
|
||||
$alias = $database->get_pairs($query,
|
||||
array("limit"=>$alias_per_page, "offset"=>$page_number * $alias_per_page)
|
||||
);
|
||||
|
||||
$total_pages = ceil($database->get_one("SELECT COUNT(*) FROM aliases") / $alias_per_page);
|
||||
|
||||
$this->theme->display_aliases($alias, $page_number + 1, $total_pages);
|
||||
}
|
||||
else if($event->get_arg(0) == "export") {
|
||||
$page->set_mode("data");
|
||||
$page->set_type("text/csv");
|
||||
$page->set_filename("aliases.csv");
|
||||
$page->set_data($this->get_alias_csv($database));
|
||||
}
|
||||
else if($event->get_arg(0) == "import") {
|
||||
if($user->can("manage_alias_list")) {
|
||||
if(count($_FILES) > 0) {
|
||||
$tmp = $_FILES['alias_file']['tmp_name'];
|
||||
$contents = file_get_contents($tmp);
|
||||
$this->add_alias_csv($database, $contents);
|
||||
log_info("alias_editor", "Imported aliases from file", "Imported aliases"); # FIXME: how many?
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("alias/list"));
|
||||
}
|
||||
else {
|
||||
$this->theme->display_error(400, "No File Specified", "You have to upload a file");
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->theme->display_error(401, "Admins Only", "Only admins can edit the alias list");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function onAddAlias(AddAliasEvent $event) {
|
||||
global $database;
|
||||
$pair = array("oldtag" => $event->oldtag, "newtag" => $event->newtag);
|
||||
if($database->get_row("SELECT * FROM aliases WHERE oldtag=:oldtag AND lower(newtag)=lower(:newtag)", $pair)) {
|
||||
throw new AddAliasException("That alias already exists");
|
||||
}
|
||||
else if($database->get_row("SELECT * FROM aliases WHERE oldtag=:newtag", array("newtag" => $event->newtag))) {
|
||||
throw new AddAliasException("{$event->newtag} is itself an alias");
|
||||
}
|
||||
else {
|
||||
$database->execute("INSERT INTO aliases(oldtag, newtag) VALUES(:oldtag, :newtag)", $pair);
|
||||
log_info("alias_editor", "Added alias for {$event->oldtag} -> {$event->newtag}", "Added alias");
|
||||
}
|
||||
}
|
||||
|
||||
public function onUserBlockBuilding(UserBlockBuildingEvent $event) {
|
||||
global $user;
|
||||
if($user->can("manage_alias_list")) {
|
||||
$event->add_link("Alias Editor", make_link("alias/list"));
|
||||
}
|
||||
}
|
||||
|
||||
private function get_alias_csv(Database $database): string {
|
||||
$csv = "";
|
||||
$aliases = $database->get_pairs("SELECT oldtag, newtag FROM aliases ORDER BY newtag");
|
||||
foreach($aliases as $old => $new) {
|
||||
$csv .= "\"$old\",\"$new\"\n";
|
||||
}
|
||||
return $csv;
|
||||
}
|
||||
|
||||
private function add_alias_csv(Database $database, string $csv) {
|
||||
$csv = str_replace("\r", "\n", $csv);
|
||||
foreach(explode("\n", $csv) as $line) {
|
||||
$parts = str_getcsv($line);
|
||||
if(count($parts) == 2) {
|
||||
try {
|
||||
$aae = new AddAliasEvent($parts[0], $parts[1]);
|
||||
send_event($aae);
|
||||
}
|
||||
catch(AddAliasException $ex) {
|
||||
$this->theme->display_error(500, "Error adding alias", $ex->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the priority for this extension.
|
||||
*
|
||||
* Add alias *after* mass tag editing, else the MTE will
|
||||
* search for the images and be redirected to the alias,
|
||||
* missing out the images tagged with the old tag.
|
||||
*/
|
||||
public function get_priority(): int {return 60;}
|
||||
class AddAliasException extends SCoreException
|
||||
{
|
||||
}
|
||||
|
||||
class AliasEditor extends Extension
|
||||
{
|
||||
public function onPageRequest(PageRequestEvent $event)
|
||||
{
|
||||
global $config, $database, $page, $user;
|
||||
|
||||
if ($event->page_matches("alias")) {
|
||||
if ($event->get_arg(0) == "add") {
|
||||
if ($user->can("manage_alias_list")) {
|
||||
if (isset($_POST['oldtag']) && isset($_POST['newtag'])) {
|
||||
try {
|
||||
$aae = new AddAliasEvent($_POST['oldtag'], $_POST['newtag']);
|
||||
send_event($aae);
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("alias/list"));
|
||||
} catch (AddAliasException $ex) {
|
||||
$this->theme->display_error(500, "Error adding alias", $ex->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif ($event->get_arg(0) == "remove") {
|
||||
if ($user->can("manage_alias_list")) {
|
||||
if (isset($_POST['oldtag'])) {
|
||||
$database->execute("DELETE FROM aliases WHERE oldtag=:oldtag", ["oldtag" => $_POST['oldtag']]);
|
||||
log_info("alias_editor", "Deleted alias for ".$_POST['oldtag'], "Deleted alias");
|
||||
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("alias/list"));
|
||||
}
|
||||
}
|
||||
} elseif ($event->get_arg(0) == "list") {
|
||||
$page_number = $event->get_arg(1);
|
||||
if (is_null($page_number) || !is_numeric($page_number)) {
|
||||
$page_number = 0;
|
||||
} elseif ($page_number <= 0) {
|
||||
$page_number = 0;
|
||||
} else {
|
||||
$page_number--;
|
||||
}
|
||||
|
||||
$alias_per_page = $config->get_int('alias_items_per_page', 30);
|
||||
|
||||
$query = "SELECT oldtag, newtag FROM aliases ORDER BY newtag ASC LIMIT :limit OFFSET :offset";
|
||||
$alias = $database->get_pairs(
|
||||
$query,
|
||||
["limit"=>$alias_per_page, "offset"=>$page_number * $alias_per_page]
|
||||
);
|
||||
|
||||
$total_pages = ceil($database->get_one("SELECT COUNT(*) FROM aliases") / $alias_per_page);
|
||||
|
||||
$this->theme->display_aliases($alias, $page_number + 1, $total_pages);
|
||||
} elseif ($event->get_arg(0) == "export") {
|
||||
$page->set_mode("data");
|
||||
$page->set_type("text/csv");
|
||||
$page->set_filename("aliases.csv");
|
||||
$page->set_data($this->get_alias_csv($database));
|
||||
} elseif ($event->get_arg(0) == "import") {
|
||||
if ($user->can("manage_alias_list")) {
|
||||
if (count($_FILES) > 0) {
|
||||
$tmp = $_FILES['alias_file']['tmp_name'];
|
||||
$contents = file_get_contents($tmp);
|
||||
$this->add_alias_csv($database, $contents);
|
||||
log_info("alias_editor", "Imported aliases from file", "Imported aliases"); # FIXME: how many?
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("alias/list"));
|
||||
} else {
|
||||
$this->theme->display_error(400, "No File Specified", "You have to upload a file");
|
||||
}
|
||||
} else {
|
||||
$this->theme->display_error(401, "Admins Only", "Only admins can edit the alias list");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function onAddAlias(AddAliasEvent $event)
|
||||
{
|
||||
global $database;
|
||||
$pair = ["oldtag" => $event->oldtag, "newtag" => $event->newtag];
|
||||
if ($database->get_row("SELECT * FROM aliases WHERE oldtag=:oldtag AND lower(newtag)=lower(:newtag)", $pair)) {
|
||||
throw new AddAliasException("That alias already exists");
|
||||
} elseif ($database->get_row("SELECT * FROM aliases WHERE oldtag=:newtag", ["newtag" => $event->newtag])) {
|
||||
throw new AddAliasException("{$event->newtag} is itself an alias");
|
||||
} else {
|
||||
$database->execute("INSERT INTO aliases(oldtag, newtag) VALUES(:oldtag, :newtag)", $pair);
|
||||
log_info("alias_editor", "Added alias for {$event->oldtag} -> {$event->newtag}", "Added alias");
|
||||
}
|
||||
}
|
||||
|
||||
public function onUserBlockBuilding(UserBlockBuildingEvent $event)
|
||||
{
|
||||
global $user;
|
||||
if ($user->can("manage_alias_list")) {
|
||||
$event->add_link("Alias Editor", make_link("alias/list"));
|
||||
}
|
||||
}
|
||||
|
||||
private function get_alias_csv(Database $database): string
|
||||
{
|
||||
$csv = "";
|
||||
$aliases = $database->get_pairs("SELECT oldtag, newtag FROM aliases ORDER BY newtag");
|
||||
foreach ($aliases as $old => $new) {
|
||||
$csv .= "\"$old\",\"$new\"\n";
|
||||
}
|
||||
return $csv;
|
||||
}
|
||||
|
||||
private function add_alias_csv(Database $database, string $csv)
|
||||
{
|
||||
$csv = str_replace("\r", "\n", $csv);
|
||||
foreach (explode("\n", $csv) as $line) {
|
||||
$parts = str_getcsv($line);
|
||||
if (count($parts) == 2) {
|
||||
try {
|
||||
$aae = new AddAliasEvent($parts[0], $parts[1]);
|
||||
send_event($aae);
|
||||
} catch (AddAliasException $ex) {
|
||||
$this->theme->display_error(500, "Error adding alias", $ex->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the priority for this extension.
|
||||
*
|
||||
* Add alias *after* mass tag editing, else the MTE will
|
||||
* search for the images and be redirected to the alias,
|
||||
* missing out the images tagged with the old tag.
|
||||
*/
|
||||
public function get_priority(): int
|
||||
{
|
||||
return 60;
|
||||
}
|
||||
}
|
||||
|
@@ -1,104 +1,107 @@
|
||||
<?php
|
||||
class AliasEditorTest extends ShimmiePHPUnitTestCase {
|
||||
public function testAliasList() {
|
||||
$this->get_page('alias/list');
|
||||
$this->assert_response(200);
|
||||
$this->assert_title("Alias List");
|
||||
}
|
||||
class AliasEditorTest extends ShimmiePHPUnitTestCase
|
||||
{
|
||||
public function testAliasList()
|
||||
{
|
||||
$this->get_page('alias/list');
|
||||
$this->assert_response(200);
|
||||
$this->assert_title("Alias List");
|
||||
}
|
||||
|
||||
public function testAliasListReadOnly() {
|
||||
// Check that normal users can't add aliases.
|
||||
$this->log_in_as_user();
|
||||
$this->get_page('alias/list');
|
||||
$this->assert_title("Alias List");
|
||||
$this->assert_no_text("Add");
|
||||
}
|
||||
public function testAliasListReadOnly()
|
||||
{
|
||||
// Check that normal users can't add aliases.
|
||||
$this->log_in_as_user();
|
||||
$this->get_page('alias/list');
|
||||
$this->assert_title("Alias List");
|
||||
$this->assert_no_text("Add");
|
||||
}
|
||||
|
||||
public function testAliasEditor() {
|
||||
/*
|
||||
**********************************************************************
|
||||
* FIXME: TODO:
|
||||
* For some reason the alias tests always fail when they are running
|
||||
* inside the TravisCI VM environment. I have tried to determine
|
||||
* the exact cause of this, but have been unable to pin it down.
|
||||
*
|
||||
* For now, I am commenting them out until I have more time to
|
||||
* dig into this and determine exactly what is happening.
|
||||
*
|
||||
*********************************************************************
|
||||
*/
|
||||
$this->markTestIncomplete();
|
||||
public function testAliasEditor()
|
||||
{
|
||||
/*
|
||||
**********************************************************************
|
||||
* FIXME: TODO:
|
||||
* For some reason the alias tests always fail when they are running
|
||||
* inside the TravisCI VM environment. I have tried to determine
|
||||
* the exact cause of this, but have been unable to pin it down.
|
||||
*
|
||||
* For now, I am commenting them out until I have more time to
|
||||
* dig into this and determine exactly what is happening.
|
||||
*
|
||||
*********************************************************************
|
||||
*/
|
||||
$this->markTestIncomplete();
|
||||
|
||||
$this->log_in_as_admin();
|
||||
$this->log_in_as_admin();
|
||||
|
||||
# test one to one
|
||||
$this->get_page('alias/list');
|
||||
$this->assert_title("Alias List");
|
||||
$this->set_field('oldtag', "test1");
|
||||
$this->set_field('newtag', "test2");
|
||||
$this->clickSubmit('Add');
|
||||
$this->assert_no_text("Error adding alias");
|
||||
# test one to one
|
||||
$this->get_page('alias/list');
|
||||
$this->assert_title("Alias List");
|
||||
$this->set_field('oldtag', "test1");
|
||||
$this->set_field('newtag', "test2");
|
||||
$this->clickSubmit('Add');
|
||||
$this->assert_no_text("Error adding alias");
|
||||
|
||||
$this->get_page('alias/list');
|
||||
$this->assert_text("test1");
|
||||
$this->get_page('alias/list');
|
||||
$this->assert_text("test1");
|
||||
|
||||
$this->get_page("alias/export/aliases.csv");
|
||||
$this->assert_text("test1,test2");
|
||||
$this->get_page("alias/export/aliases.csv");
|
||||
$this->assert_text("test1,test2");
|
||||
|
||||
$image_id = $this->post_image("tests/pbx_screenshot.jpg", "test1");
|
||||
$this->get_page("post/view/$image_id"); # check that the tag has been replaced
|
||||
$this->assert_title("Image $image_id: test2");
|
||||
$this->get_page("post/list/test1/1"); # searching for an alias should find the master tag
|
||||
$this->assert_title("Image $image_id: test2");
|
||||
$this->get_page("post/list/test2/1"); # check that searching for the main tag still works
|
||||
$this->assert_title("Image $image_id: test2");
|
||||
$this->delete_image($image_id);
|
||||
$image_id = $this->post_image("tests/pbx_screenshot.jpg", "test1");
|
||||
$this->get_page("post/view/$image_id"); # check that the tag has been replaced
|
||||
$this->assert_title("Image $image_id: test2");
|
||||
$this->get_page("post/list/test1/1"); # searching for an alias should find the master tag
|
||||
$this->assert_title("Image $image_id: test2");
|
||||
$this->get_page("post/list/test2/1"); # check that searching for the main tag still works
|
||||
$this->assert_title("Image $image_id: test2");
|
||||
$this->delete_image($image_id);
|
||||
|
||||
$this->get_page('alias/list');
|
||||
$this->click("Remove");
|
||||
$this->get_page('alias/list');
|
||||
$this->assert_title("Alias List");
|
||||
$this->assert_no_text("test1");
|
||||
$this->get_page('alias/list');
|
||||
$this->click("Remove");
|
||||
$this->get_page('alias/list');
|
||||
$this->assert_title("Alias List");
|
||||
$this->assert_no_text("test1");
|
||||
|
||||
# test one to many
|
||||
$this->get_page('alias/list');
|
||||
$this->assert_title("Alias List");
|
||||
$this->set_field('oldtag', "onetag");
|
||||
$this->set_field('newtag', "multi tag");
|
||||
$this->click("Add");
|
||||
$this->get_page('alias/list');
|
||||
$this->assert_text("multi");
|
||||
$this->assert_text("tag");
|
||||
# test one to many
|
||||
$this->get_page('alias/list');
|
||||
$this->assert_title("Alias List");
|
||||
$this->set_field('oldtag', "onetag");
|
||||
$this->set_field('newtag', "multi tag");
|
||||
$this->click("Add");
|
||||
$this->get_page('alias/list');
|
||||
$this->assert_text("multi");
|
||||
$this->assert_text("tag");
|
||||
|
||||
$this->get_page("alias/export/aliases.csv");
|
||||
$this->assert_text("onetag,multi tag");
|
||||
$this->get_page("alias/export/aliases.csv");
|
||||
$this->assert_text("onetag,multi tag");
|
||||
|
||||
$image_id_1 = $this->post_image("tests/pbx_screenshot.jpg", "onetag");
|
||||
$image_id_2 = $this->post_image("tests/bedroom_workshop.jpg", "onetag");
|
||||
// FIXME: known broken
|
||||
//$this->get_page("post/list/onetag/1"); # searching for an aliased tag should find its aliases
|
||||
//$this->assert_title("onetag");
|
||||
//$this->assert_no_text("No Images Found");
|
||||
$this->get_page("post/list/multi/1");
|
||||
$this->assert_title("multi");
|
||||
$this->assert_no_text("No Images Found");
|
||||
$this->get_page("post/list/multi%20tag/1");
|
||||
$this->assert_title("multi tag");
|
||||
$this->assert_no_text("No Images Found");
|
||||
$this->delete_image($image_id_1);
|
||||
$this->delete_image($image_id_2);
|
||||
$image_id_1 = $this->post_image("tests/pbx_screenshot.jpg", "onetag");
|
||||
$image_id_2 = $this->post_image("tests/bedroom_workshop.jpg", "onetag");
|
||||
// FIXME: known broken
|
||||
//$this->get_page("post/list/onetag/1"); # searching for an aliased tag should find its aliases
|
||||
//$this->assert_title("onetag");
|
||||
//$this->assert_no_text("No Images Found");
|
||||
$this->get_page("post/list/multi/1");
|
||||
$this->assert_title("multi");
|
||||
$this->assert_no_text("No Images Found");
|
||||
$this->get_page("post/list/multi%20tag/1");
|
||||
$this->assert_title("multi tag");
|
||||
$this->assert_no_text("No Images Found");
|
||||
$this->delete_image($image_id_1);
|
||||
$this->delete_image($image_id_2);
|
||||
|
||||
$this->get_page('alias/list');
|
||||
$this->click("Remove");
|
||||
$this->get_page('alias/list');
|
||||
$this->assert_title("Alias List");
|
||||
$this->assert_no_text("test1");
|
||||
$this->get_page('alias/list');
|
||||
$this->click("Remove");
|
||||
$this->get_page('alias/list');
|
||||
$this->assert_title("Alias List");
|
||||
$this->assert_no_text("test1");
|
||||
|
||||
$this->log_out();
|
||||
$this->log_out();
|
||||
|
||||
$this->get_page('alias/list');
|
||||
$this->assert_title("Alias List");
|
||||
$this->assert_no_text("Add");
|
||||
}
|
||||
$this->get_page('alias/list');
|
||||
$this->assert_title("Alias List");
|
||||
$this->assert_no_text("Add");
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,18 +1,20 @@
|
||||
<?php
|
||||
|
||||
class AliasEditorTheme extends Themelet {
|
||||
/**
|
||||
* Show a page of aliases.
|
||||
*
|
||||
* Note: $can_manage = whether things like "add new alias" should be shown
|
||||
*/
|
||||
public function display_aliases(array $aliases, int $pageNumber, int $totalPages): void {
|
||||
global $page, $user;
|
||||
class AliasEditorTheme extends Themelet
|
||||
{
|
||||
/**
|
||||
* Show a page of aliases.
|
||||
*
|
||||
* Note: $can_manage = whether things like "add new alias" should be shown
|
||||
*/
|
||||
public function display_aliases(array $aliases, int $pageNumber, int $totalPages): void
|
||||
{
|
||||
global $page, $user;
|
||||
|
||||
$can_manage = $user->can("manage_alias_list");
|
||||
if($can_manage) {
|
||||
$h_action = "<th width='10%'>Action</th>";
|
||||
$h_add = "
|
||||
$can_manage = $user->can("manage_alias_list");
|
||||
if ($can_manage) {
|
||||
$h_action = "<th width='10%'>Action</th>";
|
||||
$h_add = "
|
||||
<tr>
|
||||
".make_form(make_link("alias/add"))."
|
||||
<td><input type='text' name='oldtag' class='autocomplete_tags' autocomplete='off'></td>
|
||||
@@ -21,20 +23,19 @@ class AliasEditorTheme extends Themelet {
|
||||
</form>
|
||||
</tr>
|
||||
";
|
||||
}
|
||||
else {
|
||||
$h_action = "";
|
||||
$h_add = "";
|
||||
}
|
||||
} else {
|
||||
$h_action = "";
|
||||
$h_add = "";
|
||||
}
|
||||
|
||||
$h_aliases = "";
|
||||
foreach($aliases as $old => $new) {
|
||||
$h_old = html_escape($old);
|
||||
$h_new = "<a href='".make_link("post/list/".url_escape($new)."/1")."'>".html_escape($new)."</a>";
|
||||
$h_aliases = "";
|
||||
foreach ($aliases as $old => $new) {
|
||||
$h_old = html_escape($old);
|
||||
$h_new = "<a href='".make_link("post/list/".url_escape($new)."/1")."'>".html_escape($new)."</a>";
|
||||
|
||||
$h_aliases .= "<tr><td>$h_old</td><td>$h_new</td>";
|
||||
if($can_manage) {
|
||||
$h_aliases .= "
|
||||
$h_aliases .= "<tr><td>$h_old</td><td>$h_new</td>";
|
||||
if ($can_manage) {
|
||||
$h_aliases .= "
|
||||
<td>
|
||||
".make_form(make_link("alias/remove"))."
|
||||
<input type='hidden' name='oldtag' value='$h_old'>
|
||||
@@ -42,10 +43,10 @@ class AliasEditorTheme extends Themelet {
|
||||
</form>
|
||||
</td>
|
||||
";
|
||||
}
|
||||
$h_aliases .= "</tr>";
|
||||
}
|
||||
$html = "
|
||||
}
|
||||
$h_aliases .= "</tr>";
|
||||
}
|
||||
$html = "
|
||||
<table id='aliases' class='sortable zebra'>
|
||||
<thead><tr><th>From</th><th>To</th>$h_action</tr></thead>
|
||||
<tbody>$h_aliases</tbody>
|
||||
@@ -54,22 +55,21 @@ class AliasEditorTheme extends Themelet {
|
||||
<p><a href='".make_link("alias/export/aliases.csv")."' download='aliases.csv'>Download as CSV</a></p>
|
||||
";
|
||||
|
||||
$bulk_html = "
|
||||
$bulk_html = "
|
||||
".make_form(make_link("alias/import"), 'post', true)."
|
||||
<input type='file' name='alias_file'>
|
||||
<input type='submit' value='Upload List'>
|
||||
</form>
|
||||
";
|
||||
|
||||
$page->set_title("Alias List");
|
||||
$page->set_heading("Alias List");
|
||||
$page->add_block(new NavBlock());
|
||||
$page->add_block(new Block("Aliases", $html));
|
||||
if($can_manage) {
|
||||
$page->add_block(new Block("Bulk Upload", $bulk_html, "main", 51));
|
||||
}
|
||||
$page->set_title("Alias List");
|
||||
$page->set_heading("Alias List");
|
||||
$page->add_block(new NavBlock());
|
||||
$page->add_block(new Block("Aliases", $html));
|
||||
if ($can_manage) {
|
||||
$page->add_block(new Block("Bulk Upload", $bulk_html, "main", 51));
|
||||
}
|
||||
|
||||
$this->display_paginator($page, "alias/list", null, $pageNumber, $totalPages);
|
||||
}
|
||||
$this->display_paginator($page, "alias/list", null, $pageNumber, $totalPages);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user