Passed
Push — master ( f1aad3...85aeb8 )
by Ferry
05:16 queued 02:22
created
src/assets/assets/edit_area/edit_area_compressor.php 2 patches
Indentation   +359 added lines, -359 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-	/******
2
+    /******
3 3
 	 *
4 4
 	 *	EditArea PHP compressor
5 5
 	 * 	Developped by Christophe Dolivet
@@ -8,421 +8,421 @@  discard block
 block discarded – undo
8 8
 	 *
9 9
 	******/
10 10
 	
11
-	// CONFIG
12
-	$param['cache_duration']= 3600 * 24 * 10;		// 10 days util client cache expires
13
-	$param['compress'] = true;						// enable the code compression, should be activated but it can be usefull to desactivate it for easier error retrieving (true or false)
14
-	$param['debug'] = false;						// Enable this option if you need debuging info
15
-	$param['use_disk_cache']= true;					// If you enable this option gzip files will be cached on disk.
16
-	$param['use_gzip']= true;						// Enable gzip compression
17
-	// END CONFIG
11
+    // CONFIG
12
+    $param['cache_duration']= 3600 * 24 * 10;		// 10 days util client cache expires
13
+    $param['compress'] = true;						// enable the code compression, should be activated but it can be usefull to desactivate it for easier error retrieving (true or false)
14
+    $param['debug'] = false;						// Enable this option if you need debuging info
15
+    $param['use_disk_cache']= true;					// If you enable this option gzip files will be cached on disk.
16
+    $param['use_gzip']= true;						// Enable gzip compression
17
+    // END CONFIG
18 18
 	
19
-	$compressor= new Compressor($param);
19
+    $compressor= new Compressor($param);
20 20
 	
21
-	class Compressor{
21
+    class Compressor{
22 22
 	
23 23
 		
24
-		function compressor($param)
25
-		{
26
-			$this->__construct($param);
27
-		}
24
+        function compressor($param)
25
+        {
26
+            $this->__construct($param);
27
+        }
28 28
 		
29
-		function __construct($param)
30
-		{
31
-			$this->start_time= $this->get_microtime();
32
-			$this->file_loaded_size=0;
33
-			$this->param= $param;
34
-			$this->script_list="";
35
-			$this->path= dirname(__FILE__)."/";
36
-			if(isset($_GET['plugins'])){
37
-				$this->load_all_plugins= true;
38
-				$this->full_cache_file= $this->path."edit_area_full_with_plugins.js";
39
-				$this->gzip_cache_file= $this->path."edit_area_full_with_plugins.gz";
40
-			}else{
41
-				$this->load_all_plugins= false;
42
-				$this->full_cache_file= $this->path."edit_area_full.js";
43
-				$this->gzip_cache_file= $this->path."edit_area_full.gz";
44
-			}
29
+        function __construct($param)
30
+        {
31
+            $this->start_time= $this->get_microtime();
32
+            $this->file_loaded_size=0;
33
+            $this->param= $param;
34
+            $this->script_list="";
35
+            $this->path= dirname(__FILE__)."/";
36
+            if(isset($_GET['plugins'])){
37
+                $this->load_all_plugins= true;
38
+                $this->full_cache_file= $this->path."edit_area_full_with_plugins.js";
39
+                $this->gzip_cache_file= $this->path."edit_area_full_with_plugins.gz";
40
+            }else{
41
+                $this->load_all_plugins= false;
42
+                $this->full_cache_file= $this->path."edit_area_full.js";
43
+                $this->gzip_cache_file= $this->path."edit_area_full.gz";
44
+            }
45 45
 			
46
-			$this->check_gzip_use();
47
-			$this->send_headers();
48
-			$this->check_cache();
49
-			$this->load_files();
50
-			$this->send_datas();
51
-		}
46
+            $this->check_gzip_use();
47
+            $this->send_headers();
48
+            $this->check_cache();
49
+            $this->load_files();
50
+            $this->send_datas();
51
+        }
52 52
 		
53
-		function send_headers()
54
-		{
55
-			header("Content-type: text/javascript; charset: UTF-8");
56
-			header("Vary: Accept-Encoding"); // Handle proxies
57
-			header(sprintf("Expires: %s GMT", gmdate("D, d M Y H:i:s", time() + $this->param['cache_duration'])) );
58
-			if($this->use_gzip)
59
-				header("Content-Encoding: ".$this->gzip_enc_header);
60
-		}
53
+        function send_headers()
54
+        {
55
+            header("Content-type: text/javascript; charset: UTF-8");
56
+            header("Vary: Accept-Encoding"); // Handle proxies
57
+            header(sprintf("Expires: %s GMT", gmdate("D, d M Y H:i:s", time() + $this->param['cache_duration'])) );
58
+            if($this->use_gzip)
59
+                header("Content-Encoding: ".$this->gzip_enc_header);
60
+        }
61 61
 		
62
-		function check_gzip_use()
63
-		{
64
-			$encodings = array();
65
-			$desactivate_gzip=false;
62
+        function check_gzip_use()
63
+        {
64
+            $encodings = array();
65
+            $desactivate_gzip=false;
66 66
 					
67
-			if (isset($_SERVER['HTTP_ACCEPT_ENCODING']))
68
-				$encodings = explode(',', strtolower(preg_replace("/\s+/", "", $_SERVER['HTTP_ACCEPT_ENCODING'])));
67
+            if (isset($_SERVER['HTTP_ACCEPT_ENCODING']))
68
+                $encodings = explode(',', strtolower(preg_replace("/\s+/", "", $_SERVER['HTTP_ACCEPT_ENCODING'])));
69 69
 			
70
-			// desactivate gzip for IE version < 7
71
-			if(preg_match("/(?:msie )([0-9.]+)/i", $_SERVER['HTTP_USER_AGENT'], $ie))
72
-			{
73
-				if($ie[1]<7)
74
-					$desactivate_gzip=true;	
75
-			}
70
+            // desactivate gzip for IE version < 7
71
+            if(preg_match("/(?:msie )([0-9.]+)/i", $_SERVER['HTTP_USER_AGENT'], $ie))
72
+            {
73
+                if($ie[1]<7)
74
+                    $desactivate_gzip=true;	
75
+            }
76 76
 			
77
-			// Check for gzip header or northon internet securities
78
-			if (!$desactivate_gzip && $this->param['use_gzip'] && (in_array('gzip', $encodings) || in_array('x-gzip', $encodings) || isset($_SERVER['---------------'])) && function_exists('ob_gzhandler') && !ini_get('zlib.output_compression')) {
79
-				$this->gzip_enc_header= in_array('x-gzip', $encodings) ? "x-gzip" : "gzip";
80
-				$this->use_gzip=true;
81
-				$this->cache_file=$this->gzip_cache_file;
82
-			}else{
83
-				$this->use_gzip=false;
84
-				$this->cache_file=$this->full_cache_file;
85
-			}
86
-		}
77
+            // Check for gzip header or northon internet securities
78
+            if (!$desactivate_gzip && $this->param['use_gzip'] && (in_array('gzip', $encodings) || in_array('x-gzip', $encodings) || isset($_SERVER['---------------'])) && function_exists('ob_gzhandler') && !ini_get('zlib.output_compression')) {
79
+                $this->gzip_enc_header= in_array('x-gzip', $encodings) ? "x-gzip" : "gzip";
80
+                $this->use_gzip=true;
81
+                $this->cache_file=$this->gzip_cache_file;
82
+            }else{
83
+                $this->use_gzip=false;
84
+                $this->cache_file=$this->full_cache_file;
85
+            }
86
+        }
87 87
 		
88
-		function check_cache()
89
-		{
90
-			// Only gzip the contents if clients and server support it
91
-			if (file_exists($this->cache_file)) {
92
-				// check if cache file must be updated
93
-				$cache_date=0;				
94
-				if ($dir = opendir($this->path)) {
95
-					while (($file = readdir($dir)) !== false) {
96
-						if(is_file($this->path.$file) && $file!="." && $file!="..")
97
-							$cache_date= max($cache_date, filemtime($this->path.$file));
98
-					}
99
-					closedir($dir);
100
-				}
101
-				if($this->load_all_plugins){
102
-					$plug_path= $this->path."plugins/";
103
-					if (($dir = @opendir($plug_path)) !== false)
104
-					{
105
-						while (($file = readdir($dir)) !== false)
106
-						{
107
-							if ($file !== "." && $file !== "..")
108
-							{
109
-								if(is_dir($plug_path.$file) && file_exists($plug_path.$file."/".$file.".js"))
110
-									$cache_date= max($cache_date, filemtime("plugins/".$file."/".$file.".js"));
111
-							}
112
-						}
113
-						closedir($dir);
114
-					}
115
-				}
88
+        function check_cache()
89
+        {
90
+            // Only gzip the contents if clients and server support it
91
+            if (file_exists($this->cache_file)) {
92
+                // check if cache file must be updated
93
+                $cache_date=0;				
94
+                if ($dir = opendir($this->path)) {
95
+                    while (($file = readdir($dir)) !== false) {
96
+                        if(is_file($this->path.$file) && $file!="." && $file!="..")
97
+                            $cache_date= max($cache_date, filemtime($this->path.$file));
98
+                    }
99
+                    closedir($dir);
100
+                }
101
+                if($this->load_all_plugins){
102
+                    $plug_path= $this->path."plugins/";
103
+                    if (($dir = @opendir($plug_path)) !== false)
104
+                    {
105
+                        while (($file = readdir($dir)) !== false)
106
+                        {
107
+                            if ($file !== "." && $file !== "..")
108
+                            {
109
+                                if(is_dir($plug_path.$file) && file_exists($plug_path.$file."/".$file.".js"))
110
+                                    $cache_date= max($cache_date, filemtime("plugins/".$file."/".$file.".js"));
111
+                            }
112
+                        }
113
+                        closedir($dir);
114
+                    }
115
+                }
116 116
 
117
-				if(filemtime($this->cache_file) >= $cache_date){
118
-					// if cache file is up to date
119
-					$last_modified = gmdate("D, d M Y H:i:s",filemtime($this->cache_file))." GMT";
120
-					if (isset($_SERVER["HTTP_IF_MODIFIED_SINCE"]) && strcasecmp($_SERVER["HTTP_IF_MODIFIED_SINCE"], $last_modified) === 0)
121
-					{
122
-						header("HTTP/1.1 304 Not Modified");
123
-						header("Last-modified: ".$last_modified);
124
-						header("Cache-Control: Public"); // Tells HTTP 1.1 clients to cache
125
-						header("Pragma:"); // Tells HTTP 1.0 clients to cache
126
-					}
127
-					else
128
-					{
129
-						header("Last-modified: ".$last_modified);
130
-						header("Cache-Control: Public"); // Tells HTTP 1.1 clients to cache
131
-						header("Pragma:"); // Tells HTTP 1.0 clients to cache
132
-						header('Content-Length: '.filesize($this->cache_file));
133
-						echo file_get_contents($this->cache_file);
134
-					}				
135
-					die;
136
-				}
137
-			}
138
-			return false;
139
-		}
117
+                if(filemtime($this->cache_file) >= $cache_date){
118
+                    // if cache file is up to date
119
+                    $last_modified = gmdate("D, d M Y H:i:s",filemtime($this->cache_file))." GMT";
120
+                    if (isset($_SERVER["HTTP_IF_MODIFIED_SINCE"]) && strcasecmp($_SERVER["HTTP_IF_MODIFIED_SINCE"], $last_modified) === 0)
121
+                    {
122
+                        header("HTTP/1.1 304 Not Modified");
123
+                        header("Last-modified: ".$last_modified);
124
+                        header("Cache-Control: Public"); // Tells HTTP 1.1 clients to cache
125
+                        header("Pragma:"); // Tells HTTP 1.0 clients to cache
126
+                    }
127
+                    else
128
+                    {
129
+                        header("Last-modified: ".$last_modified);
130
+                        header("Cache-Control: Public"); // Tells HTTP 1.1 clients to cache
131
+                        header("Pragma:"); // Tells HTTP 1.0 clients to cache
132
+                        header('Content-Length: '.filesize($this->cache_file));
133
+                        echo file_get_contents($this->cache_file);
134
+                    }				
135
+                    die;
136
+                }
137
+            }
138
+            return false;
139
+        }
140 140
 		
141
-		function load_files()
142
-		{
143
-			$loader= $this->get_content("edit_area_loader.js")."\n";
141
+        function load_files()
142
+        {
143
+            $loader= $this->get_content("edit_area_loader.js")."\n";
144 144
 			
145
-			// get the list of other files to load
146
-	    	$loader= preg_replace("/(t\.scripts_to_load=\s*)\[([^\]]*)\];/e"
147
-						, "\$this->replace_scripts('script_list', '\\1', '\\2')"
148
-						, $loader);
145
+            // get the list of other files to load
146
+            $loader= preg_replace("/(t\.scripts_to_load=\s*)\[([^\]]*)\];/e"
147
+                        , "\$this->replace_scripts('script_list', '\\1', '\\2')"
148
+                        , $loader);
149 149
 		
150
-			$loader= preg_replace("/(t\.sub_scripts_to_load=\s*)\[([^\]]*)\];/e"
151
-						, "\$this->replace_scripts('sub_script_list', '\\1', '\\2')"
152
-						, $loader);
150
+            $loader= preg_replace("/(t\.sub_scripts_to_load=\s*)\[([^\]]*)\];/e"
151
+                        , "\$this->replace_scripts('sub_script_list', '\\1', '\\2')"
152
+                        , $loader);
153 153
 
154
-			// replace languages names
155
-			$reg_path= $this->path."reg_syntax/";
156
-			$a_displayName	= array();
157
-			if (($dir = @opendir($reg_path)) !== false)
158
-			{
159
-				while (($file = readdir($dir)) !== false)
160
-				{
161
-					if( $file !== "." && $file !== ".." && ( $pos = strpos( $file, '.js' ) ) !== false )
162
-					{
163
-						$jsContent	= $this->file_get_contents( $reg_path.$file );
164
-						if( preg_match( '@(\'|")DISPLAY_NAME\1\s*:\s*(\'|")(.*)\2@', $jsContent, $match ) )
165
-						{
166
-							$a_displayName[] = "'". substr( $file, 0, $pos ) ."':'". htmlspecialchars( $match[3], ENT_QUOTES ) ."'";
167
-						}
168
-					}
169
-				}
170
-				closedir($dir);
171
-			}
172
-			$loader	= str_replace( '/*syntax_display_name_AUTO-FILL-BY-COMPRESSOR*/', implode( ",", $a_displayName ), $loader );
154
+            // replace languages names
155
+            $reg_path= $this->path."reg_syntax/";
156
+            $a_displayName	= array();
157
+            if (($dir = @opendir($reg_path)) !== false)
158
+            {
159
+                while (($file = readdir($dir)) !== false)
160
+                {
161
+                    if( $file !== "." && $file !== ".." && ( $pos = strpos( $file, '.js' ) ) !== false )
162
+                    {
163
+                        $jsContent	= $this->file_get_contents( $reg_path.$file );
164
+                        if( preg_match( '@(\'|")DISPLAY_NAME\1\s*:\s*(\'|")(.*)\2@', $jsContent, $match ) )
165
+                        {
166
+                            $a_displayName[] = "'". substr( $file, 0, $pos ) ."':'". htmlspecialchars( $match[3], ENT_QUOTES ) ."'";
167
+                        }
168
+                    }
169
+                }
170
+                closedir($dir);
171
+            }
172
+            $loader	= str_replace( '/*syntax_display_name_AUTO-FILL-BY-COMPRESSOR*/', implode( ",", $a_displayName ), $loader );
173 173
 						
174
-			$this->datas= $loader;
175
-			$this->compress_javascript($this->datas);
174
+            $this->datas= $loader;
175
+            $this->compress_javascript($this->datas);
176 176
 			
177
-			// load other scripts needed for the loader
178
-			preg_match_all('/"([^"]*)"/', $this->script_list, $match);
179
-			foreach($match[1] as $key => $value)
180
-			{
181
-				$content= $this->get_content(preg_replace("/\\|\//i", "", $value).".js");
182
-				$this->compress_javascript($content);
183
-				$this->datas.= $content."\n";
184
-			}
185
-			//$this->datas);
186
-			//$this->datas= preg_replace('/(( |\t|\r)*\n( |\t)*)+/s', "", $this->datas);
177
+            // load other scripts needed for the loader
178
+            preg_match_all('/"([^"]*)"/', $this->script_list, $match);
179
+            foreach($match[1] as $key => $value)
180
+            {
181
+                $content= $this->get_content(preg_replace("/\\|\//i", "", $value).".js");
182
+                $this->compress_javascript($content);
183
+                $this->datas.= $content."\n";
184
+            }
185
+            //$this->datas);
186
+            //$this->datas= preg_replace('/(( |\t|\r)*\n( |\t)*)+/s', "", $this->datas);
187 187
 			
188
-			// improved compression step 1/2	
189
-			$this->datas= preg_replace(array("/(\b)EditAreaLoader(\b)/", "/(\b)editAreaLoader(\b)/", "/(\b)editAreas(\b)/"), array("EAL", "eAL", "eAs"), $this->datas);
190
-			//$this->datas= str_replace(array("EditAreaLoader", "editAreaLoader", "editAreas"), array("EAL", "eAL", "eAs"), $this->datas);
191
-			$this->datas.= "var editAreaLoader= eAL;var editAreas=eAs;EditAreaLoader=EAL;";
188
+            // improved compression step 1/2	
189
+            $this->datas= preg_replace(array("/(\b)EditAreaLoader(\b)/", "/(\b)editAreaLoader(\b)/", "/(\b)editAreas(\b)/"), array("EAL", "eAL", "eAs"), $this->datas);
190
+            //$this->datas= str_replace(array("EditAreaLoader", "editAreaLoader", "editAreas"), array("EAL", "eAL", "eAs"), $this->datas);
191
+            $this->datas.= "var editAreaLoader= eAL;var editAreas=eAs;EditAreaLoader=EAL;";
192 192
 		
193
-			// load sub scripts
194
-			$sub_scripts="";
195
-			$sub_scripts_list= array();
196
-			preg_match_all('/"([^"]*)"/', $this->sub_script_list, $match);
197
-			foreach($match[1] as $value){
198
-				$sub_scripts_list[]= preg_replace("/\\|\//i", "", $value).".js";
199
-			}
193
+            // load sub scripts
194
+            $sub_scripts="";
195
+            $sub_scripts_list= array();
196
+            preg_match_all('/"([^"]*)"/', $this->sub_script_list, $match);
197
+            foreach($match[1] as $value){
198
+                $sub_scripts_list[]= preg_replace("/\\|\//i", "", $value).".js";
199
+            }
200 200
 		
201
-			if($this->load_all_plugins){
202
-				// load plugins scripts
203
-				$plug_path= $this->path."plugins/";
204
-				if (($dir = @opendir($plug_path)) !== false)
205
-				{
206
-					while (($file = readdir($dir)) !== false)
207
-					{
208
-						if ($file !== "." && $file !== "..")
209
-						{
210
-							if(is_dir($plug_path.$file) && file_exists($plug_path.$file."/".$file.".js"))
211
-								$sub_scripts_list[]= "plugins/".$file."/".$file.".js";
212
-						}
213
-					}
214
-					closedir($dir);
215
-				}
216
-			}
201
+            if($this->load_all_plugins){
202
+                // load plugins scripts
203
+                $plug_path= $this->path."plugins/";
204
+                if (($dir = @opendir($plug_path)) !== false)
205
+                {
206
+                    while (($file = readdir($dir)) !== false)
207
+                    {
208
+                        if ($file !== "." && $file !== "..")
209
+                        {
210
+                            if(is_dir($plug_path.$file) && file_exists($plug_path.$file."/".$file.".js"))
211
+                                $sub_scripts_list[]= "plugins/".$file."/".$file.".js";
212
+                        }
213
+                    }
214
+                    closedir($dir);
215
+                }
216
+            }
217 217
 							
218
-			foreach($sub_scripts_list as $value){
219
-				$sub_scripts.= $this->get_javascript_content($value);
220
-			}
221
-			// improved compression step 2/2	
222
-			$sub_scripts= preg_replace(array("/(\b)editAreaLoader(\b)/", "/(\b)editAreas(\b)/", "/(\b)editArea(\b)/", "/(\b)EditArea(\b)/"), array("eAL", "eAs", "eA", "EA"), $sub_scripts);
223
-		//	$sub_scripts= str_replace(array("editAreaLoader", "editAreas", "editArea", "EditArea"), array("eAL", "eAs", "eA", "EA"), $sub_scripts);
224
-			$sub_scripts.= "var editArea= eA;EditArea=EA;";
218
+            foreach($sub_scripts_list as $value){
219
+                $sub_scripts.= $this->get_javascript_content($value);
220
+            }
221
+            // improved compression step 2/2	
222
+            $sub_scripts= preg_replace(array("/(\b)editAreaLoader(\b)/", "/(\b)editAreas(\b)/", "/(\b)editArea(\b)/", "/(\b)EditArea(\b)/"), array("eAL", "eAs", "eA", "EA"), $sub_scripts);
223
+        //	$sub_scripts= str_replace(array("editAreaLoader", "editAreas", "editArea", "EditArea"), array("eAL", "eAs", "eA", "EA"), $sub_scripts);
224
+            $sub_scripts.= "var editArea= eA;EditArea=EA;";
225 225
 			
226 226
 			
227
-			// add the scripts
228
-		//	$this->datas.= sprintf("editAreaLoader.iframe_script= \"<script type='text/javascript'>%s</script>\";\n", $sub_scripts);
227
+            // add the scripts
228
+        //	$this->datas.= sprintf("editAreaLoader.iframe_script= \"<script type='text/javascript'>%s</script>\";\n", $sub_scripts);
229 229
 		
230 230
 		
231
-			// add the script and use a last compression 
232
-			if( $this->param['compress'] )
233
-			{
234
-				$last_comp	= array( 'Á' => 'this',
235
-								 'Â' => 'textarea',
236
-								 'Ã' => 'function',
237
-								 'Ä' => 'prototype',
238
-								 'Å' => 'settings',
239
-								 'Æ' => 'length',
240
-								 'Ç' => 'style',
241
-								 'È' => 'parent',
242
-								 'É' => 'last_selection',
243
-								 'Ê' => 'value',
244
-								 'Ë' => 'true',
245
-								 'Ì' => 'false'
246
-								 /*,
231
+            // add the script and use a last compression 
232
+            if( $this->param['compress'] )
233
+            {
234
+                $last_comp	= array( 'Á' => 'this',
235
+                                    'Â' => 'textarea',
236
+                                    'Ã' => 'function',
237
+                                    'Ä' => 'prototype',
238
+                                    'Å' => 'settings',
239
+                                    'Æ' => 'length',
240
+                                    'Ç' => 'style',
241
+                                    'È' => 'parent',
242
+                                    'É' => 'last_selection',
243
+                                    'Ê' => 'value',
244
+                                    'Ë' => 'true',
245
+                                    'Ì' => 'false'
246
+                                    /*,
247 247
 									'Î' => '"',
248 248
 								 'Ï' => "\n",
249 249
 								 'À' => "\r"*/);
250
-			}
251
-			else
252
-			{
253
-				$last_comp	= array();
254
-			}
250
+            }
251
+            else
252
+            {
253
+                $last_comp	= array();
254
+            }
255 255
 			
256
-			$js_replace= '';
257
-			foreach( $last_comp as $key => $val )
258
-				$js_replace .= ".replace(/". $key ."/g,'". str_replace( array("\n", "\r"), array('\n','\r'), $val ) ."')";
256
+            $js_replace= '';
257
+            foreach( $last_comp as $key => $val )
258
+                $js_replace .= ".replace(/". $key ."/g,'". str_replace( array("\n", "\r"), array('\n','\r'), $val ) ."')";
259 259
 			
260
-			$this->datas.= sprintf("editAreaLoader.iframe_script= \"<script type='text/javascript'>%s</script>\"%s;\n",
261
-								str_replace( array_values($last_comp), array_keys($last_comp), $sub_scripts ), 
262
-								$js_replace);
260
+            $this->datas.= sprintf("editAreaLoader.iframe_script= \"<script type='text/javascript'>%s</script>\"%s;\n",
261
+                                str_replace( array_values($last_comp), array_keys($last_comp), $sub_scripts ), 
262
+                                $js_replace);
263 263
 			
264
-			if($this->load_all_plugins)
265
-				$this->datas.="editAreaLoader.all_plugins_loaded=true;\n";
264
+            if($this->load_all_plugins)
265
+                $this->datas.="editAreaLoader.all_plugins_loaded=true;\n";
266 266
 		
267 267
 			
268
-			// load the template
269
-			$this->datas.= sprintf("editAreaLoader.template= \"%s\";\n", $this->get_html_content("template.html"));
270
-			// load the css
271
-			$this->datas.= sprintf("editAreaLoader.iframe_css= \"<style>%s</style>\";\n", $this->get_css_content("edit_area.css"));
268
+            // load the template
269
+            $this->datas.= sprintf("editAreaLoader.template= \"%s\";\n", $this->get_html_content("template.html"));
270
+            // load the css
271
+            $this->datas.= sprintf("editAreaLoader.iframe_css= \"<style>%s</style>\";\n", $this->get_css_content("edit_area.css"));
272 272
 					
273
-		//	$this->datas= "function editArea(){};editArea.prototype.loader= function(){alert('bouhbouh');} var a= new editArea();a.loader();";
273
+        //	$this->datas= "function editArea(){};editArea.prototype.loader= function(){alert('bouhbouh');} var a= new editArea();a.loader();";
274 274
 					
275
-		}
275
+        }
276 276
 		
277
-		function send_datas()
278
-		{
279
-			if($this->param['debug']){
280
-				$header=sprintf("/* USE PHP COMPRESSION\n");
281
-				$header.=sprintf("javascript size: based files: %s => PHP COMPRESSION => %s ", $this->file_loaded_size, strlen($this->datas));
282
-				if($this->use_gzip){
283
-					$gzip_datas=  gzencode($this->datas, 9, FORCE_GZIP);				
284
-					$header.=sprintf("=> GZIP COMPRESSION => %s", strlen($gzip_datas));
285
-					$ratio = round(100 - strlen($gzip_datas) / $this->file_loaded_size * 100.0);			
286
-				}else{
287
-					$ratio = round(100 - strlen($this->datas) / $this->file_loaded_size * 100.0);
288
-				}
289
-				$header.=sprintf(", reduced by %s%%\n", $ratio);
290
-				$header.=sprintf("compression time: %s\n", $this->get_microtime()-$this->start_time); 
291
-				$header.=sprintf("%s\n", implode("\n", $this->infos));
292
-				$header.=sprintf("*/\n");
293
-				$this->datas= $header.$this->datas;	
294
-			}
295
-			$mtime= time(); // ensure that the 2 disk files will have the same update time
296
-			// generate gzip file and cahce it if using disk cache
297
-			if($this->use_gzip){
298
-				$this->gzip_datas= gzencode($this->datas, 9, FORCE_GZIP);
299
-				if($this->param['use_disk_cache'])
300
-					$this->file_put_contents($this->gzip_cache_file, $this->gzip_datas, $mtime);
301
-			}
277
+        function send_datas()
278
+        {
279
+            if($this->param['debug']){
280
+                $header=sprintf("/* USE PHP COMPRESSION\n");
281
+                $header.=sprintf("javascript size: based files: %s => PHP COMPRESSION => %s ", $this->file_loaded_size, strlen($this->datas));
282
+                if($this->use_gzip){
283
+                    $gzip_datas=  gzencode($this->datas, 9, FORCE_GZIP);				
284
+                    $header.=sprintf("=> GZIP COMPRESSION => %s", strlen($gzip_datas));
285
+                    $ratio = round(100 - strlen($gzip_datas) / $this->file_loaded_size * 100.0);			
286
+                }else{
287
+                    $ratio = round(100 - strlen($this->datas) / $this->file_loaded_size * 100.0);
288
+                }
289
+                $header.=sprintf(", reduced by %s%%\n", $ratio);
290
+                $header.=sprintf("compression time: %s\n", $this->get_microtime()-$this->start_time); 
291
+                $header.=sprintf("%s\n", implode("\n", $this->infos));
292
+                $header.=sprintf("*/\n");
293
+                $this->datas= $header.$this->datas;	
294
+            }
295
+            $mtime= time(); // ensure that the 2 disk files will have the same update time
296
+            // generate gzip file and cahce it if using disk cache
297
+            if($this->use_gzip){
298
+                $this->gzip_datas= gzencode($this->datas, 9, FORCE_GZIP);
299
+                if($this->param['use_disk_cache'])
300
+                    $this->file_put_contents($this->gzip_cache_file, $this->gzip_datas, $mtime);
301
+            }
302 302
 			
303
-			// generate full js file and cache it if using disk cache			
304
-			if($this->param['use_disk_cache'])
305
-				$this->file_put_contents($this->full_cache_file, $this->datas, $mtime);
303
+            // generate full js file and cache it if using disk cache			
304
+            if($this->param['use_disk_cache'])
305
+                $this->file_put_contents($this->full_cache_file, $this->datas, $mtime);
306 306
 			
307
-			// generate output
308
-			if($this->use_gzip)
309
-				echo $this->gzip_datas;
310
-			else
311
-				echo $this->datas;
307
+            // generate output
308
+            if($this->use_gzip)
309
+                echo $this->gzip_datas;
310
+            else
311
+                echo $this->datas;
312 312
 				
313 313
 //			die;
314
-		}
314
+        }
315 315
 				
316 316
 		
317
-		function get_content($end_uri)
318
-		{
319
-			$end_uri=preg_replace("/\.\./", "", $end_uri); // Remove any .. (security)
320
-			$file= $this->path.$end_uri;
321
-			if(file_exists($file)){
322
-				$this->infos[]=sprintf("'%s' loaded", $end_uri);
323
-				/*$fd = fopen($file, 'rb');
317
+        function get_content($end_uri)
318
+        {
319
+            $end_uri=preg_replace("/\.\./", "", $end_uri); // Remove any .. (security)
320
+            $file= $this->path.$end_uri;
321
+            if(file_exists($file)){
322
+                $this->infos[]=sprintf("'%s' loaded", $end_uri);
323
+                /*$fd = fopen($file, 'rb');
324 324
 				$content = fread($fd, filesize($file));
325 325
 				fclose($fd);
326 326
 				return $content;*/
327
-				return $this->file_get_contents($file);
328
-			}else{
329
-				$this->infos[]=sprintf("'%s' not loaded", $end_uri);
330
-				return "";
331
-			}
332
-		}
327
+                return $this->file_get_contents($file);
328
+            }else{
329
+                $this->infos[]=sprintf("'%s' not loaded", $end_uri);
330
+                return "";
331
+            }
332
+        }
333 333
 		
334
-		function get_javascript_content($end_uri)
335
-		{
336
-			$val=$this->get_content($end_uri);
334
+        function get_javascript_content($end_uri)
335
+        {
336
+            $val=$this->get_content($end_uri);
337 337
 	
338
-			$this->compress_javascript($val);
339
-			$this->prepare_string_for_quotes($val);
340
-			return $val;
341
-		}
338
+            $this->compress_javascript($val);
339
+            $this->prepare_string_for_quotes($val);
340
+            return $val;
341
+        }
342 342
 		
343
-		function compress_javascript(&$code)
344
-		{
345
-			if($this->param['compress'])
346
-			{
347
-				// remove all comments
348
-				//	(\"(?:[^\"\\]*(?:\\\\)*(?:\\\"?)?)*(?:\"|$))|(\'(?:[^\'\\]*(?:\\\\)*(?:\\'?)?)*(?:\'|$))|(?:\/\/(?:.|\r|\t)*?(\n|$))|(?:\/\*(?:.|\n|\r|\t)*?(?:\*\/|$))
349
-				$code= preg_replace("/(\"(?:[^\"\\\\]*(?:\\\\\\\\)*(?:\\\\\"?)?)*(?:\"|$))|(\'(?:[^\'\\\\]*(?:\\\\\\\\)*(?:\\\\\'?)?)*(?:\'|$))|(?:\/\/(?:.|\r|\t)*?(\n|$))|(?:\/\*(?:.|\n|\r|\t)*?(?:\*\/|$))/s", "$1$2$3", $code);
350
-				// remove line return, empty line and tabulation
351
-				$code= preg_replace('/(( |\t|\r)*\n( |\t)*)+/s', " ", $code);
352
-				// add line break before "else" otherwise navigators can't manage to parse the file
353
-				$code= preg_replace('/(\b(else)\b)/', "\n$1", $code);
354
-				// remove unnecessary spaces
355
-				$code= preg_replace('/( |\t|\r)*(;|\{|\}|=|==|\-|\+|,|\(|\)|\|\||&\&|\:)( |\t|\r)*/', "$2", $code);
356
-			}
357
-		}
343
+        function compress_javascript(&$code)
344
+        {
345
+            if($this->param['compress'])
346
+            {
347
+                // remove all comments
348
+                //	(\"(?:[^\"\\]*(?:\\\\)*(?:\\\"?)?)*(?:\"|$))|(\'(?:[^\'\\]*(?:\\\\)*(?:\\'?)?)*(?:\'|$))|(?:\/\/(?:.|\r|\t)*?(\n|$))|(?:\/\*(?:.|\n|\r|\t)*?(?:\*\/|$))
349
+                $code= preg_replace("/(\"(?:[^\"\\\\]*(?:\\\\\\\\)*(?:\\\\\"?)?)*(?:\"|$))|(\'(?:[^\'\\\\]*(?:\\\\\\\\)*(?:\\\\\'?)?)*(?:\'|$))|(?:\/\/(?:.|\r|\t)*?(\n|$))|(?:\/\*(?:.|\n|\r|\t)*?(?:\*\/|$))/s", "$1$2$3", $code);
350
+                // remove line return, empty line and tabulation
351
+                $code= preg_replace('/(( |\t|\r)*\n( |\t)*)+/s', " ", $code);
352
+                // add line break before "else" otherwise navigators can't manage to parse the file
353
+                $code= preg_replace('/(\b(else)\b)/', "\n$1", $code);
354
+                // remove unnecessary spaces
355
+                $code= preg_replace('/( |\t|\r)*(;|\{|\}|=|==|\-|\+|,|\(|\)|\|\||&\&|\:)( |\t|\r)*/', "$2", $code);
356
+            }
357
+        }
358 358
 		
359
-		function get_css_content($end_uri){
360
-			$code=$this->get_content($end_uri);
361
-			// remove comments
362
-			$code= preg_replace("/(?:\/\*(?:.|\n|\r|\t)*?(?:\*\/|$))/s", "", $code);
363
-			// remove spaces
364
-			$code= preg_replace('/(( |\t|\r)*\n( |\t)*)+/s', "", $code);
365
-			// remove spaces
366
-			$code= preg_replace('/( |\t|\r)?(\:|,|\{|\})( |\t|\r)+/', "$2", $code);
359
+        function get_css_content($end_uri){
360
+            $code=$this->get_content($end_uri);
361
+            // remove comments
362
+            $code= preg_replace("/(?:\/\*(?:.|\n|\r|\t)*?(?:\*\/|$))/s", "", $code);
363
+            // remove spaces
364
+            $code= preg_replace('/(( |\t|\r)*\n( |\t)*)+/s', "", $code);
365
+            // remove spaces
366
+            $code= preg_replace('/( |\t|\r)?(\:|,|\{|\})( |\t|\r)+/', "$2", $code);
367 367
 		
368
-			$this->prepare_string_for_quotes($code);
369
-			return $code;
370
-		}
368
+            $this->prepare_string_for_quotes($code);
369
+            return $code;
370
+        }
371 371
 		
372
-		function get_html_content($end_uri){
373
-			$code=$this->get_content($end_uri);
374
-			//$code= preg_replace('/(\"(?:\\\"|[^\"])*(?:\"|$))|' . "(\'(?:\\\'|[^\'])*(?:\'|$))|(?:\/\/(?:.|\r|\t)*?(\n|$))|(?:\/\*(?:.|\n|\r|\t)*?(?:\*\/|$))/s", "$1$2$3", $code);
375
-			$code= preg_replace('/(( |\t|\r)*\n( |\t)*)+/s', " ", $code);
376
-			$this->prepare_string_for_quotes($code);
377
-			return $code;
378
-		}
372
+        function get_html_content($end_uri){
373
+            $code=$this->get_content($end_uri);
374
+            //$code= preg_replace('/(\"(?:\\\"|[^\"])*(?:\"|$))|' . "(\'(?:\\\'|[^\'])*(?:\'|$))|(?:\/\/(?:.|\r|\t)*?(\n|$))|(?:\/\*(?:.|\n|\r|\t)*?(?:\*\/|$))/s", "$1$2$3", $code);
375
+            $code= preg_replace('/(( |\t|\r)*\n( |\t)*)+/s', " ", $code);
376
+            $this->prepare_string_for_quotes($code);
377
+            return $code;
378
+        }
379 379
 		
380
-		function prepare_string_for_quotes(&$str){
381
-			// prepare the code to be putted into quotes 
382
-			/*$pattern= array("/(\\\\)?\"/", '/\\\n/'	, '/\\\r/'	, "/(\r?\n)/");
380
+        function prepare_string_for_quotes(&$str){
381
+            // prepare the code to be putted into quotes 
382
+            /*$pattern= array("/(\\\\)?\"/", '/\\\n/'	, '/\\\r/'	, "/(\r?\n)/");
383 383
 			$replace= array('$1$1\\"', '\\\\\\n', '\\\\\\r'	, '\\\n"$1+"');*/
384
-			$pattern= array("/(\\\\)?\"/", '/\\\n/'	, '/\\\r/'	, "/(\r?\n)/");
385
-			if($this->param['compress'])
386
-				$replace= array('$1$1\\"', '\\\\\\n', '\\\\\\r'	, '\n');
387
-			else
388
-				$replace= array('$1$1\\"', '\\\\\\n', '\\\\\\r'	, "\\n\"\n+\"");
389
-			$str= preg_replace($pattern, $replace, $str);
390
-		}
384
+            $pattern= array("/(\\\\)?\"/", '/\\\n/'	, '/\\\r/'	, "/(\r?\n)/");
385
+            if($this->param['compress'])
386
+                $replace= array('$1$1\\"', '\\\\\\n', '\\\\\\r'	, '\n');
387
+            else
388
+                $replace= array('$1$1\\"', '\\\\\\n', '\\\\\\r'	, "\\n\"\n+\"");
389
+            $str= preg_replace($pattern, $replace, $str);
390
+        }
391 391
 		
392
-		function replace_scripts($var, $param1, $param2)
393
-		{
394
-			$this->$var=stripslashes($param2);
395
-	        return $param1."[];";
396
-		}
392
+        function replace_scripts($var, $param1, $param2)
393
+        {
394
+            $this->$var=stripslashes($param2);
395
+            return $param1."[];";
396
+        }
397 397
 
398
-		/* for php version that have not thoses functions */
399
-		function file_get_contents($file)
400
-		{
401
-			$fd = fopen($file, 'rb');
402
-			$content = fread($fd, filesize($file));
403
-			fclose($fd);
404
-			$this->file_loaded_size+= strlen($content);
405
-			return $content;				
406
-		}
398
+        /* for php version that have not thoses functions */
399
+        function file_get_contents($file)
400
+        {
401
+            $fd = fopen($file, 'rb');
402
+            $content = fread($fd, filesize($file));
403
+            fclose($fd);
404
+            $this->file_loaded_size+= strlen($content);
405
+            return $content;				
406
+        }
407 407
 		
408
-		function file_put_contents($file, &$content, $mtime=-1)
409
-		{
410
-			if($mtime==-1)
411
-				$mtime=time();
412
-			$fp = @fopen($file, "wb");
413
-			if ($fp) {
414
-				fwrite($fp, $content);
415
-				fclose($fp);
416
-				touch($file, $mtime);
417
-				return true;
418
-			}
419
-			return false;
420
-		}
408
+        function file_put_contents($file, &$content, $mtime=-1)
409
+        {
410
+            if($mtime==-1)
411
+                $mtime=time();
412
+            $fp = @fopen($file, "wb");
413
+            if ($fp) {
414
+                fwrite($fp, $content);
415
+                fclose($fp);
416
+                touch($file, $mtime);
417
+                return true;
418
+            }
419
+            return false;
420
+        }
421 421
 		
422
-		function get_microtime()
423
-		{
424
-		   list($usec, $sec) = explode(" ", microtime());
425
-		   return ((float)$usec + (float)$sec);
426
-		}
427
-	}	
422
+        function get_microtime()
423
+        {
424
+            list($usec, $sec) = explode(" ", microtime());
425
+            return ((float)$usec + (float)$sec);
426
+        }
427
+    }	
428 428
 ?>
Please login to merge, or discard this patch.
Braces   +49 added lines, -38 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 				$this->load_all_plugins= true;
38 38
 				$this->full_cache_file= $this->path."edit_area_full_with_plugins.js";
39 39
 				$this->gzip_cache_file= $this->path."edit_area_full_with_plugins.gz";
40
-			}else{
40
+			} else{
41 41
 				$this->load_all_plugins= false;
42 42
 				$this->full_cache_file= $this->path."edit_area_full.js";
43 43
 				$this->gzip_cache_file= $this->path."edit_area_full.gz";
@@ -55,8 +55,9 @@  discard block
 block discarded – undo
55 55
 			header("Content-type: text/javascript; charset: UTF-8");
56 56
 			header("Vary: Accept-Encoding"); // Handle proxies
57 57
 			header(sprintf("Expires: %s GMT", gmdate("D, d M Y H:i:s", time() + $this->param['cache_duration'])) );
58
-			if($this->use_gzip)
59
-				header("Content-Encoding: ".$this->gzip_enc_header);
58
+			if($this->use_gzip) {
59
+							header("Content-Encoding: ".$this->gzip_enc_header);
60
+			}
60 61
 		}
61 62
 		
62 63
 		function check_gzip_use()
@@ -64,14 +65,16 @@  discard block
 block discarded – undo
64 65
 			$encodings = array();
65 66
 			$desactivate_gzip=false;
66 67
 					
67
-			if (isset($_SERVER['HTTP_ACCEPT_ENCODING']))
68
-				$encodings = explode(',', strtolower(preg_replace("/\s+/", "", $_SERVER['HTTP_ACCEPT_ENCODING'])));
68
+			if (isset($_SERVER['HTTP_ACCEPT_ENCODING'])) {
69
+							$encodings = explode(',', strtolower(preg_replace("/\s+/", "", $_SERVER['HTTP_ACCEPT_ENCODING'])));
70
+			}
69 71
 			
70 72
 			// desactivate gzip for IE version < 7
71 73
 			if(preg_match("/(?:msie )([0-9.]+)/i", $_SERVER['HTTP_USER_AGENT'], $ie))
72 74
 			{
73
-				if($ie[1]<7)
74
-					$desactivate_gzip=true;	
75
+				if($ie[1]<7) {
76
+									$desactivate_gzip=true;
77
+				}
75 78
 			}
76 79
 			
77 80
 			// Check for gzip header or northon internet securities
@@ -79,7 +82,7 @@  discard block
 block discarded – undo
79 82
 				$this->gzip_enc_header= in_array('x-gzip', $encodings) ? "x-gzip" : "gzip";
80 83
 				$this->use_gzip=true;
81 84
 				$this->cache_file=$this->gzip_cache_file;
82
-			}else{
85
+			} else{
83 86
 				$this->use_gzip=false;
84 87
 				$this->cache_file=$this->full_cache_file;
85 88
 			}
@@ -93,8 +96,9 @@  discard block
 block discarded – undo
93 96
 				$cache_date=0;				
94 97
 				if ($dir = opendir($this->path)) {
95 98
 					while (($file = readdir($dir)) !== false) {
96
-						if(is_file($this->path.$file) && $file!="." && $file!="..")
97
-							$cache_date= max($cache_date, filemtime($this->path.$file));
99
+						if(is_file($this->path.$file) && $file!="." && $file!="..") {
100
+													$cache_date= max($cache_date, filemtime($this->path.$file));
101
+						}
98 102
 					}
99 103
 					closedir($dir);
100 104
 				}
@@ -106,8 +110,9 @@  discard block
 block discarded – undo
106 110
 						{
107 111
 							if ($file !== "." && $file !== "..")
108 112
 							{
109
-								if(is_dir($plug_path.$file) && file_exists($plug_path.$file."/".$file.".js"))
110
-									$cache_date= max($cache_date, filemtime("plugins/".$file."/".$file.".js"));
113
+								if(is_dir($plug_path.$file) && file_exists($plug_path.$file."/".$file.".js")) {
114
+																	$cache_date= max($cache_date, filemtime("plugins/".$file."/".$file.".js"));
115
+								}
111 116
 							}
112 117
 						}
113 118
 						closedir($dir);
@@ -123,8 +128,7 @@  discard block
 block discarded – undo
123 128
 						header("Last-modified: ".$last_modified);
124 129
 						header("Cache-Control: Public"); // Tells HTTP 1.1 clients to cache
125 130
 						header("Pragma:"); // Tells HTTP 1.0 clients to cache
126
-					}
127
-					else
131
+					} else
128 132
 					{
129 133
 						header("Last-modified: ".$last_modified);
130 134
 						header("Cache-Control: Public"); // Tells HTTP 1.1 clients to cache
@@ -207,8 +211,9 @@  discard block
 block discarded – undo
207 211
 					{
208 212
 						if ($file !== "." && $file !== "..")
209 213
 						{
210
-							if(is_dir($plug_path.$file) && file_exists($plug_path.$file."/".$file.".js"))
211
-								$sub_scripts_list[]= "plugins/".$file."/".$file.".js";
214
+							if(is_dir($plug_path.$file) && file_exists($plug_path.$file."/".$file.".js")) {
215
+															$sub_scripts_list[]= "plugins/".$file."/".$file.".js";
216
+							}
212 217
 						}
213 218
 					}
214 219
 					closedir($dir);
@@ -247,22 +252,23 @@  discard block
 block discarded – undo
247 252
 									'Î' => '"',
248 253
 								 'Ï' => "\n",
249 254
 								 'À' => "\r"*/);
250
-			}
251
-			else
255
+			} else
252 256
 			{
253 257
 				$last_comp	= array();
254 258
 			}
255 259
 			
256 260
 			$js_replace= '';
257
-			foreach( $last_comp as $key => $val )
258
-				$js_replace .= ".replace(/". $key ."/g,'". str_replace( array("\n", "\r"), array('\n','\r'), $val ) ."')";
261
+			foreach( $last_comp as $key => $val ) {
262
+							$js_replace .= ".replace(/". $key ."/g,'". str_replace( array("\n", "\r"), array('\n','\r'), $val ) ."')";
263
+			}
259 264
 			
260 265
 			$this->datas.= sprintf("editAreaLoader.iframe_script= \"<script type='text/javascript'>%s</script>\"%s;\n",
261 266
 								str_replace( array_values($last_comp), array_keys($last_comp), $sub_scripts ), 
262 267
 								$js_replace);
263 268
 			
264
-			if($this->load_all_plugins)
265
-				$this->datas.="editAreaLoader.all_plugins_loaded=true;\n";
269
+			if($this->load_all_plugins) {
270
+							$this->datas.="editAreaLoader.all_plugins_loaded=true;\n";
271
+			}
266 272
 		
267 273
 			
268 274
 			// load the template
@@ -283,7 +289,7 @@  discard block
 block discarded – undo
283 289
 					$gzip_datas=  gzencode($this->datas, 9, FORCE_GZIP);				
284 290
 					$header.=sprintf("=> GZIP COMPRESSION => %s", strlen($gzip_datas));
285 291
 					$ratio = round(100 - strlen($gzip_datas) / $this->file_loaded_size * 100.0);			
286
-				}else{
292
+				} else{
287 293
 					$ratio = round(100 - strlen($this->datas) / $this->file_loaded_size * 100.0);
288 294
 				}
289 295
 				$header.=sprintf(", reduced by %s%%\n", $ratio);
@@ -296,19 +302,22 @@  discard block
 block discarded – undo
296 302
 			// generate gzip file and cahce it if using disk cache
297 303
 			if($this->use_gzip){
298 304
 				$this->gzip_datas= gzencode($this->datas, 9, FORCE_GZIP);
299
-				if($this->param['use_disk_cache'])
300
-					$this->file_put_contents($this->gzip_cache_file, $this->gzip_datas, $mtime);
305
+				if($this->param['use_disk_cache']) {
306
+									$this->file_put_contents($this->gzip_cache_file, $this->gzip_datas, $mtime);
307
+				}
301 308
 			}
302 309
 			
303 310
 			// generate full js file and cache it if using disk cache			
304
-			if($this->param['use_disk_cache'])
305
-				$this->file_put_contents($this->full_cache_file, $this->datas, $mtime);
311
+			if($this->param['use_disk_cache']) {
312
+							$this->file_put_contents($this->full_cache_file, $this->datas, $mtime);
313
+			}
306 314
 			
307 315
 			// generate output
308
-			if($this->use_gzip)
309
-				echo $this->gzip_datas;
310
-			else
311
-				echo $this->datas;
316
+			if($this->use_gzip) {
317
+							echo $this->gzip_datas;
318
+			} else {
319
+							echo $this->datas;
320
+			}
312 321
 				
313 322
 //			die;
314 323
 		}
@@ -325,7 +334,7 @@  discard block
 block discarded – undo
325 334
 				fclose($fd);
326 335
 				return $content;*/
327 336
 				return $this->file_get_contents($file);
328
-			}else{
337
+			} else{
329 338
 				$this->infos[]=sprintf("'%s' not loaded", $end_uri);
330 339
 				return "";
331 340
 			}
@@ -382,10 +391,11 @@  discard block
 block discarded – undo
382 391
 			/*$pattern= array("/(\\\\)?\"/", '/\\\n/'	, '/\\\r/'	, "/(\r?\n)/");
383 392
 			$replace= array('$1$1\\"', '\\\\\\n', '\\\\\\r'	, '\\\n"$1+"');*/
384 393
 			$pattern= array("/(\\\\)?\"/", '/\\\n/'	, '/\\\r/'	, "/(\r?\n)/");
385
-			if($this->param['compress'])
386
-				$replace= array('$1$1\\"', '\\\\\\n', '\\\\\\r'	, '\n');
387
-			else
388
-				$replace= array('$1$1\\"', '\\\\\\n', '\\\\\\r'	, "\\n\"\n+\"");
394
+			if($this->param['compress']) {
395
+							$replace= array('$1$1\\"', '\\\\\\n', '\\\\\\r'	, '\n');
396
+			} else {
397
+							$replace= array('$1$1\\"', '\\\\\\n', '\\\\\\r'	, "\\n\"\n+\"");
398
+			}
389 399
 			$str= preg_replace($pattern, $replace, $str);
390 400
 		}
391 401
 		
@@ -407,8 +417,9 @@  discard block
 block discarded – undo
407 417
 		
408 418
 		function file_put_contents($file, &$content, $mtime=-1)
409 419
 		{
410
-			if($mtime==-1)
411
-				$mtime=time();
420
+			if($mtime==-1) {
421
+							$mtime=time();
422
+			}
412 423
 			$fp = @fopen($file, "wb");
413 424
 			if ($fp) {
414 425
 				fwrite($fp, $content);
Please login to merge, or discard this patch.
src/views/default/type_components/radio/component_detail.blade.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,9 @@
 block discarded – undo
30 30
                 break;
31 31
             }
32 32
         }
33
-        if (! $value) $value = [];
33
+        if (! $value) {
34
+            $value = [];
35
+        }
34 36
     }
35 37
 } else {
36 38
     $value = explode(";", $value);
Please login to merge, or discard this patch.
src/views/default/type_components/radio/component.blade.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -68,7 +68,9 @@
 block discarded – undo
68 68
 
69 69
             foreach ($selects_data as $d) {
70 70
                 $val = $d->{$select_field_alias};
71
-                if ($val == '' || ! $d->id) continue;
71
+                if ($val == '' || ! $d->id) {
72
+                    continue;
73
+                }
72 74
 
73 75
                 $checked = ($value == $d->id) ? "checked" : "";
74 76
 
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
                 } else {
26 26
                     $val = $label = $d;
27 27
                 }
28
-				$checked = ( ($value && in_array($val, $value)) || (CRUDBooster::isCreate() && ($k==0 && $form['validation'])) ) ? "checked" : "";
28
+                $checked = ( ($value && in_array($val, $value)) || (CRUDBooster::isCreate() && ($k==0 && $form['validation'])) ) ? "checked" : "";
29 29
                 ?>
30 30
                 <div class=" {{$disabled}}">
31 31
                     <label class='radio-inline'>
Please login to merge, or discard this patch.
src/fonts/Fontawesome.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -2,8 +2,8 @@  discard block
 block discarded – undo
2 2
 namespace crocodicstudio\crudbooster\fonts;
3 3
 
4 4
 class Fontawesome {
5
-	public static function getIcons() {
6
-		return [
5
+    public static function getIcons() {
6
+        return [
7 7
             "glass",
8 8
             "music",
9 9
             "search",
@@ -699,5 +699,5 @@  discard block
 block discarded – undo
699 699
             "bluetooth-b",
700 700
             "percent",
701 701
         ];
702
-	}
702
+    }
703 703
 }
704 704
\ No newline at end of file
Please login to merge, or discard this patch.
src/helpers/CRUDBooster.php 1 patch
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
 class CRUDBooster
16 16
 {
17 17
     /**
18
-    *	Comma-delimited data output from the child table
19
-    */
18
+     *	Comma-delimited data output from the child table
19
+     */
20 20
     public static function echoSelect2Mult($values, $table, $id, $name) {
21 21
         $values = explode(",", $values);
22 22
         return implode(", ", DB::table($table)->whereIn($id, $values)->pluck($name)->toArray());
@@ -43,13 +43,13 @@  discard block
 block discarded – undo
43 43
         @$mime_type = $mime_type[1];
44 44
         if ($mime_type) {
45 45
             $filePath = 'uploads/'.$userID.'/'.date('Y-m');
46
-		Storage::makeDirectory($filePath);
47
-		$filename = md5(str_random(5)).'.'.$mime_type;
48
-		if (Storage::put($filePath.'/'.$filename, $filedata)) {
49
-		    self::resizeImage($filePath.'/'.$filename);
46
+        Storage::makeDirectory($filePath);
47
+        $filename = md5(str_random(5)).'.'.$mime_type;
48
+        if (Storage::put($filePath.'/'.$filename, $filedata)) {
49
+            self::resizeImage($filePath.'/'.$filename);
50 50
 
51
-		    return $filePath.'/'.$filename;
52
-		}
51
+            return $filePath.'/'.$filename;
52
+        }
53 53
         }
54 54
     }
55 55
 
@@ -374,17 +374,17 @@  discard block
 block discarded – undo
374 374
 
375 375
     public static function getCurrentModule()
376 376
     {
377
-	$modulepath = self::getModulePath();
377
+    $modulepath = self::getModulePath();
378 378
 
379
-	if (Cache::has('moduls_'.$modulepath)) {
380
-	    return Cache::get('moduls_'.$modulepath);
381
-	} else {
379
+    if (Cache::has('moduls_'.$modulepath)) {
380
+        return Cache::get('moduls_'.$modulepath);
381
+    } else {
382 382
 
383
-	    $module = DB::table('cms_moduls')->where('path', self::getModulePath())->first();
383
+        $module = DB::table('cms_moduls')->where('path', self::getModulePath())->first();
384 384
 	    
385
-	    //supply modulpath instead of $module incase where user decides to create form and custom url that does not exist in cms_moduls table.
386
-	    return ($module)?:$modulepath; 
387
-	}
385
+        //supply modulpath instead of $module incase where user decides to create form and custom url that does not exist in cms_moduls table.
386
+        return ($module)?:$modulepath; 
387
+    }
388 388
     }
389 389
 
390 390
     public static function getCurrentDashboardId()
@@ -526,22 +526,22 @@  discard block
 block discarded – undo
526 526
 
527 527
     public static function getModulePath()
528 528
     {
529
-          // Check to position of admin_path
530
-          if(config("crudbooster.ADMIN_PATH")) {
531
-              $adminPathSegments = explode('/', Request::path());
532
-              $no = 1;
533
-              foreach($adminPathSegments as $path) {
534
-                  if($path == config("crudbooster.ADMIN_PATH")) {
535
-                      $segment = $no+1;
536
-                      break;
537
-                  }
538
-                  $no++;
539
-              }
540
-          } else {
541
-              $segment = 1;
542
-          }
543
-
544
-          return Request::segment($segment);
529
+            // Check to position of admin_path
530
+            if(config("crudbooster.ADMIN_PATH")) {
531
+                $adminPathSegments = explode('/', Request::path());
532
+                $no = 1;
533
+                foreach($adminPathSegments as $path) {
534
+                    if($path == config("crudbooster.ADMIN_PATH")) {
535
+                        $segment = $no+1;
536
+                        break;
537
+                    }
538
+                    $no++;
539
+                }
540
+            } else {
541
+                $segment = 1;
542
+            }
543
+
544
+            return Request::segment($segment);
545 545
     }	
546 546
 
547 547
     public static function mainpath($path = null)
@@ -937,19 +937,19 @@  discard block
 block discarded – undo
937 937
 //         }
938 938
 //     }
939 939
 
940
-	public static function findPrimaryKey($table)
941
-	{
942
-		if(!$table)
943
-		{
944
-			return 'id';
945
-		}
940
+    public static function findPrimaryKey($table)
941
+    {
942
+        if(!$table)
943
+        {
944
+            return 'id';
945
+        }
946 946
 		
947
-		$pk = DB::getDoctrineSchemaManager()->listTableDetails($table)->getPrimaryKey();
948
-		if(!$pk) {
949
-		    return null;
950
-		}
951
-		return $pk->getColumns()[0];	
952
-	}
947
+        $pk = DB::getDoctrineSchemaManager()->listTableDetails($table)->getPrimaryKey();
948
+        if(!$pk) {
949
+            return null;
950
+        }
951
+        return $pk->getColumns()[0];	
952
+    }
953 953
 
954 954
     public static function newId($table)
955 955
     {
Please login to merge, or discard this patch.
src/controllers/CBController.php 1 patch
Braces   +7 added lines, -4 removed lines patch added patch discarded remove patch
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
                     $columns_table[$index]['type_data'] = CRUDBooster::getFieldType($table, $field);
364 364
                     $columns_table[$index]['field'] = $table.'_'.$field;
365 365
                     $columns_table[$index]['field_raw'] = $table.'.'.$field;
366
-                }else{
366
+                } else{
367 367
                     $result->addselect($table.'.'.$field);
368 368
                     $columns_table[$index]['type_data'] = CRUDBooster::getFieldType($table, $field);
369 369
                     $columns_table[$index]['field'] = $field;
@@ -1154,8 +1154,9 @@  discard block
 block discarded – undo
1154 1154
         $lastInsertId = $id = DB::table($this->table)->insertGetId($this->arr);
1155 1155
         
1156 1156
         //fix bug if primary key is uuid
1157
-        if($this->arr[$this->primary_key]!=$id)
1158
-            $id = $this->arr[$this->primary_key];
1157
+        if($this->arr[$this->primary_key]!=$id) {
1158
+                    $id = $this->arr[$this->primary_key];
1159
+        }
1159 1160
         
1160 1161
         //Looping Data Input Again After Insert
1161 1162
         foreach ($this->data_inputan as $ro) {
@@ -1350,7 +1351,9 @@  discard block
 block discarded – undo
1350 1351
                 }
1351 1352
                 if ($ro['relationship_table'] && $ro["datatable_orig"] != "") {
1352 1353
                     $params = explode("|", $ro['datatable_orig']);
1353
-                    if(!isset($params[2])) $params[2] = "id";
1354
+                    if(!isset($params[2])) {
1355
+                        $params[2] = "id";
1356
+                    }
1354 1357
                     DB::table($params[0])->where($params[2], $id)->update([$params[1] => implode(",",$inputdata)]);
1355 1358
                 }
1356 1359
             }
Please login to merge, or discard this patch.
src/views/module_generator/step3.blade.php 1 patch
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -502,22 +502,28 @@
 block discarded – undo
502 502
 
503 503
                                     </div>
504 504
 
505
-                                    <?php else:?>
505
+                                    <?php else {
506
+    :?>
506 507
 
507 508
                                     <div class="form-group">
508 509
                                         <label>{{$key}}</label>
509 510
                                         <input type="text" name="option[{{$index}}][{{$key}}]" placeholder="{{$val->placeholder}}" value="{{$value}}"
510 511
                                                class="form-control">
511 512
                                     </div>
512
-                                    <?php endif;?>
513
-                                    <?php else:?>
513
+                                    <?php endif;
514
+}
515
+?>
516
+                                    <?php else {
517
+    :?>
514 518
 
515 519
                                     <div class="form-group">
516 520
                                         <label>{{$key}}</label>
517 521
                                         <input type="text" name="option[{{$index}}][{{$key}}]" placeholder="{{$val}}" value="{{$value}}" class="form-control">
518 522
                                     </div>
519 523
 
520
-                                    <?php endif;?>
524
+                                    <?php endif;
525
+}
526
+?>
521 527
                                     <?php endforeach; endif;?>
522 528
 
523 529
 
Please login to merge, or discard this patch.
src/localization/ru/crudbooster.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -268,5 +268,5 @@
 block discarded – undo
268 268
     'please_complete_the_form' =>'Пожалуйста заполните форму !',
269 269
     'this_field_is_required'   =>'Это поле обязательное',
270 270
     'text_form'                => 'Форма',
271
-     "your_file_extension_is_not_allowed "=>"Тип фашего файла не поддерживается !",
271
+        "your_file_extension_is_not_allowed "=>"Тип фашего файла не поддерживается !",
272 272
 ];
Please login to merge, or discard this patch.
src/controllers/ApiController.php 1 patch
Braces   +5 added lines, -3 removed lines patch added patch discarded remove patch
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
                 try{
592 592
                     $id = DB::table($table)->insertGetId($row_assign);
593 593
                     DB::commit();
594
-                }catch (\Exception $e)
594
+                } catch (\Exception $e)
595 595
                 {
596 596
                     DB::rollBack();
597 597
                     throw new \Exception($e->getMessage());
@@ -658,11 +658,13 @@  discard block
 block discarded – undo
658 658
         }
659 659
 
660 660
         $this->hook_after($posts, $result);
661
-        if($this->output) return response()->json($this->output);
661
+        if($this->output) {
662
+            return response()->json($this->output);
663
+        }
662 664
 
663 665
         if($output == 'JSON') {
664 666
             return response()->json($result, 200);    
665
-        }else{
667
+        } else{
666 668
             return $result;
667 669
         }        
668 670
     }
Please login to merge, or discard this patch.