[623] | 1 | <?php |
---|
[3554] | 2 | //include_once(PHPGW_INCLUDE_ROOT.'/mobile/inc/class.ui_mobile.inc.php'); |
---|
[623] | 3 | class mobiletemplate |
---|
| 4 | { |
---|
| 5 | private $template; |
---|
[3829] | 6 | private $href_back; |
---|
[623] | 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']); |
---|
[3727] | 15 | |
---|
| 16 | $template = $GLOBALS['phpgw']->session->appsession('mobile.layout','mobile'); |
---|
| 17 | |
---|
[3731] | 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")); |
---|
[3734] | 25 | $this->template->set_var('lang_search_error_message_four_digits',lang("search word need not be empty and has more then four char")); |
---|
[3731] | 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'); |
---|
[3571] | 34 | $this->template->set_block('home_t','success_message'); |
---|
[3731] | 35 | $this->template->set_block('home_t','error_message'); |
---|
[623] | 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 | } |
---|
[3571] | 47 | |
---|
| 48 | /* |
---|
[3727] | 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 | /* |
---|
[3571] | 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 | } |
---|
[3731] | 68 | } |
---|
[3571] | 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 | } |
---|
[623] | 78 | |
---|
[3571] | 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 | |
---|
[623] | 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 | */ |
---|
[3571] | 93 | public function print_page($class, $method){ |
---|
[623] | 94 | $this->print_header(); |
---|
[3690] | 95 | $this->init_mobile(); |
---|
[3731] | 96 | if(!($class == 'ui_home' && $method == 'index')) $this->print_navbar(); |
---|
[623] | 97 | $filename = 'inc/class.'.$class.'.inc.php'; |
---|
[3571] | 98 | include_once($filename); |
---|
[623] | 99 | $obj = new $class(); |
---|
[3554] | 100 | $obj -> $method($_REQUEST); |
---|
[3731] | 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 | |
---|
[623] | 107 | $this->template->pfp('out', 'mobile_home'); |
---|
| 108 | } |
---|
[3652] | 109 | |
---|
[3690] | 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(); |
---|
[3731] | 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'); |
---|
[3690] | 122 | } |
---|
| 123 | |
---|
[623] | 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(){ |
---|
[3731] | 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"); |
---|
[623] | 139 | } |
---|
| 140 | |
---|
[3829] | 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 | |
---|
[3867] | 167 | $GLOBALS['phpgw']->session->appsession('mobile.last_url','mobile',$_SERVER["SCRIPT_NAME"]); |
---|
[3829] | 168 | $GLOBALS['phpgw']->session->appsession('mobile.last_request','mobile',$_REQUEST); |
---|
| 169 | } |
---|
| 170 | |
---|
| 171 | function get_back_link(){ |
---|
| 172 | return $this->href_back; |
---|
| 173 | } |
---|
| 174 | |
---|
[623] | 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(); |
---|
[3731] | 182 | $var = Array('title' => lang("expresso mini")); |
---|
| 183 | $this->template->set_var($var); |
---|
[3829] | 184 | $this->process_back_link(); |
---|
[3484] | 185 | } |
---|
| 186 | |
---|
[623] | 187 | } |
---|
[1474] | 188 | ?> |
---|