CoreCommunity ExtensionsIncubatorDistributionsTYPO3 4.5 ProjectsTYPO3 4.6 ProjectsTYPO3 4.7 ProjectsTYPO3 6.0 ProjectsTYPO3 6.1 ProjectsTYPO3 6.2 Projects (+)

27466_v2.diff

Xavier Perseguers, 2011-06-20 23:00

Download (12.7 kB)

 
Resources/Private/Templates/Standard/Service.html (working copy)
190 190
		<div class="tx_egovapi_block_contact_openingHours">###SERVICE_CONTACT_OPENING_HOURS###</div>
191 191
	</div>
192 192
	<div class="clear"></div>
193
	<p class="tx_egovapi_vcard">
194
		<a href="###VCARD_URL###">Download as vCard</a>
195
	</p>
193 196
</div>
194 197
<!-- ###SHOW_CONTACT### [end] -->
195 198

  
Resources/Private/Templates/Fluid/Service/Single.html (working copy)
176 176
			<div class="tx_egovapi_block_contact_openingHours"><f:format.html>{service.contact.openingHours}</f:format.html></div>
177 177
		</div>
178 178
		<div class="clear"></div>
179
		<p class="tx_egovapi_vcard">
180
			<a href="{vcardUrl}">Download as vCard</a>
181
		</p>
179 182
	</div>
180 183
</f:if>
181 184

  
Resources/Private/Templates/Vcard.txt (revision 0)
1
BEGIN:VCARD
2
VERSION:3.0
3
PRODID:-//egovapi//NONSGML Version 3//EN
4
REV:###REVISION###
5
N:;;;;
6
FN:###SERVICE_CONTACT_DEPARTMENT###
7
ORG:###SERVICE_CONTACT_DEPARTMENT###;###SERVICE_CONTACT_OFFICE###
8
EMAIL;type=INTERNET,PREF:###SERVICE_CONTACT_EMAIL###
9
TEL;type=WORK,VOICE:###SERVICE_CONTACT_PHONE1###
10
TEL;type=WORK,FAX:###SERVICE_CONTACT_FAX###
11
ADR;type=WORK:###SERVICE_CONTACT_POSTAL_CASE###;;###SERVICE_CONTACT_ADDRESS###;###SERVICE_CONTACT_MUNICIPALITY###;;###SERVICE_CONTACT_POSTAL_CODE###;Switzerland
12
NOTE:###SERVICE_CONTACT_OPENING_HOURS###
13
X-ABShowAs:COMPANY
14
END:VCARD
Classes/Controller/Pi1/FluidRenderer.php (working copy)
229 229
	 */
230 230
	protected function prepareServiceSingle(/* tx_egovapi_domain_model_service */ $service) {
231 231
		$this->view->assign('service', $service);
232
		$this->view->assign('vcardUrl', $this->settings['vcardUrl']);
232 233

  
233 234
		$this->populateServiceConditions();
234 235
	}
Classes/Controller/Pi1/TemplateRenderer.php (working copy)
541 541
				$this->subparts['SHOW_' . $block] = '';
542 542
			}
543 543
		}
544

  
545
		$this->markers['VCARD_URL'] = $this->settings['vcardUrl'];
544 546
	}
545 547

  
546 548
	/**
Classes/Controller/Pi1/class.tx_egovapi_pi1.php (working copy)
59 59
		$this->init($conf);
60 60
		$this->pi_setPiVarDefaults();
61 61
		$useCaching = !$this->conf['dynamicConfig'];
62
		$vcard = FALSE;
62 63
		$this->pi_USER_INT_obj = $useCaching ? 0 : 1;
63 64

  
65
		if (t3lib_div::_GET('vcard') === '1') {
66
			$useCaching = FALSE;
67
			$vcard = TRUE;
68
		}
69

  
64 70
		if (!$useCaching && $this->cObj->getUserObjectType() == tslib_cObj::OBJECTTYPE_USER) {
65 71
			$this->cObj->convertToUserIntObject();
66 72
			return '';
......
81 87
		}
82 88

  
83 89
		$start = microtime(TRUE);
84
		if ($this->conf['useFluid']) {
90
		if ($vcard) {
91
			$renderer = t3lib_div::makeInstance('tx_egovapi_controller_pi1_vcardRenderer');
92
		} elseif ($this->conf['useFluid']) {
85 93
			$renderer = t3lib_div::makeInstance('tx_egovapi_controller_pi1_fluidRenderer');
86 94
		} else {
87 95
			$renderer = t3lib_div::makeInstance('tx_egovapi_controller_pi1_templateRenderer');
......
262 270
			unset($this->conf['version']);
263 271
		}
264 272

  
273
		$requestUrl = t3lib_div::getIndpEnv('TYPO3_REQUEST_URL');
274
		$requestUrl .= (strpos($requestUrl, '?') !== FALSE) ? '&' : '?';
275
		$this->conf['vcardUrl'] = $requestUrl . 'vcard=1';
276

  
265 277
		$this->debug = $this->conf['enableDebug'];
266 278
	}
267 279

  
Classes/Controller/Pi1/VcardRenderer.php (revision 0)
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('&#64;', '&#46;'), 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 />', '&nbsp;'),
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
?>
ext_autoload.php (working copy)
57 57
	'tx_egovapi_controller_pi1_abstractrenderer' => $classPath . 'Controller/Pi1/AbstractRenderer.php',
58 58
	'tx_egovapi_controller_pi1_fluidrenderer' => $classPath . 'Controller/Pi1/FluidRenderer.php',
59 59
	'tx_egovapi_controller_pi1_templaterenderer' => $classPath . 'Controller/Pi1/TemplateRenderer.php',
60
	'tx_egovapi_controller_pi1_vcardrenderer' => $classPath . 'Controller/Pi1/VcardRenderer.php',
60 61
	'tx_egovapi_interfaces_ajaxhook' => $extensionPath . 'Interfaces/AjaxHook.php',
61 62
	'tx_egovapi_interfaces_template_audiencehook' => $extensionPath . 'Interfaces/Template/AudienceHook.php',
62 63
	'tx_egovapi_interfaces_template_domainhook' => $extensionPath . 'Interfaces/Template/DomainHook.php',