@@ -46,9 +46,9 @@ discard block |
||
46 | 46 | $uh = new UpgradeHistory(); |
47 | 47 | |
48 | 48 | function unlinkTempFiles() { |
49 | - global $sugar_config; |
|
50 | - @unlink($_FILES['upgrade_zip']['tmp_name']); |
|
51 | - @unlink("upload://".$_FILES['upgrade_zip']['name']); |
|
49 | + global $sugar_config; |
|
50 | + @unlink($_FILES['upgrade_zip']['tmp_name']); |
|
51 | + @unlink("upload://".$_FILES['upgrade_zip']['name']); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | $base_upgrade_dir = "upload://upgrades"; |
@@ -63,15 +63,15 @@ discard block |
||
63 | 63 | |
64 | 64 | // get labels and text that are specific to either Module Loader or Upgrade Wizard |
65 | 65 | if( $view == "module") { |
66 | - $uploaddLabel = $mod_strings['LBL_UW_UPLOAD_MODULE']; |
|
67 | - $descItemsQueued = $mod_strings['LBL_UW_DESC_MODULES_QUEUED']; |
|
68 | - $descItemsInstalled = $mod_strings['LBL_UW_DESC_MODULES_INSTALLED']; |
|
66 | + $uploaddLabel = $mod_strings['LBL_UW_UPLOAD_MODULE']; |
|
67 | + $descItemsQueued = $mod_strings['LBL_UW_DESC_MODULES_QUEUED']; |
|
68 | + $descItemsInstalled = $mod_strings['LBL_UW_DESC_MODULES_INSTALLED']; |
|
69 | 69 | } |
70 | 70 | else { |
71 | 71 | |
72 | - $uploaddLabel = $mod_strings['LBL_UPLOAD_UPGRADE']; |
|
73 | - $descItemsQueued = $mod_strings['DESC_FILES_QUEUED']; |
|
74 | - $descItemsInstalled = $mod_strings['DESC_FILES_INSTALLED']; |
|
72 | + $uploaddLabel = $mod_strings['LBL_UPLOAD_UPGRADE']; |
|
73 | + $descItemsQueued = $mod_strings['DESC_FILES_QUEUED']; |
|
74 | + $descItemsInstalled = $mod_strings['DESC_FILES_INSTALLED']; |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | // |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | $upload_max_filesize_bytes = return_bytes($upload_max_filesize); |
85 | 85 | if($upload_max_filesize_bytes < constant('SUGARCRM_MIN_UPLOAD_MAX_FILESIZE_BYTES')) |
86 | 86 | { |
87 | - $GLOBALS['log']->debug("detected upload_max_filesize: $upload_max_filesize"); |
|
88 | - print('<p class="error">' . $mod_strings['MSG_INCREASE_UPLOAD_MAX_FILESIZE'] . ' ' |
|
89 | - . get_cfg_var('cfg_file_path') . "</p>\n"); |
|
87 | + $GLOBALS['log']->debug("detected upload_max_filesize: $upload_max_filesize"); |
|
88 | + print('<p class="error">' . $mod_strings['MSG_INCREASE_UPLOAD_MAX_FILESIZE'] . ' ' |
|
89 | + . get_cfg_var('cfg_file_path') . "</p>\n"); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | // |
@@ -105,10 +105,10 @@ discard block |
||
105 | 105 | $perform = true; |
106 | 106 | $base_filename = urldecode($tempFile); |
107 | 107 | } elseif(!empty($_REQUEST['load_module_from_dir'])) { |
108 | - //copy file to proper location then call performSetup |
|
109 | - copy($_REQUEST['load_module_from_dir'].'/'.$_REQUEST['upgrade_zip_escaped'], "upload://".$_REQUEST['upgrade_zip_escaped']); |
|
108 | + //copy file to proper location then call performSetup |
|
109 | + copy($_REQUEST['load_module_from_dir'].'/'.$_REQUEST['upgrade_zip_escaped'], "upload://".$_REQUEST['upgrade_zip_escaped']); |
|
110 | 110 | |
111 | - $perform = true; |
|
111 | + $perform = true; |
|
112 | 112 | $base_filename = urldecode( $_REQUEST['upgrade_zip_escaped'] ); |
113 | 113 | } else { |
114 | 114 | if( empty( $_FILES['upgrade_zip']['tmp_name'] ) ){ |
@@ -119,72 +119,72 @@ discard block |
||
119 | 119 | strtolower(pathinfo($upload->get_stored_file_name(), PATHINFO_EXTENSION)) != 'zip' || |
120 | 120 | !$upload->final_move($upload->get_stored_file_name()) |
121 | 121 | ) { |
122 | - unlinkTempFiles(); |
|
122 | + unlinkTempFiles(); |
|
123 | 123 | sugar_die("Invalid Package"); |
124 | - } else { |
|
125 | - $tempFile = "upload://".$upload->get_stored_file_name(); |
|
126 | - $perform = true; |
|
127 | - $base_filename = urldecode( $_REQUEST['upgrade_zip_escaped'] ); |
|
128 | - } |
|
124 | + } else { |
|
125 | + $tempFile = "upload://".$upload->get_stored_file_name(); |
|
126 | + $perform = true; |
|
127 | + $base_filename = urldecode( $_REQUEST['upgrade_zip_escaped'] ); |
|
128 | + } |
|
129 | 129 | } |
130 | 130 | } |
131 | 131 | if($perform) { |
132 | 132 | $manifest_file = extractManifest( $tempFile ); |
133 | - if(is_file($manifest_file)) |
|
134 | - { |
|
135 | - //SCAN THE MANIFEST FILE TO MAKE SURE NO COPIES OR ANYTHING ARE HAPPENING IN IT |
|
136 | - $ms = new ModuleScanner(); |
|
137 | - $ms->lockConfig(); |
|
138 | - $fileIssues = $ms->scanFile($manifest_file); |
|
139 | - if(!empty($fileIssues)){ |
|
140 | - echo '<h2>' . $mod_strings['ML_MANIFEST_ISSUE'] . '</h2><br>'; |
|
141 | - $ms->displayIssues(); |
|
142 | - die(); |
|
143 | - } |
|
144 | - list($manifest, $installdefs) = MSLoadManifest($manifest_file); |
|
145 | - if($ms->checkConfig($manifest_file)) { |
|
146 | - echo '<h2>' . $mod_strings['ML_MANIFEST_ISSUE'] . '</h2><br>'; |
|
147 | - $ms->displayIssues(); |
|
148 | - die(); |
|
149 | - } |
|
150 | - validate_manifest( $manifest ); |
|
151 | - |
|
152 | - $upgrade_zip_type = $manifest['type']; |
|
153 | - |
|
154 | - // exclude the bad permutations |
|
155 | - if( $view == "module" ) { |
|
156 | - if ($upgrade_zip_type != "module" && $upgrade_zip_type != "theme" && $upgrade_zip_type != "langpack") { |
|
157 | - unlinkTempFiles(); |
|
158 | - die($mod_strings['ERR_UW_NOT_ACCEPTIBLE_TYPE']); |
|
159 | - } |
|
160 | - } elseif( $view == "default" ) { |
|
161 | - if($upgrade_zip_type != "patch" ) { |
|
162 | - unlinkTempFiles(); |
|
163 | - die($mod_strings['ERR_UW_ONLY_PATCHES']); |
|
164 | - } |
|
165 | - } |
|
166 | - |
|
167 | - $base_filename = pathinfo($tempFile, PATHINFO_BASENAME); |
|
168 | - |
|
169 | - mkdir_recursive( "$base_upgrade_dir/$upgrade_zip_type" ); |
|
170 | - $target_path = "$base_upgrade_dir/$upgrade_zip_type/$base_filename"; |
|
171 | - $target_manifest = remove_file_extension( $target_path ) . "-manifest.php"; |
|
172 | - |
|
173 | - if( isset($manifest['icon']) && $manifest['icon'] != "" ){ |
|
174 | - $icon_location = extractFile( $tempFile ,$manifest['icon'] ); |
|
175 | - copy($icon_location, remove_file_extension( $target_path )."-icon.".pathinfo($icon_location, PATHINFO_EXTENSION)); |
|
176 | - } |
|
177 | - |
|
178 | - if(rename( $tempFile , $target_path )) { |
|
179 | - copy( $manifest_file, $target_manifest ); |
|
180 | - $GLOBALS['ML_STATUS_MESSAGE'] = $base_filename.$mod_strings['LBL_UW_UPLOAD_SUCCESS']; |
|
133 | + if(is_file($manifest_file)) |
|
134 | + { |
|
135 | + //SCAN THE MANIFEST FILE TO MAKE SURE NO COPIES OR ANYTHING ARE HAPPENING IN IT |
|
136 | + $ms = new ModuleScanner(); |
|
137 | + $ms->lockConfig(); |
|
138 | + $fileIssues = $ms->scanFile($manifest_file); |
|
139 | + if(!empty($fileIssues)){ |
|
140 | + echo '<h2>' . $mod_strings['ML_MANIFEST_ISSUE'] . '</h2><br>'; |
|
141 | + $ms->displayIssues(); |
|
142 | + die(); |
|
143 | + } |
|
144 | + list($manifest, $installdefs) = MSLoadManifest($manifest_file); |
|
145 | + if($ms->checkConfig($manifest_file)) { |
|
146 | + echo '<h2>' . $mod_strings['ML_MANIFEST_ISSUE'] . '</h2><br>'; |
|
147 | + $ms->displayIssues(); |
|
148 | + die(); |
|
149 | + } |
|
150 | + validate_manifest( $manifest ); |
|
151 | + |
|
152 | + $upgrade_zip_type = $manifest['type']; |
|
153 | + |
|
154 | + // exclude the bad permutations |
|
155 | + if( $view == "module" ) { |
|
156 | + if ($upgrade_zip_type != "module" && $upgrade_zip_type != "theme" && $upgrade_zip_type != "langpack") { |
|
157 | + unlinkTempFiles(); |
|
158 | + die($mod_strings['ERR_UW_NOT_ACCEPTIBLE_TYPE']); |
|
159 | + } |
|
160 | + } elseif( $view == "default" ) { |
|
161 | + if($upgrade_zip_type != "patch" ) { |
|
162 | + unlinkTempFiles(); |
|
163 | + die($mod_strings['ERR_UW_ONLY_PATCHES']); |
|
164 | + } |
|
165 | + } |
|
166 | + |
|
167 | + $base_filename = pathinfo($tempFile, PATHINFO_BASENAME); |
|
168 | + |
|
169 | + mkdir_recursive( "$base_upgrade_dir/$upgrade_zip_type" ); |
|
170 | + $target_path = "$base_upgrade_dir/$upgrade_zip_type/$base_filename"; |
|
171 | + $target_manifest = remove_file_extension( $target_path ) . "-manifest.php"; |
|
172 | + |
|
173 | + if( isset($manifest['icon']) && $manifest['icon'] != "" ){ |
|
174 | + $icon_location = extractFile( $tempFile ,$manifest['icon'] ); |
|
175 | + copy($icon_location, remove_file_extension( $target_path )."-icon.".pathinfo($icon_location, PATHINFO_EXTENSION)); |
|
176 | + } |
|
177 | + |
|
178 | + if(rename( $tempFile , $target_path )) { |
|
179 | + copy( $manifest_file, $target_manifest ); |
|
180 | + $GLOBALS['ML_STATUS_MESSAGE'] = $base_filename.$mod_strings['LBL_UW_UPLOAD_SUCCESS']; |
|
181 | 181 | } else{ |
182 | - $GLOBALS['ML_STATUS_MESSAGE'] = $mod_strings['ERR_UW_UPLOAD_ERROR']; |
|
183 | - } |
|
184 | - } else { |
|
185 | - unlinkTempFiles(); |
|
186 | - die($mod_strings['ERR_UW_NO_MANIFEST']); |
|
187 | - } |
|
182 | + $GLOBALS['ML_STATUS_MESSAGE'] = $mod_strings['ERR_UW_UPLOAD_ERROR']; |
|
183 | + } |
|
184 | + } else { |
|
185 | + unlinkTempFiles(); |
|
186 | + die($mod_strings['ERR_UW_NO_MANIFEST']); |
|
187 | + } |
|
188 | 188 | } |
189 | 189 | } else if( $run == $mod_strings['LBL_UW_BTN_DELETE_PACKAGE'] ){ |
190 | 190 | if(!empty ($_REQUEST['install_file']) ){ |
@@ -199,36 +199,36 @@ discard block |
||
199 | 199 | strpos($checkFile, "..") !== false || !file_exists($checkFile)) { |
200 | 200 | die("<span class='error'>File is not a zipped archive.</span>"); |
201 | 201 | } |
202 | - if(unlink($delete_me)) { // successful deletion? |
|
203 | - echo "Package $delete_me has been removed.<br>"; |
|
204 | - } else { |
|
205 | - die("Problem removing package $delete_me."); |
|
206 | - } |
|
202 | + if(unlink($delete_me)) { // successful deletion? |
|
203 | + echo "Package $delete_me has been removed.<br>"; |
|
204 | + } else { |
|
205 | + die("Problem removing package $delete_me."); |
|
206 | + } |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 | |
210 | 210 | if( $view == "module") { |
211 | - print( getClassicModuleTitle($mod_strings['LBL_MODULE_NAME'], array($mod_strings['LBL_MODULE_LOADER_TITLE']), false) ); |
|
211 | + print( getClassicModuleTitle($mod_strings['LBL_MODULE_NAME'], array($mod_strings['LBL_MODULE_LOADER_TITLE']), false) ); |
|
212 | 212 | } |
213 | 213 | else { |
214 | - print( getClassicModuleTitle($mod_strings['LBL_MODULE_NAME'], array($mod_strings['LBL_MODULE_NAME'],$mod_strings['LBL_UPGRADE_WIZARD_TITLE']), false) ); |
|
214 | + print( getClassicModuleTitle($mod_strings['LBL_MODULE_NAME'], array($mod_strings['LBL_MODULE_NAME'],$mod_strings['LBL_UPGRADE_WIZARD_TITLE']), false) ); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | // upload link |
218 | 218 | if(!empty($GLOBALS['sugar_config']['use_common_ml_dir']) && $GLOBALS['sugar_config']['use_common_ml_dir'] && !empty($GLOBALS['sugar_config']['common_ml_dir'])){ |
219 | - //rrs |
|
220 | - $form = '<form name="move_form" action="index.php?module=Administration&view=module&action=UpgradeWizard" method="post" ><input type=hidden name="run" value="upload" /><input type=hidden name="load_module_from_dir" id="load_module_from_dir" value="'.$GLOBALS['sugar_config']['common_ml_dir'].'" /><input type=hidden name="upgrade_zip_escaped" value="" />'; |
|
221 | - $form .= '<br>'.$mod_strings['LBL_MODULE_UPLOAD_DISABLE_HELP_TEXT'].'</br>'; |
|
222 | - $form .='<table width="100%" class="edit view"><tr><th align="left">'.$mod_strings['LBL_ML_NAME'].'</th><th align="left">'.$mod_strings['LBL_ML_ACTION'].'</th></tr>'; |
|
223 | - if ($handle = opendir($GLOBALS['sugar_config']['common_ml_dir'])) { |
|
224 | - while (false !== ($filename = readdir($handle))) { |
|
225 | - if($filename == '.' || $filename == '..' || !preg_match("#.*\.zip\$#", $filename)) { |
|
219 | + //rrs |
|
220 | + $form = '<form name="move_form" action="index.php?module=Administration&view=module&action=UpgradeWizard" method="post" ><input type=hidden name="run" value="upload" /><input type=hidden name="load_module_from_dir" id="load_module_from_dir" value="'.$GLOBALS['sugar_config']['common_ml_dir'].'" /><input type=hidden name="upgrade_zip_escaped" value="" />'; |
|
221 | + $form .= '<br>'.$mod_strings['LBL_MODULE_UPLOAD_DISABLE_HELP_TEXT'].'</br>'; |
|
222 | + $form .='<table width="100%" class="edit view"><tr><th align="left">'.$mod_strings['LBL_ML_NAME'].'</th><th align="left">'.$mod_strings['LBL_ML_ACTION'].'</th></tr>'; |
|
223 | + if ($handle = opendir($GLOBALS['sugar_config']['common_ml_dir'])) { |
|
224 | + while (false !== ($filename = readdir($handle))) { |
|
225 | + if($filename == '.' || $filename == '..' || !preg_match("#.*\.zip\$#", $filename)) { |
|
226 | 226 | continue; |
227 | 227 | } |
228 | - $form .= '<tr><td>'.$filename.'</td><td><input type=button class="button" value="'.$mod_strings['LBL_UW_BTN_UPLOAD'].'" onClick="document.move_form.upgrade_zip_escaped.value = escape( \''.$filename.'\');document.move_form.submit();" /></td></tr>'; |
|
229 | - } |
|
230 | - } |
|
231 | - $form .= '</table></form>'; |
|
228 | + $form .= '<tr><td>'.$filename.'</td><td><input type=button class="button" value="'.$mod_strings['LBL_UW_BTN_UPLOAD'].'" onClick="document.move_form.upgrade_zip_escaped.value = escape( \''.$filename.'\');document.move_form.submit();" /></td></tr>'; |
|
229 | + } |
|
230 | + } |
|
231 | + $form .= '</table></form>'; |
|
232 | 232 | //rrs |
233 | 233 | |
234 | 234 | }else{ |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
3 | 3 | /********************************************************************************* |
4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -55,14 +55,14 @@ discard block |
||
55 | 55 | $base_tmp_upgrade_dir = sugar_cached('upgrades/temp'); |
56 | 56 | |
57 | 57 | // make sure dirs exist |
58 | -foreach( $GLOBALS['subdirs'] as $subdir ){ |
|
59 | - if(!file_exists("$base_upgrade_dir/$subdir")) { |
|
58 | +foreach ($GLOBALS['subdirs'] as $subdir) { |
|
59 | + if (!file_exists("$base_upgrade_dir/$subdir")) { |
|
60 | 60 | sugar_mkdir("$base_upgrade_dir/$subdir", 0770, true); |
61 | 61 | } |
62 | 62 | } |
63 | 63 | |
64 | 64 | // get labels and text that are specific to either Module Loader or Upgrade Wizard |
65 | -if( $view == "module") { |
|
65 | +if ($view == "module") { |
|
66 | 66 | $uploaddLabel = $mod_strings['LBL_UW_UPLOAD_MODULE']; |
67 | 67 | $descItemsQueued = $mod_strings['LBL_UW_DESC_MODULES_QUEUED']; |
68 | 68 | $descItemsInstalled = $mod_strings['LBL_UW_DESC_MODULES_INSTALLED']; |
@@ -78,44 +78,44 @@ discard block |
||
78 | 78 | // check that the upload limit is set to 6M or greater |
79 | 79 | // |
80 | 80 | |
81 | -define('SUGARCRM_MIN_UPLOAD_MAX_FILESIZE_BYTES', 6 * 1024 * 1024); // 6 Megabytes |
|
81 | +define('SUGARCRM_MIN_UPLOAD_MAX_FILESIZE_BYTES', 6 * 1024 * 1024); // 6 Megabytes |
|
82 | 82 | |
83 | 83 | $upload_max_filesize = ini_get('upload_max_filesize'); |
84 | 84 | $upload_max_filesize_bytes = return_bytes($upload_max_filesize); |
85 | -if($upload_max_filesize_bytes < constant('SUGARCRM_MIN_UPLOAD_MAX_FILESIZE_BYTES')) |
|
85 | +if ($upload_max_filesize_bytes < constant('SUGARCRM_MIN_UPLOAD_MAX_FILESIZE_BYTES')) |
|
86 | 86 | { |
87 | 87 | $GLOBALS['log']->debug("detected upload_max_filesize: $upload_max_filesize"); |
88 | - print('<p class="error">' . $mod_strings['MSG_INCREASE_UPLOAD_MAX_FILESIZE'] . ' ' |
|
89 | - . get_cfg_var('cfg_file_path') . "</p>\n"); |
|
88 | + print('<p class="error">'.$mod_strings['MSG_INCREASE_UPLOAD_MAX_FILESIZE'].' ' |
|
89 | + . get_cfg_var('cfg_file_path')."</p>\n"); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | // |
93 | 93 | // process "run" commands |
94 | 94 | // |
95 | 95 | |
96 | -if( isset( $_REQUEST['run'] ) && ($_REQUEST['run'] != "") ){ |
|
96 | +if (isset($_REQUEST['run']) && ($_REQUEST['run'] != "")) { |
|
97 | 97 | $run = $_REQUEST['run']; |
98 | 98 | |
99 | - if( $run == "upload" ){ |
|
99 | + if ($run == "upload") { |
|
100 | 100 | $perform = false; |
101 | - if(isset($_REQUEST['release_id']) && $_REQUEST['release_id'] != ""){ |
|
101 | + if (isset($_REQUEST['release_id']) && $_REQUEST['release_id'] != "") { |
|
102 | 102 | require_once('ModuleInstall/PackageManager.php'); |
103 | 103 | $pm = new PackageManager(); |
104 | - $tempFile = $pm->download('','',$_REQUEST['release_id']); |
|
104 | + $tempFile = $pm->download('', '', $_REQUEST['release_id']); |
|
105 | 105 | $perform = true; |
106 | 106 | $base_filename = urldecode($tempFile); |
107 | - } elseif(!empty($_REQUEST['load_module_from_dir'])) { |
|
107 | + } elseif (!empty($_REQUEST['load_module_from_dir'])) { |
|
108 | 108 | //copy file to proper location then call performSetup |
109 | 109 | copy($_REQUEST['load_module_from_dir'].'/'.$_REQUEST['upgrade_zip_escaped'], "upload://".$_REQUEST['upgrade_zip_escaped']); |
110 | 110 | |
111 | 111 | $perform = true; |
112 | - $base_filename = urldecode( $_REQUEST['upgrade_zip_escaped'] ); |
|
112 | + $base_filename = urldecode($_REQUEST['upgrade_zip_escaped']); |
|
113 | 113 | } else { |
114 | - if( empty( $_FILES['upgrade_zip']['tmp_name'] ) ){ |
|
114 | + if (empty($_FILES['upgrade_zip']['tmp_name'])) { |
|
115 | 115 | echo $mod_strings['ERR_UW_NO_UPLOAD_FILE']; |
116 | - } else{ |
|
116 | + } else { |
|
117 | 117 | $upload = new UploadFile('upgrade_zip'); |
118 | - if(!$upload->confirm_upload() || |
|
118 | + if (!$upload->confirm_upload() || |
|
119 | 119 | strtolower(pathinfo($upload->get_stored_file_name(), PATHINFO_EXTENSION)) != 'zip' || |
120 | 120 | !$upload->final_move($upload->get_stored_file_name()) |
121 | 121 | ) { |
@@ -124,41 +124,41 @@ discard block |
||
124 | 124 | } else { |
125 | 125 | $tempFile = "upload://".$upload->get_stored_file_name(); |
126 | 126 | $perform = true; |
127 | - $base_filename = urldecode( $_REQUEST['upgrade_zip_escaped'] ); |
|
127 | + $base_filename = urldecode($_REQUEST['upgrade_zip_escaped']); |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 | } |
131 | - if($perform) { |
|
132 | - $manifest_file = extractManifest( $tempFile ); |
|
133 | - if(is_file($manifest_file)) |
|
131 | + if ($perform) { |
|
132 | + $manifest_file = extractManifest($tempFile); |
|
133 | + if (is_file($manifest_file)) |
|
134 | 134 | { |
135 | 135 | //SCAN THE MANIFEST FILE TO MAKE SURE NO COPIES OR ANYTHING ARE HAPPENING IN IT |
136 | 136 | $ms = new ModuleScanner(); |
137 | 137 | $ms->lockConfig(); |
138 | 138 | $fileIssues = $ms->scanFile($manifest_file); |
139 | - if(!empty($fileIssues)){ |
|
140 | - echo '<h2>' . $mod_strings['ML_MANIFEST_ISSUE'] . '</h2><br>'; |
|
139 | + if (!empty($fileIssues)) { |
|
140 | + echo '<h2>'.$mod_strings['ML_MANIFEST_ISSUE'].'</h2><br>'; |
|
141 | 141 | $ms->displayIssues(); |
142 | 142 | die(); |
143 | 143 | } |
144 | 144 | list($manifest, $installdefs) = MSLoadManifest($manifest_file); |
145 | - if($ms->checkConfig($manifest_file)) { |
|
146 | - echo '<h2>' . $mod_strings['ML_MANIFEST_ISSUE'] . '</h2><br>'; |
|
145 | + if ($ms->checkConfig($manifest_file)) { |
|
146 | + echo '<h2>'.$mod_strings['ML_MANIFEST_ISSUE'].'</h2><br>'; |
|
147 | 147 | $ms->displayIssues(); |
148 | 148 | die(); |
149 | 149 | } |
150 | - validate_manifest( $manifest ); |
|
150 | + validate_manifest($manifest); |
|
151 | 151 | |
152 | 152 | $upgrade_zip_type = $manifest['type']; |
153 | 153 | |
154 | 154 | // exclude the bad permutations |
155 | - if( $view == "module" ) { |
|
155 | + if ($view == "module") { |
|
156 | 156 | if ($upgrade_zip_type != "module" && $upgrade_zip_type != "theme" && $upgrade_zip_type != "langpack") { |
157 | 157 | unlinkTempFiles(); |
158 | 158 | die($mod_strings['ERR_UW_NOT_ACCEPTIBLE_TYPE']); |
159 | 159 | } |
160 | - } elseif( $view == "default" ) { |
|
161 | - if($upgrade_zip_type != "patch" ) { |
|
160 | + } elseif ($view == "default") { |
|
161 | + if ($upgrade_zip_type != "patch") { |
|
162 | 162 | unlinkTempFiles(); |
163 | 163 | die($mod_strings['ERR_UW_ONLY_PATCHES']); |
164 | 164 | } |
@@ -166,19 +166,19 @@ discard block |
||
166 | 166 | |
167 | 167 | $base_filename = pathinfo($tempFile, PATHINFO_BASENAME); |
168 | 168 | |
169 | - mkdir_recursive( "$base_upgrade_dir/$upgrade_zip_type" ); |
|
169 | + mkdir_recursive("$base_upgrade_dir/$upgrade_zip_type"); |
|
170 | 170 | $target_path = "$base_upgrade_dir/$upgrade_zip_type/$base_filename"; |
171 | - $target_manifest = remove_file_extension( $target_path ) . "-manifest.php"; |
|
171 | + $target_manifest = remove_file_extension($target_path)."-manifest.php"; |
|
172 | 172 | |
173 | - if( isset($manifest['icon']) && $manifest['icon'] != "" ){ |
|
174 | - $icon_location = extractFile( $tempFile ,$manifest['icon'] ); |
|
175 | - copy($icon_location, remove_file_extension( $target_path )."-icon.".pathinfo($icon_location, PATHINFO_EXTENSION)); |
|
173 | + if (isset($manifest['icon']) && $manifest['icon'] != "") { |
|
174 | + $icon_location = extractFile($tempFile, $manifest['icon']); |
|
175 | + copy($icon_location, remove_file_extension($target_path)."-icon.".pathinfo($icon_location, PATHINFO_EXTENSION)); |
|
176 | 176 | } |
177 | 177 | |
178 | - if(rename( $tempFile , $target_path )) { |
|
179 | - copy( $manifest_file, $target_manifest ); |
|
178 | + if (rename($tempFile, $target_path)) { |
|
179 | + copy($manifest_file, $target_manifest); |
|
180 | 180 | $GLOBALS['ML_STATUS_MESSAGE'] = $base_filename.$mod_strings['LBL_UW_UPLOAD_SUCCESS']; |
181 | - } else{ |
|
181 | + } else { |
|
182 | 182 | $GLOBALS['ML_STATUS_MESSAGE'] = $mod_strings['ERR_UW_UPLOAD_ERROR']; |
183 | 183 | } |
184 | 184 | } else { |
@@ -186,8 +186,8 @@ discard block |
||
186 | 186 | die($mod_strings['ERR_UW_NO_MANIFEST']); |
187 | 187 | } |
188 | 188 | } |
189 | - } else if( $run == $mod_strings['LBL_UW_BTN_DELETE_PACKAGE'] ){ |
|
190 | - if(!empty ($_REQUEST['install_file']) ){ |
|
189 | + } else if ($run == $mod_strings['LBL_UW_BTN_DELETE_PACKAGE']) { |
|
190 | + if (!empty ($_REQUEST['install_file'])) { |
|
191 | 191 | die($mod_strings['ERR_UW_NO_UPLOAD_FILE']); |
192 | 192 | } |
193 | 193 | |
@@ -195,11 +195,11 @@ discard block |
||
195 | 195 | |
196 | 196 | $checkFile = strtolower($delete_me); |
197 | 197 | |
198 | - if(substr($delete_me, -4) != ".zip" || substr($delete_me, 0, 9) != "upload://" || |
|
198 | + if (substr($delete_me, -4) != ".zip" || substr($delete_me, 0, 9) != "upload://" || |
|
199 | 199 | strpos($checkFile, "..") !== false || !file_exists($checkFile)) { |
200 | 200 | die("<span class='error'>File is not a zipped archive.</span>"); |
201 | 201 | } |
202 | - if(unlink($delete_me)) { // successful deletion? |
|
202 | + if (unlink($delete_me)) { // successful deletion? |
|
203 | 203 | echo "Package $delete_me has been removed.<br>"; |
204 | 204 | } else { |
205 | 205 | die("Problem removing package $delete_me."); |
@@ -207,22 +207,22 @@ discard block |
||
207 | 207 | } |
208 | 208 | } |
209 | 209 | |
210 | -if( $view == "module") { |
|
211 | - print( getClassicModuleTitle($mod_strings['LBL_MODULE_NAME'], array($mod_strings['LBL_MODULE_LOADER_TITLE']), false) ); |
|
210 | +if ($view == "module") { |
|
211 | + print(getClassicModuleTitle($mod_strings['LBL_MODULE_NAME'], array($mod_strings['LBL_MODULE_LOADER_TITLE']), false)); |
|
212 | 212 | } |
213 | 213 | else { |
214 | - print( getClassicModuleTitle($mod_strings['LBL_MODULE_NAME'], array($mod_strings['LBL_MODULE_NAME'],$mod_strings['LBL_UPGRADE_WIZARD_TITLE']), false) ); |
|
214 | + print(getClassicModuleTitle($mod_strings['LBL_MODULE_NAME'], array($mod_strings['LBL_MODULE_NAME'], $mod_strings['LBL_UPGRADE_WIZARD_TITLE']), false)); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | // upload link |
218 | -if(!empty($GLOBALS['sugar_config']['use_common_ml_dir']) && $GLOBALS['sugar_config']['use_common_ml_dir'] && !empty($GLOBALS['sugar_config']['common_ml_dir'])){ |
|
218 | +if (!empty($GLOBALS['sugar_config']['use_common_ml_dir']) && $GLOBALS['sugar_config']['use_common_ml_dir'] && !empty($GLOBALS['sugar_config']['common_ml_dir'])) { |
|
219 | 219 | //rrs |
220 | 220 | $form = '<form name="move_form" action="index.php?module=Administration&view=module&action=UpgradeWizard" method="post" ><input type=hidden name="run" value="upload" /><input type=hidden name="load_module_from_dir" id="load_module_from_dir" value="'.$GLOBALS['sugar_config']['common_ml_dir'].'" /><input type=hidden name="upgrade_zip_escaped" value="" />'; |
221 | 221 | $form .= '<br>'.$mod_strings['LBL_MODULE_UPLOAD_DISABLE_HELP_TEXT'].'</br>'; |
222 | - $form .='<table width="100%" class="edit view"><tr><th align="left">'.$mod_strings['LBL_ML_NAME'].'</th><th align="left">'.$mod_strings['LBL_ML_ACTION'].'</th></tr>'; |
|
222 | + $form .= '<table width="100%" class="edit view"><tr><th align="left">'.$mod_strings['LBL_ML_NAME'].'</th><th align="left">'.$mod_strings['LBL_ML_ACTION'].'</th></tr>'; |
|
223 | 223 | if ($handle = opendir($GLOBALS['sugar_config']['common_ml_dir'])) { |
224 | 224 | while (false !== ($filename = readdir($handle))) { |
225 | - if($filename == '.' || $filename == '..' || !preg_match("#.*\.zip\$#", $filename)) { |
|
225 | + if ($filename == '.' || $filename == '..' || !preg_match("#.*\.zip\$#", $filename)) { |
|
226 | 226 | continue; |
227 | 227 | } |
228 | 228 | $form .= '<tr><td>'.$filename.'</td><td><input type=button class="button" value="'.$mod_strings['LBL_UW_BTN_UPLOAD'].'" onClick="document.move_form.upgrade_zip_escaped.value = escape( \''.$filename.'\');document.move_form.submit();" /></td></tr>'; |
@@ -231,8 +231,8 @@ discard block |
||
231 | 231 | $form .= '</table></form>'; |
232 | 232 | //rrs |
233 | 233 | |
234 | -}else{ |
|
235 | - $form =<<<eoq |
|
234 | +} else { |
|
235 | + $form = <<<eoq |
|
236 | 236 | <form name="the_form" enctype="multipart/form-data" action="{$form_action}" method="post" > |
237 | 237 | <table width="100%" border="0" cellspacing="0" cellpadding="0" class="edit view"> |
238 | 238 | <tr><td> |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | $hidden_fields .= "<input type=hidden name=\"mode\"/>"; |
257 | 257 | |
258 | 258 | $form2 = PackageManagerDisplay::buildPackageDisplay($form, $hidden_fields, $form_action, array('module')); |
259 | -$form3 =<<<eoq3 |
|
259 | +$form3 = <<<eoq3 |
|
260 | 260 | |
261 | 261 | |
262 | 262 | eoq3; |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | ?> |
350 | 350 | */ |
351 | 351 | |
352 | -$GLOBALS['log']->info( "Upgrade Wizard view"); |
|
352 | +$GLOBALS['log']->info("Upgrade Wizard view"); |
|
353 | 353 | ?> |
354 | 354 | </td> |
355 | 355 | </tr> |
@@ -1,5 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
3 | + die('Not A Valid Entry Point'); |
|
4 | +} |
|
3 | 5 | /********************************************************************************* |
4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -66,8 +68,7 @@ discard block |
||
66 | 68 | $uploaddLabel = $mod_strings['LBL_UW_UPLOAD_MODULE']; |
67 | 69 | $descItemsQueued = $mod_strings['LBL_UW_DESC_MODULES_QUEUED']; |
68 | 70 | $descItemsInstalled = $mod_strings['LBL_UW_DESC_MODULES_INSTALLED']; |
69 | -} |
|
70 | -else { |
|
71 | +} else { |
|
71 | 72 | |
72 | 73 | $uploaddLabel = $mod_strings['LBL_UPLOAD_UPGRADE']; |
73 | 74 | $descItemsQueued = $mod_strings['DESC_FILES_QUEUED']; |
@@ -209,8 +210,7 @@ discard block |
||
209 | 210 | |
210 | 211 | if( $view == "module") { |
211 | 212 | print( getClassicModuleTitle($mod_strings['LBL_MODULE_NAME'], array($mod_strings['LBL_MODULE_LOADER_TITLE']), false) ); |
212 | -} |
|
213 | -else { |
|
213 | +} else { |
|
214 | 214 | print( getClassicModuleTitle($mod_strings['LBL_MODULE_NAME'], array($mod_strings['LBL_MODULE_NAME'],$mod_strings['LBL_UPGRADE_WIZARD_TITLE']), false) ); |
215 | 215 | } |
216 | 216 | |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | $form .= '</table></form>'; |
232 | 232 | //rrs |
233 | 233 | |
234 | -}else{ |
|
234 | +} else{ |
|
235 | 235 | $form =<<<eoq |
236 | 236 | <form name="the_form" enctype="multipart/form-data" action="{$form_action}" method="post" > |
237 | 237 | <table width="100%" border="0" cellspacing="0" cellpadding="0" class="edit view"> |
@@ -41,42 +41,42 @@ |
||
41 | 41 | global $current_user; |
42 | 42 | |
43 | 43 | if(!is_admin($current_user)){ |
44 | - die('Unauthorized Access. Aborting.'); |
|
44 | + die('Unauthorized Access. Aborting.'); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | //find modules that have a full-text index and rebuild it. |
48 | 48 | global $beanFiles; |
49 | 49 | foreach ($beanFiles as $beanname=>$beanpath) { |
50 | - require_once($beanpath); |
|
51 | - $focus= new $beanname(); |
|
50 | + require_once($beanpath); |
|
51 | + $focus= new $beanname(); |
|
52 | 52 | |
53 | - //skips beans based on same tables. user, employee and group are an example. |
|
54 | - if(empty($focus->table_name) || isset($processed_tables[$focus->table_name])) { |
|
55 | - continue; |
|
56 | - } else { |
|
57 | - $processed_tables[$focus->table_name]=$focus->table_name; |
|
58 | - } |
|
53 | + //skips beans based on same tables. user, employee and group are an example. |
|
54 | + if(empty($focus->table_name) || isset($processed_tables[$focus->table_name])) { |
|
55 | + continue; |
|
56 | + } else { |
|
57 | + $processed_tables[$focus->table_name]=$focus->table_name; |
|
58 | + } |
|
59 | 59 | |
60 | - if(!empty($dictionary[$focus->object_name]['indices'])) { |
|
61 | - $indices=$dictionary[$focus->object_name]['indices']; |
|
62 | - } else { |
|
63 | - $indices=array(); |
|
64 | - } |
|
60 | + if(!empty($dictionary[$focus->object_name]['indices'])) { |
|
61 | + $indices=$dictionary[$focus->object_name]['indices']; |
|
62 | + } else { |
|
63 | + $indices=array(); |
|
64 | + } |
|
65 | 65 | |
66 | - //clean vardef definitions.. removed indexes not value for this dbtype. |
|
67 | - //set index name as the key. |
|
68 | - $var_indices=array(); |
|
69 | - foreach ($indices as $definition) { |
|
70 | - //database helpers do not know how to handle full text indices |
|
71 | - if ($definition['type']=='fulltext') { |
|
72 | - if (isset($definition['db']) and $definition['db'] != $GLOBALS['db']->dbType) { |
|
73 | - continue; |
|
74 | - } |
|
66 | + //clean vardef definitions.. removed indexes not value for this dbtype. |
|
67 | + //set index name as the key. |
|
68 | + $var_indices=array(); |
|
69 | + foreach ($indices as $definition) { |
|
70 | + //database helpers do not know how to handle full text indices |
|
71 | + if ($definition['type']=='fulltext') { |
|
72 | + if (isset($definition['db']) and $definition['db'] != $GLOBALS['db']->dbType) { |
|
73 | + continue; |
|
74 | + } |
|
75 | 75 | |
76 | - echo "Rebuilding Index {$definition['name']} <BR/>"; |
|
77 | - $GLOBALS['db']->query('alter index ' .$definition['name'] . " REBUILD"); |
|
78 | - } |
|
76 | + echo "Rebuilding Index {$definition['name']} <BR/>"; |
|
77 | + $GLOBALS['db']->query('alter index ' .$definition['name'] . " REBUILD"); |
|
78 | + } |
|
79 | 79 | |
80 | - } |
|
80 | + } |
|
81 | 81 | } |
82 | 82 | ?> |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
3 | 3 | /********************************************************************************* |
4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | global $current_user; |
42 | 42 | |
43 | -if(!is_admin($current_user)){ |
|
43 | +if (!is_admin($current_user)) { |
|
44 | 44 | die('Unauthorized Access. Aborting.'); |
45 | 45 | } |
46 | 46 | |
@@ -48,33 +48,33 @@ discard block |
||
48 | 48 | global $beanFiles; |
49 | 49 | foreach ($beanFiles as $beanname=>$beanpath) { |
50 | 50 | require_once($beanpath); |
51 | - $focus= new $beanname(); |
|
51 | + $focus = new $beanname(); |
|
52 | 52 | |
53 | 53 | //skips beans based on same tables. user, employee and group are an example. |
54 | - if(empty($focus->table_name) || isset($processed_tables[$focus->table_name])) { |
|
54 | + if (empty($focus->table_name) || isset($processed_tables[$focus->table_name])) { |
|
55 | 55 | continue; |
56 | 56 | } else { |
57 | - $processed_tables[$focus->table_name]=$focus->table_name; |
|
57 | + $processed_tables[$focus->table_name] = $focus->table_name; |
|
58 | 58 | } |
59 | 59 | |
60 | - if(!empty($dictionary[$focus->object_name]['indices'])) { |
|
61 | - $indices=$dictionary[$focus->object_name]['indices']; |
|
60 | + if (!empty($dictionary[$focus->object_name]['indices'])) { |
|
61 | + $indices = $dictionary[$focus->object_name]['indices']; |
|
62 | 62 | } else { |
63 | - $indices=array(); |
|
63 | + $indices = array(); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | //clean vardef definitions.. removed indexes not value for this dbtype. |
67 | 67 | //set index name as the key. |
68 | - $var_indices=array(); |
|
68 | + $var_indices = array(); |
|
69 | 69 | foreach ($indices as $definition) { |
70 | 70 | //database helpers do not know how to handle full text indices |
71 | - if ($definition['type']=='fulltext') { |
|
71 | + if ($definition['type'] == 'fulltext') { |
|
72 | 72 | if (isset($definition['db']) and $definition['db'] != $GLOBALS['db']->dbType) { |
73 | 73 | continue; |
74 | 74 | } |
75 | 75 | |
76 | 76 | echo "Rebuilding Index {$definition['name']} <BR/>"; |
77 | - $GLOBALS['db']->query('alter index ' .$definition['name'] . " REBUILD"); |
|
77 | + $GLOBALS['db']->query('alter index '.$definition['name']." REBUILD"); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | } |
@@ -1,5 +1,7 @@ |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
3 | + die('Not A Valid Entry Point'); |
|
4 | +} |
|
3 | 5 | /********************************************************************************* |
4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if (!defined('sugarEntry') || !sugarEntry) |
3 | - die('Not A Valid Entry Point'); |
|
3 | + die('Not A Valid Entry Point'); |
|
4 | 4 | /********************************************************************************* |
5 | 5 | * SugarCRM Community Edition is a customer relationship management program developed by |
6 | 6 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -47,78 +47,78 @@ discard block |
||
47 | 47 | $db = DBManagerFactory::getInstance(); |
48 | 48 | |
49 | 49 | if (is_admin($current_user) || isset ($from_sync_client) || is_admin_for_any_module($current_user)) { |
50 | - isset($_REQUEST['execute'])? $execute=$_REQUEST['execute'] : $execute= false; |
|
51 | - $export = false; |
|
52 | - |
|
53 | - if (sizeof($_POST) && isset ($_POST['raction'])) { |
|
54 | - if (isset ($_POST['raction']) && strtolower($_POST['raction']) == "export") { |
|
55 | - //jc - output buffering is being used. if we do not clean the output buffer |
|
56 | - //the contents of the buffer up to the length of the repair statement(s) |
|
57 | - //will be saved in the file... |
|
58 | - ob_clean(); |
|
59 | - |
|
60 | - header("Content-Disposition: attachment; filename=repairSugarDB.sql"); |
|
61 | - header("Content-Type: text/sql; charset={$app_strings['LBL_CHARSET']}"); |
|
62 | - header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); |
|
63 | - header("Last-Modified: " . TimeDate::httpTime()); |
|
64 | - header("Cache-Control: post-check=0, pre-check=0", false); |
|
65 | - header("Content-Length: " . strlen($_POST['sql'])); |
|
66 | - |
|
67 | - //jc:7347 - for whatever reason, html_entity_decode is choking on converting |
|
68 | - //the html entity ' to a single quote, so we will use str_replace |
|
69 | - //instead |
|
70 | - $sql = str_replace(''',"'", $_POST['sql']); |
|
71 | - //echo html_entity_decode($_POST['sql']); |
|
72 | - echo $sql; |
|
73 | - } |
|
74 | - elseif (isset ($_POST['raction']) && strtolower($_POST['raction']) == "execute") { |
|
75 | - $sql = str_replace( |
|
76 | - array( |
|
77 | - "\n", |
|
78 | - ''', |
|
79 | - ), |
|
80 | - array( |
|
81 | - '', |
|
82 | - "'", |
|
83 | - ), |
|
84 | - preg_replace('#(/\*.+?\*/\n*)#', '', $_POST['sql']) |
|
85 | - ); |
|
86 | - foreach (explode(";", $sql) as $stmt) { |
|
87 | - $stmt = trim($stmt); |
|
88 | - |
|
89 | - if (!empty ($stmt)) { |
|
90 | - $db->query($stmt,true,'Executing repair query: '); |
|
91 | - } |
|
92 | - } |
|
93 | - |
|
94 | - echo "<h3>{$mod_strings['LBL_REPAIR_DATABASE_SYNCED']}</h3>"; |
|
95 | - } |
|
96 | - } else { |
|
97 | - |
|
98 | - if (!$export && empty ($_REQUEST['repair_silent'])) { |
|
99 | - if ( empty($hideModuleMenu) ) |
|
100 | - echo getClassicModuleTitle($mod_strings['LBL_REPAIR_DATABASE'], array($mod_strings['LBL_REPAIR_DATABASE']), true); |
|
101 | - echo "<h1 id=\"rdloading\">{$mod_strings['LBL_REPAIR_DATABASE_PROCESSING']}</h1>"; |
|
102 | - ob_flush(); |
|
103 | - } |
|
104 | - |
|
105 | - $sql = ''; |
|
106 | - |
|
107 | - VardefManager::clearVardef(); |
|
108 | - $repairedTables = array(); |
|
109 | - |
|
110 | - foreach ($beanFiles as $bean => $file) { |
|
111 | - if(file_exists($file)){ |
|
112 | - require_once ($file); |
|
113 | - unset($GLOBALS['dictionary'][$bean]); |
|
114 | - $focus = new $bean (); |
|
115 | - if (($focus instanceOf SugarBean) && !isset($repairedTables[$focus->table_name])) { |
|
116 | - $sql .= $db->repairTable($focus, $execute); |
|
117 | - $repairedTables[$focus->table_name] = true; |
|
118 | - } |
|
50 | + isset($_REQUEST['execute'])? $execute=$_REQUEST['execute'] : $execute= false; |
|
51 | + $export = false; |
|
52 | + |
|
53 | + if (sizeof($_POST) && isset ($_POST['raction'])) { |
|
54 | + if (isset ($_POST['raction']) && strtolower($_POST['raction']) == "export") { |
|
55 | + //jc - output buffering is being used. if we do not clean the output buffer |
|
56 | + //the contents of the buffer up to the length of the repair statement(s) |
|
57 | + //will be saved in the file... |
|
58 | + ob_clean(); |
|
59 | + |
|
60 | + header("Content-Disposition: attachment; filename=repairSugarDB.sql"); |
|
61 | + header("Content-Type: text/sql; charset={$app_strings['LBL_CHARSET']}"); |
|
62 | + header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); |
|
63 | + header("Last-Modified: " . TimeDate::httpTime()); |
|
64 | + header("Cache-Control: post-check=0, pre-check=0", false); |
|
65 | + header("Content-Length: " . strlen($_POST['sql'])); |
|
66 | + |
|
67 | + //jc:7347 - for whatever reason, html_entity_decode is choking on converting |
|
68 | + //the html entity ' to a single quote, so we will use str_replace |
|
69 | + //instead |
|
70 | + $sql = str_replace(''',"'", $_POST['sql']); |
|
71 | + //echo html_entity_decode($_POST['sql']); |
|
72 | + echo $sql; |
|
73 | + } |
|
74 | + elseif (isset ($_POST['raction']) && strtolower($_POST['raction']) == "execute") { |
|
75 | + $sql = str_replace( |
|
76 | + array( |
|
77 | + "\n", |
|
78 | + ''', |
|
79 | + ), |
|
80 | + array( |
|
81 | + '', |
|
82 | + "'", |
|
83 | + ), |
|
84 | + preg_replace('#(/\*.+?\*/\n*)#', '', $_POST['sql']) |
|
85 | + ); |
|
86 | + foreach (explode(";", $sql) as $stmt) { |
|
87 | + $stmt = trim($stmt); |
|
88 | + |
|
89 | + if (!empty ($stmt)) { |
|
90 | + $db->query($stmt,true,'Executing repair query: '); |
|
91 | + } |
|
92 | + } |
|
93 | + |
|
94 | + echo "<h3>{$mod_strings['LBL_REPAIR_DATABASE_SYNCED']}</h3>"; |
|
95 | + } |
|
96 | + } else { |
|
97 | + |
|
98 | + if (!$export && empty ($_REQUEST['repair_silent'])) { |
|
99 | + if ( empty($hideModuleMenu) ) |
|
100 | + echo getClassicModuleTitle($mod_strings['LBL_REPAIR_DATABASE'], array($mod_strings['LBL_REPAIR_DATABASE']), true); |
|
101 | + echo "<h1 id=\"rdloading\">{$mod_strings['LBL_REPAIR_DATABASE_PROCESSING']}</h1>"; |
|
102 | + ob_flush(); |
|
103 | + } |
|
104 | + |
|
105 | + $sql = ''; |
|
106 | + |
|
107 | + VardefManager::clearVardef(); |
|
108 | + $repairedTables = array(); |
|
109 | + |
|
110 | + foreach ($beanFiles as $bean => $file) { |
|
111 | + if(file_exists($file)){ |
|
112 | + require_once ($file); |
|
113 | + unset($GLOBALS['dictionary'][$bean]); |
|
114 | + $focus = new $bean (); |
|
115 | + if (($focus instanceOf SugarBean) && !isset($repairedTables[$focus->table_name])) { |
|
116 | + $sql .= $db->repairTable($focus, $execute); |
|
117 | + $repairedTables[$focus->table_name] = true; |
|
118 | + } |
|
119 | 119 | //Repair Custom Fields |
120 | 120 | if (($focus instanceOf SugarBean) && $focus->hasCustomFields() && !isset($repairedTables[$focus->table_name . '_cstm'])) { |
121 | - $df = new DynamicField($focus->module_dir); |
|
121 | + $df = new DynamicField($focus->module_dir); |
|
122 | 122 | //Need to check if the method exists as during upgrade an old version of Dynamic Fields may be loaded. |
123 | 123 | if (method_exists($df, "repairCustomFields")) |
124 | 124 | { |
@@ -126,56 +126,56 @@ discard block |
||
126 | 126 | $sql .= $df->repairCustomFields($execute); |
127 | 127 | $repairedTables[$focus->table_name . '_cstm'] = true; |
128 | 128 | } |
129 | - } |
|
130 | - } |
|
131 | - } |
|
129 | + } |
|
130 | + } |
|
131 | + } |
|
132 | 132 | |
133 | - $olddictionary = $dictionary; |
|
133 | + $olddictionary = $dictionary; |
|
134 | 134 | |
135 | - unset ($dictionary); |
|
136 | - include ('modules/TableDictionary.php'); |
|
135 | + unset ($dictionary); |
|
136 | + include ('modules/TableDictionary.php'); |
|
137 | 137 | |
138 | - foreach ($dictionary as $meta) { |
|
138 | + foreach ($dictionary as $meta) { |
|
139 | 139 | |
140 | - if ( !isset($meta['table']) || isset($repairedTables[$meta['table']])) |
|
140 | + if ( !isset($meta['table']) || isset($repairedTables[$meta['table']])) |
|
141 | 141 | continue; |
142 | 142 | |
143 | 143 | $tablename = $meta['table']; |
144 | - $fielddefs = $meta['fields']; |
|
145 | - $indices = $meta['indices']; |
|
146 | - $engine = isset($meta['engine'])?$meta['engine']:null; |
|
147 | - $sql .= $db->repairTableParams($tablename, $fielddefs, $indices, $execute, $engine); |
|
148 | - $repairedTables[$tablename] = true; |
|
149 | - } |
|
144 | + $fielddefs = $meta['fields']; |
|
145 | + $indices = $meta['indices']; |
|
146 | + $engine = isset($meta['engine'])?$meta['engine']:null; |
|
147 | + $sql .= $db->repairTableParams($tablename, $fielddefs, $indices, $execute, $engine); |
|
148 | + $repairedTables[$tablename] = true; |
|
149 | + } |
|
150 | 150 | |
151 | - $dictionary = $olddictionary; |
|
151 | + $dictionary = $olddictionary; |
|
152 | 152 | |
153 | 153 | |
154 | 154 | |
155 | - if (empty ($_REQUEST['repair_silent'])) { |
|
156 | - echo "<script type=\"text/javascript\">document.getElementById('rdloading').style.display = \"none\";</script>"; |
|
155 | + if (empty ($_REQUEST['repair_silent'])) { |
|
156 | + echo "<script type=\"text/javascript\">document.getElementById('rdloading').style.display = \"none\";</script>"; |
|
157 | 157 | |
158 | - if (isset ($sql) && !empty ($sql)) { |
|
158 | + if (isset ($sql) && !empty ($sql)) { |
|
159 | 159 | |
160 | - $qry_str = ""; |
|
161 | - foreach (explode("\n", $sql) as $line) { |
|
162 | - if (!empty ($line) && substr($line, -2) != "*/") { |
|
163 | - $line .= ";"; |
|
164 | - } |
|
160 | + $qry_str = ""; |
|
161 | + foreach (explode("\n", $sql) as $line) { |
|
162 | + if (!empty ($line) && substr($line, -2) != "*/") { |
|
163 | + $line .= ";"; |
|
164 | + } |
|
165 | 165 | |
166 | - $qry_str .= $line . "\n"; |
|
167 | - } |
|
166 | + $qry_str .= $line . "\n"; |
|
167 | + } |
|
168 | 168 | |
169 | - $ss = new Sugar_Smarty(); |
|
170 | - $ss->assign('MOD', $GLOBALS['mod_strings']); |
|
171 | - $ss->assign('qry_str', $qry_str); |
|
172 | - echo $ss->fetch('modules/Administration/templates/RepairDatabase.tpl'); |
|
173 | - } else { |
|
174 | - echo "<h3>{$mod_strings['LBL_REPAIR_DATABASE_SYNCED']}</h3>"; |
|
175 | - } |
|
176 | - } |
|
177 | - } |
|
169 | + $ss = new Sugar_Smarty(); |
|
170 | + $ss->assign('MOD', $GLOBALS['mod_strings']); |
|
171 | + $ss->assign('qry_str', $qry_str); |
|
172 | + echo $ss->fetch('modules/Administration/templates/RepairDatabase.tpl'); |
|
173 | + } else { |
|
174 | + echo "<h3>{$mod_strings['LBL_REPAIR_DATABASE_SYNCED']}</h3>"; |
|
175 | + } |
|
176 | + } |
|
177 | + } |
|
178 | 178 | |
179 | 179 | } else { |
180 | - sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']); |
|
180 | + sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']); |
|
181 | 181 | } |
182 | 182 | \ No newline at end of file |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $db = DBManagerFactory::getInstance(); |
48 | 48 | |
49 | 49 | if (is_admin($current_user) || isset ($from_sync_client) || is_admin_for_any_module($current_user)) { |
50 | - isset($_REQUEST['execute'])? $execute=$_REQUEST['execute'] : $execute= false; |
|
50 | + isset($_REQUEST['execute']) ? $execute = $_REQUEST['execute'] : $execute = false; |
|
51 | 51 | $export = false; |
52 | 52 | |
53 | 53 | if (sizeof($_POST) && isset ($_POST['raction'])) { |
@@ -60,14 +60,14 @@ discard block |
||
60 | 60 | header("Content-Disposition: attachment; filename=repairSugarDB.sql"); |
61 | 61 | header("Content-Type: text/sql; charset={$app_strings['LBL_CHARSET']}"); |
62 | 62 | header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); |
63 | - header("Last-Modified: " . TimeDate::httpTime()); |
|
63 | + header("Last-Modified: ".TimeDate::httpTime()); |
|
64 | 64 | header("Cache-Control: post-check=0, pre-check=0", false); |
65 | - header("Content-Length: " . strlen($_POST['sql'])); |
|
65 | + header("Content-Length: ".strlen($_POST['sql'])); |
|
66 | 66 | |
67 | 67 | //jc:7347 - for whatever reason, html_entity_decode is choking on converting |
68 | 68 | //the html entity ' to a single quote, so we will use str_replace |
69 | 69 | //instead |
70 | - $sql = str_replace(''',"'", $_POST['sql']); |
|
70 | + $sql = str_replace(''', "'", $_POST['sql']); |
|
71 | 71 | //echo html_entity_decode($_POST['sql']); |
72 | 72 | echo $sql; |
73 | 73 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $stmt = trim($stmt); |
88 | 88 | |
89 | 89 | if (!empty ($stmt)) { |
90 | - $db->query($stmt,true,'Executing repair query: '); |
|
90 | + $db->query($stmt, true, 'Executing repair query: '); |
|
91 | 91 | } |
92 | 92 | } |
93 | 93 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | } else { |
97 | 97 | |
98 | 98 | if (!$export && empty ($_REQUEST['repair_silent'])) { |
99 | - if ( empty($hideModuleMenu) ) |
|
99 | + if (empty($hideModuleMenu)) |
|
100 | 100 | echo getClassicModuleTitle($mod_strings['LBL_REPAIR_DATABASE'], array($mod_strings['LBL_REPAIR_DATABASE']), true); |
101 | 101 | echo "<h1 id=\"rdloading\">{$mod_strings['LBL_REPAIR_DATABASE_PROCESSING']}</h1>"; |
102 | 102 | ob_flush(); |
@@ -108,23 +108,23 @@ discard block |
||
108 | 108 | $repairedTables = array(); |
109 | 109 | |
110 | 110 | foreach ($beanFiles as $bean => $file) { |
111 | - if(file_exists($file)){ |
|
111 | + if (file_exists($file)) { |
|
112 | 112 | require_once ($file); |
113 | 113 | unset($GLOBALS['dictionary'][$bean]); |
114 | - $focus = new $bean (); |
|
114 | + $focus = new $bean(); |
|
115 | 115 | if (($focus instanceOf SugarBean) && !isset($repairedTables[$focus->table_name])) { |
116 | 116 | $sql .= $db->repairTable($focus, $execute); |
117 | 117 | $repairedTables[$focus->table_name] = true; |
118 | 118 | } |
119 | 119 | //Repair Custom Fields |
120 | - if (($focus instanceOf SugarBean) && $focus->hasCustomFields() && !isset($repairedTables[$focus->table_name . '_cstm'])) { |
|
120 | + if (($focus instanceOf SugarBean) && $focus->hasCustomFields() && !isset($repairedTables[$focus->table_name.'_cstm'])) { |
|
121 | 121 | $df = new DynamicField($focus->module_dir); |
122 | 122 | //Need to check if the method exists as during upgrade an old version of Dynamic Fields may be loaded. |
123 | 123 | if (method_exists($df, "repairCustomFields")) |
124 | 124 | { |
125 | 125 | $df->bean = $focus; |
126 | 126 | $sql .= $df->repairCustomFields($execute); |
127 | - $repairedTables[$focus->table_name . '_cstm'] = true; |
|
127 | + $repairedTables[$focus->table_name.'_cstm'] = true; |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 | } |
@@ -137,13 +137,13 @@ discard block |
||
137 | 137 | |
138 | 138 | foreach ($dictionary as $meta) { |
139 | 139 | |
140 | - if ( !isset($meta['table']) || isset($repairedTables[$meta['table']])) |
|
140 | + if (!isset($meta['table']) || isset($repairedTables[$meta['table']])) |
|
141 | 141 | continue; |
142 | 142 | |
143 | 143 | $tablename = $meta['table']; |
144 | 144 | $fielddefs = $meta['fields']; |
145 | 145 | $indices = $meta['indices']; |
146 | - $engine = isset($meta['engine'])?$meta['engine']:null; |
|
146 | + $engine = isset($meta['engine']) ? $meta['engine'] : null; |
|
147 | 147 | $sql .= $db->repairTableParams($tablename, $fielddefs, $indices, $execute, $engine); |
148 | 148 | $repairedTables[$tablename] = true; |
149 | 149 | } |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | $line .= ";"; |
164 | 164 | } |
165 | 165 | |
166 | - $qry_str .= $line . "\n"; |
|
166 | + $qry_str .= $line."\n"; |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | $ss = new Sugar_Smarty(); |
@@ -1,6 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('sugarEntry') || !sugarEntry) |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) { |
|
3 | 3 | die('Not A Valid Entry Point'); |
4 | +} |
|
4 | 5 | /********************************************************************************* |
5 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
6 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -70,8 +71,7 @@ discard block |
||
70 | 71 | $sql = str_replace(''',"'", $_POST['sql']); |
71 | 72 | //echo html_entity_decode($_POST['sql']); |
72 | 73 | echo $sql; |
73 | - } |
|
74 | - elseif (isset ($_POST['raction']) && strtolower($_POST['raction']) == "execute") { |
|
74 | + } elseif (isset ($_POST['raction']) && strtolower($_POST['raction']) == "execute") { |
|
75 | 75 | $sql = str_replace( |
76 | 76 | array( |
77 | 77 | "\n", |
@@ -96,8 +96,9 @@ discard block |
||
96 | 96 | } else { |
97 | 97 | |
98 | 98 | if (!$export && empty ($_REQUEST['repair_silent'])) { |
99 | - if ( empty($hideModuleMenu) ) |
|
100 | - echo getClassicModuleTitle($mod_strings['LBL_REPAIR_DATABASE'], array($mod_strings['LBL_REPAIR_DATABASE']), true); |
|
99 | + if ( empty($hideModuleMenu) ) { |
|
100 | + echo getClassicModuleTitle($mod_strings['LBL_REPAIR_DATABASE'], array($mod_strings['LBL_REPAIR_DATABASE']), true); |
|
101 | + } |
|
101 | 102 | echo "<h1 id=\"rdloading\">{$mod_strings['LBL_REPAIR_DATABASE_PROCESSING']}</h1>"; |
102 | 103 | ob_flush(); |
103 | 104 | } |
@@ -137,8 +138,9 @@ discard block |
||
137 | 138 | |
138 | 139 | foreach ($dictionary as $meta) { |
139 | 140 | |
140 | - if ( !isset($meta['table']) || isset($repairedTables[$meta['table']])) |
|
141 | - continue; |
|
141 | + if ( !isset($meta['table']) || isset($repairedTables[$meta['table']])) { |
|
142 | + continue; |
|
143 | + } |
|
142 | 144 | |
143 | 145 | $tablename = $meta['table']; |
144 | 146 | $fielddefs = $meta['fields']; |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if(!defined('sugarEntry') || !sugarEntry) |
3 | - die('Not A Valid Entry Point'); |
|
3 | + die('Not A Valid Entry Point'); |
|
4 | 4 | /********************************************************************************* |
5 | 5 | * SugarCRM Community Edition is a customer relationship management program developed by |
6 | 6 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | global $db; |
45 | 45 | |
46 | 46 | if (!isset ($db)) { |
47 | - $db = DBManagerFactory:: getInstance(); |
|
47 | + $db = DBManagerFactory:: getInstance(); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | $result = $db->query('SELECT * FROM fields_meta_data WHERE deleted = 0 ORDER BY custom_module'); |
@@ -53,82 +53,82 @@ discard block |
||
53 | 53 | * get the real field_meta_data |
54 | 54 | */ |
55 | 55 | while ($row = $db->fetchByAssoc($result)) { |
56 | - $the_modules = $row['custom_module']; |
|
57 | - if (!isset ($modules[$the_modules])) { |
|
58 | - $modules[$the_modules] = array (); |
|
59 | - } |
|
60 | - $modules[$the_modules][$row['name']] = $row['name']; |
|
56 | + $the_modules = $row['custom_module']; |
|
57 | + if (!isset ($modules[$the_modules])) { |
|
58 | + $modules[$the_modules] = array (); |
|
59 | + } |
|
60 | + $modules[$the_modules][$row['name']] = $row['name']; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | $simulate = false; |
64 | 64 | if (!isset ($_REQUEST['run'])) { |
65 | - $simulate = true; |
|
66 | - echo "SIMULATION MODE - NO CHANGES WILL BE MADE EXCEPT CLEARING CACHE"; |
|
65 | + $simulate = true; |
|
66 | + echo "SIMULATION MODE - NO CHANGES WILL BE MADE EXCEPT CLEARING CACHE"; |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | foreach ($modules as $the_module => $fields) { |
70 | - $class_name = $beanList[$the_module]; |
|
71 | - echo "<br><br>Scanning $the_module <br>"; |
|
70 | + $class_name = $beanList[$the_module]; |
|
71 | + echo "<br><br>Scanning $the_module <br>"; |
|
72 | 72 | |
73 | - require_once ($beanFiles[$class_name]); |
|
74 | - $mod = new $class_name (); |
|
75 | - if (!$db->tableExists($mod->table_name."_cstm")) { |
|
76 | - $mod->custom_fields = new DynamicField(); |
|
77 | - $mod->custom_fields->setup($mod); |
|
78 | - $mod->custom_fields->createCustomTable(); |
|
79 | - } |
|
73 | + require_once ($beanFiles[$class_name]); |
|
74 | + $mod = new $class_name (); |
|
75 | + if (!$db->tableExists($mod->table_name."_cstm")) { |
|
76 | + $mod->custom_fields = new DynamicField(); |
|
77 | + $mod->custom_fields->setup($mod); |
|
78 | + $mod->custom_fields->createCustomTable(); |
|
79 | + } |
|
80 | 80 | |
81 | - $table = $db->getTableDescription($mod->table_name."_cstm"); |
|
82 | - foreach($table as $row) { |
|
83 | - $col = strtolower(empty ($row['Field']) ? $row['field'] : $row['Field']); |
|
84 | - $the_field = $mod->custom_fields->getField($col); |
|
85 | - $type = strtolower(empty ($row['Type']) ? $row['type'] : $row['Type']); |
|
86 | - if (!empty($row['data_precision']) && !empty($row['data_scale'])) { |
|
87 | - $type.='(' . $row['data_precision']; |
|
88 | - if (!empty($row['data_scale'])) { |
|
89 | - $type.=',' . $row['data_scale']; |
|
90 | - } |
|
91 | - $type.=')'; |
|
92 | - } elseif(!empty($row['data_length']) && (strtolower($row['type'])=='varchar' or strtolower($row['type'])=='varchar2')) { |
|
93 | - $type.='(' . $row['data_length'] . ')'; |
|
94 | - } |
|
95 | - if (!isset ($fields[$col]) && $col != 'id_c') { |
|
96 | - if (!$simulate) { |
|
97 | - $db->query("ALTER TABLE $mod->table_name"."_cstm DROP COLUMN $col"); |
|
98 | - } |
|
99 | - unset ($fields[$col]); |
|
100 | - echo "Dropping Column $col from $mod->table_name"."_cstm for module $the_module<br>"; |
|
101 | - } else { |
|
102 | - if ($col != 'id_c') { |
|
103 | - $db_data_type = strtolower(str_replace(' ' , '', $the_field->get_db_type())); |
|
81 | + $table = $db->getTableDescription($mod->table_name."_cstm"); |
|
82 | + foreach($table as $row) { |
|
83 | + $col = strtolower(empty ($row['Field']) ? $row['field'] : $row['Field']); |
|
84 | + $the_field = $mod->custom_fields->getField($col); |
|
85 | + $type = strtolower(empty ($row['Type']) ? $row['type'] : $row['Type']); |
|
86 | + if (!empty($row['data_precision']) && !empty($row['data_scale'])) { |
|
87 | + $type.='(' . $row['data_precision']; |
|
88 | + if (!empty($row['data_scale'])) { |
|
89 | + $type.=',' . $row['data_scale']; |
|
90 | + } |
|
91 | + $type.=')'; |
|
92 | + } elseif(!empty($row['data_length']) && (strtolower($row['type'])=='varchar' or strtolower($row['type'])=='varchar2')) { |
|
93 | + $type.='(' . $row['data_length'] . ')'; |
|
94 | + } |
|
95 | + if (!isset ($fields[$col]) && $col != 'id_c') { |
|
96 | + if (!$simulate) { |
|
97 | + $db->query("ALTER TABLE $mod->table_name"."_cstm DROP COLUMN $col"); |
|
98 | + } |
|
99 | + unset ($fields[$col]); |
|
100 | + echo "Dropping Column $col from $mod->table_name"."_cstm for module $the_module<br>"; |
|
101 | + } else { |
|
102 | + if ($col != 'id_c') { |
|
103 | + $db_data_type = strtolower(str_replace(' ' , '', $the_field->get_db_type())); |
|
104 | 104 | |
105 | - $type = strtolower(str_replace(' ' , '', $type)); |
|
106 | - if (strcmp($db_data_type,$type) != 0) { |
|
105 | + $type = strtolower(str_replace(' ' , '', $type)); |
|
106 | + if (strcmp($db_data_type,$type) != 0) { |
|
107 | 107 | |
108 | - echo "Fixing Column Type for $col changing $type to ".$db_data_type."<br>"; |
|
109 | - if (!$simulate) { |
|
110 | - $db->query($the_field->get_db_modify_alter_table($mod->table_name.'_cstm')); |
|
108 | + echo "Fixing Column Type for $col changing $type to ".$db_data_type."<br>"; |
|
109 | + if (!$simulate) { |
|
110 | + $db->query($the_field->get_db_modify_alter_table($mod->table_name.'_cstm')); |
|
111 | 111 | } |
112 | - } |
|
113 | - } |
|
112 | + } |
|
113 | + } |
|
114 | 114 | |
115 | - unset ($fields[$col]); |
|
116 | - } |
|
115 | + unset ($fields[$col]); |
|
116 | + } |
|
117 | 117 | |
118 | - } |
|
118 | + } |
|
119 | 119 | |
120 | - echo sizeof($fields)." field(s) missing from $mod->table_name"."_cstm<br>"; |
|
121 | - foreach ($fields as $field) { |
|
122 | - echo "Adding Column $field to $mod->table_name"."_cstm<br>"; |
|
123 | - if (!$simulate) |
|
124 | - $mod->custom_fields->add_existing_custom_field($field); |
|
125 | - } |
|
120 | + echo sizeof($fields)." field(s) missing from $mod->table_name"."_cstm<br>"; |
|
121 | + foreach ($fields as $field) { |
|
122 | + echo "Adding Column $field to $mod->table_name"."_cstm<br>"; |
|
123 | + if (!$simulate) |
|
124 | + $mod->custom_fields->add_existing_custom_field($field); |
|
125 | + } |
|
126 | 126 | |
127 | 127 | } |
128 | 128 | |
129 | 129 | DynamicField :: deleteCache(); |
130 | 130 | echo '<br>Done<br>'; |
131 | 131 | if ($simulate) { |
132 | - echo '<a href="index.php?module=Administration&action=UpgradeFields&run=true">Execute non-simulation mode</a>'; |
|
132 | + echo '<a href="index.php?module=Administration&action=UpgradeFields&run=true">Execute non-simulation mode</a>'; |
|
133 | 133 | } |
134 | 134 | ?> |
135 | 135 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) |
|
3 | 3 | die('Not A Valid Entry Point'); |
4 | 4 | /********************************************************************************* |
5 | 5 | * SugarCRM Community Edition is a customer relationship management program developed by |
@@ -48,14 +48,14 @@ discard block |
||
48 | 48 | } |
49 | 49 | |
50 | 50 | $result = $db->query('SELECT * FROM fields_meta_data WHERE deleted = 0 ORDER BY custom_module'); |
51 | -$modules = array (); |
|
51 | +$modules = array(); |
|
52 | 52 | /* |
53 | 53 | * get the real field_meta_data |
54 | 54 | */ |
55 | 55 | while ($row = $db->fetchByAssoc($result)) { |
56 | 56 | $the_modules = $row['custom_module']; |
57 | 57 | if (!isset ($modules[$the_modules])) { |
58 | - $modules[$the_modules] = array (); |
|
58 | + $modules[$the_modules] = array(); |
|
59 | 59 | } |
60 | 60 | $modules[$the_modules][$row['name']] = $row['name']; |
61 | 61 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | echo "<br><br>Scanning $the_module <br>"; |
72 | 72 | |
73 | 73 | require_once ($beanFiles[$class_name]); |
74 | - $mod = new $class_name (); |
|
74 | + $mod = new $class_name(); |
|
75 | 75 | if (!$db->tableExists($mod->table_name."_cstm")) { |
76 | 76 | $mod->custom_fields = new DynamicField(); |
77 | 77 | $mod->custom_fields->setup($mod); |
@@ -79,18 +79,18 @@ discard block |
||
79 | 79 | } |
80 | 80 | |
81 | 81 | $table = $db->getTableDescription($mod->table_name."_cstm"); |
82 | - foreach($table as $row) { |
|
82 | + foreach ($table as $row) { |
|
83 | 83 | $col = strtolower(empty ($row['Field']) ? $row['field'] : $row['Field']); |
84 | 84 | $the_field = $mod->custom_fields->getField($col); |
85 | 85 | $type = strtolower(empty ($row['Type']) ? $row['type'] : $row['Type']); |
86 | 86 | if (!empty($row['data_precision']) && !empty($row['data_scale'])) { |
87 | - $type.='(' . $row['data_precision']; |
|
87 | + $type .= '('.$row['data_precision']; |
|
88 | 88 | if (!empty($row['data_scale'])) { |
89 | - $type.=',' . $row['data_scale']; |
|
89 | + $type .= ','.$row['data_scale']; |
|
90 | 90 | } |
91 | - $type.=')'; |
|
92 | - } elseif(!empty($row['data_length']) && (strtolower($row['type'])=='varchar' or strtolower($row['type'])=='varchar2')) { |
|
93 | - $type.='(' . $row['data_length'] . ')'; |
|
91 | + $type .= ')'; |
|
92 | + } elseif (!empty($row['data_length']) && (strtolower($row['type']) == 'varchar' or strtolower($row['type']) == 'varchar2')) { |
|
93 | + $type .= '('.$row['data_length'].')'; |
|
94 | 94 | } |
95 | 95 | if (!isset ($fields[$col]) && $col != 'id_c') { |
96 | 96 | if (!$simulate) { |
@@ -100,10 +100,10 @@ discard block |
||
100 | 100 | echo "Dropping Column $col from $mod->table_name"."_cstm for module $the_module<br>"; |
101 | 101 | } else { |
102 | 102 | if ($col != 'id_c') { |
103 | - $db_data_type = strtolower(str_replace(' ' , '', $the_field->get_db_type())); |
|
103 | + $db_data_type = strtolower(str_replace(' ', '', $the_field->get_db_type())); |
|
104 | 104 | |
105 | - $type = strtolower(str_replace(' ' , '', $type)); |
|
106 | - if (strcmp($db_data_type,$type) != 0) { |
|
105 | + $type = strtolower(str_replace(' ', '', $type)); |
|
106 | + if (strcmp($db_data_type, $type) != 0) { |
|
107 | 107 | |
108 | 108 | echo "Fixing Column Type for $col changing $type to ".$db_data_type."<br>"; |
109 | 109 | if (!$simulate) { |
@@ -1,6 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) |
|
2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
3 | 3 | die('Not A Valid Entry Point'); |
4 | +} |
|
4 | 5 | /********************************************************************************* |
5 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
6 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -120,8 +121,9 @@ discard block |
||
120 | 121 | echo sizeof($fields)." field(s) missing from $mod->table_name"."_cstm<br>"; |
121 | 122 | foreach ($fields as $field) { |
122 | 123 | echo "Adding Column $field to $mod->table_name"."_cstm<br>"; |
123 | - if (!$simulate) |
|
124 | - $mod->custom_fields->add_existing_custom_field($field); |
|
124 | + if (!$simulate) { |
|
125 | + $mod->custom_fields->add_existing_custom_field($field); |
|
126 | + } |
|
125 | 127 | } |
126 | 128 | |
127 | 129 | } |
@@ -75,7 +75,7 @@ |
||
75 | 75 | ConcatenateFiles("$from"); |
76 | 76 | |
77 | 77 | }elseif($_REQUEST['js_admin_repair'] == 'repair'){ |
78 | - //should compress existing javascript (including changes done) without overwriting original source files |
|
78 | + //should compress existing javascript (including changes done) without overwriting original source files |
|
79 | 79 | BackUpAndCompressScriptFiles("$from","",false); |
80 | 80 | ConcatenateFiles("$from"); |
81 | 81 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
3 | 3 | /********************************************************************************* |
4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -47,41 +47,41 @@ discard block |
||
47 | 47 | |
48 | 48 | //set default root directory |
49 | 49 | $from = getcwd(); |
50 | - if(isset($_REQUEST['root_directory']) && !empty($_REQUEST['root_directory'])){ |
|
50 | + if (isset($_REQUEST['root_directory']) && !empty($_REQUEST['root_directory'])) { |
|
51 | 51 | $from = $_REQUEST['root_directory']; |
52 | 52 | } |
53 | 53 | //this script can take a while, change max execution time to 10 mins |
54 | 54 | $tmp_time = ini_get('max_execution_time'); |
55 | - ini_set('max_execution_time','600'); |
|
55 | + ini_set('max_execution_time', '600'); |
|
56 | 56 | |
57 | 57 | //figure out which commands to call. |
58 | - if($_REQUEST['js_admin_repair'] == 'concat' ){ |
|
58 | + if ($_REQUEST['js_admin_repair'] == 'concat') { |
|
59 | 59 | //concatenate mode, call the files that will concatenate javascript group files |
60 | 60 | $_REQUEST['js_rebuild_concat'] = 'rebuild'; |
61 | 61 | require_once('jssource/minify.php'); |
62 | 62 | |
63 | - }else{ |
|
63 | + } else { |
|
64 | 64 | $_REQUEST['root_directory'] = getcwd(); |
65 | 65 | require_once('jssource/minify.php'); |
66 | 66 | |
67 | - if($_REQUEST['js_admin_repair'] == 'replace'){ |
|
67 | + if ($_REQUEST['js_admin_repair'] == 'replace') { |
|
68 | 68 | //should replace compressed JS with source js |
69 | - reverseScripts("$from/jssource/src_files","$from"); |
|
69 | + reverseScripts("$from/jssource/src_files", "$from"); |
|
70 | 70 | |
71 | - }elseif($_REQUEST['js_admin_repair'] == 'mini'){ |
|
71 | + }elseif ($_REQUEST['js_admin_repair'] == 'mini') { |
|
72 | 72 | //should replace compressed JS with minified version of source js |
73 | - reverseScripts("$from/jssource/src_files","$from"); |
|
74 | - BackUpAndCompressScriptFiles("$from","",false); |
|
73 | + reverseScripts("$from/jssource/src_files", "$from"); |
|
74 | + BackUpAndCompressScriptFiles("$from", "", false); |
|
75 | 75 | ConcatenateFiles("$from"); |
76 | 76 | |
77 | - }elseif($_REQUEST['js_admin_repair'] == 'repair'){ |
|
77 | + }elseif ($_REQUEST['js_admin_repair'] == 'repair') { |
|
78 | 78 | //should compress existing javascript (including changes done) without overwriting original source files |
79 | - BackUpAndCompressScriptFiles("$from","",false); |
|
79 | + BackUpAndCompressScriptFiles("$from", "", false); |
|
80 | 80 | ConcatenateFiles("$from"); |
81 | 81 | } |
82 | 82 | } |
83 | 83 | //set execution time back to what it was |
84 | - ini_set('max_execution_time',$tmp_time); |
|
84 | + ini_set('max_execution_time', $tmp_time); |
|
85 | 85 | |
86 | 86 | |
87 | 87 |
@@ -1,5 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
3 | + die('Not A Valid Entry Point'); |
|
4 | +} |
|
3 | 5 | /********************************************************************************* |
4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -60,7 +62,7 @@ discard block |
||
60 | 62 | $_REQUEST['js_rebuild_concat'] = 'rebuild'; |
61 | 63 | require_once('jssource/minify.php'); |
62 | 64 | |
63 | - }else{ |
|
65 | + } else{ |
|
64 | 66 | $_REQUEST['root_directory'] = getcwd(); |
65 | 67 | require_once('jssource/minify.php'); |
66 | 68 | |
@@ -68,13 +70,13 @@ discard block |
||
68 | 70 | //should replace compressed JS with source js |
69 | 71 | reverseScripts("$from/jssource/src_files","$from"); |
70 | 72 | |
71 | - }elseif($_REQUEST['js_admin_repair'] == 'mini'){ |
|
73 | + } elseif($_REQUEST['js_admin_repair'] == 'mini'){ |
|
72 | 74 | //should replace compressed JS with minified version of source js |
73 | 75 | reverseScripts("$from/jssource/src_files","$from"); |
74 | 76 | BackUpAndCompressScriptFiles("$from","",false); |
75 | 77 | ConcatenateFiles("$from"); |
76 | 78 | |
77 | - }elseif($_REQUEST['js_admin_repair'] == 'repair'){ |
|
79 | + } elseif($_REQUEST['js_admin_repair'] == 'repair'){ |
|
78 | 80 | //should compress existing javascript (including changes done) without overwriting original source files |
79 | 81 | BackUpAndCompressScriptFiles("$from","",false); |
80 | 82 | ConcatenateFiles("$from"); |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $silent = isset($_REQUEST['silent']) ? true : false; |
43 | 43 | if(is_admin($current_user)){ |
44 | 44 | global $mod_strings; |
45 | - if (!$silent) { echo $mod_strings['LBL_REBUILD_DASHLETS_DESC']; } |
|
45 | + if (!$silent) { echo $mod_strings['LBL_REBUILD_DASHLETS_DESC']; } |
|
46 | 46 | if(is_file($cachedfile = sugar_cached('dashlets/dashlets.php'))) { |
47 | 47 | unlink($cachedfile); |
48 | 48 | } |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | |
51 | 51 | $dc = new DashletCacheBuilder(); |
52 | 52 | $dc->buildCache(); |
53 | - if( !$silent ) echo '<br><br><br><br>' . $mod_strings['LBL_REBUILD_DASHLETS_DESC_SUCCESS']; |
|
53 | + if( !$silent ) echo '<br><br><br><br>' . $mod_strings['LBL_REBUILD_DASHLETS_DESC_SUCCESS']; |
|
54 | 54 | } |
55 | 55 | else{ |
56 | - sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']); |
|
56 | + sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']); |
|
57 | 57 | } |
58 | 58 | ?> |
59 | 59 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
3 | 3 | /********************************************************************************* |
4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -40,19 +40,19 @@ discard block |
||
40 | 40 | |
41 | 41 | global $current_user; |
42 | 42 | $silent = isset($_REQUEST['silent']) ? true : false; |
43 | -if(is_admin($current_user)){ |
|
43 | +if (is_admin($current_user)) { |
|
44 | 44 | global $mod_strings; |
45 | 45 | if (!$silent) { echo $mod_strings['LBL_REBUILD_DASHLETS_DESC']; } |
46 | - if(is_file($cachedfile = sugar_cached('dashlets/dashlets.php'))) { |
|
46 | + if (is_file($cachedfile = sugar_cached('dashlets/dashlets.php'))) { |
|
47 | 47 | unlink($cachedfile); |
48 | 48 | } |
49 | 49 | require_once('include/Dashlets/DashletCacheBuilder.php'); |
50 | 50 | |
51 | 51 | $dc = new DashletCacheBuilder(); |
52 | 52 | $dc->buildCache(); |
53 | - if( !$silent ) echo '<br><br><br><br>' . $mod_strings['LBL_REBUILD_DASHLETS_DESC_SUCCESS']; |
|
53 | + if (!$silent) echo '<br><br><br><br>'.$mod_strings['LBL_REBUILD_DASHLETS_DESC_SUCCESS']; |
|
54 | 54 | } |
55 | -else{ |
|
55 | +else { |
|
56 | 56 | sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']); |
57 | 57 | } |
58 | 58 | ?> |
59 | 59 | \ No newline at end of file |
@@ -1,5 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
3 | + die('Not A Valid Entry Point'); |
|
4 | +} |
|
3 | 5 | /********************************************************************************* |
4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -50,9 +52,10 @@ discard block |
||
50 | 52 | |
51 | 53 | $dc = new DashletCacheBuilder(); |
52 | 54 | $dc->buildCache(); |
53 | - if( !$silent ) echo '<br><br><br><br>' . $mod_strings['LBL_REBUILD_DASHLETS_DESC_SUCCESS']; |
|
54 | -} |
|
55 | -else{ |
|
55 | + if( !$silent ) { |
|
56 | + echo '<br><br><br><br>' . $mod_strings['LBL_REBUILD_DASHLETS_DESC_SUCCESS']; |
|
57 | + } |
|
58 | + } else{ |
|
56 | 59 | sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']); |
57 | 60 | } |
58 | 61 | ?> |
59 | 62 | \ No newline at end of file |
@@ -43,21 +43,21 @@ discard block |
||
43 | 43 | require_once("include/utils/sugar_file_utils.php"); |
44 | 44 | |
45 | 45 | foreach ($beanFiles as $classname => $filename){ |
46 | - if (file_exists($filename)){ |
|
47 | - // Rename the class and its constructor adding SugarCore at the beginning (Ex: class SugarCoreCall) |
|
48 | - $handle = file_get_contents($filename); |
|
46 | + if (file_exists($filename)){ |
|
47 | + // Rename the class and its constructor adding SugarCore at the beginning (Ex: class SugarCoreCall) |
|
48 | + $handle = file_get_contents($filename); |
|
49 | 49 | $patterns = array ('/class '.$classname.'/','/function '.$classname.'/'); |
50 | 50 | $replace = array ('class SugarCore'.$classname,'function SugarCore'.$classname); |
51 | - $data = preg_replace($patterns,$replace, $handle); |
|
52 | - sugar_file_put_contents($filename,$data); |
|
51 | + $data = preg_replace($patterns,$replace, $handle); |
|
52 | + sugar_file_put_contents($filename,$data); |
|
53 | 53 | |
54 | - // Rename the SugarBean file into SugarCore.SugarBean (Ex: SugarCore.Call.php) |
|
55 | - $pos=strrpos($filename,"/"); |
|
56 | - $newfilename=substr_replace($filename, 'SugarCore.', $pos+1, 0); |
|
57 | - sugar_rename($filename,$newfilename); |
|
54 | + // Rename the SugarBean file into SugarCore.SugarBean (Ex: SugarCore.Call.php) |
|
55 | + $pos=strrpos($filename,"/"); |
|
56 | + $newfilename=substr_replace($filename, 'SugarCore.', $pos+1, 0); |
|
57 | + sugar_rename($filename,$newfilename); |
|
58 | 58 | |
59 | - //Create a new SugarBean that extends CoreBean |
|
60 | - $fileHandle = sugar_fopen($filename, 'w') ; |
|
59 | + //Create a new SugarBean that extends CoreBean |
|
60 | + $fileHandle = sugar_fopen($filename, 'w') ; |
|
61 | 61 | $newclass = <<<FABRICE |
62 | 62 | <?php |
63 | 63 | if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
@@ -110,8 +110,8 @@ discard block |
||
110 | 110 | } |
111 | 111 | ?> |
112 | 112 | FABRICE; |
113 | - fwrite($fileHandle, $newclass); |
|
114 | - fclose($fileHandle); |
|
115 | - } |
|
113 | + fwrite($fileHandle, $newclass); |
|
114 | + fclose($fileHandle); |
|
115 | + } |
|
116 | 116 | } |
117 | 117 | ?> |
118 | 118 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
3 | 3 | /********************************************************************************* |
4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -42,22 +42,22 @@ discard block |
||
42 | 42 | require("include/modules.php"); |
43 | 43 | require_once("include/utils/sugar_file_utils.php"); |
44 | 44 | |
45 | -foreach ($beanFiles as $classname => $filename){ |
|
46 | - if (file_exists($filename)){ |
|
45 | +foreach ($beanFiles as $classname => $filename) { |
|
46 | + if (file_exists($filename)) { |
|
47 | 47 | // Rename the class and its constructor adding SugarCore at the beginning (Ex: class SugarCoreCall) |
48 | 48 | $handle = file_get_contents($filename); |
49 | - $patterns = array ('/class '.$classname.'/','/function '.$classname.'/'); |
|
50 | - $replace = array ('class SugarCore'.$classname,'function SugarCore'.$classname); |
|
51 | - $data = preg_replace($patterns,$replace, $handle); |
|
52 | - sugar_file_put_contents($filename,$data); |
|
49 | + $patterns = array('/class '.$classname.'/', '/function '.$classname.'/'); |
|
50 | + $replace = array('class SugarCore'.$classname, 'function SugarCore'.$classname); |
|
51 | + $data = preg_replace($patterns, $replace, $handle); |
|
52 | + sugar_file_put_contents($filename, $data); |
|
53 | 53 | |
54 | 54 | // Rename the SugarBean file into SugarCore.SugarBean (Ex: SugarCore.Call.php) |
55 | - $pos=strrpos($filename,"/"); |
|
56 | - $newfilename=substr_replace($filename, 'SugarCore.', $pos+1, 0); |
|
57 | - sugar_rename($filename,$newfilename); |
|
55 | + $pos = strrpos($filename, "/"); |
|
56 | + $newfilename = substr_replace($filename, 'SugarCore.', $pos + 1, 0); |
|
57 | + sugar_rename($filename, $newfilename); |
|
58 | 58 | |
59 | 59 | //Create a new SugarBean that extends CoreBean |
60 | - $fileHandle = sugar_fopen($filename, 'w') ; |
|
60 | + $fileHandle = sugar_fopen($filename, 'w'); |
|
61 | 61 | $newclass = <<<FABRICE |
62 | 62 | <?php |
63 | 63 | if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
@@ -1,5 +1,7 @@ |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
3 | + die('Not A Valid Entry Point'); |
|
4 | +} |
|
3 | 5 | /********************************************************************************* |
4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -43,8 +43,8 @@ discard block |
||
43 | 43 | } |
44 | 44 | |
45 | 45 | if (empty($_FILES)) { |
46 | - echo $mod_strings['LBL_IMPORT_CUSTOM_FIELDS_DESC']; |
|
47 | - echo <<<EOQ |
|
46 | + echo $mod_strings['LBL_IMPORT_CUSTOM_FIELDS_DESC']; |
|
47 | + echo <<<EOQ |
|
48 | 48 | <br> |
49 | 49 | <br> |
50 | 50 | <form enctype="multipart/form-data" action="index.php" method="POST"> |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | if (trim($line) == 'DONE') { |
65 | 65 | $fmd->new_with_id = true; |
66 | 66 | echo $mod_strings['LBL_IMPORT_CUSTOM_FIELDS_ADDING'] . ':' . $fmd->custom_module . '-' . |
67 | - $fmd->name . '<br>'; |
|
67 | + $fmd->name . '<br>'; |
|
68 | 68 | $fmd->db->query("DELETE FROM $fmd->table_name WHERE id=".$fmd->db->quoted($fmd->id)); |
69 | 69 | $fmd->save(false); |
70 | 70 | $fmd = BeanFactory::getBean('EditCustomFields'); |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | } |
81 | 81 | } |
82 | 82 | } |
83 | - $_REQUEST['run'] = true; |
|
84 | - $result = $fmd->db->query("SELECT count(*) field_count FROM $fmd->table_name"); |
|
85 | - $row = $fmd->db->fetchByAssoc($result); |
|
86 | - echo 'Total Custom Fields :' . $row['field_count'] . '<br>'; |
|
87 | - include('modules/Administration/UpgradeFields.php'); |
|
83 | + $_REQUEST['run'] = true; |
|
84 | + $result = $fmd->db->query("SELECT count(*) field_count FROM $fmd->table_name"); |
|
85 | + $row = $fmd->db->fetchByAssoc($result); |
|
86 | + echo 'Total Custom Fields :' . $row['field_count'] . '<br>'; |
|
87 | + include('modules/Administration/UpgradeFields.php'); |
|
88 | 88 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
3 | 3 | /********************************************************************************* |
4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -57,14 +57,14 @@ discard block |
||
57 | 57 | } else { |
58 | 58 | $fmd = BeanFactory::getBean('EditCustomFields'); |
59 | 59 | |
60 | - echo $mod_strings['LBL_ICF_DROPPING'] . '<br>'; |
|
60 | + echo $mod_strings['LBL_ICF_DROPPING'].'<br>'; |
|
61 | 61 | $lines = file($_FILES['sugfile']['tmp_name']); |
62 | 62 | $cur = array(); |
63 | 63 | foreach ($lines as $line) { |
64 | 64 | if (trim($line) == 'DONE') { |
65 | 65 | $fmd->new_with_id = true; |
66 | - echo $mod_strings['LBL_IMPORT_CUSTOM_FIELDS_ADDING'] . ':' . $fmd->custom_module . '-' . |
|
67 | - $fmd->name . '<br>'; |
|
66 | + echo $mod_strings['LBL_IMPORT_CUSTOM_FIELDS_ADDING'].':'.$fmd->custom_module.'-'. |
|
67 | + $fmd->name.'<br>'; |
|
68 | 68 | $fmd->db->query("DELETE FROM $fmd->table_name WHERE id=".$fmd->db->quoted($fmd->id)); |
69 | 69 | $fmd->save(false); |
70 | 70 | $fmd = BeanFactory::getBean('EditCustomFields'); |
@@ -83,6 +83,6 @@ discard block |
||
83 | 83 | $_REQUEST['run'] = true; |
84 | 84 | $result = $fmd->db->query("SELECT count(*) field_count FROM $fmd->table_name"); |
85 | 85 | $row = $fmd->db->fetchByAssoc($result); |
86 | - echo 'Total Custom Fields :' . $row['field_count'] . '<br>'; |
|
86 | + echo 'Total Custom Fields :'.$row['field_count'].'<br>'; |
|
87 | 87 | include('modules/Administration/UpgradeFields.php'); |
88 | 88 | } |
@@ -1,5 +1,7 @@ |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
3 | + die('Not A Valid Entry Point'); |
|
4 | +} |
|
3 | 5 | /********************************************************************************* |
4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -43,49 +43,49 @@ discard block |
||
43 | 43 | |
44 | 44 | class SugarSpriteBuilder |
45 | 45 | { |
46 | - var $isAvailable = false; |
|
47 | - var $silentRun = false; |
|
46 | + var $isAvailable = false; |
|
47 | + var $silentRun = false; |
|
48 | 48 | var $fromSilentUpgrade = false; |
49 | 49 | var $writeToUpgradeLog = false; |
50 | 50 | |
51 | - var $debug = false; |
|
52 | - var $fileName = 'sprites'; |
|
53 | - var $cssMinify = true; |
|
51 | + var $debug = false; |
|
52 | + var $fileName = 'sprites'; |
|
53 | + var $cssMinify = true; |
|
54 | 54 | |
55 | - // class supported image types |
|
56 | - var $supportedTypeMap = array( |
|
57 | - IMG_GIF => IMAGETYPE_GIF, |
|
58 | - IMG_JPG => IMAGETYPE_JPEG, |
|
59 | - IMG_PNG => IMAGETYPE_PNG, |
|
60 | - ); |
|
55 | + // class supported image types |
|
56 | + var $supportedTypeMap = array( |
|
57 | + IMG_GIF => IMAGETYPE_GIF, |
|
58 | + IMG_JPG => IMAGETYPE_JPEG, |
|
59 | + IMG_PNG => IMAGETYPE_PNG, |
|
60 | + ); |
|
61 | 61 | |
62 | - // sprite settings |
|
63 | - var $pngCompression = 9; |
|
64 | - var $pngFilter = PNG_NO_FILTER; |
|
65 | - var $maxWidth = 75; |
|
66 | - var $maxHeight = 75; |
|
67 | - var $rowCnt = 30; |
|
62 | + // sprite settings |
|
63 | + var $pngCompression = 9; |
|
64 | + var $pngFilter = PNG_NO_FILTER; |
|
65 | + var $maxWidth = 75; |
|
66 | + var $maxHeight = 75; |
|
67 | + var $rowCnt = 30; |
|
68 | 68 | |
69 | - // processed image types |
|
70 | - var $imageTypes = array(); |
|
69 | + // processed image types |
|
70 | + var $imageTypes = array(); |
|
71 | 71 | |
72 | - // source files |
|
73 | - var $spriteSrc = array(); |
|
74 | - var $spriteRepeat = array(); |
|
72 | + // source files |
|
73 | + var $spriteSrc = array(); |
|
74 | + var $spriteRepeat = array(); |
|
75 | 75 | |
76 | - // sprite resource images |
|
77 | - var $spriteImg; |
|
76 | + // sprite resource images |
|
77 | + var $spriteImg; |
|
78 | 78 | |
79 | - // sprite_config collection |
|
80 | - var $sprites_config = array(); |
|
79 | + // sprite_config collection |
|
80 | + var $sprites_config = array(); |
|
81 | 81 | |
82 | 82 | |
83 | 83 | public function __construct() |
84 | 84 | { |
85 | - // check if we have gd installed |
|
86 | - if(function_exists('imagecreatetruecolor')) |
|
85 | + // check if we have gd installed |
|
86 | + if(function_exists('imagecreatetruecolor')) |
|
87 | 87 | { |
88 | - $this->isAvailable = true; |
|
88 | + $this->isAvailable = true; |
|
89 | 89 | foreach($this->supportedTypeMap as $gd_bit => $imagetype) |
90 | 90 | { |
91 | 91 | if(imagetypes() & $gd_bit) { |
@@ -93,13 +93,13 @@ discard block |
||
93 | 93 | $this->imageTypes[$imagetype] = $gd_bit; |
94 | 94 | } |
95 | 95 | } |
96 | - } |
|
96 | + } |
|
97 | 97 | |
98 | 98 | if(function_exists('logThis') && isset($GLOBALS['path'])) |
99 | 99 | { |
100 | 100 | $this->writeToUpgradeLog = true; |
101 | 101 | } |
102 | - } |
|
102 | + } |
|
103 | 103 | |
104 | 104 | |
105 | 105 | /** |
@@ -109,80 +109,80 @@ discard block |
||
109 | 109 | * @param $name String value of the sprite name |
110 | 110 | * @param $dir String value of the directory associated with the sprite entry |
111 | 111 | */ |
112 | - public function addDirectory($name, $dir) { |
|
112 | + public function addDirectory($name, $dir) { |
|
113 | 113 | |
114 | - // sprite namespace |
|
115 | - if(!array_key_exists($name, $this->spriteSrc)) |
|
114 | + // sprite namespace |
|
115 | + if(!array_key_exists($name, $this->spriteSrc)) |
|
116 | 116 | { |
117 | - $this->spriteSrc[$name] = array(); |
|
118 | - } |
|
117 | + $this->spriteSrc[$name] = array(); |
|
118 | + } |
|
119 | 119 | |
120 | - // add files from directory |
|
121 | - $this->spriteSrc[$name][$dir] = $this->getFileList($dir); |
|
122 | - } |
|
120 | + // add files from directory |
|
121 | + $this->spriteSrc[$name][$dir] = $this->getFileList($dir); |
|
122 | + } |
|
123 | 123 | |
124 | - /** |
|
124 | + /** |
|
125 | 125 | * getFileList |
126 | 126 | * |
127 | 127 | * This method processes files in a directory and adds them to the sprites array |
128 | 128 | * @param $dir String value of the directory to scan for image files in |
129 | 129 | */ |
130 | - private function getFileList($dir) { |
|
131 | - $list = array(); |
|
132 | - if(is_dir($dir)) { |
|
133 | - if($dh = opendir($dir)) { |
|
130 | + private function getFileList($dir) { |
|
131 | + $list = array(); |
|
132 | + if(is_dir($dir)) { |
|
133 | + if($dh = opendir($dir)) { |
|
134 | 134 | |
135 | - // optional sprites_config.php file |
|
136 | - $this->loadSpritesConfig($dir); |
|
135 | + // optional sprites_config.php file |
|
136 | + $this->loadSpritesConfig($dir); |
|
137 | 137 | |
138 | - while (($file = readdir($dh)) !== false) |
|
138 | + while (($file = readdir($dh)) !== false) |
|
139 | 139 | { |
140 | - if ($file != "." && $file != ".." && $file != "sprites_config.php") |
|
140 | + if ($file != "." && $file != ".." && $file != "sprites_config.php") |
|
141 | 141 | { |
142 | 142 | |
143 | - // file info & check supported image format |
|
144 | - if($info = $this->getFileInfo($dir, $file)) { |
|
143 | + // file info & check supported image format |
|
144 | + if($info = $this->getFileInfo($dir, $file)) { |
|
145 | 145 | |
146 | - // skip excluded files |
|
147 | - if(isset($this->sprites_config[$dir]['exclude']) && array_search($file, $this->sprites_config[$dir]['exclude']) !== false) |
|
146 | + // skip excluded files |
|
147 | + if(isset($this->sprites_config[$dir]['exclude']) && array_search($file, $this->sprites_config[$dir]['exclude']) !== false) |
|
148 | 148 | { |
149 | 149 | global $mod_strings; |
150 | 150 | $msg = string_format($mod_strings['LBL_SPRITES_EXCLUDING_FILE'], array("{$dir}/{$file}")); |
151 | - $GLOBALS['log']->debug($msg); |
|
151 | + $GLOBALS['log']->debug($msg); |
|
152 | 152 | $this->logMessage($msg); |
153 | - } else { |
|
154 | - // repeatable sprite ? |
|
155 | - $isRepeat = false; |
|
153 | + } else { |
|
154 | + // repeatable sprite ? |
|
155 | + $isRepeat = false; |
|
156 | 156 | |
157 | - if(isset($this->sprites_config[$dir]['repeat'])) |
|
157 | + if(isset($this->sprites_config[$dir]['repeat'])) |
|
158 | 158 | { |
159 | - foreach($this->sprites_config[$dir]['repeat'] as $repeat) |
|
159 | + foreach($this->sprites_config[$dir]['repeat'] as $repeat) |
|
160 | 160 | { |
161 | - if($info['x'] == $repeat['width'] && $info['y'] == $repeat['height']) |
|
161 | + if($info['x'] == $repeat['width'] && $info['y'] == $repeat['height']) |
|
162 | 162 | { |
163 | - $id = md5($repeat['width'].$repeat['height'].$repeat['direction']); |
|
164 | - $isRepeat = true; |
|
165 | - $this->spriteRepeat['repeat_'.$repeat['direction'].'_'.$id][$dir][$file] = $info; |
|
166 | - } |
|
167 | - } |
|
168 | - } |
|
169 | - |
|
170 | - if(!$isRepeat) |
|
163 | + $id = md5($repeat['width'].$repeat['height'].$repeat['direction']); |
|
164 | + $isRepeat = true; |
|
165 | + $this->spriteRepeat['repeat_'.$repeat['direction'].'_'.$id][$dir][$file] = $info; |
|
166 | + } |
|
167 | + } |
|
168 | + } |
|
169 | + |
|
170 | + if(!$isRepeat) |
|
171 | 171 | { |
172 | - $list[$file] = $info; |
|
172 | + $list[$file] = $info; |
|
173 | 173 | } |
174 | - } |
|
175 | - } else if(preg_match('/\.(jpg|jpeg|gif|png|bmp|ico)$/i', $file)) { |
|
174 | + } |
|
175 | + } else if(preg_match('/\.(jpg|jpeg|gif|png|bmp|ico)$/i', $file)) { |
|
176 | 176 | $GLOBALS['log']->error('Unable to process image file ' . $file); |
177 | 177 | //$this->logMessage('Unable to process image file ' . $file); |
178 | 178 | } |
179 | - } |
|
180 | - } |
|
181 | - } |
|
182 | - closedir($dh); |
|
183 | - } |
|
184 | - return $list; |
|
185 | - } |
|
179 | + } |
|
180 | + } |
|
181 | + } |
|
182 | + closedir($dh); |
|
183 | + } |
|
184 | + return $list; |
|
185 | + } |
|
186 | 186 | |
187 | 187 | |
188 | 188 | /** |
@@ -194,19 +194,19 @@ discard block |
||
194 | 194 | * |
195 | 195 | * @param $dir String value of the directory containing the custom sprites_config.php file |
196 | 196 | */ |
197 | - private function loadSpritesConfig($dir) { |
|
198 | - $sprites_config = array(); |
|
199 | - if(file_exists("$dir/sprites_config.php")) |
|
197 | + private function loadSpritesConfig($dir) { |
|
198 | + $sprites_config = array(); |
|
199 | + if(file_exists("$dir/sprites_config.php")) |
|
200 | 200 | { |
201 | - include("$dir/sprites_config.php"); |
|
202 | - if(count($sprites_config)) { |
|
203 | - $this->sprites_config = array_merge($this->sprites_config, $sprites_config); |
|
204 | - } |
|
205 | - } |
|
206 | - } |
|
201 | + include("$dir/sprites_config.php"); |
|
202 | + if(count($sprites_config)) { |
|
203 | + $this->sprites_config = array_merge($this->sprites_config, $sprites_config); |
|
204 | + } |
|
205 | + } |
|
206 | + } |
|
207 | 207 | |
208 | 208 | |
209 | - /** |
|
209 | + /** |
|
210 | 210 | * getFileInfo |
211 | 211 | * |
212 | 212 | * This is a private helper function to return attributes about an image. If the width, height or type of the |
@@ -214,44 +214,44 @@ discard block |
||
214 | 214 | * |
215 | 215 | * @return array of file info entries containing file information (x, y, type) if image type is supported |
216 | 216 | */ |
217 | - private function getFileInfo($dir, $file) { |
|
218 | - $result = false; |
|
219 | - $info = @getimagesize($dir.'/'.$file); |
|
220 | - if($info) { |
|
217 | + private function getFileInfo($dir, $file) { |
|
218 | + $result = false; |
|
219 | + $info = @getimagesize($dir.'/'.$file); |
|
220 | + if($info) { |
|
221 | 221 | |
222 | - // supported image type ? |
|
223 | - if(isset($this->imageTypes[$info[2]])) |
|
222 | + // supported image type ? |
|
223 | + if(isset($this->imageTypes[$info[2]])) |
|
224 | 224 | { |
225 | - $w = $info[0]; |
|
226 | - $h = $info[1]; |
|
227 | - $surface = $w * $h; |
|
225 | + $w = $info[0]; |
|
226 | + $h = $info[1]; |
|
227 | + $surface = $w * $h; |
|
228 | 228 | |
229 | - // be sure we have an image size |
|
230 | - $addSprite = false; |
|
231 | - if($surface) |
|
229 | + // be sure we have an image size |
|
230 | + $addSprite = false; |
|
231 | + if($surface) |
|
232 | 232 | { |
233 | - // sprite dimensions |
|
234 | - if($w <= $this->maxWidth && $h <= $this->maxHeight) |
|
233 | + // sprite dimensions |
|
234 | + if($w <= $this->maxWidth && $h <= $this->maxHeight) |
|
235 | 235 | { |
236 | - $addSprite = true; |
|
237 | - } |
|
238 | - } |
|
236 | + $addSprite = true; |
|
237 | + } |
|
238 | + } |
|
239 | 239 | |
240 | - if($addSprite) |
|
240 | + if($addSprite) |
|
241 | 241 | { |
242 | - $result = array(); |
|
243 | - $result['x'] = $w; |
|
244 | - $result['y'] = $h; |
|
245 | - $result['type'] = $info[2]; |
|
246 | - } |
|
247 | - } else { |
|
242 | + $result = array(); |
|
243 | + $result['x'] = $w; |
|
244 | + $result['y'] = $h; |
|
245 | + $result['type'] = $info[2]; |
|
246 | + } |
|
247 | + } else { |
|
248 | 248 | $msg = "Skipping unsupported image file type ({$info[2]}) for file {$file}"; |
249 | 249 | $GLOBALS['log']->error($msg); |
250 | 250 | $this->logMessage($msg."\n"); |
251 | 251 | } |
252 | - } |
|
253 | - return $result; |
|
254 | - } |
|
252 | + } |
|
253 | + return $result; |
|
254 | + } |
|
255 | 255 | |
256 | 256 | |
257 | 257 | /** |
@@ -261,220 +261,220 @@ discard block |
||
261 | 261 | * |
262 | 262 | * @return $result boolean value indicating whether or not sprites were created |
263 | 263 | */ |
264 | - public function createSprites() { |
|
264 | + public function createSprites() { |
|
265 | 265 | |
266 | 266 | global $mod_strings; |
267 | 267 | |
268 | - if(!$this->isAvailable) |
|
268 | + if(!$this->isAvailable) |
|
269 | 269 | { |
270 | - if(!$this->silentRun) |
|
270 | + if(!$this->silentRun) |
|
271 | 271 | { |
272 | 272 | $msg = $mod_strings['LBL_SPRITES_NOT_SUPPORTED']; |
273 | 273 | $GLOBALS['log']->warn($msg); |
274 | 274 | $this->logMessage($msg); |
275 | 275 | } |
276 | - return false; |
|
277 | - } |
|
276 | + return false; |
|
277 | + } |
|
278 | 278 | |
279 | - // add repeatable sprites |
|
280 | - if(count($this->spriteRepeat)) |
|
279 | + // add repeatable sprites |
|
280 | + if(count($this->spriteRepeat)) |
|
281 | 281 | { |
282 | - $this->spriteSrc = array_merge($this->spriteSrc, $this->spriteRepeat); |
|
282 | + $this->spriteSrc = array_merge($this->spriteSrc, $this->spriteRepeat); |
|
283 | 283 | } |
284 | 284 | |
285 | - foreach($this->spriteSrc as $name => $dirs) |
|
285 | + foreach($this->spriteSrc as $name => $dirs) |
|
286 | 286 | { |
287 | - if(!$this->silentRun) |
|
287 | + if(!$this->silentRun) |
|
288 | 288 | { |
289 | 289 | $msg = string_format($mod_strings['LBL_SPRITES_CREATING_NAMESPACE'], array($name)); |
290 | 290 | $GLOBALS['log']->debug($msg); |
291 | - $this->logMessage($msg); |
|
291 | + $this->logMessage($msg); |
|
292 | 292 | } |
293 | 293 | |
294 | - // setup config for sprite placement algorithm |
|
295 | - if(substr($name, 0, 6) == 'repeat') |
|
294 | + // setup config for sprite placement algorithm |
|
295 | + if(substr($name, 0, 6) == 'repeat') |
|
296 | 296 | { |
297 | - $isRepeat = true; |
|
297 | + $isRepeat = true; |
|
298 | 298 | $type = substr($name, 7, 10) == 'horizontal' ? 'horizontal' : 'vertical'; |
299 | - $config = array( |
|
300 | - 'type' => $type, |
|
301 | - ); |
|
302 | - } else { |
|
303 | - $isRepeat = false; |
|
304 | - $config = array( |
|
305 | - 'type' => 'boxed', |
|
306 | - 'width' => $this->maxWidth, |
|
307 | - 'height' => $this->maxHeight, |
|
308 | - 'rowcnt' => $this->rowCnt, |
|
309 | - ); |
|
310 | - } |
|
311 | - |
|
312 | - // use separate class to arrange the images |
|
313 | - $sp = new SpritePlacement($dirs, $config); |
|
314 | - $sp->processSprites(); |
|
315 | - |
|
316 | - //if(! $this->silentRun) |
|
317 | - // echo " (size {$sp->width()}x{$sp->height()})<br />"; |
|
318 | - |
|
319 | - // we need a target image size |
|
320 | - if($sp->width() && $sp->height()) |
|
299 | + $config = array( |
|
300 | + 'type' => $type, |
|
301 | + ); |
|
302 | + } else { |
|
303 | + $isRepeat = false; |
|
304 | + $config = array( |
|
305 | + 'type' => 'boxed', |
|
306 | + 'width' => $this->maxWidth, |
|
307 | + 'height' => $this->maxHeight, |
|
308 | + 'rowcnt' => $this->rowCnt, |
|
309 | + ); |
|
310 | + } |
|
311 | + |
|
312 | + // use separate class to arrange the images |
|
313 | + $sp = new SpritePlacement($dirs, $config); |
|
314 | + $sp->processSprites(); |
|
315 | + |
|
316 | + //if(! $this->silentRun) |
|
317 | + // echo " (size {$sp->width()}x{$sp->height()})<br />"; |
|
318 | + |
|
319 | + // we need a target image size |
|
320 | + if($sp->width() && $sp->height()) |
|
321 | 321 | { |
322 | - // init sprite image |
|
323 | - $this->initSpriteImg($sp->width(), $sp->height()); |
|
322 | + // init sprite image |
|
323 | + $this->initSpriteImg($sp->width(), $sp->height()); |
|
324 | 324 | |
325 | - // add sprites based upon determined coordinates |
|
326 | - foreach($dirs as $dir => $files) |
|
325 | + // add sprites based upon determined coordinates |
|
326 | + foreach($dirs as $dir => $files) |
|
327 | 327 | { |
328 | - if(!$this->silentRun) |
|
328 | + if(!$this->silentRun) |
|
329 | 329 | { |
330 | 330 | $msg = string_format($mod_strings['LBL_SPRITES_PROCESSING_DIR'], array($dir)); |
331 | 331 | $GLOBALS['log']->debug($msg); |
332 | 332 | $this->logMessage($msg); |
333 | 333 | } |
334 | 334 | |
335 | - foreach($files as $file => $info) |
|
335 | + foreach($files as $file => $info) |
|
336 | 336 | { |
337 | - if($im = $this->loadImage($dir, $file, $info['type'])) |
|
337 | + if($im = $this->loadImage($dir, $file, $info['type'])) |
|
338 | 338 | { |
339 | - // coordinates |
|
340 | - $dst_x = $sp->spriteMatrix[$dir.'/'.$file]['x']; |
|
341 | - $dst_y = $sp->spriteMatrix[$dir.'/'.$file]['y']; |
|
339 | + // coordinates |
|
340 | + $dst_x = $sp->spriteMatrix[$dir.'/'.$file]['x']; |
|
341 | + $dst_y = $sp->spriteMatrix[$dir.'/'.$file]['y']; |
|
342 | 342 | |
343 | - imagecopy($this->spriteImg, $im, $dst_x, $dst_y, 0, 0, $info['x'], $info['y']); |
|
344 | - imagedestroy($im); |
|
343 | + imagecopy($this->spriteImg, $im, $dst_x, $dst_y, 0, 0, $info['x'], $info['y']); |
|
344 | + imagedestroy($im); |
|
345 | 345 | |
346 | - if(!$this->silentRun) |
|
346 | + if(!$this->silentRun) |
|
347 | 347 | { |
348 | 348 | $msg = string_format($mod_strings['LBL_SPRITES_ADDED'], array("{$dir}/{$file}")); |
349 | 349 | $GLOBALS['log']->debug($msg); |
350 | 350 | $this->logMessage($msg); |
351 | 351 | } |
352 | - } |
|
353 | - } |
|
354 | - } |
|
352 | + } |
|
353 | + } |
|
354 | + } |
|
355 | 355 | |
356 | - // dir & filenames |
|
357 | - if($isRepeat) |
|
356 | + // dir & filenames |
|
357 | + if($isRepeat) |
|
358 | 358 | { |
359 | - $outputDir = sugar_cached("sprites/Repeatable"); |
|
360 | - $spriteFileName = "{$name}.png"; |
|
361 | - $cssFileName = "{$this->fileName}.css"; |
|
362 | - $metaFileName = "{$this->fileName}.meta.php"; |
|
363 | - $nameSpace = "Repeatable"; |
|
364 | - } else { |
|
365 | - $outputDir = sugar_cached("sprites/$name"); |
|
366 | - $spriteFileName = "{$this->fileName}.png"; |
|
367 | - $cssFileName = "{$this->fileName}.css"; |
|
368 | - $metaFileName = "{$this->fileName}.meta.php"; |
|
369 | - $nameSpace = "{$name}"; |
|
370 | - } |
|
371 | - |
|
372 | - // directory structure |
|
373 | - if(!is_dir(sugar_cached("sprites/$nameSpace"))) |
|
359 | + $outputDir = sugar_cached("sprites/Repeatable"); |
|
360 | + $spriteFileName = "{$name}.png"; |
|
361 | + $cssFileName = "{$this->fileName}.css"; |
|
362 | + $metaFileName = "{$this->fileName}.meta.php"; |
|
363 | + $nameSpace = "Repeatable"; |
|
364 | + } else { |
|
365 | + $outputDir = sugar_cached("sprites/$name"); |
|
366 | + $spriteFileName = "{$this->fileName}.png"; |
|
367 | + $cssFileName = "{$this->fileName}.css"; |
|
368 | + $metaFileName = "{$this->fileName}.meta.php"; |
|
369 | + $nameSpace = "{$name}"; |
|
370 | + } |
|
371 | + |
|
372 | + // directory structure |
|
373 | + if(!is_dir(sugar_cached("sprites/$nameSpace"))) |
|
374 | 374 | { |
375 | - sugar_mkdir(sugar_cached("sprites/$nameSpace"), 0775, true); |
|
375 | + sugar_mkdir(sugar_cached("sprites/$nameSpace"), 0775, true); |
|
376 | 376 | } |
377 | 377 | |
378 | - // save sprite image |
|
379 | - imagepng($this->spriteImg, "$outputDir/$spriteFileName", $this->pngCompression, $this->pngFilter); |
|
380 | - imagedestroy($this->spriteImg); |
|
378 | + // save sprite image |
|
379 | + imagepng($this->spriteImg, "$outputDir/$spriteFileName", $this->pngCompression, $this->pngFilter); |
|
380 | + imagedestroy($this->spriteImg); |
|
381 | 381 | |
382 | - /* generate css & metadata */ |
|
382 | + /* generate css & metadata */ |
|
383 | 383 | |
384 | - $head = ''; |
|
385 | - $body = ''; |
|
386 | - $metadata = ''; |
|
384 | + $head = ''; |
|
385 | + $body = ''; |
|
386 | + $metadata = ''; |
|
387 | 387 | |
388 | - foreach($sp->spriteSrc as $id => $info) |
|
388 | + foreach($sp->spriteSrc as $id => $info) |
|
389 | 389 | { |
390 | - // sprite id |
|
391 | - $hash_id = md5($id); |
|
390 | + // sprite id |
|
391 | + $hash_id = md5($id); |
|
392 | 392 | |
393 | - // header |
|
394 | - $head .= "span.spr_{$hash_id},\n"; |
|
393 | + // header |
|
394 | + $head .= "span.spr_{$hash_id},\n"; |
|
395 | 395 | |
396 | - // image size |
|
397 | - $w = $info['x']; |
|
398 | - $h = $info['y']; |
|
396 | + // image size |
|
397 | + $w = $info['x']; |
|
398 | + $h = $info['y']; |
|
399 | 399 | |
400 | - // image offset |
|
401 | - $offset_x = $sp->spriteMatrix[$id]['x']; |
|
402 | - $offset_y = $sp->spriteMatrix[$id]['y']; |
|
400 | + // image offset |
|
401 | + $offset_x = $sp->spriteMatrix[$id]['x']; |
|
402 | + $offset_y = $sp->spriteMatrix[$id]['y']; |
|
403 | 403 | |
404 | - // sprite css |
|
405 | - $body .= "/* {$id} */ |
|
404 | + // sprite css |
|
405 | + $body .= "/* {$id} */ |
|
406 | 406 | span.spr_{$hash_id} { |
407 | 407 | width: {$w}px; |
408 | 408 | height: {$h}px; |
409 | 409 | background-position: -{$offset_x}px -{$offset_y}px; |
410 | 410 | }\n"; |
411 | 411 | |
412 | - $metadata .= '$sprites["'.$id.'"] = array ("class"=>"'.$hash_id.'","width"=>"'.$w.'","height"=>"'.$h.'");'."\n"; |
|
413 | - } |
|
412 | + $metadata .= '$sprites["'.$id.'"] = array ("class"=>"'.$hash_id.'","width"=>"'.$w.'","height"=>"'.$h.'");'."\n"; |
|
413 | + } |
|
414 | 414 | |
415 | - // common css header |
|
415 | + // common css header |
|
416 | 416 | require_once('include/utils.php'); |
417 | 417 | $bg_path = getVersionedPath('index.php').'&entryPoint=getImage&imageName='.$spriteFileName.'&spriteNamespace='.$nameSpace; |
418 | - $head = rtrim($head, "\n,")." {background: url('../../../{$bg_path}'); no-repeat;display:inline-block;}\n"; |
|
418 | + $head = rtrim($head, "\n,")." {background: url('../../../{$bg_path}'); no-repeat;display:inline-block;}\n"; |
|
419 | 419 | |
420 | - // append mode for repeatable sprites |
|
420 | + // append mode for repeatable sprites |
|
421 | 421 | $fileMode = $isRepeat ? 'a' : 'w'; |
422 | 422 | |
423 | - // save css |
|
424 | - $css_content = "\n/* autogenerated sprites - $name */\n".$head.$body; |
|
425 | - if($this->cssMinify) |
|
423 | + // save css |
|
424 | + $css_content = "\n/* autogenerated sprites - $name */\n".$head.$body; |
|
425 | + if($this->cssMinify) |
|
426 | 426 | { |
427 | - $css_content = cssmin::minify($css_content); |
|
427 | + $css_content = cssmin::minify($css_content); |
|
428 | 428 | } |
429 | - $fh = fopen("$outputDir/$cssFileName", $fileMode); |
|
430 | - fwrite($fh, $css_content); |
|
431 | - fclose($fh); |
|
432 | - |
|
433 | - /* save metadata */ |
|
434 | - $add_php_tag = (file_exists("$outputDir/$metaFileName") && $isRepeat) ? false : true; |
|
435 | - $fh = fopen("$outputDir/$metaFileName", $fileMode); |
|
436 | - if($add_php_tag) |
|
429 | + $fh = fopen("$outputDir/$cssFileName", $fileMode); |
|
430 | + fwrite($fh, $css_content); |
|
431 | + fclose($fh); |
|
432 | + |
|
433 | + /* save metadata */ |
|
434 | + $add_php_tag = (file_exists("$outputDir/$metaFileName") && $isRepeat) ? false : true; |
|
435 | + $fh = fopen("$outputDir/$metaFileName", $fileMode); |
|
436 | + if($add_php_tag) |
|
437 | 437 | { |
438 | - fwrite($fh, '<?php'); |
|
438 | + fwrite($fh, '<?php'); |
|
439 | 439 | } |
440 | - fwrite($fh, "\n/* sprites metadata - $name */\n"); |
|
441 | - fwrite($fh, $metadata."\n"); |
|
442 | - fclose($fh); |
|
440 | + fwrite($fh, "\n/* sprites metadata - $name */\n"); |
|
441 | + fwrite($fh, $metadata."\n"); |
|
442 | + fclose($fh); |
|
443 | 443 | |
444 | - // if width & height |
|
445 | - } else { |
|
444 | + // if width & height |
|
445 | + } else { |
|
446 | 446 | |
447 | - if(!$this->silentRun) |
|
447 | + if(!$this->silentRun) |
|
448 | 448 | { |
449 | 449 | $msg = string_format($mod_strings['LBL_SPRITES_ADDED'], array($name)); |
450 | 450 | $GLOBALS['log']->debug($msg); |
451 | 451 | $this->logMessage($msg); |
452 | 452 | } |
453 | 453 | |
454 | - } |
|
454 | + } |
|
455 | 455 | |
456 | - } |
|
457 | - return true; |
|
458 | - } |
|
456 | + } |
|
457 | + return true; |
|
458 | + } |
|
459 | 459 | |
460 | 460 | |
461 | - /** |
|
461 | + /** |
|
462 | 462 | * initSpriteImg |
463 | 463 | * |
464 | 464 | * @param w int value representing width of sprite |
465 | 465 | * @param h int value representing height of sprite |
466 | 466 | * Private function to initialize creating the sprite canvas image |
467 | 467 | */ |
468 | - private function initSpriteImg($w, $h) { |
|
469 | - $this->spriteImg = imagecreatetruecolor($w,$h); |
|
470 | - $transparent = imagecolorallocatealpha($this->spriteImg, 0, 0, 0, 127); |
|
471 | - imagefill($this->spriteImg, 0, 0, $transparent); |
|
472 | - imagealphablending($this->spriteImg, false); |
|
473 | - imagesavealpha($this->spriteImg, true); |
|
474 | - } |
|
468 | + private function initSpriteImg($w, $h) { |
|
469 | + $this->spriteImg = imagecreatetruecolor($w,$h); |
|
470 | + $transparent = imagecolorallocatealpha($this->spriteImg, 0, 0, 0, 127); |
|
471 | + imagefill($this->spriteImg, 0, 0, $transparent); |
|
472 | + imagealphablending($this->spriteImg, false); |
|
473 | + imagesavealpha($this->spriteImg, true); |
|
474 | + } |
|
475 | 475 | |
476 | 476 | |
477 | - /** |
|
477 | + /** |
|
478 | 478 | * loadImage |
479 | 479 | * |
480 | 480 | * private function to load image resources |
@@ -484,19 +484,19 @@ discard block |
||
484 | 484 | * @param $type String value of the file type (IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG) |
485 | 485 | * |
486 | 486 | */ |
487 | - private function loadImage($dir, $file, $type) { |
|
488 | - $path_file = $dir.'/'.$file; |
|
489 | - switch($type) { |
|
490 | - case IMAGETYPE_GIF: |
|
491 | - return imagecreatefromgif($path_file); |
|
492 | - case IMAGETYPE_JPEG: |
|
493 | - return imagecreatefromjpeg($path_file); |
|
494 | - case IMAGETYPE_PNG: |
|
495 | - return imagecreatefrompng($path_file); |
|
496 | - default: |
|
497 | - return false; |
|
498 | - } |
|
499 | - } |
|
487 | + private function loadImage($dir, $file, $type) { |
|
488 | + $path_file = $dir.'/'.$file; |
|
489 | + switch($type) { |
|
490 | + case IMAGETYPE_GIF: |
|
491 | + return imagecreatefromgif($path_file); |
|
492 | + case IMAGETYPE_JPEG: |
|
493 | + return imagecreatefromjpeg($path_file); |
|
494 | + case IMAGETYPE_PNG: |
|
495 | + return imagecreatefrompng($path_file); |
|
496 | + default: |
|
497 | + return false; |
|
498 | + } |
|
499 | + } |
|
500 | 500 | |
501 | 501 | /** |
502 | 502 | * private logMessage |
@@ -527,17 +527,17 @@ discard block |
||
527 | 527 | class SpritePlacement |
528 | 528 | { |
529 | 529 | |
530 | - // occupied space |
|
531 | - var $spriteMatrix = array(); |
|
530 | + // occupied space |
|
531 | + var $spriteMatrix = array(); |
|
532 | 532 | |
533 | - // minimum surface |
|
534 | - var $minSurface = 0; |
|
533 | + // minimum surface |
|
534 | + var $minSurface = 0; |
|
535 | 535 | |
536 | - // sprite src (flattened array) |
|
537 | - var $spriteSrc = array(); |
|
536 | + // sprite src (flattened array) |
|
537 | + var $spriteSrc = array(); |
|
538 | 538 | |
539 | - // placement config array |
|
540 | - /* |
|
539 | + // placement config array |
|
540 | + /* |
|
541 | 541 | type = boxed |
542 | 542 | horizontal |
543 | 543 | vertical |
@@ -548,99 +548,99 @@ discard block |
||
548 | 548 | -> rowcnt |
549 | 549 | |
550 | 550 | */ |
551 | - var $config = array(); |
|
552 | - |
|
553 | - function __construct($spriteSrc, $config) { |
|
554 | - |
|
555 | - // convert spriteSrc to flat array |
|
556 | - foreach($spriteSrc as $dir => $files) { |
|
557 | - foreach($files as $file => $info) { |
|
558 | - // use full path as identifier |
|
559 | - $full_path = $dir.'/'.$file; |
|
560 | - $this->spriteSrc[$full_path] = $info; |
|
561 | - } |
|
562 | - } |
|
563 | - |
|
564 | - $this->config = $config; |
|
565 | - } |
|
566 | - |
|
567 | - function processSprites() { |
|
568 | - |
|
569 | - foreach($this->spriteSrc as $id => $info) { |
|
570 | - |
|
571 | - // dimensions |
|
572 | - $x = $info['x']; |
|
573 | - $y = $info['y']; |
|
574 | - |
|
575 | - // update min surface |
|
576 | - $this->minSurface += $x * $y; |
|
577 | - |
|
578 | - // get coordinates where to add this sprite |
|
579 | - if($coor = $this->addSprite($x, $y)) { |
|
580 | - $this->spriteMatrix[$id] = $coor; |
|
581 | - } |
|
582 | - } |
|
583 | - } |
|
584 | - |
|
585 | - // returns x/y coordinates to fit the sprite |
|
586 | - function addSprite($w, $h) { |
|
587 | - $result = false; |
|
588 | - |
|
589 | - switch($this->config['type']) { |
|
590 | - |
|
591 | - // boxed |
|
592 | - case 'boxed': |
|
593 | - |
|
594 | - $spriteX = $this->config['width']; |
|
595 | - $spriteY = $this->config['height']; |
|
596 | - $spriteCnt = count($this->spriteMatrix) + 1; |
|
597 | - $y = ceil($spriteCnt / $this->config['rowcnt']); |
|
598 | - $x = $spriteCnt - (($y - 1) * $this->config['rowcnt']); |
|
599 | - $result = array( |
|
600 | - 'x' => ($x * $spriteX) + 1 - $spriteX, |
|
601 | - 'y' => ($y * $spriteY) + 1 - $spriteY); |
|
602 | - |
|
603 | - break; |
|
604 | - |
|
605 | - // horizontal -> align vertically |
|
606 | - case 'horizontal': |
|
607 | - $result = array('x' => 1, 'y' => $this->height() + 1); |
|
608 | - break; |
|
609 | - |
|
610 | - // vertical -> align horizontally |
|
611 | - case 'vertical': |
|
612 | - $result = array('x' => $this->width() + 1, 'y' => 1); |
|
613 | - break; |
|
614 | - |
|
615 | - default: |
|
616 | - $GLOBALS['log']->warn(__CLASS__.": Unknown sprite placement algorithm -> {$this->config['type']}"); |
|
617 | - break; |
|
618 | - } |
|
619 | - |
|
620 | - return $result; |
|
621 | - } |
|
622 | - |
|
623 | - // calculate total width |
|
624 | - function width() { |
|
625 | - return $this->getMaxAxis('x'); |
|
626 | - } |
|
627 | - |
|
628 | - // calculate total height |
|
629 | - function height() { |
|
630 | - return $this->getMaxAxis('y'); |
|
631 | - } |
|
632 | - |
|
633 | - // helper function to get highest axis value |
|
634 | - function getMaxAxis($axis) { |
|
635 | - $val = 0; |
|
636 | - foreach($this->spriteMatrix as $id => $coor) { |
|
637 | - $new_val = $coor[$axis] + $this->spriteSrc[$id][$axis] - 1; |
|
638 | - if($new_val > $val) { |
|
639 | - $val = $new_val; |
|
640 | - } |
|
641 | - } |
|
642 | - return $val; |
|
643 | - } |
|
551 | + var $config = array(); |
|
552 | + |
|
553 | + function __construct($spriteSrc, $config) { |
|
554 | + |
|
555 | + // convert spriteSrc to flat array |
|
556 | + foreach($spriteSrc as $dir => $files) { |
|
557 | + foreach($files as $file => $info) { |
|
558 | + // use full path as identifier |
|
559 | + $full_path = $dir.'/'.$file; |
|
560 | + $this->spriteSrc[$full_path] = $info; |
|
561 | + } |
|
562 | + } |
|
563 | + |
|
564 | + $this->config = $config; |
|
565 | + } |
|
566 | + |
|
567 | + function processSprites() { |
|
568 | + |
|
569 | + foreach($this->spriteSrc as $id => $info) { |
|
570 | + |
|
571 | + // dimensions |
|
572 | + $x = $info['x']; |
|
573 | + $y = $info['y']; |
|
574 | + |
|
575 | + // update min surface |
|
576 | + $this->minSurface += $x * $y; |
|
577 | + |
|
578 | + // get coordinates where to add this sprite |
|
579 | + if($coor = $this->addSprite($x, $y)) { |
|
580 | + $this->spriteMatrix[$id] = $coor; |
|
581 | + } |
|
582 | + } |
|
583 | + } |
|
584 | + |
|
585 | + // returns x/y coordinates to fit the sprite |
|
586 | + function addSprite($w, $h) { |
|
587 | + $result = false; |
|
588 | + |
|
589 | + switch($this->config['type']) { |
|
590 | + |
|
591 | + // boxed |
|
592 | + case 'boxed': |
|
593 | + |
|
594 | + $spriteX = $this->config['width']; |
|
595 | + $spriteY = $this->config['height']; |
|
596 | + $spriteCnt = count($this->spriteMatrix) + 1; |
|
597 | + $y = ceil($spriteCnt / $this->config['rowcnt']); |
|
598 | + $x = $spriteCnt - (($y - 1) * $this->config['rowcnt']); |
|
599 | + $result = array( |
|
600 | + 'x' => ($x * $spriteX) + 1 - $spriteX, |
|
601 | + 'y' => ($y * $spriteY) + 1 - $spriteY); |
|
602 | + |
|
603 | + break; |
|
604 | + |
|
605 | + // horizontal -> align vertically |
|
606 | + case 'horizontal': |
|
607 | + $result = array('x' => 1, 'y' => $this->height() + 1); |
|
608 | + break; |
|
609 | + |
|
610 | + // vertical -> align horizontally |
|
611 | + case 'vertical': |
|
612 | + $result = array('x' => $this->width() + 1, 'y' => 1); |
|
613 | + break; |
|
614 | + |
|
615 | + default: |
|
616 | + $GLOBALS['log']->warn(__CLASS__.": Unknown sprite placement algorithm -> {$this->config['type']}"); |
|
617 | + break; |
|
618 | + } |
|
619 | + |
|
620 | + return $result; |
|
621 | + } |
|
622 | + |
|
623 | + // calculate total width |
|
624 | + function width() { |
|
625 | + return $this->getMaxAxis('x'); |
|
626 | + } |
|
627 | + |
|
628 | + // calculate total height |
|
629 | + function height() { |
|
630 | + return $this->getMaxAxis('y'); |
|
631 | + } |
|
632 | + |
|
633 | + // helper function to get highest axis value |
|
634 | + function getMaxAxis($axis) { |
|
635 | + $val = 0; |
|
636 | + foreach($this->spriteMatrix as $id => $coor) { |
|
637 | + $new_val = $coor[$axis] + $this->spriteSrc[$id][$axis] - 1; |
|
638 | + if($new_val > $val) { |
|
639 | + $val = $new_val; |
|
640 | + } |
|
641 | + } |
|
642 | + return $val; |
|
643 | + } |
|
644 | 644 | } |
645 | 645 | |
646 | 646 | ?> |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
3 | 3 | /********************************************************************************* |
4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -83,19 +83,19 @@ discard block |
||
83 | 83 | public function __construct() |
84 | 84 | { |
85 | 85 | // check if we have gd installed |
86 | - if(function_exists('imagecreatetruecolor')) |
|
86 | + if (function_exists('imagecreatetruecolor')) |
|
87 | 87 | { |
88 | 88 | $this->isAvailable = true; |
89 | - foreach($this->supportedTypeMap as $gd_bit => $imagetype) |
|
89 | + foreach ($this->supportedTypeMap as $gd_bit => $imagetype) |
|
90 | 90 | { |
91 | - if(imagetypes() & $gd_bit) { |
|
91 | + if (imagetypes() & $gd_bit) { |
|
92 | 92 | // swap gd_bit & imagetype |
93 | 93 | $this->imageTypes[$imagetype] = $gd_bit; |
94 | 94 | } |
95 | 95 | } |
96 | 96 | } |
97 | 97 | |
98 | - if(function_exists('logThis') && isset($GLOBALS['path'])) |
|
98 | + if (function_exists('logThis') && isset($GLOBALS['path'])) |
|
99 | 99 | { |
100 | 100 | $this->writeToUpgradeLog = true; |
101 | 101 | } |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | public function addDirectory($name, $dir) { |
113 | 113 | |
114 | 114 | // sprite namespace |
115 | - if(!array_key_exists($name, $this->spriteSrc)) |
|
115 | + if (!array_key_exists($name, $this->spriteSrc)) |
|
116 | 116 | { |
117 | 117 | $this->spriteSrc[$name] = array(); |
118 | 118 | } |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | */ |
130 | 130 | private function getFileList($dir) { |
131 | 131 | $list = array(); |
132 | - if(is_dir($dir)) { |
|
133 | - if($dh = opendir($dir)) { |
|
132 | + if (is_dir($dir)) { |
|
133 | + if ($dh = opendir($dir)) { |
|
134 | 134 | |
135 | 135 | // optional sprites_config.php file |
136 | 136 | $this->loadSpritesConfig($dir); |
@@ -141,10 +141,10 @@ discard block |
||
141 | 141 | { |
142 | 142 | |
143 | 143 | // file info & check supported image format |
144 | - if($info = $this->getFileInfo($dir, $file)) { |
|
144 | + if ($info = $this->getFileInfo($dir, $file)) { |
|
145 | 145 | |
146 | 146 | // skip excluded files |
147 | - if(isset($this->sprites_config[$dir]['exclude']) && array_search($file, $this->sprites_config[$dir]['exclude']) !== false) |
|
147 | + if (isset($this->sprites_config[$dir]['exclude']) && array_search($file, $this->sprites_config[$dir]['exclude']) !== false) |
|
148 | 148 | { |
149 | 149 | global $mod_strings; |
150 | 150 | $msg = string_format($mod_strings['LBL_SPRITES_EXCLUDING_FILE'], array("{$dir}/{$file}")); |
@@ -154,11 +154,11 @@ discard block |
||
154 | 154 | // repeatable sprite ? |
155 | 155 | $isRepeat = false; |
156 | 156 | |
157 | - if(isset($this->sprites_config[$dir]['repeat'])) |
|
157 | + if (isset($this->sprites_config[$dir]['repeat'])) |
|
158 | 158 | { |
159 | - foreach($this->sprites_config[$dir]['repeat'] as $repeat) |
|
159 | + foreach ($this->sprites_config[$dir]['repeat'] as $repeat) |
|
160 | 160 | { |
161 | - if($info['x'] == $repeat['width'] && $info['y'] == $repeat['height']) |
|
161 | + if ($info['x'] == $repeat['width'] && $info['y'] == $repeat['height']) |
|
162 | 162 | { |
163 | 163 | $id = md5($repeat['width'].$repeat['height'].$repeat['direction']); |
164 | 164 | $isRepeat = true; |
@@ -167,13 +167,13 @@ discard block |
||
167 | 167 | } |
168 | 168 | } |
169 | 169 | |
170 | - if(!$isRepeat) |
|
170 | + if (!$isRepeat) |
|
171 | 171 | { |
172 | 172 | $list[$file] = $info; |
173 | 173 | } |
174 | 174 | } |
175 | - } else if(preg_match('/\.(jpg|jpeg|gif|png|bmp|ico)$/i', $file)) { |
|
176 | - $GLOBALS['log']->error('Unable to process image file ' . $file); |
|
175 | + } else if (preg_match('/\.(jpg|jpeg|gif|png|bmp|ico)$/i', $file)) { |
|
176 | + $GLOBALS['log']->error('Unable to process image file '.$file); |
|
177 | 177 | //$this->logMessage('Unable to process image file ' . $file); |
178 | 178 | } |
179 | 179 | } |
@@ -196,10 +196,10 @@ discard block |
||
196 | 196 | */ |
197 | 197 | private function loadSpritesConfig($dir) { |
198 | 198 | $sprites_config = array(); |
199 | - if(file_exists("$dir/sprites_config.php")) |
|
199 | + if (file_exists("$dir/sprites_config.php")) |
|
200 | 200 | { |
201 | 201 | include("$dir/sprites_config.php"); |
202 | - if(count($sprites_config)) { |
|
202 | + if (count($sprites_config)) { |
|
203 | 203 | $this->sprites_config = array_merge($this->sprites_config, $sprites_config); |
204 | 204 | } |
205 | 205 | } |
@@ -217,10 +217,10 @@ discard block |
||
217 | 217 | private function getFileInfo($dir, $file) { |
218 | 218 | $result = false; |
219 | 219 | $info = @getimagesize($dir.'/'.$file); |
220 | - if($info) { |
|
220 | + if ($info) { |
|
221 | 221 | |
222 | 222 | // supported image type ? |
223 | - if(isset($this->imageTypes[$info[2]])) |
|
223 | + if (isset($this->imageTypes[$info[2]])) |
|
224 | 224 | { |
225 | 225 | $w = $info[0]; |
226 | 226 | $h = $info[1]; |
@@ -228,16 +228,16 @@ discard block |
||
228 | 228 | |
229 | 229 | // be sure we have an image size |
230 | 230 | $addSprite = false; |
231 | - if($surface) |
|
231 | + if ($surface) |
|
232 | 232 | { |
233 | 233 | // sprite dimensions |
234 | - if($w <= $this->maxWidth && $h <= $this->maxHeight) |
|
234 | + if ($w <= $this->maxWidth && $h <= $this->maxHeight) |
|
235 | 235 | { |
236 | 236 | $addSprite = true; |
237 | 237 | } |
238 | 238 | } |
239 | 239 | |
240 | - if($addSprite) |
|
240 | + if ($addSprite) |
|
241 | 241 | { |
242 | 242 | $result = array(); |
243 | 243 | $result['x'] = $w; |
@@ -265,9 +265,9 @@ discard block |
||
265 | 265 | |
266 | 266 | global $mod_strings; |
267 | 267 | |
268 | - if(!$this->isAvailable) |
|
268 | + if (!$this->isAvailable) |
|
269 | 269 | { |
270 | - if(!$this->silentRun) |
|
270 | + if (!$this->silentRun) |
|
271 | 271 | { |
272 | 272 | $msg = $mod_strings['LBL_SPRITES_NOT_SUPPORTED']; |
273 | 273 | $GLOBALS['log']->warn($msg); |
@@ -277,14 +277,14 @@ discard block |
||
277 | 277 | } |
278 | 278 | |
279 | 279 | // add repeatable sprites |
280 | - if(count($this->spriteRepeat)) |
|
280 | + if (count($this->spriteRepeat)) |
|
281 | 281 | { |
282 | 282 | $this->spriteSrc = array_merge($this->spriteSrc, $this->spriteRepeat); |
283 | 283 | } |
284 | 284 | |
285 | - foreach($this->spriteSrc as $name => $dirs) |
|
285 | + foreach ($this->spriteSrc as $name => $dirs) |
|
286 | 286 | { |
287 | - if(!$this->silentRun) |
|
287 | + if (!$this->silentRun) |
|
288 | 288 | { |
289 | 289 | $msg = string_format($mod_strings['LBL_SPRITES_CREATING_NAMESPACE'], array($name)); |
290 | 290 | $GLOBALS['log']->debug($msg); |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | } |
293 | 293 | |
294 | 294 | // setup config for sprite placement algorithm |
295 | - if(substr($name, 0, 6) == 'repeat') |
|
295 | + if (substr($name, 0, 6) == 'repeat') |
|
296 | 296 | { |
297 | 297 | $isRepeat = true; |
298 | 298 | $type = substr($name, 7, 10) == 'horizontal' ? 'horizontal' : 'vertical'; |
@@ -317,24 +317,24 @@ discard block |
||
317 | 317 | // echo " (size {$sp->width()}x{$sp->height()})<br />"; |
318 | 318 | |
319 | 319 | // we need a target image size |
320 | - if($sp->width() && $sp->height()) |
|
320 | + if ($sp->width() && $sp->height()) |
|
321 | 321 | { |
322 | 322 | // init sprite image |
323 | 323 | $this->initSpriteImg($sp->width(), $sp->height()); |
324 | 324 | |
325 | 325 | // add sprites based upon determined coordinates |
326 | - foreach($dirs as $dir => $files) |
|
326 | + foreach ($dirs as $dir => $files) |
|
327 | 327 | { |
328 | - if(!$this->silentRun) |
|
328 | + if (!$this->silentRun) |
|
329 | 329 | { |
330 | 330 | $msg = string_format($mod_strings['LBL_SPRITES_PROCESSING_DIR'], array($dir)); |
331 | 331 | $GLOBALS['log']->debug($msg); |
332 | 332 | $this->logMessage($msg); |
333 | 333 | } |
334 | 334 | |
335 | - foreach($files as $file => $info) |
|
335 | + foreach ($files as $file => $info) |
|
336 | 336 | { |
337 | - if($im = $this->loadImage($dir, $file, $info['type'])) |
|
337 | + if ($im = $this->loadImage($dir, $file, $info['type'])) |
|
338 | 338 | { |
339 | 339 | // coordinates |
340 | 340 | $dst_x = $sp->spriteMatrix[$dir.'/'.$file]['x']; |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | imagecopy($this->spriteImg, $im, $dst_x, $dst_y, 0, 0, $info['x'], $info['y']); |
344 | 344 | imagedestroy($im); |
345 | 345 | |
346 | - if(!$this->silentRun) |
|
346 | + if (!$this->silentRun) |
|
347 | 347 | { |
348 | 348 | $msg = string_format($mod_strings['LBL_SPRITES_ADDED'], array("{$dir}/{$file}")); |
349 | 349 | $GLOBALS['log']->debug($msg); |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | } |
355 | 355 | |
356 | 356 | // dir & filenames |
357 | - if($isRepeat) |
|
357 | + if ($isRepeat) |
|
358 | 358 | { |
359 | 359 | $outputDir = sugar_cached("sprites/Repeatable"); |
360 | 360 | $spriteFileName = "{$name}.png"; |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | } |
371 | 371 | |
372 | 372 | // directory structure |
373 | - if(!is_dir(sugar_cached("sprites/$nameSpace"))) |
|
373 | + if (!is_dir(sugar_cached("sprites/$nameSpace"))) |
|
374 | 374 | { |
375 | 375 | sugar_mkdir(sugar_cached("sprites/$nameSpace"), 0775, true); |
376 | 376 | } |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | $body = ''; |
386 | 386 | $metadata = ''; |
387 | 387 | |
388 | - foreach($sp->spriteSrc as $id => $info) |
|
388 | + foreach ($sp->spriteSrc as $id => $info) |
|
389 | 389 | { |
390 | 390 | // sprite id |
391 | 391 | $hash_id = md5($id); |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | |
423 | 423 | // save css |
424 | 424 | $css_content = "\n/* autogenerated sprites - $name */\n".$head.$body; |
425 | - if($this->cssMinify) |
|
425 | + if ($this->cssMinify) |
|
426 | 426 | { |
427 | 427 | $css_content = cssmin::minify($css_content); |
428 | 428 | } |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | /* save metadata */ |
434 | 434 | $add_php_tag = (file_exists("$outputDir/$metaFileName") && $isRepeat) ? false : true; |
435 | 435 | $fh = fopen("$outputDir/$metaFileName", $fileMode); |
436 | - if($add_php_tag) |
|
436 | + if ($add_php_tag) |
|
437 | 437 | { |
438 | 438 | fwrite($fh, '<?php'); |
439 | 439 | } |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | // if width & height |
445 | 445 | } else { |
446 | 446 | |
447 | - if(!$this->silentRun) |
|
447 | + if (!$this->silentRun) |
|
448 | 448 | { |
449 | 449 | $msg = string_format($mod_strings['LBL_SPRITES_ADDED'], array($name)); |
450 | 450 | $GLOBALS['log']->debug($msg); |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | * Private function to initialize creating the sprite canvas image |
467 | 467 | */ |
468 | 468 | private function initSpriteImg($w, $h) { |
469 | - $this->spriteImg = imagecreatetruecolor($w,$h); |
|
469 | + $this->spriteImg = imagecreatetruecolor($w, $h); |
|
470 | 470 | $transparent = imagecolorallocatealpha($this->spriteImg, 0, 0, 0, 127); |
471 | 471 | imagefill($this->spriteImg, 0, 0, $transparent); |
472 | 472 | imagealphablending($this->spriteImg, false); |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | */ |
487 | 487 | private function loadImage($dir, $file, $type) { |
488 | 488 | $path_file = $dir.'/'.$file; |
489 | - switch($type) { |
|
489 | + switch ($type) { |
|
490 | 490 | case IMAGETYPE_GIF: |
491 | 491 | return imagecreatefromgif($path_file); |
492 | 492 | case IMAGETYPE_JPEG: |
@@ -508,13 +508,13 @@ discard block |
||
508 | 508 | */ |
509 | 509 | private function logMessage($msg) |
510 | 510 | { |
511 | - if(!$this->silentRun && !$this->fromSilentUpgrade) |
|
511 | + if (!$this->silentRun && !$this->fromSilentUpgrade) |
|
512 | 512 | { |
513 | - echo $msg . '<br />'; |
|
513 | + echo $msg.'<br />'; |
|
514 | 514 | } else if ($this->fromSilentUpgrade && $this->writeToUpgradeLog) { |
515 | 515 | logThis($msg, $GLOBALS['path']); |
516 | - } else if(!$this->silentRun) { |
|
517 | - echo $msg . "\n"; |
|
516 | + } else if (!$this->silentRun) { |
|
517 | + echo $msg."\n"; |
|
518 | 518 | } |
519 | 519 | } |
520 | 520 | } |
@@ -553,8 +553,8 @@ discard block |
||
553 | 553 | function __construct($spriteSrc, $config) { |
554 | 554 | |
555 | 555 | // convert spriteSrc to flat array |
556 | - foreach($spriteSrc as $dir => $files) { |
|
557 | - foreach($files as $file => $info) { |
|
556 | + foreach ($spriteSrc as $dir => $files) { |
|
557 | + foreach ($files as $file => $info) { |
|
558 | 558 | // use full path as identifier |
559 | 559 | $full_path = $dir.'/'.$file; |
560 | 560 | $this->spriteSrc[$full_path] = $info; |
@@ -566,7 +566,7 @@ discard block |
||
566 | 566 | |
567 | 567 | function processSprites() { |
568 | 568 | |
569 | - foreach($this->spriteSrc as $id => $info) { |
|
569 | + foreach ($this->spriteSrc as $id => $info) { |
|
570 | 570 | |
571 | 571 | // dimensions |
572 | 572 | $x = $info['x']; |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | $this->minSurface += $x * $y; |
577 | 577 | |
578 | 578 | // get coordinates where to add this sprite |
579 | - if($coor = $this->addSprite($x, $y)) { |
|
579 | + if ($coor = $this->addSprite($x, $y)) { |
|
580 | 580 | $this->spriteMatrix[$id] = $coor; |
581 | 581 | } |
582 | 582 | } |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | function addSprite($w, $h) { |
587 | 587 | $result = false; |
588 | 588 | |
589 | - switch($this->config['type']) { |
|
589 | + switch ($this->config['type']) { |
|
590 | 590 | |
591 | 591 | // boxed |
592 | 592 | case 'boxed': |
@@ -633,9 +633,9 @@ discard block |
||
633 | 633 | // helper function to get highest axis value |
634 | 634 | function getMaxAxis($axis) { |
635 | 635 | $val = 0; |
636 | - foreach($this->spriteMatrix as $id => $coor) { |
|
636 | + foreach ($this->spriteMatrix as $id => $coor) { |
|
637 | 637 | $new_val = $coor[$axis] + $this->spriteSrc[$id][$axis] - 1; |
638 | - if($new_val > $val) { |
|
638 | + if ($new_val > $val) { |
|
639 | 639 | $val = $new_val; |
640 | 640 | } |
641 | 641 | } |
@@ -1,5 +1,7 @@ |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
3 | + die('Not A Valid Entry Point'); |
|
4 | +} |
|
3 | 5 | /********************************************************************************* |
4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |