/** * Initialize the object * * @param AssetModel $model */ public function __construct(AssetModel $model) { parent::__construct($model); $filters = deserialize($model->filters, true); // Add filters foreach ($filters as $filter) { $this->addFilter(AssetsManager::getFilter($filter)); } }
/** * Get the assets of the current group * * @return array */ protected function getAssets() { $assetsCollection = AssetModel::findBy('pid', $this->model->id, array('order' => 'sorting')); if ($assetsCollection === null) { return array(); } $assets = array(); foreach ($assetsCollection as $assetModel) { $asset = AssetsManager::getAssetByModel($assetModel); if ($asset === null) { continue; } $assets[] = $asset; } return $assets; }
/** * Generate the label * * @param array $row * * @return string */ public function generateLabel(array $row) { $badgeText = '?'; $badgeColor = ''; $description = ''; // Include CSS $GLOBALS['TL_CSS'][] = 'system/modules/assets_manager/assets/backend.css'; /** @var BaseAsset $asset */ $asset = AssetsManager::getAssetById($row['id']); if ($asset !== null) { $badgeText = $asset->getBackendBadgeText() ?: $badgeText; $badgeColor = $asset->getBackendBadgeColor() ?: $badgeColor; $description = $asset->getBackendDescription(); } return '<div class="am_asset_label"> <div class="badge"> <span style="background-color:' . $badgeColor . ';">' . $badgeText . '</span> </div> <div class="text"> <span>' . $row['name'] . '</span> ' . ($description ? '<span class="description">[' . $description . ']</span>' : '') . ' </div> </div>'; }