@@ -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. |
@@ -65,18 +67,24 @@ discard block |
||
| 65 | 67 | } |
| 66 | 68 | |
| 67 | 69 | $additionalFormFields = array(); |
| 68 | - if(isset($defines['focus']->billing_address_street)) |
|
| 69 | - $additionalFormFields['primary_address_street'] = $defines['focus']->billing_address_street; |
|
| 70 | - if(isset($defines['focus']->billing_address_city)) |
|
| 71 | - $additionalFormFields['primary_address_city'] = $defines['focus']->billing_address_city; |
|
| 72 | - if(isset($defines['focus']->billing_address_state)) |
|
| 73 | - $additionalFormFields['primary_address_state'] = $defines['focus']->billing_address_state; |
|
| 74 | - if(isset($defines['focus']->billing_address_country)) |
|
| 75 | - $additionalFormFields['primary_address_country'] = $defines['focus']->billing_address_country; |
|
| 76 | - if(isset($defines['focus']->billing_address_postalcode)) |
|
| 77 | - $additionalFormFields['primary_address_postalcode'] = $defines['focus']->billing_address_postalcode; |
|
| 78 | - if(isset($defines['focus']->phone_office)) |
|
| 79 | - $additionalFormFields['phone_work'] = $defines['focus']->phone_office; |
|
| 70 | + if(isset($defines['focus']->billing_address_street)) { |
|
| 71 | + $additionalFormFields['primary_address_street'] = $defines['focus']->billing_address_street; |
|
| 72 | + } |
|
| 73 | + if(isset($defines['focus']->billing_address_city)) { |
|
| 74 | + $additionalFormFields['primary_address_city'] = $defines['focus']->billing_address_city; |
|
| 75 | + } |
|
| 76 | + if(isset($defines['focus']->billing_address_state)) { |
|
| 77 | + $additionalFormFields['primary_address_state'] = $defines['focus']->billing_address_state; |
|
| 78 | + } |
|
| 79 | + if(isset($defines['focus']->billing_address_country)) { |
|
| 80 | + $additionalFormFields['primary_address_country'] = $defines['focus']->billing_address_country; |
|
| 81 | + } |
|
| 82 | + if(isset($defines['focus']->billing_address_postalcode)) { |
|
| 83 | + $additionalFormFields['primary_address_postalcode'] = $defines['focus']->billing_address_postalcode; |
|
| 84 | + } |
|
| 85 | + if(isset($defines['focus']->phone_office)) { |
|
| 86 | + $additionalFormFields['phone_work'] = $defines['focus']->phone_office; |
|
| 87 | + } |
|
| 80 | 88 | |
| 81 | 89 | |
| 82 | 90 | $button = $this->_get_form($defines, $additionalFormFields); |
@@ -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. |
@@ -111,7 +113,7 @@ discard block |
||
| 111 | 113 | if($layout_def['ListView']) { |
| 112 | 114 | return "<a href=\"javascript:sub_p_rem('$subpanel', '$linked_field'" .", '$record', $refresh_page);\"" |
| 113 | 115 | . ' class="listViewTdToolsS1"' . " onclick=\"return sp_rem_conf();\"" . ">$icon_remove_text</a>"; |
| 114 | - }else{ |
|
| 116 | + } else{ |
|
| 115 | 117 | return ''; |
| 116 | 118 | } |
| 117 | 119 | } |
@@ -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. |
@@ -59,8 +61,7 @@ discard block |
||
| 59 | 61 | if(isset($layout_def['varname'])) |
| 60 | 62 | { |
| 61 | 63 | $key = strtoupper($layout_def['varname']); |
| 62 | - } |
|
| 63 | - else |
|
| 64 | + } else |
|
| 64 | 65 | { |
| 65 | 66 | $key = $this->_get_column_alias($layout_def); |
| 66 | 67 | $key = strtoupper($key); |
@@ -77,8 +78,7 @@ discard block |
||
| 77 | 78 | if(empty($layout_def['target_module'])) |
| 78 | 79 | { |
| 79 | 80 | $module = $layout_def['module']; |
| 80 | - } |
|
| 81 | - else |
|
| 81 | + } else |
|
| 82 | 82 | { |
| 83 | 83 | $module = $layout_def['target_module']; |
| 84 | 84 | } |
@@ -87,8 +87,7 @@ discard block |
||
| 87 | 87 | if(empty($layout_def['target_record_key'])) |
| 88 | 88 | { |
| 89 | 89 | $record = $layout_def['fields']['ID']; |
| 90 | - } |
|
| 91 | - else |
|
| 90 | + } else |
|
| 92 | 91 | { |
| 93 | 92 | $record_key = strtoupper($layout_def['target_record_key']); |
| 94 | 93 | $record = $layout_def['fields'][$record_key]; |
@@ -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. |
@@ -106,8 +108,9 @@ discard block |
||
| 106 | 108 | |
| 107 | 109 | $icon_remove_text = mb_strtolower($app_strings['LBL_ID_FF_REMOVE'], 'UTF-8'); |
| 108 | 110 | |
| 109 | - if($linked_field == 'get_emails_by_assign_or_link') |
|
| 110 | - $linked_field = 'emails'; |
|
| 111 | + if($linked_field == 'get_emails_by_assign_or_link') { |
|
| 112 | + $linked_field = 'emails'; |
|
| 113 | + } |
|
| 111 | 114 | //based on listview since that lets you select records |
| 112 | 115 | if($layout_def['ListView'] && !$hideremove) { |
| 113 | 116 | $retStr = "<a href=\"javascript:sub_p_rem('$subpanel', '$linked_field'" |
@@ -118,7 +121,7 @@ discard block |
||
| 118 | 121 | . ">$icon_remove_text</a>"; |
| 119 | 122 | return $retStr; |
| 120 | 123 | |
| 121 | - }else{ |
|
| 124 | + } else{ |
|
| 122 | 125 | return ''; |
| 123 | 126 | } |
| 124 | 127 | } |
@@ -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' ) { |
@@ -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 | |
@@ -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 | } |
@@ -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 ; |
@@ -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']) |