Parcourir la source

create new component

jabongwa il y a 2 ans
Parent
commit
638f795f6a

+ 61 - 14
Classes/Hooks/TCE/TCEMainHook.php

@@ -56,6 +56,17 @@ class TCEMainHook
         'default_hero_lte600' => array('width' => 560, 'height' => 373),
       )
     ),
+    'mrm_be_cm_dynamic_tileexternaloverview' => array(
+      'default' => array(
+        'default_hero_lte600' => array('width' => 560, 'height' => 373),
+      ),
+      'i_1_1' => array(
+        'square_big' => array('width' => 520, 'height' => 520),
+      ),
+      'i_21_9' => array(
+        'flat_big' => array('width' => 700, 'height' => 300),
+      ),
+    ),
     'mrm_be_cm_heroimage' => array(
       'default' => array(
         'lte600' => array('width' => 560, 'height' => 373),
@@ -223,7 +234,7 @@ class TCEMainHook
         continue;
       }
 
-      $qrfilename = '/var/www/html/public/typo3temp/' . mt_rand(0, 0xffffff) . '_' . mt_rand(0, 0xffffff) . '.svg';
+      $qrfilename = '/var/www/html/typo3temp/' . mt_rand(0, 0xffffff) . '_' . mt_rand(0, 0xffffff) . '.svg';
       \QRcode::svg("https://abi.de" . $slugData, $qrfilename);
       $qrsvg = file_get_contents($qrfilename);
       unlink($qrfilename);
@@ -1597,8 +1608,7 @@ class TCEMainHook
             } else {
               $cleaned[$new_value]['text'] = $val;
             }
-          }
-          elseif (strpos($key, 'url') != false) {
+          } elseif (strpos($key, 'url') != false) {
             $new_value = str_replace('url', '', $key);
             if (!array_key_exists($new_value, $cleaned)) {
               continue;
@@ -1609,27 +1619,25 @@ class TCEMainHook
         }
 
         $data = [];
-        foreach($cleaned as $k => $val) {
-          foreach($val as $field => $value) {
-            if(isset($value) && !empty($value)) {
+        foreach ($cleaned as $k => $val) {
+          foreach ($val as $field => $value) {
+            if (isset($value) && !empty($value)) {
               $data[$k][$field] = $value;
-            }
-            else {
+            } else {
               continue;
             }
           }
-
         }
 
-        foreach($data as $key => $value) {
+        foreach ($data as $key => $value) {
           $box = $this->createContentElement("boxwrapper");
-          if(isset($value['headline']) && !empty($value['headline'])) {
+          if (isset($value['headline']) && !empty($value['headline'])) {
             $box["subElements"] = array_merge($box["subElements"], $this->checkText($value['headline'], $dbReference, $processedData, "h3"));
           }
-          if(isset($value['text']) && !empty($value['text'])) {
+          if (isset($value['text']) && !empty($value['text'])) {
             $box["subElements"] = array_merge($box["subElements"], $this->checkText($value['text'], $dbReference, $processedData, "typo3_paragraph"));
           }
-          if(isset($value['url']) && !empty($value['url'])) {
+          if (isset($value['url']) && !empty($value['url'])) {
             $box["subElements"] = array_merge($box["subElements"], $this->checkText($value['url'], $dbReference, $processedData, "link"));
           }
           $elements[] = $box;
@@ -2033,6 +2041,24 @@ class TCEMainHook
         $subs[] = $s;
         $processedData["status"]["hasQuiz"] = true;
         break;
+      case "mrm_be_cm_dynamic_tileexternaloverview":
+        $type = "tile_external";
+        $prop = [];
+        $elements = [];
+
+        $imageData  =  $this->processImagesTTContent($dbReference, "mrm_be_cm_dynamic_tileexternaloverview");
+
+        foreach ($imageData as $key => $val) {
+          foreach ($val as $k => $field) {
+            $prop[$key]['type'] = 'tile_external';
+            if ($k === 'title') $prop[$key]['props']['headline'] = $field;
+            if ($k === 'caption') $prop[$key]['props']['description'] = $field;
+            if ($k === 'sources') $prop[$key]['props']['image']['sources'] = $field;
+            if ($k === 'link') $prop[$key]['props']['link'] = $this->processLink($field, null, $processedData);
+          }
+        }
+        $subs[] = $this->createContentElement('external_tileoverview', array(), null, $prop);
+        break;
 
       default:
         $this->log("MISSING PROCESSDATA 4 " . $dbReference['CType']);
@@ -2041,6 +2067,23 @@ class TCEMainHook
     }
   }
 
+  private function processLink($link, $dbReference, &$processedData)
+  {
+    $cleanedLink = [];
+    if (substr($link, 0, 2) === 't3') {
+      $parts = explode(' ', $link);
+      $cleanedLink['href'] = $this->replaceT3Link($parts[0], $dbReference, $processedData);
+      $cleanedLink['target'] = '_top';
+      //$cleanedLink['title'] = $parts[3] ?? '';
+    } else {
+      $parts = explode(' ', $link);
+      $cleanedLink['href'] = $parts[0];
+      $cleanedLink['target'] = $parts[1];
+      //$cleanedLink['title'] = $parts[3] ?? '';
+    }
+    return $cleanedLink;
+  }
+
   private function checkText($txt, $dbReference, &$processedData, $defaultElementType = "typo3_paragraph")
   {
     $txt = $this->checkTextForInternalLinks($txt, $dbReference, $processedData);
@@ -2297,10 +2340,14 @@ class TCEMainHook
       $alt = $img['reference']['alternative'] != NULL ? $img['reference']['alternative'] : ($img['original']['alternative'] != NULL ? $img['original']['alternative'] : NULL);
       $title = $img['reference']['title'] != NULL ? $img['reference']['title'] : ($img['original']['title'] != NULL ? $img['original']['title'] : NULL);
       $caption = $img['reference']['description'] != NULL ? $img['reference']['description'] : ($img['original']['description'] != NULL ? $img['original']['description'] : NULL);
+      $link = $img['reference']['link'] != NULL ? $img['reference']['link'] : ($img['original']['link'] != NULL ? $img['original']['link'] : NULL);
+
       $copyright = $img['reference']['copyright'] != NULL ? $img['reference']['copyright'] : ($img['original']['copyright'] != NULL ? $img['original']['copyright'] : NULL);
       if ($alt != NULL) $processArray['alt'] = $alt;
       if ($title != NULL) $processArray['title'] = $title;
       if ($caption != NULL) $processArray['caption'] = $caption;
+      if ($link != NULL) $processArray['link'] = $link;
+
       if ($copyright != NULL) $processArray['copyright'] = $copyright;
 
       if ($cropareas['passthru']) {
@@ -2479,6 +2526,6 @@ class TCEMainHook
     if (!$isString) {
       $msg = json_encode($msg, JSON_PRETTY_PRINT);
     }
-    file_put_contents('/var/www/html/public/typo3temp/debug.log', $msg . PHP_EOL, FILE_APPEND);
+    file_put_contents('/var/www/html/typo3temp/debug.log', $msg . PHP_EOL, FILE_APPEND);
   }
 }

+ 107 - 0
Configuration/FlexForms/dynamictileexternaloverview.xml

@@ -0,0 +1,107 @@
+<T3DataStructure>
+	<meta>
+		<langDisable>1</langDisable>
+	</meta>
+	<sheets>
+	<sIMAGES>
+      <ROOT>
+        <sheetTitle>LLL:EXT:mrm_be/Resources/Private/Language/locallang_ttc.xlf:mrm_be_cm_dynamic_tileexternalverview.sheetTitle.tiles</sheetTitle>
+        <type>array</type>
+        <el>
+          <images>
+            <TCEforms>
+              <label>LLL:EXT:mrm_be/Resources/Private/Language/locallang_ttc.xlf:mrm_be_cm_dynamic_tileexternaloverview.link</label>
+              <config>
+                <type>inline</type>
+                <foreign_table>sys_file_reference</foreign_table>
+                <foreign_table_field>tablenames</foreign_table_field>
+                <foreign_label>uid_local</foreign_label>
+                <foreign_sortby>sorting_foreign</foreign_sortby>
+                <foreign_field>uid_foreign</foreign_field>
+                <foreign_selector>uid_local</foreign_selector>
+                <foreign_selector_fieldTcaOverride>
+                  <config>
+                    <appearance>
+                      <elementBrowserType>file</elementBrowserType>
+                      <elementBrowserAllowed>gif,jpg,jpeg,png,svg</elementBrowserAllowed>
+                    </appearance>
+                  </config>
+                </foreign_selector_fieldTcaOverride>
+                <foreign_types type="array">
+                  <numIndex index="0">
+                    <showitem>--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,--palette--;;filePalette</showitem>
+                  </numIndex>
+                  <numIndex index="2">
+                    <showitem>--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,--palette--;;filePalette</showitem>
+                  </numIndex>
+                </foreign_types>
+                <foreign_match_fields>
+                  <fieldname>image</fieldname>
+                  <!-- CAUTION!! Replace "fal" with the variable name of this field! -->
+                </foreign_match_fields>
+                <appearance type="array">
+                  <fileUploadAllowed>0</fileUploadAllowed>
+                  <newRecordLinkAddTitle>1</newRecordLinkAddTitle>
+                  <headerThumbnail>
+                    <field>uid_local</field>
+                    <height>64</height>
+                    <width>64</width>
+                  </headerThumbnail>
+                  <enabledControls>
+                    <info>1</info>
+                    <new>0</new>
+                    <dragdrop>0</dragdrop>
+                    <sort>1</sort>
+                    <hide>0</hide>
+                    <delete>1</delete>
+                    <localize>0</localize>
+                  </enabledControls>
+                  <createNewRelationLinkTitle>LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:images.addFileReference</createNewRelationLinkTitle>
+                </appearance>
+                <behaviour>
+                  <localizationMode>select</localizationMode>
+                  <localizeChildrenAtParentLocalization>1</localizeChildrenAtParentLocalization>
+                </behaviour>
+                <overrideChildTca>
+                  <columns type="array">
+                    <uid_local type="array">
+                      <config type="array">
+                        <appearance type="array">
+                          <elementBrowserType>file</elementBrowserType>
+                          <elementBrowserAllowed>jpg,png,svg,jpeg,gif</elementBrowserAllowed>
+                        </appearance>
+                      </config>
+                    </uid_local>
+                  </columns>
+                  <types type="array">
+                    <numIndex index="2">
+                      <showitem>--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,--palette--;;filePalette</showitem>
+                    </numIndex>
+                  </types>
+                </overrideChildTca>
+              </config>
+            </TCEforms>
+          </images>
+        </el>
+      </ROOT>
+    </sIMAGES>	
+		<sSETTINGS>
+			<ROOT>
+				<sheetTitle>LLL:EXT:mrm_be/Resources/Private/Language/locallang_ttc.xlf:mrm_be_cm_dynamic_tileoverview.sheetTitle.settings</sheetTitle>
+				<type>array</type>
+				<el>
+					<cssClass>
+						<TCEforms>
+							<label>LLL:EXT:mrm_be/Resources/Private/Language/locallang_ttc.xlf:mrm_be_cm_dynamic_tileoverview.settings.css</label>
+							<config>
+								<type>input</type>
+								<eval>trim</eval>
+								<cols>200</cols>
+							</config>
+						</TCEforms>
+					</cssClass>
+				</el>
+			</ROOT>
+		</sSETTINGS>
+	</sheets>
+</T3DataStructure>

+ 16 - 0
Configuration/TCA/Overrides/custom_components/dynamictileexternaloverview.php

@@ -0,0 +1,16 @@
+<?php
+
+\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTcaSelectItem(
+   'tt_content',
+   'CType',
+    [
+        'LLL:EXT:mrm_be/Resources/Private/Language/locallang_ttc.xlf:mrm_be_cm_dynamic_tileexternaloverview.title',
+        'mrm_be_cm_dynamic_tileexternaloverview',
+        'mrm_be_cm_dynamic_tileexternaloverview_icon',
+    ]
+);
+
+$GLOBALS['TCA']['tt_content']['columns']['pi_flexform']['config']['ds'][',mrm_be_cm_dynamic_tileexternaloverview'] = 'FILE:EXT:mrm_be/Configuration/FlexForms/dynamictileexternaloverview.xml';
+$GLOBALS['TCA']['tt_content']['types']['mrm_be_cm_dynamic_tileexternaloverview'] = [
+    'showitem' => 'CType;;;1-1-1,pi_flexform;LLL:EXT:mrm_be/Resources/Private/Language/locallang_ttc.xlf:mrm_be_cm_dynamic_tileexternaloverview.title,',
+];

+ 1 - 0
Configuration/TCA/Overrides/tt_content.php

@@ -29,6 +29,7 @@ require_once(dirname(__FILE__).'/custom_components/highlightbox.php');
 require_once(dirname(__FILE__).'/custom_components/statementbox.php');
 require_once(dirname(__FILE__).'/custom_components/explorerbox.php');
 require_once(dirname(__FILE__).'/custom_components/dynamictileoverview.php');
+require_once(dirname(__FILE__).'/custom_components/dynamictileexternaloverview.php');
 require_once(dirname(__FILE__).'/custom_components/menu.php');
 require_once(dirname(__FILE__).'/custom_components/picturechoice.php');
 require_once(dirname(__FILE__).'/custom_components/checklist-todo.php');

+ 8 - 0
Configuration/TsConfig/pageTsConfig.ts

@@ -711,6 +711,14 @@ mod {
             CType = mrm_be_cm_dynamic_tileoverview
           }
         }
+        mrm_be_cm_dynamic_tileexternaloverview {
+          title = LLL:EXT:mrm_be/Resources/Private/Language/locallang_ttc.xlf:mrm_be_cm_dynamic_tileexternaloverview.title
+          description = LLL:EXT:mrm_be/Resources/Private/Language/locallang_ttc.xlf:mrm_be_cm_dynamic_tileexternaloverview.description
+          iconIdentifier = mrm_be_cm_dynamic_tileexternaloverview_icon
+          tt_content_defValues {
+            CType = mrm_be_cm_dynamic_tileexternaloverview
+          }
+        }
         mrm_be_cm_publication {
           title = LLL:EXT:mrm_be/Resources/Private/Language/locallang_ttc.xlf:mrm_be_cm_publication.title
           description = LLL:EXT:mrm_be/Resources/Private/Language/locallang_ttc.xlf:mrm_be_cm_publication.description

+ 22 - 0
Resources/Private/Language/locallang_ttc.xlf

@@ -1259,6 +1259,28 @@
         <source>Custom CSS Class</source>
       </trans-unit>
 
+      <trans-unit id="mrm_be_cm_dynamic_tileexternaloverview.title">
+        <source>Kachelmatrix Extern</source>
+      </trans-unit>
+      <trans-unit id="mrm_be_cm_dynamic_tileexternaloverview.description">
+        <source>Eine dynamische Matrix aus verschiedenen Kacheln aus Externe Links</source>
+      </trans-unit>
+      <trans-unit id="mrm_be_cm_dynamic_tileexternalverview.sheetTitle.tiles">
+        <source>Kacheln</source>
+      </trans-unit>
+      <trans-unit id="mrm_be_cm_dynamic_tileexternaloverview.link">
+        <source>Extern Link</source>
+      </trans-unit>
+      <trans-unit id="mrm_be_cm_dynamic_tileoverview.sheetTitle.settings">
+        <source>Einstellungen</source>
+      </trans-unit>
+      <trans-unit id="mrm_be_cm_dynamic_tileoverview.settings.css">
+        <source>Custom CSS Class</source>
+      </trans-unit>
+      <trans-unit id="mrm_be_cm_dynamic_tileoexternalverview.image">
+        <source>Bild</source>
+      </trans-unit>
+
       <trans-unit id="mrm_be_cm_tileoverview.title">
         <source>Kachellinkliste</source>
       </trans-unit>

+ 0 - 21
Resources/Public/Icons/_mrm_be_cm_extra_infosbox_prefilled.svg

@@ -1,21 +0,0 @@
-<?xml version="1.0" standalone="no"?>
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
- "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
-<svg version="1.0" xmlns="http://www.w3.org/2000/svg" width="64.000000pt" height="64.000000pt" viewBox="0 0 16 16"
- preserveAspectRatio="xMidYMid meet">
-
-<g transform="translate(0.000000,64.000000) scale(0.100000,-0.100000)"
-fill="#000000" stroke="none">
-<path d="M346 605 c-17 -13 -16 -17 33 -67 l51 -53 25 28 c23 25 55 37 55 19
-0 -14 -65 -72 -80 -72 -8 0 -45 32 -82 72 l-66 73 -24 -22 c-13 -13 -34 -23
--47 -23 -12 0 -53 -24 -91 -52 -50 -39 -75 -67 -94 -106 -29 -58 -27 -79 5
--62 18 10 19 6 19 -125 l0 -135 203 0 203 0 52 65 c46 57 52 70 52 111 l0 46
--18 -22 c-23 -29 -34 -22 -69 42 l-28 52 -5 -135 -5 -134 -177 -3 -178 -2 0
-170 0 170 177 -2 178 -3 33 -55 c18 -30 37 -62 42 -70 7 -12 21 -3 71 47 l62
-61 -42 71 -42 71 -59 0 c-54 0 -63 3 -87 30 -29 33 -40 36 -67 15z m-167 -105
-c-19 -23 -41 -40 -53 -40 -12 0 -16 4 -10 9 11 12 88 70 92 71 2 0 -12 -18
--29 -40z"/>
-<path d="M180 370 c0 -6 32 -10 75 -10 43 0 75 4 75 10 0 6 -32 10 -75 10 -43
-0 -75 -4 -75 -10z"/>
-</g>
-</svg>

+ 23 - 0
Resources/Public/Icons/mrm_be_cm_dynamic_tileexternaloverview.svg

@@ -0,0 +1,23 @@
+<svg id="Ebene_1" data-name="Ebene 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">
+  <defs>
+    <style>
+      .cls-1 {
+        fill: #b30920;
+      }
+
+      .cls-2 {
+        fill: #c6c6c6;
+      }
+    </style>
+  </defs>
+  <g>
+    <rect class="cls-1" x="0.5" y="0.5" width="15" height="15"/>
+    <path class="cls-1" d="M15,1V15H1V1H15m1-1H0V16H16V0Z"/>
+  </g>
+  <rect class="cls-2" x="1" y="1" width="6" height="4"/>
+  <rect class="cls-2" x="9" y="1" width="6" height="4"/>
+  <rect class="cls-2" x="1" y="6" width="6" height="4"/>
+  <rect class="cls-2" x="9" y="6" width="6" height="4"/>
+  <rect class="cls-2" x="1" y="11" width="6" height="4"/>
+  <rect class="cls-2" x="9" y="11" width="6" height="4"/>
+</svg>

+ 2 - 0
ext_localconf.php

@@ -86,6 +86,7 @@ $iconRegistry->registerIcon( 'mrm_be_cm_themaderwoche_icon', TYPO3\CMS\Core\Imag
 $iconRegistry->registerIcon( 'mrm_be_cm_injection_icon', TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, ['source' => 'EXT:mrm_be/Resources/Public/Icons/mrm_be_cm_injection.svg'] );
 $iconRegistry->registerIcon( 'mrm_be_cm_tileoverview_icon', TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, ['source' => 'EXT:mrm_be/Resources/Public/Icons/mrm_be_cm_tileoverview.svg'] );
 $iconRegistry->registerIcon( 'mrm_be_cm_dynamic_tileoverview_icon', TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, ['source' => 'EXT:mrm_be/Resources/Public/Icons/mrm_be_cm_dynamic_tileoverview.svg'] );
+$iconRegistry->registerIcon( 'mrm_be_cm_dynamic_tileexternaloverview_icon', TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, ['source' => 'EXT:mrm_be/Resources/Public/Icons/mrm_be_cm_dynamic_tileexternaloverview.svg'] );
 $iconRegistry->registerIcon( 'mrm_be_cm_publication_icon', TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, ['source' => 'EXT:mrm_be/Resources/Public/Icons/mrm_be_cm_publication.svg'] );
 $iconRegistry->registerIcon( 'mrm_be_cm_homeheaderinfo_icon', TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, ['source' => 'EXT:mrm_be/Resources/Public/Icons/mrm_be_cm_homeheaderinfo.svg'] );
 $iconRegistry->registerIcon( 'mrm_be_cm_highlightbox_icon', TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, ['source' => 'EXT:mrm_be/Resources/Public/Icons/mrm_be_cm_highlightbox.svg'] );
@@ -114,6 +115,7 @@ $iconRegistry->registerIcon( 'mrm_be_cm_interviewantwort_icon', TYPO3\CMS\Core\I
 $iconRegistry->registerIcon( 'mrm_be_cm_foldout_h3_icon', TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, ['source' => 'EXT:mrm_be/Resources/Public/Icons/mrm_be_cm_foldout_h3.svg'] );
 $iconRegistry->registerIcon( 'mrm_be_cm_quiz_direct_icon', TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, ['source' => 'EXT:mrm_be/Resources/Public/Icons/mrm_be_cm_quiz_direct.svg'] );
 $iconRegistry->registerIcon( 'mrm_be_cm_extra_infosbox_prefilled_icon', TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, ['source' => 'EXT:mrm_be/Resources/Public/Icons/mrm_be_cm_extra_infosbox_prefilled.svg'] );
+$iconRegistry->registerIcon( 'mrm_be_cm_dynamic_tileexternaloverview_icon', TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, ['source' => 'EXT:mrm_be/Resources/Public/Icons/mrm_be_cm_dynamic_tileexternaloverview.svg'] );