-
Notifications
You must be signed in to change notification settings - Fork 33
/
single-notizia.php
executable file
·263 lines (257 loc) · 15.6 KB
/
single-notizia.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
<?php
/**
* Notizia template file
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
*
* @package Design_Comuni_Italia
*/
global $uo_id, $inline;
get_header();
?>
<main>
<?php
while ( have_posts() ) :
the_post();
$user_can_view_post = dci_members_can_user_view_post(get_current_user_id(), $post->ID);
$prefix= '_dci_notizia_';
$descrizione_breve = dci_get_meta("descrizione_breve", $prefix, $post->ID);
$data_pubblicazione_arr = dci_get_data_pubblicazione_arr("data_pubblicazione", $prefix, $post->ID);
$date = date_i18n('d F Y', mktime(0, 0, 0, $data_pubblicazione_arr[1], $data_pubblicazione_arr[0], $data_pubblicazione_arr[2]));
$persone = dci_get_meta("persone", $prefix, $post->ID);
$descrizione = dci_get_wysiwyg_field("testo_completo", $prefix, $post->ID);
$documenti = dci_get_meta("documenti", $prefix, $post->ID);
$allegati = dci_get_meta("allegati", $prefix, $post->ID);
$datasets = dci_get_meta("dataset", $prefix, $post->ID);
$a_cura_di = dci_get_meta("a_cura_di", $prefix, $post->ID);
?>
<div class="container" id="main-container">
<div class="row">
<div class="col px-lg-4">
<?php get_template_part("template-parts/common/breadcrumb"); ?>
</div>
</div>
<div class="row">
<div class="col-lg-8 px-lg-4 py-lg-2">
<h1 data-audio><?php the_title(); ?></h1>
<h2 class="visually-hidden" data-audio>Dettagli della notizia</h2>
<p data-audio>
<?php echo $descrizione_breve; ?>
</p>
<div class="row mt-5 mb-4">
<div class="col-6">
<small>Data:</small>
<p class="fw-semibold font-monospace">
<?php echo $date; ?>
</p>
</div>
<div class="col-6">
<small>Tempo di lettura:</small>
<p class="fw-semibold" id="readingTime"></p>
</div>
</div>
</div>
<div class="col-lg-3 offset-lg-1">
<?php
$inline = true;
get_template_part('template-parts/single/actions');
?>
</div>
</div>
</div>
<?php get_template_part('template-parts/single/image-large'); ?>
<div class="container">
<div class="row border-top border-light row-column-border row-column-menu-left">
<aside class="col-lg-4">
<div class="cmp-navscroll sticky-top" aria-labelledby="accordion-title-one">
<nav class="navbar it-navscroll-wrapper navbar-expand-lg" aria-label="Indice della pagina" data-bs-navscroll>
<div class="navbar-custom" id="navbarNavProgress">
<div class="menu-wrapper">
<div class="link-list-wrapper">
<div class="accordion">
<div class="accordion-item">
<span class="accordion-header" id="accordion-title-one">
<button
class="accordion-button pb-10 px-3 text-uppercase"
type="button"
aria-controls="collapse-one"
aria-expanded="true"
data-bs-toggle="collapse"
data-bs-target="#collapse-one"
>INDICE DELLA PAGINA
<svg class="icon icon-sm icon-primary align-top">
<use xlink:href="#it-expand"></use>
</svg>
</button>
</span>
<div class="progress">
<div class="progress-bar it-navscroll-progressbar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
</div>
<div id="collapse-one" class="accordion-collapse collapse show" role="region" aria-labelledby="accordion-title-one">
<div class="accordion-body">
<ul class="link-list" data-element="page-index">
<li class="nav-item">
<a class="nav-link" href="#descrizione">
<span>Descrizione</span>
</a>
</li>
<?php if( is_array($documenti) && count($documenti) ) { ?>
<li class="nav-item">
<a class="nav-link" href="#documenti">
<span>Documenti</span>
</a>
</li>
<?php } ?>
<?php if( is_array($allegati) && count($allegati) ) { ?>
<li class="nav-item">
<a class="nav-link" href="#allegati">
<span>Allegati</span>
</a>
</li>
<?php } ?>
<?php if( is_array($datasets) && count($datasets) ) { ?>
<li class="nav-item">
<a class="nav-link" href="#dataset">
<span>Dataset</span>
</a>
</li>
<?php } ?>
<li class="nav-item">
<a class="nav-link" href="#a-cura-di">
<span>A cura di</span>
</a>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</nav>
</div>
</aside>
<section class="col-lg-8 it-page-sections-container border-light">
<article class="it-page-section anchor-offset" data-audio>
<h4 id="descrizione">Descrizione</h4>
<div class="richtext-wrapper lora">
<?php echo $descrizione; ?>
</div>
</article>
<?php if( is_array($documenti) && count($documenti) ) { ?>
<article class="it-page-section anchor-offset mt-5">
<h4 id="documenti">Documenti</h4>
<div class="card-wrapper card-teaser-wrapper card-teaser-wrapper-equal">
<?php foreach ($documenti as $doc_id) {
$documento = get_post($doc_id);
?>
<div class="card card-teaser shadow-sm p-4 mt-3 rounded border border-light flex-nowrap">
<svg class="icon" aria-hidden="true">
<use
xlink:href="#it-clip"
></use>
</svg>
<div class="card-body">
<h5 class="card-title">
<a class="text-decoration-none" href="<?php echo get_permalink($doc_id); ?>" aria-label="Visualizza il documento <?php echo $documento->post_title; ?>" title="Visualizza il documento <?php echo $documento->post_title; ?>">
<?php echo $documento->post_title; ?>
</a>
</h5>
</div>
</div>
<?php } ?>
</div>
</article>
<?php } ?>
<?php if( is_array($allegati) && count($allegati) ) { ?>
<article class="it-page-section anchor-offset mt-5">
<h4 id="allegati">Allegati</h4>
<div class="card-wrapper card-teaser-wrapper card-teaser-wrapper-equal">
<?php foreach ($allegati as $all_url) {
$all_id = attachment_url_to_postid($all_url);
$allegato = get_post($all_id);
?>
<div class="card card-teaser shadow-sm p-4 mt-3 rounded border border-light flex-nowrap">
<svg class="icon" aria-hidden="true">
<use
xlink:href="#it-clip"
></use>
</svg>
<div class="card-body">
<h5 class="card-title">
<a class="text-decoration-none" href="<?php echo get_the_guid($allegato); ?>" aria-label="Scarica l'allegato <?php echo $allegato->post_title; ?>" title="Scarica l'allegato <?php echo $allegato->post_title; ?>">
<?php echo $allegato->post_title; ?>
</a>
</h5>
</div>
</div>
<?php } ?>
</div>
</article>
<?php } ?>
<?php if( is_array($datasets) && count($datasets) ) { ?>
<article class="it-page-section anchor-offset mt-5">
<h4 id="dataset">Dataset</h4>
<div class="card-wrapper card-teaser-wrapper card-teaser-wrapper-equal">
<?php foreach ($datasets as $dataset_id) {
$dataset = get_post($dataset_id);
?>
<div class="card card-teaser shadow-sm p-4 mt-3 rounded border border-light flex-nowrap">
<svg class="icon" aria-hidden="true">
<use
xlink:href="#it-clip"
></use>
</svg>
<div class="card-body">
<h5 class="card-title">
<a class="text-decoration-none" href="<?php echo get_permalink($dataset_id); ?>" aria-label="Visualizza il dataset <?php echo $dataset->post_title; ?>" title="Visualizza il dataset <?php echo $dataset->post_title; ?>">
<?php echo $dataset->post_title; ?>
</a>
</h5>
</div>
</div>
<?php } ?>
</div>
</article>
<?php } ?>
<article class="it-page-section anchor-offset mt-5">
<h4 id="a-cura-di">A cura di</h4>
<div class="row">
<div class="col-12 col-sm-8">
<h6><small>Questa pagina è gestita da</small></h6>
<?php foreach ($a_cura_di as $uo_id) {
$with_border = true;
get_template_part("template-parts/unita-organizzativa/card");
} ?>
</div>
<?php if(is_array($persone) && count($persone)) { ?>
<div class="col-12 col-sm-4">
<h6><small>Persone</small></h6>
<?php get_template_part("template-parts/single/persone"); ?>
</div>
<?php } ?>
</div>
</article>
<!-- <article
id="ulteriori-informazioni"
class="it-page-section anchor-offset mt-5"
>
<h4 class="mb-3">Ulteriori informazioni</h4>
</article> -->
<?php get_template_part('template-parts/single/page_bottom'); ?>
</section>
</div>
</div>
<?php get_template_part("template-parts/common/valuta-servizio"); ?>
<?php
endwhile; // End of the loop.
?>
</main>
<script>
const descText = document.querySelector('#descrizione')?.closest('article').innerText;
const wordsNumber = descText.split(' ').length
document.querySelector('#readingTime').innerHTML = `${Math.ceil(wordsNumber / 200)} min`;
</script>
<?php
get_footer();