<?php

class QRGenerator extends CWidget
{
    public $content;
    public $width = '256';
    public $height='256';
    public $colorDark='#000000';
    public $colorLight='#ffffff';
    public $correctLevel='QRCode.CorrectLevel.M'; // L:1, M:0, Q:3, H:2
    
    
    public function init()
    {
        cs()->registerScriptFile(Yii::app()->baseUrl . '/js/qrcodejs/qrcode.min.js', CClientScript::POS_HEAD);
        // this method is called by CController::beginWidget()
        parent::init();
    }

    public function run()
    {
        // this method is called by CController::endWidget()
        $this->renderQRCode();
    }
    
    public function renderQRCode()
    {
        $this->render('QRGenerator',array(
            'content'=>json_encode($this->content),
            'width'=>$this->width,
            'height'=>$this->height,
            'colorDark'=>$this->colorDark,
            'colorLight'=>$this->colorLight,
            'correctLevel'=>$this->correctLevel,
            ));
    }
}
?>