mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
I think, I've finally found a use for traits
- working on listviews displaying only the columns needed - still fighting leftovers from class conversion
This commit is contained in:
@@ -5,6 +5,8 @@ if (!defined('AOWOW_REVISION'))
|
|||||||
|
|
||||||
class AchievementList extends BaseType
|
class AchievementList extends BaseType
|
||||||
{
|
{
|
||||||
|
use listviewHelper;
|
||||||
|
|
||||||
public $criteria = [];
|
public $criteria = [];
|
||||||
public $tooltip = [];
|
public $tooltip = [];
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ if (!defined('AOWOW_REVISION'))
|
|||||||
|
|
||||||
class TitleList extends BaseType
|
class TitleList extends BaseType
|
||||||
{
|
{
|
||||||
private $sources = [];
|
use listviewHelper;
|
||||||
|
|
||||||
|
public $sources = [];
|
||||||
|
|
||||||
protected $setupQuery = 'SELECT *, id AS ARRAY_KEY FROM ?_titles WHERE [cond] ORDER BY Id ASC';
|
protected $setupQuery = 'SELECT *, id AS ARRAY_KEY FROM ?_titles WHERE [cond] ORDER BY Id ASC';
|
||||||
protected $matchQuery = 'SELECT COUNT(1) FROM ?_titles WHERE [cond]';
|
protected $matchQuery = 'SELECT COUNT(1) FROM ?_titles WHERE [cond]';
|
||||||
@@ -33,6 +35,7 @@ class TitleList extends BaseType
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$this->reset(); // push first element back for instant use
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getListviewData()
|
public function getListviewData()
|
||||||
@@ -127,7 +130,7 @@ class TitleList extends BaseType
|
|||||||
|
|
||||||
public function getHtmlizedName($gender = GENDER_MALE)
|
public function getHtmlizedName($gender = GENDER_MALE)
|
||||||
{
|
{
|
||||||
return str_replace('%s', '<span class="q0"><'.Lang::$main['name'].'></span>', $this->name[$gender]);
|
return str_replace('%s', '<span class="q0"><'.Lang::$main['name'].'></span>', $this->names[$this->id][$gender]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addRewardsToJScript(&$ref) { }
|
public function addRewardsToJScript(&$ref) { }
|
||||||
|
|||||||
@@ -193,6 +193,41 @@ abstract class BaseType
|
|||||||
abstract public function renderTooltip();
|
abstract public function renderTooltip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trait listviewHelper
|
||||||
|
{
|
||||||
|
public function hasDiffCategories()
|
||||||
|
{
|
||||||
|
$this->reset();
|
||||||
|
$curCat = $this->getField('category');
|
||||||
|
if ($curCat === null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
while ($this->iterate())
|
||||||
|
if ($curCat != $this->getField('category'))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hasAnySource()
|
||||||
|
{
|
||||||
|
if (!isset($this->sources))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
foreach ($this->sources as $src)
|
||||||
|
{
|
||||||
|
if (!is_array($src))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!empty($src))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
class Lang
|
class Lang
|
||||||
{
|
{
|
||||||
public static $main;
|
public static $main;
|
||||||
|
|||||||
@@ -27,6 +27,12 @@ if (!$smarty->loadCache($cacheKey, $pageData))
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if ($titles->hasDiffCategories())
|
||||||
|
$pageData['params']['visibleCols'] = "$['category']";
|
||||||
|
|
||||||
|
if (!$titles->hasAnySource())
|
||||||
|
$pageData['params']['hiddenCols'] = "$['source']";
|
||||||
|
|
||||||
$smarty->saveCache($cacheKey, $pageData);
|
$smarty->saveCache($cacheKey, $pageData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user