]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - include/SugarFields/Fields/Collection/ViewSugarFieldCollection.php
Release 6.1.4
[Github/sugarcrm.git] / include / SugarFields / Fields / Collection / ViewSugarFieldCollection.php
1 <?php
2 /*********************************************************************************
3  * SugarCRM is a customer relationship management program developed by
4  * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
5  * 
6  * This program is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License version 3 as published by the
8  * Free Software Foundation with the addition of the following permission added
9  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10  * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
11  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12  * 
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
16  * details.
17  * 
18  * You should have received a copy of the GNU Affero General Public License along with
19  * this program; if not, see http://www.gnu.org/licenses or write to the Free
20  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  * 02110-1301 USA.
22  * 
23  * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
24  * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
25  * 
26  * The interactive user interfaces in modified source and object code versions
27  * of this program must display Appropriate Legal Notices, as required under
28  * Section 5 of the GNU Affero General Public License version 3.
29  * 
30  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31  * these Appropriate Legal Notices must retain the display of the "Powered by
32  * SugarCRM" logo. If the display of the logo is not reasonably feasible for
33  * technical reasons, the Appropriate Legal Notices must display the words
34  * "Powered by SugarCRM".
35  ********************************************************************************/
36
37 require_once('include/SugarFields/Fields/Collection/SugarFieldCollection.php');
38
39
40 class ViewSugarFieldCollection{
41     var $ss; // Sugar Smarty Object
42     var $bean;
43     var $bean_id;
44     var $name;
45     var $value_name;
46     var $displayParams; // DisplayParams for the collection field (defined in the metadata)
47     var $vardef; // vardef of the collection field.
48     var $related_module; // module name of the related module
49     var $module_dir; // name of the module where the collection field is.
50     var $numFields;
51     var $json;
52     var $tpl_path;
53     var $extra_var;
54     var $skipModuleQuickSearch = false;
55     var $field_to_name_array; //mapping of fields for the return of the select popup
56     var $showSelectButton = true;
57     var $hideShowHideButton = false;
58     var $action_type;
59     var $form_name;
60     
61     function ViewSugarFieldCollection($fill_data = true){
62         $this->json = getJSONobj();
63         if($fill_data){
64                 $this->displayParams = $this->json->decode(html_entity_decode($_REQUEST['displayParams']));
65                 $this->vardef = $this->json->decode(html_entity_decode($_REQUEST['vardef']));
66                 $this->module_dir = $_REQUEST['module_dir'];
67                 $this->action_type = $_REQUEST['action_type'];
68                 $this->name = $this->vardef['name'];
69                 $this->value_name = $this->name . '_values';
70                 $this->numFields = 1;
71                 $this->ss = new Sugar_Smarty();
72                 $this->edit_tpl_path = 'include/SugarFields/Fields/Collection/CollectionEditView.tpl';
73                 $this->detail_tpl_path = 'include/SugarFields/Fields/Collection/CollectionDetailView.tpl';
74                 $this->extra_var = array();
75                 $this->field_to_name_array = array();
76         }
77     }
78     /*
79      * Retrieve the related module and load the bean and the relationship
80      * call retrieve values()
81      */
82     function setup(){
83         if(!class_exists('Relationship')){
84             
85         }
86         $rel = new Relationship();
87         if(!empty($this->vardef['relationship'])){
88                 $rel->retrieve_by_name($this->vardef['relationship']);
89         }
90         if($rel->relationship_type == 'many-to-many'){
91             if($rel->lhs_module == $this->module_dir){
92                 $this->related_module = $rel->rhs_module;
93                 $module_dir = $rel->lhs_module;
94             }else if($rel->rhs_module == $this->module_dir){
95                 $this->related_module = $rel->lhs_module;
96                 $module_dir = $rel->rhs_module;
97             }else{
98                 die("this field has no relationships mapped with this module");
99             }
100             if($module_dir != $this->module_dir){
101                 die('These modules do not match : '. $this->module_dir . ' and ' . $module_dir);
102             }
103             if(isset($GLOBALS['beanList'][$this->module_dir])){
104                 $class = $GLOBALS['beanList'][$this->module_dir];
105                 if(file_exists($GLOBALS['beanFiles'][$class])){
106                     $this->bean = loadBean($this->module_dir);
107                     $this->bean->retrieve($_REQUEST['bean_id']);
108                     if($this->bean->load_relationship($this->vardef['name'])){
109                         $this->retrieve_values();
110                     }else{
111                         die('failed to load the relationship');
112                     }
113                 }else{
114                     die('class file do not exist');
115                 }
116             }else{
117                 die($this->module_dir . ' is not in the beanList.');
118             }
119         }
120         else{
121             die("the relationship is not a many-to-many");
122         }
123     }
124     /*
125      * Retrieve the values from the DB using the get method of the link class
126      * Organize and save the value into the bean
127      */
128     function retrieve_values(){
129         if(empty($this->bean->{$this->value_name}) && isset($this->bean->{$this->name})){
130             $values = array();
131             $values = $this->bean->{$this->name}->get(true);
132             $role_field = $this->bean->{$this->name}->_get_link_table_role_field($this->bean->{$this->name}->_relationship_name);
133             foreach($values as $v){
134                 $role = '';
135                 foreach($v as $kk=>$vv){
136                     if($kk == $role_field){
137                         $role=$vv;
138                     }
139                 }
140                 if($role == 'primary'){
141                     $primary_id = $v['id'];
142                 }else{
143                     $secondary_ids[] = array('id'=>$v['id'], 'role'=>$role);
144                 }
145             }
146             $this->bean->{$this->value_name} = array('role_field'=>$role_field);
147             if(isset($primary_id) || isset($secondary_ids)){
148                 if(!isset($primary_id)){
149                     $primary_id = $secondary_ids[0]['id'];
150                     unset($secondary_ids[0]);
151                 }
152                 if(isset($GLOBALS['beanList'][ $this->related_module])){
153                     $class = $GLOBALS['beanList'][$this->related_module];
154                     if(file_exists($GLOBALS['beanFiles'][$class])){
155                         $mod = loadBean($this->module_dir);
156                         $mod->relDepth = $this->bean->relDepth + 1;
157                         $mod->retrieve($primary_id);
158                         if (isset($mod->name)) {
159                             $this->bean->{$this->value_name}=array_merge($this->bean->{$this->value_name}, array('primary'=>array('id'=>$primary_id, 'name'=>$mod->name)));
160                         }
161                         $secondaries = array();
162                         if(isset($secondary_ids)){
163                             foreach($secondary_ids as $v){
164                                 if($mod->retrieve($v['id'])){
165                                     if (isset($mod->name)){
166                                         $secondaries['secondaries'][]=array('id'=>$v['id'], 'name'=>$mod->name);
167                                     }
168                                 }
169                             }
170                         }
171                         $this->bean->{$this->value_name}=array_merge($this->bean->{$this->value_name}, $secondaries);
172                         if(isset($field['additionalFields'])){
173                             foreach($field['additionalFields'] as $field=>$to){
174                                 if(isset($mod->$field)){
175                                     $this->bean->$to = $mod->$field;
176                                 }
177                             }
178                         }   
179                     }
180                 }
181             }
182         }
183     }
184     /*
185      * redirect to the good process method.
186      */
187     function process(){
188         if($this->action_type == 'editview'){
189             $this->process_editview();
190         }else if($this->action_type == 'detailview'){
191             $this->process_detailview();
192         }
193     }
194     function process_detailview(){
195         
196     }
197     /*
198      * Build the DisplayParams array
199      */
200     function process_editview(){
201         if(isset($this->bean->{$this->value_name}['secondaries'])){
202             $this->numFields=count($this->bean->{$this->value_name}['secondaries'])+1;
203         }
204         if(!isset($this->displayParams['readOnly'])) {
205            $this->displayParams['readOnly'] = '';
206         } else {
207            $this->displayParams['readOnly'] = $this->displayParams['readOnly'] == false ? '' : 'READONLY';  
208         }
209         // If there is extra field to show.
210         if(isset($this->displayParams['collection_field_list'])){
211                 
212             require_once('include/SugarFields/SugarFieldHandler.php');
213             $sfh = new SugarFieldHandler();
214             vardefmanager::loadVardef($this->related_module, $GLOBALS['beanList'][$this->related_module]);
215             foreach($this->displayParams['collection_field_list'] as $k=>$v){
216                 $javascript='';
217                 $collection_field_vardef = $GLOBALS['dictionary'][$GLOBALS['beanList'][$this->related_module]]['fields'][$v['name']];
218                
219                 // For each extra field the params which are not displayParams will be consider as params to override the vardefs values.
220                 foreach($v as $k_override=>$v_override){
221                     if($k_override != 'displayParams'){
222                         $collection_field_vardef[$k_override] = $v_override;
223                     }
224                 }
225
226                 // If relate field : enable quick search by creating the sqs_object array.
227                 if($collection_field_vardef['type'] == 'relate'){
228                     require_once('include/TemplateHandler/TemplateHandler.php');
229                     $tph = new TemplateHandler();
230                     $javascript = $tph->createQuickSearchCode(array($collection_field_vardef['name']=>$collection_field_vardef), array($v), $this->form_name);
231                     $javascript = str_replace('<script language="javascript">'."if(typeof sqs_objects == 'undefined'){var sqs_objects = new Array;}sqs_objects['{$collection_field_vardef['name']}']=","",$javascript);
232                     $javascript = substr($javascript, 0, -10);//remove ";</script>"
233                     $javascriptPHP = $this->json->decode($javascript);
234                     foreach($javascriptPHP['populate_list'] as $kk=>$vv){
235                         $javascriptPHP['populate_list'][$kk] .= "_" . $this->vardef['name'] . "_collection_extra_0";
236                     }
237                     foreach($javascriptPHP['required_list'] as $kk=>$vv){
238                         $javascriptPHP['required_list'][$kk] .= "_" . $this->vardef['name'] . "_collection_extra_0";
239                     }
240                     foreach($javascriptPHP['field_list'] as $kk=>$vv){
241                         if($vv == 'id'){
242                             $javascriptPHP['populate_list'][$kk];
243                         }
244                     }
245                     $javascript = $this->json->encode($javascriptPHP);
246                     $javascript = "<script language='javascript'>if(typeof sqs_objects == 'undefined'){var sqs_objects = new Array;}sqs_objects['{$collection_field_vardef['name']}_" . $this->vardef['name'] . "_collection_extra_0']=".$javascript.';</script>';
247                 }
248                 
249                 $collection_field_vardef['name'] .= "_" . $this->vardef['name'] . "_collection_extra_0";
250                 if(isset($collection_field_vardef['id_name'])){
251                     $collection_field_vardef['id_name'] .= "_" . $this->vardef['name'] . "_collection_extra_0";
252                 }
253                 if(isset($this->displayParams['allow_update']) && ($this->displayParams['allow_update'] === false || $this->displayParams['allow_update'] === 'false')){
254                     $this->displayParams['allow_update']='false';
255                     $v['displayParams']['field']['disabled']='';
256                 }else{
257                     $this->displayParams['allow_update']='true';
258                     if(!isset($v['displayParams'])){
259                         $v['displayParams']=array();
260                     }
261                 }
262                     $viewtype='EditView';
263                 $name = $collection_field_vardef['name'];
264                 // Rearranging the array with name as key instaead of number. This is required for displaySmarty() to assign the good variable.
265                 $this->displayParams['collection_field_list'][$name]['vardefName'] = $this->displayParams['collection_field_list'][$k]['name'];
266                 $this->displayParams['collection_field_list'][$name]['name'] = $name;
267                 if($collection_field_vardef['type'] == 'relate'){
268                     $this->displayParams['collection_field_list'][$name]['id_name'] = $collection_field_vardef['id_name'];
269                     $this->displayParams['collection_field_list'][$name]['module'] = $collection_field_vardef['module'];
270                 }
271                 $this->displayParams['collection_field_list'][$name]['label'] = "{sugar_translate label='{$collection_field_vardef['vname']}' module='{$this->related_module}'}";//translate($collection_field_vardef['vname'], $this->related_module);
272                 $this->displayParams['collection_field_list'][$name]['field'] = $sfh->displaySmarty('displayParams.collection_field_list', $collection_field_vardef, $viewtype, $v['displayParams'], 1);
273                 $this->displayParams['collection_field_list'][$name]['field'] .= '{literal}'.$javascript;
274             // Handle update_field array ONCHANGE
275                 $this->displayParams['collection_field_list'][$name]['field'] .= <<<FRA
276                 <script language='javascript'>
277                     var oldonchange = '';
278                     if(typeof(document.getElementById('{$collection_field_vardef['name']}').attributes.onchange) != 'undefined')
279                     {
280                         oldonchange=document.getElementById('{$collection_field_vardef['name']}').attributes.onchange.value;
281                     }
282 FRA;
283                 $this->displayParams['collection_field_list'][$name]['field'] .= "eval(\"document.getElementById('{$collection_field_vardef['name']}').onchange = function onchange(event){collection['{$this->vardef['name']}'].update_fields.{$collection_field_vardef['name']}=true;";
284                 if($collection_field_vardef['type'] == 'relate'){
285                     // If relate add the ID field to the array
286                     $this->displayParams['collection_field_list'][$name]['field'] .= "collection['{$this->vardef['name']}'].update_fields.{$collection_field_vardef['id_name']}=true;";
287                 }
288                 $this->displayParams['collection_field_list'][$name]['field'] .= "document.getElementById('update_fields_{$this->vardef['name']}_collection').value = JSON.stringifyNoSecurity(collection['{$this->vardef['name']}'].update_fields);\" + oldonchange + \"};\");</script>{/literal}";
289                 //we need to get rid of the old value;
290                 unset($this->displayParams['collection_field_list'][$k]);
291             }
292         }
293         if(!isset($this->displayParams['class'])) $this->displayParams['class']='';
294         if(isset($this->displayParams['allow_new']) && ($this->displayParams['allow_new'] === false || $this->displayParams['allow_new'] === 'false')){
295             $this->displayParams['allow_new']='false';
296             $this->displayParams['class']=str_replace('sqsNoAutofill','',$this->displayParams['class']);
297         }else{
298             $this->displayParams['allow_new']='true';
299             $this->displayParams['class'].=' sqsNoAutofill';
300         }
301         if(isset($this->displayParams['new_on_update']) && ($this->displayParams['new_on_update'] !== false || $this->displayParams['new_on_update'] !== 'false' || $this->displayParams['new_on_update'] !== 'FALSE' || $this->displayParams['new_on_update'] !== '0')){
302             $this->displayParams['new_on_update']='true';
303         }else{
304             $this->displayParams['new_on_update']='false';
305         }
306     }
307     
308     /*
309      * Init the template with the variables
310      */
311     function init_tpl(){
312         foreach($this->extra_var as $k=>$v){
313             $this->ss->assign($k,$v);
314         }
315         if($this->action_type == 'editview'){
316             $this->ss->assign('quickSearchCode',$this->createQuickSearchCode());
317             $this->createPopupCode();// this code populate $this->displayParams with popupdata.
318             $this->tpl_path = $this->edit_tpl_path;
319         }else if($this->action_type == 'detailview'){
320             $this->tpl_path = $this->detail_tpl_path;
321         }
322
323         $this->ss->assign('displayParams',$this->displayParams);
324         $this->ss->assign('vardef',$this->vardef);
325         $this->ss->assign('module',$this->related_module);
326         $this->ss->assign('values',$this->bean->{$this->value_name});
327         $this->ss->assign('showSelectButton',$this->showSelectButton);
328         $this->ss->assign('hideShowHideButton',$this->hideShowHideButton);
329         $this->ss->assign('APP',$GLOBALS['app_strings']);
330     }
331     /*
332      * Display the collection field after retrieving the cached row.
333      */
334     function display(){
335         $cacheRowFile = $GLOBALS['sugar_config']['cache_dir'] . 'modules/'. $this->module_dir .  '/collections/'. $this->name . '.tpl';
336         if(!$this->checkTemplate($cacheRowFile)){
337             $dir = dirname($cacheRowFile);
338             if(!file_exists($dir)) {
339                
340                mkdir_recursive($dir, null, true);
341             }
342             $cacheRow = $this->ss->fetch('include/SugarFields/Fields/Collection/CollectionEditViewRow.tpl');
343             file_put_contents($cacheRowFile, $cacheRow);
344         }
345         $this->ss->assign('cacheRowFile', $cacheRowFile);
346         return $this->ss->fetch($this->tpl_path);
347     }
348     /*
349      * Check if the template is cached
350      * return a bool
351      */
352     function checkTemplate($cacheRowFile){
353         if(!empty($GLOBALS['sugar_config']['developerMode']) || !empty($_SESSION['developerMode'])){
354             return false;
355         }
356         return file_exists($cacheRowFile);
357     }
358
359     
360     /*
361      * Create the quickSearch code for the collection field. 
362      * return the javascript code which define sqs_objects.
363      */
364     function createQuickSearchCode($returnAsJavascript = true){
365         $sqs_objects = array();
366         require_once('include/QuickSearchDefaults.php');
367         $qsd = new QuickSearchDefaults();
368         $qsd->setFormName($this->form_name);
369         for($i=0; $i<$this->numFields; $i++){
370             $name1 = "{$this->form_name}_{$this->name}_collection_{$i}";
371             if(!$this->skipModuleQuickSearch && preg_match('/(Campaigns|Teams|Users|Contacts|Accounts)/si', $this->related_module, $matches)) {
372                 if($matches[0] == 'Users'){
373                     $sqs_objects[$name1] = $qsd->getQSUser();
374                 } else if($matches[0] == 'Campaigns') {
375                     $sqs_objects[$name1] = $qsd->getQSCampaigns();
376
377                 } else if($matches[0] == 'Users'){
378                     $sqs_objects[$name1] = $qsd->getQSUser();
379
380                 } else if($matches[0] == 'Accounts') {
381                     $nameKey = "{$this->name}_collection_{$i}";
382                     $idKey = "id_{$this->name}_collection_{$i}";
383                  
384                  //There are billingKey, shippingKey and additionalFields entries you can define in editviewdefs.php 
385                  //entry to allow quick search to autocomplete fields with a suffix value of the 
386                  //billing/shippingKey value (i.e. 'billingKey' => 'primary' in Contacts will populate
387                  //primary_XXX fields with the Account's billing address values).        
388                  //addtionalFields are key/value pair of fields to fill from Accounts(key) to Contacts(value)
389                     $billingKey = isset($this->displayParams['billingKey']) ? $this->displayParams['billingKey'] : null;
390                     $shippingKey = isset($this->displayParams['shippingKey']) ? $this->displayParams['shippingKey'] : null;
391                     $additionalFields = isset($this->displayParams['additionalFields']) ? $this->displayParams['additionalFields'] : null;
392                     $sqs_objects[$name1] = $qsd->getQSAccount($nameKey, $idKey, $billingKey, $shippingKey, $additionalFields);
393                 } else if($matches[0] == 'Contacts'){
394                     $sqs_objects[$name1] = $qsd->getQSContact($name1, "id_".$name1);
395                 }
396                 $temp_array = array('field_list'=>array(),'populate_list'=>array());
397                 foreach($sqs_objects[$name1]['field_list'] as $k=>$v){
398                     if(!in_array($v, array('name','id'))){
399                         $sqs_objects[$name1]['primary_field_list'][]=$v;
400                         $sqs_objects[$name1]['primary_populate_list'][]=$sqs_objects[$name1]['populate_list'][$k];
401                     }else{
402                         $temp_array['field_list'][]=$v;
403                         $temp_array['populate_list'][]=$sqs_objects[$name1]['populate_list'][$k];
404                     }
405                 }
406                 $sqs_objects[$name1]['field_list'] = $temp_array['field_list'];
407                 $sqs_objects[$name1]['populate_list'] = $temp_array['populate_list'];
408                 if(isset($this->displayParams['collection_field_list'])){
409                     foreach($this->displayParams['collection_field_list'] as $v){
410                         $sqs_objects[$name1]['populate_list'][]=  $v['vardefName']."_".$this->name."_collection_extra_".$i;
411                         $sqs_objects[$name1]['field_list'][] = $v['vardefName'];
412                     }
413                 }
414             }else {
415                 $sqs_objects[$name1] = $qsd->getQSParent($this->related_module);
416                 $sqs_objects[$name1]['populate_list'] = array("{$this->vardef['name']}_collection_{$i}", "id_{$this->vardef['name']}_collection_{$i}");
417                 $sqs_objects[$name1]['field_list'] = array('name', 'id');
418                 if(isset($this->displayParams['collection_field_list'])){
419                     foreach($this->displayParams['collection_field_list'] as $v){
420                         $sqs_objects[$name1]['populate_list'][] = $v['vardefName']."_".$this->name."_collection_extra_".$i;
421                         $sqs_objects[$name1]['field_list'][] = $v['vardefName'];
422                     }
423                 }
424                 if(isset($this->displayParams['field_to_name_array'])){
425                     foreach($this->displayParams['field_to_name_array'] as $k=>$v){
426                         /*
427                          * "primary_populate_list" and "primary_field_list" are used when the field is selected as a primary.
428                          * At this time the JS function changePrimary() will copy "primary_populate_list" and "primary_field_list"
429                          * into "populate_list" and "field_list" and remove the values from all the others which are secondaries.
430                          * "primary_populate_list" and "primary_field_list" contain the fields which has to be populated outside of 
431                          * the collection field. For example the "Address Information" are populated with the "billing address" of the 
432                          * selected account in a contact editview.
433                          */
434                         $sqs_objects[$name1]['primary_populate_list'][] = $v;
435                         $sqs_objects[$name1]['primary_field_list'][] = $k;
436                     }
437                 }else if(isset($field['field_list']) && isset($field['populate_list'])){
438                     $sqs_objects[$name1]['primary_populate_list'] = array_merge($sqs_objects[$name1]['populate_list'], $field['field_list']);
439                     $sqs_objects[$name1]['primary_field_list'] = array_merge($sqs_objects[$name1]['field_list'], $field['populate_list']);
440                 }else{
441                     $sqs_objects[$name1]['primary_populate_list'] = array();
442                     $sqs_objects[$name1]['primary_field_list'] = array();
443                 }
444             }
445         }
446
447         $id = "{$this->form_name}_{$this->name}_collection_0";
448
449         if(!empty($sqs_objects) && count($sqs_objects) > 0) {
450             foreach($sqs_objects[$id]['field_list'] as $k=>$v){
451                 $this->field_to_name_array[$v] = $sqs_objects[$id]['populate_list'][$k];
452             }
453             if($returnAsJavascript){
454                     $quicksearch_js = '<script language="javascript">';
455                     $quicksearch_js.= "if(typeof sqs_objects == 'undefined'){var sqs_objects = new Array;}";
456                     
457                     foreach($sqs_objects as $sqsfield=>$sqsfieldArray){
458                        $quicksearch_js .= "sqs_objects['$sqsfield']={$this->json->encode($sqsfieldArray)};";
459                     }
460
461                     return $quicksearch_js .= '</script>';
462             }else{
463                 return $sqs_objects;
464             }
465        }
466        return '';
467     }
468     /*
469      * Always call createQuickSearchCode() before createPopupCode() to define field_to_name_array
470      */
471     function createPopupCode(){
472         // TODO the 'select' button is not fully working. We should use the sqs_objects in open_popup instead of the parameter.
473         if(isset($this->field_to_name_array) && !empty($this->field_to_name_array)){
474             $call_back_function = 'set_return';
475
476             if(isset($this->displayParams['formName'])) {
477                 $form = $this->displayParams['formName'];
478             } else if($this->action_type == 'editview'){
479                 $form = 'EditView';
480             } else if($this->action_type == 'quickcreate'){
481                 $form = "QuickCreate_{$this->module_dir}";
482             }
483             
484             if(isset($this->displayParams['call_back_function'])) {
485                 $call_back_function = $this->displayParams['call_back_function'];
486             }
487
488             $popup_request_data= array(
489                 'call_back_function' => $call_back_function,
490                 'form_name' => $form,
491                 'field_to_name_array' => $this->field_to_name_array,
492             );
493
494             //Make sure to replace {{ and }} with spacing in between because Smarty template parsing will treat {{ or }} specially
495             $this->displayParams['popupData'] = '{literal}'. str_replace(array('{{', '}}'), array('{ {', '} }'), $this->json->encode($popup_request_data)) . '{/literal}';
496         }
497     }
498 }
499
500 ?>