Permalink
Browse files

Merge pull request #2240 from daniellienert/feature/copyright-notice

FEATURE: Extend the asset model by a copyright notice
  • Loading branch information...
robertlemke committed Nov 5, 2018
2 parents af4d107 + 9579441 commit 7584a1d6ef3666c471a5ae9147dd585c6cf77a7c
@@ -34,7 +34,7 @@ class AssetProxyController extends ActionController
* @param string $assetIdentifier The asset-source specific identifier of the asset to import
* @return string
*/
public function importAction(string $assetSourceIdentifier, string $assetIdentifier)
public function importAction(string $assetSourceIdentifier, string $assetIdentifier): string
{
$this->response->setHeader('Content-Type', 'application/json');
@@ -15,14 +15,18 @@
<label for="title">{neos:backend.translate(id: 'field.title', package: 'Neos.Media.Browser')}</label>
<input id="title" readonly="readonly" value="{assetProxy.iptcProperties.Title}"/>
<label for="caption">{neos:backend.translate(id: 'field.caption', package: 'Neos.Media.Browser')}</label>
<textarea id="caption" rows="3" readonly="readonly">{assetProxy.iptcProperties.CaptionAbstract}</textarea>
<textarea id="caption" rows="2" readonly="readonly">{assetProxy.iptcProperties.CaptionAbstract}</textarea>
<label for="copyrightnotice">{neos:backend.translate(id: 'field.copyrightnotice', package: 'Neos.Media.Browser')}</label>
<textarea id="copyrightnotice" rows="2" readonly="readonly">{assetProxy.iptcProperties.CopyrightNotice}</textarea>
</f:then>
<f:else>
<legend>{neos:backend.translate(id: 'basics', package: 'Neos.Media.Browser')}</legend>
<label for="title">{neos:backend.translate(id: 'field.title', package: 'Neos.Media.Browser')}</label>
<f:form.textfield property="title" id="title" placeholder="{neos:backend.translate(id: 'field.title', package: 'Neos.Media.Browser')}"/>
<label for="caption">{neos:backend.translate(id: 'field.caption', package: 'Neos.Media.Browser')}</label>
<f:form.textarea property="caption" id="caption" rows="3" placeholder="{neos:backend.translate(id: 'field.caption', package: 'Neos.Media.Browser')}"/>
<f:form.textarea property="caption" id="caption" rows="2" placeholder="{neos:backend.translate(id: 'field.caption', package: 'Neos.Media.Browser')}"/>
<label for="copyrightnotice">{neos:backend.translate(id: 'field.copyrightnotice', package: 'Neos.Media.Browser')}</label>
<f:form.textarea property="copyrightNotice" id="copyrightnotice" rows="2" placeholder="{neos:backend.translate(id: 'field.copyrightnotice', package: 'Neos.Media.Browser')}"/>
</f:else>
</f:if>
<f:if condition="{tags}">
@@ -12,7 +12,9 @@
<label for="title">{neos:backend.translate(id: 'field.title', package: 'Neos.Media.Browser')}</label>
<input id="title" readonly="readonly" value="{assetProxy.iptcProperties.Title}"/>
<label for="caption">{neos:backend.translate(id: 'field.caption', package: 'Neos.Media.Browser')}</label>
<textarea id="caption" rows="3" readonly="readonly">{assetProxy.iptcProperties.CaptionAbstract}</textarea>
<textarea id="caption" rows="2" readonly="readonly">{assetProxy.iptcProperties.CaptionAbstract}</textarea>
<label for="copyrightnotice">{neos:backend.translate(id: 'field.copyrightnotice', package: 'Neos.Media.Browser')}</label>
<textarea id="copyrightnotice" rows="2" readonly="readonly">{assetProxy.iptcProperties.CopyrightNotice}</textarea>
</fieldset>
<fieldset>
<legend>{neos:backend.translate(id: 'metadata', package: 'Neos.Media.Browser')}</legend>
@@ -26,6 +26,9 @@
<trans-unit id="field.caption" xml:space="preserve">
<source>Caption</source>
</trans-unit>
<trans-unit id="field.copyrightnotice" xml:space="preserve">
<source>Copyright Notice</source>
</trans-unit>
<trans-unit id="field.lastModified" xml:space="preserve">
<source>Last modified</source>
</trans-unit>
@@ -98,6 +98,12 @@ class Asset implements AssetInterface
*/
protected $caption = '';
/**
* @var string
* @ORM\Column(type="text")
*/
protected $copyrightNotice = '';
/**
* @var PersistentResource
* @ORM\OneToOne(orphanRemoval=true, cascade={"all"})
@@ -299,6 +305,22 @@ public function getCaption()
return $this->caption;
}
/**
* @return string
*/
public function getCopyrightNotice(): string
{
return $this->copyrightNotice;
}
/**
* @param string $copyrightNotice
*/
public function setCopyrightNotice(string $copyrightNotice): void
{
$this->copyrightNotice = $copyrightNotice;
}
/**
* Return the tags assigned to this asset
*
@@ -337,6 +359,7 @@ public function addTag(Tag $tag)
* @param string $ratioMode Whether the resulting image should be cropped if both edge's sizes are supplied that would hurt the aspect ratio
* @param boolean $allowUpScaling Whether the resulting image should be upscaled
* @return Thumbnail
* @throws \Exception
* @api
*/
public function getThumbnail($maximumWidth = null, $maximumHeight = null, $ratioMode = ImageInterface::RATIOMODE_INSET, $allowUpScaling = null)
@@ -1,4 +1,7 @@
<?php
declare(strict_types = 1);
namespace Neos\Media\Domain\Service;
/*
@@ -13,6 +16,7 @@
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Log\PsrSystemLoggerInterface;
use Neos\Flow\Log\Utility\LogEnvironment;
use Neos\Flow\Persistence\PersistenceManagerInterface;
use Neos\Flow\ResourceManagement\Exception;
use Neos\Flow\ResourceManagement\ResourceManager;
@@ -118,7 +122,7 @@ public function importAsset(string $assetSourceIdentifier, string $assetIdentifi
$assetProxy = $assetProxyRepository->getAssetProxy($assetIdentifier);
if (!$assetProxy instanceof HasRemoteOriginalInterface) {
$this->systemLogger->log(LOG_ERR, sprintf('Failed importing an the asset %s from asset source %s because it does not have a remote original.', $assetProxy->getFilename(), $assetSourceIdentifier));
$this->systemLogger->error(sprintf('Failed importing an the asset %s from asset source %s because it does not have a remote original.', $assetProxy->getFilename(), $assetSourceIdentifier), LogEnvironment::fromMethodName(__METHOD__));
throw new AssetSourceServiceException(sprintf('Failed importing an the asset %s from asset source %s because it does not have a remote original.', $assetProxy->getFilename(), $assetSourceIdentifier), 1538754066);
}
@@ -128,7 +132,7 @@ public function importAsset(string $assetSourceIdentifier, string $assetIdentifi
$assetResource = $this->resourceManager->importResource($assetProxy->getImportStream());
$assetResource->setFilename($assetProxy->getFilename());
} catch (Exception $exception) {
$this->systemLogger->log(LOG_ERR, sprintf('Failed importing an the asset %s from asset source %s. Original URI: %s. Error: %s', $assetProxy->getFilename(), $assetSourceIdentifier, $assetProxy->getImportStream(), $exception->getMessage()));
$this->systemLogger->error(sprintf('Failed importing an the asset %s from asset source %s. Original URI: %s. Error: %s', $assetProxy->getFilename(), $assetSourceIdentifier, $assetProxy->getImportStream(), $exception->getMessage()), LogEnvironment::fromMethodName(__METHOD__));
throw $exception;
}
@@ -144,6 +148,7 @@ public function importAsset(string $assetSourceIdentifier, string $assetIdentifi
if ($assetProxy instanceof SupportsIptcMetadataInterface) {
$asset->setTitle($assetProxy->getIptcProperty('Title'));
$asset->setCaption($assetProxy->getIptcProperty('CaptionAbstract'));
$asset->setCopyrightNotice($assetProxy->getIptcProperty('CopyrightNotice'));
}
$this->assetRepository->add($asset);
@@ -165,7 +170,7 @@ public function importAsset(string $assetSourceIdentifier, string $assetIdentifi
/**
* @return void
*/
private function initialize()
private function initialize(): void
{
if ($this->assetSources === []) {
foreach ($this->assetSourcesConfiguration as $assetSourceIdentifier => $assetSourceConfiguration) {
@@ -0,0 +1,57 @@
<?php
namespace Neos\Flow\Persistence\Doctrine\Migrations;
/*
* This file is part of the Neos.Media package.
*
* (c) Contributors of the Neos Project - www.neos.io
*
* This package is Open Source Software. For the full copyright and license
* information, please view the LICENSE file which was distributed with this
* source code.
*/
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Migrations\AbortMigrationException;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
class Version20181104152203 extends AbstractMigration
{
/**
* @return string
*/
public function getDescription()
{
return 'Introduce copyright notice';
}
/**
* @param Schema $schema
* @return void
* @throws DBALException
* @throws AbortMigrationException
*/
public function up(Schema $schema)
{
// this up() migration is autogenerated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on "mysql".');
$this->addSql('ALTER TABLE neos_media_domain_model_asset ADD copyrightnotice LONGTEXT NOT NULL');
}
/**
* @param Schema $schema
* @return void
* @throws DBALException
* @throws AbortMigrationException
*/
public function down(Schema $schema)
{
// this down() migration is autogenerated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on "mysql".');
$this->addSql('ALTER TABLE neos_media_domain_model_asset DROP copyrightnotice');
}
}
@@ -0,0 +1,57 @@
<?php
namespace Neos\Flow\Persistence\Doctrine\Migrations;
/*
* This file is part of the Neos.Media package.
*
* (c) Contributors of the Neos Project - www.neos.io
*
* This package is Open Source Software. For the full copyright and license
* information, please view the LICENSE file which was distributed with this
* source code.
*/
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Migrations\AbortMigrationException;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
class Version20181104152204 extends AbstractMigration
{
/**
* @return string
*/
public function getDescription()
{
return 'Introduce copyright notice';
}
/**
* @param Schema $schema
* @return void
* @throws DBALException
* @throws AbortMigrationException
*/
public function up(Schema $schema)
{
// this up() migration is autogenerated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on "postgresql".');
$this->addSql('ALTER TABLE neos_media_domain_model_asset ADD copyrightnotice TEXT NOT NULL');
}
/**
* @param Schema $schema
* @return void
* @throws DBALException
* @throws AbortMigrationException
*/
public function down(Schema $schema)
{
// this down() migration is autogenerated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on "postgresql".');
$this->addSql('ALTER TABLE neos_media_domain_model_asset DROP copyrightnotice');
}
}

0 comments on commit 7584a1d

Please sign in to comment.