|
1 |
<?php
|
|
2 |
/***************************************************************
|
|
3 |
* Copyright notice
|
|
4 |
*
|
|
5 |
* (c) 2011 Xavier Perseguers <xavier@causal.ch>
|
|
6 |
* All rights reserved
|
|
7 |
*
|
|
8 |
* This script is part of the TYPO3 project. The TYPO3 project is
|
|
9 |
* free software; you can redistribute it and/or modify
|
|
10 |
* it under the terms of the GNU General Public License as published by
|
|
11 |
* the Free Software Foundation; either version 2 of the License, or
|
|
12 |
* (at your option) any later version.
|
|
13 |
*
|
|
14 |
* The GNU General Public License can be found at
|
|
15 |
* http://www.gnu.org/copyleft/gpl.html.
|
|
16 |
*
|
|
17 |
* This script is distributed in the hope that it will be useful,
|
|
18 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
20 |
* GNU General Public License for more details.
|
|
21 |
*
|
|
22 |
* This copyright notice MUST APPEAR in all copies of the script!
|
|
23 |
***************************************************************/
|
|
24 |
|
|
25 |
/**
|
|
26 |
* Vcard renderer for plugin 'eGov API' for the 'egovapi' extension.
|
|
27 |
*
|
|
28 |
* @category Plugin
|
|
29 |
* @package TYPO3
|
|
30 |
* @subpackage tx_egovapi
|
|
31 |
* @author Xavier Perseguers <xavier@causal.ch>
|
|
32 |
* @copyright Causal Sàrl / SECO (http://www.cyberadmin.ch/)
|
|
33 |
* @license http://www.gnu.org/copyleft/gpl.html
|
|
34 |
* @version SVN: $Id$
|
|
35 |
*/
|
|
36 |
class tx_egovapi_controller_pi1_vcardRenderer extends tx_egovapi_controller_pi1_templateRenderer {
|
|
37 |
|
|
38 |
/**
|
|
39 |
* Renders the vCard.
|
|
40 |
*
|
|
41 |
* @return string
|
|
42 |
*/
|
|
43 |
public function render() {
|
|
44 |
$this->initializeRender();
|
|
45 |
|
|
46 |
// Fix some markers
|
|
47 |
$email = $this->markers['SERVICE_CONTACT_EMAIL'];
|
|
48 |
$openingHours = $this->markers['SERVICE_CONTACT_OPENING_HOURS'];
|
|
49 |
$department = $this->markers['SERVICE_CONTACT_DEPARTMENT'];
|
|
50 |
|
|
51 |
$this->markers['SERVICE_CONTACT_EMAIL'] = str_replace(array('@', '.'), array('@', '.'), $email);
|
|
52 |
$this->markers['REVISION'] = date('Ymd\THis\Z');
|
|
53 |
$this->markers['SERVICE_CONTACT_OPENING_HOURS'] = str_replace(
|
|
54 |
"\n", '\n', // Use literal \n marker for new lines
|
|
55 |
trim(strip_tags(str_replace(
|
|
56 |
array('</p>', '<br />', ' '),
|
|
57 |
array("\n\n", "\n", ' '),
|
|
58 |
$openingHours
|
|
59 |
)))
|
|
60 |
);
|
|
61 |
if (!$department) {
|
|
62 |
// Office is defined but not department and due to logical inversion
|
|
63 |
// of fields, see http://forge.typo3.org/issues/27467, we take over
|
|
64 |
// information from SERVICE_CONTACT_OFFICE instead to have a valid
|
|
65 |
// vCard with a proper office defined
|
|
66 |
$this->markers['SERVICE_CONTACT_DEPARTMENT'] = $this->markers['SERVICE_CONTACT_OFFICE'];
|
|
67 |
$this->markers['SERVICE_CONTACT_OFFICE'] = '';
|
|
68 |
}
|
|
69 |
|
|
70 |
$output = $this->cObj->substituteSubpartArray($this->template, $this->subparts);
|
|
71 |
$output = $this->cObj->substituteMarkerArray($output, $this->markers, '###|###');
|
|
72 |
|
|
73 |
$filename = 'contact_' . $this->markers['SERVICE_ID'] . '.vcf';
|
|
74 |
|
|
75 |
t3lib_div::flushOutputBuffers();
|
|
76 |
header('Content-Type: text/x-vcard; charset=utf-8');
|
|
77 |
header('Content-Disposition: attachment; filename="' . $filename . '"');
|
|
78 |
|
|
79 |
echo str_replace("\n", "\r\n", $output);
|
|
80 |
exit;
|
|
81 |
}
|
|
82 |
|
|
83 |
/**
|
|
84 |
* Initializes the template by loading the corresponding file
|
|
85 |
* and preparing global marker substitution.
|
|
86 |
*
|
|
87 |
* @return void
|
|
88 |
*/
|
|
89 |
protected function initializeOutput() {
|
|
90 |
$templateFile = 'EXT:egovapi/Resources/Private/Templates/Vcard.txt';
|
|
91 |
|
|
92 |
$this->template = $this->cObj->fileResource($templateFile);
|
|
93 |
$this->subparts = array();
|
|
94 |
$this->markers = array();
|
|
95 |
}
|
|
96 |
|
|
97 |
/**
|
|
98 |
* Configures the output to render a SINGLE service.
|
|
99 |
*
|
|
100 |
* @param tx_egovapi_domain_model_service $service
|
|
101 |
* @return void
|
|
102 |
*/
|
|
103 |
protected function prepareServiceSingle(/* tx_egovapi_domain_model_service */ $service) {
|
|
104 |
return parent::prepareServiceSingle($service);
|
|
105 |
}
|
|
106 |
|
|
107 |
/**
|
|
108 |
* Configures the output to render LIST of services.
|
|
109 |
*
|
|
110 |
* @param tx_egovapi_domain_model_topic $topic
|
|
111 |
* @param tx_egovapi_domain_model_service[] $services
|
|
112 |
* @return void
|
|
113 |
*/
|
|
114 |
protected function prepareServiceList(/* tx_egovapi_domain_model_topic */ $topic, array $services) {
|
|
115 |
throw new RuntimeException('prepareServiceList is not implemented', 1308140884);
|
|
116 |
}
|
|
117 |
|
|
118 |
/**
|
|
119 |
* Configures the output to render a SINGLE topic.
|
|
120 |
*
|
|
121 |
* @param tx_egovapi_domain_model_topic $topic
|
|
122 |
* @return void
|
|
123 |
*/
|
|
124 |
protected function prepareTopicSingle(/* tx_egovapi_domain_model_topic */ $topic) {
|
|
125 |
throw new RuntimeException('prepareTopicSingle is not implemented', 1308140910);
|
|
126 |
}
|
|
127 |
|
|
128 |
/**
|
|
129 |
* Configures the output to render LIST of topics.
|
|
130 |
*
|
|
131 |
* @param tx_egovapi_domain_model_domain $domain
|
|
132 |
* @param tx_egovapi_domain_model_topic[] $topics
|
|
133 |
* @return void
|
|
134 |
*/
|
|
135 |
protected function prepareTopicList(/* tx_egovapi_domain_model_domain */ $domain, array $topics) {
|
|
136 |
throw new RuntimeException('prepareTopicList is not implemented', 1308140928);
|
|
137 |
}
|
|
138 |
|
|
139 |
/**
|
|
140 |
* Configures the output to render a SINGLE domain.
|
|
141 |
*
|
|
142 |
* @param tx_egovapi_domain_model_domain $domain
|
|
143 |
* @return void
|
|
144 |
*/
|
|
145 |
protected function prepareDomainSingle(/* tx_egovapi_domain_model_domain */ $domain) {
|
|
146 |
throw new RuntimeException('prepareDomainSingle is not implemented', 1308140944);
|
|
147 |
}
|
|
148 |
|
|
149 |
/**
|
|
150 |
* Configures the output to render LIST of domains.
|
|
151 |
*
|
|
152 |
* @param tx_egovapi_domain_model_view $view
|
|
153 |
* @param tx_egovapi_domain_model_domain[] $domains
|
|
154 |
* @return void
|
|
155 |
*/
|
|
156 |
protected function prepareDomainList(/* tx_egovapi_domain_model_view */ $view, array $domains) {
|
|
157 |
throw new RuntimeException('prepareDomainList is not implemented', 1308140962);
|
|
158 |
}
|
|
159 |
|
|
160 |
/**
|
|
161 |
* Configures the output to render a SINGLE view.
|
|
162 |
*
|
|
163 |
* @param tx_egovapi_domain_model_view $view
|
|
164 |
* @return void
|
|
165 |
*/
|
|
166 |
protected function prepareViewSingle( /* tx_egovapi_domain_model_view */ $view) {
|
|
167 |
throw new RuntimeException('prepareViewSingle is not implemented', 1308140987);
|
|
168 |
}
|
|
169 |
|
|
170 |
/**
|
|
171 |
* Configures the output to render LIST of views.
|
|
172 |
*
|
|
173 |
* @param tx_egovapi_domain_model_audience $audience
|
|
174 |
* @param tx_egovapi_domain_model_view[] $views
|
|
175 |
* @return void
|
|
176 |
*/
|
|
177 |
protected function prepareViewList(/* tx_egovapi_domain_model_audience */ $audience, array $views) {
|
|
178 |
throw new RuntimeException('prepareViewList is not implemented', 1308141020);
|
|
179 |
}
|
|
180 |
|
|
181 |
/**
|
|
182 |
* Configures the output to render a SINGLE audience.
|
|
183 |
*
|
|
184 |
* @param tx_egovapi_domain_model_audience $audience
|
|
185 |
* @return void
|
|
186 |
*/
|
|
187 |
protected function prepareAudienceSingle(/* tx_egovapi_domain_model_audience */ $audience) {
|
|
188 |
throw new RuntimeException('prepareAudienceSingle is not implemented', 1308141047);
|
|
189 |
}
|
|
190 |
|
|
191 |
/**
|
|
192 |
* Configures the output to render LIST of audiences.
|
|
193 |
*
|
|
194 |
* @param tx_egovapi_domain_model_audience[] $audiences
|
|
195 |
* @return void
|
|
196 |
*/
|
|
197 |
protected function prepareAudienceList(array $audiences) {
|
|
198 |
throw new RuntimeException('prepareAudienceList is not implemented', 1308141064);
|
|
199 |
}
|
|
200 |
|
|
201 |
}
|
|
202 |
|
|
203 |
|
|
204 |
if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/egovapi/Classes/Controller/Pi1/VcardRenderer.php'])) {
|
|
205 |
include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/egovapi/Classes/Controller/Pi1/VcardRenderer.php']);
|
|
206 |
}
|
|
207 |
|
|
208 |
?>
|