mirror of
https://github.com/Karaka-Management/oms-Media.git
synced 2026-01-11 17:08:40 +00:00
Bulkl path fix
This commit is contained in:
parent
4dd701ff90
commit
9d7a9cb690
|
|
@ -1,44 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.1
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
namespace Modules\Media\Admin;
|
||||
|
||||
|
||||
use phpOMS\DataStorage\Database\DatabasePool;
|
||||
use phpOMS\Module\ActivateAbstract;
|
||||
use phpOMS\Module\InfoManager;
|
||||
|
||||
/**
|
||||
* Navigation class.
|
||||
*
|
||||
* @category Modules
|
||||
* @package Modules\Admin
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @license OMS License 1.0
|
||||
* @link http://orange-management.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Activate extends ActivateAbstract
|
||||
{
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function activate(DatabasePool $dbPool, InfoManager $info)
|
||||
{
|
||||
parent::activate($dbPool, $info);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.1
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
namespace Modules\Media\Admin;
|
||||
|
||||
|
||||
use phpOMS\DataStorage\Database\DatabasePool;
|
||||
use phpOMS\Module\DeactivateAbstract;
|
||||
use phpOMS\Module\InfoManager;
|
||||
|
||||
/**
|
||||
* Navigation class.
|
||||
*
|
||||
* @category Modules
|
||||
* @package Modules\Admin
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @license OMS License 1.0
|
||||
* @link http://orange-management.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Deactivate extends DeactivateAbstract
|
||||
{
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function deactivate(DatabasePool $dbPool, InfoManager $info)
|
||||
{
|
||||
parent::deactivate($dbPool, $info);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,78 +0,0 @@
|
|||
[
|
||||
{
|
||||
"id": 1000401001,
|
||||
"pid": "754a08ddf8bcb1cf22f310f09206dd783d42f7dd",
|
||||
"type": 2,
|
||||
"subtype": 1,
|
||||
"name": "Media",
|
||||
"uri": "/{/lang}/backend/media/list?{?}",
|
||||
"target": "self",
|
||||
"icon": null,
|
||||
"order": 20,
|
||||
"from": "Media",
|
||||
"permission": null,
|
||||
"parent": 1000201001,
|
||||
"children": [
|
||||
{
|
||||
"id": 1000402001,
|
||||
"pid": "1ba288c868cacf14e56f8205efef31d697301d02",
|
||||
"type": 3,
|
||||
"subtype": 1,
|
||||
"name": "List",
|
||||
"uri": "/{/lang}/backend/media/list?{?}",
|
||||
"target": "self",
|
||||
"icon": null,
|
||||
"order": 1,
|
||||
"from": "Media",
|
||||
"permission": null,
|
||||
"parent": 1000401001,
|
||||
"children": []
|
||||
},
|
||||
{
|
||||
"id": 1000403001,
|
||||
"pid": "1ba288c868cacf14e56f8205efef31d697301d02",
|
||||
"type": 3,
|
||||
"subtype": 5,
|
||||
"name": "Create",
|
||||
"uri": "/{/lang}/backend/media/create?{?}",
|
||||
"target": "self",
|
||||
"icon": null,
|
||||
"order": 5,
|
||||
"from": "Media",
|
||||
"permission": null,
|
||||
"parent": 1000401001,
|
||||
"children": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 1000410001,
|
||||
"pid": "722846d6c55f46fd3d372bba7311a150acd1f23c",
|
||||
"type": 2,
|
||||
"subtype": 2,
|
||||
"name": "Media",
|
||||
"uri": "/{/lang}/backend/profile/single/media?{?}",
|
||||
"target": "self",
|
||||
"icon": null,
|
||||
"order": 3,
|
||||
"from": "Media",
|
||||
"permission": null,
|
||||
"parent": 1000301001,
|
||||
"children": []
|
||||
},
|
||||
{
|
||||
"id": 1000410002,
|
||||
"pid": "f277f11a122129a52d36f788f42e5c09766cf4ae",
|
||||
"type": 3,
|
||||
"subtype": 1,
|
||||
"name": "Media",
|
||||
"uri": "/{/lang}/backend/admin/account/single/media?{?}",
|
||||
"target": "self",
|
||||
"icon": null,
|
||||
"order": 3,
|
||||
"from": "Media",
|
||||
"permission": null,
|
||||
"parent": 1000104001,
|
||||
"children": []
|
||||
}
|
||||
]
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.1
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
namespace Modules\Media\Admin\Install;
|
||||
use phpOMS\DataStorage\Database\DatabasePool;
|
||||
|
||||
/**
|
||||
* Navigation class.
|
||||
*
|
||||
* @category Modules
|
||||
* @package Modules\Admin
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @license OMS License 1.0
|
||||
* @link http://orange-management.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Navigation
|
||||
{
|
||||
public static function install(string $path, DatabasePool $dbPool)
|
||||
{
|
||||
$navData = json_decode(file_get_contents(__DIR__ . '/Navigation.install.json'), true);
|
||||
|
||||
$class = '\\Modules\\Navigation\\Admin\\Installer';
|
||||
/** @var $class \Modules\Navigation\Admin\Installer */
|
||||
$class::installExternal($dbPool, $navData);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,104 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.1
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
namespace Modules\Media\Admin;
|
||||
|
||||
use phpOMS\DataStorage\Database\DatabaseType;
|
||||
use phpOMS\DataStorage\Database\DatabasePool;
|
||||
use phpOMS\Module\InfoManager;
|
||||
use phpOMS\Module\InstallerAbstract;
|
||||
|
||||
/**
|
||||
* Media install class.
|
||||
*
|
||||
* @category Modules
|
||||
* @package Modules\Media
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @license OMS License 1.0
|
||||
* @link http://orange-management.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Installer extends InstallerAbstract
|
||||
{
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function install(string $path, DatabasePool $dbPool, InfoManager $info)
|
||||
{
|
||||
parent::install($path, $dbPool, $info);
|
||||
|
||||
switch ($dbPool->get('core')->getType()) {
|
||||
case DatabaseType::MYSQL:
|
||||
$dbPool->get('core')->con->prepare(
|
||||
'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'media` (
|
||||
`media_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`media_name` varchar(100) NOT NULL,
|
||||
`media_versioned` tinyint(1) NOT NULL,
|
||||
`media_file` varchar(255) NOT NULL,
|
||||
`media_extension` varchar(10) NULL,
|
||||
`media_collection` tinyint(1) NULL,
|
||||
`media_description` varchar(255) NULL,
|
||||
`media_size` int(11) NULL,
|
||||
`media_created_by` int(11) DEFAULT NULL,
|
||||
`media_created_at` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`media_id`),
|
||||
KEY `media_created_by` (`media_created_by`)
|
||||
)ENGINE=InnoDB DEFAULT CHARSET=utf8;'
|
||||
)->execute();
|
||||
|
||||
$dbPool->get('core')->con->prepare(
|
||||
'ALTER TABLE `' . $dbPool->get('core')->prefix . 'media`
|
||||
ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'media_ibfk_1` FOREIGN KEY (`media_created_by`) REFERENCES `' . $dbPool->get('core')->prefix . 'account` (`account_id`);'
|
||||
)->execute();
|
||||
|
||||
$dbPool->get('core')->con->prepare(
|
||||
'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'media_relation` (
|
||||
`media_relation_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`media_relation_src` int(11) NULL,
|
||||
`media_relation_dst` int(11) NULL,
|
||||
PRIMARY KEY (`media_relation_id`),
|
||||
KEY `media_relation_src` (`media_relation_src`),
|
||||
KEY `media_relation_dst` (`media_relation_dst`)
|
||||
)ENGINE=InnoDB DEFAULT CHARSET=utf8;'
|
||||
)->execute();
|
||||
|
||||
$dbPool->get('core')->con->prepare(
|
||||
'ALTER TABLE `' . $dbPool->get('core')->prefix . 'media_relation`
|
||||
ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'media_relation_ibfk_1` FOREIGN KEY (`media_relation_src`) REFERENCES `' . $dbPool->get('core')->prefix . 'media` (`media_id`),
|
||||
ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'media_relation_ibfk_2` FOREIGN KEY (`media_relation_dst`) REFERENCES `' . $dbPool->get('core')->prefix . 'media` (`media_id`);'
|
||||
)->execute();
|
||||
|
||||
$dbPool->get('core')->con->prepare(
|
||||
'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'media_permission` (
|
||||
`media_permission_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`media_permission_type` tinyint(1) NOT NULL,
|
||||
`media_permission_reference` int(11) NOT NULL,
|
||||
`media_permission_permission` tinyint(2) NOT NULL,
|
||||
`media_permission_media` int(11) NOT NULL,
|
||||
PRIMARY KEY (`media_permission_id`),
|
||||
KEY `media_permission_media` (`media_permission_media`)
|
||||
)ENGINE=InnoDB DEFAULT CHARSET=utf8;'
|
||||
)->execute();
|
||||
|
||||
$dbPool->get('core')->con->prepare(
|
||||
'ALTER TABLE `' . $dbPool->get('core')->prefix . 'media_permission`
|
||||
ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'media_permission_ibfk_1` FOREIGN KEY (`media_permission_media`) REFERENCES `' . $dbPool->get('core')->prefix . 'media` (`media_id`);'
|
||||
)->execute();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
<?php
|
||||
|
||||
use phpOMS\Router\RouteVerb;
|
||||
|
||||
return [
|
||||
'^.*/api/media/collection.*$' => [
|
||||
[
|
||||
'dest' => '\Modules\Media\Controller:apiCollectionCreate',
|
||||
'verb' => RouteVerb::SET,
|
||||
],
|
||||
],
|
||||
'^.*/api/media$' => [
|
||||
[
|
||||
'dest' => '\Modules\Media\Controller:apiMediaUpload',
|
||||
'verb' => RouteVerb::SET,
|
||||
],
|
||||
],
|
||||
'^.*/api/media/create.*$' => [
|
||||
[
|
||||
'dest' => '\Modules\Media\Controller:apiMediaCreate',
|
||||
'verb' => RouteVerb::SET,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
<?php
|
||||
|
||||
use phpOMS\Router\RouteVerb;
|
||||
|
||||
return [
|
||||
'^.*/backend/media/list.*$' => [
|
||||
[
|
||||
'dest' => '\Modules\Media\Controller:viewMediaList',
|
||||
'verb' => RouteVerb::GET,
|
||||
],
|
||||
],
|
||||
'^.*/backend/media/create.*$' => [
|
||||
[
|
||||
'dest' => '\Modules\Media\Controller:setUpFileUploader',
|
||||
'verb' => RouteVerb::GET,
|
||||
],
|
||||
[
|
||||
'dest' => '\Modules\Media\Controller:viewMediaCreate',
|
||||
'verb' => RouteVerb::GET,
|
||||
],
|
||||
],
|
||||
'^.*/backend/media/single.*$' => [
|
||||
[
|
||||
'dest' => '\Modules\Media\Controller:viewMediaSingle',
|
||||
'verb' => RouteVerb::GET,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
<?php
|
||||
|
||||
$moduleRoutes = [];
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
<?php
|
||||
|
||||
$moduleRoutes = [];
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.1
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
namespace Modules\Media\Admin;
|
||||
|
||||
|
||||
use phpOMS\DataStorage\Database\DatabasePool;
|
||||
use phpOMS\DataStorage\Database\Schema\Builder;
|
||||
use phpOMS\Module\UninstallAbstract;
|
||||
|
||||
/**
|
||||
* Navigation class.
|
||||
*
|
||||
* @category Modules
|
||||
* @package Modules\Admin
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @license OMS License 1.0
|
||||
* @link http://orange-management.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Uninstall extends UninstallAbstract
|
||||
{
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function uninstall(DatabasePool $dbPool, InfoManager $info)
|
||||
{
|
||||
parent::uninstall($dbPool, $info);
|
||||
|
||||
$query = new Builder($dbPool->get());
|
||||
|
||||
$query->prefix($dbPool->get('core')->getPrefix())->drop(
|
||||
'media_permission',
|
||||
'media_relation',
|
||||
'media'
|
||||
);
|
||||
|
||||
$dbPool->get()->con->prepare($query->toSql())->execute();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.1
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
namespace Modules\Media\Admin;
|
||||
|
||||
|
||||
use phpOMS\DataStorage\Database\DatabasePool;
|
||||
use phpOMS\Module\UpdateAbstract;
|
||||
use phpOMS\System\File\Directory;
|
||||
|
||||
/**
|
||||
* Navigation class.
|
||||
*
|
||||
* @category Modules
|
||||
* @package Modules\Admin
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @license OMS License 1.0
|
||||
* @link http://orange-management.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Update extends UpdateAbstract
|
||||
{
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function update(DatabasePool $dbPool, array $info)
|
||||
{
|
||||
Directory::deletePath(__DIR__ . '/Update');
|
||||
mkdir('Update');
|
||||
parent::update($dbPool, $info);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
(function (jsOMS)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
jsOMS.Autoloader.defineNamespace('jsOMS.Modules');
|
||||
|
||||
jsOMS.Modules.Media = function (app)
|
||||
{
|
||||
this.app = app;
|
||||
};
|
||||
|
||||
jsOMS.Modules.Media.prototype.bind = function (id)
|
||||
{
|
||||
let e = typeof id === 'undefined' ? document.getElementsByTagName('form') : [document.getElementById(id)],
|
||||
length = e.length;
|
||||
|
||||
for (let i = 0; i < length; i++) {
|
||||
this.bindElement(e[i]);
|
||||
}
|
||||
};
|
||||
|
||||
jsOMS.Modules.Media.prototype.bindElement = function (form)
|
||||
{
|
||||
if (typeof form === 'undefined' || !form) {
|
||||
// todo: do logging here
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
let self = this;
|
||||
|
||||
if (!form.querySelector('input[type=file]')|| !document.querySelector('input[type=file][form=' + form.id + ']')) {
|
||||
try {
|
||||
// Inject media upload into form view
|
||||
this.app.uiManager.getFormManager().get(form.id).injectSubmit(function (e, requestId, requestGroup)
|
||||
{
|
||||
let fileFields = e.querySelectorAll('input[type=file]'),
|
||||
uploader = new jsOMS.Modules.Models.Media.Upload(self.app.responseManager, self.app.logger);
|
||||
|
||||
uploader.setSuccess(e.id, function (type, response)
|
||||
{
|
||||
e.querySelector('input[type=file]+input[type=hidden]').value = JSON.stringify(response.uploads);
|
||||
self.app.eventManager.trigger(requestGroup, requestId);
|
||||
});
|
||||
|
||||
uploader.setUri(Url + '{/lang}/api/media');
|
||||
|
||||
for (let i = 0; i < fileFields.length; i++) {
|
||||
for (let j = 0; j < fileFields[i].files.length; j++) {
|
||||
uploader.addFile(fileFields[i].files[j]);
|
||||
}
|
||||
}
|
||||
|
||||
if (uploader.count() < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
uploader.upload(e.id);
|
||||
});
|
||||
} catch (e) {
|
||||
this.app.logger.info('Tried to add media upload support for form without an ID.');
|
||||
}
|
||||
}
|
||||
};
|
||||
}(window.jsOMS = window.jsOMS || {}));
|
||||
|
||||
jsOMS.ready(function ()
|
||||
{
|
||||
"use strict";
|
||||
|
||||
window.omsApp.moduleManager.get('Media').bind();
|
||||
});
|
||||
282
Controller.php
282
Controller.php
|
|
@ -1,282 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.1
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
namespace Modules\Media;
|
||||
|
||||
use Modules\Media\Models\Media;
|
||||
use Modules\Media\Models\MediaMapper;
|
||||
use Modules\Media\Models\UploadFile;
|
||||
use Modules\Media\Models\UploadStatus;
|
||||
use phpOMS\Asset\AssetType;
|
||||
use phpOMS\Message\RequestAbstract;
|
||||
use phpOMS\Message\ResponseAbstract;
|
||||
use phpOMS\Model\Html\Head;
|
||||
use phpOMS\Module\ModuleAbstract;
|
||||
use phpOMS\Module\WebInterface;
|
||||
use phpOMS\System\MimeType;
|
||||
use phpOMS\Views\View;
|
||||
|
||||
/**
|
||||
* Media class.
|
||||
*
|
||||
* @category Modules
|
||||
* @package Modules\Media
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @license OMS License 1.0
|
||||
* @link http://orange-management.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Controller extends ModuleAbstract implements WebInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Module path.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
/* public */ const MODULE_PATH = __DIR__;
|
||||
|
||||
/**
|
||||
* Module version.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
/* public */ const MODULE_VERSION = '1.0.0';
|
||||
|
||||
/**
|
||||
* Module name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
/* public */ const MODULE_NAME = 'Media';
|
||||
|
||||
/**
|
||||
* Providing.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static $providing = [];
|
||||
|
||||
/**
|
||||
* Dependencies.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static $dependencies = [
|
||||
];
|
||||
|
||||
/**
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function setUpFileUploader(RequestAbstract $request, ResponseAbstract $response, $data = null)
|
||||
{
|
||||
/** @var Head $head */
|
||||
$head = $response->get('Content')->getData('head');
|
||||
$head->addAsset(AssetType::JSLATE, $request->getUri()->getBase() . 'Modules/Media/Models/Upload.js');
|
||||
$head->addAsset(AssetType::JSLATE, $request->getUri()->getBase() . 'Modules/Media/Controller.js');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $data Generic data
|
||||
*
|
||||
* @return \Serializable
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function viewMediaList(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable
|
||||
{
|
||||
$view = new View($this->app, $request, $response);
|
||||
$view->setTemplate('/Modules/Media/Theme/Backend/media-list');
|
||||
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000401001, $request, $response));
|
||||
|
||||
$media = MediaMapper::getNewest(25);
|
||||
$view->addData('media', $media);
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $data Generic data
|
||||
*
|
||||
* @return \Serializable
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function viewMediaSingle(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable
|
||||
{
|
||||
$view = new View($this->app, $request, $response);
|
||||
$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')));
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $data Generic data
|
||||
*
|
||||
* @return \Serializable
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function viewMediaCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable
|
||||
{
|
||||
$view = new View($this->app, $request, $response);
|
||||
$view->setTemplate('/Modules/Media/Theme/Backend/media-create');
|
||||
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000401001, $request, $response));
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows api content.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function apiMediaUpload(RequestAbstract $request, ResponseAbstract $response, $data = null)
|
||||
{
|
||||
$uploads = $this->uploadFiles($request->getFiles(), $request->getAccount(), $request->getData('path') ?? '/Modules/Media/Files');
|
||||
|
||||
$ids = [];
|
||||
foreach($uploads as $file) {
|
||||
$ids[] = $file->getId();
|
||||
}
|
||||
|
||||
$response->getHeader()->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true);
|
||||
$response->set($request->__toString(), [['uploads' => $ids, 'type' => 'UI']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows api content.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function apiMediaCreate(RequestAbstract $request, ResponseAbstract $response, $data = null)
|
||||
{
|
||||
// todo: change database entry for files if has write permission
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $files Files
|
||||
* @param int $account Uploader
|
||||
* @param string $basePath Base path
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function uploadFiles(array $files, int $account, string $basePath = 'Modules/Media/Files') : array
|
||||
{
|
||||
$mediaCreated = [];
|
||||
|
||||
if (!empty($files)) {
|
||||
$upload = new UploadFile();
|
||||
$path = self::createMediaPath($basePath);
|
||||
$upload->setOutputDir($path);
|
||||
$upload->setFileName(false);
|
||||
|
||||
$status = $upload->upload($files);
|
||||
$mediaCreated = self::createDbEntries($status, $account);
|
||||
}
|
||||
|
||||
return $mediaCreated;
|
||||
}
|
||||
|
||||
public static function createMediaPath(string $basePath = 'Modules/Media/Files') : string
|
||||
{
|
||||
$rndPath = str_pad(dechex(rand(0, 65535)), 4, '0', STR_PAD_LEFT);
|
||||
return $basePath . '/' . $rndPath[0] . $rndPath[1] . '/' . $rndPath[2] . $rndPath[3];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $status Files
|
||||
* @param int $account Uploader
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function createDbEntries(array $status, int $account) : array
|
||||
{
|
||||
$mediaCreated = [];
|
||||
|
||||
foreach ($status as $uFile) {
|
||||
if(!is_null($created = self::createDbEntry($uFile, $account))) {
|
||||
$mediaCreated[] = $created;
|
||||
}
|
||||
}
|
||||
|
||||
return $mediaCreated;
|
||||
}
|
||||
|
||||
public static function createDbEntry(array $status, int $account)
|
||||
{
|
||||
$media = null;
|
||||
|
||||
if ($status['status'] === UploadStatus::OK) {
|
||||
$media = new Media();
|
||||
$media->setPath(trim($status['path'], '/') . '/' . $status['filename']);
|
||||
$media->setName($status['name']);
|
||||
$media->setSize($status['size']);
|
||||
$media->setCreatedBy($account);
|
||||
$media->setCreatedAt(new \DateTime('NOW'));
|
||||
$media->setExtension($status['extension']);
|
||||
|
||||
MediaMapper::create($media);
|
||||
}
|
||||
|
||||
return $media;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,103 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.1
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
namespace Modules\Media\Models;
|
||||
|
||||
/**
|
||||
* Media class.
|
||||
*
|
||||
* @category Modules
|
||||
* @package Modules\Media
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @license OMS License 1.0
|
||||
* @link http://orange-management.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Collection extends Media
|
||||
{
|
||||
|
||||
/**
|
||||
* Resource id.
|
||||
*
|
||||
* @var int[]
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private $sources = [];
|
||||
|
||||
protected $extension = 'collection';
|
||||
protected $versioned = false;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Set sources.
|
||||
*
|
||||
* @param array $sources Source array
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function setSources(array $sources)
|
||||
{
|
||||
$this->sources = $sources;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set sources.
|
||||
*
|
||||
* @param int $source Source
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function addSource(int $source)
|
||||
{
|
||||
$this->sources[] = $source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sources.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function getSources() : array
|
||||
{
|
||||
return $this->sources;
|
||||
}
|
||||
|
||||
public function setExtension(string $extension)
|
||||
{
|
||||
}
|
||||
|
||||
public function setVersioned(bool $versioned)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.1
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
namespace Modules\Media\Models;
|
||||
|
||||
use Modules\Media\Models\MediaMapper;
|
||||
use phpOMS\DataStorage\Database\Query\Builder;
|
||||
use phpOMS\DataStorage\Database\Query\Column;
|
||||
|
||||
class CollectionMapper extends MediaMapper
|
||||
{
|
||||
protected static $hasMany = [
|
||||
'sources' => [
|
||||
'mapper' => MediaMapper::class, /* mapper of the related object */
|
||||
'table' => 'media_relation', /* table of the related object, null if no relation table is used (many->1) */
|
||||
'dst' => 'media_relation_dst',
|
||||
'src' => 'media_relation_src',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static $table = 'media';
|
||||
|
||||
/**
|
||||
* Created at.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static $createdAt = 'media_created_at';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static $primaryField = 'media_id';
|
||||
|
||||
/**
|
||||
* Find.
|
||||
*
|
||||
* @param array $columns Columns to select
|
||||
*
|
||||
* @return Builder
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function find(...$columns) : Builder
|
||||
{
|
||||
return parent::find(...$columns)->from('account_permission')
|
||||
->where('account_permission.account_permission_for', '=', 'news')
|
||||
->where('account_permission.account_permission_id1', '=', 1)
|
||||
->where('news.news_id', '=', new Column('account_permission.account_permission_id2'))
|
||||
->where('account_permission.account_permission_r', '=', 1);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.1
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/ // TODO: implement file storage interface
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.1
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
namespace Modules\Media\Models;
|
||||
|
||||
use phpOMS\Asset\AssetType;
|
||||
use phpOMS\Message\RequestAbstract;
|
||||
use phpOMS\Message\ResponseAbstract;
|
||||
|
||||
/**
|
||||
* Options trait.
|
||||
*
|
||||
* @category Framework
|
||||
* @package phpOMS\Config
|
||||
* @since 1.0.0
|
||||
*/
|
||||
trait FileUploaderTrait
|
||||
{
|
||||
|
||||
/**
|
||||
* Setup file uploader.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $data Misc. data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function setUpFileUploader(RequestAbstract $request, ResponseAbstract $response, $data = null)
|
||||
{
|
||||
$head = $response->getHead();
|
||||
$head->addAsset(AssetType::JS, $request->getUri()->getBase() . 'Modules/Media/ModuleMedia.js');
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.1
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/ // TODO: implement filestorage on remote ftp server
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.1
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/ // TODO: implement local file storage
|
||||
338
Models/Media.php
338
Models/Media.php
|
|
@ -1,338 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.1
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
namespace Modules\Media\Models;
|
||||
|
||||
/**
|
||||
* Media class.
|
||||
*
|
||||
* @category Modules
|
||||
* @package Modules\Media
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @license OMS License 1.0
|
||||
* @link http://orange-management.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Media
|
||||
{
|
||||
|
||||
/**
|
||||
* ID.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $id = 0;
|
||||
|
||||
/**
|
||||
* Name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $name = '';
|
||||
|
||||
/**
|
||||
* Extension.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $extension = '';
|
||||
|
||||
/**
|
||||
* File size in bytes.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $size = 0;
|
||||
|
||||
/**
|
||||
* Author.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $createdBy = 0;
|
||||
|
||||
/**
|
||||
* Uploaded.
|
||||
*
|
||||
* @var \DateTime
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $createdAt = null;
|
||||
|
||||
/**
|
||||
* Resource path.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $path = '';
|
||||
|
||||
/**
|
||||
* Is versioned.
|
||||
*
|
||||
* @var bool
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $versioned = false;
|
||||
|
||||
/**
|
||||
* Media Description.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $description = '';
|
||||
|
||||
/**
|
||||
* Permissions.
|
||||
*
|
||||
* @var array
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $permissions = [
|
||||
'r' => ['groups' => [],
|
||||
'users' => [],],
|
||||
'w' => ['groups' => [],
|
||||
'users' => [],],
|
||||
'p' => ['groups' => [],
|
||||
'users' => [],],
|
||||
'd' => ['groups' => [],
|
||||
'users' => [],],
|
||||
];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function getId() : int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function getCreatedBy() : int
|
||||
{
|
||||
return $this->createdBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function getCreatedAt() : \DateTime
|
||||
{
|
||||
return $this->createdAt ?? new \DateTime('now');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function getExtension() : string
|
||||
{
|
||||
return $this->extension;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function getPath() : string
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function getName() : string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function getDescription() : string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function getSize() : int
|
||||
{
|
||||
return $this->size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function isVersioned() : bool
|
||||
{
|
||||
return $this->versioned;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $createdBy Creator
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function setCreatedBy(int $createdBy)
|
||||
{
|
||||
$this->createdBy = $createdBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $createdAt Creation date
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function setCreatedAt(\DateTime $createdAt)
|
||||
{
|
||||
$this->createdAt = $createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $extension Extension
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function setExtension(string $extension)
|
||||
{
|
||||
$this->extension = $extension;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path $filepath
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function setPath(string $path)
|
||||
{
|
||||
$this->path = $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name Media name (not file name)
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function setName(string $name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $description Media description
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function setDescription(string $description)
|
||||
{
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $size Filesize
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function setSize(int $size)
|
||||
{
|
||||
$this->size = $size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $versioned File is version controlled
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function setVersioned(bool $versioned)
|
||||
{
|
||||
$this->versioned = $versioned;
|
||||
}
|
||||
|
||||
public function toArray()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,127 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.1
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
namespace Modules\Media\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
use phpOMS\DataStorage\Database\Query\Builder;
|
||||
use phpOMS\DataStorage\Database\Query\Column;
|
||||
use phpOMS\DataStorage\Database\RelationType;
|
||||
|
||||
class MediaMapper extends DataMapperAbstract
|
||||
{
|
||||
|
||||
/**
|
||||
* Columns.
|
||||
*
|
||||
* @var array
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static $columns = [
|
||||
'media_id' => ['name' => 'media_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'media_name' => ['name' => 'media_name', 'type' => 'string', 'internal' => 'name'],
|
||||
'media_versioned' => ['name' => 'media_versioned', 'type' => 'bool', 'internal' => 'versioned'],
|
||||
'media_file' => ['name' => 'media_file', 'type' => 'string', 'internal' => 'path'],
|
||||
'media_extension' => ['name' => 'media_extension', 'type' => 'string', 'internal' => 'extension'],
|
||||
'media_collection' => ['name' => 'media_collection', 'type' => 'bool', 'internal' => 'collection'],
|
||||
'media_description' => ['name' => 'media_description', 'type' => 'string', 'internal' => 'description'],
|
||||
'media_size' => ['name' => 'media_size', 'type' => 'int', 'internal' => 'size'],
|
||||
'media_created_by' => ['name' => 'media_created_by', 'type' => 'int', 'internal' => 'createdBy'],
|
||||
'media_created_at' => ['name' => 'media_created_at', 'type' => 'DateTime', 'internal' => 'createdAt'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static $table = 'media';
|
||||
|
||||
/**
|
||||
* Created at.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static $createdAt = 'media_created_at';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static $primaryField = 'media_id';
|
||||
|
||||
/**
|
||||
* Create object.
|
||||
*
|
||||
* @param mixed $obj Object
|
||||
* @param int $relations Behavior for relations creation
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function create($obj, int $relations = RelationType::ALL)
|
||||
{
|
||||
try {
|
||||
$objId = parent::create($obj, $relations);
|
||||
$query = new Builder(self::$db);
|
||||
$query->prefix(self::$db->getPrefix())
|
||||
->insert(
|
||||
'account_permission_account',
|
||||
'account_permission_from',
|
||||
'account_permission_for',
|
||||
'account_permission_id1',
|
||||
'account_permission_id2',
|
||||
'account_permission_r',
|
||||
'account_permission_w',
|
||||
'account_permission_m',
|
||||
'account_permission_d',
|
||||
'account_permission_p'
|
||||
)
|
||||
->into('account_permission')
|
||||
->values($obj->getCreatedBy(), 'media', 'media', 1, $objId, 1, 1, 1, 1, 1);
|
||||
|
||||
self::$db->con->prepare($query->toSql())->execute();
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $objId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find.
|
||||
*
|
||||
* @param array $columns Columns to select
|
||||
*
|
||||
* @return Builder
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function find(...$columns) : Builder
|
||||
{
|
||||
return parent::find(...$columns)->from('account_permission')
|
||||
->where('account_permission.account_permission_for', '=', 'media')
|
||||
->where('account_permission.account_permission_id1', '=', 1)
|
||||
->where('media.media_id', '=', new Column('account_permission.account_permission_id2'))
|
||||
->where('account_permission.account_permission_r', '=', 1);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.1
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
namespace Modules\Media\Models;
|
||||
|
||||
/**
|
||||
* Media class.
|
||||
*
|
||||
* @category Modules
|
||||
* @package Modules\Media
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @license OMS License 1.0
|
||||
* @link http://orange-management.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class NullCollection extends Collection
|
||||
{
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.1
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
namespace Modules\Media\Models;
|
||||
|
||||
/**
|
||||
* Media class.
|
||||
*
|
||||
* @category Modules
|
||||
* @package Modules\Media
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @license OMS License 1.0
|
||||
* @link http://orange-management.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class NullMedia extends Media
|
||||
{
|
||||
}
|
||||
106
Models/Upload.js
106
Models/Upload.js
|
|
@ -1,106 +0,0 @@
|
|||
(function (jsOMS)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
jsOMS.Autoloader.defineNamespace('jsOMS.Modules.Models.Media');
|
||||
|
||||
jsOMS.Modules.Models.Media.Upload = function (responseManager, logger)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.responseManager = responseManager;
|
||||
this.success = [];
|
||||
|
||||
this.uri = '';
|
||||
this.allowedTypes = [];
|
||||
this.maxFileSize = 0;
|
||||
this.files = [];
|
||||
};
|
||||
|
||||
jsOMS.Modules.Models.Media.Upload.prototype.setMaxFileSize = function (size)
|
||||
{
|
||||
this.maxFileSize = size;
|
||||
};
|
||||
|
||||
jsOMS.Modules.Models.Media.Upload.prototype.getMaxFileSize = function (size)
|
||||
{
|
||||
return this.maxFileSize;
|
||||
};
|
||||
|
||||
jsOMS.Modules.Models.Media.Upload.prototype.setSuccess = function (id, callback)
|
||||
{
|
||||
this.success[id] = callback;
|
||||
};
|
||||
|
||||
jsOMS.Modules.Models.Media.Upload.prototype.setUri = function (uri)
|
||||
{
|
||||
this.uri = uri;
|
||||
};
|
||||
|
||||
jsOMS.Modules.Models.Media.Upload.prototype.setAllowedTypes = function (allowed)
|
||||
{
|
||||
this.allowedTypes = allowed;
|
||||
};
|
||||
|
||||
jsOMS.Modules.Models.Media.Upload.prototype.addAllowedType = function (allowed)
|
||||
{
|
||||
this.allowedTypes.push(allowed);
|
||||
};
|
||||
|
||||
jsOMS.Modules.Models.Media.Upload.prototype.setMaxFileSize = function (size)
|
||||
{
|
||||
this.maxFileSize = size;
|
||||
};
|
||||
|
||||
jsOMS.Modules.Models.Media.Upload.prototype.addFile = function (file)
|
||||
{
|
||||
this.files.push(file);
|
||||
};
|
||||
|
||||
jsOMS.Modules.Models.Media.Upload.prototype.count = function ()
|
||||
{
|
||||
return this.files.length;
|
||||
};
|
||||
|
||||
// todo: maybe do file upload together with data upload in FormData.
|
||||
// let the module forward the files to the media module?!
|
||||
jsOMS.Modules.Models.Media.Upload.prototype.upload = function (formId)
|
||||
{
|
||||
// TODO: validate file type + file size
|
||||
|
||||
let request = new jsOMS.Message.Request.Request(),
|
||||
formData = new FormData(),
|
||||
self = this;
|
||||
|
||||
this.files.forEach(function (element, index)
|
||||
{
|
||||
formData.append('file' + index, element);
|
||||
});
|
||||
|
||||
request.setData(formData);
|
||||
request.setType(jsOMS.Message.Request.RequestType.RAW);
|
||||
request.setUri(this.uri);
|
||||
request.setMethod(jsOMS.Message.Request.RequestMethod.POST);
|
||||
request.setRequestHeader('HTTP_X_REQUESTED_WITH', 'XMLHttpRequest');
|
||||
request.setSuccess(function (xhr)
|
||||
{
|
||||
try {
|
||||
let response = JSON.parse(xhr.response);
|
||||
|
||||
for (let k = 0; k < response.length; k++) {
|
||||
if (!self.success[formId]) {
|
||||
self.responseManager.run(response[k].type, response[k]);
|
||||
} else {
|
||||
self.success[formId](response[k].type, response[k]);
|
||||
}
|
||||
}
|
||||
} catch (exception) {
|
||||
console.log(exception);
|
||||
self.logger.error('Invalid media upload response: ' + xhr.response);
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
request.send();
|
||||
};
|
||||
}(window.jsOMS = window.jsOMS || {}));
|
||||
|
|
@ -1,396 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.1
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
namespace Modules\Media\Models;
|
||||
|
||||
use phpOMS\System\File\Local\Directory;
|
||||
|
||||
|
||||
/**
|
||||
* Upload.
|
||||
*
|
||||
* @category Modules
|
||||
* @package Modules\Media
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @license OMS License 1.0
|
||||
* @link http://orange-management.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class UploadFile
|
||||
{
|
||||
/* public */ const PATH_GENERATION_LIMIT = 1000;
|
||||
|
||||
/**
|
||||
* Image interlaced.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private $interlaced = true;
|
||||
|
||||
/**
|
||||
* Upload max size.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private $maxSize = 50000000;
|
||||
|
||||
/**
|
||||
* Allowed mime types.
|
||||
*
|
||||
* @var array
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private $allowedTypes = [];
|
||||
|
||||
/**
|
||||
* Output directory.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private $outputDir = 'Modules/Media/Files';
|
||||
|
||||
/**
|
||||
* Output file name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private $fileName = '';
|
||||
|
||||
/**
|
||||
* Output file name.
|
||||
*
|
||||
* @var bool
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private $preserveFileName = true;
|
||||
|
||||
/**
|
||||
* Upload file to server.
|
||||
*
|
||||
* @param array $files File data ($_FILE)
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws \Exception
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function upload(array $files) : array
|
||||
{
|
||||
$result = [];
|
||||
|
||||
if (count($files) == count($files, COUNT_RECURSIVE)) {
|
||||
$files = [$files];
|
||||
}
|
||||
|
||||
$this->findOutputDir($files);
|
||||
$path = ROOT_PATH . $this->outputDir;
|
||||
|
||||
foreach ($files as $key => $f) {
|
||||
$result[$key] = [];
|
||||
$result[$key]['status'] = UploadStatus::OK;
|
||||
|
||||
if (!isset($f['error'])) {
|
||||
// TODO: handle wrong parameters
|
||||
$result[$key]['status'] = UploadStatus::WRONG_PARAMETERS;
|
||||
|
||||
return $result;
|
||||
} elseif ($f['error'] !== UPLOAD_ERR_OK) {
|
||||
$result[$key]['status'] = $this->getUploadError($f['error']);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
$result[$key]['size'] = $f['size'];
|
||||
|
||||
if ($f['size'] > $this->maxSize) {
|
||||
// too large2
|
||||
$result[$key]['status'] = UploadStatus::CONFIG_SIZE;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
// TODO: do I need pecl fileinfo?
|
||||
if (!empty($this->allowedTypes) && ($ext = array_search($f['type'], $this->allowedTypes, true)) === false) {
|
||||
// wrong file format
|
||||
$result[$key]['status'] = UploadStatus::WRONG_EXTENSION;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
if ($this->preserveFileName) {
|
||||
$this->fileName = $f['name'];
|
||||
}
|
||||
|
||||
$split = explode('.', $f['name']);
|
||||
$result[$key]['name'] = $split[0];
|
||||
$extension = count($split) > 1 ? $split[count($split) - 1] : '';
|
||||
$result[$key]['extension'] = $extension;
|
||||
|
||||
// ! and empty same?!
|
||||
$result[$key]['filename'] = $this->fileName;
|
||||
if (!$this->fileName || empty($this->fileName) || file_exists($path . '/' . $this->fileName)) {
|
||||
$rnd = '';
|
||||
|
||||
$limit = 0;
|
||||
do {
|
||||
$sha = sha1_file($f['tmp_name'] . $rnd);
|
||||
|
||||
if ($sha === false) {
|
||||
$result[$key]['status'] = UploadStatus::FAILED_HASHING;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
$sha .= '.' . $extension;
|
||||
|
||||
$this->fileName = $sha;
|
||||
$rnd = mt_rand();
|
||||
$limit++;
|
||||
} while (file_exists($path . '/' . $this->fileName) && $limit < self::PATH_GENERATION_LIMIT);
|
||||
|
||||
if($limit >= self::PATH_GENERATION_LIMIT) {
|
||||
throw new \Exception('No file path could be found. Potential attack!');
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_dir($path)) {
|
||||
Directory::create($path, 0655, true);
|
||||
}
|
||||
|
||||
if (!is_uploaded_file($f['tmp_name'])) {
|
||||
$result[$key]['status'] = UploadStatus::NOT_UPLOADED;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
if (!move_uploaded_file($f['tmp_name'], $dest = $path . '/' . $this->fileName)) {
|
||||
$result[$key]['status'] = UploadStatus::NOT_MOVABLE;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
if($this->interlaced && in_array($extension, ['png', 'jpg', 'jpeg', 'gif'])) {
|
||||
$this->interlace($extension, $dest);
|
||||
}
|
||||
|
||||
$result[$key]['path'] = $this->outputDir;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function interlace(string $extension, string $path) /* : void */
|
||||
{
|
||||
|
||||
if($extension === 'png') {
|
||||
$img = imagecreatefrompng($path);
|
||||
} elseif($extension === 'jpg' || $extension === 'jpeg') {
|
||||
$img = imagecreatefromjpeg($path);
|
||||
} else {
|
||||
$img = imagecreatefromgif($path);
|
||||
}
|
||||
|
||||
imageinterlace($img, (int) $this->interlaced);
|
||||
|
||||
if($extension === 'png') {
|
||||
imagepng($img, $path);
|
||||
} elseif($extension === 'jpg' || $extension === 'jpeg') {
|
||||
imagejpeg($img, $path);
|
||||
} else {
|
||||
imagegif($img, $path);
|
||||
}
|
||||
|
||||
imagedestroy($img);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find unique output path for batch of files
|
||||
*
|
||||
* @param array $files Array of files
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
private function findOutputDir(array $files)
|
||||
{
|
||||
if (count($files) > 1) {
|
||||
do {
|
||||
$rndPath = str_pad(dechex(rand(0, 65535)), 4, '0', STR_PAD_LEFT);
|
||||
} while (file_exists($this->outputDir . '/' . $rndPath));
|
||||
|
||||
$this->outputDir = $this->outputDir . '/' . $rndPath;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get upload error
|
||||
*
|
||||
* @param mixed $error Error type
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
private function getUploadError($error) : int
|
||||
{
|
||||
switch ($error) {
|
||||
case UPLOAD_ERR_NO_FILE:
|
||||
// TODO: no file sent
|
||||
return UploadStatus::NOTHING_UPLOADED;
|
||||
case UPLOAD_ERR_INI_SIZE:
|
||||
case UPLOAD_ERR_FORM_SIZE:
|
||||
return UploadStatus::UPLOAD_SIZE;
|
||||
default:
|
||||
return UploadStatus::UNKNOWN_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function getMaxSize() : int
|
||||
{
|
||||
return $this->maxSize;
|
||||
}
|
||||
|
||||
public function setInterlaced(bool $interlaced) /* : void */
|
||||
{
|
||||
$this->interlaced = $interlaced;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $maxSize
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function setMaxSize(int $maxSize)
|
||||
{
|
||||
$this->maxSize = $maxSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function getAllowedTypes() : array
|
||||
{
|
||||
return $this->allowedTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $allowedTypes
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function setAllowedTypes(array $allowedTypes)
|
||||
{
|
||||
$this->allowedTypes = $allowedTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $allowedTypes
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function addAllowedTypes($allowedTypes)
|
||||
{
|
||||
$this->allowedTypes[] = $allowedTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function getOutputDir() : string
|
||||
{
|
||||
return $this->outputDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $outputDir
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function setOutputDir(string $outputDir)
|
||||
{
|
||||
$this->outputDir = $outputDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function getFileName() : string
|
||||
{
|
||||
return $this->fileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $fileName
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function setFileName(string $fileName)
|
||||
{
|
||||
$this->fileName = $fileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $preserveFileName
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function setPreserveFileName(bool $preserveFileName)
|
||||
{
|
||||
$this->preserveFileName = $preserveFileName;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.1
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
namespace Modules\Media\Models;
|
||||
|
||||
use phpOMS\Datatypes\Enum;
|
||||
|
||||
/**
|
||||
* Upload status.
|
||||
*
|
||||
* @category Framework
|
||||
* @package phpOMS\DataStorage\Database
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @license OMS License 1.0
|
||||
* @link http://orange-management.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
abstract class UploadStatus extends Enum
|
||||
{
|
||||
/* public */ const OK = 0;
|
||||
/* public */ const WRONG_PARAMETERS = -1;
|
||||
/* public */ const NOTHING_UPLOADED = -2;
|
||||
/* public */ const UPLOAD_SIZE = -3;
|
||||
/* public */ const UNKNOWN_ERROR = -4;
|
||||
/* public */ const CONFIG_SIZE = -5;
|
||||
/* public */ const WRONG_EXTENSION = -6;
|
||||
/* public */ const NOT_UPLOADED = -7;
|
||||
/* public */ const NOT_MOVABLE = -8;
|
||||
/* public */ const FAILED_HASHING = -9;
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
<span id="media-upload"></span>
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.1
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
return ['Navigation' => [
|
||||
'Create' => 'Create',
|
||||
'List' => 'List',
|
||||
'Media' => 'Media',
|
||||
]];
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.1
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
$MODLANG[1] = [
|
||||
'i:ModuleInstalled' => 'Installation of the module {$1} was successful.',
|
||||
];
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.1
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
return ['Media' => [
|
||||
'Account' => 'Account',
|
||||
'Author' => 'Author',
|
||||
'Changed' => 'Changed',
|
||||
'Changedby' => 'Changed by',
|
||||
'Created' => 'Created',
|
||||
'Creator' => 'Creator',
|
||||
'Data' => 'Data',
|
||||
'Editability' => 'Editability',
|
||||
'Extension' => 'Extension',
|
||||
'Files' => 'Files',
|
||||
'Media' => 'Media',
|
||||
'Name' => 'Name',
|
||||
'Permission' => 'Permission',
|
||||
'Preview' => 'Preview',
|
||||
'Settings' => 'Settings',
|
||||
'Size' => 'Size',
|
||||
'Type' => 'Type',
|
||||
'Upload' => 'Upload',
|
||||
'Visibility' => 'Visibility',
|
||||
]];
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.1
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
/**
|
||||
* @var \phpOMS\Views\View $this
|
||||
*/
|
||||
|
||||
echo $this->getData('nav')->render(); ?>
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-6">
|
||||
<section class="box wf-100">
|
||||
<header><h1><?= $this->getText('Upload'); ?></h1></header>
|
||||
<div class="inner">
|
||||
<form method="POST" id="media-uploader" action="<?= \phpOMS\Uri\UriFactory::build('/{/lang}/api/media'); ?>">
|
||||
<table class="layout wf-100">
|
||||
<tr><td><label for="iName"><?= $this->getText('Name'); ?></label>
|
||||
<tr><td><input type="text" id="iName" name="name" placeholder="">
|
||||
<tr><td><label for="iFiles"><?= $this->getText('Files'); ?></label>
|
||||
<tr><td><input type="file" id="iFiles" name="files" multiple><input name="media" type="hidden">
|
||||
<tr><td><input type="submit" value="<?= $this->getText('Create', 0, 0); ?>">
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1,89 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.1
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
/**
|
||||
* @var \phpOMS\Views\View $this
|
||||
*/
|
||||
|
||||
$media = $this->getData('media');
|
||||
$footerView = new \Web\Views\Lists\PaginationView($this->app, $this->request, $this->response);
|
||||
$footerView->setTemplate('/Web/Templates/Lists/Footer/PaginationBig');
|
||||
$footerView->setPages(count($media) / 25);
|
||||
$footerView->setPage(1);
|
||||
|
||||
echo $this->getData('nav')->render(); ?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="box wf-100">
|
||||
<table class="table">
|
||||
<caption><?= $this->getText('Media'); ?></caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<td>
|
||||
<td class="wf-100"><?= $this->getText('Name'); ?>
|
||||
<td><?= $this->getText('Type'); ?>
|
||||
<td><?= $this->getText('Size'); ?>
|
||||
<td><?= $this->getText('Creator'); ?>
|
||||
<td><?= $this->getText('Created'); ?>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="3"><?= $footerView->render(); ?>
|
||||
<tbody>
|
||||
<?php $count = 0; foreach($media as $key => $value) : $count++;
|
||||
$url = \phpOMS\Uri\UriFactory::build('/{/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>
|
||||
<td><a href="<?= $url; ?>"><i class="fa fa-<?= $icon; ?>"></i></a>
|
||||
<td><a href="<?= $url; ?>"><?= $value->getName(); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $value->getExtension(); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $value->getSize(); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $value->getCreatedBy(); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $value->getCreatedAt()->format('Y-m-d H:i:s'); ?></a>
|
||||
<?php endforeach; ?>
|
||||
<?php if($count === 0) : ?>
|
||||
<tr><td colspan="5" class="empty"><?= $this->getText('Empty', 0, 0); ?>
|
||||
<?php endif; ?>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.1
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
/**
|
||||
* @var \phpOMS\Views\View $this
|
||||
*/
|
||||
/**
|
||||
* @var $media \Modules\Media\Models\Media
|
||||
*/
|
||||
$media = $this->getData('media');
|
||||
echo $this->getData('nav')->render();
|
||||
?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<section class="box wf-100">
|
||||
<header><h1><?= $media->getName() ?></h1></header>
|
||||
<div class="inner">
|
||||
<table class="list w-100">
|
||||
<tbody>
|
||||
<tr><td>Size<td class="wf-100"><?= $media->getSize(); ?>
|
||||
<tr><td>Created at<td><?= $media->getCreatedAt()->format('Y-m-d'); ?>
|
||||
<tr><td>Created by<td><?= $media->getCreatedBy(); ?>
|
||||
<tr><td>Description<td><?= $media->getDescription(); ?>
|
||||
<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="<?= $this->request->getUri()->getBase() . $media->getPath(); ?>"></div>
|
||||
<?php elseif($media->getExtension() === 'collection') : ?>
|
||||
collection
|
||||
<?php else : ?>
|
||||
<pre>
|
||||
<?php
|
||||
$output = htmlspecialchars(file_get_contents(ROOT_PATH . '/' . $media->getPath()));
|
||||
$output = str_replace(["\r\n", "\r"], "\n", $output);
|
||||
$output = explode("\n", $output);
|
||||
foreach($output as $line) : ?><span><?= $line; ?></span><?php endforeach; ?>
|
||||
</pre>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1 +0,0 @@
|
|||
<span id="media-upload"></span>
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.1
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
return ['Navigation' => [
|
||||
'Create' => 'Create',
|
||||
'List' => 'List',
|
||||
'Media' => 'Media',
|
||||
]];
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.1
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
$MODLANG[1] = [
|
||||
'i:ModuleInstalled' => 'Installation of the module {$1} was successful.',
|
||||
];
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.1
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
return ['Media' => [
|
||||
'Account' => 'Account',
|
||||
'Author' => 'Author',
|
||||
'Changed' => 'Changed',
|
||||
'Changedby' => 'Changed by',
|
||||
'Created' => 'Created',
|
||||
'Creator' => 'Creator',
|
||||
'Data' => 'Data',
|
||||
'Editability' => 'Editability',
|
||||
'Extension' => 'Extension',
|
||||
'Files' => 'Files',
|
||||
'Media' => 'Media',
|
||||
'Name' => 'Name',
|
||||
'Permission' => 'Permission',
|
||||
'Preview' => 'Preview',
|
||||
'Settings' => 'Settings',
|
||||
'Size' => 'Size',
|
||||
'Type' => 'Type',
|
||||
'Upload' => 'Upload',
|
||||
'Visibility' => 'Visibility',
|
||||
]];
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.1
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
/**
|
||||
* @var \phpOMS\Views\View $this
|
||||
*/
|
||||
|
||||
echo $this->getData('nav')->render(); ?>
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-6">
|
||||
<section class="box wf-100">
|
||||
<header><h1><?= $this->getText('Upload'); ?></h1></header>
|
||||
<div class="inner">
|
||||
<form method="POST" id="media-uploader" action="<?= \phpOMS\Uri\UriFactory::build('/{/lang}/api/media'); ?>">
|
||||
<table class="layout wf-100">
|
||||
<tr><td><label for="iName"><?= $this->getText('Name'); ?></label>
|
||||
<tr><td><input type="text" id="iName" name="name" placeholder="">
|
||||
<tr><td><label for="iFiles"><?= $this->getText('Files'); ?></label>
|
||||
<tr><td><input type="file" id="iFiles" name="files" multiple><input name="media" type="hidden">
|
||||
<tr><td><input type="submit" value="<?= $this->getText('Create', 0, 0); ?>">
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1,89 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.1
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
/**
|
||||
* @var \phpOMS\Views\View $this
|
||||
*/
|
||||
|
||||
$media = $this->getData('media');
|
||||
$footerView = new \Web\Views\Lists\PaginationView($this->app, $this->request, $this->response);
|
||||
$footerView->setTemplate('/Web/Templates/Lists/Footer/PaginationBig');
|
||||
$footerView->setPages(count($media) / 25);
|
||||
$footerView->setPage(1);
|
||||
|
||||
echo $this->getData('nav')->render(); ?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="box wf-100">
|
||||
<table class="table">
|
||||
<caption><?= $this->getText('Media'); ?></caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<td>
|
||||
<td class="wf-100"><?= $this->getText('Name'); ?>
|
||||
<td><?= $this->getText('Type'); ?>
|
||||
<td><?= $this->getText('Size'); ?>
|
||||
<td><?= $this->getText('Creator'); ?>
|
||||
<td><?= $this->getText('Created'); ?>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="3"><?= $footerView->render(); ?>
|
||||
<tbody>
|
||||
<?php $count = 0; foreach($media as $key => $value) : $count++;
|
||||
$url = \phpOMS\Uri\UriFactory::build('/{/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>
|
||||
<td><a href="<?= $url; ?>"><i class="fa fa-<?= $icon; ?>"></i></a>
|
||||
<td><a href="<?= $url; ?>"><?= $value->getName(); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $value->getExtension(); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $value->getSize(); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $value->getCreatedBy(); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $value->getCreatedAt()->format('Y-m-d H:i:s'); ?></a>
|
||||
<?php endforeach; ?>
|
||||
<?php if($count === 0) : ?>
|
||||
<tr><td colspan="5" class="empty"><?= $this->getText('Empty', 0, 0); ?>
|
||||
<?php endif; ?>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.1
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
/**
|
||||
* @var \phpOMS\Views\View $this
|
||||
*/
|
||||
/**
|
||||
* @var $media \Modules\Media\Models\Media
|
||||
*/
|
||||
$media = $this->getData('media');
|
||||
echo $this->getData('nav')->render();
|
||||
?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<section class="box wf-100">
|
||||
<header><h1><?= $media->getName() ?></h1></header>
|
||||
<div class="inner">
|
||||
<table class="list w-100">
|
||||
<tbody>
|
||||
<tr><td>Size<td class="wf-100"><?= $media->getSize(); ?>
|
||||
<tr><td>Created at<td><?= $media->getCreatedAt()->format('Y-m-d'); ?>
|
||||
<tr><td>Created by<td><?= $media->getCreatedBy(); ?>
|
||||
<tr><td>Description<td><?= $media->getDescription(); ?>
|
||||
<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="<?= $this->request->getUri()->getBase() . $media->getPath(); ?>"></div>
|
||||
<?php elseif($media->getExtension() === 'collection') : ?>
|
||||
collection
|
||||
<?php else : ?>
|
||||
<pre>
|
||||
<?php
|
||||
$output = htmlspecialchars(file_get_contents(ROOT_PATH . '/' . $media->getPath()));
|
||||
$output = str_replace(["\r\n", "\r"], "\n", $output);
|
||||
$output = explode("\n", $output);
|
||||
foreach($output as $line) : ?><span><?= $line; ?></span><?php endforeach; ?>
|
||||
</pre>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.1
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
namespace Modules\Media\Views;
|
||||
|
||||
use phpOMS\Views\View;
|
||||
|
||||
/**
|
||||
* Media list view.
|
||||
*
|
||||
* @category Modules
|
||||
* @package Modules\Media
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @license OMS License 1.0
|
||||
* @link http://orange-management.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class MediaCreateView extends View
|
||||
{
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 48 KiB |
62
info.json
62
info.json
|
|
@ -1,62 +0,0 @@
|
|||
{
|
||||
"name": {
|
||||
"id": 1000400000,
|
||||
"internal": "Media",
|
||||
"external": "OMS Media"
|
||||
},
|
||||
"version": "1.0.0",
|
||||
"requirements": {
|
||||
"phpOMS": "1.0.0",
|
||||
"phpOMS-db": "1.0.0"
|
||||
},
|
||||
"creator": {
|
||||
"name": "Orange Management",
|
||||
"website": "www.spl1nes.com"
|
||||
},
|
||||
"description": "The profile module.",
|
||||
"directory": "Media",
|
||||
"dependencies": {
|
||||
"Admin" : "1.0.0"
|
||||
},
|
||||
"providing": {
|
||||
"Navigation": "*"
|
||||
},
|
||||
"load": [
|
||||
{
|
||||
"pid": [
|
||||
"1ba288c868cacf14e56f8205efef31d697301d02"
|
||||
],
|
||||
"type": 4,
|
||||
"for": "Content",
|
||||
"file": "Media",
|
||||
"from": "Media"
|
||||
},
|
||||
{
|
||||
"pid": [
|
||||
"15b5e54cc7b2f8bdb84ed667d9931d758c6bc108"
|
||||
],
|
||||
"type": 4,
|
||||
"for": "CostUnitAccounting",
|
||||
"file": "Media",
|
||||
"from": "Media"
|
||||
},
|
||||
{
|
||||
"pid": [
|
||||
"e56f238d391b804975e0f47f26d20b6d2d675200"
|
||||
],
|
||||
"type": 4,
|
||||
"for": "Admin",
|
||||
"file": "Media",
|
||||
"from": "Media"
|
||||
},
|
||||
{
|
||||
"pid": [
|
||||
"754a08ddf8bcb1cf22f310f09206dd783d42f7dd"
|
||||
],
|
||||
"type": 5,
|
||||
"from": "Media",
|
||||
"for": "Navigation",
|
||||
"file": "Navigation"
|
||||
}
|
||||
]
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user