diff --git a/Classes/Controller/ModuleController.php b/Classes/Controller/ModuleController.php
index d7f87cf..cbaa8bb 100644
--- a/Classes/Controller/ModuleController.php
+++ b/Classes/Controller/ModuleController.php
@@ -17,6 +17,7 @@
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\View\ViewInterface;
use Neos\Flow\Mvc\Controller\ActionController;
+use Neos\Fusion\View\FusionView;
use Sitegeist\Taxonomy\Service\DimensionService;
use Sitegeist\Taxonomy\Service\TaxonomyService;
use Neos\ContentRepository\Domain\Service\ContextFactoryInterface;
@@ -35,6 +36,15 @@
*/
class ModuleController extends ActionController
{
+ /**
+ * @var string
+ */
+ protected $defaultViewObjectName = FusionView::class;
+
+ /**
+ * @var FusionView
+ */
+ protected $view;
/**
* @Flow\Inject
@@ -60,6 +70,12 @@ class ModuleController extends ActionController
*/
protected $persistenceManager;
+ /**
+ * @var array
+ * @Flow\InjectConfiguration(path="backendModule.additionalFusionIncludePathes")
+ */
+ protected $additionalFusionIncludePathes;
+
/**
* @var string
* @Flow\InjectConfiguration(package="Neos.ContentRepository", path="contentDimensions")
@@ -91,6 +107,11 @@ class ModuleController extends ActionController
*/
public function initializeView(ViewInterface $view)
{
+ $fusionPathes = ['resource://Sitegeist.Taxonomy/Private/Fusion/Backend'];
+ if ($this->additionalFusionIncludePathes && is_array($this->additionalFusionIncludePathes)) {
+ $fusionPathes = Arrays::arrayMergeRecursiveOverrule($fusionPathes, $this->additionalFusionIncludePathes);
+ }
+ $this->view->setFusionPathPatterns($fusionPathes);
$this->view->assign('contentDimensionOptions', $this->getContentDimensionOptions());
}
@@ -150,6 +171,7 @@ public function changeContextAction($targetAction, $targetProperty, NodeInterfac
$newContextProperties['targetDimensions'][$dimensionName] = $presetName;
}
$modifiedContext = $this->contextFactory->create(array_merge($contextProperties, $newContextProperties));
+
$nodeInModifiedContext = $modifiedContext->getNodeByIdentifier($contextNode->getIdentifier());
$this->redirect($targetAction, null, null, [$targetProperty => $nodeInModifiedContext]);
@@ -277,24 +299,27 @@ public function newVocabularyAction(NodeInterface $taxonomyRoot)
* Create a new vocabulary
*
* @param NodeInterface $taxonomyRoot
- * @param string $title
- * @param string $description
+ * @param array $properties
* @return void
*/
- public function createVocabularyAction(NodeInterface $taxonomyRoot, $title, $description = '')
+ public function createVocabularyAction(NodeInterface $taxonomyRoot, array $properties)
{
$vocabularyNodeType = $this->nodeTypeManager->getNodeType($this->taxonomyService->getVocabularyNodeType());
+ $vocabularyProperties = $vocabularyNodeType->getProperties();
$nodeTemplate = new NodeTemplate();
$nodeTemplate->setNodeType($vocabularyNodeType);
- $nodeTemplate->setName(CrUtitlity::renderValidNodeName($title));
- $nodeTemplate->setProperty('title', $title);
- $nodeTemplate->setProperty('description', $description);
+ $nodeTemplate->setName(CrUtitlity::renderValidNodeName($properties['title']));
+ foreach($properties as $name => $value) {
+ if (array_key_exists($name, $vocabularyProperties)) {
+ $nodeTemplate->setProperty($name, $value);
+ }
+ }
$vocabulary = $taxonomyRoot->createNodeFromTemplate($nodeTemplate);
$this->addFlashMessage(
- sprintf('Created vocabulary %s at path %s', $title, $vocabulary->getPath())
+ sprintf('Created vocabulary %s at path %s', $properties['title'], $vocabulary->getLabel())
);
$this->redirect('index', null, null, ['root' => $taxonomyRoot]);
}
@@ -317,26 +342,24 @@ public function editVocabularyAction(NodeInterface $vocabulary)
* Apply changes to the given vocabulary
*
* @param NodeInterface $vocabulary
- * @param string $title
- * @param string $description
+ * @param array $properties
* @return void
*/
- public function updateVocabularyAction(NodeInterface $vocabulary, $title, $description = '')
+ public function updateVocabularyAction(NodeInterface $vocabulary, array $properties)
{
$taxonomyRoot = $this->taxonomyService->getRoot($vocabulary->getContext());
- $previousTitle = $vocabulary->getProperty('title');
- $previousDescription = $vocabulary->getProperty('description');
-
- if ($previousTitle !== $title) {
- $vocabulary->setProperty('title', $title);
- }
-
- if ($previousDescription !== $description) {
- $vocabulary->setProperty('description', $description);
+ $vocabularyProperties = $vocabulary->getNodeType()->getProperties();
+ foreach($properties as $name => $value) {
+ if (array_key_exists($name, $vocabularyProperties)) {
+ $previous = $vocabulary->getProperty($name);
+ if ($previous !== $value) {
+ $vocabulary->setProperty($name, $value);
+ }
+ }
}
$this->addFlashMessage(
- sprintf('Updated vocabulary %s', $title)
+ sprintf('Updated vocabulary %s', $vocabulary->getLabel())
);
$this->redirect('index', null, null, ['root' => $taxonomyRoot]);
}
@@ -381,22 +404,28 @@ public function newTaxonomyAction(NodeInterface $parent)
* Create a new taxonomy
*
* @param NodeInterface $parent
- * @param string $title
- * @param string $description
+ * @param array $properties
* @return void
*/
- public function createTaxonomyAction(NodeInterface $parent, $title, $description = '')
+ public function createTaxonomyAction(NodeInterface $parent, array $properties)
{
+ $taxonomyNodeType = $this->nodeTypeManager->getNodeType($this->taxonomyService->getTaxonomyNodeType());
+ $taxomonyProperties = $taxonomyNodeType->getProperties();
+
$nodeTemplate = new NodeTemplate();
- $nodeTemplate->setNodeType($this->nodeTypeManager->getNodeType($this->taxonomyService->getTaxonomyNodeType()));
- $nodeTemplate->setName(CrUtitlity::renderValidNodeName($title));
- $nodeTemplate->setProperty('title', $title);
- $nodeTemplate->setProperty('description', $description);
+ $nodeTemplate->setNodeType($taxonomyNodeType);
+ $nodeTemplate->setName(CrUtitlity::renderValidNodeName($properties['title']));
+
+ foreach($properties as $name => $value) {
+ if (array_key_exists($name, $taxomonyProperties)) {
+ $nodeTemplate->setProperty($name, $value);
+ }
+ }
$taxonomy = $parent->createNodeFromTemplate($nodeTemplate);
$this->addFlashMessage(
- sprintf('Created taxonomy %s at path %s', $title, $taxonomy->getPath())
+ sprintf('Created taxonomy %s at path %s', $taxonomy->getLabel(), $taxonomy->getPath())
);
$flowQuery = new FlowQuery([$taxonomy]);
@@ -430,28 +459,25 @@ public function editTaxonomyAction(NodeInterface $taxonomy)
$this->view->assign('taxonomy', $taxonomy);
$this->view->assign('defaultTaxonomy', $this->getNodeInDefaultDimensions($taxonomy));
-
}
/**
* Apply changes to the given taxonomy
*
* @param NodeInterface $taxonomy
- * @param string $title
- * @param string $description
+ * @param array $properties
* @return void
*/
- public function updateTaxonomyAction(NodeInterface $taxonomy, $title, $description = '')
+ public function updateTaxonomyAction(NodeInterface $taxonomy, array $properties)
{
- $previousTitle = $taxonomy->getProperty('title');
- $previousDescription = $taxonomy->getProperty('description');
-
- if ($previousTitle !== $title) {
- $taxonomy->setProperty('title', $title);
- }
-
- if ($previousDescription !== $description) {
- $taxonomy->setProperty('description', $description);
+ $taxonomyProperties = $taxonomy->getNodeType()->getProperties();
+ foreach($properties as $name => $value) {
+ if (array_key_exists($name, $taxonomyProperties)) {
+ $previous = $taxonomy->getProperty($name);
+ if ($previous !== $value) {
+ $taxonomy->setProperty($name, $value);
+ }
+ }
}
$this->addFlashMessage(
@@ -491,4 +517,6 @@ public function deleteTaxonomyAction(NodeInterface $taxonomy)
$this->redirect('vocabulary', null, null, ['vocabulary' => $vocabulary]);
}
+
+
}
diff --git a/Configuration/Settings.yaml b/Configuration/Settings.yaml
index b9c2215..f54f8ac 100644
--- a/Configuration/Settings.yaml
+++ b/Configuration/Settings.yaml
@@ -1,5 +1,13 @@
Sitegeist:
Taxonomy:
+ backendModule:
+ # fusion files or folders that are to be included in the backend module
+ additionalFusionIncludePathes: []
+ # names of additional prototypes to be rendered in vocabulary forms
+ additionalVocabularyFieldPrototypes: []
+ # names of additional prototypes to be rendered in taxonomy forms
+ additionalTaxonomyFieldPrototypes: []
+
contentRepository:
rootNodeName: 'taxonomies'
rootNodeType: 'Sitegeist.Taxonomy:Root'
diff --git a/README.md b/README.md
index b958da0..12c5ba4 100644
--- a/README.md
+++ b/README.md
@@ -27,6 +27,10 @@ multiple sites and the taxonomy documents can be defined without interfering wit
It also provides a separate backend module for managing vocabularies and taxonomies.
+## Installation
+
+Sitegeist.Taxonomy is available via packagist `composer require sitegeist/taxonomy`.
+We use semantic-versioning, so every breaking change will increase the major version number.
## Storing vocabularies and taxonomies in the ContentRepository
@@ -113,12 +117,16 @@ of taxonomies:
Reading and referencing taxonomies from other nodes is currently not limited.
-## Installation
+## Extensibility
-Sitegeist.Taxonomy is available via packagist. `"sitegeist/taxonomy" : "^1.0"` to the require section of the composer.json
-or run `composer require sitegeist/taxonomy`.
+Packages can add additional fields to the forms of taxonomies and vocabularies. To do this
+the following steps are required.
-We use semantic-versioning, so every breaking change will increase the major version number.
+1. Extend the NodeTypes `Sitegeist.Taxonomy:Taxonomy` or `Sitegeist.Taxonomy:Vocabulary` in your package.
+2. Add tha path to your additional `Root.fusion` to the Setting in path `Sitegeist.Taxonomy.backendModule.additionalFusionIncludePathes`.
+3. In the fusion code define each field as prototype that accepts the props `name` plus `taxon` & `defaultTaxon` resp. `vocabulary` & `defaultVocabulary`.
+4. Register addtional prototypesNames by adding them to the Settings `Sitegeist.Taxonomy.backendModule.additionalVocabularyFieldPrototypes` or
+ `Sitegeist.Taxonomy.backendModule.additionalTaxonomyFieldPrototypes`
## Contribution
diff --git a/Resources/Private/Fusion/Backend/Form/Taxonomy.fusion b/Resources/Private/Fusion/Backend/Form/Taxonomy.fusion
new file mode 100644
index 0000000..1e53440
--- /dev/null
+++ b/Resources/Private/Fusion/Backend/Form/Taxonomy.fusion
@@ -0,0 +1,67 @@
+prototype(Sitegeist.Taxonomy:Form.Taxonomy) < prototype(Neos.Fusion:Component) {
+
+ i18nMain = ${Translation.value('').package("Sitegeist.Taxonomy").source('Main')}
+ i18nVocabulary = ${Translation.value('').package("Sitegeist.Taxonomy").source('NodeTypes/Vocabulary')}
+ i18nTaxonomy = ${Translation.value('').package("Sitegeist.Taxonomy").source('NodeTypes/Taxonomy')}
+
+ targetAction = null
+ taxonomy = null
+ defaultTaxonomy = null
+ parent = null
+ vocabulary = null
+
+ additionalFieldPrototypeNames = ${Configuration.setting('Sitegeist.Taxonomy.backendModule.additionalTaxonomyFieldPrototypes')}
+
+ renderer = afx`
+
+ {vocabulary.properties.description} +
+ ++ {props.i18n.id('vocabulary.empty')} +
+ ++ {props.i18nTaxonomy.id('properties.title')} + | ++ {defaultVocabulary ? 'Default' : ''} + | ++ |
---|
+ {props.i18n.id('noVocabularies')} +
+ +- {f:translate(id: 'noVocabularies')} -
-- {vocabulary.properties.description} -
- -- {f:translate(id: 'properties.title', source:'NodeTypes/Taxonomy')} - | -
- |
- - |
---|
- {f:translate(id: 'vocabulary.empty')} -
-