PSR-2. I'm not a huge fan, but ugly consistency beats no consistency...

This commit is contained in:
Shish
2019-05-28 17:59:38 +01:00
parent 5ec3e89884
commit 34b05cca7c
295 changed files with 27094 additions and 24632 deletions

View File

@@ -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);
}
}