Skip to content
Permalink
Browse files

Implemented new type: mail

 * display and link clientside mails to other types and events
 * fixed favorites menu for new types
 * fixed sorting column triggered spells in enchantment listview
 * some misc cleanups
  • Loading branch information
Sarjuuk committed Dec 15, 2018
1 parent ccef113 commit fd04e9f97784823000cfd8e6ca4db99ca26f217c
@@ -172,25 +172,8 @@ public static function getCommentPreviews($params = [], &$nFound = 0)
if (empty($params['replies']))
unset($c['commentid']);

// remove line breaks
$c['preview'] = strtr($c['preview'], ["\n" => ' ', "\r" => ' ']);
// limit whitespaces to one at a time
$c['preview'] = preg_replace('/\s+/', ' ', $c['preview']);
// limit previews to 100 chars + whatever it takes to make the last word full
if (mb_strlen($c['preview']) > 100)
{
$n = 0;
$b = [];
$parts = explode(' ', $c['preview']);
while ($n < 100 && $parts)
{
$_ = array_shift($parts);
$n += mb_strlen($_);
$b[] = $_;
}

$c['preview'] = implode(' ', $b).'…';
}
// format text for listview
$c['preview'] = Lang::trimTextClean($c['preview']);
}
else
{
@@ -36,6 +36,7 @@
define('TYPE_EMOTE', 501);
define('TYPE_ENCHANTMENT', 502);
define('TYPE_AREATRIGGER', 503);
define('TYPE_MAIL', 504);

define('CACHE_TYPE_NONE', 0); // page will not be cached
define('CACHE_TYPE_PAGE', 1);
@@ -18,18 +18,6 @@ class AreaTriggerList extends BaseType
's' => ['j' => ['?_spawns s ON s.type = 503 AND s.typeId = a.id', true], 's' => ', s.areaId']
);

public function __construct($conditions = [])
{
parent::__construct($conditions);

// post processing
foreach ($this->iterate() as &$curTpl)
{
// remap for generic access
// $curTpl['name'] = $curTpl['cmd'];
}
}

public function getListviewData()
{
$data = [];
@@ -49,15 +37,7 @@ public function getListviewData()
return $data;
}

public function getJSGlobals($addMask = GLOBALINFO_ANY)
{
$data = [];

// foreach ($this->iterate() as $__)
// $data[TYPE_EMOTE][$this->id] = ['name' => $this->getField('cmd')];

return $data;
}
public function getJSGlobals($addMask = GLOBALINFO_ANY) { }

public function renderTooltip() { }
}
@@ -0,0 +1,69 @@
<?php

if (!defined('AOWOW_REVISION'))
die('illegal access');


class MailList extends BaseType
{
public static $type = TYPE_MAIL;
public static $brickFile = 'mail';
public static $dataTable = '?_mails';

protected $queryBase = 'SELECT m.*, m.id AS ARRAY_KEY FROM ?_mails m';
protected $queryOpts = [];

public function __construct($conditions = [])
{
parent::__construct($conditions);

if ($this->error)
return;

// post processing
foreach ($this->iterate() as &$_curTpl)
{
$_curTpl['name'] = Util::localizedString($_curTpl, 'subject', true);
}
}

public static function getName($id)
{
$n = DB::Aowow()->SelectRow('SELECT subject_loc0, subject_loc2, subject_loc3, subject_loc4, subject_loc6, subject_loc8 FROM ?_mails WHERE id = ?d', $id);
return Util::localizedString($n, 'subject');
}

public function getListviewData()
{
$data = [];

foreach ($this->iterate() as $__)
{
$body = str_replace('[br]', ' ', Util::parseHtmlText($this->getField('text', true), true));

$data[$this->id] = array(
'id' => $this->id,
'subject' => $this->getField('subject', true),
'body' => Lang::trimTextClean($body),
'attachments' => [$this->getField('attachment')]
);
}

return $data;
}

public function getJSGlobals($addMask = 0)
{
$data = [];

foreach ($this->iterate() as $__)
if ($a = $this->curTpl['attachment'])
$data[TYPE_ITEM][$a] = $a;

return $data;
}

public function renderTooltip() { }
}

?>
@@ -671,7 +671,7 @@ public static function getFavorites()

$entities = [];
foreach ($tc->iterate() as $id => $__)
$entities[] = [$id, $tc->getField('name', true)];
$entities[] = [$id, $tc->getField('name', true, true)];

if ($entities)
$data[] = ['id' => $type, 'entities' => $entities];

0 comments on commit fd04e9f

Please sign in to comment.
You can’t perform that action at this time.