Skip to content

Commit

Permalink
Fixed issue #6846: Graph statistics in Arabic are bad
Browse files Browse the repository at this point in the history
  • Loading branch information
c-schmitz committed Nov 10, 2012
1 parent b248cbc commit 3657fba
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 32 deletions.
16 changes: 0 additions & 16 deletions application/controllers/Statistics_userController.php
Expand Up @@ -148,22 +148,6 @@ function actionAction($surveyid,$language)
$language = Survey::model()->findByPk($iSurveyID)->language;



$chartfontfile = Yii::app()->getConfig("chartfontfile");
//pick the best font file if font setting is 'auto'
if ($chartfontfile=='auto')
{
$chartfontfile='vera.ttf';
if ( $language=='ar')
{
$chartfontfile='KacstOffice.ttf';
}
elseif ($language=='fa' )
{
$chartfontfile='KacstFarsi.ttf';
}
}

//set survey language for translations
$clang = SetSurveyLanguage($iSurveyID, $language);

Expand Down
28 changes: 13 additions & 15 deletions application/helpers/admin/statistics_helper.php
Expand Up @@ -34,8 +34,7 @@ function createChart($iQuestionID, $iSurveyID, $type = null, $lbl, $gdata, $graw
$scriptname = Yii::app()->getConfig("scriptname");
$chartfontfile = Yii::app()->getConfig("chartfontfile");
$chartfontsize = Yii::app()->getConfig("chartfontsize");
$language = Survey::model()->findByPk($iSurveyID)->language;
$statlang = $oLanguage;
$language = $oLanguage->langcode;
$cachefilename = "";

/* Set the fonts for the chart */
Expand Down Expand Up @@ -106,9 +105,7 @@ function createChart($iQuestionID, $iSurveyID, $type = null, $lbl, $gdata, $graw
$graph->setFontProperties($rootdir . DIRECTORY_SEPARATOR . 'fonts' . DIRECTORY_SEPARATOR . $chartfontfile, $chartfontsize);
$legendsize = $graph->getLegendBoxSize($DataSet->GetDataDescription());

if ($legendsize[1] < 320)
$gheight = 420; else
$gheight = $legendsize[1] + 100;
if ($legendsize[1]<320) $gheight=420; else $gheight=$legendsize[1]+100;
$graph = new pChart(690 + $legendsize[0], $gheight);
$graph->loadColorPalette($homedir . DIRECTORY_SEPARATOR . 'styles' . DIRECTORY_SEPARATOR . $admintheme . DIRECTORY_SEPARATOR . 'limesurvey.pal');
$graph->setFontProperties($rootdir . DIRECTORY_SEPARATOR . 'fonts' . DIRECTORY_SEPARATOR . $chartfontfile, $chartfontsize);
Expand Down Expand Up @@ -139,19 +136,20 @@ function createChart($iQuestionID, $iSurveyID, $type = null, $lbl, $gdata, $graw
// this block is to remove the items with value == 0
// and an inelegant way to remove comments from List with Comments questions
$i = 0;
while (isset($gdata[$i])) {
if ($gdata[$i] == 0 || ($type == "O" && substr($lbl[$i], 0, strlen($statlang->gT("Comments"))) == $statlang->gT("Comments"))) {
array_splice($gdata, $i, 1);
array_splice($lbl, $i, 1);
} else {
$i++;
while (isset ($gdata[$i]))
{
if ($gdata[$i] == 0 || ($type == "O" && substr($lbl[$i],0,strlen($oLanguage->gT("Comments")))==$oLanguage->gT("Comments")))
{
array_splice ($gdata, $i, 1);
array_splice ($lbl, $i, 1);
}
}

$lblout = array();
if ($language == 'ar') {
$lblout = $lbl; //reset text order to original
Yii::import('application.libraries.admin.Arabic', true);
$lblout=array();
if ($language=='ar')
{
$lblout=$lbl; //reset text order to original
Yii::import('application.libraries.Arabic', true);
$Arabic = new Arabic('ArGlyphs');
foreach ($lblout as $kkey => $kval) {
if (preg_match("^[A-Za-z]^", $kval)) { //auto detect if english
Expand Down
2 changes: 1 addition & 1 deletion application/libraries/Arabic.php
Expand Up @@ -123,7 +123,7 @@ class Arabic
*/
public function __construct($library)
{
if($library[0]) $this->load($library[0]);
$this->load($library);
}

public function load($library)
Expand Down

0 comments on commit 3657fba

Please sign in to comment.