Skip to content

Commit d2d787c

Browse files
committed
initial commit
0 parents  commit d2d787c

File tree

11 files changed

+460
-0
lines changed

11 files changed

+460
-0
lines changed

.php-cs-fixer.dist.php

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
$date = date('Y');
4+
5+
$header = <<<EOF
6+
Contact Element for Contao Open Source CMS.
7+
8+
@copyright Copyright (c) $date, Erdmann & Freunde
9+
@author Erdmann & Freunde <https://erdmann-freunde.de>
10+
@license MIT
11+
@link http://github.com/nutshell-framework/contact-element
12+
EOF;
13+
14+
15+
$finder = PhpCsFixer\Finder::create()
16+
->in(__DIR__)
17+
;
18+
19+
$config = new PhpCsFixer\Config();
20+
return $config->setRules([
21+
'@Symfony' => true,
22+
'@Symfony:risky' => true,
23+
'@PHPUnit60Migration:risky' => true,
24+
'align_multiline_comment' => true,
25+
'array_indentation' => true,
26+
'array_syntax' => ['syntax' => 'short'],
27+
'combine_consecutive_issets' => true,
28+
'combine_consecutive_unsets' => true,
29+
'comment_to_phpdoc' => true,
30+
'compact_nullable_typehint' => true,
31+
'declare_strict_types' => true,
32+
'header_comment' => ['header' => $header],
33+
'heredoc_to_nowdoc' => true,
34+
'linebreak_after_opening_tag' => true,
35+
'native_function_invocation' => [
36+
'include' => ['@compiler_optimized'],
37+
],
38+
'no_null_property_initialization' => true,
39+
'no_superfluous_elseif' => true,
40+
'no_unreachable_default_argument_value' => true,
41+
'no_useless_else' => true,
42+
'no_useless_return' => true,
43+
'ordered_class_elements' => true,
44+
'ordered_imports' => true,
45+
'php_unit_strict' => true,
46+
'phpdoc_add_missing_param_annotation' => true,
47+
'phpdoc_order' => true,
48+
'phpdoc_types_order' => [
49+
'null_adjustment' => 'always_last',
50+
'sort_algorithm' => 'none',
51+
],
52+
'strict_comparison' => true,
53+
'strict_param' => true,
54+
])
55+
->setFinder(PhpCsFixer\Finder::create()->in([__DIR__.'/src']))
56+
->setRiskyAllowed(true)
57+
->setUsingCache(false)
58+
;

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Erdmann & Freunde Kontakt-Erweiterung für Contao
2+
3+
Diese Erweiterung stellt ein neues Inhaltselement „Kontakt“ zur Verfügung. Im Kontakt-Element können Überschrift, Name, Position, e-Mail, Beschreibung und Bild eines Kontaktes hinterlegt werden.

composer.json

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name": "nutshell-framework/contact-element",
3+
"description": "Contao Extension for a Contact Content Element",
4+
"keywords": [
5+
"contao",
6+
"contact",
7+
"euf contact"
8+
],
9+
"type": "contao-module",
10+
"homepage": "https://github.com/nutshell-framework/contact-element",
11+
"license": "GPL-3.0+",
12+
"authors": [
13+
{
14+
"name": "Erdmann & Freunde - Dennis Erdmann",
15+
"homepage": "https://erdmann-freunde.de",
16+
"role": "Developer"
17+
}
18+
],
19+
"support": {
20+
"email": "[email protected]",
21+
"issues": "https://github.com/nutshell-framework/contact-element/issues",
22+
"source": "https://github.com/nutshell-framework/contact-element"
23+
},
24+
"require": {
25+
"php": ">=5.6",
26+
"contao/core-bundle": "~4.1",
27+
"symfony/http-kernel": "^3.3 || ^4.0"
28+
},
29+
"require-dev": {
30+
"contao/manager-plugin": "^2.2"
31+
},
32+
"autoload": {
33+
"psr-4": {
34+
"Nutshell\\ContactElement\\": "src/"
35+
}
36+
},
37+
"extra": {
38+
"contao-manager-plugin": "Nutshell\\ContactElement\\ContaoManager\\Plugin"
39+
}
40+
}

src/ContaoManager/Plugin.php

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* Contact Element for Contao Open Source CMS.
7+
*
8+
* @copyright Copyright (c) 2021, Erdmann & Freunde
9+
* @author Erdmann & Freunde <https://erdmann-freunde.de>
10+
* @license MIT
11+
* @link http://github.com/nutshell-framework/contact-element
12+
*/
13+
14+
namespace Nutshell\ContactElement\ContaoManager;
15+
16+
use Contao\CoreBundle\ContaoCoreBundle;
17+
use Contao\ManagerPlugin\Bundle\BundlePluginInterface;
18+
use Contao\ManagerPlugin\Bundle\Config\BundleConfig;
19+
use Contao\ManagerPlugin\Bundle\Parser\ParserInterface;
20+
use Nutshell\ContactElement\NutshellContactElement;
21+
22+
/**
23+
* Contao Manager plugin.
24+
*/
25+
class Plugin implements BundlePluginInterface
26+
{
27+
/**
28+
* {@inheritdoc}
29+
*/
30+
public function getBundles(ParserInterface $parser)
31+
{
32+
return [
33+
BundleConfig::create(NutshellContactElement::class)
34+
->setLoadAfter(
35+
[
36+
ContaoCoreBundle::class,
37+
]
38+
),
39+
];
40+
}
41+
}

src/Content/Contact.php

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* Contact Element for Contao Open Source CMS.
7+
*
8+
* @copyright Copyright (c) 2021, Erdmann & Freunde
9+
* @author Erdmann & Freunde <https://erdmann-freunde.de>
10+
* @license MIT
11+
* @link http://github.com/nutshell-framework/contact-element
12+
*/
13+
14+
namespace Nutshell\ContactElement\Content;
15+
16+
use Contao\Config;
17+
use Contao\ContentElement;
18+
use Contao\FilesModel;
19+
use Contao\StringUtil;
20+
21+
class Contact extends ContentElement
22+
{
23+
/**
24+
* Template.
25+
*
26+
* @var string
27+
*/
28+
protected $strTemplate = 'ce_contact';
29+
30+
/**
31+
* Generate the content element.
32+
*/
33+
protected function compile(): void
34+
{
35+
// Clean the RTE output
36+
$this->text = StringUtil::toHtml5($this->text);
37+
38+
// Add the static files URL to images
39+
if (TL_FILES_URL) {
40+
$path = Config::get('uploadPath').'/';
41+
42+
$this->text = str_replace(' src="'.$path, ' src="'.TL_FILES_URL.$path, $this->text);
43+
}
44+
45+
$this->Template->text = StringUtil::encodeEmail($this->text);
46+
$this->Template->addContactImage = false;
47+
48+
// Add an image
49+
if ($this->addContactImage && $this->singleSRC) {
50+
$objModel = FilesModel::findByUuid($this->singleSRC);
51+
52+
if (null !== $objModel && is_file(TL_ROOT.'/'.$objModel->path)) {
53+
$this->singleSRC = $objModel->path;
54+
$this->overwriteMeta = ($this->alt || $this->imageTitle || $this->caption);
55+
$this->addImageToTemplate($this->Template, $this->arrData, null, null, $objModel);
56+
}
57+
58+
$this->Template->addContactImage = true;
59+
}
60+
61+
// Encode contact email
62+
$this->Template->contactEmail = StringUtil::encodeEmail($this->contactEmail);
63+
64+
// Add contact email link
65+
$this->Template->contactEmailLink = '&#109;&#97;&#105;&#108;&#116;&#111;&#58;'.StringUtil::encodeEmail($this->contactEmail);
66+
}
67+
}

src/NutshellContactElement.php

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* Contact Element for Contao Open Source CMS.
7+
*
8+
* @copyright Copyright (c) 2021, Erdmann & Freunde
9+
* @author Erdmann & Freunde <https://erdmann-freunde.de>
10+
* @license MIT
11+
* @link http://github.com/nutshell-framework/contact-element
12+
*/
13+
14+
namespace Nutshell\ContactElement;
15+
16+
use Symfony\Component\HttpKernel\Bundle\Bundle;
17+
18+
/**
19+
* The Bundle class.
20+
*/
21+
class NutshellContactElement extends Bundle
22+
{
23+
}
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* Contact Element for Contao Open Source CMS.
7+
*
8+
* @copyright Copyright (c) 2021, Erdmann & Freunde
9+
* @author Erdmann & Freunde <https://erdmann-freunde.de>
10+
* @license MIT
11+
* @link http://github.com/nutshell-framework/contact-element
12+
*/
13+
14+
use Nutshell\ContactElement\Content\Contact;
15+
16+
/*
17+
* EuF Hero ContentElement
18+
*/
19+
array_insert(
20+
$GLOBALS['TL_CTE']['media'],
21+
4,
22+
[
23+
'contact' => Contact::class,
24+
]
25+
);
+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* Contact Element for Contao Open Source CMS.
7+
*
8+
* @copyright Copyright (c) 2021, Erdmann & Freunde
9+
* @author Erdmann & Freunde <https://erdmann-freunde.de>
10+
* @license MIT
11+
* @link http://github.com/nutshell-framework/contact-element
12+
*/
13+
14+
/*
15+
* Palettes
16+
*/
17+
18+
$GLOBALS['TL_DCA']['tl_content']['palettes']['__selector__'][] = 'addContactImage';
19+
20+
$GLOBALS['TL_DCA']['tl_content']['palettes']['contact'] =
21+
'{type_legend},type,headline;'
22+
.'{text_legend},contactName,contactPosition,contactEmail,contactPhone,contactDescription;'
23+
.'{image_legend},addContactImage;'
24+
.'{template_legend:hide},customTpl;'
25+
.'{protected_legend:hide},protected;'
26+
.'{expert_legend:hide},guests,cssID,space;'
27+
.'{invisible_legend:hide},invisible,start,stop';
28+
29+
/*
30+
* Subpalettes
31+
*/
32+
$GLOBALS['TL_DCA']['tl_content']['subpalettes']['addContactImage'] = 'singleSRC,size,alt,imageTitle,caption';
33+
34+
/*
35+
* Fields
36+
*/
37+
38+
// name
39+
$GLOBALS['TL_DCA']['tl_content']['fields']['contactName'] = [
40+
'exclude' => true,
41+
'search' => true,
42+
'flag' => 1,
43+
'inputType' => 'text',
44+
'eval' => [
45+
'maxlength' => 255,
46+
'tl_class' => 'w50',
47+
],
48+
'sql' => "varchar(255) NOT NULL default ''",
49+
];
50+
51+
// position
52+
$GLOBALS['TL_DCA']['tl_content']['fields']['contactPosition'] = [
53+
'exclude' => true,
54+
'search' => true,
55+
'flag' => 1,
56+
'inputType' => 'text',
57+
'eval' => [
58+
'maxlength' => 255,
59+
'tl_class' => 'w50',
60+
],
61+
'sql' => "varchar(255) NOT NULL default ''",
62+
];
63+
64+
// position
65+
$GLOBALS['TL_DCA']['tl_content']['fields']['contactEmail'] = [
66+
'exclude' => true,
67+
'search' => true,
68+
'inputType' => 'text',
69+
'eval' => [
70+
'maxlength' => 255,
71+
'rgxp' => 'email',
72+
'decodeEntities' => true,
73+
'tl_class' => 'w50',
74+
],
75+
'sql' => "varchar(255) NOT NULL default ''",
76+
];
77+
78+
$GLOBALS['TL_DCA']['tl_content']['fields']['contactPhone'] = [
79+
'exclude' => true,
80+
'search' => true,
81+
'flag' => 1,
82+
'inputType' => 'text',
83+
'eval' => [
84+
'maxlength' => 255,
85+
'tl_class' => 'w50',
86+
],
87+
'sql' => "varchar(255) NOT NULL default ''",
88+
];
89+
90+
// description
91+
$GLOBALS['TL_DCA']['tl_content']['fields']['contactDescription'] = [
92+
'exclude' => true,
93+
'search' => true,
94+
'inputType' => 'textarea',
95+
'eval' => [
96+
'rte' => 'tinyMCE',
97+
'tl_class' => 'clr',
98+
],
99+
'sql' => 'mediumtext NULL',
100+
];
101+
102+
$GLOBALS['TL_DCA']['tl_content']['fields']['addContactImage'] = [
103+
'label' => &$GLOBALS['TL_LANG']['tl_content']['addContactImage'],
104+
'exclude' => true,
105+
'inputType' => 'checkbox',
106+
'eval' => [
107+
'submitOnChange' => true,
108+
],
109+
'sql' => "char(1) NOT NULL default ''",
110+
];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* Contact Element for Contao Open Source CMS.
7+
*
8+
* @copyright Copyright (c) 2021, Erdmann & Freunde
9+
* @author Erdmann & Freunde <https://erdmann-freunde.de>
10+
* @license MIT
11+
* @link http://github.com/nutshell-framework/contact-element
12+
*/
13+
14+
/*
15+
* Elemente
16+
*/
17+
$GLOBALS['TL_LANG']['CTE']['contact'][0] = 'Kontakt';

0 commit comments

Comments
 (0)