forked from ezsystems/ezpublish-kernel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ezsystems#1104 from ezsystems/fix-EZP-23513-richte…
…xt-linked-embeds-2 Fix EZP-23513: embed rendering (RichText)
- Loading branch information
Showing
68 changed files
with
2,046 additions
and
306 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
...ndle/EzPublishCoreBundle/DependencyInjection/Compiler/RichTextEzxmlInputConverterPass.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
/** | ||
* File containing the RichTextEzxmlInputConverterPass class. | ||
* | ||
* @copyright Copyright (C) eZ Systems AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
* @version //autogentag// | ||
*/ | ||
|
||
namespace eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler; | ||
|
||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
|
||
/** | ||
* Compiler pass for the RichText EZXML input Aggregate converter tags. | ||
* @see \eZ\Publish\Core\FieldType\RichText\Converter\Aggregate | ||
*/ | ||
class RichTextEzxmlInputConverterPass implements CompilerPassInterface | ||
{ | ||
public function process( ContainerBuilder $container ) | ||
{ | ||
if ( !$container->hasDefinition( 'ezpublish.fieldType.ezrichtext.converter.input.ezxml' ) ) | ||
{ | ||
return; | ||
} | ||
|
||
$ezxmlInputConverterDefinition = $container->getDefinition( 'ezpublish.fieldType.ezrichtext.converter.input.ezxml' ); | ||
$taggedServiceIds = $container->findTaggedServiceIds( 'ezpublish.ezrichtext.converter.input.ezxml' ); | ||
|
||
$convertersByPriority = array(); | ||
foreach ( $taggedServiceIds as $id => $tags ) | ||
{ | ||
foreach ( $tags as $tag ) | ||
{ | ||
$priority = isset( $tag['priority'] ) ? (int)$tag['priority'] : 0; | ||
$convertersByPriority[$priority][] = new Reference( $id ); | ||
} | ||
} | ||
|
||
if ( count( $convertersByPriority ) > 0 ) | ||
{ | ||
$ezxmlInputConverterDefinition->setArguments( | ||
array( | ||
$this->sortConverters( $convertersByPriority ), | ||
) | ||
); | ||
} | ||
} | ||
|
||
/** | ||
* Transforms a two-dimensional array of converters, indexed by priority, | ||
* into a flat array of Reference objects. | ||
* | ||
* @param array $convertersByPriority | ||
* | ||
* @return \Symfony\Component\DependencyInjection\Reference[] | ||
*/ | ||
protected function sortConverters( array $convertersByPriority ) | ||
{ | ||
ksort( $convertersByPriority ); | ||
|
||
return call_user_func_array( 'array_merge', $convertersByPriority ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 19 additions & 12 deletions
31
eZ/Bundle/EzPublishCoreBundle/Resources/views/FieldType/RichText/embed/content.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,21 @@ | ||
<div class="{% if align is defined %}align-{{ align }}{% endif %}{% if class is defined %} {{ class }}{% endif %}"> | ||
{{ | ||
render( | ||
controller( | ||
"ez_content:embedContent", | ||
{ | ||
"contentId": id, | ||
"viewType": view, | ||
"params": params | ||
} | ||
{% set params = { "objectParameters": {} } %} | ||
{% if embedParams.config is defined %} | ||
{% set params = params|merge( { "objectParameters": embedParams.config } ) %} | ||
{% endif %} | ||
{% if embedParams.link is defined %} | ||
{% set params = params|merge( { "linkParameters": embedParams.link } ) %} | ||
{% endif %} | ||
<div class="{% if embedParams.align is defined %}align-{{ embedParams.align }}{% endif %}{% if embedParams.class is defined %} {{ embedParams.class }}{% endif %}"> | ||
{{ | ||
render( | ||
controller( | ||
"ez_content:embedContent", | ||
{ | ||
"contentId": embedParams.id, | ||
"viewType": embedParams.viewType, | ||
"params": params | ||
} | ||
) | ||
) | ||
) | ||
}} | ||
}} | ||
</div> |
4 changes: 2 additions & 2 deletions
4
...dle/EzPublishCoreBundle/Resources/views/FieldType/RichText/embed/content_denied.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<div class="{% if align is defined %}align-{{ align }}{% endif %}{% if class is defined %} {{ class }}{% endif %}"> | ||
Content #{{ id }}: You do not have permission to view this Content | ||
<div class="{% if embedParams.align is defined %}align-{{ embedParams.align }}{% endif %}{% if embedParams.class is defined %} {{ embedParams.class }}{% endif %}"> | ||
Content #{{ embedParams.id }}: You do not have permission to view this Content | ||
</div> |
11 changes: 9 additions & 2 deletions
11
...dle/EzPublishCoreBundle/Resources/views/FieldType/RichText/embed/content_inline.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ublishCoreBundle/Resources/views/FieldType/RichText/embed/content_inline_denied.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
[[ Content #{{ id }}: You do not have permission to view this Content ]] | ||
[[ Content #{{ embedParams.id }}: You do not have permission to view this Content ]] |
31 changes: 19 additions & 12 deletions
31
eZ/Bundle/EzPublishCoreBundle/Resources/views/FieldType/RichText/embed/location.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,21 @@ | ||
<div class="{% if align is defined %}align-{{ align }}{% endif %}{% if class is defined %} {{ class }}{% endif %}"> | ||
{{ | ||
render( | ||
controller( | ||
"ez_content:viewLocation", | ||
{ | ||
"locationId": id, | ||
"viewType": view, | ||
"params": params | ||
} | ||
{% set params = { "objectParameters": {} } %} | ||
{% if embedParams.config is defined %} | ||
{% set params = params|merge( { "objectParameters": embedParams.config } ) %} | ||
{% endif %} | ||
{% if embedParams.link is defined %} | ||
{% set params = params|merge( { "linkParameters": embedParams.link } ) %} | ||
{% endif %} | ||
<div class="{% if embedParams.align is defined %}align-{{ embedParams.align }}{% endif %}{% if embedParams.class is defined %} {{ embedParams.class }}{% endif %}"> | ||
{{ | ||
render( | ||
controller( | ||
"ez_content:viewLocation", | ||
{ | ||
"locationId": embedParams.id, | ||
"viewType": embedParams.viewType, | ||
"params": params | ||
} | ||
) | ||
) | ||
) | ||
}} | ||
}} | ||
</div> |
4 changes: 2 additions & 2 deletions
4
...le/EzPublishCoreBundle/Resources/views/FieldType/RichText/embed/location_denied.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<div class="{% if align is defined %}align-{{ align }}{% endif %}{% if class is defined %} {{ class }}{% endif %}"> | ||
Location #{{ id }}: You do not have permission to view this Location | ||
<div class="{% if embedParams.align is defined %}align-{{ embedParams.align }}{% endif %}{% if embedParams.class is defined %} {{ embedParams.class }}{% endif %}"> | ||
Location #{{ embedParams.id }}: You do not have permission to view this Location | ||
</div> |
11 changes: 9 additions & 2 deletions
11
...le/EzPublishCoreBundle/Resources/views/FieldType/RichText/embed/location_inline.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...blishCoreBundle/Resources/views/FieldType/RichText/embed/location_inline_denied.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
[[ Location #{{ id }}: You do not have permission to view this Location ]] | ||
[[ Location #{{ embedParams.id }}: You do not have permission to view this Location ]] |
62 changes: 62 additions & 0 deletions
62
eZ/Publish/Core/FieldType/RichText/Converter/Ezxml/ToRichTextPreNormalize.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
/** | ||
* File containing the eZ\Publish\Core\FieldType\RichText\Converter\Ezxml\ToRichTextPreNormalize class. | ||
* | ||
* @copyright Copyright (C) eZ Systems AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
* @version //autogentag// | ||
*/ | ||
|
||
namespace eZ\Publish\Core\FieldType\RichText\Converter\Ezxml; | ||
|
||
use eZ\Publish\Core\FieldType\XmlText\Converter\EmbedLinking; | ||
use eZ\Publish\Core\FieldType\XmlText\Converter\Expanding; | ||
use eZ\Publish\Core\FieldType\RichText\Converter; | ||
use DOMDocument; | ||
|
||
/** | ||
* Expands paragraphs and links embeds of a XML document in legacy ezxml format. | ||
* | ||
* Relies on XmlText's Expanding and EmbedLinking converters implementation. | ||
*/ | ||
class ToRichTextPreNormalize implements Converter | ||
{ | ||
/** | ||
* @var \eZ\Publish\Core\FieldType\XmlText\Converter\Expanding | ||
*/ | ||
protected $expandingConverter; | ||
|
||
/** | ||
* @var \eZ\Publish\Core\FieldType\XmlText\Converter\EmbedLinking | ||
*/ | ||
protected $embedLinkingConverter; | ||
|
||
/** | ||
* Construct from XmlText converters implementation. | ||
* | ||
* @param \eZ\Publish\Core\FieldType\XmlText\Converter\Expanding $expandingConverter | ||
* @param \eZ\Publish\Core\FieldType\XmlText\Converter\EmbedLinking $embedLinkingConverter | ||
*/ | ||
public function __construct( Expanding $expandingConverter, EmbedLinking $embedLinkingConverter ) | ||
{ | ||
$this->expandingConverter = $expandingConverter; | ||
$this->embedLinkingConverter = $embedLinkingConverter; | ||
} | ||
|
||
/** | ||
* Converts given $document into another \DOMDocument object | ||
* | ||
* @param \DOMDocument $document | ||
* | ||
* @return \DOMDocument | ||
*/ | ||
public function convert( DOMDocument $document ) | ||
{ | ||
// First | ||
$this->expandingConverter->convert( $document ); | ||
// Second | ||
$this->embedLinkingConverter->convert( $document ); | ||
|
||
return $document; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.