• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Vcard for Company Directory output
PostPosted: Tue Sep 29, 2009 3:44 am 
Offline
Power Poster
Power Poster
User avatar

Joined: Wed Jan 02, 2008 11:39 pm
Posts: 2154
Location: Lewiston-Idaho
Hello, so here as another simple trick to Vcard for Company Directory output...


UDT:    addContact
Code:
$filename="uploads/companyContacts/".$params['ConName'].".vcf";

if(file_exists($filename)){

}else{

if(!file_exists("uploads/companyContacts/")){
     mkdir("uploads/companyContacts/", 0777);
}
   $ourFileName = $filename;
   $ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
   fclose($ourFileHandle);

$event="BEGIN:VCARD
VERSION:2.1
N;LANGUAGE=en-us:".$params['Name']."
FN:".$params['Name']."
ORG:".$params['Name']."
TITLE:
TEL;WORK;VOICE:".$params['WORKVOICE']."
TEL;CELL;VOICE:
TEL;VOICE:
TEL;WORK;FAX:".$params['FAX']."
ADR;WORK:;;".$params['ADR']."
EMAIL;WORK:".$params['EMAIL']."
REV:20080724T183242Z
END:VCARD
";

   // GET LENGTH, AND STORE DATA TO OUR SERVER (OR DATA BASE)
    $len = strlen($event);
    $chk = file_put_contents($filename, $event);
   
    // TEST FOR SUCCESSFUL STORAGE
   if ($len!=$chk) die("LENGTH MISMATCH");
}
echo '<a href="'.$filename.'" target="_blank">'.$params['linktext'].'</a>';



In the cal template

Code:
{assign var=company_id value=$entry->id}
{assign var=Name value=$entry->company_name}
{assign var=FName value="$Name-$company_id"|replace:" ":"-"|replace:"&":"N"}
{assign var=EMAIL value=$entry->company_name}
{assign var=ADR value=$entry->address|replace:",":";"}
{assign var=FAX value=$entry->fax}
{assign var=WORKVOICE value=$entry->telephone}
{assign var=altFront value='<img src="/images/cms/editbutton.png" alt="Add '}
{assign var=AltBack value=' To Contacts" />'}

{addContact ConName="$FName" Name="$Name" EMAIL=$EMAIL ADR=$ADR FAX=$FAX WORKVOICE=$WORKVOICE linktext=$altFront$Name$AltBack}





now if you don't want the image... change

Code:
{assign var=altFront value='<img src="/images/cms/editbutton.png" alt="Add '}
{assign var=AltBack value=' To your Contacts" />'}





to

Code:
{assign var=altFront value=''}
{assign var=AltBack value=''}





I will be cleaning this out more later... but.... simple dirty and gets the job done... you can view the output here,


http://98.129.105.20/

which will be come

http://www.northcentralidaho.org


Cheers
Jeremy

Please let me know
what programs you tried it in, any errors, etc... I have Outlook 2000 and 2007 confirmed working... but it should work with much more...


Compatible and tested with:

  • Outlook 2000
  • Outlook 2007






Note:
You may want to add this to your .htaccess or equal since there is iis users out there

Code:
AddType application/octet-stream .vcf




You need to force the download since some browsers are not well debate who cares get the job done... ;) see ... I got your back

adjust to fit..

_________________
Sorry. Too little support in projects, too little reason to not deprioritize. May-be if more attention is needed.
Follow me on Twitter | Follow me on FaceBook


Top
 Profile  
 
 Post subject: Re: Vcard for Company Directory output
PostPosted: Tue Oct 06, 2009 5:14 am 
Offline
Power Poster
Power Poster
User avatar

Joined: Wed Jan 02, 2008 11:39 pm
Posts: 2154
Location: Lewiston-Idaho
Ok... one better ?? ... with an image... again if you have a better way to write it please feel free...

Code:
{assign var=company_id value=$entry->id}
{assign var=Name value=$entry->company_name}
{assign var=FName value="$Name-$company_id"|replace:" ":"-"|replace:"&":"N"|replace:"/":"-"}
{assign var=EMAIL value=$entry->company_name}
{assign var=ADR value=$entry->address|replace:",":";"}
{assign var=FAX value=$entry->fax}
{assign var=WORKVOICE value=$entry->telephone}
{assign var=Logoimage value=$entry->logo_path}
{assign var=altFront value='<img src="/uploads/Vcal_N_vcard/vcard.png" alt="Add '}
{assign var=AltBack value=' To Contacts" />Add to your Contacts'}
<h3>{addContact ConName="$FName" Name="$Name" EMAIL=$EMAIL ADR=$ADR FAX=$FAX WORKVOICE=$WORKVOICE linktext=$altFront$Name$AltBack Logoimage=$Logoimage}</h3>







Code:
$filename="uploads/companyContacts/".$params['ConName'].".vcf";

if(file_exists($filename)){

}else{

if(!file_exists("uploads/companyContacts/")){
     mkdir("uploads/companyContacts/", 0777);
}
   $ourFileName = $filename;
   $ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
   fclose($ourFileHandle);
$insertablImage="";
$image=$params['Logoimage'];
if($image!=""){
   $handle = fopen($image, "rb");
   $img = stream_get_contents($handle);
   fclose($handle);   
   $encoded_image = base64_encode($img);
   $insertablImage = "PHOTO;TYPE=JPEG;ENCODING=BASE64:\r";
   $insertablImage .= $encoded_image;
}
$event="BEGIN:VCARD
VERSION:2.1
N;LANGUAGE=en-us:".$params['Name']."
FN:".$params['Name']."
ORG:".$params['Name']."
TITLE:
$insertablImage
TEL;WORK;VOICE:".$params['WORKVOICE']."
TEL;CELL;VOICE:
TEL;VOICE:
TEL;WORK;FAX:".$params['FAX']."
ADR;WORK:;;".$params['ADR']."
EMAIL;WORK:".$params['EMAIL']."
TZ:-0700
REV:20080724T183242Z
END:VCARD
";

   // GET LENGTH, AND STORE DATA TO OUR SERVER (OR DATA BASE)
    $len = strlen($event);
    $chk = file_put_contents($filename, $event);
    
    // TEST FOR SUCCESSFUL STORAGE
   if ($len!=$chk) die("LENGTH MISMATCH");
}
echo '<a href="'.$filename.'" target="_blank" class="block">'.$params['linktext'].'</a>';






outputing something like this...


Quote:
BEGIN:VCARD
VERSION:2.1
N;LANGUAGE=en-us:Canyon House
FN:Canyon House
ORG:Canyon House
TITLE:
PHOTO;TYPE=JPEG;ENCODING=BASE64:
/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAEBAQEBAQEBAQEcEjOwoTAzDkQRczbpSVawCqnDhkXpVONwdYLRFjCDMddUnHgoxazv
UTxl9lYU/bn+d1rtBYYAEobqg0udBm0o1rEUID6LaTzn4Gh5AgSUbIRNeHSBbpAc75tYEOgekwRYKerrQKZAfnF8rUpYI2BS8Fqj+KpkZV
tQglBo/QB8UPs8Aph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x
kAG4BCfYvabaqajWK29mJpPy9NO0tnjS2owgAIaRdZaWjDHWIoQyraRQYAb8kM/TKi2gBQAyFD2CNogIBHlZBCrfBED4GgcAOYWGEfQSBeRJ
OWt/7RAGlzpIaLSglCz4WAVMpYf8Agv/Z
TEL;WORK;VOICE:866.330.2777
TEL;CELL;VOICE:
TEL;VOICE:
TEL;WORK;FAX:
ADR;WORK:;;124 White Bird Road;White Bird ID 83554
EMAIL;WORK:Canyon House
TZ:-0700
REV:20080724T183242Z
END:VCARD



_________________
Sorry. Too little support in projects, too little reason to not deprioritize. May-be if more attention is needed.
Follow me on Twitter | Follow me on FaceBook


Last edited by JeremyBASS on Tue Oct 06, 2009 5:16 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Vcard for Company Directory output
PostPosted: Fri Oct 09, 2009 5:34 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Wed Jan 02, 2008 11:39 pm
Posts: 2154
Location: Lewiston-Idaho
Here is another suggested change... replace the top with

Code:
global $gCms;
$config =& $gCms->GetConfig();

$filename=$config['uploads_path']."/companyContacts/".$params['ConName'].".vcf";

if(file_exists($filename)){

}else{

if(!file_exists($config['uploads_path']."/companyContacts/")){
     mkdir($config['uploads_path']."/companyContacts/", 0777);
}



also the $filename in the echo at the bottom need to be

$config['uploads_url']."/companyContacts/".$params['ConName'].".vcf"


I have my uploads in a subdomain served cookie free.. Cheers
Jeremy

_________________
Sorry. Too little support in projects, too little reason to not deprioritize. May-be if more attention is needed.
Follow me on Twitter | Follow me on FaceBook


Last edited by JeremyBASS on Sat Oct 10, 2009 9:32 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Vcard for Company Directory output
PostPosted: Mon Jan 10, 2011 4:22 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Sun Apr 17, 2005 2:40 pm
Posts: 187
Location: Germany -- Augsburg
Hi Jeremy,
this is really great and exactly what I was looking for. I tried copy and paste, but only an empty vCard appears. I used your 2nd Version because this
Code:
echo '<a href=".$config['uploads_url']."/companyContacts/".$params['ConName'].".vcf" target="_blank" class="block">'.$params['linktext'].'</a>';
produces an error at me.
Can you please tell me what I did wrong?

Best regards Andreas


Top
 Profile  
 
 Post subject: Re: Vcard for Company Directory output
PostPosted: Tue Jan 11, 2011 3:38 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Wed Jan 02, 2008 11:39 pm
Posts: 2154
Location: Lewiston-Idaho
Hello, here is the latest I'm using that in not in module form... I plan on making a module.. you can look to iCal module to get the idea of what it'll be like when done.. but.. I have yet to do the mod less someone wants to pay for the time to do it now. So here is the udt I use now.

Code:
global $gCms;
$config =& $gCms->GetConfig();

$filename=$config['uploads_path']."/companyContacts/".$params['ConName'].".vcf";
$Dfilename=$config['uploads_url']."/companyContacts/".$params['ConName'].".vcf";
if(file_exists($filename)){

}else{

if(!file_exists($config['uploads_path']."/companyContacts/")){
     mkdir($config['uploads_path']."/companyContacts/", 0777);
}

$image = $config['root_path'].$params['PHOTO'];
if($image!=''){
$imagetypes = array
(
    IMAGETYPE_JPEG => 'JPEG',
    IMAGETYPE_GIF  => 'GIF',
    IMAGETYPE_PNG  => 'PNG'
);
$imageinfo = @getimagesize($image) ;

    $photo = base64_encode(file_get_contents($image));
    $type  = $imagetypes[$imageinfo[2]];

    $vcardPHOTO.= sprintf("PHOTO;TYPE=$type;ENCODING=BASE64:");


$i=0;
$strphoto=sprintf($photo);

while($i<strlen($strphoto))
{
  if($i%75==0)
    $vcardPHOTO.="\r\n ".$strphoto[$i];
  else 
    $vcardPHOTO.=$strphoto[$i];
       
$i++;


}

$event="BEGIN:VCARD\r\n
VERSION:2.1\r\n
N;LANGUAGE=en-us:".$params['Name']."\r\n
FN:".$params['Name']."\r\n
ORG:Customized Energy Solutions\r\n
URL;WORK:http://ces-ltd.com\n
TITLE:".$params['TITLE']."\r\n
$vcardPHOTO\r\n
TEL;WORK;VOICE:".$params['WORKVOICE']."\r\n
TEL;CELL;VOICE:\r\n
TEL;VOICE:\r\n
TEL;WORK;FAX:".$params['FAX']."\r\n
ADR;WORK:;;".$params['ADR']."\r\n
EMAIL;WORK:".$params['EMAIL']."\r\n
NOTE;CHARSET=UTF-8:".$params['NOTE']."\r\n
TZ:-0700 \r\n
REV:20080724T183242Z\r\n
END:VCARD\r\n
";

   // GET LENGTH, AND STORE DATA TO OUR SERVER (OR DATA BASE)
    $len = strlen($event);
    $chk = file_put_contents($filename, $event);
   
    // TEST FOR SUCCESSFUL STORAGE
   if ($len!=$chk) die("LENGTH MISMATCH");
}
echo '<a href="'.$Dfilename.'" target="_blank" class="block">'.$params['linktext'].'</a>';





and an example of what would go in the template.. (Company directory detail template example)
Code:
{assign var=ext value="Ext."}
{assign var=ext value=$entry->customfieldsbyname.$ext}
{assign var=Direct value="Direct Number"}
{assign var=Direct value=$entry->customfieldsbyname.$Direct}

{if $ext !=''}{assign var=ext value=" Ex: $ext"}{/if}
{assign var=Direct value=$Direct$ext}


{assign var=company_id value=$entry->id}
{assign var=Name value=$entry->employee_name}
{assign var=FName value="$Name-$company_id"|replace:" ":"-"|replace:"&":"N"|replace:"/":"-"}
{assign var=TITLE value=$entry->customfieldsbyname.Job_Title}
{assign var=EMAIL value=$entry->contact_email}
{assign var=ADR value=$entry->address}
{assign var=FAX value=$entry->fax}
{assign var=WORKVOICE value=$Direct}


{capture assign=mainImage}{if $entry->picture_location==''}/uploads/energyTheme/man-comingsoon.png{else}{$entry->picture_path}{/if}{/capture}


{supersizer path=$mainImage|replace:'www.ces-ltd.com/':'' width=150 url=true quality=90 prefix=$entry->employee_name|replace:' ':'-' assign=MAINPHOTO root='/uploads/' cachebuster=false}
{assign var=PHOTO value=$MAINPHOTO}
{assign var=NOTE value=$entry->details|strip_tags|html_entity_decode|htmlspecialchars_decode}

{assign var=altFront value='<img src="uploads/energyTheme/_blank.gif" width="37px" height="23px" alt="'}
{assign var=AltBack value='" style="position:absolute; top:5px;right:35px;background: transparent url(/uploads/energyTheme/Sprit_bottons.png) no-repeat -357px -247px;" />'}




now that does add an image via the plugin supersizer.. you can see the output here.. http://www.ces-ltd.com/company/company-search.html the little Vcard icon.. and that is it.. but with the long part to put in the template that is why a module would be better so you'd only need to put in {vCard id=1} and the Vcard profile with id of 1 would be used to produce that set of cards, and you could have all different sets that way.

HTH Cheers -Jeremy


Top
 Profile  
 
 Post subject: Re: Vcard for Company Directory output
PostPosted: Fri Jan 14, 2011 1:09 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Sun Apr 17, 2005 2:40 pm
Posts: 187
Location: Germany -- Augsburg
Thanks! Thanks! Thanks!

A little tip for the Module: Please make the link more flexible to put an image instead of text more easy. Like:
<a class="myClass" href="{$item->cardURL}" title=""><img src="" alt="" title="" /></a>

OT: I can’t use you iCal-Module. The Admin-Panel is not usable in 1.8.2.


best regards Andreas


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Arvixe - A CMSMS Partner