mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
Misc
* added option to 'verbose' concatenate a list of items to class Lang * added option to strip tags from a string to class Markdown * fixed several instances of wrong categories on pages * actually display world state conditions for zone music * some typos all over the place
This commit is contained in:
@@ -14,6 +14,8 @@ class Markup
|
||||
private $text = '';
|
||||
private $jsGlobals = [];
|
||||
|
||||
private static $dbTagPattern = '/(?<!\\\\)\[(npc|object|item|itemset|quest|spell|zone|faction|pet|achievement|statistic|title|event|class|race|skill|currency|emote|enchantment|money|sound|icondb)=(-?\d+)[^\]]*\]/i';
|
||||
|
||||
public function __construct($text)
|
||||
{
|
||||
$this->text = $text;
|
||||
@@ -21,7 +23,7 @@ class Markup
|
||||
|
||||
public function parseGlobalsFromText(&$jsg = [])
|
||||
{
|
||||
if (preg_match_all('/(?<!\\\\)\[(npc|object|item|itemset|quest|spell|zone|faction|pet|achievement|statistic|title|event|class|race|skill|currency|emote|enchantment|money|sound|icondb)=(-?\d+)[^\]]*\]/i', $this->text, $matches, PREG_SET_ORDER))
|
||||
if (preg_match_all(self::$dbTagPattern, $this->text, $matches, PREG_SET_ORDER))
|
||||
{
|
||||
foreach ($matches as $match)
|
||||
{
|
||||
@@ -33,7 +35,7 @@ class Markup
|
||||
{
|
||||
if (stripos($match[0], 'items'))
|
||||
{
|
||||
if (preg_match('/items=([0-9,]+)/', $match[0], $submatch))
|
||||
if (preg_match('/items=([0-9,]+)/i', $match[0], $submatch))
|
||||
{
|
||||
$sm = explode(',', $submatch[1]);
|
||||
for ($i = 0; $i < count($sm); $i+=2)
|
||||
@@ -43,7 +45,7 @@ class Markup
|
||||
|
||||
if (stripos($match[0], 'currency'))
|
||||
{
|
||||
if (preg_match('/currency=([0-9,]+)/', $match[0], $submatch))
|
||||
if (preg_match('/currency=([0-9,]+)/i', $match[0], $submatch))
|
||||
{
|
||||
$sm = explode(',', $submatch[1]);
|
||||
for ($i = 0; $i < count($sm); $i+=2)
|
||||
@@ -61,6 +63,79 @@ class Markup
|
||||
return $this->jsGlobals;
|
||||
}
|
||||
|
||||
public function stripTags($globals = [])
|
||||
{
|
||||
// since this is an article the db-tags should already be parsed
|
||||
$text = preg_replace_callback(self::$dbTagPattern, function ($match) use ($globals) {
|
||||
if ($match[1] == 'statistic')
|
||||
$match[1] = 'achievement';
|
||||
else if ($match[1] == 'icondb')
|
||||
$match[1] = 'icon';
|
||||
else if ($match[1] == 'money')
|
||||
{
|
||||
$moneys = [];
|
||||
if (stripos($match[0], 'items'))
|
||||
{
|
||||
if (preg_match('/items=([0-9,]+)/i', $match[0], $submatch))
|
||||
{
|
||||
$sm = explode(',', $submatch[1]);
|
||||
for ($i = 0; $i < count($sm); $i += 2)
|
||||
{
|
||||
if (!empty($globals[TYPE_ITEM][1][$sm[$i]]))
|
||||
$moneys[] = $globals[TYPE_ITEM][1][$sm[$i]]['name'];
|
||||
else
|
||||
$moneys[] = Util::ucFirst(Lang::game('item')).' #'.$sm[$i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (stripos($match[0], 'currency'))
|
||||
{
|
||||
if (preg_match('/currency=([0-9,]+)/i', $match[0], $submatch))
|
||||
{
|
||||
$sm = explode(',', $submatch[1]);
|
||||
for ($i = 0; $i < count($sm); $i += 2)
|
||||
{
|
||||
if (!empty($globals[TYPE_CURRENCY][1][$sm[$i]]))
|
||||
$moneys[] = $globals[TYPE_CURRENCY][1][$sm[$i]]['name'];
|
||||
else
|
||||
$moneys[] = Util::ucFirst(Lang::game('curency')).' #'.$sm[$i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Lang::concat($moneys);
|
||||
}
|
||||
|
||||
if ($type = array_search($match[1], Util::$typeStrings))
|
||||
{
|
||||
if (!empty($globals[$type][1][$match[2]]))
|
||||
return $globals[$type][1][$match[2]]['name'];
|
||||
else
|
||||
return Util::ucFirst(Lang::game($match[1])).' #'.$match[2];
|
||||
}
|
||||
|
||||
trigger_error('Markup::stripTags() - encountered unhandled db-tag: '.var_export($match));
|
||||
return '';
|
||||
}, $this->text);
|
||||
|
||||
$text = str_replace('[br]', "\n", $text);
|
||||
$stripped = '';
|
||||
|
||||
$inTag = false;
|
||||
for ($i = 0; $i < strlen($text); $i++)
|
||||
{
|
||||
if ($text[$i] == '[')
|
||||
$inTag = true;
|
||||
if (!$inTag)
|
||||
$stripped .= $text[$i];
|
||||
if ($text[$i] == ']')
|
||||
$inTag = false;
|
||||
}
|
||||
|
||||
return $stripped;
|
||||
}
|
||||
|
||||
public function fromHtml()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1366,7 +1366,7 @@ class ItemList extends BaseType
|
||||
return null;
|
||||
}
|
||||
// level independant Bonus
|
||||
else if (in_array($type, Util::$lvlIndepRating))
|
||||
else if (in_array($type, Game::$lvlIndepRating))
|
||||
return Lang::item('trigger', 1).str_replace('%d', '<!--rtg'.$type.'-->'.$value, Lang::item('statType', $type));
|
||||
// rating-Bonuses
|
||||
else
|
||||
|
||||
@@ -57,7 +57,7 @@ class SkillList extends BaseType
|
||||
'name' => Util::jsEscape($this->getField('name', true)),
|
||||
'profession' => $this->curTpl['professionMask'],
|
||||
'recipeSubclass' => $this->curTpl['recipeSubClass'],
|
||||
'specializations' => Util::toJSON($this->curTpl['specializations']),
|
||||
'specializations' => Util::toJSON($this->curTpl['specializations'], JSON_NUMERIC_CHECK),
|
||||
'icon' => Util::jsEscape($this->curTpl['iconString'])
|
||||
);
|
||||
}
|
||||
|
||||
@@ -90,6 +90,29 @@ class Lang
|
||||
return self::vspf($var, $vspfArgs);
|
||||
}
|
||||
|
||||
public static function concat($args, $useAnd = true, $callback = null)
|
||||
{
|
||||
$b = '';
|
||||
$i = 0;
|
||||
$n = count($args);
|
||||
foreach ($args as $k => $arg)
|
||||
{
|
||||
if (is_callable($callback))
|
||||
$b .= $callback($arg, $k);
|
||||
else
|
||||
$b .= $arg;
|
||||
|
||||
if ($n > 1 && $i < ($n - 2))
|
||||
$b .= ', ';
|
||||
else if ($n > 1 && $i == $n - 2)
|
||||
$b .= Lang::main($useAnd ? 'and' : 'or');
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
return $b;
|
||||
}
|
||||
|
||||
public static function sort($prop, $group, $method = SORT_NATURAL)
|
||||
{
|
||||
|
||||
|
||||
@@ -721,7 +721,8 @@ $lang = array(
|
||||
'pet' => array(
|
||||
'notFound' => "Diese Tierart existiert nicht.",
|
||||
'exotic' => "Exotisch",
|
||||
'cat' => ["Wildheit", "Hartnäckigkeit", "Gerissenheit"]
|
||||
'cat' => ["Wildheit", "Hartnäckigkeit", "Gerissenheit"],
|
||||
'food' => ["Fleisch", "Fisch", "Käse", "Brot", "Fungus", "Obst", "Rohes Fleisch", "Roher Fisch"]
|
||||
),
|
||||
'faction' => array(
|
||||
'notFound' => "Diese Fraktion existiert nicht.",
|
||||
|
||||
@@ -721,7 +721,8 @@ $lang = array(
|
||||
'pet' => array(
|
||||
'notFound' => "This pet family doesn't exist.",
|
||||
'exotic' => "Exotic",
|
||||
'cat' => ["Ferocity", "Tenacity", "Cunning"]
|
||||
'cat' => ["Ferocity", "Tenacity", "Cunning"],
|
||||
'food' => ["Meat", "Fish", "Cheese", "Bread", "Fungus", "Fruit", "Raw Meat", "Raw Fish"] // ItemPetFood.dbc
|
||||
),
|
||||
'faction' => array(
|
||||
'notFound' => "This faction doesn't exist.",
|
||||
|
||||
@@ -721,7 +721,8 @@ $lang = array(
|
||||
'pet' => array(
|
||||
'notFound' => "Esta familia de mascotas no existe.",
|
||||
'exotic' => "Exótica",
|
||||
'cat' => ["Ferocidad", "Tenacidad", "Astucia"]
|
||||
'cat' => ["Ferocidad", "Tenacidad", "Astucia"],
|
||||
'food' => ["Carne", "Pescado", "Queso", "Pan", "Hongo", "Fruta", "Carne cruda", "Pescado crudo"]
|
||||
),
|
||||
'faction' => array(
|
||||
'notFound' => "Esta facción no existe.",
|
||||
|
||||
@@ -721,7 +721,8 @@ $lang = array(
|
||||
'pet' => array(
|
||||
'notFound' => "Cette famille de familiers n'existe pas.",
|
||||
'exotic' => "Exotique",
|
||||
'cat' => ["Férocité", "Tenacité", "Ruse"]
|
||||
'cat' => ["Férocité", "Tenacité", "Ruse"],
|
||||
'food' => ["Viande", "Poisson", "Fromage", "Pain", "Champignon", "Fruit", "Viande crue", "Poisson cru"]
|
||||
),
|
||||
'faction' => array(
|
||||
'notFound' => "Cette faction n'existe pas.",
|
||||
|
||||
@@ -721,7 +721,8 @@ $lang = array(
|
||||
'pet' => array(
|
||||
'notFound' => "Такой породы питомцев не существует.",
|
||||
'exotic' => "Экзотический",
|
||||
'cat' => ["Свирепость", "Упорство", "Хитрость"]
|
||||
'cat' => ["Свирепость", "Упорство", "Хитрость"],
|
||||
'food' => ["Мясо", "Рыба", "Сыр", "Хлеб", "Грибы", "Фрукты", "Сырое мясо", "Сырая рыба"]
|
||||
),
|
||||
'faction' => array(
|
||||
'notFound' => "Такая фракция не существует.",
|
||||
|
||||
@@ -224,24 +224,26 @@ class GenericPage
|
||||
if (!isset($this->category) || empty($this->validCats))
|
||||
return true;
|
||||
|
||||
switch (count($this->category))
|
||||
$c = $this->category; // shorthand
|
||||
|
||||
switch (count($c))
|
||||
{
|
||||
case 0: // no params works always
|
||||
return true;
|
||||
case 1: // null is valid || value in a 1-dim-array || key for a n-dim-array
|
||||
case 1: // null is valid || value in a 1-dim-array || (key for a n-dim-array && ( has more subcats || no further subCats ))
|
||||
$filtered = array_filter($this->validCats, function ($x) { return is_int($x); });
|
||||
return $this->category[0] === null || in_array($this->category[0], $filtered) || !empty($this->validCats[$this->category[0]]);
|
||||
return $c[0] === null || in_array($c[0], $filtered) || (!empty($this->validCats[$c[0]]) && (is_array($this->validCats[$c[0]]) || $this->validCats[$c[0]] === true));
|
||||
case 2: // first param has to be a key. otherwise invalid
|
||||
if (!isset($this->validCats[$this->category[0]]))
|
||||
if (!isset($this->validCats[$c[0]]))
|
||||
return false;
|
||||
|
||||
// check if the sub-array is n-imensional
|
||||
if (count($this->validCats[$this->category[0]]) == count($this->validCats[$this->category[0]], COUNT_RECURSIVE))
|
||||
return in_array($this->category[1], $this->validCats[$this->category[0]]); // second param is value in second level array
|
||||
if (is_array($this->validCats[$c[0]]) && count($this->validCats[$c[0]]) == count($this->validCats[$c[0]], COUNT_RECURSIVE))
|
||||
return in_array($c[1], $this->validCats[$c[0]]); // second param is value in second level array
|
||||
else
|
||||
return isset($this->validCats[$this->category[0]][$this->category[1]]); // check if params is key of another array
|
||||
return isset($this->validCats[$c[0]][$c[1]]); // check if params is key of another array
|
||||
case 3: // 3 params MUST point to a specific value
|
||||
return isset($this->validCats[$this->category[0]][$this->category[1]]) && in_array($this->category[2], $this->validCats[$this->category[0]][$this->category[1]]);
|
||||
return isset($this->validCats[$c[0]][$c[1]]) && in_array($c[2], $this->validCats[$c[0]][$c[1]]);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -139,7 +139,7 @@ class NpcPage extends GenericPage
|
||||
// Classification
|
||||
if ($_ = $this->subject->getField('rank')) // != NPC_RANK_NORMAL
|
||||
{
|
||||
$str = $_typeFlags & 0x4 ? '[span class=icon-boss]'.Lang::npc('rank', $_).'[/span]' : Lang::npc('rank', $_);
|
||||
$str = $this->subject->isBoss() ? '[span class=icon-boss]'.Lang::npc('rank', $_).'[/span]' : Lang::npc('rank', $_);
|
||||
$infobox[] = Lang::npc('classification').Lang::main('colon').$str;
|
||||
}
|
||||
|
||||
|
||||
@@ -99,6 +99,10 @@ class NpcsPage extends GenericPage
|
||||
array_unshift($this->title, $this->name);
|
||||
if ($this->category)
|
||||
array_unshift($this->title, Lang::npc('cat', $this->category[0]));
|
||||
|
||||
$form = $this->filterObj->getForm();
|
||||
if (isset($form['fa']) && !is_array($form['fa']))
|
||||
array_unshift($this->title, Lang::game('fa', $form['fa']));
|
||||
}
|
||||
|
||||
protected function generatePath()
|
||||
@@ -106,7 +110,7 @@ class NpcsPage extends GenericPage
|
||||
if ($this->category)
|
||||
$this->path[] = $this->category[0];
|
||||
|
||||
$form = $this->filterObj->getForm('form');
|
||||
$form = $this->filterObj->getForm();
|
||||
if (isset($form['fa']) && !is_array($form['fa']))
|
||||
$this->path[] = $form['fa'];
|
||||
}
|
||||
|
||||
@@ -350,7 +350,7 @@ class ObjectPage extends GenericPage
|
||||
if ($goLoot->getByContainer(LOOT_GAMEOBJECT, $_))
|
||||
{
|
||||
$extraCols = $goLoot->extraCols;
|
||||
$extraCols[] = 'Listview.extraCols.percent';
|
||||
$extraCols[] = '$Listview.extraCols.percent';
|
||||
$hiddenCols = ['source', 'side', 'slot', 'reqlevel'];
|
||||
|
||||
$this->extendGlobalData($goLoot->jsGlobals);
|
||||
@@ -375,7 +375,7 @@ class ObjectPage extends GenericPage
|
||||
'id' => 'contains',
|
||||
'name' => '$LANG.tab_contains',
|
||||
'sort' => ['-percent', 'name'],
|
||||
'extraCols' => ['$Listview.extraCols.percent']
|
||||
'extraCols' => $extraCols
|
||||
);
|
||||
|
||||
if ($hiddenCols)
|
||||
|
||||
@@ -103,7 +103,7 @@ class PetPage extends GenericPage
|
||||
// tab: diet
|
||||
$list = [];
|
||||
$mask = $this->subject->getField('foodMask');
|
||||
for ($i = 1; $i < 7; $i++)
|
||||
for ($i = 1; $i < 9; $i++)
|
||||
if ($mask & (1 << ($i - 1)))
|
||||
$list[] = $i;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ class PetsPage extends GenericPage
|
||||
protected $path = [0, 8];
|
||||
protected $tabId = 0;
|
||||
protected $mode = CACHE_TYPE_PAGE;
|
||||
protected $validCats = [1, 2, 3];
|
||||
protected $validCats = [0, 1, 2];
|
||||
|
||||
public function __construct($pageCall, $pageParam)
|
||||
{
|
||||
|
||||
@@ -11,7 +11,6 @@ class SoundPage extends GenericPage
|
||||
use DetailPage;
|
||||
|
||||
protected $type = TYPE_SOUND;
|
||||
protected $typeId = 0;
|
||||
protected $tpl = 'sound';
|
||||
protected $path = [0, 19];
|
||||
protected $tabId = 0;
|
||||
@@ -30,7 +29,8 @@ class SoundPage extends GenericPage
|
||||
$this->special = true;
|
||||
$this->name = Lang::sound('cat', 1000);
|
||||
$this->cat = 1000;
|
||||
$this->typeId = -1000;
|
||||
$this->articleUrl = 'sound&playlist';
|
||||
$this->hasComContent = false;
|
||||
}
|
||||
// regular case
|
||||
else
|
||||
|
||||
@@ -708,7 +708,7 @@ class ZonePage extends GenericPage
|
||||
$soundIds = [];
|
||||
$zoneMusic = DB::Aowow()->select('
|
||||
SELECT
|
||||
x.soundId, x.worldStateId, x.worldStateValue
|
||||
x.soundId AS ARRAY_KEY, x.soundId, x.worldStateId, x.worldStateValue
|
||||
FROM (
|
||||
SELECT ambienceDay AS soundId, worldStateId, worldStateValue FROM ?_zones_sounds WHERE id IN (?a) AND ambienceDay > 0 UNION
|
||||
SELECT ambienceNight AS soundId, worldStateId, worldStateValue FROM ?_zones_sounds WHERE id IN (?a) AND ambienceNight > 0 UNION
|
||||
@@ -734,13 +734,13 @@ class ZonePage extends GenericPage
|
||||
$data = $music->getListviewData();
|
||||
$tabData = [];
|
||||
|
||||
if (array_filter(array_column($soundIds, 'worldStateId')))
|
||||
if (array_filter(array_column($zoneMusic, 'worldStateId')))
|
||||
{
|
||||
$tabData['extraCols'] = ['$Listview.extraCols.condition'];
|
||||
|
||||
foreach ($soundIds as $sData)
|
||||
if ($sData['worldStateId'])
|
||||
$data[$sData['soundId']]['condition'][0][$this->typeId][] = [[CND_WORLD_STATE, $sData['worldStateId'], $sData['worldStateValue']]];
|
||||
foreach ($soundIds as $sId)
|
||||
if (!empty($zoneMusic[$sId]['worldStateId']))
|
||||
$data[$sId]['condition'][0][$this->typeId][] = [[CND_WORLD_STATE, $zoneMusic[$sId]['worldStateId'], $zoneMusic[$sId]['worldStateValue']]];
|
||||
}
|
||||
|
||||
$tabData['data'] = array_values($data);
|
||||
|
||||
@@ -1382,7 +1382,7 @@ var g_pet_types = {
|
||||
|
||||
var g_pet_foods = {
|
||||
1: 'Fleisch',
|
||||
2: 'Fish',
|
||||
2: 'Fisch',
|
||||
4: 'Käse',
|
||||
8: 'Brot',
|
||||
16: 'Fungus',
|
||||
|
||||
@@ -7,15 +7,10 @@ elseif (!empty($this->map['data'])):
|
||||
elseif ($this->type != TYPE_ZONE):
|
||||
echo ' <div>'.($this->type == TYPE_OBJECT ? Lang::gameObject('foundIn') : ($this->type == TYPE_SOUND ? Lang::sound('foundIn') : Lang::npc('foundIn'))).' <span id="mapper-zone-generic">';
|
||||
|
||||
$n = count($this->map['mapperData']);
|
||||
$i = 0;
|
||||
foreach ($this->map['mapperData'] as $areaId => $areaData):
|
||||
if ($n > 1 && $i++ > 0):
|
||||
echo $i < $n ? ', ' : Lang::main('and');
|
||||
endif;
|
||||
|
||||
echo '<a href="javascript:;" onclick="myMapper.update({zone: '.$areaId.'}); g_setSelectedLink(this, \'mapper\'); return false" onmousedown="return false">'.$this->map['extra'][$areaId].'</a> ('.reset($areaData)['count'].')';
|
||||
endforeach;
|
||||
$extra = $this->map['extra'];
|
||||
echo Lang::concat($this->map['mapperData'], true, function ($areaData, $areaId) use ($extra) {
|
||||
return '<a href="javascript:;" onclick="myMapper.update({zone: '.$areaId.'}); g_setSelectedLink(this, \'mapper\'); return false" onmousedown="return false">'.$extra[$areaId].'</a> ('.reset($areaData)['count'].')';
|
||||
});
|
||||
|
||||
echo ".</span></div>\n";
|
||||
endif;
|
||||
|
||||
@@ -22,15 +22,7 @@
|
||||
|
||||
if ($this->accessory):
|
||||
echo ' <div>'.Lang::npc('accessoryFor').' ';
|
||||
|
||||
$n = count($this->accessory);
|
||||
foreach ($this->accessory as $i => $ac):
|
||||
if ($n > 1 && $i > 0):
|
||||
echo ($i == $n - 1) ? Lang::main('and') : ', ';
|
||||
endif;
|
||||
echo '<a href="?npc='.$ac[0].'">'.$ac[1].'</a>';
|
||||
endforeach;
|
||||
|
||||
echo Lang::concat($this->accessory, true, function ($v, $k) { return '<a href="?npc='.$v[0].'">'.$v[1].'</a>'; });
|
||||
echo ".</div>\n";
|
||||
endif;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user