mirror of
https://github.com/Karaka-Management/oms-Media.git
synced 2026-02-10 06:28:41 +00:00
fix #49
This commit is contained in:
parent
d87a89cf3d
commit
296956e9c7
|
|
@ -35,7 +35,7 @@ class MediaMapper extends DataMapperAbstract
|
|||
'media_description' => ['name' => 'media_description', 'type' => 'string', 'internal' => 'description'],
|
||||
'media_versioned' => ['name' => 'media_versioned', 'type' => 'bool', 'internal' => 'versioned'],
|
||||
'media_file' => ['name' => 'media_file', 'type' => 'string', 'internal' => 'path'],
|
||||
'media_absolute' => ['name' => 'media_absolute', 'type' => 'string', 'internal' => 'isAbsolute'],
|
||||
'media_absolute' => ['name' => 'media_absolute', 'type' => 'bool', 'internal' => 'isAbsolute'],
|
||||
'media_extension' => ['name' => 'media_extension', 'type' => 'string', 'internal' => 'extension'],
|
||||
'media_description' => ['name' => 'media_description', 'type' => 'string', 'internal' => 'description'],
|
||||
'media_size' => ['name' => 'media_size', 'type' => 'int', 'internal' => 'size'],
|
||||
|
|
|
|||
|
|
@ -37,21 +37,122 @@ echo $this->getData('nav')->render();
|
|||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<?php if(
|
||||
(
|
||||
$media->getExtension() === 'collection'
|
||||
&& !is_file($media->getPath() . $this->request->getData('sub'))
|
||||
) || (
|
||||
is_dir($media->getPath())
|
||||
&& ($this->request->getData('sub') === null || is_dir($media->getPath() . $this->request->getData('sub')))
|
||||
)
|
||||
) : ?>
|
||||
<div class="col-xs-12">
|
||||
<div class="box wf-100">
|
||||
<table class="table red">
|
||||
<caption><?= $this->getHtml('Media') ?></caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<td>
|
||||
<td class="wf-100"><?= $this->getHtml('Name') ?>
|
||||
<td><?= $this->getHtml('Type') ?>
|
||||
<td><?= $this->getHtml('Size') ?>
|
||||
<td><?= $this->getHtml('Creator') ?>
|
||||
<td><?= $this->getHtml('Created') ?>
|
||||
<tbody>
|
||||
<?php if(!is_dir($media->getPath())) : foreach($media as $key => $value) :
|
||||
$url = \phpOMS\Uri\UriFactory::build('{/base}/{/lang}/backend/media/single?{?}&id=' . $value->getId());
|
||||
|
||||
$icon = '';
|
||||
$extensionType = \phpOMS\System\File\FileUtils::getExtensionType($value->getExtension());
|
||||
|
||||
if($extensionType === \phpOMS\System\File\ExtensionType::CODE) {
|
||||
$icon = 'file-code-o';
|
||||
} elseif($extensionType === \phpOMS\System\File\ExtensionType::TEXT) {
|
||||
$icon = 'file-text-o';
|
||||
} elseif($extensionType === \phpOMS\System\File\ExtensionType::PRESENTATION) {
|
||||
$icon = 'file-powerpoint-o';
|
||||
} elseif($extensionType === \phpOMS\System\File\ExtensionType::PDF) {
|
||||
$icon = 'file-pdf-o';
|
||||
} elseif($extensionType === \phpOMS\System\File\ExtensionType::ARCHIVE) {
|
||||
$icon = 'file-zip-o';
|
||||
} elseif($extensionType === \phpOMS\System\File\ExtensionType::AUDIO) {
|
||||
$icon = 'file-audio-o';
|
||||
} elseif($extensionType === \phpOMS\System\File\ExtensionType::VIDEO) {
|
||||
$icon = 'file-video-o';
|
||||
} elseif($extensionType === \phpOMS\System\File\ExtensionType::IMAGE) {
|
||||
$icon = 'file-image-o';
|
||||
} elseif($extensionType === \phpOMS\System\File\ExtensionType::SPREADSHEET) {
|
||||
$icon = 'file-excel-o';
|
||||
} elseif($value->getExtension() === 'collection') {
|
||||
$icon = 'folder-open-o';
|
||||
} else {
|
||||
$icon = 'file-o';
|
||||
}
|
||||
?>
|
||||
<tr data-href="<?= $url; ?>">
|
||||
<td><a href="<?= $url; ?>"><i class="fa fa-<?= $this->printHtml($icon); ?>"></i></a>
|
||||
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->getName()); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->getExtension()); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->getSize()); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->getCreatedBy()->getName1()); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->getCreatedAt()->format('Y-m-d H:i:s')); ?></a>
|
||||
<?php endforeach; else : $path = is_dir($media->getPath() . $this->request->getData('sub')) && phpOMS\Utils\StringUtils::startsWith(str_replace('\\', '/', realpath($media->getPath() . $this->request->getData('sub'))), $media->getPath()) ? $media->getPath() . $this->request->getData('sub') : $media->getPath(); ?>
|
||||
<?php $list = \phpOMS\System\File\Local\Directory::list($path);
|
||||
foreach($list as $key => $value) :
|
||||
$url = \phpOMS\Uri\UriFactory::build('{/base}/{/lang}/backend/media/single?{?}&id=' . $media->getId() . '&sub=' . substr($value, strlen($media->getPath())));
|
||||
$icon = '';
|
||||
$extensionType = \phpOMS\System\File\FileUtils::getExtensionType(!is_dir($value) ? \phpOMS\System\File\Local\File::extension($value) : 'collection');
|
||||
|
||||
if($extensionType === \phpOMS\System\File\ExtensionType::CODE) {
|
||||
$icon = 'file-code-o';
|
||||
} elseif($extensionType === \phpOMS\System\File\ExtensionType::TEXT) {
|
||||
$icon = 'file-text-o';
|
||||
} elseif($extensionType === \phpOMS\System\File\ExtensionType::PRESENTATION) {
|
||||
$icon = 'file-powerpoint-o';
|
||||
} elseif($extensionType === \phpOMS\System\File\ExtensionType::PDF) {
|
||||
$icon = 'file-pdf-o';
|
||||
} elseif($extensionType === \phpOMS\System\File\ExtensionType::ARCHIVE) {
|
||||
$icon = 'file-zip-o';
|
||||
} elseif($extensionType === \phpOMS\System\File\ExtensionType::AUDIO) {
|
||||
$icon = 'file-audio-o';
|
||||
} elseif($extensionType === \phpOMS\System\File\ExtensionType::VIDEO) {
|
||||
$icon = 'file-video-o';
|
||||
} elseif($extensionType === \phpOMS\System\File\ExtensionType::IMAGE) {
|
||||
$icon = 'file-image-o';
|
||||
} elseif($extensionType === \phpOMS\System\File\ExtensionType::SPREADSHEET) {
|
||||
$icon = 'file-excel-o';
|
||||
} elseif($extensionType === 'collection') {
|
||||
$icon = 'folder-open-o';
|
||||
} else {
|
||||
$icon = 'file-o';
|
||||
}
|
||||
?>
|
||||
<tr data-href="<?= $url; ?>">
|
||||
<td><a href="<?= $url; ?>"><i class="fa fa-<?= $this->printHtml($icon); ?>"></i></a>
|
||||
<td><a href="<?= $url; ?>"><?= substr($value, strlen($media->getPath())); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= !is_dir($value) ? \phpOMS\System\File\Local\File::extension($value) : 'collection'; ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= !is_dir($value) ? \phpOMS\System\File\Local\File::size($value) : ''; ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= \phpOMS\System\File\Local\File::owner($value); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= \phpOMS\System\File\Local\File::created($value)->format('Y-m-d'); ?></a>
|
||||
<?php endforeach; endif; ?>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="col-xs-12">
|
||||
<section class="box wf-100">
|
||||
<div class="inner">
|
||||
<?php if(\phpOMS\System\File\FileUtils::getExtensionType($media->getExtension()) === \phpOMS\System\File\ExtensionType::IMAGE) : ?>
|
||||
<div class="h-overflow"><img src="<?= $this->printHtml($this->request->getUri()->getBase() . $media->getPath()); ?>"></div>
|
||||
<?php elseif($media->getExtension() === 'collection') : ?>
|
||||
<ul>
|
||||
<?php foreach($media as $file) : ?>
|
||||
<li><a href="<?= \phpOMS\Uri\UriFactory::build('{/base}/{/lang}/backend/media/single?{?}&id=' . $file->getId()); ?>"><?= $this->printHtml($file->getName()); ?></a>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php
|
||||
$path = is_file($media->getPath() . $this->request->getData('sub')) && phpOMS\Utils\StringUtils::startsWith(str_replace('\\', '/', realpath($media->getPath() . $this->request->getData('sub'))), $media->getPath()) ? $media->getPath() . $this->request->getData('sub') : $media->getPath();
|
||||
if(\phpOMS\System\File\FileUtils::getExtensionType($media->getExtension()) === \phpOMS\System\File\ExtensionType::IMAGE || \phpOMS\System\File\FileUtils::getExtensionType(\phpOMS\System\File\Local\File::extension($path)) === \phpOMS\System\File\ExtensionType::IMAGE) : ?>
|
||||
<div class="h-overflow"><img src="<?= $media->isAbsolute() ? $this->printHtml($path) : $this->printHtml($this->request->getUri()->getBase() . $path); ?>"></div>
|
||||
<?php else : ?>
|
||||
<pre>
|
||||
<?php
|
||||
$output = file_get_contents(__DIR__ . '/../../../../' . $media->getPath());
|
||||
$output = file_get_contents($media->isAbsolute() ? $path : __DIR__ . '/../../../../' . $path);
|
||||
$output = str_replace(["\r\n", "\r"], "\n", $output);
|
||||
$output = explode("\n", $output);
|
||||
foreach($output as $line) : ?><span><?= $this->printHtml($line); ?></span><?php endforeach; ?>
|
||||
|
|
@ -60,4 +161,5 @@ echo $this->getData('nav')->render();
|
|||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
Loading…
Reference in New Issue
Block a user