Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ public function __construct(Type $type, ?int $folderId = null, ?string $searchQu
$this->getParameters($type, $folderId, $searchQuery)
);

$this->addColumn('detail');
$this->setColumnFunction(
[__CLASS__, 'getDetailUrl'],
['[sharding_folder_name]', '[url]', '[storage_type]'],
'detail'
);

// filter on folder?
if ($folderId !== null) {
$this->setURL('&folder=' . $folderId, true);
Expand Down Expand Up @@ -212,4 +219,21 @@ private function setExtras(Type $type, ?int $folderId = null): void
$this->setRowAttributes(['id' => 'row-[id]']);
$this->setColumnFunction('htmlspecialchars', ['[title]'], 'title', false);
}

public static function getDetailUrl(string $shardingFolderName, string $url, string $storageType): string
{
if ($storageType === 'youtube') {
$link = 'https://youtube.com/watch?v=' . $url;
} elseif ($storageType === 'vimeo') {
Comment thread
tijsverkoyen marked this conversation as resolved.
$link = 'https://www.vimeo.com/' . $url;
} else {
$link = '/src/Frontend/Files/MediaLibrary/' . $shardingFolderName . '/' . $url;
}
Comment on lines +225 to +231
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Consider using a generated/public-facing URL instead of a hard-coded path into src/Frontend.

Hard-coding /src/Frontend/Files/MediaLibrary/ couples this link to the current directory structure and will likely break if the public path or deployment layout changes. Prefer using an existing helper/config value to build media URLs (or adding one if missing) instead of embedding the path directly.

Suggested change
if ($storageType === 'youtube') {
$link = 'https://youtube.com/watch?v=' . $url;
} elseif ($storageType === 'vimeo') {
$link = 'https://www.vimeo.com/' . $url;
} else {
$link = '/src/Frontend/Files/MediaLibrary/' . $shardingFolderName . '/' . $url;
}
if ($storageType === 'youtube') {
$link = 'https://youtube.com/watch?v=' . $url;
} elseif ($storageType === 'vimeo') {
$link = 'https://www.vimeo.com/' . $url;
} else {
$link = FRONTEND_FILES_URL . '/MediaLibrary/' . $shardingFolderName . '/' . $url;
}


$html = '<a href="' . $link . '" target="_blank" class="btn btn-default btn-xs pull-right">';
$html .= '<span class="fa fa-eye"></span>' . ucfirst(Language::lbl('View'));
$html .= '</a>';

return $html;
}
}
Loading