'; $width = isset($params['width']) ? $params['width'] : '100'; $height = isset($params['height']) ? $params['height'] : '100'; $data_uri = isset($params['data_uri']) ? $params['data_uri'] : false; $path = isset($params['path']) ? $params['path'] : 'qr'; // data params $lastname = $params['lastname']; $firstname = $params['firstname']; $company = $params['company']; $position = $params['position']; $phone = $params['phone']; $address = $params['address']; $city = $params['city']; $state = $params['state']; $zip = $params['zip']; $country = $params['country']; $email = $params['email']; $url = $params['url']; $bday = $params['bday']; $type = strtoupper($params['type']); $text = $params['data']; $noencode = isset($params['noencode']) ? $params['noencode'] : false; switch($params['action']) { default: $data = $url; break; case 'phone': $data = 'tel:'.$phone; break; case 'sms': $data = 'sms:'.$phone; break; case 'email': $data = $email; break; case 'vcard': $data = urlencode(vcard_data($lastname, $firstname, $company, $position, $type, $phone, $address, $city, $state, $zip, $country, $email, $url, $bday, $text)); break; case 'mecard': $data = urlencode(mecard_data($lastname, $firstname, $phone, $address, $city, $state, $zip, $country, $email, $url, $bday, $text)); break; case 'custom': if ($noencode != false) { $data = $text; } else { $data = urlencode($text); } break; } // get image from google charts api $image_url_qr = 'https://chart.googleapis.com/chart?chs=' . $width . 'x' . $height . '&cht=qr&chl=' . $data . '&choe=UTF-8'; // generate image $image_path_qr = $gCms -> config['image_uploads_path'] . '/' . $path . '/'; $image_filename_qr = md5(serialize($params)) . '.gif'; if(!file_exists($image_path_qr . $image_filename_qr) || $image_filename_qr == md5(serialize($params))) { @mkdir($image_path_qr, 0755, true); $image_to_fetch = file_get_contents($image_url_qr); $local_image_file = fopen($image_path_qr . $image_filename_qr, 'w'); chmod($image_path_qr . $image_filename_qr, 0755); fwrite($local_image_file, $image_to_fetch); fclose($local_image_file); } // if file exists construct image tag / if(file_exists($image_path_qr)) { // if param data_uri is set show base64 image if($data_uri != false) { $get_image = $image_path_qr . $image_filename_qr; $qr_image = $start_img .= '"data:image/gif;base64,' . base64_encode(file_get_contents($get_image)) . '"'; // else show gif image } else { $qr_image = $start_img .= '"' . $gCms -> config['image_uploads_url'] . '/' . $path . '/' . $image_filename_qr . '"'; } $qr_image .= ' width="' . $width . '"'; $qr_image .= ' height="' . $height . '"'; if(!empty($params['alt'])) { $alt = $params['alt']; } else { $alt = $params['url'];} $qr_image .= ' alt="' . $alt . '"'; if(!empty($params['title'])) { $title = $params['title']; } else { $title = $params['url']; } $qr_image .= ' title="' . $title . '"'; if(!empty($params['class'])) { $qr_image .= ' class="' . $params['class'] . '"'; } $qr_image .= $close_img; } else { $qr_image = '
Oh no. Something is wrong.
Image was not found.
This plugin generates a simple QR Code using Google Charts API.
QR Codes are popular among Smartphone user, where with help of QR Code you are able to easily access or save information specified in that code.
With QR Image Plugin generated QR code from Google Charts API is saved in a predefined folder.
Furthermore, Plugin was extended so it can be used with different formats as far supported by GoogleCharts API, like vcard, text, telephone, sms, email and url.
For example:
With actions "vcard" or "mecard" you can embed vCard or meCard information in generated QR code.
BEGIN:VCARD
VERSION:3.0
N:Lastname;Firstname
FN:Lastname Firsname
ORG:Company Name
TITLE:CEO
TEL;TYPE=WORK:99999999
ADR;TYPE=WORK:;;Some Address 99;Some City;LA;99999;United States
LABEL;TYPE=WORK:Some Address 99\nSome City\nLA\n99999\nUnited States
EMAIL;TYPE=PREF,INTERNET:some@email.com
URL:www.domain.com
BDAY:01.01.1979
NOTE:Lorem ipsum
REV:20111217T195243Z
END:VCARD
MECARD:
N:Lastname,Firstname;
TEL:99999999
ADR:Some Address 99,Some City,LA;99999,United States;
EMAIL:some@email.com;
URL:www.domain.com;
BDAY:01.01.1979;
NOTE:Lorem ipsum;
Just insert the tag into your template/page like:
{qr_image url='http://www.domain.com' width='120' height='120' title='some title' alt='alt text'}
With parameter action='custom' and noencode='1' you can use this Plugin in combination with other Plugins or UDT's.
When updating this plugin i have also had a discussion with Rober Campbell where he has quickly written a standalone vcard Plugin
which you should also find in CMSMS Forge.
Example:
{vcard firstname='robert' lastname='Campbell' pobox='P.O. Box 1944' street='123 Anywhere St' city='Somewhere' state='CA' zip=90210 country='Zimbabwe' teltype=work tel='1 814 495 0338' company='Techcom Consulting' position='guru' assign='card'}
{qr_image width='300' height='300' action='custom' noencode='1' data=$card}
With additional parameter you can use the generated QR Image with VCARD information.
{qr_image action='vcard' firstname='Goran' lastname='Ilic' address='Behind the hill 99' city='Chakalaka' zip='99999' country='Cmsmsania'}
Author: Goran Ilic www.ich-mach-das.at
Author: Goran Ilic www.ich-mach-das.at