Skip to content
This repository was archived by the owner on Oct 9, 2019. It is now read-only.

Commit 522299e

Browse files
committed
Preparing for Version 2
1 parent cda43e4 commit 522299e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+3003
-0
lines changed

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.idea/
2+
.sass-cache/
3+
.tmp/
4+
node_modules/
5+
vendor/
6+
composer.phar
7+
composer.lock
8+
grunt.lock
9+
phpunit.phar
10+
.php_cs.cache
11+

.idea/CjwMultiSiteBundle.iml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/encodings.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CjwMultiSiteBundle.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
/**
3+
* File containing the CjwMultiSiteBundle class.
4+
*
5+
* @copyright Copyright (C) 2007-2014 CJW Network - Coolscreen.de, JAC Systeme GmbH, Webmanufaktur. All rights reserved.
6+
* @license http://ez.no/licenses/gnu_gpl GNU GPL v2
7+
* @version //autogentag//
8+
* @filesource
9+
*/
10+
11+
namespace Cjw\MultiSiteBundle;
12+
13+
use Symfony\Component\HttpKernel\Bundle\Bundle;
14+
15+
class CjwMultiSiteBundle extends Bundle
16+
{
17+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace Cjw\MultiSiteBundle\DependencyInjection;
4+
5+
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
6+
use Symfony\Component\DependencyInjection\ContainerBuilder;
7+
use Symfony\Component\DependencyInjection\Loader;
8+
use Symfony\Component\Config\FileLocator;
9+
10+
/**
11+
* This is the class that loads and manages your bundle configuration.
12+
*
13+
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
14+
*/
15+
class CjwMultiSiteExtension extends Extension
16+
{
17+
/**
18+
* {@inheritdoc}
19+
*/
20+
public function load(array $configs, ContainerBuilder $container)
21+
{
22+
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
23+
$loader->load('services.yml');
24+
}
25+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
/**
3+
* File containing the ConfigResolver class.
4+
*
5+
* @copyright Copyright (C) 1999-2013 eZ Systems AS. All rights reserved.
6+
* @license http://ez.no/licenses/gnu_gpl GNU General Public License v2.0
7+
* @version
8+
*/
9+
10+
namespace Cjw\MultiSiteBundle\DependencyInjection\Configuration;
11+
12+
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\ConfigResolver;
13+
use eZ\Publish\Core\MVC\Symfony\SiteAccess;
14+
15+
class CjwConfigResolver extends ConfigResolver
16+
{
17+
/**
18+
* Returns value for $paramName, in $namespace.
19+
*
20+
* @param string $paramName The parameter name, without $prefix and the current scope (i.e. siteaccess name).
21+
* @param string $namespace Namespace for the parameter name. If null, the default namespace will be used.
22+
* @param string $scope The scope you need $paramName value for. It's typically the siteaccess name.
23+
* If null, the current siteaccess name will be used.
24+
*
25+
* @throws \eZ\Publish\Core\MVC\Exception\ParameterNotFoundException
26+
*
27+
* @return mixed
28+
*/
29+
public function getParameter($paramName, $namespace = null, $scope = null)
30+
{
31+
$value = parent::getParameter($paramName, $namespace, $scope);
32+
33+
if ($paramName == 'fieldtypes.ezxml.custom_xsl') {
34+
echo $paramName;
35+
}
36+
37+
return $value;
38+
}
39+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
/**
3+
* This file is part of the eZ Platform XmlText Field Type package.
4+
*
5+
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
6+
* @license For full copyright and license information view LICENSE file distributed with this source code.
7+
*
8+
* @version //autogentag//
9+
*/
10+
11+
namespace Cjw\MultiSiteBundle\FieldType\XmlText\Converter;
12+
13+
use DOMDocument;
14+
use eZ\Publish\Core\FieldType\XmlText\Converter\EmbedToHtml5 as BaseEmbedToHtml5;
15+
16+
class EmbedToHtml5 extends BaseEmbedToHtml5
17+
{
18+
protected function processTag(DOMDocument $xmlDoc, $tagName)
19+
{
20+
// <embed view="embed" size="medium" href="ezobject://99" />
21+
// q&d fix for embed problems in site_khf
22+
// if ($xmlDoc->textContent != '') {
23+
// parent::processTag($xmlDoc, $tagName);
24+
// }
25+
parent::processTag($xmlDoc, $tagName);
26+
}
27+
}
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
<?php
2+
/**
3+
* File containing the eZ\Publish\Core\FieldType\XmlText\Converter\EzLinkToHtml5 class.
4+
*
5+
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
6+
* @license For full copyright and license information view LICENSE file distributed with this source code.
7+
* @version //autogentag//
8+
*/
9+
10+
namespace Cjw\MultiSiteBundle\FieldType\XmlText\Converter;
11+
12+
use eZ\Publish\API\Repository\ContentService;
13+
use eZ\Publish\API\Repository\LocationService;
14+
use eZ\Publish\Core\FieldType\XmlText\Converter;
15+
use Psr\Log\LoggerInterface;
16+
use eZ\Publish\API\Repository\Exceptions\NotFoundException as APINotFoundException;
17+
use eZ\Publish\API\Repository\Exceptions\UnauthorizedException as APIUnauthorizedException;
18+
use DOMDocument;
19+
use Cjw\MultiSiteBundle\Routing\CrossDomainRouter;
20+
21+
class EzLinkToHtml5 implements Converter
22+
{
23+
/**
24+
* @var \eZ\Publish\API\Repository\LocationService
25+
*/
26+
protected $locationService;
27+
28+
/**
29+
* @var \eZ\Publish\API\Repository\ContentService
30+
*/
31+
protected $contentService;
32+
33+
/**
34+
* @var CrossDomainRouter
35+
*/
36+
protected $urlAliasRouter;
37+
38+
/**
39+
* @var \Psr\Log\LoggerInterface
40+
*/
41+
protected $logger;
42+
43+
public function __construct(LocationService $locationService, ContentService $contentService, CrossDomainRouter $urlAliasRouter, LoggerInterface $logger = null)
44+
{
45+
$this->locationService = $locationService;
46+
$this->contentService = $contentService;
47+
$this->urlAliasRouter = $urlAliasRouter;
48+
$this->logger = $logger;
49+
}
50+
51+
/**
52+
* Converts internal links (eznode:// and ezobject://) to URLs.
53+
*
54+
* @param \DOMDocument $xmlDoc
55+
*
56+
* @return string|null
57+
*/
58+
public function convert(DOMDocument $xmlDoc)
59+
{
60+
foreach ($xmlDoc->getElementsByTagName('link') as $link) {
61+
$location = null;
62+
63+
if ($link->hasAttribute('object_id')) {
64+
try {
65+
$contentInfo = $this->contentService->loadContentInfo($link->getAttribute('object_id'));
66+
$location = $this->locationService->loadLocation($contentInfo->mainLocationId);
67+
} catch (APINotFoundException $e) {
68+
if ($this->logger) {
69+
$this->logger->warning(
70+
'While generating links for xmltext, could not locate ' .
71+
'Content object with ID ' . $link->getAttribute('object_id')
72+
);
73+
}
74+
} catch (APIUnauthorizedException $e) {
75+
if ($this->logger) {
76+
$this->logger->notice(
77+
'While generating links for xmltext, unauthorized to load ' .
78+
'Content object with ID ' . $link->getAttribute('object_id')
79+
);
80+
}
81+
}
82+
}
83+
84+
if ($link->hasAttribute('node_id')) {
85+
try {
86+
$location = $this->locationService->loadLocation($link->getAttribute('node_id'));
87+
} catch (APINotFoundException $e) {
88+
if ($this->logger) {
89+
$this->logger->warning(
90+
'While generating links for xmltext, could not locate ' .
91+
'Location with ID ' . $link->getAttribute('node_id')
92+
);
93+
}
94+
} catch (APIUnauthorizedException $e) {
95+
if ($this->logger) {
96+
$this->logger->notice(
97+
'While generating links for xmltext, unauthorized to load ' .
98+
'Location with ID ' . $link->getAttribute('node_id')
99+
);
100+
}
101+
}
102+
}
103+
104+
if ($location !== null) {
105+
$link->setAttribute('url', $this->urlAliasRouter->generate($location));
106+
}
107+
108+
if ($link->hasAttribute('anchor_name')) {
109+
$link->setAttribute('url', $link->getAttribute('url') . '#' . $link->getAttribute('anchor_name'));
110+
}
111+
}
112+
}
113+
}

FieldType/XmlText/Converter/Html5.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
/**
3+
* File containing the Html5 class.
4+
*
5+
* @copyright Copyright (C) 1999-2013 eZ Systems AS. All rights reserved.
6+
* @license http://ez.no/licenses/gnu_gpl GNU General Public License v2.0
7+
* @version
8+
*/
9+
10+
namespace Cjw\MultiSiteBundle\FieldType\XmlText\Converter;
11+
12+
use eZ\Publish\Core\FieldType\XmlText\Converter\Html5 as BaseHtml5Converter;
13+
14+
/**
15+
* Adds ConfigResolver awareness to the original Html5 converter.
16+
*
17+
* Fixing a bug in eZ\Bundle\EzPublishCoreBundle\FieldType\XmlText\Converter\Html5
18+
* by overiding the class and fixing the rootDir of default value for 'fieldtypes.ezxml.custom_xsl'
19+
*
20+
* @see original ezclass eZ\Bundle\EzPublishCoreBundle\FieldType\XmlText\Converter\Html5
21+
*/
22+
class Html5 extends BaseHtml5Converter
23+
{
24+
public function __construct($stylesheet, array $customStylesheets = array(), array $preConverters = array())
25+
{
26+
// patch start
27+
for ($i = 0; $i < count($customStylesheets); ++$i) {
28+
$customStylesheets[$i]['path'] = str_replace('app/../vendor', 'app/../../../../vendor', $customStylesheets[$i]['path']);
29+
}
30+
//patch ends
31+
32+
$customStylesheets = $customStylesheets ?: array();
33+
parent::__construct($stylesheet, $customStylesheets, $preConverters);
34+
}
35+
36+
public function setCustomStylesheets($customStylesheets)
37+
{
38+
$this->customStylesheets = [];
39+
if (!$customStylesheets) {
40+
return;
41+
}
42+
// patch start
43+
for ($i = 0; $i < count($customStylesheets); ++$i) {
44+
$customStylesheets[$i]['path'] = str_replace('app/../vendor', 'app/../../../../vendor', $customStylesheets[$i]['path']);
45+
}
46+
// patch ends
47+
foreach ($customStylesheets as $stylesheet) {
48+
if (!isset($this->customStylesheets[$stylesheet['priority']])) {
49+
$this->customStylesheets[$stylesheet['priority']] = array();
50+
}
51+
52+
$this->customStylesheets[$stylesheet['priority']][] = $stylesheet['path'];
53+
}
54+
}
55+
}

INSTALL.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# CjwMultiSiteBundle Installation
2+
3+
see [Resources/doc/installation.md](Resources/doc/installation.md)

0 commit comments

Comments
 (0)