Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEATURE: Allows further data to be stored #27

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions Classes/Controller/ModuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ public function newTaxonomyAction(NodeInterface $parent)
$vocabulary = $flowQuery->closest('[instanceof ' . $this->taxonomyService->getVocabularyNodeType() . ']')->get(0);
$this->view->assign('vocabulary', $vocabulary);
$this->view->assign('parent', $parent);
$this->view->assign('nodeTypeName', $this->nodeTypeManager->getNodeType($this->taxonomyService->getTaxonomyNodeType($parent)));
}

/**
Expand All @@ -370,16 +371,23 @@ public function newTaxonomyAction(NodeInterface $parent)
* @param NodeInterface $parent
* @param string $title
* @param string $description
* @param array $additionalData
* @return void
*/
public function createTaxonomyAction(NodeInterface $parent, $title, $description = '')
public function createTaxonomyAction(NodeInterface $parent, $title, $description = '', array $additionalData = null)
{
$nodeTemplate = new NodeTemplate();
$nodeTemplate->setNodeType($this->nodeTypeManager->getNodeType($this->taxonomyService->getTaxonomyNodeType()));
$nodeTemplate->setNodeType($this->nodeTypeManager->getNodeType($this->taxonomyService->getTaxonomyNodeType($parent)));
$nodeTemplate->setName(CrUtitlity::renderValidNodeName($title));
$nodeTemplate->setProperty('title', $title);
$nodeTemplate->setProperty('description', $description);

if ($additionalData !== null) {
foreach ($additionalData as $key => $value) {
$nodeTemplate->setProperty($key, $value);
}
}

$taxonomy = $parent->createNodeFromTemplate($nodeTemplate);

$this->addFlashMessage(
Expand Down Expand Up @@ -417,7 +425,7 @@ public function editTaxonomyAction(NodeInterface $taxonomy)

$this->view->assign('taxonomy', $taxonomy);
$this->view->assign('defaultTaxonomy', $this->getNodeInDefaultDimensions($taxonomy));

$this->view->assign('nodeTypeName', $this->nodeTypeManager->getNodeType($this->taxonomyService->getTaxonomyNodeType($taxonomy)));
}

/**
Expand All @@ -426,9 +434,10 @@ public function editTaxonomyAction(NodeInterface $taxonomy)
* @param NodeInterface $taxonomy
* @param string $title
* @param string $description
* @param array $additionalData
* @return void
*/
public function updateTaxonomyAction(NodeInterface $taxonomy, $title, $description = '')
public function updateTaxonomyAction(NodeInterface $taxonomy, $title, $description = '', array $additionalData = null)
{
$previousTitle = $taxonomy->getProperty('title');
$previousDescription = $taxonomy->getProperty('description');
Expand All @@ -441,6 +450,12 @@ public function updateTaxonomyAction(NodeInterface $taxonomy, $title, $descripti
$taxonomy->setProperty('description', $description);
}

if ($additionalData !== null) {
foreach ($additionalData as $key => $value) {
$taxonomy->setProperty($key, $value);
}
}

$this->addFlashMessage(
sprintf('Updated taxonomy %s', $taxonomy->getPath())
);
Expand Down
23 changes: 22 additions & 1 deletion Classes/Service/TaxonomyService.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ class TaxonomyService
*/
protected $taxonomyNodeType;

/**
* @var array
* @Flow\InjectConfiguration(path="contentRepository.taxonomyNodeTypes")
*/
protected $taxonomyNodeTypes;

/**
* @var NodeInterface[]
*/
Expand Down Expand Up @@ -105,10 +111,25 @@ public function getVocabularyNodeType()
}

/**
* @param NodeInterface $parent
* @return string
*/
public function getTaxonomyNodeType()
public function getTaxonomyNodeType(NodeInterface $parent = null)
{
if ($parent !== null) {
$currentVocabularyNodeType = null;
do {
if ($parent->getNodeType()->isOfType($this->getVocabularyNodeType())) {
$currentVocabularyNodeType = $parent->getNodeType()->getName();
} else {
$parent = $parent->getParent();
}
} while ($parent !== null && $currentVocabularyNodeType === null);

if ($currentVocabularyNodeType !== null && !empty($this->taxonomyNodeTypes[$currentVocabularyNodeType])) {
return $this->taxonomyNodeTypes[$currentVocabularyNodeType];
}
}
return $this->taxonomyNodeType;
}

Expand Down
Empty file.
3 changes: 2 additions & 1 deletion Resources/Private/Templates/Module/EditTaxonomy.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@
</f:if>
</div>

<f:render partial="{nodeTypeName}" arguments="{_all}" />

<f:link.action class="neos-button" action="vocabulary" arguments="{vocabulary: vocabulary}">{f:translate(id: 'generic.cancel')}</f:link.action>
<f:form.submit value="{f:translate(id: 'generic.save')}" class="neos-button neos-button-primary" />

</fieldset>
</f:form>
</f:section>
2 changes: 2 additions & 0 deletions Resources/Private/Templates/Module/NewTaxonomy.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
<f:form.textarea class="neos-span6" name="description" id="description"/>
</div>

<f:render partial="{nodeTypeName}" />

<f:link.action class="neos-button" action="vocabulary" arguments="{vocabulary: vocabulary}">{f:translate(id: 'generic.cancel')}</f:link.action>
<f:form.submit value="{f:translate(id: 'taxon.create')}" class="neos-button neos-button-primary" />
</fieldset>
Expand Down