[4277] | 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 | { |
---|
| 15 | $this->template = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']); |
---|
| 16 | |
---|
| 17 | $template = $GLOBALS['phpgw']->session->appsession('mobile.layout','mobile'); |
---|
| 18 | |
---|
| 19 | if( $template == "mini_desktop" ) |
---|
| 20 | { |
---|
[5043] | 21 | $url_expresso = $this->getUrlExpresso() . "index.php"; |
---|
| 22 | |
---|
[4277] | 23 | $this->template->set_file(array('home_t' => 'pc_template.tpl')); |
---|
| 24 | $this->template->set_file(array('home_t_search_bar' => 'search_bar.tpl')); |
---|
| 25 | $this->template->set_block('home_t_search_bar','search_bar'); |
---|
| 26 | $this->template->set_var('search',$this->template->fp('out','search_bar')); |
---|
[5043] | 27 | $this->template->set_var('url_expresso',$url_expresso); |
---|
[4277] | 28 | $this->template->set_var('lang_mini_mobile', lang('mini mobile')); |
---|
| 29 | $this->template->set_var('lang_search_error_message',lang("need choose one option")); |
---|
| 30 | $this->template->set_var('lang_search_error_message_four_digits',lang("search word need not be empty and has more then four char")); |
---|
| 31 | } |
---|
| 32 | else |
---|
| 33 | { |
---|
| 34 | $this->template->set_file(array('home_t' => 'template.tpl')); |
---|
| 35 | $this->template->set_var('lang_mini_desktop', lang('mini desktop')); |
---|
| 36 | |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | $this->template->set_block('home_t', 'mobile_home'); |
---|
| 40 | $this->template->set_block('home_t','success_message'); |
---|
| 41 | $this->template->set_block('home_t','error_message'); |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | /* |
---|
| 45 | * @function set_content |
---|
| 46 | * @abstract Carrega o atributo "content" do template principal |
---|
| 47 | * @author Nilton Emilio Buhrer Neto <niltonneto@celepar.pr.gov.br> |
---|
| 48 | */ |
---|
| 49 | public function set_content($content){ |
---|
| 50 | $pre_content = $this->template->get_var("content"); |
---|
| 51 | $this->template->set_var("content", $pre_content.$content); |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | /* |
---|
| 55 | * @function set_home |
---|
| 56 | * @abstract Carrega o atributo "home" do template principal para PC. |
---|
| 57 | * @author Diógenes Ribeiro Duarte <diogenes.duarte@prodeb.ba.gov.br> |
---|
| 58 | */ |
---|
| 59 | public function set_home($content) { |
---|
| 60 | $pre_content = $this->template->get_var("home"); |
---|
| 61 | $this->template->set_var("home", $pre_content.$content); |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | /* |
---|
| 65 | * @function set_msg |
---|
| 66 | * @abstract Seta a mensagem de sucesso ou error a depender do tipo. |
---|
| 67 | * @author Thiago Antonius |
---|
| 68 | */ |
---|
| 69 | public function set_msg($msg, $type){ |
---|
| 70 | if(isset($msg) && trim($msg)!="") { |
---|
| 71 | $this->template->set_var("message", $msg); |
---|
| 72 | $this->template->parse("message_box", $type."_message", true); |
---|
| 73 | } |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | /* |
---|
| 77 | * @function set_success_msg |
---|
| 78 | * @abstract Seta a mensagem de sucesso. |
---|
| 79 | * @author Thiago Antonius |
---|
| 80 | */ |
---|
| 81 | public function set_success_msg($msg){ |
---|
| 82 | $this->set_msg($msg, "success"); |
---|
| 83 | } |
---|
| 84 | |
---|
| 85 | /* |
---|
| 86 | * @function set_error_msg |
---|
| 87 | * @abstract Seta a mensagem de erro |
---|
| 88 | * @author Thiago Antonius |
---|
| 89 | */ |
---|
| 90 | public function set_error_msg($msg){ |
---|
| 91 | $this->set_msg($msg, "error"); |
---|
| 92 | } |
---|
| 93 | |
---|
| 94 | /* |
---|
| 95 | * @function print_all |
---|
| 96 | * @abstract Imprime toda tela do Expresso Mini |
---|
| 97 | * @author Nilton Emilio Buhrer Neto <niltonneto@celepar.pr.gov.br> |
---|
| 98 | */ |
---|
| 99 | public function print_page($class, $method ) |
---|
| 100 | { |
---|
| 101 | if( $GLOBALS['phpgw']->session->appsession('mobile.layout','mobile') == "mini_desktop" ) |
---|
| 102 | { |
---|
| 103 | //force to don' t call ui_home.index in a mini desktop version |
---|
| 104 | if($class == "ui_home" && $method == "index") { |
---|
| 105 | $class = "ui_mobilemail"; |
---|
| 106 | $method = "change_folder"; |
---|
| 107 | $_REQUEST["folder"] = 0; |
---|
| 108 | } |
---|
| 109 | } |
---|
| 110 | |
---|
| 111 | //need be called before invoke the action |
---|
| 112 | $this->print_header(); |
---|
| 113 | $this->init_mobile(); |
---|
| 114 | |
---|
| 115 | if(!($class == 'ui_home' && $method == 'index')) $this->print_navbar(); |
---|
| 116 | $filename = 'inc/class.'.$class.'.inc.php'; |
---|
| 117 | include_once($filename); |
---|
| 118 | $obj = new $class(); |
---|
| 119 | $obj->$method($_REQUEST); |
---|
| 120 | |
---|
| 121 | if($GLOBALS['phpgw']->session->appsession('mobile.layout','mobile') == "mini_desktop") { |
---|
| 122 | $ui_home = CreateObject('mobile.ui_home'); |
---|
| 123 | $ui_home->index($_REQUEST); |
---|
| 124 | } |
---|
| 125 | |
---|
| 126 | $this->template->pfp('out', 'mobile_home'); |
---|
| 127 | } |
---|
| 128 | |
---|
| 129 | public function init_mobile() |
---|
| 130 | { |
---|
| 131 | $ui_mobilemail = CreateObject('mobile.ui_mobilemail'); |
---|
| 132 | $obj = createobject("expressoMail1_2.functions"); |
---|
| 133 | // setting timezone preference |
---|
| 134 | $zones = $obj->getTimezones(); |
---|
| 135 | $_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)); |
---|
| 136 | |
---|
| 137 | $this->template->set_var('global_title', lang('expresso mini')); |
---|
[5043] | 138 | $this->template->set_var('style_1','position:absolute; float: left;'); |
---|
| 139 | $this->template->set_var('style_2','position:relative; float: right; display: block'); |
---|
| 140 | $this->template->set_var('lang_tips', lang('Tips')); |
---|
| 141 | $this->template->set_var('lang_logout', lang('logout')); |
---|
| 142 | $this->template->set_var('lang_search', lang('search')); |
---|
| 143 | |
---|
| 144 | if( isset($_SESSION['mobile']['displayIOS']) && $_SESSION['mobile']['displayIOS'] == "true" ) |
---|
[4277] | 145 | { |
---|
[5043] | 146 | $this->template->set_var('display_IOS', "none"); |
---|
[4277] | 147 | } |
---|
| 148 | else |
---|
| 149 | { |
---|
[5043] | 150 | $this->template->set_var('display_IOS', "block"); |
---|
[4277] | 151 | } |
---|
| 152 | |
---|
[5043] | 153 | if( isset($_COOKIE['lem']) && isset($_COOKIE['pem']) ) |
---|
| 154 | { |
---|
| 155 | $this->template->set_var('href_logout', 'login.php?cd=logout_mobile'); |
---|
| 156 | } |
---|
[4277] | 157 | else |
---|
[5043] | 158 | { |
---|
| 159 | $this->template->set_var('href_logout', 'login.php?cd=1'); |
---|
| 160 | } |
---|
[4277] | 161 | } |
---|
| 162 | |
---|
| 163 | /* |
---|
| 164 | * @function print_navbar |
---|
| 165 | * @abstract Imprime o início da tela do Expresso Mini => barra de navegação |
---|
| 166 | * @author Mário César Kolling <mario.kolling@serpro.gov.br> |
---|
| 167 | */ |
---|
| 168 | private function print_navbar(){ |
---|
| 169 | $this->template->set_var('lang_back', lang('Back')); |
---|
| 170 | $this->template->set_var('lang_home', lang('home')); |
---|
| 171 | $this->template->set_var('lang_email', lang('E-mail')); |
---|
| 172 | $this->template->set_var('lang_contacts', lang('Contact Center')); |
---|
| 173 | $this->template->set_var('lang_calendar', lang('Calendar')); |
---|
| 174 | $this->template->set_var('href_cc', 'index.php?menuaction=mobile.ui_mobilecc.init_cc'); |
---|
| 175 | $this->template->set_var('href_email', "index.php?menuaction=mobile.ui_mobilemail.change_folder&folder=0"); |
---|
| 176 | $this->template->set_var('href_calendar', "index.php?menuaction=mobile.ui_mobilecalendar.index"); |
---|
| 177 | $this->template->set_var('href_home', "index.php?menuaction=mobile.ui_home.index"); |
---|
| 178 | } |
---|
| 179 | |
---|
| 180 | private function process_back_link() { |
---|
| 181 | $trace = $GLOBALS['phpgw']->session->appsession('mobile.trace_urls','mobile'); |
---|
| 182 | |
---|
| 183 | $trace_idx = 0; |
---|
| 184 | |
---|
| 185 | if($trace) { |
---|
| 186 | $trace_idx = sizeof($trace)-1; |
---|
| 187 | |
---|
| 188 | if($_REQUEST["is_back_link"]) |
---|
| 189 | $trace_idx = $trace_idx - 2; |
---|
| 190 | |
---|
| 191 | if($trace_idx < 0) $trace_idx = 0; |
---|
| 192 | |
---|
| 193 | $url = $trace[$trace_idx]["url"]; |
---|
| 194 | $params = $trace[$trace_idx]["request"]; |
---|
| 195 | |
---|
| 196 | $this->href_back = $this->build_url($url, $params); |
---|
| 197 | } else { |
---|
| 198 | $trace = array(); |
---|
| 199 | $this->href_back = ''; |
---|
| 200 | } |
---|
| 201 | |
---|
| 202 | if(!$_REQUEST["is_back_link"]) { |
---|
| 203 | $current_url = $_SERVER["SCRIPT_NAME"]; |
---|
| 204 | $current_params = $_REQUEST; |
---|
| 205 | |
---|
| 206 | unset($current_params['sessionid']); |
---|
| 207 | unset($current_params['domain']); |
---|
| 208 | unset($current_params['last_loginid']); |
---|
| 209 | unset($current_params['last_domain']); |
---|
| 210 | unset($current_params['kp3']); |
---|
| 211 | unset($current_params['showHeader']); |
---|
| 212 | |
---|
| 213 | $built_current_url = $this->build_url($current_url, $current_params); |
---|
| 214 | |
---|
| 215 | if( (preg_match('/menuaction/i',$built_current_url) |
---|
| 216 | && !preg_match('/mobile\.ui_mobilemail\.(send_mail|save_draft|delete_msg)/i',$built_current_url) ) |
---|
| 217 | && !$current_params["ignore_trace_url"] ) { |
---|
| 218 | |
---|
| 219 | //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 |
---|
| 220 | if(str_replace("&is_back_link=true","",$built_current_url) != str_replace("&is_back_link=true","",$this->href_back)) |
---|
| 221 | $trace[sizeof($trace)] = array("url" => $current_url, "request" => $current_params); |
---|
| 222 | else { |
---|
| 223 | if($trace_idx >= 1) $trace_idx--; |
---|
| 224 | $this->href_back = $this->build_url($trace[$trace_idx]["url"], $trace[$trace_idx]["request"]); |
---|
| 225 | } |
---|
| 226 | } |
---|
| 227 | } else { |
---|
| 228 | if(sizeof($trace) > 1) |
---|
| 229 | unset($trace[sizeof($trace)-1]); |
---|
| 230 | } |
---|
| 231 | |
---|
| 232 | if(sizeof($trace) > 0) |
---|
| 233 | $GLOBALS['phpgw']->session->appsession('mobile.trace_urls','mobile',$trace); |
---|
| 234 | else |
---|
| 235 | $GLOBALS['phpgw']->session->appsession('mobile.trace_urls','mobile',null); |
---|
| 236 | |
---|
| 237 | $this->template->set_var('href_back', $this->href_back); |
---|
| 238 | } |
---|
| 239 | |
---|
| 240 | private function build_url($url, $params) { |
---|
| 241 | $query_string = ""; |
---|
| 242 | |
---|
| 243 | foreach ($params as $key => $value) { |
---|
| 244 | $query_string .= "&".$key."=".$value; |
---|
| 245 | } |
---|
| 246 | |
---|
| 247 | if($query_string != "") |
---|
| 248 | $url .= "?".substr($query_string,1); |
---|
| 249 | |
---|
| 250 | if(!$params["is_back_link"]) |
---|
| 251 | $url .= "&is_back_link=true"; |
---|
| 252 | |
---|
| 253 | return $url; |
---|
| 254 | } |
---|
[5043] | 255 | |
---|
| 256 | private function getUrlExpresso() |
---|
| 257 | { |
---|
| 258 | $url_expresso = $GLOBALS['phpgw_info']['server']['webserver_url']; |
---|
| 259 | $url_expresso = ( !empty($url_expresso) ) ? $url_expresso : '/'; |
---|
| 260 | |
---|
| 261 | if(strrpos($url_expresso,'/') === false || strrpos($url_expresso,'/') != (strlen($url_expresso)-1)) |
---|
| 262 | { |
---|
| 263 | $url_expresso .= '/'; |
---|
| 264 | } |
---|
[4277] | 265 | |
---|
[5043] | 266 | return $url_expresso; |
---|
| 267 | } |
---|
| 268 | |
---|
[4277] | 269 | function get_back_link(){ |
---|
| 270 | return $this->href_back; |
---|
| 271 | } |
---|
| 272 | |
---|
| 273 | /* |
---|
| 274 | * @function print_header |
---|
| 275 | * @abstract Imprime o início da tela do Expresso Mini => headers html |
---|
| 276 | * @author Mário César Kolling <mario.kolling@serpro.gov.br> |
---|
| 277 | */ |
---|
| 278 | private function print_header(){ |
---|
| 279 | $GLOBALS['phpgw']->accounts->read_repository(); |
---|
| 280 | $var = Array('title' => lang("expresso mini")); |
---|
| 281 | $this->template->set_var($var); |
---|
| 282 | $this->process_back_link(); |
---|
| 283 | } |
---|
| 284 | |
---|
| 285 | } |
---|
| 286 | ?> |
---|