source: branches/2.2/mobile/inc/class.mobiletemplate.inc.php @ 3727

Revision 3727, 5.8 KB checked in by eduardoalex, 13 years ago (diff)

Ticket #1523 - Alterando estrutura do mobile para disponibilizar a versão desktop

  • 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               
7                /*
8                * @function mobiletemplate
9                * @abstract Construtor da classe, que monta o template home
10                * @author Nilton Emilio Buhrer Neto <niltonneto@celepar.pr.gov.br>
11                */             
12                function mobiletemplate(){
13                        $this->template = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']);
14                       
15                        $template = $GLOBALS['phpgw']->session->appsession('mobile.layout','mobile');
16                       
17                        $this->template->set_file(Array('home_t' => $template=="mini"?'pc_template.tpl':'template.tpl'));       
18                        $this->template->set_block('home_t', 'mobile_home');   
19                        $this->template->set_block('home_t','success_message');
20                        $this->template->set_block('home_t','error_message');           
21                }
22
23                /*
24                * @function set_content
25                * @abstract Carrega o atributo "content" do template principal
26                * @author Nilton Emilio Buhrer Neto <niltonneto@celepar.pr.gov.br>
27                */             
28                public function set_content($content){
29                        $pre_content = $this->template->get_var("content");
30                        $this->template->set_var("content", $pre_content.$content);
31                }
32               
33                /*
34                * @function set_home
35                * @abstract Carrega o atributo "home" do template principal para PC.
36                * @author Diógenes Ribeiro Duarte <diogenes.duarte@prodeb.ba.gov.br>
37                */     
38                public function set_home($content) {
39                        $pre_content = $this->template->get_var("home");
40                        $this->template->set_var("home", $pre_content.$content);
41                }
42               
43                /*
44                * @function set_msg
45                * @abstract Seta a mensagem de sucesso ou error a depender do tipo.
46                * @author Thiago Antonius
47                */             
48                public function set_msg($msg, $type){
49                        if(isset($msg) && trim($msg)!="") {
50                                $this->template->set_var("message", $msg);
51                                $this->template->parse("message_box", $type."_message", true);
52                        }
53                }               
54               
55                /*
56                * @function set_success_msg
57                * @abstract Seta a mensagem de sucesso.
58                * @author Thiago Antonius
59                */             
60                public function set_success_msg($msg){
61                        $this->set_msg($msg, "success");
62                }
63
64                        /*
65                * @function set_error_msg
66                * @abstract Seta a mensagem de erro
67                * @author Thiago Antonius
68                */             
69                public function set_error_msg($msg){
70                        $this->set_msg($msg, "error");
71                }               
72
73                /*
74                * @function print_all
75                * @abstract Imprime toda tela do Expresso Mini
76                * @author Nilton Emilio Buhrer Neto <niltonneto@celepar.pr.gov.br>
77                */
78                public function print_page($class, $method){
79                        $this->print_header();
80                        $this->init_mobile();
81                        $class=='ui_home' && $method=='index'?$this->print_logout():$this->print_navbar();
82                        $filename = 'inc/class.'.$class.'.inc.php';
83                        if($GLOBALS['phpgw']->session->appsession('mobile.layout','mobile')=="mini") {
84                                $ui_home = CreateObject('mobile.ui_home');
85                                $ui_home->index(array());
86                        }
87                        include_once($filename);
88                        $obj = new $class();           
89                        $obj -> $method($_REQUEST);
90                        $this->template->pfp('out', 'mobile_home');
91                }
92               
93                public function init_mobile() {
94                        $ui_mobilemail = CreateObject('mobile.ui_mobilemail');
95                        $obj = createobject("expressoMail1_2.functions");
96      // setting timezone preference
97      $zones = $obj->getTimezones();
98      $_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));                   
99                }
100               
101                /*
102                * @function print_logout
103                * @abstract Exibe label e link para Logout
104                * @author Diego Moreno
105                */
106                public function print_logout(){
107                        $this-> template->set_var('lang_logout', lang('logout'));
108                        $this-> template->set_var('href_logout', 'login.php?cd=1');
109                }
110               
111                /*
112                * @function print_navbar
113                * @abstract Imprime o início da tela do Expresso Mini => barra de navegação
114                * @author Mário César Kolling <mario.kolling@serpro.gov.br>
115                */
116                private function print_navbar(){
117                        $this-> print_logout();                 
118                        $this-> template->set_var('lang_back', lang('Back'));
119                        $this-> template->set_var('lang_home', lang('home'));
120                        $this-> template->set_var('lang_email', lang('E-mail'));
121                        $this-> template->set_var('lang_contacts', lang('Contact Center'));
122                        $this-> template->set_var('lang_calendar', lang('Calendar'));
123                        $this-> template->set_var('href_back', 'javascript:history.back()');
124                        $this-> template->set_var('href_cc', 'index.php?menuaction=mobile.ui_mobilecc.init_cc');
125                        $this-> template->set_var('href_email', "index.php?menuaction=mobile.ui_mobilemail.change_folder&folder=0");
126                        $this-> template->set_var('href_calendar', "index.php?menuaction=mobile.ui_mobilecalendar.index");
127                        $this-> template->set_var('href_home', "index.php?menuaction=mobile.ui_home.index");
128                }
129
130                /*
131                * @function print_header
132                * @abstract Imprime o início da tela do Expresso Mini => headers html
133                * @author Mário César Kolling <mario.kolling@serpro.gov.br>
134                */             
135                private function print_header(){
136                        $GLOBALS['phpgw']->accounts->read_repository();
137                        $var  = Array(
138                                'css'   => $this->get_mobile_css(),
139                                'title' => lang("expresso mini")
140                        );             
141                        $this->template->set_var($var);         
142                }
143
144
145                public function get_mobile_css() {
146                        $css = "/mobile/templates/%s.css";
147
148                        global $path, $link;
149
150                        $path = PHPGW_SERVER_ROOT . str_replace( '/', SEP, $css );
151
152                        $link = '<LINK href="%s" type="text/css" rel="StyleSheet">';
153                        $link = sprintf( $link,
154                                "{$GLOBALS[ 'phpgw_info' ][ 'server' ][ 'webserver_url' ]}{$css}"
155                        );
156
157                        function _css( $css )
158                        {
159                                global $link, $path;
160
161                                if ( file_exists( sprintf( $path, str_replace( '/', SEP, $css ) ) ) )
162                                        return sprintf( $link, $css );
163
164                                return '';
165                        }
166
167                        $css = _css( 'css/mobile' );
168                        $css .= _css( $GLOBALS['phpgw_info']['server']['template_set'].'/css/base');
169                        $css .= _css( $GLOBALS['phpgw_info']['server']['template_set'].'/css/'.$GLOBALS['phpgw_info']['user']['preferences']['common']['theme']);
170
171                        return ( $css );
172
173                }
174
175        }
176?>
Note: See TracBrowser for help on using the repository browser.