mirror of
https://github.com/Karaka-Management/oms-Media.git
synced 2026-02-07 21:18:41 +00:00
Show collection file list
This commit is contained in:
parent
c1157d67fc
commit
34b6b1528c
|
|
@ -16,6 +16,9 @@ namespace Modules\Media;
|
|||
|
||||
use Modules\Media\Models\Media;
|
||||
use Modules\Media\Models\MediaMapper;
|
||||
use Modules\Media\Models\CollectionMapper;
|
||||
use Modules\Media\Models\Collection;
|
||||
|
||||
use Modules\Media\Models\UploadFile;
|
||||
use Modules\Media\Models\UploadStatus;
|
||||
use phpOMS\Asset\AssetType;
|
||||
|
|
@ -133,7 +136,12 @@ class Controller extends ModuleAbstract implements WebInterface
|
|||
$view->setTemplate('/Modules/Media/Theme/Backend/media-single');
|
||||
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000401001, $request, $response));
|
||||
|
||||
$view->addData('media', MediaMapper::get($request->getData('id')));
|
||||
$media = MediaMapper::get($request->getData('id'));
|
||||
if($media->getExtension() === 'collection') {
|
||||
$media = CollectionMapper::get($media->getId());
|
||||
}
|
||||
|
||||
$view->addData('media', $media);
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ namespace Modules\Media\Models;
|
|||
* @link http://orange-management.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Collection extends Media
|
||||
class Collection extends Media implements \Iterator
|
||||
{
|
||||
|
||||
/**
|
||||
|
|
@ -95,4 +95,29 @@ class Collection extends Media
|
|||
public function setVersioned(bool $versioned)
|
||||
{
|
||||
}
|
||||
|
||||
public function rewind()
|
||||
{
|
||||
reset($this->sources);
|
||||
}
|
||||
|
||||
public function current()
|
||||
{
|
||||
return current($this->sources);
|
||||
}
|
||||
|
||||
public function key()
|
||||
{
|
||||
return key($this->sources);
|
||||
}
|
||||
|
||||
public function next()
|
||||
{
|
||||
next($this->sources);
|
||||
}
|
||||
|
||||
public function valid()
|
||||
{
|
||||
return current($this->sources) !== false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,21 +30,25 @@ echo $this->getData('nav')->render();
|
|||
<tbody>
|
||||
<tr><td>Size<td class="wf-100"><?= htmlspecialchars($media->getSize(), ENT_COMPAT, 'utf-8'); ?>
|
||||
<tr><td>Created at<td><?= htmlspecialchars($media->getCreatedAt()->format('Y-m-d'), ENT_COMPAT, 'utf-8'); ?>
|
||||
<tr><td>Created by<td><?= htmlspecialchars($media->getCreatedBy(), ENT_COMPAT, 'utf-8'); ?>
|
||||
<tr><td>Created by<td><?= htmlspecialchars($media->getCreatedBy()->getName1(), ENT_COMPAT, 'utf-8'); ?>
|
||||
<tr><td>Description<td><?= htmlspecialchars($media->getDescription(), ENT_COMPAT, 'utf-8'); ?>
|
||||
<tr><td colspan="2">Content
|
||||
</table>
|
||||
<?php if(\phpOMS\System\File\FileUtils::getExtensionType($media->getExtension()) === \phpOMS\System\File\ExtensionType::IMAGE) : ?>
|
||||
<div class="h-overflow"><img src="<?= htmlspecialchars($this->request->getUri()->getBase() . $media->getPath(), ENT_COMPAT, 'utf-8'); ?>"></div>
|
||||
<?php elseif($media->getExtension() === 'collection') : ?>
|
||||
collection
|
||||
<ul>
|
||||
<?php foreach($media as $file) : $test = $file; $test2 = $file->getName(); ?>
|
||||
<li><a href="<?= \phpOMS\Uri\UriFactory::build('{/base}/{/lang}/backend/media/single?{?}&id=' . $file->getId()); ?>"><?= htmlspecialchars($file->getName(), ENT_COMPAT, 'utf-8'); ?></a>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php else : ?>
|
||||
<pre>
|
||||
<?php
|
||||
$output = htmlspecialchars(file_get_contents(__DIR__ . '/../../../../' . $media->getPath()));
|
||||
$output = file_get_contents(__DIR__ . '/../../../../' . $media->getPath());
|
||||
$output = str_replace(["\r\n", "\r"], "\n", $output);
|
||||
$output = explode("\n", $output);
|
||||
foreach($output as $line) : ?><span><?= htmlspecialchars($line, ENT_COMPAT, 'utf-8'); ?></span><?php endforeach; ?>
|
||||
foreach($output as $line) : ?><span><?= $line; ?></span><?php endforeach; ?>
|
||||
</pre>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user