Paul's Programming Notes     Archive     Feed     Github

Yii Google Chart Extension

Here's YiiWheel's google chart wrapper extension: https://github.com/2amigos/yiiwheels/blob/master/widgets/google/WhVisualizationChart.php

I downloaded just the WhVisualizationChart file and put this in my view:

$this->widget('ext.WhVisualizationChart', array(
    'visualization' => 'PieChart',
    'data' => $chartDataProvider,
    'options' => array(
        'pieHole'=> '0.5',
        'backgroundColor'=>array('fill'=>'transparent'),
    ),
    'htmlOptions'=>array('style'=>'width:100%; height:375px'),
));

and this in my controller:

public function actionIndex()
{
        $chartDataProvider = array(
            array('Task', 'Hours per Day'),
            array('Work', 11),
            array('Eat', 2),
            array('Commute', 2),
            array('Watch TV', 2),
            array('Sleep', 7)
        );
$this->render('index', array('chartDataProvider'=>$chartDataProvider));
}

Examples on how to use it are at the bottom of this page: http://yiiwheels.2amigos.us/site/charts#visualizationchart

Enabling SSL On Apache


This is a quick overview of the process of adding an SSL certificate to apache (for next time...):
  1. Generate your private key and CSR with:
    openssl req -new -newkey rsa:2048 -nodes -keyout yourdomain.key -out yourdomain.csr
  2. Request your certificate
  3. Save requested certificate onto server in a .crt file
  4. Download the intermediary/root cert from http://www.symantec.com/page.jsp?id=roots
  5. Make your site file in /etc/apache2/sites-enabled/ look like this:
<VirtualHost *:443>


        SSLEngine On
         SSLCertificateFile /home/youruser/yourdomain.crt
         SSLCertificateKeyFile /home/youruser/yourdomain.key
         SSLCACertificateFile /var/www/verisign.crt

        ServerName www.yourdomain.com

        DocumentRoot /var/www/yourdomain


An explanation of each of those certificates:
SSLCertificateFile - This is the certificate you received after your request.
SSLCertificateKeyFile - This is the private key you generated in step 1.
SSLCACertificateFile - This is the intermediary cert you downloaded from verisign.

Yii quickdlgs Without UrlManager Enabled

EQuickDlgs::iframeButton(
array(
'controllerRoute' => 'controller/create',
'dialogTitle' => 'Create New Record',
'dialogWidth' => 800,
'dialogHeight' => 600,
'openButtonText' => 'Add Record',
'closeButtonText' => 'Close',
//'openButtonHtmlOptions' => array(...),
)
);


With the code above, I was getting the following error:
The system is unable to find the requested action "create?qdsClass=EFrameJuiDlg".

I had to change line 79 in EFrameJuiDlg.php inside the quickdlgs extension from:
            $url .= '?' . http_build_query($this->urlParams);
to:
            $url .= '&' . http_build_query($this->urlParams);

htmlspecialchars() expects parameter 1 - Yii (echmultiselect)

htmlspecialchars() expects parameter 1 to be string, array given C:\xampp\htdocs\yii\framework\web\helpers\CHtml.php(98) 
The error only occurred when trying to apply the echmultiselect filter to the filter above the gridview.

Here's what I did to fix:
1. Went to the Yii framework folder and found the following file: yii\framework\web\helpers\CHtml.php

2. Modifed line 98 from "return htmlspecialchars($text,ENT_QUOTES,Yii::app()->charset);" to:
"return htmlspecialchars(print_r($text, true),ENT_QUOTES,Yii::app()->charset);"

Then you need to implement the echmultiselect extension in the view (my example shows adding it for site_status):

3. Added this php code to the view: $data= CHtml::listData(Nvdaily::model()->findAll(), 'blahblahblah', 'blahblahblah');
(but it should probably be in the model)

4. Made my 'columns' array look like this:
'columns'=>array(
'id',
'blah',
'blahblah',
array (
            'name'=>'blahblahblah',
            'filter'=> $this->widget('ext.EchMultiselect.EchMultiselect',
array(
                'model' => $model,
                'dropDownAttribute' => 'blahblahblah',
                'data' => $data,
                'options' => array('buttonWidth' => 80, 'ajaxRefresh' => true),
            ),
            true // capture output; needed so the widget displays inside the grid
),
),
array(
'class'=>'bootstrap.widgets.TbButtonColumn',
),
),