Explorar o código

initial commit

ksieren %!s(int64=2) %!d(string=hai) anos
achega
fba7347a22

+ 5 - 0
.gitignore

@@ -0,0 +1,5 @@
+.DS_Store
+.AppleDouble
+Resources/VueSrc/node_modules
+Resources/VueSrc/*.lock
+Resources/VueSrc/package-lock.json

+ 76 - 0
Classes/Api/chatbotterms.php

@@ -0,0 +1,76 @@
+<?php
+
+namespace Meramo\Crazytermsapi\Api;
+
+use http\Client\Request;
+use http\Message\Body;
+use Meramo\Begriffmgt\Domain\Model\Type;
+use nn\t3;
+use Nng\Nnrestapi\Api\AbstractApi;
+use Nng\Nnrestapi\Annotations as Api;
+use Meramo\Begriffmgt\Domain\Model\Term as TermModel;
+use Meramo\Begriffmgt\Domain\Repository\TermRepository;
+use Symfony\Component\HttpFoundation\JsonResponse;
+use TYPO3\CMS\Core\Http\Response;
+
+/**
+ * This annotation registers this class as an Endpoint!
+ *
+ * @Api\Endpoint()
+ */
+class chatbotterms extends AbstractApi
+{
+    /**
+     * Constructor
+     * Inject the TermRepository.
+     *
+     * @return void
+     */
+    public function __construct(TermRepository $termRepository)
+    {
+        $this->termRepository = t3::injectClass( TermRepository::class );
+        $this->termRepositoryOri = $termRepository;
+    }
+
+    /**
+     * # Retrieve existing Terms
+     *
+     * Send a simple POST request to retrieve terms by type or category or whatever from the database.
+     * The actual request is made based on the combination of params you provide.
+     * ```
+     * https://www.this-sites-url.com/api/chatbotterms
+     * ```
+     * Add your request parameters to the request.
+     * Based on the fields in the db a possible request could be i.e.:
+     * ```
+     * ?type=gedoens
+     * ```
+     * which retrieves all terms with type 'gedoens' or
+     * ```
+     * ?category=obst
+     * ```
+     * which retrieves all terms of category 'obst' or
+     * ```
+     * ?type=gedoens&category=obst
+     * ```
+     * which retrieves all terms with type 'gedoens' and category 'obst' or even
+     * ```
+     * ```
+     * which retrieves all terms objects.
+     *
+     * @Api\Access("fe_users")
+     * @Api\Localize()
+     * @Api\Label("/api/chatbotterms")
+     * @return array
+     */
+    public function getIndexAction()
+    {
+        $requestArgs = $this->getRequest()->getArguments();
+        $type = $requestArgs['type'];
+        $category = $requestArgs['category'];
+        $termsQueryResults = $this->termRepositoryOri->findAllTermsByTypeOrCategoryOrSimplyAll($type, $category);
+        $response = json_decode(json_encode($termsQueryResults));
+
+        return $response;
+    }
+}

+ 7 - 0
Configuration/TCA/Overrides/sys_template.php

@@ -0,0 +1,7 @@
+<?php
+
+use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
+
+defined('TYPO3_MODE') || die();
+
+ExtensionManagementUtility::addStaticFile('crazytermsapi', 'Configuration/TypoScript', 'Crazy Terms RestApi');

+ 27 - 0
Configuration/TypoScript/setup.txt

@@ -0,0 +1,27 @@
+
+plugin.tx_nnrestapi {
+	settings {
+		
+		# where to upload new files. Use @Api\Upload("config[crazytermsapi]")
+		fileUploads {
+			crazytermsapi {
+				defaultStoragePath = 1:/user_upload/apiupload/
+			}		
+		}
+		
+		# Default values for new entries
+		insertDefaultValues {
+			Meramo\Crazytermsapi\Domain\Model\Entry {
+				pid = 4
+			}
+		}
+
+		# Reduce JSON in response to certain fields
+		globalDistillers {
+			Meramo\Crazytermsapi\Domain\Model\Entry {
+				#include = uid, title, files
+				flattenFileReferences = 1
+			}
+		}
+	}
+}

+ 42 - 0
README.md

@@ -0,0 +1,42 @@
+# Very Basic RestApi Extension
+
+This extension comes with a very simple Endpoint that
+can read Terms which are aimed to be used for filtering the frontends' chatbot searches.
+
+
+## Installation
+
+* First install this: ``composer req nng/nnrestapi``
+* Add this to the `repositories` section of your typo3 main composer.json:
+  ```
+ 		{
+			"type": "git",
+			"url": "https://git2.meramo.org/typo3-Extensions/chatbotbegriffe.git",
+			"options": {
+				"ssl": {
+					"verify_peer": true,
+					"verify_peer_name": true
+				},
+				"http": {
+					"header": "Authorization: Bearer 4164b811b0774eaa8a34938e39458bcd66309e57"
+				}
+			}
+		},
+		{
+			"type": "git",
+			"url": "https://git2.meramo.org/typo3-Extensions/crazytermsapi.git",
+			"options": {
+				"ssl": {
+					"verify_peer": true,
+					"verify_peer_name": true
+				},
+				"http": {
+					"header": "Authorization: Bearer 4164b811b0774eaa8a34938e39458bcd66309e57"
+				}
+			}
+		}
+ 
+  ```
+* Install your extension using ``composer req meramo/crazytermsapi``
+* Include the static TypoScript templates in your site root
+* Switch to the RestApi backend module to test the new endpoint

+ 13 - 0
Resources/Private/Language/locallang_db.xlf

@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<xliff version="1.0">
+	<file source-language="en" datatype="plaintext" original="messages" date="2015-03-12T20:58:18Z" product-name="crazytermsapi">
+		<header/>
+		<body>
+								
+			<trans-unit id="tx_crazytermsapi_domain_model_entry">
+				<source>Example data</source>
+			</trans-unit>
+
+		</body>
+	</file>
+</xliff>

+ 24 - 0
Resources/Public/Icons/Extension.svg

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 25.2.1, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
+<svg version="1.1" id="Ebene_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+	 viewBox="0 0 791 792" style="enable-background:new 0 0 791 792;" xml:space="preserve">
+<style type="text/css">
+	.st0{fill:#15B5A2;}
+	.st1{fill:#FFFFFF;}
+	.st2{fill:#34495E;}
+</style>
+<path class="st0" d="M637.7,781.8H152.2C73.4,781.8,9.6,718,9.6,639.2V153.8c0-78.7,63.8-142.6,142.6-142.6h485.5
+	c78.8,0,142.6,63.8,142.6,142.6v485.5C780.2,718,716.5,781.8,637.7,781.8z"/>
+<path class="st1" d="M263.1,169.4h-46.5c-51.4,0-93,41.6-93,93v36.3c0,8.2-3.3,16.1-9.1,21.9l-43.8,43.8
+	c-12.1,12.1-12.1,31.7,0,43.8l0,0l43.8,43.8c5.8,5.8,9.1,13.7,9.1,21.9v36.3c0,51.4,41.6,93,93,93h46.5c8.6,0,15.5-6.9,15.5-15.5
+	v-31c0-8.6-6.9-15.5-15.5-15.5h-46.5c-17.1,0-31-13.9-31-31v-36.3c0-24.7-9.8-48.3-27.3-65.8l-21.9-21.7l21.9-21.9
+	c17.4-17.4,27.2-41.1,27.2-65.8v-36.3c0-17.1,13.9-31,31-31H263c8.6,0,15.5-6.9,15.5-15.5v-31C278.6,176.4,271.6,169.4,263.1,169.4z
+	 M705.5,365.6l-43.8-43.8c-5.8-5.8-9.1-13.7-9.1-21.9v-36.3c0-51.4-41.6-93-93-93h-46.5c-8.6,0-15.5,6.9-15.5,15.5v31
+	c0,8.6,6.9,15.5,15.5,15.5h46.5c17.1,0,31,13.9,31,31v36.3c0,24.7,9.8,48.3,27.3,65.8l21.9,21.9L618,409.5
+	c-17.4,17.4-27.2,41.1-27.3,65.8v36.3c0,17.1-13.9,31-31,31h-46.5c-8.6,0-15.5,6.9-15.5,15.5v31c0,8.6,6.9,15.5,15.5,15.5h46.5
+	c51.4,0,93-41.6,93-93v-36.3c0-8.2,3.3-16.1,9.1-21.9l43.8-43.8C717.7,397.4,717.7,377.7,705.5,365.6L705.5,365.6L705.5,365.6z"/>
+<g>
+	<path class="st1" d="M421.1,297.8l-35,60.6l-35-60.6H234.4L386,560.4l151.6-262.6H421.1z"/>
+	<path class="st2" d="M421.1,297.8l-35,60.6l-35-60.6h-55.9l91,157.5l91-157.5H421.1z"/>
+</g>
+</svg>

+ 26 - 0
composer.json

@@ -0,0 +1,26 @@
+{
+  "name": "meramo/crazytermsapi",
+  "type": "typo3-cms-extension",
+  "description": "Rest-Api Extension for EXT:begriffmgt based on EXT:nnrestapi",
+  "authors": [],
+  "require": {
+    "typo3/cms-core": "^9.5 || ^10.0 || ^11.0",
+    "nng/nnrestapi": "^1.0",
+    "nng/nnhelpers": "^1.5"
+  },
+    "autoload": {
+    "psr-4": {
+      "Meramo\\Crazytermsapi\\": "Classes"
+    }
+  },
+  "autoload-dev": {
+    "psr-4": {
+      "Meramo\\Crazytermsapi\\Tests\\": "Tests"
+    }
+  },
+  "extra": {
+    "typo3/cms": {
+       "extension-key": "crazytermsapi"
+    }
+  }
+}

+ 24 - 0
ext_emconf.php

@@ -0,0 +1,24 @@
+<?php
+
+$EM_CONF[$_EXTKEY] = [
+    'title' => 'Crazy Terms Rest-Api',
+    'description' => 'Extension for EXT:begriffmgt based on EXT:nnrestapi',
+    'category' => 'frontend',
+    'author' => 'kerstin',
+    'author_email' => 'k.sieren@meramo.de',
+    'state' => 'stable',
+    'internal' => '',
+    'uploadfolder' => '0',
+    'createDirs' => '',
+    'clearCacheOnLoad' => 0,
+    'version' => '0.1',
+    'constraints' => [
+        'depends' => [
+            'typo3' => '9.5.0-11.9.99',
+            'nnhelpers' => '1.4.0-0.0.0',
+            'nnrestapi' => '1.0.0-0.0.0',
+        ],
+        'conflicts' => [],
+        'suggests' => [],
+    ],
+];

+ 8 - 0
ext_localconf.php

@@ -0,0 +1,8 @@
+<?php
+defined('TYPO3_MODE') || die('Access denied.');
+
+call_user_func(
+	function( $extKey )
+	{
+	},
+'crazytermsapi');

+ 10 - 0
ext_tables.php

@@ -0,0 +1,10 @@
+<?php
+
+defined('TYPO3_MODE') || die('Access denied.');
+
+call_user_func(
+    function( $extKey )
+	{
+		
+	},
+'crazytermsapi');

+ 43 - 0
ext_tables.sql

@@ -0,0 +1,43 @@
+#
+# Table structure for table 'tx_crazytermsapi_domain_model_entry'
+#
+CREATE TABLE tx_crazytermsapi_domain_model_entry (
+
+	uid int(11) NOT NULL auto_increment,
+	pid int(11) DEFAULT '0' NOT NULL,
+
+	title varchar(255) DEFAULT '' NOT NULL,
+	files text DEFAULT '' NOT NULL,
+		
+	fe_user int(11) unsigned DEFAULT '0' NOT NULL,
+	tstamp int(11) unsigned DEFAULT '0' NOT NULL,
+	crdate int(11) unsigned DEFAULT '0' NOT NULL,
+	cruser_id int(11) unsigned DEFAULT '0' NOT NULL,
+	deleted tinyint(4) unsigned DEFAULT '0' NOT NULL,
+	hidden tinyint(4) unsigned DEFAULT '0' NOT NULL,
+	starttime int(11) unsigned DEFAULT '0' NOT NULL,
+	endtime int(11) unsigned DEFAULT '0' NOT NULL,
+ 	fe_group varchar(100) DEFAULT '0' NOT NULL,
+ 
+	t3ver_oid int(11) DEFAULT '0' NOT NULL,
+	t3ver_id int(11) DEFAULT '0' NOT NULL,
+	t3ver_wsid int(11) DEFAULT '0' NOT NULL,
+	t3ver_label varchar(255) DEFAULT '' NOT NULL,
+	t3ver_state tinyint(4) DEFAULT '0' NOT NULL,
+	t3ver_stage int(11) DEFAULT '0' NOT NULL,
+	t3ver_count int(11) DEFAULT '0' NOT NULL,
+	t3ver_tstamp int(11) DEFAULT '0' NOT NULL,
+	t3ver_move_id int(11) DEFAULT '0' NOT NULL,
+	sorting int(11) DEFAULT '0' NOT NULL,
+	
+	sys_language_uid int(11) DEFAULT '0' NOT NULL,
+	l10n_parent int(11) DEFAULT '0' NOT NULL,
+	l10n_diffsource mediumtext,
+	l10n_source int(11) DEFAULT '0' NOT NULL,
+
+	PRIMARY KEY (uid),
+	KEY parent (pid),
+	KEY t3ver_oid (t3ver_oid,t3ver_wsid),
+ 	KEY language (l10n_parent,sys_language_uid)
+
+);