[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){ |
---|
[3996] | 94 | if($GLOBALS['phpgw']->session->appsession('mobile.layout','mobile') == "mini_desktop") { |
---|
| 95 | //force to don' t call ui_home.index in a mini desktop version |
---|
| 96 | if($class == "ui_home" && $method == "index") { |
---|
| 97 | $class = "ui_mobilemail"; |
---|
| 98 | $method = "change_folder"; |
---|
| 99 | $_REQUEST["folder"] = 0; |
---|
| 100 | } |
---|
| 101 | } |
---|
| 102 | |
---|
| 103 | //need be called before invoke the action |
---|
[623] | 104 | $this->print_header(); |
---|
[3690] | 105 | $this->init_mobile(); |
---|
[3996] | 106 | |
---|
[3731] | 107 | if(!($class == 'ui_home' && $method == 'index')) $this->print_navbar(); |
---|
[623] | 108 | $filename = 'inc/class.'.$class.'.inc.php'; |
---|
[3571] | 109 | include_once($filename); |
---|
[3996] | 110 | $obj = new $class(); |
---|
| 111 | $obj->$method($_REQUEST); |
---|
| 112 | |
---|
[3731] | 113 | if($GLOBALS['phpgw']->session->appsession('mobile.layout','mobile') == "mini_desktop") { |
---|
| 114 | $ui_home = CreateObject('mobile.ui_home'); |
---|
| 115 | $ui_home->index($_REQUEST); |
---|
| 116 | } |
---|
| 117 | |
---|
[623] | 118 | $this->template->pfp('out', 'mobile_home'); |
---|
| 119 | } |
---|
[3996] | 120 | |
---|
[3690] | 121 | public function init_mobile() { |
---|
| 122 | $ui_mobilemail = CreateObject('mobile.ui_mobilemail'); |
---|
| 123 | $obj = createobject("expressoMail1_2.functions"); |
---|
| 124 | // setting timezone preference |
---|
| 125 | $zones = $obj->getTimezones(); |
---|
[3731] | 126 | $_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)); |
---|
| 127 | |
---|
| 128 | $this->template->set_var('global_title', lang('expresso mini')); |
---|
| 129 | $this->template->set_var('lang_logout', lang('logout')); |
---|
| 130 | $this->template->set_var('lang_search', lang('search')); |
---|
| 131 | |
---|
| 132 | $this->template->set_var('href_logout', 'login.php?cd=1'); |
---|
[3690] | 133 | } |
---|
| 134 | |
---|
[623] | 135 | /* |
---|
| 136 | * @function print_navbar |
---|
| 137 | * @abstract Imprime o início da tela do Expresso Mini => barra de navegação |
---|
| 138 | * @author Mário César Kolling <mario.kolling@serpro.gov.br> |
---|
| 139 | */ |
---|
| 140 | private function print_navbar(){ |
---|
[3731] | 141 | $this->template->set_var('lang_back', lang('Back')); |
---|
| 142 | $this->template->set_var('lang_home', lang('home')); |
---|
| 143 | $this->template->set_var('lang_email', lang('E-mail')); |
---|
| 144 | $this->template->set_var('lang_contacts', lang('Contact Center')); |
---|
| 145 | $this->template->set_var('lang_calendar', lang('Calendar')); |
---|
| 146 | $this->template->set_var('href_cc', 'index.php?menuaction=mobile.ui_mobilecc.init_cc'); |
---|
| 147 | $this->template->set_var('href_email', "index.php?menuaction=mobile.ui_mobilemail.change_folder&folder=0"); |
---|
| 148 | $this->template->set_var('href_calendar', "index.php?menuaction=mobile.ui_mobilecalendar.index"); |
---|
| 149 | $this->template->set_var('href_home', "index.php?menuaction=mobile.ui_home.index"); |
---|
[623] | 150 | } |
---|
| 151 | |
---|
[3829] | 152 | private function process_back_link() { |
---|
[3987] | 153 | $trace = $GLOBALS['phpgw']->session->appsession('mobile.trace_urls','mobile'); |
---|
[3829] | 154 | |
---|
[3987] | 155 | $trace_idx = 0; |
---|
[3829] | 156 | |
---|
[3987] | 157 | if($trace) { |
---|
| 158 | $trace_idx = sizeof($trace)-1; |
---|
[3829] | 159 | |
---|
[3987] | 160 | if($_REQUEST["is_back_link"]) |
---|
| 161 | $trace_idx = $trace_idx - 2; |
---|
[3829] | 162 | |
---|
[3987] | 163 | if($trace_idx < 0) $trace_idx = 0; |
---|
| 164 | |
---|
| 165 | $url = $trace[$trace_idx]["url"]; |
---|
| 166 | $params = $trace[$trace_idx]["request"]; |
---|
| 167 | |
---|
| 168 | $this->href_back = $this->build_url($url, $params); |
---|
[3829] | 169 | } else { |
---|
[3987] | 170 | $trace = array(); |
---|
| 171 | $this->href_back = ''; |
---|
[3829] | 172 | } |
---|
[3987] | 173 | |
---|
| 174 | if(!$_REQUEST["is_back_link"]) { |
---|
| 175 | $current_url = $_SERVER["SCRIPT_NAME"]; |
---|
| 176 | $current_params = $_REQUEST; |
---|
[3829] | 177 | |
---|
[3987] | 178 | unset($current_params['sessionid']); |
---|
| 179 | unset($current_params['domain']); |
---|
| 180 | unset($current_params['last_loginid']); |
---|
| 181 | unset($current_params['last_domain']); |
---|
| 182 | unset($current_params['kp3']); |
---|
| 183 | unset($current_params['showHeader']); |
---|
| 184 | |
---|
| 185 | $built_current_url = $this->build_url($current_url, $current_params); |
---|
[4046] | 186 | |
---|
| 187 | if( (preg_match('/menuaction/i',$built_current_url) |
---|
| 188 | && !preg_match('/mobile\.ui_mobilemail\.(send_mail|save_draft|delete_msg)/i',$built_current_url) ) |
---|
| 189 | && !$current_params["ignore_trace_url"] ) { |
---|
[3987] | 190 | |
---|
[4046] | 191 | //se der reload não vai gravar a url e vai sobreescrever o link do botão voltar para não voltar para a mesma página |
---|
| 192 | if(str_replace("&is_back_link=true","",$built_current_url) != str_replace("&is_back_link=true","",$this->href_back)) |
---|
| 193 | $trace[sizeof($trace)] = array("url" => $current_url, "request" => $current_params); |
---|
| 194 | else { |
---|
| 195 | if($trace_idx >= 1) $trace_idx--; |
---|
| 196 | $this->href_back = $this->build_url($trace[$trace_idx]["url"], $trace[$trace_idx]["request"]); |
---|
| 197 | } |
---|
[3987] | 198 | } |
---|
| 199 | } else { |
---|
| 200 | if(sizeof($trace) > 1) |
---|
| 201 | unset($trace[sizeof($trace)-1]); |
---|
| 202 | } |
---|
| 203 | |
---|
| 204 | if(sizeof($trace) > 0) |
---|
| 205 | $GLOBALS['phpgw']->session->appsession('mobile.trace_urls','mobile',$trace); |
---|
| 206 | else |
---|
| 207 | $GLOBALS['phpgw']->session->appsession('mobile.trace_urls','mobile',null); |
---|
| 208 | |
---|
| 209 | $this->template->set_var('href_back', $this->href_back); |
---|
[3829] | 210 | } |
---|
[3987] | 211 | |
---|
| 212 | private function build_url($url, $params) { |
---|
| 213 | $query_string = ""; |
---|
| 214 | |
---|
| 215 | foreach ($params as $key => $value) { |
---|
| 216 | $query_string .= "&".$key."=".$value; |
---|
| 217 | } |
---|
[3829] | 218 | |
---|
[3987] | 219 | if($query_string != "") |
---|
| 220 | $url .= "?".substr($query_string,1); |
---|
| 221 | |
---|
| 222 | if(!$params["is_back_link"]) |
---|
| 223 | $url .= "&is_back_link=true"; |
---|
| 224 | |
---|
| 225 | return $url; |
---|
| 226 | } |
---|
| 227 | |
---|
[3829] | 228 | function get_back_link(){ |
---|
| 229 | return $this->href_back; |
---|
| 230 | } |
---|
| 231 | |
---|
[623] | 232 | /* |
---|
| 233 | * @function print_header |
---|
| 234 | * @abstract Imprime o início da tela do Expresso Mini => headers html |
---|
| 235 | * @author Mário César Kolling <mario.kolling@serpro.gov.br> |
---|
| 236 | */ |
---|
| 237 | private function print_header(){ |
---|
| 238 | $GLOBALS['phpgw']->accounts->read_repository(); |
---|
[3731] | 239 | $var = Array('title' => lang("expresso mini")); |
---|
| 240 | $this->template->set_var($var); |
---|
[3829] | 241 | $this->process_back_link(); |
---|
[3484] | 242 | } |
---|
| 243 | |
---|
[623] | 244 | } |
---|
[1474] | 245 | ?> |
---|