Преглед на файлове

Add icon lookup table

staging
Christopher Ross Hind преди 3 години
родител
ревизия
88f974c97a
променени са 2 файла, в които са добавени 83 реда и са изтрити 1 реда
  1. +82
    -0
      app/Knockout/Thread.php
  2. +1
    -1
      resources/views/partial/thread.blade.php

+ 82
- 0
app/Knockout/Thread.php Целия файл

@@ -9,6 +9,7 @@ class Thread {

// meta
public $id;
public $icon;
public $title;
public $postCount;

@@ -18,11 +19,92 @@ class Thread {
public Post $lastPost;
public User $user;

private static function getIcon(int $iconId)
{
$icons = [
0 => 'default',
1 => 'drama',
2 => 'games',
3 => 'life',
4 => 'money',
5 => 'announcement',
6 => 'arcade-cabinet',
7 => 'blog',
8 => 'bomb',
9 => 'bug',
10 => 'code',
11 => 'combo-chart',
12 => 'cooker',
13 => 'crying-baby',
14 => 'dota',
15 => 'europe-news',
16 => 'gallery',
17 => 'grocery-bag',
18 => 'gun',
19 => 'heart-with-pulse',
20 => 'help',
21 => 'hot-article',
22 => 'news',
23 => 'nintendo-entertainment-system',
24 => 'pin',
25 => 'planner',
26 => 'tv-show',
27 => 'uk-news',
28 => 'us-music',
29 => 'us-news',
30 => 'retro-tv',
31 => 'smiling',
32 => 'vomited',
33 => 'test-tube',
34 => 'easel',
35 => 'banana',
36 => 'heart-with-arrow',
37 => 'radio-active',
38 => 'poison',
39 => 'invisible',
40 => 'visible',
41 => 'controller',
42 => 'boring',
43 => 'swearing-male',
44 => 'idea',
45 => 'megaphone',
46 => 'banknotes',
47 => 'robot-3',
48 => 'phonelink-ring',
49 => 'thriller',
50 => 'hamburger',
51 => 'sakura',
52 => 'sushi',
53 => 'lifebuoy',
54 => 'handshake',
55 => 'clenched-fist',
56 => 'anonymous-mask',
57 => 'rocket',
58 => 'vodka',
59 => 'poo',
60 => 'sedan',
61 => 'tesla-model-x',
62 => 'memory-slot',
63 => 'processor',
64 => 'fire-element',
65 => 'firework',
66 => 'siren',
67 => 'confetti',
68 => 'campfire',
69 => 'panties',
70 => 'mushroom-cloud',
71 => 'bomb-with-timer'
];

return $icons[$iconId] ?? 'poo';
}

public static function unwrap($thread)
{
$s = new self();

$s->id = $thread->id;
$s->icon = self::getIcon($thread->iconId);
$s->title = $thread->title;
$s->postCount = $thread->postCount;



+ 1
- 1
resources/views/partial/thread.blade.php Целия файл

@@ -1,5 +1,5 @@
<div class="row thread {{ ($key % 2) ? 'even' : 'odd' }}">
<img class="icon" src="/img/thread-icons/tv-show.gif" alt="tv-show" />
<img class="icon" src="/img/thread-icons/{{ $thread->icon }}.gif" alt="{{ $thread->icon }}" />
<a class="main" href="{{ route('thread', ['thread' => $thread->id]) }}">{{ $thread->title }}</a>
<div class="meta">
<a class="left">by {{ $thread->user->username }}, {{ $thread->postCount }} replies</a>


Loading…
Отказ
Запис