@@ -1,140 +1,140 @@ |
||
1 | 1 | <?php |
2 | 2 | // created: 2014-01-29 09:59:23 |
3 | 3 | $unified_search_modules_display = array ( |
4 | - 'AOP_Case_Events' => |
|
5 | - array ( |
|
4 | + 'AOP_Case_Events' => |
|
5 | + array ( |
|
6 | 6 | 'visible' => false, |
7 | - ), |
|
8 | - 'AOP_Case_Updates' => |
|
9 | - array ( |
|
7 | + ), |
|
8 | + 'AOP_Case_Updates' => |
|
9 | + array ( |
|
10 | 10 | 'visible' => false, |
11 | - ), |
|
12 | - 'AOR_Reports' => |
|
13 | - array ( |
|
11 | + ), |
|
12 | + 'AOR_Reports' => |
|
13 | + array ( |
|
14 | 14 | 'visible' => false, |
15 | - ), |
|
16 | - 'AOS_Contracts' => |
|
17 | - array ( |
|
15 | + ), |
|
16 | + 'AOS_Contracts' => |
|
17 | + array ( |
|
18 | 18 | 'visible' => false, |
19 | - ), |
|
20 | - 'AOS_Invoices' => |
|
21 | - array ( |
|
19 | + ), |
|
20 | + 'AOS_Invoices' => |
|
21 | + array ( |
|
22 | 22 | 'visible' => false, |
23 | - ), |
|
24 | - 'AOS_PDF_Templates' => |
|
25 | - array ( |
|
23 | + ), |
|
24 | + 'AOS_PDF_Templates' => |
|
25 | + array ( |
|
26 | 26 | 'visible' => false, |
27 | - ), |
|
28 | - 'AOS_Product_Categories' => |
|
29 | - array ( |
|
27 | + ), |
|
28 | + 'AOS_Product_Categories' => |
|
29 | + array ( |
|
30 | 30 | 'visible' => false, |
31 | - ), |
|
32 | - 'AOS_Products' => |
|
33 | - array ( |
|
31 | + ), |
|
32 | + 'AOS_Products' => |
|
33 | + array ( |
|
34 | 34 | 'visible' => false, |
35 | - ), |
|
36 | - 'AOS_Quotes' => |
|
37 | - array ( |
|
35 | + ), |
|
36 | + 'AOS_Quotes' => |
|
37 | + array ( |
|
38 | 38 | 'visible' => false, |
39 | - ), |
|
40 | - 'AOW_Processed' => |
|
41 | - array ( |
|
39 | + ), |
|
40 | + 'AOW_Processed' => |
|
41 | + array ( |
|
42 | 42 | 'visible' => false, |
43 | - ), |
|
44 | - 'AOW_WorkFlow' => |
|
45 | - array ( |
|
43 | + ), |
|
44 | + 'AOW_WorkFlow' => |
|
45 | + array ( |
|
46 | 46 | 'visible' => false, |
47 | - ), |
|
48 | - 'Accounts' => |
|
49 | - array ( |
|
47 | + ), |
|
48 | + 'Accounts' => |
|
49 | + array ( |
|
50 | 50 | 'visible' => true, |
51 | - ), |
|
52 | - 'Bugs' => |
|
53 | - array ( |
|
51 | + ), |
|
52 | + 'Bugs' => |
|
53 | + array ( |
|
54 | 54 | 'visible' => false, |
55 | - ), |
|
56 | - 'Calls' => |
|
57 | - array ( |
|
55 | + ), |
|
56 | + 'Calls' => |
|
57 | + array ( |
|
58 | 58 | 'visible' => true, |
59 | - ), |
|
60 | - 'Calls_Reschedule' => |
|
61 | - array ( |
|
59 | + ), |
|
60 | + 'Calls_Reschedule' => |
|
61 | + array ( |
|
62 | 62 | 'visible' => false, |
63 | - ), |
|
64 | - 'Campaigns' => |
|
65 | - array ( |
|
63 | + ), |
|
64 | + 'Campaigns' => |
|
65 | + array ( |
|
66 | 66 | 'visible' => false, |
67 | - ), |
|
68 | - 'Cases' => |
|
69 | - array ( |
|
67 | + ), |
|
68 | + 'Cases' => |
|
69 | + array ( |
|
70 | 70 | 'visible' => true, |
71 | - ), |
|
72 | - 'Contacts' => |
|
73 | - array ( |
|
71 | + ), |
|
72 | + 'Contacts' => |
|
73 | + array ( |
|
74 | 74 | 'visible' => true, |
75 | - ), |
|
76 | - 'Documents' => |
|
77 | - array ( |
|
75 | + ), |
|
76 | + 'Documents' => |
|
77 | + array ( |
|
78 | 78 | 'visible' => true, |
79 | - ), |
|
80 | - 'FP_Event_Locations' => |
|
81 | - array ( |
|
79 | + ), |
|
80 | + 'FP_Event_Locations' => |
|
81 | + array ( |
|
82 | 82 | 'visible' => false, |
83 | - ), |
|
84 | - 'FP_events' => |
|
85 | - array ( |
|
83 | + ), |
|
84 | + 'FP_events' => |
|
85 | + array ( |
|
86 | 86 | 'visible' => false, |
87 | - ), |
|
88 | - 'Leads' => |
|
89 | - array ( |
|
87 | + ), |
|
88 | + 'Leads' => |
|
89 | + array ( |
|
90 | 90 | 'visible' => true, |
91 | - ), |
|
92 | - 'Meetings' => |
|
93 | - array ( |
|
91 | + ), |
|
92 | + 'Meetings' => |
|
93 | + array ( |
|
94 | 94 | 'visible' => true, |
95 | - ), |
|
96 | - 'Notes' => |
|
97 | - array ( |
|
95 | + ), |
|
96 | + 'Notes' => |
|
97 | + array ( |
|
98 | 98 | 'visible' => true, |
99 | - ), |
|
100 | - 'Opportunities' => |
|
101 | - array ( |
|
99 | + ), |
|
100 | + 'Opportunities' => |
|
101 | + array ( |
|
102 | 102 | 'visible' => true, |
103 | - ), |
|
104 | - 'Project' => |
|
105 | - array ( |
|
103 | + ), |
|
104 | + 'Project' => |
|
105 | + array ( |
|
106 | 106 | 'visible' => false, |
107 | - ), |
|
108 | - 'ProjectTask' => |
|
109 | - array ( |
|
107 | + ), |
|
108 | + 'ProjectTask' => |
|
109 | + array ( |
|
110 | 110 | 'visible' => false, |
111 | - ), |
|
112 | - 'ProspectLists' => |
|
113 | - array ( |
|
111 | + ), |
|
112 | + 'ProspectLists' => |
|
113 | + array ( |
|
114 | 114 | 'visible' => false, |
115 | - ), |
|
116 | - 'Prospects' => |
|
117 | - array ( |
|
115 | + ), |
|
116 | + 'Prospects' => |
|
117 | + array ( |
|
118 | 118 | 'visible' => false, |
119 | - ), |
|
120 | - 'Tasks' => |
|
121 | - array ( |
|
119 | + ), |
|
120 | + 'Tasks' => |
|
121 | + array ( |
|
122 | 122 | 'visible' => false, |
123 | - ), |
|
124 | - 'jjwg_Address_Cache' => |
|
125 | - array ( |
|
123 | + ), |
|
124 | + 'jjwg_Address_Cache' => |
|
125 | + array ( |
|
126 | 126 | 'visible' => false, |
127 | - ), |
|
128 | - 'jjwg_Areas' => |
|
129 | - array ( |
|
127 | + ), |
|
128 | + 'jjwg_Areas' => |
|
129 | + array ( |
|
130 | 130 | 'visible' => false, |
131 | - ), |
|
132 | - 'jjwg_Maps' => |
|
133 | - array ( |
|
131 | + ), |
|
132 | + 'jjwg_Maps' => |
|
133 | + array ( |
|
134 | 134 | 'visible' => false, |
135 | - ), |
|
136 | - 'jjwg_Markers' => |
|
137 | - array ( |
|
135 | + ), |
|
136 | + 'jjwg_Markers' => |
|
137 | + array ( |
|
138 | 138 | 'visible' => false, |
139 | - ), |
|
139 | + ), |
|
140 | 140 | ); |
141 | 141 | \ No newline at end of file |
@@ -1,140 +1,140 @@ |
||
1 | 1 | <?php |
2 | 2 | // created: 2014-01-29 09:59:23 |
3 | -$unified_search_modules_display = array ( |
|
3 | +$unified_search_modules_display = array( |
|
4 | 4 | 'AOP_Case_Events' => |
5 | - array ( |
|
5 | + array( |
|
6 | 6 | 'visible' => false, |
7 | 7 | ), |
8 | 8 | 'AOP_Case_Updates' => |
9 | - array ( |
|
9 | + array( |
|
10 | 10 | 'visible' => false, |
11 | 11 | ), |
12 | 12 | 'AOR_Reports' => |
13 | - array ( |
|
13 | + array( |
|
14 | 14 | 'visible' => false, |
15 | 15 | ), |
16 | 16 | 'AOS_Contracts' => |
17 | - array ( |
|
17 | + array( |
|
18 | 18 | 'visible' => false, |
19 | 19 | ), |
20 | 20 | 'AOS_Invoices' => |
21 | - array ( |
|
21 | + array( |
|
22 | 22 | 'visible' => false, |
23 | 23 | ), |
24 | 24 | 'AOS_PDF_Templates' => |
25 | - array ( |
|
25 | + array( |
|
26 | 26 | 'visible' => false, |
27 | 27 | ), |
28 | 28 | 'AOS_Product_Categories' => |
29 | - array ( |
|
29 | + array( |
|
30 | 30 | 'visible' => false, |
31 | 31 | ), |
32 | 32 | 'AOS_Products' => |
33 | - array ( |
|
33 | + array( |
|
34 | 34 | 'visible' => false, |
35 | 35 | ), |
36 | 36 | 'AOS_Quotes' => |
37 | - array ( |
|
37 | + array( |
|
38 | 38 | 'visible' => false, |
39 | 39 | ), |
40 | 40 | 'AOW_Processed' => |
41 | - array ( |
|
41 | + array( |
|
42 | 42 | 'visible' => false, |
43 | 43 | ), |
44 | 44 | 'AOW_WorkFlow' => |
45 | - array ( |
|
45 | + array( |
|
46 | 46 | 'visible' => false, |
47 | 47 | ), |
48 | 48 | 'Accounts' => |
49 | - array ( |
|
49 | + array( |
|
50 | 50 | 'visible' => true, |
51 | 51 | ), |
52 | 52 | 'Bugs' => |
53 | - array ( |
|
53 | + array( |
|
54 | 54 | 'visible' => false, |
55 | 55 | ), |
56 | 56 | 'Calls' => |
57 | - array ( |
|
57 | + array( |
|
58 | 58 | 'visible' => true, |
59 | 59 | ), |
60 | 60 | 'Calls_Reschedule' => |
61 | - array ( |
|
61 | + array( |
|
62 | 62 | 'visible' => false, |
63 | 63 | ), |
64 | 64 | 'Campaigns' => |
65 | - array ( |
|
65 | + array( |
|
66 | 66 | 'visible' => false, |
67 | 67 | ), |
68 | 68 | 'Cases' => |
69 | - array ( |
|
69 | + array( |
|
70 | 70 | 'visible' => true, |
71 | 71 | ), |
72 | 72 | 'Contacts' => |
73 | - array ( |
|
73 | + array( |
|
74 | 74 | 'visible' => true, |
75 | 75 | ), |
76 | 76 | 'Documents' => |
77 | - array ( |
|
77 | + array( |
|
78 | 78 | 'visible' => true, |
79 | 79 | ), |
80 | 80 | 'FP_Event_Locations' => |
81 | - array ( |
|
81 | + array( |
|
82 | 82 | 'visible' => false, |
83 | 83 | ), |
84 | 84 | 'FP_events' => |
85 | - array ( |
|
85 | + array( |
|
86 | 86 | 'visible' => false, |
87 | 87 | ), |
88 | 88 | 'Leads' => |
89 | - array ( |
|
89 | + array( |
|
90 | 90 | 'visible' => true, |
91 | 91 | ), |
92 | 92 | 'Meetings' => |
93 | - array ( |
|
93 | + array( |
|
94 | 94 | 'visible' => true, |
95 | 95 | ), |
96 | 96 | 'Notes' => |
97 | - array ( |
|
97 | + array( |
|
98 | 98 | 'visible' => true, |
99 | 99 | ), |
100 | 100 | 'Opportunities' => |
101 | - array ( |
|
101 | + array( |
|
102 | 102 | 'visible' => true, |
103 | 103 | ), |
104 | 104 | 'Project' => |
105 | - array ( |
|
105 | + array( |
|
106 | 106 | 'visible' => false, |
107 | 107 | ), |
108 | 108 | 'ProjectTask' => |
109 | - array ( |
|
109 | + array( |
|
110 | 110 | 'visible' => false, |
111 | 111 | ), |
112 | 112 | 'ProspectLists' => |
113 | - array ( |
|
113 | + array( |
|
114 | 114 | 'visible' => false, |
115 | 115 | ), |
116 | 116 | 'Prospects' => |
117 | - array ( |
|
117 | + array( |
|
118 | 118 | 'visible' => false, |
119 | 119 | ), |
120 | 120 | 'Tasks' => |
121 | - array ( |
|
121 | + array( |
|
122 | 122 | 'visible' => false, |
123 | 123 | ), |
124 | 124 | 'jjwg_Address_Cache' => |
125 | - array ( |
|
125 | + array( |
|
126 | 126 | 'visible' => false, |
127 | 127 | ), |
128 | 128 | 'jjwg_Areas' => |
129 | - array ( |
|
129 | + array( |
|
130 | 130 | 'visible' => false, |
131 | 131 | ), |
132 | 132 | 'jjwg_Maps' => |
133 | - array ( |
|
133 | + array( |
|
134 | 134 | 'visible' => false, |
135 | 135 | ), |
136 | 136 | 'jjwg_Markers' => |
137 | - array ( |
|
137 | + array( |
|
138 | 138 | 'visible' => false, |
139 | 139 | ), |
140 | 140 | ); |
141 | 141 | \ No newline at end of file |
@@ -28,4 +28,4 @@ |
||
28 | 28 | if (!isset($hook_array['after_save']) || !is_array($hook_array['after_save'])) { |
29 | 29 | $hook_array['after_save'] = array(); |
30 | 30 | } |
31 | -$hook_array['after_save'][] = Array(99, 'AOW_Workflow', 'modules/AOW_WorkFlow/AOW_WorkFlow.php','AOW_WorkFlow', 'run_bean_flows'); |
|
32 | 31 | \ No newline at end of file |
32 | +$hook_array['after_save'][] = Array(99, 'AOW_Workflow', 'modules/AOW_WorkFlow/AOW_WorkFlow.php', 'AOW_WorkFlow', 'run_bean_flows'); |
|
33 | 33 | \ No newline at end of file |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | } |
59 | 59 | |
60 | 60 | function parse() { |
61 | - return "NOT AVAILABLE"; |
|
61 | + return "NOT AVAILABLE"; |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -66,14 +66,14 @@ discard block |
||
66 | 66 | * Parses for contents enclosed within <form>...</form> tags |
67 | 67 | */ |
68 | 68 | function getFormContents($contents, $all = true) { |
69 | - if($all) { |
|
70 | - preg_match_all("'(<form[^>]*?>)(.*?)(</form[^>]*?>)'si", $contents, $matches); |
|
71 | - return $matches; |
|
72 | - } |
|
69 | + if($all) { |
|
70 | + preg_match_all("'(<form[^>]*?>)(.*?)(</form[^>]*?>)'si", $contents, $matches); |
|
71 | + return $matches; |
|
72 | + } |
|
73 | 73 | |
74 | - preg_match("'(<form[^>]*?>)(.*?)(</form[^>]*?>)'si", $contents, $matches); |
|
75 | - return $this->convertToTagElement($matches); |
|
76 | - //return $matches; |
|
74 | + preg_match("'(<form[^>]*?>)(.*?)(</form[^>]*?>)'si", $contents, $matches); |
|
75 | + return $this->convertToTagElement($matches); |
|
76 | + //return $matches; |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | |
@@ -84,12 +84,12 @@ discard block |
||
84 | 84 | * @return $matches Array of matches of PREG_SET_ORDER |
85 | 85 | */ |
86 | 86 | function getFormElements($contents) { |
87 | - preg_match_all("'(<[ ]*?)(textarea|input|select)([^>]*?)(>)'si", $contents, $matches, PREG_PATTERN_ORDER); |
|
88 | - $elems = array(); |
|
89 | - foreach($matches[3] as $match) { |
|
90 | - $elems[] = $match; |
|
91 | - } |
|
92 | - return $elems; |
|
87 | + preg_match_all("'(<[ ]*?)(textarea|input|select)([^>]*?)(>)'si", $contents, $matches, PREG_PATTERN_ORDER); |
|
88 | + $elems = array(); |
|
89 | + foreach($matches[3] as $match) { |
|
90 | + $elems[] = $match; |
|
91 | + } |
|
92 | + return $elems; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | * @return $matches Array of name/value pairs |
101 | 101 | */ |
102 | 102 | function getFormElementsNames($contents) { |
103 | - preg_match_all("'(<[ ]*?)(textarea|input|select)[^>]*?name=[\'\"]([^\'\"]*?)(\[\])?(_basic)?[\'\"]([^>]*?>)'si", $contents, $matches, PREG_PATTERN_ORDER); |
|
104 | - return !empty($matches[3]) ? $matches[3] : null; |
|
103 | + preg_match_all("'(<[ ]*?)(textarea|input|select)[^>]*?name=[\'\"]([^\'\"]*?)(\[\])?(_basic)?[\'\"]([^>]*?>)'si", $contents, $matches, PREG_PATTERN_ORDER); |
|
104 | + return !empty($matches[3]) ? $matches[3] : null; |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | |
@@ -114,21 +114,21 @@ discard block |
||
114 | 114 | * @return Array of name/value for matching attribute |
115 | 115 | */ |
116 | 116 | function getTagAttribute($name, $contents, $filter = '') { |
117 | - //$exp = "'".$name."[ ]*?=[ ]*?[\'\"]([a-zA-Z0-9\_\[\]]*)[\'\"]'si"; |
|
117 | + //$exp = "'".$name."[ ]*?=[ ]*?[\'\"]([a-zA-Z0-9\_\[\]]*)[\'\"]'si"; |
|
118 | 118 | |
119 | - $exp = "'".$name."[\s]*?=[\s]*?[\'\"]([^\'^\"]*?)[\'\"]'si"; |
|
120 | - preg_match_all($exp, $contents, $matches, PREG_SET_ORDER); |
|
121 | - if(empty($filter)) { |
|
122 | - return !empty($matches[0][1]) ? $matches[0][1] : ''; |
|
123 | - } |
|
119 | + $exp = "'".$name."[\s]*?=[\s]*?[\'\"]([^\'^\"]*?)[\'\"]'si"; |
|
120 | + preg_match_all($exp, $contents, $matches, PREG_SET_ORDER); |
|
121 | + if(empty($filter)) { |
|
122 | + return !empty($matches[0][1]) ? $matches[0][1] : ''; |
|
123 | + } |
|
124 | 124 | |
125 | - $filtered = array(); |
|
126 | - foreach($matches as $tag) { |
|
127 | - if(preg_match($filter, $tag[1])) { |
|
128 | - $filtered[] = $tag; |
|
129 | - } |
|
130 | - } |
|
131 | - return $filtered; |
|
125 | + $filtered = array(); |
|
126 | + foreach($matches as $tag) { |
|
127 | + if(preg_match($filter, $tag[1])) { |
|
128 | + $filtered[] = $tag; |
|
129 | + } |
|
130 | + } |
|
131 | + return $filtered; |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
@@ -140,18 +140,18 @@ discard block |
||
140 | 140 | * @return Array of table elements found |
141 | 141 | */ |
142 | 142 | function getTables($tableClass = null, $contents) { |
143 | - preg_match_all("'(<table[^>]*?>)(.*?)(</table[^>]*?>)'si", $contents, $matches, PREG_SET_ORDER); |
|
144 | - if($tableClass == null) { |
|
145 | - return $matches; |
|
146 | - } |
|
143 | + preg_match_all("'(<table[^>]*?>)(.*?)(</table[^>]*?>)'si", $contents, $matches, PREG_SET_ORDER); |
|
144 | + if($tableClass == null) { |
|
145 | + return $matches; |
|
146 | + } |
|
147 | 147 | |
148 | - $tables = array(); |
|
149 | - foreach($matches as $key => $table) { |
|
150 | - if(strpos($table[1], $tableClass) > 0) { |
|
151 | - $tables[] = $table; |
|
152 | - } |
|
153 | - } |
|
154 | - return $this->convertToTagElement($tables); |
|
148 | + $tables = array(); |
|
149 | + foreach($matches as $key => $table) { |
|
150 | + if(strpos($table[1], $tableClass) > 0) { |
|
151 | + $tables[] = $table; |
|
152 | + } |
|
153 | + } |
|
154 | + return $this->convertToTagElement($tables); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -167,40 +167,40 @@ discard block |
||
167 | 167 | * @return a tag element format Array |
168 | 168 | */ |
169 | 169 | function getElementsByType($type, $contents) { |
170 | - $x = strlen($contents); |
|
171 | - $mark = 0; |
|
172 | - $count = 0; |
|
173 | - $stag1 = "<" . trim($type, " <>") . '>'; |
|
174 | - $stag2 = "<" . trim($type, " <>") . ' '; |
|
175 | - $etag = "</".$type.">"; |
|
176 | - $sincrement = strlen($stag1); |
|
177 | - $eincrement = strlen($etag); |
|
178 | - $sarr = array(); |
|
179 | - $values = array(); |
|
180 | - |
|
181 | - while($count < $x) { |
|
182 | - $stok = substr($contents, $count, $sincrement); |
|
183 | - $etok = substr($contents, $count, $eincrement); |
|
184 | - if($stok == $stag1 || $stok == $stag2) { |
|
185 | - //Reset mark; |
|
186 | - if(count($sarr) == 0) { |
|
187 | - $mark = $count; |
|
188 | - } |
|
170 | + $x = strlen($contents); |
|
171 | + $mark = 0; |
|
172 | + $count = 0; |
|
173 | + $stag1 = "<" . trim($type, " <>") . '>'; |
|
174 | + $stag2 = "<" . trim($type, " <>") . ' '; |
|
175 | + $etag = "</".$type.">"; |
|
176 | + $sincrement = strlen($stag1); |
|
177 | + $eincrement = strlen($etag); |
|
178 | + $sarr = array(); |
|
179 | + $values = array(); |
|
180 | + |
|
181 | + while($count < $x) { |
|
182 | + $stok = substr($contents, $count, $sincrement); |
|
183 | + $etok = substr($contents, $count, $eincrement); |
|
184 | + if($stok == $stag1 || $stok == $stag2) { |
|
185 | + //Reset mark; |
|
186 | + if(count($sarr) == 0) { |
|
187 | + $mark = $count; |
|
188 | + } |
|
189 | 189 | $sarr[] = $count; |
190 | 190 | |
191 | - } else if($etok == $etag) { |
|
192 | - array_shift($sarr); |
|
193 | - if(count($sarr) == 0) { |
|
194 | - $val = substr($contents, $mark, ($count - $mark) + $eincrement); |
|
195 | - $values[] = $val; |
|
196 | - $mark = $count; |
|
197 | - } |
|
198 | - } |
|
199 | - $count++; |
|
200 | - } |
|
191 | + } else if($etok == $etag) { |
|
192 | + array_shift($sarr); |
|
193 | + if(count($sarr) == 0) { |
|
194 | + $val = substr($contents, $mark, ($count - $mark) + $eincrement); |
|
195 | + $values[] = $val; |
|
196 | + $mark = $count; |
|
197 | + } |
|
198 | + } |
|
199 | + $count++; |
|
200 | + } |
|
201 | 201 | |
202 | - $count = 0; |
|
203 | - return $values; |
|
202 | + $count = 0; |
|
203 | + return $values; |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | |
@@ -210,14 +210,14 @@ discard block |
||
210 | 210 | * |
211 | 211 | */ |
212 | 212 | function getElementValue($type, $contents, $filter = "(.*?)") { |
213 | - $exp = "'<".$type."[^>]*?>".$filter."</".$type."[^>]*?>'si"; |
|
214 | - preg_match($exp, $contents, $matches); |
|
215 | - return isset($matches[1]) ? $matches[1] : ''; |
|
213 | + $exp = "'<".$type."[^>]*?>".$filter."</".$type."[^>]*?>'si"; |
|
214 | + preg_match($exp, $contents, $matches); |
|
215 | + return isset($matches[1]) ? $matches[1] : ''; |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | |
219 | 219 | function stripComments($contents) { |
220 | - return preg_replace("'(<!--.*?-->)'si", "", $contents); |
|
220 | + return preg_replace("'(<!--.*?-->)'si", "", $contents); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |
@@ -229,14 +229,14 @@ discard block |
||
229 | 229 | * @param $result The file contents with non-matching flavor tags and their nested comments removed |
230 | 230 | */ |
231 | 231 | function stripFlavorTags($contents) { |
232 | - $flavor = isset($GLOBALS['sugar_flavor']) ? $GLOBALS['sugar_flavor'] : 'PRO'; |
|
233 | - $isPro = ($flavor == 'ENT' || $flavor == 'PRO') ? true : false; |
|
234 | - if($isPro) { |
|
235 | - $contents = preg_replace('/<!-- BEGIN: open_source -->.*?<!-- END: open_source -->/', '', $contents); |
|
236 | - } else { |
|
237 | - $contents = preg_replace('/<!-- BEGIN: pro -->.*?<!-- END: pro -->/', '', $contents); |
|
238 | - } |
|
239 | - return $contents; |
|
232 | + $flavor = isset($GLOBALS['sugar_flavor']) ? $GLOBALS['sugar_flavor'] : 'PRO'; |
|
233 | + $isPro = ($flavor == 'ENT' || $flavor == 'PRO') ? true : false; |
|
234 | + if($isPro) { |
|
235 | + $contents = preg_replace('/<!-- BEGIN: open_source -->.*?<!-- END: open_source -->/', '', $contents); |
|
236 | + } else { |
|
237 | + $contents = preg_replace('/<!-- BEGIN: pro -->.*?<!-- END: pro -->/', '', $contents); |
|
238 | + } |
|
239 | + return $contents; |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | /** |
@@ -247,34 +247,34 @@ discard block |
||
247 | 247 | * @return The maximum column count |
248 | 248 | */ |
249 | 249 | function getMaxColumns($contents, $filter) { |
250 | - preg_match_all("'(<tr[^>]*?>)(.*?)(</tr[^>]*?>)'si", $contents, $matches, PREG_SET_ORDER); |
|
251 | - $max = 0; |
|
252 | - foreach($matches as $tableRows) { |
|
253 | - $count = substr_count($tableRows[2], $filter); |
|
254 | - if($count > $max) { |
|
255 | - $max = $count; |
|
256 | - } |
|
257 | - } |
|
250 | + preg_match_all("'(<tr[^>]*?>)(.*?)(</tr[^>]*?>)'si", $contents, $matches, PREG_SET_ORDER); |
|
251 | + $max = 0; |
|
252 | + foreach($matches as $tableRows) { |
|
253 | + $count = substr_count($tableRows[2], $filter); |
|
254 | + if($count > $max) { |
|
255 | + $max = $count; |
|
256 | + } |
|
257 | + } |
|
258 | 258 | |
259 | - return $max; |
|
259 | + return $max; |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | function convertToTagElement($matches) { |
263 | 263 | |
264 | - $elements = array(); |
|
264 | + $elements = array(); |
|
265 | 265 | |
266 | - foreach($matches as $data) { |
|
267 | - // We need 4 because the 1,2,3 indexes make up start,body,end |
|
268 | - if(count($data) == 4) { |
|
269 | - $element = array(); |
|
270 | - $element['start'] = $data[1]; |
|
271 | - $element['body'] = $data[2]; |
|
272 | - $element['end'] = $data[3]; |
|
273 | - $elements[] = $element; |
|
274 | - } |
|
275 | - } |
|
266 | + foreach($matches as $data) { |
|
267 | + // We need 4 because the 1,2,3 indexes make up start,body,end |
|
268 | + if(count($data) == 4) { |
|
269 | + $element = array(); |
|
270 | + $element['start'] = $data[1]; |
|
271 | + $element['body'] = $data[2]; |
|
272 | + $element['end'] = $data[3]; |
|
273 | + $elements[] = $element; |
|
274 | + } |
|
275 | + } |
|
276 | 276 | |
277 | - return empty($elements) ? $matches : $elements; |
|
277 | + return empty($elements) ? $matches : $elements; |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | /* |
@@ -282,10 +282,10 @@ discard block |
||
282 | 282 | * This function removes the \r (return), \n (newline) and \t (tab) markup from string |
283 | 283 | */ |
284 | 284 | function trimHTML($contents) { |
285 | - $contents = str_replace(array("\r"), array(""), $contents); |
|
286 | - $contents = str_replace(array("\n"), array(""), $contents); |
|
287 | - $contents = str_replace(array("\t"), array(""), $contents); |
|
288 | - return $contents; |
|
285 | + $contents = str_replace(array("\r"), array(""), $contents); |
|
286 | + $contents = str_replace(array("\n"), array(""), $contents); |
|
287 | + $contents = str_replace(array("\t"), array(""), $contents); |
|
288 | + return $contents; |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | |
@@ -307,11 +307,11 @@ discard block |
||
307 | 307 | //Check if there are Javascript blocks of code to process |
308 | 308 | preg_match_all("'(<script[^>]*?>)(.*?)(</script[^>]*?>)'si", $contents, $matches, PREG_PATTERN_ORDER); |
309 | 309 | if(empty($matches)) { |
310 | - return $javascript; |
|
310 | + return $javascript; |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | foreach($matches[0] as $scriptBlock) { |
314 | - $javascript .= "\n" . $scriptBlock; |
|
314 | + $javascript .= "\n" . $scriptBlock; |
|
315 | 315 | } //foreach |
316 | 316 | |
317 | 317 | $javascript = substr($javascript, 1); |
@@ -323,19 +323,19 @@ discard block |
||
323 | 323 | //Find all blocks that may need to be replaced with Smarty syntax |
324 | 324 | preg_match_all("'([\{])([a-zA-Z0-9_]*?)([\}])'si", $javascript, $matches, PREG_PATTERN_ORDER); |
325 | 325 | if(!empty($matches)) { |
326 | - $replace = array(); |
|
326 | + $replace = array(); |
|
327 | 327 | |
328 | - foreach($matches[0] as $xTemplateCode) { |
|
329 | - if(!isset($replace[$xTemplateCode])) { |
|
330 | - $replace[$xTemplateCode] = str_replace("{", "{\$", $xTemplateCode); |
|
331 | - } //if |
|
332 | - } //foreach |
|
328 | + foreach($matches[0] as $xTemplateCode) { |
|
329 | + if(!isset($replace[$xTemplateCode])) { |
|
330 | + $replace[$xTemplateCode] = str_replace("{", "{\$", $xTemplateCode); |
|
331 | + } //if |
|
332 | + } //foreach |
|
333 | 333 | |
334 | - $javascript = str_replace(array_keys($replace), array_values($replace), $javascript); |
|
334 | + $javascript = str_replace(array_keys($replace), array_values($replace), $javascript); |
|
335 | 335 | } //if |
336 | 336 | |
337 | 337 | if(!$addLiterals) { |
338 | - return $javascript; |
|
338 | + return $javascript; |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | return $this->parseDelimiters($javascript); |
@@ -343,44 +343,44 @@ discard block |
||
343 | 343 | } |
344 | 344 | |
345 | 345 | static function parseDelimiters($javascript) { |
346 | - $newJavascript = ''; |
|
347 | - $scriptLength = strlen($javascript); |
|
348 | - $count = 0; |
|
349 | - $inSmartyVariable = false; |
|
350 | - |
|
351 | - while($count < $scriptLength) { |
|
352 | - |
|
353 | - if($inSmartyVariable) { |
|
354 | - $start = $count; |
|
355 | - $numOfChars = 1; |
|
356 | - while(isset($javascript[$count]) && $javascript[$count] != '}') { |
|
357 | - $count++; |
|
358 | - $numOfChars++; |
|
359 | - } |
|
360 | - |
|
361 | - $newJavascript .= substr($javascript, $start, $numOfChars); |
|
362 | - $inSmartyVariable = false; |
|
363 | - |
|
364 | - } else { |
|
365 | - |
|
366 | - $char = $javascript[$count]; |
|
367 | - $nextChar = ($count + 1 >= $scriptLength) ? '' : $javascript[$count + 1]; |
|
368 | - |
|
369 | - if($char == "{" && $nextChar == "$") { |
|
370 | - $inSmartyVariable = true; |
|
371 | - $newJavascript .= $javascript[$count]; |
|
372 | - } else if($char == "{") { |
|
373 | - $newJavascript .= " {ldelim} "; |
|
374 | - } else if($char == "}") { |
|
375 | - $newJavascript .= " {rdelim} "; |
|
376 | - } else { |
|
377 | - $newJavascript .= $javascript[$count]; |
|
378 | - } |
|
379 | - } |
|
380 | - $count++; |
|
381 | - } //while |
|
382 | - |
|
383 | - return $newJavascript; |
|
346 | + $newJavascript = ''; |
|
347 | + $scriptLength = strlen($javascript); |
|
348 | + $count = 0; |
|
349 | + $inSmartyVariable = false; |
|
350 | + |
|
351 | + while($count < $scriptLength) { |
|
352 | + |
|
353 | + if($inSmartyVariable) { |
|
354 | + $start = $count; |
|
355 | + $numOfChars = 1; |
|
356 | + while(isset($javascript[$count]) && $javascript[$count] != '}') { |
|
357 | + $count++; |
|
358 | + $numOfChars++; |
|
359 | + } |
|
360 | + |
|
361 | + $newJavascript .= substr($javascript, $start, $numOfChars); |
|
362 | + $inSmartyVariable = false; |
|
363 | + |
|
364 | + } else { |
|
365 | + |
|
366 | + $char = $javascript[$count]; |
|
367 | + $nextChar = ($count + 1 >= $scriptLength) ? '' : $javascript[$count + 1]; |
|
368 | + |
|
369 | + if($char == "{" && $nextChar == "$") { |
|
370 | + $inSmartyVariable = true; |
|
371 | + $newJavascript .= $javascript[$count]; |
|
372 | + } else if($char == "{") { |
|
373 | + $newJavascript .= " {ldelim} "; |
|
374 | + } else if($char == "}") { |
|
375 | + $newJavascript .= " {rdelim} "; |
|
376 | + } else { |
|
377 | + $newJavascript .= $javascript[$count]; |
|
378 | + } |
|
379 | + } |
|
380 | + $count++; |
|
381 | + } //while |
|
382 | + |
|
383 | + return $newJavascript; |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | /** |
@@ -397,43 +397,43 @@ discard block |
||
397 | 397 | */ |
398 | 398 | function findAssignedVariableName($name, $filePath) { |
399 | 399 | |
400 | - if($this->mPHPFile == "INVALID") { |
|
401 | - return $name; |
|
402 | - } |
|
403 | - |
|
404 | - if(!isset($this->mPHPFile)) { |
|
405 | - if(preg_match('/(.*?)(DetailView).html$/', $filePath, $matches)) { |
|
406 | - $dir = $matches[1]; |
|
407 | - } else if(preg_match('/(.*?)(EditView).html$/', $filePath, $matches)) { |
|
408 | - $dir = $matches[1]; |
|
409 | - } |
|
410 | - |
|
411 | - if(!isset($dir) || !is_dir($dir)) { |
|
412 | - $this->mPHPFile = "INVALID"; |
|
413 | - return $name; |
|
414 | - } |
|
415 | - |
|
416 | - $filesInDir = $this->dirList($dir); |
|
417 | - $phpFile = $matches[2].'.*?[\.]php'; |
|
418 | - foreach($filesInDir as $file) { |
|
419 | - if(preg_match("/$phpFile/", $file)) { |
|
420 | - $this->mPHPFile = $matches[1] . $file; |
|
421 | - break; |
|
422 | - } |
|
423 | - } |
|
424 | - |
|
425 | - if(!isset($this->mPHPFile) || !file_exists($this->mPHPFile)) { |
|
426 | - $this->mPHPFile = "INVALID"; |
|
427 | - return $name; |
|
428 | - } |
|
429 | - } |
|
430 | - |
|
431 | - $phpContents = file_get_contents($this->mPHPFile); |
|
432 | - $uname = strtoupper($name); |
|
433 | - if(preg_match("/xtpl->assign[\(][\"\']".$uname."[\"\'][\s]*?,[\s]*?[\$]focus->(.*?)[\)]/si", $phpContents, $matches)) { |
|
434 | - return $matches[1]; |
|
435 | - } |
|
436 | - return $name; |
|
400 | + if($this->mPHPFile == "INVALID") { |
|
401 | + return $name; |
|
402 | + } |
|
403 | + |
|
404 | + if(!isset($this->mPHPFile)) { |
|
405 | + if(preg_match('/(.*?)(DetailView).html$/', $filePath, $matches)) { |
|
406 | + $dir = $matches[1]; |
|
407 | + } else if(preg_match('/(.*?)(EditView).html$/', $filePath, $matches)) { |
|
408 | + $dir = $matches[1]; |
|
409 | + } |
|
410 | + |
|
411 | + if(!isset($dir) || !is_dir($dir)) { |
|
412 | + $this->mPHPFile = "INVALID"; |
|
413 | + return $name; |
|
414 | + } |
|
415 | + |
|
416 | + $filesInDir = $this->dirList($dir); |
|
417 | + $phpFile = $matches[2].'.*?[\.]php'; |
|
418 | + foreach($filesInDir as $file) { |
|
419 | + if(preg_match("/$phpFile/", $file)) { |
|
420 | + $this->mPHPFile = $matches[1] . $file; |
|
421 | + break; |
|
422 | + } |
|
423 | + } |
|
424 | + |
|
425 | + if(!isset($this->mPHPFile) || !file_exists($this->mPHPFile)) { |
|
426 | + $this->mPHPFile = "INVALID"; |
|
427 | + return $name; |
|
428 | + } |
|
429 | + } |
|
430 | + |
|
431 | + $phpContents = file_get_contents($this->mPHPFile); |
|
432 | + $uname = strtoupper($name); |
|
433 | + if(preg_match("/xtpl->assign[\(][\"\']".$uname."[\"\'][\s]*?,[\s]*?[\$]focus->(.*?)[\)]/si", $phpContents, $matches)) { |
|
434 | + return $matches[1]; |
|
435 | + } |
|
436 | + return $name; |
|
437 | 437 | } |
438 | 438 | |
439 | 439 | |
@@ -476,65 +476,65 @@ discard block |
||
476 | 476 | */ |
477 | 477 | function getCustomField($elementNames) { |
478 | 478 | |
479 | - if(!isset($elementNames) || (!is_string($elementNames) && !is_array($elementNames))) { |
|
480 | - return null; |
|
481 | - } |
|
479 | + if(!isset($elementNames) || (!is_string($elementNames) && !is_array($elementNames))) { |
|
480 | + return null; |
|
481 | + } |
|
482 | 482 | |
483 | - if(is_string($elementNames)) { |
|
484 | - if(preg_match('/(.+_c)(_basic)?(\[\])?$/', $elementNames, $matches)) { |
|
485 | - return count($matches) == 1 ? $matches[0] : $matches[1]; |
|
486 | - } |
|
487 | - return null; |
|
488 | - } |
|
483 | + if(is_string($elementNames)) { |
|
484 | + if(preg_match('/(.+_c)(_basic)?(\[\])?$/', $elementNames, $matches)) { |
|
485 | + return count($matches) == 1 ? $matches[0] : $matches[1]; |
|
486 | + } |
|
487 | + return null; |
|
488 | + } |
|
489 | 489 | |
490 | - foreach($elementNames as $name) { |
|
491 | - if(preg_match('/(.+_c)(_basic)?(\[\])?$/', $name, $matches)) { |
|
492 | - return count($matches) == 1 ? $matches[0] : $matches[1]; |
|
493 | - } |
|
494 | - } |
|
490 | + foreach($elementNames as $name) { |
|
491 | + if(preg_match('/(.+_c)(_basic)?(\[\])?$/', $name, $matches)) { |
|
492 | + return count($matches) == 1 ? $matches[0] : $matches[1]; |
|
493 | + } |
|
494 | + } |
|
495 | 495 | |
496 | - return null; |
|
496 | + return null; |
|
497 | 497 | } |
498 | 498 | |
499 | 499 | function applyPreRules($moduleDir, $panels) { |
500 | - if(file_exists("include/SugarFields/Parsers/Rules/".$moduleDir."ParseRule.php")) { |
|
501 | - require_once("include/SugarFields/Parsers/Rules/".$moduleDir."ParseRule.php"); |
|
502 | - $class = $moduleDir."ParseRule"; |
|
503 | - $parseRule = new $class(); |
|
504 | - $panels = $parseRule->preParse($panels, $this->mView); |
|
505 | - } |
|
506 | - return $panels; |
|
500 | + if(file_exists("include/SugarFields/Parsers/Rules/".$moduleDir."ParseRule.php")) { |
|
501 | + require_once("include/SugarFields/Parsers/Rules/".$moduleDir."ParseRule.php"); |
|
502 | + $class = $moduleDir."ParseRule"; |
|
503 | + $parseRule = new $class(); |
|
504 | + $panels = $parseRule->preParse($panels, $this->mView); |
|
505 | + } |
|
506 | + return $panels; |
|
507 | 507 | } |
508 | 508 | |
509 | 509 | function applyRules($moduleDir, $panels) { |
510 | - return $this->applyPostRules($moduleDir, $panels); |
|
510 | + return $this->applyPostRules($moduleDir, $panels); |
|
511 | 511 | } |
512 | 512 | |
513 | 513 | function applyPostRules($moduleDir, $panels) { |
514 | - //Run module specific rules |
|
515 | - if(file_exists("include/SugarFields/Parsers/Rules/".$moduleDir."ParseRule.php")) { |
|
516 | - require_once("include/SugarFields/Parsers/Rules/".$moduleDir."ParseRule.php"); |
|
517 | - $class = $moduleDir."ParseRule"; |
|
518 | - $parseRule = new $class(); |
|
519 | - $panels = $parseRule->parsePanels($panels, $this->mView); |
|
520 | - } |
|
514 | + //Run module specific rules |
|
515 | + if(file_exists("include/SugarFields/Parsers/Rules/".$moduleDir."ParseRule.php")) { |
|
516 | + require_once("include/SugarFields/Parsers/Rules/".$moduleDir."ParseRule.php"); |
|
517 | + $class = $moduleDir."ParseRule"; |
|
518 | + $parseRule = new $class(); |
|
519 | + $panels = $parseRule->parsePanels($panels, $this->mView); |
|
520 | + } |
|
521 | 521 | |
522 | - //Now run defined rules |
|
523 | - require_once("include/SugarFields/Parsers/Rules/ParseRules.php"); |
|
524 | - $rules = ParseRules::getRules(); |
|
522 | + //Now run defined rules |
|
523 | + require_once("include/SugarFields/Parsers/Rules/ParseRules.php"); |
|
524 | + $rules = ParseRules::getRules(); |
|
525 | 525 | |
526 | - foreach($rules as $rule) { |
|
527 | - if(!file_exists($rule['file'])) { |
|
528 | - $GLOBALS['log']->error("Cannot run rule for " . $rule['file']); |
|
529 | - continue; |
|
530 | - } //if |
|
531 | - require_once($rule['file']); |
|
532 | - $runRule = new $rule['class']; |
|
533 | - $panels = $runRule->parsePanels($panels, $this->mView); |
|
526 | + foreach($rules as $rule) { |
|
527 | + if(!file_exists($rule['file'])) { |
|
528 | + $GLOBALS['log']->error("Cannot run rule for " . $rule['file']); |
|
529 | + continue; |
|
530 | + } //if |
|
531 | + require_once($rule['file']); |
|
532 | + $runRule = new $rule['class']; |
|
533 | + $panels = $runRule->parsePanels($panels, $this->mView); |
|
534 | 534 | |
535 | - } //foreach |
|
535 | + } //foreach |
|
536 | 536 | |
537 | - return $panels; |
|
537 | + return $panels; |
|
538 | 538 | } |
539 | 539 | |
540 | 540 | function createFileContents($moduleDir, $panels, $templateMeta=array(), $htmlFilePath) { |
@@ -574,11 +574,11 @@ discard block |
||
574 | 574 | ); |
575 | 575 | ?>"; |
576 | 576 | |
577 | - $metadata = ''; |
|
578 | - $body = var_export($panels, true); |
|
579 | - $metadata = $header . $body . $footer; |
|
580 | - $metadata = preg_replace('/(\d+)[\s]=>[\s]?/',"",$metadata); |
|
581 | - return $metadata; |
|
577 | + $metadata = ''; |
|
578 | + $body = var_export($panels, true); |
|
579 | + $metadata = $header . $body . $footer; |
|
580 | + $metadata = preg_replace('/(\d+)[\s]=>[\s]?/',"",$metadata); |
|
581 | + return $metadata; |
|
582 | 582 | |
583 | 583 | } |
584 | 584 | |
@@ -592,88 +592,88 @@ discard block |
||
592 | 592 | * @return Array of merged $panel definition |
593 | 593 | */ |
594 | 594 | function mergePanels($panels, $vardefs, $moduleDir, $masterCopy) { |
595 | - require($masterCopy); |
|
596 | - $masterpanels = $viewdefs[$moduleDir][$this->mView]['panels']; |
|
597 | - $hasMultiplePanels = $this->hasMultiplePanels($masterpanels); |
|
595 | + require($masterCopy); |
|
596 | + $masterpanels = $viewdefs[$moduleDir][$this->mView]['panels']; |
|
597 | + $hasMultiplePanels = $this->hasMultiplePanels($masterpanels); |
|
598 | 598 | |
599 | - if(!$hasMultiplePanels) { |
|
600 | - $keys = array_keys($viewdefs[$moduleDir][$this->mView]['panels']); |
|
599 | + if(!$hasMultiplePanels) { |
|
600 | + $keys = array_keys($viewdefs[$moduleDir][$this->mView]['panels']); |
|
601 | 601 | if(!empty($keys) && count($keys) == 1) { |
602 | - if(strtolower($keys[0]) == 'default') { |
|
603 | - $masterpanels = array('default'=>$viewdefs[$moduleDir][$this->mView]['panels'][$keys[0]]); |
|
604 | - } else { |
|
605 | - $firstPanel = array_values($viewdefs[$moduleDir][$this->mView]['panels']); |
|
606 | - $masterpanels = array('default'=> $firstPanel[0]); |
|
607 | - } |
|
602 | + if(strtolower($keys[0]) == 'default') { |
|
603 | + $masterpanels = array('default'=>$viewdefs[$moduleDir][$this->mView]['panels'][$keys[0]]); |
|
604 | + } else { |
|
605 | + $firstPanel = array_values($viewdefs[$moduleDir][$this->mView]['panels']); |
|
606 | + $masterpanels = array('default'=> $firstPanel[0]); |
|
607 | + } |
|
608 | 608 | } else { |
609 | - $masterpanels = array('default'=>$viewdefs[$moduleDir][$this->mView]['panels']); |
|
609 | + $masterpanels = array('default'=>$viewdefs[$moduleDir][$this->mView]['panels']); |
|
610 | 610 | } |
611 | - } |
|
612 | - foreach($masterpanels as $name=>$masterpanel) { |
|
613 | - if(isset($panels[$name])) { |
|
614 | - // Get all the names in the panel |
|
615 | - $existingElements = array(); |
|
616 | - $existingLocation = array(); |
|
617 | - |
|
618 | - foreach($panels[$name] as $rowKey=>$row) { |
|
619 | - foreach($row as $colKey=>$column) { |
|
620 | - if(is_array($column) && !empty($column['name'])) { |
|
621 | - $existingElements[$column['name']] = $column['name']; |
|
622 | - $existingLocation[$column['name']] = array("panel"=>$name, "row"=>$rowKey, "col"=>$colKey); |
|
623 | - } else if(!is_array($column) && !empty($column)) { |
|
624 | - $existingElements[$column] = $column; |
|
625 | - $existingLocation[$column] = array("panel"=>$name, "row"=>$rowKey, "col"=>$colKey); |
|
626 | - } |
|
627 | - } //foreach |
|
628 | - } //foreach |
|
629 | - |
|
630 | - // Now check against the $masterCopy |
|
631 | - foreach($masterpanel as $rowKey=>$row) { |
|
632 | - |
|
633 | - $addRow = array(); |
|
634 | - |
|
635 | - foreach($row as $colKey=>$column) { |
|
636 | - if(is_array($column) && isset($column['name'])) { |
|
637 | - $id = $column['name']; |
|
638 | - } else if(!is_array($column) && !empty($column)) { |
|
639 | - $id = $column; |
|
640 | - } else { |
|
641 | - continue; |
|
642 | - } |
|
643 | - if(empty($existingElements[$id])) { |
|
644 | - //Only add if |
|
645 | - // 1) if it is a required field (as defined in metadata) |
|
646 | - // 2) or if it has a customLabel and customCode (a very deep customization) |
|
647 | - if((is_array($column) && !empty($column['displayParams']['required'])) || |
|
648 | - (is_array($column) && !empty($column['customCode']) && !empty($column['customLabel']))) { |
|
649 | - $addRow[] = $column; |
|
650 | - } |
|
651 | - } else { |
|
652 | - //Use definition from master copy instead |
|
653 | - $panels[$existingLocation[$id]['panel']][$existingLocation[$id]['row']][$existingLocation[$id]['col']] = $column; |
|
654 | - } |
|
655 | - } //foreach |
|
656 | - |
|
657 | - // Add it to the $panels |
|
658 | - if(!empty($addRow)) { |
|
659 | - $panels[$name][] = $addRow; |
|
660 | - } |
|
661 | - } //foreach |
|
662 | - |
|
663 | - } else { |
|
664 | - $panels[$name] = $masterpanel; |
|
665 | - } |
|
666 | - } //foreach |
|
667 | - |
|
668 | - // We're not done yet... go through the $panels Array now and try to remove duplicate |
|
669 | - // or empty panels |
|
670 | - foreach($panels as $name=>$panel) { |
|
671 | - if(count($panel) == 0 || !isset($masterpanels[$name])) { |
|
672 | - unset($panels[$name]); |
|
673 | - } |
|
674 | - } //foreach |
|
675 | - |
|
676 | - return $panels; |
|
611 | + } |
|
612 | + foreach($masterpanels as $name=>$masterpanel) { |
|
613 | + if(isset($panels[$name])) { |
|
614 | + // Get all the names in the panel |
|
615 | + $existingElements = array(); |
|
616 | + $existingLocation = array(); |
|
617 | + |
|
618 | + foreach($panels[$name] as $rowKey=>$row) { |
|
619 | + foreach($row as $colKey=>$column) { |
|
620 | + if(is_array($column) && !empty($column['name'])) { |
|
621 | + $existingElements[$column['name']] = $column['name']; |
|
622 | + $existingLocation[$column['name']] = array("panel"=>$name, "row"=>$rowKey, "col"=>$colKey); |
|
623 | + } else if(!is_array($column) && !empty($column)) { |
|
624 | + $existingElements[$column] = $column; |
|
625 | + $existingLocation[$column] = array("panel"=>$name, "row"=>$rowKey, "col"=>$colKey); |
|
626 | + } |
|
627 | + } //foreach |
|
628 | + } //foreach |
|
629 | + |
|
630 | + // Now check against the $masterCopy |
|
631 | + foreach($masterpanel as $rowKey=>$row) { |
|
632 | + |
|
633 | + $addRow = array(); |
|
634 | + |
|
635 | + foreach($row as $colKey=>$column) { |
|
636 | + if(is_array($column) && isset($column['name'])) { |
|
637 | + $id = $column['name']; |
|
638 | + } else if(!is_array($column) && !empty($column)) { |
|
639 | + $id = $column; |
|
640 | + } else { |
|
641 | + continue; |
|
642 | + } |
|
643 | + if(empty($existingElements[$id])) { |
|
644 | + //Only add if |
|
645 | + // 1) if it is a required field (as defined in metadata) |
|
646 | + // 2) or if it has a customLabel and customCode (a very deep customization) |
|
647 | + if((is_array($column) && !empty($column['displayParams']['required'])) || |
|
648 | + (is_array($column) && !empty($column['customCode']) && !empty($column['customLabel']))) { |
|
649 | + $addRow[] = $column; |
|
650 | + } |
|
651 | + } else { |
|
652 | + //Use definition from master copy instead |
|
653 | + $panels[$existingLocation[$id]['panel']][$existingLocation[$id]['row']][$existingLocation[$id]['col']] = $column; |
|
654 | + } |
|
655 | + } //foreach |
|
656 | + |
|
657 | + // Add it to the $panels |
|
658 | + if(!empty($addRow)) { |
|
659 | + $panels[$name][] = $addRow; |
|
660 | + } |
|
661 | + } //foreach |
|
662 | + |
|
663 | + } else { |
|
664 | + $panels[$name] = $masterpanel; |
|
665 | + } |
|
666 | + } //foreach |
|
667 | + |
|
668 | + // We're not done yet... go through the $panels Array now and try to remove duplicate |
|
669 | + // or empty panels |
|
670 | + foreach($panels as $name=>$panel) { |
|
671 | + if(count($panel) == 0 || !isset($masterpanels[$name])) { |
|
672 | + unset($panels[$name]); |
|
673 | + } |
|
674 | + } //foreach |
|
675 | + |
|
676 | + return $panels; |
|
677 | 677 | } |
678 | 678 | |
679 | 679 | /** |
@@ -685,70 +685,70 @@ discard block |
||
685 | 685 | * @return Array of merged $templateMeta definition |
686 | 686 | */ |
687 | 687 | function mergeTemplateMeta($templateMeta, $moduleDir, $masterCopy) { |
688 | - require($masterCopy); |
|
689 | - $masterTemplateMeta = $viewdefs[$moduleDir][$this->mView]['templateMeta']; |
|
688 | + require($masterCopy); |
|
689 | + $masterTemplateMeta = $viewdefs[$moduleDir][$this->mView]['templateMeta']; |
|
690 | 690 | |
691 | - if(isset($masterTemplateMeta['javascript'])) { |
|
692 | - //Insert the getJSPath code back into src value |
|
693 | - $masterTemplateMeta['javascript'] = preg_replace('/src\s*=\s*[\'\"].*?(modules\/|include\/)([^\.]*?\.js)([^\'\"]*?)[\'\"]/i', 'src="@sq . getJSPath(@sq${1}${2}@sq) . @sq"', $masterTemplateMeta['javascript']); |
|
694 | - } |
|
691 | + if(isset($masterTemplateMeta['javascript'])) { |
|
692 | + //Insert the getJSPath code back into src value |
|
693 | + $masterTemplateMeta['javascript'] = preg_replace('/src\s*=\s*[\'\"].*?(modules\/|include\/)([^\.]*?\.js)([^\'\"]*?)[\'\"]/i', 'src="@sq . getJSPath(@sq${1}${2}@sq) . @sq"', $masterTemplateMeta['javascript']); |
|
694 | + } |
|
695 | 695 | |
696 | - return $masterTemplateMeta; |
|
696 | + return $masterTemplateMeta; |
|
697 | 697 | } |
698 | 698 | |
699 | 699 | function hasRequiredSpanLabel($html) { |
700 | - if(empty($html)) { |
|
701 | - return false; |
|
702 | - } |
|
700 | + if(empty($html)) { |
|
701 | + return false; |
|
702 | + } |
|
703 | 703 | |
704 | - return preg_match('/\<(div|span) class=(\")?required(\")?\s?>\*<\/(div|span)>/si', $html); |
|
704 | + return preg_match('/\<(div|span) class=(\")?required(\")?\s?>\*<\/(div|span)>/si', $html); |
|
705 | 705 | } |
706 | 706 | |
707 | 707 | function hasMultiplePanels($panels) { |
708 | 708 | |
709 | - if(!isset($panels) || empty($panels) || !is_array($panels)) { |
|
710 | - return false; |
|
711 | - } |
|
709 | + if(!isset($panels) || empty($panels) || !is_array($panels)) { |
|
710 | + return false; |
|
711 | + } |
|
712 | 712 | |
713 | - if(is_array($panels) && (count($panels) == 0 || count($panels) == 1)) { |
|
714 | - return false; |
|
715 | - } |
|
713 | + if(is_array($panels) && (count($panels) == 0 || count($panels) == 1)) { |
|
714 | + return false; |
|
715 | + } |
|
716 | 716 | |
717 | - foreach($panels as $panel) { |
|
718 | - if(!empty($panel) && !is_array($panel)) { |
|
719 | - return false; |
|
720 | - } else { |
|
721 | - foreach($panel as $row) { |
|
722 | - if(!empty($row) && !is_array($row)) { |
|
723 | - return false; |
|
724 | - } //if |
|
725 | - } //foreach |
|
726 | - } //if-else |
|
727 | - } //foreach |
|
717 | + foreach($panels as $panel) { |
|
718 | + if(!empty($panel) && !is_array($panel)) { |
|
719 | + return false; |
|
720 | + } else { |
|
721 | + foreach($panel as $row) { |
|
722 | + if(!empty($row) && !is_array($row)) { |
|
723 | + return false; |
|
724 | + } //if |
|
725 | + } //foreach |
|
726 | + } //if-else |
|
727 | + } //foreach |
|
728 | 728 | |
729 | - return true; |
|
729 | + return true; |
|
730 | 730 | } |
731 | 731 | |
732 | 732 | function getRelateFieldName($mixed='') { |
733 | - if(!is_array($mixed)) { |
|
734 | - return ''; |
|
735 | - } else if(count($mixed) == 2){ |
|
736 | - $id = ''; |
|
737 | - $name = ''; |
|
738 | - foreach($mixed as $el) { |
|
739 | - if(preg_match('/_id$/', $el)) { |
|
740 | - $id = $el; |
|
741 | - } else if(preg_match('/_name$/', $el)) { |
|
742 | - $name = $el; |
|
743 | - } |
|
744 | - } |
|
745 | - return (!empty($id) && !empty($name)) ? $name : ''; |
|
746 | - } |
|
747 | - return ''; |
|
733 | + if(!is_array($mixed)) { |
|
734 | + return ''; |
|
735 | + } else if(count($mixed) == 2){ |
|
736 | + $id = ''; |
|
737 | + $name = ''; |
|
738 | + foreach($mixed as $el) { |
|
739 | + if(preg_match('/_id$/', $el)) { |
|
740 | + $id = $el; |
|
741 | + } else if(preg_match('/_name$/', $el)) { |
|
742 | + $name = $el; |
|
743 | + } |
|
744 | + } |
|
745 | + return (!empty($id) && !empty($name)) ? $name : ''; |
|
746 | + } |
|
747 | + return ''; |
|
748 | 748 | } |
749 | 749 | |
750 | 750 | function getCustomPanels() { |
751 | - return $this->mCustomPanels; |
|
751 | + return $this->mCustomPanels; |
|
752 | 752 | } |
753 | 753 | |
754 | 754 | /** |
@@ -759,10 +759,10 @@ discard block |
||
759 | 759 | * |
760 | 760 | */ |
761 | 761 | function fixTablesWithMissingTr($tableContents) { |
762 | - if(preg_match('/(<table[^>]*?[\/]?>\s*?<td)/i', $tableContents, $matches)) { |
|
763 | - return preg_replace('/(<table[^>]*?[\/]?>\s*?<td)/i', '<table><tr><td', $tableContents); |
|
764 | - } |
|
765 | - return $tableContents; |
|
762 | + if(preg_match('/(<table[^>]*?[\/]?>\s*?<td)/i', $tableContents, $matches)) { |
|
763 | + return preg_replace('/(<table[^>]*?[\/]?>\s*?<td)/i', '<table><tr><td', $tableContents); |
|
764 | + } |
|
765 | + return $tableContents; |
|
766 | 766 | } |
767 | 767 | |
768 | 768 | /** |
@@ -770,10 +770,10 @@ discard block |
||
770 | 770 | * This is a very crude function to fix instances where files have an </tr> tag immediately followed by a <td> tag |
771 | 771 | */ |
772 | 772 | function fixRowsWithMissingTr($tableContents) { |
773 | - if(preg_match('/(<\/tr[^>]*?[\/]?>\s*?<td)/i', $tableContents, $matches)) { |
|
774 | - return preg_replace('/(<\/tr[^>]*?[\/]?>\s*?<td)/i', '</tr><tr><td', $tableContents); |
|
775 | - } |
|
776 | - return $tableContents; |
|
773 | + if(preg_match('/(<\/tr[^>]*?[\/]?>\s*?<td)/i', $tableContents, $matches)) { |
|
774 | + return preg_replace('/(<\/tr[^>]*?[\/]?>\s*?<td)/i', '</tr><tr><td', $tableContents); |
|
775 | + } |
|
776 | + return $tableContents; |
|
777 | 777 | } |
778 | 778 | |
779 | 779 | /** |
@@ -781,10 +781,10 @@ discard block |
||
781 | 781 | * This is a very crude function to fix instances where files have two consecutive <tr> tags |
782 | 782 | */ |
783 | 783 | function fixDuplicateTrTags($tableContents) { |
784 | - if(preg_match('/(<tr[^>]*?[\/]?>\s*?<tr)/i', $tableContents, $matches)) { |
|
785 | - return preg_replace('/(<tr[^>]*?[\/]?>\s*?<tr)/i', '<tr', $tableContents); |
|
786 | - } |
|
787 | - return $tableContents; |
|
784 | + if(preg_match('/(<tr[^>]*?[\/]?>\s*?<tr)/i', $tableContents, $matches)) { |
|
785 | + return preg_replace('/(<tr[^>]*?[\/]?>\s*?<tr)/i', '<tr', $tableContents); |
|
786 | + } |
|
787 | + return $tableContents; |
|
788 | 788 | } |
789 | 789 | |
790 | 790 | /** |
@@ -793,18 +793,18 @@ discard block |
||
793 | 793 | * return that vardef name |
794 | 794 | */ |
795 | 795 | function findSingleVardefElement($formElements=array(), $vardefs=array()) { |
796 | - if(empty($formElements) || !is_array($formElements)) { |
|
797 | - return ''; |
|
798 | - } |
|
799 | - |
|
800 | - $found = array(); |
|
801 | - foreach($formElements as $el) { |
|
802 | - if(isset($vardefs[$el])) { |
|
803 | - $found[] = $el; |
|
804 | - } |
|
805 | - } |
|
806 | - |
|
807 | - return count($found) == 1 ? $found[0] : ''; |
|
796 | + if(empty($formElements) || !is_array($formElements)) { |
|
797 | + return ''; |
|
798 | + } |
|
799 | + |
|
800 | + $found = array(); |
|
801 | + foreach($formElements as $el) { |
|
802 | + if(isset($vardefs[$el])) { |
|
803 | + $found[] = $el; |
|
804 | + } |
|
805 | + } |
|
806 | + |
|
807 | + return count($found) == 1 ? $found[0] : ''; |
|
808 | 808 | } |
809 | 809 | |
810 | 810 |
@@ -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,7 +66,7 @@ discard block |
||
66 | 66 | * Parses for contents enclosed within <form>...</form> tags |
67 | 67 | */ |
68 | 68 | function getFormContents($contents, $all = true) { |
69 | - if($all) { |
|
69 | + if ($all) { |
|
70 | 70 | preg_match_all("'(<form[^>]*?>)(.*?)(</form[^>]*?>)'si", $contents, $matches); |
71 | 71 | return $matches; |
72 | 72 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | function getFormElements($contents) { |
87 | 87 | preg_match_all("'(<[ ]*?)(textarea|input|select)([^>]*?)(>)'si", $contents, $matches, PREG_PATTERN_ORDER); |
88 | 88 | $elems = array(); |
89 | - foreach($matches[3] as $match) { |
|
89 | + foreach ($matches[3] as $match) { |
|
90 | 90 | $elems[] = $match; |
91 | 91 | } |
92 | 92 | return $elems; |
@@ -118,13 +118,13 @@ discard block |
||
118 | 118 | |
119 | 119 | $exp = "'".$name."[\s]*?=[\s]*?[\'\"]([^\'^\"]*?)[\'\"]'si"; |
120 | 120 | preg_match_all($exp, $contents, $matches, PREG_SET_ORDER); |
121 | - if(empty($filter)) { |
|
121 | + if (empty($filter)) { |
|
122 | 122 | return !empty($matches[0][1]) ? $matches[0][1] : ''; |
123 | 123 | } |
124 | 124 | |
125 | 125 | $filtered = array(); |
126 | - foreach($matches as $tag) { |
|
127 | - if(preg_match($filter, $tag[1])) { |
|
126 | + foreach ($matches as $tag) { |
|
127 | + if (preg_match($filter, $tag[1])) { |
|
128 | 128 | $filtered[] = $tag; |
129 | 129 | } |
130 | 130 | } |
@@ -141,13 +141,13 @@ discard block |
||
141 | 141 | */ |
142 | 142 | function getTables($tableClass = null, $contents) { |
143 | 143 | preg_match_all("'(<table[^>]*?>)(.*?)(</table[^>]*?>)'si", $contents, $matches, PREG_SET_ORDER); |
144 | - if($tableClass == null) { |
|
144 | + if ($tableClass == null) { |
|
145 | 145 | return $matches; |
146 | 146 | } |
147 | 147 | |
148 | 148 | $tables = array(); |
149 | - foreach($matches as $key => $table) { |
|
150 | - if(strpos($table[1], $tableClass) > 0) { |
|
149 | + foreach ($matches as $key => $table) { |
|
150 | + if (strpos($table[1], $tableClass) > 0) { |
|
151 | 151 | $tables[] = $table; |
152 | 152 | } |
153 | 153 | } |
@@ -170,27 +170,27 @@ discard block |
||
170 | 170 | $x = strlen($contents); |
171 | 171 | $mark = 0; |
172 | 172 | $count = 0; |
173 | - $stag1 = "<" . trim($type, " <>") . '>'; |
|
174 | - $stag2 = "<" . trim($type, " <>") . ' '; |
|
173 | + $stag1 = "<".trim($type, " <>").'>'; |
|
174 | + $stag2 = "<".trim($type, " <>").' '; |
|
175 | 175 | $etag = "</".$type.">"; |
176 | 176 | $sincrement = strlen($stag1); |
177 | 177 | $eincrement = strlen($etag); |
178 | 178 | $sarr = array(); |
179 | 179 | $values = array(); |
180 | 180 | |
181 | - while($count < $x) { |
|
181 | + while ($count < $x) { |
|
182 | 182 | $stok = substr($contents, $count, $sincrement); |
183 | 183 | $etok = substr($contents, $count, $eincrement); |
184 | - if($stok == $stag1 || $stok == $stag2) { |
|
184 | + if ($stok == $stag1 || $stok == $stag2) { |
|
185 | 185 | //Reset mark; |
186 | - if(count($sarr) == 0) { |
|
186 | + if (count($sarr) == 0) { |
|
187 | 187 | $mark = $count; |
188 | 188 | } |
189 | 189 | $sarr[] = $count; |
190 | 190 | |
191 | - } else if($etok == $etag) { |
|
191 | + } else if ($etok == $etag) { |
|
192 | 192 | array_shift($sarr); |
193 | - if(count($sarr) == 0) { |
|
193 | + if (count($sarr) == 0) { |
|
194 | 194 | $val = substr($contents, $mark, ($count - $mark) + $eincrement); |
195 | 195 | $values[] = $val; |
196 | 196 | $mark = $count; |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | function stripFlavorTags($contents) { |
232 | 232 | $flavor = isset($GLOBALS['sugar_flavor']) ? $GLOBALS['sugar_flavor'] : 'PRO'; |
233 | 233 | $isPro = ($flavor == 'ENT' || $flavor == 'PRO') ? true : false; |
234 | - if($isPro) { |
|
234 | + if ($isPro) { |
|
235 | 235 | $contents = preg_replace('/<!-- BEGIN: open_source -->.*?<!-- END: open_source -->/', '', $contents); |
236 | 236 | } else { |
237 | 237 | $contents = preg_replace('/<!-- BEGIN: pro -->.*?<!-- END: pro -->/', '', $contents); |
@@ -249,9 +249,9 @@ discard block |
||
249 | 249 | function getMaxColumns($contents, $filter) { |
250 | 250 | preg_match_all("'(<tr[^>]*?>)(.*?)(</tr[^>]*?>)'si", $contents, $matches, PREG_SET_ORDER); |
251 | 251 | $max = 0; |
252 | - foreach($matches as $tableRows) { |
|
252 | + foreach ($matches as $tableRows) { |
|
253 | 253 | $count = substr_count($tableRows[2], $filter); |
254 | - if($count > $max) { |
|
254 | + if ($count > $max) { |
|
255 | 255 | $max = $count; |
256 | 256 | } |
257 | 257 | } |
@@ -263,9 +263,9 @@ discard block |
||
263 | 263 | |
264 | 264 | $elements = array(); |
265 | 265 | |
266 | - foreach($matches as $data) { |
|
266 | + foreach ($matches as $data) { |
|
267 | 267 | // We need 4 because the 1,2,3 indexes make up start,body,end |
268 | - if(count($data) == 4) { |
|
268 | + if (count($data) == 4) { |
|
269 | 269 | $element = array(); |
270 | 270 | $element['start'] = $data[1]; |
271 | 271 | $element['body'] = $data[2]; |
@@ -306,12 +306,12 @@ discard block |
||
306 | 306 | |
307 | 307 | //Check if there are Javascript blocks of code to process |
308 | 308 | preg_match_all("'(<script[^>]*?>)(.*?)(</script[^>]*?>)'si", $contents, $matches, PREG_PATTERN_ORDER); |
309 | -if(empty($matches)) { |
|
309 | +if (empty($matches)) { |
|
310 | 310 | return $javascript; |
311 | 311 | } |
312 | 312 | |
313 | -foreach($matches[0] as $scriptBlock) { |
|
314 | - $javascript .= "\n" . $scriptBlock; |
|
313 | +foreach ($matches[0] as $scriptBlock) { |
|
314 | + $javascript .= "\n".$scriptBlock; |
|
315 | 315 | } //foreach |
316 | 316 | |
317 | 317 | $javascript = substr($javascript, 1); |
@@ -322,11 +322,11 @@ discard block |
||
322 | 322 | |
323 | 323 | //Find all blocks that may need to be replaced with Smarty syntax |
324 | 324 | preg_match_all("'([\{])([a-zA-Z0-9_]*?)([\}])'si", $javascript, $matches, PREG_PATTERN_ORDER); |
325 | -if(!empty($matches)) { |
|
325 | +if (!empty($matches)) { |
|
326 | 326 | $replace = array(); |
327 | 327 | |
328 | - foreach($matches[0] as $xTemplateCode) { |
|
329 | - if(!isset($replace[$xTemplateCode])) { |
|
328 | + foreach ($matches[0] as $xTemplateCode) { |
|
329 | + if (!isset($replace[$xTemplateCode])) { |
|
330 | 330 | $replace[$xTemplateCode] = str_replace("{", "{\$", $xTemplateCode); |
331 | 331 | } //if |
332 | 332 | } //foreach |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | $javascript = str_replace(array_keys($replace), array_values($replace), $javascript); |
335 | 335 | } //if |
336 | 336 | |
337 | -if(!$addLiterals) { |
|
337 | +if (!$addLiterals) { |
|
338 | 338 | return $javascript; |
339 | 339 | } |
340 | 340 | |
@@ -348,12 +348,12 @@ discard block |
||
348 | 348 | $count = 0; |
349 | 349 | $inSmartyVariable = false; |
350 | 350 | |
351 | - while($count < $scriptLength) { |
|
351 | + while ($count < $scriptLength) { |
|
352 | 352 | |
353 | - if($inSmartyVariable) { |
|
353 | + if ($inSmartyVariable) { |
|
354 | 354 | $start = $count; |
355 | 355 | $numOfChars = 1; |
356 | - while(isset($javascript[$count]) && $javascript[$count] != '}') { |
|
356 | + while (isset($javascript[$count]) && $javascript[$count] != '}') { |
|
357 | 357 | $count++; |
358 | 358 | $numOfChars++; |
359 | 359 | } |
@@ -366,12 +366,12 @@ discard block |
||
366 | 366 | $char = $javascript[$count]; |
367 | 367 | $nextChar = ($count + 1 >= $scriptLength) ? '' : $javascript[$count + 1]; |
368 | 368 | |
369 | - if($char == "{" && $nextChar == "$") { |
|
369 | + if ($char == "{" && $nextChar == "$") { |
|
370 | 370 | $inSmartyVariable = true; |
371 | 371 | $newJavascript .= $javascript[$count]; |
372 | - } else if($char == "{") { |
|
373 | - $newJavascript .= " {ldelim} "; |
|
374 | - } else if($char == "}") { |
|
372 | + } else if ($char == "{") { |
|
373 | + $newJavascript .= " {ldelim} "; |
|
374 | + } else if ($char == "}") { |
|
375 | 375 | $newJavascript .= " {rdelim} "; |
376 | 376 | } else { |
377 | 377 | $newJavascript .= $javascript[$count]; |
@@ -397,32 +397,32 @@ discard block |
||
397 | 397 | */ |
398 | 398 | function findAssignedVariableName($name, $filePath) { |
399 | 399 | |
400 | - if($this->mPHPFile == "INVALID") { |
|
400 | + if ($this->mPHPFile == "INVALID") { |
|
401 | 401 | return $name; |
402 | 402 | } |
403 | 403 | |
404 | - if(!isset($this->mPHPFile)) { |
|
405 | - if(preg_match('/(.*?)(DetailView).html$/', $filePath, $matches)) { |
|
404 | + if (!isset($this->mPHPFile)) { |
|
405 | + if (preg_match('/(.*?)(DetailView).html$/', $filePath, $matches)) { |
|
406 | 406 | $dir = $matches[1]; |
407 | - } else if(preg_match('/(.*?)(EditView).html$/', $filePath, $matches)) { |
|
407 | + } else if (preg_match('/(.*?)(EditView).html$/', $filePath, $matches)) { |
|
408 | 408 | $dir = $matches[1]; |
409 | 409 | } |
410 | 410 | |
411 | - if(!isset($dir) || !is_dir($dir)) { |
|
411 | + if (!isset($dir) || !is_dir($dir)) { |
|
412 | 412 | $this->mPHPFile = "INVALID"; |
413 | 413 | return $name; |
414 | 414 | } |
415 | 415 | |
416 | 416 | $filesInDir = $this->dirList($dir); |
417 | 417 | $phpFile = $matches[2].'.*?[\.]php'; |
418 | - foreach($filesInDir as $file) { |
|
419 | - if(preg_match("/$phpFile/", $file)) { |
|
420 | - $this->mPHPFile = $matches[1] . $file; |
|
418 | + foreach ($filesInDir as $file) { |
|
419 | + if (preg_match("/$phpFile/", $file)) { |
|
420 | + $this->mPHPFile = $matches[1].$file; |
|
421 | 421 | break; |
422 | 422 | } |
423 | 423 | } |
424 | 424 | |
425 | - if(!isset($this->mPHPFile) || !file_exists($this->mPHPFile)) { |
|
425 | + if (!isset($this->mPHPFile) || !file_exists($this->mPHPFile)) { |
|
426 | 426 | $this->mPHPFile = "INVALID"; |
427 | 427 | return $name; |
428 | 428 | } |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | |
431 | 431 | $phpContents = file_get_contents($this->mPHPFile); |
432 | 432 | $uname = strtoupper($name); |
433 | - if(preg_match("/xtpl->assign[\(][\"\']".$uname."[\"\'][\s]*?,[\s]*?[\$]focus->(.*?)[\)]/si", $phpContents, $matches)) { |
|
433 | + if (preg_match("/xtpl->assign[\(][\"\']".$uname."[\"\'][\s]*?,[\s]*?[\$]focus->(.*?)[\)]/si", $phpContents, $matches)) { |
|
434 | 434 | return $matches[1]; |
435 | 435 | } |
436 | 436 | return $name; |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | * @param $directory The directory to scan |
445 | 445 | * @return $results The files in the directory that were found |
446 | 446 | */ |
447 | -function dirList ($directory) { |
|
447 | +function dirList($directory) { |
|
448 | 448 | |
449 | 449 | // create an array to hold directory list |
450 | 450 | $results = array(); |
@@ -476,19 +476,19 @@ discard block |
||
476 | 476 | */ |
477 | 477 | function getCustomField($elementNames) { |
478 | 478 | |
479 | - if(!isset($elementNames) || (!is_string($elementNames) && !is_array($elementNames))) { |
|
479 | + if (!isset($elementNames) || (!is_string($elementNames) && !is_array($elementNames))) { |
|
480 | 480 | return null; |
481 | 481 | } |
482 | 482 | |
483 | - if(is_string($elementNames)) { |
|
484 | - if(preg_match('/(.+_c)(_basic)?(\[\])?$/', $elementNames, $matches)) { |
|
483 | + if (is_string($elementNames)) { |
|
484 | + if (preg_match('/(.+_c)(_basic)?(\[\])?$/', $elementNames, $matches)) { |
|
485 | 485 | return count($matches) == 1 ? $matches[0] : $matches[1]; |
486 | 486 | } |
487 | 487 | return null; |
488 | 488 | } |
489 | 489 | |
490 | - foreach($elementNames as $name) { |
|
491 | - if(preg_match('/(.+_c)(_basic)?(\[\])?$/', $name, $matches)) { |
|
490 | + foreach ($elementNames as $name) { |
|
491 | + if (preg_match('/(.+_c)(_basic)?(\[\])?$/', $name, $matches)) { |
|
492 | 492 | return count($matches) == 1 ? $matches[0] : $matches[1]; |
493 | 493 | } |
494 | 494 | } |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | } |
498 | 498 | |
499 | 499 | function applyPreRules($moduleDir, $panels) { |
500 | - if(file_exists("include/SugarFields/Parsers/Rules/".$moduleDir."ParseRule.php")) { |
|
500 | + if (file_exists("include/SugarFields/Parsers/Rules/".$moduleDir."ParseRule.php")) { |
|
501 | 501 | require_once("include/SugarFields/Parsers/Rules/".$moduleDir."ParseRule.php"); |
502 | 502 | $class = $moduleDir."ParseRule"; |
503 | 503 | $parseRule = new $class(); |
@@ -512,7 +512,7 @@ discard block |
||
512 | 512 | |
513 | 513 | function applyPostRules($moduleDir, $panels) { |
514 | 514 | //Run module specific rules |
515 | - if(file_exists("include/SugarFields/Parsers/Rules/".$moduleDir."ParseRule.php")) { |
|
515 | + if (file_exists("include/SugarFields/Parsers/Rules/".$moduleDir."ParseRule.php")) { |
|
516 | 516 | require_once("include/SugarFields/Parsers/Rules/".$moduleDir."ParseRule.php"); |
517 | 517 | $class = $moduleDir."ParseRule"; |
518 | 518 | $parseRule = new $class(); |
@@ -523,9 +523,9 @@ discard block |
||
523 | 523 | require_once("include/SugarFields/Parsers/Rules/ParseRules.php"); |
524 | 524 | $rules = ParseRules::getRules(); |
525 | 525 | |
526 | - foreach($rules as $rule) { |
|
527 | - if(!file_exists($rule['file'])) { |
|
528 | - $GLOBALS['log']->error("Cannot run rule for " . $rule['file']); |
|
526 | + foreach ($rules as $rule) { |
|
527 | + if (!file_exists($rule['file'])) { |
|
528 | + $GLOBALS['log']->error("Cannot run rule for ".$rule['file']); |
|
529 | 529 | continue; |
530 | 530 | } //if |
531 | 531 | require_once($rule['file']); |
@@ -537,11 +537,11 @@ discard block |
||
537 | 537 | return $panels; |
538 | 538 | } |
539 | 539 | |
540 | -function createFileContents($moduleDir, $panels, $templateMeta=array(), $htmlFilePath) { |
|
540 | +function createFileContents($moduleDir, $panels, $templateMeta = array(), $htmlFilePath) { |
|
541 | 541 | |
542 | 542 | $header = "<?php\n\n"; |
543 | 543 | |
544 | -if(empty($templateMeta)) { |
|
544 | +if (empty($templateMeta)) { |
|
545 | 545 | $header .= "\$viewdefs['$moduleDir']['$this->mView'] = array( |
546 | 546 | 'templateMeta' => array('maxColumns' => '2', |
547 | 547 | 'widths' => array( |
@@ -551,7 +551,7 @@ discard block |
||
551 | 551 | ),"; |
552 | 552 | } else { |
553 | 553 | $header .= "\$viewdefs['$moduleDir']['$this->mView'] = array( |
554 | - 'templateMeta' =>" . var_export($templateMeta, true) . ","; |
|
554 | + 'templateMeta' =>".var_export($templateMeta, true).","; |
|
555 | 555 | } |
556 | 556 | |
557 | 557 | //Replace all the @sq (single quote tags that may have been inserted) |
@@ -576,8 +576,8 @@ discard block |
||
576 | 576 | |
577 | 577 | $metadata = ''; |
578 | 578 | $body = var_export($panels, true); |
579 | - $metadata = $header . $body . $footer; |
|
580 | - $metadata = preg_replace('/(\d+)[\s]=>[\s]?/',"",$metadata); |
|
579 | + $metadata = $header.$body.$footer; |
|
580 | + $metadata = preg_replace('/(\d+)[\s]=>[\s]?/', "", $metadata); |
|
581 | 581 | return $metadata; |
582 | 582 | |
583 | 583 | } |
@@ -596,10 +596,10 @@ discard block |
||
596 | 596 | $masterpanels = $viewdefs[$moduleDir][$this->mView]['panels']; |
597 | 597 | $hasMultiplePanels = $this->hasMultiplePanels($masterpanels); |
598 | 598 | |
599 | - if(!$hasMultiplePanels) { |
|
599 | + if (!$hasMultiplePanels) { |
|
600 | 600 | $keys = array_keys($viewdefs[$moduleDir][$this->mView]['panels']); |
601 | - if(!empty($keys) && count($keys) == 1) { |
|
602 | - if(strtolower($keys[0]) == 'default') { |
|
601 | + if (!empty($keys) && count($keys) == 1) { |
|
602 | + if (strtolower($keys[0]) == 'default') { |
|
603 | 603 | $masterpanels = array('default'=>$viewdefs[$moduleDir][$this->mView]['panels'][$keys[0]]); |
604 | 604 | } else { |
605 | 605 | $firstPanel = array_values($viewdefs[$moduleDir][$this->mView]['panels']); |
@@ -609,18 +609,18 @@ discard block |
||
609 | 609 | $masterpanels = array('default'=>$viewdefs[$moduleDir][$this->mView]['panels']); |
610 | 610 | } |
611 | 611 | } |
612 | - foreach($masterpanels as $name=>$masterpanel) { |
|
613 | - if(isset($panels[$name])) { |
|
612 | + foreach ($masterpanels as $name=>$masterpanel) { |
|
613 | + if (isset($panels[$name])) { |
|
614 | 614 | // Get all the names in the panel |
615 | 615 | $existingElements = array(); |
616 | 616 | $existingLocation = array(); |
617 | 617 | |
618 | - foreach($panels[$name] as $rowKey=>$row) { |
|
619 | - foreach($row as $colKey=>$column) { |
|
620 | - if(is_array($column) && !empty($column['name'])) { |
|
618 | + foreach ($panels[$name] as $rowKey=>$row) { |
|
619 | + foreach ($row as $colKey=>$column) { |
|
620 | + if (is_array($column) && !empty($column['name'])) { |
|
621 | 621 | $existingElements[$column['name']] = $column['name']; |
622 | 622 | $existingLocation[$column['name']] = array("panel"=>$name, "row"=>$rowKey, "col"=>$colKey); |
623 | - } else if(!is_array($column) && !empty($column)) { |
|
623 | + } else if (!is_array($column) && !empty($column)) { |
|
624 | 624 | $existingElements[$column] = $column; |
625 | 625 | $existingLocation[$column] = array("panel"=>$name, "row"=>$rowKey, "col"=>$colKey); |
626 | 626 | } |
@@ -628,23 +628,23 @@ discard block |
||
628 | 628 | } //foreach |
629 | 629 | |
630 | 630 | // Now check against the $masterCopy |
631 | - foreach($masterpanel as $rowKey=>$row) { |
|
631 | + foreach ($masterpanel as $rowKey=>$row) { |
|
632 | 632 | |
633 | 633 | $addRow = array(); |
634 | 634 | |
635 | - foreach($row as $colKey=>$column) { |
|
636 | - if(is_array($column) && isset($column['name'])) { |
|
635 | + foreach ($row as $colKey=>$column) { |
|
636 | + if (is_array($column) && isset($column['name'])) { |
|
637 | 637 | $id = $column['name']; |
638 | - } else if(!is_array($column) && !empty($column)) { |
|
638 | + } else if (!is_array($column) && !empty($column)) { |
|
639 | 639 | $id = $column; |
640 | 640 | } else { |
641 | 641 | continue; |
642 | 642 | } |
643 | - if(empty($existingElements[$id])) { |
|
643 | + if (empty($existingElements[$id])) { |
|
644 | 644 | //Only add if |
645 | 645 | // 1) if it is a required field (as defined in metadata) |
646 | 646 | // 2) or if it has a customLabel and customCode (a very deep customization) |
647 | - if((is_array($column) && !empty($column['displayParams']['required'])) || |
|
647 | + if ((is_array($column) && !empty($column['displayParams']['required'])) || |
|
648 | 648 | (is_array($column) && !empty($column['customCode']) && !empty($column['customLabel']))) { |
649 | 649 | $addRow[] = $column; |
650 | 650 | } |
@@ -655,7 +655,7 @@ discard block |
||
655 | 655 | } //foreach |
656 | 656 | |
657 | 657 | // Add it to the $panels |
658 | - if(!empty($addRow)) { |
|
658 | + if (!empty($addRow)) { |
|
659 | 659 | $panels[$name][] = $addRow; |
660 | 660 | } |
661 | 661 | } //foreach |
@@ -667,8 +667,8 @@ discard block |
||
667 | 667 | |
668 | 668 | // We're not done yet... go through the $panels Array now and try to remove duplicate |
669 | 669 | // or empty panels |
670 | - foreach($panels as $name=>$panel) { |
|
671 | - if(count($panel) == 0 || !isset($masterpanels[$name])) { |
|
670 | + foreach ($panels as $name=>$panel) { |
|
671 | + if (count($panel) == 0 || !isset($masterpanels[$name])) { |
|
672 | 672 | unset($panels[$name]); |
673 | 673 | } |
674 | 674 | } //foreach |
@@ -688,7 +688,7 @@ discard block |
||
688 | 688 | require($masterCopy); |
689 | 689 | $masterTemplateMeta = $viewdefs[$moduleDir][$this->mView]['templateMeta']; |
690 | 690 | |
691 | - if(isset($masterTemplateMeta['javascript'])) { |
|
691 | + if (isset($masterTemplateMeta['javascript'])) { |
|
692 | 692 | //Insert the getJSPath code back into src value |
693 | 693 | $masterTemplateMeta['javascript'] = preg_replace('/src\s*=\s*[\'\"].*?(modules\/|include\/)([^\.]*?\.js)([^\'\"]*?)[\'\"]/i', 'src="@sq . getJSPath(@sq${1}${2}@sq) . @sq"', $masterTemplateMeta['javascript']); |
694 | 694 | } |
@@ -697,7 +697,7 @@ discard block |
||
697 | 697 | } |
698 | 698 | |
699 | 699 | function hasRequiredSpanLabel($html) { |
700 | - if(empty($html)) { |
|
700 | + if (empty($html)) { |
|
701 | 701 | return false; |
702 | 702 | } |
703 | 703 | |
@@ -706,20 +706,20 @@ discard block |
||
706 | 706 | |
707 | 707 | function hasMultiplePanels($panels) { |
708 | 708 | |
709 | - if(!isset($panels) || empty($panels) || !is_array($panels)) { |
|
709 | + if (!isset($panels) || empty($panels) || !is_array($panels)) { |
|
710 | 710 | return false; |
711 | 711 | } |
712 | 712 | |
713 | - if(is_array($panels) && (count($panels) == 0 || count($panels) == 1)) { |
|
713 | + if (is_array($panels) && (count($panels) == 0 || count($panels) == 1)) { |
|
714 | 714 | return false; |
715 | 715 | } |
716 | 716 | |
717 | - foreach($panels as $panel) { |
|
718 | - if(!empty($panel) && !is_array($panel)) { |
|
717 | + foreach ($panels as $panel) { |
|
718 | + if (!empty($panel) && !is_array($panel)) { |
|
719 | 719 | return false; |
720 | 720 | } else { |
721 | - foreach($panel as $row) { |
|
722 | - if(!empty($row) && !is_array($row)) { |
|
721 | + foreach ($panel as $row) { |
|
722 | + if (!empty($row) && !is_array($row)) { |
|
723 | 723 | return false; |
724 | 724 | } //if |
725 | 725 | } //foreach |
@@ -729,16 +729,16 @@ discard block |
||
729 | 729 | return true; |
730 | 730 | } |
731 | 731 | |
732 | -function getRelateFieldName($mixed='') { |
|
733 | - if(!is_array($mixed)) { |
|
732 | +function getRelateFieldName($mixed = '') { |
|
733 | + if (!is_array($mixed)) { |
|
734 | 734 | return ''; |
735 | - } else if(count($mixed) == 2){ |
|
735 | + } else if (count($mixed) == 2) { |
|
736 | 736 | $id = ''; |
737 | 737 | $name = ''; |
738 | - foreach($mixed as $el) { |
|
739 | - if(preg_match('/_id$/', $el)) { |
|
738 | + foreach ($mixed as $el) { |
|
739 | + if (preg_match('/_id$/', $el)) { |
|
740 | 740 | $id = $el; |
741 | - } else if(preg_match('/_name$/', $el)) { |
|
741 | + } else if (preg_match('/_name$/', $el)) { |
|
742 | 742 | $name = $el; |
743 | 743 | } |
744 | 744 | } |
@@ -759,7 +759,7 @@ discard block |
||
759 | 759 | * |
760 | 760 | */ |
761 | 761 | function fixTablesWithMissingTr($tableContents) { |
762 | - if(preg_match('/(<table[^>]*?[\/]?>\s*?<td)/i', $tableContents, $matches)) { |
|
762 | + if (preg_match('/(<table[^>]*?[\/]?>\s*?<td)/i', $tableContents, $matches)) { |
|
763 | 763 | return preg_replace('/(<table[^>]*?[\/]?>\s*?<td)/i', '<table><tr><td', $tableContents); |
764 | 764 | } |
765 | 765 | return $tableContents; |
@@ -770,7 +770,7 @@ discard block |
||
770 | 770 | * This is a very crude function to fix instances where files have an </tr> tag immediately followed by a <td> tag |
771 | 771 | */ |
772 | 772 | function fixRowsWithMissingTr($tableContents) { |
773 | - if(preg_match('/(<\/tr[^>]*?[\/]?>\s*?<td)/i', $tableContents, $matches)) { |
|
773 | + if (preg_match('/(<\/tr[^>]*?[\/]?>\s*?<td)/i', $tableContents, $matches)) { |
|
774 | 774 | return preg_replace('/(<\/tr[^>]*?[\/]?>\s*?<td)/i', '</tr><tr><td', $tableContents); |
775 | 775 | } |
776 | 776 | return $tableContents; |
@@ -781,7 +781,7 @@ discard block |
||
781 | 781 | * This is a very crude function to fix instances where files have two consecutive <tr> tags |
782 | 782 | */ |
783 | 783 | function fixDuplicateTrTags($tableContents) { |
784 | - if(preg_match('/(<tr[^>]*?[\/]?>\s*?<tr)/i', $tableContents, $matches)) { |
|
784 | + if (preg_match('/(<tr[^>]*?[\/]?>\s*?<tr)/i', $tableContents, $matches)) { |
|
785 | 785 | return preg_replace('/(<tr[^>]*?[\/]?>\s*?<tr)/i', '<tr', $tableContents); |
786 | 786 | } |
787 | 787 | return $tableContents; |
@@ -792,14 +792,14 @@ discard block |
||
792 | 792 | * Scans array of form elements to see if just one is a vardef element and, if so, |
793 | 793 | * return that vardef name |
794 | 794 | */ |
795 | -function findSingleVardefElement($formElements=array(), $vardefs=array()) { |
|
796 | - if(empty($formElements) || !is_array($formElements)) { |
|
795 | +function findSingleVardefElement($formElements = array(), $vardefs = array()) { |
|
796 | + if (empty($formElements) || !is_array($formElements)) { |
|
797 | 797 | return ''; |
798 | 798 | } |
799 | 799 | |
800 | 800 | $found = array(); |
801 | - foreach($formElements as $el) { |
|
802 | - if(isset($vardefs[$el])) { |
|
801 | + foreach ($formElements as $el) { |
|
802 | + if (isset($vardefs[$el])) { |
|
803 | 803 | $found[] = $el; |
804 | 804 | } |
805 | 805 | } |
@@ -1,5 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
3 | + die('Not A Valid Entry Point'); |
|
4 | +} |
|
3 | 5 | /********************************************************************************* |
4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -456,8 +458,9 @@ discard block |
||
456 | 458 | while ($file = readdir($handler)) { |
457 | 459 | // if $file isn't this directory or its parent, |
458 | 460 | // add it to the results array |
459 | - if ($file != '.' && $file != '..') |
|
460 | - $results[] = $file; |
|
461 | + if ($file != '.' && $file != '..') { |
|
462 | + $results[] = $file; |
|
463 | + } |
|
461 | 464 | } |
462 | 465 | |
463 | 466 | // tidy up: close the handler |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | class QuickCreateMetaParser extends MetaParser { |
53 | 53 | |
54 | 54 | function QuickCreateMetaParser() { |
55 | - $this->mView = 'QuickCreate'; |
|
55 | + $this->mView = 'QuickCreate'; |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -67,199 +67,199 @@ discard block |
||
67 | 67 | **/ |
68 | 68 | function parse($filePath, $vardefs = array(), $moduleDir = '', $merge=false, $masterCopy=null) { |
69 | 69 | |
70 | - global $app_strings; |
|
71 | - $contents = file_get_contents($filePath); |
|
70 | + global $app_strings; |
|
71 | + $contents = file_get_contents($filePath); |
|
72 | 72 | |
73 | - // The contents are not well formed so we add this section to make it easier to parse |
|
74 | - $contents = $this->trimHTML($contents) . '</td></tr></table>'; |
|
75 | - $moduleName = ''; |
|
73 | + // The contents are not well formed so we add this section to make it easier to parse |
|
74 | + $contents = $this->trimHTML($contents) . '</td></tr></table>'; |
|
75 | + $moduleName = ''; |
|
76 | 76 | |
77 | - $forms = $this->getElementsByType("form", $contents); |
|
78 | - $tables = $this->getElementsByType("table", $forms[0] . "</td></tr></table>"); |
|
79 | - $mainrow = $this->getElementsByType("tr", $tables[1]); |
|
80 | - $rows = substr($mainrow[0], strpos($mainrow[0], "</tr>")); |
|
81 | - $tablerows = $this->getElementsByType("tr", $rows); |
|
77 | + $forms = $this->getElementsByType("form", $contents); |
|
78 | + $tables = $this->getElementsByType("table", $forms[0] . "</td></tr></table>"); |
|
79 | + $mainrow = $this->getElementsByType("tr", $tables[1]); |
|
80 | + $rows = substr($mainrow[0], strpos($mainrow[0], "</tr>")); |
|
81 | + $tablerows = $this->getElementsByType("tr", $rows); |
|
82 | 82 | |
83 | - foreach($tablerows as $trow) { |
|
83 | + foreach($tablerows as $trow) { |
|
84 | 84 | |
85 | - $emptyCount = 0; |
|
86 | - $tablecolumns = $this->getElementsByType("td", $trow); |
|
87 | - $col = array(); |
|
88 | - $slot = 0; |
|
85 | + $emptyCount = 0; |
|
86 | + $tablecolumns = $this->getElementsByType("td", $trow); |
|
87 | + $col = array(); |
|
88 | + $slot = 0; |
|
89 | 89 | |
90 | - foreach($tablecolumns as $tcols) { |
|
90 | + foreach($tablecolumns as $tcols) { |
|
91 | 91 | |
92 | - $sugarAttrLabel = $this->getTagAttribute("sugar", $tcols, "'^slot[^b]+$'"); |
|
93 | - $sugarAttrValue = $this->getTagAttribute("sugar", $tcols, "'slot[0-9]+b$'"); |
|
92 | + $sugarAttrLabel = $this->getTagAttribute("sugar", $tcols, "'^slot[^b]+$'"); |
|
93 | + $sugarAttrValue = $this->getTagAttribute("sugar", $tcols, "'slot[0-9]+b$'"); |
|
94 | 94 | |
95 | - // If there wasn't any slot numbering/lettering then just default to expect label->vallue pairs |
|
96 | - $sugarAttrLabel = count($sugarAttrLabel) != 0 ? $sugarAttrLabel : ($slot % 2 == 0) ? true : false; |
|
97 | - $sugarAttrValue = count($sugarAttrValue) != 0 ? $sugarAttrValue : ($slot % 2 == 1) ? true : false; |
|
95 | + // If there wasn't any slot numbering/lettering then just default to expect label->vallue pairs |
|
96 | + $sugarAttrLabel = count($sugarAttrLabel) != 0 ? $sugarAttrLabel : ($slot % 2 == 0) ? true : false; |
|
97 | + $sugarAttrValue = count($sugarAttrValue) != 0 ? $sugarAttrValue : ($slot % 2 == 1) ? true : false; |
|
98 | 98 | |
99 | - $slot++; |
|
99 | + $slot++; |
|
100 | 100 | |
101 | - if($sugarAttrValue) { |
|
101 | + if($sugarAttrValue) { |
|
102 | 102 | |
103 | - $spanValue = strtolower($this->getElementValue("span", $tcols)); |
|
104 | - if(empty($spanValue)) { |
|
103 | + $spanValue = strtolower($this->getElementValue("span", $tcols)); |
|
104 | + if(empty($spanValue)) { |
|
105 | 105 | $spanValue = strtolower($this->getElementValue("slot", $tcols)); |
106 | - } |
|
107 | - if(empty($spanValue)) { |
|
106 | + } |
|
107 | + if(empty($spanValue)) { |
|
108 | 108 | $spanValue = strtolower($this->getElementValue("td", $tcols)); |
109 | - } |
|
109 | + } |
|
110 | 110 | |
111 | - //Get all the editable form elements' names |
|
112 | - $formElementNames = $this->getFormElementsNames($spanValue); |
|
113 | - $customField = $this->getCustomField($formElementNames); |
|
111 | + //Get all the editable form elements' names |
|
112 | + $formElementNames = $this->getFormElementsNames($spanValue); |
|
113 | + $customField = $this->getCustomField($formElementNames); |
|
114 | 114 | |
115 | - $name = ''; |
|
116 | - $readOnly = false; |
|
117 | - $fields = null; |
|
118 | - $customCode = null; |
|
115 | + $name = ''; |
|
116 | + $readOnly = false; |
|
117 | + $fields = null; |
|
118 | + $customCode = null; |
|
119 | 119 | |
120 | - if(!empty($customField)) { |
|
121 | - // If it's a custom field we just set the name |
|
122 | - $name = $customField; |
|
120 | + if(!empty($customField)) { |
|
121 | + // If it's a custom field we just set the name |
|
122 | + $name = $customField; |
|
123 | 123 | |
124 | - } else if(empty($formElementNames) && preg_match_all('/[\{]([^\}]*?)[\}]/s', $spanValue, $matches, PREG_SET_ORDER)) { |
|
125 | - // We are here if the $spanValue did not contain a form element for editing. |
|
126 | - // We will assume that it is read only (since there were no edit form elements) |
|
124 | + } else if(empty($formElementNames) && preg_match_all('/[\{]([^\}]*?)[\}]/s', $spanValue, $matches, PREG_SET_ORDER)) { |
|
125 | + // We are here if the $spanValue did not contain a form element for editing. |
|
126 | + // We will assume that it is read only (since there were no edit form elements) |
|
127 | 127 | |
128 | 128 | |
129 | - // If there is more than one matching {} value then try to find the right one to key off |
|
130 | - // based on vardefs.php file. Also, use the entire spanValue as customCode |
|
131 | - if(count($matches) > 1) { |
|
132 | - $name = $matches[0][1]; |
|
133 | - $customCode = $spanValue; |
|
134 | - foreach($matches as $pair) { |
|
135 | - if(preg_match("/^(mod[\.]|app[\.]).*?/s", $pair[1])) { |
|
136 | - $customCode = str_replace($pair[1], '$'.strtoupper($pair[1]), $customCode); |
|
137 | - } else if(!empty($vardefs[$pair[1]])) { |
|
138 | - $name = $pair[1]; |
|
139 | - $customCode = str_replace($pair[1], '$fields.'.$pair[1].'.value', $customCode); |
|
140 | - } |
|
141 | - } //foreach |
|
142 | - } else { |
|
143 | - //If it is only a label, skip |
|
144 | - if(preg_match("/^(mod[\.]|app[\.]).*?/s", $matches[0][1])) { |
|
145 | - continue; |
|
146 | - } else if(preg_match("/^[\$].*?/s", $matches[0][1])) { |
|
147 | - $name = '{' . strtoupper($matches[0][1]) . '}'; |
|
148 | - } else { |
|
149 | - $name = $matches[0][1]; |
|
150 | - } |
|
151 | - } |
|
129 | + // If there is more than one matching {} value then try to find the right one to key off |
|
130 | + // based on vardefs.php file. Also, use the entire spanValue as customCode |
|
131 | + if(count($matches) > 1) { |
|
132 | + $name = $matches[0][1]; |
|
133 | + $customCode = $spanValue; |
|
134 | + foreach($matches as $pair) { |
|
135 | + if(preg_match("/^(mod[\.]|app[\.]).*?/s", $pair[1])) { |
|
136 | + $customCode = str_replace($pair[1], '$'.strtoupper($pair[1]), $customCode); |
|
137 | + } else if(!empty($vardefs[$pair[1]])) { |
|
138 | + $name = $pair[1]; |
|
139 | + $customCode = str_replace($pair[1], '$fields.'.$pair[1].'.value', $customCode); |
|
140 | + } |
|
141 | + } //foreach |
|
142 | + } else { |
|
143 | + //If it is only a label, skip |
|
144 | + if(preg_match("/^(mod[\.]|app[\.]).*?/s", $matches[0][1])) { |
|
145 | + continue; |
|
146 | + } else if(preg_match("/^[\$].*?/s", $matches[0][1])) { |
|
147 | + $name = '{' . strtoupper($matches[0][1]) . '}'; |
|
148 | + } else { |
|
149 | + $name = $matches[0][1]; |
|
150 | + } |
|
151 | + } |
|
152 | 152 | |
153 | - $readOnly = true; |
|
154 | - } else if(is_array($formElementNames)) { |
|
153 | + $readOnly = true; |
|
154 | + } else if(is_array($formElementNames)) { |
|
155 | 155 | |
156 | - if(count($formElementNames) == 1) { |
|
157 | - if(!empty($vardefs[$formElementNames[0]])) { |
|
158 | - $name = $formElementNames[0]; |
|
159 | - } |
|
160 | - } else { |
|
161 | - $fields = array(); |
|
162 | - foreach($formElementNames as $elementName) { |
|
163 | - // What we are doing here is saying that we will add all your fields assuming |
|
164 | - // there are none that are of type relate or link. However, if we find such a type |
|
165 | - // we'll take the first one found and assume that is the field you want (the SugarFields |
|
166 | - // library will handle rendering the popup and select and clear buttons for you). |
|
167 | - if(isset($vardefs[$elementName])) { |
|
168 | - $type = $vardefs[$elementName]['type']; |
|
169 | - if($type != 'relate' && $type != 'link') { |
|
170 | - $fields[] = $elementName; |
|
171 | - $name = $elementName; |
|
172 | - } else { |
|
173 | - unset($fields); |
|
174 | - $name = $elementName; |
|
175 | - break; |
|
176 | - } |
|
177 | - } |
|
178 | - } |
|
179 | - } //if-else |
|
180 | - } |
|
156 | + if(count($formElementNames) == 1) { |
|
157 | + if(!empty($vardefs[$formElementNames[0]])) { |
|
158 | + $name = $formElementNames[0]; |
|
159 | + } |
|
160 | + } else { |
|
161 | + $fields = array(); |
|
162 | + foreach($formElementNames as $elementName) { |
|
163 | + // What we are doing here is saying that we will add all your fields assuming |
|
164 | + // there are none that are of type relate or link. However, if we find such a type |
|
165 | + // we'll take the first one found and assume that is the field you want (the SugarFields |
|
166 | + // library will handle rendering the popup and select and clear buttons for you). |
|
167 | + if(isset($vardefs[$elementName])) { |
|
168 | + $type = $vardefs[$elementName]['type']; |
|
169 | + if($type != 'relate' && $type != 'link') { |
|
170 | + $fields[] = $elementName; |
|
171 | + $name = $elementName; |
|
172 | + } else { |
|
173 | + unset($fields); |
|
174 | + $name = $elementName; |
|
175 | + break; |
|
176 | + } |
|
177 | + } |
|
178 | + } |
|
179 | + } //if-else |
|
180 | + } |
|
181 | 181 | |
182 | - // Build the entry |
|
183 | - if(preg_match("/<textarea/si", $spanValue)) { |
|
184 | - //special case for textarea form elements (add the displayParams) |
|
185 | - $displayParams = array(); |
|
186 | - $displayParams['rows'] = $this->getTagAttribute("rows", $spanValue); |
|
187 | - $displayParams['cols'] = $this->getTagAttribute("cols", $spanValue); |
|
182 | + // Build the entry |
|
183 | + if(preg_match("/<textarea/si", $spanValue)) { |
|
184 | + //special case for textarea form elements (add the displayParams) |
|
185 | + $displayParams = array(); |
|
186 | + $displayParams['rows'] = $this->getTagAttribute("rows", $spanValue); |
|
187 | + $displayParams['cols'] = $this->getTagAttribute("cols", $spanValue); |
|
188 | 188 | |
189 | - if(!empty($displayParams['rows']) && !empty($displayParams['cols'])) { |
|
190 | - $field = array(); |
|
191 | - $field['name'] = $name; |
|
192 | - $field['displayParams'] = $displayParams; |
|
193 | - } else { |
|
194 | - $field = $name; |
|
195 | - } |
|
196 | - $col[] = $field; |
|
197 | - } else if($readOnly) { |
|
198 | - $field = array(); |
|
199 | - $field['name'] = $name; |
|
200 | - $field['type'] = 'readonly'; |
|
201 | - if(isset($customCode)) { |
|
202 | - $field['customCode'] = $customCode; |
|
203 | - } //if |
|
204 | - $col[] = $field; |
|
205 | - } else { |
|
189 | + if(!empty($displayParams['rows']) && !empty($displayParams['cols'])) { |
|
190 | + $field = array(); |
|
191 | + $field['name'] = $name; |
|
192 | + $field['displayParams'] = $displayParams; |
|
193 | + } else { |
|
194 | + $field = $name; |
|
195 | + } |
|
196 | + $col[] = $field; |
|
197 | + } else if($readOnly) { |
|
198 | + $field = array(); |
|
199 | + $field['name'] = $name; |
|
200 | + $field['type'] = 'readonly'; |
|
201 | + if(isset($customCode)) { |
|
202 | + $field['customCode'] = $customCode; |
|
203 | + } //if |
|
204 | + $col[] = $field; |
|
205 | + } else { |
|
206 | 206 | |
207 | - if(isset($fields) || isset($customCode)) { |
|
208 | - $field = array(); |
|
209 | - $field['name'] = $name; |
|
210 | - if(isset($fields)) { |
|
211 | - $field['fields'] = $fields; |
|
212 | - } |
|
213 | - if(isset($customCode)) { |
|
214 | - $field['customCode'] = $customCode; |
|
215 | - } |
|
207 | + if(isset($fields) || isset($customCode)) { |
|
208 | + $field = array(); |
|
209 | + $field['name'] = $name; |
|
210 | + if(isset($fields)) { |
|
211 | + $field['fields'] = $fields; |
|
212 | + } |
|
213 | + if(isset($customCode)) { |
|
214 | + $field['customCode'] = $customCode; |
|
215 | + } |
|
216 | 216 | |
217 | - $col[] = $field; |
|
218 | - } else { |
|
219 | - $emptyCount = $name == '' ? $emptyCount + 1 : $emptyCount; |
|
220 | - $col[] = $name; |
|
221 | - } |
|
222 | - } //if-else if-else block |
|
223 | - } //if($sugarAttrValue) |
|
224 | - } //foreach |
|
217 | + $col[] = $field; |
|
218 | + } else { |
|
219 | + $emptyCount = $name == '' ? $emptyCount + 1 : $emptyCount; |
|
220 | + $col[] = $name; |
|
221 | + } |
|
222 | + } //if-else if-else block |
|
223 | + } //if($sugarAttrValue) |
|
224 | + } //foreach |
|
225 | 225 | |
226 | - // One last final check. If $emptyCount does not equal Array $col count, don't add |
|
227 | - if($emptyCount != count($col)) { |
|
228 | - $metarow[] = $col; |
|
229 | - } //if |
|
230 | - } //foreach |
|
226 | + // One last final check. If $emptyCount does not equal Array $col count, don't add |
|
227 | + if($emptyCount != count($col)) { |
|
228 | + $metarow[] = $col; |
|
229 | + } //if |
|
230 | + } //foreach |
|
231 | 231 | |
232 | - $templateMeta = array(); |
|
233 | - $templateMeta['form']['buttons'] = 'button'; |
|
232 | + $templateMeta = array(); |
|
233 | + $templateMeta['form']['buttons'] = 'button'; |
|
234 | 234 | |
235 | - preg_match_all("/(<input[^>]*?)>/si", $tables[0], $matches); |
|
236 | - $buttons = array(); |
|
237 | - foreach($matches[0] as $button) { |
|
238 | - $buttons[] = array('customCode'=>$button); |
|
239 | - } |
|
240 | - $templateMeta['form']['buttons'] = $buttons; |
|
235 | + preg_match_all("/(<input[^>]*?)>/si", $tables[0], $matches); |
|
236 | + $buttons = array(); |
|
237 | + foreach($matches[0] as $button) { |
|
238 | + $buttons[] = array('customCode'=>$button); |
|
239 | + } |
|
240 | + $templateMeta['form']['buttons'] = $buttons; |
|
241 | 241 | |
242 | - $formElements = $this->getFormElements($contents); |
|
243 | - $hiddenInputs = array(); |
|
244 | - foreach($formElements as $elem) { |
|
245 | - $type = $this->getTagAttribute("type", $elem); |
|
246 | - if(preg_match('/hidden/si',$type, $matches)) { |
|
247 | - $name = $this->getTagAttribute("name", $elem); |
|
248 | - $value = $this->getTagAttribute("value", $elem); |
|
249 | - $index = stripos($value, '$REQUEST'); |
|
250 | - $value = !empty($index) ? '$smarty.request.' . substr($value, 10) : $value; |
|
251 | - $hiddenInputs[] = '<input id="' . $name . '" name="' . $name . '" value="' . $value . '">'; |
|
252 | - } |
|
253 | - } //foreach |
|
242 | + $formElements = $this->getFormElements($contents); |
|
243 | + $hiddenInputs = array(); |
|
244 | + foreach($formElements as $elem) { |
|
245 | + $type = $this->getTagAttribute("type", $elem); |
|
246 | + if(preg_match('/hidden/si',$type, $matches)) { |
|
247 | + $name = $this->getTagAttribute("name", $elem); |
|
248 | + $value = $this->getTagAttribute("value", $elem); |
|
249 | + $index = stripos($value, '$REQUEST'); |
|
250 | + $value = !empty($index) ? '$smarty.request.' . substr($value, 10) : $value; |
|
251 | + $hiddenInputs[] = '<input id="' . $name . '" name="' . $name . '" value="' . $value . '">'; |
|
252 | + } |
|
253 | + } //foreach |
|
254 | 254 | |
255 | - $templateMeta['form']['hidden'] = $hiddenInputs; |
|
256 | - $templateMeta['widths'] = array(array('label' => '10', 'field' => '30'), array('label' => '10', 'field' => '30')); |
|
257 | - $templateMeta['maxColumns'] = 2; |
|
255 | + $templateMeta['form']['hidden'] = $hiddenInputs; |
|
256 | + $templateMeta['widths'] = array(array('label' => '10', 'field' => '30'), array('label' => '10', 'field' => '30')); |
|
257 | + $templateMeta['maxColumns'] = 2; |
|
258 | 258 | |
259 | - $panels = array(); |
|
260 | - $panels['default'] = $metarow; |
|
261 | - $panels = $this->appplyRules($moduleDir, $panels); |
|
262 | - return $this->createFileContents($moduleDir, $panels, $templateMeta, $filePath); |
|
259 | + $panels = array(); |
|
260 | + $panels['default'] = $metarow; |
|
261 | + $panels = $this->appplyRules($moduleDir, $panels); |
|
262 | + return $this->createFileContents($moduleDir, $panels, $templateMeta, $filePath); |
|
263 | 263 | |
264 | 264 | |
265 | 265 | } |
@@ -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. |
@@ -65,29 +65,29 @@ discard block |
||
65 | 65 | * @param $masterCopy The file path of the mater copy of the metadata file to merge against |
66 | 66 | * @return String format of metadata contents |
67 | 67 | **/ |
68 | -function parse($filePath, $vardefs = array(), $moduleDir = '', $merge=false, $masterCopy=null) { |
|
68 | +function parse($filePath, $vardefs = array(), $moduleDir = '', $merge = false, $masterCopy = null) { |
|
69 | 69 | |
70 | 70 | global $app_strings; |
71 | 71 | $contents = file_get_contents($filePath); |
72 | 72 | |
73 | 73 | // The contents are not well formed so we add this section to make it easier to parse |
74 | - $contents = $this->trimHTML($contents) . '</td></tr></table>'; |
|
74 | + $contents = $this->trimHTML($contents).'</td></tr></table>'; |
|
75 | 75 | $moduleName = ''; |
76 | 76 | |
77 | 77 | $forms = $this->getElementsByType("form", $contents); |
78 | - $tables = $this->getElementsByType("table", $forms[0] . "</td></tr></table>"); |
|
78 | + $tables = $this->getElementsByType("table", $forms[0]."</td></tr></table>"); |
|
79 | 79 | $mainrow = $this->getElementsByType("tr", $tables[1]); |
80 | 80 | $rows = substr($mainrow[0], strpos($mainrow[0], "</tr>")); |
81 | 81 | $tablerows = $this->getElementsByType("tr", $rows); |
82 | 82 | |
83 | - foreach($tablerows as $trow) { |
|
83 | + foreach ($tablerows as $trow) { |
|
84 | 84 | |
85 | 85 | $emptyCount = 0; |
86 | 86 | $tablecolumns = $this->getElementsByType("td", $trow); |
87 | 87 | $col = array(); |
88 | 88 | $slot = 0; |
89 | 89 | |
90 | - foreach($tablecolumns as $tcols) { |
|
90 | + foreach ($tablecolumns as $tcols) { |
|
91 | 91 | |
92 | 92 | $sugarAttrLabel = $this->getTagAttribute("sugar", $tcols, "'^slot[^b]+$'"); |
93 | 93 | $sugarAttrValue = $this->getTagAttribute("sugar", $tcols, "'slot[0-9]+b$'"); |
@@ -98,13 +98,13 @@ discard block |
||
98 | 98 | |
99 | 99 | $slot++; |
100 | 100 | |
101 | - if($sugarAttrValue) { |
|
101 | + if ($sugarAttrValue) { |
|
102 | 102 | |
103 | 103 | $spanValue = strtolower($this->getElementValue("span", $tcols)); |
104 | - if(empty($spanValue)) { |
|
104 | + if (empty($spanValue)) { |
|
105 | 105 | $spanValue = strtolower($this->getElementValue("slot", $tcols)); |
106 | 106 | } |
107 | - if(empty($spanValue)) { |
|
107 | + if (empty($spanValue)) { |
|
108 | 108 | $spanValue = strtolower($this->getElementValue("td", $tcols)); |
109 | 109 | } |
110 | 110 | |
@@ -117,56 +117,56 @@ discard block |
||
117 | 117 | $fields = null; |
118 | 118 | $customCode = null; |
119 | 119 | |
120 | - if(!empty($customField)) { |
|
120 | + if (!empty($customField)) { |
|
121 | 121 | // If it's a custom field we just set the name |
122 | 122 | $name = $customField; |
123 | 123 | |
124 | - } else if(empty($formElementNames) && preg_match_all('/[\{]([^\}]*?)[\}]/s', $spanValue, $matches, PREG_SET_ORDER)) { |
|
124 | + } else if (empty($formElementNames) && preg_match_all('/[\{]([^\}]*?)[\}]/s', $spanValue, $matches, PREG_SET_ORDER)) { |
|
125 | 125 | // We are here if the $spanValue did not contain a form element for editing. |
126 | 126 | // We will assume that it is read only (since there were no edit form elements) |
127 | 127 | |
128 | 128 | |
129 | 129 | // If there is more than one matching {} value then try to find the right one to key off |
130 | 130 | // based on vardefs.php file. Also, use the entire spanValue as customCode |
131 | - if(count($matches) > 1) { |
|
131 | + if (count($matches) > 1) { |
|
132 | 132 | $name = $matches[0][1]; |
133 | 133 | $customCode = $spanValue; |
134 | - foreach($matches as $pair) { |
|
135 | - if(preg_match("/^(mod[\.]|app[\.]).*?/s", $pair[1])) { |
|
134 | + foreach ($matches as $pair) { |
|
135 | + if (preg_match("/^(mod[\.]|app[\.]).*?/s", $pair[1])) { |
|
136 | 136 | $customCode = str_replace($pair[1], '$'.strtoupper($pair[1]), $customCode); |
137 | - } else if(!empty($vardefs[$pair[1]])) { |
|
137 | + } else if (!empty($vardefs[$pair[1]])) { |
|
138 | 138 | $name = $pair[1]; |
139 | 139 | $customCode = str_replace($pair[1], '$fields.'.$pair[1].'.value', $customCode); |
140 | 140 | } |
141 | 141 | } //foreach |
142 | 142 | } else { |
143 | 143 | //If it is only a label, skip |
144 | - if(preg_match("/^(mod[\.]|app[\.]).*?/s", $matches[0][1])) { |
|
144 | + if (preg_match("/^(mod[\.]|app[\.]).*?/s", $matches[0][1])) { |
|
145 | 145 | continue; |
146 | - } else if(preg_match("/^[\$].*?/s", $matches[0][1])) { |
|
147 | - $name = '{' . strtoupper($matches[0][1]) . '}'; |
|
146 | + } else if (preg_match("/^[\$].*?/s", $matches[0][1])) { |
|
147 | + $name = '{'.strtoupper($matches[0][1]).'}'; |
|
148 | 148 | } else { |
149 | 149 | $name = $matches[0][1]; |
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
153 | 153 | $readOnly = true; |
154 | - } else if(is_array($formElementNames)) { |
|
154 | + } else if (is_array($formElementNames)) { |
|
155 | 155 | |
156 | - if(count($formElementNames) == 1) { |
|
157 | - if(!empty($vardefs[$formElementNames[0]])) { |
|
156 | + if (count($formElementNames) == 1) { |
|
157 | + if (!empty($vardefs[$formElementNames[0]])) { |
|
158 | 158 | $name = $formElementNames[0]; |
159 | 159 | } |
160 | 160 | } else { |
161 | 161 | $fields = array(); |
162 | - foreach($formElementNames as $elementName) { |
|
162 | + foreach ($formElementNames as $elementName) { |
|
163 | 163 | // What we are doing here is saying that we will add all your fields assuming |
164 | 164 | // there are none that are of type relate or link. However, if we find such a type |
165 | 165 | // we'll take the first one found and assume that is the field you want (the SugarFields |
166 | 166 | // library will handle rendering the popup and select and clear buttons for you). |
167 | - if(isset($vardefs[$elementName])) { |
|
167 | + if (isset($vardefs[$elementName])) { |
|
168 | 168 | $type = $vardefs[$elementName]['type']; |
169 | - if($type != 'relate' && $type != 'link') { |
|
169 | + if ($type != 'relate' && $type != 'link') { |
|
170 | 170 | $fields[] = $elementName; |
171 | 171 | $name = $elementName; |
172 | 172 | } else { |
@@ -180,13 +180,13 @@ discard block |
||
180 | 180 | } |
181 | 181 | |
182 | 182 | // Build the entry |
183 | - if(preg_match("/<textarea/si", $spanValue)) { |
|
183 | + if (preg_match("/<textarea/si", $spanValue)) { |
|
184 | 184 | //special case for textarea form elements (add the displayParams) |
185 | 185 | $displayParams = array(); |
186 | 186 | $displayParams['rows'] = $this->getTagAttribute("rows", $spanValue); |
187 | 187 | $displayParams['cols'] = $this->getTagAttribute("cols", $spanValue); |
188 | 188 | |
189 | - if(!empty($displayParams['rows']) && !empty($displayParams['cols'])) { |
|
189 | + if (!empty($displayParams['rows']) && !empty($displayParams['cols'])) { |
|
190 | 190 | $field = array(); |
191 | 191 | $field['name'] = $name; |
192 | 192 | $field['displayParams'] = $displayParams; |
@@ -194,23 +194,23 @@ discard block |
||
194 | 194 | $field = $name; |
195 | 195 | } |
196 | 196 | $col[] = $field; |
197 | - } else if($readOnly) { |
|
197 | + } else if ($readOnly) { |
|
198 | 198 | $field = array(); |
199 | 199 | $field['name'] = $name; |
200 | 200 | $field['type'] = 'readonly'; |
201 | - if(isset($customCode)) { |
|
201 | + if (isset($customCode)) { |
|
202 | 202 | $field['customCode'] = $customCode; |
203 | 203 | } //if |
204 | 204 | $col[] = $field; |
205 | 205 | } else { |
206 | 206 | |
207 | - if(isset($fields) || isset($customCode)) { |
|
207 | + if (isset($fields) || isset($customCode)) { |
|
208 | 208 | $field = array(); |
209 | 209 | $field['name'] = $name; |
210 | - if(isset($fields)) { |
|
210 | + if (isset($fields)) { |
|
211 | 211 | $field['fields'] = $fields; |
212 | 212 | } |
213 | - if(isset($customCode)) { |
|
213 | + if (isset($customCode)) { |
|
214 | 214 | $field['customCode'] = $customCode; |
215 | 215 | } |
216 | 216 | |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | } //foreach |
225 | 225 | |
226 | 226 | // One last final check. If $emptyCount does not equal Array $col count, don't add |
227 | - if($emptyCount != count($col)) { |
|
227 | + if ($emptyCount != count($col)) { |
|
228 | 228 | $metarow[] = $col; |
229 | 229 | } //if |
230 | 230 | } //foreach |
@@ -234,26 +234,26 @@ discard block |
||
234 | 234 | |
235 | 235 | preg_match_all("/(<input[^>]*?)>/si", $tables[0], $matches); |
236 | 236 | $buttons = array(); |
237 | - foreach($matches[0] as $button) { |
|
237 | + foreach ($matches[0] as $button) { |
|
238 | 238 | $buttons[] = array('customCode'=>$button); |
239 | 239 | } |
240 | 240 | $templateMeta['form']['buttons'] = $buttons; |
241 | 241 | |
242 | 242 | $formElements = $this->getFormElements($contents); |
243 | 243 | $hiddenInputs = array(); |
244 | - foreach($formElements as $elem) { |
|
244 | + foreach ($formElements as $elem) { |
|
245 | 245 | $type = $this->getTagAttribute("type", $elem); |
246 | - if(preg_match('/hidden/si',$type, $matches)) { |
|
246 | + if (preg_match('/hidden/si', $type, $matches)) { |
|
247 | 247 | $name = $this->getTagAttribute("name", $elem); |
248 | 248 | $value = $this->getTagAttribute("value", $elem); |
249 | 249 | $index = stripos($value, '$REQUEST'); |
250 | - $value = !empty($index) ? '$smarty.request.' . substr($value, 10) : $value; |
|
251 | - $hiddenInputs[] = '<input id="' . $name . '" name="' . $name . '" value="' . $value . '">'; |
|
250 | + $value = !empty($index) ? '$smarty.request.'.substr($value, 10) : $value; |
|
251 | + $hiddenInputs[] = '<input id="'.$name.'" name="'.$name.'" value="'.$value.'">'; |
|
252 | 252 | } |
253 | 253 | } //foreach |
254 | 254 | |
255 | 255 | $templateMeta['form']['hidden'] = $hiddenInputs; |
256 | - $templateMeta['widths'] = array(array('label' => '10', 'field' => '30'), array('label' => '10', 'field' => '30')); |
|
256 | + $templateMeta['widths'] = array(array('label' => '10', 'field' => '30'), array('label' => '10', 'field' => '30')); |
|
257 | 257 | $templateMeta['maxColumns'] = 2; |
258 | 258 | |
259 | 259 | $panels = array(); |
@@ -1,5 +1,7 @@ |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
3 | + die('Not A Valid Entry Point'); |
|
4 | +} |
|
3 | 5 | /********************************************************************************* |
4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | class EditViewMetaParser extends MetaParser { |
53 | 53 | |
54 | 54 | function EditViewMetaParser() { |
55 | - $this->mView = 'EditView'; |
|
55 | + $this->mView = 'EditView'; |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -67,277 +67,277 @@ discard block |
||
67 | 67 | **/ |
68 | 68 | function parse($filePath, $vardefs = array(), $moduleDir = '', $merge=false, $masterCopy=null) { |
69 | 69 | |
70 | - global $app_strings; |
|
71 | - $contents = file_get_contents($filePath); |
|
72 | - $contents = $this->trimHTML($contents); |
|
73 | - $contents = $this->stripFlavorTags($contents); |
|
74 | - $moduleName = ''; |
|
70 | + global $app_strings; |
|
71 | + $contents = file_get_contents($filePath); |
|
72 | + $contents = $this->trimHTML($contents); |
|
73 | + $contents = $this->stripFlavorTags($contents); |
|
74 | + $moduleName = ''; |
|
75 | 75 | |
76 | - $contents = $this->fixDuplicateTrTags($contents); |
|
77 | - $contents = $this->fixRowsWithMissingTr($contents); |
|
76 | + $contents = $this->fixDuplicateTrTags($contents); |
|
77 | + $contents = $this->fixRowsWithMissingTr($contents); |
|
78 | 78 | |
79 | - $tables = $this->getElementsByType("table", $contents); |
|
80 | - $formElements = $this->getFormElements($tables[0]); |
|
81 | - $hiddenInputs = array(); |
|
82 | - foreach($formElements as $elem) { |
|
83 | - $type = $this->getTagAttribute("type", $elem); |
|
84 | - if(preg_match('/hidden/si',$type)) { |
|
85 | - $name = $this->getTagAttribute("name", $elem); |
|
86 | - $value = $this->getTagAttribute("value", $elem); |
|
87 | - $hiddenInputs[$name] = $value; |
|
88 | - } |
|
89 | - } |
|
79 | + $tables = $this->getElementsByType("table", $contents); |
|
80 | + $formElements = $this->getFormElements($tables[0]); |
|
81 | + $hiddenInputs = array(); |
|
82 | + foreach($formElements as $elem) { |
|
83 | + $type = $this->getTagAttribute("type", $elem); |
|
84 | + if(preg_match('/hidden/si',$type)) { |
|
85 | + $name = $this->getTagAttribute("name", $elem); |
|
86 | + $value = $this->getTagAttribute("value", $elem); |
|
87 | + $hiddenInputs[$name] = $value; |
|
88 | + } |
|
89 | + } |
|
90 | 90 | |
91 | - // Get the second table in the page and onward |
|
92 | - $tables = array_slice($tables, 1); |
|
93 | - $panels = array(); |
|
94 | - $tableCount = 0; |
|
95 | - $addedElements = array(); |
|
96 | - $maxTableCountNum = 0; |
|
97 | - $tableCount = 0; |
|
98 | - foreach($tables as $table) { |
|
99 | - $table = $this->fixTablesWithMissingTr($table); |
|
100 | - $toptr = $this->getElementsByType("tr", $table); |
|
101 | - foreach($toptr as $tr) { |
|
102 | - $tabledata = $this->getElementsByType("table", $tr); |
|
103 | - $data = array(); |
|
104 | - $panelKey = $tableCount == 0 ? "default" : ''; |
|
105 | - foreach($tabledata as $t) { |
|
106 | - $vals = array_values($this->getElementsByType("tr", $t)); |
|
107 | - if(preg_match_all('/<h4[^>]*?>.*?(\{MOD\.|\{APP\.)(LBL_[^\}]*?)[\}].*?<\/h4>/s', $vals[0], $matches, PREG_SET_ORDER)) { |
|
108 | - array_shift($vals); |
|
109 | - $panelKey = count($matches[0]) == 3 ? strtolower($matches[0][2]) : $panelKey; |
|
110 | - } |
|
91 | + // Get the second table in the page and onward |
|
92 | + $tables = array_slice($tables, 1); |
|
93 | + $panels = array(); |
|
94 | + $tableCount = 0; |
|
95 | + $addedElements = array(); |
|
96 | + $maxTableCountNum = 0; |
|
97 | + $tableCount = 0; |
|
98 | + foreach($tables as $table) { |
|
99 | + $table = $this->fixTablesWithMissingTr($table); |
|
100 | + $toptr = $this->getElementsByType("tr", $table); |
|
101 | + foreach($toptr as $tr) { |
|
102 | + $tabledata = $this->getElementsByType("table", $tr); |
|
103 | + $data = array(); |
|
104 | + $panelKey = $tableCount == 0 ? "default" : ''; |
|
105 | + foreach($tabledata as $t) { |
|
106 | + $vals = array_values($this->getElementsByType("tr", $t)); |
|
107 | + if(preg_match_all('/<h4[^>]*?>.*?(\{MOD\.|\{APP\.)(LBL_[^\}]*?)[\}].*?<\/h4>/s', $vals[0], $matches, PREG_SET_ORDER)) { |
|
108 | + array_shift($vals); |
|
109 | + $panelKey = count($matches[0]) == 3 ? strtolower($matches[0][2]) : $panelKey; |
|
110 | + } |
|
111 | 111 | |
112 | - //If $panelKey is empty use the maxTableCountNum value |
|
113 | - if(empty($panelKey)) { |
|
114 | - $panels[$maxTableCountNum++] = $vals; |
|
115 | - } else { |
|
116 | - $panels[$panelKey] = $vals; |
|
117 | - } |
|
118 | - } //foreach |
|
119 | - $tableCount++; |
|
120 | - } //foreach; |
|
121 | - } //foreach |
|
112 | + //If $panelKey is empty use the maxTableCountNum value |
|
113 | + if(empty($panelKey)) { |
|
114 | + $panels[$maxTableCountNum++] = $vals; |
|
115 | + } else { |
|
116 | + $panels[$panelKey] = $vals; |
|
117 | + } |
|
118 | + } //foreach |
|
119 | + $tableCount++; |
|
120 | + } //foreach; |
|
121 | + } //foreach |
|
122 | 122 | |
123 | - foreach($panels as $id=>$tablerows) { |
|
123 | + foreach($panels as $id=>$tablerows) { |
|
124 | 124 | |
125 | - $metarow = array(); |
|
125 | + $metarow = array(); |
|
126 | 126 | |
127 | - foreach($tablerows as $trow) { |
|
127 | + foreach($tablerows as $trow) { |
|
128 | 128 | |
129 | - $emptyCount = 0; |
|
130 | - $tablecolumns = $this->getElementsByType("td", $trow); |
|
131 | - $col = array(); |
|
132 | - $slot = 0; |
|
129 | + $emptyCount = 0; |
|
130 | + $tablecolumns = $this->getElementsByType("td", $trow); |
|
131 | + $col = array(); |
|
132 | + $slot = 0; |
|
133 | 133 | |
134 | - foreach($tablecolumns as $tcols) { |
|
135 | - $hasRequiredLabel = false; |
|
134 | + foreach($tablecolumns as $tcols) { |
|
135 | + $hasRequiredLabel = false; |
|
136 | 136 | |
137 | - //Get the sugar attribute value in the span elements of each table row |
|
138 | - $sugarAttrLabel = $this->getTagAttribute("sugar", $tcols, "'^slot[^b]+$'"); |
|
137 | + //Get the sugar attribute value in the span elements of each table row |
|
138 | + $sugarAttrLabel = $this->getTagAttribute("sugar", $tcols, "'^slot[^b]+$'"); |
|
139 | 139 | |
140 | - //If there was no sugar attribute, try id (some versions of EditView.html used this instead) |
|
141 | - if(empty($sugarAttrLabel)) { |
|
142 | - $sugarAttrLabel = $this->getTagAttribute("id", $tcols, "'^slot[^b]+$'"); |
|
143 | - } |
|
140 | + //If there was no sugar attribute, try id (some versions of EditView.html used this instead) |
|
141 | + if(empty($sugarAttrLabel)) { |
|
142 | + $sugarAttrLabel = $this->getTagAttribute("id", $tcols, "'^slot[^b]+$'"); |
|
143 | + } |
|
144 | 144 | |
145 | - //Check if this field is required |
|
146 | - if(!empty($sugarAttrLabel)) { |
|
147 | - $hasRequiredLabel = $this->hasRequiredSpanLabel($tcols); |
|
148 | - } |
|
145 | + //Check if this field is required |
|
146 | + if(!empty($sugarAttrLabel)) { |
|
147 | + $hasRequiredLabel = $this->hasRequiredSpanLabel($tcols); |
|
148 | + } |
|
149 | 149 | |
150 | - $sugarAttrValue = $this->getTagAttribute("sugar", $tcols, "'slot[0-9]+b$'"); |
|
150 | + $sugarAttrValue = $this->getTagAttribute("sugar", $tcols, "'slot[0-9]+b$'"); |
|
151 | 151 | |
152 | - //If there was no sugar attribute, try id (some versions of EditView.html used this instead) |
|
153 | - if(empty($sugarAttrValue)) { |
|
154 | - $sugarAttrValue = $this->getTagAttribute("id", $tcols, "'slot[0-9]+b$'"); |
|
155 | - } |
|
152 | + //If there was no sugar attribute, try id (some versions of EditView.html used this instead) |
|
153 | + if(empty($sugarAttrValue)) { |
|
154 | + $sugarAttrValue = $this->getTagAttribute("id", $tcols, "'slot[0-9]+b$'"); |
|
155 | + } |
|
156 | 156 | |
157 | - // If there wasn't any slot numbering/lettering then just default to expect label->vallue pairs |
|
158 | - $sugarAttrLabel = count($sugarAttrLabel) != 0 ? $sugarAttrLabel : ($slot % 2 == 0) ? true : false; |
|
159 | - $sugarAttrValue = count($sugarAttrValue) != 0 ? $sugarAttrValue : ($slot % 2 == 1) ? true : false; |
|
160 | - $slot++; |
|
157 | + // If there wasn't any slot numbering/lettering then just default to expect label->vallue pairs |
|
158 | + $sugarAttrLabel = count($sugarAttrLabel) != 0 ? $sugarAttrLabel : ($slot % 2 == 0) ? true : false; |
|
159 | + $sugarAttrValue = count($sugarAttrValue) != 0 ? $sugarAttrValue : ($slot % 2 == 1) ? true : false; |
|
160 | + $slot++; |
|
161 | 161 | |
162 | - if($sugarAttrValue) { |
|
162 | + if($sugarAttrValue) { |
|
163 | 163 | |
164 | - $spanValue = $this->getElementValue("span", $tcols); |
|
164 | + $spanValue = $this->getElementValue("span", $tcols); |
|
165 | 165 | |
166 | - if(empty($spanValue)) { |
|
167 | - $spanValue = $this->getElementValue("slot", $tcols); |
|
168 | - } |
|
166 | + if(empty($spanValue)) { |
|
167 | + $spanValue = $this->getElementValue("slot", $tcols); |
|
168 | + } |
|
169 | 169 | |
170 | - if(empty($spanValue)) { |
|
171 | - $spanValue = $this->getElementValue("td", $tcols); |
|
172 | - } |
|
170 | + if(empty($spanValue)) { |
|
171 | + $spanValue = $this->getElementValue("td", $tcols); |
|
172 | + } |
|
173 | 173 | |
174 | - //Get all the editable form elements' names |
|
175 | - $formElementNames = $this->getFormElementsNames($spanValue); |
|
176 | - $customField = $this->getCustomField($formElementNames); |
|
174 | + //Get all the editable form elements' names |
|
175 | + $formElementNames = $this->getFormElementsNames($spanValue); |
|
176 | + $customField = $this->getCustomField($formElementNames); |
|
177 | 177 | |
178 | - $name = ''; |
|
179 | - $fields = null; |
|
180 | - $customCode = null; |
|
178 | + $name = ''; |
|
179 | + $fields = null; |
|
180 | + $customCode = null; |
|
181 | 181 | |
182 | - if(!empty($customField)) { |
|
183 | - // If it's a custom field we just set the name |
|
184 | - $name = $customField; |
|
182 | + if(!empty($customField)) { |
|
183 | + // If it's a custom field we just set the name |
|
184 | + $name = $customField; |
|
185 | 185 | |
186 | - } else if(empty($formElementNames) && preg_match_all('/[\{]([^\}]*?)[\}]/s', $spanValue, $matches, PREG_SET_ORDER)) { |
|
187 | - // We are here if the $spanValue did not contain a form element for editing. |
|
188 | - // We will assume that it is read only (since there were no edit form elements) |
|
186 | + } else if(empty($formElementNames) && preg_match_all('/[\{]([^\}]*?)[\}]/s', $spanValue, $matches, PREG_SET_ORDER)) { |
|
187 | + // We are here if the $spanValue did not contain a form element for editing. |
|
188 | + // We will assume that it is read only (since there were no edit form elements) |
|
189 | 189 | |
190 | 190 | |
191 | - // If there is more than one matching {} value then try to find the right one to key off |
|
192 | - // based on vardefs.php file. Also, use the entire spanValue as customCode |
|
193 | - if(count($matches) > 1) { |
|
194 | - $name = $matches[0][1]; |
|
195 | - $customCode = $spanValue; |
|
196 | - foreach($matches as $pair) { |
|
197 | - if(preg_match("/^(mod[\.]|app[\.]).*?/i", $pair[1])) { |
|
198 | - $customCode = str_replace($pair[1], '$'.strtoupper($pair[1]), $customCode); |
|
199 | - } else { |
|
200 | - if(!empty($vardefs[$pair[1]])) { |
|
201 | - $name = $pair[1]; |
|
202 | - $customCode = str_replace($pair[1], '$fields.'.strtolower($pair[1]).'.value', $customCode); |
|
203 | - } else { |
|
204 | - $phpName = $this->findAssignedVariableName($pair[1], $filePath); |
|
205 | - $customCode = str_replace($pair[1], '$fields.'.strtolower($phpName).'.value', $customCode); |
|
206 | - } //if-else |
|
207 | - } |
|
208 | - } //foreach |
|
209 | - } else { |
|
210 | - //If it is only a label, skip |
|
211 | - if(preg_match("/^(mod[\.]|app[\.]).*?/i", $matches[0][1])) { |
|
212 | - continue; |
|
213 | - } |
|
214 | - $name = strtolower($matches[0][1]); |
|
215 | - } |
|
191 | + // If there is more than one matching {} value then try to find the right one to key off |
|
192 | + // based on vardefs.php file. Also, use the entire spanValue as customCode |
|
193 | + if(count($matches) > 1) { |
|
194 | + $name = $matches[0][1]; |
|
195 | + $customCode = $spanValue; |
|
196 | + foreach($matches as $pair) { |
|
197 | + if(preg_match("/^(mod[\.]|app[\.]).*?/i", $pair[1])) { |
|
198 | + $customCode = str_replace($pair[1], '$'.strtoupper($pair[1]), $customCode); |
|
199 | + } else { |
|
200 | + if(!empty($vardefs[$pair[1]])) { |
|
201 | + $name = $pair[1]; |
|
202 | + $customCode = str_replace($pair[1], '$fields.'.strtolower($pair[1]).'.value', $customCode); |
|
203 | + } else { |
|
204 | + $phpName = $this->findAssignedVariableName($pair[1], $filePath); |
|
205 | + $customCode = str_replace($pair[1], '$fields.'.strtolower($phpName).'.value', $customCode); |
|
206 | + } //if-else |
|
207 | + } |
|
208 | + } //foreach |
|
209 | + } else { |
|
210 | + //If it is only a label, skip |
|
211 | + if(preg_match("/^(mod[\.]|app[\.]).*?/i", $matches[0][1])) { |
|
212 | + continue; |
|
213 | + } |
|
214 | + $name = strtolower($matches[0][1]); |
|
215 | + } |
|
216 | 216 | |
217 | - } else if(is_array($formElementNames)) { |
|
217 | + } else if(is_array($formElementNames)) { |
|
218 | 218 | |
219 | - if(count($formElementNames) == 1) { |
|
219 | + if(count($formElementNames) == 1) { |
|
220 | 220 | |
221 | - if(!empty($vardefs[$formElementNames[0]])) { |
|
222 | - $name = $formElementNames[0]; |
|
223 | - } else { |
|
224 | - // Try to use the EdtiView.php file to find author's intent |
|
225 | - $name = $this->findAssignedVariableName($formElementNames[0], $filePath); |
|
221 | + if(!empty($vardefs[$formElementNames[0]])) { |
|
222 | + $name = $formElementNames[0]; |
|
223 | + } else { |
|
224 | + // Try to use the EdtiView.php file to find author's intent |
|
225 | + $name = $this->findAssignedVariableName($formElementNames[0], $filePath); |
|
226 | 226 | |
227 | - //If it's still empty, just use the entire block as customCode |
|
228 | - if(empty($vardefs[$name])) { |
|
229 | - //Replace any { characters just in case |
|
230 | - $customCode = str_replace('{', '{$', $spanValue); |
|
231 | - } |
|
232 | - } //if-else |
|
233 | - } else { |
|
234 | - //If it is an Array of form elements, it is likely the _id and _name relate field combo |
|
235 | - $relateName = $this->getRelateFieldName($formElementNames); |
|
236 | - if(!empty($relateName)) { |
|
237 | - $name = $relateName; |
|
238 | - } else { |
|
239 | - //One last attempt to scan $formElementNames for one vardef field only |
|
240 | - $name = $this->findSingleVardefElement($formElementNames, $vardefs); |
|
241 | - if(empty($name)) { |
|
242 | - $fields = array(); |
|
243 | - $name = $formElementNames[0]; |
|
244 | - foreach($formElementNames as $elementName) { |
|
245 | - if(isset($vardefs[$elementName])) { |
|
246 | - $fields[] = $elementName; |
|
247 | - } else { |
|
248 | - $fields[] = $this->findAssignedVariableName($elementName, $filePath); |
|
249 | - } //if-else |
|
250 | - } //foreach |
|
251 | - } //if |
|
252 | - } //if-else |
|
253 | - } //if-else |
|
254 | - } |
|
227 | + //If it's still empty, just use the entire block as customCode |
|
228 | + if(empty($vardefs[$name])) { |
|
229 | + //Replace any { characters just in case |
|
230 | + $customCode = str_replace('{', '{$', $spanValue); |
|
231 | + } |
|
232 | + } //if-else |
|
233 | + } else { |
|
234 | + //If it is an Array of form elements, it is likely the _id and _name relate field combo |
|
235 | + $relateName = $this->getRelateFieldName($formElementNames); |
|
236 | + if(!empty($relateName)) { |
|
237 | + $name = $relateName; |
|
238 | + } else { |
|
239 | + //One last attempt to scan $formElementNames for one vardef field only |
|
240 | + $name = $this->findSingleVardefElement($formElementNames, $vardefs); |
|
241 | + if(empty($name)) { |
|
242 | + $fields = array(); |
|
243 | + $name = $formElementNames[0]; |
|
244 | + foreach($formElementNames as $elementName) { |
|
245 | + if(isset($vardefs[$elementName])) { |
|
246 | + $fields[] = $elementName; |
|
247 | + } else { |
|
248 | + $fields[] = $this->findAssignedVariableName($elementName, $filePath); |
|
249 | + } //if-else |
|
250 | + } //foreach |
|
251 | + } //if |
|
252 | + } //if-else |
|
253 | + } //if-else |
|
254 | + } |
|
255 | 255 | |
256 | - // Build the entry |
|
257 | - if(preg_match("/<textarea/si", $spanValue)) { |
|
258 | - //special case for textarea form elements (add the displayParams) |
|
259 | - $displayParams = array(); |
|
260 | - $displayParams['rows'] = $this->getTagAttribute("rows", $spanValue); |
|
261 | - $displayParams['cols'] = $this->getTagAttribute("cols", $spanValue); |
|
256 | + // Build the entry |
|
257 | + if(preg_match("/<textarea/si", $spanValue)) { |
|
258 | + //special case for textarea form elements (add the displayParams) |
|
259 | + $displayParams = array(); |
|
260 | + $displayParams['rows'] = $this->getTagAttribute("rows", $spanValue); |
|
261 | + $displayParams['cols'] = $this->getTagAttribute("cols", $spanValue); |
|
262 | 262 | |
263 | - if(!empty($displayParams['rows']) && !empty($displayParams['cols'])) { |
|
264 | - $field = array(); |
|
265 | - $field['name'] = $name; |
|
266 | - $field['displayParams'] = $displayParams; |
|
267 | - } else { |
|
268 | - $field = $name; |
|
269 | - } |
|
270 | - } else { |
|
263 | + if(!empty($displayParams['rows']) && !empty($displayParams['cols'])) { |
|
264 | + $field = array(); |
|
265 | + $field['name'] = $name; |
|
266 | + $field['displayParams'] = $displayParams; |
|
267 | + } else { |
|
268 | + $field = $name; |
|
269 | + } |
|
270 | + } else { |
|
271 | 271 | |
272 | - if(isset($fields) || isset($customCode)) { |
|
273 | - $field = array(); |
|
274 | - $field['name'] = $name; |
|
275 | - if(isset($fields)) { |
|
276 | - $field['fields'] = $fields; |
|
277 | - } |
|
278 | - if(isset($customCode)) { |
|
279 | - $field['customCode'] = $customCode; |
|
280 | - $field['description'] = 'This field was auto generated'; |
|
281 | - } |
|
282 | - } else { |
|
283 | - $emptyCount = $name == '' ? $emptyCount + 1 : $emptyCount; |
|
284 | - $field = $name; |
|
285 | - } |
|
286 | - } //if-else if-else block |
|
272 | + if(isset($fields) || isset($customCode)) { |
|
273 | + $field = array(); |
|
274 | + $field['name'] = $name; |
|
275 | + if(isset($fields)) { |
|
276 | + $field['fields'] = $fields; |
|
277 | + } |
|
278 | + if(isset($customCode)) { |
|
279 | + $field['customCode'] = $customCode; |
|
280 | + $field['description'] = 'This field was auto generated'; |
|
281 | + } |
|
282 | + } else { |
|
283 | + $emptyCount = $name == '' ? $emptyCount + 1 : $emptyCount; |
|
284 | + $field = $name; |
|
285 | + } |
|
286 | + } //if-else if-else block |
|
287 | 287 | |
288 | - $addedField = is_array($field) ? $field['name'] : $field; |
|
289 | - if(empty($addedField) || empty($addedElements[$addedField])) { |
|
290 | - //Add the meta-data definition for required fields |
|
291 | - if($hasRequiredLabel) { |
|
292 | - if(is_array($field)) { |
|
293 | - if(isset($field['displayParams']) && is_array($field['displayParams'])) { |
|
294 | - $field['displayParams']['required']=true; |
|
295 | - } else { |
|
296 | - $field['displayParams'] = array('required'=>true); |
|
297 | - } |
|
298 | - } else { |
|
299 | - $field = array('name'=>strtolower($field), 'displayParams'=>array('required'=>true)); |
|
300 | - } |
|
301 | - } |
|
302 | - $col[] = is_array($field) ? $field : strtolower($field); |
|
303 | - $addedElements[$addedField] = $addedField; |
|
304 | - } |
|
305 | - } //if($sugarAttValue) |
|
306 | - } //foreach |
|
288 | + $addedField = is_array($field) ? $field['name'] : $field; |
|
289 | + if(empty($addedField) || empty($addedElements[$addedField])) { |
|
290 | + //Add the meta-data definition for required fields |
|
291 | + if($hasRequiredLabel) { |
|
292 | + if(is_array($field)) { |
|
293 | + if(isset($field['displayParams']) && is_array($field['displayParams'])) { |
|
294 | + $field['displayParams']['required']=true; |
|
295 | + } else { |
|
296 | + $field['displayParams'] = array('required'=>true); |
|
297 | + } |
|
298 | + } else { |
|
299 | + $field = array('name'=>strtolower($field), 'displayParams'=>array('required'=>true)); |
|
300 | + } |
|
301 | + } |
|
302 | + $col[] = is_array($field) ? $field : strtolower($field); |
|
303 | + $addedElements[$addedField] = $addedField; |
|
304 | + } |
|
305 | + } //if($sugarAttValue) |
|
306 | + } //foreach |
|
307 | 307 | |
308 | - // One last final check. If $emptyCount does not equal Array $col count, don't add |
|
309 | - if($emptyCount != count($col)) { |
|
308 | + // One last final check. If $emptyCount does not equal Array $col count, don't add |
|
309 | + if($emptyCount != count($col)) { |
|
310 | 310 | |
311 | - if($hasRequiredLabel) { |
|
312 | - if(is_array($col)) { |
|
313 | - if(isset($col['displayParams'])) { |
|
314 | - $col['displayParams']['required']=true; |
|
315 | - } else { |
|
316 | - $col['displayParams']=array('required'=>true); |
|
317 | - } |
|
318 | - } else { |
|
319 | - $col = array('name'=>strtolower($col), 'displayParams'=>array('required'=>true)); |
|
320 | - } |
|
321 | - } |
|
311 | + if($hasRequiredLabel) { |
|
312 | + if(is_array($col)) { |
|
313 | + if(isset($col['displayParams'])) { |
|
314 | + $col['displayParams']['required']=true; |
|
315 | + } else { |
|
316 | + $col['displayParams']=array('required'=>true); |
|
317 | + } |
|
318 | + } else { |
|
319 | + $col = array('name'=>strtolower($col), 'displayParams'=>array('required'=>true)); |
|
320 | + } |
|
321 | + } |
|
322 | 322 | |
323 | - $metarow[] = $col; |
|
324 | - } //if |
|
325 | - } //foreach |
|
323 | + $metarow[] = $col; |
|
324 | + } //if |
|
325 | + } //foreach |
|
326 | 326 | |
327 | - $panels[$id] = $metarow; |
|
327 | + $panels[$id] = $metarow; |
|
328 | 328 | |
329 | - } //foreach |
|
329 | + } //foreach |
|
330 | 330 | |
331 | - $this->mCustomPanels = $panels; |
|
332 | - $panels = $this->applyPreRules($moduleDir, $panels); |
|
331 | + $this->mCustomPanels = $panels; |
|
332 | + $panels = $this->applyPreRules($moduleDir, $panels); |
|
333 | 333 | |
334 | - $templateMeta = array(); |
|
335 | - if($merge && !empty($masterCopy) && file_exists($masterCopy)) { |
|
336 | - $panels = $this->mergePanels($panels, $vardefs, $moduleDir, $masterCopy); |
|
337 | - $templateMeta = $this->mergeTemplateMeta($templateMeta, $moduleDir, $masterCopy); |
|
338 | - } |
|
339 | - $panels = $this->applyRules($moduleDir, $panels); |
|
340 | - return $this->createFileContents($moduleDir, $panels, $templateMeta, $filePath); |
|
334 | + $templateMeta = array(); |
|
335 | + if($merge && !empty($masterCopy) && file_exists($masterCopy)) { |
|
336 | + $panels = $this->mergePanels($panels, $vardefs, $moduleDir, $masterCopy); |
|
337 | + $templateMeta = $this->mergeTemplateMeta($templateMeta, $moduleDir, $masterCopy); |
|
338 | + } |
|
339 | + $panels = $this->applyRules($moduleDir, $panels); |
|
340 | + return $this->createFileContents($moduleDir, $panels, $templateMeta, $filePath); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 |
@@ -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. |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @param $masterCopy The file path of the mater copy of the metadata file to merge against |
66 | 66 | * @return String format of metadata contents |
67 | 67 | **/ |
68 | -function parse($filePath, $vardefs = array(), $moduleDir = '', $merge=false, $masterCopy=null) { |
|
68 | +function parse($filePath, $vardefs = array(), $moduleDir = '', $merge = false, $masterCopy = null) { |
|
69 | 69 | |
70 | 70 | global $app_strings; |
71 | 71 | $contents = file_get_contents($filePath); |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | $tables = $this->getElementsByType("table", $contents); |
80 | 80 | $formElements = $this->getFormElements($tables[0]); |
81 | 81 | $hiddenInputs = array(); |
82 | - foreach($formElements as $elem) { |
|
82 | + foreach ($formElements as $elem) { |
|
83 | 83 | $type = $this->getTagAttribute("type", $elem); |
84 | - if(preg_match('/hidden/si',$type)) { |
|
84 | + if (preg_match('/hidden/si', $type)) { |
|
85 | 85 | $name = $this->getTagAttribute("name", $elem); |
86 | 86 | $value = $this->getTagAttribute("value", $elem); |
87 | 87 | $hiddenInputs[$name] = $value; |
@@ -95,22 +95,22 @@ discard block |
||
95 | 95 | $addedElements = array(); |
96 | 96 | $maxTableCountNum = 0; |
97 | 97 | $tableCount = 0; |
98 | - foreach($tables as $table) { |
|
98 | + foreach ($tables as $table) { |
|
99 | 99 | $table = $this->fixTablesWithMissingTr($table); |
100 | 100 | $toptr = $this->getElementsByType("tr", $table); |
101 | - foreach($toptr as $tr) { |
|
101 | + foreach ($toptr as $tr) { |
|
102 | 102 | $tabledata = $this->getElementsByType("table", $tr); |
103 | 103 | $data = array(); |
104 | 104 | $panelKey = $tableCount == 0 ? "default" : ''; |
105 | - foreach($tabledata as $t) { |
|
105 | + foreach ($tabledata as $t) { |
|
106 | 106 | $vals = array_values($this->getElementsByType("tr", $t)); |
107 | - if(preg_match_all('/<h4[^>]*?>.*?(\{MOD\.|\{APP\.)(LBL_[^\}]*?)[\}].*?<\/h4>/s', $vals[0], $matches, PREG_SET_ORDER)) { |
|
107 | + if (preg_match_all('/<h4[^>]*?>.*?(\{MOD\.|\{APP\.)(LBL_[^\}]*?)[\}].*?<\/h4>/s', $vals[0], $matches, PREG_SET_ORDER)) { |
|
108 | 108 | array_shift($vals); |
109 | 109 | $panelKey = count($matches[0]) == 3 ? strtolower($matches[0][2]) : $panelKey; |
110 | 110 | } |
111 | 111 | |
112 | 112 | //If $panelKey is empty use the maxTableCountNum value |
113 | - if(empty($panelKey)) { |
|
113 | + if (empty($panelKey)) { |
|
114 | 114 | $panels[$maxTableCountNum++] = $vals; |
115 | 115 | } else { |
116 | 116 | $panels[$panelKey] = $vals; |
@@ -120,37 +120,37 @@ discard block |
||
120 | 120 | } //foreach; |
121 | 121 | } //foreach |
122 | 122 | |
123 | - foreach($panels as $id=>$tablerows) { |
|
123 | + foreach ($panels as $id=>$tablerows) { |
|
124 | 124 | |
125 | 125 | $metarow = array(); |
126 | 126 | |
127 | - foreach($tablerows as $trow) { |
|
127 | + foreach ($tablerows as $trow) { |
|
128 | 128 | |
129 | 129 | $emptyCount = 0; |
130 | 130 | $tablecolumns = $this->getElementsByType("td", $trow); |
131 | 131 | $col = array(); |
132 | 132 | $slot = 0; |
133 | 133 | |
134 | - foreach($tablecolumns as $tcols) { |
|
134 | + foreach ($tablecolumns as $tcols) { |
|
135 | 135 | $hasRequiredLabel = false; |
136 | 136 | |
137 | 137 | //Get the sugar attribute value in the span elements of each table row |
138 | 138 | $sugarAttrLabel = $this->getTagAttribute("sugar", $tcols, "'^slot[^b]+$'"); |
139 | 139 | |
140 | 140 | //If there was no sugar attribute, try id (some versions of EditView.html used this instead) |
141 | - if(empty($sugarAttrLabel)) { |
|
141 | + if (empty($sugarAttrLabel)) { |
|
142 | 142 | $sugarAttrLabel = $this->getTagAttribute("id", $tcols, "'^slot[^b]+$'"); |
143 | 143 | } |
144 | 144 | |
145 | 145 | //Check if this field is required |
146 | - if(!empty($sugarAttrLabel)) { |
|
146 | + if (!empty($sugarAttrLabel)) { |
|
147 | 147 | $hasRequiredLabel = $this->hasRequiredSpanLabel($tcols); |
148 | 148 | } |
149 | 149 | |
150 | 150 | $sugarAttrValue = $this->getTagAttribute("sugar", $tcols, "'slot[0-9]+b$'"); |
151 | 151 | |
152 | 152 | //If there was no sugar attribute, try id (some versions of EditView.html used this instead) |
153 | - if(empty($sugarAttrValue)) { |
|
153 | + if (empty($sugarAttrValue)) { |
|
154 | 154 | $sugarAttrValue = $this->getTagAttribute("id", $tcols, "'slot[0-9]+b$'"); |
155 | 155 | } |
156 | 156 | |
@@ -159,15 +159,15 @@ discard block |
||
159 | 159 | $sugarAttrValue = count($sugarAttrValue) != 0 ? $sugarAttrValue : ($slot % 2 == 1) ? true : false; |
160 | 160 | $slot++; |
161 | 161 | |
162 | - if($sugarAttrValue) { |
|
162 | + if ($sugarAttrValue) { |
|
163 | 163 | |
164 | 164 | $spanValue = $this->getElementValue("span", $tcols); |
165 | 165 | |
166 | - if(empty($spanValue)) { |
|
166 | + if (empty($spanValue)) { |
|
167 | 167 | $spanValue = $this->getElementValue("slot", $tcols); |
168 | 168 | } |
169 | 169 | |
170 | - if(empty($spanValue)) { |
|
170 | + if (empty($spanValue)) { |
|
171 | 171 | $spanValue = $this->getElementValue("td", $tcols); |
172 | 172 | } |
173 | 173 | |
@@ -179,25 +179,25 @@ discard block |
||
179 | 179 | $fields = null; |
180 | 180 | $customCode = null; |
181 | 181 | |
182 | - if(!empty($customField)) { |
|
182 | + if (!empty($customField)) { |
|
183 | 183 | // If it's a custom field we just set the name |
184 | 184 | $name = $customField; |
185 | 185 | |
186 | - } else if(empty($formElementNames) && preg_match_all('/[\{]([^\}]*?)[\}]/s', $spanValue, $matches, PREG_SET_ORDER)) { |
|
186 | + } else if (empty($formElementNames) && preg_match_all('/[\{]([^\}]*?)[\}]/s', $spanValue, $matches, PREG_SET_ORDER)) { |
|
187 | 187 | // We are here if the $spanValue did not contain a form element for editing. |
188 | 188 | // We will assume that it is read only (since there were no edit form elements) |
189 | 189 | |
190 | 190 | |
191 | 191 | // If there is more than one matching {} value then try to find the right one to key off |
192 | 192 | // based on vardefs.php file. Also, use the entire spanValue as customCode |
193 | - if(count($matches) > 1) { |
|
193 | + if (count($matches) > 1) { |
|
194 | 194 | $name = $matches[0][1]; |
195 | 195 | $customCode = $spanValue; |
196 | - foreach($matches as $pair) { |
|
197 | - if(preg_match("/^(mod[\.]|app[\.]).*?/i", $pair[1])) { |
|
196 | + foreach ($matches as $pair) { |
|
197 | + if (preg_match("/^(mod[\.]|app[\.]).*?/i", $pair[1])) { |
|
198 | 198 | $customCode = str_replace($pair[1], '$'.strtoupper($pair[1]), $customCode); |
199 | 199 | } else { |
200 | - if(!empty($vardefs[$pair[1]])) { |
|
200 | + if (!empty($vardefs[$pair[1]])) { |
|
201 | 201 | $name = $pair[1]; |
202 | 202 | $customCode = str_replace($pair[1], '$fields.'.strtolower($pair[1]).'.value', $customCode); |
203 | 203 | } else { |
@@ -208,24 +208,24 @@ discard block |
||
208 | 208 | } //foreach |
209 | 209 | } else { |
210 | 210 | //If it is only a label, skip |
211 | - if(preg_match("/^(mod[\.]|app[\.]).*?/i", $matches[0][1])) { |
|
211 | + if (preg_match("/^(mod[\.]|app[\.]).*?/i", $matches[0][1])) { |
|
212 | 212 | continue; |
213 | 213 | } |
214 | 214 | $name = strtolower($matches[0][1]); |
215 | 215 | } |
216 | 216 | |
217 | - } else if(is_array($formElementNames)) { |
|
217 | + } else if (is_array($formElementNames)) { |
|
218 | 218 | |
219 | - if(count($formElementNames) == 1) { |
|
219 | + if (count($formElementNames) == 1) { |
|
220 | 220 | |
221 | - if(!empty($vardefs[$formElementNames[0]])) { |
|
221 | + if (!empty($vardefs[$formElementNames[0]])) { |
|
222 | 222 | $name = $formElementNames[0]; |
223 | 223 | } else { |
224 | 224 | // Try to use the EdtiView.php file to find author's intent |
225 | 225 | $name = $this->findAssignedVariableName($formElementNames[0], $filePath); |
226 | 226 | |
227 | 227 | //If it's still empty, just use the entire block as customCode |
228 | - if(empty($vardefs[$name])) { |
|
228 | + if (empty($vardefs[$name])) { |
|
229 | 229 | //Replace any { characters just in case |
230 | 230 | $customCode = str_replace('{', '{$', $spanValue); |
231 | 231 | } |
@@ -233,16 +233,16 @@ discard block |
||
233 | 233 | } else { |
234 | 234 | //If it is an Array of form elements, it is likely the _id and _name relate field combo |
235 | 235 | $relateName = $this->getRelateFieldName($formElementNames); |
236 | - if(!empty($relateName)) { |
|
236 | + if (!empty($relateName)) { |
|
237 | 237 | $name = $relateName; |
238 | 238 | } else { |
239 | 239 | //One last attempt to scan $formElementNames for one vardef field only |
240 | 240 | $name = $this->findSingleVardefElement($formElementNames, $vardefs); |
241 | - if(empty($name)) { |
|
241 | + if (empty($name)) { |
|
242 | 242 | $fields = array(); |
243 | 243 | $name = $formElementNames[0]; |
244 | - foreach($formElementNames as $elementName) { |
|
245 | - if(isset($vardefs[$elementName])) { |
|
244 | + foreach ($formElementNames as $elementName) { |
|
245 | + if (isset($vardefs[$elementName])) { |
|
246 | 246 | $fields[] = $elementName; |
247 | 247 | } else { |
248 | 248 | $fields[] = $this->findAssignedVariableName($elementName, $filePath); |
@@ -254,13 +254,13 @@ discard block |
||
254 | 254 | } |
255 | 255 | |
256 | 256 | // Build the entry |
257 | - if(preg_match("/<textarea/si", $spanValue)) { |
|
257 | + if (preg_match("/<textarea/si", $spanValue)) { |
|
258 | 258 | //special case for textarea form elements (add the displayParams) |
259 | 259 | $displayParams = array(); |
260 | 260 | $displayParams['rows'] = $this->getTagAttribute("rows", $spanValue); |
261 | 261 | $displayParams['cols'] = $this->getTagAttribute("cols", $spanValue); |
262 | 262 | |
263 | - if(!empty($displayParams['rows']) && !empty($displayParams['cols'])) { |
|
263 | + if (!empty($displayParams['rows']) && !empty($displayParams['cols'])) { |
|
264 | 264 | $field = array(); |
265 | 265 | $field['name'] = $name; |
266 | 266 | $field['displayParams'] = $displayParams; |
@@ -269,13 +269,13 @@ discard block |
||
269 | 269 | } |
270 | 270 | } else { |
271 | 271 | |
272 | - if(isset($fields) || isset($customCode)) { |
|
272 | + if (isset($fields) || isset($customCode)) { |
|
273 | 273 | $field = array(); |
274 | 274 | $field['name'] = $name; |
275 | - if(isset($fields)) { |
|
275 | + if (isset($fields)) { |
|
276 | 276 | $field['fields'] = $fields; |
277 | 277 | } |
278 | - if(isset($customCode)) { |
|
278 | + if (isset($customCode)) { |
|
279 | 279 | $field['customCode'] = $customCode; |
280 | 280 | $field['description'] = 'This field was auto generated'; |
281 | 281 | } |
@@ -286,12 +286,12 @@ discard block |
||
286 | 286 | } //if-else if-else block |
287 | 287 | |
288 | 288 | $addedField = is_array($field) ? $field['name'] : $field; |
289 | - if(empty($addedField) || empty($addedElements[$addedField])) { |
|
289 | + if (empty($addedField) || empty($addedElements[$addedField])) { |
|
290 | 290 | //Add the meta-data definition for required fields |
291 | - if($hasRequiredLabel) { |
|
292 | - if(is_array($field)) { |
|
293 | - if(isset($field['displayParams']) && is_array($field['displayParams'])) { |
|
294 | - $field['displayParams']['required']=true; |
|
291 | + if ($hasRequiredLabel) { |
|
292 | + if (is_array($field)) { |
|
293 | + if (isset($field['displayParams']) && is_array($field['displayParams'])) { |
|
294 | + $field['displayParams']['required'] = true; |
|
295 | 295 | } else { |
296 | 296 | $field['displayParams'] = array('required'=>true); |
297 | 297 | } |
@@ -306,14 +306,14 @@ discard block |
||
306 | 306 | } //foreach |
307 | 307 | |
308 | 308 | // One last final check. If $emptyCount does not equal Array $col count, don't add |
309 | - if($emptyCount != count($col)) { |
|
309 | + if ($emptyCount != count($col)) { |
|
310 | 310 | |
311 | - if($hasRequiredLabel) { |
|
312 | - if(is_array($col)) { |
|
313 | - if(isset($col['displayParams'])) { |
|
314 | - $col['displayParams']['required']=true; |
|
311 | + if ($hasRequiredLabel) { |
|
312 | + if (is_array($col)) { |
|
313 | + if (isset($col['displayParams'])) { |
|
314 | + $col['displayParams']['required'] = true; |
|
315 | 315 | } else { |
316 | - $col['displayParams']=array('required'=>true); |
|
316 | + $col['displayParams'] = array('required'=>true); |
|
317 | 317 | } |
318 | 318 | } else { |
319 | 319 | $col = array('name'=>strtolower($col), 'displayParams'=>array('required'=>true)); |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | $panels = $this->applyPreRules($moduleDir, $panels); |
333 | 333 | |
334 | 334 | $templateMeta = array(); |
335 | - if($merge && !empty($masterCopy) && file_exists($masterCopy)) { |
|
335 | + if ($merge && !empty($masterCopy) && file_exists($masterCopy)) { |
|
336 | 336 | $panels = $this->mergePanels($panels, $vardefs, $moduleDir, $masterCopy); |
337 | 337 | $templateMeta = $this->mergeTemplateMeta($templateMeta, $moduleDir, $masterCopy); |
338 | 338 | } |
@@ -1,5 +1,7 @@ |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
3 | + die('Not A Valid Entry Point'); |
|
4 | +} |
|
3 | 5 | /********************************************************************************* |
4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | class DetailViewMetaParser extends MetaParser { |
60 | 60 | |
61 | 61 | function DetailViewMetaParser() { |
62 | - $this->mView = 'DetailView'; |
|
62 | + $this->mView = 'DetailView'; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | |
86 | 86 | // Notes DetailView.html file is messed up |
87 | 87 | if($moduleDir == 'Notes') { |
88 | - $contents = str_replace('{PAGINATION}<tr><td>', '{PAGINATION}', $contents); |
|
89 | - $contents = str_replace('</td></tr></table><script>', '</table><script>', $contents); |
|
90 | - $contents = str_replace("<tr><div id='portal_flag_row' name='portal_flag_row' style='display:none'>", "<div id='portal_flag_row' name='portal_flag_row' style='display:none'>", $contents); |
|
88 | + $contents = str_replace('{PAGINATION}<tr><td>', '{PAGINATION}', $contents); |
|
89 | + $contents = str_replace('</td></tr></table><script>', '</table><script>', $contents); |
|
90 | + $contents = str_replace("<tr><div id='portal_flag_row' name='portal_flag_row' style='display:none'>", "<div id='portal_flag_row' name='portal_flag_row' style='display:none'>", $contents); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | $contents = $this->fixDuplicateTrTags($contents); |
@@ -104,75 +104,75 @@ discard block |
||
104 | 104 | $metarow = array(); |
105 | 105 | foreach($tables as $table) { |
106 | 106 | |
107 | - $table = $this->fixTablesWithMissingTr($table); |
|
108 | - $tablerows = $this->getElementsByType("tr", $table); |
|
107 | + $table = $this->fixTablesWithMissingTr($table); |
|
108 | + $tablerows = $this->getElementsByType("tr", $table); |
|
109 | 109 | |
110 | - foreach($tablerows as $trow) { |
|
110 | + foreach($tablerows as $trow) { |
|
111 | 111 | |
112 | - $metacolumns = array(); |
|
113 | - $columns = $this->getElementsByType("td", $trow); |
|
114 | - $columns = array_reverse($columns, true); |
|
115 | - foreach($columns as $tcols) { |
|
112 | + $metacolumns = array(); |
|
113 | + $columns = $this->getElementsByType("td", $trow); |
|
114 | + $columns = array_reverse($columns, true); |
|
115 | + foreach($columns as $tcols) { |
|
116 | 116 | |
117 | - $sugarAttrValue = $this->getTagAttribute("sugar", $tcols, "'slot[0-9]+b$'"); |
|
118 | - if(empty($sugarAttrValue)) { |
|
119 | - continue; |
|
120 | - } |
|
117 | + $sugarAttrValue = $this->getTagAttribute("sugar", $tcols, "'slot[0-9]+b$'"); |
|
118 | + if(empty($sugarAttrValue)) { |
|
119 | + continue; |
|
120 | + } |
|
121 | 121 | |
122 | - $def = ''; |
|
123 | - $field = $this->getElementValue("span", $tcols); |
|
124 | - //If it's a space, simply add a blank string |
|
125 | - if($field == ' ') { |
|
126 | - $metacolumns[] = ""; |
|
127 | - } else if(!empty($field)) { |
|
122 | + $def = ''; |
|
123 | + $field = $this->getElementValue("span", $tcols); |
|
124 | + //If it's a space, simply add a blank string |
|
125 | + if($field == ' ') { |
|
126 | + $metacolumns[] = ""; |
|
127 | + } else if(!empty($field)) { |
|
128 | 128 | |
129 | - preg_match_all('/[\{]([^\}].*?)[\}]/s', $field, $matches, PREG_SET_ORDER); |
|
130 | - if(!empty($matches)) { |
|
131 | - if(count($matches) > 1) { |
|
129 | + preg_match_all('/[\{]([^\}].*?)[\}]/s', $field, $matches, PREG_SET_ORDER); |
|
130 | + if(!empty($matches)) { |
|
131 | + if(count($matches) > 1) { |
|
132 | 132 | |
133 | - $def = array(); |
|
134 | - |
|
135 | - $def['name'] = preg_match('/_c$/i', $matches[0][1]) ? $matches[0][1] : strtolower($matches[0][1]); |
|
136 | - foreach($matches as $m) { |
|
137 | - if(isset($vardefs[strtolower($m[1])])) { |
|
138 | - $def['name'] = strtolower($m[1]); |
|
139 | - } |
|
140 | - } |
|
141 | - |
|
142 | - $field = preg_replace('/<\{tag\.[a-z_]*?\}/i', '<a', $field); |
|
143 | - $field = preg_replace('/<\/\{tag\.[a-z_]*?\}>/i', '</a>', $field); |
|
144 | - |
|
145 | - foreach($matches as $tag[1]) { |
|
146 | - if(preg_match("/^(mod[\.]|app[\.]).*?/i", $tag[1][1])) { |
|
147 | - $field = str_replace($tag[1][1], '$'.$tag[1][1], $field); |
|
148 | - } else { |
|
149 | - $theField = preg_match('/_c$/i', $tag[1][1]) ? $tag[1][1] : strtolower($tag[1][1]); |
|
150 | - if(!empty($vardefs[$theField])) { |
|
151 | - $field = str_replace($tag[1][1], '$fields.'. $theField.'.value', $field); |
|
152 | - } else { |
|
153 | - $phpName = $this->findAssignedVariableName($tag[1][1], $filePath); |
|
154 | - $field = str_replace($tag[1][1], '$fields.'. $theField.'.value', $field); |
|
155 | - } //if-else |
|
156 | - } |
|
157 | - } |
|
158 | - |
|
159 | - $def['customCode'] = $field; |
|
160 | - $def['description'] = 'This field was auto generated'; |
|
161 | - } else { |
|
162 | - $def = strtolower($matches[0][1]); |
|
163 | - } |
|
164 | - } //if |
|
165 | - $metacolumns[] = $def; |
|
166 | - } //if |
|
167 | - } //foreach($tablecolumns as $tcols) |
|
168 | - |
|
169 | - $metarow[] = array_reverse($metacolumns); |
|
170 | - } //foreach($tablerows as $trow) |
|
133 | + $def = array(); |
|
134 | + |
|
135 | + $def['name'] = preg_match('/_c$/i', $matches[0][1]) ? $matches[0][1] : strtolower($matches[0][1]); |
|
136 | + foreach($matches as $m) { |
|
137 | + if(isset($vardefs[strtolower($m[1])])) { |
|
138 | + $def['name'] = strtolower($m[1]); |
|
139 | + } |
|
140 | + } |
|
141 | + |
|
142 | + $field = preg_replace('/<\{tag\.[a-z_]*?\}/i', '<a', $field); |
|
143 | + $field = preg_replace('/<\/\{tag\.[a-z_]*?\}>/i', '</a>', $field); |
|
144 | + |
|
145 | + foreach($matches as $tag[1]) { |
|
146 | + if(preg_match("/^(mod[\.]|app[\.]).*?/i", $tag[1][1])) { |
|
147 | + $field = str_replace($tag[1][1], '$'.$tag[1][1], $field); |
|
148 | + } else { |
|
149 | + $theField = preg_match('/_c$/i', $tag[1][1]) ? $tag[1][1] : strtolower($tag[1][1]); |
|
150 | + if(!empty($vardefs[$theField])) { |
|
151 | + $field = str_replace($tag[1][1], '$fields.'. $theField.'.value', $field); |
|
152 | + } else { |
|
153 | + $phpName = $this->findAssignedVariableName($tag[1][1], $filePath); |
|
154 | + $field = str_replace($tag[1][1], '$fields.'. $theField.'.value', $field); |
|
155 | + } //if-else |
|
156 | + } |
|
157 | + } |
|
158 | + |
|
159 | + $def['customCode'] = $field; |
|
160 | + $def['description'] = 'This field was auto generated'; |
|
161 | + } else { |
|
162 | + $def = strtolower($matches[0][1]); |
|
163 | + } |
|
164 | + } //if |
|
165 | + $metacolumns[] = $def; |
|
166 | + } //if |
|
167 | + } //foreach($tablecolumns as $tcols) |
|
168 | + |
|
169 | + $metarow[] = array_reverse($metacolumns); |
|
170 | + } //foreach($tablerows as $trow) |
|
171 | 171 | |
172 | 172 | |
173 | - $id = $tableCount == 0 ? 'default' : $tableCount; |
|
174 | - $tableCount++; |
|
175 | - $panels[$id] = $metarow; |
|
173 | + $id = $tableCount == 0 ? 'default' : $tableCount; |
|
174 | + $tableCount++; |
|
175 | + $panels[$id] = $metarow; |
|
176 | 176 | |
177 | 177 | } //foreach($tables as $table) |
178 | 178 | |
@@ -181,8 +181,8 @@ discard block |
||
181 | 181 | |
182 | 182 | $templateMeta = array(); |
183 | 183 | if($merge && !empty($masterCopy) && file_exists($masterCopy)) { |
184 | - $panels = $this->mergePanels($panels, $vardefs, $moduleDir, $masterCopy); |
|
185 | - $templateMeta = $this->mergeTemplateMeta($templateMeta, $moduleDir, $masterCopy); |
|
184 | + $panels = $this->mergePanels($panels, $vardefs, $moduleDir, $masterCopy); |
|
185 | + $templateMeta = $this->mergeTemplateMeta($templateMeta, $moduleDir, $masterCopy); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | $panels = $this->applyRules($moduleDir, $panels); |
@@ -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. |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * @param $masterCopy The file path of the mater copy of the metadata file to merge against |
74 | 74 | * @return String format of metadata contents |
75 | 75 | **/ |
76 | -function parse($filePath, $vardefs = array(), $moduleDir = '', $merge=false, $masterCopy=null) { |
|
76 | +function parse($filePath, $vardefs = array(), $moduleDir = '', $merge = false, $masterCopy = null) { |
|
77 | 77 | |
78 | 78 | // Grab file contents |
79 | 79 | $contents = file_get_contents($filePath); |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | |
85 | 85 | |
86 | 86 | // Notes DetailView.html file is messed up |
87 | -if($moduleDir == 'Notes') { |
|
87 | +if ($moduleDir == 'Notes') { |
|
88 | 88 | $contents = str_replace('{PAGINATION}<tr><td>', '{PAGINATION}', $contents); |
89 | 89 | $contents = str_replace('</td></tr></table><script>', '</table><script>', $contents); |
90 | 90 | $contents = str_replace("<tr><div id='portal_flag_row' name='portal_flag_row' style='display:none'>", "<div id='portal_flag_row' name='portal_flag_row' style='display:none'>", $contents); |
@@ -102,39 +102,39 @@ discard block |
||
102 | 102 | $panels = array(); |
103 | 103 | $tableCount = 0; |
104 | 104 | $metarow = array(); |
105 | -foreach($tables as $table) { |
|
105 | +foreach ($tables as $table) { |
|
106 | 106 | |
107 | 107 | $table = $this->fixTablesWithMissingTr($table); |
108 | 108 | $tablerows = $this->getElementsByType("tr", $table); |
109 | 109 | |
110 | - foreach($tablerows as $trow) { |
|
110 | + foreach ($tablerows as $trow) { |
|
111 | 111 | |
112 | 112 | $metacolumns = array(); |
113 | 113 | $columns = $this->getElementsByType("td", $trow); |
114 | 114 | $columns = array_reverse($columns, true); |
115 | - foreach($columns as $tcols) { |
|
115 | + foreach ($columns as $tcols) { |
|
116 | 116 | |
117 | 117 | $sugarAttrValue = $this->getTagAttribute("sugar", $tcols, "'slot[0-9]+b$'"); |
118 | - if(empty($sugarAttrValue)) { |
|
118 | + if (empty($sugarAttrValue)) { |
|
119 | 119 | continue; |
120 | 120 | } |
121 | 121 | |
122 | 122 | $def = ''; |
123 | 123 | $field = $this->getElementValue("span", $tcols); |
124 | 124 | //If it's a space, simply add a blank string |
125 | - if($field == ' ') { |
|
125 | + if ($field == ' ') { |
|
126 | 126 | $metacolumns[] = ""; |
127 | - } else if(!empty($field)) { |
|
127 | + } else if (!empty($field)) { |
|
128 | 128 | |
129 | 129 | preg_match_all('/[\{]([^\}].*?)[\}]/s', $field, $matches, PREG_SET_ORDER); |
130 | - if(!empty($matches)) { |
|
131 | - if(count($matches) > 1) { |
|
130 | + if (!empty($matches)) { |
|
131 | + if (count($matches) > 1) { |
|
132 | 132 | |
133 | 133 | $def = array(); |
134 | 134 | |
135 | 135 | $def['name'] = preg_match('/_c$/i', $matches[0][1]) ? $matches[0][1] : strtolower($matches[0][1]); |
136 | - foreach($matches as $m) { |
|
137 | - if(isset($vardefs[strtolower($m[1])])) { |
|
136 | + foreach ($matches as $m) { |
|
137 | + if (isset($vardefs[strtolower($m[1])])) { |
|
138 | 138 | $def['name'] = strtolower($m[1]); |
139 | 139 | } |
140 | 140 | } |
@@ -142,16 +142,16 @@ discard block |
||
142 | 142 | $field = preg_replace('/<\{tag\.[a-z_]*?\}/i', '<a', $field); |
143 | 143 | $field = preg_replace('/<\/\{tag\.[a-z_]*?\}>/i', '</a>', $field); |
144 | 144 | |
145 | - foreach($matches as $tag[1]) { |
|
146 | - if(preg_match("/^(mod[\.]|app[\.]).*?/i", $tag[1][1])) { |
|
145 | + foreach ($matches as $tag[1]) { |
|
146 | + if (preg_match("/^(mod[\.]|app[\.]).*?/i", $tag[1][1])) { |
|
147 | 147 | $field = str_replace($tag[1][1], '$'.$tag[1][1], $field); |
148 | 148 | } else { |
149 | 149 | $theField = preg_match('/_c$/i', $tag[1][1]) ? $tag[1][1] : strtolower($tag[1][1]); |
150 | - if(!empty($vardefs[$theField])) { |
|
151 | - $field = str_replace($tag[1][1], '$fields.'. $theField.'.value', $field); |
|
150 | + if (!empty($vardefs[$theField])) { |
|
151 | + $field = str_replace($tag[1][1], '$fields.'.$theField.'.value', $field); |
|
152 | 152 | } else { |
153 | 153 | $phpName = $this->findAssignedVariableName($tag[1][1], $filePath); |
154 | - $field = str_replace($tag[1][1], '$fields.'. $theField.'.value', $field); |
|
154 | + $field = str_replace($tag[1][1], '$fields.'.$theField.'.value', $field); |
|
155 | 155 | } //if-else |
156 | 156 | } |
157 | 157 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | $panels = $this->applyPreRules($moduleDir, $panels); |
181 | 181 | |
182 | 182 | $templateMeta = array(); |
183 | -if($merge && !empty($masterCopy) && file_exists($masterCopy)) { |
|
183 | +if ($merge && !empty($masterCopy) && file_exists($masterCopy)) { |
|
184 | 184 | $panels = $this->mergePanels($panels, $vardefs, $moduleDir, $masterCopy); |
185 | 185 | $templateMeta = $this->mergeTemplateMeta($templateMeta, $moduleDir, $masterCopy); |
186 | 186 | } |
@@ -1,5 +1,7 @@ |
||
1 | 1 | <?php |
2 | -if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
|
2 | +if(!defined('sugarEntry') || !sugarEntry) { |
|
3 | + die('Not A Valid Entry Point'); |
|
4 | +} |
|
3 | 5 | /********************************************************************************* |
4 | 6 | * SugarCRM Community Edition is a customer relationship management program developed by |
5 | 7 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | class SearchFormMetaParser extends MetaParser { |
43 | 43 | |
44 | 44 | function SearchFormMetaParser() { |
45 | - $this->mView = 'Search'; |
|
45 | + $this->mView = 'Search'; |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -52,28 +52,28 @@ discard block |
||
52 | 52 | **/ |
53 | 53 | function parse($filePath, $vardefs = array(), $moduleDir = '', $merge=false, $masterCopy=null) { |
54 | 54 | |
55 | - $contents = file_get_contents($filePath); |
|
56 | - $contents = $this->trimHTML($contents); |
|
55 | + $contents = file_get_contents($filePath); |
|
56 | + $contents = $this->trimHTML($contents); |
|
57 | 57 | |
58 | - // Get the second table in the page and onward |
|
59 | - $tables = $this->getElementsByType("table", $contents); |
|
60 | - //basic search table |
|
61 | - $basicSection = $this->processSection("basic", $tables[0], $filePath, $vardefs); |
|
62 | - $advancedSection = $this->processSection("advanced", $tables[1], $filePath, $vardefs); |
|
63 | - if(file_exists($masterCopy)) { |
|
64 | - require($masterCopy); |
|
65 | - $layouts = $searchdefs[$moduleDir]['layout']; |
|
58 | + // Get the second table in the page and onward |
|
59 | + $tables = $this->getElementsByType("table", $contents); |
|
60 | + //basic search table |
|
61 | + $basicSection = $this->processSection("basic", $tables[0], $filePath, $vardefs); |
|
62 | + $advancedSection = $this->processSection("advanced", $tables[1], $filePath, $vardefs); |
|
63 | + if(file_exists($masterCopy)) { |
|
64 | + require($masterCopy); |
|
65 | + $layouts = $searchdefs[$moduleDir]['layout']; |
|
66 | 66 | |
67 | - if(isset($layouts['basic_search'])) { |
|
68 | - $basicSection = $this->mergeSection($basicSection, $layouts['basic_search']); |
|
69 | - $basicSection = $this->applyRules($moduleDir, $basicSection); |
|
70 | - } |
|
67 | + if(isset($layouts['basic_search'])) { |
|
68 | + $basicSection = $this->mergeSection($basicSection, $layouts['basic_search']); |
|
69 | + $basicSection = $this->applyRules($moduleDir, $basicSection); |
|
70 | + } |
|
71 | 71 | |
72 | - if(isset($layouts['advanced_search'])) { |
|
73 | - $advancedSection = $this->mergeSection($advancedSection, $layouts['advanced_search']); |
|
74 | - $advancedSection = $this->applyRules($moduleDir, $advancedSection); |
|
75 | - } |
|
76 | - } //if |
|
72 | + if(isset($layouts['advanced_search'])) { |
|
73 | + $advancedSection = $this->mergeSection($advancedSection, $layouts['advanced_search']); |
|
74 | + $advancedSection = $this->applyRules($moduleDir, $advancedSection); |
|
75 | + } |
|
76 | + } //if |
|
77 | 77 | |
78 | 78 | $header = "<?php\n\n"; |
79 | 79 | $header .= "\$searchdefs['$moduleDir'] = array( |
@@ -95,177 +95,177 @@ discard block |
||
95 | 95 | |
96 | 96 | function mergeSection($section, $masterSection) { |
97 | 97 | |
98 | - // Get all the names in the panel |
|
99 | - $existingElements = array(); |
|
100 | - $existingLocation = array(); |
|
98 | + // Get all the names in the panel |
|
99 | + $existingElements = array(); |
|
100 | + $existingLocation = array(); |
|
101 | 101 | |
102 | - foreach($section as $rowKey=>$row) { |
|
103 | - if(is_array($row) && !empty($row['name'])) { |
|
104 | - $existingElements[$row['name']] = $row['name']; |
|
105 | - $existingLocation[$row['name']] = array("row"=>$rowKey); |
|
106 | - } else if(!is_array($row) && !empty($row)) { |
|
107 | - $existingElements[$row] = $row; |
|
108 | - $existingLocation[$row] = array("row"=>$rowKey); |
|
109 | - } |
|
110 | - } //foreach |
|
102 | + foreach($section as $rowKey=>$row) { |
|
103 | + if(is_array($row) && !empty($row['name'])) { |
|
104 | + $existingElements[$row['name']] = $row['name']; |
|
105 | + $existingLocation[$row['name']] = array("row"=>$rowKey); |
|
106 | + } else if(!is_array($row) && !empty($row)) { |
|
107 | + $existingElements[$row] = $row; |
|
108 | + $existingLocation[$row] = array("row"=>$rowKey); |
|
109 | + } |
|
110 | + } //foreach |
|
111 | 111 | |
112 | - // Now check against the $masterCopy |
|
113 | - foreach($masterSection as $row) { |
|
112 | + // Now check against the $masterCopy |
|
113 | + foreach($masterSection as $row) { |
|
114 | 114 | |
115 | - $addEntry = ''; |
|
116 | - $id = is_array($row) ? $row['name'] : $row; |
|
115 | + $addEntry = ''; |
|
116 | + $id = is_array($row) ? $row['name'] : $row; |
|
117 | 117 | |
118 | - /* |
|
118 | + /* |
|
119 | 119 | if(!isset($existingElements[$id])) { |
120 | 120 | //$addEntry = $row; |
121 | 121 | } |
122 | 122 | */ |
123 | 123 | |
124 | - if(isset($existingElements[$id])) { |
|
125 | - //Use master copy instead |
|
126 | - $section[$existingLocation[$id]['row']] = $row; |
|
127 | - } |
|
124 | + if(isset($existingElements[$id])) { |
|
125 | + //Use master copy instead |
|
126 | + $section[$existingLocation[$id]['row']] = $row; |
|
127 | + } |
|
128 | 128 | |
129 | - // Add it to the $panels |
|
130 | - /* |
|
129 | + // Add it to the $panels |
|
130 | + /* |
|
131 | 131 | if(!empty($addEntry)) { |
132 | 132 | $section[] = $addEntry; |
133 | 133 | } |
134 | 134 | */ |
135 | - } //foreach |
|
135 | + } //foreach |
|
136 | 136 | |
137 | - return $section; |
|
137 | + return $section; |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | function processSection($section, $table, $filePath, $vardefs=array()) { |
141 | 141 | |
142 | - $toptr = $this->getElementsByType("tr", $table); |
|
142 | + $toptr = $this->getElementsByType("tr", $table); |
|
143 | 143 | |
144 | - if(!is_array($toptr) || empty($toptr)) { |
|
145 | - $GLOBALS['log']->error("Could not process top row (<tr>) for $section section"); |
|
146 | - $GLOBALS['log']->error($table); |
|
147 | - return array(); |
|
148 | - } |
|
144 | + if(!is_array($toptr) || empty($toptr)) { |
|
145 | + $GLOBALS['log']->error("Could not process top row (<tr>) for $section section"); |
|
146 | + $GLOBALS['log']->error($table); |
|
147 | + return array(); |
|
148 | + } |
|
149 | 149 | |
150 | - $tabledata = $this->getElementsByType("table", $toptr[0]); |
|
150 | + $tabledata = $this->getElementsByType("table", $toptr[0]); |
|
151 | 151 | |
152 | - if(empty($tabledata)) { |
|
153 | - $GLOBALS['log']->error("Error: HTML format for SearchForm.html not as expected, results may not be accurate"); |
|
154 | - $GLOBALS['log']->error($toptr[0]); |
|
155 | - $tabledata[0] = "<table>{$table}</table>"; |
|
156 | - } |
|
152 | + if(empty($tabledata)) { |
|
153 | + $GLOBALS['log']->error("Error: HTML format for SearchForm.html not as expected, results may not be accurate"); |
|
154 | + $GLOBALS['log']->error($toptr[0]); |
|
155 | + $tabledata[0] = "<table>{$table}</table>"; |
|
156 | + } |
|
157 | 157 | |
158 | - if(is_array($tabledata) && !empty($tabledata[0])) { |
|
159 | - $rows = $this->getElementsByType("tr", $tabledata[0]); |
|
160 | - } else { |
|
161 | - $rows = $toptr[0]; |
|
162 | - } |
|
158 | + if(is_array($tabledata) && !empty($tabledata[0])) { |
|
159 | + $rows = $this->getElementsByType("tr", $tabledata[0]); |
|
160 | + } else { |
|
161 | + $rows = $toptr[0]; |
|
162 | + } |
|
163 | 163 | |
164 | - if(!is_array($rows)) { |
|
165 | - return array(); |
|
166 | - } |
|
164 | + if(!is_array($rows)) { |
|
165 | + return array(); |
|
166 | + } |
|
167 | 167 | |
168 | - $metarow = array(); |
|
169 | - foreach($rows as $trow) { |
|
170 | - $tablecolumns = $this->getElementsByType("td", $trow); |
|
168 | + $metarow = array(); |
|
169 | + foreach($rows as $trow) { |
|
170 | + $tablecolumns = $this->getElementsByType("td", $trow); |
|
171 | 171 | |
172 | - $emptyCount = 0; |
|
173 | - $metacolumn = array(); |
|
174 | - $col = null; |
|
172 | + $emptyCount = 0; |
|
173 | + $metacolumn = array(); |
|
174 | + $col = null; |
|
175 | 175 | |
176 | - foreach($tablecolumns as $tcols) { |
|
176 | + foreach($tablecolumns as $tcols) { |
|
177 | 177 | |
178 | - $spanValue = strtolower($this->getElementValue("span", $tcols)); |
|
179 | - $spanValue2 = strtolower($this->getElementValue("slot", $tcols)); |
|
180 | - $spanValue = !empty($spanValue2) ? $spanValue2 : $spanValue; |
|
181 | - $spanValue3 = strtolower($this->getElementValue("td", $tcols)); |
|
182 | - $spanValue = !empty($spanValue3) ? $spanValue3 : $spanValue; |
|
178 | + $spanValue = strtolower($this->getElementValue("span", $tcols)); |
|
179 | + $spanValue2 = strtolower($this->getElementValue("slot", $tcols)); |
|
180 | + $spanValue = !empty($spanValue2) ? $spanValue2 : $spanValue; |
|
181 | + $spanValue3 = strtolower($this->getElementValue("td", $tcols)); |
|
182 | + $spanValue = !empty($spanValue3) ? $spanValue3 : $spanValue; |
|
183 | 183 | |
184 | - //Get all the editable form elements' names |
|
185 | - $formElementNames = $this->getFormElementsNames($spanValue); |
|
186 | - $customField = $this->getCustomField($formElementNames); |
|
184 | + //Get all the editable form elements' names |
|
185 | + $formElementNames = $this->getFormElementsNames($spanValue); |
|
186 | + $customField = $this->getCustomField($formElementNames); |
|
187 | 187 | |
188 | - $name = ''; |
|
189 | - $fields = null; |
|
190 | - $customCode = null; |
|
188 | + $name = ''; |
|
189 | + $fields = null; |
|
190 | + $customCode = null; |
|
191 | 191 | |
192 | - if(!empty($customField)) { |
|
193 | - // If it's a custom field we just set the name |
|
194 | - $name = $customField; |
|
195 | - } else if(is_array($formElementNames) && count($formElementNames) == 1 |
|
196 | - && (isset($vardefs[$formElementNames[0]]) || $formElementNames[0] == 'current_user_only')) { |
|
197 | - $name = $formElementNames[0]; |
|
198 | - } |
|
192 | + if(!empty($customField)) { |
|
193 | + // If it's a custom field we just set the name |
|
194 | + $name = $customField; |
|
195 | + } else if(is_array($formElementNames) && count($formElementNames) == 1 |
|
196 | + && (isset($vardefs[$formElementNames[0]]) || $formElementNames[0] == 'current_user_only')) { |
|
197 | + $name = $formElementNames[0]; |
|
198 | + } |
|
199 | 199 | |
200 | - //Skip and continue if $name is empty |
|
201 | - if(empty($name)) { |
|
202 | - continue; |
|
203 | - } |
|
200 | + //Skip and continue if $name is empty |
|
201 | + if(empty($name)) { |
|
202 | + continue; |
|
203 | + } |
|
204 | 204 | |
205 | - // Build the entry |
|
206 | - if(preg_match("/<textarea/si", $spanValue)) { |
|
207 | - //special case for textarea form elements (add the displayParams) |
|
208 | - $displayParams = array(); |
|
209 | - $displayParams['rows'] = $this->getTagAttribute("rows", $spanValue); |
|
210 | - $displayParams['cols'] = $this->getTagAttribute("cols", $spanValue); |
|
205 | + // Build the entry |
|
206 | + if(preg_match("/<textarea/si", $spanValue)) { |
|
207 | + //special case for textarea form elements (add the displayParams) |
|
208 | + $displayParams = array(); |
|
209 | + $displayParams['rows'] = $this->getTagAttribute("rows", $spanValue); |
|
210 | + $displayParams['cols'] = $this->getTagAttribute("cols", $spanValue); |
|
211 | 211 | |
212 | - if(!empty($displayParams['rows']) && !empty($displayParams['cols'])) { |
|
213 | - $field = array(); |
|
214 | - $field['name'] = $name; |
|
215 | - $field['displayParams'] = $displayParams; |
|
216 | - } else { |
|
217 | - $field = $name; |
|
218 | - } |
|
212 | + if(!empty($displayParams['rows']) && !empty($displayParams['cols'])) { |
|
213 | + $field = array(); |
|
214 | + $field['name'] = $name; |
|
215 | + $field['displayParams'] = $displayParams; |
|
216 | + } else { |
|
217 | + $field = $name; |
|
218 | + } |
|
219 | 219 | |
220 | - $col = $field; |
|
220 | + $col = $field; |
|
221 | 221 | |
222 | - } else { |
|
222 | + } else { |
|
223 | 223 | |
224 | - if(isset($fields)) { |
|
225 | - $field = array(); |
|
226 | - $field['name'] = $name; |
|
227 | - if(isset($fields)) { |
|
228 | - $field['fields'] = $fields; |
|
229 | - } |
|
224 | + if(isset($fields)) { |
|
225 | + $field = array(); |
|
226 | + $field['name'] = $name; |
|
227 | + if(isset($fields)) { |
|
228 | + $field['fields'] = $fields; |
|
229 | + } |
|
230 | 230 | |
231 | - if(!empty($customCode)) { |
|
232 | - $field['customCode'] = $customCode; |
|
233 | - } |
|
231 | + if(!empty($customCode)) { |
|
232 | + $field['customCode'] = $customCode; |
|
233 | + } |
|
234 | 234 | |
235 | - $col = $field; |
|
236 | - } else { |
|
237 | - $emptyCount = $name == '' ? $emptyCount + 1 : $emptyCount; |
|
238 | - $col = $name; |
|
239 | - } |
|
240 | - } //if-else if-else block |
|
241 | - $metarow[] = $col; |
|
242 | - } //foreach |
|
235 | + $col = $field; |
|
236 | + } else { |
|
237 | + $emptyCount = $name == '' ? $emptyCount + 1 : $emptyCount; |
|
238 | + $col = $name; |
|
239 | + } |
|
240 | + } //if-else if-else block |
|
241 | + $metarow[] = $col; |
|
242 | + } //foreach |
|
243 | 243 | |
244 | - // One last final check. If $emptyCount does not equal Array $col count, don't add |
|
245 | - if($emptyCount != count($col)) { |
|
246 | - //$metarow[] = $col; |
|
247 | - } //if |
|
244 | + // One last final check. If $emptyCount does not equal Array $col count, don't add |
|
245 | + if($emptyCount != count($col)) { |
|
246 | + //$metarow[] = $col; |
|
247 | + } //if |
|
248 | 248 | |
249 | - } //foreach |
|
249 | + } //foreach |
|
250 | 250 | |
251 | - return $metarow; |
|
251 | + return $metarow; |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | function applyRules($moduleDir, $section=array()) { |
255 | - require_once('include/SugarFields/Parsers/Rules/BaseRule.php'); |
|
256 | - $baseRule = new BaseRule(); |
|
257 | - if(!is_array($section)) { |
|
258 | - $GLOBALS['log']->error("Error: SearchFormMetaParser->applyRules expects Array"); |
|
259 | - return $section; |
|
260 | - } |
|
255 | + require_once('include/SugarFields/Parsers/Rules/BaseRule.php'); |
|
256 | + $baseRule = new BaseRule(); |
|
257 | + if(!is_array($section)) { |
|
258 | + $GLOBALS['log']->error("Error: SearchFormMetaParser->applyRules expects Array"); |
|
259 | + return $section; |
|
260 | + } |
|
261 | 261 | |
262 | - foreach($section as $key=>$row) { |
|
263 | - //Override email1 fields |
|
264 | - if($baseRule->matches($row, '/^email1$/si')) { |
|
265 | - $section[$key] = array('name' => 'email', 'label' =>'LBL_ANY_EMAIL', 'type' => 'name'); |
|
266 | - } |
|
267 | - } |
|
268 | - return $section; |
|
262 | + foreach($section as $key=>$row) { |
|
263 | + //Override email1 fields |
|
264 | + if($baseRule->matches($row, '/^email1$/si')) { |
|
265 | + $section[$key] = array('name' => 'email', 'label' =>'LBL_ANY_EMAIL', 'type' => 'name'); |
|
266 | + } |
|
267 | + } |
|
268 | + return $section; |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * @param $mixed |
51 | 51 | * @return $obj A MetaDataBean instance |
52 | 52 | **/ |
53 | -function parse($filePath, $vardefs = array(), $moduleDir = '', $merge=false, $masterCopy=null) { |
|
53 | +function parse($filePath, $vardefs = array(), $moduleDir = '', $merge = false, $masterCopy = null) { |
|
54 | 54 | |
55 | 55 | $contents = file_get_contents($filePath); |
56 | 56 | $contents = $this->trimHTML($contents); |
@@ -60,16 +60,16 @@ discard block |
||
60 | 60 | //basic search table |
61 | 61 | $basicSection = $this->processSection("basic", $tables[0], $filePath, $vardefs); |
62 | 62 | $advancedSection = $this->processSection("advanced", $tables[1], $filePath, $vardefs); |
63 | - if(file_exists($masterCopy)) { |
|
63 | + if (file_exists($masterCopy)) { |
|
64 | 64 | require($masterCopy); |
65 | 65 | $layouts = $searchdefs[$moduleDir]['layout']; |
66 | 66 | |
67 | - if(isset($layouts['basic_search'])) { |
|
67 | + if (isset($layouts['basic_search'])) { |
|
68 | 68 | $basicSection = $this->mergeSection($basicSection, $layouts['basic_search']); |
69 | 69 | $basicSection = $this->applyRules($moduleDir, $basicSection); |
70 | 70 | } |
71 | 71 | |
72 | - if(isset($layouts['advanced_search'])) { |
|
72 | + if (isset($layouts['advanced_search'])) { |
|
73 | 73 | $advancedSection = $this->mergeSection($advancedSection, $layouts['advanced_search']); |
74 | 74 | $advancedSection = $this->applyRules($moduleDir, $advancedSection); |
75 | 75 | } |
@@ -80,15 +80,15 @@ discard block |
||
80 | 80 | 'templateMeta' => array('maxColumns' => '3', 'widths' => array('label' => '10', 'field' => '30')), |
81 | 81 | 'layout' => array( |
82 | 82 | \n\t'basic_search' =>"; |
83 | -$header .= "\t" . var_export($basicSection, true); |
|
83 | +$header .= "\t".var_export($basicSection, true); |
|
84 | 84 | $header .= "\n\t,'advanced_search' =>"; |
85 | -$header .= "\t" . var_export($advancedSection, true); |
|
85 | +$header .= "\t".var_export($advancedSection, true); |
|
86 | 86 | $header .= " |
87 | 87 | ),\n |
88 | 88 | ); |
89 | 89 | ?>"; |
90 | 90 | |
91 | -$header = preg_replace('/(\d+)[\s]=>[\s]?/',"",$header); |
|
91 | +$header = preg_replace('/(\d+)[\s]=>[\s]?/', "", $header); |
|
92 | 92 | return $header; |
93 | 93 | |
94 | 94 | } |
@@ -99,18 +99,18 @@ discard block |
||
99 | 99 | $existingElements = array(); |
100 | 100 | $existingLocation = array(); |
101 | 101 | |
102 | - foreach($section as $rowKey=>$row) { |
|
103 | - if(is_array($row) && !empty($row['name'])) { |
|
102 | + foreach ($section as $rowKey=>$row) { |
|
103 | + if (is_array($row) && !empty($row['name'])) { |
|
104 | 104 | $existingElements[$row['name']] = $row['name']; |
105 | 105 | $existingLocation[$row['name']] = array("row"=>$rowKey); |
106 | - } else if(!is_array($row) && !empty($row)) { |
|
106 | + } else if (!is_array($row) && !empty($row)) { |
|
107 | 107 | $existingElements[$row] = $row; |
108 | 108 | $existingLocation[$row] = array("row"=>$rowKey); |
109 | 109 | } |
110 | 110 | } //foreach |
111 | 111 | |
112 | 112 | // Now check against the $masterCopy |
113 | - foreach($masterSection as $row) { |
|
113 | + foreach ($masterSection as $row) { |
|
114 | 114 | |
115 | 115 | $addEntry = ''; |
116 | 116 | $id = is_array($row) ? $row['name'] : $row; |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | } |
122 | 122 | */ |
123 | 123 | |
124 | - if(isset($existingElements[$id])) { |
|
124 | + if (isset($existingElements[$id])) { |
|
125 | 125 | //Use master copy instead |
126 | 126 | $section[$existingLocation[$id]['row']] = $row; |
127 | 127 | } |
@@ -137,11 +137,11 @@ discard block |
||
137 | 137 | return $section; |
138 | 138 | } |
139 | 139 | |
140 | -function processSection($section, $table, $filePath, $vardefs=array()) { |
|
140 | +function processSection($section, $table, $filePath, $vardefs = array()) { |
|
141 | 141 | |
142 | 142 | $toptr = $this->getElementsByType("tr", $table); |
143 | 143 | |
144 | - if(!is_array($toptr) || empty($toptr)) { |
|
144 | + if (!is_array($toptr) || empty($toptr)) { |
|
145 | 145 | $GLOBALS['log']->error("Could not process top row (<tr>) for $section section"); |
146 | 146 | $GLOBALS['log']->error($table); |
147 | 147 | return array(); |
@@ -149,31 +149,31 @@ discard block |
||
149 | 149 | |
150 | 150 | $tabledata = $this->getElementsByType("table", $toptr[0]); |
151 | 151 | |
152 | - if(empty($tabledata)) { |
|
152 | + if (empty($tabledata)) { |
|
153 | 153 | $GLOBALS['log']->error("Error: HTML format for SearchForm.html not as expected, results may not be accurate"); |
154 | 154 | $GLOBALS['log']->error($toptr[0]); |
155 | 155 | $tabledata[0] = "<table>{$table}</table>"; |
156 | 156 | } |
157 | 157 | |
158 | - if(is_array($tabledata) && !empty($tabledata[0])) { |
|
158 | + if (is_array($tabledata) && !empty($tabledata[0])) { |
|
159 | 159 | $rows = $this->getElementsByType("tr", $tabledata[0]); |
160 | 160 | } else { |
161 | 161 | $rows = $toptr[0]; |
162 | 162 | } |
163 | 163 | |
164 | - if(!is_array($rows)) { |
|
164 | + if (!is_array($rows)) { |
|
165 | 165 | return array(); |
166 | 166 | } |
167 | 167 | |
168 | 168 | $metarow = array(); |
169 | - foreach($rows as $trow) { |
|
169 | + foreach ($rows as $trow) { |
|
170 | 170 | $tablecolumns = $this->getElementsByType("td", $trow); |
171 | 171 | |
172 | 172 | $emptyCount = 0; |
173 | 173 | $metacolumn = array(); |
174 | 174 | $col = null; |
175 | 175 | |
176 | - foreach($tablecolumns as $tcols) { |
|
176 | + foreach ($tablecolumns as $tcols) { |
|
177 | 177 | |
178 | 178 | $spanValue = strtolower($this->getElementValue("span", $tcols)); |
179 | 179 | $spanValue2 = strtolower($this->getElementValue("slot", $tcols)); |
@@ -189,27 +189,27 @@ discard block |
||
189 | 189 | $fields = null; |
190 | 190 | $customCode = null; |
191 | 191 | |
192 | - if(!empty($customField)) { |
|
192 | + if (!empty($customField)) { |
|
193 | 193 | // If it's a custom field we just set the name |
194 | 194 | $name = $customField; |
195 | - } else if(is_array($formElementNames) && count($formElementNames) == 1 |
|
195 | + } else if (is_array($formElementNames) && count($formElementNames) == 1 |
|
196 | 196 | && (isset($vardefs[$formElementNames[0]]) || $formElementNames[0] == 'current_user_only')) { |
197 | 197 | $name = $formElementNames[0]; |
198 | 198 | } |
199 | 199 | |
200 | 200 | //Skip and continue if $name is empty |
201 | - if(empty($name)) { |
|
201 | + if (empty($name)) { |
|
202 | 202 | continue; |
203 | 203 | } |
204 | 204 | |
205 | 205 | // Build the entry |
206 | - if(preg_match("/<textarea/si", $spanValue)) { |
|
206 | + if (preg_match("/<textarea/si", $spanValue)) { |
|
207 | 207 | //special case for textarea form elements (add the displayParams) |
208 | 208 | $displayParams = array(); |
209 | 209 | $displayParams['rows'] = $this->getTagAttribute("rows", $spanValue); |
210 | 210 | $displayParams['cols'] = $this->getTagAttribute("cols", $spanValue); |
211 | 211 | |
212 | - if(!empty($displayParams['rows']) && !empty($displayParams['cols'])) { |
|
212 | + if (!empty($displayParams['rows']) && !empty($displayParams['cols'])) { |
|
213 | 213 | $field = array(); |
214 | 214 | $field['name'] = $name; |
215 | 215 | $field['displayParams'] = $displayParams; |
@@ -221,14 +221,14 @@ discard block |
||
221 | 221 | |
222 | 222 | } else { |
223 | 223 | |
224 | - if(isset($fields)) { |
|
224 | + if (isset($fields)) { |
|
225 | 225 | $field = array(); |
226 | 226 | $field['name'] = $name; |
227 | - if(isset($fields)) { |
|
227 | + if (isset($fields)) { |
|
228 | 228 | $field['fields'] = $fields; |
229 | 229 | } |
230 | 230 | |
231 | - if(!empty($customCode)) { |
|
231 | + if (!empty($customCode)) { |
|
232 | 232 | $field['customCode'] = $customCode; |
233 | 233 | } |
234 | 234 | |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | } //foreach |
243 | 243 | |
244 | 244 | // One last final check. If $emptyCount does not equal Array $col count, don't add |
245 | - if($emptyCount != count($col)) { |
|
245 | + if ($emptyCount != count($col)) { |
|
246 | 246 | //$metarow[] = $col; |
247 | 247 | } //if |
248 | 248 | |
@@ -251,17 +251,17 @@ discard block |
||
251 | 251 | return $metarow; |
252 | 252 | } |
253 | 253 | |
254 | -function applyRules($moduleDir, $section=array()) { |
|
254 | +function applyRules($moduleDir, $section = array()) { |
|
255 | 255 | require_once('include/SugarFields/Parsers/Rules/BaseRule.php'); |
256 | 256 | $baseRule = new BaseRule(); |
257 | - if(!is_array($section)) { |
|
257 | + if (!is_array($section)) { |
|
258 | 258 | $GLOBALS['log']->error("Error: SearchFormMetaParser->applyRules expects Array"); |
259 | 259 | return $section; |
260 | 260 | } |
261 | 261 | |
262 | - foreach($section as $key=>$row) { |
|
262 | + foreach ($section as $key=>$row) { |
|
263 | 263 | //Override email1 fields |
264 | - if($baseRule->matches($row, '/^email1$/si')) { |
|
264 | + if ($baseRule->matches($row, '/^email1$/si')) { |
|
265 | 265 | $section[$key] = array('name' => 'email', 'label' =>'LBL_ANY_EMAIL', 'type' => 'name'); |
266 | 266 | } |
267 | 267 | } |
@@ -49,24 +49,24 @@ discard block |
||
49 | 49 | |
50 | 50 | static function fixupFieldType($field) { |
51 | 51 | switch($field) { |
52 | - case 'double': |
|
52 | + case 'double': |
|
53 | 53 | case 'decimal': |
54 | 54 | $field = 'float'; |
55 | 55 | break; |
56 | - case 'uint': |
|
56 | + case 'uint': |
|
57 | 57 | case 'ulong': |
58 | 58 | case 'long': |
59 | 59 | case 'short': |
60 | 60 | case 'tinyint': |
61 | 61 | $field = 'int'; |
62 | 62 | break; |
63 | - case 'date': |
|
63 | + case 'date': |
|
64 | 64 | $field = 'datetime'; |
65 | 65 | break; |
66 | - case 'url': |
|
67 | - $field = 'link'; |
|
68 | - break; |
|
69 | - case 'varchar': |
|
66 | + case 'url': |
|
67 | + $field = 'link'; |
|
68 | + break; |
|
69 | + case 'varchar': |
|
70 | 70 | $field = 'base'; |
71 | 71 | break; |
72 | 72 | } |
@@ -86,34 +86,34 @@ discard block |
||
86 | 86 | $field = ucfirst($field); |
87 | 87 | |
88 | 88 | if(!isset($sugarFieldObjects[$field])) { |
89 | - //check custom directory |
|
90 | - if(file_exists('custom/include/SugarFields/Fields/' . $field . '/SugarField' . $field. '.php')){ |
|
91 | - $file = 'custom/include/SugarFields/Fields/' . $field . '/SugarField' . $field. '.php'; |
|
89 | + //check custom directory |
|
90 | + if(file_exists('custom/include/SugarFields/Fields/' . $field . '/SugarField' . $field. '.php')){ |
|
91 | + $file = 'custom/include/SugarFields/Fields/' . $field . '/SugarField' . $field. '.php'; |
|
92 | 92 | $type = $field; |
93 | - //else check the fields directory |
|
94 | - }else if(file_exists('include/SugarFields/Fields/' . $field . '/SugarField' . $field. '.php')){ |
|
95 | - $file = 'include/SugarFields/Fields/' . $field . '/SugarField' . $field. '.php'; |
|
93 | + //else check the fields directory |
|
94 | + }else if(file_exists('include/SugarFields/Fields/' . $field . '/SugarField' . $field. '.php')){ |
|
95 | + $file = 'include/SugarFields/Fields/' . $field . '/SugarField' . $field. '.php'; |
|
96 | 96 | $type = $field; |
97 | - }else{ |
|
97 | + }else{ |
|
98 | 98 | // No direct class, check the directories to see if they are defined |
99 | - if( $returnNullIfBase && |
|
99 | + if( $returnNullIfBase && |
|
100 | 100 | !is_dir('custom/include/SugarFields/Fields/'.$field) && |
101 | 101 | !is_dir('include/SugarFields/Fields/'.$field) ) { |
102 | 102 | return null; |
103 | 103 | } |
104 | - $file = 'include/SugarFields/Fields/Base/SugarFieldBase.php'; |
|
104 | + $file = 'include/SugarFields/Fields/Base/SugarFieldBase.php'; |
|
105 | 105 | $type = 'Base'; |
106 | - } |
|
107 | - require_once($file); |
|
106 | + } |
|
107 | + require_once($file); |
|
108 | 108 | |
109 | - $class = 'SugarField' . $type; |
|
110 | - //could be a custom class check it |
|
111 | - $customClass = 'Custom' . $class; |
|
112 | - if(class_exists($customClass)){ |
|
113 | - $sugarFieldObjects[$field] = new $customClass($field); |
|
114 | - }else{ |
|
115 | - $sugarFieldObjects[$field] = new $class($field); |
|
116 | - } |
|
109 | + $class = 'SugarField' . $type; |
|
110 | + //could be a custom class check it |
|
111 | + $customClass = 'Custom' . $class; |
|
112 | + if(class_exists($customClass)){ |
|
113 | + $sugarFieldObjects[$field] = new $customClass($field); |
|
114 | + }else{ |
|
115 | + $sugarFieldObjects[$field] = new $class($field); |
|
116 | + } |
|
117 | 117 | } |
118 | 118 | return $sugarFieldObjects[$field]; |
119 | 119 | } |
@@ -134,22 +134,22 @@ discard block |
||
134 | 134 | $string = ''; |
135 | 135 | $displayTypeFunc = 'get' . $displayType . 'Smarty'; // getDetailViewSmarty, getEditViewSmarty, etc... |
136 | 136 | |
137 | - // This will handle custom type fields. |
|
138 | - // The incoming $vardef Array may have custom_type set. |
|
139 | - // If so, set $vardef['type'] to the $vardef['custom_type'] value |
|
140 | - if(isset($vardef['custom_type'])) { |
|
141 | - $vardef['type'] = $vardef['custom_type']; |
|
142 | - } |
|
143 | - if(empty($vardef['type'])) { |
|
144 | - $vardef['type'] = 'varchar'; |
|
145 | - } |
|
137 | + // This will handle custom type fields. |
|
138 | + // The incoming $vardef Array may have custom_type set. |
|
139 | + // If so, set $vardef['type'] to the $vardef['custom_type'] value |
|
140 | + if(isset($vardef['custom_type'])) { |
|
141 | + $vardef['type'] = $vardef['custom_type']; |
|
142 | + } |
|
143 | + if(empty($vardef['type'])) { |
|
144 | + $vardef['type'] = 'varchar'; |
|
145 | + } |
|
146 | 146 | |
147 | - $field = self::getSugarField($vardef['type']); |
|
148 | - if ( !empty($vardef['function']) ) { |
|
149 | - $string = $field->displayFromFunc($displayType, $parentFieldArray, $vardef, $displayParams, $tabindex); |
|
150 | - } else { |
|
151 | - $string = $field->$displayTypeFunc($parentFieldArray, $vardef, $displayParams, $tabindex); |
|
152 | - } |
|
147 | + $field = self::getSugarField($vardef['type']); |
|
148 | + if ( !empty($vardef['function']) ) { |
|
149 | + $string = $field->displayFromFunc($displayType, $parentFieldArray, $vardef, $displayParams, $tabindex); |
|
150 | + } else { |
|
151 | + $string = $field->$displayTypeFunc($parentFieldArray, $vardef, $displayParams, $tabindex); |
|
152 | + } |
|
153 | 153 | |
154 | 154 | return $string; |
155 | 155 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | } |
49 | 49 | |
50 | 50 | static function fixupFieldType($field) { |
51 | - switch($field) { |
|
51 | + switch ($field) { |
|
52 | 52 | case 'double': |
53 | 53 | case 'decimal': |
54 | 54 | $field = 'float'; |
@@ -79,26 +79,26 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @param field string field type |
81 | 81 | */ |
82 | - static function getSugarField($field, $returnNullIfBase=false) { |
|
82 | + static function getSugarField($field, $returnNullIfBase = false) { |
|
83 | 83 | static $sugarFieldObjects = array(); |
84 | 84 | |
85 | 85 | $field = self::fixupFieldType($field); |
86 | 86 | $field = ucfirst($field); |
87 | 87 | |
88 | - if(!isset($sugarFieldObjects[$field])) { |
|
88 | + if (!isset($sugarFieldObjects[$field])) { |
|
89 | 89 | //check custom directory |
90 | - if(file_exists('custom/include/SugarFields/Fields/' . $field . '/SugarField' . $field. '.php')){ |
|
91 | - $file = 'custom/include/SugarFields/Fields/' . $field . '/SugarField' . $field. '.php'; |
|
90 | + if (file_exists('custom/include/SugarFields/Fields/'.$field.'/SugarField'.$field.'.php')) { |
|
91 | + $file = 'custom/include/SugarFields/Fields/'.$field.'/SugarField'.$field.'.php'; |
|
92 | 92 | $type = $field; |
93 | 93 | //else check the fields directory |
94 | - }else if(file_exists('include/SugarFields/Fields/' . $field . '/SugarField' . $field. '.php')){ |
|
95 | - $file = 'include/SugarFields/Fields/' . $field . '/SugarField' . $field. '.php'; |
|
94 | + } else if (file_exists('include/SugarFields/Fields/'.$field.'/SugarField'.$field.'.php')) { |
|
95 | + $file = 'include/SugarFields/Fields/'.$field.'/SugarField'.$field.'.php'; |
|
96 | 96 | $type = $field; |
97 | - }else{ |
|
97 | + } else { |
|
98 | 98 | // No direct class, check the directories to see if they are defined |
99 | - if( $returnNullIfBase && |
|
99 | + if ($returnNullIfBase && |
|
100 | 100 | !is_dir('custom/include/SugarFields/Fields/'.$field) && |
101 | - !is_dir('include/SugarFields/Fields/'.$field) ) { |
|
101 | + !is_dir('include/SugarFields/Fields/'.$field)) { |
|
102 | 102 | return null; |
103 | 103 | } |
104 | 104 | $file = 'include/SugarFields/Fields/Base/SugarFieldBase.php'; |
@@ -106,12 +106,12 @@ discard block |
||
106 | 106 | } |
107 | 107 | require_once($file); |
108 | 108 | |
109 | - $class = 'SugarField' . $type; |
|
109 | + $class = 'SugarField'.$type; |
|
110 | 110 | //could be a custom class check it |
111 | - $customClass = 'Custom' . $class; |
|
112 | - if(class_exists($customClass)){ |
|
111 | + $customClass = 'Custom'.$class; |
|
112 | + if (class_exists($customClass)) { |
|
113 | 113 | $sugarFieldObjects[$field] = new $customClass($field); |
114 | - }else{ |
|
114 | + } else { |
|
115 | 115 | $sugarFieldObjects[$field] = new $class($field); |
116 | 116 | } |
117 | 117 | } |
@@ -132,20 +132,20 @@ discard block |
||
132 | 132 | */ |
133 | 133 | static function displaySmarty($parentFieldArray, $vardef, $displayType, $displayParams = array(), $tabindex = 1) { |
134 | 134 | $string = ''; |
135 | - $displayTypeFunc = 'get' . $displayType . 'Smarty'; // getDetailViewSmarty, getEditViewSmarty, etc... |
|
135 | + $displayTypeFunc = 'get'.$displayType.'Smarty'; // getDetailViewSmarty, getEditViewSmarty, etc... |
|
136 | 136 | |
137 | 137 | // This will handle custom type fields. |
138 | 138 | // The incoming $vardef Array may have custom_type set. |
139 | 139 | // If so, set $vardef['type'] to the $vardef['custom_type'] value |
140 | - if(isset($vardef['custom_type'])) { |
|
140 | + if (isset($vardef['custom_type'])) { |
|
141 | 141 | $vardef['type'] = $vardef['custom_type']; |
142 | 142 | } |
143 | - if(empty($vardef['type'])) { |
|
143 | + if (empty($vardef['type'])) { |
|
144 | 144 | $vardef['type'] = 'varchar'; |
145 | 145 | } |
146 | 146 | |
147 | 147 | $field = self::getSugarField($vardef['type']); |
148 | - if ( !empty($vardef['function']) ) { |
|
148 | + if (!empty($vardef['function'])) { |
|
149 | 149 | $string = $field->displayFromFunc($displayType, $parentFieldArray, $vardef, $displayParams, $tabindex); |
150 | 150 | } else { |
151 | 151 | $string = $field->$displayTypeFunc($parentFieldArray, $vardef, $displayParams, $tabindex); |
@@ -91,10 +91,10 @@ discard block |
||
91 | 91 | $file = 'custom/include/SugarFields/Fields/' . $field . '/SugarField' . $field. '.php'; |
92 | 92 | $type = $field; |
93 | 93 | //else check the fields directory |
94 | - }else if(file_exists('include/SugarFields/Fields/' . $field . '/SugarField' . $field. '.php')){ |
|
94 | + } else if(file_exists('include/SugarFields/Fields/' . $field . '/SugarField' . $field. '.php')){ |
|
95 | 95 | $file = 'include/SugarFields/Fields/' . $field . '/SugarField' . $field. '.php'; |
96 | 96 | $type = $field; |
97 | - }else{ |
|
97 | + } else{ |
|
98 | 98 | // No direct class, check the directories to see if they are defined |
99 | 99 | if( $returnNullIfBase && |
100 | 100 | !is_dir('custom/include/SugarFields/Fields/'.$field) && |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $customClass = 'Custom' . $class; |
112 | 112 | if(class_exists($customClass)){ |
113 | 113 | $sugarFieldObjects[$field] = new $customClass($field); |
114 | - }else{ |
|
114 | + } else{ |
|
115 | 115 | $sugarFieldObjects[$field] = new $class($field); |
116 | 116 | } |
117 | 117 | } |
@@ -44,19 +44,19 @@ discard block |
||
44 | 44 | function getEditViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) { |
45 | 45 | // Create Smarty variables for the Calendar picker widget |
46 | 46 | if(!isset($displayParams['showMinutesDropdown'])) { |
47 | - $displayParams['showMinutesDropdown'] = false; |
|
47 | + $displayParams['showMinutesDropdown'] = false; |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | if(!isset($displayParams['showHoursDropdown'])) { |
51 | - $displayParams['showHoursDropdown'] = false; |
|
51 | + $displayParams['showHoursDropdown'] = false; |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | if(!isset($displayParams['showNoneCheckbox'])) { |
55 | - $displayParams['showNoneCheckbox'] = false; |
|
55 | + $displayParams['showNoneCheckbox'] = false; |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | if(!isset($displayParams['showFormats'])) { |
59 | - $displayParams['showFormats'] = false; |
|
59 | + $displayParams['showFormats'] = false; |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | global $timedate; |
@@ -75,44 +75,44 @@ discard block |
||
75 | 75 | |
76 | 76 | function getSearchViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) { |
77 | 77 | |
78 | - if($this->isRangeSearchView($vardef)) { |
|
79 | - $displayParams['showMinutesDropdown'] = false; |
|
80 | - $displayParams['showHoursDropdown'] = false; |
|
81 | - $displayParams['showNoneCheckbox'] = false; |
|
82 | - $displayParams['showFormats'] = false; |
|
83 | - global $timedate, $current_language; |
|
84 | - $displayParams['dateFormat'] = $timedate->get_cal_date_format(); |
|
85 | - $displayParams['timeFormat'] = $timedate->get_user_time_format(); |
|
86 | - |
|
87 | - $this->setup($parentFieldArray, $vardef, $displayParams, $tabindex); |
|
88 | - $id = isset($displayParams['idName']) ? $displayParams['idName'] : $vardef['name']; |
|
89 | - $this->ss->assign('original_id', "{$id}"); |
|
90 | - $this->ss->assign('id_range', "range_{$id}"); |
|
91 | - $this->ss->assign('id_range_start', "start_range_{$id}"); |
|
92 | - $this->ss->assign('id_range_end', "end_range_{$id}"); |
|
93 | - $this->ss->assign('id_range_choice', "{$id}_range_choice"); |
|
94 | - if(file_exists('custom/include/SugarFields/Fields/Datetimecombo/RangeSearchForm.tpl')) |
|
95 | - { |
|
96 | - return $this->fetch('custom/include/SugarFields/Fields/Datetimecombo/RangeSearchForm.tpl'); |
|
97 | - } |
|
98 | - return $this->fetch('include/SugarFields/Fields/Datetimecombo/RangeSearchForm.tpl'); |
|
78 | + if($this->isRangeSearchView($vardef)) { |
|
79 | + $displayParams['showMinutesDropdown'] = false; |
|
80 | + $displayParams['showHoursDropdown'] = false; |
|
81 | + $displayParams['showNoneCheckbox'] = false; |
|
82 | + $displayParams['showFormats'] = false; |
|
83 | + global $timedate, $current_language; |
|
84 | + $displayParams['dateFormat'] = $timedate->get_cal_date_format(); |
|
85 | + $displayParams['timeFormat'] = $timedate->get_user_time_format(); |
|
86 | + |
|
87 | + $this->setup($parentFieldArray, $vardef, $displayParams, $tabindex); |
|
88 | + $id = isset($displayParams['idName']) ? $displayParams['idName'] : $vardef['name']; |
|
89 | + $this->ss->assign('original_id', "{$id}"); |
|
90 | + $this->ss->assign('id_range', "range_{$id}"); |
|
91 | + $this->ss->assign('id_range_start', "start_range_{$id}"); |
|
92 | + $this->ss->assign('id_range_end', "end_range_{$id}"); |
|
93 | + $this->ss->assign('id_range_choice', "{$id}_range_choice"); |
|
94 | + if(file_exists('custom/include/SugarFields/Fields/Datetimecombo/RangeSearchForm.tpl')) |
|
95 | + { |
|
96 | + return $this->fetch('custom/include/SugarFields/Fields/Datetimecombo/RangeSearchForm.tpl'); |
|
97 | + } |
|
98 | + return $this->fetch('include/SugarFields/Fields/Datetimecombo/RangeSearchForm.tpl'); |
|
99 | 99 | } |
100 | 100 | |
101 | - // Create Smarty variables for the Calendar picker widget |
|
101 | + // Create Smarty variables for the Calendar picker widget |
|
102 | 102 | if(!isset($displayParams['showMinutesDropdown'])) { |
103 | - $displayParams['showMinutesDropdown'] = false; |
|
103 | + $displayParams['showMinutesDropdown'] = false; |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | if(!isset($displayParams['showHoursDropdown'])) { |
107 | - $displayParams['showHoursDropdown'] = false; |
|
107 | + $displayParams['showHoursDropdown'] = false; |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | if(!isset($displayParams['showNoneCheckbox'])) { |
111 | - $displayParams['showNoneCheckbox'] = false; |
|
111 | + $displayParams['showNoneCheckbox'] = false; |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | if(!isset($displayParams['showFormats'])) { |
115 | - $displayParams['showFormats'] = false; |
|
115 | + $displayParams['showFormats'] = false; |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | global $timedate; |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | } |
125 | 125 | |
126 | 126 | |
127 | - public function getEmailTemplateValue($inputField, $vardef, $context = null, $tabindex = 0){ |
|
127 | + public function getEmailTemplateValue($inputField, $vardef, $context = null, $tabindex = 0){ |
|
128 | 128 | // This does not return a smarty section, instead it returns a direct value |
129 | 129 | if(isset($context['notify_user'])) { |
130 | 130 | $user = $context['notify_user']; |
@@ -143,14 +143,14 @@ discard block |
||
143 | 143 | |
144 | 144 | if(strpos($params[$prefix.$field], ' ') > 0) { |
145 | 145 | if ($timedate->check_matching_format($params[$prefix.$field], TimeDate::DB_DATETIME_FORMAT)) { |
146 | - $bean->$field = $params[$prefix.$field]; |
|
146 | + $bean->$field = $params[$prefix.$field]; |
|
147 | 147 | } else { |
148 | 148 | $bean->$field = $timedate->to_db($params[$prefix.$field]); |
149 | 149 | } |
150 | 150 | } else { |
151 | - $GLOBALS['log']->error('Field ' . $prefix.$field . ' expecting datetime format, but got value: ' . $params[$prefix.$field]); |
|
152 | - //Default to assume date format value |
|
153 | - if ($timedate->check_matching_format($params[$prefix.$field], TimeDate::DB_DATE_FORMAT)) { |
|
151 | + $GLOBALS['log']->error('Field ' . $prefix.$field . ' expecting datetime format, but got value: ' . $params[$prefix.$field]); |
|
152 | + //Default to assume date format value |
|
153 | + if ($timedate->check_matching_format($params[$prefix.$field], TimeDate::DB_DATE_FORMAT)) { |
|
154 | 154 | $bean->$field = $params[$prefix.$field]; |
155 | 155 | } else { |
156 | 156 | $bean->$field = $timedate->to_db_date($params[$prefix.$field]); |
@@ -175,10 +175,10 @@ discard block |
||
175 | 175 | if ( !$timedate->check_matching_format($value, $format) ) { |
176 | 176 | $parts = $timedate->split_date_time($value); |
177 | 177 | if(empty($parts[0])) { |
178 | - $datepart = $timedate->getNow()->format($settings->dateformat); |
|
178 | + $datepart = $timedate->getNow()->format($settings->dateformat); |
|
179 | 179 | } |
180 | 180 | else { |
181 | - $datepart = $parts[0]; |
|
181 | + $datepart = $parts[0]; |
|
182 | 182 | } |
183 | 183 | if(empty($parts[1])) { |
184 | 184 | $timepart = $timedate->fromTimestamp(0)->format($settings->timeformat); |
@@ -43,19 +43,19 @@ discard block |
||
43 | 43 | |
44 | 44 | function getEditViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) { |
45 | 45 | // Create Smarty variables for the Calendar picker widget |
46 | - if(!isset($displayParams['showMinutesDropdown'])) { |
|
46 | + if (!isset($displayParams['showMinutesDropdown'])) { |
|
47 | 47 | $displayParams['showMinutesDropdown'] = false; |
48 | 48 | } |
49 | 49 | |
50 | - if(!isset($displayParams['showHoursDropdown'])) { |
|
50 | + if (!isset($displayParams['showHoursDropdown'])) { |
|
51 | 51 | $displayParams['showHoursDropdown'] = false; |
52 | 52 | } |
53 | 53 | |
54 | - if(!isset($displayParams['showNoneCheckbox'])) { |
|
54 | + if (!isset($displayParams['showNoneCheckbox'])) { |
|
55 | 55 | $displayParams['showNoneCheckbox'] = false; |
56 | 56 | } |
57 | 57 | |
58 | - if(!isset($displayParams['showFormats'])) { |
|
58 | + if (!isset($displayParams['showFormats'])) { |
|
59 | 59 | $displayParams['showFormats'] = false; |
60 | 60 | } |
61 | 61 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | |
76 | 76 | function getSearchViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex) { |
77 | 77 | |
78 | - if($this->isRangeSearchView($vardef)) { |
|
78 | + if ($this->isRangeSearchView($vardef)) { |
|
79 | 79 | $displayParams['showMinutesDropdown'] = false; |
80 | 80 | $displayParams['showHoursDropdown'] = false; |
81 | 81 | $displayParams['showNoneCheckbox'] = false; |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | $this->ss->assign('id_range_start', "start_range_{$id}"); |
92 | 92 | $this->ss->assign('id_range_end', "end_range_{$id}"); |
93 | 93 | $this->ss->assign('id_range_choice', "{$id}_range_choice"); |
94 | - if(file_exists('custom/include/SugarFields/Fields/Datetimecombo/RangeSearchForm.tpl')) |
|
94 | + if (file_exists('custom/include/SugarFields/Fields/Datetimecombo/RangeSearchForm.tpl')) |
|
95 | 95 | { |
96 | 96 | return $this->fetch('custom/include/SugarFields/Fields/Datetimecombo/RangeSearchForm.tpl'); |
97 | 97 | } |
@@ -99,19 +99,19 @@ discard block |
||
99 | 99 | } |
100 | 100 | |
101 | 101 | // Create Smarty variables for the Calendar picker widget |
102 | - if(!isset($displayParams['showMinutesDropdown'])) { |
|
102 | + if (!isset($displayParams['showMinutesDropdown'])) { |
|
103 | 103 | $displayParams['showMinutesDropdown'] = false; |
104 | 104 | } |
105 | 105 | |
106 | - if(!isset($displayParams['showHoursDropdown'])) { |
|
106 | + if (!isset($displayParams['showHoursDropdown'])) { |
|
107 | 107 | $displayParams['showHoursDropdown'] = false; |
108 | 108 | } |
109 | 109 | |
110 | - if(!isset($displayParams['showNoneCheckbox'])) { |
|
110 | + if (!isset($displayParams['showNoneCheckbox'])) { |
|
111 | 111 | $displayParams['showNoneCheckbox'] = false; |
112 | 112 | } |
113 | 113 | |
114 | - if(!isset($displayParams['showFormats'])) { |
|
114 | + if (!isset($displayParams['showFormats'])) { |
|
115 | 115 | $displayParams['showFormats'] = false; |
116 | 116 | } |
117 | 117 | |
@@ -124,9 +124,9 @@ discard block |
||
124 | 124 | } |
125 | 125 | |
126 | 126 | |
127 | - public function getEmailTemplateValue($inputField, $vardef, $context = null, $tabindex = 0){ |
|
127 | + public function getEmailTemplateValue($inputField, $vardef, $context = null, $tabindex = 0) { |
|
128 | 128 | // This does not return a smarty section, instead it returns a direct value |
129 | - if(isset($context['notify_user'])) { |
|
129 | + if (isset($context['notify_user'])) { |
|
130 | 130 | $user = $context['notify_user']; |
131 | 131 | } else { |
132 | 132 | $user = $GLOBALS['current_user']; |
@@ -136,19 +136,19 @@ discard block |
||
136 | 136 | |
137 | 137 | public function save(&$bean, $params, $field, $properties, $prefix = '') { |
138 | 138 | global $timedate; |
139 | - if ( !isset($params[$prefix.$field]) ) { |
|
139 | + if (!isset($params[$prefix.$field])) { |
|
140 | 140 | //$bean->$field = ''; |
141 | 141 | return; |
142 | 142 | } |
143 | 143 | |
144 | - if(strpos($params[$prefix.$field], ' ') > 0) { |
|
144 | + if (strpos($params[$prefix.$field], ' ') > 0) { |
|
145 | 145 | if ($timedate->check_matching_format($params[$prefix.$field], TimeDate::DB_DATETIME_FORMAT)) { |
146 | 146 | $bean->$field = $params[$prefix.$field]; |
147 | 147 | } else { |
148 | 148 | $bean->$field = $timedate->to_db($params[$prefix.$field]); |
149 | 149 | } |
150 | 150 | } else { |
151 | - $GLOBALS['log']->error('Field ' . $prefix.$field . ' expecting datetime format, but got value: ' . $params[$prefix.$field]); |
|
151 | + $GLOBALS['log']->error('Field '.$prefix.$field.' expecting datetime format, but got value: '.$params[$prefix.$field]); |
|
152 | 152 | //Default to assume date format value |
153 | 153 | if ($timedate->check_matching_format($params[$prefix.$field], TimeDate::DB_DATE_FORMAT)) { |
154 | 154 | $bean->$field = $params[$prefix.$field]; |
@@ -172,39 +172,39 @@ discard block |
||
172 | 172 | |
173 | 173 | $format = $timedate->merge_date_time($settings->dateformat, $settings->timeformat); |
174 | 174 | |
175 | - if ( !$timedate->check_matching_format($value, $format) ) { |
|
175 | + if (!$timedate->check_matching_format($value, $format)) { |
|
176 | 176 | $parts = $timedate->split_date_time($value); |
177 | - if(empty($parts[0])) { |
|
177 | + if (empty($parts[0])) { |
|
178 | 178 | $datepart = $timedate->getNow()->format($settings->dateformat); |
179 | 179 | } |
180 | 180 | else { |
181 | 181 | $datepart = $parts[0]; |
182 | 182 | } |
183 | - if(empty($parts[1])) { |
|
183 | + if (empty($parts[1])) { |
|
184 | 184 | $timepart = $timedate->fromTimestamp(0)->format($settings->timeformat); |
185 | 185 | } else { |
186 | 186 | $timepart = $parts[1]; |
187 | 187 | // see if we can get by stripping the seconds |
188 | - if(strpos($settings->timeformat, 's') === false) { |
|
188 | + if (strpos($settings->timeformat, 's') === false) { |
|
189 | 189 | $sep = $timedate->timeSeparatorFormat($settings->timeformat); |
190 | 190 | // We are assuming here seconds are the last component, which |
191 | 191 | // is kind of reasonable - no sane time format puts seconds first |
192 | 192 | $timeparts = explode($sep, $timepart); |
193 | - if(!empty($timeparts[2])) { |
|
193 | + if (!empty($timeparts[2])) { |
|
194 | 194 | $timepart = join($sep, array($timeparts[0], $timeparts[1])); |
195 | 195 | } |
196 | 196 | } |
197 | 197 | } |
198 | 198 | |
199 | 199 | $value = $timedate->merge_date_time($datepart, $timepart); |
200 | - if ( !$timedate->check_matching_format($value, $format) ) { |
|
200 | + if (!$timedate->check_matching_format($value, $format)) { |
|
201 | 201 | return false; |
202 | 202 | } |
203 | 203 | } |
204 | 204 | |
205 | 205 | try { |
206 | 206 | $date = SugarDateTime::createFromFormat($format, $value, new DateTimeZone($settings->timezone)); |
207 | - } catch(Exception $e) { |
|
207 | + }catch (Exception $e) { |
|
208 | 208 | return false; |
209 | 209 | } |
210 | 210 | return $date->asDb(); |
@@ -55,8 +55,7 @@ |
||
55 | 55 | } |
56 | 56 | if(isset($parameters[$condition_item['condition_order']])) { |
57 | 57 | $parameters[] = $condition_item; |
58 | - } |
|
59 | - else { |
|
58 | + } else { |
|
60 | 59 | $parameters[$condition_item['condition_order']] = $condition_item; |
61 | 60 | } |
62 | 61 | } |