Additional access control related ui helpers added: check_edit_access, access_post...
[fa-stable.git] / reporting / includes / class.graphic.inc
index 58259529c65edb2aed7fbdfead8e7b1e53563a21..60b41021fa124846d56b9ca86b3564d7e276a545 100644 (file)
@@ -151,15 +151,15 @@ class graph
        
     function graph()
     {
-       global $UTF8_fontfile;
+       global $SysPrefs;
                $this->encoding = strtoupper($_SESSION['language']->encoding);
                $path = dirname(__FILE__).'/../fonts/';
 
                // If you use UTF-8 encoding you have to download and install FreeSans.ttf font.
                // It is not bundled with application due to its size.
                // You can also use another UTF-8 font and put it in config.php with the name in $UTF8_fontfile 
-               $this->fontfile = $this->encoding == 'UTF-8' ? (isset($UTF8_fontfile) && $UTF8_fontfile != "" ? $path.$UTF8_fontfile : $path.'FreeSans.ttf') : 
-                       $path.'LiberationSans-Regular.ttf';
+               $this->fontfile = $this->encoding == 'UTF-8' ? (isset($SysPrefs->UTF8_fontfile) && $SysPrefs->UTF8_fontfile != "" ?
+                       $path.$SysPrefs->UTF8_fontfile : $path.'FreeSans.ttf') : $path.'LiberationSans-Regular.ttf';
                
         $this->x = $this->y = $this->z = array();
         $this->biggest_x        = NULL;
@@ -284,7 +284,8 @@ class graph
             }
 
             // Axis X
-            $this->_imagestring($this->img, $this->size, $this->graphic_area_x2+10, $this->graphic_area_y2+3, $this->axis_x, $this->color['title']);
+            //$this->_imagestring($this->img, $this->size, $this->graphic_area_x2+10, $this->graphic_area_y2+3, $this->axis_x, $this->color['title']);
+            $this->_imagestring($this->img, $this->size, $this->graphic_area_x2+40, $this->graphic_area_y2+3, $this->axis_x, $this->color['title']);
             imageline($this->img, $this->graphic_area_x1, $this->graphic_area_y2, $this->graphic_area_x2, $this->graphic_area_y2, $this->color['axis_line']);
             // Axis Y
             $this->_imagestring($this->img, $this->size, 20, $this->graphic_area_y1-20, $this->axis_y, $this->color['title']);
@@ -372,7 +373,8 @@ class graph
                 imageline($this->img, ($x2+1), ($y1-1), ($x2+1), $y2, $this->color['bars_shadow']);
                 imageline($this->img, ($x2+2), ($y1-1), ($x2+2), $y2, $this->color['bars_shadow']);
                 imagefilledrectangle($this->img, $x1, $y1, $x2, $y2, $this->color['bars']);
-                $this->_imagestring($this->img, $this->size, ((($x1+$x2)/2) - (strlen($parameter)*7/2)), ($y2+2), $parameter, $this->color['axis_values'], $alt);
+                //$this->_imagestring($this->img, $this->size, ((($x1+$x2)/2) - (strlen($parameter)*7/2)), ($y2+2), $parameter, $this->color['axis_values'], $alt);
+                $this->_imagestring($this->img, $this->size, $x1, ($y2+2), $parameter, $this->color['axis_values'], $alt);
             }
         }
 
@@ -443,7 +445,8 @@ class graph
                 {
                     imageline($this->img, $x[$i], ($this->graphic_area_y1+10), $x[$i], ($this->graphic_area_y2-1), $this->color['bg_lines']);
                 }
-                $this->_imagestring($this->img, $this->size, ($x[$i] - (strlen($parameter)*7/2 )), ($this->graphic_area_y2+2), $parameter, $this->color['axis_values'], $alt);
+                //$this->_imagestring($this->img, $this->size, ($x[$i] - (strlen($parameter)*7/2 )), ($this->graphic_area_y2+2), $parameter, $this->color['axis_values'], $alt);
+                $this->_imagestring($this->img, $this->size, $x[$i], ($this->graphic_area_y2+2), $parameter, $this->color['axis_values'], $alt);
 
                 $x[$i+1] = $x[$i] + 40;
             }
@@ -966,9 +969,6 @@ class graph
 
     function _imagestring($img, $size, $x, $y, $string, $col, $alt=0)
     {
-               if ($alt && mb_strlen($string) > 12)
-                       $string = mb_substr($string, 0, 12);
-
                if ($this->encoding != 'UTF-8') {
                        if (function_exists('iconv'))
                                $string = iconv($this->encoding, 'UTF-8', $string);
@@ -977,6 +977,15 @@ class graph
                }
                
                // New 2014-06-26 Joe Hunt for handling ev. RTL languages
+               if ($alt)
+               {
+                       if ($this->encoding == 'UTF-8' && is_arabic($string))
+                               $alt_len = 18;
+                       else
+                               $alt_len = 12;
+                       if (strlen($string) > $alt_len)
+                               $string = substr($string, 0, $alt_len);
+               }               
                if ($this->encoding == 'UTF-8')
                {
                        if (is_arabic($string))
@@ -1065,7 +1074,9 @@ function utf8_chr($uni)
        return $r;
 }
 
-global $p_chars;
+///
+function arabic($str,$z="",$method='normal')
+{
 $p_chars = array (
     utf8_chr(0x0622) => array (utf8_chr(0xfe82), utf8_chr(0xfe82), utf8_chr(0x0622)),
     utf8_chr(0x0627) => array (utf8_chr(0xfe8e), utf8_chr(0xfe8e), utf8_chr(0x0627)),
@@ -1108,29 +1119,22 @@ $p_chars = array (
     utf8_chr(0x0629) => array (utf8_chr(0xfe94), utf8_chr(0xfe98), utf8_chr(0xfe97))
 );
 
-global $nastaligh;
 $nastaligh = array (
     utf8_chr(0x0647) => array (utf8_chr(0xfbab), utf8_chr(0xfbad), utf8_chr(0xfbac))
 );
-global $normal;
+
 $normal = array (
     utf8_chr(0x0647) => array (utf8_chr(0xfeea), utf8_chr(0xfeec), utf8_chr(0xfeeb))
 );
 
-global $mp_chars;
 $mp_chars = array (utf8_chr(0x0622), utf8_chr(0x0627), utf8_chr(0x062f), utf8_chr(0x0630), utf8_chr(0x0631), utf8_chr(0x0632), 
        utf8_chr(0x0698), utf8_chr(0x0648), utf8_chr(0x0623), utf8_chr(0x0625), utf8_chr(0x0624));
 
-global $ignorelist;
 $ignorelist = array (utf8_chr(0x0000), utf8_chr(0x064c), utf8_chr(0x064d), utf8_chr(0x064b), utf8_chr(0x064f), utf8_chr(0x0650), 
        utf8_chr(0x064e), utf8_chr(0x0651), utf8_chr(0x0653), utf8_chr(0x0670), utf8_chr(0x0654), utf8_chr(0xfe76), utf8_chr(0xfe7a), 
        utf8_chr(0xfe78), utf8_chr(0xfe7c), utf8_chr(0xfe7e), utf8_chr(0xfe74), utf8_chr(0xfe70), utf8_chr(0xfc5e), utf8_chr(0xfc5f), 
        utf8_chr(0xfc60), utf8_chr(0xfc61), utf8_chr(0xfc62), utf8_chr(0xfc63));
 
-///
-function arabic($str,$z="",$method='normal')
-{
-       global $p_chars,$mp_chars, $ignorelist,$nastaligh,$normal;
        $str_back = $output = $e_output = $str_next = $str1 = $num = "";
        if ($method == 'nastaligh')
                $p_chars = array_merge($p_chars, $nastaligh);
@@ -1295,4 +1299,3 @@ function arabic($str,$z="",$method='normal')
        return  $output;
 }
 
-?>