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
<?php
namespace SIW\Widgets;
use SIW\Elements;
use SIW\Formatting;
use SIW\i18n;
use SIW\HTML;
class Dutch_Projects extends Widget {
protected $widget_id ='dutch_projects';
protected $widget_dashicon = 'list-view';
protected function set_widget_properties() {
$this->widget_name = __( 'Nederlandse projecten', 'siw' );
$this->widget_description = __( 'Toont omschrijving van Nederlandse projecten', 'siw' );
}
public function get_widget_form() {
$widget_form = [
'title' => [
'type' => 'text',
'label' => __( 'Titel', 'siw'),
],
];
return $widget_form;
}
protected function get_content( array $instance, array $args, array $template_vars, string $css_name ) {
$language = i18n::get_current_language();
$projects = siw_get_option( 'dutch_projects');
$accordion_panes = [];
$tabs_panes = [];
foreach ( $projects as $project ) {
$work_type = siw_get_work_type( $project['work_type'] );
$icon = Elements::generate_icon( $work_type ? $work_type->get_icon_class() : '', 4, 'circle' );
$summary = wpautop( sprintf( __( 'Thema: %s', 'siw' ), $work_type ? $work_type->get_name() : '' ) );
$summary .= wpautop( sprintf( __( 'Projectcode: %s', 'siw' ), $project['code'] ) );
$content = Formatting::generate_columns([
[ 'width' => 2, 'content' => $icon . $summary ],
[ 'width' => 10, 'content' => $project["description_{$language}"] ],
]);
$tabs_panes[] = [
'title' => $project["name_{$language}"],
'content' => $content,
];
$accordion_panes[] = [
'title' => $project["name_{$language}"],
'content' => $project["description_{$language}"],
];
}
$content = Elements::generate_tabs( $tabs_panes );
$mobile_content = Elements::generate_accordion( $accordion_panes );
$content = '<div class="hidden-xs">' . $content . '</div>';
$content .= '<div class="hidden-sm hidden-md hidden-lg">' . $mobile_content . '</div>';
$booklet_link = $this->get_booklet_link();
if ( false !== $booklet_link ) {
$content .= $booklet_link;
}
return $content;
}
protected function get_booklet_link() {
$booklets = siw_get_option( 'dutch_projects_booklet');
$booklet = reset( $booklets );
$booklet_year = siw_get_option( 'dutch_projects_booklet_year');
if ( ! empty( $booklet ) ) {
$booklet_link = HTML::generate_link(
$booklet['url'],
sprintf( __( 'Engelstalige programmaboekje %d (PDF)', 'siw' ), $booklet_year ),
[
'target' => '_blank',
'rel' => 'noopener',
'data-ga-track' => 1,
'data-ga-type' => 'event',
'data-ga-category' => 'Document',
'data-ga-action' => 'Downloaden',
'data-ga-label' => $booklet['url'],
]
);
$booklet_link = sprintf( __( 'Wil jij meer lezen over onze Nederlandse vrijwilligersprojecten, download dan ons %s.', 'siw' ), $booklet_link );
}
else {
$booklet_link = false;
}
return $booklet_link;
}
}