/** * 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; }
/** * Get the asset by ID * * @param int $id * * @return BaseAsset|null * * @throws \Exception */ public static function getAssetById($id) { $model = AssetModel::findByPk($id); if ($model === null) { throw new \Exception(sprintf('Unable to find the asset ID %s', $id)); } return static::getAssetByModel($model); }
/** * Generate the label * * @param array $row * * @return string */ public function generateLabel(array $row) { $count = sprintf($GLOBALS['TL_LANG']['tl_asset_group']['assetsCount'], AssetModel::countBy(array('pid=?'), $row['id'])); return '<div>' . $row['name'] . ' <span style="padding-left:3px;color:#b3b3b3;">[' . $count . ']</span></div>'; }
/** * Get the editor sheets of the current theme * * @param \DataContainer $dc * * @return array */ public function getEditorSheets(\DataContainer $dc) { $assetModel = AssetModel::findByPk($dc->id); $groupModel = AssetGroupModel::findByPk($assetModel->pid); $sheetModels = \StyleSheetModel::findBy('pid', $groupModel->pid, array('order' => 'name')); if ($sheetModels === null) { return array(); } $return = array(); foreach ($sheetModels as $sheetModel) { $return[$sheetModel->id] = $sheetModel->name; } return $return; }