source: branches/2.2.0.1/mobile/inc/class.mobiletemplate.inc.php @ 3867

Revision 3867, 6.5 KB checked in by niltonneto, 13 years ago (diff)

Ticket #1653 - Alterado de SCRIPT_URL para SCRIPT_NAME, por não ser variável padrão.

  • Property svn:executable set to *
Line 
1<?php
2//include_once(PHPGW_INCLUDE_ROOT.'/mobile/inc/class.ui_mobile.inc.php');
3        class mobiletemplate
4        {
5                private $template;
6                private $href_back;
7               
8                /*
9                * @function mobiletemplate
10                * @abstract Construtor da classe, que monta o template home
11                * @author Nilton Emilio Buhrer Neto <niltonneto@celepar.pr.gov.br>
12                */             
13                function mobiletemplate(){
14                        $this->template = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']);
15                       
16                        $template = $GLOBALS['phpgw']->session->appsession('mobile.layout','mobile');
17                       
18                        if($template == "mini_desktop") {
19                                $this->template->set_file(array('home_t' => 'pc_template.tpl'));
20                                $this->template->set_file(array('home_t_search_bar' => 'search_bar.tpl'));
21                                $this->template->set_block('home_t_search_bar','search_bar');
22                                $this->template->set_var('search',$this->template->fp('out','search_bar'));
23                                $this->template->set_var('lang_mini_mobile', lang('mini mobile'));
24                                $this->template->set_var('lang_search_error_message',lang("need choose one option"));
25                                $this->template->set_var('lang_search_error_message_four_digits',lang("search word need not be empty and has more then four char"));
26                        }       else {
27                                $this->template->set_file(array('home_t' => 'template.tpl'));
28                                $this->template->set_var('lang_mini_desktop', lang('mini desktop'));
29                        }
30                       
31
32                       
33                        $this->template->set_block('home_t', 'mobile_home');
34                        $this->template->set_block('home_t','success_message');
35                        $this->template->set_block('home_t','error_message');
36                }
37
38                /*
39                * @function set_content
40                * @abstract Carrega o atributo "content" do template principal
41                * @author Nilton Emilio Buhrer Neto <niltonneto@celepar.pr.gov.br>
42                */             
43                public function set_content($content){
44                        $pre_content = $this->template->get_var("content");
45                        $this->template->set_var("content", $pre_content.$content);
46                }
47               
48                /*
49                * @function set_home
50                * @abstract Carrega o atributo "home" do template principal para PC.
51                * @author Diógenes Ribeiro Duarte <diogenes.duarte@prodeb.ba.gov.br>
52                */     
53                public function set_home($content) {
54                        $pre_content = $this->template->get_var("home");
55                        $this->template->set_var("home", $pre_content.$content);
56                }
57               
58                /*
59                * @function set_msg
60                * @abstract Seta a mensagem de sucesso ou error a depender do tipo.
61                * @author Thiago Antonius
62                */             
63                public function set_msg($msg, $type){
64                        if(isset($msg) && trim($msg)!="") {
65                                $this->template->set_var("message", $msg);
66                                $this->template->parse("message_box", $type."_message", true);
67                        }
68                }
69               
70                /*
71                * @function set_success_msg
72                * @abstract Seta a mensagem de sucesso.
73                * @author Thiago Antonius
74                */             
75                public function set_success_msg($msg){
76                        $this->set_msg($msg, "success");
77                }
78
79                        /*
80                * @function set_error_msg
81                * @abstract Seta a mensagem de erro
82                * @author Thiago Antonius
83                */             
84                public function set_error_msg($msg){
85                        $this->set_msg($msg, "error");
86                }               
87
88                /*
89                * @function print_all
90                * @abstract Imprime toda tela do Expresso Mini
91                * @author Nilton Emilio Buhrer Neto <niltonneto@celepar.pr.gov.br>
92                */
93                public function print_page($class, $method){
94                        $this->print_header();
95                        $this->init_mobile();
96                        if(!($class == 'ui_home' && $method == 'index')) $this->print_navbar();
97                        $filename = 'inc/class.'.$class.'.inc.php';
98                        include_once($filename);
99                        $obj = new $class();           
100                        $obj -> $method($_REQUEST);
101                       
102                        if($GLOBALS['phpgw']->session->appsession('mobile.layout','mobile') == "mini_desktop") {
103                                $ui_home = CreateObject('mobile.ui_home');
104                                $ui_home->index($_REQUEST);
105                        }
106                       
107                        $this->template->pfp('out', 'mobile_home');
108                }
109               
110                public function init_mobile() {
111                        $ui_mobilemail = CreateObject('mobile.ui_mobilemail');
112                        $obj = createobject("expressoMail1_2.functions");
113      // setting timezone preference
114      $zones = $obj->getTimezones();
115      $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['timezone'] = $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['timezone'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['timezone'] : sprintf("%s", array_search("America/Sao_Paulo", $zones));
116                       
117                        $this->template->set_var('global_title', lang('expresso mini'));
118                        $this->template->set_var('lang_logout', lang('logout'));
119                        $this->template->set_var('lang_search', lang('search'));
120                       
121                        $this->template->set_var('href_logout', 'login.php?cd=1');
122                }
123               
124                /*
125                * @function print_navbar
126                * @abstract Imprime o início da tela do Expresso Mini => barra de navegação
127                * @author Mário César Kolling <mario.kolling@serpro.gov.br>
128                */
129                private function print_navbar(){
130                        $this->template->set_var('lang_back', lang('Back'));
131                        $this->template->set_var('lang_home', lang('home'));
132                        $this->template->set_var('lang_email', lang('E-mail'));
133                        $this->template->set_var('lang_contacts', lang('Contact Center'));
134                        $this->template->set_var('lang_calendar', lang('Calendar'));
135                        $this->template->set_var('href_cc', 'index.php?menuaction=mobile.ui_mobilecc.init_cc');
136                        $this->template->set_var('href_email', "index.php?menuaction=mobile.ui_mobilemail.change_folder&folder=0");
137                        $this->template->set_var('href_calendar', "index.php?menuaction=mobile.ui_mobilecalendar.index");
138                        $this->template->set_var('href_home', "index.php?menuaction=mobile.ui_home.index");
139                }
140
141                private function process_back_link() {
142                        $url = $GLOBALS['phpgw']->session->appsession('mobile.last_url','mobile');
143
144                        if($url) {
145                                $params = $GLOBALS['phpgw']->session->appsession('mobile.last_request','mobile');
146
147                                $query_string = "";
148                                unset($params['sessionid']);
149                                unset($params['domain']);
150                                unset($params['last_loginid']);
151                                unset($params['last_domain']);
152                                unset($params['kp3']);
153                                unset($params['showHeader']);
154                               
155                                foreach ($params as $key => $value) {
156                                        $query_string .= "&".$key."=".$value;
157                                }
158
159                                if($query_string != "")
160                                        $url .= "?".substr($query_string,1);
161
162                                $this->href_back = $url;
163                        } else {
164                                $this->href_back = 'javascript:history.back()';
165                        }
166
167                        $GLOBALS['phpgw']->session->appsession('mobile.last_url','mobile',$_SERVER["SCRIPT_NAME"]);
168                        $GLOBALS['phpgw']->session->appsession('mobile.last_request','mobile',$_REQUEST);
169                }
170
171                function get_back_link(){
172                        return $this->href_back;
173                }
174
175                /*
176                * @function print_header
177                * @abstract Imprime o início da tela do Expresso Mini => headers html
178                * @author Mário César Kolling <mario.kolling@serpro.gov.br>
179                */             
180                private function print_header(){
181                        $GLOBALS['phpgw']->accounts->read_repository();
182                        $var  = Array('title' => lang("expresso mini"));
183                        $this->template->set_var($var);
184                        $this->process_back_link();
185                }
186
187        }
188?>
Note: See TracBrowser for help on using the repository browser.