@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | if (empty($global_currency_obj)) |
| 53 | 53 | { |
| 54 | 54 | $global_currency_obj = new Currency(); |
| 55 | - // $global_currency_symbol = '$'; |
|
| 55 | + // $global_currency_symbol = '$'; |
|
| 56 | 56 | |
| 57 | 57 | if($current_user->getPreference('currency') ) |
| 58 | 58 | { |
@@ -106,18 +106,18 @@ discard block |
||
| 106 | 106 | $record = $layout_def['fields'][strtoupper($layout_def['table_alias']."_id")]; |
| 107 | 107 | } |
| 108 | 108 | if (!empty($record)) { |
| 109 | - $field_name = $layout_def['name']; |
|
| 110 | - $field_type = $field_def['type']; |
|
| 111 | - $module = $field_def['module']; |
|
| 109 | + $field_name = $layout_def['name']; |
|
| 110 | + $field_type = $field_def['type']; |
|
| 111 | + $module = $field_def['module']; |
|
| 112 | 112 | |
| 113 | - $div_id = $module ."&$record&$field_name"; |
|
| 114 | - $str = "<div id='$div_id'>".$display; |
|
| 113 | + $div_id = $module ."&$record&$field_name"; |
|
| 114 | + $str = "<div id='$div_id'>".$display; |
|
| 115 | 115 | global $sugar_config; |
| 116 | 116 | if (isset ($sugar_config['enable_inline_reports_edit']) && $sugar_config['enable_inline_reports_edit']) { |
| 117 | 117 | $str .= " " .SugarThemeRegistry::current()->getImage("edit_inline","border='0' alt='Edit Layout' align='bottom' onClick='SUGAR.reportsInlineEdit.inlineEdit(\"$div_id\",\"$value\",\"$module\",\"$record\",\"$field_name\",\"$field_type\",\"$currency_id\",\"$symbol\");'"); |
| 118 | 118 | } |
| 119 | - $str .= "</div>"; |
|
| 120 | - return $str; |
|
| 119 | + $str .= "</div>"; |
|
| 120 | + return $str; |
|
| 121 | 121 | } |
| 122 | 122 | else |
| 123 | 123 | return $display; |
@@ -135,61 +135,61 @@ discard block |
||
| 135 | 135 | ); |
| 136 | 136 | return $value; |
| 137 | 137 | } |
| 138 | - function queryFilterEquals(&$layout_def) |
|
| 139 | - { |
|
| 140 | - return $this->_get_column_select($layout_def)."=".$GLOBALS['db']->quote(unformat_number($layout_def['input_name0']))."\n"; |
|
| 141 | - } |
|
| 138 | + function queryFilterEquals(&$layout_def) |
|
| 139 | + { |
|
| 140 | + return $this->_get_column_select($layout_def)."=".$GLOBALS['db']->quote(unformat_number($layout_def['input_name0']))."\n"; |
|
| 141 | + } |
|
| 142 | 142 | |
| 143 | - function queryFilterNot_Equals(&$layout_def) |
|
| 144 | - { |
|
| 145 | - return $this->_get_column_select($layout_def)."!=".$GLOBALS['db']->quote(unformat_number($layout_def['input_name0']))."\n"; |
|
| 146 | - } |
|
| 143 | + function queryFilterNot_Equals(&$layout_def) |
|
| 144 | + { |
|
| 145 | + return $this->_get_column_select($layout_def)."!=".$GLOBALS['db']->quote(unformat_number($layout_def['input_name0']))."\n"; |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - function queryFilterGreater(&$layout_def) |
|
| 149 | - { |
|
| 150 | - return $this->_get_column_select($layout_def)." > ".$GLOBALS['db']->quote(unformat_number($layout_def['input_name0']))."\n"; |
|
| 151 | - } |
|
| 148 | + function queryFilterGreater(&$layout_def) |
|
| 149 | + { |
|
| 150 | + return $this->_get_column_select($layout_def)." > ".$GLOBALS['db']->quote(unformat_number($layout_def['input_name0']))."\n"; |
|
| 151 | + } |
|
| 152 | 152 | |
| 153 | - function queryFilterLess(&$layout_def) |
|
| 154 | - { |
|
| 155 | - return $this->_get_column_select($layout_def)." < ".$GLOBALS['db']->quote(unformat_number($layout_def['input_name0']))."\n"; |
|
| 156 | - } |
|
| 153 | + function queryFilterLess(&$layout_def) |
|
| 154 | + { |
|
| 155 | + return $this->_get_column_select($layout_def)." < ".$GLOBALS['db']->quote(unformat_number($layout_def['input_name0']))."\n"; |
|
| 156 | + } |
|
| 157 | 157 | |
| 158 | - function queryFilterBetween(&$layout_def){ |
|
| 159 | - return $this->_get_column_select($layout_def)." > ".$GLOBALS['db']->quote(unformat_number($layout_def['input_name0'])). " AND ". $this->_get_column_select($layout_def)." < ".$GLOBALS['db']->quote(unformat_number($layout_def['input_name1']))."\n"; |
|
| 160 | - } |
|
| 158 | + function queryFilterBetween(&$layout_def){ |
|
| 159 | + return $this->_get_column_select($layout_def)." > ".$GLOBALS['db']->quote(unformat_number($layout_def['input_name0'])). " AND ". $this->_get_column_select($layout_def)." < ".$GLOBALS['db']->quote(unformat_number($layout_def['input_name1']))."\n"; |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - function isSystemCurrency(&$layout_def) |
|
| 163 | - { |
|
| 164 | - if (strpos($layout_def['name'],'_usdoll') === false) { |
|
| 165 | - return false; |
|
| 166 | - } else { |
|
| 167 | - return true; |
|
| 168 | - } |
|
| 169 | - } |
|
| 162 | + function isSystemCurrency(&$layout_def) |
|
| 163 | + { |
|
| 164 | + if (strpos($layout_def['name'],'_usdoll') === false) { |
|
| 165 | + return false; |
|
| 166 | + } else { |
|
| 167 | + return true; |
|
| 168 | + } |
|
| 169 | + } |
|
| 170 | 170 | |
| 171 | - function querySelect(&$layout_def) |
|
| 172 | - { |
|
| 171 | + function querySelect(&$layout_def) |
|
| 172 | + { |
|
| 173 | 173 | // add currency column to select |
| 174 | 174 | $table = $this->getCurrencyIdTable($layout_def); |
| 175 | 175 | if($table) { |
| 176 | 176 | return $this->_get_column_select($layout_def)." ".$this->_get_column_alias($layout_def)." , ".$table.".currency_id ". $this->getTruncatedColumnAlias($this->_get_column_alias($layout_def)."_currency") . "\n"; |
| 177 | 177 | } |
| 178 | 178 | return $this->_get_column_select($layout_def)." ".$this->_get_column_alias($layout_def)."\n"; |
| 179 | - } |
|
| 179 | + } |
|
| 180 | 180 | |
| 181 | - function queryGroupBy($layout_def) |
|
| 182 | - { |
|
| 181 | + function queryGroupBy($layout_def) |
|
| 182 | + { |
|
| 183 | 183 | // add currency column to group by |
| 184 | 184 | $table = $this->getCurrencyIdTable($layout_def); |
| 185 | 185 | if($table) { |
| 186 | 186 | return $this->_get_column_select($layout_def)." , ".$table.".currency_id \n"; |
| 187 | 187 | } |
| 188 | 188 | return $this->_get_column_select($layout_def)." \n"; |
| 189 | - } |
|
| 189 | + } |
|
| 190 | 190 | |
| 191 | - function getCurrencyIdTable($layout_def) |
|
| 192 | - { |
|
| 191 | + function getCurrencyIdTable($layout_def) |
|
| 192 | + { |
|
| 193 | 193 | // We need to fetch the currency id as well |
| 194 | 194 | if ( !$this->isSystemCurrency($layout_def) && empty($layout_def['group_function'])) { |
| 195 | 195 | |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | } |
| 220 | 220 | } |
| 221 | 221 | return false; |
| 222 | - } |
|
| 222 | + } |
|
| 223 | 223 | |
| 224 | 224 | /** |
| 225 | 225 | * Return currency for layout_def |
@@ -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. |
@@ -48,13 +48,13 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | function get_currency() |
| 50 | 50 | { |
| 51 | - global $current_user,$global_currency_obj; |
|
| 51 | + global $current_user, $global_currency_obj; |
|
| 52 | 52 | if (empty($global_currency_obj)) |
| 53 | 53 | { |
| 54 | 54 | $global_currency_obj = new Currency(); |
| 55 | 55 | // $global_currency_symbol = '$'; |
| 56 | 56 | |
| 57 | - if($current_user->getPreference('currency') ) |
|
| 57 | + if ($current_user->getPreference('currency')) |
|
| 58 | 58 | { |
| 59 | 59 | $global_currency_obj->retrieve($current_user->getPreference('currency')); |
| 60 | 60 | } |
@@ -82,9 +82,9 @@ discard block |
||
| 82 | 82 | $currency_id = $locale->getPrecedentPreference('currency'); |
| 83 | 83 | |
| 84 | 84 | // If it's not grouped, or if it's grouped around a system currency column, look up the currency symbol so we can display it next to the amount |
| 85 | - if ( empty($layout_def['group_function']) || $this->isSystemCurrency($layout_def) ) { |
|
| 85 | + if (empty($layout_def['group_function']) || $this->isSystemCurrency($layout_def)) { |
|
| 86 | 86 | $c = $this->getCurrency($layout_def); |
| 87 | - if(!empty($c['currency_id']) && !empty($c['currency_symbol'])) |
|
| 87 | + if (!empty($c['currency_id']) && !empty($c['currency_symbol'])) |
|
| 88 | 88 | { |
| 89 | 89 | $symbol = $c['currency_symbol']; |
| 90 | 90 | $currency_id = $c['currency_id']; |
@@ -94,15 +94,15 @@ discard block |
||
| 94 | 94 | $layout_def['currency_id'] = $currency_id; |
| 95 | 95 | $display = $this->displayListPlain($layout_def); |
| 96 | 96 | |
| 97 | - if(!empty($layout_def['column_key'])){ |
|
| 97 | + if (!empty($layout_def['column_key'])) { |
|
| 98 | 98 | $field_def = $this->reporter->all_fields[$layout_def['column_key']]; |
| 99 | - }else if(!empty($layout_def['fields'])){ |
|
| 99 | + } else if (!empty($layout_def['fields'])) { |
|
| 100 | 100 | $field_def = $layout_def['fields']; |
| 101 | 101 | } |
| 102 | 102 | $record = ''; |
| 103 | 103 | if ($layout_def['table_key'] == 'self' && isset($layout_def['fields']['PRIMARYID'])) |
| 104 | 104 | $record = $layout_def['fields']['PRIMARYID']; |
| 105 | - else if (isset($layout_def['fields'][strtoupper($layout_def['table_alias']."_id")])){ |
|
| 105 | + else if (isset($layout_def['fields'][strtoupper($layout_def['table_alias']."_id")])) { |
|
| 106 | 106 | $record = $layout_def['fields'][strtoupper($layout_def['table_alias']."_id")]; |
| 107 | 107 | } |
| 108 | 108 | if (!empty($record)) { |
@@ -110,11 +110,11 @@ discard block |
||
| 110 | 110 | $field_type = $field_def['type']; |
| 111 | 111 | $module = $field_def['module']; |
| 112 | 112 | |
| 113 | - $div_id = $module ."&$record&$field_name"; |
|
| 113 | + $div_id = $module."&$record&$field_name"; |
|
| 114 | 114 | $str = "<div id='$div_id'>".$display; |
| 115 | 115 | global $sugar_config; |
| 116 | 116 | if (isset ($sugar_config['enable_inline_reports_edit']) && $sugar_config['enable_inline_reports_edit']) { |
| 117 | - $str .= " " .SugarThemeRegistry::current()->getImage("edit_inline","border='0' alt='Edit Layout' align='bottom' onClick='SUGAR.reportsInlineEdit.inlineEdit(\"$div_id\",\"$value\",\"$module\",\"$record\",\"$field_name\",\"$field_type\",\"$currency_id\",\"$symbol\");'"); |
|
| 117 | + $str .= " ".SugarThemeRegistry::current()->getImage("edit_inline", "border='0' alt='Edit Layout' align='bottom' onClick='SUGAR.reportsInlineEdit.inlineEdit(\"$div_id\",\"$value\",\"$module\",\"$record\",\"$field_name\",\"$field_type\",\"$currency_id\",\"$symbol\");'"); |
|
| 118 | 118 | } |
| 119 | 119 | $str .= "</div>"; |
| 120 | 120 | return $str; |
@@ -155,13 +155,13 @@ discard block |
||
| 155 | 155 | return $this->_get_column_select($layout_def)." < ".$GLOBALS['db']->quote(unformat_number($layout_def['input_name0']))."\n"; |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - function queryFilterBetween(&$layout_def){ |
|
| 159 | - return $this->_get_column_select($layout_def)." > ".$GLOBALS['db']->quote(unformat_number($layout_def['input_name0'])). " AND ". $this->_get_column_select($layout_def)." < ".$GLOBALS['db']->quote(unformat_number($layout_def['input_name1']))."\n"; |
|
| 158 | + function queryFilterBetween(&$layout_def) { |
|
| 159 | + return $this->_get_column_select($layout_def)." > ".$GLOBALS['db']->quote(unformat_number($layout_def['input_name0']))." AND ".$this->_get_column_select($layout_def)." < ".$GLOBALS['db']->quote(unformat_number($layout_def['input_name1']))."\n"; |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | function isSystemCurrency(&$layout_def) |
| 163 | 163 | { |
| 164 | - if (strpos($layout_def['name'],'_usdoll') === false) { |
|
| 164 | + if (strpos($layout_def['name'], '_usdoll') === false) { |
|
| 165 | 165 | return false; |
| 166 | 166 | } else { |
| 167 | 167 | return true; |
@@ -172,8 +172,8 @@ discard block |
||
| 172 | 172 | { |
| 173 | 173 | // add currency column to select |
| 174 | 174 | $table = $this->getCurrencyIdTable($layout_def); |
| 175 | - if($table) { |
|
| 176 | - return $this->_get_column_select($layout_def)." ".$this->_get_column_alias($layout_def)." , ".$table.".currency_id ". $this->getTruncatedColumnAlias($this->_get_column_alias($layout_def)."_currency") . "\n"; |
|
| 175 | + if ($table) { |
|
| 176 | + return $this->_get_column_select($layout_def)." ".$this->_get_column_alias($layout_def)." , ".$table.".currency_id ".$this->getTruncatedColumnAlias($this->_get_column_alias($layout_def)."_currency")."\n"; |
|
| 177 | 177 | } |
| 178 | 178 | return $this->_get_column_select($layout_def)." ".$this->_get_column_alias($layout_def)."\n"; |
| 179 | 179 | } |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | { |
| 183 | 183 | // add currency column to group by |
| 184 | 184 | $table = $this->getCurrencyIdTable($layout_def); |
| 185 | - if($table) { |
|
| 185 | + if ($table) { |
|
| 186 | 186 | return $this->_get_column_select($layout_def)." , ".$table.".currency_id \n"; |
| 187 | 187 | } |
| 188 | 188 | return $this->_get_column_select($layout_def)." \n"; |
@@ -191,9 +191,9 @@ discard block |
||
| 191 | 191 | function getCurrencyIdTable($layout_def) |
| 192 | 192 | { |
| 193 | 193 | // We need to fetch the currency id as well |
| 194 | - if ( !$this->isSystemCurrency($layout_def) && empty($layout_def['group_function'])) { |
|
| 194 | + if (!$this->isSystemCurrency($layout_def) && empty($layout_def['group_function'])) { |
|
| 195 | 195 | |
| 196 | - if ( !empty($layout_def['table_alias']) ) { |
|
| 196 | + if (!empty($layout_def['table_alias'])) { |
|
| 197 | 197 | $table = $layout_def['table_alias']; |
| 198 | 198 | } else { |
| 199 | 199 | $table = ''; |
@@ -204,16 +204,16 @@ discard block |
||
| 204 | 204 | $real_table = $this->reporter->all_fields[$layout_def['column_key']]['real_table']; |
| 205 | 205 | |
| 206 | 206 | $add_currency_id = false; |
| 207 | - if(!empty($table)) { |
|
| 207 | + if (!empty($table)) { |
|
| 208 | 208 | $cols = $GLOBALS['db']->getHelper()->get_columns($real_table); |
| 209 | 209 | $add_currency_id = isset($cols['currency_id']) ? true : false; |
| 210 | 210 | |
| 211 | - if(!$add_currency_id && preg_match('/.*?_cstm$/i', $real_table)) { |
|
| 211 | + if (!$add_currency_id && preg_match('/.*?_cstm$/i', $real_table)) { |
|
| 212 | 212 | $table = str_replace('_cstm', '', $table); |
| 213 | 213 | $cols = $GLOBALS['db']->getHelper()->get_columns($table); |
| 214 | 214 | $add_currency_id = isset($cols['currency_id']) ? true : false; |
| 215 | 215 | } |
| 216 | - if($add_currency_id) { |
|
| 216 | + if ($add_currency_id) { |
|
| 217 | 217 | return $table; |
| 218 | 218 | } |
| 219 | 219 | } |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | { |
| 231 | 231 | $currency_id = false; |
| 232 | 232 | $currency_symbol = false; |
| 233 | - if(isset($layout_def['currency_symbol']) && isset($layout_def['currency_id'])) |
|
| 233 | + if (isset($layout_def['currency_symbol']) && isset($layout_def['currency_id'])) |
|
| 234 | 234 | { |
| 235 | 235 | $currency_symbol = $layout_def['currency_symbol']; |
| 236 | 236 | $currency_id = $layout_def['currency_id']; |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | else |
| 239 | 239 | { |
| 240 | 240 | $key = strtoupper(isset($layout_def['varname']) ? $layout_def['varname'] : $this->_get_column_alias($layout_def)); |
| 241 | - if ( $this->isSystemCurrency($layout_def) ) |
|
| 241 | + if ($this->isSystemCurrency($layout_def)) |
|
| 242 | 242 | { |
| 243 | 243 | $currency_id = '-99'; |
| 244 | 244 | } |
@@ -246,14 +246,14 @@ discard block |
||
| 246 | 246 | { |
| 247 | 247 | $currency_id = $layout_def['fields'][$key.'_CURRENCY']; |
| 248 | 248 | } |
| 249 | - elseif(isset($layout_def['fields'][$this->getTruncatedColumnAlias($this->_get_column_alias($layout_def)."_currency")])) |
|
| 249 | + elseif (isset($layout_def['fields'][$this->getTruncatedColumnAlias($this->_get_column_alias($layout_def)."_currency")])) |
|
| 250 | 250 | { |
| 251 | 251 | $currency_id = $layout_def['fields'][$this->getTruncatedColumnAlias($this->_get_column_alias($layout_def)."_currency")]; |
| 252 | 252 | } |
| 253 | - if($currency_id) |
|
| 253 | + if ($currency_id) |
|
| 254 | 254 | { |
| 255 | 255 | $currency = BeanFactory::getBean('Currencies', $currency_id); |
| 256 | - if(!empty($currency ->symbol)) |
|
| 256 | + if (!empty($currency ->symbol)) |
|
| 257 | 257 | { |
| 258 | 258 | $currency_symbol = $currency ->symbol; |
| 259 | 259 | } |
@@ -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. |
@@ -57,8 +59,7 @@ discard block |
||
| 57 | 59 | if($current_user->getPreference('currency') ) |
| 58 | 60 | { |
| 59 | 61 | $global_currency_obj->retrieve($current_user->getPreference('currency')); |
| 60 | - } |
|
| 61 | - else |
|
| 62 | + } else |
|
| 62 | 63 | { |
| 63 | 64 | $global_currency_obj->retrieve('-99'); |
| 64 | 65 | } |
@@ -96,13 +97,13 @@ discard block |
||
| 96 | 97 | |
| 97 | 98 | if(!empty($layout_def['column_key'])){ |
| 98 | 99 | $field_def = $this->reporter->all_fields[$layout_def['column_key']]; |
| 99 | - }else if(!empty($layout_def['fields'])){ |
|
| 100 | + } else if(!empty($layout_def['fields'])){ |
|
| 100 | 101 | $field_def = $layout_def['fields']; |
| 101 | 102 | } |
| 102 | 103 | $record = ''; |
| 103 | - if ($layout_def['table_key'] == 'self' && isset($layout_def['fields']['PRIMARYID'])) |
|
| 104 | - $record = $layout_def['fields']['PRIMARYID']; |
|
| 105 | - else if (isset($layout_def['fields'][strtoupper($layout_def['table_alias']."_id")])){ |
|
| 104 | + if ($layout_def['table_key'] == 'self' && isset($layout_def['fields']['PRIMARYID'])) { |
|
| 105 | + $record = $layout_def['fields']['PRIMARYID']; |
|
| 106 | + } else if (isset($layout_def['fields'][strtoupper($layout_def['table_alias']."_id")])){ |
|
| 106 | 107 | $record = $layout_def['fields'][strtoupper($layout_def['table_alias']."_id")]; |
| 107 | 108 | } |
| 108 | 109 | if (!empty($record)) { |
@@ -118,9 +119,9 @@ discard block |
||
| 118 | 119 | } |
| 119 | 120 | $str .= "</div>"; |
| 120 | 121 | return $str; |
| 122 | + } else { |
|
| 123 | + return $display; |
|
| 121 | 124 | } |
| 122 | - else |
|
| 123 | - return $display; |
|
| 124 | 125 | } |
| 125 | 126 | |
| 126 | 127 | function displayListPlain($layout_def) { |
@@ -200,8 +201,9 @@ discard block |
||
| 200 | 201 | } |
| 201 | 202 | |
| 202 | 203 | $real_table = ''; |
| 203 | - if (!empty($this->reporter->all_fields[$layout_def['column_key']]['real_table'])) |
|
| 204 | - $real_table = $this->reporter->all_fields[$layout_def['column_key']]['real_table']; |
|
| 204 | + if (!empty($this->reporter->all_fields[$layout_def['column_key']]['real_table'])) { |
|
| 205 | + $real_table = $this->reporter->all_fields[$layout_def['column_key']]['real_table']; |
|
| 206 | + } |
|
| 205 | 207 | |
| 206 | 208 | $add_currency_id = false; |
| 207 | 209 | if(!empty($table)) { |
@@ -234,19 +236,16 @@ discard block |
||
| 234 | 236 | { |
| 235 | 237 | $currency_symbol = $layout_def['currency_symbol']; |
| 236 | 238 | $currency_id = $layout_def['currency_id']; |
| 237 | - } |
|
| 238 | - else |
|
| 239 | + } else |
|
| 239 | 240 | { |
| 240 | 241 | $key = strtoupper(isset($layout_def['varname']) ? $layout_def['varname'] : $this->_get_column_alias($layout_def)); |
| 241 | 242 | if ( $this->isSystemCurrency($layout_def) ) |
| 242 | 243 | { |
| 243 | 244 | $currency_id = '-99'; |
| 244 | - } |
|
| 245 | - elseif (isset($layout_def['fields'][$key.'_CURRENCY'])) |
|
| 245 | + } elseif (isset($layout_def['fields'][$key.'_CURRENCY'])) |
|
| 246 | 246 | { |
| 247 | 247 | $currency_id = $layout_def['fields'][$key.'_CURRENCY']; |
| 248 | - } |
|
| 249 | - elseif(isset($layout_def['fields'][$this->getTruncatedColumnAlias($this->_get_column_alias($layout_def)."_currency")])) |
|
| 248 | + } elseif(isset($layout_def['fields'][$this->getTruncatedColumnAlias($this->_get_column_alias($layout_def)."_currency")])) |
|
| 250 | 249 | { |
| 251 | 250 | $currency_id = $layout_def['fields'][$this->getTruncatedColumnAlias($this->_get_column_alias($layout_def)."_currency")]; |
| 252 | 251 | } |
@@ -66,55 +66,55 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | require_once('include/formbase.php'); |
| 68 | 68 | |
| 69 | - global $beanFiles,$beanList; |
|
| 70 | - $bean_name = $beanList[$_REQUEST['module']]; |
|
| 71 | - require_once($beanFiles[$bean_name]); |
|
| 72 | - $focus = new $bean_name(); |
|
| 73 | - if ( empty($_REQUEST['linked_id']) || empty($_REQUEST['linked_field']) || empty($_REQUEST['record'])) |
|
| 74 | - { |
|
| 75 | - die("need linked_field, linked_id and record fields"); |
|
| 76 | - } |
|
| 77 | - $linked_field = $_REQUEST['linked_field']; |
|
| 78 | - $record = $_REQUEST['record']; |
|
| 79 | - $linked_id = $_REQUEST['linked_id']; |
|
| 80 | - if($bean_name == 'Team') |
|
| 81 | - { |
|
| 82 | - $focus->retrieve($record); |
|
| 83 | - $focus->remove_user_from_team($linked_id); |
|
| 84 | - } |
|
| 85 | - else |
|
| 86 | - { |
|
| 87 | - // cut it off: |
|
| 88 | - $focus->load_relationship($linked_field); |
|
| 89 | - if($focus->$linked_field->_relationship->relationship_name == 'quotes_contacts_shipto') |
|
| 90 | - unset($focus->$linked_field->_relationship->relationship_role_column); |
|
| 91 | - $focus->$linked_field->delete($record,$linked_id); |
|
| 92 | - } |
|
| 93 | - if ($bean_name == 'Campaign' and $linked_field=='prospectlists' ) { |
|
| 69 | + global $beanFiles,$beanList; |
|
| 70 | + $bean_name = $beanList[$_REQUEST['module']]; |
|
| 71 | + require_once($beanFiles[$bean_name]); |
|
| 72 | + $focus = new $bean_name(); |
|
| 73 | + if ( empty($_REQUEST['linked_id']) || empty($_REQUEST['linked_field']) || empty($_REQUEST['record'])) |
|
| 74 | + { |
|
| 75 | + die("need linked_field, linked_id and record fields"); |
|
| 76 | + } |
|
| 77 | + $linked_field = $_REQUEST['linked_field']; |
|
| 78 | + $record = $_REQUEST['record']; |
|
| 79 | + $linked_id = $_REQUEST['linked_id']; |
|
| 80 | + if($bean_name == 'Team') |
|
| 81 | + { |
|
| 82 | + $focus->retrieve($record); |
|
| 83 | + $focus->remove_user_from_team($linked_id); |
|
| 84 | + } |
|
| 85 | + else |
|
| 86 | + { |
|
| 87 | + // cut it off: |
|
| 88 | + $focus->load_relationship($linked_field); |
|
| 89 | + if($focus->$linked_field->_relationship->relationship_name == 'quotes_contacts_shipto') |
|
| 90 | + unset($focus->$linked_field->_relationship->relationship_role_column); |
|
| 91 | + $focus->$linked_field->delete($record,$linked_id); |
|
| 92 | + } |
|
| 93 | + if ($bean_name == 'Campaign' and $linked_field=='prospectlists' ) { |
|
| 94 | 94 | |
| 95 | - $query="SELECT email_marketing_prospect_lists.id from email_marketing_prospect_lists "; |
|
| 96 | - $query.=" left join email_marketing on email_marketing.id=email_marketing_prospect_lists.email_marketing_id"; |
|
| 97 | - $query.=" where email_marketing.campaign_id='$record'"; |
|
| 98 | - $query.=" and email_marketing_prospect_lists.prospect_list_id='$linked_id'"; |
|
| 95 | + $query="SELECT email_marketing_prospect_lists.id from email_marketing_prospect_lists "; |
|
| 96 | + $query.=" left join email_marketing on email_marketing.id=email_marketing_prospect_lists.email_marketing_id"; |
|
| 97 | + $query.=" where email_marketing.campaign_id='$record'"; |
|
| 98 | + $query.=" and email_marketing_prospect_lists.prospect_list_id='$linked_id'"; |
|
| 99 | 99 | |
| 100 | - $result=$focus->db->query($query); |
|
| 101 | - while (($row=$focus->db->fetchByAssoc($result)) != null) { |
|
| 102 | - $del_query =" update email_marketing_prospect_lists set email_marketing_prospect_lists.deleted=1, email_marketing_prospect_lists.date_modified=".$focus->db->convert("'".TimeDate::getInstance()->nowDb()."'",'datetime'); |
|
| 103 | - $del_query.=" WHERE email_marketing_prospect_lists.id='{$row['id']}'"; |
|
| 104 | - $focus->db->query($del_query); |
|
| 105 | - } |
|
| 106 | - $focus->db->query($query); |
|
| 107 | - } |
|
| 100 | + $result=$focus->db->query($query); |
|
| 101 | + while (($row=$focus->db->fetchByAssoc($result)) != null) { |
|
| 102 | + $del_query =" update email_marketing_prospect_lists set email_marketing_prospect_lists.deleted=1, email_marketing_prospect_lists.date_modified=".$focus->db->convert("'".TimeDate::getInstance()->nowDb()."'",'datetime'); |
|
| 103 | + $del_query.=" WHERE email_marketing_prospect_lists.id='{$row['id']}'"; |
|
| 104 | + $focus->db->query($del_query); |
|
| 105 | + } |
|
| 106 | + $focus->db->query($query); |
|
| 107 | + } |
|
| 108 | 108 | if ($bean_name == "Meeting") { |
| 109 | 109 | $focus->retrieve($record); |
| 110 | 110 | $user = new User(); |
| 111 | 111 | $user->retrieve($linked_id); |
| 112 | 112 | if (!empty($user->id)) { //make sure that record exists. we may have a contact on our hands. |
| 113 | 113 | |
| 114 | - if($focus->update_vcal) |
|
| 115 | - { |
|
| 116 | - vCal::cache_sugar_vcal($user); |
|
| 117 | - } |
|
| 114 | + if($focus->update_vcal) |
|
| 115 | + { |
|
| 116 | + vCal::cache_sugar_vcal($user); |
|
| 117 | + } |
|
| 118 | 118 | } |
| 119 | 119 | } |
| 120 | 120 | if ($bean_name == "User" && $linked_field == 'eapm') { |
@@ -123,11 +123,11 @@ discard block |
||
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | if(!empty($_REQUEST['return_url'])){ |
| 126 | - $_REQUEST['return_url'] =urldecode($_REQUEST['return_url']); |
|
| 126 | + $_REQUEST['return_url'] =urldecode($_REQUEST['return_url']); |
|
| 127 | 127 | } |
| 128 | 128 | $GLOBALS['log']->debug("deleted relationship: bean: $bean_name, linked_field: $linked_field, linked_id:$linked_id" ); |
| 129 | 129 | if(empty($_REQUEST['refresh_page'])){ |
| 130 | - handleRedirect(); |
|
| 130 | + handleRedirect(); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | |
@@ -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. |
@@ -66,18 +66,18 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | require_once('include/formbase.php'); |
| 68 | 68 | |
| 69 | - global $beanFiles,$beanList; |
|
| 69 | + global $beanFiles, $beanList; |
|
| 70 | 70 | $bean_name = $beanList[$_REQUEST['module']]; |
| 71 | 71 | require_once($beanFiles[$bean_name]); |
| 72 | 72 | $focus = new $bean_name(); |
| 73 | - if ( empty($_REQUEST['linked_id']) || empty($_REQUEST['linked_field']) || empty($_REQUEST['record'])) |
|
| 73 | + if (empty($_REQUEST['linked_id']) || empty($_REQUEST['linked_field']) || empty($_REQUEST['record'])) |
|
| 74 | 74 | { |
| 75 | 75 | die("need linked_field, linked_id and record fields"); |
| 76 | 76 | } |
| 77 | 77 | $linked_field = $_REQUEST['linked_field']; |
| 78 | 78 | $record = $_REQUEST['record']; |
| 79 | 79 | $linked_id = $_REQUEST['linked_id']; |
| 80 | - if($bean_name == 'Team') |
|
| 80 | + if ($bean_name == 'Team') |
|
| 81 | 81 | { |
| 82 | 82 | $focus->retrieve($record); |
| 83 | 83 | $focus->remove_user_from_team($linked_id); |
@@ -86,21 +86,21 @@ discard block |
||
| 86 | 86 | { |
| 87 | 87 | // cut it off: |
| 88 | 88 | $focus->load_relationship($linked_field); |
| 89 | - if($focus->$linked_field->_relationship->relationship_name == 'quotes_contacts_shipto') |
|
| 89 | + if ($focus->$linked_field->_relationship->relationship_name == 'quotes_contacts_shipto') |
|
| 90 | 90 | unset($focus->$linked_field->_relationship->relationship_role_column); |
| 91 | - $focus->$linked_field->delete($record,$linked_id); |
|
| 91 | + $focus->$linked_field->delete($record, $linked_id); |
|
| 92 | 92 | } |
| 93 | - if ($bean_name == 'Campaign' and $linked_field=='prospectlists' ) { |
|
| 93 | + if ($bean_name == 'Campaign' and $linked_field == 'prospectlists') { |
|
| 94 | 94 | |
| 95 | - $query="SELECT email_marketing_prospect_lists.id from email_marketing_prospect_lists "; |
|
| 96 | - $query.=" left join email_marketing on email_marketing.id=email_marketing_prospect_lists.email_marketing_id"; |
|
| 97 | - $query.=" where email_marketing.campaign_id='$record'"; |
|
| 98 | - $query.=" and email_marketing_prospect_lists.prospect_list_id='$linked_id'"; |
|
| 95 | + $query = "SELECT email_marketing_prospect_lists.id from email_marketing_prospect_lists "; |
|
| 96 | + $query .= " left join email_marketing on email_marketing.id=email_marketing_prospect_lists.email_marketing_id"; |
|
| 97 | + $query .= " where email_marketing.campaign_id='$record'"; |
|
| 98 | + $query .= " and email_marketing_prospect_lists.prospect_list_id='$linked_id'"; |
|
| 99 | 99 | |
| 100 | - $result=$focus->db->query($query); |
|
| 101 | - while (($row=$focus->db->fetchByAssoc($result)) != null) { |
|
| 102 | - $del_query =" update email_marketing_prospect_lists set email_marketing_prospect_lists.deleted=1, email_marketing_prospect_lists.date_modified=".$focus->db->convert("'".TimeDate::getInstance()->nowDb()."'",'datetime'); |
|
| 103 | - $del_query.=" WHERE email_marketing_prospect_lists.id='{$row['id']}'"; |
|
| 100 | + $result = $focus->db->query($query); |
|
| 101 | + while (($row = $focus->db->fetchByAssoc($result)) != null) { |
|
| 102 | + $del_query = " update email_marketing_prospect_lists set email_marketing_prospect_lists.deleted=1, email_marketing_prospect_lists.date_modified=".$focus->db->convert("'".TimeDate::getInstance()->nowDb()."'", 'datetime'); |
|
| 103 | + $del_query .= " WHERE email_marketing_prospect_lists.id='{$row['id']}'"; |
|
| 104 | 104 | $focus->db->query($del_query); |
| 105 | 105 | } |
| 106 | 106 | $focus->db->query($query); |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | $user->retrieve($linked_id); |
| 112 | 112 | if (!empty($user->id)) { //make sure that record exists. we may have a contact on our hands. |
| 113 | 113 | |
| 114 | - if($focus->update_vcal) |
|
| 114 | + if ($focus->update_vcal) |
|
| 115 | 115 | { |
| 116 | 116 | vCal::cache_sugar_vcal($user); |
| 117 | 117 | } |
@@ -122,11 +122,11 @@ discard block |
||
| 122 | 122 | $eapm->mark_deleted($linked_id); |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | -if(!empty($_REQUEST['return_url'])){ |
|
| 126 | - $_REQUEST['return_url'] =urldecode($_REQUEST['return_url']); |
|
| 125 | +if (!empty($_REQUEST['return_url'])) { |
|
| 126 | + $_REQUEST['return_url'] = urldecode($_REQUEST['return_url']); |
|
| 127 | 127 | } |
| 128 | -$GLOBALS['log']->debug("deleted relationship: bean: $bean_name, linked_field: $linked_field, linked_id:$linked_id" ); |
|
| 129 | -if(empty($_REQUEST['refresh_page'])){ |
|
| 128 | +$GLOBALS['log']->debug("deleted relationship: bean: $bean_name, linked_field: $linked_field, linked_id:$linked_id"); |
|
| 129 | +if (empty($_REQUEST['refresh_page'])) { |
|
| 130 | 130 | handleRedirect(); |
| 131 | 131 | } |
| 132 | 132 | |
@@ -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. |
@@ -81,13 +83,13 @@ discard block |
||
| 81 | 83 | { |
| 82 | 84 | $focus->retrieve($record); |
| 83 | 85 | $focus->remove_user_from_team($linked_id); |
| 84 | - } |
|
| 85 | - else |
|
| 86 | + } else |
|
| 86 | 87 | { |
| 87 | 88 | // cut it off: |
| 88 | 89 | $focus->load_relationship($linked_field); |
| 89 | - if($focus->$linked_field->_relationship->relationship_name == 'quotes_contacts_shipto') |
|
| 90 | - unset($focus->$linked_field->_relationship->relationship_role_column); |
|
| 90 | + if($focus->$linked_field->_relationship->relationship_name == 'quotes_contacts_shipto') { |
|
| 91 | + unset($focus->$linked_field->_relationship->relationship_role_column); |
|
| 92 | + } |
|
| 91 | 93 | $focus->$linked_field->delete($record,$linked_id); |
| 92 | 94 | } |
| 93 | 95 | if ($bean_name == 'Campaign' and $linked_field=='prospectlists' ) { |
@@ -246,12 +246,12 @@ discard block |
||
| 246 | 246 | */ |
| 247 | 247 | private $_templateCache = array(); |
| 248 | 248 | |
| 249 | - /** |
|
| 250 | - * Cache built of sprite meta data |
|
| 251 | - * |
|
| 252 | - * @var array |
|
| 253 | - */ |
|
| 254 | - private $_spriteCache = array(); |
|
| 249 | + /** |
|
| 250 | + * Cache built of sprite meta data |
|
| 251 | + * |
|
| 252 | + * @var array |
|
| 253 | + */ |
|
| 254 | + private $_spriteCache = array(); |
|
| 255 | 255 | |
| 256 | 256 | /** |
| 257 | 257 | * Size of the caches after the are initialized in the constructor |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | 'imageCache' => 0, |
| 264 | 264 | 'jsCache' => 0, |
| 265 | 265 | 'templateCache' => 0, |
| 266 | - 'spriteCache' => 0, |
|
| 266 | + 'spriteCache' => 0, |
|
| 267 | 267 | ); |
| 268 | 268 | |
| 269 | 269 | /** |
@@ -329,21 +329,21 @@ discard block |
||
| 329 | 329 | $this->_templateCache = $caches['templateCache']; |
| 330 | 330 | } |
| 331 | 331 | $cachedfile = sugar_cached($this->getFilePath().'/spriteCache.php'); |
| 332 | - if(!empty($GLOBALS['sugar_config']['use_sprites']) && sugar_is_file($cachedfile)) { |
|
| 333 | - $this->_spriteCache = unserialize(sugar_file_get_contents($cachedfile)); |
|
| 334 | - } |
|
| 332 | + if(!empty($GLOBALS['sugar_config']['use_sprites']) && sugar_is_file($cachedfile)) { |
|
| 333 | + $this->_spriteCache = unserialize(sugar_file_get_contents($cachedfile)); |
|
| 334 | + } |
|
| 335 | 335 | } |
| 336 | 336 | $this->_initialCacheSize = array( |
| 337 | 337 | 'jsCache' => count($this->_jsCache), |
| 338 | 338 | 'cssCache' => count($this->_cssCache), |
| 339 | 339 | 'imageCache' => count($this->_imageCache), |
| 340 | 340 | 'templateCache' => count($this->_templateCache), |
| 341 | - 'spriteCache' => count($this->_spriteCache), |
|
| 341 | + 'spriteCache' => count($this->_spriteCache), |
|
| 342 | 342 | ); |
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | /** |
| 346 | - * This is needed to prevent unserialize vulnerability |
|
| 346 | + * This is needed to prevent unserialize vulnerability |
|
| 347 | 347 | */ |
| 348 | 348 | public function __wakeup() |
| 349 | 349 | { |
@@ -380,8 +380,8 @@ discard block |
||
| 380 | 380 | |
| 381 | 381 | if (is_file("$cachedir/pathCache.php")) |
| 382 | 382 | unlink("$cachedir/pathCache.php"); |
| 383 | - if (is_file("$cachedir/spriteCache.php")) |
|
| 384 | - unlink("$cachedir/spriteCache.php"); |
|
| 383 | + if (is_file("$cachedir/spriteCache.php")) |
|
| 384 | + unlink("$cachedir/spriteCache.php"); |
|
| 385 | 385 | |
| 386 | 386 | } |
| 387 | 387 | elseif ( !inDeveloperMode() ) { |
@@ -404,12 +404,12 @@ discard block |
||
| 404 | 404 | ); |
| 405 | 405 | |
| 406 | 406 | } |
| 407 | - if ( count($this->_spriteCache) != $this->_initialCacheSize['spriteCache']) { |
|
| 408 | - sugar_file_put_contents( |
|
| 409 | - "$cachedir/spriteCache.php", |
|
| 410 | - serialize($this->_spriteCache) |
|
| 411 | - ); |
|
| 412 | - } |
|
| 407 | + if ( count($this->_spriteCache) != $this->_initialCacheSize['spriteCache']) { |
|
| 408 | + sugar_file_put_contents( |
|
| 409 | + "$cachedir/spriteCache.php", |
|
| 410 | + serialize($this->_spriteCache) |
|
| 411 | + ); |
|
| 412 | + } |
|
| 413 | 413 | } |
| 414 | 414 | } |
| 415 | 415 | |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | } |
| 439 | 439 | |
| 440 | 440 | public function __isset($key){ |
| 441 | - return isset($this->$key); |
|
| 441 | + return isset($this->$key); |
|
| 442 | 442 | |
| 443 | 443 | } |
| 444 | 444 | |
@@ -603,27 +603,27 @@ discard block |
||
| 603 | 603 | $html .= '<link rel="stylesheet" type="text/css" href="'.$this->getCSSURL('style.css').'" />'; |
| 604 | 604 | |
| 605 | 605 | |
| 606 | - // sprites |
|
| 607 | - if(!empty($GLOBALS['sugar_config']['use_sprites']) && $GLOBALS['sugar_config']['use_sprites']) { |
|
| 606 | + // sprites |
|
| 607 | + if(!empty($GLOBALS['sugar_config']['use_sprites']) && $GLOBALS['sugar_config']['use_sprites']) { |
|
| 608 | 608 | |
| 609 | - // system wide sprites |
|
| 610 | - if(file_exists("cache/sprites/default/sprites.css")) |
|
| 611 | - $html .= '<link rel="stylesheet" type="text/css" href="'.getJSPath('cache/sprites/default/sprites.css').'" />'; |
|
| 609 | + // system wide sprites |
|
| 610 | + if(file_exists("cache/sprites/default/sprites.css")) |
|
| 611 | + $html .= '<link rel="stylesheet" type="text/css" href="'.getJSPath('cache/sprites/default/sprites.css').'" />'; |
|
| 612 | 612 | |
| 613 | - // theme specific sprites |
|
| 614 | - if(file_exists("cache/sprites/{$this->dirName}/sprites.css")) |
|
| 615 | - $html .= '<link rel="stylesheet" type="text/css" href="'.getJSPath('cache/sprites/'.$this->dirName.'/sprites.css').'" />'; |
|
| 613 | + // theme specific sprites |
|
| 614 | + if(file_exists("cache/sprites/{$this->dirName}/sprites.css")) |
|
| 615 | + $html .= '<link rel="stylesheet" type="text/css" href="'.getJSPath('cache/sprites/'.$this->dirName.'/sprites.css').'" />'; |
|
| 616 | 616 | |
| 617 | - // parent sprites |
|
| 618 | - if($this->parentTheme && $parent = SugarThemeRegistry::get($this->parentTheme)) { |
|
| 619 | - if(file_exists("cache/sprites/{$parent->dirName}/sprites.css")) |
|
| 620 | - $html .= '<link rel="stylesheet" type="text/css" href="'.getJSPath('cache/sprites/'.$parent->dirName.'/sprites.css').'" />'; |
|
| 621 | - } |
|
| 617 | + // parent sprites |
|
| 618 | + if($this->parentTheme && $parent = SugarThemeRegistry::get($this->parentTheme)) { |
|
| 619 | + if(file_exists("cache/sprites/{$parent->dirName}/sprites.css")) |
|
| 620 | + $html .= '<link rel="stylesheet" type="text/css" href="'.getJSPath('cache/sprites/'.$parent->dirName.'/sprites.css').'" />'; |
|
| 621 | + } |
|
| 622 | 622 | |
| 623 | - // repeatable sprites |
|
| 624 | - if(file_exists("cache/sprites/Repeatable/sprites.css")) |
|
| 625 | - $html .= '<link rel="stylesheet" type="text/css" href="'.getJSPath('cache/sprites/Repeatable/sprites.css').'" />'; |
|
| 626 | - } |
|
| 623 | + // repeatable sprites |
|
| 624 | + if(file_exists("cache/sprites/Repeatable/sprites.css")) |
|
| 625 | + $html .= '<link rel="stylesheet" type="text/css" href="'.getJSPath('cache/sprites/Repeatable/sprites.css').'" />'; |
|
| 626 | + } |
|
| 627 | 627 | |
| 628 | 628 | // for BC during upgrade |
| 629 | 629 | if ( !empty($this->colors) ) { |
@@ -700,180 +700,180 @@ discard block |
||
| 700 | 700 | * |
| 701 | 701 | * @param string $image image name |
| 702 | 702 | * @param string $other_attributes optional, other attributes to add to the image tag, not cached |
| 703 | - * @param string $width optional, defaults to the actual image's width |
|
| 704 | - * @param string $height optional, defaults to the actual image's height |
|
| 705 | - * @param string $ext optional, image extension (TODO can we deprecate this one ?) |
|
| 703 | + * @param string $width optional, defaults to the actual image's width |
|
| 704 | + * @param string $height optional, defaults to the actual image's height |
|
| 705 | + * @param string $ext optional, image extension (TODO can we deprecate this one ?) |
|
| 706 | 706 | * @param string $alt optional, only used when image contains something useful, i.e. "Sally's profile pic" |
| 707 | 707 | * @return string HTML image tag or sprite |
| 708 | 708 | */ |
| 709 | 709 | public function getImage( |
| 710 | 710 | $imageName, |
| 711 | 711 | $other_attributes = '', |
| 712 | - $width = null, |
|
| 713 | - $height = null, |
|
| 714 | - $ext = null, |
|
| 712 | + $width = null, |
|
| 713 | + $height = null, |
|
| 714 | + $ext = null, |
|
| 715 | 715 | $alt = '' |
| 716 | 716 | ) |
| 717 | 717 | { |
| 718 | 718 | |
| 719 | 719 | static $cached_results = array(); |
| 720 | 720 | |
| 721 | - // trap deprecated use of image extension |
|
| 722 | - if(is_null($ext)) { |
|
| 723 | - $imageNameExp = explode('.',$imageName); |
|
| 724 | - if(count($imageNameExp) == 1) |
|
| 725 | - $imageName .= '.gif'; |
|
| 726 | - } else { |
|
| 727 | - $imageName .= $ext; |
|
| 728 | - } |
|
| 729 | - |
|
| 730 | - // trap alt attributes in other_attributes |
|
| 731 | - if(preg_match('/alt=["\']([^\'"]+)["\']/i', $other_attributes)) |
|
| 732 | - $GLOBALS['log']->debug("Sprites: alt attribute detected for $imageName"); |
|
| 733 | - // sprite handler, makes use of own caching mechanism |
|
| 734 | - if(!empty($GLOBALS['sugar_config']['use_sprites']) && $GLOBALS['sugar_config']['use_sprites']) { |
|
| 735 | - // get sprite metadata |
|
| 736 | - if($sp = $this->getSpriteMeta($imageName)) { |
|
| 737 | - // requested size should match |
|
| 738 | - if( (!is_null($width) && $sp['width'] == $width) || (is_null($width)) && |
|
| 739 | - (!is_null($height) && $sp['height'] == $height) || (is_null($height)) ) |
|
| 740 | - { |
|
| 721 | + // trap deprecated use of image extension |
|
| 722 | + if(is_null($ext)) { |
|
| 723 | + $imageNameExp = explode('.',$imageName); |
|
| 724 | + if(count($imageNameExp) == 1) |
|
| 725 | + $imageName .= '.gif'; |
|
| 726 | + } else { |
|
| 727 | + $imageName .= $ext; |
|
| 728 | + } |
|
| 729 | + |
|
| 730 | + // trap alt attributes in other_attributes |
|
| 731 | + if(preg_match('/alt=["\']([^\'"]+)["\']/i', $other_attributes)) |
|
| 732 | + $GLOBALS['log']->debug("Sprites: alt attribute detected for $imageName"); |
|
| 733 | + // sprite handler, makes use of own caching mechanism |
|
| 734 | + if(!empty($GLOBALS['sugar_config']['use_sprites']) && $GLOBALS['sugar_config']['use_sprites']) { |
|
| 735 | + // get sprite metadata |
|
| 736 | + if($sp = $this->getSpriteMeta($imageName)) { |
|
| 737 | + // requested size should match |
|
| 738 | + if( (!is_null($width) && $sp['width'] == $width) || (is_null($width)) && |
|
| 739 | + (!is_null($height) && $sp['height'] == $height) || (is_null($height)) ) |
|
| 740 | + { |
|
| 741 | 741 | $other_attributes .= ' data-orig="'.$imageName.'"'; |
| 742 | 742 | |
| 743 | - if($sprite = $this->getSprite($sp['class'], $other_attributes, $alt)) |
|
| 744 | - { |
|
| 745 | - return $sprite; |
|
| 746 | - } |
|
| 747 | - } |
|
| 748 | - } |
|
| 749 | - } |
|
| 750 | - |
|
| 751 | - // img caching |
|
| 752 | - if(empty($cached_results[$imageName])) { |
|
| 753 | - $imageURL = $this->getImageURL($imageName,false); |
|
| 754 | - if ( empty($imageURL) ) |
|
| 755 | - return false; |
|
| 743 | + if($sprite = $this->getSprite($sp['class'], $other_attributes, $alt)) |
|
| 744 | + { |
|
| 745 | + return $sprite; |
|
| 746 | + } |
|
| 747 | + } |
|
| 748 | + } |
|
| 749 | + } |
|
| 750 | + |
|
| 751 | + // img caching |
|
| 752 | + if(empty($cached_results[$imageName])) { |
|
| 753 | + $imageURL = $this->getImageURL($imageName,false); |
|
| 754 | + if ( empty($imageURL) ) |
|
| 755 | + return false; |
|
| 756 | 756 | if(strpos($imageURL, '.svg', strlen($imageURL)-4)){ |
| 757 | 757 | $cached_results[$imageName] = file_get_contents($imageURL); |
| 758 | 758 | } else { |
| 759 | 759 | $cached_results[$imageName] = '<img src="'.getJSPath($imageURL).'" '; |
| 760 | 760 | } |
| 761 | 761 | |
| 762 | - } |
|
| 762 | + } |
|
| 763 | 763 | |
| 764 | - $attr_width = (is_null($width)) ? "" : "width=\"$width\""; |
|
| 765 | - $attr_height = (is_null($height)) ? "" : "height=\"$height\""; |
|
| 764 | + $attr_width = (is_null($width)) ? "" : "width=\"$width\""; |
|
| 765 | + $attr_height = (is_null($height)) ? "" : "height=\"$height\""; |
|
| 766 | 766 | |
| 767 | 767 | if(strpos($cached_results[$imageName], 'svg') !== false){ |
| 768 | 768 | return $cached_results[$imageName]; |
| 769 | 769 | } |
| 770 | - return $cached_results[$imageName] . " $attr_width $attr_height $other_attributes alt=\"$alt\" />"; |
|
| 770 | + return $cached_results[$imageName] . " $attr_width $attr_height $other_attributes alt=\"$alt\" />"; |
|
| 771 | + } |
|
| 772 | + |
|
| 773 | + /** |
|
| 774 | + * Returns sprite meta data |
|
| 775 | + * |
|
| 776 | + * @param string $imageName Image filename including extension |
|
| 777 | + * @return array Sprite meta data |
|
| 778 | + */ |
|
| 779 | + public function getSpriteMeta($imageName) { |
|
| 780 | + |
|
| 781 | + // return from cache |
|
| 782 | + if(isset($this->_spriteCache[$imageName])) |
|
| 783 | + return $this->_spriteCache[$imageName]; |
|
| 784 | + |
|
| 785 | + // sprite keys are base on imageURL |
|
| 786 | + $imageURL = $this->getImageURL($imageName,false); |
|
| 787 | + if(empty($imageURL)) { |
|
| 788 | + $this->_spriteCache[$imageName] = false; |
|
| 789 | + return false; |
|
| 790 | + } |
|
| 791 | + |
|
| 792 | + // load meta data, includes default images |
|
| 793 | + require_once("include/SugarTheme/SugarSprites.php"); |
|
| 794 | + $meta = SugarSprites::getInstance(); |
|
| 795 | + // add current theme dir |
|
| 796 | + $meta->loadSpriteMeta($this->dirName); |
|
| 797 | + // add parent theme dir |
|
| 798 | + if($this->parentTheme && $parent = SugarThemeRegistry::get($this->parentTheme)) { |
|
| 799 | + $meta->loadSpriteMeta($parent->dirName); |
|
| 800 | + } |
|
| 801 | + |
|
| 802 | + // add to cache |
|
| 803 | + if(isset($meta->sprites[$imageURL])) { |
|
| 804 | + $this->_spriteCache[$imageName] = $meta->sprites[$imageURL]; |
|
| 805 | + // add imageURL to cache |
|
| 806 | + //$this->_spriteCache[$imageName]['imageURL'] = $imageURL; |
|
| 807 | + } else { |
|
| 808 | + $this->_spriteCache[$imageName] = false; |
|
| 809 | + $GLOBALS['log']->debug("Sprites: miss for $imageURL"); |
|
| 810 | + } |
|
| 811 | + return $this->_spriteCache[$imageName]; |
|
| 812 | + } |
|
| 813 | + |
|
| 814 | + /** |
|
| 815 | + * Returns sprite HTML span tag |
|
| 816 | + * |
|
| 817 | + * @param string class The md5 id used in the CSS sprites class |
|
| 818 | + * @param string attr optional, list of additional html attributes |
|
| 819 | + * @param string title optional, the title (equivalent to alt on img) |
|
| 820 | + * @return string HTML span tag |
|
| 821 | + */ |
|
| 822 | + public function getSprite($class, $attr, $title) { |
|
| 823 | + |
|
| 824 | + // handle multiple class tags |
|
| 825 | + $class_regex = '/class=["\']([^\'"]+)["\']/i'; |
|
| 826 | + preg_match($class_regex, $attr, $match); |
|
| 827 | + if(isset($match[1])) { |
|
| 828 | + $attr = preg_replace($class_regex, 'class="spr_'.$class.' ${1}"', $attr); |
|
| 829 | + |
|
| 830 | + // single class |
|
| 831 | + } else { |
|
| 832 | + $attr .= ' class="spr_'.$class.'"'; |
|
| 833 | + } |
|
| 834 | + |
|
| 835 | + if($title) |
|
| 836 | + $attr .= ' title="'.$title.'"'; |
|
| 837 | + |
|
| 838 | + // use </span> instead of /> to prevent weird UI results |
|
| 839 | + $GLOBALS['log']->debug("Sprites: generated sprite -> $attr"); |
|
| 840 | + return "<span {$attr}></span>"; |
|
| 771 | 841 | } |
| 772 | 842 | |
| 773 | - /** |
|
| 774 | - * Returns sprite meta data |
|
| 775 | - * |
|
| 776 | - * @param string $imageName Image filename including extension |
|
| 777 | - * @return array Sprite meta data |
|
| 778 | - */ |
|
| 779 | - public function getSpriteMeta($imageName) { |
|
| 780 | - |
|
| 781 | - // return from cache |
|
| 782 | - if(isset($this->_spriteCache[$imageName])) |
|
| 783 | - return $this->_spriteCache[$imageName]; |
|
| 784 | - |
|
| 785 | - // sprite keys are base on imageURL |
|
| 786 | - $imageURL = $this->getImageURL($imageName,false); |
|
| 787 | - if(empty($imageURL)) { |
|
| 788 | - $this->_spriteCache[$imageName] = false; |
|
| 789 | - return false; |
|
| 790 | - } |
|
| 791 | - |
|
| 792 | - // load meta data, includes default images |
|
| 793 | - require_once("include/SugarTheme/SugarSprites.php"); |
|
| 794 | - $meta = SugarSprites::getInstance(); |
|
| 795 | - // add current theme dir |
|
| 796 | - $meta->loadSpriteMeta($this->dirName); |
|
| 797 | - // add parent theme dir |
|
| 798 | - if($this->parentTheme && $parent = SugarThemeRegistry::get($this->parentTheme)) { |
|
| 799 | - $meta->loadSpriteMeta($parent->dirName); |
|
| 800 | - } |
|
| 801 | - |
|
| 802 | - // add to cache |
|
| 803 | - if(isset($meta->sprites[$imageURL])) { |
|
| 804 | - $this->_spriteCache[$imageName] = $meta->sprites[$imageURL]; |
|
| 805 | - // add imageURL to cache |
|
| 806 | - //$this->_spriteCache[$imageName]['imageURL'] = $imageURL; |
|
| 807 | - } else { |
|
| 808 | - $this->_spriteCache[$imageName] = false; |
|
| 809 | - $GLOBALS['log']->debug("Sprites: miss for $imageURL"); |
|
| 810 | - } |
|
| 811 | - return $this->_spriteCache[$imageName]; |
|
| 812 | - } |
|
| 813 | - |
|
| 814 | - /** |
|
| 815 | - * Returns sprite HTML span tag |
|
| 816 | - * |
|
| 817 | - * @param string class The md5 id used in the CSS sprites class |
|
| 818 | - * @param string attr optional, list of additional html attributes |
|
| 819 | - * @param string title optional, the title (equivalent to alt on img) |
|
| 820 | - * @return string HTML span tag |
|
| 821 | - */ |
|
| 822 | - public function getSprite($class, $attr, $title) { |
|
| 823 | - |
|
| 824 | - // handle multiple class tags |
|
| 825 | - $class_regex = '/class=["\']([^\'"]+)["\']/i'; |
|
| 826 | - preg_match($class_regex, $attr, $match); |
|
| 827 | - if(isset($match[1])) { |
|
| 828 | - $attr = preg_replace($class_regex, 'class="spr_'.$class.' ${1}"', $attr); |
|
| 829 | - |
|
| 830 | - // single class |
|
| 831 | - } else { |
|
| 832 | - $attr .= ' class="spr_'.$class.'"'; |
|
| 833 | - } |
|
| 834 | - |
|
| 835 | - if($title) |
|
| 836 | - $attr .= ' title="'.$title.'"'; |
|
| 837 | - |
|
| 838 | - // use </span> instead of /> to prevent weird UI results |
|
| 839 | - $GLOBALS['log']->debug("Sprites: generated sprite -> $attr"); |
|
| 840 | - return "<span {$attr}></span>"; |
|
| 841 | - } |
|
| 842 | - |
|
| 843 | - /** |
|
| 844 | - * Returns a link HTML tag with or without an embedded image |
|
| 845 | - */ |
|
| 843 | + /** |
|
| 844 | + * Returns a link HTML tag with or without an embedded image |
|
| 845 | + */ |
|
| 846 | 846 | public function getLink( |
| 847 | - $url, |
|
| 848 | - $title, |
|
| 849 | - $other_attributes = '', |
|
| 847 | + $url, |
|
| 848 | + $title, |
|
| 849 | + $other_attributes = '', |
|
| 850 | 850 | $img_name = '', |
| 851 | 851 | $img_other_attributes = '', |
| 852 | - $img_width = null, |
|
| 853 | - $img_height = null, |
|
| 854 | - $img_alt = '', |
|
| 855 | - $img_placement = 'imageonly' |
|
| 852 | + $img_width = null, |
|
| 853 | + $img_height = null, |
|
| 854 | + $img_alt = '', |
|
| 855 | + $img_placement = 'imageonly' |
|
| 856 | 856 | ) |
| 857 | 857 | { |
| 858 | 858 | |
| 859 | - if($img_name) { |
|
| 860 | - $img = $this->getImage($img_name, $img_other_attributes, $img_width, $img_height, null, $img_alt); |
|
| 861 | - if($img == false) { |
|
| 862 | - $GLOBALS['log']->debug('Sprites: unknown image getLink'); |
|
| 863 | - $img = 'unknown'; |
|
| 864 | - } |
|
| 865 | - switch($img_placement) { |
|
| 866 | - case 'left': $inner_html = $img."<span class='title'>".$title."</span>"; break; |
|
| 867 | - case 'right': $inner_html = "<span class='title'>".$title."</span>".$img; break; |
|
| 868 | - default: $inner_html = $img; break; |
|
| 869 | - } |
|
| 870 | - } else { |
|
| 871 | - $inner_html = $title; |
|
| 872 | - } |
|
| 859 | + if($img_name) { |
|
| 860 | + $img = $this->getImage($img_name, $img_other_attributes, $img_width, $img_height, null, $img_alt); |
|
| 861 | + if($img == false) { |
|
| 862 | + $GLOBALS['log']->debug('Sprites: unknown image getLink'); |
|
| 863 | + $img = 'unknown'; |
|
| 864 | + } |
|
| 865 | + switch($img_placement) { |
|
| 866 | + case 'left': $inner_html = $img."<span class='title'>".$title."</span>"; break; |
|
| 867 | + case 'right': $inner_html = "<span class='title'>".$title."</span>".$img; break; |
|
| 868 | + default: $inner_html = $img; break; |
|
| 869 | + } |
|
| 870 | + } else { |
|
| 871 | + $inner_html = $title; |
|
| 872 | + } |
|
| 873 | 873 | |
| 874 | - return '<a href="'.$url.'" title="'.$title.'" '.$other_attributes.'>'.$inner_html.'</a>'; |
|
| 874 | + return '<a href="'.$url.'" title="'.$title.'" '.$other_attributes.'>'.$inner_html.'</a>'; |
|
| 875 | 875 | |
| 876 | - } |
|
| 876 | + } |
|
| 877 | 877 | |
| 878 | 878 | /** |
| 879 | 879 | * Returns the URL for an image in the current theme. If not found in the current theme, will revert |
@@ -905,8 +905,8 @@ discard block |
||
| 905 | 905 | $imagePath = $filename; |
| 906 | 906 | elseif (($filename = $this->_getImageFileName($this->getDefaultImagePath().'/'.$imageName)) != '') |
| 907 | 907 | $imagePath = $filename; |
| 908 | - elseif (($filename = $this->_getImageFileName('include/images/'.$imageName)) != '') |
|
| 909 | - $imagePath = $filename; |
|
| 908 | + elseif (($filename = $this->_getImageFileName('include/images/'.$imageName)) != '') |
|
| 909 | + $imagePath = $filename; |
|
| 910 | 910 | else { |
| 911 | 911 | $GLOBALS['log']->warn("Image $imageName not found"); |
| 912 | 912 | return false; |
@@ -1040,8 +1040,8 @@ discard block |
||
| 1040 | 1040 | if (isset($this->parentTheme) |
| 1041 | 1041 | && SugarThemeRegistry::get($this->parentTheme) instanceOf SugarTheme |
| 1042 | 1042 | && ($filename = SugarThemeRegistry::get($this->parentTheme)->getJSURL($jsFileName,false)) != '' && !in_array($jsFileName,$this->ignoreParentFiles)) { |
| 1043 | - $jsFileContents .= file_get_contents($filename); |
|
| 1044 | - } else { |
|
| 1043 | + $jsFileContents .= file_get_contents($filename); |
|
| 1044 | + } else { |
|
| 1045 | 1045 | if (sugar_is_file($defaultFileName)) |
| 1046 | 1046 | $jsFileContents .= file_get_contents($defaultFileName); |
| 1047 | 1047 | if (sugar_is_file('custom/'.$defaultFileName)) |
@@ -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. |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | * theme basis. |
| 47 | 47 | ********************************************************************************/ |
| 48 | 48 | |
| 49 | -if(!defined('JSMIN_AS_LIB')) |
|
| 49 | +if (!defined('JSMIN_AS_LIB')) |
|
| 50 | 50 | define('JSMIN_AS_LIB', true); |
| 51 | 51 | |
| 52 | 52 | require_once("include/SugarTheme/cssmin.php"); |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | * @deprecated only here for BC during upgrades |
| 115 | 115 | * @var array |
| 116 | 116 | */ |
| 117 | - protected $fonts = array(); |
|
| 117 | + protected $fonts = array(); |
|
| 118 | 118 | |
| 119 | 119 | /** |
| 120 | 120 | * Maximum sugar version this theme is for; defaults to 5.5.1 as all the themes without this |
@@ -292,44 +292,44 @@ discard block |
||
| 292 | 292 | ) |
| 293 | 293 | { |
| 294 | 294 | // apply parent theme's properties first |
| 295 | - if ( isset($defaults['parentTheme']) ) { |
|
| 295 | + if (isset($defaults['parentTheme'])) { |
|
| 296 | 296 | $themedef = array(); |
| 297 | 297 | include("themes/{$defaults['parentTheme']}/themedef.php"); |
| 298 | - foreach ( $themedef as $key => $value ) { |
|
| 299 | - if ( property_exists(__CLASS__,$key) ) { |
|
| 298 | + foreach ($themedef as $key => $value) { |
|
| 299 | + if (property_exists(__CLASS__, $key)) { |
|
| 300 | 300 | // For all arrays ( except colors and fonts ) you can just specify the items |
| 301 | 301 | // to change instead of all of the values |
| 302 | - if ( is_array($this->$key) && !in_array($key,array('colors','fonts')) ) |
|
| 303 | - $this->$key = array_merge($this->$key,$value); |
|
| 302 | + if (is_array($this->$key) && !in_array($key, array('colors', 'fonts'))) |
|
| 303 | + $this->$key = array_merge($this->$key, $value); |
|
| 304 | 304 | else |
| 305 | 305 | $this->$key = $value; |
| 306 | 306 | } |
| 307 | 307 | } |
| 308 | 308 | } |
| 309 | - foreach ( $defaults as $key => $value ) { |
|
| 310 | - if ( property_exists(__CLASS__,$key) ) { |
|
| 309 | + foreach ($defaults as $key => $value) { |
|
| 310 | + if (property_exists(__CLASS__, $key)) { |
|
| 311 | 311 | // For all arrays ( except colors and fonts ) you can just specify the items |
| 312 | 312 | // to change instead of all of the values |
| 313 | - if ( is_array($this->$key) && !in_array($key,array('colors','fonts')) ) |
|
| 314 | - $this->$key = array_merge($this->$key,$value); |
|
| 313 | + if (is_array($this->$key) && !in_array($key, array('colors', 'fonts'))) |
|
| 314 | + $this->$key = array_merge($this->$key, $value); |
|
| 315 | 315 | else |
| 316 | 316 | $this->$key = $value; |
| 317 | 317 | } |
| 318 | 318 | } |
| 319 | - if ( !inDeveloperMode() ) { |
|
| 320 | - if ( sugar_is_file($cachedfile = sugar_cached($this->getFilePath().'/pathCache.php'))) { |
|
| 319 | + if (!inDeveloperMode()) { |
|
| 320 | + if (sugar_is_file($cachedfile = sugar_cached($this->getFilePath().'/pathCache.php'))) { |
|
| 321 | 321 | $caches = unserialize(file_get_contents($cachedfile)); |
| 322 | - if ( isset($caches['jsCache']) ) |
|
| 322 | + if (isset($caches['jsCache'])) |
|
| 323 | 323 | $this->_jsCache = $caches['jsCache']; |
| 324 | - if ( isset($caches['cssCache']) ) |
|
| 324 | + if (isset($caches['cssCache'])) |
|
| 325 | 325 | $this->_cssCache = $caches['cssCache']; |
| 326 | - if ( isset($caches['imageCache']) ) |
|
| 326 | + if (isset($caches['imageCache'])) |
|
| 327 | 327 | $this->_imageCache = $caches['imageCache']; |
| 328 | - if ( isset($caches['templateCache']) ) |
|
| 328 | + if (isset($caches['templateCache'])) |
|
| 329 | 329 | $this->_templateCache = $caches['templateCache']; |
| 330 | 330 | } |
| 331 | 331 | $cachedfile = sugar_cached($this->getFilePath().'/spriteCache.php'); |
| 332 | - if(!empty($GLOBALS['sugar_config']['use_sprites']) && sugar_is_file($cachedfile)) { |
|
| 332 | + if (!empty($GLOBALS['sugar_config']['use_sprites']) && sugar_is_file($cachedfile)) { |
|
| 333 | 333 | $this->_spriteCache = unserialize(sugar_file_get_contents($cachedfile)); |
| 334 | 334 | } |
| 335 | 335 | } |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | public function __wakeup() |
| 349 | 349 | { |
| 350 | 350 | // clean all properties |
| 351 | - foreach(get_object_vars($this) as $k => $v) { |
|
| 351 | + foreach (get_object_vars($this) as $k => $v) { |
|
| 352 | 352 | $this->$k = null; |
| 353 | 353 | } |
| 354 | 354 | throw new Exception("Not a serializable object"); |
@@ -361,14 +361,14 @@ discard block |
||
| 361 | 361 | public function __destruct() |
| 362 | 362 | { |
| 363 | 363 | // Set the current directory to one which we expect it to be (i.e. the root directory of the install |
| 364 | - $dir = realpath(dirname(__FILE__) . '/../..'); |
|
| 364 | + $dir = realpath(dirname(__FILE__).'/../..'); |
|
| 365 | 365 | static $includePathIsPatched = false; |
| 366 | 366 | if ($includePathIsPatched == false) |
| 367 | 367 | { |
| 368 | 368 | $path = explode(PATH_SEPARATOR, get_include_path()); |
| 369 | 369 | if (in_array($dir, $path) == false) |
| 370 | 370 | { |
| 371 | - set_include_path($dir . PATH_SEPARATOR . get_include_path()); |
|
| 371 | + set_include_path($dir.PATH_SEPARATOR.get_include_path()); |
|
| 372 | 372 | } |
| 373 | 373 | $includePathIsPatched = true; |
| 374 | 374 | } |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | $cachedir = sugar_cached($this->getFilePath()); |
| 377 | 377 | sugar_mkdir($cachedir, 0775, true); |
| 378 | 378 | // clear out the cache on destroy if we are asked to |
| 379 | - if ( $this->_clearCacheOnDestroy ) { |
|
| 379 | + if ($this->_clearCacheOnDestroy) { |
|
| 380 | 380 | |
| 381 | 381 | if (is_file("$cachedir/pathCache.php")) |
| 382 | 382 | unlink("$cachedir/pathCache.php"); |
@@ -384,9 +384,9 @@ discard block |
||
| 384 | 384 | unlink("$cachedir/spriteCache.php"); |
| 385 | 385 | |
| 386 | 386 | } |
| 387 | - elseif ( !inDeveloperMode() ) { |
|
| 387 | + elseif (!inDeveloperMode()) { |
|
| 388 | 388 | // only update the caches if they have been changed in this request |
| 389 | - if ( count($this->_jsCache) != $this->_initialCacheSize['jsCache'] |
|
| 389 | + if (count($this->_jsCache) != $this->_initialCacheSize['jsCache'] |
|
| 390 | 390 | || count($this->_cssCache) != $this->_initialCacheSize['cssCache'] |
| 391 | 391 | || count($this->_imageCache) != $this->_initialCacheSize['imageCache'] |
| 392 | 392 | || count($this->_templateCache) != $this->_initialCacheSize['templateCache'] |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | ); |
| 405 | 405 | |
| 406 | 406 | } |
| 407 | - if ( count($this->_spriteCache) != $this->_initialCacheSize['spriteCache']) { |
|
| 407 | + if (count($this->_spriteCache) != $this->_initialCacheSize['spriteCache']) { |
|
| 408 | 408 | sugar_file_put_contents( |
| 409 | 409 | "$cachedir/spriteCache.php", |
| 410 | 410 | serialize($this->_spriteCache) |
@@ -433,11 +433,11 @@ discard block |
||
| 433 | 433 | $key |
| 434 | 434 | ) |
| 435 | 435 | { |
| 436 | - if ( isset($this->$key) ) |
|
| 436 | + if (isset($this->$key)) |
|
| 437 | 437 | return $this->$key; |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | - public function __isset($key){ |
|
| 440 | + public function __isset($key) { |
|
| 441 | 441 | return isset($this->$key); |
| 442 | 442 | |
| 443 | 443 | } |
@@ -604,38 +604,38 @@ discard block |
||
| 604 | 604 | |
| 605 | 605 | |
| 606 | 606 | // sprites |
| 607 | - if(!empty($GLOBALS['sugar_config']['use_sprites']) && $GLOBALS['sugar_config']['use_sprites']) { |
|
| 607 | + if (!empty($GLOBALS['sugar_config']['use_sprites']) && $GLOBALS['sugar_config']['use_sprites']) { |
|
| 608 | 608 | |
| 609 | 609 | // system wide sprites |
| 610 | - if(file_exists("cache/sprites/default/sprites.css")) |
|
| 610 | + if (file_exists("cache/sprites/default/sprites.css")) |
|
| 611 | 611 | $html .= '<link rel="stylesheet" type="text/css" href="'.getJSPath('cache/sprites/default/sprites.css').'" />'; |
| 612 | 612 | |
| 613 | 613 | // theme specific sprites |
| 614 | - if(file_exists("cache/sprites/{$this->dirName}/sprites.css")) |
|
| 614 | + if (file_exists("cache/sprites/{$this->dirName}/sprites.css")) |
|
| 615 | 615 | $html .= '<link rel="stylesheet" type="text/css" href="'.getJSPath('cache/sprites/'.$this->dirName.'/sprites.css').'" />'; |
| 616 | 616 | |
| 617 | 617 | // parent sprites |
| 618 | - if($this->parentTheme && $parent = SugarThemeRegistry::get($this->parentTheme)) { |
|
| 619 | - if(file_exists("cache/sprites/{$parent->dirName}/sprites.css")) |
|
| 618 | + if ($this->parentTheme && $parent = SugarThemeRegistry::get($this->parentTheme)) { |
|
| 619 | + if (file_exists("cache/sprites/{$parent->dirName}/sprites.css")) |
|
| 620 | 620 | $html .= '<link rel="stylesheet" type="text/css" href="'.getJSPath('cache/sprites/'.$parent->dirName.'/sprites.css').'" />'; |
| 621 | 621 | } |
| 622 | 622 | |
| 623 | 623 | // repeatable sprites |
| 624 | - if(file_exists("cache/sprites/Repeatable/sprites.css")) |
|
| 624 | + if (file_exists("cache/sprites/Repeatable/sprites.css")) |
|
| 625 | 625 | $html .= '<link rel="stylesheet" type="text/css" href="'.getJSPath('cache/sprites/Repeatable/sprites.css').'" />'; |
| 626 | 626 | } |
| 627 | 627 | |
| 628 | 628 | // for BC during upgrade |
| 629 | - if ( !empty($this->colors) ) { |
|
| 630 | - if ( isset($_SESSION['authenticated_user_theme_color']) && in_array($_SESSION['authenticated_user_theme_color'], $this->colors)) |
|
| 629 | + if (!empty($this->colors)) { |
|
| 630 | + if (isset($_SESSION['authenticated_user_theme_color']) && in_array($_SESSION['authenticated_user_theme_color'], $this->colors)) |
|
| 631 | 631 | $color = $_SESSION['authenticated_user_theme_color']; |
| 632 | 632 | else |
| 633 | 633 | $color = $this->colors[0]; |
| 634 | 634 | $html .= '<link rel="stylesheet" type="text/css" href="'.$this->getCSSURL('colors.'.$color.'.css').'" id="current_color_style" />'; |
| 635 | 635 | } |
| 636 | 636 | |
| 637 | - if ( !empty($this->fonts) ) { |
|
| 638 | - if ( isset($_SESSION['authenticated_user_theme_font']) && in_array($_SESSION['authenticated_user_theme_font'], $this->fonts)) |
|
| 637 | + if (!empty($this->fonts)) { |
|
| 638 | + if (isset($_SESSION['authenticated_user_theme_font']) && in_array($_SESSION['authenticated_user_theme_font'], $this->fonts)) |
|
| 639 | 639 | $font = $_SESSION['authenticated_user_theme_font']; |
| 640 | 640 | else |
| 641 | 641 | $font = $this->fonts[0]; |
@@ -669,7 +669,7 @@ discard block |
||
| 669 | 669 | $templateName |
| 670 | 670 | ) |
| 671 | 671 | { |
| 672 | - if ( isset($this->_templateCache[$templateName]) ) |
|
| 672 | + if (isset($this->_templateCache[$templateName])) |
|
| 673 | 673 | return $this->_templateCache[$templateName]; |
| 674 | 674 | |
| 675 | 675 | $templatePath = ''; |
@@ -719,28 +719,28 @@ discard block |
||
| 719 | 719 | static $cached_results = array(); |
| 720 | 720 | |
| 721 | 721 | // trap deprecated use of image extension |
| 722 | - if(is_null($ext)) { |
|
| 723 | - $imageNameExp = explode('.',$imageName); |
|
| 724 | - if(count($imageNameExp) == 1) |
|
| 722 | + if (is_null($ext)) { |
|
| 723 | + $imageNameExp = explode('.', $imageName); |
|
| 724 | + if (count($imageNameExp) == 1) |
|
| 725 | 725 | $imageName .= '.gif'; |
| 726 | 726 | } else { |
| 727 | 727 | $imageName .= $ext; |
| 728 | 728 | } |
| 729 | 729 | |
| 730 | 730 | // trap alt attributes in other_attributes |
| 731 | - if(preg_match('/alt=["\']([^\'"]+)["\']/i', $other_attributes)) |
|
| 731 | + if (preg_match('/alt=["\']([^\'"]+)["\']/i', $other_attributes)) |
|
| 732 | 732 | $GLOBALS['log']->debug("Sprites: alt attribute detected for $imageName"); |
| 733 | 733 | // sprite handler, makes use of own caching mechanism |
| 734 | - if(!empty($GLOBALS['sugar_config']['use_sprites']) && $GLOBALS['sugar_config']['use_sprites']) { |
|
| 734 | + if (!empty($GLOBALS['sugar_config']['use_sprites']) && $GLOBALS['sugar_config']['use_sprites']) { |
|
| 735 | 735 | // get sprite metadata |
| 736 | - if($sp = $this->getSpriteMeta($imageName)) { |
|
| 736 | + if ($sp = $this->getSpriteMeta($imageName)) { |
|
| 737 | 737 | // requested size should match |
| 738 | - if( (!is_null($width) && $sp['width'] == $width) || (is_null($width)) && |
|
| 739 | - (!is_null($height) && $sp['height'] == $height) || (is_null($height)) ) |
|
| 738 | + if ((!is_null($width) && $sp['width'] == $width) || (is_null($width)) && |
|
| 739 | + (!is_null($height) && $sp['height'] == $height) || (is_null($height))) |
|
| 740 | 740 | { |
| 741 | 741 | $other_attributes .= ' data-orig="'.$imageName.'"'; |
| 742 | 742 | |
| 743 | - if($sprite = $this->getSprite($sp['class'], $other_attributes, $alt)) |
|
| 743 | + if ($sprite = $this->getSprite($sp['class'], $other_attributes, $alt)) |
|
| 744 | 744 | { |
| 745 | 745 | return $sprite; |
| 746 | 746 | } |
@@ -749,11 +749,11 @@ discard block |
||
| 749 | 749 | } |
| 750 | 750 | |
| 751 | 751 | // img caching |
| 752 | - if(empty($cached_results[$imageName])) { |
|
| 753 | - $imageURL = $this->getImageURL($imageName,false); |
|
| 754 | - if ( empty($imageURL) ) |
|
| 752 | + if (empty($cached_results[$imageName])) { |
|
| 753 | + $imageURL = $this->getImageURL($imageName, false); |
|
| 754 | + if (empty($imageURL)) |
|
| 755 | 755 | return false; |
| 756 | - if(strpos($imageURL, '.svg', strlen($imageURL)-4)){ |
|
| 756 | + if (strpos($imageURL, '.svg', strlen($imageURL) - 4)) { |
|
| 757 | 757 | $cached_results[$imageName] = file_get_contents($imageURL); |
| 758 | 758 | } else { |
| 759 | 759 | $cached_results[$imageName] = '<img src="'.getJSPath($imageURL).'" '; |
@@ -764,10 +764,10 @@ discard block |
||
| 764 | 764 | $attr_width = (is_null($width)) ? "" : "width=\"$width\""; |
| 765 | 765 | $attr_height = (is_null($height)) ? "" : "height=\"$height\""; |
| 766 | 766 | |
| 767 | - if(strpos($cached_results[$imageName], 'svg') !== false){ |
|
| 767 | + if (strpos($cached_results[$imageName], 'svg') !== false) { |
|
| 768 | 768 | return $cached_results[$imageName]; |
| 769 | 769 | } |
| 770 | - return $cached_results[$imageName] . " $attr_width $attr_height $other_attributes alt=\"$alt\" />"; |
|
| 770 | + return $cached_results[$imageName]." $attr_width $attr_height $other_attributes alt=\"$alt\" />"; |
|
| 771 | 771 | } |
| 772 | 772 | |
| 773 | 773 | /** |
@@ -779,12 +779,12 @@ discard block |
||
| 779 | 779 | public function getSpriteMeta($imageName) { |
| 780 | 780 | |
| 781 | 781 | // return from cache |
| 782 | - if(isset($this->_spriteCache[$imageName])) |
|
| 782 | + if (isset($this->_spriteCache[$imageName])) |
|
| 783 | 783 | return $this->_spriteCache[$imageName]; |
| 784 | 784 | |
| 785 | 785 | // sprite keys are base on imageURL |
| 786 | - $imageURL = $this->getImageURL($imageName,false); |
|
| 787 | - if(empty($imageURL)) { |
|
| 786 | + $imageURL = $this->getImageURL($imageName, false); |
|
| 787 | + if (empty($imageURL)) { |
|
| 788 | 788 | $this->_spriteCache[$imageName] = false; |
| 789 | 789 | return false; |
| 790 | 790 | } |
@@ -795,12 +795,12 @@ discard block |
||
| 795 | 795 | // add current theme dir |
| 796 | 796 | $meta->loadSpriteMeta($this->dirName); |
| 797 | 797 | // add parent theme dir |
| 798 | - if($this->parentTheme && $parent = SugarThemeRegistry::get($this->parentTheme)) { |
|
| 798 | + if ($this->parentTheme && $parent = SugarThemeRegistry::get($this->parentTheme)) { |
|
| 799 | 799 | $meta->loadSpriteMeta($parent->dirName); |
| 800 | 800 | } |
| 801 | 801 | |
| 802 | 802 | // add to cache |
| 803 | - if(isset($meta->sprites[$imageURL])) { |
|
| 803 | + if (isset($meta->sprites[$imageURL])) { |
|
| 804 | 804 | $this->_spriteCache[$imageName] = $meta->sprites[$imageURL]; |
| 805 | 805 | // add imageURL to cache |
| 806 | 806 | //$this->_spriteCache[$imageName]['imageURL'] = $imageURL; |
@@ -824,7 +824,7 @@ discard block |
||
| 824 | 824 | // handle multiple class tags |
| 825 | 825 | $class_regex = '/class=["\']([^\'"]+)["\']/i'; |
| 826 | 826 | preg_match($class_regex, $attr, $match); |
| 827 | - if(isset($match[1])) { |
|
| 827 | + if (isset($match[1])) { |
|
| 828 | 828 | $attr = preg_replace($class_regex, 'class="spr_'.$class.' ${1}"', $attr); |
| 829 | 829 | |
| 830 | 830 | // single class |
@@ -832,7 +832,7 @@ discard block |
||
| 832 | 832 | $attr .= ' class="spr_'.$class.'"'; |
| 833 | 833 | } |
| 834 | 834 | |
| 835 | - if($title) |
|
| 835 | + if ($title) |
|
| 836 | 836 | $attr .= ' title="'.$title.'"'; |
| 837 | 837 | |
| 838 | 838 | // use </span> instead of /> to prevent weird UI results |
@@ -856,13 +856,13 @@ discard block |
||
| 856 | 856 | ) |
| 857 | 857 | { |
| 858 | 858 | |
| 859 | - if($img_name) { |
|
| 859 | + if ($img_name) { |
|
| 860 | 860 | $img = $this->getImage($img_name, $img_other_attributes, $img_width, $img_height, null, $img_alt); |
| 861 | - if($img == false) { |
|
| 861 | + if ($img == false) { |
|
| 862 | 862 | $GLOBALS['log']->debug('Sprites: unknown image getLink'); |
| 863 | 863 | $img = 'unknown'; |
| 864 | 864 | } |
| 865 | - switch($img_placement) { |
|
| 865 | + switch ($img_placement) { |
|
| 866 | 866 | case 'left': $inner_html = $img."<span class='title'>".$title."</span>"; break; |
| 867 | 867 | case 'right': $inner_html = "<span class='title'>".$title."</span>".$img; break; |
| 868 | 868 | default: $inner_html = $img; break; |
@@ -885,9 +885,9 @@ discard block |
||
| 885 | 885 | public function getImageURL( |
| 886 | 886 | $imageName, |
| 887 | 887 | $addJSPath = true |
| 888 | - ){ |
|
| 889 | - if ( isset($this->_imageCache[$imageName]) ) { |
|
| 890 | - if ( $addJSPath ) |
|
| 888 | + ) { |
|
| 889 | + if (isset($this->_imageCache[$imageName])) { |
|
| 890 | + if ($addJSPath) |
|
| 891 | 891 | return getJSPath($this->_imageCache[$imageName]); |
| 892 | 892 | else |
| 893 | 893 | return $this->_imageCache[$imageName]; |
@@ -899,7 +899,7 @@ discard block |
||
| 899 | 899 | $imagePath = $filename; |
| 900 | 900 | elseif (isset($this->parentTheme) |
| 901 | 901 | && SugarThemeRegistry::get($this->parentTheme) instanceOf SugarTheme |
| 902 | - && ($filename = SugarThemeRegistry::get($this->parentTheme)->getImageURL($imageName,false)) != '') |
|
| 902 | + && ($filename = SugarThemeRegistry::get($this->parentTheme)->getImageURL($imageName, false)) != '') |
|
| 903 | 903 | $imagePath = $filename; |
| 904 | 904 | elseif (($filename = $this->_getImageFileName('custom/'.$this->getDefaultImagePath().'/'.$imageName)) != '') |
| 905 | 905 | $imagePath = $filename; |
@@ -914,7 +914,7 @@ discard block |
||
| 914 | 914 | |
| 915 | 915 | $this->_imageCache[$imageName] = $imagePath; |
| 916 | 916 | |
| 917 | - if ( $addJSPath ) |
|
| 917 | + if ($addJSPath) |
|
| 918 | 918 | return getJSPath($imagePath); |
| 919 | 919 | |
| 920 | 920 | return $imagePath; |
@@ -931,13 +931,13 @@ discard block |
||
| 931 | 931 | ) |
| 932 | 932 | { |
| 933 | 933 | // return now if the extension matches that of which we are looking for |
| 934 | - if ( sugar_is_file($imageName) ) |
|
| 934 | + if (sugar_is_file($imageName)) |
|
| 935 | 935 | return $imageName; |
| 936 | 936 | $pathParts = pathinfo($imageName); |
| 937 | - foreach ( $this->imageExtensions as $extension ) |
|
| 938 | - if ( isset($pathParts['extension']) ) |
|
| 939 | - if ( ( $extension != $pathParts['extension'] ) |
|
| 940 | - && sugar_is_file($pathParts['dirname'].'/'.$pathParts['filename'].'.'.$extension) ) |
|
| 937 | + foreach ($this->imageExtensions as $extension) |
|
| 938 | + if (isset($pathParts['extension'])) |
|
| 939 | + if (($extension != $pathParts['extension']) |
|
| 940 | + && sugar_is_file($pathParts['dirname'].'/'.$pathParts['filename'].'.'.$extension)) |
|
| 941 | 941 | return $pathParts['dirname'].'/'.$pathParts['filename'].'.'.$extension; |
| 942 | 942 | |
| 943 | 943 | return ''; |
@@ -953,8 +953,8 @@ discard block |
||
| 953 | 953 | */ |
| 954 | 954 | public function getCSSURL($cssFileName, $returnURL = true) |
| 955 | 955 | { |
| 956 | - if ( isset($this->_cssCache[$cssFileName]) && sugar_is_file(sugar_cached($this->_cssCache[$cssFileName])) ) { |
|
| 957 | - if ( $returnURL ) |
|
| 956 | + if (isset($this->_cssCache[$cssFileName]) && sugar_is_file(sugar_cached($this->_cssCache[$cssFileName]))) { |
|
| 957 | + if ($returnURL) |
|
| 958 | 958 | return getJSPath("cache/".$this->_cssCache[$cssFileName]); |
| 959 | 959 | else |
| 960 | 960 | return sugar_cached($this->_cssCache[$cssFileName]); |
@@ -965,7 +965,7 @@ discard block |
||
| 965 | 965 | $fullFileName = $this->getCSSPath().'/'.$cssFileName; |
| 966 | 966 | if (isset($this->parentTheme) |
| 967 | 967 | && SugarThemeRegistry::get($this->parentTheme) instanceOf SugarTheme |
| 968 | - && ($filename = SugarThemeRegistry::get($this->parentTheme)->getCSSURL($cssFileName,false)) != '') |
|
| 968 | + && ($filename = SugarThemeRegistry::get($this->parentTheme)->getCSSURL($cssFileName, false)) != '') |
|
| 969 | 969 | $cssFileContents .= file_get_contents($filename); |
| 970 | 970 | else { |
| 971 | 971 | if (sugar_is_file($defaultFileName)) |
@@ -994,24 +994,24 @@ discard block |
||
| 994 | 994 | |
| 995 | 995 | // if this is the style.css file, prepend the base.css and calendar-win2k-cold-1.css |
| 996 | 996 | // files before the theme styles |
| 997 | - if ( $cssFileName == 'style.css' && !isset($this->parentTheme) ) { |
|
| 998 | - if ( inDeveloperMode() ) |
|
| 999 | - $cssFileContents = file_get_contents('include/javascript/yui/build/base/base.css') . $cssFileContents; |
|
| 997 | + if ($cssFileName == 'style.css' && !isset($this->parentTheme)) { |
|
| 998 | + if (inDeveloperMode()) |
|
| 999 | + $cssFileContents = file_get_contents('include/javascript/yui/build/base/base.css').$cssFileContents; |
|
| 1000 | 1000 | else |
| 1001 | - $cssFileContents = file_get_contents('include/javascript/yui/build/base/base-min.css') . $cssFileContents; |
|
| 1001 | + $cssFileContents = file_get_contents('include/javascript/yui/build/base/base-min.css').$cssFileContents; |
|
| 1002 | 1002 | } |
| 1003 | 1003 | |
| 1004 | 1004 | // minify the css |
| 1005 | - if ( !inDeveloperMode() && !sugar_is_file($cssFilePath) ) { |
|
| 1005 | + if (!inDeveloperMode() && !sugar_is_file($cssFilePath)) { |
|
| 1006 | 1006 | $cssFileContents = cssmin::minify($cssFileContents); |
| 1007 | 1007 | } |
| 1008 | 1008 | |
| 1009 | 1009 | // now write the css to cache |
| 1010 | - sugar_file_put_contents($cssFilePath,$cssFileContents); |
|
| 1010 | + sugar_file_put_contents($cssFilePath, $cssFileContents); |
|
| 1011 | 1011 | |
| 1012 | 1012 | $this->_cssCache[$cssFileName] = $fullFileName; |
| 1013 | 1013 | |
| 1014 | - if ( $returnURL ) |
|
| 1014 | + if ($returnURL) |
|
| 1015 | 1015 | return getJSPath("cache/".$fullFileName); |
| 1016 | 1016 | |
| 1017 | 1017 | return sugar_cached($fullFileName); |
@@ -1027,8 +1027,8 @@ discard block |
||
| 1027 | 1027 | */ |
| 1028 | 1028 | public function getJSURL($jsFileName, $returnURL = true) |
| 1029 | 1029 | { |
| 1030 | - if ( isset($this->_jsCache[$jsFileName]) && sugar_is_file(sugar_cached($this->_jsCache[$jsFileName])) ) { |
|
| 1031 | - if ( $returnURL ) |
|
| 1030 | + if (isset($this->_jsCache[$jsFileName]) && sugar_is_file(sugar_cached($this->_jsCache[$jsFileName]))) { |
|
| 1031 | + if ($returnURL) |
|
| 1032 | 1032 | return getJSPath("cache/".$this->_jsCache[$jsFileName]); |
| 1033 | 1033 | else |
| 1034 | 1034 | return sugar_cached($this->_jsCache[$jsFileName]); |
@@ -1039,7 +1039,7 @@ discard block |
||
| 1039 | 1039 | $defaultFileName = $this->getDefaultJSPath().'/'.$jsFileName; |
| 1040 | 1040 | if (isset($this->parentTheme) |
| 1041 | 1041 | && SugarThemeRegistry::get($this->parentTheme) instanceOf SugarTheme |
| 1042 | - && ($filename = SugarThemeRegistry::get($this->parentTheme)->getJSURL($jsFileName,false)) != '' && !in_array($jsFileName,$this->ignoreParentFiles)) { |
|
| 1042 | + && ($filename = SugarThemeRegistry::get($this->parentTheme)->getJSURL($jsFileName, false)) != '' && !in_array($jsFileName, $this->ignoreParentFiles)) { |
|
| 1043 | 1043 | $jsFileContents .= file_get_contents($filename); |
| 1044 | 1044 | } else { |
| 1045 | 1045 | if (sugar_is_file($defaultFileName)) |
@@ -1060,18 +1060,18 @@ discard block |
||
| 1060 | 1060 | $jsFilePath = create_cache_directory($fullFileName); |
| 1061 | 1061 | |
| 1062 | 1062 | // minify the js |
| 1063 | - if ( !inDeveloperMode()&& !sugar_is_file(str_replace('.js','-min.js',$jsFilePath)) ) { |
|
| 1063 | + if (!inDeveloperMode() && !sugar_is_file(str_replace('.js', '-min.js', $jsFilePath))) { |
|
| 1064 | 1064 | $jsFileContents = SugarMin::minify($jsFileContents); |
| 1065 | - $jsFilePath = str_replace('.js','-min.js',$jsFilePath); |
|
| 1066 | - $fullFileName = str_replace('.js','-min.js',$fullFileName); |
|
| 1065 | + $jsFilePath = str_replace('.js', '-min.js', $jsFilePath); |
|
| 1066 | + $fullFileName = str_replace('.js', '-min.js', $fullFileName); |
|
| 1067 | 1067 | } |
| 1068 | 1068 | |
| 1069 | 1069 | // now write the js to cache |
| 1070 | - sugar_file_put_contents($jsFilePath,$jsFileContents); |
|
| 1070 | + sugar_file_put_contents($jsFilePath, $jsFileContents); |
|
| 1071 | 1071 | |
| 1072 | 1072 | $this->_jsCache[$jsFileName] = $fullFileName; |
| 1073 | 1073 | |
| 1074 | - if ( $returnURL ) |
|
| 1074 | + if ($returnURL) |
|
| 1075 | 1075 | return getJSPath("cache/".$fullFileName); |
| 1076 | 1076 | |
| 1077 | 1077 | return sugar_cached($fullFileName); |
@@ -1087,7 +1087,7 @@ discard block |
||
| 1087 | 1087 | // first, lets get all the paths of where to look |
| 1088 | 1088 | $pathsToSearch = array($this->getImagePath()); |
| 1089 | 1089 | $theme = $this; |
| 1090 | - while (isset($theme->parentTheme) && SugarThemeRegistry::get($theme->parentTheme) instanceOf SugarTheme ) { |
|
| 1090 | + while (isset($theme->parentTheme) && SugarThemeRegistry::get($theme->parentTheme) instanceOf SugarTheme) { |
|
| 1091 | 1091 | $theme = SugarThemeRegistry::get($theme->parentTheme); |
| 1092 | 1092 | $pathsToSearch[] = $theme->getImagePath(); |
| 1093 | 1093 | } |
@@ -1095,7 +1095,7 @@ discard block |
||
| 1095 | 1095 | |
| 1096 | 1096 | // now build the array |
| 1097 | 1097 | $imageArray = array(); |
| 1098 | - foreach ( $pathsToSearch as $path ) |
|
| 1098 | + foreach ($pathsToSearch as $path) |
|
| 1099 | 1099 | { |
| 1100 | 1100 | if (!sugar_is_dir($path)) $path = "custom/$path"; |
| 1101 | 1101 | if (sugar_is_dir($path) && is_readable($path) && $dir = opendir($path)) { |
@@ -1107,8 +1107,8 @@ discard block |
||
| 1107 | 1107 | || $file == "Attic" |
| 1108 | 1108 | ) |
| 1109 | 1109 | continue; |
| 1110 | - if ( !isset($imageArray[$file]) ) |
|
| 1111 | - $imageArray[$file] = $this->getImageURL($file,false); |
|
| 1110 | + if (!isset($imageArray[$file])) |
|
| 1111 | + $imageArray[$file] = $this->getImageURL($file, false); |
|
| 1112 | 1112 | } |
| 1113 | 1113 | closedir($dir); |
| 1114 | 1114 | } |
@@ -1130,13 +1130,13 @@ discard block |
||
| 1130 | 1130 | |
| 1131 | 1131 | $config = array(); |
| 1132 | 1132 | |
| 1133 | - foreach($this->config_options as $name => $def){ |
|
| 1133 | + foreach ($this->config_options as $name => $def) { |
|
| 1134 | 1134 | $config[$name] = $def; |
| 1135 | 1135 | |
| 1136 | 1136 | $value = ''; |
| 1137 | - if(isset($sugar_config['theme_settings'][$this->dirName][$name])){ |
|
| 1137 | + if (isset($sugar_config['theme_settings'][$this->dirName][$name])) { |
|
| 1138 | 1138 | $value = $sugar_config['theme_settings'][$this->dirName][$name]; |
| 1139 | - } else if(isset($def['default'])){ |
|
| 1139 | + } else if (isset($def['default'])) { |
|
| 1140 | 1140 | $value = $def['default']; |
| 1141 | 1141 | } |
| 1142 | 1142 | $config[$name] = $value; |
@@ -1189,28 +1189,28 @@ discard block |
||
| 1189 | 1189 | } |
| 1190 | 1190 | |
| 1191 | 1191 | // Assume theme is designed for 5.5.x if not specified otherwise |
| 1192 | - if ( !isset($themedef['version']) ) |
|
| 1192 | + if (!isset($themedef['version'])) |
|
| 1193 | 1193 | $themedef['version']['regex_matches'] = array('5\.5\.*'); |
| 1194 | 1194 | |
| 1195 | 1195 | // Check to see if theme is valid for this version of Sugar; return false if not |
| 1196 | 1196 | $version_ok = false; |
| 1197 | - if( isset($themedef['version']['exact_matches']) ){ |
|
| 1197 | + if (isset($themedef['version']['exact_matches'])) { |
|
| 1198 | 1198 | $matches_empty = false; |
| 1199 | - foreach( $themedef['version']['exact_matches'] as $match ){ |
|
| 1200 | - if( $match == $GLOBALS['sugar_version'] ){ |
|
| 1199 | + foreach ($themedef['version']['exact_matches'] as $match) { |
|
| 1200 | + if ($match == $GLOBALS['sugar_version']) { |
|
| 1201 | 1201 | $version_ok = true; |
| 1202 | 1202 | } |
| 1203 | 1203 | } |
| 1204 | 1204 | } |
| 1205 | - if( !$version_ok && isset($themedef['version']['regex_matches']) ){ |
|
| 1205 | + if (!$version_ok && isset($themedef['version']['regex_matches'])) { |
|
| 1206 | 1206 | $matches_empty = false; |
| 1207 | - foreach( $themedef['version']['regex_matches'] as $match ){ |
|
| 1208 | - if( preg_match( "/$match/", $GLOBALS['sugar_version'] ) ){ |
|
| 1207 | + foreach ($themedef['version']['regex_matches'] as $match) { |
|
| 1208 | + if (preg_match("/$match/", $GLOBALS['sugar_version'])) { |
|
| 1209 | 1209 | $version_ok = true; |
| 1210 | 1210 | } |
| 1211 | 1211 | } |
| 1212 | 1212 | } |
| 1213 | - if ( !$version_ok ) |
|
| 1213 | + if (!$version_ok) |
|
| 1214 | 1214 | return false; |
| 1215 | 1215 | |
| 1216 | 1216 | $theme = new SugarTheme($themedef); |
@@ -1226,7 +1226,7 @@ discard block |
||
| 1226 | 1226 | $themeName |
| 1227 | 1227 | ) |
| 1228 | 1228 | { |
| 1229 | - if ( self::exists($themeName) ) |
|
| 1229 | + if (self::exists($themeName)) |
|
| 1230 | 1230 | unset(self::$_themes[$themeName]); |
| 1231 | 1231 | } |
| 1232 | 1232 | |
@@ -1239,7 +1239,7 @@ discard block |
||
| 1239 | 1239 | $themeName |
| 1240 | 1240 | ) |
| 1241 | 1241 | { |
| 1242 | - if ( isset(self::$_themes[$themeName]) ) |
|
| 1242 | + if (isset(self::$_themes[$themeName])) |
|
| 1243 | 1243 | return self::$_themes[$themeName]; |
| 1244 | 1244 | } |
| 1245 | 1245 | |
@@ -1250,7 +1250,7 @@ discard block |
||
| 1250 | 1250 | */ |
| 1251 | 1251 | public static function current() |
| 1252 | 1252 | { |
| 1253 | - if ( !isset(self::$_currentTheme) ) |
|
| 1253 | + if (!isset(self::$_currentTheme)) |
|
| 1254 | 1254 | self::buildRegistry(); |
| 1255 | 1255 | |
| 1256 | 1256 | return self::$_themes[self::$_currentTheme]; |
@@ -1263,10 +1263,10 @@ discard block |
||
| 1263 | 1263 | */ |
| 1264 | 1264 | public static function getDefault() |
| 1265 | 1265 | { |
| 1266 | - if ( !isset(self::$_currentTheme) ) |
|
| 1266 | + if (!isset(self::$_currentTheme)) |
|
| 1267 | 1267 | self::buildRegistry(); |
| 1268 | 1268 | |
| 1269 | - if ( isset($GLOBALS['sugar_config']['default_theme']) && self::exists($GLOBALS['sugar_config']['default_theme']) ) { |
|
| 1269 | + if (isset($GLOBALS['sugar_config']['default_theme']) && self::exists($GLOBALS['sugar_config']['default_theme'])) { |
|
| 1270 | 1270 | return self::get($GLOBALS['sugar_config']['default_theme']); |
| 1271 | 1271 | } |
| 1272 | 1272 | $array_keys = array_keys(self::availableThemes()); |
@@ -1295,7 +1295,7 @@ discard block |
||
| 1295 | 1295 | $themeName |
| 1296 | 1296 | ) |
| 1297 | 1297 | { |
| 1298 | - if ( !self::exists($themeName) ) |
|
| 1298 | + if (!self::exists($themeName)) |
|
| 1299 | 1299 | return false; |
| 1300 | 1300 | |
| 1301 | 1301 | self::$_currentTheme = $themeName; |
@@ -1312,17 +1312,17 @@ discard block |
||
| 1312 | 1312 | public static function buildRegistry() |
| 1313 | 1313 | { |
| 1314 | 1314 | self::$_themes = array(); |
| 1315 | - $dirs = array("themes/","custom/themes/"); |
|
| 1315 | + $dirs = array("themes/", "custom/themes/"); |
|
| 1316 | 1316 | |
| 1317 | 1317 | // check for a default themedef file |
| 1318 | 1318 | $themedefDefault = array(); |
| 1319 | - if ( sugar_is_file("custom/themes/default/themedef.php") ) { |
|
| 1319 | + if (sugar_is_file("custom/themes/default/themedef.php")) { |
|
| 1320 | 1320 | $themedef = array(); |
| 1321 | 1321 | require("custom/themes/default/themedef.php"); |
| 1322 | 1322 | $themedefDefault = $themedef; |
| 1323 | 1323 | } |
| 1324 | 1324 | |
| 1325 | - foreach ($dirs as $dirPath ) { |
|
| 1325 | + foreach ($dirs as $dirPath) { |
|
| 1326 | 1326 | if (sugar_is_dir('./'.$dirPath) && is_readable('./'.$dirPath) && $dir = opendir('./'.$dirPath)) { |
| 1327 | 1327 | while (($file = readdir($dir)) !== false) { |
| 1328 | 1328 | if ($file == ".." |
@@ -1337,18 +1337,18 @@ discard block |
||
| 1337 | 1337 | continue; |
| 1338 | 1338 | $themedef = array(); |
| 1339 | 1339 | require("./{$dirPath}{$file}/themedef.php"); |
| 1340 | - $themedef = array_merge($themedef,$themedefDefault); |
|
| 1340 | + $themedef = array_merge($themedef, $themedefDefault); |
|
| 1341 | 1341 | $themedef['dirName'] = $file; |
| 1342 | 1342 | // check for theme already existing in the registry |
| 1343 | 1343 | // if so, then it will override the current one |
| 1344 | - if ( self::exists($themedef['dirName']) ) { |
|
| 1344 | + if (self::exists($themedef['dirName'])) { |
|
| 1345 | 1345 | $existingTheme = self::get($themedef['dirName']); |
| 1346 | - foreach ( SugarTheme::getThemeDefFields() as $field ) |
|
| 1347 | - if ( !isset($themedef[$field]) ) |
|
| 1346 | + foreach (SugarTheme::getThemeDefFields() as $field) |
|
| 1347 | + if (!isset($themedef[$field])) |
|
| 1348 | 1348 | $themedef[$field] = $existingTheme->$field; |
| 1349 | 1349 | self::remove($themedef['dirName']); |
| 1350 | 1350 | } |
| 1351 | - if ( isset($themedef['name']) ) { |
|
| 1351 | + if (isset($themedef['name'])) { |
|
| 1352 | 1352 | self::add($themedef); |
| 1353 | 1353 | } |
| 1354 | 1354 | } |
@@ -1356,8 +1356,8 @@ discard block |
||
| 1356 | 1356 | } |
| 1357 | 1357 | } |
| 1358 | 1358 | // default to setting the default theme as the current theme |
| 1359 | - if ( !isset($GLOBALS['sugar_config']['default_theme']) || !self::set($GLOBALS['sugar_config']['default_theme']) ) { |
|
| 1360 | - if ( count(self::availableThemes()) == 0 ) |
|
| 1359 | + if (!isset($GLOBALS['sugar_config']['default_theme']) || !self::set($GLOBALS['sugar_config']['default_theme'])) { |
|
| 1360 | + if (count(self::availableThemes()) == 0) |
|
| 1361 | 1361 | { |
| 1362 | 1362 | sugar_die('No valid themes are found on this instance'); |
| 1363 | 1363 | } else { |
@@ -1379,9 +1379,9 @@ discard block |
||
| 1379 | 1379 | private static function getDefaultThemeKey() |
| 1380 | 1380 | { |
| 1381 | 1381 | $availableThemes = self::availableThemes(); |
| 1382 | - foreach($availableThemes as $key=>$theme) |
|
| 1382 | + foreach ($availableThemes as $key=>$theme) |
|
| 1383 | 1383 | { |
| 1384 | - if(strtolower($key) == 'sugar') |
|
| 1384 | + if (strtolower($key) == 'sugar') |
|
| 1385 | 1385 | { |
| 1386 | 1386 | return $key; |
| 1387 | 1387 | } |
@@ -1400,11 +1400,11 @@ discard block |
||
| 1400 | 1400 | { |
| 1401 | 1401 | $themelist = array(); |
| 1402 | 1402 | $disabledThemes = array(); |
| 1403 | - if ( isset($GLOBALS['sugar_config']['disabled_themes']) ) |
|
| 1404 | - $disabledThemes = explode(',',$GLOBALS['sugar_config']['disabled_themes']); |
|
| 1403 | + if (isset($GLOBALS['sugar_config']['disabled_themes'])) |
|
| 1404 | + $disabledThemes = explode(',', $GLOBALS['sugar_config']['disabled_themes']); |
|
| 1405 | 1405 | |
| 1406 | - foreach ( self::$_themes as $themename => $themeobject ) { |
|
| 1407 | - if ( in_array($themename,$disabledThemes) ) |
|
| 1406 | + foreach (self::$_themes as $themename => $themeobject) { |
|
| 1407 | + if (in_array($themename, $disabledThemes)) |
|
| 1408 | 1408 | continue; |
| 1409 | 1409 | $themelist[$themeobject->dirName] = $themeobject->name; |
| 1410 | 1410 | } |
@@ -1421,11 +1421,11 @@ discard block |
||
| 1421 | 1421 | { |
| 1422 | 1422 | $themelist = array(); |
| 1423 | 1423 | $disabledThemes = array(); |
| 1424 | - if ( isset($GLOBALS['sugar_config']['disabled_themes']) ) |
|
| 1425 | - $disabledThemes = explode(',',$GLOBALS['sugar_config']['disabled_themes']); |
|
| 1424 | + if (isset($GLOBALS['sugar_config']['disabled_themes'])) |
|
| 1425 | + $disabledThemes = explode(',', $GLOBALS['sugar_config']['disabled_themes']); |
|
| 1426 | 1426 | |
| 1427 | - foreach ( self::$_themes as $themename => $themeobject ) { |
|
| 1428 | - if ( in_array($themename,$disabledThemes) ) |
|
| 1427 | + foreach (self::$_themes as $themename => $themeobject) { |
|
| 1428 | + if (in_array($themename, $disabledThemes)) |
|
| 1429 | 1429 | $themelist[$themeobject->dirName] = $themeobject->name; |
| 1430 | 1430 | } |
| 1431 | 1431 | |
@@ -1441,7 +1441,7 @@ discard block |
||
| 1441 | 1441 | { |
| 1442 | 1442 | $themelist = array(); |
| 1443 | 1443 | |
| 1444 | - foreach ( self::$_themes as $themename => $themeobject ) |
|
| 1444 | + foreach (self::$_themes as $themename => $themeobject) |
|
| 1445 | 1445 | $themelist[$themeobject->dirName] = $themeobject->name; |
| 1446 | 1446 | |
| 1447 | 1447 | return $themelist; |
@@ -1478,18 +1478,18 @@ discard block |
||
| 1478 | 1478 | { |
| 1479 | 1479 | global $sugar_config; |
| 1480 | 1480 | |
| 1481 | - if ( !self::exists($themeName) ) |
|
| 1481 | + if (!self::exists($themeName)) |
|
| 1482 | 1482 | return false; |
| 1483 | 1483 | |
| 1484 | 1484 | $config = array(); |
| 1485 | 1485 | |
| 1486 | - foreach(self::$_themes[$themeName]->config_options as $name => $def){ |
|
| 1486 | + foreach (self::$_themes[$themeName]->config_options as $name => $def) { |
|
| 1487 | 1487 | $config[$name] = $def; |
| 1488 | 1488 | |
| 1489 | 1489 | $value = ''; |
| 1490 | - if(isset($sugar_config['theme_settings'][$themeName][$name])){ |
|
| 1490 | + if (isset($sugar_config['theme_settings'][$themeName][$name])) { |
|
| 1491 | 1491 | $value = $sugar_config['theme_settings'][$themeName][$name]; |
| 1492 | - } else if(isset($def['default'])){ |
|
| 1492 | + } else if (isset($def['default'])) { |
|
| 1493 | 1493 | $value = $def['default']; |
| 1494 | 1494 | } |
| 1495 | 1495 | $config[$name]['value'] = $value; |
@@ -1505,7 +1505,7 @@ discard block |
||
| 1505 | 1505 | */ |
| 1506 | 1506 | public static function clearAllCaches() |
| 1507 | 1507 | { |
| 1508 | - foreach ( self::$_themes as $themeobject ) { |
|
| 1508 | + foreach (self::$_themes as $themeobject) { |
|
| 1509 | 1509 | $themeobject->clearCache(); |
| 1510 | 1510 | } |
| 1511 | 1511 | } |
@@ -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. |
@@ -46,8 +48,9 @@ discard block |
||
| 46 | 48 | * theme basis. |
| 47 | 49 | ********************************************************************************/ |
| 48 | 50 | |
| 49 | -if(!defined('JSMIN_AS_LIB')) |
|
| 51 | +if(!defined('JSMIN_AS_LIB')) { |
|
| 50 | 52 | define('JSMIN_AS_LIB', true); |
| 53 | +} |
|
| 51 | 54 | |
| 52 | 55 | require_once("include/SugarTheme/cssmin.php"); |
| 53 | 56 | require_once("jssource/jsmin.php"); |
@@ -299,10 +302,11 @@ discard block |
||
| 299 | 302 | if ( property_exists(__CLASS__,$key) ) { |
| 300 | 303 | // For all arrays ( except colors and fonts ) you can just specify the items |
| 301 | 304 | // to change instead of all of the values |
| 302 | - if ( is_array($this->$key) && !in_array($key,array('colors','fonts')) ) |
|
| 303 | - $this->$key = array_merge($this->$key,$value); |
|
| 304 | - else |
|
| 305 | - $this->$key = $value; |
|
| 305 | + if ( is_array($this->$key) && !in_array($key,array('colors','fonts')) ) { |
|
| 306 | + $this->$key = array_merge($this->$key,$value); |
|
| 307 | + } else { |
|
| 308 | + $this->$key = $value; |
|
| 309 | + } |
|
| 306 | 310 | } |
| 307 | 311 | } |
| 308 | 312 | } |
@@ -310,23 +314,28 @@ discard block |
||
| 310 | 314 | if ( property_exists(__CLASS__,$key) ) { |
| 311 | 315 | // For all arrays ( except colors and fonts ) you can just specify the items |
| 312 | 316 | // to change instead of all of the values |
| 313 | - if ( is_array($this->$key) && !in_array($key,array('colors','fonts')) ) |
|
| 314 | - $this->$key = array_merge($this->$key,$value); |
|
| 315 | - else |
|
| 316 | - $this->$key = $value; |
|
| 317 | + if ( is_array($this->$key) && !in_array($key,array('colors','fonts')) ) { |
|
| 318 | + $this->$key = array_merge($this->$key,$value); |
|
| 319 | + } else { |
|
| 320 | + $this->$key = $value; |
|
| 321 | + } |
|
| 317 | 322 | } |
| 318 | 323 | } |
| 319 | 324 | if ( !inDeveloperMode() ) { |
| 320 | 325 | if ( sugar_is_file($cachedfile = sugar_cached($this->getFilePath().'/pathCache.php'))) { |
| 321 | 326 | $caches = unserialize(file_get_contents($cachedfile)); |
| 322 | - if ( isset($caches['jsCache']) ) |
|
| 323 | - $this->_jsCache = $caches['jsCache']; |
|
| 324 | - if ( isset($caches['cssCache']) ) |
|
| 325 | - $this->_cssCache = $caches['cssCache']; |
|
| 326 | - if ( isset($caches['imageCache']) ) |
|
| 327 | - $this->_imageCache = $caches['imageCache']; |
|
| 328 | - if ( isset($caches['templateCache']) ) |
|
| 329 | - $this->_templateCache = $caches['templateCache']; |
|
| 327 | + if ( isset($caches['jsCache']) ) { |
|
| 328 | + $this->_jsCache = $caches['jsCache']; |
|
| 329 | + } |
|
| 330 | + if ( isset($caches['cssCache']) ) { |
|
| 331 | + $this->_cssCache = $caches['cssCache']; |
|
| 332 | + } |
|
| 333 | + if ( isset($caches['imageCache']) ) { |
|
| 334 | + $this->_imageCache = $caches['imageCache']; |
|
| 335 | + } |
|
| 336 | + if ( isset($caches['templateCache']) ) { |
|
| 337 | + $this->_templateCache = $caches['templateCache']; |
|
| 338 | + } |
|
| 330 | 339 | } |
| 331 | 340 | $cachedfile = sugar_cached($this->getFilePath().'/spriteCache.php'); |
| 332 | 341 | if(!empty($GLOBALS['sugar_config']['use_sprites']) && sugar_is_file($cachedfile)) { |
@@ -378,13 +387,14 @@ discard block |
||
| 378 | 387 | // clear out the cache on destroy if we are asked to |
| 379 | 388 | if ( $this->_clearCacheOnDestroy ) { |
| 380 | 389 | |
| 381 | - if (is_file("$cachedir/pathCache.php")) |
|
| 382 | - unlink("$cachedir/pathCache.php"); |
|
| 383 | - if (is_file("$cachedir/spriteCache.php")) |
|
| 384 | - unlink("$cachedir/spriteCache.php"); |
|
| 390 | + if (is_file("$cachedir/pathCache.php")) { |
|
| 391 | + unlink("$cachedir/pathCache.php"); |
|
| 392 | + } |
|
| 393 | + if (is_file("$cachedir/spriteCache.php")) { |
|
| 394 | + unlink("$cachedir/spriteCache.php"); |
|
| 395 | + } |
|
| 385 | 396 | |
| 386 | - } |
|
| 387 | - elseif ( !inDeveloperMode() ) { |
|
| 397 | + } elseif ( !inDeveloperMode() ) { |
|
| 388 | 398 | // only update the caches if they have been changed in this request |
| 389 | 399 | if ( count($this->_jsCache) != $this->_initialCacheSize['jsCache'] |
| 390 | 400 | || count($this->_cssCache) != $this->_initialCacheSize['cssCache'] |
@@ -433,8 +443,9 @@ discard block |
||
| 433 | 443 | $key |
| 434 | 444 | ) |
| 435 | 445 | { |
| 436 | - if ( isset($this->$key) ) |
|
| 437 | - return $this->$key; |
|
| 446 | + if ( isset($this->$key) ) { |
|
| 447 | + return $this->$key; |
|
| 448 | + } |
|
| 438 | 449 | } |
| 439 | 450 | |
| 440 | 451 | public function __isset($key){ |
@@ -607,38 +618,44 @@ discard block |
||
| 607 | 618 | if(!empty($GLOBALS['sugar_config']['use_sprites']) && $GLOBALS['sugar_config']['use_sprites']) { |
| 608 | 619 | |
| 609 | 620 | // system wide sprites |
| 610 | - if(file_exists("cache/sprites/default/sprites.css")) |
|
| 611 | - $html .= '<link rel="stylesheet" type="text/css" href="'.getJSPath('cache/sprites/default/sprites.css').'" />'; |
|
| 621 | + if(file_exists("cache/sprites/default/sprites.css")) { |
|
| 622 | + $html .= '<link rel="stylesheet" type="text/css" href="'.getJSPath('cache/sprites/default/sprites.css').'" />'; |
|
| 623 | + } |
|
| 612 | 624 | |
| 613 | 625 | // theme specific sprites |
| 614 | - if(file_exists("cache/sprites/{$this->dirName}/sprites.css")) |
|
| 615 | - $html .= '<link rel="stylesheet" type="text/css" href="'.getJSPath('cache/sprites/'.$this->dirName.'/sprites.css').'" />'; |
|
| 626 | + if(file_exists("cache/sprites/{$this->dirName}/sprites.css")) { |
|
| 627 | + $html .= '<link rel="stylesheet" type="text/css" href="'.getJSPath('cache/sprites/'.$this->dirName.'/sprites.css').'" />'; |
|
| 628 | + } |
|
| 616 | 629 | |
| 617 | 630 | // parent sprites |
| 618 | 631 | if($this->parentTheme && $parent = SugarThemeRegistry::get($this->parentTheme)) { |
| 619 | - if(file_exists("cache/sprites/{$parent->dirName}/sprites.css")) |
|
| 620 | - $html .= '<link rel="stylesheet" type="text/css" href="'.getJSPath('cache/sprites/'.$parent->dirName.'/sprites.css').'" />'; |
|
| 632 | + if(file_exists("cache/sprites/{$parent->dirName}/sprites.css")) { |
|
| 633 | + $html .= '<link rel="stylesheet" type="text/css" href="'.getJSPath('cache/sprites/'.$parent->dirName.'/sprites.css').'" />'; |
|
| 634 | + } |
|
| 621 | 635 | } |
| 622 | 636 | |
| 623 | 637 | // repeatable sprites |
| 624 | - if(file_exists("cache/sprites/Repeatable/sprites.css")) |
|
| 625 | - $html .= '<link rel="stylesheet" type="text/css" href="'.getJSPath('cache/sprites/Repeatable/sprites.css').'" />'; |
|
| 638 | + if(file_exists("cache/sprites/Repeatable/sprites.css")) { |
|
| 639 | + $html .= '<link rel="stylesheet" type="text/css" href="'.getJSPath('cache/sprites/Repeatable/sprites.css').'" />'; |
|
| 640 | + } |
|
| 626 | 641 | } |
| 627 | 642 | |
| 628 | 643 | // for BC during upgrade |
| 629 | 644 | if ( !empty($this->colors) ) { |
| 630 | - if ( isset($_SESSION['authenticated_user_theme_color']) && in_array($_SESSION['authenticated_user_theme_color'], $this->colors)) |
|
| 631 | - $color = $_SESSION['authenticated_user_theme_color']; |
|
| 632 | - else |
|
| 633 | - $color = $this->colors[0]; |
|
| 645 | + if ( isset($_SESSION['authenticated_user_theme_color']) && in_array($_SESSION['authenticated_user_theme_color'], $this->colors)) { |
|
| 646 | + $color = $_SESSION['authenticated_user_theme_color']; |
|
| 647 | + } else { |
|
| 648 | + $color = $this->colors[0]; |
|
| 649 | + } |
|
| 634 | 650 | $html .= '<link rel="stylesheet" type="text/css" href="'.$this->getCSSURL('colors.'.$color.'.css').'" id="current_color_style" />'; |
| 635 | 651 | } |
| 636 | 652 | |
| 637 | 653 | if ( !empty($this->fonts) ) { |
| 638 | - if ( isset($_SESSION['authenticated_user_theme_font']) && in_array($_SESSION['authenticated_user_theme_font'], $this->fonts)) |
|
| 639 | - $font = $_SESSION['authenticated_user_theme_font']; |
|
| 640 | - else |
|
| 641 | - $font = $this->fonts[0]; |
|
| 654 | + if ( isset($_SESSION['authenticated_user_theme_font']) && in_array($_SESSION['authenticated_user_theme_font'], $this->fonts)) { |
|
| 655 | + $font = $_SESSION['authenticated_user_theme_font']; |
|
| 656 | + } else { |
|
| 657 | + $font = $this->fonts[0]; |
|
| 658 | + } |
|
| 642 | 659 | $html .= '<link rel="stylesheet" type="text/css" href="'.$this->getCSSURL('fonts.'.$font.'.css').'" id="current_font_style" />'; |
| 643 | 660 | } |
| 644 | 661 | |
@@ -669,23 +686,24 @@ discard block |
||
| 669 | 686 | $templateName |
| 670 | 687 | ) |
| 671 | 688 | { |
| 672 | - if ( isset($this->_templateCache[$templateName]) ) |
|
| 673 | - return $this->_templateCache[$templateName]; |
|
| 689 | + if ( isset($this->_templateCache[$templateName]) ) { |
|
| 690 | + return $this->_templateCache[$templateName]; |
|
| 691 | + } |
|
| 674 | 692 | |
| 675 | 693 | $templatePath = ''; |
| 676 | - if (sugar_is_file('custom/'.$this->getTemplatePath().'/'.$templateName)) |
|
| 677 | - $templatePath = 'custom/'.$this->getTemplatePath().'/'.$templateName; |
|
| 678 | - elseif (sugar_is_file($this->getTemplatePath().'/'.$templateName)) |
|
| 679 | - $templatePath = $this->getTemplatePath().'/'.$templateName; |
|
| 680 | - elseif (isset($this->parentTheme) |
|
| 694 | + if (sugar_is_file('custom/'.$this->getTemplatePath().'/'.$templateName)) { |
|
| 695 | + $templatePath = 'custom/'.$this->getTemplatePath().'/'.$templateName; |
|
| 696 | + } elseif (sugar_is_file($this->getTemplatePath().'/'.$templateName)) { |
|
| 697 | + $templatePath = $this->getTemplatePath().'/'.$templateName; |
|
| 698 | + } elseif (isset($this->parentTheme) |
|
| 681 | 699 | && SugarThemeRegistry::get($this->parentTheme) instanceOf SugarTheme |
| 682 | - && ($filename = SugarThemeRegistry::get($this->parentTheme)->getTemplate($templateName)) != '') |
|
| 683 | - $templatePath = $filename; |
|
| 684 | - elseif (sugar_is_file('custom/'.$this->getDefaultTemplatePath().'/'.$templateName)) |
|
| 685 | - $templatePath = 'custom/'.$this->getDefaultTemplatePath().'/'.$templateName; |
|
| 686 | - elseif (sugar_is_file($this->getDefaultTemplatePath().'/'.$templateName)) |
|
| 687 | - $templatePath = $this->getDefaultTemplatePath().'/'.$templateName; |
|
| 688 | - else { |
|
| 700 | + && ($filename = SugarThemeRegistry::get($this->parentTheme)->getTemplate($templateName)) != '') { |
|
| 701 | + $templatePath = $filename; |
|
| 702 | + } elseif (sugar_is_file('custom/'.$this->getDefaultTemplatePath().'/'.$templateName)) { |
|
| 703 | + $templatePath = 'custom/'.$this->getDefaultTemplatePath().'/'.$templateName; |
|
| 704 | + } elseif (sugar_is_file($this->getDefaultTemplatePath().'/'.$templateName)) { |
|
| 705 | + $templatePath = $this->getDefaultTemplatePath().'/'.$templateName; |
|
| 706 | + } else { |
|
| 689 | 707 | $GLOBALS['log']->warn("Template $templateName not found"); |
| 690 | 708 | return false; |
| 691 | 709 | } |
@@ -721,15 +739,17 @@ discard block |
||
| 721 | 739 | // trap deprecated use of image extension |
| 722 | 740 | if(is_null($ext)) { |
| 723 | 741 | $imageNameExp = explode('.',$imageName); |
| 724 | - if(count($imageNameExp) == 1) |
|
| 725 | - $imageName .= '.gif'; |
|
| 742 | + if(count($imageNameExp) == 1) { |
|
| 743 | + $imageName .= '.gif'; |
|
| 744 | + } |
|
| 726 | 745 | } else { |
| 727 | 746 | $imageName .= $ext; |
| 728 | 747 | } |
| 729 | 748 | |
| 730 | 749 | // trap alt attributes in other_attributes |
| 731 | - if(preg_match('/alt=["\']([^\'"]+)["\']/i', $other_attributes)) |
|
| 732 | - $GLOBALS['log']->debug("Sprites: alt attribute detected for $imageName"); |
|
| 750 | + if(preg_match('/alt=["\']([^\'"]+)["\']/i', $other_attributes)) { |
|
| 751 | + $GLOBALS['log']->debug("Sprites: alt attribute detected for $imageName"); |
|
| 752 | + } |
|
| 733 | 753 | // sprite handler, makes use of own caching mechanism |
| 734 | 754 | if(!empty($GLOBALS['sugar_config']['use_sprites']) && $GLOBALS['sugar_config']['use_sprites']) { |
| 735 | 755 | // get sprite metadata |
@@ -751,8 +771,9 @@ discard block |
||
| 751 | 771 | // img caching |
| 752 | 772 | if(empty($cached_results[$imageName])) { |
| 753 | 773 | $imageURL = $this->getImageURL($imageName,false); |
| 754 | - if ( empty($imageURL) ) |
|
| 755 | - return false; |
|
| 774 | + if ( empty($imageURL) ) { |
|
| 775 | + return false; |
|
| 776 | + } |
|
| 756 | 777 | if(strpos($imageURL, '.svg', strlen($imageURL)-4)){ |
| 757 | 778 | $cached_results[$imageName] = file_get_contents($imageURL); |
| 758 | 779 | } else { |
@@ -779,8 +800,9 @@ discard block |
||
| 779 | 800 | public function getSpriteMeta($imageName) { |
| 780 | 801 | |
| 781 | 802 | // return from cache |
| 782 | - if(isset($this->_spriteCache[$imageName])) |
|
| 783 | - return $this->_spriteCache[$imageName]; |
|
| 803 | + if(isset($this->_spriteCache[$imageName])) { |
|
| 804 | + return $this->_spriteCache[$imageName]; |
|
| 805 | + } |
|
| 784 | 806 | |
| 785 | 807 | // sprite keys are base on imageURL |
| 786 | 808 | $imageURL = $this->getImageURL($imageName,false); |
@@ -832,8 +854,9 @@ discard block |
||
| 832 | 854 | $attr .= ' class="spr_'.$class.'"'; |
| 833 | 855 | } |
| 834 | 856 | |
| 835 | - if($title) |
|
| 836 | - $attr .= ' title="'.$title.'"'; |
|
| 857 | + if($title) { |
|
| 858 | + $attr .= ' title="'.$title.'"'; |
|
| 859 | + } |
|
| 837 | 860 | |
| 838 | 861 | // use </span> instead of /> to prevent weird UI results |
| 839 | 862 | $GLOBALS['log']->debug("Sprites: generated sprite -> $attr"); |
@@ -887,35 +910,37 @@ discard block |
||
| 887 | 910 | $addJSPath = true |
| 888 | 911 | ){ |
| 889 | 912 | if ( isset($this->_imageCache[$imageName]) ) { |
| 890 | - if ( $addJSPath ) |
|
| 891 | - return getJSPath($this->_imageCache[$imageName]); |
|
| 892 | - else |
|
| 893 | - return $this->_imageCache[$imageName]; |
|
| 913 | + if ( $addJSPath ) { |
|
| 914 | + return getJSPath($this->_imageCache[$imageName]); |
|
| 915 | + } else { |
|
| 916 | + return $this->_imageCache[$imageName]; |
|
| 917 | + } |
|
| 894 | 918 | } |
| 895 | 919 | $imagePath = ''; |
| 896 | - if (($filename = $this->_getImageFileName('custom/'.$this->getImagePath().'/'.$imageName)) != '') |
|
| 897 | - $imagePath = $filename; |
|
| 898 | - elseif (($filename = $this->_getImageFileName($this->getImagePath().'/'.$imageName)) != '') |
|
| 899 | - $imagePath = $filename; |
|
| 900 | - elseif (isset($this->parentTheme) |
|
| 920 | + if (($filename = $this->_getImageFileName('custom/'.$this->getImagePath().'/'.$imageName)) != '') { |
|
| 921 | + $imagePath = $filename; |
|
| 922 | + } elseif (($filename = $this->_getImageFileName($this->getImagePath().'/'.$imageName)) != '') { |
|
| 923 | + $imagePath = $filename; |
|
| 924 | + } elseif (isset($this->parentTheme) |
|
| 901 | 925 | && SugarThemeRegistry::get($this->parentTheme) instanceOf SugarTheme |
| 902 | - && ($filename = SugarThemeRegistry::get($this->parentTheme)->getImageURL($imageName,false)) != '') |
|
| 903 | - $imagePath = $filename; |
|
| 904 | - elseif (($filename = $this->_getImageFileName('custom/'.$this->getDefaultImagePath().'/'.$imageName)) != '') |
|
| 905 | - $imagePath = $filename; |
|
| 906 | - elseif (($filename = $this->_getImageFileName($this->getDefaultImagePath().'/'.$imageName)) != '') |
|
| 907 | - $imagePath = $filename; |
|
| 908 | - elseif (($filename = $this->_getImageFileName('include/images/'.$imageName)) != '') |
|
| 909 | - $imagePath = $filename; |
|
| 910 | - else { |
|
| 926 | + && ($filename = SugarThemeRegistry::get($this->parentTheme)->getImageURL($imageName,false)) != '') { |
|
| 927 | + $imagePath = $filename; |
|
| 928 | + } elseif (($filename = $this->_getImageFileName('custom/'.$this->getDefaultImagePath().'/'.$imageName)) != '') { |
|
| 929 | + $imagePath = $filename; |
|
| 930 | + } elseif (($filename = $this->_getImageFileName($this->getDefaultImagePath().'/'.$imageName)) != '') { |
|
| 931 | + $imagePath = $filename; |
|
| 932 | + } elseif (($filename = $this->_getImageFileName('include/images/'.$imageName)) != '') { |
|
| 933 | + $imagePath = $filename; |
|
| 934 | + } else { |
|
| 911 | 935 | $GLOBALS['log']->warn("Image $imageName not found"); |
| 912 | 936 | return false; |
| 913 | 937 | } |
| 914 | 938 | |
| 915 | 939 | $this->_imageCache[$imageName] = $imagePath; |
| 916 | 940 | |
| 917 | - if ( $addJSPath ) |
|
| 918 | - return getJSPath($imagePath); |
|
| 941 | + if ( $addJSPath ) { |
|
| 942 | + return getJSPath($imagePath); |
|
| 943 | + } |
|
| 919 | 944 | |
| 920 | 945 | return $imagePath; |
| 921 | 946 | } |
@@ -931,14 +956,16 @@ discard block |
||
| 931 | 956 | ) |
| 932 | 957 | { |
| 933 | 958 | // return now if the extension matches that of which we are looking for |
| 934 | - if ( sugar_is_file($imageName) ) |
|
| 935 | - return $imageName; |
|
| 959 | + if ( sugar_is_file($imageName) ) { |
|
| 960 | + return $imageName; |
|
| 961 | + } |
|
| 936 | 962 | $pathParts = pathinfo($imageName); |
| 937 | - foreach ( $this->imageExtensions as $extension ) |
|
| 938 | - if ( isset($pathParts['extension']) ) |
|
| 963 | + foreach ( $this->imageExtensions as $extension ) { |
|
| 964 | + if ( isset($pathParts['extension']) ) |
|
| 939 | 965 | if ( ( $extension != $pathParts['extension'] ) |
| 940 | 966 | && sugar_is_file($pathParts['dirname'].'/'.$pathParts['filename'].'.'.$extension) ) |
| 941 | 967 | return $pathParts['dirname'].'/'.$pathParts['filename'].'.'.$extension; |
| 968 | + } |
|
| 942 | 969 | |
| 943 | 970 | return ''; |
| 944 | 971 | } |
@@ -954,10 +981,11 @@ discard block |
||
| 954 | 981 | public function getCSSURL($cssFileName, $returnURL = true) |
| 955 | 982 | { |
| 956 | 983 | if ( isset($this->_cssCache[$cssFileName]) && sugar_is_file(sugar_cached($this->_cssCache[$cssFileName])) ) { |
| 957 | - if ( $returnURL ) |
|
| 958 | - return getJSPath("cache/".$this->_cssCache[$cssFileName]); |
|
| 959 | - else |
|
| 960 | - return sugar_cached($this->_cssCache[$cssFileName]); |
|
| 984 | + if ( $returnURL ) { |
|
| 985 | + return getJSPath("cache/".$this->_cssCache[$cssFileName]); |
|
| 986 | + } else { |
|
| 987 | + return sugar_cached($this->_cssCache[$cssFileName]); |
|
| 988 | + } |
|
| 961 | 989 | } |
| 962 | 990 | |
| 963 | 991 | $cssFileContents = ''; |
@@ -965,13 +993,15 @@ discard block |
||
| 965 | 993 | $fullFileName = $this->getCSSPath().'/'.$cssFileName; |
| 966 | 994 | if (isset($this->parentTheme) |
| 967 | 995 | && SugarThemeRegistry::get($this->parentTheme) instanceOf SugarTheme |
| 968 | - && ($filename = SugarThemeRegistry::get($this->parentTheme)->getCSSURL($cssFileName,false)) != '') |
|
| 969 | - $cssFileContents .= file_get_contents($filename); |
|
| 970 | - else { |
|
| 971 | - if (sugar_is_file($defaultFileName)) |
|
| 972 | - $cssFileContents .= file_get_contents($defaultFileName); |
|
| 973 | - if (sugar_is_file('custom/'.$defaultFileName)) |
|
| 974 | - $cssFileContents .= file_get_contents('custom/'.$defaultFileName); |
|
| 996 | + && ($filename = SugarThemeRegistry::get($this->parentTheme)->getCSSURL($cssFileName,false)) != '') { |
|
| 997 | + $cssFileContents .= file_get_contents($filename); |
|
| 998 | + } else { |
|
| 999 | + if (sugar_is_file($defaultFileName)) { |
|
| 1000 | + $cssFileContents .= file_get_contents($defaultFileName); |
|
| 1001 | + } |
|
| 1002 | + if (sugar_is_file('custom/'.$defaultFileName)) { |
|
| 1003 | + $cssFileContents .= file_get_contents('custom/'.$defaultFileName); |
|
| 1004 | + } |
|
| 975 | 1005 | } |
| 976 | 1006 | if (sugar_is_file($fullFileName)) { |
| 977 | 1007 | $cssFileContents .= file_get_contents($fullFileName); |
@@ -995,10 +1025,11 @@ discard block |
||
| 995 | 1025 | // if this is the style.css file, prepend the base.css and calendar-win2k-cold-1.css |
| 996 | 1026 | // files before the theme styles |
| 997 | 1027 | if ( $cssFileName == 'style.css' && !isset($this->parentTheme) ) { |
| 998 | - if ( inDeveloperMode() ) |
|
| 999 | - $cssFileContents = file_get_contents('include/javascript/yui/build/base/base.css') . $cssFileContents; |
|
| 1000 | - else |
|
| 1001 | - $cssFileContents = file_get_contents('include/javascript/yui/build/base/base-min.css') . $cssFileContents; |
|
| 1028 | + if ( inDeveloperMode() ) { |
|
| 1029 | + $cssFileContents = file_get_contents('include/javascript/yui/build/base/base.css') . $cssFileContents; |
|
| 1030 | + } else { |
|
| 1031 | + $cssFileContents = file_get_contents('include/javascript/yui/build/base/base-min.css') . $cssFileContents; |
|
| 1032 | + } |
|
| 1002 | 1033 | } |
| 1003 | 1034 | |
| 1004 | 1035 | // minify the css |
@@ -1011,8 +1042,9 @@ discard block |
||
| 1011 | 1042 | |
| 1012 | 1043 | $this->_cssCache[$cssFileName] = $fullFileName; |
| 1013 | 1044 | |
| 1014 | - if ( $returnURL ) |
|
| 1015 | - return getJSPath("cache/".$fullFileName); |
|
| 1045 | + if ( $returnURL ) { |
|
| 1046 | + return getJSPath("cache/".$fullFileName); |
|
| 1047 | + } |
|
| 1016 | 1048 | |
| 1017 | 1049 | return sugar_cached($fullFileName); |
| 1018 | 1050 | } |
@@ -1028,10 +1060,11 @@ discard block |
||
| 1028 | 1060 | public function getJSURL($jsFileName, $returnURL = true) |
| 1029 | 1061 | { |
| 1030 | 1062 | if ( isset($this->_jsCache[$jsFileName]) && sugar_is_file(sugar_cached($this->_jsCache[$jsFileName])) ) { |
| 1031 | - if ( $returnURL ) |
|
| 1032 | - return getJSPath("cache/".$this->_jsCache[$jsFileName]); |
|
| 1033 | - else |
|
| 1034 | - return sugar_cached($this->_jsCache[$jsFileName]); |
|
| 1063 | + if ( $returnURL ) { |
|
| 1064 | + return getJSPath("cache/".$this->_jsCache[$jsFileName]); |
|
| 1065 | + } else { |
|
| 1066 | + return sugar_cached($this->_jsCache[$jsFileName]); |
|
| 1067 | + } |
|
| 1035 | 1068 | } |
| 1036 | 1069 | |
| 1037 | 1070 | $jsFileContents = ''; |
@@ -1042,15 +1075,19 @@ discard block |
||
| 1042 | 1075 | && ($filename = SugarThemeRegistry::get($this->parentTheme)->getJSURL($jsFileName,false)) != '' && !in_array($jsFileName,$this->ignoreParentFiles)) { |
| 1043 | 1076 | $jsFileContents .= file_get_contents($filename); |
| 1044 | 1077 | } else { |
| 1045 | - if (sugar_is_file($defaultFileName)) |
|
| 1046 | - $jsFileContents .= file_get_contents($defaultFileName); |
|
| 1047 | - if (sugar_is_file('custom/'.$defaultFileName)) |
|
| 1048 | - $jsFileContents .= file_get_contents('custom/'.$defaultFileName); |
|
| 1078 | + if (sugar_is_file($defaultFileName)) { |
|
| 1079 | + $jsFileContents .= file_get_contents($defaultFileName); |
|
| 1080 | + } |
|
| 1081 | + if (sugar_is_file('custom/'.$defaultFileName)) { |
|
| 1082 | + $jsFileContents .= file_get_contents('custom/'.$defaultFileName); |
|
| 1083 | + } |
|
| 1084 | + } |
|
| 1085 | + if (sugar_is_file($fullFileName)) { |
|
| 1086 | + $jsFileContents .= file_get_contents($fullFileName); |
|
| 1087 | + } |
|
| 1088 | + if (sugar_is_file('custom/'.$fullFileName)) { |
|
| 1089 | + $jsFileContents .= file_get_contents('custom/'.$fullFileName); |
|
| 1049 | 1090 | } |
| 1050 | - if (sugar_is_file($fullFileName)) |
|
| 1051 | - $jsFileContents .= file_get_contents($fullFileName); |
|
| 1052 | - if (sugar_is_file('custom/'.$fullFileName)) |
|
| 1053 | - $jsFileContents .= file_get_contents('custom/'.$fullFileName); |
|
| 1054 | 1091 | if (empty($jsFileContents)) { |
| 1055 | 1092 | $GLOBALS['log']->warn("Javascript File $jsFileName not found"); |
| 1056 | 1093 | return false; |
@@ -1071,8 +1108,9 @@ discard block |
||
| 1071 | 1108 | |
| 1072 | 1109 | $this->_jsCache[$jsFileName] = $fullFileName; |
| 1073 | 1110 | |
| 1074 | - if ( $returnURL ) |
|
| 1075 | - return getJSPath("cache/".$fullFileName); |
|
| 1111 | + if ( $returnURL ) { |
|
| 1112 | + return getJSPath("cache/".$fullFileName); |
|
| 1113 | + } |
|
| 1076 | 1114 | |
| 1077 | 1115 | return sugar_cached($fullFileName); |
| 1078 | 1116 | } |
@@ -1097,7 +1135,9 @@ discard block |
||
| 1097 | 1135 | $imageArray = array(); |
| 1098 | 1136 | foreach ( $pathsToSearch as $path ) |
| 1099 | 1137 | { |
| 1100 | - if (!sugar_is_dir($path)) $path = "custom/$path"; |
|
| 1138 | + if (!sugar_is_dir($path)) { |
|
| 1139 | + $path = "custom/$path"; |
|
| 1140 | + } |
|
| 1101 | 1141 | if (sugar_is_dir($path) && is_readable($path) && $dir = opendir($path)) { |
| 1102 | 1142 | while (($file = readdir($dir)) !== false) { |
| 1103 | 1143 | if ($file == ".." |
@@ -1105,10 +1145,12 @@ discard block |
||
| 1105 | 1145 | || $file == ".svn" |
| 1106 | 1146 | || $file == "CVS" |
| 1107 | 1147 | || $file == "Attic" |
| 1108 | - ) |
|
| 1109 | - continue; |
|
| 1110 | - if ( !isset($imageArray[$file]) ) |
|
| 1111 | - $imageArray[$file] = $this->getImageURL($file,false); |
|
| 1148 | + ) { |
|
| 1149 | + continue; |
|
| 1150 | + } |
|
| 1151 | + if ( !isset($imageArray[$file]) ) { |
|
| 1152 | + $imageArray[$file] = $this->getImageURL($file,false); |
|
| 1153 | + } |
|
| 1112 | 1154 | } |
| 1113 | 1155 | closedir($dir); |
| 1114 | 1156 | } |
@@ -1189,8 +1231,9 @@ discard block |
||
| 1189 | 1231 | } |
| 1190 | 1232 | |
| 1191 | 1233 | // Assume theme is designed for 5.5.x if not specified otherwise |
| 1192 | - if ( !isset($themedef['version']) ) |
|
| 1193 | - $themedef['version']['regex_matches'] = array('5\.5\.*'); |
|
| 1234 | + if ( !isset($themedef['version']) ) { |
|
| 1235 | + $themedef['version']['regex_matches'] = array('5\.5\.*'); |
|
| 1236 | + } |
|
| 1194 | 1237 | |
| 1195 | 1238 | // Check to see if theme is valid for this version of Sugar; return false if not |
| 1196 | 1239 | $version_ok = false; |
@@ -1210,8 +1253,9 @@ discard block |
||
| 1210 | 1253 | } |
| 1211 | 1254 | } |
| 1212 | 1255 | } |
| 1213 | - if ( !$version_ok ) |
|
| 1214 | - return false; |
|
| 1256 | + if ( !$version_ok ) { |
|
| 1257 | + return false; |
|
| 1258 | + } |
|
| 1215 | 1259 | |
| 1216 | 1260 | $theme = new SugarTheme($themedef); |
| 1217 | 1261 | self::$_themes[$theme->dirName] = $theme; |
@@ -1226,8 +1270,9 @@ discard block |
||
| 1226 | 1270 | $themeName |
| 1227 | 1271 | ) |
| 1228 | 1272 | { |
| 1229 | - if ( self::exists($themeName) ) |
|
| 1230 | - unset(self::$_themes[$themeName]); |
|
| 1273 | + if ( self::exists($themeName) ) { |
|
| 1274 | + unset(self::$_themes[$themeName]); |
|
| 1275 | + } |
|
| 1231 | 1276 | } |
| 1232 | 1277 | |
| 1233 | 1278 | /** |
@@ -1239,8 +1284,9 @@ discard block |
||
| 1239 | 1284 | $themeName |
| 1240 | 1285 | ) |
| 1241 | 1286 | { |
| 1242 | - if ( isset(self::$_themes[$themeName]) ) |
|
| 1243 | - return self::$_themes[$themeName]; |
|
| 1287 | + if ( isset(self::$_themes[$themeName]) ) { |
|
| 1288 | + return self::$_themes[$themeName]; |
|
| 1289 | + } |
|
| 1244 | 1290 | } |
| 1245 | 1291 | |
| 1246 | 1292 | /** |
@@ -1250,8 +1296,9 @@ discard block |
||
| 1250 | 1296 | */ |
| 1251 | 1297 | public static function current() |
| 1252 | 1298 | { |
| 1253 | - if ( !isset(self::$_currentTheme) ) |
|
| 1254 | - self::buildRegistry(); |
|
| 1299 | + if ( !isset(self::$_currentTheme) ) { |
|
| 1300 | + self::buildRegistry(); |
|
| 1301 | + } |
|
| 1255 | 1302 | |
| 1256 | 1303 | return self::$_themes[self::$_currentTheme]; |
| 1257 | 1304 | } |
@@ -1263,8 +1310,9 @@ discard block |
||
| 1263 | 1310 | */ |
| 1264 | 1311 | public static function getDefault() |
| 1265 | 1312 | { |
| 1266 | - if ( !isset(self::$_currentTheme) ) |
|
| 1267 | - self::buildRegistry(); |
|
| 1313 | + if ( !isset(self::$_currentTheme) ) { |
|
| 1314 | + self::buildRegistry(); |
|
| 1315 | + } |
|
| 1268 | 1316 | |
| 1269 | 1317 | if ( isset($GLOBALS['sugar_config']['default_theme']) && self::exists($GLOBALS['sugar_config']['default_theme']) ) { |
| 1270 | 1318 | return self::get($GLOBALS['sugar_config']['default_theme']); |
@@ -1295,8 +1343,9 @@ discard block |
||
| 1295 | 1343 | $themeName |
| 1296 | 1344 | ) |
| 1297 | 1345 | { |
| 1298 | - if ( !self::exists($themeName) ) |
|
| 1299 | - return false; |
|
| 1346 | + if ( !self::exists($themeName) ) { |
|
| 1347 | + return false; |
|
| 1348 | + } |
|
| 1300 | 1349 | |
| 1301 | 1350 | self::$_currentTheme = $themeName; |
| 1302 | 1351 | |
@@ -1333,8 +1382,9 @@ discard block |
||
| 1333 | 1382 | || $file == "default" |
| 1334 | 1383 | || !sugar_is_dir("./$dirPath".$file) |
| 1335 | 1384 | || !sugar_is_file("./{$dirPath}{$file}/themedef.php") |
| 1336 | - ) |
|
| 1337 | - continue; |
|
| 1385 | + ) { |
|
| 1386 | + continue; |
|
| 1387 | + } |
|
| 1338 | 1388 | $themedef = array(); |
| 1339 | 1389 | require("./{$dirPath}{$file}/themedef.php"); |
| 1340 | 1390 | $themedef = array_merge($themedef,$themedefDefault); |
@@ -1343,9 +1393,10 @@ discard block |
||
| 1343 | 1393 | // if so, then it will override the current one |
| 1344 | 1394 | if ( self::exists($themedef['dirName']) ) { |
| 1345 | 1395 | $existingTheme = self::get($themedef['dirName']); |
| 1346 | - foreach ( SugarTheme::getThemeDefFields() as $field ) |
|
| 1347 | - if ( !isset($themedef[$field]) ) |
|
| 1396 | + foreach ( SugarTheme::getThemeDefFields() as $field ) { |
|
| 1397 | + if ( !isset($themedef[$field]) ) |
|
| 1348 | 1398 | $themedef[$field] = $existingTheme->$field; |
| 1399 | + } |
|
| 1349 | 1400 | self::remove($themedef['dirName']); |
| 1350 | 1401 | } |
| 1351 | 1402 | if ( isset($themedef['name']) ) { |
@@ -1400,12 +1451,14 @@ discard block |
||
| 1400 | 1451 | { |
| 1401 | 1452 | $themelist = array(); |
| 1402 | 1453 | $disabledThemes = array(); |
| 1403 | - if ( isset($GLOBALS['sugar_config']['disabled_themes']) ) |
|
| 1404 | - $disabledThemes = explode(',',$GLOBALS['sugar_config']['disabled_themes']); |
|
| 1454 | + if ( isset($GLOBALS['sugar_config']['disabled_themes']) ) { |
|
| 1455 | + $disabledThemes = explode(',',$GLOBALS['sugar_config']['disabled_themes']); |
|
| 1456 | + } |
|
| 1405 | 1457 | |
| 1406 | 1458 | foreach ( self::$_themes as $themename => $themeobject ) { |
| 1407 | - if ( in_array($themename,$disabledThemes) ) |
|
| 1408 | - continue; |
|
| 1459 | + if ( in_array($themename,$disabledThemes) ) { |
|
| 1460 | + continue; |
|
| 1461 | + } |
|
| 1409 | 1462 | $themelist[$themeobject->dirName] = $themeobject->name; |
| 1410 | 1463 | } |
| 1411 | 1464 | asort($themelist, SORT_STRING); |
@@ -1421,12 +1474,14 @@ discard block |
||
| 1421 | 1474 | { |
| 1422 | 1475 | $themelist = array(); |
| 1423 | 1476 | $disabledThemes = array(); |
| 1424 | - if ( isset($GLOBALS['sugar_config']['disabled_themes']) ) |
|
| 1425 | - $disabledThemes = explode(',',$GLOBALS['sugar_config']['disabled_themes']); |
|
| 1477 | + if ( isset($GLOBALS['sugar_config']['disabled_themes']) ) { |
|
| 1478 | + $disabledThemes = explode(',',$GLOBALS['sugar_config']['disabled_themes']); |
|
| 1479 | + } |
|
| 1426 | 1480 | |
| 1427 | 1481 | foreach ( self::$_themes as $themename => $themeobject ) { |
| 1428 | - if ( in_array($themename,$disabledThemes) ) |
|
| 1429 | - $themelist[$themeobject->dirName] = $themeobject->name; |
|
| 1482 | + if ( in_array($themename,$disabledThemes) ) { |
|
| 1483 | + $themelist[$themeobject->dirName] = $themeobject->name; |
|
| 1484 | + } |
|
| 1430 | 1485 | } |
| 1431 | 1486 | |
| 1432 | 1487 | return $themelist; |
@@ -1441,8 +1496,9 @@ discard block |
||
| 1441 | 1496 | { |
| 1442 | 1497 | $themelist = array(); |
| 1443 | 1498 | |
| 1444 | - foreach ( self::$_themes as $themename => $themeobject ) |
|
| 1445 | - $themelist[$themeobject->dirName] = $themeobject->name; |
|
| 1499 | + foreach ( self::$_themes as $themename => $themeobject ) { |
|
| 1500 | + $themelist[$themeobject->dirName] = $themeobject->name; |
|
| 1501 | + } |
|
| 1446 | 1502 | |
| 1447 | 1503 | return $themelist; |
| 1448 | 1504 | } |
@@ -1456,8 +1512,9 @@ discard block |
||
| 1456 | 1512 | { |
| 1457 | 1513 | $themelist = array(); |
| 1458 | 1514 | $disabledThemes = array(); |
| 1459 | - if (isset($GLOBALS['sugar_config']['disabled_themes'])) |
|
| 1460 | - $disabledThemes = explode(',', $GLOBALS['sugar_config']['disabled_themes']); |
|
| 1515 | + if (isset($GLOBALS['sugar_config']['disabled_themes'])) { |
|
| 1516 | + $disabledThemes = explode(',', $GLOBALS['sugar_config']['disabled_themes']); |
|
| 1517 | + } |
|
| 1461 | 1518 | |
| 1462 | 1519 | foreach (self::$_themes as $themename => $themeobject) { |
| 1463 | 1520 | $themearray['name'] = $themeobject->name; |
@@ -1478,8 +1535,9 @@ discard block |
||
| 1478 | 1535 | { |
| 1479 | 1536 | global $sugar_config; |
| 1480 | 1537 | |
| 1481 | - if ( !self::exists($themeName) ) |
|
| 1482 | - return false; |
|
| 1538 | + if ( !self::exists($themeName) ) { |
|
| 1539 | + return false; |
|
| 1540 | + } |
|
| 1483 | 1541 | |
| 1484 | 1542 | $config = array(); |
| 1485 | 1543 | |
@@ -458,7 +458,7 @@ discard block |
||
| 458 | 458 | /** |
| 459 | 459 | * Return array of all valid fields that can be specified in the themedef.php file |
| 460 | 460 | * |
| 461 | - * @return array |
|
| 461 | + * @return string[] |
|
| 462 | 462 | */ |
| 463 | 463 | public static function getThemeDefFields() |
| 464 | 464 | { |
@@ -698,7 +698,7 @@ discard block |
||
| 698 | 698 | /** |
| 699 | 699 | * Returns an image tag for the given image. |
| 700 | 700 | * |
| 701 | - * @param string $image image name |
|
| 701 | + * @param string $imageName image name |
|
| 702 | 702 | * @param string $other_attributes optional, other attributes to add to the image tag, not cached |
| 703 | 703 | * @param string $width optional, defaults to the actual image's width |
| 704 | 704 | * @param string $height optional, defaults to the actual image's height |
@@ -817,6 +817,8 @@ discard block |
||
| 817 | 817 | * @param string class The md5 id used in the CSS sprites class |
| 818 | 818 | * @param string attr optional, list of additional html attributes |
| 819 | 819 | * @param string title optional, the title (equivalent to alt on img) |
| 820 | + * @param string $attr |
|
| 821 | + * @param string $title |
|
| 820 | 822 | * @return string HTML span tag |
| 821 | 823 | */ |
| 822 | 824 | public function getSprite($class, $attr, $title) { |
@@ -44,226 +44,226 @@ discard block |
||
| 44 | 44 | class LanguageManager |
| 45 | 45 | { |
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * Called from VardefManager to allow for caching a lang file for a module |
|
| 49 | - * @param module - the name of the module we are working with |
|
| 50 | - * @param templates - an array of templates this module uses |
|
| 51 | - */ |
|
| 52 | - static function createLanguageFile($module , $templates=array('default'), $refresh = false){ |
|
| 53 | - global $mod_strings, $current_language; |
|
| 54 | - if(inDeveloperMode() || !empty($_SESSION['developerMode'])){ |
|
| 55 | - $refresh = true; |
|
| 56 | - } |
|
| 57 | - $temp_mod_strings = $mod_strings; |
|
| 58 | - $lang = $current_language; |
|
| 47 | + /** |
|
| 48 | + * Called from VardefManager to allow for caching a lang file for a module |
|
| 49 | + * @param module - the name of the module we are working with |
|
| 50 | + * @param templates - an array of templates this module uses |
|
| 51 | + */ |
|
| 52 | + static function createLanguageFile($module , $templates=array('default'), $refresh = false){ |
|
| 53 | + global $mod_strings, $current_language; |
|
| 54 | + if(inDeveloperMode() || !empty($_SESSION['developerMode'])){ |
|
| 55 | + $refresh = true; |
|
| 56 | + } |
|
| 57 | + $temp_mod_strings = $mod_strings; |
|
| 58 | + $lang = $current_language; |
|
| 59 | 59 | if(empty($lang)) |
| 60 | 60 | $lang = $GLOBALS['sugar_config']['default_language']; |
| 61 | - static $createdModules = array(); |
|
| 62 | - if(empty($createdModules[$module]) && ($refresh || !file_exists(sugar_cached('modules/').$module.'/language/'.$lang.'.lang.php'))){ |
|
| 63 | - $loaded_mod_strings = array(); |
|
| 64 | - $loaded_mod_strings = LanguageManager::loadTemplateLanguage($module , $templates, $lang , $loaded_mod_strings); |
|
| 65 | - $createdModules[$module] = true; |
|
| 66 | - LanguageManager::refreshLanguage($module,$lang, $loaded_mod_strings); |
|
| 67 | - } |
|
| 68 | - } |
|
| 61 | + static $createdModules = array(); |
|
| 62 | + if(empty($createdModules[$module]) && ($refresh || !file_exists(sugar_cached('modules/').$module.'/language/'.$lang.'.lang.php'))){ |
|
| 63 | + $loaded_mod_strings = array(); |
|
| 64 | + $loaded_mod_strings = LanguageManager::loadTemplateLanguage($module , $templates, $lang , $loaded_mod_strings); |
|
| 65 | + $createdModules[$module] = true; |
|
| 66 | + LanguageManager::refreshLanguage($module,$lang, $loaded_mod_strings); |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * Load the module tempalte lauguage files |
|
| 72 | - * @param module - the name of the module we are working with |
|
| 73 | - * @param templates - an array of templates this module uses |
|
| 74 | - * @param lang - current language this module use |
|
| 75 | - * @param loaded_mod_strings - the string that we will add the module template language into |
|
| 76 | - */ |
|
| 77 | - static function loadTemplateLanguage($module , $templates , $lang, $loaded_mod_strings){ |
|
| 78 | - $templates = array_reverse($templates); |
|
| 79 | - foreach($templates as $template){ |
|
| 80 | - $temp = LanguageManager::addTemplate($module,$lang, $template); |
|
| 81 | - $loaded_mod_strings = sugarLangArrayMerge($loaded_mod_strings, $temp); |
|
| 82 | - } |
|
| 83 | - return $loaded_mod_strings; |
|
| 84 | - } |
|
| 70 | + /** |
|
| 71 | + * Load the module tempalte lauguage files |
|
| 72 | + * @param module - the name of the module we are working with |
|
| 73 | + * @param templates - an array of templates this module uses |
|
| 74 | + * @param lang - current language this module use |
|
| 75 | + * @param loaded_mod_strings - the string that we will add the module template language into |
|
| 76 | + */ |
|
| 77 | + static function loadTemplateLanguage($module , $templates , $lang, $loaded_mod_strings){ |
|
| 78 | + $templates = array_reverse($templates); |
|
| 79 | + foreach($templates as $template){ |
|
| 80 | + $temp = LanguageManager::addTemplate($module,$lang, $template); |
|
| 81 | + $loaded_mod_strings = sugarLangArrayMerge($loaded_mod_strings, $temp); |
|
| 82 | + } |
|
| 83 | + return $loaded_mod_strings; |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - static function addTemplate($module, $lang, $template){ |
|
| 87 | - if($template == 'default')$template = 'basic'; |
|
| 88 | - $templates = array(); |
|
| 89 | - $fields = array(); |
|
| 90 | - if(empty($templates[$template])){ |
|
| 91 | - $path = 'include/SugarObjects/templates/' . $template . '/language/'.$lang.'.lang.php'; |
|
| 92 | - if(file_exists($path)){ |
|
| 93 | - require($path); |
|
| 94 | - $templates[$template] = $mod_strings; |
|
| 95 | - }else{ |
|
| 96 | - $path = 'include/SugarObjects/implements/' . $template . '/language/'.$lang.'.lang.php'; |
|
| 97 | - if(file_exists($path)){ |
|
| 98 | - require($path); |
|
| 99 | - $templates[$template] = $mod_strings; |
|
| 100 | - } |
|
| 101 | - } |
|
| 102 | - } |
|
| 103 | - if(!empty($templates[$template])){ |
|
| 104 | - return $templates[$template]; |
|
| 105 | - } |
|
| 106 | - } |
|
| 86 | + static function addTemplate($module, $lang, $template){ |
|
| 87 | + if($template == 'default')$template = 'basic'; |
|
| 88 | + $templates = array(); |
|
| 89 | + $fields = array(); |
|
| 90 | + if(empty($templates[$template])){ |
|
| 91 | + $path = 'include/SugarObjects/templates/' . $template . '/language/'.$lang.'.lang.php'; |
|
| 92 | + if(file_exists($path)){ |
|
| 93 | + require($path); |
|
| 94 | + $templates[$template] = $mod_strings; |
|
| 95 | + }else{ |
|
| 96 | + $path = 'include/SugarObjects/implements/' . $template . '/language/'.$lang.'.lang.php'; |
|
| 97 | + if(file_exists($path)){ |
|
| 98 | + require($path); |
|
| 99 | + $templates[$template] = $mod_strings; |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | + } |
|
| 103 | + if(!empty($templates[$template])){ |
|
| 104 | + return $templates[$template]; |
|
| 105 | + } |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - static function saveCache($module,$lang, $loaded_mod_strings, $additonal_objects= array()){ |
|
| 109 | - if(empty($lang)) |
|
| 110 | - $lang = $GLOBALS['sugar_config']['default_language']; |
|
| 108 | + static function saveCache($module,$lang, $loaded_mod_strings, $additonal_objects= array()){ |
|
| 109 | + if(empty($lang)) |
|
| 110 | + $lang = $GLOBALS['sugar_config']['default_language']; |
|
| 111 | 111 | |
| 112 | - $file = create_cache_directory('modules/' . $module . '/language/'.$lang.'.lang.php'); |
|
| 113 | - write_array_to_file('mod_strings',$loaded_mod_strings, $file); |
|
| 114 | - include($file); |
|
| 112 | + $file = create_cache_directory('modules/' . $module . '/language/'.$lang.'.lang.php'); |
|
| 113 | + write_array_to_file('mod_strings',$loaded_mod_strings, $file); |
|
| 114 | + include($file); |
|
| 115 | 115 | |
| 116 | - // put the item in the sugar cache. |
|
| 117 | - $key = self::getLanguageCacheKey($module,$lang); |
|
| 118 | - sugar_cache_put($key,$loaded_mod_strings); |
|
| 119 | - } |
|
| 116 | + // put the item in the sugar cache. |
|
| 117 | + $key = self::getLanguageCacheKey($module,$lang); |
|
| 118 | + sugar_cache_put($key,$loaded_mod_strings); |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | - /** |
|
| 122 | - * clear out the language cache. |
|
| 123 | - * @param string module_dir the module_dir to clear, if not specified then clear |
|
| 124 | - * clear language cache for all modules. |
|
| 125 | - * @param string lang the name of the object we are clearing this is for sugar_cache |
|
| 126 | - */ |
|
| 127 | - static function clearLanguageCache($module_dir = '', $lang = ''){ |
|
| 128 | - if(empty($lang)) { |
|
| 129 | - $languages = array_keys($GLOBALS['sugar_config']['languages']); |
|
| 130 | - } else { |
|
| 131 | - $languages = array($lang); |
|
| 132 | - } |
|
| 133 | - //if we have a module name specified then just remove that language file |
|
| 134 | - //otherwise go through each module and clean up the language |
|
| 135 | - if(!empty($module_dir)) { |
|
| 136 | - foreach($languages as $clean_lang) { |
|
| 137 | - LanguageManager::_clearCache($module_dir, $clean_lang); |
|
| 138 | - } |
|
| 139 | - } else { |
|
| 140 | - $cache_dir = sugar_cached('modules/'); |
|
| 141 | - if(file_exists($cache_dir) && $dir = @opendir($cache_dir)) { |
|
| 142 | - while(($entry = readdir($dir)) !== false) { |
|
| 143 | - if ($entry == "." || $entry == "..") continue; |
|
| 144 | - foreach($languages as $clean_lang) { |
|
| 145 | - LanguageManager::_clearCache($entry, $clean_lang); |
|
| 146 | - } |
|
| 147 | - } |
|
| 148 | - closedir($dir); |
|
| 149 | - } |
|
| 150 | - } |
|
| 151 | - } |
|
| 121 | + /** |
|
| 122 | + * clear out the language cache. |
|
| 123 | + * @param string module_dir the module_dir to clear, if not specified then clear |
|
| 124 | + * clear language cache for all modules. |
|
| 125 | + * @param string lang the name of the object we are clearing this is for sugar_cache |
|
| 126 | + */ |
|
| 127 | + static function clearLanguageCache($module_dir = '', $lang = ''){ |
|
| 128 | + if(empty($lang)) { |
|
| 129 | + $languages = array_keys($GLOBALS['sugar_config']['languages']); |
|
| 130 | + } else { |
|
| 131 | + $languages = array($lang); |
|
| 132 | + } |
|
| 133 | + //if we have a module name specified then just remove that language file |
|
| 134 | + //otherwise go through each module and clean up the language |
|
| 135 | + if(!empty($module_dir)) { |
|
| 136 | + foreach($languages as $clean_lang) { |
|
| 137 | + LanguageManager::_clearCache($module_dir, $clean_lang); |
|
| 138 | + } |
|
| 139 | + } else { |
|
| 140 | + $cache_dir = sugar_cached('modules/'); |
|
| 141 | + if(file_exists($cache_dir) && $dir = @opendir($cache_dir)) { |
|
| 142 | + while(($entry = readdir($dir)) !== false) { |
|
| 143 | + if ($entry == "." || $entry == "..") continue; |
|
| 144 | + foreach($languages as $clean_lang) { |
|
| 145 | + LanguageManager::_clearCache($entry, $clean_lang); |
|
| 146 | + } |
|
| 147 | + } |
|
| 148 | + closedir($dir); |
|
| 149 | + } |
|
| 150 | + } |
|
| 151 | + } |
|
| 152 | 152 | |
| 153 | - /** |
|
| 154 | - * PRIVATE function used within clearLanguageCache so we do not repeat logic |
|
| 155 | - * @param string module_dir the module_dir to clear |
|
| 156 | - * @param string lang the name of the language file we are clearing this is for sugar_cache |
|
| 157 | - */ |
|
| 158 | - static function _clearCache($module_dir = '', $lang){ |
|
| 159 | - if(!empty($module_dir) && !empty($lang)){ |
|
| 160 | - $file = sugar_cached('modules/').$module_dir.'/language/'.$lang.'.lang.php'; |
|
| 161 | - if(file_exists($file)){ |
|
| 162 | - unlink($file); |
|
| 163 | - $key = self::getLanguageCacheKey($module_dir,$lang); |
|
| 164 | - sugar_cache_clear($key); |
|
| 165 | - } |
|
| 166 | - } |
|
| 167 | - } |
|
| 153 | + /** |
|
| 154 | + * PRIVATE function used within clearLanguageCache so we do not repeat logic |
|
| 155 | + * @param string module_dir the module_dir to clear |
|
| 156 | + * @param string lang the name of the language file we are clearing this is for sugar_cache |
|
| 157 | + */ |
|
| 158 | + static function _clearCache($module_dir = '', $lang){ |
|
| 159 | + if(!empty($module_dir) && !empty($lang)){ |
|
| 160 | + $file = sugar_cached('modules/').$module_dir.'/language/'.$lang.'.lang.php'; |
|
| 161 | + if(file_exists($file)){ |
|
| 162 | + unlink($file); |
|
| 163 | + $key = self::getLanguageCacheKey($module_dir,$lang); |
|
| 164 | + sugar_cache_clear($key); |
|
| 165 | + } |
|
| 166 | + } |
|
| 167 | + } |
|
| 168 | 168 | |
| 169 | - /** |
|
| 170 | - * Given a module, search all of the specified locations, and any others as specified |
|
| 171 | - * in order to refresh the cache file |
|
| 172 | - * |
|
| 173 | - * @param string $module the given module we want to load the vardefs for |
|
| 174 | - * @param string $lang the given language we wish to load |
|
| 175 | - * @param array $additional_search_paths an array which allows a consumer to pass in additional vardef locations to search |
|
| 176 | - */ |
|
| 177 | - static function refreshLanguage($module, $lang, $loaded_mod_strings = array(), $additional_search_paths = null){ |
|
| 178 | - // Some of the vardefs do not correctly define dictionary as global. Declare it first. |
|
| 179 | - $lang_paths = array( |
|
| 180 | - 'modules/'.$module.'/language/'.$lang.'.lang.php', |
|
| 181 | - 'modules/'.$module.'/language/'.$lang.'.lang.override.php', |
|
| 182 | - 'custom/modules/'.$module.'/language/'.$lang.'.lang.php', |
|
| 183 | - 'custom/modules/'.$module.'/Ext/Language/'.$lang.'.lang.ext.php', |
|
| 184 | - ); |
|
| 169 | + /** |
|
| 170 | + * Given a module, search all of the specified locations, and any others as specified |
|
| 171 | + * in order to refresh the cache file |
|
| 172 | + * |
|
| 173 | + * @param string $module the given module we want to load the vardefs for |
|
| 174 | + * @param string $lang the given language we wish to load |
|
| 175 | + * @param array $additional_search_paths an array which allows a consumer to pass in additional vardef locations to search |
|
| 176 | + */ |
|
| 177 | + static function refreshLanguage($module, $lang, $loaded_mod_strings = array(), $additional_search_paths = null){ |
|
| 178 | + // Some of the vardefs do not correctly define dictionary as global. Declare it first. |
|
| 179 | + $lang_paths = array( |
|
| 180 | + 'modules/'.$module.'/language/'.$lang.'.lang.php', |
|
| 181 | + 'modules/'.$module.'/language/'.$lang.'.lang.override.php', |
|
| 182 | + 'custom/modules/'.$module.'/language/'.$lang.'.lang.php', |
|
| 183 | + 'custom/modules/'.$module.'/Ext/Language/'.$lang.'.lang.ext.php', |
|
| 184 | + ); |
|
| 185 | 185 | |
| 186 | - #27023, if this module template language file was not attached , get the template from this module vardef cache file if exsits and load the template language files. |
|
| 187 | - static $createdModules; |
|
| 188 | - if(empty($createdModules[$module]) && isset($GLOBALS['beanList'][$module])){ |
|
| 189 | - $object = $GLOBALS['beanList'][$module]; |
|
| 186 | + #27023, if this module template language file was not attached , get the template from this module vardef cache file if exsits and load the template language files. |
|
| 187 | + static $createdModules; |
|
| 188 | + if(empty($createdModules[$module]) && isset($GLOBALS['beanList'][$module])){ |
|
| 189 | + $object = $GLOBALS['beanList'][$module]; |
|
| 190 | 190 | |
| 191 | - if ($object == 'aCase') |
|
| 192 | - $object = 'Case'; |
|
| 191 | + if ($object == 'aCase') |
|
| 192 | + $object = 'Case'; |
|
| 193 | 193 | |
| 194 | - if(!empty($GLOBALS["dictionary"]["$object"]["templates"])){ |
|
| 195 | - $templates = $GLOBALS["dictionary"]["$object"]["templates"]; |
|
| 196 | - $loaded_mod_strings = LanguageManager::loadTemplateLanguage($module , $templates, $lang , $loaded_mod_strings); |
|
| 197 | - $createdModules[$module] = true; |
|
| 198 | - } |
|
| 199 | - } |
|
| 200 | - //end of fix #27023 |
|
| 194 | + if(!empty($GLOBALS["dictionary"]["$object"]["templates"])){ |
|
| 195 | + $templates = $GLOBALS["dictionary"]["$object"]["templates"]; |
|
| 196 | + $loaded_mod_strings = LanguageManager::loadTemplateLanguage($module , $templates, $lang , $loaded_mod_strings); |
|
| 197 | + $createdModules[$module] = true; |
|
| 198 | + } |
|
| 199 | + } |
|
| 200 | + //end of fix #27023 |
|
| 201 | 201 | |
| 202 | - // Add in additional search paths if they were provided. |
|
| 203 | - if(!empty($additional_search_paths) && is_array($additional_search_paths)) |
|
| 204 | - { |
|
| 205 | - $lang_paths = array_merge($lang_paths, $additional_search_paths); |
|
| 206 | - } |
|
| 202 | + // Add in additional search paths if they were provided. |
|
| 203 | + if(!empty($additional_search_paths) && is_array($additional_search_paths)) |
|
| 204 | + { |
|
| 205 | + $lang_paths = array_merge($lang_paths, $additional_search_paths); |
|
| 206 | + } |
|
| 207 | 207 | |
| 208 | - //search a predefined set of locations for the vardef files |
|
| 209 | - foreach($lang_paths as $path){ |
|
| 210 | - if(file_exists($path)){ |
|
| 211 | - require($path); |
|
| 212 | - if(!empty($mod_strings)){ |
|
| 213 | - if (function_exists('sugarArrayMergeRecursive')){ |
|
| 214 | - $loaded_mod_strings = sugarArrayMergeRecursive($loaded_mod_strings, $mod_strings); |
|
| 215 | - } |
|
| 216 | - else{ |
|
| 217 | - $loaded_mod_strings = sugarLangArrayMerge($loaded_mod_strings, $mod_strings); |
|
| 218 | - } |
|
| 219 | - } |
|
| 220 | - } |
|
| 221 | - } |
|
| 208 | + //search a predefined set of locations for the vardef files |
|
| 209 | + foreach($lang_paths as $path){ |
|
| 210 | + if(file_exists($path)){ |
|
| 211 | + require($path); |
|
| 212 | + if(!empty($mod_strings)){ |
|
| 213 | + if (function_exists('sugarArrayMergeRecursive')){ |
|
| 214 | + $loaded_mod_strings = sugarArrayMergeRecursive($loaded_mod_strings, $mod_strings); |
|
| 215 | + } |
|
| 216 | + else{ |
|
| 217 | + $loaded_mod_strings = sugarLangArrayMerge($loaded_mod_strings, $mod_strings); |
|
| 218 | + } |
|
| 219 | + } |
|
| 220 | + } |
|
| 221 | + } |
|
| 222 | 222 | |
| 223 | - //great! now that we have loaded all of our vardefs. |
|
| 224 | - //let's go save them to the cache file. |
|
| 225 | - if(!empty($loaded_mod_strings)) |
|
| 226 | - LanguageManager::saveCache($module, $lang, $loaded_mod_strings); |
|
| 227 | - } |
|
| 223 | + //great! now that we have loaded all of our vardefs. |
|
| 224 | + //let's go save them to the cache file. |
|
| 225 | + if(!empty($loaded_mod_strings)) |
|
| 226 | + LanguageManager::saveCache($module, $lang, $loaded_mod_strings); |
|
| 227 | + } |
|
| 228 | 228 | |
| 229 | - static function loadModuleLanguage($module, $lang, $refresh=false){ |
|
| 230 | - //here check if the cache file exists, if it does then load it, if it doesn't |
|
| 231 | - //then call refreshVardef |
|
| 232 | - //if either our session or the system is set to developerMode then refresh is set to true |
|
| 229 | + static function loadModuleLanguage($module, $lang, $refresh=false){ |
|
| 230 | + //here check if the cache file exists, if it does then load it, if it doesn't |
|
| 231 | + //then call refreshVardef |
|
| 232 | + //if either our session or the system is set to developerMode then refresh is set to true |
|
| 233 | 233 | |
| 234 | - // Retrieve the vardefs from cache. |
|
| 235 | - $key = self::getLanguageCacheKey($module,$lang); |
|
| 234 | + // Retrieve the vardefs from cache. |
|
| 235 | + $key = self::getLanguageCacheKey($module,$lang); |
|
| 236 | 236 | |
| 237 | - if(!$refresh) |
|
| 238 | - { |
|
| 239 | - $return_result = sugar_cache_retrieve($key); |
|
| 240 | - if(!empty($return_result) && is_array($return_result)){ |
|
| 241 | - return $return_result; |
|
| 242 | - } |
|
| 243 | - } |
|
| 237 | + if(!$refresh) |
|
| 238 | + { |
|
| 239 | + $return_result = sugar_cache_retrieve($key); |
|
| 240 | + if(!empty($return_result) && is_array($return_result)){ |
|
| 241 | + return $return_result; |
|
| 242 | + } |
|
| 243 | + } |
|
| 244 | 244 | |
| 245 | - // Some of the vardefs do not correctly define dictionary as global. Declare it first. |
|
| 246 | - $cachedfile = sugar_cached('modules/').$module.'/language/'.$lang.'.lang.php'; |
|
| 247 | - if($refresh || !file_exists($cachedfile)){ |
|
| 248 | - LanguageManager::refreshLanguage($module, $lang); |
|
| 249 | - } |
|
| 245 | + // Some of the vardefs do not correctly define dictionary as global. Declare it first. |
|
| 246 | + $cachedfile = sugar_cached('modules/').$module.'/language/'.$lang.'.lang.php'; |
|
| 247 | + if($refresh || !file_exists($cachedfile)){ |
|
| 248 | + LanguageManager::refreshLanguage($module, $lang); |
|
| 249 | + } |
|
| 250 | 250 | |
| 251 | - //at this point we should have the cache/modules/... file |
|
| 252 | - //which was created from the refreshVardefs so let's try to load it. |
|
| 253 | - if(file_exists($cachedfile)){ |
|
| 254 | - global $mod_strings; |
|
| 251 | + //at this point we should have the cache/modules/... file |
|
| 252 | + //which was created from the refreshVardefs so let's try to load it. |
|
| 253 | + if(file_exists($cachedfile)){ |
|
| 254 | + global $mod_strings; |
|
| 255 | 255 | |
| 256 | - require $cachedfile; |
|
| 256 | + require $cachedfile; |
|
| 257 | 257 | |
| 258 | - // now that we hae loaded the data from disk, put it in the cache. |
|
| 259 | - if(!empty($mod_strings)) |
|
| 260 | - sugar_cache_put($key,$mod_strings); |
|
| 261 | - if(!empty($_SESSION['translation_mode'])){ |
|
| 262 | - $mod_strings = array_map('translated_prefix', $mod_strings); |
|
| 263 | - } |
|
| 264 | - return $mod_strings; |
|
| 265 | - } |
|
| 266 | - } |
|
| 258 | + // now that we hae loaded the data from disk, put it in the cache. |
|
| 259 | + if(!empty($mod_strings)) |
|
| 260 | + sugar_cache_put($key,$mod_strings); |
|
| 261 | + if(!empty($_SESSION['translation_mode'])){ |
|
| 262 | + $mod_strings = array_map('translated_prefix', $mod_strings); |
|
| 263 | + } |
|
| 264 | + return $mod_strings; |
|
| 265 | + } |
|
| 266 | + } |
|
| 267 | 267 | |
| 268 | 268 | /** |
| 269 | 269 | * Return the cache key for the module language definition |
@@ -274,9 +274,9 @@ discard block |
||
| 274 | 274 | * @return string |
| 275 | 275 | */ |
| 276 | 276 | public static function getLanguageCacheKey($module, $lang) |
| 277 | - { |
|
| 278 | - return "LanguageManager.$module.$lang"; |
|
| 279 | - } |
|
| 277 | + { |
|
| 278 | + return "LanguageManager.$module.$lang"; |
|
| 279 | + } |
|
| 280 | 280 | |
| 281 | 281 | /** |
| 282 | 282 | * Remove any cached js language strings. |
@@ -302,5 +302,5 @@ discard block |
||
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | function translated_prefix($key){ |
| 305 | - return '[translated]' . $key; |
|
| 305 | + return '[translated]' . $key; |
|
| 306 | 306 | } |
@@ -49,21 +49,21 @@ discard block |
||
| 49 | 49 | * @param module - the name of the module we are working with |
| 50 | 50 | * @param templates - an array of templates this module uses |
| 51 | 51 | */ |
| 52 | - static function createLanguageFile($module , $templates=array('default'), $refresh = false){ |
|
| 52 | + static function createLanguageFile($module, $templates = array('default'), $refresh = false) { |
|
| 53 | 53 | global $mod_strings, $current_language; |
| 54 | - if(inDeveloperMode() || !empty($_SESSION['developerMode'])){ |
|
| 54 | + if (inDeveloperMode() || !empty($_SESSION['developerMode'])) { |
|
| 55 | 55 | $refresh = true; |
| 56 | 56 | } |
| 57 | 57 | $temp_mod_strings = $mod_strings; |
| 58 | 58 | $lang = $current_language; |
| 59 | - if(empty($lang)) |
|
| 59 | + if (empty($lang)) |
|
| 60 | 60 | $lang = $GLOBALS['sugar_config']['default_language']; |
| 61 | 61 | static $createdModules = array(); |
| 62 | - if(empty($createdModules[$module]) && ($refresh || !file_exists(sugar_cached('modules/').$module.'/language/'.$lang.'.lang.php'))){ |
|
| 62 | + if (empty($createdModules[$module]) && ($refresh || !file_exists(sugar_cached('modules/').$module.'/language/'.$lang.'.lang.php'))) { |
|
| 63 | 63 | $loaded_mod_strings = array(); |
| 64 | - $loaded_mod_strings = LanguageManager::loadTemplateLanguage($module , $templates, $lang , $loaded_mod_strings); |
|
| 64 | + $loaded_mod_strings = LanguageManager::loadTemplateLanguage($module, $templates, $lang, $loaded_mod_strings); |
|
| 65 | 65 | $createdModules[$module] = true; |
| 66 | - LanguageManager::refreshLanguage($module,$lang, $loaded_mod_strings); |
|
| 66 | + LanguageManager::refreshLanguage($module, $lang, $loaded_mod_strings); |
|
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | |
@@ -74,48 +74,48 @@ discard block |
||
| 74 | 74 | * @param lang - current language this module use |
| 75 | 75 | * @param loaded_mod_strings - the string that we will add the module template language into |
| 76 | 76 | */ |
| 77 | - static function loadTemplateLanguage($module , $templates , $lang, $loaded_mod_strings){ |
|
| 77 | + static function loadTemplateLanguage($module, $templates, $lang, $loaded_mod_strings) { |
|
| 78 | 78 | $templates = array_reverse($templates); |
| 79 | - foreach($templates as $template){ |
|
| 80 | - $temp = LanguageManager::addTemplate($module,$lang, $template); |
|
| 79 | + foreach ($templates as $template) { |
|
| 80 | + $temp = LanguageManager::addTemplate($module, $lang, $template); |
|
| 81 | 81 | $loaded_mod_strings = sugarLangArrayMerge($loaded_mod_strings, $temp); |
| 82 | 82 | } |
| 83 | 83 | return $loaded_mod_strings; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - static function addTemplate($module, $lang, $template){ |
|
| 87 | - if($template == 'default')$template = 'basic'; |
|
| 86 | + static function addTemplate($module, $lang, $template) { |
|
| 87 | + if ($template == 'default')$template = 'basic'; |
|
| 88 | 88 | $templates = array(); |
| 89 | 89 | $fields = array(); |
| 90 | - if(empty($templates[$template])){ |
|
| 91 | - $path = 'include/SugarObjects/templates/' . $template . '/language/'.$lang.'.lang.php'; |
|
| 92 | - if(file_exists($path)){ |
|
| 90 | + if (empty($templates[$template])) { |
|
| 91 | + $path = 'include/SugarObjects/templates/'.$template.'/language/'.$lang.'.lang.php'; |
|
| 92 | + if (file_exists($path)) { |
|
| 93 | 93 | require($path); |
| 94 | 94 | $templates[$template] = $mod_strings; |
| 95 | - }else{ |
|
| 96 | - $path = 'include/SugarObjects/implements/' . $template . '/language/'.$lang.'.lang.php'; |
|
| 97 | - if(file_exists($path)){ |
|
| 95 | + } else { |
|
| 96 | + $path = 'include/SugarObjects/implements/'.$template.'/language/'.$lang.'.lang.php'; |
|
| 97 | + if (file_exists($path)) { |
|
| 98 | 98 | require($path); |
| 99 | 99 | $templates[$template] = $mod_strings; |
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | - if(!empty($templates[$template])){ |
|
| 103 | + if (!empty($templates[$template])) { |
|
| 104 | 104 | return $templates[$template]; |
| 105 | 105 | } |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - static function saveCache($module,$lang, $loaded_mod_strings, $additonal_objects= array()){ |
|
| 109 | - if(empty($lang)) |
|
| 108 | + static function saveCache($module, $lang, $loaded_mod_strings, $additonal_objects = array()) { |
|
| 109 | + if (empty($lang)) |
|
| 110 | 110 | $lang = $GLOBALS['sugar_config']['default_language']; |
| 111 | 111 | |
| 112 | - $file = create_cache_directory('modules/' . $module . '/language/'.$lang.'.lang.php'); |
|
| 113 | - write_array_to_file('mod_strings',$loaded_mod_strings, $file); |
|
| 112 | + $file = create_cache_directory('modules/'.$module.'/language/'.$lang.'.lang.php'); |
|
| 113 | + write_array_to_file('mod_strings', $loaded_mod_strings, $file); |
|
| 114 | 114 | include($file); |
| 115 | 115 | |
| 116 | 116 | // put the item in the sugar cache. |
| 117 | - $key = self::getLanguageCacheKey($module,$lang); |
|
| 118 | - sugar_cache_put($key,$loaded_mod_strings); |
|
| 117 | + $key = self::getLanguageCacheKey($module, $lang); |
|
| 118 | + sugar_cache_put($key, $loaded_mod_strings); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | /** |
@@ -124,24 +124,24 @@ discard block |
||
| 124 | 124 | * clear language cache for all modules. |
| 125 | 125 | * @param string lang the name of the object we are clearing this is for sugar_cache |
| 126 | 126 | */ |
| 127 | - static function clearLanguageCache($module_dir = '', $lang = ''){ |
|
| 128 | - if(empty($lang)) { |
|
| 127 | + static function clearLanguageCache($module_dir = '', $lang = '') { |
|
| 128 | + if (empty($lang)) { |
|
| 129 | 129 | $languages = array_keys($GLOBALS['sugar_config']['languages']); |
| 130 | 130 | } else { |
| 131 | 131 | $languages = array($lang); |
| 132 | 132 | } |
| 133 | 133 | //if we have a module name specified then just remove that language file |
| 134 | 134 | //otherwise go through each module and clean up the language |
| 135 | - if(!empty($module_dir)) { |
|
| 136 | - foreach($languages as $clean_lang) { |
|
| 135 | + if (!empty($module_dir)) { |
|
| 136 | + foreach ($languages as $clean_lang) { |
|
| 137 | 137 | LanguageManager::_clearCache($module_dir, $clean_lang); |
| 138 | 138 | } |
| 139 | 139 | } else { |
| 140 | 140 | $cache_dir = sugar_cached('modules/'); |
| 141 | - if(file_exists($cache_dir) && $dir = @opendir($cache_dir)) { |
|
| 142 | - while(($entry = readdir($dir)) !== false) { |
|
| 141 | + if (file_exists($cache_dir) && $dir = @opendir($cache_dir)) { |
|
| 142 | + while (($entry = readdir($dir)) !== false) { |
|
| 143 | 143 | if ($entry == "." || $entry == "..") continue; |
| 144 | - foreach($languages as $clean_lang) { |
|
| 144 | + foreach ($languages as $clean_lang) { |
|
| 145 | 145 | LanguageManager::_clearCache($entry, $clean_lang); |
| 146 | 146 | } |
| 147 | 147 | } |
@@ -155,12 +155,12 @@ discard block |
||
| 155 | 155 | * @param string module_dir the module_dir to clear |
| 156 | 156 | * @param string lang the name of the language file we are clearing this is for sugar_cache |
| 157 | 157 | */ |
| 158 | - static function _clearCache($module_dir = '', $lang){ |
|
| 159 | - if(!empty($module_dir) && !empty($lang)){ |
|
| 158 | + static function _clearCache($module_dir = '', $lang) { |
|
| 159 | + if (!empty($module_dir) && !empty($lang)) { |
|
| 160 | 160 | $file = sugar_cached('modules/').$module_dir.'/language/'.$lang.'.lang.php'; |
| 161 | - if(file_exists($file)){ |
|
| 161 | + if (file_exists($file)) { |
|
| 162 | 162 | unlink($file); |
| 163 | - $key = self::getLanguageCacheKey($module_dir,$lang); |
|
| 163 | + $key = self::getLanguageCacheKey($module_dir, $lang); |
|
| 164 | 164 | sugar_cache_clear($key); |
| 165 | 165 | } |
| 166 | 166 | } |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | * @param string $lang the given language we wish to load |
| 175 | 175 | * @param array $additional_search_paths an array which allows a consumer to pass in additional vardef locations to search |
| 176 | 176 | */ |
| 177 | - static function refreshLanguage($module, $lang, $loaded_mod_strings = array(), $additional_search_paths = null){ |
|
| 177 | + static function refreshLanguage($module, $lang, $loaded_mod_strings = array(), $additional_search_paths = null) { |
|
| 178 | 178 | // Some of the vardefs do not correctly define dictionary as global. Declare it first. |
| 179 | 179 | $lang_paths = array( |
| 180 | 180 | 'modules/'.$module.'/language/'.$lang.'.lang.php', |
@@ -185,35 +185,35 @@ discard block |
||
| 185 | 185 | |
| 186 | 186 | #27023, if this module template language file was not attached , get the template from this module vardef cache file if exsits and load the template language files. |
| 187 | 187 | static $createdModules; |
| 188 | - if(empty($createdModules[$module]) && isset($GLOBALS['beanList'][$module])){ |
|
| 188 | + if (empty($createdModules[$module]) && isset($GLOBALS['beanList'][$module])) { |
|
| 189 | 189 | $object = $GLOBALS['beanList'][$module]; |
| 190 | 190 | |
| 191 | 191 | if ($object == 'aCase') |
| 192 | 192 | $object = 'Case'; |
| 193 | 193 | |
| 194 | - if(!empty($GLOBALS["dictionary"]["$object"]["templates"])){ |
|
| 194 | + if (!empty($GLOBALS["dictionary"]["$object"]["templates"])) { |
|
| 195 | 195 | $templates = $GLOBALS["dictionary"]["$object"]["templates"]; |
| 196 | - $loaded_mod_strings = LanguageManager::loadTemplateLanguage($module , $templates, $lang , $loaded_mod_strings); |
|
| 196 | + $loaded_mod_strings = LanguageManager::loadTemplateLanguage($module, $templates, $lang, $loaded_mod_strings); |
|
| 197 | 197 | $createdModules[$module] = true; |
| 198 | 198 | } |
| 199 | 199 | } |
| 200 | 200 | //end of fix #27023 |
| 201 | 201 | |
| 202 | 202 | // Add in additional search paths if they were provided. |
| 203 | - if(!empty($additional_search_paths) && is_array($additional_search_paths)) |
|
| 203 | + if (!empty($additional_search_paths) && is_array($additional_search_paths)) |
|
| 204 | 204 | { |
| 205 | 205 | $lang_paths = array_merge($lang_paths, $additional_search_paths); |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | //search a predefined set of locations for the vardef files |
| 209 | - foreach($lang_paths as $path){ |
|
| 210 | - if(file_exists($path)){ |
|
| 209 | + foreach ($lang_paths as $path) { |
|
| 210 | + if (file_exists($path)) { |
|
| 211 | 211 | require($path); |
| 212 | - if(!empty($mod_strings)){ |
|
| 213 | - if (function_exists('sugarArrayMergeRecursive')){ |
|
| 212 | + if (!empty($mod_strings)) { |
|
| 213 | + if (function_exists('sugarArrayMergeRecursive')) { |
|
| 214 | 214 | $loaded_mod_strings = sugarArrayMergeRecursive($loaded_mod_strings, $mod_strings); |
| 215 | 215 | } |
| 216 | - else{ |
|
| 216 | + else { |
|
| 217 | 217 | $loaded_mod_strings = sugarLangArrayMerge($loaded_mod_strings, $mod_strings); |
| 218 | 218 | } |
| 219 | 219 | } |
@@ -222,43 +222,43 @@ discard block |
||
| 222 | 222 | |
| 223 | 223 | //great! now that we have loaded all of our vardefs. |
| 224 | 224 | //let's go save them to the cache file. |
| 225 | - if(!empty($loaded_mod_strings)) |
|
| 225 | + if (!empty($loaded_mod_strings)) |
|
| 226 | 226 | LanguageManager::saveCache($module, $lang, $loaded_mod_strings); |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - static function loadModuleLanguage($module, $lang, $refresh=false){ |
|
| 229 | + static function loadModuleLanguage($module, $lang, $refresh = false) { |
|
| 230 | 230 | //here check if the cache file exists, if it does then load it, if it doesn't |
| 231 | 231 | //then call refreshVardef |
| 232 | 232 | //if either our session or the system is set to developerMode then refresh is set to true |
| 233 | 233 | |
| 234 | 234 | // Retrieve the vardefs from cache. |
| 235 | - $key = self::getLanguageCacheKey($module,$lang); |
|
| 235 | + $key = self::getLanguageCacheKey($module, $lang); |
|
| 236 | 236 | |
| 237 | - if(!$refresh) |
|
| 237 | + if (!$refresh) |
|
| 238 | 238 | { |
| 239 | 239 | $return_result = sugar_cache_retrieve($key); |
| 240 | - if(!empty($return_result) && is_array($return_result)){ |
|
| 240 | + if (!empty($return_result) && is_array($return_result)) { |
|
| 241 | 241 | return $return_result; |
| 242 | 242 | } |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | // Some of the vardefs do not correctly define dictionary as global. Declare it first. |
| 246 | 246 | $cachedfile = sugar_cached('modules/').$module.'/language/'.$lang.'.lang.php'; |
| 247 | - if($refresh || !file_exists($cachedfile)){ |
|
| 247 | + if ($refresh || !file_exists($cachedfile)) { |
|
| 248 | 248 | LanguageManager::refreshLanguage($module, $lang); |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | //at this point we should have the cache/modules/... file |
| 252 | 252 | //which was created from the refreshVardefs so let's try to load it. |
| 253 | - if(file_exists($cachedfile)){ |
|
| 253 | + if (file_exists($cachedfile)) { |
|
| 254 | 254 | global $mod_strings; |
| 255 | 255 | |
| 256 | 256 | require $cachedfile; |
| 257 | 257 | |
| 258 | 258 | // now that we hae loaded the data from disk, put it in the cache. |
| 259 | - if(!empty($mod_strings)) |
|
| 260 | - sugar_cache_put($key,$mod_strings); |
|
| 261 | - if(!empty($_SESSION['translation_mode'])){ |
|
| 259 | + if (!empty($mod_strings)) |
|
| 260 | + sugar_cache_put($key, $mod_strings); |
|
| 261 | + if (!empty($_SESSION['translation_mode'])) { |
|
| 262 | 262 | $mod_strings = array_map('translated_prefix', $mod_strings); |
| 263 | 263 | } |
| 264 | 264 | return $mod_strings; |
@@ -288,19 +288,19 @@ discard block |
||
| 288 | 288 | { |
| 289 | 289 | $jsFiles = array(); |
| 290 | 290 | getFiles($jsFiles, sugar_cached('jsLanguage')); |
| 291 | - foreach($jsFiles as $file) { |
|
| 291 | + foreach ($jsFiles as $file) { |
|
| 292 | 292 | unlink($file); |
| 293 | 293 | } |
| 294 | 294 | |
| 295 | - if( empty($GLOBALS['sugar_config']['js_lang_version']) ) |
|
| 295 | + if (empty($GLOBALS['sugar_config']['js_lang_version'])) |
|
| 296 | 296 | $GLOBALS['sugar_config']['js_lang_version'] = 1; |
| 297 | 297 | else |
| 298 | 298 | $GLOBALS['sugar_config']['js_lang_version'] += 1; |
| 299 | 299 | |
| 300 | - write_array_to_file( "sugar_config", $GLOBALS['sugar_config'], "config.php"); |
|
| 300 | + write_array_to_file("sugar_config", $GLOBALS['sugar_config'], "config.php"); |
|
| 301 | 301 | } |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | -function translated_prefix($key){ |
|
| 305 | - return '[translated]' . $key; |
|
| 304 | +function translated_prefix($key) { |
|
| 305 | + return '[translated]'.$key; |
|
| 306 | 306 | } |
@@ -56,8 +56,9 @@ discard block |
||
| 56 | 56 | } |
| 57 | 57 | $temp_mod_strings = $mod_strings; |
| 58 | 58 | $lang = $current_language; |
| 59 | - if(empty($lang)) |
|
| 60 | - $lang = $GLOBALS['sugar_config']['default_language']; |
|
| 59 | + if(empty($lang)) { |
|
| 60 | + $lang = $GLOBALS['sugar_config']['default_language']; |
|
| 61 | + } |
|
| 61 | 62 | static $createdModules = array(); |
| 62 | 63 | if(empty($createdModules[$module]) && ($refresh || !file_exists(sugar_cached('modules/').$module.'/language/'.$lang.'.lang.php'))){ |
| 63 | 64 | $loaded_mod_strings = array(); |
@@ -84,7 +85,9 @@ discard block |
||
| 84 | 85 | } |
| 85 | 86 | |
| 86 | 87 | static function addTemplate($module, $lang, $template){ |
| 87 | - if($template == 'default')$template = 'basic'; |
|
| 88 | + if($template == 'default') { |
|
| 89 | + $template = 'basic'; |
|
| 90 | + } |
|
| 88 | 91 | $templates = array(); |
| 89 | 92 | $fields = array(); |
| 90 | 93 | if(empty($templates[$template])){ |
@@ -92,7 +95,7 @@ discard block |
||
| 92 | 95 | if(file_exists($path)){ |
| 93 | 96 | require($path); |
| 94 | 97 | $templates[$template] = $mod_strings; |
| 95 | - }else{ |
|
| 98 | + } else{ |
|
| 96 | 99 | $path = 'include/SugarObjects/implements/' . $template . '/language/'.$lang.'.lang.php'; |
| 97 | 100 | if(file_exists($path)){ |
| 98 | 101 | require($path); |
@@ -106,8 +109,9 @@ discard block |
||
| 106 | 109 | } |
| 107 | 110 | |
| 108 | 111 | static function saveCache($module,$lang, $loaded_mod_strings, $additonal_objects= array()){ |
| 109 | - if(empty($lang)) |
|
| 110 | - $lang = $GLOBALS['sugar_config']['default_language']; |
|
| 112 | + if(empty($lang)) { |
|
| 113 | + $lang = $GLOBALS['sugar_config']['default_language']; |
|
| 114 | + } |
|
| 111 | 115 | |
| 112 | 116 | $file = create_cache_directory('modules/' . $module . '/language/'.$lang.'.lang.php'); |
| 113 | 117 | write_array_to_file('mod_strings',$loaded_mod_strings, $file); |
@@ -140,7 +144,9 @@ discard block |
||
| 140 | 144 | $cache_dir = sugar_cached('modules/'); |
| 141 | 145 | if(file_exists($cache_dir) && $dir = @opendir($cache_dir)) { |
| 142 | 146 | while(($entry = readdir($dir)) !== false) { |
| 143 | - if ($entry == "." || $entry == "..") continue; |
|
| 147 | + if ($entry == "." || $entry == "..") { |
|
| 148 | + continue; |
|
| 149 | + } |
|
| 144 | 150 | foreach($languages as $clean_lang) { |
| 145 | 151 | LanguageManager::_clearCache($entry, $clean_lang); |
| 146 | 152 | } |
@@ -188,8 +194,9 @@ discard block |
||
| 188 | 194 | if(empty($createdModules[$module]) && isset($GLOBALS['beanList'][$module])){ |
| 189 | 195 | $object = $GLOBALS['beanList'][$module]; |
| 190 | 196 | |
| 191 | - if ($object == 'aCase') |
|
| 192 | - $object = 'Case'; |
|
| 197 | + if ($object == 'aCase') { |
|
| 198 | + $object = 'Case'; |
|
| 199 | + } |
|
| 193 | 200 | |
| 194 | 201 | if(!empty($GLOBALS["dictionary"]["$object"]["templates"])){ |
| 195 | 202 | $templates = $GLOBALS["dictionary"]["$object"]["templates"]; |
@@ -212,8 +219,7 @@ discard block |
||
| 212 | 219 | if(!empty($mod_strings)){ |
| 213 | 220 | if (function_exists('sugarArrayMergeRecursive')){ |
| 214 | 221 | $loaded_mod_strings = sugarArrayMergeRecursive($loaded_mod_strings, $mod_strings); |
| 215 | - } |
|
| 216 | - else{ |
|
| 222 | + } else{ |
|
| 217 | 223 | $loaded_mod_strings = sugarLangArrayMerge($loaded_mod_strings, $mod_strings); |
| 218 | 224 | } |
| 219 | 225 | } |
@@ -222,8 +228,9 @@ discard block |
||
| 222 | 228 | |
| 223 | 229 | //great! now that we have loaded all of our vardefs. |
| 224 | 230 | //let's go save them to the cache file. |
| 225 | - if(!empty($loaded_mod_strings)) |
|
| 226 | - LanguageManager::saveCache($module, $lang, $loaded_mod_strings); |
|
| 231 | + if(!empty($loaded_mod_strings)) { |
|
| 232 | + LanguageManager::saveCache($module, $lang, $loaded_mod_strings); |
|
| 233 | + } |
|
| 227 | 234 | } |
| 228 | 235 | |
| 229 | 236 | static function loadModuleLanguage($module, $lang, $refresh=false){ |
@@ -256,8 +263,9 @@ discard block |
||
| 256 | 263 | require $cachedfile; |
| 257 | 264 | |
| 258 | 265 | // now that we hae loaded the data from disk, put it in the cache. |
| 259 | - if(!empty($mod_strings)) |
|
| 260 | - sugar_cache_put($key,$mod_strings); |
|
| 266 | + if(!empty($mod_strings)) { |
|
| 267 | + sugar_cache_put($key,$mod_strings); |
|
| 268 | + } |
|
| 261 | 269 | if(!empty($_SESSION['translation_mode'])){ |
| 262 | 270 | $mod_strings = array_map('translated_prefix', $mod_strings); |
| 263 | 271 | } |
@@ -292,10 +300,11 @@ discard block |
||
| 292 | 300 | unlink($file); |
| 293 | 301 | } |
| 294 | 302 | |
| 295 | - if( empty($GLOBALS['sugar_config']['js_lang_version']) ) |
|
| 296 | - $GLOBALS['sugar_config']['js_lang_version'] = 1; |
|
| 297 | - else |
|
| 298 | - $GLOBALS['sugar_config']['js_lang_version'] += 1; |
|
| 303 | + if( empty($GLOBALS['sugar_config']['js_lang_version']) ) { |
|
| 304 | + $GLOBALS['sugar_config']['js_lang_version'] = 1; |
|
| 305 | + } else { |
|
| 306 | + $GLOBALS['sugar_config']['js_lang_version'] += 1; |
|
| 307 | + } |
|
| 299 | 308 | |
| 300 | 309 | write_array_to_file( "sugar_config", $GLOBALS['sugar_config'], "config.php"); |
| 301 | 310 | } |
@@ -105,6 +105,10 @@ discard block |
||
| 105 | 105 | } |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | + /** |
|
| 109 | + * @param string $module |
|
| 110 | + * @param string $lang |
|
| 111 | + */ |
|
| 108 | 112 | static function saveCache($module,$lang, $loaded_mod_strings, $additonal_objects= array()){ |
| 109 | 113 | if(empty($lang)) |
| 110 | 114 | $lang = $GLOBALS['sugar_config']['default_language']; |
@@ -226,6 +230,9 @@ discard block |
||
| 226 | 230 | LanguageManager::saveCache($module, $lang, $loaded_mod_strings); |
| 227 | 231 | } |
| 228 | 232 | |
| 233 | + /** |
|
| 234 | + * @param string $module |
|
| 235 | + */ |
|
| 229 | 236 | static function loadModuleLanguage($module, $lang, $refresh=false){ |
| 230 | 237 | //here check if the cache file exists, if it does then load it, if it doesn't |
| 231 | 238 | //then call refreshVardef |
@@ -89,9 +89,9 @@ discard block |
||
| 89 | 89 | */ |
| 90 | 90 | public static function setCustomAllowedForModule($module, $enable) { |
| 91 | 91 | if ($enable && isset($custom_disabled_modules[$module])) { |
| 92 | - unset($custom_disabled_modules[$module]); |
|
| 92 | + unset($custom_disabled_modules[$module]); |
|
| 93 | 93 | } else if (!$enable) { |
| 94 | - $custom_disabled_modules[$module] = true; |
|
| 94 | + $custom_disabled_modules[$module] = true; |
|
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | 'modules/'.$module.'/vardefs.php', |
| 237 | 237 | 'custom/modules/'.$module.'/Ext/Vardefs/vardefs.ext.php', |
| 238 | 238 | 'custom/Extension/modules/'.$module.'/Ext/Vardefs/vardefs.php' |
| 239 | - ); |
|
| 239 | + ); |
|
| 240 | 240 | |
| 241 | 241 | // Add in additional search paths if they were provided. |
| 242 | 242 | if(!empty($additional_search_paths) && is_array($additional_search_paths)) |
@@ -426,10 +426,10 @@ discard block |
||
| 426 | 426 | //if the consumer has demanded a refresh or the cache/modules... file |
| 427 | 427 | //does not exist, then we should do out and try to reload things |
| 428 | 428 | |
| 429 | - $cachedfile = sugar_cached('modules/'). $module . '/' . $object . 'vardefs.php'; |
|
| 430 | - if($refresh || !file_exists($cachedfile)){ |
|
| 431 | - VardefManager::refreshVardefs($module, $object, null, true, $params); |
|
| 432 | - } |
|
| 429 | + $cachedfile = sugar_cached('modules/'). $module . '/' . $object . 'vardefs.php'; |
|
| 430 | + if($refresh || !file_exists($cachedfile)){ |
|
| 431 | + VardefManager::refreshVardefs($module, $object, null, true, $params); |
|
| 432 | + } |
|
| 433 | 433 | |
| 434 | 434 | //at this point we should have the cache/modules/... file |
| 435 | 435 | //which was created from the refreshVardefs so let's try to load it. |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * Vardefs management |
| 43 | 43 | * @api |
| 44 | 44 | */ |
| 45 | -class VardefManager{ |
|
| 45 | +class VardefManager { |
|
| 46 | 46 | static $custom_disabled_modules = array(); |
| 47 | 47 | static $linkFields; |
| 48 | 48 | |
@@ -67,8 +67,8 @@ discard block |
||
| 67 | 67 | if (isset(VardefManager::$custom_disabled_modules[$module])) |
| 68 | 68 | { |
| 69 | 69 | $vardef_paths = array( |
| 70 | - 'custom/modules/' . $module . '/Ext/Vardefs/vardefs.ext.php', |
|
| 71 | - 'custom/Extension/modules/' . $module . '/Ext/Vardefs/vardefs.php' |
|
| 70 | + 'custom/modules/'.$module.'/Ext/Vardefs/vardefs.ext.php', |
|
| 71 | + 'custom/Extension/modules/'.$module.'/Ext/Vardefs/vardefs.php' |
|
| 72 | 72 | ); |
| 73 | 73 | |
| 74 | 74 | //search a predefined set of locations for the vardef files |
@@ -95,41 +95,41 @@ discard block |
||
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - static function addTemplate($module, $object, $template, $object_name=false){ |
|
| 99 | - if($template == 'default')$template = 'basic'; |
|
| 98 | + static function addTemplate($module, $object, $template, $object_name = false) { |
|
| 99 | + if ($template == 'default')$template = 'basic'; |
|
| 100 | 100 | $templates = array(); |
| 101 | 101 | $fields = array(); |
| 102 | - if(empty($object_name))$object_name = $object; |
|
| 102 | + if (empty($object_name))$object_name = $object; |
|
| 103 | 103 | $_object_name = strtolower($object_name); |
| 104 | - if(!empty($GLOBALS['dictionary'][$object]['table'])){ |
|
| 104 | + if (!empty($GLOBALS['dictionary'][$object]['table'])) { |
|
| 105 | 105 | $table_name = $GLOBALS['dictionary'][$object]['table']; |
| 106 | - }else{ |
|
| 106 | + } else { |
|
| 107 | 107 | $table_name = strtolower($module); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - if(empty($templates[$template])){ |
|
| 111 | - $path = 'include/SugarObjects/templates/' . $template . '/vardefs.php'; |
|
| 112 | - if(file_exists($path)){ |
|
| 110 | + if (empty($templates[$template])) { |
|
| 111 | + $path = 'include/SugarObjects/templates/'.$template.'/vardefs.php'; |
|
| 112 | + if (file_exists($path)) { |
|
| 113 | 113 | require($path); |
| 114 | 114 | $templates[$template] = $vardefs; |
| 115 | - }else{ |
|
| 116 | - $path = 'include/SugarObjects/implements/' . $template . '/vardefs.php'; |
|
| 117 | - if(file_exists($path)){ |
|
| 115 | + } else { |
|
| 116 | + $path = 'include/SugarObjects/implements/'.$template.'/vardefs.php'; |
|
| 117 | + if (file_exists($path)) { |
|
| 118 | 118 | require($path); |
| 119 | 119 | $templates[$template] = $vardefs; |
| 120 | 120 | } |
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - if(!empty($templates[$template])){ |
|
| 125 | - if(empty($GLOBALS['dictionary'][$object]['fields']))$GLOBALS['dictionary'][$object]['fields'] = array(); |
|
| 126 | - if(empty($GLOBALS['dictionary'][$object]['relationships']))$GLOBALS['dictionary'][$object]['relationships'] = array(); |
|
| 127 | - if(empty($GLOBALS['dictionary'][$object]['indices']))$GLOBALS['dictionary'][$object]['indices'] = array(); |
|
| 124 | + if (!empty($templates[$template])) { |
|
| 125 | + if (empty($GLOBALS['dictionary'][$object]['fields']))$GLOBALS['dictionary'][$object]['fields'] = array(); |
|
| 126 | + if (empty($GLOBALS['dictionary'][$object]['relationships']))$GLOBALS['dictionary'][$object]['relationships'] = array(); |
|
| 127 | + if (empty($GLOBALS['dictionary'][$object]['indices']))$GLOBALS['dictionary'][$object]['indices'] = array(); |
|
| 128 | 128 | $GLOBALS['dictionary'][$object]['fields'] = array_merge($templates[$template]['fields'], $GLOBALS['dictionary'][$object]['fields']); |
| 129 | - if(!empty($templates[$template]['relationships']))$GLOBALS['dictionary'][$object]['relationships'] = array_merge($templates[$template]['relationships'], $GLOBALS['dictionary'][$object]['relationships']); |
|
| 130 | - if(!empty($templates[$template]['indices']))$GLOBALS['dictionary'][$object]['indices'] = array_merge($templates[$template]['indices'], $GLOBALS['dictionary'][$object]['indices']); |
|
| 129 | + if (!empty($templates[$template]['relationships']))$GLOBALS['dictionary'][$object]['relationships'] = array_merge($templates[$template]['relationships'], $GLOBALS['dictionary'][$object]['relationships']); |
|
| 130 | + if (!empty($templates[$template]['indices']))$GLOBALS['dictionary'][$object]['indices'] = array_merge($templates[$template]['indices'], $GLOBALS['dictionary'][$object]['indices']); |
|
| 131 | 131 | // maintain a record of this objects inheritance from the SugarObject templates... |
| 132 | - $GLOBALS['dictionary'][$object]['templates'][ $template ] = $template ; |
|
| 132 | + $GLOBALS['dictionary'][$object]['templates'][$template] = $template; |
|
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | */ |
| 143 | 143 | static function cleanVardefs($fieldDefs) |
| 144 | 144 | { |
| 145 | - foreach($fieldDefs as $field => $defs) |
|
| 145 | + foreach ($fieldDefs as $field => $defs) |
|
| 146 | 146 | { |
| 147 | 147 | if (empty($def['name']) || empty($def['type'])) |
| 148 | 148 | { |
@@ -158,15 +158,15 @@ discard block |
||
| 158 | 158 | * @param string $module the name of the module |
| 159 | 159 | * @param string $object the name of the object |
| 160 | 160 | */ |
| 161 | - static function saveCache($module,$object, $additonal_objects= array()){ |
|
| 161 | + static function saveCache($module, $object, $additonal_objects = array()) { |
|
| 162 | 162 | |
| 163 | 163 | if (empty($GLOBALS['dictionary'][$object])) |
| 164 | 164 | $object = BeanFactory::getObjectName($module); |
| 165 | - $file = create_cache_directory('modules/' . $module . '/' . $object . 'vardefs.php'); |
|
| 165 | + $file = create_cache_directory('modules/'.$module.'/'.$object.'vardefs.php'); |
|
| 166 | 166 | |
| 167 | - $out="<?php \n \$GLOBALS[\"dictionary\"][\"". $object . "\"]=" . var_export($GLOBALS['dictionary'][$object], true) .";"; |
|
| 167 | + $out = "<?php \n \$GLOBALS[\"dictionary\"][\"".$object."\"]=".var_export($GLOBALS['dictionary'][$object], true).";"; |
|
| 168 | 168 | sugar_file_put_contents_atomic($file, $out); |
| 169 | - if ( sugar_is_file($file) && is_readable($file)) { |
|
| 169 | + if (sugar_is_file($file) && is_readable($file)) { |
|
| 170 | 170 | include($file); |
| 171 | 171 | } |
| 172 | 172 | |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | $key = "VardefManager.$module.$object"; |
| 175 | 175 | //Sometimes bad definitions can get in from left over extensions or file system lag(caching). We need to clean those. |
| 176 | 176 | $data = self::cleanVardefs($GLOBALS['dictionary'][$object]); |
| 177 | - sugar_cache_put($key,$data); |
|
| 177 | + sugar_cache_put($key, $data); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | /** |
@@ -184,14 +184,14 @@ discard block |
||
| 184 | 184 | * clear vardef cache for all modules. |
| 185 | 185 | * @param string object_name the name of the object we are clearing this is for sugar_cache |
| 186 | 186 | */ |
| 187 | - static function clearVardef($module_dir = '', $object_name = ''){ |
|
| 187 | + static function clearVardef($module_dir = '', $object_name = '') { |
|
| 188 | 188 | //if we have a module name specified then just remove that vardef file |
| 189 | 189 | //otherwise go through each module and remove the vardefs.php |
| 190 | - if(!empty($module_dir) && !empty($object_name)){ |
|
| 190 | + if (!empty($module_dir) && !empty($object_name)) { |
|
| 191 | 191 | VardefManager::_clearCache($module_dir, $object_name); |
| 192 | - }else{ |
|
| 192 | + } else { |
|
| 193 | 193 | global $beanList; |
| 194 | - foreach($beanList as $module_dir => $object_name){ |
|
| 194 | + foreach ($beanList as $module_dir => $object_name) { |
|
| 195 | 195 | VardefManager::_clearCache($module_dir, $object_name); |
| 196 | 196 | } |
| 197 | 197 | } |
@@ -202,8 +202,8 @@ discard block |
||
| 202 | 202 | * @param string module_dir the module_dir to clear |
| 203 | 203 | * @param string object_name the name of the object we are clearing this is for sugar_cache |
| 204 | 204 | */ |
| 205 | - static function _clearCache($module_dir = '', $object_name = ''){ |
|
| 206 | - if(!empty($module_dir) && !empty($object_name)){ |
|
| 205 | + static function _clearCache($module_dir = '', $object_name = '') { |
|
| 206 | + if (!empty($module_dir) && !empty($object_name)) { |
|
| 207 | 207 | |
| 208 | 208 | //Some modules like cases have a bean name that doesn't match the object name |
| 209 | 209 | if (empty($GLOBALS['dictionary'][$object_name])) { |
@@ -211,9 +211,9 @@ discard block |
||
| 211 | 211 | $object_name = $newName != false ? $newName : $object_name; |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | - $file = sugar_cached('modules/').$module_dir.'/' . $object_name . 'vardefs.php'; |
|
| 214 | + $file = sugar_cached('modules/').$module_dir.'/'.$object_name.'vardefs.php'; |
|
| 215 | 215 | |
| 216 | - if(file_exists($file)){ |
|
| 216 | + if (file_exists($file)) { |
|
| 217 | 217 | unlink($file); |
| 218 | 218 | $key = "VardefManager.$module_dir.$object_name"; |
| 219 | 219 | sugar_cache_clear($key); |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | * @param string $object the given object we wish to load the vardefs for |
| 230 | 230 | * @param array $additional_search_paths an array which allows a consumer to pass in additional vardef locations to search |
| 231 | 231 | */ |
| 232 | - static function refreshVardefs($module, $object, $additional_search_paths = null, $cacheCustom = true, $params = array()){ |
|
| 232 | + static function refreshVardefs($module, $object, $additional_search_paths = null, $cacheCustom = true, $params = array()) { |
|
| 233 | 233 | // Some of the vardefs do not correctly define dictionary as global. Declare it first. |
| 234 | 234 | global $dictionary, $beanList; |
| 235 | 235 | $vardef_paths = array( |
@@ -239,20 +239,20 @@ discard block |
||
| 239 | 239 | ); |
| 240 | 240 | |
| 241 | 241 | // Add in additional search paths if they were provided. |
| 242 | - if(!empty($additional_search_paths) && is_array($additional_search_paths)) |
|
| 242 | + if (!empty($additional_search_paths) && is_array($additional_search_paths)) |
|
| 243 | 243 | { |
| 244 | 244 | $vardef_paths = array_merge($vardef_paths, $additional_search_paths); |
| 245 | 245 | } |
| 246 | 246 | $found = false; |
| 247 | 247 | //search a predefined set of locations for the vardef files |
| 248 | - foreach($vardef_paths as $path){ |
|
| 249 | - if(file_exists($path)){ |
|
| 248 | + foreach ($vardef_paths as $path) { |
|
| 249 | + if (file_exists($path)) { |
|
| 250 | 250 | require($path); |
| 251 | 251 | $found = true; |
| 252 | 252 | } |
| 253 | 253 | } |
| 254 | 254 | //Some modules have multiple beans, we need to see if this object has a module_dir that is different from its module_name |
| 255 | - if(!$found){ |
|
| 255 | + if (!$found) { |
|
| 256 | 256 | $temp = BeanFactory::newBean($module); |
| 257 | 257 | if ($temp) |
| 258 | 258 | { |
@@ -271,15 +271,15 @@ discard block |
||
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | //load custom fields into the vardef cache |
| 274 | - if($cacheCustom){ |
|
| 274 | + if ($cacheCustom) { |
|
| 275 | 275 | require_once("modules/DynamicFields/DynamicField.php"); |
| 276 | - $df = new DynamicField ($module) ; |
|
| 276 | + $df = new DynamicField($module); |
|
| 277 | 277 | $df->buildCache($module, false); |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | //great! now that we have loaded all of our vardefs. |
| 281 | 281 | //let's go save them to the cache file. |
| 282 | - if(!empty($dictionary[$object])) { |
|
| 282 | + if (!empty($dictionary[$object])) { |
|
| 283 | 283 | VardefManager::saveCache($module, $object); |
| 284 | 284 | } |
| 285 | 285 | } |
@@ -316,10 +316,10 @@ discard block |
||
| 316 | 316 | |
| 317 | 317 | $vardef = $dictionary[$object]; |
| 318 | 318 | $links = array(); |
| 319 | - foreach($vardef['fields'] as $name => $def) |
|
| 319 | + foreach ($vardef['fields'] as $name => $def) |
|
| 320 | 320 | { |
| 321 | 321 | //Look through all link fields for related modules that have calculated fields that use that relationship |
| 322 | - if(!empty($def['type']) && $def['type'] == 'link' && !empty($def['relationship'])) |
|
| 322 | + if (!empty($def['type']) && $def['type'] == 'link' && !empty($def['relationship'])) |
|
| 323 | 323 | { |
| 324 | 324 | $links[$name] = $def; |
| 325 | 325 | } |
@@ -335,14 +335,14 @@ discard block |
||
| 335 | 335 | { |
| 336 | 336 | $cacheKey = "LFR{$module}{$object}{$relName}"; |
| 337 | 337 | $cacheValue = sugar_cache_retrieve($cacheKey); |
| 338 | - if(!empty($cacheValue)) |
|
| 338 | + if (!empty($cacheValue)) |
|
| 339 | 339 | return $cacheValue; |
| 340 | 340 | |
| 341 | 341 | $relLinkFields = self::getLinkFieldsForModule($module, $object); |
| 342 | 342 | $matches = array(); |
| 343 | 343 | if (!empty($relLinkFields)) |
| 344 | 344 | { |
| 345 | - foreach($relLinkFields as $rfName => $rfDef) |
|
| 345 | + foreach ($relLinkFields as $rfName => $rfDef) |
|
| 346 | 346 | { |
| 347 | 347 | if ($rfDef['relationship'] == $relName) |
| 348 | 348 | { |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | $results = $matches; |
| 360 | 360 | |
| 361 | 361 | sugar_cache_put($cacheKey, $results); |
| 362 | - return $results ; |
|
| 362 | + return $results; |
|
| 363 | 363 | } |
| 364 | 364 | |
| 365 | 365 | |
@@ -398,22 +398,22 @@ discard block |
||
| 398 | 398 | * @param string $object the given object we wish to load the vardefs for |
| 399 | 399 | * @param bool $refresh whether or not we wish to refresh the cache file. |
| 400 | 400 | */ |
| 401 | - static function loadVardef($module, $object, $refresh=false, $params = array()){ |
|
| 401 | + static function loadVardef($module, $object, $refresh = false, $params = array()) { |
|
| 402 | 402 | //here check if the cache file exists, if it does then load it, if it doesn't |
| 403 | 403 | //then call refreshVardef |
| 404 | 404 | //if either our session or the system is set to developerMode then refresh is set to true |
| 405 | - if(inDeveloperMode() || !empty($_SESSION['developerMode'])){ |
|
| 405 | + if (inDeveloperMode() || !empty($_SESSION['developerMode'])) { |
|
| 406 | 406 | $refresh = true; |
| 407 | 407 | } |
| 408 | 408 | // Retrieve the vardefs from cache. |
| 409 | 409 | $key = "VardefManager.$module.$object"; |
| 410 | 410 | |
| 411 | - if(!$refresh) |
|
| 411 | + if (!$refresh) |
|
| 412 | 412 | { |
| 413 | 413 | $return_result = sugar_cache_retrieve($key); |
| 414 | 414 | $return_result = self::applyGlobalAccountRequirements($return_result); |
| 415 | 415 | |
| 416 | - if(!empty($return_result)) |
|
| 416 | + if (!empty($return_result)) |
|
| 417 | 417 | { |
| 418 | 418 | $GLOBALS['dictionary'][$object] = $return_result; |
| 419 | 419 | return; |
@@ -422,28 +422,28 @@ discard block |
||
| 422 | 422 | |
| 423 | 423 | // Some of the vardefs do not correctly define dictionary as global. Declare it first. |
| 424 | 424 | global $dictionary; |
| 425 | - if(empty($GLOBALS['dictionary'][$object]) || $refresh){ |
|
| 425 | + if (empty($GLOBALS['dictionary'][$object]) || $refresh) { |
|
| 426 | 426 | //if the consumer has demanded a refresh or the cache/modules... file |
| 427 | 427 | //does not exist, then we should do out and try to reload things |
| 428 | 428 | |
| 429 | - $cachedfile = sugar_cached('modules/'). $module . '/' . $object . 'vardefs.php'; |
|
| 430 | - if($refresh || !file_exists($cachedfile)){ |
|
| 429 | + $cachedfile = sugar_cached('modules/').$module.'/'.$object.'vardefs.php'; |
|
| 430 | + if ($refresh || !file_exists($cachedfile)) { |
|
| 431 | 431 | VardefManager::refreshVardefs($module, $object, null, true, $params); |
| 432 | 432 | } |
| 433 | 433 | |
| 434 | 434 | //at this point we should have the cache/modules/... file |
| 435 | 435 | //which was created from the refreshVardefs so let's try to load it. |
| 436 | - if(file_exists($cachedfile)) |
|
| 436 | + if (file_exists($cachedfile)) |
|
| 437 | 437 | { |
| 438 | 438 | if (is_readable($cachedfile)) |
| 439 | 439 | { |
| 440 | 440 | include($cachedfile); |
| 441 | 441 | } |
| 442 | 442 | // now that we hae loaded the data from disk, put it in the cache. |
| 443 | - if(!empty($GLOBALS['dictionary'][$object])) |
|
| 443 | + if (!empty($GLOBALS['dictionary'][$object])) |
|
| 444 | 444 | { |
| 445 | 445 | $GLOBALS['dictionary'][$object] = self::applyGlobalAccountRequirements($GLOBALS['dictionary'][$object]); |
| 446 | - sugar_cache_put($key,$GLOBALS['dictionary'][$object]); |
|
| 446 | + sugar_cache_put($key, $GLOBALS['dictionary'][$object]); |
|
| 447 | 447 | } |
| 448 | 448 | } |
| 449 | 449 | } |
@@ -96,14 +96,18 @@ discard block |
||
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | static function addTemplate($module, $object, $template, $object_name=false){ |
| 99 | - if($template == 'default')$template = 'basic'; |
|
| 99 | + if($template == 'default') { |
|
| 100 | + $template = 'basic'; |
|
| 101 | + } |
|
| 100 | 102 | $templates = array(); |
| 101 | 103 | $fields = array(); |
| 102 | - if(empty($object_name))$object_name = $object; |
|
| 104 | + if(empty($object_name)) { |
|
| 105 | + $object_name = $object; |
|
| 106 | + } |
|
| 103 | 107 | $_object_name = strtolower($object_name); |
| 104 | 108 | if(!empty($GLOBALS['dictionary'][$object]['table'])){ |
| 105 | 109 | $table_name = $GLOBALS['dictionary'][$object]['table']; |
| 106 | - }else{ |
|
| 110 | + } else{ |
|
| 107 | 111 | $table_name = strtolower($module); |
| 108 | 112 | } |
| 109 | 113 | |
@@ -112,7 +116,7 @@ discard block |
||
| 112 | 116 | if(file_exists($path)){ |
| 113 | 117 | require($path); |
| 114 | 118 | $templates[$template] = $vardefs; |
| 115 | - }else{ |
|
| 119 | + } else{ |
|
| 116 | 120 | $path = 'include/SugarObjects/implements/' . $template . '/vardefs.php'; |
| 117 | 121 | if(file_exists($path)){ |
| 118 | 122 | require($path); |
@@ -122,12 +126,22 @@ discard block |
||
| 122 | 126 | } |
| 123 | 127 | |
| 124 | 128 | if(!empty($templates[$template])){ |
| 125 | - if(empty($GLOBALS['dictionary'][$object]['fields']))$GLOBALS['dictionary'][$object]['fields'] = array(); |
|
| 126 | - if(empty($GLOBALS['dictionary'][$object]['relationships']))$GLOBALS['dictionary'][$object]['relationships'] = array(); |
|
| 127 | - if(empty($GLOBALS['dictionary'][$object]['indices']))$GLOBALS['dictionary'][$object]['indices'] = array(); |
|
| 129 | + if(empty($GLOBALS['dictionary'][$object]['fields'])) { |
|
| 130 | + $GLOBALS['dictionary'][$object]['fields'] = array(); |
|
| 131 | + } |
|
| 132 | + if(empty($GLOBALS['dictionary'][$object]['relationships'])) { |
|
| 133 | + $GLOBALS['dictionary'][$object]['relationships'] = array(); |
|
| 134 | + } |
|
| 135 | + if(empty($GLOBALS['dictionary'][$object]['indices'])) { |
|
| 136 | + $GLOBALS['dictionary'][$object]['indices'] = array(); |
|
| 137 | + } |
|
| 128 | 138 | $GLOBALS['dictionary'][$object]['fields'] = array_merge($templates[$template]['fields'], $GLOBALS['dictionary'][$object]['fields']); |
| 129 | - if(!empty($templates[$template]['relationships']))$GLOBALS['dictionary'][$object]['relationships'] = array_merge($templates[$template]['relationships'], $GLOBALS['dictionary'][$object]['relationships']); |
|
| 130 | - if(!empty($templates[$template]['indices']))$GLOBALS['dictionary'][$object]['indices'] = array_merge($templates[$template]['indices'], $GLOBALS['dictionary'][$object]['indices']); |
|
| 139 | + if(!empty($templates[$template]['relationships'])) { |
|
| 140 | + $GLOBALS['dictionary'][$object]['relationships'] = array_merge($templates[$template]['relationships'], $GLOBALS['dictionary'][$object]['relationships']); |
|
| 141 | + } |
|
| 142 | + if(!empty($templates[$template]['indices'])) { |
|
| 143 | + $GLOBALS['dictionary'][$object]['indices'] = array_merge($templates[$template]['indices'], $GLOBALS['dictionary'][$object]['indices']); |
|
| 144 | + } |
|
| 131 | 145 | // maintain a record of this objects inheritance from the SugarObject templates... |
| 132 | 146 | $GLOBALS['dictionary'][$object]['templates'][ $template ] = $template ; |
| 133 | 147 | } |
@@ -160,8 +174,9 @@ discard block |
||
| 160 | 174 | */ |
| 161 | 175 | static function saveCache($module,$object, $additonal_objects= array()){ |
| 162 | 176 | |
| 163 | - if (empty($GLOBALS['dictionary'][$object])) |
|
| 164 | - $object = BeanFactory::getObjectName($module); |
|
| 177 | + if (empty($GLOBALS['dictionary'][$object])) { |
|
| 178 | + $object = BeanFactory::getObjectName($module); |
|
| 179 | + } |
|
| 165 | 180 | $file = create_cache_directory('modules/' . $module . '/' . $object . 'vardefs.php'); |
| 166 | 181 | |
| 167 | 182 | $out="<?php \n \$GLOBALS[\"dictionary\"][\"". $object . "\"]=" . var_export($GLOBALS['dictionary'][$object], true) .";"; |
@@ -189,7 +204,7 @@ discard block |
||
| 189 | 204 | //otherwise go through each module and remove the vardefs.php |
| 190 | 205 | if(!empty($module_dir) && !empty($object_name)){ |
| 191 | 206 | VardefManager::_clearCache($module_dir, $object_name); |
| 192 | - }else{ |
|
| 207 | + } else{ |
|
| 193 | 208 | global $beanList; |
| 194 | 209 | foreach($beanList as $module_dir => $object_name){ |
| 195 | 210 | VardefManager::_clearCache($module_dir, $object_name); |
@@ -308,11 +323,13 @@ discard block |
||
| 308 | 323 | } |
| 309 | 324 | |
| 310 | 325 | //Cache link fields for this call in a static variable |
| 311 | - if (!isset(self::$linkFields)) |
|
| 312 | - self::$linkFields = array(); |
|
| 326 | + if (!isset(self::$linkFields)) { |
|
| 327 | + self::$linkFields = array(); |
|
| 328 | + } |
|
| 313 | 329 | |
| 314 | - if (isset(self::$linkFields[$object])) |
|
| 315 | - return self::$linkFields[$object]; |
|
| 330 | + if (isset(self::$linkFields[$object])) { |
|
| 331 | + return self::$linkFields[$object]; |
|
| 332 | + } |
|
| 316 | 333 | |
| 317 | 334 | $vardef = $dictionary[$object]; |
| 318 | 335 | $links = array(); |
@@ -335,8 +352,9 @@ discard block |
||
| 335 | 352 | { |
| 336 | 353 | $cacheKey = "LFR{$module}{$object}{$relName}"; |
| 337 | 354 | $cacheValue = sugar_cache_retrieve($cacheKey); |
| 338 | - if(!empty($cacheValue)) |
|
| 339 | - return $cacheValue; |
|
| 355 | + if(!empty($cacheValue)) { |
|
| 356 | + return $cacheValue; |
|
| 357 | + } |
|
| 340 | 358 | |
| 341 | 359 | $relLinkFields = self::getLinkFieldsForModule($module, $object); |
| 342 | 360 | $matches = array(); |
@@ -350,13 +368,15 @@ discard block |
||
| 350 | 368 | } |
| 351 | 369 | } |
| 352 | 370 | } |
| 353 | - if (empty($matches)) |
|
| 354 | - return false; |
|
| 355 | - if (sizeof($matches) == 1) |
|
| 356 | - $results = $matches[0]; |
|
| 357 | - else |
|
| 358 | - //For relationships where both sides are the same module, more than one link will be returned |
|
| 371 | + if (empty($matches)) { |
|
| 372 | + return false; |
|
| 373 | + } |
|
| 374 | + if (sizeof($matches) == 1) { |
|
| 375 | + $results = $matches[0]; |
|
| 376 | + } else { |
|
| 377 | + //For relationships where both sides are the same module, more than one link will be returned |
|
| 359 | 378 | $results = $matches; |
| 379 | + } |
|
| 360 | 380 | |
| 361 | 381 | sugar_cache_put($cacheKey, $results); |
| 362 | 382 | return $results ; |
@@ -39,141 +39,141 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | $vardefs = array( |
| 41 | 41 | 'fields' => array ( |
| 42 | - 'id' => |
|
| 43 | - array ( |
|
| 44 | - 'name' => 'id', |
|
| 45 | - 'vname' => 'LBL_ID', |
|
| 46 | - 'type' => 'id', |
|
| 47 | - 'required'=>true, |
|
| 48 | - 'reportable'=>true, |
|
| 49 | - 'comment' => 'Unique identifier', |
|
| 50 | - 'inline_edit' => false, |
|
| 51 | - ), |
|
| 52 | - 'name'=> |
|
| 53 | - array( |
|
| 54 | - 'name'=>'name', |
|
| 55 | - 'vname'=> 'LBL_NAME', |
|
| 56 | - 'type'=>'name', |
|
| 57 | - 'link' => true, // bug 39288 |
|
| 58 | - 'dbType' => 'varchar', |
|
| 59 | - 'len'=>255, |
|
| 42 | + 'id' => |
|
| 43 | + array ( |
|
| 44 | + 'name' => 'id', |
|
| 45 | + 'vname' => 'LBL_ID', |
|
| 46 | + 'type' => 'id', |
|
| 47 | + 'required'=>true, |
|
| 48 | + 'reportable'=>true, |
|
| 49 | + 'comment' => 'Unique identifier', |
|
| 50 | + 'inline_edit' => false, |
|
| 51 | + ), |
|
| 52 | + 'name'=> |
|
| 53 | + array( |
|
| 54 | + 'name'=>'name', |
|
| 55 | + 'vname'=> 'LBL_NAME', |
|
| 56 | + 'type'=>'name', |
|
| 57 | + 'link' => true, // bug 39288 |
|
| 58 | + 'dbType' => 'varchar', |
|
| 59 | + 'len'=>255, |
|
| 60 | 60 | 'unified_search' => true, |
| 61 | 61 | 'full_text_search' => array('boost' => 3), |
| 62 | 62 | 'required'=>true, |
| 63 | - 'importable' => 'required', |
|
| 63 | + 'importable' => 'required', |
|
| 64 | 64 | 'duplicate_merge' => 'enabled', |
| 65 | 65 | //'duplicate_merge_dom_value' => '3', |
| 66 | 66 | 'merge_filter' => 'selected', |
| 67 | - ), |
|
| 68 | - 'date_entered' => |
|
| 69 | - array ( |
|
| 70 | - 'name' => 'date_entered', |
|
| 71 | - 'vname' => 'LBL_DATE_ENTERED', |
|
| 72 | - 'type' => 'datetime', |
|
| 73 | - 'group'=>'created_by_name', |
|
| 74 | - 'comment' => 'Date record created', |
|
| 75 | - 'enable_range_search' => true, |
|
| 76 | - 'options' => 'date_range_search_dom', |
|
| 77 | - 'inline_edit' => false, |
|
| 78 | - ), |
|
| 79 | - 'date_modified' => |
|
| 80 | - array ( |
|
| 81 | - 'name' => 'date_modified', |
|
| 82 | - 'vname' => 'LBL_DATE_MODIFIED', |
|
| 83 | - 'type' => 'datetime', |
|
| 84 | - 'group'=>'modified_by_name', |
|
| 85 | - 'comment' => 'Date record last modified', |
|
| 86 | - 'enable_range_search' => true, |
|
| 87 | - 'options' => 'date_range_search_dom', |
|
| 88 | - 'inline_edit' => false, |
|
| 89 | - ), |
|
| 90 | - 'modified_user_id' => |
|
| 91 | - array ( |
|
| 92 | - 'name' => 'modified_user_id', |
|
| 93 | - 'rname' => 'user_name', |
|
| 94 | - 'id_name' => 'modified_user_id', |
|
| 95 | - 'vname' => 'LBL_MODIFIED', |
|
| 96 | - 'type' => 'assigned_user_name', |
|
| 97 | - 'table' => 'users', |
|
| 98 | - 'isnull' => 'false', |
|
| 99 | - 'group'=>'modified_by_name', |
|
| 100 | - 'dbType' => 'id', |
|
| 101 | - 'reportable'=>true, |
|
| 102 | - 'comment' => 'User who last modified record', |
|
| 67 | + ), |
|
| 68 | + 'date_entered' => |
|
| 69 | + array ( |
|
| 70 | + 'name' => 'date_entered', |
|
| 71 | + 'vname' => 'LBL_DATE_ENTERED', |
|
| 72 | + 'type' => 'datetime', |
|
| 73 | + 'group'=>'created_by_name', |
|
| 74 | + 'comment' => 'Date record created', |
|
| 75 | + 'enable_range_search' => true, |
|
| 76 | + 'options' => 'date_range_search_dom', |
|
| 77 | + 'inline_edit' => false, |
|
| 78 | + ), |
|
| 79 | + 'date_modified' => |
|
| 80 | + array ( |
|
| 81 | + 'name' => 'date_modified', |
|
| 82 | + 'vname' => 'LBL_DATE_MODIFIED', |
|
| 83 | + 'type' => 'datetime', |
|
| 84 | + 'group'=>'modified_by_name', |
|
| 85 | + 'comment' => 'Date record last modified', |
|
| 86 | + 'enable_range_search' => true, |
|
| 87 | + 'options' => 'date_range_search_dom', |
|
| 88 | + 'inline_edit' => false, |
|
| 89 | + ), |
|
| 90 | + 'modified_user_id' => |
|
| 91 | + array ( |
|
| 92 | + 'name' => 'modified_user_id', |
|
| 93 | + 'rname' => 'user_name', |
|
| 94 | + 'id_name' => 'modified_user_id', |
|
| 95 | + 'vname' => 'LBL_MODIFIED', |
|
| 96 | + 'type' => 'assigned_user_name', |
|
| 97 | + 'table' => 'users', |
|
| 98 | + 'isnull' => 'false', |
|
| 99 | + 'group'=>'modified_by_name', |
|
| 100 | + 'dbType' => 'id', |
|
| 101 | + 'reportable'=>true, |
|
| 102 | + 'comment' => 'User who last modified record', |
|
| 103 | 103 | 'massupdate' => false, |
| 104 | - 'inline_edit' => false, |
|
| 105 | - ), |
|
| 106 | - 'modified_by_name' => |
|
| 107 | - array ( |
|
| 108 | - 'name' => 'modified_by_name', |
|
| 109 | - 'vname' => 'LBL_MODIFIED_NAME', |
|
| 110 | - 'type' => 'relate', |
|
| 111 | - 'reportable'=>false, |
|
| 112 | - 'source'=>'non-db', |
|
| 113 | - 'rname'=>'user_name', |
|
| 114 | - 'table' => 'users', |
|
| 115 | - 'id_name' => 'modified_user_id', |
|
| 116 | - 'module'=>'Users', |
|
| 117 | - 'link'=>'modified_user_link', |
|
| 118 | - 'duplicate_merge'=>'disabled', |
|
| 104 | + 'inline_edit' => false, |
|
| 105 | + ), |
|
| 106 | + 'modified_by_name' => |
|
| 107 | + array ( |
|
| 108 | + 'name' => 'modified_by_name', |
|
| 109 | + 'vname' => 'LBL_MODIFIED_NAME', |
|
| 110 | + 'type' => 'relate', |
|
| 111 | + 'reportable'=>false, |
|
| 112 | + 'source'=>'non-db', |
|
| 113 | + 'rname'=>'user_name', |
|
| 114 | + 'table' => 'users', |
|
| 115 | + 'id_name' => 'modified_user_id', |
|
| 116 | + 'module'=>'Users', |
|
| 117 | + 'link'=>'modified_user_link', |
|
| 118 | + 'duplicate_merge'=>'disabled', |
|
| 119 | 119 | 'massupdate' => false, |
| 120 | - 'inline_edit' => false, |
|
| 121 | - ), |
|
| 122 | - 'created_by' => |
|
| 123 | - array ( |
|
| 124 | - 'name' => 'created_by', |
|
| 125 | - 'rname' => 'user_name', |
|
| 126 | - 'id_name' => 'modified_user_id', |
|
| 127 | - 'vname' => 'LBL_CREATED', |
|
| 128 | - 'type' => 'assigned_user_name', |
|
| 129 | - 'table' => 'users', |
|
| 130 | - 'isnull' => 'false', |
|
| 131 | - 'dbType' => 'id', |
|
| 132 | - 'group'=>'created_by_name', |
|
| 133 | - 'comment' => 'User who created record', |
|
| 120 | + 'inline_edit' => false, |
|
| 121 | + ), |
|
| 122 | + 'created_by' => |
|
| 123 | + array ( |
|
| 124 | + 'name' => 'created_by', |
|
| 125 | + 'rname' => 'user_name', |
|
| 126 | + 'id_name' => 'modified_user_id', |
|
| 127 | + 'vname' => 'LBL_CREATED', |
|
| 128 | + 'type' => 'assigned_user_name', |
|
| 129 | + 'table' => 'users', |
|
| 130 | + 'isnull' => 'false', |
|
| 131 | + 'dbType' => 'id', |
|
| 132 | + 'group'=>'created_by_name', |
|
| 133 | + 'comment' => 'User who created record', |
|
| 134 | 134 | 'massupdate' => false, |
| 135 | - 'inline_edit' => false, |
|
| 136 | - ), |
|
| 137 | - 'created_by_name' => |
|
| 138 | - array ( |
|
| 139 | - 'name' => 'created_by_name', |
|
| 140 | - 'vname' => 'LBL_CREATED', |
|
| 141 | - 'type' => 'relate', |
|
| 142 | - 'reportable'=>false, |
|
| 143 | - 'link' => 'created_by_link', |
|
| 144 | - 'rname' => 'user_name', |
|
| 145 | - 'source'=>'non-db', |
|
| 146 | - 'table' => 'users', |
|
| 147 | - 'id_name' => 'created_by', |
|
| 148 | - 'module'=>'Users', |
|
| 149 | - 'duplicate_merge'=>'disabled', |
|
| 135 | + 'inline_edit' => false, |
|
| 136 | + ), |
|
| 137 | + 'created_by_name' => |
|
| 138 | + array ( |
|
| 139 | + 'name' => 'created_by_name', |
|
| 140 | + 'vname' => 'LBL_CREATED', |
|
| 141 | + 'type' => 'relate', |
|
| 142 | + 'reportable'=>false, |
|
| 143 | + 'link' => 'created_by_link', |
|
| 144 | + 'rname' => 'user_name', |
|
| 145 | + 'source'=>'non-db', |
|
| 146 | + 'table' => 'users', |
|
| 147 | + 'id_name' => 'created_by', |
|
| 148 | + 'module'=>'Users', |
|
| 149 | + 'duplicate_merge'=>'disabled', |
|
| 150 | 150 | 'importable' => 'false', |
| 151 | 151 | 'massupdate' => false, |
| 152 | - 'inline_edit' => false, |
|
| 153 | - ), |
|
| 154 | - 'description' => |
|
| 155 | - array ( |
|
| 156 | - 'name' => 'description', |
|
| 157 | - 'vname' => 'LBL_DESCRIPTION', |
|
| 158 | - 'type' => 'text', |
|
| 159 | - 'comment' => 'Full text of the note', |
|
| 160 | - 'rows' => 6, |
|
| 161 | - 'cols' => 80, |
|
| 162 | - ), |
|
| 163 | - 'deleted' => |
|
| 164 | - array ( |
|
| 165 | - 'name' => 'deleted', |
|
| 166 | - 'vname' => 'LBL_DELETED', |
|
| 167 | - 'type' => 'bool', |
|
| 168 | - 'default' => '0', |
|
| 169 | - 'reportable'=>false, |
|
| 170 | - 'comment' => 'Record deletion indicator' |
|
| 171 | - ), |
|
| 152 | + 'inline_edit' => false, |
|
| 153 | + ), |
|
| 154 | + 'description' => |
|
| 155 | + array ( |
|
| 156 | + 'name' => 'description', |
|
| 157 | + 'vname' => 'LBL_DESCRIPTION', |
|
| 158 | + 'type' => 'text', |
|
| 159 | + 'comment' => 'Full text of the note', |
|
| 160 | + 'rows' => 6, |
|
| 161 | + 'cols' => 80, |
|
| 162 | + ), |
|
| 163 | + 'deleted' => |
|
| 164 | + array ( |
|
| 165 | + 'name' => 'deleted', |
|
| 166 | + 'vname' => 'LBL_DELETED', |
|
| 167 | + 'type' => 'bool', |
|
| 168 | + 'default' => '0', |
|
| 169 | + 'reportable'=>false, |
|
| 170 | + 'comment' => 'Record deletion indicator' |
|
| 171 | + ), |
|
| 172 | 172 | |
| 173 | 173 | /////////////////RELATIONSHIP LINKS//////////////////////////// |
| 174 | - 'created_by_link' => |
|
| 175 | - array ( |
|
| 176 | - 'name' => 'created_by_link', |
|
| 174 | + 'created_by_link' => |
|
| 175 | + array ( |
|
| 176 | + 'name' => 'created_by_link', |
|
| 177 | 177 | 'type' => 'link', |
| 178 | 178 | 'relationship' => strtolower($module) . '_created_by', |
| 179 | 179 | 'vname' => 'LBL_CREATED_USER', |
@@ -181,9 +181,9 @@ discard block |
||
| 181 | 181 | 'module'=>'Users', |
| 182 | 182 | 'bean_name'=>'User', |
| 183 | 183 | 'source'=>'non-db', |
| 184 | - ), |
|
| 185 | - 'modified_user_link' => |
|
| 186 | - array ( |
|
| 184 | + ), |
|
| 185 | + 'modified_user_link' => |
|
| 186 | + array ( |
|
| 187 | 187 | 'name' => 'modified_user_link', |
| 188 | 188 | 'type' => 'link', |
| 189 | 189 | 'relationship' => strtolower($module). '_modified_user', |
@@ -192,21 +192,21 @@ discard block |
||
| 192 | 192 | 'module'=>'Users', |
| 193 | 193 | 'bean_name'=>'User', |
| 194 | 194 | 'source'=>'non-db', |
| 195 | - ), |
|
| 195 | + ), |
|
| 196 | 196 | |
| 197 | 197 | ), |
| 198 | 198 | 'indices' => array ( |
| 199 | - 'id'=>array('name' =>strtolower($module).'pk', 'type' =>'primary', 'fields'=>array('id')), |
|
| 200 | - ), |
|
| 199 | + 'id'=>array('name' =>strtolower($module).'pk', 'type' =>'primary', 'fields'=>array('id')), |
|
| 200 | + ), |
|
| 201 | 201 | 'relationships'=>array( |
| 202 | - strtolower($module).'_modified_user' => |
|
| 203 | - array('lhs_module'=> 'Users', 'lhs_table'=> 'users', 'lhs_key' => 'id', |
|
| 204 | - 'rhs_module'=> $module, 'rhs_table'=> strtolower($module), 'rhs_key' => 'modified_user_id', |
|
| 205 | - 'relationship_type'=>'one-to-many') |
|
| 206 | - ,strtolower($module).'_created_by' => |
|
| 207 | - array('lhs_module'=> 'Users', 'lhs_table'=> 'users', 'lhs_key' => 'id', |
|
| 208 | - 'rhs_module'=> $module, 'rhs_table'=> strtolower($module), 'rhs_key' => 'created_by', |
|
| 209 | - 'relationship_type'=>'one-to-many') |
|
| 202 | + strtolower($module).'_modified_user' => |
|
| 203 | + array('lhs_module'=> 'Users', 'lhs_table'=> 'users', 'lhs_key' => 'id', |
|
| 204 | + 'rhs_module'=> $module, 'rhs_table'=> strtolower($module), 'rhs_key' => 'modified_user_id', |
|
| 205 | + 'relationship_type'=>'one-to-many') |
|
| 206 | + ,strtolower($module).'_created_by' => |
|
| 207 | + array('lhs_module'=> 'Users', 'lhs_table'=> 'users', 'lhs_key' => 'id', |
|
| 208 | + 'rhs_module'=> $module, 'rhs_table'=> strtolower($module), 'rhs_key' => 'created_by', |
|
| 209 | + 'relationship_type'=>'one-to-many') |
|
| 210 | 210 | ), |
| 211 | 211 | |
| 212 | 212 | |
@@ -38,9 +38,9 @@ discard block |
||
| 38 | 38 | ********************************************************************************/ |
| 39 | 39 | |
| 40 | 40 | $vardefs = array( |
| 41 | -'fields' => array ( |
|
| 41 | +'fields' => array( |
|
| 42 | 42 | 'id' => |
| 43 | - array ( |
|
| 43 | + array( |
|
| 44 | 44 | 'name' => 'id', |
| 45 | 45 | 'vname' => 'LBL_ID', |
| 46 | 46 | 'type' => 'id', |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | 'merge_filter' => 'selected', |
| 67 | 67 | ), |
| 68 | 68 | 'date_entered' => |
| 69 | - array ( |
|
| 69 | + array( |
|
| 70 | 70 | 'name' => 'date_entered', |
| 71 | 71 | 'vname' => 'LBL_DATE_ENTERED', |
| 72 | 72 | 'type' => 'datetime', |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | 'inline_edit' => false, |
| 78 | 78 | ), |
| 79 | 79 | 'date_modified' => |
| 80 | - array ( |
|
| 80 | + array( |
|
| 81 | 81 | 'name' => 'date_modified', |
| 82 | 82 | 'vname' => 'LBL_DATE_MODIFIED', |
| 83 | 83 | 'type' => 'datetime', |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | 'inline_edit' => false, |
| 89 | 89 | ), |
| 90 | 90 | 'modified_user_id' => |
| 91 | - array ( |
|
| 91 | + array( |
|
| 92 | 92 | 'name' => 'modified_user_id', |
| 93 | 93 | 'rname' => 'user_name', |
| 94 | 94 | 'id_name' => 'modified_user_id', |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | 'inline_edit' => false, |
| 105 | 105 | ), |
| 106 | 106 | 'modified_by_name' => |
| 107 | - array ( |
|
| 107 | + array( |
|
| 108 | 108 | 'name' => 'modified_by_name', |
| 109 | 109 | 'vname' => 'LBL_MODIFIED_NAME', |
| 110 | 110 | 'type' => 'relate', |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | 'inline_edit' => false, |
| 121 | 121 | ), |
| 122 | 122 | 'created_by' => |
| 123 | - array ( |
|
| 123 | + array( |
|
| 124 | 124 | 'name' => 'created_by', |
| 125 | 125 | 'rname' => 'user_name', |
| 126 | 126 | 'id_name' => 'modified_user_id', |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | 'inline_edit' => false, |
| 136 | 136 | ), |
| 137 | 137 | 'created_by_name' => |
| 138 | - array ( |
|
| 138 | + array( |
|
| 139 | 139 | 'name' => 'created_by_name', |
| 140 | 140 | 'vname' => 'LBL_CREATED', |
| 141 | 141 | 'type' => 'relate', |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | 'inline_edit' => false, |
| 153 | 153 | ), |
| 154 | 154 | 'description' => |
| 155 | - array ( |
|
| 155 | + array( |
|
| 156 | 156 | 'name' => 'description', |
| 157 | 157 | 'vname' => 'LBL_DESCRIPTION', |
| 158 | 158 | 'type' => 'text', |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | 'cols' => 80, |
| 162 | 162 | ), |
| 163 | 163 | 'deleted' => |
| 164 | - array ( |
|
| 164 | + array( |
|
| 165 | 165 | 'name' => 'deleted', |
| 166 | 166 | 'vname' => 'LBL_DELETED', |
| 167 | 167 | 'type' => 'bool', |
@@ -172,10 +172,10 @@ discard block |
||
| 172 | 172 | |
| 173 | 173 | /////////////////RELATIONSHIP LINKS//////////////////////////// |
| 174 | 174 | 'created_by_link' => |
| 175 | - array ( |
|
| 175 | + array( |
|
| 176 | 176 | 'name' => 'created_by_link', |
| 177 | 177 | 'type' => 'link', |
| 178 | - 'relationship' => strtolower($module) . '_created_by', |
|
| 178 | + 'relationship' => strtolower($module).'_created_by', |
|
| 179 | 179 | 'vname' => 'LBL_CREATED_USER', |
| 180 | 180 | 'link_type' => 'one', |
| 181 | 181 | 'module'=>'Users', |
@@ -183,10 +183,10 @@ discard block |
||
| 183 | 183 | 'source'=>'non-db', |
| 184 | 184 | ), |
| 185 | 185 | 'modified_user_link' => |
| 186 | - array ( |
|
| 186 | + array( |
|
| 187 | 187 | 'name' => 'modified_user_link', |
| 188 | 188 | 'type' => 'link', |
| 189 | - 'relationship' => strtolower($module). '_modified_user', |
|
| 189 | + 'relationship' => strtolower($module).'_modified_user', |
|
| 190 | 190 | 'vname' => 'LBL_MODIFIED_USER', |
| 191 | 191 | 'link_type' => 'one', |
| 192 | 192 | 'module'=>'Users', |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | ), |
| 196 | 196 | |
| 197 | 197 | ), |
| 198 | -'indices' => array ( |
|
| 198 | +'indices' => array( |
|
| 199 | 199 | 'id'=>array('name' =>strtolower($module).'pk', 'type' =>'primary', 'fields'=>array('id')), |
| 200 | 200 | ), |
| 201 | 201 | 'relationships'=>array( |
@@ -54,7 +54,7 @@ |
||
| 54 | 54 | 'LBL_MODIFIED_USER'=>'Modified by User', |
| 55 | 55 | 'LBL_LIST_NAME'=>'Name', |
| 56 | 56 | 'LBL_EDIT_BUTTON' => 'Edit', |
| 57 | - 'LBL_REMOVE' => 'Remove', |
|
| 57 | + 'LBL_REMOVE' => 'Remove', |
|
| 58 | 58 | |
| 59 | 59 | |
| 60 | 60 | ); |
| 61 | 61 | \ No newline at end of file |
@@ -43,16 +43,16 @@ |
||
| 43 | 43 | /** |
| 44 | 44 | * Constructor |
| 45 | 45 | */ |
| 46 | - public function Basic() |
|
| 47 | - { |
|
| 48 | - parent::SugarBean(); |
|
| 49 | - } |
|
| 46 | + public function Basic() |
|
| 47 | + { |
|
| 48 | + parent::SugarBean(); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @see SugarBean::get_summary_text() |
|
| 53 | - */ |
|
| 54 | - public function get_summary_text() |
|
| 55 | - { |
|
| 56 | - return "$this->name"; |
|
| 57 | - } |
|
| 51 | + /** |
|
| 52 | + * @see SugarBean::get_summary_text() |
|
| 53 | + */ |
|
| 54 | + public function get_summary_text() |
|
| 55 | + { |
|
| 56 | + return "$this->name"; |
|
| 57 | + } |
|
| 58 | 58 | } |
| 59 | 59 | \ No newline at end of file |
@@ -143,10 +143,10 @@ discard block |
||
| 143 | 143 | 'url' => 'nvarchar', |
| 144 | 144 | 'encrypt' => 'nvarchar', |
| 145 | 145 | 'file' => 'nvarchar', |
| 146 | - 'decimal_tpl' => 'decimal(%d, %d)', |
|
| 146 | + 'decimal_tpl' => 'decimal(%d, %d)', |
|
| 147 | 147 | ); |
| 148 | 148 | |
| 149 | - /** |
|
| 149 | + /** |
|
| 150 | 150 | * @see DBManager::connect() |
| 151 | 151 | */ |
| 152 | 152 | public function connect(array $configOptions = null, $dieOnError = false) |
@@ -203,10 +203,10 @@ discard block |
||
| 203 | 203 | return true; |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | - /** |
|
| 206 | + /** |
|
| 207 | 207 | * @see DBManager::query() |
| 208 | - */ |
|
| 209 | - public function query($sql, $dieOnError = false, $msg = '', $suppress = false, $keepResult = false) |
|
| 208 | + */ |
|
| 209 | + public function query($sql, $dieOnError = false, $msg = '', $suppress = false, $keepResult = false) |
|
| 210 | 210 | { |
| 211 | 211 | if(is_array($sql)) { |
| 212 | 212 | return $this->queryArray($sql, $dieOnError, $msg, $suppress); |
@@ -232,15 +232,15 @@ discard block |
||
| 232 | 232 | return $result; |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | - /** |
|
| 235 | + /** |
|
| 236 | 236 | * @see DBManager::getFieldsArray() |
| 237 | 237 | */ |
| 238 | - public function getFieldsArray($result, $make_lower_case = false) |
|
| 239 | - { |
|
| 238 | + public function getFieldsArray($result, $make_lower_case = false) |
|
| 239 | + { |
|
| 240 | 240 | $field_array = array(); |
| 241 | 241 | |
| 242 | 242 | if ( !$result ) { |
| 243 | - return false; |
|
| 243 | + return false; |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | foreach ( sqlsrv_field_metadata($result) as $fieldMetadata ) { |
@@ -252,16 +252,16 @@ discard block |
||
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | return $field_array; |
| 255 | - } |
|
| 255 | + } |
|
| 256 | 256 | |
| 257 | - /** |
|
| 258 | - * @see DBManager::fetchRow() |
|
| 259 | - */ |
|
| 260 | - public function fetchRow($result) |
|
| 261 | - { |
|
| 262 | - if (empty($result)) return false; |
|
| 257 | + /** |
|
| 258 | + * @see DBManager::fetchRow() |
|
| 259 | + */ |
|
| 260 | + public function fetchRow($result) |
|
| 261 | + { |
|
| 262 | + if (empty($result)) return false; |
|
| 263 | 263 | |
| 264 | - $row = sqlsrv_fetch_array($result,SQLSRV_FETCH_ASSOC); |
|
| 264 | + $row = sqlsrv_fetch_array($result,SQLSRV_FETCH_ASSOC); |
|
| 265 | 265 | if (empty($row)) { |
| 266 | 266 | return false; |
| 267 | 267 | } |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | return $row; |
| 280 | - } |
|
| 280 | + } |
|
| 281 | 281 | |
| 282 | 282 | /** |
| 283 | 283 | * @see DBManager::convert() |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | return parent::convert($string, $type, $additional_parameters); |
| 292 | 292 | } |
| 293 | 293 | |
| 294 | - /** |
|
| 294 | + /** |
|
| 295 | 295 | * Compares two vardefs. Overriding 39098 due to bug: 39098 . IN 6.0 we changed the id columns to dbType = 'id' |
| 296 | 296 | * for example emails_beans. In 554 the field email_id was nvarchar but in 6.0 since it id dbType = 'id' we would want to alter |
| 297 | 297 | * it to varchar. This code will prevent it. |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | */ |
| 318 | 318 | public function disconnect() |
| 319 | 319 | { |
| 320 | - $GLOBALS['log']->debug('Calling Mssql::disconnect()'); |
|
| 320 | + $GLOBALS['log']->debug('Calling Mssql::disconnect()'); |
|
| 321 | 321 | if(!empty($this->database)){ |
| 322 | 322 | $this->freeResult(); |
| 323 | 323 | sqlsrv_close($this->database); |
@@ -335,10 +335,10 @@ discard block |
||
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | |
| 338 | - /** |
|
| 339 | - * Detect if no clustered index has been created for a table; if none created then just pick the first index and make it that |
|
| 340 | - * |
|
| 341 | - * @see MssqlHelper::indexSQL() |
|
| 338 | + /** |
|
| 339 | + * Detect if no clustered index has been created for a table; if none created then just pick the first index and make it that |
|
| 340 | + * |
|
| 341 | + * @see MssqlHelper::indexSQL() |
|
| 342 | 342 | */ |
| 343 | 343 | public function getConstraintSql($indices, $table) |
| 344 | 344 | { |
@@ -378,12 +378,12 @@ discard block |
||
| 378 | 378 | $columns[$column_name]['len']=strtolower($row['PRECISION']); |
| 379 | 379 | $columns[$column_name]['len'].=','.strtolower($row['SCALE']); |
| 380 | 380 | } |
| 381 | - elseif ( in_array($row['TYPE_NAME'],array('nchar','nvarchar')) ) { |
|
| 382 | - $columns[$column_name]['len']=strtolower($row['PRECISION']); |
|
| 383 | - if ( $row['TYPE_NAME'] == 'nvarchar' && $row['PRECISION'] == '0' ) { |
|
| 384 | - $columns[$column_name]['len']='max'; |
|
| 385 | - } |
|
| 386 | - } |
|
| 381 | + elseif ( in_array($row['TYPE_NAME'],array('nchar','nvarchar')) ) { |
|
| 382 | + $columns[$column_name]['len']=strtolower($row['PRECISION']); |
|
| 383 | + if ( $row['TYPE_NAME'] == 'nvarchar' && $row['PRECISION'] == '0' ) { |
|
| 384 | + $columns[$column_name]['len']='max'; |
|
| 385 | + } |
|
| 386 | + } |
|
| 387 | 387 | elseif ( !in_array($row['TYPE_NAME'],array('datetime','text')) ) { |
| 388 | 388 | $columns[$column_name]['len']=strtolower($row['LENGTH']); |
| 389 | 389 | } |
@@ -488,21 +488,21 @@ discard block |
||
| 488 | 488 | return "TRUNCATE TABLE $name"; |
| 489 | 489 | } |
| 490 | 490 | |
| 491 | - /** |
|
| 492 | - * (non-PHPdoc) |
|
| 493 | - * @see DBManager::lastDbError() |
|
| 494 | - */ |
|
| 491 | + /** |
|
| 492 | + * (non-PHPdoc) |
|
| 493 | + * @see DBManager::lastDbError() |
|
| 494 | + */ |
|
| 495 | 495 | public function lastDbError() |
| 496 | 496 | { |
| 497 | 497 | $errors = sqlsrv_errors(SQLSRV_ERR_ERRORS); |
| 498 | 498 | if(empty($errors)) return false; |
| 499 | 499 | global $app_strings; |
| 500 | 500 | if (empty($app_strings) |
| 501 | - or !isset($app_strings['ERR_MSSQL_DB_CONTEXT']) |
|
| 502 | - or !isset($app_strings['ERR_MSSQL_WARNING']) ) { |
|
| 501 | + or !isset($app_strings['ERR_MSSQL_DB_CONTEXT']) |
|
| 502 | + or !isset($app_strings['ERR_MSSQL_WARNING']) ) { |
|
| 503 | 503 | //ignore the message from sql-server if $app_strings array is empty. This will happen |
| 504 | 504 | //only if connection if made before languge is set. |
| 505 | - return false; |
|
| 505 | + return false; |
|
| 506 | 506 | } |
| 507 | 507 | $messages = array(); |
| 508 | 508 | foreach($errors as $error) { |
@@ -515,7 +515,7 @@ discard block |
||
| 515 | 515 | } |
| 516 | 516 | $sqlpos = strpos($sqlmsg, $app_strings['ERR_MSSQL_DB_CONTEXT']); |
| 517 | 517 | $sqlpos2 = strpos($sqlmsg, $app_strings['ERR_MSSQL_WARNING']); |
| 518 | - if ( $sqlpos !== false || $sqlpos2 !== false) { |
|
| 518 | + if ( $sqlpos !== false || $sqlpos2 !== false) { |
|
| 519 | 519 | continue; |
| 520 | 520 | } |
| 521 | 521 | $messages[] = $sqlmsg; |
@@ -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. |
@@ -175,14 +175,14 @@ discard block |
||
| 175 | 175 | "ReturnDatesAsStrings" => true, |
| 176 | 176 | "MultipleActiveResultSets" => true, |
| 177 | 177 | ); |
| 178 | - if(!empty($configOptions['db_name'])) { |
|
| 178 | + if (!empty($configOptions['db_name'])) { |
|
| 179 | 179 | $options["Database"] = $configOptions['db_name']; |
| 180 | 180 | } |
| 181 | 181 | $this->database = sqlsrv_connect($connect_param, $options); |
| 182 | - if(empty($this->database)) { |
|
| 182 | + if (empty($this->database)) { |
|
| 183 | 183 | $GLOBALS['log']->fatal("Could not connect to server ".$configOptions['db_host_name']." as ".$configOptions['db_user_name']."."); |
| 184 | - if($dieOnError) { |
|
| 185 | - if(isset($GLOBALS['app_strings']['ERR_NO_DB'])) { |
|
| 184 | + if ($dieOnError) { |
|
| 185 | + if (isset($GLOBALS['app_strings']['ERR_NO_DB'])) { |
|
| 186 | 186 | sugar_die($GLOBALS['app_strings']['ERR_NO_DB']); |
| 187 | 187 | } else { |
| 188 | 188 | sugar_die("Could not connect to the database. Please refer to suitecrm.log for details."); |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | } |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - if($this->checkError('Could Not Connect:', $dieOnError)) |
|
| 195 | + if ($this->checkError('Could Not Connect:', $dieOnError)) |
|
| 196 | 196 | $GLOBALS['log']->info("connected to db"); |
| 197 | 197 | |
| 198 | 198 | sqlsrv_query($this->database, 'SET DATEFORMAT mdy'); |
@@ -208,26 +208,26 @@ discard block |
||
| 208 | 208 | */ |
| 209 | 209 | public function query($sql, $dieOnError = false, $msg = '', $suppress = false, $keepResult = false) |
| 210 | 210 | { |
| 211 | - if(is_array($sql)) { |
|
| 211 | + if (is_array($sql)) { |
|
| 212 | 212 | return $this->queryArray($sql, $dieOnError, $msg, $suppress); |
| 213 | 213 | } |
| 214 | 214 | $sql = $this->_appendN($sql); |
| 215 | 215 | |
| 216 | 216 | $this->countQuery($sql); |
| 217 | - $GLOBALS['log']->info('Query:' . $sql); |
|
| 217 | + $GLOBALS['log']->info('Query:'.$sql); |
|
| 218 | 218 | $this->checkConnection(); |
| 219 | 219 | $this->query_time = microtime(true); |
| 220 | 220 | |
| 221 | - $result = $suppress?@sqlsrv_query($this->database, $sql):sqlsrv_query($this->database, $sql); |
|
| 221 | + $result = $suppress ? @sqlsrv_query($this->database, $sql) : sqlsrv_query($this->database, $sql); |
|
| 222 | 222 | |
| 223 | 223 | $this->query_time = microtime(true) - $this->query_time; |
| 224 | 224 | $GLOBALS['log']->info('Query Execution Time:'.$this->query_time); |
| 225 | 225 | |
| 226 | 226 | |
| 227 | - $this->checkError($msg.' Query Failed:' . $sql . '::', $dieOnError); |
|
| 227 | + $this->checkError($msg.' Query Failed:'.$sql.'::', $dieOnError); |
|
| 228 | 228 | |
| 229 | 229 | //suppress non error messages |
| 230 | - sqlsrv_configure('WarningsReturnAsErrors',false); |
|
| 230 | + sqlsrv_configure('WarningsReturnAsErrors', false); |
|
| 231 | 231 | |
| 232 | 232 | return $result; |
| 233 | 233 | } |
@@ -239,13 +239,13 @@ discard block |
||
| 239 | 239 | { |
| 240 | 240 | $field_array = array(); |
| 241 | 241 | |
| 242 | - if ( !$result ) { |
|
| 242 | + if (!$result) { |
|
| 243 | 243 | return false; |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - foreach ( sqlsrv_field_metadata($result) as $fieldMetadata ) { |
|
| 246 | + foreach (sqlsrv_field_metadata($result) as $fieldMetadata) { |
|
| 247 | 247 | $key = $fieldMetadata['Name']; |
| 248 | - if($make_lower_case==true) |
|
| 248 | + if ($make_lower_case == true) |
|
| 249 | 249 | $key = strtolower($key); |
| 250 | 250 | |
| 251 | 251 | $field_array[] = $key; |
@@ -261,12 +261,12 @@ discard block |
||
| 261 | 261 | { |
| 262 | 262 | if (empty($result)) return false; |
| 263 | 263 | |
| 264 | - $row = sqlsrv_fetch_array($result,SQLSRV_FETCH_ASSOC); |
|
| 264 | + $row = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC); |
|
| 265 | 265 | if (empty($row)) { |
| 266 | 266 | return false; |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - foreach($row as $key => $column) { |
|
| 269 | + foreach ($row as $key => $column) { |
|
| 270 | 270 | // MSSQL returns a space " " when a varchar column is empty ("") and not null. |
| 271 | 271 | // We need to strip empty spaces |
| 272 | 272 | // notice we only strip if one space is returned. we do not want to strip |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | */ |
| 285 | 285 | public function convert($string, $type, array $additional_parameters = array()) |
| 286 | 286 | { |
| 287 | - if ( $type == 'datetime') |
|
| 287 | + if ($type == 'datetime') |
|
| 288 | 288 | // see http://msdn.microsoft.com/en-us/library/ms187928.aspx for details |
| 289 | 289 | return "CONVERT(datetime,$string,120)"; |
| 290 | 290 | else |
@@ -300,10 +300,10 @@ discard block |
||
| 300 | 300 | * @param array $fielddef2 |
| 301 | 301 | * @return bool true if they match, false if they don't |
| 302 | 302 | */ |
| 303 | - public function compareVarDefs($fielddef1,$fielddef2, $ignoreName = false) |
|
| 303 | + public function compareVarDefs($fielddef1, $fielddef2, $ignoreName = false) |
|
| 304 | 304 | { |
| 305 | - if((isset($fielddef2['dbType']) && $fielddef2['dbType'] == 'id') || preg_match('/(_id$|^id$)/', $fielddef2['name'])){ |
|
| 306 | - if(isset($fielddef1['type']) && isset($fielddef2['type'])){ |
|
| 305 | + if ((isset($fielddef2['dbType']) && $fielddef2['dbType'] == 'id') || preg_match('/(_id$|^id$)/', $fielddef2['name'])) { |
|
| 306 | + if (isset($fielddef1['type']) && isset($fielddef2['type'])) { |
|
| 307 | 307 | $fielddef2['type'] = $fielddef1['type']; |
| 308 | 308 | } |
| 309 | 309 | } |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | public function disconnect() |
| 319 | 319 | { |
| 320 | 320 | $GLOBALS['log']->debug('Calling Mssql::disconnect()'); |
| 321 | - if(!empty($this->database)){ |
|
| 321 | + if (!empty($this->database)) { |
|
| 322 | 322 | $this->freeResult(); |
| 323 | 323 | sqlsrv_close($this->database); |
| 324 | 324 | $this->database = null; |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | */ |
| 331 | 331 | protected function freeDbResult($dbResult) |
| 332 | 332 | { |
| 333 | - if(!empty($dbResult)) |
|
| 333 | + if (!empty($dbResult)) |
|
| 334 | 334 | sqlsrv_free_stmt($dbResult); |
| 335 | 335 | } |
| 336 | 336 | |
@@ -342,19 +342,19 @@ discard block |
||
| 342 | 342 | */ |
| 343 | 343 | public function getConstraintSql($indices, $table) |
| 344 | 344 | { |
| 345 | - if ( $this->doesTableHaveAClusteredIndexDefined($table) ) { |
|
| 345 | + if ($this->doesTableHaveAClusteredIndexDefined($table)) { |
|
| 346 | 346 | return parent::getConstraintSql($indices, $table); |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | // check to see if one of the passed in indices is a primary one; if so we can bail as well |
| 350 | - foreach ( $indices as $index ) { |
|
| 351 | - if ( $index['type'] == 'primary' ) { |
|
| 350 | + foreach ($indices as $index) { |
|
| 351 | + if ($index['type'] == 'primary') { |
|
| 352 | 352 | return parent::getConstraintSql($indices, $table); |
| 353 | 353 | } |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | // Change the first index listed to be a clustered one instead ( so we have at least one for the table ) |
| 357 | - if ( isset($indices[0]) ) { |
|
| 357 | + if (isset($indices[0])) { |
|
| 358 | 358 | $indices[0]['type'] = 'clustered'; |
| 359 | 359 | } |
| 360 | 360 | |
@@ -370,41 +370,41 @@ discard block |
||
| 370 | 370 | $result = $this->query("sp_columns_90 $tablename"); |
| 371 | 371 | |
| 372 | 372 | $columns = array(); |
| 373 | - while (($row=$this->fetchByAssoc($result)) !=null) { |
|
| 373 | + while (($row = $this->fetchByAssoc($result)) != null) { |
|
| 374 | 374 | $column_name = strtolower($row['COLUMN_NAME']); |
| 375 | - $columns[$column_name]['name']=$column_name; |
|
| 376 | - $columns[$column_name]['type']=strtolower($row['TYPE_NAME']); |
|
| 377 | - if ( $row['TYPE_NAME'] == 'decimal' ) { |
|
| 378 | - $columns[$column_name]['len']=strtolower($row['PRECISION']); |
|
| 379 | - $columns[$column_name]['len'].=','.strtolower($row['SCALE']); |
|
| 375 | + $columns[$column_name]['name'] = $column_name; |
|
| 376 | + $columns[$column_name]['type'] = strtolower($row['TYPE_NAME']); |
|
| 377 | + if ($row['TYPE_NAME'] == 'decimal') { |
|
| 378 | + $columns[$column_name]['len'] = strtolower($row['PRECISION']); |
|
| 379 | + $columns[$column_name]['len'] .= ','.strtolower($row['SCALE']); |
|
| 380 | 380 | } |
| 381 | - elseif ( in_array($row['TYPE_NAME'],array('nchar','nvarchar')) ) { |
|
| 382 | - $columns[$column_name]['len']=strtolower($row['PRECISION']); |
|
| 383 | - if ( $row['TYPE_NAME'] == 'nvarchar' && $row['PRECISION'] == '0' ) { |
|
| 384 | - $columns[$column_name]['len']='max'; |
|
| 381 | + elseif (in_array($row['TYPE_NAME'], array('nchar', 'nvarchar'))) { |
|
| 382 | + $columns[$column_name]['len'] = strtolower($row['PRECISION']); |
|
| 383 | + if ($row['TYPE_NAME'] == 'nvarchar' && $row['PRECISION'] == '0') { |
|
| 384 | + $columns[$column_name]['len'] = 'max'; |
|
| 385 | 385 | } |
| 386 | 386 | } |
| 387 | - elseif ( !in_array($row['TYPE_NAME'],array('datetime','text')) ) { |
|
| 388 | - $columns[$column_name]['len']=strtolower($row['LENGTH']); |
|
| 387 | + elseif (!in_array($row['TYPE_NAME'], array('datetime', 'text'))) { |
|
| 388 | + $columns[$column_name]['len'] = strtolower($row['LENGTH']); |
|
| 389 | 389 | } |
| 390 | - if ( stristr($row['TYPE_NAME'],'identity') ) { |
|
| 390 | + if (stristr($row['TYPE_NAME'], 'identity')) { |
|
| 391 | 391 | $columns[$column_name]['auto_increment'] = '1'; |
| 392 | - $columns[$column_name]['type']=str_replace(' identity','',strtolower($row['TYPE_NAME'])); |
|
| 392 | + $columns[$column_name]['type'] = str_replace(' identity', '', strtolower($row['TYPE_NAME'])); |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | - if (!empty($row['IS_NULLABLE']) && $row['IS_NULLABLE'] == 'NO' && (empty($row['KEY']) || !stristr($row['KEY'],'PRI'))) |
|
| 395 | + if (!empty($row['IS_NULLABLE']) && $row['IS_NULLABLE'] == 'NO' && (empty($row['KEY']) || !stristr($row['KEY'], 'PRI'))) |
|
| 396 | 396 | $columns[strtolower($row['COLUMN_NAME'])]['required'] = 'true'; |
| 397 | 397 | |
| 398 | 398 | $column_def = 1; |
| 399 | - if ( strtolower($tablename) == 'relationships' ) { |
|
| 399 | + if (strtolower($tablename) == 'relationships') { |
|
| 400 | 400 | $column_def = $this->getOne("select cdefault from syscolumns where id = object_id('relationships') and name = '$column_name'"); |
| 401 | 401 | } |
| 402 | - if ( $column_def != 0 && ($row['COLUMN_DEF'] != null)) { // NOTE Not using !empty as an empty string may be a viable default value. |
|
| 402 | + if ($column_def != 0 && ($row['COLUMN_DEF'] != null)) { // NOTE Not using !empty as an empty string may be a viable default value. |
|
| 403 | 403 | $matches = array(); |
| 404 | - $row['COLUMN_DEF'] = html_entity_decode($row['COLUMN_DEF'],ENT_QUOTES); |
|
| 405 | - if ( preg_match('/\([\(|\'](.*)[\)|\']\)/i',$row['COLUMN_DEF'],$matches) ) |
|
| 404 | + $row['COLUMN_DEF'] = html_entity_decode($row['COLUMN_DEF'], ENT_QUOTES); |
|
| 405 | + if (preg_match('/\([\(|\'](.*)[\)|\']\)/i', $row['COLUMN_DEF'], $matches)) |
|
| 406 | 406 | $columns[$column_name]['default'] = $matches[1]; |
| 407 | - elseif ( preg_match('/\(N\'(.*)\'\)/i',$row['COLUMN_DEF'],$matches) ) |
|
| 407 | + elseif (preg_match('/\(N\'(.*)\'\)/i', $row['COLUMN_DEF'], $matches)) |
|
| 408 | 408 | $columns[$column_name]['default'] = $matches[1]; |
| 409 | 409 | else |
| 410 | 410 | $columns[$column_name]['default'] = $row['COLUMN_DEF']; |
@@ -430,7 +430,7 @@ discard block |
||
| 430 | 430 | EOSQL; |
| 431 | 431 | |
| 432 | 432 | $result = $this->getOne($query); |
| 433 | - if ( !$result ) { |
|
| 433 | + if (!$result) { |
|
| 434 | 434 | return false; |
| 435 | 435 | } |
| 436 | 436 | |
@@ -453,7 +453,7 @@ discard block |
||
| 453 | 453 | EOSQL; |
| 454 | 454 | |
| 455 | 455 | $result = $this->getOne($query); |
| 456 | - if ( !$result ) { |
|
| 456 | + if (!$result) { |
|
| 457 | 457 | return false; |
| 458 | 458 | } |
| 459 | 459 | |
@@ -466,10 +466,10 @@ discard block |
||
| 466 | 466 | * @see DBManager::changeColumnSQL() |
| 467 | 467 | * @see MssqlHelper::changeColumnSQL() |
| 468 | 468 | */ |
| 469 | - protected function changeColumnSQL($tablename,$fieldDefs, $action, $ignoreRequired = false) |
|
| 469 | + protected function changeColumnSQL($tablename, $fieldDefs, $action, $ignoreRequired = false) |
|
| 470 | 470 | { |
| 471 | 471 | $sql = ''; |
| 472 | - if ( $action == 'drop' && $this->doesTableHaveAFulltextIndexDefined($tablename) ) { |
|
| 472 | + if ($action == 'drop' && $this->doesTableHaveAFulltextIndexDefined($tablename)) { |
|
| 473 | 473 | $sql .= "DROP FULLTEXT INDEX ON {$tablename}"; |
| 474 | 474 | } |
| 475 | 475 | |
@@ -495,33 +495,33 @@ discard block |
||
| 495 | 495 | public function lastDbError() |
| 496 | 496 | { |
| 497 | 497 | $errors = sqlsrv_errors(SQLSRV_ERR_ERRORS); |
| 498 | - if(empty($errors)) return false; |
|
| 498 | + if (empty($errors)) return false; |
|
| 499 | 499 | global $app_strings; |
| 500 | 500 | if (empty($app_strings) |
| 501 | 501 | or !isset($app_strings['ERR_MSSQL_DB_CONTEXT']) |
| 502 | - or !isset($app_strings['ERR_MSSQL_WARNING']) ) { |
|
| 502 | + or !isset($app_strings['ERR_MSSQL_WARNING'])) { |
|
| 503 | 503 | //ignore the message from sql-server if $app_strings array is empty. This will happen |
| 504 | 504 | //only if connection if made before languge is set. |
| 505 | 505 | return false; |
| 506 | 506 | } |
| 507 | 507 | $messages = array(); |
| 508 | - foreach($errors as $error) { |
|
| 508 | + foreach ($errors as $error) { |
|
| 509 | 509 | $sqlmsg = $error['message']; |
| 510 | 510 | $sqlpos = strpos($sqlmsg, 'Changed database context to'); |
| 511 | 511 | $sqlpos2 = strpos($sqlmsg, 'Warning:'); |
| 512 | 512 | $sqlpos3 = strpos($sqlmsg, 'Checking identity information:'); |
| 513 | - if ( $sqlpos !== false || $sqlpos2 !== false || $sqlpos3 !== false ) { |
|
| 513 | + if ($sqlpos !== false || $sqlpos2 !== false || $sqlpos3 !== false) { |
|
| 514 | 514 | continue; |
| 515 | 515 | } |
| 516 | 516 | $sqlpos = strpos($sqlmsg, $app_strings['ERR_MSSQL_DB_CONTEXT']); |
| 517 | 517 | $sqlpos2 = strpos($sqlmsg, $app_strings['ERR_MSSQL_WARNING']); |
| 518 | - if ( $sqlpos !== false || $sqlpos2 !== false) { |
|
| 518 | + if ($sqlpos !== false || $sqlpos2 !== false) { |
|
| 519 | 519 | continue; |
| 520 | 520 | } |
| 521 | 521 | $messages[] = $sqlmsg; |
| 522 | 522 | } |
| 523 | 523 | |
| 524 | - if(!empty($messages)) { |
|
| 524 | + if (!empty($messages)) { |
|
| 525 | 525 | return join("\n", $messages); |
| 526 | 526 | } |
| 527 | 527 | return false; |
@@ -548,7 +548,7 @@ discard block |
||
| 548 | 548 | protected function verifyGenericQueryRollback($type, $table, $query) |
| 549 | 549 | { |
| 550 | 550 | $this->log->debug("verifying $type statement"); |
| 551 | - if(!sqlsrv_begin_transaction($this->database)) { |
|
| 551 | + if (!sqlsrv_begin_transaction($this->database)) { |
|
| 552 | 552 | return "Failed to create transaction"; |
| 553 | 553 | } |
| 554 | 554 | $this->query($query, false); |
@@ -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. |
@@ -153,16 +155,18 @@ discard block |
||
| 153 | 155 | { |
| 154 | 156 | global $sugar_config; |
| 155 | 157 | |
| 156 | - if (is_null($configOptions)) |
|
| 157 | - $configOptions = $sugar_config['dbconfig']; |
|
| 158 | + if (is_null($configOptions)) { |
|
| 159 | + $configOptions = $sugar_config['dbconfig']; |
|
| 160 | + } |
|
| 158 | 161 | |
| 159 | 162 | //set the connections parameters |
| 160 | 163 | $connect_param = ''; |
| 161 | 164 | $configOptions['db_host_instance'] = trim($configOptions['db_host_instance']); |
| 162 | - if (empty($configOptions['db_host_instance'])) |
|
| 163 | - $connect_param = $configOptions['db_host_name']; |
|
| 164 | - else |
|
| 165 | - $connect_param = $configOptions['db_host_name']."\\".$configOptions['db_host_instance']; |
|
| 165 | + if (empty($configOptions['db_host_instance'])) { |
|
| 166 | + $connect_param = $configOptions['db_host_name']; |
|
| 167 | + } else { |
|
| 168 | + $connect_param = $configOptions['db_host_name']."\\".$configOptions['db_host_instance']; |
|
| 169 | + } |
|
| 166 | 170 | |
| 167 | 171 | /* |
| 168 | 172 | * Don't try to specifically use a persistent connection |
@@ -192,8 +196,9 @@ discard block |
||
| 192 | 196 | } |
| 193 | 197 | } |
| 194 | 198 | |
| 195 | - if($this->checkError('Could Not Connect:', $dieOnError)) |
|
| 196 | - $GLOBALS['log']->info("connected to db"); |
|
| 199 | + if($this->checkError('Could Not Connect:', $dieOnError)) { |
|
| 200 | + $GLOBALS['log']->info("connected to db"); |
|
| 201 | + } |
|
| 197 | 202 | |
| 198 | 203 | sqlsrv_query($this->database, 'SET DATEFORMAT mdy'); |
| 199 | 204 | |
@@ -245,8 +250,9 @@ discard block |
||
| 245 | 250 | |
| 246 | 251 | foreach ( sqlsrv_field_metadata($result) as $fieldMetadata ) { |
| 247 | 252 | $key = $fieldMetadata['Name']; |
| 248 | - if($make_lower_case==true) |
|
| 249 | - $key = strtolower($key); |
|
| 253 | + if($make_lower_case==true) { |
|
| 254 | + $key = strtolower($key); |
|
| 255 | + } |
|
| 250 | 256 | |
| 251 | 257 | $field_array[] = $key; |
| 252 | 258 | } |
@@ -259,7 +265,9 @@ discard block |
||
| 259 | 265 | */ |
| 260 | 266 | public function fetchRow($result) |
| 261 | 267 | { |
| 262 | - if (empty($result)) return false; |
|
| 268 | + if (empty($result)) { |
|
| 269 | + return false; |
|
| 270 | + } |
|
| 263 | 271 | |
| 264 | 272 | $row = sqlsrv_fetch_array($result,SQLSRV_FETCH_ASSOC); |
| 265 | 273 | if (empty($row)) { |
@@ -284,11 +292,12 @@ discard block |
||
| 284 | 292 | */ |
| 285 | 293 | public function convert($string, $type, array $additional_parameters = array()) |
| 286 | 294 | { |
| 287 | - if ( $type == 'datetime') |
|
| 288 | - // see http://msdn.microsoft.com/en-us/library/ms187928.aspx for details |
|
| 295 | + if ( $type == 'datetime') { |
|
| 296 | + // see http://msdn.microsoft.com/en-us/library/ms187928.aspx for details |
|
| 289 | 297 | return "CONVERT(datetime,$string,120)"; |
| 290 | - else |
|
| 291 | - return parent::convert($string, $type, $additional_parameters); |
|
| 298 | + } else { |
|
| 299 | + return parent::convert($string, $type, $additional_parameters); |
|
| 300 | + } |
|
| 292 | 301 | } |
| 293 | 302 | |
| 294 | 303 | /** |
@@ -330,8 +339,9 @@ discard block |
||
| 330 | 339 | */ |
| 331 | 340 | protected function freeDbResult($dbResult) |
| 332 | 341 | { |
| 333 | - if(!empty($dbResult)) |
|
| 334 | - sqlsrv_free_stmt($dbResult); |
|
| 342 | + if(!empty($dbResult)) { |
|
| 343 | + sqlsrv_free_stmt($dbResult); |
|
| 344 | + } |
|
| 335 | 345 | } |
| 336 | 346 | |
| 337 | 347 | |
@@ -377,14 +387,12 @@ discard block |
||
| 377 | 387 | if ( $row['TYPE_NAME'] == 'decimal' ) { |
| 378 | 388 | $columns[$column_name]['len']=strtolower($row['PRECISION']); |
| 379 | 389 | $columns[$column_name]['len'].=','.strtolower($row['SCALE']); |
| 380 | - } |
|
| 381 | - elseif ( in_array($row['TYPE_NAME'],array('nchar','nvarchar')) ) { |
|
| 390 | + } elseif ( in_array($row['TYPE_NAME'],array('nchar','nvarchar')) ) { |
|
| 382 | 391 | $columns[$column_name]['len']=strtolower($row['PRECISION']); |
| 383 | 392 | if ( $row['TYPE_NAME'] == 'nvarchar' && $row['PRECISION'] == '0' ) { |
| 384 | 393 | $columns[$column_name]['len']='max'; |
| 385 | 394 | } |
| 386 | - } |
|
| 387 | - elseif ( !in_array($row['TYPE_NAME'],array('datetime','text')) ) { |
|
| 395 | + } elseif ( !in_array($row['TYPE_NAME'],array('datetime','text')) ) { |
|
| 388 | 396 | $columns[$column_name]['len']=strtolower($row['LENGTH']); |
| 389 | 397 | } |
| 390 | 398 | if ( stristr($row['TYPE_NAME'],'identity') ) { |
@@ -392,8 +400,9 @@ discard block |
||
| 392 | 400 | $columns[$column_name]['type']=str_replace(' identity','',strtolower($row['TYPE_NAME'])); |
| 393 | 401 | } |
| 394 | 402 | |
| 395 | - if (!empty($row['IS_NULLABLE']) && $row['IS_NULLABLE'] == 'NO' && (empty($row['KEY']) || !stristr($row['KEY'],'PRI'))) |
|
| 396 | - $columns[strtolower($row['COLUMN_NAME'])]['required'] = 'true'; |
|
| 403 | + if (!empty($row['IS_NULLABLE']) && $row['IS_NULLABLE'] == 'NO' && (empty($row['KEY']) || !stristr($row['KEY'],'PRI'))) { |
|
| 404 | + $columns[strtolower($row['COLUMN_NAME'])]['required'] = 'true'; |
|
| 405 | + } |
|
| 397 | 406 | |
| 398 | 407 | $column_def = 1; |
| 399 | 408 | if ( strtolower($tablename) == 'relationships' ) { |
@@ -402,12 +411,13 @@ discard block |
||
| 402 | 411 | if ( $column_def != 0 && ($row['COLUMN_DEF'] != null)) { // NOTE Not using !empty as an empty string may be a viable default value. |
| 403 | 412 | $matches = array(); |
| 404 | 413 | $row['COLUMN_DEF'] = html_entity_decode($row['COLUMN_DEF'],ENT_QUOTES); |
| 405 | - if ( preg_match('/\([\(|\'](.*)[\)|\']\)/i',$row['COLUMN_DEF'],$matches) ) |
|
| 406 | - $columns[$column_name]['default'] = $matches[1]; |
|
| 407 | - elseif ( preg_match('/\(N\'(.*)\'\)/i',$row['COLUMN_DEF'],$matches) ) |
|
| 408 | - $columns[$column_name]['default'] = $matches[1]; |
|
| 409 | - else |
|
| 410 | - $columns[$column_name]['default'] = $row['COLUMN_DEF']; |
|
| 414 | + if ( preg_match('/\([\(|\'](.*)[\)|\']\)/i',$row['COLUMN_DEF'],$matches) ) { |
|
| 415 | + $columns[$column_name]['default'] = $matches[1]; |
|
| 416 | + } elseif ( preg_match('/\(N\'(.*)\'\)/i',$row['COLUMN_DEF'],$matches) ) { |
|
| 417 | + $columns[$column_name]['default'] = $matches[1]; |
|
| 418 | + } else { |
|
| 419 | + $columns[$column_name]['default'] = $row['COLUMN_DEF']; |
|
| 420 | + } |
|
| 411 | 421 | } |
| 412 | 422 | } |
| 413 | 423 | return $columns; |
@@ -495,7 +505,9 @@ discard block |
||
| 495 | 505 | public function lastDbError() |
| 496 | 506 | { |
| 497 | 507 | $errors = sqlsrv_errors(SQLSRV_ERR_ERRORS); |
| 498 | - if(empty($errors)) return false; |
|
| 508 | + if(empty($errors)) { |
|
| 509 | + return false; |
|
| 510 | + } |
|
| 499 | 511 | global $app_strings; |
| 500 | 512 | if (empty($app_strings) |
| 501 | 513 | or !isset($app_strings['ERR_MSSQL_DB_CONTEXT']) |
@@ -540,7 +540,7 @@ |
||
| 540 | 540 | |
| 541 | 541 | /** |
| 542 | 542 | * Execute data manipulation statement, then roll it back |
| 543 | - * @param $type |
|
| 543 | + * @param string $type |
|
| 544 | 544 | * @param $table |
| 545 | 545 | * @param $query |
| 546 | 546 | * @return string |