- Timestamp:
- 06/14/12 01:17:45 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/expressoServiceImap/prototype/services/ImapServiceAdapter.php
r6457 r6486 89 89 { 90 90 //begin: for grid 91 $page = isset($criteria['page']) ? $criteria['page'] : 1 ; //{1} get the requested page92 $limit = isset($criteria['rows']) ? $criteria['rows'] : 10 ; //{10} get how many rows we want to have into the grid93 $sidx = isset($criteria['sidx']) ? $criteria['sidx'] : 0; //{id} get index row - i.e. user click to sort94 $sord = isset($criteria['sord']) ? $criteria['sord'] : ''; //{desc} get the direction91 // $page = isset($criteria['page']) ? $criteria['page'] : 1 ; //{1} get the requested page 92 // $limit = isset($criteria['rows']) ? $criteria['rows'] : 10 ; //{10} get how many rows we want to have into the grid 93 // $sidx = isset($criteria['sidx']) ? $criteria['sidx'] : 0; //{id} get index row - i.e. user click to sort 94 // $sord = isset($criteria['sord']) ? $criteria['sord'] : ''; //{desc} get the direction 95 95 96 96 $filter = isset($criteria['filter']) ? $criteria['filter'] : ''; 97 97 98 if( !$sidx ) $sidx = 1;98 // if( !$sidx ) $sidx = 1; 99 99 100 100 $folder_name = isset($URI['folder']) ? $URI['folder'] : str_replace( '.', $this->imap_delimiter, isset($context['folder']) ? $context['folder'] : 'INBOX'); 101 101 102 102 $count = imap_num_msg( $this->open_mbox( $folder_name ) ); 103 104 $total_pages = $count > 0 ? ceil( $count/$limit ) : 0; 105 106 if( $page > $total_pages ) 107 $page = $total_pages; 108 109 $start = $limit * $page - $limit; 103 // 104 // $total_pages = $count > 0 ? ceil( $count/$limit ) : 0; 105 // 106 // if( $page > $total_pages ) 107 // $page = $total_pages; 108 // 109 // $start = $limit * $page - $limit; 110 110 111 // do not put $limit*($page - 1) 111 112 //end: for grid … … 162 163 if( $filter[0] !== 'msgNumber' ) 163 164 { 164 for( $i = 0; $i < count($filter); $i++ )165 {166 if( count( $filter[$i] ) === 4 )167 $criteria['isExact'] = ( array_shift( $filter[$i] ) === 'AND' );168 169 $criteria[ $filter[$i][0] ] = array( 'criteria' => $filter[$i][2], 'filter' => $filter[$i][1] );170 }171 172 return $this->searchSieveRule($criteria);173 } 174 175 $msgNumber = array();176 177 for( $i = $start; $i < $start + $limit && isset( $filter[2][$i] ); $i++ )178 $msgNumber[] = $filter[2][$i];179 180 if( empty( $msgNumber ) )181 return( false );165 for( $i = 0; $i < count($filter); $i++ ) 166 { 167 if( count( $filter[$i] ) === 4 ) 168 $criteria['isExact'] = ( array_shift( $filter[$i] ) === 'AND' ); 169 170 $criteria[ $filter[$i][0] ] = array( 'criteria' => $filter[$i][2], 'filter' => $filter[$i][1] ); 171 } 172 173 return $this->searchSieveRule($criteria); 174 } 175 176 // $msgNumber = array(); 177 // 178 // for( $i = $start; $i < $start + $limit && isset( $filter[2][$i] ); $i++ ) 179 // $msgNumber[] = $filter[2][$i]; 180 // 181 // if( empty( $msgNumber ) ) 182 // return( false ); 182 183 183 184 $result = $this->get_info_msgs( array( 'folder' => $folder_name, 184 'msgs_number' => implode( ',', $ msgNumber) ) );185 'msgs_number' => implode( ',', $filter[2] ) ) ); 185 186 186 187 foreach( $result as $i => $val ) … … 193 194 array( 194 195 'folder' => $folder_name, //INBOX 195 'msg_range_begin' => $ start+ 1, //??196 'msg_range_end' => $ start + $limit, //$limit = $_GET['rows']; // get how many rows we want to have into the grid196 'msg_range_begin' => $criteria['offset'] + 1, //?? 197 'msg_range_end' => $criteria['limit'], //$limit = $_GET['rows']; // get how many rows we want to have into the grid 197 198 'sort_box_type' => 'SORTARRIVAL', 198 199 'search_box_type' => 'ALL', … … 203 204 //return var_export($result); 204 205 205 $response = array( "page" => $page, "total" => $total_pages, "records" => $count ); 206 $response = array( "page" => $count > 0 ? ceil( $criteria['offset'] / $criteria['limit'] ) + 1 : 0, 207 "total" => $count > 0 ? ceil( $count/$criteria['limit'] ) : 0, 208 "records" => $count ); 206 209 207 210 for ($i=0; $i<count($result); $i++)
Note: See TracChangeset
for help on using the changeset viewer.