class Media extends AbstractData
{
public function getEntityWith($forView = false)
{
$get = ['User', 'Category', 'Album'];
if ($forView)
{
$visitor = \XF::visitor();
$get[] = 'Category.Permissions|' . $visitor->permission_combination_id;
}
return $get;
}
public function getIndexData(Entity $entity)
{
// Return null to prevent media items from being indexed
return null;
}
protected function getMetaData(MediaItem $entity)
{
// No metadata needed as media items are not indexed
return [];
}
public function setupMetadataStructure(MetadataStructure $structure)
{
// No metadata fields needed
}
public function getResultDate(Entity $entity)
{
return $entity->media_date;
}
public function getSearchableContentTypes()
{
// Return an empty array to exclude media items from search
return [];
}
public function getTemplateData(Entity $entity, array $options = [])
{
return [
'mediaItem' => $entity,
'options' => $options,
];
}
public function getSearchFormTab()
{
// Return null to remove the media tab from the search form
return null;
}
public function getSectionContext()
{
return 'xfmg';
}
public function getSearchFormData()
{
return [
'categoryTree' => $this->getSearchableCategoryTree(),
];
}
/**
* @return Tree
*/
protected function getSearchableCategoryTree()
{
/** @var Category $categoryRepo */
$categoryRepo = \XF::repository('XFMG:Category');
$categoryTree = $categoryRepo->createCategoryTree($categoryRepo->getViewableCategories());
return $categoryTree;
}
public function applyTypeConstraintsFromInput(Query $query, Request $request, array &$urlConstraints)
{
// Do not apply any constraints as media items are not searchable
}
public function canUseInlineModeration(Entity $entity, &$error = null)
{
return $entity->canUseInlineModeration($error);
}
}