-
- public static function escape($text)
- {
- return preg_replace('/[,;]/', '\\\\$0', $text);
- }
-
- public static function format_adr($params, &$smarty)
- {
- // $adr1, $adr2, $adr3, $postcode, $city, $region, $country
- extract($params['adr']);
- $adr = trim($adr1);
- $adr = trim("$adr\n$adr2");
- $adr = trim("$adr\n$adr3");
- return VCard::text_encode(';;'
- . VCard::escape($adr) . ';'
- . VCard::escape($city) . ';'
- . VCard::escape($region) . ';'
- . VCard::escape($postcode) . ';'
- . VCard::escape($country), false);
- }
-
- public static function text_encode($text, $escape = true)
- {
- if (is_array($text)) {
- return implode(',', array_map(array('VCard', 'text_encode'), $text));
- }
- if ($escape) {
- $text = VCard::escape($text);
- }
- return preg_replace("/(\r\n|\n|\r)/", '\n', $text);
- }
-
- public function do_page(&$page)
- {
- $page->changeTpl('core/vcard.tpl', NO_SKIN);
- $page->register_modifier('vcard_enc', array($this, 'text_encode'));
- $page->register_function('format_adr', array($this, 'format_adr'));
- $page->assign_by_ref('users', $this->iterator);
-
- header("Pragma: ");
- header("Cache-Control: ");
- header("Content-type: text/x-vcard; charset=UTF-8");
- header("Content-Transfer-Encoding: 8bit");
- }