vCard Plugin

Compatible with DokuWiki

No compatibility info given!

plugin Creates vCards/hCards that can be downloaded and added to your addressbook

Provides
Syntax
Requires
folded

Tagged with address, hcard, users, vcard

By Esther Brunner

Updated version by Tomáš Valenta below

Rewritten version by Bruno De Fraine further below

Updated version by Jürgen A.Lamers further further below

Description

This plugin lets you create vCard files on the fly in your wiki, which other users can download and add to their addressbook. With the folded plugin installed, you can unfold information about the person right in your wiki.

The vCard plugin uses the vCard PHP class by Kai Blankenhorn.

The output the plugin will produce looks like this:

Usage

Example:

{{vcard>[organisation] Full Name <email@host.com> http://www.host.com 1976-05-03 # +41 43 534 0462 | Street Nr., ZIP City, Country}}

All information besides the name is optional. Here are the parameters:

  1. Name: space delimited words; the first is considered to be the first name, the last to be the last name; everything in between will be middle / additional name.
  2. E-Mail: enclosed in < and > signs.
  3. Website: only http is recognized.
  4. Birthday: in format yyyy-mm-dd.
  5. Phone Number(s): after a # sign; multiple numbers are delimited by an & sign; the first is considered as home phone, the second as cell phone, the third as work phone and the fourth as fax number.
  6. Address: after a | sign; comma delimited with first street, then zip-code and city and finally country.

You can see the plugin in action here.

Installation

  1. Unzip the archive and put the files into /lib/plugins/vcard/.

To Do

  • There are some encoding problems with converting the vCard to quoted-printable and Apple Addressbook doesn't recognize UTF-8.

Updated version

Tested with DokuWiki 2006-11-06 on Debian/GNU Linux.

Preview

vCard plugin example

Usage

{{vcard>[Kriminálka] Kapitán Dastych <kapitan@dastych.cz> http://www.dastych.cz 1997-2-11 # work & mobile & home & fax | Protiprávní 12, 11000 Praha, Czech replublic }}

Fields in first part (before #)

  • [company] - company name
  • name - first name, middle name optional and surname
  • <email> - email address
  • http://address.xy - website, must not have http prefix
  • yyyy-mm-dd - birthday

Second part (between # and |) are numbers separated by & in order

  • work number
  • cell phone number (mobile phone)
  • home number
  • fax number

Third part is address; there are three field separated by commas

  • street address
  • zip and city separated by space
  • country

Installation

Install with plugin manager: vcard-plugin.zip

Changelog

2007-05-16 Changes from original

  • mailguarding does not work, removed
  • fixed folding
  • fixed filename generation, space replaced with dash (-)
  • added company name support
  • reordered phone numbers
  • reordered folded details rendering

Recommended bugfix

In “syntax.php” lines 180-182 should be changed, in order to function with the recent version of plugin:folded

$renderer->doc .= '<a class="folder" href="#folded_'.$plugin_folded_count.'">';
$renderer->doc .= '</a>';
$renderer->doc .= '<span class="folded hidden" id="folded_'.$plugin_folded_count.'" >';

regards, GA, 2009-05-22

Rewritten version

As an alternative to the ad hoc approach of the above versions, the vcard plugin was rewritten without hardcoding any vCard field names or field structures (so without Kai's PHP class). The idea is that you write the vcard record directly between <vcard> tags, but in a much nicer syntax. This allows you to put any (text-based) properties in the vCard. Main drawback: plain HTML presentation of the same data is no longer possible (fold or no fold).

Usage

<vcard Bill Gates>
N: Gates, William, Henry, , III
Nickname: Bill
Org: Microsoft
Title: Co-founder

Email, Internet, Work: billg@microsoft.com
Adr, Work: , , 1 Microsoft Way, Redmond, Washington, 98052, United States
Tel, Work: +1 425-882-8080 # General Microsoft number
# Comments like these are not included in the vCard

Bday: 1955-10-28

URL: http://www.microsoft.com/presspass/exec/billg/
</vcard>

For more fields, check the vCard specification.

Features

  • Checksum to prevent cross-site scripting (configure $conf['plugin']['vcard']['secret'] to some secret string)
  • UTF8 encoding of extended characters seems to work (tested with Mac OS X Address Book)

Download

Discussion

'folding/unfolding' of the vcard doesn't work.

To make it work, replace line 160 of syntax.php:

$renderer->doc .= '<a href="#" class="folder" onclick="fold(this, \'folded_'.$plugin_folded_count.'\');">';

by the following:

$renderer->doc .= '<a href="#" class="folder" onclick="fold(this, \'' . $plugin_folded_count . '\');">';

(the folded plugin's fold function automatically adds the string folded_ to the second parameter).

syntax.php error

I'm running a slightly older version of PHP than is recommended (4.3.8), but this plugin doesn't work for me. When I paste in the above vcard example, I get the following error:

Fatal error: Call to a member function on a non-object in /var/www/html/dokuwiki/lib/plugins/vcard/syntax.php on line 193

It only works if I comment out line 193 of syntax.php

Aaron Hathaway 2006/02/07 10:48

Note/Question regarding Filename & File Suffix

Hi, just installed the plugin. I realized two things , don't know if i would call them bugs:

  1. If you click the vcard link the file which gets saved is only the firstname, not firstname_lastname as i think it should be.
  2. There is no suffix @ the end of the filename. As far as I know, the standard suffix for vCards is ”.vcf” Makes it easier for Applications.

Is it possible to change it so that the resulting overall filename: is <firstname_lastname.vcf> ? That would be great.

- Michael (keep up the good work , you create great plugins!)

  1. Is there a way to add job title?

- Tom

folding/unfolding' of the vcard doesn't work again

Replace the

 if ( @file_exists(DOKU_INC.'lib/plugins/folded/closed.gif') && ($folded) ){
 ... whatever is in here
 }

with:

 if ( @file_exists(DOKU_INC.'lib/plugins/folded/closed.gif') && ($folded) ){
                // folded plugin is installed: enables additional feature
                $renderer->doc .= '<a href="#folded_'.$plugin_folded_count.'" class="folder"></a>';
		$renderer->doc .= '<span class="folded hidden" id="folded_'.$plugin_folded_count.'">';
                $renderer->doc .= $folded;
                $renderer->doc .= '</span>';
 }

Cheers, — Drye Kindrew 2007-01-26 10:22


It's not working for me with Dokuwiki 2008-05-05. The problem seems to be that span#folded_reveal and span#folded_hide are not found by the JavaScript from the folded plugin. This leads to the unfolding links not being initialized. A solution to this is to add the following lines to the end of function handle() in vcard/syntax.php, just before the return call:

     } else {
          $first  = $match;
          $middle = NULL;
          $last   = NULL;
      }
      
      // snip
      
      if ($my =& plugin_load('syntax', 'folded_span')) {
          $handler->status['plugin_folded'] = true;
          if (!$this->register_hook) {
          
            global $EVENT_HANDLER;
            $EVENT_HANDLER->register_hook('PARSER_HANDLER_DONE','BEFORE', $my, 'add_writestrings');

            $this->register_hook = true;
          }
      }

      // snip
      
      return array($first,$middle,$last,$email,$website,$birthday,$phones,trim($street),$zip,$city,trim($country),$company);

They are taken from folded/syntax/span.php and make sure that the spans mentioned above are added.

Hope it helps, — Georg Sorst 2008-03-12 22:06

Adding hCard

It would be neat if you added hCard to this plugin. It ought to be quite easy. (I might have a look at it in a while, if I can find the time for it…) – Wilhelm Raab

Doing hCard

Well, I spent a little time to implement the hCard-Feature and update the folded-Feature (or Bug!?!). You can configure the feature to build the hCard-Tags and add an extra Buttons for EMail. If you do not configure the hCard-Feature, it should work like the Kapitán Dastych-Version.

Installation

  1. Unzip the archive and put the files into /lib/plugins/vcard/.

Better way:

Install with plugin manager: http://jaloma.ac.googlepages.com/h_vcard.zip

Bugs

Well, i get some differences between the export with the vcard-export-url and the Firefox-Extension operator. Some time i will fix this…

Hints

  • Using the hCard-Feature, you can not change the text work, home etc. to your desired language.
  • Test your tag-Environment… cause 'span-div-p' sequence maybe has some curious result to your layout.

Jürgen A.Lamers 2008/01/18

plugin/vcard.txt · Last modified: 2011/05/22 18:16 by 84.146.150.133
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 3.0 Unported
Imprint Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
WikiForumIRCBugsGitXRefTranslate