Skip to content

Commit edfdb67

Browse files
authored
[FEATURE] Make confvals searchable (#745)
1 parent e2808cc commit edfdb67

File tree

20 files changed

+410
-492
lines changed

20 files changed

+410
-492
lines changed

Documentation-rendertest/Confval/ConfvalTrees.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Properties of CASE
1616
.. confval:: array of cObjects
1717
:name: case-array
1818
:type: cObject
19+
:searchFacet: TypoScript
1920

2021
Array of cObjects. Use this to define cObjects for the different
2122
values of `cobj-case-key`. If `cobj-case-key` has a certain value,
@@ -25,12 +26,14 @@ Properties of CASE
2526
.. confval:: cache
2627
:name: case-cache
2728
:type: cache
29+
:searchFacet: TypoScript
2830

2931
See for details.
3032

3133
.. confval:: default
3234
:name: case-default
3335
:type: cObject
36+
:searchFacet: TypoScript
3437

3538
Use this to define the rendering for *those* values of cobj-case-key that
3639
do *not* match any of the values of the cobj-case-array-of-cObjects. If no
@@ -40,6 +43,7 @@ Properties of CASE
4043
.. confval:: if
4144
:name: case-if
4245
:type: ->if
46+
:searchFacet: TypoScript
4347

4448
If if returns false, nothing is returned.
4549

@@ -55,19 +59,22 @@ Properties of COA
5559
.. confval:: 1,2,3,4...
5660
:name: coa-array
5761
:type: cObject
62+
:searchFacet: TCA
5863

5964
Numbered properties to define the different cObjects, which should be
6065
rendered.
6166

6267
.. confval:: cache
6368
:name: coa-cache
6469
:type: cache
70+
:searchFacet: TCA
6571

6672
See cache function description for details.
6773

6874
.. confval:: if
6975
:name: coa-if
7076
:type: ->if <if>
77+
:searchFacet: TCA
7178

7279
If `if` returns false, the COA is **not** rendered.
7380

Documentation-rendertest/guides.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
links-are-relative="true">
66
<extension class="\T3Docs\Typo3DocsTheme\DependencyInjection\Typo3DocsThemeExtension"
77
typo3-core-preferred="stable"
8+
confval-default="TCA"
89
/>
910
<project title="TYPO3 Theme Rendering Test"
1011
release="main"

packages/typo3-docs-theme/resources/template/body/directive/confval.html.twig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<section data-search-title="{{ node.plainContent }}" data-search-id="{{ node.anchor }}" data-search-facet="{{ filterAllowedSearchFacets(renderNode(node.additionalOptions.searchFacet)|default(getSettings('confval_default'))) }}">
12
<dl class="confval">
23
<dt{% if not node.noindex %} id="{{ node.anchor }}"{% endif %} class="d-flex justify-content-between">
34
<div class="confval-header">
@@ -35,9 +36,11 @@
3536
</dd>
3637
{% endif -%}
3738
{%- for key, option in node.additionalOptions -%}
39+
{%- if not key in ['searchFacet', 'searchKeywords'] %}
3840
<dt class="field-even">{{ key }}</dt>
3941
<dd class="field-even">{{ renderNode(option) }}
4042
</dd>
43+
{% endif -%}
4144
{% endfor -%}
4245
</dl>
4346
{% endif %}
@@ -46,3 +49,4 @@
4649
</div>
4750
</dd>
4851
</dl>
52+
</section>

packages/typo3-docs-theme/src/DependencyInjection/Typo3DocsThemeExtension.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public function load(array $configs, ContainerBuilder $container): void
6565
'project_issues' => $this->getConfigValue($configs, 'project_issues', ''),
6666
'report_issue' => $this->getConfigValue($configs, 'report_issue', ''),
6767
'typo3_core_preferred' => $this->getConfigValue($configs, 'typo3_core_preferred', ''),
68+
'confval_default' => $this->getConfigValue($configs, 'confval_default', 'Option'),
6869
],
6970
],
7071
);

packages/typo3-docs-theme/src/Nodes/ConfvalMenuNode.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public function __construct(
3333
private readonly bool $excludeNoindex = false,
3434
private readonly array $exclude = [],
3535
private readonly bool $noindex = false,
36+
private readonly string $facet = 'Option',
3637
) {
3738
parent::__construct('confval-menu', $plainContent, $content, $value);
3839
}
@@ -112,4 +113,9 @@ public function isNoindex(): bool
112113
{
113114
return $this->noindex;
114115
}
116+
117+
public function getFacet(): string
118+
{
119+
return $this->facet;
120+
}
115121
}

packages/typo3-docs-theme/src/Twig/TwigExtension.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,23 @@ public function getFunctions(): array
9191
new TwigFunction('getRstCodeForLink', $this->getRstCodeForLink(...), ['is_safe' => [], 'needs_context' => true]),
9292
new TwigFunction('isRenderedForDeployment', $this->isRenderedForDeployment(...)),
9393
new TwigFunction('replaceLineBreakOpportunityTags', $this->replaceLineBreakOpportunityTags(...), ['is_safe' => ['html'], 'needs_context' => false]),
94+
new TwigFunction('filterAllowedSearchFacets', $this->filterAllowedSearchFacets(...), ['is_safe' => ['html'], 'needs_context' => false]),
9495
];
9596
}
97+
public function filterAllowedSearchFacets(string $value): string
98+
{
99+
$allowed = [
100+
'TypoScript',
101+
'TSconfig',
102+
'ViewHelper',
103+
'TCA',
104+
'TYPO3_CONF_VAR',
105+
];
106+
if (!in_array(trim($value), $allowed, true)) {
107+
return 'Option';
108+
}
109+
return $value;
110+
}
96111
public function replaceLineBreakOpportunityTags(string $value): string
97112
{
98113
// as the result is html safe

tests/Integration/tests/confval/confval-basic/expected/index.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<!-- content start -->
22
<section class="section" id="confval">
33
<h1>Confval<a class="headerlink" href="#confval" data-bs-toggle="modal" data-bs-target="#linkReferenceModal" title="Reference this headline"></a></h1>
4-
<dl class="confval">
4+
<section data-search-title="demo" data-search-id="confval-demo" data-search-facet="Option">
5+
<dl class="confval">
56
<dt id="confval-demo" class="d-flex justify-content-between">
67
<div class="confval-header">
78
<code class="sig-name descname"><span class="pre">demo</span></code>
@@ -25,6 +26,7 @@ <h1>Confval<a class="headerlink" href="#confval" data-bs-toggle="modal" data-bs-
2526
</div>
2627
</dd>
2728
</dl>
29+
</section>
2830

2931
<p>See also <a href="#confval-demo">demo</a>.</p>
3032

tests/Integration/tests/confval/confval-duplicate-with-name/expected/anotherDomain.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<!-- content start -->
22
<section class="section" id="confval-in-another-domain">
33
<h1>Confval in another domain<a class="headerlink" href="#confval-in-another-domain" data-bs-toggle="modal" data-bs-target="#linkReferenceModal" title="Reference this headline"></a></h1>
4-
<dl class="confval">
4+
<section data-search-title="demo" data-search-id="confval-another-demo" data-search-facet="Option">
5+
<dl class="confval">
56
<dt id="confval-another-demo" class="d-flex justify-content-between">
67
<div class="confval-header">
78
<code class="sig-name descname"><span class="pre">demo</span></code>
@@ -25,5 +26,6 @@ <h1>Confval in another domain<a class="headerlink" href="#confval-in-another-dom
2526
</div>
2627
</dd>
2728
</dl>
29+
</section>
2830
</section>
2931
<!-- content end -->

tests/Integration/tests/confval/confval-duplicate-with-name/expected/index.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<!-- content start -->
22
<section class="section" id="confval">
33
<h1>Confval<a class="headerlink" href="#confval" data-bs-toggle="modal" data-bs-target="#linkReferenceModal" title="Reference this headline"></a></h1>
4-
<dl class="confval">
4+
<section data-search-title="demo" data-search-id="confval-demo" data-search-facet="Option">
5+
<dl class="confval">
56
<dt id="confval-demo" class="d-flex justify-content-between">
67
<div class="confval-header">
78
<code class="sig-name descname"><span class="pre">demo</span></code>
@@ -25,6 +26,7 @@ <h1>Confval<a class="headerlink" href="#confval" data-bs-toggle="modal" data-bs-
2526
</div>
2627
</dd>
2728
</dl>
29+
</section>
2830

2931
<p>See also <a href="#confval-demo">demo</a> and the config value in the other domain: <a href="anotherDomain.html#confval-another-demo">demo</a>.</p>
3032

tests/Integration/tests/confval/confval-duplicate/expected/anotherDomain.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<!-- content start -->
22
<section class="section" id="confval-in-another-domain">
33
<h1>Confval in another domain<a class="headerlink" href="#confval-in-another-domain" data-bs-toggle="modal" data-bs-target="#linkReferenceModal" title="Reference this headline"></a></h1>
4-
<dl class="confval">
4+
<section data-search-title="demo" data-search-id="confval-demo" data-search-facet="Option">
5+
<dl class="confval">
56
<dt id="confval-demo" class="d-flex justify-content-between">
67
<div class="confval-header">
78
<code class="sig-name descname"><span class="pre">demo</span></code>
@@ -25,5 +26,6 @@ <h1>Confval in another domain<a class="headerlink" href="#confval-in-another-dom
2526
</div>
2627
</dd>
2728
</dl>
29+
</section>
2830
</section>
2931
<!-- content end -->

tests/Integration/tests/confval/confval-duplicate/expected/index.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<!-- content start -->
22
<section class="section" id="confval">
33
<h1>Confval<a class="headerlink" href="#confval" data-bs-toggle="modal" data-bs-target="#linkReferenceModal" title="Reference this headline"></a></h1>
4-
<dl class="confval">
4+
<section data-search-title="demo" data-search-id="confval-demo" data-search-facet="Option">
5+
<dl class="confval">
56
<dt id="confval-demo" class="d-flex justify-content-between">
67
<div class="confval-header">
78
<code class="sig-name descname"><span class="pre">demo</span></code>
@@ -25,6 +26,7 @@ <h1>Confval<a class="headerlink" href="#confval" data-bs-toggle="modal" data-bs-
2526
</div>
2627
</dd>
2728
</dl>
29+
</section>
2830

2931
<p>See also <a href="anotherDomain.html#confval-demo">demo</a>.</p>
3032

tests/Integration/tests/confval/confval-menu-tree-anchor/expected/index.html

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ <h1>Confval<a class="headerlink" href="#confval" data-bs-toggle="modal" data-bs-
4545
</table>
4646
</div>
4747
<a id="case-array"></a>
48-
<dl class="confval">
48+
<section data-search-title="array of cObjects" data-search-id="confval-case-array" data-search-facet="Option">
49+
<dl class="confval">
4950
<dt id="confval-case-array" class="d-flex justify-content-between">
5051
<div class="confval-header">
5152
<code class="sig-name descname"><span class="pre">array of c<wbr>Objects</span></code>
@@ -69,8 +70,10 @@ <h1>Confval<a class="headerlink" href="#confval" data-bs-toggle="modal" data-bs-
6970
</div>
7071
</dd>
7172
</dl>
73+
</section>
7274
<a id="case-cache"></a>
73-
<dl class="confval">
75+
<section data-search-title="cache" data-search-id="confval-case-cache" data-search-facet="Option">
76+
<dl class="confval">
7477
<dt id="confval-case-cache" class="d-flex justify-content-between">
7578
<div class="confval-header">
7679
<code class="sig-name descname"><span class="pre">cache</span></code>
@@ -91,8 +94,10 @@ <h1>Confval<a class="headerlink" href="#confval" data-bs-toggle="modal" data-bs-
9194
</div>
9295
</dd>
9396
</dl>
97+
</section>
9498
<a id="case-default"></a>
95-
<dl class="confval">
99+
<section data-search-title="default" data-search-id="confval-case-default" data-search-facet="Option">
100+
<dl class="confval">
96101
<dt id="confval-case-default" class="d-flex justify-content-between">
97102
<div class="confval-header">
98103
<code class="sig-name descname"><span class="pre">default</span></code>
@@ -116,9 +121,11 @@ <h1>Confval<a class="headerlink" href="#confval" data-bs-toggle="modal" data-bs-
116121
</div>
117122
</dd>
118123
</dl>
124+
</section>
119125
<div class="rubric h2">Conditions</div>
120126
<a id="case-if"></a>
121-
<dl class="confval">
127+
<section data-search-title="if" data-search-id="confval-case-if" data-search-facet="Option">
128+
<dl class="confval">
122129
<dt id="confval-case-if" class="d-flex justify-content-between">
123130
<div class="confval-header">
124131
<code class="sig-name descname"><span class="pre">if</span></code>
@@ -139,6 +146,7 @@ <h1>Confval<a class="headerlink" href="#confval" data-bs-toggle="modal" data-bs-
139146
</div>
140147
</dd>
141148
</dl>
149+
</section>
142150

143151
</section>
144152
<!-- content end -->

tests/Integration/tests/confval/confval-menu-tree-multiple/expected/index.html

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ <h2>Properties of CASE<a class="headerlink" href="#properties-of-case" data-bs-t
4949

5050
</table>
5151
</div>
52-
<dl class="confval">
52+
<section data-search-title="array of cObjects" data-search-id="confval-case-array" data-search-facet="Option">
53+
<dl class="confval">
5354
<dt id="confval-case-array" class="d-flex justify-content-between">
5455
<div class="confval-header">
5556
<code class="sig-name descname"><span class="pre">array of c<wbr>Objects</span></code>
@@ -73,7 +74,9 @@ <h2>Properties of CASE<a class="headerlink" href="#properties-of-case" data-bs-t
7374
</div>
7475
</dd>
7576
</dl>
76-
<dl class="confval">
77+
</section>
78+
<section data-search-title="cache" data-search-id="confval-case-cache" data-search-facet="Option">
79+
<dl class="confval">
7780
<dt id="confval-case-cache" class="d-flex justify-content-between">
7881
<div class="confval-header">
7982
<code class="sig-name descname"><span class="pre">cache</span></code>
@@ -94,7 +97,9 @@ <h2>Properties of CASE<a class="headerlink" href="#properties-of-case" data-bs-t
9497
</div>
9598
</dd>
9699
</dl>
97-
<dl class="confval">
100+
</section>
101+
<section data-search-title="default" data-search-id="confval-case-default" data-search-facet="Option">
102+
<dl class="confval">
98103
<dt id="confval-case-default" class="d-flex justify-content-between">
99104
<div class="confval-header">
100105
<code class="sig-name descname"><span class="pre">default</span></code>
@@ -118,7 +123,9 @@ <h2>Properties of CASE<a class="headerlink" href="#properties-of-case" data-bs-t
118123
</div>
119124
</dd>
120125
</dl>
121-
<dl class="confval">
126+
</section>
127+
<section data-search-title="if" data-search-id="confval-case-if" data-search-facet="Option">
128+
<dl class="confval">
122129
<dt id="confval-case-if" class="d-flex justify-content-between">
123130
<div class="confval-header">
124131
<code class="sig-name descname"><span class="pre">if</span></code>
@@ -139,6 +146,7 @@ <h2>Properties of CASE<a class="headerlink" href="#properties-of-case" data-bs-t
139146
</div>
140147
</dd>
141148
</dl>
149+
</section>
142150

143151
</section>
144152
<section class="section" id="properties-of-coa">
@@ -179,7 +187,8 @@ <h2>Properties of COA<a class="headerlink" href="#properties-of-coa" data-bs-tog
179187

180188
</table>
181189
</div>
182-
<dl class="confval">
190+
<section data-search-title="1,2,3,4..." data-search-id="confval-coa-array" data-search-facet="Option">
191+
<dl class="confval">
183192
<dt id="confval-coa-array" class="d-flex justify-content-between">
184193
<div class="confval-header">
185194
<code class="sig-name descname"><span class="pre">1,2,3,4...</span></code>
@@ -201,7 +210,9 @@ <h2>Properties of COA<a class="headerlink" href="#properties-of-coa" data-bs-tog
201210
</div>
202211
</dd>
203212
</dl>
204-
<dl class="confval">
213+
</section>
214+
<section data-search-title="cache" data-search-id="confval-coa-cache" data-search-facet="Option">
215+
<dl class="confval">
205216
<dt id="confval-coa-cache" class="d-flex justify-content-between">
206217
<div class="confval-header">
207218
<code class="sig-name descname"><span class="pre">cache</span></code>
@@ -222,7 +233,9 @@ <h2>Properties of COA<a class="headerlink" href="#properties-of-coa" data-bs-tog
222233
</div>
223234
</dd>
224235
</dl>
225-
<dl class="confval">
236+
</section>
237+
<section data-search-title="if" data-search-id="confval-coa-if" data-search-facet="Option">
238+
<dl class="confval">
226239
<dt id="confval-coa-if" class="d-flex justify-content-between">
227240
<div class="confval-header">
228241
<code class="sig-name descname"><span class="pre">if</span></code>
@@ -243,6 +256,7 @@ <h2>Properties of COA<a class="headerlink" href="#properties-of-coa" data-bs-tog
243256
</div>
244257
</dd>
245258
</dl>
259+
</section>
246260

247261
</section>
248262
</section>

0 commit comments

Comments
 (0)