瀏覽代碼

Merge branch 'refactoring' into develop

* refactoring:
  add basic ordering of terms and remove obsolete code
  hate styles
  change the separation of terms to semicolon and add some basic styles
  add delete action for terms
  add model and controller for urls
  add controllers for each model to keep things simple
  add models for categories and types and update view
  remove obsolete comments
  be more generic
ksieren 2 年之前
父節點
當前提交
fc9af89a17

+ 23 - 0
Classes/Controller/CategoryController.php

@@ -0,0 +1,23 @@
+<?php
+
+namespace Meramo\Begriffmgt\Controller;
+
+use Meramo\Begriffmgt\Domain\Model\Category;
+use Meramo\Begriffmgt\Domain\Repository\CategoryRepository;
+use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
+use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager;
+
+class CategoryController extends ActionController
+{
+    public function __construct(CategoryRepository $categoryRepository) {
+        $this->categoryRepository = $categoryRepository;
+    }
+
+    public function createAction(string $title) {
+        $category = new Category();
+        $category->setTitle($title);
+        $this->categoryRepository->add($category);
+        $this->objectManager->get(PersistenceManager::class)->persistAll();
+        return $category->getUid();
+    }
+}

+ 71 - 37
Classes/Controller/DashboardController.php

@@ -4,46 +4,80 @@ declare(strict_types=1);
 
 namespace Meramo\Begriffmgt\Controller;
 
+use Meramo\Begriffmgt\Domain\Repository\TypeRepository;
+use Meramo\Begriffmgt\Domain\Repository\UrlRepository;
 use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
 use Meramo\Begriffmgt\Domain\Repository\TermRepository;
-use TYPO3\CMS\Extbase\Persistence\QueryInterface;
-use TYPO3\CMS\Extbase\Utility\DebuggerUtility;
-use Meramo\Begriffmgt\Domain\Model\Term;
+use Meramo\Begriffmgt\Domain\Repository\CategoryRepository;
 
-
-/**
- * Determines what happens when the Module Buttom/Link is clicked
- */
 class DashboardController extends ActionController
 {
-  /**
-   * @var TermRepository $termRepository
-   */
-  protected $termRepository;
-
-  /**
-   * Set Sort order of Data in List Module
-   */
-  protected $defaultOrderings = ['uid' => QueryInterface::ORDER_ASCENDING];
-
-  /**
-   * @param TermRepository $termRepository
-   */
-  public function injectTermRepository(TermRepository $termRepository): void
-  {
-    $this->termRepository = $termRepository;
-  }
-
-  public function indexAction()
-  {
-
-    $terms = $this->termRepository->findAll();
-    // DebuggerUtility::var_dump($terms);
-    $query = $terms->getQuery();
-    // DebuggerUtility::var_dump($query);
-    $query->setOrderings(['uid' => QueryInterface::ORDER_ASCENDING]);
-
-    $this->view->assign('terms', $query->execute());
-
-  }
+    protected $termRepository;
+    protected $termController;
+    protected $categoryRepository;
+    protected $categoryController;
+    protected $typeRepository;
+    protected $typeController;
+    protected $urlRepository;
+    protected $urlController;
+
+    public function __construct(
+        TermRepository $termRepository,
+        CategoryRepository $categoryRepository,
+        CategoryController $categoryController,
+        TypeRepository $typeRepository,
+        TypeController $typeController,
+        UrlRepository $urlRepository,
+        UrlController $urlController,
+        TermController $termController
+    ) {
+        $this->termRepository = $termRepository;
+        $this->categoryRepository = $categoryRepository;
+        $this->categoryController = $categoryController;
+        $this->termController = $termController;
+        $this->typeRepository = $typeRepository;
+        $this->typeController = $typeController;
+        $this->urlRepository = $urlRepository;
+        $this->urlController = $urlController;
+    }
+
+    public function indexAction(): void
+    {
+        $terms = $this->termRepository->findAllOrderedByTerm();
+        $categories = $this->categoryRepository->findAll();
+        $types = $this->typeRepository->findAll();
+        $urls = $this->urlRepository->findAll();
+        $this->view->assignMultiple([
+            'terms' => $terms,
+            'categories' => $categories,
+            'types' => $types,
+            'urls' => $urls
+        ]);
+    }
+
+    public function newAction(): void {
+    }
+
+    public function listAction(): void {
+        $terms = $this->termRepository->findAll();
+        $this->view->assign('terms', $terms);
+    }
+
+    public function createAction(string $termList, string $categoryTitle, string $typeTitle, string $urlTitle): void {
+        $terms = array_map('trim', explode(';', $termList));
+        $category = $this->categoryController->createAction($categoryTitle);
+        $categoryObj = $this->categoryRepository->findByUid($category);
+        $type = $this->typeController->createAction($typeTitle);
+        $typeObj = $this->typeRepository->findByUid($type);
+        $url = $this->urlController->createAction($urlTitle);
+        $urlObj = $this->urlRepository->findByUid($url);
+        $this->termController->createAction($terms, $categoryObj, $typeObj, $urlObj);
+        $this->redirect('index');
+    }
+
+    public function deleteTermAction(int $termId): void {
+        $this->termController->deleteAction($termId);
+        $this->redirect('index');
+    }
+
 }

+ 33 - 0
Classes/Controller/TermController.php

@@ -0,0 +1,33 @@
+<?php
+
+namespace Meramo\Begriffmgt\Controller;
+use Meramo\Begriffmgt\Domain\Model\Term;
+use Meramo\Begriffmgt\Domain\Repository\TermRepository;
+use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
+
+class TermController extends ActionController
+{
+    public function __construct(
+        TermRepository $termRepository
+    ) {
+        $this->termRepository = $termRepository;
+    }
+
+    public function createAction($terms, $categoryObj, $typeObj, $urlObj): void {
+        foreach ($terms as $term) {
+            $termObj = new Term();
+            $termObj->setTerm($term);
+            $termObj->setCategory($categoryObj);
+            $termObj->setType($typeObj);
+            $termObj->setUrl($urlObj);
+            $this->termRepository->add($termObj);
+        }
+    }
+
+    public function deleteAction(int $termId): void {
+        $term = $this->termRepository->findByUid($termId);
+        if ($term) {
+            $this->termRepository->remove($term);
+        }
+    }
+}

+ 23 - 0
Classes/Controller/TypeController.php

@@ -0,0 +1,23 @@
+<?php
+
+namespace Meramo\Begriffmgt\Controller;
+
+use Meramo\Begriffmgt\Domain\Model\Type;
+use Meramo\Begriffmgt\Domain\Repository\TypeRepository;
+use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
+use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager;
+
+class TypeController extends ActionController
+{
+    public function __construct(TypeRepository $typeRepository) {
+        $this->typeRepository = $typeRepository;
+    }
+
+    public function createAction(string $title) {
+        $type = new Type();
+        $type->setTitle($title);
+        $this->typeRepository->add($type);
+        $this->objectManager->get(PersistenceManager::class)->persistAll();
+        return $type->getUid();
+    }
+}

+ 23 - 0
Classes/Controller/UrlController.php

@@ -0,0 +1,23 @@
+<?php
+
+namespace Meramo\Begriffmgt\Controller;
+
+use Meramo\Begriffmgt\Domain\Model\Url;
+use Meramo\Begriffmgt\Domain\Repository\UrlRepository;
+use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
+use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager;
+
+class UrlController extends ActionController
+{
+    public function __construct(UrlRepository $urlRepository) {
+        $this->urlRepository = $urlRepository;
+    }
+
+    public function createAction(string $title) {
+        $url = new Url();
+        $url->setTitle($title);
+        $this->urlRepository->add($url);
+        $this->objectManager->get(PersistenceManager::class)->persistAll();
+        return $url->getUid();
+    }
+}

+ 43 - 0
Classes/Domain/Model/Category.php

@@ -0,0 +1,43 @@
+<?php
+
+namespace Meramo\Begriffmgt\Domain\Model;
+
+use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
+use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
+
+class Category extends AbstractEntity
+{
+    protected $uid;
+    protected string $title = '';
+    protected ObjectStorage $terms;
+
+    public function __construct()
+    {
+        $this->terms = new ObjectStorage();
+    }
+
+    public function getUid(): int
+    {
+        return $this->uid;
+    }
+
+    public function getTitle(): string
+    {
+        return $this->title;
+    }
+
+    public function setTitle(string $title): void
+    {
+        $this->title = $title;
+    }
+
+    public function getTerms(): ObjectStorage
+    {
+        return $this->terms;
+    }
+
+    public function setTerms(ObjectStorage $terms): void
+    {
+        $this->terms = $terms;
+    }
+}

+ 17 - 106
Classes/Domain/Model/Term.php

@@ -1,137 +1,48 @@
 <?php
 
-#declare(strict_types=1);
+declare(strict_types=1);
 
 namespace Meramo\Begriffmgt\Domain\Model;
 
 
 use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
 
-/**
- * This file is part of the "Chatbot Term Management" Extension for TYPO3 CMS.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * (c) 2023 Meramo Developer <development@meramo.de>, Meramo Verlag GmbH
- */
-
-/**
- * Table is used to manage chatbot terms
- */
 class Term extends AbstractEntity
 {
+    protected string $term = '';
+    protected ?Category $category = null;
+    protected ?Type $type = null;
+    protected ?Url $url = null;
 
-    /**
-     * chatbotType
-     *
-     * @var string
-     */
-    protected $type = '';
-
-    /**
-     * chatbotCategory
-     *
-     * @var string
-     */
-    protected $category = '';
-
-    /**
-     * chatbotTerms
-     *
-     * @var string
-     */
-    protected $terms = '';
-
-    /**
-     * chatbotUrl
-     *
-     * @var string
-     */
-    protected $url = '';
-
-    /**
-     * Returns the chatbotType
-     *
-     * @return string
-     */
-    public function getType()
-    {
-        return $this->type;
+    public function getTerm(): string {
+        return $this->term;
     }
 
-    /**
-     * Sets the chatbotType
-     *
-     * @param string $type
-     * @return void
-     */
-    public function setType(int $type)
-    {
-        $this->type = $type;
+    public function setTerm(string $term): void {
+        $this->term = $term;
     }
 
-    /**
-     * Returns the category
-     *
-     * @return string
-     */
-    public function getCategory()
-    {
+    public function getCategory(): ?Category {
         return $this->category;
     }
 
-    /**
-     * Sets the category
-     *
-     * @param string $category
-     * @return void
-     */
-    public function setCategory(int $category)
-    {
+    public function setCategory(?Category $category): void {
         $this->category = $category;
     }
 
-
-    /**
-     * Returns Terms
-     *
-     * @return string
-     */
-    public function getTerms()
-    {
-        return $this->terms;
+    public function getType(): ?Type {
+        return $this->type;
     }
 
-    /**
-     * Sets the chatbotTerms
-     *
-     * @param string $terms
-     * @return void
-     */
-    public function setTerms(string $terms)
-    {
-        $this->terms = $terms;
+    public function setType(?Type $type): void {
+        $this->type = $type;
     }
 
-    /**
-     * Returns the url
-     *
-     * @return string
-     */
-    public function getUrl()
-    {
+    public function getUrl(): ?Url {
         return $this->url;
     }
 
-    /**
-     * Sets the chatbot_url
-     *
-     * @param string $Url
-     * @return void
-     */
-    public function setUrl(string $url)
-    {
+    public function setUrl(?Url $url): void {
         $this->url = $url;
     }
 }

+ 43 - 0
Classes/Domain/Model/Type.php

@@ -0,0 +1,43 @@
+<?php
+
+namespace Meramo\Begriffmgt\Domain\Model;
+use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
+use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
+
+
+class Type extends AbstractEntity
+{
+    protected $uid;
+    protected string $title = '';
+    protected ObjectStorage $terms;
+
+    public function __construct()
+    {
+        $this->terms = new ObjectStorage();
+    }
+
+    public function getUid(): int
+    {
+        return $this->uid;
+    }
+
+    public function getTitle(): string
+    {
+        return $this->title;
+    }
+
+    public function setTitle(string $title): void
+    {
+        $this->title = $title;
+    }
+
+    public function getTerms(): ObjectStorage
+    {
+        return $this->terms;
+    }
+
+    public function setTerms(ObjectStorage $terms): void
+    {
+        $this->terms = $terms;
+    }
+}

+ 43 - 0
Classes/Domain/Model/Url.php

@@ -0,0 +1,43 @@
+<?php
+
+namespace Meramo\Begriffmgt\Domain\Model;
+
+use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
+use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
+
+class Url extends AbstractEntity
+{
+    protected $uid;
+    protected string $title = '';
+    protected ObjectStorage $urls;
+
+    public function __construct()
+    {
+        $this->urls = new ObjectStorage();
+    }
+
+    public function getUid(): int
+    {
+        return $this->uid;
+    }
+
+    public function getTitle(): string
+    {
+        return $this->title;
+    }
+
+    public function setTitle(string $title): void
+    {
+        $this->title = $title;
+    }
+
+    public function getTerms(): ObjectStorage
+    {
+        return $this->terms;
+    }
+
+    public function setTerms(ObjectStorage $terms): void
+    {
+        $this->terms = $terms;
+    }
+}

+ 9 - 0
Classes/Domain/Repository/CategoryRepository.php

@@ -0,0 +1,9 @@
+<?php
+
+namespace Meramo\Begriffmgt\Domain\Repository;
+
+use TYPO3\CMS\Extbase\Persistence\Repository;
+
+class CategoryRepository extends Repository {
+    // Add any custom methods or queries for the Category repository if needed.
+}

+ 15 - 8
Classes/Domain/Repository/TermRepository.php

@@ -1,18 +1,25 @@
-<?php 
+<?php
 
   declare(strict_types=1);
 
   namespace Meramo\Begriffmgt\Domain\Repository;
 
+  use TYPO3\CMS\Extbase\Persistence\QueryInterface;
   use TYPO3\CMS\Extbase\Persistence\Repository;
   use TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings;
 
   class TermRepository extends Repository
-  { 
-    public function initializeObject() {
-      $querySettings = $this->objectManager->get(Typo3QuerySettings::class);
-      $querySettings->setRespectStoragePage(false);
-      $this->setDefaultQuerySettings($querySettings);
-   }
+  {
+      /**
+       * Find all records and order them by 'term' in ascending order.
+       *
+       * @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface|array
+       */
+      public function findAllOrderedByTerm()
+      {
+          $query = $this->createQuery();
+          $query->setOrderings(['term' => QueryInterface::ORDER_ASCENDING]);
 
-  }
+          return $query->execute();
+      }
+  }

+ 10 - 0
Classes/Domain/Repository/TypeRepository.php

@@ -0,0 +1,10 @@
+<?php
+
+namespace Meramo\Begriffmgt\Domain\Repository;
+
+use TYPO3\CMS\Extbase\Persistence\Repository;
+
+class TypeRepository extends Repository
+{
+    // Add any custom methods or queries for the Type repository if needed.
+}

+ 9 - 0
Classes/Domain/Repository/UrlRepository.php

@@ -0,0 +1,9 @@
+<?php
+
+namespace Meramo\Begriffmgt\Domain\Repository;
+
+use TYPO3\CMS\Extbase\Persistence\Repository;
+
+class UrlRepository extends Repository {
+    // Add any custom methods or queries for the Url repository if needed.
+}

+ 58 - 0
Configuration/TCA/tx_begriffmgt_domain_model_category.php

@@ -0,0 +1,58 @@
+<?php
+
+return [
+    'ctrl' => [
+        'title' => 'LLL:EXT:begriffmgt/Resources/Private/Language/locallang.xlf:tx_begriffmgt_domain_model_category',
+        'label' => 'title',
+        'tstamp' => 'tstamp',
+        'crdate' => 'crdate',
+        'cruser_id' => 'cruser_id',
+        'versioningWS' => true,
+        'origUid' => 't3_origuid',
+        'languageField' => 'sys_language_uid',
+        'transOrigPointerField' => 'l10n_parent',
+        'transOrigDiffSourceField' => 'l10n_diffsource',
+        'delete' => 'deleted',
+        'enablecolumns' => [
+            'disabled' => 'hidden',
+            'starttime' => 'starttime',
+            'endtime' => 'endtime',
+        ],
+        'searchFields' => 'title',
+        'iconfile' => 'EXT:begriffmgt/Resources/Public/Icons/chatbot.svg',
+    ],
+    'interface' => [
+        'showRecordFieldList' => 'title, terms',
+    ],
+    'types' => [
+        '1' => ['showitem' => 'title, terms'],
+    ],
+    'columns' => [
+        'title' => [
+            'exclude' => 0,
+            'label' => 'LLL:EXT:begriffmgt/Resources/Private/Language/locallang.xlf:tx_begriffmgt_domain_model_category.title',
+            'config' => [
+                'type' => 'input',
+                'size' => 30,
+                'eval' => 'trim,required'
+            ],
+        ],
+        'terms' => [
+            'exclude' => 1,
+            'label' => 'Terms',
+            'config' => [
+                'type' => 'inline',
+                'foreign_table' => 'tx_begriffmgt_domain_model_term',
+                'foreign_field' => 'category',
+                'maxitems' => 9999,
+                'appearance' => [
+                    'collapseAll' => 1,
+                    'levelLinksPosition' => 'top',
+                    'showSynchronizationLink' => 1,
+                    'showPossibleLocalizationRecords' => 1,
+                    'showAllLocalizationLink' => 1
+                ],
+            ],
+        ],
+    ],
+];

+ 50 - 73
Configuration/TCA/tx_begriffmgt_domain_model_term.php

@@ -8,22 +8,26 @@ return [
         'tstamp' => 'tstamp',
         'crdate' => 'crdate',
         'cruser_id' => 'cruser_id',
+        'default_sortby' => 'ORDER BY uid',
         'delete' => 'deleted',
         'enablecolumns' => [
             'disabled' => 'hidden',
             'starttime' => 'starttime',
             'endtime' => 'endtime',
         ],
-        'searchFields' => 'type,category,terms,chatbot_url',
+        'searchFields' => 'type,category,term,url',
         'typeicon_classes' => [
           'default' => 'begriffe_list_record_icon',
         ],
         'iconfile' => 'EXT:begriffmgt/Resources/Public/Icons/book.png'
     ],
+    'interface' => [
+        'showRecordFieldList' => 'type,category,term,url',
+    ],
     'types' => [
         '0' => [
           'showitem' => '
-              --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,type, category, terms,url,
+              --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,type, category, term,url,
               --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access, hidden, starttime, endtime'
         ],
     ],
@@ -43,6 +47,50 @@ return [
                 ],
             ],
         ],
+        'category' => [
+            'exclude' => 0,
+            'label' => 'Category',
+            'config' => [
+                'type' => 'select',
+                'renderType' => 'selectSingle',
+                'foreign_table' => 'tx_begriffmgt_domain_model_category',
+                'minitems' => 0,
+                'maxitems' => 1,
+            ],
+        ],
+        'type' => [
+            'exclude' => 0,
+            'label' => 'Type',
+            'config' => [
+                'type' => 'select',
+                'renderType' => 'selectSingle',
+                'foreign_table' => 'tx_begriffmgt_domain_model_type',
+                'minitems' => 0,
+                'maxitems' => 1,
+            ],
+        ],
+        'url' => [
+            'exclude' => 0,
+            'label' => 'Direct-Link',
+            'config' => [
+                'type' => 'select',
+                'renderType' => 'selectSingle',
+                'foreign_table' => 'tx_begriffmgt_domain_model_url',
+                'minitems' => 0,
+                'maxitems' => 1,
+            ],
+        ],
+        'term' => [
+            'exclude' => true,
+            'label' => 'Begriffe Einfügen (Komma getrennt)',
+            'config' => [
+                'type' => 'text',
+                'cols' => 60,
+                'rows' => 150,
+                'eval' => 'trim',
+                'default' => ''
+            ]
+        ],
         'starttime' => [
             'exclude' => true,
             'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.starttime',
@@ -72,76 +120,5 @@ return [
                 ]
             ],
         ],
-
-        'type' => [
-            'exclude' => true,
-            'label' => 'Typ',
-            'config' => [
-                'type' => 'select',
-                'renderType' => 'selectSingle',
-                'items' => [
-                    ['Auswählen', 0],
-                    ['Direct', 'direct'],
-                    ['Medical', 'medical'],
-                    ['Bewerbung', 'bewerbung'],
-                    ['Weiterbildung', 'weiterbildung'],
-                    ['Reverse', 'reverse'],
-                    ['Middlewords', 'middlewords'],
-                    ['Studiumwords', 'studiumword'],
-                    ['Ausbildungwords', 'ausbildungwords'],
-                    ['Unknown', 'unknown'],
-                ],
-                'size' => 1,
-                'maxitems' => 1,
-                'eval' => ''
-            ],
-        ],
-        'category' => [
-            'exclude' => true,
-            'label' => 'Kategorie',
-            'config' => [
-                'type' => 'select',
-                'renderType' => 'selectSingle',
-                'items' => [
-                    ['Auswählen', 0],
-                    ['Ausbildung', 'ausbildung'], 
-                    ['Studium', 'studium'],
-                    ['Adverbien', 'adverbien'],
-                    ['Verben', 'verben'],
-                    ['Substantiven', 'substantiven'],
-                    ['Konjuktionen', 'konjuktionen'],
-                    ['Pronomen', 'pronomen'],
-                    ['Relativpronomen', 'relativpronomen'],
-                    ['Indefinitpronomen', 'indefinitpronomen'],
-                    ['Indefinitpronomen', 'indefinitpronomen'],
-                    ['Numerale', 'Numerale'],
-                    ['Nomen', 'nomen'],
-                    ['Adjektive', 'adjektive'],
-                    ['Artikel', 'artikel']
-                ],
-                'size' => 1,
-                'maxitems' => 1,
-                'eval' => ''
-            ],
-        ],
-        'terms' => [
-            'exclude' => true,
-            'label' => 'Begriffe Einfügen (Komma getrennt)',
-            'config' => [
-                'type' => 'text',
-                'cols' => 60,
-                'rows' => 150,
-                'eval' => 'trim',
-                'default' => ''
-            ]
-        ],
-        'url' => [
-          'exclude' => true,
-          'label' => 'Link',
-          'config' => [
-              'type' => 'input',
-              'renderType' => 'inputLink',
-          ],
-      ],
     ],
 ];

+ 58 - 0
Configuration/TCA/tx_begriffmgt_domain_model_type.php

@@ -0,0 +1,58 @@
+<?php
+
+return [
+    'ctrl' => [
+        'title' => 'LLL:EXT:begriffmgt/Resources/Private/Language/locallang.xlf:tx_begriffmgt_domain_model_type',
+        'label' => 'title',
+        'tstamp' => 'tstamp',
+        'crdate' => 'crdate',
+        'cruser_id' => 'cruser_id',
+        'versioningWS' => true,
+        'origUid' => 't3_origuid',
+        'languageField' => 'sys_language_uid',
+        'transOrigPointerField' => 'l10n_parent',
+        'transOrigDiffSourceField' => 'l10n_diffsource',
+        'delete' => 'deleted',
+        'enablecolumns' => [
+            'disabled' => 'hidden',
+            'starttime' => 'starttime',
+            'endtime' => 'endtime',
+        ],
+        'searchFields' => 'title',
+        'iconfile' => 'EXT:begriffmgt/Resources/Public/Icons/chatbot.svg',
+    ],
+    'interface' => [
+        'showRecordFieldList' => 'title, terms',
+    ],
+    'types' => [
+        '1' => ['showitem' => 'title, terms'],
+    ],
+    'columns' => [
+        'title' => [
+            'exclude' => 0,
+            'label' => 'LLL:EXT:begriffmgt/Resources/Private/Language/locallang.xlf:tx_begriffmgt_domain_model_type.title',
+            'config' => [
+                'type' => 'input',
+                'size' => 30,
+                'eval' => 'trim,required'
+            ],
+        ],
+        'terms' => [
+            'exclude' => 1,
+            'label' => 'Terms',
+            'config' => [
+                'type' => 'inline',
+                'foreign_table' => 'tx_begriffmgt_domain_model_term',
+                'foreign_field' => 'type',
+                'maxitems' => 9999,
+                'appearance' => [
+                    'collapseAll' => 1,
+                    'levelLinksPosition' => 'top',
+                    'showSynchronizationLink' => 1,
+                    'showPossibleLocalizationRecords' => 1,
+                    'showAllLocalizationLink' => 1
+                ],
+            ],
+        ],
+    ],
+];

+ 58 - 0
Configuration/TCA/tx_begriffmgt_domain_model_url.php

@@ -0,0 +1,58 @@
+<?php
+
+return [
+    'ctrl' => [
+        'title' => 'LLL:EXT:begriffmgt/Resources/Private/Language/locallang.xlf:tx_begriffmgt_domain_model_url',
+        'label' => 'title',
+        'tstamp' => 'tstamp',
+        'crdate' => 'crdate',
+        'cruser_id' => 'cruser_id',
+        'versioningWS' => true,
+        'origUid' => 't3_origuid',
+        'languageField' => 'sys_language_uid',
+        'transOrigPointerField' => 'l10n_parent',
+        'transOrigDiffSourceField' => 'l10n_diffsource',
+        'delete' => 'deleted',
+        'enablecolumns' => [
+            'disabled' => 'hidden',
+            'starttime' => 'starttime',
+            'endtime' => 'endtime',
+        ],
+        'searchFields' => 'title',
+        'iconfile' => 'EXT:begriffmgt/Resources/Public/Icons/chatbot.svg',
+    ],
+    'interface' => [
+        'showRecordFieldList' => 'title, terms',
+    ],
+    'types' => [
+        '1' => ['showitem' => 'title, terms'],
+    ],
+    'columns' => [
+        'title' => [
+            'exclude' => 0,
+            'label' => 'LLL:EXT:begriffmgt/Resources/Private/Language/locallang.xlf:tx_begriffmgt_domain_model_url.title',
+            'config' => [
+                'type' => 'input',
+                'size' => 30,
+                'eval' => 'trim,required'
+            ],
+        ],
+        'terms' => [
+            'exclude' => 1,
+            'label' => 'Terms',
+            'config' => [
+                'type' => 'inline',
+                'foreign_table' => 'tx_begriffmgt_domain_model_term',
+                'foreign_field' => 'url',
+                'maxitems' => 9999,
+                'appearance' => [
+                    'collapseAll' => 1,
+                    'levelLinksPosition' => 'top',
+                    'showSynchronizationLink' => 1,
+                    'showPossibleLocalizationRecords' => 1,
+                    'showAllLocalizationLink' => 1
+                ],
+            ],
+        ],
+    ],
+];

+ 0 - 17
Resources/Language/locallang_mod.xlf

@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<xliff version="1.2" xmlns:t3="http://typo3.org/schemas/xliff" xmlns="urn:oasis:names:tc:xliff:document:1.2">
-	<file source-language="en" original="EXT:examples/Resources/Private/Language/Module/locallang_mod.xlf" datatype="plaintext" product-name="begriffmgt" date="2023-03-20T18:44:02+02:00">
-		<header></header>
-		<body>
-			<trans-unit id="mlang_labels_tabdescr" resname="mlang_labels_tabdescr">
-				<source>Chatbot Verwaltung</source>
-			</trans-unit>
-			<trans-unit id="mlang_labels_tablabel" resname="mlang_labels_tablabel">
-				<source>Chatbot Verwaltung</source>
-			</trans-unit>
-			<trans-unit id="mlang_tabs_tab" resname="mlang_tabs_tab">
-				<source>Chatbot Verwaltung</source>
-			</trans-unit>
-		</body>
-	</file>
-</xliff>

+ 1 - 1
Resources/Private/Language/locallang_mod.xlf

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
-	<file source-language="en" datatype="plaintext" original="EXT:mrmbe_posts/Resources/Private/Language/locallang_mod.xlf" date="2021-11-06T30:10:22Z" product-name="mrmbepages">
+	<file source-language="en" datatype="plaintext" original="EXT:begriffmgt/Resources/Private/Language/locallang_mod.xlf" date="2023-03-30T30:10:22Z" product-name="begriffmgt">
 		<header/>
 		<body>
 			<trans-unit id="mlang_labels_tablabel">

+ 15 - 0
Resources/Private/Layouts/Backend.html

@@ -0,0 +1,15 @@
+<html
+    xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
+    xmlns:be="http://typo3.org/ns/TYPO3/CMS/Backend/ViewHelpers"
+    data-namespace-typo3-fluid="true">
+
+<be:moduleLayout>
+
+    <div id="begriffe-main-content">
+        <f:render section="main" />
+    </div>
+
+</be:moduleLayout>
+
+</html>
+

+ 0 - 29
Resources/Private/Layouts/Default.html

@@ -1,29 +0,0 @@
-<html
-    xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
-    xmlns:be="http://typo3.org/ns/TYPO3/CMS/Backend/ViewHelpers"
-    data-namespace-typo3-fluid="true">
-
-<be:moduleLayout>
-    <f:be.pageRenderer
-        includeRequireJsModules="{
-            0:'TYPO3/CMS/Backend/ContextMenu',
-            1:'TYPO3/CMS/Backend/Modal',
-            2:'TYPO3/CMS/Beuser/BackendUserListing'
-        }"
-    />
-
-    <be:moduleLayout.menu identifier="BegriffmgtModalMenu">
-        <be:moduleLayout.menuItem label="Liste ChatbotBegriffe" uri="{f:uri.action(controller: 'Dashboard', action: 'index')}"/>
-    </be:moduleLayout.menu>
-
- 
-    <be:moduleLayout.button.shortcutButton displayName="Add" />
-
-    <div id="begriffe-main-content">
-        <f:render section="Content" />
-    </div>
-
-</be:moduleLayout>
-
-</html>
-

+ 118 - 61
Resources/Private/Templates/Dashboard/Index.html

@@ -1,65 +1,122 @@
-<html
-    xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
-    xmlns:core="http://typo3.org/ns/TYPO3/CMS/Core/ViewHelpers"
-    xmlns:be="http://typo3.org/ns/TYPO3/CMS/Backend/ViewHelpers"
-    data-namespace-typo3-fluid="true">
+<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers">
 
-<f:layout name="Default" />
+<f:layout name="Backend" />
 
-<f:section name="Content">
-    <h1>Auflistung Chatbot Begriffe</h1>
-    <f:if condition="{terms}">
-      <div class="table-fit">
-        <table id="chatbotbegriffmgt-terms" class="table table-striped table-hover table-vertical-top">
-          <thead>
-            <tr>
-              <td><b>Typ<b></td>
-              <td><b>Kategorie</b></td>
-              <td><b>Begriffe</b></td>
-              <td><b>Link</b></td>
-              <td></td>
-            </tr>
-          </thead>
-          <tbody>
-            <f:for each="{terms}" as="term">
-              <tr>
-                <td>
-                  {term.type}
-                  </a>
-                </td>
-                <f:if condition="{term.category} != '0' ">
-                  <f:then>
-                    <td>
-                      {term.category}
-                    </td>
-                  </f:then>
-                  <f:else>
-                    <td></td>
-                  </f:else>
-                </f:if>
-                <td>
-                  {term.terms -> f:format.crop(maxCharacters: 25)}
-                </td>
-                <f:if condition="{term.url} != '0' ">
-                  <f:then>
-                    <td>{term.url}</td>
-                  </f:then>
-                  <f:else>
-                    <td></td>
-                  </f:else>
-                </f:if>
-                <td class="col-control">
-                  <div class="btn-group" role="group">
-                    <be:link.editRecord class="btn btn-default" table="tx_begriffmgt_domain_model_term" uid="{term.uid}" title="Bearbeiten">
-                        <core:icon identifier="actions-open" />
-                    </be:link.editRecord>
-                </div>
-                </td>
-              </tr>
-            </f:for>
-          </tbody>
-        </table>
-      </div>
-    </f:if>
+
+<f:section name="main">
+  <h1>Dashboard</h1>
+
+  <h2>Add words (semicolon-separated) with a category</h2>
+  <f:flashMessages />
+  <f:form action="create">
+    <div class="form-group" additionalAttributes="{style: 'margin-bottom: 1rem;'}">
+      <label for="termList">Terms:</label>
+      <f:form.textfield name="termList" additionalAttributes="{style: 'width: 100%; height: 30px; display: block;'}" /><br>
+    </div>
+    <div class="form-group">
+      <label for="categoryTitle">Category:</label>
+      <f:form.textfield name="categoryTitle" additionalAttributes="{style: 'width: 150px; height: 30px; display: block;'}" /><br>
+    </div>
+    <div class="form-group">
+      <label for="typeTitle">Type:</label>
+      <f:form.textfield name="typeTitle" additionalAttributes="{style: 'width: 150px; height: 30px; display: block;'}" /><br>
+    </div>
+    <div class="form-group">
+      <label for="urlTitle">URL:</label>
+      <f:form.textfield name="urlTitle" additionalAttributes="{style: 'width: 400px; height: 30px; display: block;'}" /><br>
+    </div>
+    <f:form.submit value="Save" />
+  </f:form>
+
+  <hr style="width: 100%; border: 1px solid black; margin: 20px 0;">
+
+  <h2>List of terms</h2>
+  <table style="width: 100%;">
+    <thead>
+    <tr>
+      <th additionalAttributes="{style: 'width: 10px;'}">ID</th>
+      <th additionalAttributes="{style: 'width: 200px;'}">Term</th>
+      <th additionalAttributes="{style: 'width: 200px;'}">Type</th>
+      <th additionalAttributes="{style: 'width: 200px;'}">Category</th>
+      <th additionalAttributes="{style: 'width: 400px;'}">Url</th>
+      <th additionalAttributes="{style: 'width: 100px;'}">Action</th>
+    </tr>
+    </thead>
+    <tbody>
+    <f:for each="{terms}" as="term">
+      <tr>
+        <td>{term.uid}</td>
+        <td>{term.term}</td>
+        <td>{term.type.title}</td>
+        <td>{term.category.title}</td>
+        <td>{term.url.title}</td>
+        <td>
+          <f:link.action action="deleteTerm" arguments="{termId: term.uid}" class="btn" title="Delete" onclick="return confirm('Are you sure you want to delete this term?');">Delete</f:link.action>
+        </td>
+      </tr>
+    </f:for>
+    </tbody>
+  </table>
+
+  <hr style="width: 100%; border: 1px solid black; margin: 20px 0;">
+
+  <h2>List of categories</h2>
+  <table  style="width: 210px;">
+    <thead>
+    <tr>
+      <th additionalAttributes="{style: 'width: 10px;'}">ID</th>
+      <th additionalAttributes="{style: 'width: 200px;'}">Title</th>
+    </tr>
+    </thead>
+    <tbody>
+    <f:for each="{categories}" as="category">
+      <tr>
+        <td>{category.uid}</td>
+        <td>{category.title}</td>
+      </tr>
+    </f:for>
+    </tbody>
+  </table>
+
+  <hr style="width: 100%; border: 1px solid black; margin: 20px 0;">
+
+  <h2>List of types</h2>
+  <table  style="width: 210px;">
+    <thead>
+    <tr>
+      <th additionalAttributes="{style: 'width: 10px;'}">ID</th>
+      <th additionalAttributes="{style: 'width: 200px;'}">Title</th>
+    </tr>
+    </thead>
+    <tbody>
+    <f:for each="{types}" as="type">
+      <tr>
+        <td>{type.uid}</td>
+        <td>{type.title}</td>
+      </tr>
+    </f:for>
+    </tbody>
+  </table>
+
+  <hr style="width: 100%; border: 1px solid black; margin: 20px 0;">
+
+  <h2>List of urls</h2>
+  <table style="width: 410px;">
+    <thead>
+    <tr>
+      <th additionalAttributes="{style: 'width: 10px;'}">ID</th>
+      <th additionalAttributes="{style: 'width: 400px;'}">Title</th>
+    </tr>
+    </thead>
+    <tbody>
+    <f:for each="{urls}" as="url">
+      <tr>
+        <td>{url.uid}</td>
+        <td>{url.title}</td>
+      </tr>
+    </f:for>
+    </tbody>
+  </table>
 </f:section>
+
 </html>

+ 6 - 47
ext_localconf.php

@@ -1,65 +1,24 @@
 <?php
-// call_user_func( function()
-// {
-  
-// } );
 
+use TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider;
+use TYPO3\CMS\Core\Imaging\IconRegistry;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
-
-// $iconRegistry = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class);
-
-// $iconRegistry->registerIcon('begriffe_list_record_icon', \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, ['source' => 'EXT:begriffmgt/Resources/Public/Icons/book.png']);
-
+defined('TYPO3_MODE') || die();
 
 call_user_func(
   function () {
-      // \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
-      //     'Meramo.Begriffemgt',
-      //     'Termlisting',
-      //     [
-      //       \Meramo\Begriffmgt\Controller\DashboardController::class => 'list',
-      //     ],
-      //     // non-cacheable actions
-      //     [
-      //       \Meramo\Begriffmgt\Controller\DashboardController::class => 'list',
-              
-      //     ]
-      // );
-
-      // Add PageTSConfig (chapter 6)
-      //$languageFile = 'begriffmgt/Resources/Private/Language/locallang_db.xlf';
-      // \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig(
-      //     'mod {
-      //     wizards.newContentElement.wizardItems.plugins {
-      //       elements {
-      //         Termlisting {
-      //           iconIdentifier = begriffmgt-plugin-bloglisting
-      //           title = Auflistung der Chatbot Gegriffe
-      //           description = Verwaltung von Chatbot Begriffe
-      //           tt_content_defValues {
-      //             CType = list
-      //             list_type = Begriffmgt_termlisting
-      //           }
-      //         }
-      //       }
-      //       show = *
-      //     }
-      //   }'
-      // );
-
-      // Register extension icon (chapter 6)
-      $iconRegistry = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class);
+      $iconRegistry = GeneralUtility::makeInstance(IconRegistry::class);
       
       $iconRegistry->registerIcon(
           'begriffe_list_record_icon',
-          \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class,
+          SvgIconProvider::class,
           ['source' => 'EXT:begriffmgt/Resources/Public/Icons/book.png']
       );
 
       $iconRegistry->registerIcon(
         'begriffe_module_icon',
-        \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class,
+        SvgIconProvider::class,
         ['source' => 'EXT:begriffmgt/Resources/Public/Icons/chatbot.svg']
     );
   }

+ 8 - 4
ext_tables.php

@@ -1,14 +1,18 @@
-<?php 
+<?php
+
+use Meramo\Begriffmgt\Controller\DashboardController;
+use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
+use TYPO3\CMS\Extbase\Utility\ExtensionUtility;
 
 call_user_func(function()
 {
-  \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule(
+  ExtensionUtility::registerModule(
     'begriffmgt',
     'tools',
     'ChatbotBegriffManagement',
     'top',
     [
-      \Meramo\Begriffmgt\Controller\DashboardController::class => 'index',
+        DashboardController::class => 'index, list, create, deleteTerm',
     ],
     [
       'access' => 'user,admin',
@@ -20,4 +24,4 @@ call_user_func(function()
 });
 
 // Add Static file
-\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile('begriffmgt', 'Configuration/TypoScript', 'Chatbot Management');
+ExtensionManagementUtility::addStaticFile('begriffmgt', 'Configuration/TypoScript', 'Chatbot Management');

+ 53 - 5
ext_tables.sql

@@ -1,6 +1,54 @@
 CREATE TABLE tx_begriffmgt_domain_model_term (
-	type VARCHAR(255) DEFAULT '' NOT NULL,
-	category VARCHAR(255) DEFAULT '',
-	terms text NOT NULL DEFAULT '',
-	url varchar(255) DEFAULT ''
-);
+    uid int(11) unsigned NOT NULL AUTO_INCREMENT,
+    pid int(11) DEFAULT '0' NOT NULL,
+    tstamp int(11) unsigned DEFAULT '0' NOT NULL,
+    crdate int(11) unsigned DEFAULT '0' NOT NULL,
+    cruser_id int(11) DEFAULT '0' NOT NULL,
+    deleted tinyint(1) unsigned DEFAULT '0' NOT NULL,
+    hidden tinyint(1) unsigned DEFAULT '0' NOT NULL,
+	type int(11) DEFAULT '0' NOT NULL,
+    category int(11) DEFAULT '0' NOT NULL,
+    url int(11) DEFAULT '0' NOT NULL,
+	term text NOT NULL DEFAULT '',
+    PRIMARY KEY (uid)
+);
+
+CREATE TABLE tx_begriffmgt_domain_model_category (
+     uid int(11) unsigned NOT NULL AUTO_INCREMENT,
+     pid int(11) DEFAULT '0' NOT NULL,
+     tstamp int(11) unsigned DEFAULT '0' NOT NULL,
+     crdate int(11) unsigned DEFAULT '0' NOT NULL,
+     cruser_id int(11) DEFAULT '0' NOT NULL,
+     deleted tinyint(1) unsigned DEFAULT '0' NOT NULL,
+     hidden tinyint(1) unsigned DEFAULT '0' NOT NULL,
+     title varchar(255) NOT NULL,
+     terms text DEFAULT '',
+     PRIMARY KEY (uid)
+);
+
+
+CREATE TABLE tx_begriffmgt_domain_model_type (
+     uid int(11) unsigned NOT NULL AUTO_INCREMENT,
+     pid int(11) DEFAULT '0' NOT NULL,
+     tstamp int(11) unsigned DEFAULT '0' NOT NULL,
+     crdate int(11) unsigned DEFAULT '0' NOT NULL,
+     cruser_id int(11) DEFAULT '0' NOT NULL,
+     deleted tinyint(1) unsigned DEFAULT '0' NOT NULL,
+     hidden tinyint(1) unsigned DEFAULT '0' NOT NULL,
+     title varchar(255) NOT NULL,
+     terms text DEFAULT '',
+     PRIMARY KEY (uid)
+);
+
+CREATE TABLE tx_begriffmgt_domain_model_url (
+     uid int(11) unsigned NOT NULL AUTO_INCREMENT,
+     pid int(11) DEFAULT '0' NOT NULL,
+     tstamp int(11) unsigned DEFAULT '0' NOT NULL,
+     crdate int(11) unsigned DEFAULT '0' NOT NULL,
+     cruser_id int(11) DEFAULT '0' NOT NULL,
+     deleted tinyint(1) unsigned DEFAULT '0' NOT NULL,
+     hidden tinyint(1) unsigned DEFAULT '0' NOT NULL,
+     title varchar(255) NOT NULL,
+     terms text DEFAULT '',
+     PRIMARY KEY (uid)
+);