source: trunk/contactcenter/inc/class.ui_api.inc.php @ 84

Revision 84, 17.3 KB checked in by wmerlotto, 17 years ago (diff)

Internacionalização - Removido mais strings hardcoded.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2  /***************************************************************************\
3  * eGroupWare - Contacts Center                                              *
4  * http://www.egroupware.org                                                 *
5  * Written by:                                                               *
6  *  - Raphael Derosso Pereira <raphaelpereira@users.sourceforge.net>         *
7  *  - Jonas Goes <jqhcb@users.sourceforge.net>                               *
8  *  sponsored by Thyamad - http://www.thyamad.com                            *
9  * ------------------------------------------------------------------------- *
10  *  This program is free software; you can redistribute it and/or modify it  *
11  *  under the terms of the GNU General Public License as published by the    *
12  *  Free Software Foundation; either version 2 of the License, or (at your   *
13  *  option) any later version.                                               *
14  \***************************************************************************/
15
16        /*
17         * This is the Main ContactCenter API for other eGroupWare applications
18         *
19         */
20 
21        class ui_api
22        {
23                var $commons;
24                var $commons_loaded = false;
25               
26                function ui_api()
27                {
28                        $preferences = ExecMethod('contactcenter.ui_preferences.get_preferences');
29                       
30                        if (!is_array($preferences))
31                        {
32                                $preferences['personCardEmail'] = 1;
33                                //$preferences['personCardPhone'] = 2;
34                        }
35                       
36                        $template_dir = PHPGW_SERVER_ROOT . '/contactcenter/templates/default/';
37                        $template = CreateObject('phpgwapi.Template',$template_dir);
38
39                        $template->set_file(array('api' => 'api_common.tpl'));
40                       
41                        $template->set_var('cc_email_id_type', $preferences['personCardEmail']);
42                       
43                       
44                        /* Messages */
45                        $template->set_var('cc_msg_err_invalid_catalog',lang('Unavailable or empty Catalog'));
46                        $template->set_var('cc_msg_err_contacting_server',lang('Couldn\'t contact server or server response is invalid. Contact Admin.'));
47                        $template->set_var('cc_msg_err_timeout',lang('Operation Timed Out.'));
48                        $template->set_var('cc_msg_err_serialize_data_unknown',lang('Data to be serialized is of unknown type!'));
49                        /* End Messages */
50
51                        if ($preferences['displayConnector'])
52                        {
53                                $template->set_var('cc_connector_visible', 'true');
54                        }
55                        else
56                        {
57                                $template->set_var('cc_connector_visible', 'false');
58                        }
59                        $template->set_var('cc_loading_1', lang('Contacting Server...'));
60                        $template->set_var('cc_loading_2', lang('Server Contacted. Waiting for response...'));
61                        $template->set_var('cc_loading_3', lang('Processing Information...'));
62                        $template->set_var('cc_loading_image', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/templates/default/images/loading_back.png');
63                        $template->set_var('cc_server_root', $GLOBALS['phpgw_info']['server']['webserver_url']);
64                        $template->set_var('cc_phpgw_img_dir', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/images');
65
66                        /* Style Sheets */
67                        $template->set_var('cc_css', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/styles/cc_api.css');
68                        $template->set_var('cc_dtree_css', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/js/dftree/dftree.css');
69
70                        /* JS Files */
71                        $template->set_var('cc_js_aux', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/ccAux.js');
72                        $template->set_var('cc_js_connector', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/connector.js');
73                        $template->set_var('cc_js_wz_dragdrop', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/js/wz_dragdrop/wz_dragdrop.js');
74                        $template->set_var('cc_js_dtree', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/js/dftree/dftree.js');
75                        $template->set_var('cc_js_dtabs', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/js/dTabs/dTabs.js');
76                        $template->set_var('cc_js_djswin', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/js/dJSWin/dJSWin.js');
77                        $template->set_var('cc_js_catalog_tree', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/cc_tree.js');
78                       
79                        $template->parse('out','api');
80
81                        $this->commons = $template->get_var('out');
82                        $this->commons_loaded = false;
83                }
84               
85                /* DEPRECTED! Use get_email_win() instead */
86                function ui_get_email_win()
87                {
88                        return $this->get_email_win();
89                }
90
91                function get_email_win()
92                {
93                        //$search = $this->ui_get_search_win();
94                       
95                        $template_dir = PHPGW_SERVER_ROOT . '/contactcenter/templates/default/';
96                        $template = CreateObject('phpgwapi.Template', $template_dir);
97
98                        $template->set_file(array('email_win' => 'email_win.tpl'));
99                       
100                        if (!$this->commons_loaded)
101                        {
102                                $template->set_var('cc_api', $this->commons);
103                                $this->commons_loaded = true;
104                        }
105                        else
106                        {
107                                $template->set_var('cc_api', '');
108                        }
109                       
110                        //$template->set_var('cc_search_win', $search);
111                        $template->set_var('cc_js_search', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/cc_search.js');
112                       
113                        $template->set_var('cc_email_id_type', $search);
114                       
115                        $template->set_var('cc_email_win_title',lang('Contact Center').' - '.lang('Catalog Entries Emails'));
116                        $template->set_var('cc_email_status',lang('Status').':');
117                        $template->set_var('cc_email_search_text',lang('Search').'...');
118                       
119                        $template->set_var('cc_choose_catalogue',lang('Choose a catalogue').'...');
120                        $template->set_var('cc_choose_ordinance',lang('Choose a ordinance').'...');
121                       
122                        $template->set_var('cc_btn_to_add',lang('To').' >>');
123                        $template->set_var('cc_btn_to_del','<< '.lang('To'));
124                        $template->set_var('cc_btn_cc_add',lang('Cc').' >>');
125                        $template->set_var('cc_btn_cc_del','<< '.lang('Cc'));
126                        $template->set_var('cc_btn_cco_add',lang('Bcc').' >>');
127                        $template->set_var('cc_btn_cco_del','<< '.lang('Bcc'));
128                        $template->set_var('cc_btn_new',lang('New').'...');
129                        $template->set_var('cc_btn_details',lang('Details').'...');
130                        $template->set_var('cc_btn_update',lang('Update'));
131                        $template->set_var('cc_btn_ok',lang('Ok'));
132                        $template->set_var('cc_btn_cancel',lang('Cancel'));
133                       
134                        $template->set_var('cc_label_to',lang('To').':');
135                        $template->set_var('cc_label_cc',lang('Cc').':');
136                        $template->set_var('cc_label_cco',lang('Bcc').':');
137                        $template->set_var('cc_label_entries',lang('Entries').':');
138                        $template->set_var('cc_label_catalogues',lang('Catalogues').':');
139                        $template->set_var('cc_label_catalogue_type',lang('Type Of Catalogue').':');
140                        $template->set_var('cc_label_ordinance_type',lang('Type Of Ordinace').':');
141                       
142                        $template->set_var('phpgw_img_dir', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/images');
143                       
144                        $template->set_var('cc_js_email_win', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/cc_email_win.js');
145                       
146                        $template->parse('out','email_win');
147
148                        return $template->get_var('out');
149                }
150
151                function ui_get_search_win()
152                {
153                        return $this->get_search_win();
154                }
155
156                function get_search_win()
157                {
158                        $template_dir = PHPGW_SERVER_ROOT . '/contactcenter/templates/default/';
159                        $template = CreateObject('phpgwapi.Template',$template_dir);
160
161                        $template->set_file(array('search' => 'search_win.tpl'));
162                       
163                        if (!$this->commons_loaded)
164                        {
165                                $template->set_var('cc_api', $this->commons);
166                                $this->commons_loaded = true;
167                        }
168                        else
169                        {
170                                $template->set_var('cc_api', '');
171                        }
172                       
173                        $template->set_var('cc_search_title',lang('Contact Center - Search for Catalog Entries'));
174                        $template->set_var('cc_search_minimize',lang('Minimize'));
175                        $template->set_var('cc_search_close',lang('Close'));
176                        $template->set_var('cc_search_catalogues',lang('Catalogues'));
177                        $template->set_var('cc_search_for',lang('Search for...'));
178                        $template->set_var('cc_search_recursive',lang('Recursive Search?'));
179                        $template->set_var('cc_search_go',lang('Go'));
180                        $template->set_var('cc_search_cancel',lang('Cancel'));
181                       
182                        $template->set_var('cc_js_search_win', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/cc_search_win.js');
183                       
184                        $template->set_var('phpgw_img_dir', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/images');
185                       
186                        $template->parse('out','search');
187
188                        return $template->get_var('out');
189                }
190
191                function get_search_obj()
192                {
193                        return "\n".'<script type="text/javascript" src="'.$GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/cc_search.js'.'"></script>'."\n";
194                }
195
196                function ui_get_full_add()
197                {
198                        return $this->get_full_add();
199                }
200
201                function get_full_add()
202                {
203                        $template = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
204
205                        $template->set_file(array('full_add' => 'full_add.tpl'));
206                       
207                        if (!$this->commons_loaded)
208                        {
209                                $template->set_var('cc_api', $this->commons);
210                                $this->commons_loaded = true;
211                        }
212                        else
213                        {
214                                $template->set_var('cc_api', '');
215                        }
216                       
217                        $template->set_var('cc_contact_title',lang('Contact Center').' - '.lang('Contacts'));
218
219                        /* Messages */
220                        $template->set_var('cc_msg_err_empty_field',lang('field is empty'));
221                        $template->set_var('cc_msg_type_state',lang('Type new state here').'...');
222                        $template->set_var('cc_msg_type_city',lang('Type new city here').'...');
223                        /* End Messages */
224                       
225                        /* Contact */
226                        $template->set_var('cc_contact_save',lang('Save'));
227                        $template->set_var('cc_contact_cancel',lang('Cancel'));
228                        $template->set_var('cc_contact_reset',lang('Reset'));
229
230                        $template->set_var('cc_contact_personal',lang('Personal'));
231                        $template->set_var('cc_contact_addrs',lang('Addresses'));
232                        $template->set_var('cc_contact_conns',lang('Connections'));
233                        $template->set_var('emails_telephones', lang("E-Mails and Telephones"));
234
235                        /* End Contact */
236                       
237                        /* Contact - Personal Data */
238                        $dateformat = $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
239               
240                        $j = 0;
241                        for ($i = 0; $i < 5; $i+=2)
242                        {
243                                switch($dateformat{$i})
244                                {
245                                        case 'Y':
246                                                $date[$j]['size'] = 4;
247                                                $date[$j]['name'] = lang('Year');
248                                                break;
249
250                                        case 'm':
251                                        case 'M':
252                                                $date[$j]['size'] = 2;
253                                                $date[$j]['name'] = lang('Month');
254                                                break;
255
256                                        case 'd':
257                                                $date[$j]['size'] = 2;
258                                                $date[$j]['name'] = lang('Day');
259                                }
260                                $j++;
261                        }
262                       
263                        $template->set_var('cc_pd_birth_size_0', "{$date[0]['size']}");
264                        $template->set_var('cc_pd_birth_size_1', "{$date[1]['size']}");
265                        $template->set_var('cc_pd_birth_size_2', "{$date[2]['size']}");
266                       
267                        $template->set_var('cc_pd_birthdate_0', "{$date[0]['name']}");
268                        $template->set_var('cc_pd_birthdate_1', "{$date[1]['name']}");
269                        $template->set_var('cc_pd_birthdate_2', "{$date[2]['name']}");
270
271                        $template->set_var('cc_pd_select_photo_b', lang('Browse').'...');
272                        $template->set_var('cc_form_photo_src', 'photo_form.html');
273                       
274                        $template->set_var('cc_pd_select_photo',lang('Select Photo'));
275                        $template->set_var('cc_pd_alias',lang('Alias'));
276                        $template->set_var('cc_pd_given_names',lang('Given Names'));
277                        $template->set_var('cc_pd_family_names',lang('Family Names'));
278                        $template->set_var('cc_pd_full_name',lang('Full Name'));
279                        $template->set_var('cc_pd_birthdate',lang('Birthdate'));
280                        $template->set_var('cc_pd_gpg_finger_print',lang('GPG Finger Print'));
281                        $template->set_var('cc_pd_suffix',lang('Suffix'));
282                        $template->set_var('cc_pd_choose_suffix',lang('Choose Suffix...'));
283                        $template->set_var('cc_pd_prefix',lang('Prefix'));
284                        $template->set_var('cc_pd_choose_prefix',lang('Choose Prefix...'));
285                        $template->set_var('cc_pd_notes',lang('Notes'));
286                        $template->set_var('cc_pd_sex',lang('Sex'));
287                        $template->set_var('cc_pd_choose_sex',lang('Choose Sex ...'));
288                        $template->set_var('cc_pd_male',lang('Male'));
289                        $template->set_var('cc_pd_female',lang('Female'));
290                        /* End Contact - Personal Data */
291                       
292                        /* Contact - Addresses */
293                        $template->set_var('cc_addr_types',lang('Type of Address'));
294                        $template->set_var('cc_addr_choose_types',lang('Choose Type of Address').'...');
295                        $template->set_var('cc_addr_countries',lang('Country'));
296                        $template->set_var('cc_addr_choose_countries',lang('Choose Country').'...');
297                        $template->set_var('cc_addr_states',lang('State'));
298                        $template->set_var('cc_addr_states_new',lang('New State').'...');
299                        $template->set_var('cc_addr_states_nostate',lang('No State'));
300                        $template->set_var('cc_addr_choose_states',lang('Choose State').'...');
301                        $template->set_var('cc_addr_cities',lang('City'));
302                        $template->set_var('cc_addr_cities_new',lang('New City').'...');
303                        $template->set_var('cc_addr_choose_cities',lang('Choose City').'...');
304                        $template->set_var('cc_addr_1',lang('Address 1'));
305                        $template->set_var('cc_addr_2',lang('Address 2'));
306                        $template->set_var('cc_addr_complement',lang('Complement'));
307                        $template->set_var('cc_addr_other',lang('Address Other'));
308                        $template->set_var('cc_addr_postal_code',lang('Postal Code'));
309                        $template->set_var('cc_addr_po_box',lang('PO Box'));
310                        $template->set_var('cc_addr_is_default',lang('Is Default?'));
311                        $template->set_var('cc_addr_yes',lang('Yes'));
312                        $template->set_var('cc_addr_no',lang('No'));
313                        $template->set_var('cc_available',lang('Available'));
314                        /* End Contact - Addresses */
315                       
316                       
317                        /* Contact - Connections */
318                        $template->set_var('cc_conn_type',lang('Type of Connection'));
319                        $template->set_var('cc_conn_name',lang('Connection Name'));
320                        $template->set_var('cc_conn_value',lang('Connection Value'));
321                       
322                        $template->set_var('cc_new_same_type',lang('New from the same Type').'...');
323                       
324                        $template->set_var('cc_conn_type_none',lang('Choose Type of Connection').'...');
325                        /* End Contact - Connections */
326
327                        $template->set_var('email', lang("E-Mail"));
328                        $template->set_var('telephone', lang("Telephone"));
329                        $template->set_var('choose_email_telephone', lang("Choose 'E-Mail' or 'Telephone'"));
330
331                        $template->parse('out_full', 'full_add');
332
333                        return $template->get_var('out_full');
334                }
335
336                function get_quick_add_plugin()
337                {
338                        $template_dir = PHPGW_SERVER_ROOT . '/contactcenter/templates/default/';
339                        $template = CreateObject('phpgwapi.Template',$template_dir);
340
341                        $template->set_file(array('quickAdd' => 'quickAddPlugin.tpl'));
342                       
343                        if (!$this->commons_loaded)
344                        {
345                                $template->set_var('cc_api', $this->commons);
346                                $this->commons_loaded = true;
347                        }
348                        else
349                        {
350                                $template->set_var('cc_api', '');
351                        }
352                       
353                        $template->set_var('ccQAPluginFile', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/ccQuickAdd-plugin.js');
354
355                        /* Fields Insertion */
356
357                        // TODO: get this from preferences
358                        $nFields = 5;
359                        $fields = array(
360                                lang('Alias'),
361                                lang('Given Names'),
362                                lang('Family Names'),
363                                lang('Phone'),
364                                lang('Email')
365                        );
366                       
367                        $template->set_var('ccQAnFields', $nFields);
368                       
369                        $fieldsHTML = '';
370                        $fieldsTop = 10;
371                        $fieldsSpace = 30;
372                        for ($i = 0; $i < $nFields; $i++)
373                        {
374                                $fieldsHTML .= '<span id="ccQuickAddT'.$i.'" style="position: absolute; top: '.($fieldsTop+$i*$fieldsSpace).'px; left: 5px; width: 100px; text-align: right; border: 0px solid #999;">'.$fields[$i].':</span>'."\n";
375                                $fieldsHTML .= '<input id="ccQuickAddI'.$i.'" type="text" value="" maxlength="50" style="position: absolute; top: '.($fieldsTop+$i*$fieldsSpace).'px; left: 110px; width: 135px;">'."\n";
376                        }
377
378                        $template->set_var('ccQAFields', $fieldsHTML);
379                        $template->set_var('ccQAWinHeight', ($i+1)*$fieldsSpace+$fieldsTop);
380                        $template->set_var('ccQAFunctionsTop', ($fieldsTop+$i*$fieldsSpace).'px');
381                       
382                        /* Images Dir */
383                        $template->set_var('ccQACardImgRoot', $GLOBALS['phpgw_info']['server']['webserver_url'].'/contactcenter/templates/default/images/');
384                       
385                        /* Texts */
386                        $template->set_var('ccQATitle', lang('Contact Center').' - '.lang('Quick Add'));
387                        $template->set_var('ccQASave', lang('Save'));
388                        $template->set_var('ccQAClear', lang('Reset'));
389                        $template->set_var('ccQACancel', lang('Cancel'));
390                       
391                        $template->parse('out_QA', 'quickAdd');
392
393                        return $template->get_var('out_QA');
394                }
395               
396                function get_add_group()
397                {
398                        $template_dir = PHPGW_SERVER_ROOT . '/contactcenter/templates/default/';
399                        $template = CreateObject('phpgwapi.Template',$template_dir);
400
401                        $template->set_file(array('addGroup' => 'addGroup.tpl'));
402                       
403                        if (!$this->commons_loaded)
404                        {
405                                $template->set_var('cc_api', $this->commons);
406                                $this->commons_loaded = true;
407                        }
408                        else
409                        {
410                               
411                                $template->set_var('cc_api', '');
412                        }
413                       
414                        $template->set_var('ccAGFile', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/contactcenter/js/ccAddGroup.js');                 
415                        $template->set_var('ccAGWinHeightIE', '285');                   
416                        $template->set_var('ccAGWinHeightMO', '335');
417                       
418                        /* Images Dir */
419                        $template->set_var('ccAGCardImgRoot', $GLOBALS['phpgw_info']['server']['webserver_url'].'/contactcenter/templates/default/images/');
420                       
421                        /* Texts */
422                        $template->set_var('ccAGTitle', lang('Contact Center').' - '.lang('Group Add'));
423                        $template->set_var('ccAGSave', lang('Save'));
424                        $template->set_var('ccAGClear', lang('Reset'));
425                        $template->set_var('ccAGCancel', lang('Cancel'));
426                        $title = '<input type="text" id="title" name="title" value="'.$group['title'].'" size="50" maxlength="50"/>';                   
427                               
428                        $template->set_var('title', $title);                                                                                           
429                        // set content and label variables.
430                        $template->set_var(array(
431                                                'msg_text'      => lang($status),                                               
432                                                'txt_title'     => lang('Contact Group List'),                                         
433                                                'txt_cancel'=> lang('cancel'),
434                                                'txt_add'=> lang('Add'),                                               
435                                                'txt_rem'=> lang('Remove'),
436                                                'txt_personal_contacts' => lang('Personal Contacts'),
437                                                'txt_contacts_in_list' => lang("Participants"),
438                                                'txt_name'      => lang('Full Name')));
439                                               
440                        $template->parse('out_AG', 'addGroup');
441                       
442                        return $template->get_var('out_AG');
443                }
444        }
445?>
Note: See TracBrowser for help on using the repository browser.