浏览代码

Update to use c-pchart from composer - refs CT#7408

Daniel Barreto 10 年之前
父节点
当前提交
2ec4b9803e

+ 2 - 2
main/auth/inscription.php

@@ -165,8 +165,8 @@ if ($user_already_registered_show_terms == false) {
             'sessionVar'   => basename(__FILE__, '.php'),
             'imageOptions' => array(
                 'font_size' => 20,
-                'font_path' => api_get_path(LIBRARY_PATH).'pChart2/fonts/',
-                'font_file' => 'verdana.ttf',
+                'font_path' => api_get_path(SYS_CSS_PATH) . 'opensans/',
+                'font_file' => 'OpenSans-Regular.ttf',
                     //'output' => 'gif'
             )
         );

+ 1 - 6
main/gradebook/lib/fe/flatviewtable.class.php

@@ -85,11 +85,6 @@ class FlatViewTable extends SortableTable
      */
     public function display_graph_by_resource()
     {
-        require_once api_get_path(LIBRARY_PATH) . 'pChart2/class/pData.class.php';
-        require_once api_get_path(LIBRARY_PATH) . 'pChart2/class/pDraw.class.php';
-        require_once api_get_path(LIBRARY_PATH) . 'pChart2/class/pImage.class.php';
-        require_once api_get_path(LIBRARY_PATH) . 'pChart2/class/pCache.class.php';
-
         $headerName = $this->datagen->get_header_names();
         $total_users = $this->datagen->get_total_users_count();
 
@@ -215,7 +210,7 @@ class FlatViewTable extends SortableTable
                         /* Set the default font */
                         $myPicture->setFontProperties(
                             array(
-                                'FontName' => api_get_path(LIBRARY_PATH) . "pChart2/fonts/verdana.ttf",
+                                'FontName' => api_get_path(SYS_CSS_PATH) . 'opensans/OpenSans-Regular.ttf',
                                 'FontSize' => 10
                             )
                         );

+ 19 - 0
main/inc/autoload.inc.php

@@ -0,0 +1,19 @@
+<?php
+
+/**
+ * Set up the Chamilo autoload stack. Can be called several time if needed also
+ * better to avoid it.
+ */
+
+require_once dirname(__FILE__) . '/lib/autoload.class.php';
+require_once __DIR__ . '/../../vendor/autoload.php';
+Autoload::register();
+
+/**
+use Symfony\Component\ClassLoader\UniversalClassLoader;
+$loader = new UniversalClassLoader();
+$loader->registerNamespaces(array(
+    'Symfony\\Component\\HttpFoundation', __DIR__.'/vendor/symfony/http-foundation',
+));
+$loader->register();
+ */

+ 0 - 4
main/inc/lib/autoload.class.php

@@ -974,10 +974,6 @@ class Autoload
         $result['learnpath_processor'] = '/main/inc/lib/search/tool_processors/learnpath_processor.class.php';
         $result['link_processor'] = '/main/inc/lib/search/tool_processors/link_processor.class.php';
         $result['net\HttpChannel'] = '/main/inc/lib/system/net/http_channel.class.php';
-        $result['pCache'] = '/main/inc/lib/pChart2/class/pCache.class.php';
-        $result['pDraw'] = '/main/inc/lib/pChart2/class/pDraw.class.php';
-        $result['pImage'] = '/main/inc/lib/pChart2/class/pImage.class.php';
-        $result['pData'] = '/main/inc/lib/pChart2/class/pData.class.php';
         $result['quiz_processor'] = '/main/inc/lib/search/tool_processors/quiz_processor.class.php';
         $result['scorm'] = '/main/newscorm/scorm.class.php';
         $result['scormItem'] = '/main/newscorm/scormItem.class.php';

+ 12 - 21
main/inc/lib/tracking.lib.php

@@ -4,6 +4,10 @@
 require_once api_get_path(SYS_CODE_PATH).'exercice/exercise.lib.php';
 require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathList.class.php';
 
+use CpChart\Classes\pData as pData;
+use CpChart\Classes\pImage as pImage;
+use CpChart\Classes\pCache as pCache;
+
 /**
  *  Class Tracking
  *
@@ -4579,10 +4583,6 @@ class Tracking
      */
     static function generate_session_exercise_graph($names, $my_results, $average)
     {
-        require_once api_get_path(LIBRARY_PATH).'pChart2/class/pData.class.php';
-        require_once api_get_path(LIBRARY_PATH).'pChart2/class/pDraw.class.php';
-        require_once api_get_path(LIBRARY_PATH).'pChart2/class/pCache.class.php';
-
         /* Create and populate the pData object */
         $myData = new pData();
         $myData->addPoints($names, 'Labels');
@@ -4595,8 +4595,7 @@ class Tracking
         $myData->setSerieDescription('Serie1', get_lang('MyResults'));
         $myData->setSerieDescription('Serie2', get_lang('AverageScore'));
         $myData->setAxisUnit(0, '%');
-        // @TODO: Define a custom pallete
-        $myData->loadPalette(api_get_path(LIBRARY_PATH) . 'pChart2/palettes/evening.color', true);
+        // @TODO: Define a custom palette
 
         // Cache definition
         $cachePath = api_get_path(SYS_ARCHIVE_PATH);
@@ -4621,8 +4620,8 @@ class Tracking
             $myPicture->Antialias = false;
 
             /* Draw the background */
-            $Settings = array('R' => 255, 'G' => 255, 'B' => 255);
-            $myPicture->drawFilledRectangle(0, 0, $mainWidth, $mainHeight, $Settings);
+            $settings = array('R' => 255, 'G' => 255, 'B' => 255);
+            $myPicture->drawFilledRectangle(0, 0, $mainWidth, $mainHeight, $settings);
 
             /* Add a border to the picture */
             $myPicture->drawRectangle(
@@ -4636,7 +4635,7 @@ class Tracking
             /* Set the default font */
             $myPicture->setFontProperties(
                 array(
-                    'FontName' => api_get_path(LIBRARY_PATH) . "pChart2/fonts/verdana.ttf",
+                    'FontName' => api_get_path(SYS_CSS_PATH) . 'opensans/OpenSans-Regular.ttf',
                     'FontSize' => 10)
             );
             /* Write the chart title */
@@ -4653,7 +4652,7 @@ class Tracking
             /* Set the default font */
             $myPicture->setFontProperties(
                 array(
-                    'FontName' => api_get_path(LIBRARY_PATH) . "pChart2/fonts/verdana.ttf",
+                    'FontName' => api_get_path(SYS_CSS_PATH) . 'opensans/OpenSans-Regular.ttf',
                     'FontSize' => 6
                 )
             );
@@ -4695,7 +4694,7 @@ class Tracking
             /* Draw the line chart */
             $myPicture->setFontProperties(
                 array(
-                    'FontName' => api_get_path(LIBRARY_PATH) . "pChart2/fonts/verdana.ttf",
+                    'FontName' => api_get_path(SYS_CSS_PATH) . 'opensans/OpenSans-Regular.ttf',
                     'FontSize' => 10
                 )
             );
@@ -4745,10 +4744,6 @@ class Tracking
      */
     static function generate_exercise_result_thumbnail_graph($attempts)
     {
-        require_once api_get_path(LIBRARY_PATH) . 'pChart2/class/pData.class.php';
-        require_once api_get_path(LIBRARY_PATH) . 'pChart2/class/pDraw.class.php';
-        require_once api_get_path(LIBRARY_PATH) . 'pChart2/class/pCache.class.php';
-
         $exercise_title = $attempts['title'];
         $attempts       = $attempts['data'];
         $my_exercise_result_array = $exercise_result = array();
@@ -4846,7 +4841,7 @@ class Tracking
             $myPicture->drawRectangle(0, 0, $widthSize - 1, $heightSize - 1, array('R' => 0, 'G' => 0, 'B' => 0));
 
             /* Set the default font */
-            $myPicture->setFontProperties(array('FontName' => api_get_path(LIBRARY_PATH) . "pChart2/fonts/verdana.ttf", 'FontSize' => $fontSize));
+            $myPicture->setFontProperties(array('FontName' => api_get_path(SYS_CSS_PATH) . 'opensans/OpenSans-Regular.ttf', 'FontSize' => $fontSize));
 
             /* Do not write the chart title */
 
@@ -4925,10 +4920,6 @@ class Tracking
      */
     static function generate_exercise_result_graph($attempts)
     {
-        require_once api_get_path(LIBRARY_PATH).'pChart2/class/pData.class.php';
-        require_once api_get_path(LIBRARY_PATH).'pChart2/class/pDraw.class.php';
-        require_once api_get_path(LIBRARY_PATH).'pChart2/class/pCache.class.php';
-
         $exercise_title = strip_tags($attempts['title']);
         $attempts       = $attempts['data'];
         $my_exercise_result_array = $exercise_result = array();
@@ -5033,7 +5024,7 @@ class Tracking
             $myPicture->drawRectangle(0, 0, $widthSize - 1, $heightSize - 1, array('R' => 0, 'G' => 0, 'B' => 0));
 
             /* Set the default font */
-            $myPicture->setFontProperties(array('FontName' => api_get_path(LIBRARY_PATH) . "pChart2/fonts/verdana.ttf", 'FontSize' => 10));
+            $myPicture->setFontProperties(array('FontName' => api_get_path(SYS_CSS_PATH) . 'opensans/OpenSans-Regular.ttf', 'FontSize' => 10));
 
             /* Write the chart title */
             $myPicture->drawText(

+ 2 - 2
main/inc/lib/userportal.lib.php

@@ -719,8 +719,8 @@ class IndexManager
                     'sessionVar'   => basename(__FILE__, '.php'),
                     'imageOptions' => array(
                         'font_size' => 20,
-                        'font_path' => api_get_path(LIBRARY_PATH).'pChart2/fonts/',
-                        'font_file' => 'verdana.ttf',
+                        'font_path' => api_get_path(SYS_CSS_PATH) . 'opensans/',
+                        'font_file' => 'OpenSans-Regular.ttf',
                         //'output' => 'gif'
                     )
                 );

+ 12 - 12
main/mySpace/myspace.lib.php

@@ -4,6 +4,10 @@
 require_once api_get_path(LIBRARY_PATH).'export.lib.inc.php';
 require_once api_get_path(LIBRARY_PATH).'tracking.lib.php';
 
+use CpChart\Classes\pData as pData;
+use CpChart\Classes\pImage as pImage;
+use CpChart\Classes\pCache as pCache;
+
 /**
  * Class MySpace
  * @package chamilo.reporting
@@ -2781,11 +2785,8 @@ function convert_to_string($sql_result){
  * @version OCT-22- 2010
  * @return string
  */
-function grapher($sql_result, $start_date, $end_date, $type = "") {
-    require_once api_get_path(LIBRARY_PATH) . 'pChart2/class/pData.class.php';
-    require_once api_get_path(LIBRARY_PATH) . 'pChart2/class/pDraw.class.php';
-    require_once api_get_path(LIBRARY_PATH) . 'pChart2/class/pCache.class.php';
-
+function grapher($sql_result, $start_date, $end_date, $type = "")
+{
     if (empty($start_date)) { $start_date =""; }
     if (empty($end_date)) { $end_date =""; }
     if ($type == ""){ $type = 'day'; }
@@ -2841,8 +2842,7 @@ function grapher($sql_result, $start_date, $end_date, $type = "") {
         $myData->setSerieWeight('Serie1', 1);
         $myData->setSerieDescription('Serie1', get_lang('MyResults'));
         $myData->setAxisName(0, get_lang('Minutes'));
-        // @TODO: Define a custom pallete
-        $myData->loadPalette(api_get_path(LIBRARY_PATH) . 'pChart2/palettes/evening.color', true);
+        // @TODO: Define a custom palette
 
         // Cache definition
         $cachePath = api_get_path(SYS_ARCHIVE_PATH);
@@ -2867,8 +2867,8 @@ function grapher($sql_result, $start_date, $end_date, $type = "") {
             $myPicture->Antialias = false;
 
             /* Draw the background */
-            $Settings = array("R" => 255, "G" => 255, "B" => 255);
-            $myPicture->drawFilledRectangle(0, 0, $mainWidth, $mainHeight, $Settings);
+            $settings = array("R" => 255, "G" => 255, "B" => 255);
+            $myPicture->drawFilledRectangle(0, 0, $mainWidth, $mainHeight, $settings);
 
             /* Add a border to the picture */
             $myPicture->drawRectangle(
@@ -2882,7 +2882,7 @@ function grapher($sql_result, $start_date, $end_date, $type = "") {
             /* Set the default font */
             $myPicture->setFontProperties(
                 array(
-                    "FontName" => api_get_path(LIBRARY_PATH) . "pChart2/fonts/verdana.ttf",
+                    "FontName" => api_get_path(SYS_CSS_PATH) . 'opensans/OpenSans-Regular.ttf',
                     "FontSize" => 10)
             );
             /* Write the chart title */
@@ -2899,7 +2899,7 @@ function grapher($sql_result, $start_date, $end_date, $type = "") {
             /* Set the default font */
             $myPicture->setFontProperties(
                 array(
-                    "FontName" => api_get_path(LIBRARY_PATH) . "pChart2/fonts/verdana.ttf",
+                    "FontName" => api_get_path(SYS_CSS_PATH) . 'opensans/OpenSans-Regular.ttf',
                     "FontSize" => 8
                 )
             );
@@ -2941,7 +2941,7 @@ function grapher($sql_result, $start_date, $end_date, $type = "") {
             /* Draw the line chart */
             $myPicture->setFontProperties(
                 array(
-                    "FontName" => api_get_path(LIBRARY_PATH) . "pChart2/fonts/verdana.ttf",
+                    "FontName" => api_get_path(SYS_CSS_PATH) . 'opensans/OpenSans-Regular.ttf',
                     "FontSize" => 10
                 )
             );

+ 7 - 5
plugin/dashboard/block_evaluation_graph/block_evaluation_graph.class.php

@@ -1,8 +1,5 @@
 <?php
 /* For licensing terms, see /license.txt */
-require_once api_get_path(LIBRARY_PATH).'pChart2/class/pData.class.php';
-require_once api_get_path(LIBRARY_PATH).'pChart2/class/pDraw.class.php';
-require_once api_get_path(LIBRARY_PATH).'pChart2/class/pCache.class.php';
 require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/gradebookitem.class.php';
 require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/evaluation.class.php';
 require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/result.class.php';
@@ -11,6 +8,11 @@ require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/flatview_data_generator.
 require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/gradebook_functions.inc.php';
 require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/category.class.php';
 
+use CpChart\Classes\pData as pData;
+use CpChart\Classes\pImage as pImage;
+use CpChart\Classes\pCache as pCache;
+
+
 /**
  * Class BlockEvaluationGraph
  * This class is used like controller for this evaluations graph block plugin,
@@ -197,7 +199,7 @@ class BlockEvaluationGraph extends Block
                             /* Set the default font */
                             $myPicture->setFontProperties(
                                 array(
-                                    'FontName' => api_get_path(LIBRARY_PATH) . 'pChart2/fonts/verdana.ttf',
+                                    'FontName' => api_get_path(SYS_CSS_PATH) . 'opensans/OpenSans-Regular.ttf',
                                     'FontSize' => 10
                                 )
                             );
@@ -373,7 +375,7 @@ class BlockEvaluationGraph extends Block
                                 /* Set the default font */
                                 $myPicture->setFontProperties(
                                     array(
-                                        'FontName' => api_get_path(LIBRARY_PATH) . 'pChart2/fonts/verdana.ttf',
+                                        'FontName' => api_get_path(SYS_CSS_PATH) . 'opensans/OpenSans-Regular.ttf',
                                         'FontSize' => 10
                                     )
                                 );

+ 5 - 4
plugin/dashboard/block_student_graph/block_student_graph.class.php

@@ -14,15 +14,16 @@
  */
 
 require_once api_get_path(LIBRARY_PATH).'attendance.lib.php';
-require_once api_get_path(LIBRARY_PATH).'pChart2/class/pData.class.php';
-require_once api_get_path(LIBRARY_PATH).'pChart2/class/pDraw.class.php';
-require_once api_get_path(LIBRARY_PATH).'pChart2/class/pCache.class.php';
 require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/gradebookitem.class.php';
 require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/evaluation.class.php';
 require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/result.class.php';
 require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/linkfactory.class.php';
 require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/category.class.php';
 
+use CpChart\Classes\pData as pData;
+use CpChart\Classes\pImage as pImage;
+use CpChart\Classes\pCache as pCache;
+
 /**
  * This class is used like controller for student graph block plugin,
  * the class name must be registered inside path.info file (e.g: controller = "BlockStudentGraph"), so dashboard controller will be instantiate it
@@ -189,7 +190,7 @@ class BlockStudentGraph extends Block
                 /* Set the default font */
                 $myPicture->setFontProperties(
                     array(
-                        'FontName' => api_get_path(LIBRARY_PATH) . 'pChart2/fonts/verdana.ttf',
+                        'FontName' => api_get_path(SYS_CSS_PATH) . 'opensans/OpenSans-Regular.ttf',
                         'FontSize' => 10
                     )
                 );

+ 5 - 4
plugin/dashboard/block_teacher_graph/block_teacher_graph.class.php

@@ -12,9 +12,10 @@
 require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
 require_once api_get_path(LIBRARY_PATH).'course.lib.php';
 require_once api_get_path(LIBRARY_PATH).'tracking.lib.php';
-require_once api_get_path(LIBRARY_PATH) . 'pChart2/class/pData.class.php';
-require_once api_get_path(LIBRARY_PATH) . 'pChart2/class/pDraw.class.php';
-require_once api_get_path(LIBRARY_PATH) . 'pChart2/class/pCache.class.php';
+
+use CpChart\Classes\pData as pData;
+use CpChart\Classes\pImage as pImage;
+use CpChart\Classes\pCache as pCache;
 
 /**
  * This class is used like controller for teacher graph block plugin,
@@ -153,7 +154,7 @@ class BlockTeacherGraph extends Block
                 $myPicture->drawRectangle(0, 0, $widthSize - 1, $heightSize - 1, array('R' => 0, 'G' => 0, 'B' => 0));
 
                 /* Set the default font */
-                $myPicture->setFontProperties(array('FontName' => api_get_path(LIBRARY_PATH) . 'pChart2/fonts/verdana.ttf', 'FontSize' => 10));
+                $myPicture->setFontProperties(array('FontName' => api_get_path(SYS_CSS_PATH) . 'opensans/OpenSans-Regular.ttf', 'FontSize' => 10));
 
                 /* Do NOT Write the chart title */