Completed
Push — 1.10.x ( 4a4ede...319c16 )
by Yannick
163:25 queued 134:54
created
main/newscorm/openoffice_document.class.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
          // Create the directory
53 53
         $this->base_work_dir = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
54 54
         ///learning_path/ppt_dirname directory
55
-        $this->created_dir = substr($result['dir'], 0, strlen($result['dir']) -1);
55
+        $this->created_dir = substr($result['dir'], 0, strlen($result['dir']) - 1);
56 56
         $this->file_path = $this->created_dir.'/'.api_replace_dangerous_char($file['name']);
57 57
 
58 58
         //var_dump($this->file_name, $this->file_path, $this->base_work_dir, $this->created_dir);
@@ -89,18 +89,18 @@  discard block
 block discarded – undo
89 89
             $perm = api_get_setting('permissions_for_new_files');
90 90
 
91 91
             if (IS_WINDOWS_OS) { // IS_WINDOWS_OS has been defined in main_api.lib.php
92
-                $converter_path = str_replace('/', '\\', api_get_path(SYS_PATH) . 'main/inc/lib/ppt2png');
93
-                $class_path = $converter_path . ';' . $converter_path . '/jodconverter-2.2.2.jar;' . $converter_path . '/jodconverter-cli-2.2.2.jar';
92
+                $converter_path = str_replace('/', '\\', api_get_path(SYS_PATH).'main/inc/lib/ppt2png');
93
+                $class_path = $converter_path.';'.$converter_path.'/jodconverter-2.2.2.jar;'.$converter_path.'/jodconverter-cli-2.2.2.jar';
94 94
                 //$cmd = 'java -cp "'.$class_path.'" DokeosConverter';
95
-                $cmd = 'java -Dfile.encoding=UTF-8 -cp "' . $class_path . '" DokeosConverter';
95
+                $cmd = 'java -Dfile.encoding=UTF-8 -cp "'.$class_path.'" DokeosConverter';
96 96
             } else {
97
-                $converter_path = api_get_path(SYS_PATH) . 'main/inc/lib/ppt2png';
97
+                $converter_path = api_get_path(SYS_PATH).'main/inc/lib/ppt2png';
98 98
                 //$class_path = '-cp .:jodconverter-2.2.1.jar:jodconverter-cli-2.2.1.jar';
99 99
                 $class_path = ' -Dfile.encoding=UTF-8 -cp .:jodconverter-2.2.2.jar:jodconverter-cli-2.2.2.jar';
100
-                $cmd = 'cd ' . $converter_path . ' && java ' . $class_path . ' DokeosConverter';
100
+                $cmd = 'cd '.$converter_path.' && java '.$class_path.' DokeosConverter';
101 101
             }
102 102
 
103
-            $cmd .= ' -p ' . api_get_setting('service_ppt2lp', 'port');
103
+            $cmd .= ' -p '.api_get_setting('service_ppt2lp', 'port');
104 104
             // Call to the function implemented by child.
105 105
             $cmd .= $this->add_command_parameters();
106 106
             // To allow openoffice to manipulate docs.
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
             @chmod($this->base_work_dir.$this->file_path, 0777);
110 110
 
111 111
             $locale = $this->original_locale; // TODO: Improve it because we're not sure this locale is present everywhere.
112
-            putenv('LC_ALL=' . $locale);
112
+            putenv('LC_ALL='.$locale);
113 113
 
114 114
             $files = array();
115 115
             $return = 0;
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
             if (!empty($result['images'])) {
140 140
                 foreach ($result['images'] as $image => $img_data) {
141 141
                     $image_path = $this->base_work_dir.$this->created_dir;
142
-                    @file_put_contents($image_path . '/' . $image, base64_decode($img_data));
143
-                    @chmod($image_path . '/' . $image, 0777);
142
+                    @file_put_contents($image_path.'/'.$image, base64_decode($img_data));
143
+                    @chmod($image_path.'/'.$image, 0777);
144 144
                 }
145 145
             }
146 146
 
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
         $uri = '';
183 183
         $result = preg_match('/^([a-zA-Z0-9]*):\/\/([^\/]*)\//', $ppt2lp_host, $matches);
184 184
         if ($result) {
185
-            $uri = $matches[1] . '://' . $matches[2] . '/';
185
+            $uri = $matches[1].'://'.$matches[2].'/';
186 186
         } else {
187 187
             $uri = $ppt2lp_host;
188 188
         }
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
             'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 9,
202 202
         );
203 203
         if (substr($ppt2lp_host, 0, 5) === 'https') {
204
-            $options['ssl_method'] =  SOAP_SSL_METHOD_TLS;
204
+            $options['ssl_method'] = SOAP_SSL_METHOD_TLS;
205 205
         }
206 206
         $client = new SoapClient(null, $options);
207 207
         $result = '';
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
             //error_log('['.time().'] Calling wsConvertPpt webservice on ' . $ppt2lp_host);
222 222
             $result = $client->__call('wsConvertPpt', array('pptData' => $params));
223 223
         } catch (Exception $e) {
224
-            error_log('['.time().'] Chamilo SOAP call error: ' . $e->getMessage());
224
+            error_log('['.time().'] Chamilo SOAP call error: '.$e->getMessage());
225 225
         }
226 226
         // Make sure we destroy the SOAP client as it may generate SSL connection
227 227
         // binding issue (if using SSL)
@@ -254,38 +254,38 @@  discard block
 block discarded – undo
254 254
         $ppt2lpHost = api_get_setting('service_ppt2lp', 'host');
255 255
         $permissionFile = api_get_permissions_for_new_files();
256 256
         $permissionFolder = api_get_permissions_for_new_directories();
257
-        if (file_exists($this->base_work_dir . '/' . $this->created_dir)) {
257
+        if (file_exists($this->base_work_dir.'/'.$this->created_dir)) {
258 258
 
259 259
             return $ids;
260 260
         }
261 261
 
262 262
         if ($ppt2lpHost == 'localhost') {
263 263
             if (IS_WINDOWS_OS) { // IS_WINDOWS_OS has been defined in main_api.lib.php
264
-                $converterPath = str_replace('/', '\\', api_get_path(SYS_PATH) . 'main/inc/lib/ppt2png');
265
-                $classPath = $converterPath . ';' . $converterPath . '/jodconverter-2.2.2.jar;' . $converterPath . '/jodconverter-cli-2.2.2.jar';
266
-                $cmd = 'java -Dfile.encoding=UTF-8 -jar "' . $classPath . '/jodconverter-2.2.2.jar"';
264
+                $converterPath = str_replace('/', '\\', api_get_path(SYS_PATH).'main/inc/lib/ppt2png');
265
+                $classPath = $converterPath.';'.$converterPath.'/jodconverter-2.2.2.jar;'.$converterPath.'/jodconverter-cli-2.2.2.jar';
266
+                $cmd = 'java -Dfile.encoding=UTF-8 -jar "'.$classPath.'/jodconverter-2.2.2.jar"';
267 267
             } else {
268
-                $converterPath = api_get_path(SYS_PATH) . 'main/inc/lib/ppt2png';
268
+                $converterPath = api_get_path(SYS_PATH).'main/inc/lib/ppt2png';
269 269
                 $classPath = ' -Dfile.encoding=UTF-8 -jar jodconverter-cli-2.2.2.jar';
270
-                $cmd = 'cd ' . $converterPath . ' && java ' . $classPath . ' ';
270
+                $cmd = 'cd '.$converterPath.' && java '.$classPath.' ';
271 271
             }
272 272
 
273
-            $cmd .= ' -p ' . api_get_setting('service_ppt2lp', 'port');
273
+            $cmd .= ' -p '.api_get_setting('service_ppt2lp', 'port');
274 274
             // Call to the function implemented by child.
275
-            $cmd .= ' "' . $this->base_work_dir . '/' . $this->file_path . '"  "' . $this->base_work_dir . '/' . $this->created_dir . '"';
275
+            $cmd .= ' "'.$this->base_work_dir.'/'.$this->file_path.'"  "'.$this->base_work_dir.'/'.$this->created_dir.'"';
276 276
             // To allow openoffice to manipulate docs.
277 277
             @chmod($this->base_work_dir, $permissionFolder);
278
-            @chmod($this->base_work_dir . '/' . $this->file_path, $permissionFile);
278
+            @chmod($this->base_work_dir.'/'.$this->file_path, $permissionFile);
279 279
 
280 280
             $locale = $this->original_locale; // TODO: Improve it because we're not sure this locale is present everywhere.
281
-            putenv('LC_ALL=' . $locale);
281
+            putenv('LC_ALL='.$locale);
282 282
 
283 283
             $files = array();
284 284
             $return = 0;
285 285
             $shell = exec($cmd, $files, $return);
286 286
             // TODO: Chown is not working, root keep user privileges, should be www-data
287
-            @chown($this->base_work_dir . '/' . $this->created_dir, 'www-data');
288
-            @chmod($this->base_work_dir . '/' . $this->created_dir, $permissionFile);
287
+            @chown($this->base_work_dir.'/'.$this->created_dir, 'www-data');
288
+            @chmod($this->base_work_dir.'/'.$this->created_dir, $permissionFile);
289 289
 
290 290
             if ($return != 0) { // If the java application returns an error code.
291 291
                 switch ($return) {
@@ -324,14 +324,14 @@  discard block
 block discarded – undo
324 324
             */
325 325
         }
326 326
 
327
-        if (file_exists($this->base_work_dir . '/' . $this->created_dir)) {
327
+        if (file_exists($this->base_work_dir.'/'.$this->created_dir)) {
328 328
 
329 329
             // Register Files to Document tool
330 330
             $ids[] = add_document(
331 331
                 $_course,
332
-                '/' . $this->created_dir,
332
+                '/'.$this->created_dir,
333 333
                 'file',
334
-                filesize($this->base_work_dir . '/' . $this->created_dir),
334
+                filesize($this->base_work_dir.'/'.$this->created_dir),
335 335
                 $convertedTitle,
336 336
                 sprintf(
337 337
                     get_lang('FileConvertedFromXToY'),
Please login to merge, or discard this patch.