Items/Misc

* fixed queries erronously using ucFirst column names
 * fixed visible html in infobox
 * added forgotten string for locale 3
This commit is contained in:
Sarjuuk
2020-12-28 23:27:49 +01:00
parent 888ff28121
commit 2eaed47ba4
4 changed files with 46 additions and 29 deletions

View File

@@ -509,7 +509,7 @@ class ItemList extends BaseType
if ($this->enhanceR['enchantId'.$i] <= 0)
continue;
$enchant = DB::Aowow()->selectRow('SELECT * FROM ?_itemenchantment WHERE Id = ?d', $this->enhanceR['enchantId'.$i]);
$enchant = DB::Aowow()->selectRow('SELECT * FROM ?_itemenchantment WHERE id = ?d', $this->enhanceR['enchantId'.$i]);
if ($this->enhanceR['allocationPct'.$i] > 0)
{
$amount = intVal($this->enhanceR['allocationPct'.$i] * $this->generateEnchSuffixFactor());
@@ -714,7 +714,7 @@ class ItemList extends BaseType
$vspfArgs = [Lang::item('gemColors', $gemCnd['color'.$i] - 1), Lang::item('gemColors', $gemCnd['cmpColor'.$i] - 1)];
break;
default:
continue;
continue 2;
}
$x .= '<span class="q0">'.Lang::achievement('reqNumCrt').' '.Lang::item('gemConditions', $gemCnd['comparator'.$i], $vspfArgs).'</span><br />';
@@ -765,7 +765,7 @@ class ItemList extends BaseType
// Enchantment
if (isset($enhance['e']))
{
if ($enchText = DB::Aowow()->selectRow('SELECT * FROM ?_itemenchantment WHERE Id = ?', $enhance['e']))
if ($enchText = DB::Aowow()->selectRow('SELECT * FROM ?_itemenchantment WHERE id = ?', $enhance['e']))
$x .= '<span class="q2"><!--e-->'.Util::localizedString($enchText, 'name').'</span><br />';
else
{
@@ -844,7 +844,7 @@ class ItemList extends BaseType
if ($_ = $this->curTpl['socketBonus'])
{
$sbonus = DB::Aowow()->selectRow('SELECT * FROM ?_itemenchantment WHERE Id = ?d', $_);
$sbonus = DB::Aowow()->selectRow('SELECT * FROM ?_itemenchantment WHERE id = ?d', $_);
$x .= '<span class="q'.($hasMatch ? '2' : '0').'">'.Lang::item('socketBonus', ['<a href="?enchantment='.$_.'">'.Util::localizedString($sbonus, 'name').'</a>']).'</span><br />';
}
@@ -1179,7 +1179,7 @@ class ItemList extends BaseType
// is it available for this item? .. does it even exist?!
if (empty($this->enhanceR))
if (DB::World()->selectCell('SELECT 1 FROM item_enchantment_template WHERE entry = ?d AND ench = ?d', abs($this->getField('randomEnchant')), abs($randId)))
if ($_ = DB::Aowow()->selectRow('SELECT * FROM ?_itemrandomenchant WHERE Id = ?d', $randId))
if ($_ = DB::Aowow()->selectRow('SELECT * FROM ?_itemrandomenchant WHERE id = ?d', $randId))
$this->enhanceR = $_;
return !empty($this->enhanceR);
@@ -1188,7 +1188,7 @@ class ItemList extends BaseType
// from Trinity
public function generateEnchSuffixFactor()
{
$rpp = DB::Aowow()->selectRow('SELECT * FROM ?_itemrandomproppoints WHERE Id = ?', $this->curTpl['itemLevel']);
$rpp = DB::Aowow()->selectRow('SELECT * FROM ?_itemrandomproppoints WHERE id = ?', $this->curTpl['itemLevel']);
if (!$rpp)
return 0;

View File

@@ -128,7 +128,8 @@ class Lang
return $b;
}
public static function trimTextClean(string $text, int $length = 100) : string
// truncate string after X chars. If X is inside a word truncate behind it.
public static function trimTextClean(string $text, int $len = 100) : string
{
// remove line breaks
$text = strtr($text, ["\n" => ' ', "\r" => ' ']);
@@ -136,13 +137,12 @@ class Lang
// limit whitespaces to one at a time
$text = preg_replace('/\s+/', ' ', trim($text));
// limit previews to 100 chars + whatever it takes to make the last word full
if ($length > 0 && mb_strlen($text) > $length)
if ($len > 0 && mb_strlen($text) > $len)
{
$n = 0;
$b = [];
$parts = explode(' ', $text);
while ($n < $length && $parts)
while ($n < $len && $parts)
{
$_ = array_shift($parts);
$n += mb_strlen($_);
@@ -155,6 +155,39 @@ class Lang
return $text;
}
// add line breaks to string after X chars. If X is inside a word break behind it.
public static function breakTextClean(string $text, int $len = 30, bool $asHTML = true) : string
{
// remove line breaks
$text = strtr($text, ["\n" => ' ', "\r" => ' ']);
// limit whitespaces to one at a time
$text = preg_replace('/\s+/', ' ', trim($text));
$row = [];
if ($len > 0 && mb_strlen($text) > $len)
{
$i = 0;
$n = 0;
$parts = explode(' ', $text);
foreach ($parts as $p)
{
$row[$i][] = $p;
$n += (mb_strlen($p) + 1);
if ($n < $len)
continue;
$n = 0;
$i++;
}
foreach ($row as &$r)
$r = implode(' ', $r);
}
return implode($asHTML ? '<br />' : '[br]', $row);
}
public static function sort($prop, $group, $method = SORT_NATURAL)
{

View File

@@ -726,6 +726,7 @@ $lang = array(
'lootStateUNK' => '[span class=q10]unbekannter Plündern-Status #[b class=q1]%d[/b][/span]',
'weatherStateUNK' => '[span class=q10]unbekannter Wetter-Zustand #[b class=q1]%d[/b][/span]',
'entityUNK' => '[b class=q10]unbekannte Entität[/b]',
'empty' => '[span class=q0]<leer>[/span]'
),

View File

@@ -252,25 +252,8 @@ class ItemPage extends genericPage
if ($_reqRating)
{
$res = [];
$i = 0;
$len = 0;
$parts = explode(' ', str_replace('<br>', ' ', sprintf(Lang::item('reqRating', $_reqRating[1]), $_reqRating[0])));
foreach ($parts as $p)
{
$res[$i][] = $p;
$len += (mb_strlen($p) + 1);
if ($len < 30)
continue;
$len = 0;
$i++;
}
foreach ($res as &$r)
$r = implode(' ', $r);
$infobox[] = implode('[br]', $res);
$text = str_replace('<br />', ' ', Lang::item('reqRating', $_reqRating[1], [$_reqRating[0]]));
$infobox[] = Lang::breakTextClean($text, 30, false);
}
}