Passed
Push — master ( 65bdac...4e88da )
by Alxarafe
32:38
created
dolibarr/htdocs/core/modules/modExport.class.php 2 patches
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -33,66 +33,66 @@
 block discarded – undo
33 33
 class modExport extends DolibarrModules
34 34
 {
35 35
 
36
-	/**
37
-	 *   Constructor. Define names, constants, directories, boxes, permissions
38
-	 *
39
-	 *   @param      DoliDB		$db      Database handler
40
-	 */
41
-	function __construct($db)
42
-	{
43
-		$this->db = $db;
44
-		$this->numero = 240;
45
-
46
-		$this->family = "technic";
47
-		$this->module_position = '72';
36
+    /**
37
+     *   Constructor. Define names, constants, directories, boxes, permissions
38
+     *
39
+     *   @param      DoliDB		$db      Database handler
40
+     */
41
+    function __construct($db)
42
+    {
43
+        $this->db = $db;
44
+        $this->numero = 240;
45
+
46
+        $this->family = "technic";
47
+        $this->module_position = '72';
48 48
         // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
49
-		$this->name = preg_replace('/^mod/i','',get_class($this));
50
-		$this->description = "Outils d'exports de donnees Dolibarr (via un assistant)";
51
-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
52
-		$this->version = 'dolibarr';
53
-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
54
-		$this->picto = 'technic';
55
-
56
-		// Data directories to create when module is enabled
57
-		$this->dirs = array("/export/temp");
58
-
59
-		// Config pages
60
-		$this->config_page_url = array("export.php");
61
-
62
-		// Dependencies
63
-		$this->depends = array();
64
-		$this->requiredby = array();
65
-		$this->phpmin = array(4,2,0);
66
-		$this->phpmax = array();
67
-
68
-		// Constants
69
-		$this->const = array();
70
-
71
-		// Boxes
72
-		$this->boxes = array();
73
-
74
-		// Permissions
75
-		$this->rights = array();
76
-		$this->rights_class = 'export';
77
-		$r=0;
78
-
79
-		$r++;
80
-		$this->rights[$r][0] = 1201;
81
-		$this->rights[$r][1] = 'Lire les exports';
82
-		$this->rights[$r][2] = 'r';
83
-		$this->rights[$r][3] = 0;
84
-		$this->rights[$r][4] = 'lire';
85
-
86
-		$r++;
87
-		$this->rights[$r][0] = 1202;
88
-		$this->rights[$r][1] = 'Creer/modifier un export';
89
-		$this->rights[$r][2] = 'w';
90
-		$this->rights[$r][3] = 0;
91
-		$this->rights[$r][4] = 'creer';
92
-
93
-
94
-		// Menus
95
-		//-------
96
-		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
97
-	}
49
+        $this->name = preg_replace('/^mod/i','',get_class($this));
50
+        $this->description = "Outils d'exports de donnees Dolibarr (via un assistant)";
51
+        // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
52
+        $this->version = 'dolibarr';
53
+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
54
+        $this->picto = 'technic';
55
+
56
+        // Data directories to create when module is enabled
57
+        $this->dirs = array("/export/temp");
58
+
59
+        // Config pages
60
+        $this->config_page_url = array("export.php");
61
+
62
+        // Dependencies
63
+        $this->depends = array();
64
+        $this->requiredby = array();
65
+        $this->phpmin = array(4,2,0);
66
+        $this->phpmax = array();
67
+
68
+        // Constants
69
+        $this->const = array();
70
+
71
+        // Boxes
72
+        $this->boxes = array();
73
+
74
+        // Permissions
75
+        $this->rights = array();
76
+        $this->rights_class = 'export';
77
+        $r=0;
78
+
79
+        $r++;
80
+        $this->rights[$r][0] = 1201;
81
+        $this->rights[$r][1] = 'Lire les exports';
82
+        $this->rights[$r][2] = 'r';
83
+        $this->rights[$r][3] = 0;
84
+        $this->rights[$r][4] = 'lire';
85
+
86
+        $r++;
87
+        $this->rights[$r][0] = 1202;
88
+        $this->rights[$r][1] = 'Creer/modifier un export';
89
+        $this->rights[$r][2] = 'w';
90
+        $this->rights[$r][3] = 0;
91
+        $this->rights[$r][4] = 'creer';
92
+
93
+
94
+        // Menus
95
+        //-------
96
+        $this->menu = 1;        // This module add menu entries. They are coded into menu manager.
97
+    }
98 98
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  *	\brief      Fichier de description et activation du module export
25 25
  */
26 26
 
27
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
27
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
28 28
 
29 29
 
30 30
 /**
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 		$this->family = "technic";
47 47
 		$this->module_position = '72';
48 48
         // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
49
-		$this->name = preg_replace('/^mod/i','',get_class($this));
49
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
50 50
 		$this->description = "Outils d'exports de donnees Dolibarr (via un assistant)";
51 51
 		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
52 52
 		$this->version = 'dolibarr';
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 		// Dependencies
63 63
 		$this->depends = array();
64 64
 		$this->requiredby = array();
65
-		$this->phpmin = array(4,2,0);
65
+		$this->phpmin = array(4, 2, 0);
66 66
 		$this->phpmax = array();
67 67
 
68 68
 		// Constants
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 		// Permissions
75 75
 		$this->rights = array();
76 76
 		$this->rights_class = 'export';
77
-		$r=0;
77
+		$r = 0;
78 78
 
79 79
 		$r++;
80 80
 		$this->rights[$r][0] = 1201;
@@ -93,6 +93,6 @@  discard block
 block discarded – undo
93 93
 
94 94
 		// Menus
95 95
 		//-------
96
-		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
96
+		$this->menu = 1; // This module add menu entries. They are coded into menu manager.
97 97
 	}
98 98
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/export/export_excel2007.modules.php 3 patches
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -33,104 +33,104 @@
 block discarded – undo
33 33
  */
34 34
 class ExportExcel2007 extends ExportExcel
35 35
 {
36
-	/**
37
-	 * @var int ID
38
-	 */
39
-	public $id;
36
+    /**
37
+     * @var int ID
38
+     */
39
+    public $id;
40 40
 
41
-	/**
41
+    /**
42 42
      * @var string label
43 43
      */
44 44
     public $label;
45 45
 
46
-	public $extension;
46
+    public $extension;
47 47
 
48
-	/**
48
+    /**
49 49
      * Dolibarr version of the loaded document
50 50
      * @public string
51 51
      */
52
-	public $version = 'dolibarr';
52
+    public $version = 'dolibarr';
53 53
 
54
-	public $label_lib;
54
+    public $label_lib;
55 55
 
56
-	public $version_lib;
56
+    public $version_lib;
57 57
 
58
-	public $workbook;      // Handle fichier
58
+    public $workbook;      // Handle fichier
59 59
 
60
-	public $worksheet;     // Handle onglet
60
+    public $worksheet;     // Handle onglet
61 61
 
62
-	public $row;
62
+    public $row;
63 63
 
64
-	public $col;
64
+    public $col;
65 65
 
66 66
     public $file;          // To save filename
67 67
 
68
-	/**
69
-	 *	Constructor
70
-	 *
71
-	 *	@param	    DoliDB	$db      Database handler
72
-	 */
73
-	function __construct($db)
74
-	{
75
-		global $conf, $langs;
76
-		$this->db = $db;
77
-
78
-		$this->id='excel2007';                  // Same value then xxx in file name export_xxx.modules.php
79
-		$this->label='Excel 2007';               // Label of driver
80
-		$this->desc = $langs->trans('Excel2007FormatDesc');
81
-		$this->extension='xlsx';             // Extension for generated file by this driver
68
+    /**
69
+     *	Constructor
70
+     *
71
+     *	@param	    DoliDB	$db      Database handler
72
+     */
73
+    function __construct($db)
74
+    {
75
+        global $conf, $langs;
76
+        $this->db = $db;
77
+
78
+        $this->id='excel2007';                  // Same value then xxx in file name export_xxx.modules.php
79
+        $this->label='Excel 2007';               // Label of driver
80
+        $this->desc = $langs->trans('Excel2007FormatDesc');
81
+        $this->extension='xlsx';             // Extension for generated file by this driver
82 82
         $this->picto='mime/xls';			// Picto
83
-		$this->version='1.30';             // Driver version
83
+        $this->version='1.30';             // Driver version
84 84
 
85
-		$this->disabled = (in_array(constant('PHPEXCEL_PATH'),array('disabled','disabled/'))?1:0);	// A condition to disable module (used for native debian packages)
85
+        $this->disabled = (in_array(constant('PHPEXCEL_PATH'),array('disabled','disabled/'))?1:0);	// A condition to disable module (used for native debian packages)
86 86
 
87
-		if (empty($this->disabled))
88
-		{
89
-    		// If driver use an external library, put its name here
90
-    		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
91
-    		{
92
-    			require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_workbookbig.inc.php';
87
+        if (empty($this->disabled))
88
+        {
89
+            // If driver use an external library, put its name here
90
+            if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
91
+            {
92
+                require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_workbookbig.inc.php';
93 93
                 require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_worksheet.inc.php';
94 94
                 require_once PHP_WRITEEXCEL_PATH.'functions.writeexcel_utility.inc.php';
95
-    			$this->label_lib='PhpWriteExcel';
95
+                $this->label_lib='PhpWriteExcel';
96 96
                 $this->version_lib='unknown';
97
-    		}
98
-    		else
99
-    		{
97
+            }
98
+            else
99
+            {
100 100
                 require_once PHPEXCEL_PATH.'PHPExcel.php';
101 101
                 require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php';
102
-    			$this->label_lib='PhpExcel';
102
+                $this->label_lib='PhpExcel';
103 103
                 $this->version_lib='1.8.0';		// No way to get info from library
104
-    		}
105
-		}
104
+            }
105
+        }
106 106
 
107
-		$this->row=0;
108
-	}
107
+        $this->row=0;
108
+    }
109 109
 
110 110
 
111 111
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
112 112
     /**
113 113
      *  Close Excel file
114 114
      *
115
-	 *  @return		int							<0 if KO, >0 if OK
115
+     *  @return		int							<0 if KO, >0 if OK
116 116
      */
117
-	function close_file()
118
-	{
117
+    function close_file()
118
+    {
119 119
         // phpcs:enable
120
-		global $conf;
121
-
122
-		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
123
-    	{
124
-	        $this->workbook->close();
125
-    	}
126
-    	else
127
-    	{
120
+        global $conf;
121
+
122
+        if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
123
+        {
124
+            $this->workbook->close();
125
+        }
126
+        else
127
+        {
128 128
             require_once PHPEXCEL_PATH.'PHPExcel/Writer/Excel5.php';
129
-    	    $objWriter = new PHPExcel_Writer_Excel2007($this->workbook);
129
+            $objWriter = new PHPExcel_Writer_Excel2007($this->workbook);
130 130
             $objWriter->save($this->file);
131 131
             $this->workbook->disconnectWorksheets();
132 132
             unset($this->workbook);
133
-    	}
134
-		return 1;
135
-	}
133
+        }
134
+        return 1;
135
+    }
136 136
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -55,15 +55,15 @@  discard block
 block discarded – undo
55 55
 
56 56
 	public $version_lib;
57 57
 
58
-	public $workbook;      // Handle fichier
58
+	public $workbook; // Handle fichier
59 59
 
60
-	public $worksheet;     // Handle onglet
60
+	public $worksheet; // Handle onglet
61 61
 
62 62
 	public $row;
63 63
 
64 64
 	public $col;
65 65
 
66
-    public $file;          // To save filename
66
+    public $file; // To save filename
67 67
 
68 68
 	/**
69 69
 	 *	Constructor
@@ -75,36 +75,36 @@  discard block
 block discarded – undo
75 75
 		global $conf, $langs;
76 76
 		$this->db = $db;
77 77
 
78
-		$this->id='excel2007';                  // Same value then xxx in file name export_xxx.modules.php
79
-		$this->label='Excel 2007';               // Label of driver
78
+		$this->id = 'excel2007'; // Same value then xxx in file name export_xxx.modules.php
79
+		$this->label = 'Excel 2007'; // Label of driver
80 80
 		$this->desc = $langs->trans('Excel2007FormatDesc');
81
-		$this->extension='xlsx';             // Extension for generated file by this driver
82
-        $this->picto='mime/xls';			// Picto
83
-		$this->version='1.30';             // Driver version
81
+		$this->extension = 'xlsx'; // Extension for generated file by this driver
82
+        $this->picto = 'mime/xls'; // Picto
83
+		$this->version = '1.30'; // Driver version
84 84
 
85
-		$this->disabled = (in_array(constant('PHPEXCEL_PATH'),array('disabled','disabled/'))?1:0);	// A condition to disable module (used for native debian packages)
85
+		$this->disabled = (in_array(constant('PHPEXCEL_PATH'), array('disabled', 'disabled/')) ? 1 : 0); // A condition to disable module (used for native debian packages)
86 86
 
87 87
 		if (empty($this->disabled))
88 88
 		{
89 89
     		// If driver use an external library, put its name here
90
-    		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
90
+    		if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
91 91
     		{
92 92
     			require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_workbookbig.inc.php';
93 93
                 require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_worksheet.inc.php';
94 94
                 require_once PHP_WRITEEXCEL_PATH.'functions.writeexcel_utility.inc.php';
95
-    			$this->label_lib='PhpWriteExcel';
96
-                $this->version_lib='unknown';
95
+    			$this->label_lib = 'PhpWriteExcel';
96
+                $this->version_lib = 'unknown';
97 97
     		}
98 98
     		else
99 99
     		{
100 100
                 require_once PHPEXCEL_PATH.'PHPExcel.php';
101 101
                 require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php';
102
-    			$this->label_lib='PhpExcel';
103
-                $this->version_lib='1.8.0';		// No way to get info from library
102
+    			$this->label_lib = 'PhpExcel';
103
+                $this->version_lib = '1.8.0'; // No way to get info from library
104 104
     		}
105 105
 		}
106 106
 
107
-		$this->row=0;
107
+		$this->row = 0;
108 108
 	}
109 109
 
110 110
 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
         // phpcs:enable
120 120
 		global $conf;
121 121
 
122
-		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
122
+		if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
123 123
     	{
124 124
 	        $this->workbook->close();
125 125
     	}
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -94,8 +94,7 @@  discard block
 block discarded – undo
94 94
                 require_once PHP_WRITEEXCEL_PATH.'functions.writeexcel_utility.inc.php';
95 95
     			$this->label_lib='PhpWriteExcel';
96 96
                 $this->version_lib='unknown';
97
-    		}
98
-    		else
97
+    		} else
99 98
     		{
100 99
                 require_once PHPEXCEL_PATH.'PHPExcel.php';
101 100
                 require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php';
@@ -122,8 +121,7 @@  discard block
 block discarded – undo
122 121
 		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
123 122
     	{
124 123
 	        $this->workbook->close();
125
-    	}
126
-    	else
124
+    	} else
127 125
     	{
128 126
             require_once PHPEXCEL_PATH.'PHPExcel/Writer/Excel5.php';
129 127
     	    $objWriter = new PHPExcel_Writer_Excel2007($this->workbook);
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/export/export_excel.modules.php 3 patches
Indentation   +346 added lines, -346 removed lines patch added patch discarded remove patch
@@ -32,208 +32,208 @@  discard block
 block discarded – undo
32 32
  */
33 33
 class ExportExcel extends ModeleExports
34 34
 {
35
-	/**
36
-	 * @var int ID
37
-	 */
38
-	public $id;
35
+    /**
36
+     * @var int ID
37
+     */
38
+    public $id;
39 39
 
40 40
     /**
41 41
      * @var string Export Excel label
42 42
      */
43 43
     public $label;
44 44
 
45
-	public $extension;
45
+    public $extension;
46 46
 
47
-	/**
47
+    /**
48 48
      * Dolibarr version of the loaded document
49 49
      * @public string
50 50
      */
51
-	public $version = 'dolibarr';
51
+    public $version = 'dolibarr';
52 52
 
53
-	public $label_lib;
53
+    public $label_lib;
54 54
 
55
-	public $version_lib;
55
+    public $version_lib;
56 56
 
57
-	public $workbook;      // Handle file
57
+    public $workbook;      // Handle file
58 58
 
59
-	public $worksheet;     // Handle sheet
59
+    public $worksheet;     // Handle sheet
60 60
 
61
-	public $row;
61
+    public $row;
62 62
 
63
-	public $col;
63
+    public $col;
64 64
 
65 65
     public $file;          // To save filename
66 66
 
67 67
 
68
-	/**
69
-	 *	Constructor
70
-	 *
71
-	 *	@param	    DoliDB	$db      Database handler
72
-	 */
73
-	function __construct($db)
74
-	{
75
-		global $conf, $langs;
76
-		$this->db = $db;
77
-
78
-		$this->id='excel';                  // Same value then xxx in file name export_xxx.modules.php
79
-		$this->label='Excel 95';             // Label of driver
80
-		$this->desc = $langs->trans('Excel95FormatDesc');
81
-		$this->extension='xls';             // Extension for generated file by this driver
68
+    /**
69
+     *	Constructor
70
+     *
71
+     *	@param	    DoliDB	$db      Database handler
72
+     */
73
+    function __construct($db)
74
+    {
75
+        global $conf, $langs;
76
+        $this->db = $db;
77
+
78
+        $this->id='excel';                  // Same value then xxx in file name export_xxx.modules.php
79
+        $this->label='Excel 95';             // Label of driver
80
+        $this->desc = $langs->trans('Excel95FormatDesc');
81
+        $this->extension='xls';             // Extension for generated file by this driver
82 82
         $this->picto='mime/xls';					// Picto
83
-		$this->version='1.30';             // Driver version
83
+        $this->version='1.30';             // Driver version
84 84
 
85
-		$this->disabled = (in_array(constant('PHPEXCEL_PATH'),array('disabled','disabled/'))?1:0);	// A condition to disable module (used for native debian packages)
85
+        $this->disabled = (in_array(constant('PHPEXCEL_PATH'),array('disabled','disabled/'))?1:0);	// A condition to disable module (used for native debian packages)
86 86
 
87
-		if (empty($this->disabled))
88
-		{
89
-    		// If driver use an external library, put its name here
90
-    		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
91
-    		{
92
-    			require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_workbookbig.inc.php';
87
+        if (empty($this->disabled))
88
+        {
89
+            // If driver use an external library, put its name here
90
+            if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
91
+            {
92
+                require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_workbookbig.inc.php';
93 93
                 require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_worksheet.inc.php';
94 94
                 require_once PHP_WRITEEXCEL_PATH.'functions.writeexcel_utility.inc.php';
95
-    			$this->label_lib='PhpWriteExcel';
95
+                $this->label_lib='PhpWriteExcel';
96 96
                 $this->version_lib='unknown';
97
-    		}
98
-    		else
99
-    		{
97
+            }
98
+            else
99
+            {
100 100
                 require_once PHPEXCEL_PATH.'PHPExcel.php';
101 101
                 require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php';
102
-    			$this->label_lib='PhpExcel';
102
+                $this->label_lib='PhpExcel';
103 103
                 $this->version_lib='1.8.0';		// No way to get info from library
104
-    		}
105
-		}
106
-
107
-		$this->row=0;
108
-	}
109
-
110
-	/**
111
-	 * getDriverId
112
-	 *
113
-	 * @return string
114
-	 */
115
-	function getDriverId()
116
-	{
117
-		return $this->id;
118
-	}
119
-
120
-	/**
121
-	 * getDriverLabel
122
-	 *
123
-	 * @return 	string			Return driver label
124
-	 */
125
-	function getDriverLabel()
126
-	{
127
-		return $this->label;
128
-	}
129
-
130
-	/**
131
-	 * getDriverDesc
132
-	 *
133
-	 * @return string
134
-	 */
135
-	function getDriverDesc()
104
+            }
105
+        }
106
+
107
+        $this->row=0;
108
+    }
109
+
110
+    /**
111
+     * getDriverId
112
+     *
113
+     * @return string
114
+     */
115
+    function getDriverId()
116
+    {
117
+        return $this->id;
118
+    }
119
+
120
+    /**
121
+     * getDriverLabel
122
+     *
123
+     * @return 	string			Return driver label
124
+     */
125
+    function getDriverLabel()
126
+    {
127
+        return $this->label;
128
+    }
129
+
130
+    /**
131
+     * getDriverDesc
132
+     *
133
+     * @return string
134
+     */
135
+    function getDriverDesc()
136 136
     {
137 137
         return $this->desc;
138 138
     }
139 139
 
140
-	/**
141
-	 * getDriverExtension
142
-	 *
143
-	 * @return string
144
-	 */
140
+    /**
141
+     * getDriverExtension
142
+     *
143
+     * @return string
144
+     */
145 145
     function getDriverExtension()
146
-	{
147
-		return $this->extension;
148
-	}
149
-
150
-	/**
151
-	 * getDriverVersion
152
-	 *
153
-	 * @return string
154
-	 */
155
-	function getDriverVersion()
156
-	{
157
-		return $this->version;
158
-	}
159
-
160
-	/**
161
-	 * getLibLabel
162
-	 *
163
-	 * @return string
164
-	 */
165
-	function getLibLabel()
166
-	{
167
-		return $this->label_lib;
168
-	}
169
-
170
-	/**
171
-	 * getLibVersion
172
-	 *
173
-	 * @return string
174
-	 */
175
-	function getLibVersion()
176
-	{
177
-		return $this->version_lib;
178
-	}
146
+    {
147
+        return $this->extension;
148
+    }
149
+
150
+    /**
151
+     * getDriverVersion
152
+     *
153
+     * @return string
154
+     */
155
+    function getDriverVersion()
156
+    {
157
+        return $this->version;
158
+    }
159
+
160
+    /**
161
+     * getLibLabel
162
+     *
163
+     * @return string
164
+     */
165
+    function getLibLabel()
166
+    {
167
+        return $this->label_lib;
168
+    }
169
+
170
+    /**
171
+     * getLibVersion
172
+     *
173
+     * @return string
174
+     */
175
+    function getLibVersion()
176
+    {
177
+        return $this->version_lib;
178
+    }
179 179
 
180 180
 
181 181
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
182
-	/**
183
-	 *	Open output file
184
-	 *
185
-	 * 	@param		string		$file			File name to generate
186
-	 *  @param		Translate	$outputlangs	Output language object
187
-	 *	@return		int							<0 if KO, >=0 if OK
188
-	 */
189
-	function open_file($file,$outputlangs)
190
-	{
182
+    /**
183
+     *	Open output file
184
+     *
185
+     * 	@param		string		$file			File name to generate
186
+     *  @param		Translate	$outputlangs	Output language object
187
+     *	@return		int							<0 if KO, >=0 if OK
188
+     */
189
+    function open_file($file,$outputlangs)
190
+    {
191 191
         // phpcs:enable
192
-		global $user,$conf,$langs;
192
+        global $user,$conf,$langs;
193 193
 
194
-		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
195
-		{
196
-		    $outputlangs->charset_output='ISO-8859-1';	// Because Excel 5 format is ISO
197
-		}
194
+        if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
195
+        {
196
+            $outputlangs->charset_output='ISO-8859-1';	// Because Excel 5 format is ISO
197
+        }
198 198
 
199
-		dol_syslog(get_class($this)."::open_file file=".$file);
199
+        dol_syslog(get_class($this)."::open_file file=".$file);
200 200
         $this->file=$file;
201 201
 
202
-		$ret=1;
202
+        $ret=1;
203 203
 
204
-    	$outputlangs->load("exports");
205
-		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
206
-		{
204
+        $outputlangs->load("exports");
205
+        if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
206
+        {
207 207
             require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_workbookbig.inc.php';
208 208
             require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_worksheet.inc.php';
209 209
             require_once PHP_WRITEEXCEL_PATH.'functions.writeexcel_utility.inc.php';
210
-		    $this->workbook = new writeexcel_workbookbig($file);
211
-    		$this->workbook->set_tempdir($conf->export->dir_temp);			// Set temporary directory
212
-    		$this->workbook->set_sheetname($outputlangs->trans("Sheet"));
213
-    		$this->worksheet = &$this->workbook->addworksheet();
214
-		}
215
-		else
216
-		{
210
+            $this->workbook = new writeexcel_workbookbig($file);
211
+            $this->workbook->set_tempdir($conf->export->dir_temp);			// Set temporary directory
212
+            $this->workbook->set_sheetname($outputlangs->trans("Sheet"));
213
+            $this->worksheet = &$this->workbook->addworksheet();
214
+        }
215
+        else
216
+        {
217 217
             require_once PHPEXCEL_PATH.'PHPExcel.php';
218 218
             require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php';
219 219
 
220
-		    if ($this->id == 'excel2007')
221
-		    {
222
-	            if (! class_exists('ZipArchive'))	// For Excel2007, PHPExcel need ZipArchive
223
-	            {
224
-	            	$langs->load("errors");
225
-	            	$this->error=$langs->trans('ErrorPHPNeedModule','zip');
226
-	            	return -1;
227
-	            }
228
-		    }
229
-
230
-		    if (!empty($conf->global->MAIN_USE_FILECACHE_EXPORT_EXCEL_DIR)) {
231
-			    $cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_discISAM;
232
-			    $cacheSettings = array (
233
-			    		'dir' => $conf->global->MAIN_USE_FILECACHE_EXPORT_EXCEL_DIR
234
-			    );
235
-			    PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
236
-		    }
220
+            if ($this->id == 'excel2007')
221
+            {
222
+                if (! class_exists('ZipArchive'))	// For Excel2007, PHPExcel need ZipArchive
223
+                {
224
+                    $langs->load("errors");
225
+                    $this->error=$langs->trans('ErrorPHPNeedModule','zip');
226
+                    return -1;
227
+                }
228
+            }
229
+
230
+            if (!empty($conf->global->MAIN_USE_FILECACHE_EXPORT_EXCEL_DIR)) {
231
+                $cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_discISAM;
232
+                $cacheSettings = array (
233
+                        'dir' => $conf->global->MAIN_USE_FILECACHE_EXPORT_EXCEL_DIR
234
+                );
235
+                PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
236
+            }
237 237
 
238 238
             $this->workbook = new PHPExcel();
239 239
             $this->workbook->getProperties()->setCreator($user->getFullName($outputlangs).' - Dolibarr '.DOL_VERSION);
@@ -245,242 +245,242 @@  discard block
 block discarded – undo
245 245
             $this->workbook->setActiveSheetIndex(0);
246 246
             $this->workbook->getActiveSheet()->setTitle($outputlangs->trans("Sheet"));
247 247
             $this->workbook->getActiveSheet()->getDefaultRowDimension()->setRowHeight(16);
248
-		}
249
-		return $ret;
250
-	}
248
+        }
249
+        return $ret;
250
+    }
251 251
 
252 252
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
253
-	/**
254
-	 *  Write header
255
-	 *
253
+    /**
254
+     *  Write header
255
+     *
256 256
      *  @param      Translate	$outputlangs        Object lang to translate values
257
-	 * 	@return		int								<0 if KO, >0 if OK
258
-	 */
259
-	function write_header($outputlangs)
260
-	{
257
+     * 	@return		int								<0 if KO, >0 if OK
258
+     */
259
+    function write_header($outputlangs)
260
+    {
261 261
         // phpcs:enable
262
-		//$outputlangs->charset_output='ISO-8859-1';	// Because Excel 5 format is ISO
262
+        //$outputlangs->charset_output='ISO-8859-1';	// Because Excel 5 format is ISO
263 263
 
264
-		return 0;
265
-	}
264
+        return 0;
265
+    }
266 266
 
267 267
 
268 268
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
269
-	/**
269
+    /**
270 270
      *  Output title line into file
271 271
      *
272 272
      *  @param      array		$array_export_fields_label   	Array with list of label of fields
273 273
      *  @param      array		$array_selected_sorted       	Array with list of field to export
274 274
      *  @param      Translate	$outputlangs    				Object lang to translate values
275 275
      *  @param		array		$array_types					Array with types of fields
276
-	 * 	@return		int											<0 if KO, >0 if OK
277
-	 */
278
-	function write_title($array_export_fields_label,$array_selected_sorted,$outputlangs,$array_types)
279
-	{
276
+     * 	@return		int											<0 if KO, >0 if OK
277
+     */
278
+    function write_title($array_export_fields_label,$array_selected_sorted,$outputlangs,$array_types)
279
+    {
280 280
         // phpcs:enable
281
-		global $conf;
282
-
283
-		// Create a format for the column headings
284
-		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
285
-		{
286
-		    $outputlangs->charset_output='ISO-8859-1';	// Because Excel 5 format is ISO
287
-
288
-		    $formatheader =$this->workbook->addformat();
289
-    		$formatheader->set_bold();
290
-    		$formatheader->set_color('blue');
291
-    		//$formatheader->set_size(12);
292
-    		//$formatheader->set_font("Courier New");
293
-    		//$formatheader->set_align('center');
294
-		}
295
-		else
296
-		{
281
+        global $conf;
282
+
283
+        // Create a format for the column headings
284
+        if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
285
+        {
286
+            $outputlangs->charset_output='ISO-8859-1';	// Because Excel 5 format is ISO
287
+
288
+            $formatheader =$this->workbook->addformat();
289
+            $formatheader->set_bold();
290
+            $formatheader->set_color('blue');
291
+            //$formatheader->set_size(12);
292
+            //$formatheader->set_font("Courier New");
293
+            //$formatheader->set_align('center');
294
+        }
295
+        else
296
+        {
297 297
             $this->workbook->getActiveSheet()->getStyle('1')->getFont()->setBold(true);
298
-		    $this->workbook->getActiveSheet()->getStyle('1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
299
-		}
298
+            $this->workbook->getActiveSheet()->getStyle('1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
299
+        }
300 300
 
301
-		$this->col=0;
302
-		foreach($array_selected_sorted as $code => $value)
303
-		{
301
+        $this->col=0;
302
+        foreach($array_selected_sorted as $code => $value)
303
+        {
304 304
             $alias=$array_export_fields_label[$code];
305
-			//print "dd".$alias;
306
-			if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
307
-    		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
308
-    		{
309
-    			$this->worksheet->write($this->row, $this->col, $outputlangs->transnoentities($alias), $formatheader);
310
-    		}
311
-    		else
312
-    		{
305
+            //print "dd".$alias;
306
+            if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
307
+            if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
308
+            {
309
+                $this->worksheet->write($this->row, $this->col, $outputlangs->transnoentities($alias), $formatheader);
310
+            }
311
+            else
312
+            {
313 313
                 $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, $outputlangs->transnoentities($alias));
314
-    		    if (! empty($array_types[$code]) && in_array($array_types[$code],array('Date','Numeric','TextAuto')))		// Set autowidth for some types
314
+                if (! empty($array_types[$code]) && in_array($array_types[$code],array('Date','Numeric','TextAuto')))		// Set autowidth for some types
315 315
                 {
316
-                	$this->workbook->getActiveSheet()->getColumnDimension($this->column2Letter($this->col + 1))->setAutoSize(true);
316
+                    $this->workbook->getActiveSheet()->getColumnDimension($this->column2Letter($this->col + 1))->setAutoSize(true);
317 317
                 }
318
-    		}
319
-			$this->col++;
320
-		}
321
-		$this->row++;
322
-		return 0;
323
-	}
318
+            }
319
+            $this->col++;
320
+        }
321
+        $this->row++;
322
+        return 0;
323
+    }
324 324
 
325 325
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
326
-	/**
326
+    /**
327 327
      *  Output record line into file
328 328
      *
329 329
      *  @param      array		$array_selected_sorted      Array with list of field to export
330 330
      *  @param      resource	$objp                       A record from a fetch with all fields from select
331 331
      *  @param      Translate	$outputlangs                Object lang to translate values
332 332
      *  @param		array		$array_types				Array with types of fields
333
-	 * 	@return		int										<0 if KO, >0 if OK
334
-	 */
335
-	function write_record($array_selected_sorted,$objp,$outputlangs,$array_types)
336
-	{
333
+     * 	@return		int										<0 if KO, >0 if OK
334
+     */
335
+    function write_record($array_selected_sorted,$objp,$outputlangs,$array_types)
336
+    {
337 337
         // phpcs:enable
338
-		global $conf;
338
+        global $conf;
339 339
 
340
-		// Create a format for the column headings
341
-		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
342
-		{
343
-		    $outputlangs->charset_output='ISO-8859-1';	// Because Excel 5 format is ISO
344
-		}
340
+        // Create a format for the column headings
341
+        if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
342
+        {
343
+            $outputlangs->charset_output='ISO-8859-1';	// Because Excel 5 format is ISO
344
+        }
345 345
 
346
-		// Define first row
347
-		$this->col=0;
346
+        // Define first row
347
+        $this->col=0;
348 348
 
349
-		foreach($array_selected_sorted as $code => $value)
350
-		{
351
-			if (strpos($code,' as ') == 0) $alias=str_replace(array('.','-','(',')'),'_',$code);
352
-			else $alias=substr($code, strpos($code, ' as ') + 4);
349
+        foreach($array_selected_sorted as $code => $value)
350
+        {
351
+            if (strpos($code,' as ') == 0) $alias=str_replace(array('.','-','(',')'),'_',$code);
352
+            else $alias=substr($code, strpos($code, ' as ') + 4);
353 353
             if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
354 354
             $newvalue=$objp->$alias;
355 355
 
356
-			$newvalue=$this->excel_clean($newvalue);
357
-			$typefield=isset($array_types[$code])?$array_types[$code]:'';
358
-
359
-			if (preg_match('/^Select:/i', $typefield, $reg) && $typefield = substr($typefield, 7))
360
-			{
361
-				$array = unserialize($typefield);
362
-				$array = $array['options'];
363
-				$newvalue = $array[$newvalue];
364
-			}
365
-
366
-			// Traduction newvalue
367
-			if (preg_match('/^\((.*)\)$/i',$newvalue,$reg))
368
-			{
369
-				$newvalue=$outputlangs->transnoentities($reg[1]);
370
-			}
371
-			else
372
-			{
373
-				$newvalue=$outputlangs->convToOutputCharset($newvalue);
374
-			}
375
-
376
-			if (preg_match('/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$/i',$newvalue))
377
-			{
378
-        		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
379
-        		{
380
-            		$formatdate=$this->workbook->addformat();
381
-            		$formatdate->set_num_format('yyyy-mm-dd');
382
-            		//$formatdate->set_num_format(0x0f);
383
-        		    $arrayvalue=preg_split('/[.,]/',xl_parse_date($newvalue));
384
-    				//print "x".$arrayvalue[0].'.'.strval($arrayvalue[1]).'<br>';
385
-    				$newvalue=strval($arrayvalue[0]).'.'.strval($arrayvalue[1]);	// $newvalue=strval(36892.521); directly does not work because . will be convert into , later
386
-        		    $this->worksheet->write($this->row, $this->col, $newvalue, PHPExcel_Shared_Date::PHPToExcel($formatdate));
387
-        		}
388
-        		else
389
-        		{
390
-        		    $newvalue=dol_stringtotime($newvalue);
391
-        		    $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, PHPExcel_Shared_Date::PHPToExcel($newvalue));
392
-        		    $coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
393
-        		    $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd');
394
-        		}
395
-			}
396
-			elseif (preg_match('/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]$/i',$newvalue))
397
-			{
398
-				if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
399
-    		    {
400
-            		$formatdatehour=$this->workbook->addformat();
401
-            		$formatdatehour->set_num_format('yyyy-mm-dd hh:mm:ss');
402
-            		//$formatdatehour->set_num_format(0x0f);
403
-            		$arrayvalue=preg_split('/[.,]/',xl_parse_date($newvalue));
404
-    				//print "x".$arrayvalue[0].'.'.strval($arrayvalue[1]).'<br>';
405
-    				$newvalue=strval($arrayvalue[0]).'.'.strval($arrayvalue[1]);	// $newvalue=strval(36892.521); directly does not work because . will be convert into , later
406
-    		        $this->worksheet->write($this->row, $this->col, $newvalue, $formatdatehour);
407
-    		    }
408
-    		    else
409
-    		    {
410
-        		    $newvalue=dol_stringtotime($newvalue);
411
-    		        $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, PHPExcel_Shared_Date::PHPToExcel($newvalue));
412
-        		    $coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
413
-        		    $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd h:mm:ss');
414
-    		    }
415
-			}
416
-			else
417
-			{
418
-				if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
419
-    		    {
420
-			        $this->worksheet->write($this->row, $this->col, $newvalue);
421
-    		    }
422
-    		    else
423
-				{
424
-    		    	if ($typefield == 'Text' || $typefield == 'TextAuto')
425
-    		    	{
426
-    		    		//$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->setValueExplicit($newvalue, PHPExcel_Cell_DataType::TYPE_STRING);
427
-						$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, (string) $newvalue);
428
-    		    		$coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
429
-    		    		$this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('@');
430
-    		    		$this->workbook->getActiveSheet()->getStyle($coord)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
431
-    		    	}
432
-    		    	else
433
-    		    	{
434
-    		    		$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, $newvalue);
435
-    		    	}
436
-    		    }
437
-			}
438
-			$this->col++;
439
-		}
440
-		$this->row++;
441
-		return 0;
442
-	}
356
+            $newvalue=$this->excel_clean($newvalue);
357
+            $typefield=isset($array_types[$code])?$array_types[$code]:'';
358
+
359
+            if (preg_match('/^Select:/i', $typefield, $reg) && $typefield = substr($typefield, 7))
360
+            {
361
+                $array = unserialize($typefield);
362
+                $array = $array['options'];
363
+                $newvalue = $array[$newvalue];
364
+            }
365
+
366
+            // Traduction newvalue
367
+            if (preg_match('/^\((.*)\)$/i',$newvalue,$reg))
368
+            {
369
+                $newvalue=$outputlangs->transnoentities($reg[1]);
370
+            }
371
+            else
372
+            {
373
+                $newvalue=$outputlangs->convToOutputCharset($newvalue);
374
+            }
375
+
376
+            if (preg_match('/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$/i',$newvalue))
377
+            {
378
+                if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
379
+                {
380
+                    $formatdate=$this->workbook->addformat();
381
+                    $formatdate->set_num_format('yyyy-mm-dd');
382
+                    //$formatdate->set_num_format(0x0f);
383
+                    $arrayvalue=preg_split('/[.,]/',xl_parse_date($newvalue));
384
+                    //print "x".$arrayvalue[0].'.'.strval($arrayvalue[1]).'<br>';
385
+                    $newvalue=strval($arrayvalue[0]).'.'.strval($arrayvalue[1]);	// $newvalue=strval(36892.521); directly does not work because . will be convert into , later
386
+                    $this->worksheet->write($this->row, $this->col, $newvalue, PHPExcel_Shared_Date::PHPToExcel($formatdate));
387
+                }
388
+                else
389
+                {
390
+                    $newvalue=dol_stringtotime($newvalue);
391
+                    $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, PHPExcel_Shared_Date::PHPToExcel($newvalue));
392
+                    $coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
393
+                    $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd');
394
+                }
395
+            }
396
+            elseif (preg_match('/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]$/i',$newvalue))
397
+            {
398
+                if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
399
+                {
400
+                    $formatdatehour=$this->workbook->addformat();
401
+                    $formatdatehour->set_num_format('yyyy-mm-dd hh:mm:ss');
402
+                    //$formatdatehour->set_num_format(0x0f);
403
+                    $arrayvalue=preg_split('/[.,]/',xl_parse_date($newvalue));
404
+                    //print "x".$arrayvalue[0].'.'.strval($arrayvalue[1]).'<br>';
405
+                    $newvalue=strval($arrayvalue[0]).'.'.strval($arrayvalue[1]);	// $newvalue=strval(36892.521); directly does not work because . will be convert into , later
406
+                    $this->worksheet->write($this->row, $this->col, $newvalue, $formatdatehour);
407
+                }
408
+                else
409
+                {
410
+                    $newvalue=dol_stringtotime($newvalue);
411
+                    $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, PHPExcel_Shared_Date::PHPToExcel($newvalue));
412
+                    $coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
413
+                    $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd h:mm:ss');
414
+                }
415
+            }
416
+            else
417
+            {
418
+                if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
419
+                {
420
+                    $this->worksheet->write($this->row, $this->col, $newvalue);
421
+                }
422
+                else
423
+                {
424
+                    if ($typefield == 'Text' || $typefield == 'TextAuto')
425
+                    {
426
+                        //$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->setValueExplicit($newvalue, PHPExcel_Cell_DataType::TYPE_STRING);
427
+                        $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, (string) $newvalue);
428
+                        $coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
429
+                        $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('@');
430
+                        $this->workbook->getActiveSheet()->getStyle($coord)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
431
+                    }
432
+                    else
433
+                    {
434
+                        $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, $newvalue);
435
+                    }
436
+                }
437
+            }
438
+            $this->col++;
439
+        }
440
+        $this->row++;
441
+        return 0;
442
+    }
443 443
 
444 444
 
445 445
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
446
-	/**
446
+    /**
447 447
      *	Write footer
448 448
      *
449
-	 * 	@param		Translate	$outputlangs	Output language object
450
-	 * 	@return		int							<0 if KO, >0 if OK
449
+     * 	@param		Translate	$outputlangs	Output language object
450
+     * 	@return		int							<0 if KO, >0 if OK
451 451
      */
452
-	function write_footer($outputlangs)
453
-	{
452
+    function write_footer($outputlangs)
453
+    {
454 454
         // phpcs:enable
455
-		return 0;
456
-	}
455
+        return 0;
456
+    }
457 457
 
458 458
 
459 459
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
460 460
     /**
461 461
      *	Close Excel file
462 462
      *
463
-	 * 	@return		int							<0 if KO, >0 if OK
463
+     * 	@return		int							<0 if KO, >0 if OK
464 464
      */
465
-	function close_file()
466
-	{
465
+    function close_file()
466
+    {
467 467
         // phpcs:enable
468
-		global $conf;
469
-
470
-		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
471
-    	{
472
-	        $this->workbook->close();
473
-    	}
474
-    	else
475
-    	{
468
+        global $conf;
469
+
470
+        if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
471
+        {
472
+            $this->workbook->close();
473
+        }
474
+        else
475
+        {
476 476
             require_once PHPEXCEL_PATH.'PHPExcel/Writer/Excel5.php';
477
-    	    $objWriter = new PHPExcel_Writer_Excel5($this->workbook);
477
+            $objWriter = new PHPExcel_Writer_Excel5($this->workbook);
478 478
             $objWriter->save($this->file);
479 479
             $this->workbook->disconnectWorksheets();
480 480
             unset($this->workbook);
481
-    	}
482
-		return 1;
483
-	}
481
+        }
482
+        return 1;
483
+    }
484 484
 
485 485
 
486 486
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
@@ -493,10 +493,10 @@  discard block
 block discarded – undo
493 493
     function excel_clean($newvalue)
494 494
     {
495 495
         // phpcs:enable
496
-		// Rule Dolibarr: No HTML
497
-    	$newvalue=dol_string_nohtmltag($newvalue);
496
+        // Rule Dolibarr: No HTML
497
+        $newvalue=dol_string_nohtmltag($newvalue);
498 498
 
499
-    	return $newvalue;
499
+        return $newvalue;
500 500
     }
501 501
 
502 502
 
@@ -509,16 +509,16 @@  discard block
 block discarded – undo
509 509
     function column2Letter($c)
510 510
     {
511 511
 
512
-    	$c = intval($c);
513
-    	if ($c <= 0) return '';
512
+        $c = intval($c);
513
+        if ($c <= 0) return '';
514 514
 
515
-    	while ($c != 0)
516
-    	{
517
-    		$p = ($c - 1) % 26;
518
-    		$c = intval(($c - $p) / 26);
519
-    		$letter = chr(65 + $p) . $letter;
520
-    	}
515
+        while ($c != 0)
516
+        {
517
+            $p = ($c - 1) % 26;
518
+            $c = intval(($c - $p) / 26);
519
+            $letter = chr(65 + $p) . $letter;
520
+        }
521 521
 
522
-    	return $letter;
522
+        return $letter;
523 523
     }
524 524
 }
Please login to merge, or discard this patch.
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -54,15 +54,15 @@  discard block
 block discarded – undo
54 54
 
55 55
 	public $version_lib;
56 56
 
57
-	public $workbook;      // Handle file
57
+	public $workbook; // Handle file
58 58
 
59
-	public $worksheet;     // Handle sheet
59
+	public $worksheet; // Handle sheet
60 60
 
61 61
 	public $row;
62 62
 
63 63
 	public $col;
64 64
 
65
-    public $file;          // To save filename
65
+    public $file; // To save filename
66 66
 
67 67
 
68 68
 	/**
@@ -75,36 +75,36 @@  discard block
 block discarded – undo
75 75
 		global $conf, $langs;
76 76
 		$this->db = $db;
77 77
 
78
-		$this->id='excel';                  // Same value then xxx in file name export_xxx.modules.php
79
-		$this->label='Excel 95';             // Label of driver
78
+		$this->id = 'excel'; // Same value then xxx in file name export_xxx.modules.php
79
+		$this->label = 'Excel 95'; // Label of driver
80 80
 		$this->desc = $langs->trans('Excel95FormatDesc');
81
-		$this->extension='xls';             // Extension for generated file by this driver
82
-        $this->picto='mime/xls';					// Picto
83
-		$this->version='1.30';             // Driver version
81
+		$this->extension = 'xls'; // Extension for generated file by this driver
82
+        $this->picto = 'mime/xls'; // Picto
83
+		$this->version = '1.30'; // Driver version
84 84
 
85
-		$this->disabled = (in_array(constant('PHPEXCEL_PATH'),array('disabled','disabled/'))?1:0);	// A condition to disable module (used for native debian packages)
85
+		$this->disabled = (in_array(constant('PHPEXCEL_PATH'), array('disabled', 'disabled/')) ? 1 : 0); // A condition to disable module (used for native debian packages)
86 86
 
87 87
 		if (empty($this->disabled))
88 88
 		{
89 89
     		// If driver use an external library, put its name here
90
-    		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
90
+    		if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
91 91
     		{
92 92
     			require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_workbookbig.inc.php';
93 93
                 require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_worksheet.inc.php';
94 94
                 require_once PHP_WRITEEXCEL_PATH.'functions.writeexcel_utility.inc.php';
95
-    			$this->label_lib='PhpWriteExcel';
96
-                $this->version_lib='unknown';
95
+    			$this->label_lib = 'PhpWriteExcel';
96
+                $this->version_lib = 'unknown';
97 97
     		}
98 98
     		else
99 99
     		{
100 100
                 require_once PHPEXCEL_PATH.'PHPExcel.php';
101 101
                 require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php';
102
-    			$this->label_lib='PhpExcel';
103
-                $this->version_lib='1.8.0';		// No way to get info from library
102
+    			$this->label_lib = 'PhpExcel';
103
+                $this->version_lib = '1.8.0'; // No way to get info from library
104 104
     		}
105 105
 		}
106 106
 
107
-		$this->row=0;
107
+		$this->row = 0;
108 108
 	}
109 109
 
110 110
 	/**
@@ -186,29 +186,29 @@  discard block
 block discarded – undo
186 186
 	 *  @param		Translate	$outputlangs	Output language object
187 187
 	 *	@return		int							<0 if KO, >=0 if OK
188 188
 	 */
189
-	function open_file($file,$outputlangs)
189
+	function open_file($file, $outputlangs)
190 190
 	{
191 191
         // phpcs:enable
192
-		global $user,$conf,$langs;
192
+		global $user, $conf, $langs;
193 193
 
194
-		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
194
+		if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
195 195
 		{
196
-		    $outputlangs->charset_output='ISO-8859-1';	// Because Excel 5 format is ISO
196
+		    $outputlangs->charset_output = 'ISO-8859-1'; // Because Excel 5 format is ISO
197 197
 		}
198 198
 
199 199
 		dol_syslog(get_class($this)."::open_file file=".$file);
200
-        $this->file=$file;
200
+        $this->file = $file;
201 201
 
202
-		$ret=1;
202
+		$ret = 1;
203 203
 
204 204
     	$outputlangs->load("exports");
205
-		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
205
+		if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
206 206
 		{
207 207
             require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_workbookbig.inc.php';
208 208
             require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_worksheet.inc.php';
209 209
             require_once PHP_WRITEEXCEL_PATH.'functions.writeexcel_utility.inc.php';
210 210
 		    $this->workbook = new writeexcel_workbookbig($file);
211
-    		$this->workbook->set_tempdir($conf->export->dir_temp);			// Set temporary directory
211
+    		$this->workbook->set_tempdir($conf->export->dir_temp); // Set temporary directory
212 212
     		$this->workbook->set_sheetname($outputlangs->trans("Sheet"));
213 213
     		$this->worksheet = &$this->workbook->addworksheet();
214 214
 		}
@@ -219,17 +219,17 @@  discard block
 block discarded – undo
219 219
 
220 220
 		    if ($this->id == 'excel2007')
221 221
 		    {
222
-	            if (! class_exists('ZipArchive'))	// For Excel2007, PHPExcel need ZipArchive
222
+	            if (!class_exists('ZipArchive'))	// For Excel2007, PHPExcel need ZipArchive
223 223
 	            {
224 224
 	            	$langs->load("errors");
225
-	            	$this->error=$langs->trans('ErrorPHPNeedModule','zip');
225
+	            	$this->error = $langs->trans('ErrorPHPNeedModule', 'zip');
226 226
 	            	return -1;
227 227
 	            }
228 228
 		    }
229 229
 
230 230
 		    if (!empty($conf->global->MAIN_USE_FILECACHE_EXPORT_EXCEL_DIR)) {
231 231
 			    $cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_discISAM;
232
-			    $cacheSettings = array (
232
+			    $cacheSettings = array(
233 233
 			    		'dir' => $conf->global->MAIN_USE_FILECACHE_EXPORT_EXCEL_DIR
234 234
 			    );
235 235
 			    PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
@@ -275,17 +275,17 @@  discard block
 block discarded – undo
275 275
      *  @param		array		$array_types					Array with types of fields
276 276
 	 * 	@return		int											<0 if KO, >0 if OK
277 277
 	 */
278
-	function write_title($array_export_fields_label,$array_selected_sorted,$outputlangs,$array_types)
278
+	function write_title($array_export_fields_label, $array_selected_sorted, $outputlangs, $array_types)
279 279
 	{
280 280
         // phpcs:enable
281 281
 		global $conf;
282 282
 
283 283
 		// Create a format for the column headings
284
-		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
284
+		if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
285 285
 		{
286
-		    $outputlangs->charset_output='ISO-8859-1';	// Because Excel 5 format is ISO
286
+		    $outputlangs->charset_output = 'ISO-8859-1'; // Because Excel 5 format is ISO
287 287
 
288
-		    $formatheader =$this->workbook->addformat();
288
+		    $formatheader = $this->workbook->addformat();
289 289
     		$formatheader->set_bold();
290 290
     		$formatheader->set_color('blue');
291 291
     		//$formatheader->set_size(12);
@@ -298,20 +298,20 @@  discard block
 block discarded – undo
298 298
 		    $this->workbook->getActiveSheet()->getStyle('1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
299 299
 		}
300 300
 
301
-		$this->col=0;
302
-		foreach($array_selected_sorted as $code => $value)
301
+		$this->col = 0;
302
+		foreach ($array_selected_sorted as $code => $value)
303 303
 		{
304
-            $alias=$array_export_fields_label[$code];
304
+            $alias = $array_export_fields_label[$code];
305 305
 			//print "dd".$alias;
306
-			if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
307
-    		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
306
+			if (empty($alias)) dol_print_error('', 'Bad value for field with code='.$code.'. Try to redefine export.');
307
+    		if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
308 308
     		{
309 309
     			$this->worksheet->write($this->row, $this->col, $outputlangs->transnoentities($alias), $formatheader);
310 310
     		}
311 311
     		else
312 312
     		{
313
-                $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, $outputlangs->transnoentities($alias));
314
-    		    if (! empty($array_types[$code]) && in_array($array_types[$code],array('Date','Numeric','TextAuto')))		// Set autowidth for some types
313
+                $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row + 1, $outputlangs->transnoentities($alias));
314
+    		    if (!empty($array_types[$code]) && in_array($array_types[$code], array('Date', 'Numeric', 'TextAuto')))		// Set autowidth for some types
315 315
                 {
316 316
                 	$this->workbook->getActiveSheet()->getColumnDimension($this->column2Letter($this->col + 1))->setAutoSize(true);
317 317
                 }
@@ -332,29 +332,29 @@  discard block
 block discarded – undo
332 332
      *  @param		array		$array_types				Array with types of fields
333 333
 	 * 	@return		int										<0 if KO, >0 if OK
334 334
 	 */
335
-	function write_record($array_selected_sorted,$objp,$outputlangs,$array_types)
335
+	function write_record($array_selected_sorted, $objp, $outputlangs, $array_types)
336 336
 	{
337 337
         // phpcs:enable
338 338
 		global $conf;
339 339
 
340 340
 		// Create a format for the column headings
341
-		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
341
+		if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
342 342
 		{
343
-		    $outputlangs->charset_output='ISO-8859-1';	// Because Excel 5 format is ISO
343
+		    $outputlangs->charset_output = 'ISO-8859-1'; // Because Excel 5 format is ISO
344 344
 		}
345 345
 
346 346
 		// Define first row
347
-		$this->col=0;
347
+		$this->col = 0;
348 348
 
349
-		foreach($array_selected_sorted as $code => $value)
349
+		foreach ($array_selected_sorted as $code => $value)
350 350
 		{
351
-			if (strpos($code,' as ') == 0) $alias=str_replace(array('.','-','(',')'),'_',$code);
352
-			else $alias=substr($code, strpos($code, ' as ') + 4);
353
-            if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
354
-            $newvalue=$objp->$alias;
351
+			if (strpos($code, ' as ') == 0) $alias = str_replace(array('.', '-', '(', ')'), '_', $code);
352
+			else $alias = substr($code, strpos($code, ' as ') + 4);
353
+            if (empty($alias)) dol_print_error('', 'Bad value for field with code='.$code.'. Try to redefine export.');
354
+            $newvalue = $objp->$alias;
355 355
 
356
-			$newvalue=$this->excel_clean($newvalue);
357
-			$typefield=isset($array_types[$code])?$array_types[$code]:'';
356
+			$newvalue = $this->excel_clean($newvalue);
357
+			$typefield = isset($array_types[$code]) ? $array_types[$code] : '';
358 358
 
359 359
 			if (preg_match('/^Select:/i', $typefield, $reg) && $typefield = substr($typefield, 7))
360 360
 			{
@@ -364,58 +364,58 @@  discard block
 block discarded – undo
364 364
 			}
365 365
 
366 366
 			// Traduction newvalue
367
-			if (preg_match('/^\((.*)\)$/i',$newvalue,$reg))
367
+			if (preg_match('/^\((.*)\)$/i', $newvalue, $reg))
368 368
 			{
369
-				$newvalue=$outputlangs->transnoentities($reg[1]);
369
+				$newvalue = $outputlangs->transnoentities($reg[1]);
370 370
 			}
371 371
 			else
372 372
 			{
373
-				$newvalue=$outputlangs->convToOutputCharset($newvalue);
373
+				$newvalue = $outputlangs->convToOutputCharset($newvalue);
374 374
 			}
375 375
 
376
-			if (preg_match('/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$/i',$newvalue))
376
+			if (preg_match('/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$/i', $newvalue))
377 377
 			{
378
-        		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
378
+        		if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
379 379
         		{
380
-            		$formatdate=$this->workbook->addformat();
380
+            		$formatdate = $this->workbook->addformat();
381 381
             		$formatdate->set_num_format('yyyy-mm-dd');
382 382
             		//$formatdate->set_num_format(0x0f);
383
-        		    $arrayvalue=preg_split('/[.,]/',xl_parse_date($newvalue));
383
+        		    $arrayvalue = preg_split('/[.,]/', xl_parse_date($newvalue));
384 384
     				//print "x".$arrayvalue[0].'.'.strval($arrayvalue[1]).'<br>';
385
-    				$newvalue=strval($arrayvalue[0]).'.'.strval($arrayvalue[1]);	// $newvalue=strval(36892.521); directly does not work because . will be convert into , later
385
+    				$newvalue = strval($arrayvalue[0]).'.'.strval($arrayvalue[1]); // $newvalue=strval(36892.521); directly does not work because . will be convert into , later
386 386
         		    $this->worksheet->write($this->row, $this->col, $newvalue, PHPExcel_Shared_Date::PHPToExcel($formatdate));
387 387
         		}
388 388
         		else
389 389
         		{
390
-        		    $newvalue=dol_stringtotime($newvalue);
391
-        		    $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, PHPExcel_Shared_Date::PHPToExcel($newvalue));
392
-        		    $coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
390
+        		    $newvalue = dol_stringtotime($newvalue);
391
+        		    $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row + 1, PHPExcel_Shared_Date::PHPToExcel($newvalue));
392
+        		    $coord = $this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row + 1)->getCoordinate();
393 393
         		    $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd');
394 394
         		}
395 395
 			}
396
-			elseif (preg_match('/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]$/i',$newvalue))
396
+			elseif (preg_match('/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]$/i', $newvalue))
397 397
 			{
398
-				if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
398
+				if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
399 399
     		    {
400
-            		$formatdatehour=$this->workbook->addformat();
400
+            		$formatdatehour = $this->workbook->addformat();
401 401
             		$formatdatehour->set_num_format('yyyy-mm-dd hh:mm:ss');
402 402
             		//$formatdatehour->set_num_format(0x0f);
403
-            		$arrayvalue=preg_split('/[.,]/',xl_parse_date($newvalue));
403
+            		$arrayvalue = preg_split('/[.,]/', xl_parse_date($newvalue));
404 404
     				//print "x".$arrayvalue[0].'.'.strval($arrayvalue[1]).'<br>';
405
-    				$newvalue=strval($arrayvalue[0]).'.'.strval($arrayvalue[1]);	// $newvalue=strval(36892.521); directly does not work because . will be convert into , later
405
+    				$newvalue = strval($arrayvalue[0]).'.'.strval($arrayvalue[1]); // $newvalue=strval(36892.521); directly does not work because . will be convert into , later
406 406
     		        $this->worksheet->write($this->row, $this->col, $newvalue, $formatdatehour);
407 407
     		    }
408 408
     		    else
409 409
     		    {
410
-        		    $newvalue=dol_stringtotime($newvalue);
411
-    		        $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, PHPExcel_Shared_Date::PHPToExcel($newvalue));
412
-        		    $coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
410
+        		    $newvalue = dol_stringtotime($newvalue);
411
+    		        $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row + 1, PHPExcel_Shared_Date::PHPToExcel($newvalue));
412
+        		    $coord = $this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row + 1)->getCoordinate();
413 413
         		    $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd h:mm:ss');
414 414
     		    }
415 415
 			}
416 416
 			else
417 417
 			{
418
-				if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
418
+				if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
419 419
     		    {
420 420
 			        $this->worksheet->write($this->row, $this->col, $newvalue);
421 421
     		    }
@@ -424,14 +424,14 @@  discard block
 block discarded – undo
424 424
     		    	if ($typefield == 'Text' || $typefield == 'TextAuto')
425 425
     		    	{
426 426
     		    		//$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->setValueExplicit($newvalue, PHPExcel_Cell_DataType::TYPE_STRING);
427
-						$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, (string) $newvalue);
428
-    		    		$coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
427
+						$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row + 1, (string) $newvalue);
428
+    		    		$coord = $this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row + 1)->getCoordinate();
429 429
     		    		$this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('@');
430 430
     		    		$this->workbook->getActiveSheet()->getStyle($coord)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
431 431
     		    	}
432 432
     		    	else
433 433
     		    	{
434
-    		    		$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, $newvalue);
434
+    		    		$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row + 1, $newvalue);
435 435
     		    	}
436 436
     		    }
437 437
 			}
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
         // phpcs:enable
468 468
 		global $conf;
469 469
 
470
-		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
470
+		if (!empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
471 471
     	{
472 472
 	        $this->workbook->close();
473 473
     	}
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
     {
495 495
         // phpcs:enable
496 496
 		// Rule Dolibarr: No HTML
497
-    	$newvalue=dol_string_nohtmltag($newvalue);
497
+    	$newvalue = dol_string_nohtmltag($newvalue);
498 498
 
499 499
     	return $newvalue;
500 500
     }
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
     	{
517 517
     		$p = ($c - 1) % 26;
518 518
     		$c = intval(($c - $p) / 26);
519
-    		$letter = chr(65 + $p) . $letter;
519
+    		$letter = chr(65 + $p).$letter;
520 520
     	}
521 521
 
522 522
     	return $letter;
Please login to merge, or discard this patch.
Braces   +32 added lines, -31 removed lines patch added patch discarded remove patch
@@ -94,8 +94,7 @@  discard block
 block discarded – undo
94 94
                 require_once PHP_WRITEEXCEL_PATH.'functions.writeexcel_utility.inc.php';
95 95
     			$this->label_lib='PhpWriteExcel';
96 96
                 $this->version_lib='unknown';
97
-    		}
98
-    		else
97
+    		} else
99 98
     		{
100 99
                 require_once PHPEXCEL_PATH.'PHPExcel.php';
101 100
                 require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php';
@@ -211,17 +210,18 @@  discard block
 block discarded – undo
211 210
     		$this->workbook->set_tempdir($conf->export->dir_temp);			// Set temporary directory
212 211
     		$this->workbook->set_sheetname($outputlangs->trans("Sheet"));
213 212
     		$this->worksheet = &$this->workbook->addworksheet();
214
-		}
215
-		else
213
+		} else
216 214
 		{
217 215
             require_once PHPEXCEL_PATH.'PHPExcel.php';
218 216
             require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php';
219 217
 
220 218
 		    if ($this->id == 'excel2007')
221 219
 		    {
222
-	            if (! class_exists('ZipArchive'))	// For Excel2007, PHPExcel need ZipArchive
220
+	            if (! class_exists('ZipArchive')) {
221
+	                // For Excel2007, PHPExcel need ZipArchive
223 222
 	            {
224 223
 	            	$langs->load("errors");
224
+	            }
225 225
 	            	$this->error=$langs->trans('ErrorPHPNeedModule','zip');
226 226
 	            	return -1;
227 227
 	            }
@@ -291,8 +291,7 @@  discard block
 block discarded – undo
291 291
     		//$formatheader->set_size(12);
292 292
     		//$formatheader->set_font("Courier New");
293 293
     		//$formatheader->set_align('center');
294
-		}
295
-		else
294
+		} else
296 295
 		{
297 296
             $this->workbook->getActiveSheet()->getStyle('1')->getFont()->setBold(true);
298 297
 		    $this->workbook->getActiveSheet()->getStyle('1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
@@ -303,17 +302,20 @@  discard block
 block discarded – undo
303 302
 		{
304 303
             $alias=$array_export_fields_label[$code];
305 304
 			//print "dd".$alias;
306
-			if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
305
+			if (empty($alias)) {
306
+			    dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
307
+			}
307 308
     		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
308 309
     		{
309 310
     			$this->worksheet->write($this->row, $this->col, $outputlangs->transnoentities($alias), $formatheader);
310
-    		}
311
-    		else
311
+    		} else
312 312
     		{
313 313
                 $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, $outputlangs->transnoentities($alias));
314
-    		    if (! empty($array_types[$code]) && in_array($array_types[$code],array('Date','Numeric','TextAuto')))		// Set autowidth for some types
314
+    		    if (! empty($array_types[$code]) && in_array($array_types[$code],array('Date','Numeric','TextAuto'))) {
315
+    		        // Set autowidth for some types
315 316
                 {
316 317
                 	$this->workbook->getActiveSheet()->getColumnDimension($this->column2Letter($this->col + 1))->setAutoSize(true);
318
+    		    }
317 319
                 }
318 320
     		}
319 321
 			$this->col++;
@@ -348,9 +350,14 @@  discard block
 block discarded – undo
348 350
 
349 351
 		foreach($array_selected_sorted as $code => $value)
350 352
 		{
351
-			if (strpos($code,' as ') == 0) $alias=str_replace(array('.','-','(',')'),'_',$code);
352
-			else $alias=substr($code, strpos($code, ' as ') + 4);
353
-            if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
353
+			if (strpos($code,' as ') == 0) {
354
+			    $alias=str_replace(array('.','-','(',')'),'_',$code);
355
+			} else {
356
+			    $alias=substr($code, strpos($code, ' as ') + 4);
357
+			}
358
+            if (empty($alias)) {
359
+                dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
360
+            }
354 361
             $newvalue=$objp->$alias;
355 362
 
356 363
 			$newvalue=$this->excel_clean($newvalue);
@@ -367,8 +374,7 @@  discard block
 block discarded – undo
367 374
 			if (preg_match('/^\((.*)\)$/i',$newvalue,$reg))
368 375
 			{
369 376
 				$newvalue=$outputlangs->transnoentities($reg[1]);
370
-			}
371
-			else
377
+			} else
372 378
 			{
373 379
 				$newvalue=$outputlangs->convToOutputCharset($newvalue);
374 380
 			}
@@ -384,16 +390,14 @@  discard block
 block discarded – undo
384 390
     				//print "x".$arrayvalue[0].'.'.strval($arrayvalue[1]).'<br>';
385 391
     				$newvalue=strval($arrayvalue[0]).'.'.strval($arrayvalue[1]);	// $newvalue=strval(36892.521); directly does not work because . will be convert into , later
386 392
         		    $this->worksheet->write($this->row, $this->col, $newvalue, PHPExcel_Shared_Date::PHPToExcel($formatdate));
387
-        		}
388
-        		else
393
+        		} else
389 394
         		{
390 395
         		    $newvalue=dol_stringtotime($newvalue);
391 396
         		    $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, PHPExcel_Shared_Date::PHPToExcel($newvalue));
392 397
         		    $coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
393 398
         		    $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd');
394 399
         		}
395
-			}
396
-			elseif (preg_match('/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]$/i',$newvalue))
400
+			} elseif (preg_match('/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]$/i',$newvalue))
397 401
 			{
398 402
 				if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
399 403
     		    {
@@ -404,22 +408,19 @@  discard block
 block discarded – undo
404 408
     				//print "x".$arrayvalue[0].'.'.strval($arrayvalue[1]).'<br>';
405 409
     				$newvalue=strval($arrayvalue[0]).'.'.strval($arrayvalue[1]);	// $newvalue=strval(36892.521); directly does not work because . will be convert into , later
406 410
     		        $this->worksheet->write($this->row, $this->col, $newvalue, $formatdatehour);
407
-    		    }
408
-    		    else
411
+    		    } else
409 412
     		    {
410 413
         		    $newvalue=dol_stringtotime($newvalue);
411 414
     		        $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, PHPExcel_Shared_Date::PHPToExcel($newvalue));
412 415
         		    $coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
413 416
         		    $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd h:mm:ss');
414 417
     		    }
415
-			}
416
-			else
418
+			} else
417 419
 			{
418 420
 				if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
419 421
     		    {
420 422
 			        $this->worksheet->write($this->row, $this->col, $newvalue);
421
-    		    }
422
-    		    else
423
+    		    } else
423 424
 				{
424 425
     		    	if ($typefield == 'Text' || $typefield == 'TextAuto')
425 426
     		    	{
@@ -428,8 +429,7 @@  discard block
 block discarded – undo
428 429
     		    		$coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
429 430
     		    		$this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('@');
430 431
     		    		$this->workbook->getActiveSheet()->getStyle($coord)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
431
-    		    	}
432
-    		    	else
432
+    		    	} else
433 433
     		    	{
434 434
     		    		$this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, $newvalue);
435 435
     		    	}
@@ -470,8 +470,7 @@  discard block
 block discarded – undo
470 470
 		if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
471 471
     	{
472 472
 	        $this->workbook->close();
473
-    	}
474
-    	else
473
+    	} else
475 474
     	{
476 475
             require_once PHPEXCEL_PATH.'PHPExcel/Writer/Excel5.php';
477 476
     	    $objWriter = new PHPExcel_Writer_Excel5($this->workbook);
@@ -510,7 +509,9 @@  discard block
 block discarded – undo
510 509
     {
511 510
 
512 511
     	$c = intval($c);
513
-    	if ($c <= 0) return '';
512
+    	if ($c <= 0) {
513
+    	    return '';
514
+    	}
514 515
 
515 516
     	while ($c != 0)
516 517
     	{
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/export/export_csv.modules.php 3 patches
Indentation   +284 added lines, -284 removed lines patch added patch discarded remove patch
@@ -30,208 +30,208 @@  discard block
 block discarded – undo
30 30
  */
31 31
 class ExportCsv extends ModeleExports
32 32
 {
33
-	/**
34
-	 * @var int ID
35
-	 */
36
-	public $id;
33
+    /**
34
+     * @var int ID
35
+     */
36
+    public $id;
37 37
 
38
-	/**
38
+    /**
39 39
      * @var string export files label
40 40
      */
41 41
     public $label;
42 42
 
43
-	public $extension;
43
+    public $extension;
44 44
 
45
-	/**
45
+    /**
46 46
      * Dolibarr version of the loaded document
47 47
      * @public string
48 48
      */
49
-	public $version = 'dolibarr';
50
-
51
-	public $label_lib;
52
-
53
-	public $version_lib;
54
-
55
-	public $separator;
56
-
57
-	public $handle;    // Handle fichier
58
-
59
-
60
-	/**
61
-	 *	Constructor
62
-	 *
63
-	 *	@param	    DoliDB	$db      Database handler
64
-	 */
65
-	function __construct($db)
66
-	{
67
-		global $conf, $langs;
68
-		$this->db = $db;
69
-
70
-		$this->separator=',';
71
-		if (! empty($conf->global->EXPORT_CSV_SEPARATOR_TO_USE)) $this->separator=$conf->global->EXPORT_CSV_SEPARATOR_TO_USE;
72
-		$this->escape='"';
73
-		$this->enclosure='"';
74
-
75
-		$this->id='csv';                // Same value then xxx in file name export_xxx.modules.php
76
-		$this->label = 'CSV';             // Label of driver
77
-		$this->desc=$langs->trans("CSVFormatDesc",$this->separator,$this->enclosure,$this->escape);
78
-		$this->extension='csv';         // Extension for generated file by this driver
79
-		$this->picto='mime/other';		// Picto
80
-		$this->version='1.32';         // Driver version
81
-
82
-		// If driver use an external library, put its name here
83
-		$this->label_lib='Dolibarr';
84
-		$this->version_lib=DOL_VERSION;
85
-	}
86
-
87
-	/**
88
-	 * getDriverId
89
-	 *
90
-	 * @return string
91
-	 */
92
-	function getDriverId()
93
-	{
94
-		return $this->id;
95
-	}
96
-
97
-	/**
98
-	 * getDriverLabel
99
-	 *
100
-	 * @return 	string			Return driver label
101
-	 */
102
-	function getDriverLabel()
103
-	{
104
-		return $this->label;
105
-	}
106
-
107
-	/**
108
-	 * getDriverDesc
109
-	 *
110
-	 * @return string
111
-	 */
112
-	function getDriverDesc()
113
-	{
114
-		return $this->desc;
115
-	}
116
-
117
-	/**
118
-	 * getDriverExtension
119
-	 *
120
-	 * @return string
121
-	 */
122
-	function getDriverExtension()
123
-	{
124
-		return $this->extension;
125
-	}
126
-
127
-	/**
128
-	 * getDriverVersion
129
-	 *
130
-	 * @return string
131
-	 */
132
-	function getDriverVersion()
133
-	{
134
-		return $this->version;
135
-	}
136
-
137
-	/**
138
-	 * getLabelLabel
139
-	 *
140
-	 * @return string
141
-	 */
142
-	function getLibLabel()
143
-	{
144
-		return $this->label_lib;
145
-	}
146
-
147
-	/**
148
-	 * getLibVersion
149
-	 *
150
-	 * @return string
151
-	 */
152
-	function getLibVersion()
153
-	{
154
-		return $this->version_lib;
155
-	}
49
+    public $version = 'dolibarr';
50
+
51
+    public $label_lib;
52
+
53
+    public $version_lib;
54
+
55
+    public $separator;
56
+
57
+    public $handle;    // Handle fichier
58
+
59
+
60
+    /**
61
+     *	Constructor
62
+     *
63
+     *	@param	    DoliDB	$db      Database handler
64
+     */
65
+    function __construct($db)
66
+    {
67
+        global $conf, $langs;
68
+        $this->db = $db;
69
+
70
+        $this->separator=',';
71
+        if (! empty($conf->global->EXPORT_CSV_SEPARATOR_TO_USE)) $this->separator=$conf->global->EXPORT_CSV_SEPARATOR_TO_USE;
72
+        $this->escape='"';
73
+        $this->enclosure='"';
74
+
75
+        $this->id='csv';                // Same value then xxx in file name export_xxx.modules.php
76
+        $this->label = 'CSV';             // Label of driver
77
+        $this->desc=$langs->trans("CSVFormatDesc",$this->separator,$this->enclosure,$this->escape);
78
+        $this->extension='csv';         // Extension for generated file by this driver
79
+        $this->picto='mime/other';		// Picto
80
+        $this->version='1.32';         // Driver version
81
+
82
+        // If driver use an external library, put its name here
83
+        $this->label_lib='Dolibarr';
84
+        $this->version_lib=DOL_VERSION;
85
+    }
86
+
87
+    /**
88
+     * getDriverId
89
+     *
90
+     * @return string
91
+     */
92
+    function getDriverId()
93
+    {
94
+        return $this->id;
95
+    }
96
+
97
+    /**
98
+     * getDriverLabel
99
+     *
100
+     * @return 	string			Return driver label
101
+     */
102
+    function getDriverLabel()
103
+    {
104
+        return $this->label;
105
+    }
106
+
107
+    /**
108
+     * getDriverDesc
109
+     *
110
+     * @return string
111
+     */
112
+    function getDriverDesc()
113
+    {
114
+        return $this->desc;
115
+    }
116
+
117
+    /**
118
+     * getDriverExtension
119
+     *
120
+     * @return string
121
+     */
122
+    function getDriverExtension()
123
+    {
124
+        return $this->extension;
125
+    }
126
+
127
+    /**
128
+     * getDriverVersion
129
+     *
130
+     * @return string
131
+     */
132
+    function getDriverVersion()
133
+    {
134
+        return $this->version;
135
+    }
136
+
137
+    /**
138
+     * getLabelLabel
139
+     *
140
+     * @return string
141
+     */
142
+    function getLibLabel()
143
+    {
144
+        return $this->label_lib;
145
+    }
146
+
147
+    /**
148
+     * getLibVersion
149
+     *
150
+     * @return string
151
+     */
152
+    function getLibVersion()
153
+    {
154
+        return $this->version_lib;
155
+    }
156 156
 
157 157
 
158 158
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
159
-	/**
160
-	 *	Open output file
161
-	 *
162
-	 *	@param		string		$file			Path of filename to generate
163
-	 * 	@param		Translate	$outputlangs	Output language object
164
-	 *	@return		int							<0 if KO, >=0 if OK
165
-	 */
166
-	function open_file($file,$outputlangs)
167
-	{
159
+    /**
160
+     *	Open output file
161
+     *
162
+     *	@param		string		$file			Path of filename to generate
163
+     * 	@param		Translate	$outputlangs	Output language object
164
+     *	@return		int							<0 if KO, >=0 if OK
165
+     */
166
+    function open_file($file,$outputlangs)
167
+    {
168 168
         // phpcs:enable
169
-		global $langs;
169
+        global $langs;
170 170
 
171
-		dol_syslog("ExportCsv::open_file file=".$file);
171
+        dol_syslog("ExportCsv::open_file file=".$file);
172 172
 
173
-		$ret=1;
173
+        $ret=1;
174 174
 
175
-		$outputlangs->load("exports");
176
-		$this->handle = fopen($file, "wt");
177
-		if (! $this->handle)
178
-		{
179
-			$langs->load("errors");
180
-			$this->error=$langs->trans("ErrorFailToCreateFile",$file);
181
-			$ret=-1;
182
-		}
175
+        $outputlangs->load("exports");
176
+        $this->handle = fopen($file, "wt");
177
+        if (! $this->handle)
178
+        {
179
+            $langs->load("errors");
180
+            $this->error=$langs->trans("ErrorFailToCreateFile",$file);
181
+            $ret=-1;
182
+        }
183 183
 
184
-		return $ret;
185
-	}
184
+        return $ret;
185
+    }
186 186
 
187 187
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
188
-	/**
189
-	 * 	Output header into file
190
-	 *
191
-	 * 	@param		Translate	$outputlangs	Output language object
192
-	 * 	@return		int							<0 if KO, >0 if OK
193
-	 */
194
-	function write_header($outputlangs)
195
-	{
188
+    /**
189
+     * 	Output header into file
190
+     *
191
+     * 	@param		Translate	$outputlangs	Output language object
192
+     * 	@return		int							<0 if KO, >0 if OK
193
+     */
194
+    function write_header($outputlangs)
195
+    {
196 196
         // phpcs:enable
197
-		return 0;
198
-	}
197
+        return 0;
198
+    }
199 199
 
200 200
 
201 201
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
202
-	/**
203
-	 * 	Output title line into file
204
-	 *
202
+    /**
203
+     * 	Output title line into file
204
+     *
205 205
      *  @param      array		$array_export_fields_label   	Array with list of label of fields
206 206
      *  @param      array		$array_selected_sorted       	Array with list of field to export
207 207
      *  @param      Translate	$outputlangs    				Object lang to translate values
208 208
      *  @param		array		$array_types					Array with types of fields
209
-	 * 	@return		int											<0 if KO, >0 if OK
210
-	 */
211
-	function write_title($array_export_fields_label,$array_selected_sorted,$outputlangs,$array_types)
212
-	{
209
+     * 	@return		int											<0 if KO, >0 if OK
210
+     */
211
+    function write_title($array_export_fields_label,$array_selected_sorted,$outputlangs,$array_types)
212
+    {
213 213
         // phpcs:enable
214
-		global $conf;
214
+        global $conf;
215 215
 
216
-		if (! empty($conf->global->EXPORT_CSV_FORCE_CHARSET))
217
-		{
218
-			$outputlangs->charset_output = $conf->global->EXPORT_CSV_FORCE_CHARSET;
219
-		}
220
-		else
221
-		{
222
-			$outputlangs->charset_output = 'ISO-8859-1';
223
-		}
216
+        if (! empty($conf->global->EXPORT_CSV_FORCE_CHARSET))
217
+        {
218
+            $outputlangs->charset_output = $conf->global->EXPORT_CSV_FORCE_CHARSET;
219
+        }
220
+        else
221
+        {
222
+            $outputlangs->charset_output = 'ISO-8859-1';
223
+        }
224 224
 
225
-		foreach($array_selected_sorted as $code => $value)
226
-		{
227
-			$newvalue=$outputlangs->transnoentities($array_export_fields_label[$code]);		// newvalue is now $outputlangs->charset_output encoded
228
-			$newvalue=$this->csvClean($newvalue,$outputlangs->charset_output);
225
+        foreach($array_selected_sorted as $code => $value)
226
+        {
227
+            $newvalue=$outputlangs->transnoentities($array_export_fields_label[$code]);		// newvalue is now $outputlangs->charset_output encoded
228
+            $newvalue=$this->csvClean($newvalue,$outputlangs->charset_output);
229 229
 
230
-			fwrite($this->handle,$newvalue.$this->separator);
231
-		}
232
-		fwrite($this->handle,"\n");
233
-		return 0;
234
-	}
230
+            fwrite($this->handle,$newvalue.$this->separator);
231
+        }
232
+        fwrite($this->handle,"\n");
233
+        return 0;
234
+    }
235 235
 
236 236
 
237 237
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
@@ -242,124 +242,124 @@  discard block
 block discarded – undo
242 242
      *  @param     	resource	$objp                       A record from a fetch with all fields from select
243 243
      *  @param     	Translate	$outputlangs    			Object lang to translate values
244 244
      *  @param		array		$array_types				Array with types of fields
245
-	 * 	@return		int										<0 if KO, >0 if OK
246
-	 */
247
-	function write_record($array_selected_sorted,$objp,$outputlangs,$array_types)
248
-	{
245
+     * 	@return		int										<0 if KO, >0 if OK
246
+     */
247
+    function write_record($array_selected_sorted,$objp,$outputlangs,$array_types)
248
+    {
249 249
         // phpcs:enable
250
-		global $conf;
251
-
252
-		if (! empty($conf->global->EXPORT_CSV_FORCE_CHARSET))
253
-		{
254
-			$outputlangs->charset_output = $conf->global->EXPORT_CSV_FORCE_CHARSET;
255
-		}
256
-		else
257
-		{
258
-			$outputlangs->charset_output = 'ISO-8859-1';
259
-		}
260
-
261
-		$this->col=0;
262
-		foreach($array_selected_sorted as $code => $value)
263
-		{
264
-			if (strpos($code,' as ') == 0) $alias=str_replace(array('.','-','(',')'),'_',$code);
265
-			else $alias=substr($code, strpos($code, ' as ') + 4);
266
-			if (empty($alias)) dol_print_error('','Bad value for field with key='.$code.'. Try to redefine export.');
267
-
268
-			$newvalue=$outputlangs->convToOutputCharset($objp->$alias);		// objp->$alias must be utf8 encoded as any var in memory	// newvalue is now $outputlangs->charset_output encoded
269
-			$typefield=isset($array_types[$code])?$array_types[$code]:'';
270
-
271
-			// Translation newvalue
272
-			if (preg_match('/^\((.*)\)$/i',$newvalue,$reg)) $newvalue=$outputlangs->transnoentities($reg[1]);
273
-
274
-			$newvalue=$this->csvClean($newvalue,$outputlangs->charset_output);
275
-
276
-			if (preg_match('/^Select:/i', $typefield, $reg) && $typefield = substr($typefield, 7))
277
-			{
278
-				$array = unserialize($typefield);
279
-				$array = $array['options'];
280
-				$newvalue = $array[$newvalue];
281
-			}
282
-
283
-			fwrite($this->handle,$newvalue.$this->separator);
284
-			$this->col++;
285
-		}
286
-
287
-		fwrite($this->handle,"\n");
288
-		return 0;
289
-	}
250
+        global $conf;
251
+
252
+        if (! empty($conf->global->EXPORT_CSV_FORCE_CHARSET))
253
+        {
254
+            $outputlangs->charset_output = $conf->global->EXPORT_CSV_FORCE_CHARSET;
255
+        }
256
+        else
257
+        {
258
+            $outputlangs->charset_output = 'ISO-8859-1';
259
+        }
260
+
261
+        $this->col=0;
262
+        foreach($array_selected_sorted as $code => $value)
263
+        {
264
+            if (strpos($code,' as ') == 0) $alias=str_replace(array('.','-','(',')'),'_',$code);
265
+            else $alias=substr($code, strpos($code, ' as ') + 4);
266
+            if (empty($alias)) dol_print_error('','Bad value for field with key='.$code.'. Try to redefine export.');
267
+
268
+            $newvalue=$outputlangs->convToOutputCharset($objp->$alias);		// objp->$alias must be utf8 encoded as any var in memory	// newvalue is now $outputlangs->charset_output encoded
269
+            $typefield=isset($array_types[$code])?$array_types[$code]:'';
270
+
271
+            // Translation newvalue
272
+            if (preg_match('/^\((.*)\)$/i',$newvalue,$reg)) $newvalue=$outputlangs->transnoentities($reg[1]);
273
+
274
+            $newvalue=$this->csvClean($newvalue,$outputlangs->charset_output);
275
+
276
+            if (preg_match('/^Select:/i', $typefield, $reg) && $typefield = substr($typefield, 7))
277
+            {
278
+                $array = unserialize($typefield);
279
+                $array = $array['options'];
280
+                $newvalue = $array[$newvalue];
281
+            }
282
+
283
+            fwrite($this->handle,$newvalue.$this->separator);
284
+            $this->col++;
285
+        }
286
+
287
+        fwrite($this->handle,"\n");
288
+        return 0;
289
+    }
290 290
 
291 291
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
292
-	/**
293
-	 * 	Output footer into file
294
-	 *
295
-	 * 	@param		Translate	$outputlangs	Output language object
296
-	 * 	@return		int							<0 if KO, >0 if OK
297
-	 */
298
-	function write_footer($outputlangs)
299
-	{
292
+    /**
293
+     * 	Output footer into file
294
+     *
295
+     * 	@param		Translate	$outputlangs	Output language object
296
+     * 	@return		int							<0 if KO, >0 if OK
297
+     */
298
+    function write_footer($outputlangs)
299
+    {
300 300
         // phpcs:enable
301
-		return 0;
302
-	}
301
+        return 0;
302
+    }
303 303
 
304 304
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
305
-	/**
306
-	 * 	Close file handle
307
-	 *
308
-	 * 	@return		int							<0 if KO, >0 if OK
309
-	 */
310
-	function close_file()
311
-	{
305
+    /**
306
+     * 	Close file handle
307
+     *
308
+     * 	@return		int							<0 if KO, >0 if OK
309
+     */
310
+    function close_file()
311
+    {
312 312
         // phpcs:enable
313
-		fclose($this->handle);
314
-		return 0;
315
-	}
316
-
317
-
318
-	/**
319
-	 * Clean a cell to respect rules of CSV file cells
320
-	 * Note: It uses $this->separator
321
-	 * Note: We keep this function public to be able to test
322
-	 *
323
-	 * @param 	string	$newvalue	String to clean
324
-	 * @param	string	$charset	Input AND Output character set
325
-	 * @return 	string				Value cleaned
326
-	 */
327
-	public function csvClean($newvalue, $charset)
328
-	{
329
-		global $conf;
330
-		$addquote=0;
331
-
332
-
333
-		// Rule Dolibarr: No HTML
334
-   		//print $charset.' '.$newvalue."\n";
335
-   		//$newvalue=dol_string_nohtmltag($newvalue,0,$charset);
336
-   		$newvalue=dol_htmlcleanlastbr($newvalue);
337
-   		//print $charset.' '.$newvalue."\n";
338
-
339
-		// Rule 1 CSV: No CR, LF in cells (except if USE_STRICT_CSV_RULES is on, we can keep record as it is but we must add quotes)
340
-		$oldvalue=$newvalue;
341
-		$newvalue=str_replace("\r",'',$newvalue);
342
-		$newvalue=str_replace("\n",'\n',$newvalue);
343
-		if (! empty($conf->global->USE_STRICT_CSV_RULES) && $oldvalue != $newvalue)
344
-		{
345
-			// If strict use of CSV rules, we just add quote
346
-			$newvalue=$oldvalue;
347
-			$addquote=1;
348
-		}
349
-
350
-		// Rule 2 CSV: If value contains ", we must escape with ", and add "
351
-		if (preg_match('/"/',$newvalue))
352
-		{
353
-			$addquote=1;
354
-			$newvalue=str_replace('"','""',$newvalue);
355
-		}
356
-
357
-		// Rule 3 CSV: If value contains separator, we must add "
358
-		if (preg_match('/'.$this->separator.'/',$newvalue))
359
-		{
360
-			$addquote=1;
361
-		}
362
-
363
-		return ($addquote?'"':'').$newvalue.($addquote?'"':'');
364
-	}
313
+        fclose($this->handle);
314
+        return 0;
315
+    }
316
+
317
+
318
+    /**
319
+     * Clean a cell to respect rules of CSV file cells
320
+     * Note: It uses $this->separator
321
+     * Note: We keep this function public to be able to test
322
+     *
323
+     * @param 	string	$newvalue	String to clean
324
+     * @param	string	$charset	Input AND Output character set
325
+     * @return 	string				Value cleaned
326
+     */
327
+    public function csvClean($newvalue, $charset)
328
+    {
329
+        global $conf;
330
+        $addquote=0;
331
+
332
+
333
+        // Rule Dolibarr: No HTML
334
+            //print $charset.' '.$newvalue."\n";
335
+            //$newvalue=dol_string_nohtmltag($newvalue,0,$charset);
336
+            $newvalue=dol_htmlcleanlastbr($newvalue);
337
+            //print $charset.' '.$newvalue."\n";
338
+
339
+        // Rule 1 CSV: No CR, LF in cells (except if USE_STRICT_CSV_RULES is on, we can keep record as it is but we must add quotes)
340
+        $oldvalue=$newvalue;
341
+        $newvalue=str_replace("\r",'',$newvalue);
342
+        $newvalue=str_replace("\n",'\n',$newvalue);
343
+        if (! empty($conf->global->USE_STRICT_CSV_RULES) && $oldvalue != $newvalue)
344
+        {
345
+            // If strict use of CSV rules, we just add quote
346
+            $newvalue=$oldvalue;
347
+            $addquote=1;
348
+        }
349
+
350
+        // Rule 2 CSV: If value contains ", we must escape with ", and add "
351
+        if (preg_match('/"/',$newvalue))
352
+        {
353
+            $addquote=1;
354
+            $newvalue=str_replace('"','""',$newvalue);
355
+        }
356
+
357
+        // Rule 3 CSV: If value contains separator, we must add "
358
+        if (preg_match('/'.$this->separator.'/',$newvalue))
359
+        {
360
+            $addquote=1;
361
+        }
362
+
363
+        return ($addquote?'"':'').$newvalue.($addquote?'"':'');
364
+    }
365 365
 }
Please login to merge, or discard this patch.
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
  *		\author	    Laurent Destailleur
23 23
  */
24 24
 
25
-require_once DOL_DOCUMENT_ROOT .'/core/modules/export/modules_export.php';
25
+require_once DOL_DOCUMENT_ROOT.'/core/modules/export/modules_export.php';
26 26
 
27 27
 
28 28
 /**
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 
55 55
 	public $separator;
56 56
 
57
-	public $handle;    // Handle fichier
57
+	public $handle; // Handle fichier
58 58
 
59 59
 
60 60
 	/**
@@ -67,21 +67,21 @@  discard block
 block discarded – undo
67 67
 		global $conf, $langs;
68 68
 		$this->db = $db;
69 69
 
70
-		$this->separator=',';
71
-		if (! empty($conf->global->EXPORT_CSV_SEPARATOR_TO_USE)) $this->separator=$conf->global->EXPORT_CSV_SEPARATOR_TO_USE;
72
-		$this->escape='"';
73
-		$this->enclosure='"';
70
+		$this->separator = ',';
71
+		if (!empty($conf->global->EXPORT_CSV_SEPARATOR_TO_USE)) $this->separator = $conf->global->EXPORT_CSV_SEPARATOR_TO_USE;
72
+		$this->escape = '"';
73
+		$this->enclosure = '"';
74 74
 
75
-		$this->id='csv';                // Same value then xxx in file name export_xxx.modules.php
76
-		$this->label = 'CSV';             // Label of driver
77
-		$this->desc=$langs->trans("CSVFormatDesc",$this->separator,$this->enclosure,$this->escape);
78
-		$this->extension='csv';         // Extension for generated file by this driver
79
-		$this->picto='mime/other';		// Picto
80
-		$this->version='1.32';         // Driver version
75
+		$this->id = 'csv'; // Same value then xxx in file name export_xxx.modules.php
76
+		$this->label = 'CSV'; // Label of driver
77
+		$this->desc = $langs->trans("CSVFormatDesc", $this->separator, $this->enclosure, $this->escape);
78
+		$this->extension = 'csv'; // Extension for generated file by this driver
79
+		$this->picto = 'mime/other'; // Picto
80
+		$this->version = '1.32'; // Driver version
81 81
 
82 82
 		// If driver use an external library, put its name here
83
-		$this->label_lib='Dolibarr';
84
-		$this->version_lib=DOL_VERSION;
83
+		$this->label_lib = 'Dolibarr';
84
+		$this->version_lib = DOL_VERSION;
85 85
 	}
86 86
 
87 87
 	/**
@@ -163,22 +163,22 @@  discard block
 block discarded – undo
163 163
 	 * 	@param		Translate	$outputlangs	Output language object
164 164
 	 *	@return		int							<0 if KO, >=0 if OK
165 165
 	 */
166
-	function open_file($file,$outputlangs)
166
+	function open_file($file, $outputlangs)
167 167
 	{
168 168
         // phpcs:enable
169 169
 		global $langs;
170 170
 
171 171
 		dol_syslog("ExportCsv::open_file file=".$file);
172 172
 
173
-		$ret=1;
173
+		$ret = 1;
174 174
 
175 175
 		$outputlangs->load("exports");
176 176
 		$this->handle = fopen($file, "wt");
177
-		if (! $this->handle)
177
+		if (!$this->handle)
178 178
 		{
179 179
 			$langs->load("errors");
180
-			$this->error=$langs->trans("ErrorFailToCreateFile",$file);
181
-			$ret=-1;
180
+			$this->error = $langs->trans("ErrorFailToCreateFile", $file);
181
+			$ret = -1;
182 182
 		}
183 183
 
184 184
 		return $ret;
@@ -208,12 +208,12 @@  discard block
 block discarded – undo
208 208
      *  @param		array		$array_types					Array with types of fields
209 209
 	 * 	@return		int											<0 if KO, >0 if OK
210 210
 	 */
211
-	function write_title($array_export_fields_label,$array_selected_sorted,$outputlangs,$array_types)
211
+	function write_title($array_export_fields_label, $array_selected_sorted, $outputlangs, $array_types)
212 212
 	{
213 213
         // phpcs:enable
214 214
 		global $conf;
215 215
 
216
-		if (! empty($conf->global->EXPORT_CSV_FORCE_CHARSET))
216
+		if (!empty($conf->global->EXPORT_CSV_FORCE_CHARSET))
217 217
 		{
218 218
 			$outputlangs->charset_output = $conf->global->EXPORT_CSV_FORCE_CHARSET;
219 219
 		}
@@ -222,14 +222,14 @@  discard block
 block discarded – undo
222 222
 			$outputlangs->charset_output = 'ISO-8859-1';
223 223
 		}
224 224
 
225
-		foreach($array_selected_sorted as $code => $value)
225
+		foreach ($array_selected_sorted as $code => $value)
226 226
 		{
227
-			$newvalue=$outputlangs->transnoentities($array_export_fields_label[$code]);		// newvalue is now $outputlangs->charset_output encoded
228
-			$newvalue=$this->csvClean($newvalue,$outputlangs->charset_output);
227
+			$newvalue = $outputlangs->transnoentities($array_export_fields_label[$code]); // newvalue is now $outputlangs->charset_output encoded
228
+			$newvalue = $this->csvClean($newvalue, $outputlangs->charset_output);
229 229
 
230
-			fwrite($this->handle,$newvalue.$this->separator);
230
+			fwrite($this->handle, $newvalue.$this->separator);
231 231
 		}
232
-		fwrite($this->handle,"\n");
232
+		fwrite($this->handle, "\n");
233 233
 		return 0;
234 234
 	}
235 235
 
@@ -244,12 +244,12 @@  discard block
 block discarded – undo
244 244
      *  @param		array		$array_types				Array with types of fields
245 245
 	 * 	@return		int										<0 if KO, >0 if OK
246 246
 	 */
247
-	function write_record($array_selected_sorted,$objp,$outputlangs,$array_types)
247
+	function write_record($array_selected_sorted, $objp, $outputlangs, $array_types)
248 248
 	{
249 249
         // phpcs:enable
250 250
 		global $conf;
251 251
 
252
-		if (! empty($conf->global->EXPORT_CSV_FORCE_CHARSET))
252
+		if (!empty($conf->global->EXPORT_CSV_FORCE_CHARSET))
253 253
 		{
254 254
 			$outputlangs->charset_output = $conf->global->EXPORT_CSV_FORCE_CHARSET;
255 255
 		}
@@ -258,20 +258,20 @@  discard block
 block discarded – undo
258 258
 			$outputlangs->charset_output = 'ISO-8859-1';
259 259
 		}
260 260
 
261
-		$this->col=0;
262
-		foreach($array_selected_sorted as $code => $value)
261
+		$this->col = 0;
262
+		foreach ($array_selected_sorted as $code => $value)
263 263
 		{
264
-			if (strpos($code,' as ') == 0) $alias=str_replace(array('.','-','(',')'),'_',$code);
265
-			else $alias=substr($code, strpos($code, ' as ') + 4);
266
-			if (empty($alias)) dol_print_error('','Bad value for field with key='.$code.'. Try to redefine export.');
264
+			if (strpos($code, ' as ') == 0) $alias = str_replace(array('.', '-', '(', ')'), '_', $code);
265
+			else $alias = substr($code, strpos($code, ' as ') + 4);
266
+			if (empty($alias)) dol_print_error('', 'Bad value for field with key='.$code.'. Try to redefine export.');
267 267
 
268
-			$newvalue=$outputlangs->convToOutputCharset($objp->$alias);		// objp->$alias must be utf8 encoded as any var in memory	// newvalue is now $outputlangs->charset_output encoded
269
-			$typefield=isset($array_types[$code])?$array_types[$code]:'';
268
+			$newvalue = $outputlangs->convToOutputCharset($objp->$alias); // objp->$alias must be utf8 encoded as any var in memory	// newvalue is now $outputlangs->charset_output encoded
269
+			$typefield = isset($array_types[$code]) ? $array_types[$code] : '';
270 270
 
271 271
 			// Translation newvalue
272
-			if (preg_match('/^\((.*)\)$/i',$newvalue,$reg)) $newvalue=$outputlangs->transnoentities($reg[1]);
272
+			if (preg_match('/^\((.*)\)$/i', $newvalue, $reg)) $newvalue = $outputlangs->transnoentities($reg[1]);
273 273
 
274
-			$newvalue=$this->csvClean($newvalue,$outputlangs->charset_output);
274
+			$newvalue = $this->csvClean($newvalue, $outputlangs->charset_output);
275 275
 
276 276
 			if (preg_match('/^Select:/i', $typefield, $reg) && $typefield = substr($typefield, 7))
277 277
 			{
@@ -280,11 +280,11 @@  discard block
 block discarded – undo
280 280
 				$newvalue = $array[$newvalue];
281 281
 			}
282 282
 
283
-			fwrite($this->handle,$newvalue.$this->separator);
283
+			fwrite($this->handle, $newvalue.$this->separator);
284 284
 			$this->col++;
285 285
 		}
286 286
 
287
-		fwrite($this->handle,"\n");
287
+		fwrite($this->handle, "\n");
288 288
 		return 0;
289 289
 	}
290 290
 
@@ -327,39 +327,39 @@  discard block
 block discarded – undo
327 327
 	public function csvClean($newvalue, $charset)
328 328
 	{
329 329
 		global $conf;
330
-		$addquote=0;
330
+		$addquote = 0;
331 331
 
332 332
 
333 333
 		// Rule Dolibarr: No HTML
334 334
    		//print $charset.' '.$newvalue."\n";
335 335
    		//$newvalue=dol_string_nohtmltag($newvalue,0,$charset);
336
-   		$newvalue=dol_htmlcleanlastbr($newvalue);
336
+   		$newvalue = dol_htmlcleanlastbr($newvalue);
337 337
    		//print $charset.' '.$newvalue."\n";
338 338
 
339 339
 		// Rule 1 CSV: No CR, LF in cells (except if USE_STRICT_CSV_RULES is on, we can keep record as it is but we must add quotes)
340
-		$oldvalue=$newvalue;
341
-		$newvalue=str_replace("\r",'',$newvalue);
342
-		$newvalue=str_replace("\n",'\n',$newvalue);
343
-		if (! empty($conf->global->USE_STRICT_CSV_RULES) && $oldvalue != $newvalue)
340
+		$oldvalue = $newvalue;
341
+		$newvalue = str_replace("\r", '', $newvalue);
342
+		$newvalue = str_replace("\n", '\n', $newvalue);
343
+		if (!empty($conf->global->USE_STRICT_CSV_RULES) && $oldvalue != $newvalue)
344 344
 		{
345 345
 			// If strict use of CSV rules, we just add quote
346
-			$newvalue=$oldvalue;
347
-			$addquote=1;
346
+			$newvalue = $oldvalue;
347
+			$addquote = 1;
348 348
 		}
349 349
 
350 350
 		// Rule 2 CSV: If value contains ", we must escape with ", and add "
351
-		if (preg_match('/"/',$newvalue))
351
+		if (preg_match('/"/', $newvalue))
352 352
 		{
353
-			$addquote=1;
354
-			$newvalue=str_replace('"','""',$newvalue);
353
+			$addquote = 1;
354
+			$newvalue = str_replace('"', '""', $newvalue);
355 355
 		}
356 356
 
357 357
 		// Rule 3 CSV: If value contains separator, we must add "
358
-		if (preg_match('/'.$this->separator.'/',$newvalue))
358
+		if (preg_match('/'.$this->separator.'/', $newvalue))
359 359
 		{
360
-			$addquote=1;
360
+			$addquote = 1;
361 361
 		}
362 362
 
363
-		return ($addquote?'"':'').$newvalue.($addquote?'"':'');
363
+		return ($addquote ? '"' : '').$newvalue.($addquote ? '"' : '');
364 364
 	}
365 365
 }
Please login to merge, or discard this patch.
Braces   +16 added lines, -9 removed lines patch added patch discarded remove patch
@@ -68,7 +68,9 @@  discard block
 block discarded – undo
68 68
 		$this->db = $db;
69 69
 
70 70
 		$this->separator=',';
71
-		if (! empty($conf->global->EXPORT_CSV_SEPARATOR_TO_USE)) $this->separator=$conf->global->EXPORT_CSV_SEPARATOR_TO_USE;
71
+		if (! empty($conf->global->EXPORT_CSV_SEPARATOR_TO_USE)) {
72
+		    $this->separator=$conf->global->EXPORT_CSV_SEPARATOR_TO_USE;
73
+		}
72 74
 		$this->escape='"';
73 75
 		$this->enclosure='"';
74 76
 
@@ -216,8 +218,7 @@  discard block
 block discarded – undo
216 218
 		if (! empty($conf->global->EXPORT_CSV_FORCE_CHARSET))
217 219
 		{
218 220
 			$outputlangs->charset_output = $conf->global->EXPORT_CSV_FORCE_CHARSET;
219
-		}
220
-		else
221
+		} else
221 222
 		{
222 223
 			$outputlangs->charset_output = 'ISO-8859-1';
223 224
 		}
@@ -252,8 +253,7 @@  discard block
 block discarded – undo
252 253
 		if (! empty($conf->global->EXPORT_CSV_FORCE_CHARSET))
253 254
 		{
254 255
 			$outputlangs->charset_output = $conf->global->EXPORT_CSV_FORCE_CHARSET;
255
-		}
256
-		else
256
+		} else
257 257
 		{
258 258
 			$outputlangs->charset_output = 'ISO-8859-1';
259 259
 		}
@@ -261,15 +261,22 @@  discard block
 block discarded – undo
261 261
 		$this->col=0;
262 262
 		foreach($array_selected_sorted as $code => $value)
263 263
 		{
264
-			if (strpos($code,' as ') == 0) $alias=str_replace(array('.','-','(',')'),'_',$code);
265
-			else $alias=substr($code, strpos($code, ' as ') + 4);
266
-			if (empty($alias)) dol_print_error('','Bad value for field with key='.$code.'. Try to redefine export.');
264
+			if (strpos($code,' as ') == 0) {
265
+			    $alias=str_replace(array('.','-','(',')'),'_',$code);
266
+			} else {
267
+			    $alias=substr($code, strpos($code, ' as ') + 4);
268
+			}
269
+			if (empty($alias)) {
270
+			    dol_print_error('','Bad value for field with key='.$code.'. Try to redefine export.');
271
+			}
267 272
 
268 273
 			$newvalue=$outputlangs->convToOutputCharset($objp->$alias);		// objp->$alias must be utf8 encoded as any var in memory	// newvalue is now $outputlangs->charset_output encoded
269 274
 			$typefield=isset($array_types[$code])?$array_types[$code]:'';
270 275
 
271 276
 			// Translation newvalue
272
-			if (preg_match('/^\((.*)\)$/i',$newvalue,$reg)) $newvalue=$outputlangs->transnoentities($reg[1]);
277
+			if (preg_match('/^\((.*)\)$/i',$newvalue,$reg)) {
278
+			    $newvalue=$outputlangs->transnoentities($reg[1]);
279
+			}
273 280
 
274 281
 			$newvalue=$this->csvClean($newvalue,$outputlangs->charset_output);
275 282
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/export/export_tsv.modules.php 3 patches
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -32,9 +32,9 @@  discard block
 block discarded – undo
32 32
 class ExportTsv extends ModeleExports
33 33
 {
34 34
     /**
35
-	 * @var int ID
36
-	 */
37
-	public $id;
35
+     * @var int ID
36
+     */
37
+    public $id;
38 38
 
39 39
     /**
40 40
      * @var string label
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
      * Dolibarr version of the loaded document
48 48
      * @public string
49 49
      */
50
-	public $version = 'dolibarr';
50
+    public $version = 'dolibarr';
51 51
 
52 52
     public $label_lib;
53 53
 
@@ -59,9 +59,9 @@  discard block
 block discarded – undo
59 59
 
60 60
 
61 61
     /**
62
-	 *	Constructor
63
-	 *
64
-	 *	@param	    DoliDB	$db      Database handler
62
+     *	Constructor
63
+     *
64
+     *	@param	    DoliDB	$db      Database handler
65 65
      */
66 66
     function __construct($db)
67 67
     {
@@ -80,71 +80,71 @@  discard block
 block discarded – undo
80 80
         $this->version_lib=DOL_VERSION;
81 81
     }
82 82
 
83
-	/**
84
-	 * getDriverId
85
-	 *
86
-	 * @return string
87
-	 */
83
+    /**
84
+     * getDriverId
85
+     *
86
+     * @return string
87
+     */
88 88
     function getDriverId()
89 89
     {
90 90
         return $this->id;
91 91
     }
92 92
 
93
-	/**
94
-	 * getDriverLabel
95
-	 *
96
-	 * @return 	string			Return driver label
97
-	 */
93
+    /**
94
+     * getDriverLabel
95
+     *
96
+     * @return 	string			Return driver label
97
+     */
98 98
     function getDriverLabel()
99 99
     {
100 100
         return $this->label;
101 101
     }
102 102
 
103
-	/**
104
-	 * getDriverDesc
105
-	 *
106
-	 * @return string
107
-	 */
103
+    /**
104
+     * getDriverDesc
105
+     *
106
+     * @return string
107
+     */
108 108
     function getDriverDesc()
109 109
     {
110 110
         return $this->desc;
111 111
     }
112 112
 
113
-	/**
114
-	 * getDriverExtension
115
-	 *
116
-	 * @return string
117
-	 */
113
+    /**
114
+     * getDriverExtension
115
+     *
116
+     * @return string
117
+     */
118 118
     function getDriverExtension()
119 119
     {
120 120
         return $this->extension;
121 121
     }
122 122
 
123
-	/**
124
-	 * getDriverVersion
125
-	 *
126
-	 * @return string
127
-	 */
123
+    /**
124
+     * getDriverVersion
125
+     *
126
+     * @return string
127
+     */
128 128
     function getDriverVersion()
129 129
     {
130 130
         return $this->version;
131 131
     }
132 132
 
133
-	/**
134
-	 * getLibLabel
135
-	 *
136
-	 * @return string
137
-	 */
133
+    /**
134
+     * getLibLabel
135
+     *
136
+     * @return string
137
+     */
138 138
     function getLibLabel()
139 139
     {
140 140
         return $this->label_lib;
141 141
     }
142 142
 
143
-	/**
144
-	 * getLibVersion
145
-	 *
146
-	 * @return string
147
-	 */
143
+    /**
144
+     * getLibVersion
145
+     *
146
+     * @return string
147
+     */
148 148
     function getLibVersion()
149 149
     {
150 150
         return $this->version_lib;
@@ -153,12 +153,12 @@  discard block
 block discarded – undo
153 153
 
154 154
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
155 155
     /**
156
-	*	Open output file
157
-	*
158
-	 *	@param		string		$file			Path of filename to generate
159
-	*	@param		Translate	$outputlangs	Output language object
160
-	*	@return		int							<0 if KO, >=0 if OK
161
-    */
156
+     *	Open output file
157
+     *
158
+     *	@param		string		$file			Path of filename to generate
159
+     *	@param		Translate	$outputlangs	Output language object
160
+     *	@return		int							<0 if KO, >=0 if OK
161
+     */
162 162
     function open_file($file,$outputlangs)
163 163
     {
164 164
         // phpcs:enable
@@ -169,24 +169,24 @@  discard block
 block discarded – undo
169 169
         $ret=1;
170 170
 
171 171
         $outputlangs->load("exports");
172
-		$this->handle = fopen($file, "wt");
172
+        $this->handle = fopen($file, "wt");
173 173
         if (! $this->handle)
174
-		{
175
-			$langs->load("errors");
176
-			$this->error=$langs->trans("ErrorFailToCreateFile",$file);
177
-			$ret=-1;
178
-		}
174
+        {
175
+            $langs->load("errors");
176
+            $this->error=$langs->trans("ErrorFailToCreateFile",$file);
177
+            $ret=-1;
178
+        }
179 179
 
180
-		return $ret;
180
+        return $ret;
181 181
     }
182 182
 
183 183
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
184
-	/**
185
-	 * 	Output header into file
186
-	 *
187
-	 * 	@param		Translate	$outputlangs		Output language object
188
-	 * 	@return		int								<0 if KO, >0 if OK
189
-	 */
184
+    /**
185
+     * 	Output header into file
186
+     *
187
+     * 	@param		Translate	$outputlangs		Output language object
188
+     * 	@return		int								<0 if KO, >0 if OK
189
+     */
190 190
     function write_header($outputlangs)
191 191
     {
192 192
         // phpcs:enable
@@ -202,17 +202,17 @@  discard block
 block discarded – undo
202 202
      *  @param      array		$array_selected_sorted       	Array with list of field to export
203 203
      *  @param      Translate	$outputlangs    				Object lang to translate values
204 204
      *  @param		array		$array_types					Array with types of fields
205
-	 * 	@return		int											<0 if KO, >0 if OK
206
-	 */
205
+     * 	@return		int											<0 if KO, >0 if OK
206
+     */
207 207
     function write_title($array_export_fields_label,$array_selected_sorted,$outputlangs,$array_types)
208 208
     {
209 209
         // phpcs:enable
210 210
         foreach($array_selected_sorted as $code => $value)
211 211
         {
212 212
             $newvalue=$outputlangs->transnoentities($array_export_fields_label[$code]);		// newvalue is now $outputlangs->charset_output encoded
213
-			$newvalue=$this->tsv_clean($newvalue,$outputlangs->charset_output);
213
+            $newvalue=$this->tsv_clean($newvalue,$outputlangs->charset_output);
214 214
 
215
-			fwrite($this->handle,$newvalue.$this->separator);
215
+            fwrite($this->handle,$newvalue.$this->separator);
216 216
         }
217 217
         fwrite($this->handle,"\n");
218 218
         return 0;
@@ -220,68 +220,68 @@  discard block
 block discarded – undo
220 220
 
221 221
 
222 222
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
223
-	/**
224
-	 * 	Output record line into file
225
-	 *
226
-	 *  @param      array		$array_selected_sorted      Array with list of field to export
227
-	 *  @param      resource	$objp                       A record from a fetch with all fields from select
228
-	 *  @param      Translate	$outputlangs                Object lang to translate values
223
+    /**
224
+     * 	Output record line into file
225
+     *
226
+     *  @param      array		$array_selected_sorted      Array with list of field to export
227
+     *  @param      resource	$objp                       A record from a fetch with all fields from select
228
+     *  @param      Translate	$outputlangs                Object lang to translate values
229 229
      *  @param		array		$array_types				Array with types of fields
230
-	 * 	@return		int										<0 if KO, >0 if OK
231
-	 */
230
+     * 	@return		int										<0 if KO, >0 if OK
231
+     */
232 232
     function write_record($array_selected_sorted,$objp,$outputlangs,$array_types)
233 233
     {
234 234
         // phpcs:enable
235
-    	global $conf;
235
+        global $conf;
236 236
 
237
-		$this->col=0;
238
- 		foreach($array_selected_sorted as $code => $value)
237
+        $this->col=0;
238
+            foreach($array_selected_sorted as $code => $value)
239 239
         {
240
-			if (strpos($code,' as ') == 0) $alias=str_replace(array('.','-','(',')'),'_',$code);
241
-			else $alias=substr($code, strpos($code, ' as ') + 4);
240
+            if (strpos($code,' as ') == 0) $alias=str_replace(array('.','-','(',')'),'_',$code);
241
+            else $alias=substr($code, strpos($code, ' as ') + 4);
242 242
             if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
243 243
 
244 244
             $newvalue=$outputlangs->convToOutputCharset($objp->$alias);		// objp->$alias must be utf8 encoded as any var in memory // newvalue is now $outputlangs->charset_output encoded
245 245
             $typefield=isset($array_types[$code])?$array_types[$code]:'';
246 246
 
247 247
             // Translation newvalue
248
-			if (preg_match('/^\((.*)\)$/i',$newvalue,$reg)) $newvalue=$outputlangs->transnoentities($reg[1]);
248
+            if (preg_match('/^\((.*)\)$/i',$newvalue,$reg)) $newvalue=$outputlangs->transnoentities($reg[1]);
249 249
 
250
-			$newvalue=$this->tsv_clean($newvalue,$outputlangs->charset_output);
250
+            $newvalue=$this->tsv_clean($newvalue,$outputlangs->charset_output);
251 251
 
252
-			if (preg_match('/^Select:/i', $typefield, $reg) && $typefield = substr($typefield, 7))
253
-			{
254
-				$array = unserialize($typefield);
255
-				$array = $array['options'];
256
-				$newvalue = $array[$newvalue];
257
-			}
252
+            if (preg_match('/^Select:/i', $typefield, $reg) && $typefield = substr($typefield, 7))
253
+            {
254
+                $array = unserialize($typefield);
255
+                $array = $array['options'];
256
+                $newvalue = $array[$newvalue];
257
+            }
258 258
 
259
-			fwrite($this->handle,$newvalue.$this->separator);
259
+            fwrite($this->handle,$newvalue.$this->separator);
260 260
             $this->col++;
261
-		}
261
+        }
262 262
         fwrite($this->handle,"\n");
263 263
         return 0;
264 264
     }
265 265
 
266 266
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
267
-	/**
268
-	 * 	Output footer into file
269
-	 *
270
-	 * 	@param		Translate	$outputlangs		Output language object
271
-	 * 	@return		int								<0 if KO, >0 if OK
272
-	 */
267
+    /**
268
+     * 	Output footer into file
269
+     *
270
+     * 	@param		Translate	$outputlangs		Output language object
271
+     * 	@return		int								<0 if KO, >0 if OK
272
+     */
273 273
     function write_footer($outputlangs)
274 274
     {
275 275
         // phpcs:enable
276
-		return 0;
276
+        return 0;
277 277
     }
278 278
 
279 279
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
280
-	/**
281
-	 * 	Close file handle
282
-	 *
283
-	 * 	@return		int							<0 if KO, >0 if OK
284
-	 */
280
+    /**
281
+     * 	Close file handle
282
+     *
283
+     * 	@return		int							<0 if KO, >0 if OK
284
+     */
285 285
     function close_file()
286 286
     {
287 287
         // phpcs:enable
@@ -300,18 +300,18 @@  discard block
 block discarded – undo
300 300
     function tsv_clean($newvalue, $charset)
301 301
     {
302 302
         // phpcs:enable
303
-		// Rule Dolibarr: No HTML
304
-		$newvalue=dol_string_nohtmltag($newvalue, 1, $charset);
303
+        // Rule Dolibarr: No HTML
304
+        $newvalue=dol_string_nohtmltag($newvalue, 1, $charset);
305 305
 
306
-		// Rule 1 TSV: No CR, LF in cells
307
-    	$newvalue=str_replace("\r",'',$newvalue);
306
+        // Rule 1 TSV: No CR, LF in cells
307
+        $newvalue=str_replace("\r",'',$newvalue);
308 308
         $newvalue=str_replace("\n",'\n',$newvalue);
309 309
 
310 310
         // Rule 2 TSV: If value contains tab, we must replace by space
311
-		if (preg_match('/'.$this->separator.'/',$newvalue))
312
-		{
313
-			$newvalue=str_replace("\t"," ",$newvalue);
314
-		}
311
+        if (preg_match('/'.$this->separator.'/',$newvalue))
312
+        {
313
+            $newvalue=str_replace("\t"," ",$newvalue);
314
+        }
315 315
 
316 316
         return $newvalue;
317 317
     }
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *		\author	    Laurent Destailleur
24 24
  */
25 25
 
26
-require_once DOL_DOCUMENT_ROOT .'/core/modules/export/modules_export.php';
26
+require_once DOL_DOCUMENT_ROOT.'/core/modules/export/modules_export.php';
27 27
 
28 28
 
29 29
 /**
@@ -53,9 +53,9 @@  discard block
 block discarded – undo
53 53
 
54 54
     public $version_lib;
55 55
 
56
-    public $separator="\t";
56
+    public $separator = "\t";
57 57
 
58
-    public $handle;    // Handle fichier
58
+    public $handle; // Handle fichier
59 59
 
60 60
 
61 61
     /**
@@ -68,16 +68,16 @@  discard block
 block discarded – undo
68 68
         global $conf, $langs;
69 69
         $this->db = $db;
70 70
 
71
-        $this->id='tsv';                // Same value then xxx in file name export_xxx.modules.php
72
-        $this->label = 'TSV';             // Label of driver
71
+        $this->id = 'tsv'; // Same value then xxx in file name export_xxx.modules.php
72
+        $this->label = 'TSV'; // Label of driver
73 73
         $this->desc = $langs->trans('TsvFormatDesc');
74
-        $this->extension='tsv';         // Extension for generated file by this driver
75
-        $this->picto='mime/other';		// Picto
76
-        $this->version='1.15';         // Driver version
74
+        $this->extension = 'tsv'; // Extension for generated file by this driver
75
+        $this->picto = 'mime/other'; // Picto
76
+        $this->version = '1.15'; // Driver version
77 77
 
78 78
         // If driver use an external library, put its name here
79
-        $this->label_lib='Dolibarr';
80
-        $this->version_lib=DOL_VERSION;
79
+        $this->label_lib = 'Dolibarr';
80
+        $this->version_lib = DOL_VERSION;
81 81
     }
82 82
 
83 83
 	/**
@@ -159,22 +159,22 @@  discard block
 block discarded – undo
159 159
 	*	@param		Translate	$outputlangs	Output language object
160 160
 	*	@return		int							<0 if KO, >=0 if OK
161 161
     */
162
-    function open_file($file,$outputlangs)
162
+    function open_file($file, $outputlangs)
163 163
     {
164 164
         // phpcs:enable
165 165
         global $langs;
166 166
 
167 167
         dol_syslog("ExportTsv::open_file file=".$file);
168 168
 
169
-        $ret=1;
169
+        $ret = 1;
170 170
 
171 171
         $outputlangs->load("exports");
172 172
 		$this->handle = fopen($file, "wt");
173
-        if (! $this->handle)
173
+        if (!$this->handle)
174 174
 		{
175 175
 			$langs->load("errors");
176
-			$this->error=$langs->trans("ErrorFailToCreateFile",$file);
177
-			$ret=-1;
176
+			$this->error = $langs->trans("ErrorFailToCreateFile", $file);
177
+			$ret = -1;
178 178
 		}
179 179
 
180 180
 		return $ret;
@@ -204,17 +204,17 @@  discard block
 block discarded – undo
204 204
      *  @param		array		$array_types					Array with types of fields
205 205
 	 * 	@return		int											<0 if KO, >0 if OK
206 206
 	 */
207
-    function write_title($array_export_fields_label,$array_selected_sorted,$outputlangs,$array_types)
207
+    function write_title($array_export_fields_label, $array_selected_sorted, $outputlangs, $array_types)
208 208
     {
209 209
         // phpcs:enable
210
-        foreach($array_selected_sorted as $code => $value)
210
+        foreach ($array_selected_sorted as $code => $value)
211 211
         {
212
-            $newvalue=$outputlangs->transnoentities($array_export_fields_label[$code]);		// newvalue is now $outputlangs->charset_output encoded
213
-			$newvalue=$this->tsv_clean($newvalue,$outputlangs->charset_output);
212
+            $newvalue = $outputlangs->transnoentities($array_export_fields_label[$code]); // newvalue is now $outputlangs->charset_output encoded
213
+			$newvalue = $this->tsv_clean($newvalue, $outputlangs->charset_output);
214 214
 
215
-			fwrite($this->handle,$newvalue.$this->separator);
215
+			fwrite($this->handle, $newvalue.$this->separator);
216 216
         }
217
-        fwrite($this->handle,"\n");
217
+        fwrite($this->handle, "\n");
218 218
         return 0;
219 219
     }
220 220
 
@@ -229,25 +229,25 @@  discard block
 block discarded – undo
229 229
      *  @param		array		$array_types				Array with types of fields
230 230
 	 * 	@return		int										<0 if KO, >0 if OK
231 231
 	 */
232
-    function write_record($array_selected_sorted,$objp,$outputlangs,$array_types)
232
+    function write_record($array_selected_sorted, $objp, $outputlangs, $array_types)
233 233
     {
234 234
         // phpcs:enable
235 235
     	global $conf;
236 236
 
237
-		$this->col=0;
238
- 		foreach($array_selected_sorted as $code => $value)
237
+		$this->col = 0;
238
+ 		foreach ($array_selected_sorted as $code => $value)
239 239
         {
240
-			if (strpos($code,' as ') == 0) $alias=str_replace(array('.','-','(',')'),'_',$code);
241
-			else $alias=substr($code, strpos($code, ' as ') + 4);
242
-            if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
240
+			if (strpos($code, ' as ') == 0) $alias = str_replace(array('.', '-', '(', ')'), '_', $code);
241
+			else $alias = substr($code, strpos($code, ' as ') + 4);
242
+            if (empty($alias)) dol_print_error('', 'Bad value for field with code='.$code.'. Try to redefine export.');
243 243
 
244
-            $newvalue=$outputlangs->convToOutputCharset($objp->$alias);		// objp->$alias must be utf8 encoded as any var in memory // newvalue is now $outputlangs->charset_output encoded
245
-            $typefield=isset($array_types[$code])?$array_types[$code]:'';
244
+            $newvalue = $outputlangs->convToOutputCharset($objp->$alias); // objp->$alias must be utf8 encoded as any var in memory // newvalue is now $outputlangs->charset_output encoded
245
+            $typefield = isset($array_types[$code]) ? $array_types[$code] : '';
246 246
 
247 247
             // Translation newvalue
248
-			if (preg_match('/^\((.*)\)$/i',$newvalue,$reg)) $newvalue=$outputlangs->transnoentities($reg[1]);
248
+			if (preg_match('/^\((.*)\)$/i', $newvalue, $reg)) $newvalue = $outputlangs->transnoentities($reg[1]);
249 249
 
250
-			$newvalue=$this->tsv_clean($newvalue,$outputlangs->charset_output);
250
+			$newvalue = $this->tsv_clean($newvalue, $outputlangs->charset_output);
251 251
 
252 252
 			if (preg_match('/^Select:/i', $typefield, $reg) && $typefield = substr($typefield, 7))
253 253
 			{
@@ -256,10 +256,10 @@  discard block
 block discarded – undo
256 256
 				$newvalue = $array[$newvalue];
257 257
 			}
258 258
 
259
-			fwrite($this->handle,$newvalue.$this->separator);
259
+			fwrite($this->handle, $newvalue.$this->separator);
260 260
             $this->col++;
261 261
 		}
262
-        fwrite($this->handle,"\n");
262
+        fwrite($this->handle, "\n");
263 263
         return 0;
264 264
     }
265 265
 
@@ -301,16 +301,16 @@  discard block
 block discarded – undo
301 301
     {
302 302
         // phpcs:enable
303 303
 		// Rule Dolibarr: No HTML
304
-		$newvalue=dol_string_nohtmltag($newvalue, 1, $charset);
304
+		$newvalue = dol_string_nohtmltag($newvalue, 1, $charset);
305 305
 
306 306
 		// Rule 1 TSV: No CR, LF in cells
307
-    	$newvalue=str_replace("\r",'',$newvalue);
308
-        $newvalue=str_replace("\n",'\n',$newvalue);
307
+    	$newvalue = str_replace("\r", '', $newvalue);
308
+        $newvalue = str_replace("\n", '\n', $newvalue);
309 309
 
310 310
         // Rule 2 TSV: If value contains tab, we must replace by space
311
-		if (preg_match('/'.$this->separator.'/',$newvalue))
311
+		if (preg_match('/'.$this->separator.'/', $newvalue))
312 312
 		{
313
-			$newvalue=str_replace("\t"," ",$newvalue);
313
+			$newvalue = str_replace("\t", " ", $newvalue);
314 314
 		}
315 315
 
316 316
         return $newvalue;
Please login to merge, or discard this patch.
Braces   +11 added lines, -4 removed lines patch added patch discarded remove patch
@@ -237,15 +237,22 @@
 block discarded – undo
237 237
 		$this->col=0;
238 238
  		foreach($array_selected_sorted as $code => $value)
239 239
         {
240
-			if (strpos($code,' as ') == 0) $alias=str_replace(array('.','-','(',')'),'_',$code);
241
-			else $alias=substr($code, strpos($code, ' as ') + 4);
242
-            if (empty($alias)) dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
240
+			if (strpos($code,' as ') == 0) {
241
+			    $alias=str_replace(array('.','-','(',')'),'_',$code);
242
+			} else {
243
+			    $alias=substr($code, strpos($code, ' as ') + 4);
244
+			}
245
+            if (empty($alias)) {
246
+                dol_print_error('','Bad value for field with code='.$code.'. Try to redefine export.');
247
+            }
243 248
 
244 249
             $newvalue=$outputlangs->convToOutputCharset($objp->$alias);		// objp->$alias must be utf8 encoded as any var in memory // newvalue is now $outputlangs->charset_output encoded
245 250
             $typefield=isset($array_types[$code])?$array_types[$code]:'';
246 251
 
247 252
             // Translation newvalue
248
-			if (preg_match('/^\((.*)\)$/i',$newvalue,$reg)) $newvalue=$outputlangs->transnoentities($reg[1]);
253
+			if (preg_match('/^\((.*)\)$/i',$newvalue,$reg)) {
254
+			    $newvalue=$outputlangs->transnoentities($reg[1]);
255
+			}
249 256
 
250 257
 			$newvalue=$this->tsv_clean($newvalue,$outputlangs->charset_output);
251 258
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/export/modules_export.php 2 patches
Indentation   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -30,140 +30,140 @@
 block discarded – undo
30 30
  */
31 31
 class ModeleExports extends CommonDocGenerator    // This class can't be abstract as there is instance propreties loaded by liste_modeles
32 32
 {
33
-	/**
34
-	 * @var string Error code (or message)
35
-	 */
36
-	public $error='';
33
+    /**
34
+     * @var string Error code (or message)
35
+     */
36
+    public $error='';
37 37
 
38
-	public $driverlabel=array();
38
+    public $driverlabel=array();
39 39
 
40
-	public $driverversion=array();
40
+    public $driverversion=array();
41 41
 
42
-	public $liblabel=array();
42
+    public $liblabel=array();
43 43
 
44
-	public $libversion=array();
44
+    public $libversion=array();
45 45
 
46 46
 
47 47
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
48
-	/**
49
-	 *  Load into memory list of available export format
50
-	 *
48
+    /**
49
+     *  Load into memory list of available export format
50
+     *
51 51
      *  @param	DoliDB	$db     			Database handler
52 52
      *  @param  integer	$maxfilenamelength  Max length of value to show
53 53
      *  @return	array						List of templates (same content than array this->driverlabel)
54
-	 */
55
-	function liste_modeles($db,$maxfilenamelength=0)
56
-	{
54
+     */
55
+    function liste_modeles($db,$maxfilenamelength=0)
56
+    {
57 57
         // phpcs:enable
58
-		dol_syslog(get_class($this)."::liste_modeles");
58
+        dol_syslog(get_class($this)."::liste_modeles");
59 59
 
60
-		$dir=DOL_DOCUMENT_ROOT."/core/modules/export/";
61
-		$handle=opendir($dir);
60
+        $dir=DOL_DOCUMENT_ROOT."/core/modules/export/";
61
+        $handle=opendir($dir);
62 62
 
63
-		// Recherche des fichiers drivers exports disponibles
64
-		$i=0;
63
+        // Recherche des fichiers drivers exports disponibles
64
+        $i=0;
65 65
         if (is_resource($handle))
66 66
         {
67
-    		while (($file = readdir($handle))!==false)
68
-    		{
69
-    			if (preg_match("/^export_(.*)\.modules\.php$/i",$file,$reg))
70
-    			{
71
-    				$moduleid=$reg[1];
72
-
73
-    				// Loading Class
74
-    				$file = $dir."export_".$moduleid.".modules.php";
75
-    				$classname = "Export".ucfirst($moduleid);
76
-
77
-    				require_once $file;
78
-    				if (class_exists($classname))
79
-    				{
80
-        				$module = new $classname($db);
81
-
82
-        				// Picto
83
-        				$this->picto[$module->id]=$module->picto;
84
-        				// Driver properties
85
-        				$this->driverlabel[$module->id]=$module->getDriverLabel().(empty($module->disabled)?'':' __(Disabled)__');	// '__(Disabled)__' is a key
86
-        				$this->driverdesc[$module->id]=$module->getDriverDesc();
87
-        				$this->driverversion[$module->id]=$module->getDriverVersion();
88
-        				// If use an external lib
89
-        				$this->liblabel[$module->id]=$module->getLibLabel();
90
-        				$this->libversion[$module->id]=$module->getLibVersion();
91
-    				}
92
-    				$i++;
93
-    			}
94
-    		}
95
-    		closedir($handle);
67
+            while (($file = readdir($handle))!==false)
68
+            {
69
+                if (preg_match("/^export_(.*)\.modules\.php$/i",$file,$reg))
70
+                {
71
+                    $moduleid=$reg[1];
72
+
73
+                    // Loading Class
74
+                    $file = $dir."export_".$moduleid.".modules.php";
75
+                    $classname = "Export".ucfirst($moduleid);
76
+
77
+                    require_once $file;
78
+                    if (class_exists($classname))
79
+                    {
80
+                        $module = new $classname($db);
81
+
82
+                        // Picto
83
+                        $this->picto[$module->id]=$module->picto;
84
+                        // Driver properties
85
+                        $this->driverlabel[$module->id]=$module->getDriverLabel().(empty($module->disabled)?'':' __(Disabled)__');	// '__(Disabled)__' is a key
86
+                        $this->driverdesc[$module->id]=$module->getDriverDesc();
87
+                        $this->driverversion[$module->id]=$module->getDriverVersion();
88
+                        // If use an external lib
89
+                        $this->liblabel[$module->id]=$module->getLibLabel();
90
+                        $this->libversion[$module->id]=$module->getLibVersion();
91
+                    }
92
+                    $i++;
93
+                }
94
+            }
95
+            closedir($handle);
96 96
         }
97 97
 
98 98
         asort($this->driverlabel);
99 99
 
100
-		return $this->driverlabel;
101
-	}
102
-
103
-
104
-	/**
105
-	 *  Return picto of export driver
106
-	 *
107
-	 *  @param	string	$key	Key of driver
108
-	 *  @return	string			Picto string
109
-	 */
110
-	function getPictoForKey($key)
111
-	{
112
-		return $this->picto[$key];
113
-	}
114
-
115
-	/**
116
-	 *  Renvoi libelle d'un driver export
117
-	 *
118
-	 *  @param	string	$key	Key of driver
119
-	 *  @return	string			Label
120
-	 */
121
-	function getDriverLabelForKey($key)
122
-	{
123
-		return $this->driverlabel[$key];
124
-	}
125
-
126
-	/**
127
-	 *  Renvoi le descriptif d'un driver export
128
-	 *
129
-	 *  @param	string	$key	Key of driver
130
-	 *  @return	string			Description
131
-	 */
132
-	function getDriverDescForKey($key)
133
-	{
134
-		return $this->driverdesc[$key];
135
-	}
136
-
137
-	/**
138
-	 *  Renvoi version d'un driver export
139
-	 *
140
-	 *  @param	string	$key	Key of driver
141
-	 *  @return	string			Driver version
142
-	 */
143
-	function getDriverVersionForKey($key)
144
-	{
145
-		return $this->driverversion[$key];
146
-	}
147
-
148
-	/**
149
-	 *  Renvoi libelle de librairie externe du driver
150
-	 *
151
-	 *  @param	string	$key	Key of driver
152
-	 *  @return	string			Label of library
153
-	 */
154
-	function getLibLabelForKey($key)
155
-	{
156
-		return $this->liblabel[$key];
157
-	}
158
-
159
-	/**
160
-	 *  Renvoi version de librairie externe du driver
161
-	 *
162
-	 *  @param	string	$key	Key of driver
163
-	 *  @return	string			Version of library
164
-	 */
165
-	function getLibVersionForKey($key)
166
-	{
167
-		return $this->libversion[$key];
168
-	}
100
+        return $this->driverlabel;
101
+    }
102
+
103
+
104
+    /**
105
+     *  Return picto of export driver
106
+     *
107
+     *  @param	string	$key	Key of driver
108
+     *  @return	string			Picto string
109
+     */
110
+    function getPictoForKey($key)
111
+    {
112
+        return $this->picto[$key];
113
+    }
114
+
115
+    /**
116
+     *  Renvoi libelle d'un driver export
117
+     *
118
+     *  @param	string	$key	Key of driver
119
+     *  @return	string			Label
120
+     */
121
+    function getDriverLabelForKey($key)
122
+    {
123
+        return $this->driverlabel[$key];
124
+    }
125
+
126
+    /**
127
+     *  Renvoi le descriptif d'un driver export
128
+     *
129
+     *  @param	string	$key	Key of driver
130
+     *  @return	string			Description
131
+     */
132
+    function getDriverDescForKey($key)
133
+    {
134
+        return $this->driverdesc[$key];
135
+    }
136
+
137
+    /**
138
+     *  Renvoi version d'un driver export
139
+     *
140
+     *  @param	string	$key	Key of driver
141
+     *  @return	string			Driver version
142
+     */
143
+    function getDriverVersionForKey($key)
144
+    {
145
+        return $this->driverversion[$key];
146
+    }
147
+
148
+    /**
149
+     *  Renvoi libelle de librairie externe du driver
150
+     *
151
+     *  @param	string	$key	Key of driver
152
+     *  @return	string			Label of library
153
+     */
154
+    function getLibLabelForKey($key)
155
+    {
156
+        return $this->liblabel[$key];
157
+    }
158
+
159
+    /**
160
+     *  Renvoi version de librairie externe du driver
161
+     *
162
+     *  @param	string	$key	Key of driver
163
+     *  @return	string			Version of library
164
+     */
165
+    function getLibVersionForKey($key)
166
+    {
167
+        return $this->libversion[$key];
168
+    }
169 169
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -33,15 +33,15 @@  discard block
 block discarded – undo
33 33
 	/**
34 34
 	 * @var string Error code (or message)
35 35
 	 */
36
-	public $error='';
36
+	public $error = '';
37 37
 
38
-	public $driverlabel=array();
38
+	public $driverlabel = array();
39 39
 
40
-	public $driverversion=array();
40
+	public $driverversion = array();
41 41
 
42
-	public $liblabel=array();
42
+	public $liblabel = array();
43 43
 
44
-	public $libversion=array();
44
+	public $libversion = array();
45 45
 
46 46
 
47 47
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
@@ -52,23 +52,23 @@  discard block
 block discarded – undo
52 52
      *  @param  integer	$maxfilenamelength  Max length of value to show
53 53
      *  @return	array						List of templates (same content than array this->driverlabel)
54 54
 	 */
55
-	function liste_modeles($db,$maxfilenamelength=0)
55
+	function liste_modeles($db, $maxfilenamelength = 0)
56 56
 	{
57 57
         // phpcs:enable
58 58
 		dol_syslog(get_class($this)."::liste_modeles");
59 59
 
60
-		$dir=DOL_DOCUMENT_ROOT."/core/modules/export/";
61
-		$handle=opendir($dir);
60
+		$dir = DOL_DOCUMENT_ROOT."/core/modules/export/";
61
+		$handle = opendir($dir);
62 62
 
63 63
 		// Recherche des fichiers drivers exports disponibles
64
-		$i=0;
64
+		$i = 0;
65 65
         if (is_resource($handle))
66 66
         {
67
-    		while (($file = readdir($handle))!==false)
67
+    		while (($file = readdir($handle)) !== false)
68 68
     		{
69
-    			if (preg_match("/^export_(.*)\.modules\.php$/i",$file,$reg))
69
+    			if (preg_match("/^export_(.*)\.modules\.php$/i", $file, $reg))
70 70
     			{
71
-    				$moduleid=$reg[1];
71
+    				$moduleid = $reg[1];
72 72
 
73 73
     				// Loading Class
74 74
     				$file = $dir."export_".$moduleid.".modules.php";
@@ -80,14 +80,14 @@  discard block
 block discarded – undo
80 80
         				$module = new $classname($db);
81 81
 
82 82
         				// Picto
83
-        				$this->picto[$module->id]=$module->picto;
83
+        				$this->picto[$module->id] = $module->picto;
84 84
         				// Driver properties
85
-        				$this->driverlabel[$module->id]=$module->getDriverLabel().(empty($module->disabled)?'':' __(Disabled)__');	// '__(Disabled)__' is a key
86
-        				$this->driverdesc[$module->id]=$module->getDriverDesc();
87
-        				$this->driverversion[$module->id]=$module->getDriverVersion();
85
+        				$this->driverlabel[$module->id] = $module->getDriverLabel().(empty($module->disabled) ? '' : ' __(Disabled)__'); // '__(Disabled)__' is a key
86
+        				$this->driverdesc[$module->id] = $module->getDriverDesc();
87
+        				$this->driverversion[$module->id] = $module->getDriverVersion();
88 88
         				// If use an external lib
89
-        				$this->liblabel[$module->id]=$module->getLibLabel();
90
-        				$this->libversion[$module->id]=$module->getLibVersion();
89
+        				$this->liblabel[$module->id] = $module->getLibLabel();
90
+        				$this->libversion[$module->id] = $module->getLibVersion();
91 91
     				}
92 92
     				$i++;
93 93
     			}
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modModuleBuilder.class.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -31,24 +31,24 @@  discard block
 block discarded – undo
31 31
 class modModuleBuilder extends DolibarrModules
32 32
 {
33 33
     /**
34
-	 *   Constructor. Define names, constants, directories, boxes, permissions
35
-	 *
36
-	 *   @param      DoliDB		$db      Database handler
34
+     *   Constructor. Define names, constants, directories, boxes, permissions
35
+     *
36
+     *   @param      DoliDB		$db      Database handler
37 37
      */
38 38
     function __construct($db)
39 39
     {
40
-    	global $langs,$conf;
40
+        global $langs,$conf;
41 41
 
42 42
         $this->db = $db;
43 43
         $this->numero = 3300;
44 44
 
45
-		// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
46
-		// It is used to group modules in module setup page
45
+        // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
46
+        // It is used to group modules in module setup page
47 47
         $this->family = "technic";
48 48
         // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
49 49
         $this->name = preg_replace('/^mod/i','',get_class($this));
50 50
         $this->description = "A RAD (Rapid Application Development) tool to help developers to build their own module.";
51
-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
51
+        // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
52 52
         $this->version = 'dolibarr';
53 53
         // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
54 54
         $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
@@ -64,10 +64,10 @@  discard block
 block discarded – undo
64 64
 
65 65
         // Dependencies
66 66
         //-------------
67
-	    $this->hidden = false;	// A condition to disable module
68
-	    $this->depends = array();		// List of modules id that must be enabled if this module is enabled
67
+        $this->hidden = false;	// A condition to disable module
68
+        $this->depends = array();		// List of modules id that must be enabled if this module is enabled
69 69
         $this->requiredby = array();	// List of modules id to disable if this one is disabled
70
-	    $this->conflictwith = array();	// List of modules id this module is in conflict with
70
+        $this->conflictwith = array();	// List of modules id this module is in conflict with
71 71
         $this->langfiles = array();
72 72
 
73 73
         // Constants
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *  \ingroup    blockedlog
24 24
  *  \brief      Description and activation file for module ModuleBuilder
25 25
  */
26
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
26
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
27 27
 
28 28
 /**
29 29
  *	Class to describe a ModuleBuilder module
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
      */
38 38
     function __construct($db)
39 39
     {
40
-    	global $langs,$conf;
40
+    	global $langs, $conf;
41 41
 
42 42
         $this->db = $db;
43 43
         $this->numero = 3300;
@@ -46,14 +46,14 @@  discard block
 block discarded – undo
46 46
 		// It is used to group modules in module setup page
47 47
         $this->family = "technic";
48 48
         // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
49
-        $this->name = preg_replace('/^mod/i','',get_class($this));
49
+        $this->name = preg_replace('/^mod/i', '', get_class($this));
50 50
         $this->description = "A RAD (Rapid Application Development) tool to help developers to build their own module.";
51 51
 		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
52 52
         $this->version = 'dolibarr';
53 53
         // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
54 54
         $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
55 55
         // Name of image file used for this module.
56
-        $this->picto='technic';
56
+        $this->picto = 'technic';
57 57
 
58 58
         // Data directories to create when module is enabled
59 59
         $this->dirs = array();
@@ -64,10 +64,10 @@  discard block
 block discarded – undo
64 64
 
65 65
         // Dependencies
66 66
         //-------------
67
-	    $this->hidden = false;	// A condition to disable module
68
-	    $this->depends = array();		// List of modules id that must be enabled if this module is enabled
69
-        $this->requiredby = array();	// List of modules id to disable if this one is disabled
70
-	    $this->conflictwith = array();	// List of modules id this module is in conflict with
67
+	    $this->hidden = false; // A condition to disable module
68
+	    $this->depends = array(); // List of modules id that must be enabled if this module is enabled
69
+        $this->requiredby = array(); // List of modules id to disable if this one is disabled
70
+	    $this->conflictwith = array(); // List of modules id this module is in conflict with
71 71
         $this->langfiles = array();
72 72
 
73 73
         // Constants
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
         //------------------
87 87
         $this->menu = array();
88 88
 
89
-        $this->menu[$r]=array('fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools',
89
+        $this->menu[$r] = array('fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools',
90 90
             'type'=>'left',
91 91
             'titre'=>'ModuleBuilder',
92 92
             'mainmenu'=>'home',
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/syslog/mod_syslog_chromephp.php 3 patches
Indentation   +162 added lines, -162 removed lines patch added patch discarded remove patch
@@ -7,168 +7,168 @@
 block discarded – undo
7 7
  */
8 8
 class mod_syslog_chromephp extends LogHandler implements LogHandlerInterface
9 9
 {
10
-	var $code = 'chromephp';
11
-
12
-	/**
13
-	 * 	Return name of logger
14
-	 *
15
-	 * 	@return	string		Name of logger
16
-	 */
17
-	public function getName()
18
-	{
19
-		return 'ChromePHP';
20
-	}
21
-
22
-	/**
23
-	 * Version of the module ('x.y.z' or 'dolibarr' or 'experimental' or 'development')
24
-	 *
25
-	 * @return string
26
-	 */
27
-	public function getVersion()
28
-	{
29
-		return 'dolibarr';
30
-	}
31
-
32
-	/**
33
-	 * Content of the info tooltip.
34
-	 *
35
-	 * @return string
36
-	 */
37
-	public function getInfo()
38
-	{
39
-		return '';
40
-	}
41
-
42
-	/**
43
-	 * Return warning if something is wrong with logger
44
-	 *
45
-	 * @return string
46
-	 */
47
-	public function getWarning()
48
-	{
49
-		global $langs;
50
-
51
-		return ($this->isActive() == 1)?'':$langs->trans('ClassNotFoundIntoPathWarning','ChromePhp.class.php');
52
-	}
10
+    var $code = 'chromephp';
11
+
12
+    /**
13
+     * 	Return name of logger
14
+     *
15
+     * 	@return	string		Name of logger
16
+     */
17
+    public function getName()
18
+    {
19
+        return 'ChromePHP';
20
+    }
21
+
22
+    /**
23
+     * Version of the module ('x.y.z' or 'dolibarr' or 'experimental' or 'development')
24
+     *
25
+     * @return string
26
+     */
27
+    public function getVersion()
28
+    {
29
+        return 'dolibarr';
30
+    }
31
+
32
+    /**
33
+     * Content of the info tooltip.
34
+     *
35
+     * @return string
36
+     */
37
+    public function getInfo()
38
+    {
39
+        return '';
40
+    }
41
+
42
+    /**
43
+     * Return warning if something is wrong with logger
44
+     *
45
+     * @return string
46
+     */
47
+    public function getWarning()
48
+    {
49
+        global $langs;
50
+
51
+        return ($this->isActive() == 1)?'':$langs->trans('ClassNotFoundIntoPathWarning','ChromePhp.class.php');
52
+    }
53 53
 	
54
-	/**
55
-	 * Is the module active ?
56
-	 *
57
-	 * @return int         -1 if not active, 0 if active but lib/path not found, 1 if OK
58
-	 */
59
-	public function isActive()
60
-	{
61
-		global $conf;
62
-		try
63
-		{
64
-			if (empty($conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH)) {
65
-				$conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH = DOL_DOCUMENT_ROOT . '/includes/ccampbell/chromephp/';
66
-			}
67
-			set_include_path($conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH);
68
-
69
-		    $res = @include_once 'ChromePhp.php';
70
-		    if (! $res) $res=@include_once 'ChromePhp.class.php';
71
-
72
-		    restore_include_path();
73
-
74
-		    if ($res)
75
-		    {
76
-        		return empty($conf->global->SYSLOG_DISABLE_LOGHANDLER_CHROMEPHP)?1:0;    // Set SYSLOG_DISABLE_LOGHANDLER_CHROMEPHP to 1 to disable this loghandler
77
-		    }
78
-		    else
79
-		    {
80
-		        return 0;
81
-		    }
82
-		}
83
-		catch(Exception $e)
84
-		{
85
-		    print '<!-- ChromePHP not available into PHP -->'."\n";
86
-		}
87
-
88
-		return -1;
89
-	}
90
-
91
-	/**
92
-	 * 	Return array of configuration data
93
-	 *
94
-	 * 	@return	array		Return array of configuration data
95
-	 */
96
-	public function configure()
97
-	{
98
-		global $langs;
99
-
100
-		return array(
101
-			array(
102
-				'name' => $langs->trans('IncludePath','SYSLOG_CHROMEPHP_INCLUDEPATH'),
103
-				'constant' => 'SYSLOG_CHROMEPHP_INCLUDEPATH',
104
-				'default' => DOL_DOCUMENT_ROOT . '/includes/ccampbell/chromephp/',
105
-				'attr' => 'size="60"',
106
-			    'example' =>'/usr/share/php, '.DOL_DOCUMENT_ROOT . '/includes/ccampbell/chromephp/'
107
-			)
108
-		);
109
-	}
110
-
111
-	/**
112
-	 * 	Return if configuration is valid
113
-	 *
114
-	 * 	@return	array		Array of errors. Empty array if ok.
115
-	 */
116
-	public function checkConfiguration()
117
-	{
118
-		global $langs,$conf;
119
-
120
-		$errors = array();
121
-
122
-		if (! file_exists($conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH.'/ChromePhp.php') && ! file_exists($conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH.'/ChromePhp.class.php'))
123
-		{
124
-			$conf->global->MAIN_SYSLOG_DISABLE_CHROMEPHP = 1; // avoid infinite loop
125
-			if (is_object($langs))   // $langs may not be defined yet.
126
-			{
127
-				$errors[] = $langs->trans("ErrorFailedToOpenFile", 'ChromePhp.class.php or ChromePhp.php');
128
-			}
129
-			else
130
-			{
131
-				$errors[] = "ErrorFailedToOpenFile ChromePhp.class.php or ChromePhp.php";
132
-			}
133
-		}
134
-
135
-		return $errors;
136
-	}
137
-
138
-	/**
139
-	 * 	Output log content. We also start output buffering at first log write.
140
-	 *
141
-	 *	@param	array	$content	Content to log
142
-	 * 	@return	null|false
143
-	 */
144
-	public function export($content)
145
-	{
146
-		global $conf;
147
-
148
-		if (! empty($conf->global->MAIN_SYSLOG_DISABLE_CHROMEPHP)) return;	// Global option to disable output of this handler
149
-
150
-		//We check the configuration to avoid showing PHP warnings
151
-		if (count($this->checkConfiguration()) > 0) return false;
152
-
153
-		try
154
-		{
155
-			// Warning ChromePHP must be into PHP include path. It is not possible to use into require_once a constant from
156
-			// database or config file because we must be able to log data before database or config file read.
157
-			$oldinclude=get_include_path();
158
-			set_include_path($conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH);
159
-		    $res = @include_once 'ChromePhp.php';
160
-		    if (! $res) $res=@include_once 'ChromePhp.class.php';
161
-			set_include_path($oldinclude);
54
+    /**
55
+     * Is the module active ?
56
+     *
57
+     * @return int         -1 if not active, 0 if active but lib/path not found, 1 if OK
58
+     */
59
+    public function isActive()
60
+    {
61
+        global $conf;
62
+        try
63
+        {
64
+            if (empty($conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH)) {
65
+                $conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH = DOL_DOCUMENT_ROOT . '/includes/ccampbell/chromephp/';
66
+            }
67
+            set_include_path($conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH);
68
+
69
+            $res = @include_once 'ChromePhp.php';
70
+            if (! $res) $res=@include_once 'ChromePhp.class.php';
71
+
72
+            restore_include_path();
73
+
74
+            if ($res)
75
+            {
76
+                return empty($conf->global->SYSLOG_DISABLE_LOGHANDLER_CHROMEPHP)?1:0;    // Set SYSLOG_DISABLE_LOGHANDLER_CHROMEPHP to 1 to disable this loghandler
77
+            }
78
+            else
79
+            {
80
+                return 0;
81
+            }
82
+        }
83
+        catch(Exception $e)
84
+        {
85
+            print '<!-- ChromePHP not available into PHP -->'."\n";
86
+        }
87
+
88
+        return -1;
89
+    }
90
+
91
+    /**
92
+     * 	Return array of configuration data
93
+     *
94
+     * 	@return	array		Return array of configuration data
95
+     */
96
+    public function configure()
97
+    {
98
+        global $langs;
99
+
100
+        return array(
101
+            array(
102
+                'name' => $langs->trans('IncludePath','SYSLOG_CHROMEPHP_INCLUDEPATH'),
103
+                'constant' => 'SYSLOG_CHROMEPHP_INCLUDEPATH',
104
+                'default' => DOL_DOCUMENT_ROOT . '/includes/ccampbell/chromephp/',
105
+                'attr' => 'size="60"',
106
+                'example' =>'/usr/share/php, '.DOL_DOCUMENT_ROOT . '/includes/ccampbell/chromephp/'
107
+            )
108
+        );
109
+    }
110
+
111
+    /**
112
+     * 	Return if configuration is valid
113
+     *
114
+     * 	@return	array		Array of errors. Empty array if ok.
115
+     */
116
+    public function checkConfiguration()
117
+    {
118
+        global $langs,$conf;
119
+
120
+        $errors = array();
121
+
122
+        if (! file_exists($conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH.'/ChromePhp.php') && ! file_exists($conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH.'/ChromePhp.class.php'))
123
+        {
124
+            $conf->global->MAIN_SYSLOG_DISABLE_CHROMEPHP = 1; // avoid infinite loop
125
+            if (is_object($langs))   // $langs may not be defined yet.
126
+            {
127
+                $errors[] = $langs->trans("ErrorFailedToOpenFile", 'ChromePhp.class.php or ChromePhp.php');
128
+            }
129
+            else
130
+            {
131
+                $errors[] = "ErrorFailedToOpenFile ChromePhp.class.php or ChromePhp.php";
132
+            }
133
+        }
134
+
135
+        return $errors;
136
+    }
137
+
138
+    /**
139
+     * 	Output log content. We also start output buffering at first log write.
140
+     *
141
+     *	@param	array	$content	Content to log
142
+     * 	@return	null|false
143
+     */
144
+    public function export($content)
145
+    {
146
+        global $conf;
147
+
148
+        if (! empty($conf->global->MAIN_SYSLOG_DISABLE_CHROMEPHP)) return;	// Global option to disable output of this handler
149
+
150
+        //We check the configuration to avoid showing PHP warnings
151
+        if (count($this->checkConfiguration()) > 0) return false;
152
+
153
+        try
154
+        {
155
+            // Warning ChromePHP must be into PHP include path. It is not possible to use into require_once a constant from
156
+            // database or config file because we must be able to log data before database or config file read.
157
+            $oldinclude=get_include_path();
158
+            set_include_path($conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH);
159
+            $res = @include_once 'ChromePhp.php';
160
+            if (! $res) $res=@include_once 'ChromePhp.class.php';
161
+            set_include_path($oldinclude);
162 162
 			
163
-			ob_start();	// To be sure headers are not flushed until all page is completely processed
164
-			if ($content['level'] == LOG_ERR) ChromePhp::error($content['message']);
165
-			elseif ($content['level'] == LOG_WARNING) ChromePhp::warn($content['message']);
166
-			elseif ($content['level'] == LOG_INFO) ChromePhp::log($content['message']);
167
-			else ChromePhp::log($content['message']);
168
-		}
169
-		catch (Exception $e)
170
-		{
171
-			// Do not use dol_syslog here to avoid infinite loop
172
-		}
173
-	}
163
+            ob_start();	// To be sure headers are not flushed until all page is completely processed
164
+            if ($content['level'] == LOG_ERR) ChromePhp::error($content['message']);
165
+            elseif ($content['level'] == LOG_WARNING) ChromePhp::warn($content['message']);
166
+            elseif ($content['level'] == LOG_INFO) ChromePhp::log($content['message']);
167
+            else ChromePhp::log($content['message']);
168
+        }
169
+        catch (Exception $e)
170
+        {
171
+            // Do not use dol_syslog here to avoid infinite loop
172
+        }
173
+    }
174 174
 }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	{
49 49
 		global $langs;
50 50
 
51
-		return ($this->isActive() == 1)?'':$langs->trans('ClassNotFoundIntoPathWarning','ChromePhp.class.php');
51
+		return ($this->isActive() == 1) ? '' : $langs->trans('ClassNotFoundIntoPathWarning', 'ChromePhp.class.php');
52 52
 	}
53 53
 	
54 54
 	/**
@@ -62,25 +62,25 @@  discard block
 block discarded – undo
62 62
 		try
63 63
 		{
64 64
 			if (empty($conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH)) {
65
-				$conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH = DOL_DOCUMENT_ROOT . '/includes/ccampbell/chromephp/';
65
+				$conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH = DOL_DOCUMENT_ROOT.'/includes/ccampbell/chromephp/';
66 66
 			}
67 67
 			set_include_path($conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH);
68 68
 
69 69
 		    $res = @include_once 'ChromePhp.php';
70
-		    if (! $res) $res=@include_once 'ChromePhp.class.php';
70
+		    if (!$res) $res = @include_once 'ChromePhp.class.php';
71 71
 
72 72
 		    restore_include_path();
73 73
 
74 74
 		    if ($res)
75 75
 		    {
76
-        		return empty($conf->global->SYSLOG_DISABLE_LOGHANDLER_CHROMEPHP)?1:0;    // Set SYSLOG_DISABLE_LOGHANDLER_CHROMEPHP to 1 to disable this loghandler
76
+        		return empty($conf->global->SYSLOG_DISABLE_LOGHANDLER_CHROMEPHP) ? 1 : 0; // Set SYSLOG_DISABLE_LOGHANDLER_CHROMEPHP to 1 to disable this loghandler
77 77
 		    }
78 78
 		    else
79 79
 		    {
80 80
 		        return 0;
81 81
 		    }
82 82
 		}
83
-		catch(Exception $e)
83
+		catch (Exception $e)
84 84
 		{
85 85
 		    print '<!-- ChromePHP not available into PHP -->'."\n";
86 86
 		}
@@ -99,11 +99,11 @@  discard block
 block discarded – undo
99 99
 
100 100
 		return array(
101 101
 			array(
102
-				'name' => $langs->trans('IncludePath','SYSLOG_CHROMEPHP_INCLUDEPATH'),
102
+				'name' => $langs->trans('IncludePath', 'SYSLOG_CHROMEPHP_INCLUDEPATH'),
103 103
 				'constant' => 'SYSLOG_CHROMEPHP_INCLUDEPATH',
104
-				'default' => DOL_DOCUMENT_ROOT . '/includes/ccampbell/chromephp/',
104
+				'default' => DOL_DOCUMENT_ROOT.'/includes/ccampbell/chromephp/',
105 105
 				'attr' => 'size="60"',
106
-			    'example' =>'/usr/share/php, '.DOL_DOCUMENT_ROOT . '/includes/ccampbell/chromephp/'
106
+			    'example' =>'/usr/share/php, '.DOL_DOCUMENT_ROOT.'/includes/ccampbell/chromephp/'
107 107
 			)
108 108
 		);
109 109
 	}
@@ -115,11 +115,11 @@  discard block
 block discarded – undo
115 115
 	 */
116 116
 	public function checkConfiguration()
117 117
 	{
118
-		global $langs,$conf;
118
+		global $langs, $conf;
119 119
 
120 120
 		$errors = array();
121 121
 
122
-		if (! file_exists($conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH.'/ChromePhp.php') && ! file_exists($conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH.'/ChromePhp.class.php'))
122
+		if (!file_exists($conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH.'/ChromePhp.php') && !file_exists($conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH.'/ChromePhp.class.php'))
123 123
 		{
124 124
 			$conf->global->MAIN_SYSLOG_DISABLE_CHROMEPHP = 1; // avoid infinite loop
125 125
 			if (is_object($langs))   // $langs may not be defined yet.
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	{
146 146
 		global $conf;
147 147
 
148
-		if (! empty($conf->global->MAIN_SYSLOG_DISABLE_CHROMEPHP)) return;	// Global option to disable output of this handler
148
+		if (!empty($conf->global->MAIN_SYSLOG_DISABLE_CHROMEPHP)) return; // Global option to disable output of this handler
149 149
 
150 150
 		//We check the configuration to avoid showing PHP warnings
151 151
 		if (count($this->checkConfiguration()) > 0) return false;
@@ -154,13 +154,13 @@  discard block
 block discarded – undo
154 154
 		{
155 155
 			// Warning ChromePHP must be into PHP include path. It is not possible to use into require_once a constant from
156 156
 			// database or config file because we must be able to log data before database or config file read.
157
-			$oldinclude=get_include_path();
157
+			$oldinclude = get_include_path();
158 158
 			set_include_path($conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH);
159 159
 		    $res = @include_once 'ChromePhp.php';
160
-		    if (! $res) $res=@include_once 'ChromePhp.class.php';
160
+		    if (!$res) $res = @include_once 'ChromePhp.class.php';
161 161
 			set_include_path($oldinclude);
162 162
 			
163
-			ob_start();	// To be sure headers are not flushed until all page is completely processed
163
+			ob_start(); // To be sure headers are not flushed until all page is completely processed
164 164
 			if ($content['level'] == LOG_ERR) ChromePhp::error($content['message']);
165 165
 			elseif ($content['level'] == LOG_WARNING) ChromePhp::warn($content['message']);
166 166
 			elseif ($content['level'] == LOG_INFO) ChromePhp::log($content['message']);
Please login to merge, or discard this patch.
Braces   +28 added lines, -16 removed lines patch added patch discarded remove patch
@@ -67,20 +67,20 @@  discard block
 block discarded – undo
67 67
 			set_include_path($conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH);
68 68
 
69 69
 		    $res = @include_once 'ChromePhp.php';
70
-		    if (! $res) $res=@include_once 'ChromePhp.class.php';
70
+		    if (! $res) {
71
+		        $res=@include_once 'ChromePhp.class.php';
72
+		    }
71 73
 
72 74
 		    restore_include_path();
73 75
 
74 76
 		    if ($res)
75 77
 		    {
76 78
         		return empty($conf->global->SYSLOG_DISABLE_LOGHANDLER_CHROMEPHP)?1:0;    // Set SYSLOG_DISABLE_LOGHANDLER_CHROMEPHP to 1 to disable this loghandler
77
-		    }
78
-		    else
79
+		    } else
79 80
 		    {
80 81
 		        return 0;
81 82
 		    }
82
-		}
83
-		catch(Exception $e)
83
+		} catch(Exception $e)
84 84
 		{
85 85
 		    print '<!-- ChromePHP not available into PHP -->'."\n";
86 86
 		}
@@ -122,11 +122,12 @@  discard block
 block discarded – undo
122 122
 		if (! file_exists($conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH.'/ChromePhp.php') && ! file_exists($conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH.'/ChromePhp.class.php'))
123 123
 		{
124 124
 			$conf->global->MAIN_SYSLOG_DISABLE_CHROMEPHP = 1; // avoid infinite loop
125
-			if (is_object($langs))   // $langs may not be defined yet.
125
+			if (is_object($langs)) {
126
+			    // $langs may not be defined yet.
126 127
 			{
127 128
 				$errors[] = $langs->trans("ErrorFailedToOpenFile", 'ChromePhp.class.php or ChromePhp.php');
128 129
 			}
129
-			else
130
+			} else
130 131
 			{
131 132
 				$errors[] = "ErrorFailedToOpenFile ChromePhp.class.php or ChromePhp.php";
132 133
 			}
@@ -145,10 +146,15 @@  discard block
 block discarded – undo
145 146
 	{
146 147
 		global $conf;
147 148
 
148
-		if (! empty($conf->global->MAIN_SYSLOG_DISABLE_CHROMEPHP)) return;	// Global option to disable output of this handler
149
+		if (! empty($conf->global->MAIN_SYSLOG_DISABLE_CHROMEPHP)) {
150
+		    return;
151
+		}
152
+		// Global option to disable output of this handler
149 153
 
150 154
 		//We check the configuration to avoid showing PHP warnings
151
-		if (count($this->checkConfiguration()) > 0) return false;
155
+		if (count($this->checkConfiguration()) > 0) {
156
+		    return false;
157
+		}
152 158
 
153 159
 		try
154 160
 		{
@@ -157,16 +163,22 @@  discard block
 block discarded – undo
157 163
 			$oldinclude=get_include_path();
158 164
 			set_include_path($conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH);
159 165
 		    $res = @include_once 'ChromePhp.php';
160
-		    if (! $res) $res=@include_once 'ChromePhp.class.php';
166
+		    if (! $res) {
167
+		        $res=@include_once 'ChromePhp.class.php';
168
+		    }
161 169
 			set_include_path($oldinclude);
162 170
 			
163 171
 			ob_start();	// To be sure headers are not flushed until all page is completely processed
164
-			if ($content['level'] == LOG_ERR) ChromePhp::error($content['message']);
165
-			elseif ($content['level'] == LOG_WARNING) ChromePhp::warn($content['message']);
166
-			elseif ($content['level'] == LOG_INFO) ChromePhp::log($content['message']);
167
-			else ChromePhp::log($content['message']);
168
-		}
169
-		catch (Exception $e)
172
+			if ($content['level'] == LOG_ERR) {
173
+			    ChromePhp::error($content['message']);
174
+			} elseif ($content['level'] == LOG_WARNING) {
175
+			    ChromePhp::warn($content['message']);
176
+			} elseif ($content['level'] == LOG_INFO) {
177
+			    ChromePhp::log($content['message']);
178
+			} else {
179
+			    ChromePhp::log($content['message']);
180
+			}
181
+		} catch (Exception $e)
170 182
 		{
171 183
 			// Do not use dol_syslog here to avoid infinite loop
172 184
 		}
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/syslog/mod_syslog_syslog.php 3 patches
Indentation   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -7,121 +7,121 @@
 block discarded – undo
7 7
  */
8 8
 class mod_syslog_syslog extends LogHandler implements LogHandlerInterface
9 9
 {
10
-	var $code = 'syslog';
11
-
12
-	/**
13
-	 * 	Return name of logger
14
-	 *
15
-	 * 	@return	string		Name of logger
16
-	 */
17
-	public function getName()
18
-	{
19
-		return 'Syslog';
20
-	}
21
-
22
-	/**
23
-	 * Version of the module ('x.y.z' or 'dolibarr' or 'experimental' or 'development')
24
-	 *
25
-	 * @return string
26
-	 */
27
-	public function getVersion()
28
-	{
29
-		return 'dolibarr';
30
-	}
31
-
32
-	/**
33
-	 * Content of the info tooltip.
34
-	 *
35
-	 * @return false|string
36
-	 */
37
-	public function getInfo()
38
-	{
39
-		global $langs;
40
-
41
-		return $langs->trans('OnlyWindowsLOG_USER');
42
-	}
43
-
44
-	/**
45
-	 * Is the module active ?
46
-	 *
47
-	 * @return int
48
-	 */
49
-	public function isActive()
50
-	{
51
-	    global $conf;
52
-
53
-		// This function does not exists on some ISP (Ex: Free in France)
54
-		if (!function_exists('openlog')) return 0;
55
-
56
-		return empty($conf->global->SYSLOG_DISABLE_LOGHANDLER_SYSLOG)?1:0;    // Set SYSLOG_DISABLE_LOGHANDLER_SYSLOG to 1 to disable this loghandler
57
-	}
58
-
59
-	/**
60
-	 * 	Return array of configuration data
61
-	 *
62
-	 * 	@return	array		Return array of configuration data
63
-	 */
64
-	public function configure()
65
-	{
66
-		global $langs;
67
-
68
-		return array(
69
-			array(
70
-				'constant' => 'SYSLOG_FACILITY',
71
-				'name' => $langs->trans('SyslogFacility'),
72
-				'default' => 'LOG_USER'
73
-			)
74
-		);
75
-	}
76
-
77
-	/**
78
-	 * 	Return if configuration is valid
79
-	 *
80
-	 * 	@return	array		Array of errors. Empty array if ok.
81
-	 */
82
-	public function checkConfiguration()
83
-	{
84
-		global $conf, $langs;
85
-
86
-		$errors = array();
87
-
88
-	    $facility = constant($conf->global->SYSLOG_FACILITY);
89
-	    if ($facility)
90
-		{
91
-			// Only LOG_USER supported on Windows
92
-			if (! empty($_SERVER["WINDIR"])) $facility=constant('LOG_USER');
93
-
94
-			dol_syslog("admin/syslog: facility ".$facility);
95
-		}
96
-		else
97
-		{
98
-		    $errors[] = $langs->trans("ErrorUnknownSyslogConstant", $facility);
99
-		}
100
-
101
-		return $errors;
102
-	}
103
-
104
-	/**
105
-	 * Export the message
106
-	 *
107
-	 * @param  	array 	$content 	Array containing the info about the message
108
-	 * @return	void
109
-	 */
110
-	public function export($content)
111
-	{
112
-		global $conf;
113
-
114
-		if (! empty($conf->global->MAIN_SYSLOG_DISABLE_SYSLOG)) return;	// Global option to disable output of this handler
115
-
116
-		if (! empty($conf->global->SYSLOG_FACILITY))  // Example LOG_USER
117
-		{
118
-			$facility = constant($conf->global->SYSLOG_FACILITY);
119
-		}
120
-		else $facility = constant('LOG_USER');
121
-
122
-		// (int) is required to avoid error parameter 3 expected to be long
123
-		openlog('dolibarr', LOG_PID | LOG_PERROR, (int) $facility);
124
-		syslog($content['level'], $content['message']);
125
-		closelog();
126
-	}
10
+    var $code = 'syslog';
11
+
12
+    /**
13
+     * 	Return name of logger
14
+     *
15
+     * 	@return	string		Name of logger
16
+     */
17
+    public function getName()
18
+    {
19
+        return 'Syslog';
20
+    }
21
+
22
+    /**
23
+     * Version of the module ('x.y.z' or 'dolibarr' or 'experimental' or 'development')
24
+     *
25
+     * @return string
26
+     */
27
+    public function getVersion()
28
+    {
29
+        return 'dolibarr';
30
+    }
31
+
32
+    /**
33
+     * Content of the info tooltip.
34
+     *
35
+     * @return false|string
36
+     */
37
+    public function getInfo()
38
+    {
39
+        global $langs;
40
+
41
+        return $langs->trans('OnlyWindowsLOG_USER');
42
+    }
43
+
44
+    /**
45
+     * Is the module active ?
46
+     *
47
+     * @return int
48
+     */
49
+    public function isActive()
50
+    {
51
+        global $conf;
52
+
53
+        // This function does not exists on some ISP (Ex: Free in France)
54
+        if (!function_exists('openlog')) return 0;
55
+
56
+        return empty($conf->global->SYSLOG_DISABLE_LOGHANDLER_SYSLOG)?1:0;    // Set SYSLOG_DISABLE_LOGHANDLER_SYSLOG to 1 to disable this loghandler
57
+    }
58
+
59
+    /**
60
+     * 	Return array of configuration data
61
+     *
62
+     * 	@return	array		Return array of configuration data
63
+     */
64
+    public function configure()
65
+    {
66
+        global $langs;
67
+
68
+        return array(
69
+            array(
70
+                'constant' => 'SYSLOG_FACILITY',
71
+                'name' => $langs->trans('SyslogFacility'),
72
+                'default' => 'LOG_USER'
73
+            )
74
+        );
75
+    }
76
+
77
+    /**
78
+     * 	Return if configuration is valid
79
+     *
80
+     * 	@return	array		Array of errors. Empty array if ok.
81
+     */
82
+    public function checkConfiguration()
83
+    {
84
+        global $conf, $langs;
85
+
86
+        $errors = array();
87
+
88
+        $facility = constant($conf->global->SYSLOG_FACILITY);
89
+        if ($facility)
90
+        {
91
+            // Only LOG_USER supported on Windows
92
+            if (! empty($_SERVER["WINDIR"])) $facility=constant('LOG_USER');
93
+
94
+            dol_syslog("admin/syslog: facility ".$facility);
95
+        }
96
+        else
97
+        {
98
+            $errors[] = $langs->trans("ErrorUnknownSyslogConstant", $facility);
99
+        }
100
+
101
+        return $errors;
102
+    }
103
+
104
+    /**
105
+     * Export the message
106
+     *
107
+     * @param  	array 	$content 	Array containing the info about the message
108
+     * @return	void
109
+     */
110
+    public function export($content)
111
+    {
112
+        global $conf;
113
+
114
+        if (! empty($conf->global->MAIN_SYSLOG_DISABLE_SYSLOG)) return;	// Global option to disable output of this handler
115
+
116
+        if (! empty($conf->global->SYSLOG_FACILITY))  // Example LOG_USER
117
+        {
118
+            $facility = constant($conf->global->SYSLOG_FACILITY);
119
+        }
120
+        else $facility = constant('LOG_USER');
121
+
122
+        // (int) is required to avoid error parameter 3 expected to be long
123
+        openlog('dolibarr', LOG_PID | LOG_PERROR, (int) $facility);
124
+        syslog($content['level'], $content['message']);
125
+        closelog();
126
+    }
127 127
 }
128 128
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 		// This function does not exists on some ISP (Ex: Free in France)
54 54
 		if (!function_exists('openlog')) return 0;
55 55
 
56
-		return empty($conf->global->SYSLOG_DISABLE_LOGHANDLER_SYSLOG)?1:0;    // Set SYSLOG_DISABLE_LOGHANDLER_SYSLOG to 1 to disable this loghandler
56
+		return empty($conf->global->SYSLOG_DISABLE_LOGHANDLER_SYSLOG) ? 1 : 0; // Set SYSLOG_DISABLE_LOGHANDLER_SYSLOG to 1 to disable this loghandler
57 57
 	}
58 58
 
59 59
 	/**
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	    if ($facility)
90 90
 		{
91 91
 			// Only LOG_USER supported on Windows
92
-			if (! empty($_SERVER["WINDIR"])) $facility=constant('LOG_USER');
92
+			if (!empty($_SERVER["WINDIR"])) $facility = constant('LOG_USER');
93 93
 
94 94
 			dol_syslog("admin/syslog: facility ".$facility);
95 95
 		}
@@ -111,9 +111,9 @@  discard block
 block discarded – undo
111 111
 	{
112 112
 		global $conf;
113 113
 
114
-		if (! empty($conf->global->MAIN_SYSLOG_DISABLE_SYSLOG)) return;	// Global option to disable output of this handler
114
+		if (!empty($conf->global->MAIN_SYSLOG_DISABLE_SYSLOG)) return; // Global option to disable output of this handler
115 115
 
116
-		if (! empty($conf->global->SYSLOG_FACILITY))  // Example LOG_USER
116
+		if (!empty($conf->global->SYSLOG_FACILITY))  // Example LOG_USER
117 117
 		{
118 118
 			$facility = constant($conf->global->SYSLOG_FACILITY);
119 119
 		}
Please login to merge, or discard this patch.
Braces   +16 added lines, -7 removed lines patch added patch discarded remove patch
@@ -51,7 +51,9 @@  discard block
 block discarded – undo
51 51
 	    global $conf;
52 52
 
53 53
 		// This function does not exists on some ISP (Ex: Free in France)
54
-		if (!function_exists('openlog')) return 0;
54
+		if (!function_exists('openlog')) {
55
+		    return 0;
56
+		}
55 57
 
56 58
 		return empty($conf->global->SYSLOG_DISABLE_LOGHANDLER_SYSLOG)?1:0;    // Set SYSLOG_DISABLE_LOGHANDLER_SYSLOG to 1 to disable this loghandler
57 59
 	}
@@ -89,11 +91,12 @@  discard block
 block discarded – undo
89 91
 	    if ($facility)
90 92
 		{
91 93
 			// Only LOG_USER supported on Windows
92
-			if (! empty($_SERVER["WINDIR"])) $facility=constant('LOG_USER');
94
+			if (! empty($_SERVER["WINDIR"])) {
95
+			    $facility=constant('LOG_USER');
96
+			}
93 97
 
94 98
 			dol_syslog("admin/syslog: facility ".$facility);
95
-		}
96
-		else
99
+		} else
97 100
 		{
98 101
 		    $errors[] = $langs->trans("ErrorUnknownSyslogConstant", $facility);
99 102
 		}
@@ -111,13 +114,19 @@  discard block
 block discarded – undo
111 114
 	{
112 115
 		global $conf;
113 116
 
114
-		if (! empty($conf->global->MAIN_SYSLOG_DISABLE_SYSLOG)) return;	// Global option to disable output of this handler
117
+		if (! empty($conf->global->MAIN_SYSLOG_DISABLE_SYSLOG)) {
118
+		    return;
119
+		}
120
+		// Global option to disable output of this handler
115 121
 
116
-		if (! empty($conf->global->SYSLOG_FACILITY))  // Example LOG_USER
122
+		if (! empty($conf->global->SYSLOG_FACILITY)) {
123
+		    // Example LOG_USER
117 124
 		{
118 125
 			$facility = constant($conf->global->SYSLOG_FACILITY);
119 126
 		}
120
-		else $facility = constant('LOG_USER');
127
+		} else {
128
+		    $facility = constant('LOG_USER');
129
+		}
121 130
 
122 131
 		// (int) is required to avoid error parameter 3 expected to be long
123 132
 		openlog('dolibarr', LOG_PID | LOG_PERROR, (int) $facility);
Please login to merge, or discard this patch.