Skip to content

Commit adfb996

Browse files
authored
Merge pull request #37 from Gernott/2.1.0
2.1.0
2 parents 9cb7067 + ab36e1e commit adfb996

Some content is hidden

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

61 files changed

+1126
-311
lines changed

Classes/CodeGenerator/HtmlCodeGenerator.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,12 @@ protected function generateFieldHtml($fieldKey, $elementKey, $table = "tt_conten
7070
case "Check":
7171
$html .= "{f:if(condition: " . $datafield . "." . $fieldKey . ", then: 'On', else: 'Off')}<br />\n\n";
7272
break;
73-
case "Content": // TODO: Benjamin, Fluid-Vorlage für Feld "Content Verbindung":
74-
$html .= '{' . $datafield . '.' . $fieldKey . '}<br />' . "\n\n";
73+
case "Content":
74+
$html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n";
75+
$html .= "<f:for each=\"{" . $datafield . "." . $fieldKey . "}\" as=\"" . $datafield . "_item" . "\">\n";
76+
$html .= '<f:cObject typoscriptObjectPath="lib.tx_mask.content">{' . $datafield . '_item.uid}</f:cObject><br />' . "\n";
77+
$html .= "</f:for>\n";
78+
$html .= "</f:if>\n\n";
7579
break;
7680
case "Date":
7781
$html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n";

Classes/CodeGenerator/SqlCodeGenerator.php

+8-2
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ public function getSqlByConfiguration($json)
143143
$sql_content = array();
144144
$types = array_keys($json);
145145
$nonIrreTables = array("pages", "tt_content");
146+
$fieldHelper = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('MASK\\Mask\\Helper\\FieldHelper');
146147

147148
// Generate SQL-Statements
148149
if ($types) {
@@ -201,6 +202,12 @@ public function getSqlByConfiguration($json)
201202
if ($table == "pages") {
202203
$sql_content[] = "CREATE TABLE pages_language_overlay (\n\t" . $field . " " . $definition . "\n);\n";
203204
}
205+
206+
// if this field is a content field, also add parent columns
207+
$fieldType = $fieldHelper->getFormType($field, "", $table);
208+
if ($fieldType == "Content") {
209+
$sql_content[] = "CREATE TABLE tt_content (\n\t" . $field . "_parent" . " " . $definition . "\n);\n";
210+
}
204211
}
205212
}
206213
}
@@ -209,8 +216,7 @@ public function getSqlByConfiguration($json)
209216
}
210217
}
211218
}
212-
// Parentfield
213-
// $sql_content[] = "CREATE TABLE tt_content (\n\ttx_mask_content_parent int(11) unsigned NOT NULL DEFAULT '0'\n);\n";
219+
214220
return $sql_content;
215221
}
216222

Classes/CodeGenerator/TcaCodeGenerator.php

+13-1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ public function setElementsTca($tca)
9393
}
9494
if ($tca) {
9595
foreach ($tca as $elementvalue) {
96+
if (!$elementvalue["hidden"]) {
9697
$prependTabs = "--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.general;general,";
9798
$fieldArray = array();
9899
$label = $elementvalue["shortLabel"]; // Optional shortLabel
@@ -128,6 +129,7 @@ public function setElementsTca($tca)
128129
}
129130
}
130131
}
132+
}
131133

132134
/**
133135
* Generates and sets the tca for all the extended pages
@@ -260,6 +262,14 @@ public function generateFieldsTca($tca)
260262
$tcavalue[$fieldkey]["renderType"] = "t3editor";
261263
}
262264

265+
// make some adjustmens to content fields
266+
if ($fieldkey == "config" && $tcavalue[$fieldkey]["foreign_table"] == "tt_content") {
267+
$tcavalue[$fieldkey]["foreign_field"] = $tcakey . "_parent";
268+
if ($tcavalue["cTypes"]) {
269+
$tcavalue[$fieldkey]["foreign_record_defaults"]["CType"] = reset($tcavalue["cTypes"]);
270+
}
271+
}
272+
263273
// merge user inputs with file array
264274
if (!is_array($columns[$tcakey])) {
265275
$columns[$tcakey] = array();
@@ -274,6 +284,7 @@ public function generateFieldsTca($tca)
274284
unset($columns[$tcakey]["inlineParent"]);
275285
unset($columns[$tcakey]["inlineLabel"]);
276286
unset($columns[$tcakey]["inlineIcon"]);
287+
unset($columns[$tcakey]["cTypes"]);
277288

278289
$columns[$tcakey] = $generalUtility->removeBlankOptions($columns[$tcakey]);
279290
$columns[$tcakey] = $generalUtility->replaceKey($columns[$tcakey], $tcakey);
@@ -320,7 +331,8 @@ public function generateTableTca($table, $tca)
320331
),
321332
'searchFields' => '',
322333
'dynamicConfigFile' => '',
323-
'iconfile' => ''
334+
'iconfile' => '',
335+
'requestUpdate' => 'CType'
324336
),
325337
'interface' => array(
326338
'showRecordFieldList' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, ',

Classes/CodeGenerator/TyposcriptCodeGenerator.php

+18-15
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ public function generateTsConfig($json)
5353

5454
// make content-Elements
5555
if ($json["tt_content"]["elements"]) {
56-
5756
foreach ($json["tt_content"]["elements"] as $element) {
5857
// Register icons for contentelements
5958
$iconIdentifier = 'mask-ce-' . $element["key"];
@@ -62,20 +61,22 @@ public function generateTsConfig($json)
6261
'contentElementKey' => $element["key"]
6362
)
6463
);
65-
$temp = str_replace("###ICON###", "iconIdentifier = " . $iconIdentifier, $template);
66-
$temp = str_replace("###KEY###", $element["key"], $temp);
67-
$temp = str_replace("###LABEL###", $element["label"], $temp);
68-
$temp = str_replace("###DESCRIPTION###", $element["description"], $temp);
69-
$content.= $temp;
64+
if (!$element["hidden"]) {
65+
$temp = str_replace("###ICON###", "iconIdentifier = " . $iconIdentifier, $template);
66+
$temp = str_replace("###KEY###", $element["key"], $temp);
67+
$temp = str_replace("###LABEL###", $element["label"], $temp);
68+
$temp = str_replace("###DESCRIPTION###", $element["description"], $temp);
69+
$content.= $temp;
7070

71-
// Labels
72-
$content .= "\n[userFunc = user_mask_contentType(CType|mask_" . $element["key"] . ")]\n";
73-
if ($element["columns"]) {
74-
foreach ($element["columns"] as $index => $column) {
75-
$content .= " TCEFORM.tt_content." . $column . ".label = " . $element["labels"][$index] . "\n";
71+
// Labels
72+
$content .= "\n[userFunc = user_mask_contentType(CType|mask_" . $element["key"] . ")]\n";
73+
if ($element["columns"]) {
74+
foreach ($element["columns"] as $index => $column) {
75+
$content .= " TCEFORM.tt_content." . $column . ".label = " . $element["labels"][$index] . "\n";
76+
}
7677
}
78+
$content .= "[end]\n\n";
7779
}
78-
$content .= "[end]\n\n";
7980
}
8081
}
8182
return $content;
@@ -162,9 +163,11 @@ classes {
162163
// Fill setup.ts:
163164
if ($configuration["tt_content"]["elements"]) {
164165
foreach ($configuration["tt_content"]["elements"] as $element) {
165-
$temp = str_replace("###KEY###", $element["key"], $template);
166-
$temp = str_replace("###PATH###", $settings['content'] . $element["key"] . '.html', $temp);
167-
$setupContent.= $temp;
166+
if (!$element["hidden"]) {
167+
$temp = str_replace("###KEY###", $element["key"], $template);
168+
$temp = str_replace("###PATH###", $settings['content'] . $element["key"] . '.html', $temp);
169+
$setupContent.= $temp;
170+
}
168171
}
169172
}
170173
return $setupContent;

Classes/Controller/FrontendController.php

+37
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
/**
66
* FrontendController
77
*/
8+
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
9+
use TYPO3\CMS\Core\Utility\GeneralUtility;
810

911
/**
1012
*
@@ -32,13 +34,48 @@ class FrontendController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControl
3234
*/
3335
protected $inlineHelper;
3436

37+
/**
38+
* settingsService
39+
*
40+
* @var \MASK\Mask\Domain\Service\SettingsService
41+
* @inject
42+
*/
43+
protected $settingsService;
44+
45+
/**
46+
* extension settings
47+
* @var array
48+
*/
49+
protected $extSettings;
50+
3551
/**
3652
* Displays the content in the frontend
3753
*
3854
* @return void
3955
*/
4056
public function contentelementAction()
4157
{
58+
// load extension settings
59+
$this->extSettings = $this->settingsService->get();
60+
61+
// get framework configuration
62+
$extbaseFrameworkConfiguration = $this->configurationManager->getConfiguration(
63+
ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK
64+
);
65+
66+
// if there are paths for layouts and partials set, add them to view
67+
if (!empty($this->extSettings["layouts"])) {
68+
$viewLayoutRootPaths = $this->getViewProperty($extbaseFrameworkConfiguration, 'layoutRootPaths');
69+
$extSettingsLayoutRootPath = GeneralUtility::getFileAbsFileName($this->extSettings["layouts"]);
70+
71+
$this->view->setLayoutRootPaths(array_replace($viewLayoutRootPaths, [$extSettingsLayoutRootPath]));
72+
}
73+
if (!empty($this->extSettings["partials"])) {
74+
$viewPartialRootPaths = $this->getViewProperty($extbaseFrameworkConfiguration, 'partialRootPaths');
75+
$extSettingsPartialRootPath = GeneralUtility::getFileAbsFileName($this->extSettings["partials"]);
76+
77+
$this->view->setPartialRootPaths(array_replace($viewPartialRootPaths, [$extSettingsPartialRootPath]));
78+
}
4279
$this->view->setTemplatePathAndFilename($this->settings["file"]);
4380
$data = $this->configurationManager->getContentObject()->data;
4481
$this->inlineHelper->addFilesToData($data, "tt_content");

Classes/Controller/WizardContentController.php

+61
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,65 @@ public function deleteAction($key, $type)
145145
$this->addFlashMessage(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('tx_mask.content.deletedcontentelement', 'mask'));
146146
$this->redirect('list');
147147
}
148+
149+
/**
150+
* action purge
151+
*
152+
* @param string $key
153+
* @param string $type
154+
* @return void
155+
*/
156+
public function purgeAction($key, $type)
157+
{
158+
$this->deleteHtml($key);
159+
$this->storageRepository->remove($type, $key);
160+
$this->generateAction();
161+
$this->addFlashMessage(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('tx_mask.content.deletedcontentelement', 'mask'));
162+
$this->redirect('list');
163+
}
164+
165+
/**
166+
* action hide
167+
*
168+
* @param string $key
169+
* @return void
170+
*/
171+
public function hideAction($key)
172+
{
173+
$this->storageRepository->hide("tt_content", $key);
174+
$this->generateAction();
175+
$this->addFlashMessage(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('tx_mask.content.hiddencontentelement', 'mask'));
176+
$this->redirect('list');
177+
}
178+
179+
/**
180+
* action activate
181+
*
182+
* @param string $key
183+
* @return void
184+
*/
185+
public function activateAction($key)
186+
{
187+
$this->storageRepository->activate("tt_content", $key);
188+
$this->generateAction();
189+
$this->addFlashMessage(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('tx_mask.content.activatedcontentelement', 'mask'));
190+
$this->redirect('list');
191+
}
192+
193+
/**
194+
* Deletes Fluid html, if file exists
195+
*
196+
* @param string $key
197+
* @param string $html
198+
* @author Benjamin Butschell <[email protected]>
199+
*/
200+
protected function deleteHtml($key)
201+
{
202+
if (file_exists(PATH_site . $this->extSettings["content"] . $key . ".html")) {
203+
unlink(PATH_site . $this->extSettings["content"] . $key . ".html");
204+
}
205+
if (file_exists(PATH_site . $this->extSettings["backend"] . $key . ".html")) {
206+
unlink(PATH_site . $this->extSettings["backend"] . $key . ".html");
207+
}
208+
}
148209
}

Classes/Domain/Model/Content.php

+19-2
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,25 @@ class Content extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
6666
*/
6767
protected $fieldkey;
6868

69+
/**
70+
* contentType
71+
*
72+
* @var \string
73+
* @validate NotEmpty
74+
*/
75+
protected $contentType;
76+
77+
public function getContentType()
78+
{
79+
return $this->contentType;
80+
}
81+
82+
public function setContentType(\string $contentType)
83+
{
84+
$this->contentType = $contentType;
85+
return $this;
86+
}
87+
6988
/**
7089
* Returns the title
7190
*
@@ -150,5 +169,3 @@ public function setFieldkey($fieldkey)
150169
$this->fieldkey = $fieldkey;
151170
}
152171
}
153-
154-
?>

Classes/Domain/Repository/ContentRepository.php

+9
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,13 @@
3636
class ContentRepository extends \TYPO3\CMS\Extbase\Persistence\Repository
3737
{
3838

39+
public function initializeObject()
40+
{
41+
/** @var $querySettings TYPO3CMSExtbasePersistenceGenericTypo3QuerySettings */
42+
$querySettings = $this->objectManager->get('TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings');
43+
$querySettings->setRespectStoragePage(FALSE);
44+
$querySettings->setIgnoreEnableFields(FALSE);
45+
$querySettings->setIncludeDeleted(FALSE);
46+
$this->setDefaultQuerySettings($querySettings);
47+
}
3948
}

0 commit comments

Comments
 (0)