Skip to content
This repository has been archived by the owner on Nov 2, 2020. It is now read-only.

Commit

Permalink
refactor(Site): Simple Category Detail get function
Browse files Browse the repository at this point in the history
  • Loading branch information
Rhilip committed Aug 10, 2019
1 parent 6009dc8 commit ffa6855
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- **template:** Add git commit hash in `CHANGELOG.md` (76bc527)

### Feat
- **Auth:** Use JWT to set cookies content (bf897c6)
- **ban_ips:** Store banned ip in components/Site (01084c9)

### Fix
Expand Down
12 changes: 6 additions & 6 deletions apps/components/Site.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,17 +276,17 @@ public static function getQualityTableList()
public static function ruleCategory(): array
{
return static::getStaticCacheValue('enabled_torrent_category', function () {
return app()->pdo->createCommand('SELECT * FROM `categories` WHERE `id` > 0 ORDER BY `full_path`')->queryAll();
$cats_raw = app()->pdo->createCommand('SELECT * FROM `categories` WHERE `id` > 0 ORDER BY `full_path`')->queryAll();

$cats = [];
foreach ($cats_raw as $cat_raw) $cats[$cat_raw['id']] = $cat_raw;
return $cats;
}, 86400);
}

public static function CategoryDetail($cat_id): array
{
return static::getStaticCacheValue('torrent_category_' . $cat_id, function () use ($cat_id) {
return app()->pdo->createCommand('SELECT * FROM `categories` WHERE id= :cid LIMIT 1;')->bindParams([
'cid' => $cat_id
])->queryOne();
}, 86400);
return static::ruleCategory()[$cat_id];
}

public static function ruleCanUsedCategory(): array
Expand Down
2 changes: 1 addition & 1 deletion apps/views/helper/username.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<?php if ($hide): ?>
<i>Anonymous</i>
<?php if (app()->site->getCurUser()->isPrivilege('see_anonymous_info')): ?>
(<?= $this->insert('helper/username', ['user' => $user, 'user_name_hide' => false, 'user_badge' => $show_badge]) ?>)
(<?= $this->insert('helper/username', ['user' => $user, 'hide' => false, 'user_badge' => $show_badge]) ?>)
<?php endif; ?>
<?php else: ?>
<a href="/user?id=<?= $user->getId() ?>"><?= $user->getUsername() ?></a>
Expand Down

0 comments on commit ffa6855

Please sign in to comment.