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

Revision 3690, 5.2 KB checked in by eduardoalex, 13 years ago (diff)

Ticket #1404 - Corrigido o layout da tela home do expresso mini

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