Skip to content

Commit

Permalink
Module/Character: Clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
Nightprince committed Oct 14, 2024
1 parent a9d41fb commit d401d0e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 25 deletions.
5 changes: 2 additions & 3 deletions application/modules/character/css/character.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
background-image: url(../../../images/misc/bg_alliance_complete.png);
}

.col-avatar,
.col-items {
width:70px !important;
.col-avatar, .col-items {
width:70px;
}

.col-main {
Expand Down
14 changes: 7 additions & 7 deletions application/modules/character/models/Character_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function characterExists()
{
$this->connect();

$query = $this->connection->query("SELECT COUNT(*) AS total FROM " . table("characters", $this->realmId) . " WHERE " . column("characters", "guid", false, $this->realmId) . "= ?", array($this->id));
$query = $this->connection->query("SELECT COUNT(*) AS total FROM " . table("characters", $this->realmId) . " WHERE " . column("characters", "guid", false, $this->realmId) . "= ?", [$this->id]);
$row = $query->getResultArray();

if ($row[0]['total'] > 0) {
Expand All @@ -59,7 +59,7 @@ public function getCharacter()
{
$this->connect();

$query = $this->connection->query(query('get_character', $this->realmId), array($this->id));
$query = $this->connection->query(query('get_character', $this->realmId), [$this->id]);

if ($query && $query->getNumRows() > 0) {
$row = $query->getResultArray();
Expand All @@ -84,7 +84,7 @@ public function getStats()
{
$this->connect();

$query = $this->connection->query("SELECT " . allColumns("character_stats", $this->realmId) . " FROM " . table("character_stats", $this->realmId) . " WHERE " . column("character_stats", "guid", false, $this->realmId) . "= ?", array($this->id));
$query = $this->connection->query("SELECT " . allColumns("character_stats", $this->realmId) . " FROM " . table("character_stats", $this->realmId) . " WHERE " . column("character_stats", "guid", false, $this->realmId) . "= ?", [$this->id]);

if ($query && $query->getNumRows() > 0) {
$row = $query->getResultArray();
Expand All @@ -102,7 +102,7 @@ public function getItems()
{
$this->connect();

$query = $this->connection->query(query("get_inventory_item", $this->realmId), array($this->id));
$query = $this->connection->query(query("get_inventory_item", $this->realmId), [$this->id]);

if ($query && $query->getNumRows() > 0) {
return $query->getResultArray();
Expand Down Expand Up @@ -134,7 +134,7 @@ public function getGuild()
{
$this->connect();

$query = $this->connection->query("SELECT " . column("guild_member", "guildid", true, $this->realmId) . " FROM " . table("guild_member", $this->realmId) . " WHERE " . column("guild_member", "guid", false, $this->realmId) . "= ?", array($this->id));
$query = $this->connection->query("SELECT " . column("guild_member", "guildid", true, $this->realmId) . " FROM " . table("guild_member", $this->realmId) . " WHERE " . column("guild_member", "guid", false, $this->realmId) . "= ?", [$this->id]);

if ($this->connection->error()) {
$error = $this->connection->error();
Expand All @@ -149,7 +149,7 @@ public function getGuild()

return $row[0]['guildid'];
} else {
$query2 = $this->connection->query("SELECT " . column("guild", "guildid", true, $this->realmId) . " FROM " . table("guild", $this->realmId) . " WHERE " . column("guild", "leaderguid", false, $this->realmId) . "= ?", array($this->id));
$query2 = $this->connection->query("SELECT " . column("guild", "guildid", true, $this->realmId) . " FROM " . table("guild", $this->realmId) . " WHERE " . column("guild", "leaderguid", false, $this->realmId) . "= ?", [$this->id]);

if ($this->connection->error()) {
$error = $this->connection->error();
Expand All @@ -176,7 +176,7 @@ public function getGuildName($id)
} else {
$this->connect();

$query = $this->connection->query("SELECT " . column("guild", "name", true, $this->realmId) . " FROM " . table("guild", $this->realmId) . " WHERE " . column("guild", "guildid", false, $this->realmId) . "= ?", array($id));
$query = $this->connection->query("SELECT " . column("guild", "name", true, $this->realmId) . " FROM " . table("guild", $this->realmId) . " WHERE " . column("guild", "guildid", false, $this->realmId) . "= ?", [$this->id]);

if ($query && $query->getNumRows() > 0) {
$row = $query->getResultArray();
Expand Down
30 changes: 15 additions & 15 deletions application/modules/character/views/character.tpl
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<!-- Character Top.Start -->
<div class="row top-bar">
<div class="col-avatar">
<div class="avatar">
<img src="{$url}application/images/avatars/{$avatar}.gif"/>
</div>
</div>
<div class="col-9 col-md-10 ps-4">
<div class="d-flex h-100 align-items-center">
<span class="h1 color-c{$class}">{$name}</span>
<div class="border-start border-2 ms-3 ps-3">
<div class=""> {$raceName} {$className}</div>
<div class="">{if $guildName}<a href="{$url}guild/{$realmId}/{$guild}">❮{$guildName}❯</a>{/if} {$realmName}</div>
</div>
</div>
</div>
<div class="col-avatar">
<div class="avatar">
<img src="{$url}application/images/avatars/{$avatar}.gif"/>
</div>
</div>
<div class="col-9 col-md-10 ps-4">
<div class="d-flex h-100 align-items-center">
<span class="h1 color-c{$class}">{$name}</span>
<div class="border-start border-2 ms-3 ps-3">
<div class=""> {$raceName} {$className}</div>
<div class="">{if $guildName}<a href="{$url}guild/{$realmId}/{$guild}">❮{$guildName}❯</a>{/if} {$realmName}</div>
</div>
</div>
</div>
</div>
<!-- Character Top.End -->
<hr class="my-5" />
<hr class="my-5"/>
<!-- Character Main.Start -->
<div class="row {if $faction == 1}bg-faction alliance{elseif $faction == 2}bg-faction horde{/if}">
<div class="col-items">
Expand Down

0 comments on commit d401d0e

Please sign in to comment.