@@ -99,13 +99,13 @@ discard block |
||
99 | 99 | $source = ""; |
100 | 100 | if ($this->rhs_module == $this->lhs_module) |
101 | 101 | { |
102 | - $source = $this->getJoinKeyLHS(); |
|
102 | + $source = $this->getJoinKeyLHS(); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | return array( |
106 | - $this->lhs_module => $this->getSubpanelDefinition ( |
|
107 | - $this->relationship_name, $this->rhs_module, $this->rhs_subpanel , $this->getRightModuleSystemLabel() , $source |
|
108 | - ) |
|
106 | + $this->lhs_module => $this->getSubpanelDefinition ( |
|
107 | + $this->relationship_name, $this->rhs_module, $this->rhs_subpanel , $this->getRightModuleSystemLabel() , $source |
|
108 | + ) |
|
109 | 109 | ); |
110 | 110 | } |
111 | 111 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | /* |
114 | 114 | * @return array An array of field definitions, ready for the vardefs, keyed by module |
115 | 115 | */ |
116 | - function buildVardefs ( ) |
|
116 | + function buildVardefs ( ) |
|
117 | 117 | { |
118 | 118 | $vardefs = array ( ) ; |
119 | 119 | |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | ) ; |
124 | 124 | if ($this->rhs_module != $this->lhs_module ) |
125 | 125 | { |
126 | - $vardefs [ $this->lhs_module ] [] = $this->getLinkFieldDefinition ( $this->rhs_module, $this->relationship_name, true, |
|
126 | + $vardefs [ $this->lhs_module ] [] = $this->getLinkFieldDefinition ( $this->rhs_module, $this->relationship_name, true, |
|
127 | 127 | 'LBL_' . strtoupper ( $this->relationship_name . '_FROM_' . $this->getRightModuleSystemLabel() ) . '_TITLE'); |
128 | 128 | } |
129 | 129 | if (! $this->relationship_only) |
@@ -60,21 +60,21 @@ discard block |
||
60 | 60 | function __construct ($definition) |
61 | 61 | { |
62 | 62 | |
63 | - parent::__construct ( $definition ) ; |
|
64 | - $onetomanyDef = array_merge($definition, array( |
|
65 | - 'rhs_label' => isset($definition['lhs_label']) ? $definition['lhs_label'] : null, |
|
66 | - 'lhs_label' => isset($definition['rhs_label']) ? $definition['rhs_label'] : null, |
|
67 | - 'lhs_subpanel' => isset($definition['rhs_subpanel']) ? $definition['rhs_subpanel'] : null, |
|
68 | - 'rhs_subpanel' => isset($definition['lhs_subpanel']) ? $definition['lhs_subpanel'] : null, |
|
69 | - 'lhs_module' => isset($definition['rhs_module']) ? $definition['rhs_module'] : null, |
|
70 | - 'lhs_table' => isset($definition['rhs_table']) ? $definition['rhs_table'] : null, |
|
71 | - 'lhs_key' => isset($definition['rhs_key']) ? $definition['rhs_key'] : null, |
|
72 | - 'rhs_module' => isset($definition['lhs_module']) ? $definition['lhs_module'] : null, |
|
73 | - 'rhs_table' => isset($definition['lhs_table']) ? $definition['lhs_table'] : null, |
|
74 | - 'rhs_key' => isset($definition['lhs_key']) ? $definition['lhs_key'] : null, |
|
75 | - 'join_key_lhs' => isset($definition['join_key_rhs']) ? $definition['join_key_rhs'] : null, |
|
76 | - 'join_key_rhs' => isset($definition['join_key_lhs']) ? $definition['join_key_lhs'] : null, |
|
77 | - 'relationship_type' => MB_ONETOMANY, |
|
63 | + parent::__construct ( $definition ) ; |
|
64 | + $onetomanyDef = array_merge($definition, array( |
|
65 | + 'rhs_label' => isset($definition['lhs_label']) ? $definition['lhs_label'] : null, |
|
66 | + 'lhs_label' => isset($definition['rhs_label']) ? $definition['rhs_label'] : null, |
|
67 | + 'lhs_subpanel' => isset($definition['rhs_subpanel']) ? $definition['rhs_subpanel'] : null, |
|
68 | + 'rhs_subpanel' => isset($definition['lhs_subpanel']) ? $definition['lhs_subpanel'] : null, |
|
69 | + 'lhs_module' => isset($definition['rhs_module']) ? $definition['rhs_module'] : null, |
|
70 | + 'lhs_table' => isset($definition['rhs_table']) ? $definition['rhs_table'] : null, |
|
71 | + 'lhs_key' => isset($definition['rhs_key']) ? $definition['rhs_key'] : null, |
|
72 | + 'rhs_module' => isset($definition['lhs_module']) ? $definition['lhs_module'] : null, |
|
73 | + 'rhs_table' => isset($definition['lhs_table']) ? $definition['lhs_table'] : null, |
|
74 | + 'rhs_key' => isset($definition['lhs_key']) ? $definition['lhs_key'] : null, |
|
75 | + 'join_key_lhs' => isset($definition['join_key_rhs']) ? $definition['join_key_rhs'] : null, |
|
76 | + 'join_key_rhs' => isset($definition['join_key_lhs']) ? $definition['join_key_lhs'] : null, |
|
77 | + 'relationship_type' => MB_ONETOMANY, |
|
78 | 78 | )); |
79 | 79 | $this->one_to_many = new OneToManyRelationship($onetomanyDef); |
80 | 80 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * BUILD methods called during the build |
84 | 84 | */ |
85 | 85 | |
86 | - function buildLabels () |
|
86 | + function buildLabels () |
|
87 | 87 | { |
88 | 88 | return $this->one_to_many->buildLabels(); |
89 | 89 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | */ |
105 | 105 | function buildVardefs ( ) |
106 | 106 | { |
107 | - return $this->one_to_many->buildVardefs(); |
|
107 | + return $this->one_to_many->buildVardefs(); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /* |
@@ -130,19 +130,19 @@ discard block |
||
130 | 130 | public function setName ($relationshipName) |
131 | 131 | { |
132 | 132 | parent::setName($relationshipName); |
133 | - $this->one_to_many->setname($relationshipName); |
|
133 | + $this->one_to_many->setname($relationshipName); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | public function setReadonly () |
137 | 137 | { |
138 | 138 | parent::setReadonly(); |
139 | - $this->one_to_many->setReadonly(); |
|
139 | + $this->one_to_many->setReadonly(); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | public function delete () |
143 | 143 | { |
144 | 144 | parent::delete(); |
145 | - $this->one_to_many->delete(); |
|
145 | + $this->one_to_many->delete(); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | public function setRelationship_only () |
@@ -72,10 +72,10 @@ discard block |
||
72 | 72 | class ActivitiesRelationship extends OneToManyRelationship |
73 | 73 | { |
74 | 74 | |
75 | - protected static $subpanelsAdded = array(); |
|
76 | - protected static $labelsAdded = array(); |
|
75 | + protected static $subpanelsAdded = array(); |
|
76 | + protected static $labelsAdded = array(); |
|
77 | 77 | |
78 | - /* |
|
78 | + /* |
|
79 | 79 | * Constructor |
80 | 80 | * @param array $definition Parameters passed in as array defined in parent::$definitionKeys |
81 | 81 | * The lhs_module value is for the One side; the rhs_module value is for the Many |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * BUILD methods called during the build |
90 | 90 | */ |
91 | 91 | |
92 | - /* |
|
92 | + /* |
|
93 | 93 | * Define the labels to be added to the module for the new relationships |
94 | 94 | * @return array An array of system value => display value |
95 | 95 | */ |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | } |
141 | 141 | |
142 | 142 | |
143 | - /* |
|
143 | + /* |
|
144 | 144 | * @return array An array of field definitions, ready for the vardefs, keyed by module |
145 | 145 | */ |
146 | 146 | function buildVardefs ( ) |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | return $vardefs ; |
155 | 155 | } |
156 | 156 | |
157 | - protected function getLinkFieldDefinition ($sourceModule , $relationshipName) |
|
157 | + protected function getLinkFieldDefinition ($sourceModule , $relationshipName) |
|
158 | 158 | { |
159 | 159 | $vardef = array ( ) ; |
160 | 160 | $vardef [ 'name' ] = $relationshipName; |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | return array( $this->rhs_module => $this->relationship_name . "_name" ) ; // this must match the name of the relate field from buildVardefs |
180 | 180 | } |
181 | 181 | |
182 | - function buildSubpanelDefinitions () |
|
182 | + function buildSubpanelDefinitions () |
|
183 | 183 | { |
184 | 184 | if ($this->relationship_only || isset(ActivitiesRelationship::$subpanelsAdded[$this->lhs_module])) |
185 | 185 | return array () ; |
@@ -187,9 +187,9 @@ discard block |
||
187 | 187 | ActivitiesRelationship::$subpanelsAdded[$this->lhs_module] = true; |
188 | 188 | $relationshipName = substr($this->relationship_name, 0, strrpos($this->relationship_name, '_')); |
189 | 189 | return array( $this->lhs_module => array ( |
190 | - 'activities' => $this->buildActivitiesSubpanelDefinition ( $relationshipName ), |
|
191 | - 'history' => $this->buildHistorySubpanelDefinition ( $relationshipName ) , |
|
192 | - )); |
|
190 | + 'activities' => $this->buildActivitiesSubpanelDefinition ( $relationshipName ), |
|
191 | + 'history' => $this->buildHistorySubpanelDefinition ( $relationshipName ) , |
|
192 | + )); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | /* |
@@ -209,10 +209,10 @@ discard block |
||
209 | 209 | $relMetadata ['relationship_role_column'] = 'parent_type'; |
210 | 210 | $relMetadata ['relationship_role_column_value'] = $this->definition [ 'lhs_module' ] ; |
211 | 211 | |
212 | - return array( $this->lhs_module => array( |
|
213 | - 'relationships' => array ($relationshipName => $relMetadata), |
|
214 | - 'fields' => '', 'indices' => '', 'table' => '') |
|
215 | - ) ; |
|
212 | + return array( $this->lhs_module => array( |
|
213 | + 'relationships' => array ($relationshipName => $relMetadata), |
|
214 | + 'fields' => '', 'indices' => '', 'table' => '') |
|
215 | + ) ; |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | /* |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | */ |
222 | 222 | protected function buildActivitiesSubpanelDefinition ( $relationshipName ) |
223 | 223 | { |
224 | - return array ( |
|
224 | + return array ( |
|
225 | 225 | 'order' => 10 , |
226 | 226 | 'sort_order' => 'desc' , |
227 | 227 | 'sort_by' => 'date_start' , |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | 'module' => 'History' , |
266 | 266 | 'top_buttons' => array ( |
267 | 267 | array ( 'widget_class' => 'SubPanelTopCreateNoteButton' ) , |
268 | - array ( 'widget_class' => 'SubPanelTopArchiveEmailButton'), |
|
268 | + array ( 'widget_class' => 'SubPanelTopArchiveEmailButton'), |
|
269 | 269 | array ( 'widget_class' => 'SubPanelTopSummaryButton' ) ) , |
270 | 270 | 'collection_list' => array ( |
271 | 271 | 'meetings' => array ( |
@@ -67,6 +67,6 @@ |
||
67 | 67 | |
68 | 68 | class MBConstants |
69 | 69 | { |
70 | - static $EMPTY = array ( 'name' => '(empty)' , 'label' => '(empty)' ) ; |
|
71 | - static $FILLER = array ( 'name' => '(filler)' , 'label' => 'LBL_FILLER' ) ; // would prefer to have label => translate('LBL_FILLER') but can't be done in a static, and don't want to require instantiating a new object to get these constants |
|
70 | + static $EMPTY = array ( 'name' => '(empty)' , 'label' => '(empty)' ) ; |
|
71 | + static $FILLER = array ( 'name' => '(filler)' , 'label' => 'LBL_FILLER' ) ; // would prefer to have label => translate('LBL_FILLER') but can't be done in a static, and don't want to require instantiating a new object to get these constants |
|
72 | 72 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | $deployedModule = true ; |
94 | 94 | $basepath = "custom/modules/$moduleName/language" ; |
95 | 95 | if($forRelationshipLabel){ |
96 | - $basepath = "custom/modules/$moduleName/Ext/Language" ; |
|
96 | + $basepath = "custom/modules/$moduleName/Ext/Language" ; |
|
97 | 97 | } |
98 | 98 | if (! is_dir ( $basepath )) |
99 | 99 | { |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | |
105 | 105 | $filename = "$basepath/$language.lang.php" ; |
106 | 106 | if($forRelationshipLabel){ |
107 | - $filename = "$basepath/$language.lang.ext.php" ; |
|
108 | - } |
|
107 | + $filename = "$basepath/$language.lang.ext.php" ; |
|
108 | + } |
|
109 | 109 | |
110 | 110 | $dir_exists = is_dir ( $basepath ) ; |
111 | 111 | |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | $deployedModule = true ; |
171 | 171 | $basepath = "custom/modules/$moduleName/language" ; |
172 | 172 | if($forRelationshipLabel){ |
173 | - $basepath = "custom/modules/$moduleName/Ext/Language" ; |
|
173 | + $basepath = "custom/modules/$moduleName/Ext/Language" ; |
|
174 | 174 | } |
175 | 175 | if (! is_dir ( $basepath )) |
176 | 176 | { |
@@ -180,8 +180,8 @@ discard block |
||
180 | 180 | |
181 | 181 | $filename = "$basepath/$language.lang.php" ; |
182 | 182 | if($forRelationshipLabel){ |
183 | - $filename = "$basepath/$language.lang.ext.php" ; |
|
184 | - } |
|
183 | + $filename = "$basepath/$language.lang.ext.php" ; |
|
184 | + } |
|
185 | 185 | $dir_exists = is_dir ( $basepath ) ; |
186 | 186 | |
187 | 187 | $mod_strings = array ( ) ; |
@@ -193,47 +193,47 @@ discard block |
||
193 | 193 | // obtain $mod_strings |
194 | 194 | include ($filename) ; |
195 | 195 | }else if($forRelationshipLabel){ |
196 | - $fh = fopen ($filename, 'a'); |
|
197 | - fclose($fh); |
|
196 | + $fh = fopen ($filename, 'a'); |
|
197 | + fclose($fh); |
|
198 | 198 | } |
199 | 199 | } else |
200 | 200 | { |
201 | 201 | return false ; |
202 | 202 | } |
203 | 203 | |
204 | - $changed = false ; |
|
204 | + $changed = false ; |
|
205 | 205 | |
206 | 206 | //$charset = (isset($app_strings['LBL_CHARSET'])) ? $app_strings['LBL_CHARSET'] : $GLOBALS['sugar_config']['default_charset'] ; |
207 | 207 | |
208 | - foreach ( $labels as $key => $value ) |
|
209 | - { |
|
208 | + foreach ( $labels as $key => $value ) |
|
209 | + { |
|
210 | 210 | if (! isset ( $mod_strings [ $key ] ) || strcmp ( $value, $mod_strings [ $key ] ) != 0) |
211 | - { |
|
211 | + { |
|
212 | 212 | $mod_strings [$key] = to_html(strip_tags(from_html($value))); // must match encoding used in view.labels.php |
213 | - $changed = true ; |
|
214 | - } |
|
215 | - } |
|
213 | + $changed = true ; |
|
214 | + } |
|
215 | + } |
|
216 | 216 | |
217 | - if ($changed) |
|
218 | - { |
|
217 | + if ($changed) |
|
218 | + { |
|
219 | 219 | $GLOBALS [ 'log' ]->debug ( "ParserLabel->addLabels: writing new mod_strings to $filename" ) ; |
220 | - $GLOBALS [ 'log' ]->debug ( "ParserLabel->addLabels: mod_strings=".print_r($mod_strings,true) ) ; |
|
220 | + $GLOBALS [ 'log' ]->debug ( "ParserLabel->addLabels: mod_strings=".print_r($mod_strings,true) ) ; |
|
221 | 221 | if (! write_array_to_file ( "mod_strings", $mod_strings, $filename )) |
222 | - { |
|
222 | + { |
|
223 | 223 | $GLOBALS [ 'log' ]->fatal ( "Could not write $filename" ) ; |
224 | - } else |
|
225 | - { |
|
226 | - // if we have a cache to worry about, then clear it now |
|
224 | + } else |
|
225 | + { |
|
226 | + // if we have a cache to worry about, then clear it now |
|
227 | 227 | if ($deployedModule) |
228 | - { |
|
228 | + { |
|
229 | 229 | SugarCache::cleanOpcodes(); |
230 | - $GLOBALS [ 'log' ]->debug ( "PaserLabel->addLabels: clearing language cache" ) ; |
|
231 | - $cache_key = "module_language." . $language . $moduleName ; |
|
232 | - sugar_cache_clear ( $cache_key ) ; |
|
233 | - LanguageManager::clearLanguageCache ( $moduleName, $language ) ; |
|
234 | - } |
|
235 | - } |
|
236 | - } |
|
230 | + $GLOBALS [ 'log' ]->debug ( "PaserLabel->addLabels: clearing language cache" ) ; |
|
231 | + $cache_key = "module_language." . $language . $moduleName ; |
|
232 | + sugar_cache_clear ( $cache_key ) ; |
|
233 | + LanguageManager::clearLanguageCache ( $moduleName, $language ) ; |
|
234 | + } |
|
235 | + } |
|
236 | + } |
|
237 | 237 | |
238 | 238 | // Fix for bug #51 |
239 | 239 | // when the label is recreated it defaults back to the original value (In this case its "User"). |
@@ -356,18 +356,18 @@ discard block |
||
356 | 356 | { |
357 | 357 | foreach ( $metadata as $definition ) |
358 | 358 | { |
359 | - $labels = array(); |
|
360 | - $labels[$definition [ 'system_label' ]] = $definition [ 'display_label' ]; |
|
361 | - self::addLabels ( $language, $labels, $definition [ 'module' ],null,true ); |
|
359 | + $labels = array(); |
|
360 | + $labels[$definition [ 'system_label' ]] = $definition [ 'display_label' ]; |
|
361 | + self::addLabels ( $language, $labels, $definition [ 'module' ],null,true ); |
|
362 | 362 | } |
363 | 363 | } |
364 | 364 | |
365 | 365 | function addLabelsToAllLanguages($labels) |
366 | 366 | { |
367 | - $langs = get_languages(); |
|
368 | - foreach($langs as $lang_key => $lang_display) |
|
367 | + $langs = get_languages(); |
|
368 | + foreach($langs as $lang_key => $lang_display) |
|
369 | 369 | { |
370 | - $this->addLabels($lang_key, $labels, $this->moduleName); |
|
370 | + $this->addLabels($lang_key, $labels, $this->moduleName); |
|
371 | 371 | } |
372 | 372 | } |
373 | 373 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | |
42 | 42 | require_once('modules/ModuleBuilder/parsers/ModuleBuilderParser.php'); |
43 | 43 | |
44 | - class ParserDropDown extends ModuleBuilderParser { |
|
44 | + class ParserDropDown extends ModuleBuilderParser { |
|
45 | 45 | |
46 | 46 | /** |
47 | 47 | * Takes in the request params from a save request and processes |
@@ -51,19 +51,19 @@ discard block |
||
51 | 51 | */ |
52 | 52 | function saveDropDown($params){ |
53 | 53 | require_once('modules/Administration/Common.php'); |
54 | - $emptyMarker = translate('LBL_BLANK'); |
|
55 | - $selected_lang = (!empty($params['dropdown_lang'])?$params['dropdown_lang']:$_SESSION['authenticated_user_language']); |
|
56 | - $type = $_REQUEST['view_package']; |
|
57 | - $dir = ''; |
|
58 | - $dropdown_name = $params['dropdown_name']; |
|
59 | - $json = getJSONobj(); |
|
54 | + $emptyMarker = translate('LBL_BLANK'); |
|
55 | + $selected_lang = (!empty($params['dropdown_lang'])?$params['dropdown_lang']:$_SESSION['authenticated_user_language']); |
|
56 | + $type = $_REQUEST['view_package']; |
|
57 | + $dir = ''; |
|
58 | + $dropdown_name = $params['dropdown_name']; |
|
59 | + $json = getJSONobj(); |
|
60 | 60 | |
61 | - $list_value = str_replace('"":""', '"__empty__":""', $params['list_value']); |
|
62 | - //Bug 21362 ENT_QUOTES- convert single quotes to escaped single quotes. |
|
63 | - $temp = $json->decode(html_entity_decode(rawurldecode($list_value), ENT_QUOTES) ); |
|
64 | - $dropdown = array () ; |
|
65 | - // dropdown is received as an array of (name,value) pairs - now extract to name=>value format preserving order |
|
66 | - // we rely here on PHP to preserve the order of the received name=>value pairs - associative arrays in PHP are ordered |
|
61 | + $list_value = str_replace('"":""', '"__empty__":""', $params['list_value']); |
|
62 | + //Bug 21362 ENT_QUOTES- convert single quotes to escaped single quotes. |
|
63 | + $temp = $json->decode(html_entity_decode(rawurldecode($list_value), ENT_QUOTES) ); |
|
64 | + $dropdown = array () ; |
|
65 | + // dropdown is received as an array of (name,value) pairs - now extract to name=>value format preserving order |
|
66 | + // we rely here on PHP to preserve the order of the received name=>value pairs - associative arrays in PHP are ordered |
|
67 | 67 | if(is_array($temp)) |
68 | 68 | { |
69 | 69 | foreach ( $temp as $item ) |
@@ -71,146 +71,146 @@ discard block |
||
71 | 71 | $dropdown[ SugarCleaner::stripTags(from_html($item [ 0 ]), false) ] = SugarCleaner::stripTags(from_html($item [ 1 ]), false) ; |
72 | 72 | } |
73 | 73 | } |
74 | - if(array_key_exists($emptyMarker, $dropdown)){ |
|
74 | + if(array_key_exists($emptyMarker, $dropdown)){ |
|
75 | 75 | $output=array(); |
76 | 76 | foreach($dropdown as $key => $value){ |
77 | 77 | if($emptyMarker===$key) |
78 | 78 | $output['']=''; |
79 | 79 | else |
80 | 80 | $output[$key]=$value; |
81 | - } |
|
81 | + } |
|
82 | 82 | $dropdown=$output; |
83 | - } |
|
83 | + } |
|
84 | 84 | |
85 | - if($type != 'studio'){ |
|
86 | - $mb = new ModuleBuilder(); |
|
87 | - $module = $mb->getPackageModule($params['view_package'], $params['view_module']); |
|
88 | - $this->synchMBDropDown($dropdown_name, $dropdown, $selected_lang, $module); |
|
89 | - //Can't use synch on selected lang as we want to overwrite values, not just keys |
|
90 | - $module->mblanguage->appListStrings[$selected_lang.'.lang.php'][$dropdown_name] = $dropdown; |
|
91 | - $module->mblanguage->save($module->key_name); // tyoung - key is required parameter as of |
|
92 | - }else{ |
|
93 | - $contents = return_custom_app_list_strings_file_contents($selected_lang); |
|
94 | - $my_list_strings = return_app_list_strings_language($selected_lang); |
|
95 | - if($selected_lang == $GLOBALS['current_language']){ |
|
96 | - $GLOBALS['app_list_strings'][$dropdown_name] = $dropdown; |
|
97 | - } |
|
98 | - //write to contents |
|
99 | - $contents = str_replace("?>", '', $contents); |
|
100 | - if(empty($contents))$contents = "<?php"; |
|
101 | - //add new drop down to the bottom |
|
102 | - if(!empty($params['use_push'])){ |
|
103 | - //this is for handling moduleList and such where nothing should be deleted or anything but they can be renamed |
|
104 | - foreach($dropdown as $key=>$value){ |
|
105 | - //only if the value has changed or does not exist do we want to add it this way |
|
106 | - if(!isset($my_list_strings[$dropdown_name][$key]) || strcmp($my_list_strings[$dropdown_name][$key], $value) != 0 ){ |
|
107 | - //clear out the old value |
|
108 | - $pattern_match = '/\s*\$app_list_strings\s*\[\s*\''.$dropdown_name.'\'\s*\]\[\s*\''.$key.'\'\s*\]\s*=\s*[\'\"]{1}.*?[\'\"]{1};\s*/ism'; |
|
109 | - $contents = preg_replace($pattern_match, "\n", $contents); |
|
110 | - //add the new ones |
|
111 | - $contents .= "\n\$GLOBALS['app_list_strings']['$dropdown_name']['$key']=" . var_export_helper($value) . ";"; |
|
112 | - } |
|
113 | - } |
|
114 | - }else{ |
|
115 | - //Now synch up the keys in other langauges to ensure that removed/added Drop down values work properly under all langs. |
|
116 | - $this->synchDropDown($dropdown_name, $dropdown, $selected_lang, $dir); |
|
117 | - $contents = $this->getNewCustomContents($dropdown_name, $dropdown, $selected_lang); |
|
118 | - } |
|
119 | - if(!empty($dir) && !is_dir($dir)) |
|
120 | - { |
|
121 | - $continue = mkdir_recursive($dir); |
|
122 | - } |
|
123 | - save_custom_app_list_strings_contents($contents, $selected_lang, $dir); |
|
124 | - } |
|
125 | - sugar_cache_reset(); |
|
126 | - clearAllJsAndJsLangFilesWithoutOutput(); |
|
85 | + if($type != 'studio'){ |
|
86 | + $mb = new ModuleBuilder(); |
|
87 | + $module = $mb->getPackageModule($params['view_package'], $params['view_module']); |
|
88 | + $this->synchMBDropDown($dropdown_name, $dropdown, $selected_lang, $module); |
|
89 | + //Can't use synch on selected lang as we want to overwrite values, not just keys |
|
90 | + $module->mblanguage->appListStrings[$selected_lang.'.lang.php'][$dropdown_name] = $dropdown; |
|
91 | + $module->mblanguage->save($module->key_name); // tyoung - key is required parameter as of |
|
92 | + }else{ |
|
93 | + $contents = return_custom_app_list_strings_file_contents($selected_lang); |
|
94 | + $my_list_strings = return_app_list_strings_language($selected_lang); |
|
95 | + if($selected_lang == $GLOBALS['current_language']){ |
|
96 | + $GLOBALS['app_list_strings'][$dropdown_name] = $dropdown; |
|
97 | + } |
|
98 | + //write to contents |
|
99 | + $contents = str_replace("?>", '', $contents); |
|
100 | + if(empty($contents))$contents = "<?php"; |
|
101 | + //add new drop down to the bottom |
|
102 | + if(!empty($params['use_push'])){ |
|
103 | + //this is for handling moduleList and such where nothing should be deleted or anything but they can be renamed |
|
104 | + foreach($dropdown as $key=>$value){ |
|
105 | + //only if the value has changed or does not exist do we want to add it this way |
|
106 | + if(!isset($my_list_strings[$dropdown_name][$key]) || strcmp($my_list_strings[$dropdown_name][$key], $value) != 0 ){ |
|
107 | + //clear out the old value |
|
108 | + $pattern_match = '/\s*\$app_list_strings\s*\[\s*\''.$dropdown_name.'\'\s*\]\[\s*\''.$key.'\'\s*\]\s*=\s*[\'\"]{1}.*?[\'\"]{1};\s*/ism'; |
|
109 | + $contents = preg_replace($pattern_match, "\n", $contents); |
|
110 | + //add the new ones |
|
111 | + $contents .= "\n\$GLOBALS['app_list_strings']['$dropdown_name']['$key']=" . var_export_helper($value) . ";"; |
|
112 | + } |
|
113 | + } |
|
114 | + }else{ |
|
115 | + //Now synch up the keys in other langauges to ensure that removed/added Drop down values work properly under all langs. |
|
116 | + $this->synchDropDown($dropdown_name, $dropdown, $selected_lang, $dir); |
|
117 | + $contents = $this->getNewCustomContents($dropdown_name, $dropdown, $selected_lang); |
|
118 | + } |
|
119 | + if(!empty($dir) && !is_dir($dir)) |
|
120 | + { |
|
121 | + $continue = mkdir_recursive($dir); |
|
122 | + } |
|
123 | + save_custom_app_list_strings_contents($contents, $selected_lang, $dir); |
|
124 | + } |
|
125 | + sugar_cache_reset(); |
|
126 | + clearAllJsAndJsLangFilesWithoutOutput(); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
130 | - * function synchDropDown |
|
131 | - * Ensures that the set of dropdown keys is consistant accross all languages. |
|
132 | - * |
|
133 | - * @param $dropdown_name The name of the dropdown to be synched |
|
134 | - * @param $dropdown array The dropdown currently being saved |
|
135 | - * @param $selected_lang String the language currently selected in Studio/MB |
|
136 | - * @param $saveLov String the path to the directory to save the new lang file in. |
|
137 | - */ |
|
130 | + * function synchDropDown |
|
131 | + * Ensures that the set of dropdown keys is consistant accross all languages. |
|
132 | + * |
|
133 | + * @param $dropdown_name The name of the dropdown to be synched |
|
134 | + * @param $dropdown array The dropdown currently being saved |
|
135 | + * @param $selected_lang String the language currently selected in Studio/MB |
|
136 | + * @param $saveLov String the path to the directory to save the new lang file in. |
|
137 | + */ |
|
138 | 138 | function synchDropDown($dropdown_name, $dropdown, $selected_lang, $saveLoc) { |
139 | - $allLanguages = get_languages(); |
|
139 | + $allLanguages = get_languages(); |
|
140 | 140 | foreach ($allLanguages as $lang => $langName) { |
141 | - if ($lang != $selected_lang) { |
|
142 | - $listStrings = return_app_list_strings_language($lang); |
|
143 | - $langDropDown = array(); |
|
144 | - if (isset($listStrings[$dropdown_name]) && is_array($listStrings[$dropdown_name])) |
|
145 | - { |
|
146 | - $langDropDown = $this->synchDDKeys($dropdown, $listStrings[$dropdown_name]); |
|
147 | - } else |
|
148 | - { |
|
149 | - //if the dropdown does not exist in the language, justt use what we have. |
|
150 | - $langDropDown = $dropdown; |
|
151 | - } |
|
152 | - $contents = $this->getNewCustomContents($dropdown_name, $langDropDown, $lang); |
|
153 | - save_custom_app_list_strings_contents($contents, $lang, $saveLoc); |
|
154 | - } |
|
141 | + if ($lang != $selected_lang) { |
|
142 | + $listStrings = return_app_list_strings_language($lang); |
|
143 | + $langDropDown = array(); |
|
144 | + if (isset($listStrings[$dropdown_name]) && is_array($listStrings[$dropdown_name])) |
|
145 | + { |
|
146 | + $langDropDown = $this->synchDDKeys($dropdown, $listStrings[$dropdown_name]); |
|
147 | + } else |
|
148 | + { |
|
149 | + //if the dropdown does not exist in the language, justt use what we have. |
|
150 | + $langDropDown = $dropdown; |
|
151 | + } |
|
152 | + $contents = $this->getNewCustomContents($dropdown_name, $langDropDown, $lang); |
|
153 | + save_custom_app_list_strings_contents($contents, $lang, $saveLoc); |
|
154 | + } |
|
155 | 155 | } |
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
159 | - * function synchMBDropDown |
|
160 | - * Ensures that the set of dropdown keys is consistant accross all languages in a ModuleBuilder Module |
|
161 | - * |
|
162 | - * @param $dropdown_name The name of the dropdown to be synched |
|
163 | - * @param $dropdown array The dropdown currently being saved |
|
164 | - * @param $selected_lang String the language currently selected in Studio/MB |
|
165 | - * @param $module MBModule the module to update the languages in |
|
166 | - */ |
|
159 | + * function synchMBDropDown |
|
160 | + * Ensures that the set of dropdown keys is consistant accross all languages in a ModuleBuilder Module |
|
161 | + * |
|
162 | + * @param $dropdown_name The name of the dropdown to be synched |
|
163 | + * @param $dropdown array The dropdown currently being saved |
|
164 | + * @param $selected_lang String the language currently selected in Studio/MB |
|
165 | + * @param $module MBModule the module to update the languages in |
|
166 | + */ |
|
167 | 167 | function synchMBDropDown($dropdown_name, $dropdown, $selected_lang, $module) { |
168 | - $selected_lang = $selected_lang . '.lang.php'; |
|
169 | - foreach($module->mblanguage->appListStrings as $lang => $listStrings) { |
|
170 | - if ($lang != $selected_lang) |
|
171 | - { |
|
172 | - $langDropDown = array(); |
|
173 | - if (isset($listStrings[$dropdown_name]) && is_array($listStrings[$dropdown_name])) |
|
174 | - { |
|
175 | - $langDropDown = $this->synchDDKeys($dropdown, $listStrings[$dropdown_name]); |
|
176 | - } else |
|
177 | - { |
|
178 | - $langDropDown = $dropdown; |
|
179 | - } |
|
180 | - $module->mblanguage->appListStrings[$lang][$dropdown_name] = $langDropDown; |
|
181 | - $module->mblanguage->save($module->key_name); |
|
182 | - } |
|
183 | - } |
|
168 | + $selected_lang = $selected_lang . '.lang.php'; |
|
169 | + foreach($module->mblanguage->appListStrings as $lang => $listStrings) { |
|
170 | + if ($lang != $selected_lang) |
|
171 | + { |
|
172 | + $langDropDown = array(); |
|
173 | + if (isset($listStrings[$dropdown_name]) && is_array($listStrings[$dropdown_name])) |
|
174 | + { |
|
175 | + $langDropDown = $this->synchDDKeys($dropdown, $listStrings[$dropdown_name]); |
|
176 | + } else |
|
177 | + { |
|
178 | + $langDropDown = $dropdown; |
|
179 | + } |
|
180 | + $module->mblanguage->appListStrings[$lang][$dropdown_name] = $langDropDown; |
|
181 | + $module->mblanguage->save($module->key_name); |
|
182 | + } |
|
183 | + } |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | private function synchDDKeys($dom, $sub) { |
187 | - //check for extra keys |
|
187 | + //check for extra keys |
|
188 | 188 | foreach($sub as $key=>$value) { |
189 | - if (!isset($dom[$key])) { |
|
190 | - unset ($sub[$key]); |
|
191 | - } |
|
189 | + if (!isset($dom[$key])) { |
|
190 | + unset ($sub[$key]); |
|
191 | + } |
|
192 | 192 | } |
193 | 193 | //check for missing keys |
194 | 194 | foreach($dom as $key=>$value) { |
195 | - if (!isset($sub[$key])) { |
|
196 | - $sub[$key] = $value; |
|
197 | - } |
|
195 | + if (!isset($sub[$key])) { |
|
196 | + $sub[$key] = $value; |
|
197 | + } |
|
198 | 198 | } |
199 | 199 | return $sub; |
200 | 200 | } |
201 | 201 | |
202 | 202 | function getPatternMatch($dropdown_name) { |
203 | - return '/\s*\$GLOBALS\s*\[\s*\'app_list_strings\s*\'\s*\]\[\s*\'' |
|
204 | - . $dropdown_name.'\'\s*\]\s*=\s*array\s*\([^\)]*\)\s*;\s*/ism'; |
|
203 | + return '/\s*\$GLOBALS\s*\[\s*\'app_list_strings\s*\'\s*\]\[\s*\'' |
|
204 | + . $dropdown_name.'\'\s*\]\s*=\s*array\s*\([^\)]*\)\s*;\s*/ism'; |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | function getNewCustomContents($dropdown_name, $dropdown, $lang) { |
208 | - $contents = return_custom_app_list_strings_file_contents($lang); |
|
208 | + $contents = return_custom_app_list_strings_file_contents($lang); |
|
209 | 209 | $contents = str_replace("?>", '', $contents); |
210 | - if(empty($contents))$contents = "<?php"; |
|
211 | - $contents = preg_replace($this->getPatternMatch($dropdown_name), "\n", $contents); |
|
212 | - $contents .= "\n\$GLOBALS['app_list_strings']['$dropdown_name']=" . var_export_helper($dropdown) . ";"; |
|
213 | - return $contents; |
|
210 | + if(empty($contents))$contents = "<?php"; |
|
211 | + $contents = preg_replace($this->getPatternMatch($dropdown_name), "\n", $contents); |
|
212 | + $contents .= "\n\$GLOBALS['app_list_strings']['$dropdown_name']=" . var_export_helper($dropdown) . ";"; |
|
213 | + return $contents; |
|
214 | 214 | } |
215 | 215 | } |
216 | 216 | ?> |
@@ -169,12 +169,12 @@ |
||
169 | 169 | include_once('include/TemplateHandler/TemplateHandler.php'); |
170 | 170 | if (strtolower($this->_view) == 'quickcreate') |
171 | 171 | { |
172 | - TemplateHandler::clearCache($this->_module,"form_SubPanelQuickCreate_{$this->_module}.tpl"); |
|
173 | - TemplateHandler::clearCache($this->_module,"form_DCQuickCreate_{$this->_module}.tpl"); |
|
172 | + TemplateHandler::clearCache($this->_module,"form_SubPanelQuickCreate_{$this->_module}.tpl"); |
|
173 | + TemplateHandler::clearCache($this->_module,"form_DCQuickCreate_{$this->_module}.tpl"); |
|
174 | 174 | } |
175 | 175 | else |
176 | 176 | { |
177 | - TemplateHandler::clearCache($this->_module,"{$this->_view}.tpl"); |
|
177 | + TemplateHandler::clearCache($this->_module,"{$this->_view}.tpl"); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | } |
@@ -58,7 +58,7 @@ |
||
58 | 58 | public static function getParser ( $view , $moduleName , $packageName = null , $subpanelName = null ) |
59 | 59 | { |
60 | 60 | $GLOBALS [ 'log' ]->info ( "ParserFactory->getParser($view,$moduleName,$packageName,$subpanelName )" ) ; |
61 | - $sm = null; |
|
61 | + $sm = null; |
|
62 | 62 | $lView = strtolower ( $view ); |
63 | 63 | if ( empty ( $packageName ) || ( $packageName == 'studio' ) ) |
64 | 64 | { |
@@ -43,144 +43,144 @@ discard block |
||
43 | 43 | require_once ('modules/ModuleBuilder/parsers/ModuleBuilderParser.php') ; |
44 | 44 | class ParserModifyListView extends ModuleBuilderParser |
45 | 45 | { |
46 | - var $listViewDefs = false ; |
|
47 | - var $defaults = array ( ) ; |
|
48 | - var $additional = array ( ) ; |
|
49 | - var $available = array ( ) ; |
|
50 | - var $reserved = array(); // fields marked by 'studio'=>false in the listviewdefs; need to be preserved |
|
51 | - // var $language_module = ''; |
|
52 | - var $columns = array ( 'LBL_DEFAULT' => 'getDefaultFields' , 'LBL_AVAILABLE' => 'getAdditionalFields' , 'LBL_HIDDEN' => 'getAvailableFields' ) ; |
|
53 | - function init ( $module_name , $submodule = '' ) |
|
54 | - { |
|
55 | - global $app_list_strings ; |
|
56 | - $this->module_name = $module_name ; |
|
57 | - $mod_strings = return_module_language ( $GLOBALS [ 'current_language' ], $this->module_name ) ; // needed solely so that listviewdefs that reference this can be included without error |
|
58 | - $class = $GLOBALS [ 'beanList' ] [ $this->module_name ] ; |
|
59 | - require_once ($GLOBALS [ 'beanFiles' ] [ $class ]) ; |
|
60 | - $this->module = new $class ( ) ; |
|
46 | + var $listViewDefs = false ; |
|
47 | + var $defaults = array ( ) ; |
|
48 | + var $additional = array ( ) ; |
|
49 | + var $available = array ( ) ; |
|
50 | + var $reserved = array(); // fields marked by 'studio'=>false in the listviewdefs; need to be preserved |
|
51 | + // var $language_module = ''; |
|
52 | + var $columns = array ( 'LBL_DEFAULT' => 'getDefaultFields' , 'LBL_AVAILABLE' => 'getAdditionalFields' , 'LBL_HIDDEN' => 'getAvailableFields' ) ; |
|
53 | + function init ( $module_name , $submodule = '' ) |
|
54 | + { |
|
55 | + global $app_list_strings ; |
|
56 | + $this->module_name = $module_name ; |
|
57 | + $mod_strings = return_module_language ( $GLOBALS [ 'current_language' ], $this->module_name ) ; // needed solely so that listviewdefs that reference this can be included without error |
|
58 | + $class = $GLOBALS [ 'beanList' ] [ $this->module_name ] ; |
|
59 | + require_once ($GLOBALS [ 'beanFiles' ] [ $class ]) ; |
|
60 | + $this->module = new $class ( ) ; |
|
61 | 61 | |
62 | - $loaded = $this->_loadFromFile('ListView','modules/' . $this->module_name . '/metadata/listviewdefs.php',$this->module_name); |
|
63 | - $this->originalListViewDefs = $loaded['viewdefs'] [ $this->module_name ] ; |
|
64 | - $this->_variables = $loaded['variables']; |
|
65 | - // _pp($loaded); |
|
66 | - $this->customFile = 'custom/modules/' . $this->module_name . '/metadata/listviewdefs.php' ; |
|
67 | - if (file_exists ( $this->customFile )) |
|
68 | - { |
|
69 | - $loaded = $this->_loadFromFile('ListView',$this->customFile,$this->module_name); |
|
70 | - $this->listViewDefs = $loaded['viewdefs'] [ $this->module_name ] ; |
|
71 | - $this->_variables = $loaded['variables']; |
|
72 | - } else |
|
73 | - { |
|
74 | - $this->listViewDefs = & $this->originalListViewDefs ; |
|
75 | - } |
|
62 | + $loaded = $this->_loadFromFile('ListView','modules/' . $this->module_name . '/metadata/listviewdefs.php',$this->module_name); |
|
63 | + $this->originalListViewDefs = $loaded['viewdefs'] [ $this->module_name ] ; |
|
64 | + $this->_variables = $loaded['variables']; |
|
65 | + // _pp($loaded); |
|
66 | + $this->customFile = 'custom/modules/' . $this->module_name . '/metadata/listviewdefs.php' ; |
|
67 | + if (file_exists ( $this->customFile )) |
|
68 | + { |
|
69 | + $loaded = $this->_loadFromFile('ListView',$this->customFile,$this->module_name); |
|
70 | + $this->listViewDefs = $loaded['viewdefs'] [ $this->module_name ] ; |
|
71 | + $this->_variables = $loaded['variables']; |
|
72 | + } else |
|
73 | + { |
|
74 | + $this->listViewDefs = & $this->originalListViewDefs ; |
|
75 | + } |
|
76 | 76 | |
77 | - $this->fixKeys ( $this->originalListViewDefs ) ; |
|
78 | - $this->fixKeys ( $this->listViewDefs ) ; |
|
79 | - $this->language_module = $this->module_name ; |
|
80 | - } |
|
77 | + $this->fixKeys ( $this->originalListViewDefs ) ; |
|
78 | + $this->fixKeys ( $this->listViewDefs ) ; |
|
79 | + $this->language_module = $this->module_name ; |
|
80 | + } |
|
81 | 81 | |
82 | - function getLanguage() |
|
83 | - { |
|
84 | - return $this->language_module; |
|
85 | - } |
|
86 | - // re-key array so that every entry has a key=name and all keys are lowercase - makes it easier in handleSave() later... |
|
87 | - function fixKeys ( &$defs ) |
|
88 | - { |
|
89 | - $temp = array ( ) ; |
|
90 | - foreach ( $defs as $key => $value ) |
|
91 | - { |
|
92 | - if (! is_array ( $value )) |
|
93 | - { |
|
94 | - $key = $value ; |
|
95 | - $def = array ( ) ; |
|
96 | - $def [ 'name' ] = (isset ( $this->module->field_defs [ $key ] )) ? $this->module->field_defs [ $key ] [ 'name' ] : $key ; |
|
97 | - $value = $def ; |
|
98 | - } |
|
99 | - if (isset ( $value [ 'name' ] )) |
|
100 | - { |
|
101 | - $key = $value [ 'name' ] ; // override key with name, needed when the entry lacks a key |
|
102 | - } |
|
103 | - $temp [ strtolower ( $key ) ] = $value ; |
|
104 | - } |
|
105 | - $defs = $temp ; |
|
106 | - } |
|
82 | + function getLanguage() |
|
83 | + { |
|
84 | + return $this->language_module; |
|
85 | + } |
|
86 | + // re-key array so that every entry has a key=name and all keys are lowercase - makes it easier in handleSave() later... |
|
87 | + function fixKeys ( &$defs ) |
|
88 | + { |
|
89 | + $temp = array ( ) ; |
|
90 | + foreach ( $defs as $key => $value ) |
|
91 | + { |
|
92 | + if (! is_array ( $value )) |
|
93 | + { |
|
94 | + $key = $value ; |
|
95 | + $def = array ( ) ; |
|
96 | + $def [ 'name' ] = (isset ( $this->module->field_defs [ $key ] )) ? $this->module->field_defs [ $key ] [ 'name' ] : $key ; |
|
97 | + $value = $def ; |
|
98 | + } |
|
99 | + if (isset ( $value [ 'name' ] )) |
|
100 | + { |
|
101 | + $key = $value [ 'name' ] ; // override key with name, needed when the entry lacks a key |
|
102 | + } |
|
103 | + $temp [ strtolower ( $key ) ] = $value ; |
|
104 | + } |
|
105 | + $defs = $temp ; |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * returns the default fields for a listview |
|
110 | - * Called only when displaying the listview for editing; not called when saving |
|
111 | - */ |
|
112 | - function getDefaultFields () |
|
113 | - { |
|
114 | - $this->defaults = array ( ) ; |
|
115 | - foreach ( $this->listViewDefs as $key => $def ) |
|
116 | - { |
|
117 | - // add in the default fields from the listviewdefs, stripping out any field with 'studio' set to a value other than true |
|
118 | - // Important: the 'studio' fields must be added back into the layout on save, as they're not editable rather than hidden |
|
119 | - if (! empty ( $def [ 'default' ] )) |
|
120 | - { |
|
121 | - if (! isset($def['studio']) || $def['studio'] === true) |
|
122 | - { |
|
123 | - $this->defaults [ $key ] = $def ; |
|
124 | - } |
|
125 | - else |
|
126 | - // anything which doesn't go into the defaults is a reserved field - this makes sure we don't miss anything |
|
127 | - { |
|
128 | - $this->reserved [ $key ] = $def; |
|
129 | - } |
|
130 | - } |
|
131 | - } |
|
132 | - return $this->defaults ; |
|
133 | - } |
|
134 | - /** |
|
135 | - * returns additional fields available for users to create fields |
|
136 | - */ |
|
137 | - function getAdditionalFields () |
|
138 | - { |
|
139 | - $this->additional = array ( ) ; |
|
140 | - foreach ( $this->listViewDefs as $key => $def ) |
|
141 | - { |
|
142 | - if (empty ( $def [ 'default' ] )) |
|
143 | - { |
|
144 | - $key = strtolower ( $key ) ; |
|
145 | - $this->additional [ $key ] = $def ; |
|
146 | - } |
|
147 | - } |
|
148 | - return $this->additional ; |
|
149 | - } |
|
150 | - /** |
|
151 | - * returns unused fields that are available for using in either default or additional list views |
|
152 | - */ |
|
153 | - function getAvailableFields () |
|
154 | - { |
|
155 | - $this->availableFields = array ( ) ; |
|
156 | - $lowerFieldList = array_change_key_case ( $this->listViewDefs ) ; |
|
157 | - foreach ( $this->originalListViewDefs as $key => $def ) |
|
158 | - { |
|
159 | - $key = strtolower ( $key ) ; |
|
160 | - if (! isset ( $lowerFieldList [ $key ] )) |
|
161 | - { |
|
162 | - $this->availableFields [ $key ] = $def ; |
|
163 | - } |
|
164 | - } |
|
165 | - $GLOBALS['log']->debug('parser.modifylistview.php->getAvailableFields(): field_defs='.print_r($this->availableFields,true)); |
|
166 | - $modFields = !empty($this->module->field_name_map) ? $this->module->field_name_map : $this->module->field_defs; |
|
167 | - foreach ( $modFields as $key => $def ) |
|
168 | - { |
|
169 | - $fieldName = strtolower ( $key ) ; |
|
108 | + /** |
|
109 | + * returns the default fields for a listview |
|
110 | + * Called only when displaying the listview for editing; not called when saving |
|
111 | + */ |
|
112 | + function getDefaultFields () |
|
113 | + { |
|
114 | + $this->defaults = array ( ) ; |
|
115 | + foreach ( $this->listViewDefs as $key => $def ) |
|
116 | + { |
|
117 | + // add in the default fields from the listviewdefs, stripping out any field with 'studio' set to a value other than true |
|
118 | + // Important: the 'studio' fields must be added back into the layout on save, as they're not editable rather than hidden |
|
119 | + if (! empty ( $def [ 'default' ] )) |
|
120 | + { |
|
121 | + if (! isset($def['studio']) || $def['studio'] === true) |
|
122 | + { |
|
123 | + $this->defaults [ $key ] = $def ; |
|
124 | + } |
|
125 | + else |
|
126 | + // anything which doesn't go into the defaults is a reserved field - this makes sure we don't miss anything |
|
127 | + { |
|
128 | + $this->reserved [ $key ] = $def; |
|
129 | + } |
|
130 | + } |
|
131 | + } |
|
132 | + return $this->defaults ; |
|
133 | + } |
|
134 | + /** |
|
135 | + * returns additional fields available for users to create fields |
|
136 | + */ |
|
137 | + function getAdditionalFields () |
|
138 | + { |
|
139 | + $this->additional = array ( ) ; |
|
140 | + foreach ( $this->listViewDefs as $key => $def ) |
|
141 | + { |
|
142 | + if (empty ( $def [ 'default' ] )) |
|
143 | + { |
|
144 | + $key = strtolower ( $key ) ; |
|
145 | + $this->additional [ $key ] = $def ; |
|
146 | + } |
|
147 | + } |
|
148 | + return $this->additional ; |
|
149 | + } |
|
150 | + /** |
|
151 | + * returns unused fields that are available for using in either default or additional list views |
|
152 | + */ |
|
153 | + function getAvailableFields () |
|
154 | + { |
|
155 | + $this->availableFields = array ( ) ; |
|
156 | + $lowerFieldList = array_change_key_case ( $this->listViewDefs ) ; |
|
157 | + foreach ( $this->originalListViewDefs as $key => $def ) |
|
158 | + { |
|
159 | + $key = strtolower ( $key ) ; |
|
160 | + if (! isset ( $lowerFieldList [ $key ] )) |
|
161 | + { |
|
162 | + $this->availableFields [ $key ] = $def ; |
|
163 | + } |
|
164 | + } |
|
165 | + $GLOBALS['log']->debug('parser.modifylistview.php->getAvailableFields(): field_defs='.print_r($this->availableFields,true)); |
|
166 | + $modFields = !empty($this->module->field_name_map) ? $this->module->field_name_map : $this->module->field_defs; |
|
167 | + foreach ( $modFields as $key => $def ) |
|
168 | + { |
|
169 | + $fieldName = strtolower ( $key ) ; |
|
170 | 170 | if ($fieldName == 'currency_id') |
171 | 171 | continue; |
172 | - if (!isset ( $lowerFieldList [ $fieldName ] )) // bug 16728 - check this first, so that other conditions (e.g., studio == visible) can't override and add duplicate entries |
|
173 | - { |
|
172 | + if (!isset ( $lowerFieldList [ $fieldName ] )) // bug 16728 - check this first, so that other conditions (e.g., studio == visible) can't override and add duplicate entries |
|
173 | + { |
|
174 | 174 | // bug 19656: this test changed after 5.0.0b - we now remove all ID type fields - whether set as type, or dbtype, from the fielddefs |
175 | 175 | if ($this->isValidField($key, $def)){ |
176 | - $label = (isset ( $def [ 'vname' ] )) ? $def [ 'vname' ] : (isset($def [ 'label' ]) ? $def['label'] : $def['name']) ; |
|
177 | - $this->availableFields [ $fieldName ] = array ( 'width' => '10' , 'label' => $label ) ; |
|
178 | - } |
|
179 | - } |
|
180 | - } |
|
176 | + $label = (isset ( $def [ 'vname' ] )) ? $def [ 'vname' ] : (isset($def [ 'label' ]) ? $def['label'] : $def['name']) ; |
|
177 | + $this->availableFields [ $fieldName ] = array ( 'width' => '10' , 'label' => $label ) ; |
|
178 | + } |
|
179 | + } |
|
180 | + } |
|
181 | 181 | |
182 | - return $this->availableFields ; |
|
183 | - } |
|
182 | + return $this->availableFields ; |
|
183 | + } |
|
184 | 184 | |
185 | 185 | function getFieldDefs() |
186 | 186 | { |
@@ -188,146 +188,146 @@ discard block |
||
188 | 188 | } |
189 | 189 | |
190 | 190 | |
191 | - function isValidField($key, $def) { |
|
192 | - //Allow fields that are studio visible |
|
193 | - if (! empty ( $def [ 'studio' ] ) && $def [ 'studio' ] == 'visible') |
|
194 | - return true; |
|
191 | + function isValidField($key, $def) { |
|
192 | + //Allow fields that are studio visible |
|
193 | + if (! empty ( $def [ 'studio' ] ) && $def [ 'studio' ] == 'visible') |
|
194 | + return true; |
|
195 | 195 | |
196 | - //No ID fields |
|
197 | - if ((!empty ( $def [ 'dbType' ] ) && $def [ 'dbType' ] == 'id') || (!empty ( $def [ 'type' ] ) && $def [ 'type' ] == 'id')) |
|
198 | - return false; |
|
196 | + //No ID fields |
|
197 | + if ((!empty ( $def [ 'dbType' ] ) && $def [ 'dbType' ] == 'id') || (!empty ( $def [ 'type' ] ) && $def [ 'type' ] == 'id')) |
|
198 | + return false; |
|
199 | 199 | |
200 | - //only allow DB and custom fields (if a source is specified) |
|
201 | - if (!empty($def [ 'source' ]) && $def [ 'source' ] != 'db' && $def [ 'source' ] != 'custom_fields') |
|
202 | - return false; |
|
200 | + //only allow DB and custom fields (if a source is specified) |
|
201 | + if (!empty($def [ 'source' ]) && $def [ 'source' ] != 'db' && $def [ 'source' ] != 'custom_fields') |
|
202 | + return false; |
|
203 | 203 | |
204 | - //Dont ever show the "deleted" fields or "_name" fields |
|
205 | - if (strcmp ( $key, 'deleted' ) == 0 || (isset ( $def [ 'name' ] ) && strpos ( $def [ 'name' ], "_name" ) !== false)) |
|
206 | - return false; |
|
204 | + //Dont ever show the "deleted" fields or "_name" fields |
|
205 | + if (strcmp ( $key, 'deleted' ) == 0 || (isset ( $def [ 'name' ] ) && strpos ( $def [ 'name' ], "_name" ) !== false)) |
|
206 | + return false; |
|
207 | 207 | |
208 | - //If none of the "ifs" are true, the field is valid |
|
209 | - return true; |
|
210 | - } |
|
208 | + //If none of the "ifs" are true, the field is valid |
|
209 | + return true; |
|
210 | + } |
|
211 | 211 | |
212 | 212 | |
213 | - function getField ( $fieldName ) |
|
214 | - { |
|
215 | - $fieldName = strtolower ( $fieldName ) ; |
|
216 | - foreach ( $this->listViewDefs as $key => $def ) |
|
217 | - { |
|
218 | - $key = strtolower ( $key ) ; |
|
219 | - if ($key == $fieldName) |
|
220 | - { |
|
221 | - return $def ; |
|
222 | - } |
|
223 | - } |
|
224 | - foreach ( $this->module->field_defs as $key => $def ) |
|
225 | - { |
|
226 | - $key = strtolower ( $key ) ; |
|
227 | - if ($key == $fieldName) |
|
228 | - { |
|
229 | - return $def ; |
|
230 | - } |
|
231 | - } |
|
232 | - return array ( ) ; |
|
233 | - } |
|
234 | - function addRelateData($fieldname, $listfielddef) { |
|
235 | - $modFieldDef = $this->module->field_defs [ strtolower ( $fieldname ) ]; |
|
236 | - if (!empty($modFieldDef['module']) && !empty($modFieldDef['id_name'])) { |
|
237 | - $listfielddef['module'] = $modFieldDef['module']; |
|
238 | - $listfielddef['id'] = strtoupper($modFieldDef['id_name']); |
|
239 | - $listfielddef['link'] = true; |
|
240 | - $listfielddef['related_fields'] = array (strtolower($modFieldDef['id_name'])); |
|
241 | - } |
|
242 | - return $listfielddef; |
|
243 | - } |
|
244 | - function _loadLayoutFromRequest () |
|
245 | - { |
|
246 | - $GLOBALS['log']->debug("ParserModifyListView->_loadLayoutFromRequest()"); |
|
247 | - $fields = array ( ) ; |
|
248 | - $rejectTypes = array ( 'html' , 'enum' , 'text' ) ; |
|
249 | - for ( $i = 0 ; isset ( $_POST [ 'group_' . $i ] ) && $i < 2 ; $i ++ ) |
|
250 | - { |
|
251 | - //echo "\n***group-$i Size:".sizeof($_POST['group_' . $i])."\n"; |
|
252 | - foreach ( $_POST [ 'group_' . $i ] as $field ) |
|
253 | - { |
|
254 | - $fieldname = strtoupper ( $field ) ; |
|
255 | - //originalListViewDefs are all lower case |
|
256 | - $lowerFieldName = strtolower ( $field ) ; |
|
257 | - if (isset ( $this->originalListViewDefs [ $lowerFieldName ] )) |
|
258 | - { |
|
259 | - $fields [ $fieldname ] = $this->originalListViewDefs [ $lowerFieldName ] ; |
|
260 | - } else |
|
261 | - { |
|
262 | - //check if we have the case wrong for custom fields |
|
263 | - if (! isset ( $this->module->field_defs [ $fieldname ] )) |
|
264 | - { |
|
265 | - foreach ( $this->module->field_defs as $key => $value ) |
|
266 | - { |
|
267 | - if (strtoupper ( $key ) == $fieldname) |
|
268 | - { |
|
269 | - $fields [ $fieldname ] = array ( 'width' => 10 , 'label' => $this->module->field_defs [ $key ] [ 'vname' ] ) ; |
|
270 | - break ; |
|
271 | - } |
|
272 | - } |
|
273 | - } else |
|
274 | - { |
|
275 | - $fields [ $fieldname ] = array ( 'width' => 10 , 'label' => $this->module->field_defs [ $fieldname ] [ 'vname' ] ) ; |
|
276 | - } |
|
277 | - // sorting fields of certain types will cause a database engine problems |
|
278 | - // we only check this for custom fields, as we assume that OOB fields have been independently confirmed as ok |
|
279 | - if (isset ( $this->module->field_defs [ strtolower ( $fieldname ) ] ) && (in_array ( $this->module->field_defs [ strtolower ( $fieldname ) ] [ 'type' ], $rejectTypes ) || isset($this->module->field_defs [ strtolower ( $fieldname ) ]['custom_module']))) |
|
280 | - { |
|
281 | - $fields [ $fieldname ] [ 'sortable' ] = false ; |
|
282 | - } |
|
283 | - // Bug 23728 - Make adding a currency type field default to setting the 'currency_format' to true |
|
284 | - if (isset ( $this->module->field_defs [ strtolower ( $fieldname ) ] [ 'type ' ] ) && $this->module->field_defs [ strtolower ( $fieldname ) ] [ 'type' ] == 'currency') |
|
285 | - { |
|
286 | - $fields [ $fieldname ] [ 'currency_format' ] = true; |
|
287 | - } |
|
288 | - } |
|
289 | - if (isset ( $_REQUEST [ strtolower ( $fieldname ) . 'width' ] )) |
|
290 | - { |
|
291 | - $width = substr ( $_REQUEST [ strtolower ( $fieldname ) . 'width' ], 6, 3 ) ; |
|
292 | - if (strpos ( $width, "%" ) !== false) |
|
293 | - { |
|
294 | - $width = substr ( $width, 0, 2 ) ; |
|
295 | - } |
|
296 | - if ($width < 101 && $width > 0) |
|
297 | - { |
|
298 | - $fields [ $fieldname ] [ 'width' ] = $width ; |
|
299 | - } |
|
300 | - } else if (isset ( $this->listViewDefs [ $fieldname ] [ 'width' ] )) |
|
301 | - { |
|
302 | - $fields [ $fieldname ] [ 'width' ] = $this->listViewDefs [ $fieldname ] [ 'width' ] ; |
|
303 | - } |
|
304 | - //Get additional Data for relate fields |
|
305 | - if (isset($this->module->field_defs [ strtolower ( $fieldname ) ] [ 'type' ]) && $this->module->field_defs [ strtolower ( $fieldname ) ] [ 'type' ] == 'relate') { |
|
306 | - $fields [ $fieldname ] = $this->addRelateData($field, $fields [ $fieldname ]); |
|
307 | - } |
|
308 | - $fields [ $fieldname ] [ 'default' ] = ($i == 0) ; |
|
309 | - } |
|
310 | - } |
|
311 | - // Add the reserved fields back in to the end of the default fields in the layout |
|
312 | - // ASSUMPTION: reserved fields go back at the end |
|
313 | - // First, load the reserved fields - we cannot assume that getDefaultFields has been called earlier when saving |
|
314 | - $this->getDefaultFields(); |
|
315 | - foreach ( $this->reserved as $key => $def) |
|
316 | - { |
|
317 | - $fields[ $key ] = $def; |
|
318 | - } |
|
213 | + function getField ( $fieldName ) |
|
214 | + { |
|
215 | + $fieldName = strtolower ( $fieldName ) ; |
|
216 | + foreach ( $this->listViewDefs as $key => $def ) |
|
217 | + { |
|
218 | + $key = strtolower ( $key ) ; |
|
219 | + if ($key == $fieldName) |
|
220 | + { |
|
221 | + return $def ; |
|
222 | + } |
|
223 | + } |
|
224 | + foreach ( $this->module->field_defs as $key => $def ) |
|
225 | + { |
|
226 | + $key = strtolower ( $key ) ; |
|
227 | + if ($key == $fieldName) |
|
228 | + { |
|
229 | + return $def ; |
|
230 | + } |
|
231 | + } |
|
232 | + return array ( ) ; |
|
233 | + } |
|
234 | + function addRelateData($fieldname, $listfielddef) { |
|
235 | + $modFieldDef = $this->module->field_defs [ strtolower ( $fieldname ) ]; |
|
236 | + if (!empty($modFieldDef['module']) && !empty($modFieldDef['id_name'])) { |
|
237 | + $listfielddef['module'] = $modFieldDef['module']; |
|
238 | + $listfielddef['id'] = strtoupper($modFieldDef['id_name']); |
|
239 | + $listfielddef['link'] = true; |
|
240 | + $listfielddef['related_fields'] = array (strtolower($modFieldDef['id_name'])); |
|
241 | + } |
|
242 | + return $listfielddef; |
|
243 | + } |
|
244 | + function _loadLayoutFromRequest () |
|
245 | + { |
|
246 | + $GLOBALS['log']->debug("ParserModifyListView->_loadLayoutFromRequest()"); |
|
247 | + $fields = array ( ) ; |
|
248 | + $rejectTypes = array ( 'html' , 'enum' , 'text' ) ; |
|
249 | + for ( $i = 0 ; isset ( $_POST [ 'group_' . $i ] ) && $i < 2 ; $i ++ ) |
|
250 | + { |
|
251 | + //echo "\n***group-$i Size:".sizeof($_POST['group_' . $i])."\n"; |
|
252 | + foreach ( $_POST [ 'group_' . $i ] as $field ) |
|
253 | + { |
|
254 | + $fieldname = strtoupper ( $field ) ; |
|
255 | + //originalListViewDefs are all lower case |
|
256 | + $lowerFieldName = strtolower ( $field ) ; |
|
257 | + if (isset ( $this->originalListViewDefs [ $lowerFieldName ] )) |
|
258 | + { |
|
259 | + $fields [ $fieldname ] = $this->originalListViewDefs [ $lowerFieldName ] ; |
|
260 | + } else |
|
261 | + { |
|
262 | + //check if we have the case wrong for custom fields |
|
263 | + if (! isset ( $this->module->field_defs [ $fieldname ] )) |
|
264 | + { |
|
265 | + foreach ( $this->module->field_defs as $key => $value ) |
|
266 | + { |
|
267 | + if (strtoupper ( $key ) == $fieldname) |
|
268 | + { |
|
269 | + $fields [ $fieldname ] = array ( 'width' => 10 , 'label' => $this->module->field_defs [ $key ] [ 'vname' ] ) ; |
|
270 | + break ; |
|
271 | + } |
|
272 | + } |
|
273 | + } else |
|
274 | + { |
|
275 | + $fields [ $fieldname ] = array ( 'width' => 10 , 'label' => $this->module->field_defs [ $fieldname ] [ 'vname' ] ) ; |
|
276 | + } |
|
277 | + // sorting fields of certain types will cause a database engine problems |
|
278 | + // we only check this for custom fields, as we assume that OOB fields have been independently confirmed as ok |
|
279 | + if (isset ( $this->module->field_defs [ strtolower ( $fieldname ) ] ) && (in_array ( $this->module->field_defs [ strtolower ( $fieldname ) ] [ 'type' ], $rejectTypes ) || isset($this->module->field_defs [ strtolower ( $fieldname ) ]['custom_module']))) |
|
280 | + { |
|
281 | + $fields [ $fieldname ] [ 'sortable' ] = false ; |
|
282 | + } |
|
283 | + // Bug 23728 - Make adding a currency type field default to setting the 'currency_format' to true |
|
284 | + if (isset ( $this->module->field_defs [ strtolower ( $fieldname ) ] [ 'type ' ] ) && $this->module->field_defs [ strtolower ( $fieldname ) ] [ 'type' ] == 'currency') |
|
285 | + { |
|
286 | + $fields [ $fieldname ] [ 'currency_format' ] = true; |
|
287 | + } |
|
288 | + } |
|
289 | + if (isset ( $_REQUEST [ strtolower ( $fieldname ) . 'width' ] )) |
|
290 | + { |
|
291 | + $width = substr ( $_REQUEST [ strtolower ( $fieldname ) . 'width' ], 6, 3 ) ; |
|
292 | + if (strpos ( $width, "%" ) !== false) |
|
293 | + { |
|
294 | + $width = substr ( $width, 0, 2 ) ; |
|
295 | + } |
|
296 | + if ($width < 101 && $width > 0) |
|
297 | + { |
|
298 | + $fields [ $fieldname ] [ 'width' ] = $width ; |
|
299 | + } |
|
300 | + } else if (isset ( $this->listViewDefs [ $fieldname ] [ 'width' ] )) |
|
301 | + { |
|
302 | + $fields [ $fieldname ] [ 'width' ] = $this->listViewDefs [ $fieldname ] [ 'width' ] ; |
|
303 | + } |
|
304 | + //Get additional Data for relate fields |
|
305 | + if (isset($this->module->field_defs [ strtolower ( $fieldname ) ] [ 'type' ]) && $this->module->field_defs [ strtolower ( $fieldname ) ] [ 'type' ] == 'relate') { |
|
306 | + $fields [ $fieldname ] = $this->addRelateData($field, $fields [ $fieldname ]); |
|
307 | + } |
|
308 | + $fields [ $fieldname ] [ 'default' ] = ($i == 0) ; |
|
309 | + } |
|
310 | + } |
|
311 | + // Add the reserved fields back in to the end of the default fields in the layout |
|
312 | + // ASSUMPTION: reserved fields go back at the end |
|
313 | + // First, load the reserved fields - we cannot assume that getDefaultFields has been called earlier when saving |
|
314 | + $this->getDefaultFields(); |
|
315 | + foreach ( $this->reserved as $key => $def) |
|
316 | + { |
|
317 | + $fields[ $key ] = $def; |
|
318 | + } |
|
319 | 319 | |
320 | - return $fields ; |
|
321 | - } |
|
322 | - function handleSave () |
|
323 | - { |
|
324 | - $fields = $this->_loadLayoutFromRequest(); |
|
325 | - $this->_writeToFile($this->customFile,'ListView',$this->module_name,$fields,$this->_variables); |
|
320 | + return $fields ; |
|
321 | + } |
|
322 | + function handleSave () |
|
323 | + { |
|
324 | + $fields = $this->_loadLayoutFromRequest(); |
|
325 | + $this->_writeToFile($this->customFile,'ListView',$this->module_name,$fields,$this->_variables); |
|
326 | 326 | |
327 | - $GLOBALS [ "listViewDefs" ] [ $this->module_name ] = $fields ; |
|
328 | - // now clear the cache so that the results are immediately visible |
|
329 | - include_once ('include/TemplateHandler/TemplateHandler.php') ; |
|
330 | - TemplateHandler::clearCache ( $this->module_name, "ListView.tpl" ) ; // not currently cached, but here for the future |
|
331 | - } |
|
327 | + $GLOBALS [ "listViewDefs" ] [ $this->module_name ] = $fields ; |
|
328 | + // now clear the cache so that the results are immediately visible |
|
329 | + include_once ('include/TemplateHandler/TemplateHandler.php') ; |
|
330 | + TemplateHandler::clearCache ( $this->module_name, "ListView.tpl" ) ; // not currently cached, but here for the future |
|
331 | + } |
|
332 | 332 | } |
333 | 333 | ?> |