Skip to content

Commit

Permalink
Merge pull request #37 from Gernott/2.1.0
Browse files Browse the repository at this point in the history
2.1.0
  • Loading branch information
butu authored Aug 12, 2016
2 parents 9cb7067 + ab36e1e commit adfb996
Show file tree
Hide file tree
Showing 61 changed files with 1,126 additions and 311 deletions.
8 changes: 6 additions & 2 deletions Classes/CodeGenerator/HtmlCodeGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,12 @@ protected function generateFieldHtml($fieldKey, $elementKey, $table = "tt_conten
case "Check":
$html .= "{f:if(condition: " . $datafield . "." . $fieldKey . ", then: 'On', else: 'Off')}<br />\n\n";
break;
case "Content": // TODO: Benjamin, Fluid-Vorlage für Feld "Content Verbindung":
$html .= '{' . $datafield . '.' . $fieldKey . '}<br />' . "\n\n";
case "Content":
$html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n";
$html .= "<f:for each=\"{" . $datafield . "." . $fieldKey . "}\" as=\"" . $datafield . "_item" . "\">\n";
$html .= '<f:cObject typoscriptObjectPath="lib.tx_mask.content">{' . $datafield . '_item.uid}</f:cObject><br />' . "\n";
$html .= "</f:for>\n";
$html .= "</f:if>\n\n";
break;
case "Date":
$html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n";
Expand Down
10 changes: 8 additions & 2 deletions Classes/CodeGenerator/SqlCodeGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ public function getSqlByConfiguration($json)
$sql_content = array();
$types = array_keys($json);
$nonIrreTables = array("pages", "tt_content");
$fieldHelper = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('MASK\\Mask\\Helper\\FieldHelper');

// Generate SQL-Statements
if ($types) {
Expand Down Expand Up @@ -201,6 +202,12 @@ public function getSqlByConfiguration($json)
if ($table == "pages") {
$sql_content[] = "CREATE TABLE pages_language_overlay (\n\t" . $field . " " . $definition . "\n);\n";
}

// if this field is a content field, also add parent columns
$fieldType = $fieldHelper->getFormType($field, "", $table);
if ($fieldType == "Content") {
$sql_content[] = "CREATE TABLE tt_content (\n\t" . $field . "_parent" . " " . $definition . "\n);\n";
}
}
}
}
Expand All @@ -209,8 +216,7 @@ public function getSqlByConfiguration($json)
}
}
}
// Parentfield
// $sql_content[] = "CREATE TABLE tt_content (\n\ttx_mask_content_parent int(11) unsigned NOT NULL DEFAULT '0'\n);\n";

return $sql_content;
}

Expand Down
14 changes: 13 additions & 1 deletion Classes/CodeGenerator/TcaCodeGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public function setElementsTca($tca)
}
if ($tca) {
foreach ($tca as $elementvalue) {
if (!$elementvalue["hidden"]) {
$prependTabs = "--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.general;general,";
$fieldArray = array();
$label = $elementvalue["shortLabel"]; // Optional shortLabel
Expand Down Expand Up @@ -128,6 +129,7 @@ public function setElementsTca($tca)
}
}
}
}

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

// make some adjustmens to content fields
if ($fieldkey == "config" && $tcavalue[$fieldkey]["foreign_table"] == "tt_content") {
$tcavalue[$fieldkey]["foreign_field"] = $tcakey . "_parent";
if ($tcavalue["cTypes"]) {
$tcavalue[$fieldkey]["foreign_record_defaults"]["CType"] = reset($tcavalue["cTypes"]);
}
}

// merge user inputs with file array
if (!is_array($columns[$tcakey])) {
$columns[$tcakey] = array();
Expand All @@ -274,6 +284,7 @@ public function generateFieldsTca($tca)
unset($columns[$tcakey]["inlineParent"]);
unset($columns[$tcakey]["inlineLabel"]);
unset($columns[$tcakey]["inlineIcon"]);
unset($columns[$tcakey]["cTypes"]);

$columns[$tcakey] = $generalUtility->removeBlankOptions($columns[$tcakey]);
$columns[$tcakey] = $generalUtility->replaceKey($columns[$tcakey], $tcakey);
Expand Down Expand Up @@ -320,7 +331,8 @@ public function generateTableTca($table, $tca)
),
'searchFields' => '',
'dynamicConfigFile' => '',
'iconfile' => ''
'iconfile' => '',
'requestUpdate' => 'CType'
),
'interface' => array(
'showRecordFieldList' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, ',
Expand Down
33 changes: 18 additions & 15 deletions Classes/CodeGenerator/TyposcriptCodeGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public function generateTsConfig($json)

// make content-Elements
if ($json["tt_content"]["elements"]) {

foreach ($json["tt_content"]["elements"] as $element) {
// Register icons for contentelements
$iconIdentifier = 'mask-ce-' . $element["key"];
Expand All @@ -62,20 +61,22 @@ public function generateTsConfig($json)
'contentElementKey' => $element["key"]
)
);
$temp = str_replace("###ICON###", "iconIdentifier = " . $iconIdentifier, $template);
$temp = str_replace("###KEY###", $element["key"], $temp);
$temp = str_replace("###LABEL###", $element["label"], $temp);
$temp = str_replace("###DESCRIPTION###", $element["description"], $temp);
$content.= $temp;
if (!$element["hidden"]) {
$temp = str_replace("###ICON###", "iconIdentifier = " . $iconIdentifier, $template);
$temp = str_replace("###KEY###", $element["key"], $temp);
$temp = str_replace("###LABEL###", $element["label"], $temp);
$temp = str_replace("###DESCRIPTION###", $element["description"], $temp);
$content.= $temp;

// Labels
$content .= "\n[userFunc = user_mask_contentType(CType|mask_" . $element["key"] . ")]\n";
if ($element["columns"]) {
foreach ($element["columns"] as $index => $column) {
$content .= " TCEFORM.tt_content." . $column . ".label = " . $element["labels"][$index] . "\n";
// Labels
$content .= "\n[userFunc = user_mask_contentType(CType|mask_" . $element["key"] . ")]\n";
if ($element["columns"]) {
foreach ($element["columns"] as $index => $column) {
$content .= " TCEFORM.tt_content." . $column . ".label = " . $element["labels"][$index] . "\n";
}
}
$content .= "[end]\n\n";
}
$content .= "[end]\n\n";
}
}
return $content;
Expand Down Expand Up @@ -162,9 +163,11 @@ classes {
// Fill setup.ts:
if ($configuration["tt_content"]["elements"]) {
foreach ($configuration["tt_content"]["elements"] as $element) {
$temp = str_replace("###KEY###", $element["key"], $template);
$temp = str_replace("###PATH###", $settings['content'] . $element["key"] . '.html', $temp);
$setupContent.= $temp;
if (!$element["hidden"]) {
$temp = str_replace("###KEY###", $element["key"], $template);
$temp = str_replace("###PATH###", $settings['content'] . $element["key"] . '.html', $temp);
$setupContent.= $temp;
}
}
}
return $setupContent;
Expand Down
37 changes: 37 additions & 0 deletions Classes/Controller/FrontendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
/**
* FrontendController
*/
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
*
Expand Down Expand Up @@ -32,13 +34,48 @@ class FrontendController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControl
*/
protected $inlineHelper;

/**
* settingsService
*
* @var \MASK\Mask\Domain\Service\SettingsService
* @inject
*/
protected $settingsService;

/**
* extension settings
* @var array
*/
protected $extSettings;

/**
* Displays the content in the frontend
*
* @return void
*/
public function contentelementAction()
{
// load extension settings
$this->extSettings = $this->settingsService->get();

// get framework configuration
$extbaseFrameworkConfiguration = $this->configurationManager->getConfiguration(
ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK
);

// if there are paths for layouts and partials set, add them to view
if (!empty($this->extSettings["layouts"])) {
$viewLayoutRootPaths = $this->getViewProperty($extbaseFrameworkConfiguration, 'layoutRootPaths');
$extSettingsLayoutRootPath = GeneralUtility::getFileAbsFileName($this->extSettings["layouts"]);

$this->view->setLayoutRootPaths(array_replace($viewLayoutRootPaths, [$extSettingsLayoutRootPath]));
}
if (!empty($this->extSettings["partials"])) {
$viewPartialRootPaths = $this->getViewProperty($extbaseFrameworkConfiguration, 'partialRootPaths');
$extSettingsPartialRootPath = GeneralUtility::getFileAbsFileName($this->extSettings["partials"]);

$this->view->setPartialRootPaths(array_replace($viewPartialRootPaths, [$extSettingsPartialRootPath]));
}
$this->view->setTemplatePathAndFilename($this->settings["file"]);
$data = $this->configurationManager->getContentObject()->data;
$this->inlineHelper->addFilesToData($data, "tt_content");
Expand Down
61 changes: 61 additions & 0 deletions Classes/Controller/WizardContentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,65 @@ public function deleteAction($key, $type)
$this->addFlashMessage(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('tx_mask.content.deletedcontentelement', 'mask'));
$this->redirect('list');
}

/**
* action purge
*
* @param string $key
* @param string $type
* @return void
*/
public function purgeAction($key, $type)
{
$this->deleteHtml($key);
$this->storageRepository->remove($type, $key);
$this->generateAction();
$this->addFlashMessage(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('tx_mask.content.deletedcontentelement', 'mask'));
$this->redirect('list');
}

/**
* action hide
*
* @param string $key
* @return void
*/
public function hideAction($key)
{
$this->storageRepository->hide("tt_content", $key);
$this->generateAction();
$this->addFlashMessage(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('tx_mask.content.hiddencontentelement', 'mask'));
$this->redirect('list');
}

/**
* action activate
*
* @param string $key
* @return void
*/
public function activateAction($key)
{
$this->storageRepository->activate("tt_content", $key);
$this->generateAction();
$this->addFlashMessage(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('tx_mask.content.activatedcontentelement', 'mask'));
$this->redirect('list');
}

/**
* Deletes Fluid html, if file exists
*
* @param string $key
* @param string $html
* @author Benjamin Butschell <bb@webprofil.at>
*/
protected function deleteHtml($key)
{
if (file_exists(PATH_site . $this->extSettings["content"] . $key . ".html")) {
unlink(PATH_site . $this->extSettings["content"] . $key . ".html");
}
if (file_exists(PATH_site . $this->extSettings["backend"] . $key . ".html")) {
unlink(PATH_site . $this->extSettings["backend"] . $key . ".html");
}
}
}
21 changes: 19 additions & 2 deletions Classes/Domain/Model/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,25 @@ class Content extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*/
protected $fieldkey;

/**
* contentType
*
* @var \string
* @validate NotEmpty
*/
protected $contentType;

public function getContentType()
{
return $this->contentType;
}

public function setContentType(\string $contentType)
{
$this->contentType = $contentType;
return $this;
}

/**
* Returns the title
*
Expand Down Expand Up @@ -150,5 +169,3 @@ public function setFieldkey($fieldkey)
$this->fieldkey = $fieldkey;
}
}

?>
9 changes: 9 additions & 0 deletions Classes/Domain/Repository/ContentRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,13 @@
class ContentRepository extends \TYPO3\CMS\Extbase\Persistence\Repository
{

public function initializeObject()
{
/** @var $querySettings TYPO3CMSExtbasePersistenceGenericTypo3QuerySettings */
$querySettings = $this->objectManager->get('TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings');
$querySettings->setRespectStoragePage(FALSE);
$querySettings->setIgnoreEnableFields(FALSE);
$querySettings->setIncludeDeleted(FALSE);
$this->setDefaultQuerySettings($querySettings);
}
}
Loading

0 comments on commit adfb996

Please sign in to comment.