mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
Template/Endpoints (Prep)
* modernize DB-Types - long term: should be split in class that describes the DB-Type and container class that handles multiples * make unchanging filter props static, allow lookup of criteria indizes through filter * move username/mail/password checks to util and make them usable as input filter
This commit is contained in:
65
includes/dbtypes/emote.class.php
Normal file
65
includes/dbtypes/emote.class.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace Aowow;
|
||||
|
||||
if (!defined('AOWOW_REVISION'))
|
||||
die('illegal access');
|
||||
|
||||
|
||||
class EmoteList extends DBTypeList
|
||||
{
|
||||
public static int $type = Type::EMOTE;
|
||||
public static string $brickFile = 'emote';
|
||||
public static string $dataTable = '?_emotes';
|
||||
|
||||
protected string $queryBase = 'SELECT e.*, e.`id` AS ARRAY_KEY FROM ?_emotes e';
|
||||
|
||||
public function __construct(array $conditions = [], array $miscData = [])
|
||||
{
|
||||
parent::__construct($conditions, $miscData);
|
||||
|
||||
// post processing
|
||||
foreach ($this->iterate() as &$curTpl)
|
||||
{
|
||||
// remap for generic access
|
||||
$curTpl['name'] = $curTpl['cmd'];
|
||||
}
|
||||
}
|
||||
|
||||
public static function getName(int $id) : ?LocString
|
||||
{
|
||||
if ($n = DB::Aowow()->SelectRow('SELECT `cmd` AS "name_loc0" FROM ?# WHERE `id` = ?d', self::$dataTable, $id))
|
||||
return new LocString($n);
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getListviewData() : array
|
||||
{
|
||||
$data = [];
|
||||
|
||||
foreach ($this->iterate() as $__)
|
||||
{
|
||||
$data[$this->id] = array(
|
||||
'id' => $this->curTpl['id'],
|
||||
'name' => $this->curTpl['cmd'],
|
||||
'preview' => Util::parseHtmlText($this->getField('meToExt', true) ?: $this->getField('meToNone', true) ?: $this->getField('extToMe', true) ?: $this->getField('extToExt', true) ?: $this->getField('extToNone', true), true)
|
||||
);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getJSGlobals(int $addMask = GLOBALINFO_ANY) : array
|
||||
{
|
||||
$data = [];
|
||||
|
||||
foreach ($this->iterate() as $__)
|
||||
$data[Type::EMOTE][$this->id] = ['name' => $this->getField('cmd')];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function renderTooltip() : ?string { return null; }
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user