PluginProbe
ANAC XML Bandi di Gara / 3
ANAC XML Bandi di Gara v3
7.8 trunk 0.1 1.0.0.1 1.0.1 1.0.2 1.0.3 1.0.4 1.1 1.1.1 1.1.2 2.0 2.0.1 2.0.2 2.0.3 2.1 2.2 2.3 2.3.1 3 3.0.1 3.1 3.1.1 3.1.2 3.1.3 All 57 releases
← All changes | singlehack.php +86 -383 trunk3 View file →
@@ -1,388 +1,91 @@
1 1 <?php
2 -/**
3 - * AVCP Single Post Content Filter
4 - *
5 - * Enhances the content display for AVCP post types with additional metadata
6 - * and contractor information.
7 - *
8 - * @package AVCP
9 - * @since 1.0.0
10 - */
11 -
12 -// Prevent direct access
13 -if (!defined('ABSPATH')) {
14 - exit;
2 +add_action('template_redirect', 'avcp_job_cpt_template');
3 +function avcp_job_cpt_template()
4 +{
5 + global $wp, $wp_query;
6 + if (isset($wp->query_vars['post_type']) && $wp->query_vars['post_type'] == 'avcp') {
7 + if (have_posts()) {
8 + add_filter('the_content', 'avcp_job_cpt_template_filter');
9 + } else {
10 + $wp_query->is_404 = true;
11 + }
12 + }
15 13 }
14 +function avcp_job_cpt_template_filter($content)
15 +{
16 + global $wp_query;
17 + $jobID = $wp_query->post->ID;
18 + //echo get_post_meta(get_the_ID(), 'ammap_wysiwyg', true) . '<br/>';
16 19
17 -/**
18 - * AVCP Single Post Content Filter
19 - *
20 - * Enhances the content display for AVCP post types with additional metadata
21 - * and contractor information.
22 - *
23 - * @package AVCP
24 - * @since 1.0.0
25 - */
20 + echo '<br/>';
21 + echo '<table>';
22 + echo '<tr><td>CIG:</td><td>' . get_post_meta(get_the_ID(), 'avcp_cig', true) . '</td></tr>';
23 + echo '<tr><td>Struttura proponente:</td><td>' . get_option('avcp_denominazione_ente') . '<br/>' . get_option('avcp_codicefiscale_ente') . '</td></tr>';
24 + echo '<tr><td>Oggetto del bando:</td><td>' . get_the_title(get_the_ID()) . '</td></tr>';
25 + echo '<tr><td>Procedura di scelta del contraente:</td><td>' . get_post_meta(get_the_ID(), 'avcp_contraente', true) . '</td></tr>';
26 + echo '<tr><td>Importo di aggiudicazione:</td><td>' . get_post_meta(get_the_ID(), 'avcp_aggiudicazione', true) . '</td></tr>';
27 + echo '<tr><td>Data di effettivo inizio:</td><td>' . date("d F Y", strtotime(get_post_meta(get_the_ID(), 'avcp_data_inizio', true))) . '</td></tr>';
28 + echo '<tr><td>Data di ultimazione:</td><td>' . date("d F Y", strtotime(get_post_meta(get_the_ID(), 'avcp_data_fine', true))) . '</td></tr>';
29 + echo '<tr><td>Importo delle somme liquidate:</td><td>' . get_post_meta(get_the_ID(), 'avcp_somme_liquidate', true) . '</td></tr>';
30 + echo '<tr><td>Anno di riferimento:</td><td>';
31 + $get_avcp_dis_archivioanni = get_option('avcp_dis_archivioanni');
32 + if ($get_avcp_dis_archivioanni == '1') {
33 + echo strip_tags (
34 + get_the_term_list( $post->ID, 'annirif', '', ' - ', '' )
35 + );
36 + } else {
37 + echo get_the_term_list( $post->ID, 'annirif', '', ' - ', '' );
38 + }
39 + echo '</td></tr>';
40 + echo '</table>';
41 + echo '<h3>Elenco degli operatori partecipanti</h3>';
26 42
27 -// Prevent direct access
28 -if (!defined('ABSPATH')) {
29 - exit;
43 + echo '<table>';
44 + $terms = get_the_terms( $post->ID, 'ditte' );
45 + if ($terms) {
46 + foreach($terms as $term) {
47 + $get_term = get_term_by('name', $term->name, 'ditte');
48 + $t_id = $get_term->term_id;
49 + $term_meta = get_option( "taxonomy_$t_id" );
50 + $term_return = esc_attr( $term_meta['avcp_codice_fiscale'] );
51 + $stato_var = get_tax_meta($t_id,'avcp_is_ditta_estera');
52 + if (empty($stato_var)) {$is_estera = 'IT';}else{$is_estera = 'EE';}
53 + echo '<tr>
54 + <td><a href="' . get_term_link( $t_id, 'ditte' ) . '" title="' . $term->name . '">' . $term->name . '</a></td>
55 + <td>' . $term_return . ' - <b>' . $is_estera . '</b></td>
56 + </tr>';
57 + }
58 + }
59 + echo '</table>';
60 +
61 + echo '<h3>Aggiudicatari</h3>';
62 + echo '<table>';
63 + global $post;
64 + $dittepartecipanti = get_the_terms( $post->ID, 'ditte' );
65 + $cats = get_post_meta($post->ID,'avcp_aggiudicatari',true);
66 + if(is_array($dittepartecipanti)) {
67 + foreach ($dittepartecipanti as $term) {
68 + $cterm = get_term_by('name',$term->name,'ditte');
69 + $cat_id = $cterm->term_id; //Prende l'id del termine
70 + $term_meta = get_option( "taxonomy_$cat_id" );
71 + $term_return = esc_attr( $term_meta['avcp_codice_fiscale'] );
72 + $checked = (in_array($cat_id,(array)$cats)? ' checked="checked"': "");
73 + $stato_var = get_tax_meta($cat_id,'avcp_is_ditta_estera');
74 + if (empty($stato_var)) {$is_estera = 'IT';}else{$is_estera = 'EE';}
75 + if ($checked) {
76 + echo '<tr>
77 + <td><a href="' . get_term_link( $cterm->term_id, 'ditte' ) . '" title="' . $term->name . '">' . $term->name . '</a></td>
78 + <td>' . $term_return . ' - <b>' . $is_estera . '</b></td>
79 + </tr>';
80 + }
81 + }
82 + }
83 +
84 + echo '</table>';
85 +
86 + $get_avcp_showlove = get_option('avcp_showlove');
87 + if ($get_avcp_showlove == '1') {
88 + echo '<center><small>Vista generata con il plugin <a href="http://wordpress.org/plugins/avcp/" target="_blank" title="AVCP Wordpress Plugin">AVCP XML per Wordpress</a></small></center>';
89 + }
30 90 }
31 -
32 -/**
33 - * Generates the basic contract information table
34 - *
35 - * @param int $post_id The post ID
36 - * @param array $options Cached options array
37 - * @return string HTML table content
38 - */
39 -function avcp_generate_contract_info_table($post_id, $options) {
40 - $html = '<table>';
41 -
42 - // CIG
43 - $html .= '<tr><td><acronym title="' . esc_attr__('Codice Identificativo Gara', 'avcp') . '">CIG:</acronym></td><td>' . esc_html(get_post_meta($post_id, 'avcp_cig', true)) . '</td></tr>';
44 -
45 - // Proposing structure
46 - $html .= '<tr><td>' . esc_html__('Struttura proponente:', 'avcp') . '</td><td>' . esc_html($options['denominazione_ente']);
47 -
48 - // Area sectors
49 - $html .= avcp_generate_area_sectors($post_id);
50 -
51 - $html .= '<br/>' . esc_html($options['codicefiscale_ente']) . '</td></tr>';
52 -
53 - // Contract details
54 - $html .= '<tr><td>' . esc_html__('Oggetto del bando:', 'avcp') . '</td><td>' . esc_html(get_the_title($post_id)) . '</td></tr>';
55 -
56 - // Check if avcp_get_contraente function exists
57 - if (function_exists('avcp_get_contraente')) {
58 - $contraente = avcp_get_contraente(get_post_meta($post_id, 'avcp_contraente', true));
59 - $html .= '<tr><td>' . esc_html__('Procedura di scelta del contraente:', 'avcp') . '</td><td>' . esc_html(strtolower($contraente)) . '</td></tr>';
60 - }
61 -
62 - // Award amount
63 - $aggiudicazione_amount = get_post_meta($post_id, 'avcp_aggiudicazione', true);
64 - $html .= '<tr><td>' . esc_html__('Importo di aggiudicazione:', 'avcp') . '</td><td>€ <strong>' . esc_html($aggiudicazione_amount) . '</strong></td></tr>';
65 -
66 - // Dates
67 - $html .= avcp_generate_contract_dates($post_id);
68 -
69 - // Liquidated amounts
70 - $html .= avcp_generate_liquidated_amounts($post_id);
71 -
72 - // Reference year
73 - $html .= avcp_generate_reference_year($post_id, $options);
74 -
75 - $html .= '</table>';
76 -
77 - return $html;
78 -}
79 -
80 -/**
81 - * Generates area sectors information
82 - *
83 - * @param int $post_id The post ID
84 - * @return string HTML content for area sectors
85 - */
86 -function avcp_generate_area_sectors($post_id) {
87 - $html = '';
88 - $terms = get_the_terms($post_id, 'areesettori');
89 -
90 - if ($terms && !is_wp_error($terms)) {
91 - foreach($terms as $term) {
92 - if (!is_object($term) || empty($term->name)) {
93 - continue;
94 - }
95 -
96 - $get_term = get_term_by('name', $term->name, 'areesettori');
97 - if (!$get_term || is_wp_error($get_term)) {
98 - continue;
99 - }
100 -
101 - $tsr_id = absint($get_term->term_id);
102 -
103 - // Check if get_tax_meta function exists before using it
104 - if (function_exists('get_tax_meta')) {
105 - $id_sec_red_var = get_tax_meta($tsr_id, 'aree_settori_cc_url');
106 -
107 - if ($id_sec_red_var) {
108 - $permalink = get_permalink(absint($id_sec_red_var));
109 - if ($permalink) {
110 - $html .= ' - <a href="' . esc_url($permalink) . '">' . esc_html($term->name) . '</a>';
111 - }
112 - }
113 -
114 - $id_sec_cc_var = get_tax_meta($tsr_id, 'aree_settori_cc_responsabile');
115 - if (!empty($id_sec_cc_var)) {
116 - $html .= ' - [<acronym title="' . esc_attr__('Responsabile del Centro di Costo', 'avcp') . '">resp. <b>' . esc_html($id_sec_cc_var) . '</b></acronym>]';
117 - }
118 - } else {
119 - // Fallback if get_tax_meta doesn't exist
120 - $html .= ' - ' . esc_html($term->name);
121 - }
122 - }
123 - }
124 -
125 - return $html;
126 -}
127 -
128 -/**
129 - * Generates contract dates section
130 - *
131 - * @param int $post_id The post ID
132 - * @return string HTML content for dates
133 - */
134 -function avcp_generate_contract_dates($post_id) {
135 - $d_inizio = sanitize_text_field(get_post_meta($post_id, 'avcp_data_inizio', true));
136 - $d_fine = sanitize_text_field(get_post_meta($post_id, 'avcp_data_fine', true));
137 -
138 - $avcp_data_inizio = $d_inizio ? date_i18n("d/m/Y", strtotime($d_inizio)) : esc_html__('n.d.', 'avcp');
139 - $avcp_data_fine = $d_fine ? date_i18n("d/m/Y", strtotime($d_fine)) : esc_html__('n.d.', 'avcp');
140 -
141 - $html = '<tr><td>' . esc_html__('Data di effettivo inizio:', 'avcp') . '</td><td>' . esc_html($avcp_data_inizio) . '</td></tr>';
142 - $html .= '<tr><td>' . esc_html__('Data di ultimazione:', 'avcp') . '</td><td>' . esc_html($avcp_data_fine) . '</td></tr>';
143 -
144 - return $html;
145 -}
146 -
147 -/**
148 - * Generates liquidated amounts section
149 - *
150 - * @param int $post_id The post ID
151 - * @return string HTML content for liquidated amounts
152 - */
153 -function avcp_generate_liquidated_amounts($post_id) {
154 - $html = '<tr><td>' . esc_html__('Importo delle somme liquidate:', 'avcp') . '</td><td>';
155 -
156 - $current_year = date('Y');
157 - for ($i = 2013; $i <= $current_year + 10; $i++) {
158 - $amount = get_post_meta($post_id, 'avcp_s_l_' . absint($i), true);
159 - if ($amount && floatval($amount) > 0) {
160 - $html .= '<strong>' . absint($i) . '</strong>: ' . esc_html($amount) . '<br>';
161 - }
162 - }
163 - $html .= '</td></tr>';
164 -
165 - return $html;
166 -}
167 -
168 -/**
169 - * Generates reference year section
170 - *
171 - * @param int $post_id The post ID
172 - * @param array $options Cached options array
173 - * @return string HTML content for reference year
174 - */
175 -function avcp_generate_reference_year($post_id, $options) {
176 - global $post;
177 -
178 - $html = '<tr><td>' . esc_html__('Anno di riferimento:', 'avcp') . '</td><td>';
179 -
180 - if ($options['dis_archivioanni'] == '1') {
181 - $term_list = get_the_term_list($post->ID, 'annirif', '', ' - ', '');
182 - $html .= wp_strip_all_tags($term_list);
183 - } else {
184 - $html .= get_the_term_list($post->ID, 'annirif', '', ' - ', '');
185 - }
186 -
187 - $html .= '</td></tr>';
188 -
189 - return $html;
190 -}
191 -
192 -/**
193 - * Generates the participating operators table
194 - *
195 - * @param int $post_id The post ID
196 - * @param array $options Cached options array
197 - * @return string HTML table content
198 - */
199 -function avcp_generate_participating_operators($post_id, $options) {
200 - global $post;
201 -
202 - $html = '<h3>' . esc_html__('Elenco degli operatori partecipanti', 'avcp') . '</h3>';
203 - $html .= '<table>';
204 -
205 - $terms = get_the_terms($post->ID, 'ditte');
206 - if ($terms && !is_wp_error($terms)) {
207 - foreach($terms as $term) {
208 - if (!is_object($term) || empty($term->name)) {
209 - continue;
210 - }
211 -
212 - $get_term = get_term_by('name', $term->name, 'ditte');
213 - if (!$get_term || is_wp_error($get_term)) {
214 - continue;
215 - }
216 -
217 - $t_id = absint($get_term->term_id);
218 - $term_meta = get_option("taxonomy_$t_id");
219 - $term_return = '';
220 -
221 - if (is_array($term_meta) && isset($term_meta['avcp_codice_fiscale'])) {
222 - $term_return = esc_attr($term_meta['avcp_codice_fiscale']);
223 - }
224 -
225 - $is_estera = '<acronym title="' . esc_attr__('Identificativo Fiscale Italiano', 'avcp') . '">IT</acronym>';
226 -
227 - // Check if get_tax_meta function exists before using it
228 - if (function_exists('get_tax_meta')) {
229 - $stato_var = get_tax_meta($t_id, 'avcp_is_ditta_estera');
230 - $is_estera = empty($stato_var) ?
231 - '<acronym title="' . esc_attr__('Identificativo Fiscale Italiano', 'avcp') . '">IT</acronym>' :
232 - '<acronym title="' . esc_attr__('Identificativo Fiscale Estero', 'avcp') . '">EE</acronym>';
233 - }
234 -
235 - $html .= '<tr><td>';
236 -
237 - if ($options['dis_archivioditte'] == '1') {
238 - $html .= esc_html($term->name);
239 - } else {
240 - $term_link = get_term_link($t_id, 'ditte');
241 - if (!is_wp_error($term_link)) {
242 - $html .= '<a href="' . esc_url($term_link) . '" title="' . esc_attr($term->name) . '">' . esc_html($term->name) . '</a>';
243 - } else {
244 - $html .= esc_html($term->name);
245 - }
246 - }
247 -
248 - $html .= '</td><td>' . esc_html($term_return) . ' - <b>' . $is_estera . '</b></td></tr>';
249 - }
250 - }
251 -
252 - $html .= '</table>';
253 -
254 - return $html;
255 -}
256 -
257 -/**
258 - * Generates the winning operators table
259 - *
260 - * @param int $post_id The post ID
261 - * @param array $options Cached options array
262 - * @return string HTML table content
263 - */
264 -function avcp_generate_winning_operators($post_id, $options) {
265 - global $post;
266 -
267 - $html = '<h3>' . esc_html__('Elenco degli operatori aggiudicatari', 'avcp') . '</h3>';
268 - $html .= '<table>';
269 -
270 - $dittepartecipanti = get_the_terms($post->ID, 'ditte');
271 - $cats = get_post_meta($post->ID, 'avcp_aggiudicatari', true);
272 -
273 - if (is_array($dittepartecipanti) && !is_wp_error($dittepartecipanti)) {
274 - $has_winners = false;
275 -
276 - foreach ($dittepartecipanti as $term) {
277 - if (!is_object($term) || empty($term->name)) {
278 - continue;
279 - }
280 -
281 - $cterm = get_term_by('name', $term->name, 'ditte');
282 - if (!$cterm || is_wp_error($cterm)) {
283 - continue;
284 - }
285 -
286 - $cat_id = absint($cterm->term_id);
287 - $term_meta = get_option("taxonomy_$cat_id");
288 - $term_return = '';
289 -
290 - if (is_array($term_meta) && isset($term_meta['avcp_codice_fiscale'])) {
291 - $term_return = esc_attr($term_meta['avcp_codice_fiscale']);
292 - }
293 -
294 - $checked = (in_array($cat_id, (array)$cats) ? ' checked="checked"' : "");
295 -
296 - $is_estera = '<acronym title="' . esc_attr__('Identificativo Fiscale Italiano', 'avcp') . '">IT</acronym>';
297 -
298 - // Check if get_tax_meta function exists before using it
299 - if (function_exists('get_tax_meta')) {
300 - $stato_var = get_tax_meta($cat_id, 'avcp_is_ditta_estera');
301 - $is_estera = empty($stato_var) ?
302 - '<acronym title="' . esc_attr__('Identificativo Fiscale Italiano', 'avcp') . '">IT</acronym>' :
303 - '<acronym title="' . esc_attr__('Identificativo Fiscale Estero', 'avcp') . '">EE</acronym>';
304 - }
305 -
306 - if ($checked) {
307 - $has_winners = true;
308 - $html .= '<tr><td>';
309 -
310 - if ($options['dis_archivioditte'] != '1') {
311 - $term_link = get_term_link($cterm->term_id, 'ditte');
312 - if (!is_wp_error($term_link)) {
313 - $html .= '<a href="' . esc_url($term_link) . '" title="' . esc_attr($term->name) . '">';
314 - }
315 - }
316 -
317 - $html .= esc_html($term->name);
318 -
319 - if ($options['dis_archivioditte'] != '1' && !is_wp_error($term_link)) {
320 - $html .= '</a>';
321 - }
322 -
323 - $html .= '</td><td>' . esc_html($term_return) . ' - <b>' . $is_estera . '</b></td></tr>';
324 - }
325 - }
326 -
327 - if (!$has_winners) {
328 - $html .= '<tr><td>' . esc_html__('Nessun aggiudicatario...', 'avcp') . '</td></tr>';
329 - }
330 - } else {
331 - $html .= '<tr><td>' . esc_html__('Nessun aggiudicatario...', 'avcp') . '</td></tr>';
332 - }
333 -
334 - $html .= '</table>';
335 -
336 - return $html;
337 -}
338 -
339 -/**
340 - * Generates the WPGov footer if enabled
341 - *
342 - * @param array $options Cached options array
343 - * @return string HTML content for footer
344 - */
345 -function avcp_generate_footer($options) {
346 - $html = '';
347 -
348 - if ($options['wpgov_show_love']) {
349 - $html .= '<center><a href="http://www.wpgov.it" target="_blank" title="' . esc_attr__('Software © WPGov', 'avcp') . '"><img style="margin:5px;" src="' . esc_url(plugin_dir_url(__FILE__) . 'images/wpgov.png') . '" alt="' . esc_attr__('WPGov Logo', 'avcp') . '" /></a></center>';
350 - }
351 -
352 - return $html;
353 -}
354 -
355 -add_filter('the_content', function($content) {
356 - global $post;
357 -
358 - // Validate post object and type
359 - if (!is_object($post) || empty($post->post_type) || $post->post_type !== 'avcp') {
360 - return $content;
361 - }
362 -
363 - // Validate post ID
364 - $post_id = absint($post->ID);
365 - if (!$post_id || !get_post($post_id)) {
366 - return $content;
367 - }
368 -
369 - // Cache options to avoid multiple queries
370 - $options = array(
371 - 'denominazione_ente' => get_option('avcp_denominazione_ente', ''),
372 - 'codicefiscale_ente' => get_option('avcp_codicefiscale_ente', ''),
373 - 'dis_archivioanni' => get_option('avcp_dis_archivioanni'),
374 - 'dis_archivioditte' => get_option('avcp_dis_archivioditte'),
375 - 'wpgov_show_love' => get_option('wpgov_show_love')
376 - );
377 -
378 - // Build the content
379 - $prev = '<br/>';
380 - $prev .= avcp_generate_contract_info_table($post_id, $options);
381 - $prev .= avcp_generate_participating_operators($post_id, $options);
382 - $prev .= avcp_generate_winning_operators($post_id, $options);
383 - $prev .= avcp_generate_footer($options);
384 -
385 - return $prev . $content;
386 - }
387 - );
388 -?>
91 +?>