Ignore:
Timestamp:
03/29/11 09:33:25 (13 years ago)
Author:
eduardoalex
Message:

Ticket #1685 - Paginação na listagem de compromisssos.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2/mobile/inc/class.ui_mobilecalendar.inc.php

    r3829 r3926  
    3030                                'home_search_bar' => 'search_bar.tpl' 
    3131                        )); 
     32                        $actual_max_results = $_GET["results"]?$_GET["results"]:10; 
    3233                        $this->template->set_block("calendar","page"); 
    3334                        $this->template->set_block('calendar','event_block'); 
     
    4142                        $this->template->set_var('lang_calendar',lang("Calendar")); 
    4243                        $this->template->set_var('lang_search',lang("search")); 
     44                        $this->template->set_var('lang_more',lang("more")); 
     45                        $this->template->set_var('lang_events',lang("events")); 
     46                        $this->template->set_var('type',$params['type']); 
     47                        $this->template->set_var('dia',$params['dia']); 
     48                        $this->template->set_var('mes',$params['mes']); 
     49                        $this->template->set_var('ano',$params['ano']); 
     50                        $this->template->set_var('next_max_results',$actual_max_results+10); 
    4351                         
    4452                        if($GLOBALS['phpgw']->session->appsession('mobile.layout','mobile')!="mini_desktop") 
     
    128136                        $this->template->set_var("lang_today", lang("today")); 
    129137                        $this->template->set_var("today_link", "index.php?menuaction=mobile.ui_mobilecalendar.index&type=dia&dia"); 
    130                          
     138                        $show_more_button = false; 
    131139                        if($type==="semana") { 
    132140                                $tstart = $GLOBALS['phpgw']->datetime->get_weekday_start($year, $month, $day) + $GLOBALS['phpgw']->datetime->tz_offset; 
     
    155163                                $this->template->parse('events_box','bar_block',true); 
    156164                                 
     165                                $total_events = 0;  
    157166                                if(!empty($events)) { 
    158167                                        foreach($events as $index=>$event)      { 
     168                                                if($total_events>=$actual_max_results) { 
     169                                                        $show_more_button = true; 
     170                                                        break; 
     171                                                } 
    159172                                                $event_year  = (int) substr($index,0,4); 
    160173                                                $event_month = (int) substr($index,4,2); 
    161174                                                $event_day   = (int) substr($index,6,2); 
     175                                                $complete_day = $event_year.$this->common->complete_string($event_month,2,"R","0").$this->common->complete_string($event_day,2,"R","0"); 
     176 
     177                                                //Se a quantidade de eventos for maior que o máximo pego nessa interação, o botão de mais deve aparecer 
     178                                                if(count($events[$complete_day])>$actual_max_results-$total_events)  
     179                                                        $show_more_button = true; 
     180                                                 
     181                                                //Pego os eventos até completar o máximo da paginação 
     182                                                $events_to_print = array_slice($events[$complete_day],0,$actual_max_results-$total_events); 
     183                                                $total_events += count($events_to_print); 
     184                                                 
    162185                                                print_events_header($this, $event_day, $event_month, $event_year); 
    163                                                 print_events($this, $events[$event_year.$this->common->complete_string($event_month,2,"R","0").$this->common->complete_string($event_day,2,"R","0")]);   
     186                                                print_events($this, $events_to_print); 
    164187                                        }                
    165188                                } else { 
     
    272295                                $this->template->set_var("current_label", $this->daysOfWeek[$GLOBALS['phpgw']->datetime->day_of_week($year,$month,$day)]." - ".$day."/".$month."/".$year); 
    273296                                $this->template->parse('events_box','bar_block',true);                           
    274                                  
    275                                 if(!empty($events[$year.$month.$day])) 
    276                                         print_events($this, $events[$year.$month.$day]); 
     297 
     298                                if(!empty($events[$year.$month.$day])) { 
     299                                        print_events($this, array_slice($events[$year.$month.$day],0,$actual_max_results,true)); 
     300                                        if(count($events[$year.$month.$day])>$actual_max_results)  
     301                                                        $show_more_button = true; 
     302                                } 
    277303                                else { 
    278304                                        $this->template->set_var("msg_no_event", lang("Dont have event that day")); 
     
    280306                                } 
    281307                        } 
    282                          
     308                        if($show_more_button) 
     309                                $this->template->set_var('show_more','block'); 
     310                        else 
     311                                $this->template->set_var('show_more','none'); 
    283312                        $GLOBALS['phpgw_info']['mobiletemplate']->set_content($this->template->fp('out','page')); 
    284313                } 
Note: See TracChangeset for help on using the changeset viewer.