]> git.sur5r.net Git - contagged/commitdiff
Added QR Code export
authorAndreas Gohr <gohr@cosmocode.de>
Fri, 10 Jul 2009 08:50:10 +0000 (10:50 +0200)
committerAndreas Gohr <gohr@cosmocode.de>
Fri, 10 Jul 2009 08:50:10 +0000 (10:50 +0200)
A contact can now be exported to a vcard encoded in a 2D barcode that
can be scanned with a mobile phone. The feature was tested with QuickMark
on the iPhone.

inc/lang/en.php
inc/template.php
pix/qrcode.png [new file with mode: 0644]
styles/design.css
templates/entry_show.tpl
templates/toolbar.tpl

index ef06d762c0ca6265e64c124719302de16e3c4cbc..edc9467e31ad80a007b66d51a292a5e3446f0a1c 100644 (file)
@@ -59,6 +59,7 @@ $lang['help']             = 'Help';
 $lang['select']           = 'Select';
 $lang['orgs']             = 'Companies';
 $lang['upload']           = 'Upload';
+$lang['qrcode']           = 'QR Code';
 
 $lang['publicbook']       = 'Public Addressbook';
 $lang['privatebook']      = 'Private Addressbook';
index 81c0b93d4cdead9e0019e9a1f8b30027e6d1b532..6042c7b9a75d89c1cad3fdb3bf6aeb455658c6de 100644 (file)
@@ -76,6 +76,8 @@ function tpl_entry($in){
   // join marker field to markers
   if(is_array($out['marker'])) $out['markers'] = join(', ',$out['marker']);
 
+  $out['qrcode'] = tpl_qrcode($out);
+
 /*
 print '<pre>';
 print_r($out);
@@ -85,6 +87,20 @@ print '</pre>';
   $smarty->assign('entry',$out);
 }
 
+function tpl_qrcode($in){
+    $data = "BEGIN:VCARD\n";
+    $data .= "N:{$in['name']};{$in['givenname']}\n";
+    if($in['mobile'])    $data .= "TEL;CELL:{$in['mobile']}\n";
+    if($in['phone'])     $data .= "TEL;WORK:{$in['phone']}\n";
+    if($in['homephone']) $data .= "TEL;HOME:{$in['homephone']}\n";
+    if($in['mail'][0])   $data .= "EMAIL:{$in['mail'][0]}\n";
+    $data .= "END:VCARD";
+    $data = rawurlencode($data);
+
+    return 'http://chart.apis.google.com/chart?cht=qr&chld=L|5&chs=500x500&chl='.$data.'&.png';
+}
+
+
 /**
  * assigns the last LDAP error to the template
  */
diff --git a/pix/qrcode.png b/pix/qrcode.png
new file mode 100644 (file)
index 0000000..26b6c4e
Binary files /dev/null and b/pix/qrcode.png differ
index aab332398ef81a5f451c32a15b036deb14767cf2..63320819e36a6a80b1c68132480d081a84238e63 100644 (file)
@@ -105,6 +105,11 @@ a.ed_vcfexport {
     padding: 1px 0px 1px 16px;
 }
 
+a.ed_qrcode {
+    background: transparent url(../pix/qrcode.png) 0px 1px no-repeat;
+    padding: 1px 0px 1px 16px;
+}
+
 a.ed_csvexport {
     background: transparent url(../pix/page_white_excel.png) 0px 1px no-repeat;
     padding: 1px 0px 1px 16px;
index 36de36c18f4d52482670c6f40b919d21ef2390f0..69ec28d02659bce2558ac935253d17aec7046e00 100644 (file)
   </tr>
 </table>
 
-
 </div>
 
 {include file="footer.tpl"}
index 014348d1a0166268a7aaa3c4d0e925706a01d3b7..743d268411e3dcbe4e33d4172ed5b50cf8a6656a 100644 (file)
           <a href="entry.php?dn={$dn|escape:url}&amp;mode=vcf" class="ed_vcfexport">{$lang.vcfexport}</a>
         </li>
 
+        <!-- qr code -->
+        <li>
+          <a href="{$entry.qrcode}" rel="imagebox" class="ed_qrcode" title="{$lang.qrcode}">{$lang.qrcode}</a>
+        </li>
+
         <!-- show on map -->
         {if $smarty.request.mode == 'map' && $conf.gmapkey}
             <li>