@@ -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. |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | global $app_list_strings; |
57 | 57 | global $current_user; |
58 | 58 | |
59 | - if(isset($layout_def['varname'])) |
|
59 | + if (isset($layout_def['varname'])) |
|
60 | 60 | { |
61 | 61 | $key = strtoupper($layout_def['varname']); |
62 | 62 | } |
@@ -67,14 +67,14 @@ discard block |
||
67 | 67 | } |
68 | 68 | //add module image |
69 | 69 | //add module image |
70 | - if(!empty($layout_def['target_module_key'])) { |
|
70 | + if (!empty($layout_def['target_module_key'])) { |
|
71 | 71 | if (!empty($layout_def['fields'][strtoupper($layout_def['target_module_key'])])) { |
72 | - $module=$layout_def['fields'][strtoupper($layout_def['target_module_key'])]; |
|
72 | + $module = $layout_def['fields'][strtoupper($layout_def['target_module_key'])]; |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
76 | 76 | if (empty($module)) { |
77 | - if(empty($layout_def['target_module'])) |
|
77 | + if (empty($layout_def['target_module'])) |
|
78 | 78 | { |
79 | 79 | $module = $layout_def['module']; |
80 | 80 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | } |
85 | 85 | } |
86 | 86 | $action = 'DetailView'; |
87 | - if(empty($layout_def['target_record_key'])) |
|
87 | + if (empty($layout_def['target_record_key'])) |
|
88 | 88 | { |
89 | 89 | $record = $layout_def['fields']['ID']; |
90 | 90 | } |
@@ -94,70 +94,70 @@ discard block |
||
94 | 94 | $record = $layout_def['fields'][$record_key]; |
95 | 95 | } |
96 | 96 | $action_access = false; |
97 | - if(!empty($record) && |
|
97 | + if (!empty($record) && |
|
98 | 98 | ($layout_def[$action] && !$layout_def['owner_module'] |
99 | 99 | || $layout_def[$action] && !ACLController::moduleSupportsACL($layout_def['owner_module']) |
100 | 100 | || ACLController::checkAccess($layout_def['owner_module'], 'view', $layout_def['owner_id'] == $current_user->id))) { |
101 | 101 | $action_access = true; |
102 | 102 | } |
103 | - $icon_img_html = SugarThemeRegistry::current()->getImage( $module . '', 'border="0"',null,null,'.gif',$app_list_strings['moduleList'][$module]); |
|
103 | + $icon_img_html = SugarThemeRegistry::current()->getImage($module.'', 'border="0"', null, null, '.gif', $app_list_strings['moduleList'][$module]); |
|
104 | 104 | if (!empty($layout_def['attachment_image_only']) && $layout_def['attachment_image_only'] == true) { |
105 | - $ret=""; |
|
105 | + $ret = ""; |
|
106 | 106 | } else { |
107 | 107 | if ($action_access) { |
108 | - $ret = '<a href="index.php?module=' . $module . '&action=' . $action . '&record=' . $record . '" >' . $icon_img_html . "</a>"; |
|
108 | + $ret = '<a href="index.php?module='.$module.'&action='.$action.'&record='.$record.'" >'.$icon_img_html."</a>"; |
|
109 | 109 | } else { |
110 | 110 | $ret = $icon_img_html; |
111 | 111 | } |
112 | 112 | } |
113 | 113 | |
114 | - if(!empty($layout_def['image2']) && !empty($layout_def['image2_ext_url_field'])){ |
|
114 | + if (!empty($layout_def['image2']) && !empty($layout_def['image2_ext_url_field'])) { |
|
115 | 115 | |
116 | 116 | if (!empty($layout_def['fields'][strtoupper($layout_def['image2_ext_url_field'])])) { |
117 | - $link_url = $layout_def['fields'][strtoupper($layout_def['image2_ext_url_field'])]; |
|
117 | + $link_url = $layout_def['fields'][strtoupper($layout_def['image2_ext_url_field'])]; |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | $imagePath = ''; |
121 | - if ( $layout_def['image2'] == '__VARIABLE' ) { |
|
122 | - if ( !empty($layout_def['fields'][$key.'_ICON']) ) { |
|
121 | + if ($layout_def['image2'] == '__VARIABLE') { |
|
122 | + if (!empty($layout_def['fields'][$key.'_ICON'])) { |
|
123 | 123 | $imagePath = $layout_def['fields'][$key.'_ICON']; |
124 | 124 | } |
125 | 125 | } else { |
126 | 126 | $imagePath = $layout_def['image2']; |
127 | 127 | } |
128 | 128 | |
129 | - if ( !empty($imagePath) ) { |
|
130 | - $icon_img_html = SugarThemeRegistry::current()->getImage( $imagePath . '', 'border="0"',null,null,'.gif',$imagePath); |
|
131 | - $ret.= (empty($link_url)) ? '' : ' <a href="' . $link_url. '" TARGET = "_blank">' . "$icon_img_html</a>"; |
|
129 | + if (!empty($imagePath)) { |
|
130 | + $icon_img_html = SugarThemeRegistry::current()->getImage($imagePath.'', 'border="0"', null, null, '.gif', $imagePath); |
|
131 | + $ret .= (empty($link_url)) ? '' : ' <a href="'.$link_url.'" TARGET = "_blank">'."$icon_img_html</a>"; |
|
132 | 132 | } |
133 | 133 | } |
134 | 134 | //if requested, add attachment icon. |
135 | - if(!empty($layout_def['image2']) && !empty($layout_def['image2_url_field'])){ |
|
135 | + if (!empty($layout_def['image2']) && !empty($layout_def['image2_url_field'])) { |
|
136 | 136 | |
137 | 137 | if (is_array($layout_def['image2_url_field'])) { |
138 | 138 | //Generate file url. |
139 | 139 | if (!empty($layout_def['fields'][strtoupper($layout_def['image2_url_field']['id_field'])]) |
140 | - and !empty($layout_def['fields'][strtoupper($layout_def['image2_url_field']['filename_field'])]) ) { |
|
140 | + and !empty($layout_def['fields'][strtoupper($layout_def['image2_url_field']['filename_field'])])) { |
|
141 | 141 | |
142 | - $key=$layout_def['fields'][strtoupper($layout_def['image2_url_field']['id_field'])]; |
|
143 | - $file=$layout_def['fields'][strtoupper($layout_def['image2_url_field']['filename_field'])]; |
|
144 | - $filepath="index.php?entryPoint=download&id=".$key."&type=".$layout_def['module']; |
|
142 | + $key = $layout_def['fields'][strtoupper($layout_def['image2_url_field']['id_field'])]; |
|
143 | + $file = $layout_def['fields'][strtoupper($layout_def['image2_url_field']['filename_field'])]; |
|
144 | + $filepath = "index.php?entryPoint=download&id=".$key."&type=".$layout_def['module']; |
|
145 | 145 | } |
146 | 146 | } else { |
147 | 147 | if (!empty($layout_def['fields'][strtoupper($layout_def['image2_url_field'])])) { |
148 | - $filepath="index.php?entryPoint=download&id=".$layout_def['fields']['ID']."&type=".$layout_def['module']; |
|
148 | + $filepath = "index.php?entryPoint=download&id=".$layout_def['fields']['ID']."&type=".$layout_def['module']; |
|
149 | 149 | } |
150 | 150 | } |
151 | - $icon_img_html = SugarThemeRegistry::current()->getImage( $layout_def['image2'] . '', 'border="0"',null,null,'.gif',$layout_def['image2']); |
|
151 | + $icon_img_html = SugarThemeRegistry::current()->getImage($layout_def['image2'].'', 'border="0"', null, null, '.gif', $layout_def['image2']); |
|
152 | 152 | if ($action_access && !empty($filepath)) { |
153 | - $ret .= '<a href="' . $filepath. '" >' . "$icon_img_html</a>"; |
|
153 | + $ret .= '<a href="'.$filepath.'" >'."$icon_img_html</a>"; |
|
154 | 154 | } elseif (!empty($filepath)) { |
155 | 155 | $ret .= $icon_img_html; |
156 | 156 | } |
157 | 157 | } |
158 | 158 | // now handle attachments for Emails |
159 | - else if(!empty($layout_def['module']) && $layout_def['module'] == 'Emails' && !empty($layout_def['fields']['ATTACHMENT_IMAGE'])) { |
|
160 | - $ret.= $layout_def['fields']['ATTACHMENT_IMAGE']; |
|
159 | + else if (!empty($layout_def['module']) && $layout_def['module'] == 'Emails' && !empty($layout_def['fields']['ATTACHMENT_IMAGE'])) { |
|
160 | + $ret .= $layout_def['fields']['ATTACHMENT_IMAGE']; |
|
161 | 161 | } |
162 | 162 | return $ret; |
163 | 163 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
3 | 3 | /********************************************************************************* |
4 | 4 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 5 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -47,15 +47,15 @@ discard block |
||
47 | 47 | { |
48 | 48 | function displayList(&$layout_def) |
49 | 49 | { |
50 | - $value=''; |
|
50 | + $value = ''; |
|
51 | 51 | if (isset($layout_def['source']) and is_array($layout_def['source']) and isset($layout_def['fields']) and is_array($layout_def['fields'])) { |
52 | 52 | |
53 | 53 | foreach ($layout_def['source'] as $field) { |
54 | 54 | |
55 | 55 | if (isset($layout_def['fields'][strtoupper($field)])) { |
56 | - $value.=$layout_def['fields'][strtoupper($field)]; |
|
56 | + $value .= $layout_def['fields'][strtoupper($field)]; |
|
57 | 57 | } else { |
58 | - $value.=$field; |
|
58 | + $value .= $field; |
|
59 | 59 | } |
60 | 60 | } |
61 | 61 | } |
@@ -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. |
@@ -63,26 +63,26 @@ discard block |
||
63 | 63 | |
64 | 64 | $action = 'DeleteRelationship'; |
65 | 65 | $record = $layout_def['fields']['ID']; |
66 | - $current_module=$layout_def['module']; |
|
66 | + $current_module = $layout_def['module']; |
|
67 | 67 | //in document revisions subpanel ,users are now allowed to |
68 | 68 | //delete the latest revsion of a document. this will be tested here |
69 | 69 | //and if the condition is met delete button will be removed. |
70 | - $hideremove=false; |
|
71 | - if ($current_module=='DocumentRevisions') { |
|
72 | - if ($layout_def['fields']['ID']==$layout_def['fields']['LATEST_REVISION_ID']) { |
|
73 | - $hideremove=true; |
|
70 | + $hideremove = false; |
|
71 | + if ($current_module == 'DocumentRevisions') { |
|
72 | + if ($layout_def['fields']['ID'] == $layout_def['fields']['LATEST_REVISION_ID']) { |
|
73 | + $hideremove = true; |
|
74 | 74 | } |
75 | 75 | } |
76 | 76 | // Implicit Team-memberships are not "removeable" |
77 | 77 | elseif ($_REQUEST['module'] == 'Teams' && $current_module == 'Users') { |
78 | - if($layout_def['fields']['UPLINE'] != translate('LBL_TEAM_UPLINE_EXPLICIT', 'Users')) { |
|
78 | + if ($layout_def['fields']['UPLINE'] != translate('LBL_TEAM_UPLINE_EXPLICIT', 'Users')) { |
|
79 | 79 | $hideremove = true; |
80 | 80 | } |
81 | 81 | |
82 | 82 | //We also cannot remove the user whose private team is set to the parent_record_id value |
83 | 83 | $user = new User(); |
84 | 84 | $user->retrieve($layout_def['fields']['ID']); |
85 | - if($parent_record_id == $user->getPrivateTeamID()) |
|
85 | + if ($parent_record_id == $user->getPrivateTeamID()) |
|
86 | 86 | { |
87 | 87 | $hideremove = true; |
88 | 88 | } |
@@ -94,22 +94,22 @@ discard block |
||
94 | 94 | $subpanel = $layout_def['subpanel_id']; |
95 | 95 | $return_id = $_REQUEST['record']; |
96 | 96 | if (isset($layout_def['linked_field_set']) && !empty($layout_def['linked_field_set'])) { |
97 | - $linked_field= $layout_def['linked_field_set'] ; |
|
97 | + $linked_field = $layout_def['linked_field_set']; |
|
98 | 98 | } else { |
99 | 99 | $linked_field = $layout_def['linked_field']; |
100 | 100 | } |
101 | 101 | $refresh_page = 0; |
102 | - if(!empty($layout_def['refresh_page'])){ |
|
102 | + if (!empty($layout_def['refresh_page'])) { |
|
103 | 103 | $refresh_page = 1; |
104 | 104 | } |
105 | 105 | $return_url = "index.php?module=$return_module&action=$return_action&subpanel=$subpanel&record=$return_id&sugar_body_only=1&inline=1"; |
106 | 106 | |
107 | 107 | $icon_remove_text = mb_strtolower($app_strings['LBL_ID_FF_REMOVE'], 'UTF-8'); |
108 | 108 | |
109 | - if($linked_field == 'get_emails_by_assign_or_link') |
|
109 | + if ($linked_field == 'get_emails_by_assign_or_link') |
|
110 | 110 | $linked_field = 'emails'; |
111 | 111 | //based on listview since that lets you select records |
112 | - if($layout_def['ListView'] && !$hideremove) { |
|
112 | + if ($layout_def['ListView'] && !$hideremove) { |
|
113 | 113 | $retStr = "<a href=\"javascript:sub_p_rem('$subpanel', '$linked_field'" |
114 | 114 | .", '$record', $refresh_page);\"" |
115 | 115 | . ' class="listViewTdToolsS1"' |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | . ">$icon_remove_text</a>"; |
119 | 119 | return $retStr; |
120 | 120 | |
121 | - }else{ |
|
121 | + } else { |
|
122 | 122 | return ''; |
123 | 123 | } |
124 | 124 | } |
@@ -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,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 | } |
@@ -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 | } |
@@ -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( |
@@ -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. |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | { |
70 | 70 | global $sugar_config; |
71 | 71 | |
72 | - if(empty($config['db_manager'])) { |
|
72 | + if (empty($config['db_manager'])) { |
|
73 | 73 | // standard types |
74 | - switch($type) { |
|
74 | + switch ($type) { |
|
75 | 75 | case "mysql": |
76 | 76 | if (empty($sugar_config['mysqli_disabled']) && function_exists('mysqli_connect')) { |
77 | 77 | $my_db_manager = 'MysqliManager'; |
@@ -80,11 +80,11 @@ discard block |
||
80 | 80 | } |
81 | 81 | break; |
82 | 82 | case "mssql": |
83 | - if ( function_exists('sqlsrv_connect') |
|
84 | - && (empty($config['db_mssql_force_driver']) || $config['db_mssql_force_driver'] == 'sqlsrv' )) { |
|
83 | + if (function_exists('sqlsrv_connect') |
|
84 | + && (empty($config['db_mssql_force_driver']) || $config['db_mssql_force_driver'] == 'sqlsrv')) { |
|
85 | 85 | $my_db_manager = 'SqlsrvManager'; |
86 | 86 | } elseif (self::isFreeTDS() |
87 | - && (empty($config['db_mssql_force_driver']) || $config['db_mssql_force_driver'] == 'freetds' )) { |
|
87 | + && (empty($config['db_mssql_force_driver']) || $config['db_mssql_force_driver'] == 'freetds')) { |
|
88 | 88 | $my_db_manager = 'FreeTDSManager'; |
89 | 89 | } else { |
90 | 90 | $my_db_manager = 'MssqlManager'; |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | break; |
93 | 93 | default: |
94 | 94 | $my_db_manager = self::getManagerByType($type, false); |
95 | - if(empty($my_db_manager)) { |
|
95 | + if (empty($my_db_manager)) { |
|
96 | 96 | $GLOBALS['log']->fatal("unable to load DB manager for: $type"); |
97 | 97 | sugar_die("Cannot load DB manager"); |
98 | 98 | } |
@@ -104,17 +104,17 @@ discard block |
||
104 | 104 | // sanitize the name |
105 | 105 | $my_db_manager = preg_replace("/[^A-Za-z0-9_-]/", "", $my_db_manager); |
106 | 106 | |
107 | - if(!empty($config['db_manager_class'])){ |
|
107 | + if (!empty($config['db_manager_class'])) { |
|
108 | 108 | $my_db_manager = $config['db_manager_class']; |
109 | 109 | } else { |
110 | - if(file_exists("custom/include/database/{$my_db_manager}.php")) { |
|
110 | + if (file_exists("custom/include/database/{$my_db_manager}.php")) { |
|
111 | 111 | require_once("custom/include/database/{$my_db_manager}.php"); |
112 | 112 | } else { |
113 | 113 | require_once("include/database/{$my_db_manager}.php"); |
114 | 114 | } |
115 | 115 | } |
116 | 116 | |
117 | - if(class_exists($my_db_manager)) { |
|
117 | + if (class_exists($my_db_manager)) { |
|
118 | 118 | return new $my_db_manager(); |
119 | 119 | } else { |
120 | 120 | return null; |
@@ -134,14 +134,14 @@ discard block |
||
134 | 134 | static $count = 0, $old_count = 0; |
135 | 135 | |
136 | 136 | //fall back to the default instance name |
137 | - if(empty($sugar_config['db'][$instanceName])){ |
|
137 | + if (empty($sugar_config['db'][$instanceName])) { |
|
138 | 138 | $instanceName = ''; |
139 | 139 | } |
140 | - if(!isset(self::$instances[$instanceName])){ |
|
140 | + if (!isset(self::$instances[$instanceName])) { |
|
141 | 141 | $config = $sugar_config['dbconfig']; |
142 | 142 | $count++; |
143 | 143 | self::$instances[$instanceName] = self::getTypeInstance($config['db_type'], $config); |
144 | - if(!empty($sugar_config['dbconfigoption'])) { |
|
144 | + if (!empty($sugar_config['dbconfigoption'])) { |
|
145 | 145 | self::$instances[$instanceName]->setOptions($sugar_config['dbconfigoption']); |
146 | 146 | } |
147 | 147 | self::$instances[$instanceName]->connect($config, true); |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | */ |
160 | 160 | public static function disconnectAll() |
161 | 161 | { |
162 | - foreach(self::$instances as $instance) { |
|
162 | + foreach (self::$instances as $instance) { |
|
163 | 163 | $instance->disconnect(); |
164 | 164 | } |
165 | 165 | self::$instances = array(); |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | public static function getManagerByType($type, $validate = true) |
178 | 178 | { |
179 | 179 | $drivers = self::getDbDrivers($validate); |
180 | - if(!empty($drivers[$type])) { |
|
180 | + if (!empty($drivers[$type])) { |
|
181 | 181 | return get_class($drivers[$type]); |
182 | 182 | } |
183 | 183 | return false; |
@@ -191,19 +191,19 @@ discard block |
||
191 | 191 | */ |
192 | 192 | protected static function scanDriverDir($dir, &$drivers, $validate = true) |
193 | 193 | { |
194 | - if(!is_dir($dir)) return; |
|
194 | + if (!is_dir($dir)) return; |
|
195 | 195 | $scandir = opendir($dir); |
196 | - if($scandir === false) return; |
|
197 | - while(($name = readdir($scandir)) !== false) { |
|
198 | - if(substr($name, -11) != "Manager.php") continue; |
|
199 | - if($name == "DBManager.php") continue; |
|
196 | + if ($scandir === false) return; |
|
197 | + while (($name = readdir($scandir)) !== false) { |
|
198 | + if (substr($name, -11) != "Manager.php") continue; |
|
199 | + if ($name == "DBManager.php") continue; |
|
200 | 200 | require_once("$dir/$name"); |
201 | 201 | $classname = substr($name, 0, -4); |
202 | - if(!class_exists($classname)) continue; |
|
202 | + if (!class_exists($classname)) continue; |
|
203 | 203 | $driver = new $classname; |
204 | - if(!$validate || $driver->valid()) { |
|
205 | - if(empty($drivers[$driver->dbType])) { |
|
206 | - $drivers[$driver->dbType] = array(); |
|
204 | + if (!$validate || $driver->valid()) { |
|
205 | + if (empty($drivers[$driver->dbType])) { |
|
206 | + $drivers[$driver->dbType] = array(); |
|
207 | 207 | } |
208 | 208 | $drivers[$driver->dbType][] = $driver; |
209 | 209 | } |
@@ -235,9 +235,9 @@ discard block |
||
235 | 235 | self::scanDriverDir("custom/include/database", $drivers, $validate); |
236 | 236 | |
237 | 237 | $result = array(); |
238 | - foreach($drivers as $type => $tdrivers) { |
|
239 | - if(empty($tdrivers)) continue; |
|
240 | - if(count($tdrivers) > 1) { |
|
238 | + foreach ($drivers as $type => $tdrivers) { |
|
239 | + if (empty($tdrivers)) continue; |
|
240 | + if (count($tdrivers) > 1) { |
|
241 | 241 | usort($tdrivers, array(__CLASS__, "_compareDrivers")); |
242 | 242 | } |
243 | 243 | $result[$type] = $tdrivers[0]; |
@@ -255,13 +255,13 @@ discard block |
||
255 | 255 | { |
256 | 256 | static $is_freetds = null; |
257 | 257 | |
258 | - if($is_freetds === null) { |
|
258 | + if ($is_freetds === null) { |
|
259 | 259 | ob_start(); |
260 | 260 | phpinfo(INFO_MODULES); |
261 | - $info=ob_get_contents(); |
|
261 | + $info = ob_get_contents(); |
|
262 | 262 | ob_end_clean(); |
263 | 263 | |
264 | - $is_freetds = (strpos($info,'FreeTDS') !== false); |
|
264 | + $is_freetds = (strpos($info, 'FreeTDS') !== false); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | return $is_freetds; |
@@ -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. |
@@ -53,39 +53,39 @@ discard block |
||
53 | 53 | * @param $context |
54 | 54 | * @return boolean - Returns true on success false on failure |
55 | 55 | */ |
56 | -function sugar_mkdir($pathname, $mode=null, $recursive=false, $context='') { |
|
56 | +function sugar_mkdir($pathname, $mode = null, $recursive = false, $context = '') { |
|
57 | 57 | $mode = get_mode('dir_mode', $mode); |
58 | 58 | |
59 | - if ( sugar_is_dir($pathname,$mode) ) |
|
59 | + if (sugar_is_dir($pathname, $mode)) |
|
60 | 60 | return true; |
61 | 61 | |
62 | 62 | $result = false; |
63 | - if(empty($mode)) |
|
63 | + if (empty($mode)) |
|
64 | 64 | $mode = 0777; |
65 | - if(empty($context)) { |
|
65 | + if (empty($context)) { |
|
66 | 66 | $result = @mkdir($pathname, $mode, $recursive); |
67 | 67 | } else { |
68 | 68 | $result = @mkdir($pathname, $mode, $recursive, $context); |
69 | 69 | } |
70 | 70 | |
71 | - if($result){ |
|
72 | - if(!sugar_chmod($pathname, $mode)){ |
|
71 | + if ($result) { |
|
72 | + if (!sugar_chmod($pathname, $mode)) { |
|
73 | 73 | return false; |
74 | 74 | } |
75 | - if(!empty($GLOBALS['sugar_config']['default_permissions']['user'])){ |
|
76 | - if(!sugar_chown($pathname)){ |
|
75 | + if (!empty($GLOBALS['sugar_config']['default_permissions']['user'])) { |
|
76 | + if (!sugar_chown($pathname)) { |
|
77 | 77 | return false; |
78 | 78 | } |
79 | 79 | } |
80 | - if(!empty($GLOBALS['sugar_config']['default_permissions']['group'])){ |
|
81 | - if(!sugar_chgrp($pathname)) { |
|
80 | + if (!empty($GLOBALS['sugar_config']['default_permissions']['group'])) { |
|
81 | + if (!sugar_chgrp($pathname)) { |
|
82 | 82 | return false; |
83 | 83 | } |
84 | 84 | } |
85 | 85 | } |
86 | 86 | else { |
87 | 87 | $errorMessage = "Cannot create directory $pathname cannot be touched"; |
88 | - if(is_null($GLOBALS['log'])) { |
|
88 | + if (is_null($GLOBALS['log'])) { |
|
89 | 89 | throw new Exception("Error occurred but the system doesn't have logger. Error message: \"$errorMessage\""); |
90 | 90 | } |
91 | 91 | $GLOBALS['log']->error($errorMessage); |
@@ -108,13 +108,13 @@ discard block |
||
108 | 108 | * @param $context |
109 | 109 | * @return boolean - Returns a file pointer on success, false otherwise |
110 | 110 | */ |
111 | -function sugar_fopen($filename, $mode, $use_include_path=false, $context=null){ |
|
111 | +function sugar_fopen($filename, $mode, $use_include_path = false, $context = null) { |
|
112 | 112 | //check to see if the file exists, if not then use touch to create it. |
113 | - if(!file_exists($filename)){ |
|
113 | + if (!file_exists($filename)) { |
|
114 | 114 | sugar_touch($filename); |
115 | 115 | } |
116 | 116 | |
117 | - if(empty($context)) { |
|
117 | + if (empty($context)) { |
|
118 | 118 | |
119 | 119 | return fopen($filename, $mode, $use_include_path); |
120 | 120 | } else { |
@@ -136,22 +136,22 @@ discard block |
||
136 | 136 | * @param $context |
137 | 137 | * @return int - Returns the number of bytes written to the file, false otherwise. |
138 | 138 | */ |
139 | -function sugar_file_put_contents($filename, $data, $flags=null, $context=null){ |
|
139 | +function sugar_file_put_contents($filename, $data, $flags = null, $context = null) { |
|
140 | 140 | //check to see if the file exists, if not then use touch to create it. |
141 | - if(!file_exists($filename)){ |
|
141 | + if (!file_exists($filename)) { |
|
142 | 142 | sugar_touch($filename); |
143 | 143 | } |
144 | 144 | |
145 | - if ( !is_writable($filename) ) { |
|
145 | + if (!is_writable($filename)) { |
|
146 | 146 | $GLOBALS['log']->error("File $filename cannot be written to"); |
147 | 147 | return false; |
148 | 148 | } |
149 | 149 | |
150 | - if(empty($flags)) { |
|
150 | + if (empty($flags)) { |
|
151 | 151 | return file_put_contents($filename, $data); |
152 | - } elseif(empty($context)) { |
|
152 | + } elseif (empty($context)) { |
|
153 | 153 | return file_put_contents($filename, $data, $flags); |
154 | - } else{ |
|
154 | + } else { |
|
155 | 155 | return file_put_contents($filename, $data, $flags, $context); |
156 | 156 | } |
157 | 157 | } |
@@ -169,13 +169,13 @@ discard block |
||
169 | 169 | * @param context $context Context to pass into fopen operation |
170 | 170 | * @return boolean - Returns true if $filename was created, false otherwise. |
171 | 171 | */ |
172 | -function sugar_file_put_contents_atomic($filename, $data, $mode='wb', $use_include_path=false, $context=null){ |
|
172 | +function sugar_file_put_contents_atomic($filename, $data, $mode = 'wb', $use_include_path = false, $context = null) { |
|
173 | 173 | |
174 | 174 | $dir = dirname($filename); |
175 | 175 | $temp = tempnam($dir, 'temp'); |
176 | 176 | |
177 | 177 | if (!($f = @fopen($temp, $mode))) { |
178 | - $temp = $dir . DIRECTORY_SEPARATOR . uniqid('temp'); |
|
178 | + $temp = $dir.DIRECTORY_SEPARATOR.uniqid('temp'); |
|
179 | 179 | if (!($f = @fopen($temp, $mode))) { |
180 | 180 | trigger_error("sugar_file_put_contents_atomic() : error writing temporary file '$temp'", E_USER_WARNING); |
181 | 181 | return false; |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | } |
197 | 197 | } |
198 | 198 | |
199 | - if(file_exists($filename)) |
|
199 | + if (file_exists($filename)) |
|
200 | 200 | { |
201 | 201 | return sugar_chmod($filename, 0755); |
202 | 202 | } |
@@ -214,18 +214,18 @@ discard block |
||
214 | 214 | * @param $context |
215 | 215 | * @return string|boolean - Returns a file data on success, false otherwise |
216 | 216 | */ |
217 | -function sugar_file_get_contents($filename, $use_include_path=false, $context=null){ |
|
217 | +function sugar_file_get_contents($filename, $use_include_path = false, $context = null) { |
|
218 | 218 | //check to see if the file exists, if not then use touch to create it. |
219 | - if(!file_exists($filename)){ |
|
219 | + if (!file_exists($filename)) { |
|
220 | 220 | sugar_touch($filename); |
221 | 221 | } |
222 | 222 | |
223 | - if ( !is_readable($filename) ) { |
|
223 | + if (!is_readable($filename)) { |
|
224 | 224 | $GLOBALS['log']->error("File $filename cannot be read"); |
225 | 225 | return false; |
226 | 226 | } |
227 | 227 | |
228 | - if(empty($context)) { |
|
228 | + if (empty($context)) { |
|
229 | 229 | return file_get_contents($filename, $use_include_path); |
230 | 230 | } else { |
231 | 231 | return file_get_contents($filename, $use_include_path, $context); |
@@ -246,29 +246,29 @@ discard block |
||
246 | 246 | * @return boolean - Returns TRUE on success or FALSE on failure. |
247 | 247 | * |
248 | 248 | */ |
249 | -function sugar_touch($filename, $time=null, $atime=null) { |
|
249 | +function sugar_touch($filename, $time = null, $atime = null) { |
|
250 | 250 | |
251 | 251 | $result = false; |
252 | 252 | |
253 | - if(!empty($atime) && !empty($time)) { |
|
253 | + if (!empty($atime) && !empty($time)) { |
|
254 | 254 | $result = @touch($filename, $time, $atime); |
255 | - } else if(!empty($time)) { |
|
255 | + } else if (!empty($time)) { |
|
256 | 256 | $result = @touch($filename, $time); |
257 | 257 | } else { |
258 | 258 | $result = @touch($filename); |
259 | 259 | } |
260 | 260 | |
261 | - if(!$result) { |
|
261 | + if (!$result) { |
|
262 | 262 | $GLOBALS['log']->error("File $filename cannot be touched"); |
263 | 263 | return $result; |
264 | 264 | } |
265 | - if(!empty($GLOBALS['sugar_config']['default_permissions']['file_mode'])){ |
|
265 | + if (!empty($GLOBALS['sugar_config']['default_permissions']['file_mode'])) { |
|
266 | 266 | sugar_chmod($filename, $GLOBALS['sugar_config']['default_permissions']['file_mode']); |
267 | 267 | } |
268 | - if(!empty($GLOBALS['sugar_config']['default_permissions']['user'])){ |
|
268 | + if (!empty($GLOBALS['sugar_config']['default_permissions']['user'])) { |
|
269 | 269 | sugar_chown($filename); |
270 | 270 | } |
271 | - if(!empty($GLOBALS['sugar_config']['default_permissions']['group'])){ |
|
271 | + if (!empty($GLOBALS['sugar_config']['default_permissions']['group'])) { |
|
272 | 272 | sugar_chgrp($filename); |
273 | 273 | } |
274 | 274 | |
@@ -284,16 +284,16 @@ discard block |
||
284 | 284 | * @param int $mode The integer value of the permissions mode to set the created directory to |
285 | 285 | * @return boolean Returns TRUE on success or FALSE on failure. |
286 | 286 | */ |
287 | -function sugar_chmod($filename, $mode=null) { |
|
288 | - if ( !is_int($mode) ) |
|
289 | - $mode = (int) $mode; |
|
290 | - if(!is_windows()){ |
|
291 | - if(!isset($mode)){ |
|
287 | +function sugar_chmod($filename, $mode = null) { |
|
288 | + if (!is_int($mode)) |
|
289 | + $mode = (int)$mode; |
|
290 | + if (!is_windows()) { |
|
291 | + if (!isset($mode)) { |
|
292 | 292 | $mode = get_mode('file_mode', $mode); |
293 | 293 | } |
294 | - if(isset($mode) && $mode > 0){ |
|
294 | + if (isset($mode) && $mode > 0) { |
|
295 | 295 | return @chmod($filename, $mode); |
296 | - }else{ |
|
296 | + } else { |
|
297 | 297 | return false; |
298 | 298 | } |
299 | 299 | } |
@@ -309,15 +309,15 @@ discard block |
||
309 | 309 | * @param user - A user name or number |
310 | 310 | * @return boolean - Returns TRUE on success or FALSE on failure. |
311 | 311 | */ |
312 | -function sugar_chown($filename, $user='') { |
|
313 | - if(!is_windows()){ |
|
314 | - if(strlen($user)){ |
|
312 | +function sugar_chown($filename, $user = '') { |
|
313 | + if (!is_windows()) { |
|
314 | + if (strlen($user)) { |
|
315 | 315 | return chown($filename, $user); |
316 | - }else{ |
|
317 | - if(strlen($GLOBALS['sugar_config']['default_permissions']['user'])){ |
|
316 | + } else { |
|
317 | + if (strlen($GLOBALS['sugar_config']['default_permissions']['user'])) { |
|
318 | 318 | $user = $GLOBALS['sugar_config']['default_permissions']['user']; |
319 | 319 | return chown($filename, $user); |
320 | - }else{ |
|
320 | + } else { |
|
321 | 321 | return false; |
322 | 322 | } |
323 | 323 | } |
@@ -334,15 +334,15 @@ discard block |
||
334 | 334 | * @param group - A group name or number |
335 | 335 | * @return boolean - Returns TRUE on success or FALSE on failure. |
336 | 336 | */ |
337 | -function sugar_chgrp($filename, $group='') { |
|
338 | - if(!is_windows()){ |
|
339 | - if(!empty($group)){ |
|
337 | +function sugar_chgrp($filename, $group = '') { |
|
338 | + if (!is_windows()) { |
|
339 | + if (!empty($group)) { |
|
340 | 340 | return chgrp($filename, $group); |
341 | - }else{ |
|
342 | - if(!empty($GLOBALS['sugar_config']['default_permissions']['group'])){ |
|
341 | + } else { |
|
342 | + if (!empty($GLOBALS['sugar_config']['default_permissions']['group'])) { |
|
343 | 343 | $group = $GLOBALS['sugar_config']['default_permissions']['group']; |
344 | 344 | return chgrp($filename, $group); |
345 | - }else{ |
|
345 | + } else { |
|
346 | 346 | return false; |
347 | 347 | } |
348 | 348 | } |
@@ -360,26 +360,26 @@ discard block |
||
360 | 360 | * defined in the config file. |
361 | 361 | * @return int - the mode either found in the config file or passed in via the input parameter |
362 | 362 | */ |
363 | -function get_mode($key = 'dir_mode', $mode=null) { |
|
364 | - if ( !is_int($mode) ) |
|
365 | - $mode = (int) $mode; |
|
366 | - if(!class_exists('SugarConfig', true)) { |
|
363 | +function get_mode($key = 'dir_mode', $mode = null) { |
|
364 | + if (!is_int($mode)) |
|
365 | + $mode = (int)$mode; |
|
366 | + if (!class_exists('SugarConfig', true)) { |
|
367 | 367 | require 'include/SugarObjects/SugarConfig.php'; |
368 | 368 | } |
369 | - if(!is_windows()){ |
|
370 | - $conf_inst=SugarConfig::getInstance(); |
|
369 | + if (!is_windows()) { |
|
370 | + $conf_inst = SugarConfig::getInstance(); |
|
371 | 371 | $mode = $conf_inst->get('default_permissions.'.$key, $mode); |
372 | 372 | } |
373 | 373 | return $mode; |
374 | 374 | } |
375 | 375 | |
376 | -function sugar_is_dir($path, $mode='r'){ |
|
377 | - if(defined('TEMPLATE_URL'))return is_dir($path, $mode); |
|
376 | +function sugar_is_dir($path, $mode = 'r') { |
|
377 | + if (defined('TEMPLATE_URL'))return is_dir($path, $mode); |
|
378 | 378 | return is_dir($path); |
379 | 379 | } |
380 | 380 | |
381 | -function sugar_is_file($path, $mode='r'){ |
|
382 | - if(defined('TEMPLATE_URL'))return is_file($path, $mode); |
|
381 | +function sugar_is_file($path, $mode = 'r') { |
|
382 | + if (defined('TEMPLATE_URL'))return is_file($path, $mode); |
|
383 | 383 | return is_file($path); |
384 | 384 | } |
385 | 385 | |
@@ -391,10 +391,10 @@ discard block |
||
391 | 391 | function sugar_cached($file) |
392 | 392 | { |
393 | 393 | static $cdir = null; |
394 | - if(empty($cdir) && !empty($GLOBALS['sugar_config']['cache_dir'])) { |
|
394 | + if (empty($cdir) && !empty($GLOBALS['sugar_config']['cache_dir'])) { |
|
395 | 395 | $cdir = rtrim($GLOBALS['sugar_config']['cache_dir'], '/\\'); |
396 | 396 | } |
397 | - if(empty($cdir)) { |
|
397 | + if (empty($cdir)) { |
|
398 | 398 | $cdir = "cache"; |
399 | 399 | } |
400 | 400 | return "$cdir/$file"; |