mirror of
https://github.com/Karaka-Management/oms-Media.git
synced 2026-02-17 09:48:41 +00:00
impl. more static translations
This commit is contained in:
parent
b201dc6201
commit
f06eaa78fc
|
|
@ -43,19 +43,19 @@ final class Installer extends InstallerAbstract
|
||||||
* @param DatabasePool $dbPool Database pool
|
* @param DatabasePool $dbPool Database pool
|
||||||
* @param array $data Module info
|
* @param array $data Module info
|
||||||
*
|
*
|
||||||
* @return void
|
* @return array
|
||||||
*
|
*
|
||||||
* @throws PathException This exception is thrown if the Navigation install file couldn't be found
|
* @throws PathException This exception is thrown if the Navigation install file couldn't be found
|
||||||
* @throws \Exception This exception is thrown if the Navigation install file is invalid json
|
* @throws \Exception This exception is thrown if the Navigation install file is invalid json
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function installExternal(DatabasePool $dbPool, array $data) : void
|
public static function installExternal(DatabasePool $dbPool, array $data) : array
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$dbPool->get()->con->query('select 1 from `media`');
|
$dbPool->get()->con->query('select 1 from `media`');
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return; // @codeCoverageIgnore
|
return []; // @codeCoverageIgnore
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!\is_file($data['path'] ?? '')) {
|
if (!\is_file($data['path'] ?? '')) {
|
||||||
|
|
@ -76,18 +76,26 @@ final class Installer extends InstallerAbstract
|
||||||
Directory::delete(__DIR__ . '/tmp');
|
Directory::delete(__DIR__ . '/tmp');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$result = [
|
||||||
|
'collection' => [],
|
||||||
|
'upload' => [],
|
||||||
|
];
|
||||||
|
|
||||||
\mkdir(__DIR__ . '/tmp');
|
\mkdir(__DIR__ . '/tmp');
|
||||||
foreach ($mediaData as $media) {
|
foreach ($mediaData as $media) {
|
||||||
switch ($media['type']) {
|
switch ($media['type']) {
|
||||||
case 'collection':
|
case 'collection':
|
||||||
self::createCollection($dbPool, $media);
|
$result['collection'][] = self::createCollection($dbPool, $media);
|
||||||
break;
|
break;
|
||||||
case 'upload':
|
case 'upload':
|
||||||
self::uploadMedia($dbPool, $media);
|
$result['upload'][] = self::uploadMedia($dbPool, $media);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Directory::delete(__DIR__ . '/tmp');
|
Directory::delete(__DIR__ . '/tmp');
|
||||||
|
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -96,11 +104,11 @@ final class Installer extends InstallerAbstract
|
||||||
* @param DatabasePool $dbPool Database instance
|
* @param DatabasePool $dbPool Database instance
|
||||||
* @param array $data Media info
|
* @param array $data Media info
|
||||||
*
|
*
|
||||||
* @return void
|
* @return Collection
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private static function createCollection($dbPool, $data) : void
|
private static function createCollection($dbPool, $data) : Collection
|
||||||
{
|
{
|
||||||
$collection = new Collection();
|
$collection = new Collection();
|
||||||
$collection->name = (string) $data['name'] ?? '';
|
$collection->name = (string) $data['name'] ?? '';
|
||||||
|
|
@ -117,11 +125,11 @@ final class Installer extends InstallerAbstract
|
||||||
* @param DatabasePool $dbPool Database instance
|
* @param DatabasePool $dbPool Database instance
|
||||||
* @param array $data Media info
|
* @param array $data Media info
|
||||||
*
|
*
|
||||||
* @return void
|
* @return array
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private static function uploadMedia($dbPool, $data) : void
|
private static function uploadMedia($dbPool, $data) : array
|
||||||
{
|
{
|
||||||
$files = [];
|
$files = [];
|
||||||
foreach ($data['files'] as $file) {
|
foreach ($data['files'] as $file) {
|
||||||
|
|
@ -189,6 +197,9 @@ final class Installer extends InstallerAbstract
|
||||||
$collection->setSources($mediaFiles);
|
$collection->setSources($mediaFiles);
|
||||||
|
|
||||||
CollectionMapper::create($collection);
|
CollectionMapper::create($collection);
|
||||||
|
return [$collection];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $mediaFiles;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
<?php declare(strict_types=1);
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
use phpOMS\Autoloader;
|
||||||
|
|
||||||
use PhpOffice\PhpWord\IOFactory;
|
use PhpOffice\PhpWord\IOFactory;
|
||||||
|
use PhpOffice\PhpWord\Writer\HTML;
|
||||||
|
|
||||||
Autoloader::addPath(__DIR__ . '/../../../../Resources/');
|
Autoloader::addPath(__DIR__ . '/../../../../Resources/');
|
||||||
|
|
||||||
use PhpOffice\PhpWord\Writer\HTML;
|
|
||||||
use phpOMS\Autoloader;
|
|
||||||
|
|
||||||
$media = $this->getData('media');
|
$media = $this->getData('media');
|
||||||
|
|
||||||
$reader = IOFactory::createReader('Word2007');
|
$reader = IOFactory::createReader('Word2007');
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,12 @@
|
||||||
<?php declare(strict_types=1);
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
|
||||||
|
|
||||||
Autoloader::addPath(__DIR__ . '/../../../../../../Resources/');
|
|
||||||
|
|
||||||
use PhpOffice\PhpSpreadsheet\Writer\Csv;
|
|
||||||
use phpOMS\Autoloader;
|
use phpOMS\Autoloader;
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Writer\Csv;
|
||||||
use phpOMS\Uri\UriFactory;
|
use phpOMS\Uri\UriFactory;
|
||||||
|
|
||||||
|
Autoloader::addPath(__DIR__ . '/../../../../../../Resources/');
|
||||||
?>
|
?>
|
||||||
<section id="mediaFile" class="portlet">
|
<section id="mediaFile" class="portlet">
|
||||||
<div class="portlet-body">
|
<div class="portlet-body">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user