00001 <?php
00002
00003
00004
00005
00006
00007
00008 require_once ( dirname ( __FILE__ ).'/printableList.class.php' );
00009
00010
00011
00012
00013
00014 class booklet_napdf extends printableList implements IPrintableList
00015 {
00016 var $weekday_names = null;
00017 var $pos = array ( 'start' => 1, 'end' => '', 'count' => 0, 'y' => 0, 'weekday' => 1 );
00018 var $right_offset = 0;
00019 var $formats = 0;
00020 var $special_formats = '';
00021
00022
00023
00024
00025
00026
00027
00028 function __construct ( $in_http_vars
00029 )
00030 {
00031 include ( dirname ( __FILE__ ).'/booklet_pdf_decls.php' );
00032 $this->weekday_names = $g_weekday_names;
00033 $this->page_x = 5.25;
00034 $this->page_y = 8;
00035 $this->units = 'in';
00036 $this->font = 'Times';
00037 $this->font_size = 8;
00038 $this->orientation = 'P';
00039
00040 $this->sort_keys = array ( 'weekday_tinyint' => true,
00041 'start_time' => true,
00042 'week_starts' => 1
00043 );
00044
00045 $this->out_http_vars = array ('do_search' => 'yes',
00046 'bmlt_search_type' => 'advanced',
00047 'advanced_service_bodies' => $in_http_vars['advanced_service_bodies'],
00048 'advanced_formats' => $in_http_vars['advanced_formats'],
00049 'advanced_weekdays' => $in_http_vars['advanced_weekdays'],
00050 'advanced_radius' => $in_http_vars['advanced_radius'],
00051 'advanced_mapmode' => $in_http_vars['advanced_mapmode'],
00052 'long_val' => $in_http_vars['long_val'],
00053 'lat_val' => $in_http_vars['lat_val'],
00054 'geo_width' => $in_http_vars['geo_width'],
00055 'geo_width_km' => $in_http_vars['geo_width_km'],
00056 'long_val' => $in_http_vars['long_val'],
00057 'lat_val' => $in_http_vars['lat_val'],
00058 'SearchString' => $in_http_vars['SearchString'],
00059 'StringSearchIsAnAddress' => $in_http_vars['StringSearchIsAnAddress']
00060 );
00061
00062 $this->lang_search = array ( 'en' );
00063
00064 napdf::$sort_callback = 'booklet_napdf::sort_meeting_data_callback';
00065
00066 parent::__construct ( $in_http_vars, $this->lang_search );
00067 }
00068
00069
00070
00071
00072
00073
00074 function AssemblePDF ()
00075 {
00076 $ret = false;
00077
00078 if ( $this->napdf_instance instanceof napdf )
00079 {
00080 $this->DrawFormatPage ( );
00081 $left = true;
00082 while ( !$this->pos['end'] )
00083 {
00084 $this->DrawListPage ( $left );
00085 $left = !$left;
00086 }
00087 $ret = true;
00088 }
00089
00090 return $ret;
00091 }
00092
00093
00094
00095 function OutputPDF ()
00096 {
00097 $d = date ( "Y_m_d" );
00098 $this->napdf_instance->Output( "BMLT_PrintableBooklet_$d.pdf", "D" );
00099 }
00100
00101
00102
00103
00104 private static function sort_cmp_formats ($a, $b)
00105 {
00106 $order_array = array( 0=>"O", 1=>"C",
00107 2=>"ES", 3=>"B", 4=>"M", 5=>"W", 6=>"GL", 7=>"YP", 8=>"BK", 9=>"IP", 10=>"Pi", 11=>"RF", 12=>"Rr",
00108 13=>"So", 14=>"St", 15=>"To", 16=>"Tr", 17=>"OE", 18=>"D", 19=>"SD", 20=>"TW", 21=>"IL",
00109 22=>"BL", 23=>"IW", 24=>"BT", 25=>"SG", 26=>"JT",
00110 27=>"Ti", 28=>"Sm", 29=>"NS", 30=>"CL", 31=>"CS", 32=>"NC", 33=>"SC", 34=>"CH", 35=>"SL", 36=>"WC" );
00111
00112 if ( in_array ( $a['key_string'], $order_array ) || in_array ( $b['key_string'], $order_array ) )
00113 {
00114 return (array_search ( $a['key_string'], $order_array ) < array_search ( $b['key_string'], $order_array )) ? -1 : 1;
00115 }
00116 else
00117 {
00118 return 0;
00119 }
00120 }
00121
00122
00123
00124
00125
00126
00127
00128 private static function sort_formats( $in_format_data
00129 )
00130 {
00131 $ret = array();
00132
00133 foreach ( $in_format_data as $format )
00134 {
00135 if ( $format['lang'] == 'en' )
00136 {
00137 $s_desc = ((isset ( $in_format_data[$format['id'].'_es'] )) ? '('.$in_format_data[$format['id'].'_es']['name_string'].') '.$in_format_data[$format['id'].'_es']['description_string'] : null);
00138 $r_temp = array ( 'key_string' => $format['key_string'],
00139 'description_string' => '('.$format['name_string'].') '.$format['description_string']
00140 );
00141 if ( $s_desc )
00142 {
00143 $r_temp['description_string'] .= "\n$s_desc";
00144 }
00145
00146 array_push ( $ret, $r_temp );
00147 }
00148 }
00149
00150 usort ( $ret, 'booklet_napdf::sort_cmp_formats' );
00151
00152 return $ret;
00153 }
00154
00155
00156
00157 private function DrawFormatPage ( )
00158 {
00159 include ( dirname ( __FILE__ ).'/booklet_pdf_decls.php' );
00160 $formats = self::sort_formats ( $this->napdf_instance->format_data );
00161
00162 $this->napdf_instance->SetFont ( $this->font, '', $this->font_size );
00163 $heading_height = 9;
00164 $height = ($heading_height/72) + 0.01;
00165 $top = 0.125;
00166 $left = 0.125;
00167 $bottom = $this->napdf_instance->h - 0.125;
00168 $right = $this->napdf_instance->w - 0.125;
00169 $fontFamily = $this->napdf_instance->FontFamily;
00170 $fontSize = $this->napdf_instance->FontSizePt;
00171 $fontSizeSmaller = $fontSize - 0.25;
00172 $fSize = $fontSizeSmaller / 72;
00173 $this->right_offset = 0.4;
00174 $space_needed = (($fontSizeSmaller / 72) * 5) + 0.02;
00175 $y_offset = $bottom - $fSize;
00176
00177 $newpage = 2;
00178
00179 $countmax = count ( $formats );
00180
00181 $this->special_formats = array ( );
00182
00183 for ( $count = 0; $count < $countmax; $count++ )
00184 {
00185 $format_code = $formats[$count]['key_string'];
00186 $format_english = $formats[$count]['description_string'];
00187
00188 if ( isset ( $this->special_formats[$format_code] ) )
00189 {
00190 $this->special_formats[$format_code] = $format_english;
00191 $format_code = null;
00192 }
00193
00194 if ( $format_code )
00195 {
00196 if ( $newpage )
00197 {
00198 $this->napdf_instance->AddPage();
00199 $this->napdf_instance->SetFont ( $fontFamily, 'B', 7 );
00200 $this->napdf_instance->Line ( $left, $y_offset - 0.1, $right, $y_offset - 0.1 );
00201 $this->napdf_instance->SetXY ( $right, $y_offset );
00202 $this->napdf_instance->Cell ( 0, 0, _PDF_PAGE." ".$this->napdf_instance->PageNo(), 0, 0, "R" );
00203 $this->napdf_instance->SetFont ( $fontFamily, '', $fontSize );
00204 $this->napdf_instance->SetFillColor ( 0 );
00205 $this->napdf_instance->SetTextColor ( 255 );
00206 $header = ""._PDF_LEGEND_HEADER."";
00207 if ( $newpage != 2 )
00208 {
00209 $header .= _PDF_CONTD;
00210 }
00211
00212 $this->napdf_instance->SetFont ( $fontFamily, 'B', $heading_height );
00213 $stringWidth = $this->napdf_instance->GetStringWidth ( $header );
00214 $cellleft = (($right + $left) / 2) - ($stringWidth / 2);
00215 $this->napdf_instance->Rect ( $left, $top, ($right - $left), $height, "F" );
00216 $this->napdf_instance->SetXY ( $cellleft, $top + 0.01 );
00217 $this->napdf_instance->Cell ( 0, $heading_height/72, $header );
00218 $this->napdf_instance->SetFillColor ( 255 );
00219 $this->napdf_instance->SetTextColor ( 0 );
00220 $newpage = "";
00221 $this->napdf_instance->SetY ( $top + $height );
00222 }
00223 else
00224 {
00225 $this->napdf_instance->Line ( $left, $this->napdf_instance->GetY() + 0.01, $right, $this->napdf_instance->GetY() + 0.01 );
00226 $this->napdf_instance->SetY ( $this->napdf_instance->GetY() + 0.02 );
00227 }
00228
00229 $y = $this->napdf_instance->GetY();
00230
00231 $this->napdf_instance->SetFont ( $fontFamily, 'B', $fontSizeSmaller );
00232 $this->napdf_instance->SetLeftMargin ( $left );
00233 $this->napdf_instance->SetXY ( $left, $y );
00234 $this->napdf_instance->MultiCell ( $column_width, $fSize, utf8_decode ( $format_code ), 0, "L" );
00235
00236 $this->napdf_instance->SetFont ( $fontFamily, '', $fontSizeSmaller );
00237 $this->napdf_instance->SetLeftMargin ( $this->right_offset );
00238 $this->napdf_instance->SetXY ( $this->right_offset, $y );
00239 $this->napdf_instance->MultiCell ( $column_width, $fSize, utf8_decode ( $format_english ), 0, "L" );
00240
00241 if ( ($this->napdf_instance->GetY() + 0.01 + $space_needed) >= $y_offset )
00242 {
00243 $newpage = 1;
00244 }
00245 }
00246 }
00247
00248 if ( ($this->napdf_instance->GetY() + 0.3 + $fSize/72) > $y_offset )
00249 {
00250 $this->napdf_instance->AddPage();
00251 $y = $y_offset;
00252 }
00253 else
00254 {
00255 $y = $this->napdf_instance->GetY() + 0.3;
00256 }
00257
00258 $this->napdf_instance->Line ( $left, $y - 0.1, $right, $y - 0.1 );
00259 $this->napdf_instance->SetXY ( $left, $y );
00260 $this->napdf_instance->SetFont ( $fontFamily, 'I', $fontSize );
00261 $this->napdf_instance->Cell ( 0, $fSize/72, _DEFAULT_DURATION );
00262 $this->napdf_instance->SetFont ( $fontFamily, '', $fontSize );
00263 $this->napdf_instance->SetLeftMargin ( $left );
00264 }
00265
00266
00267
00268 private function DrawListPage ( $in_left
00269 )
00270 {
00271 include ( dirname ( __FILE__ ).'/booklet_pdf_decls.php' );
00272 $meetings =& $this->napdf_instance->meeting_data;
00273
00274 $count_max = count ( $meetings );
00275
00276 $this->napdf_instance->SetFont ( $this->font, '', $this->font_size );
00277 $fontFamily = $this->napdf_instance->FontFamily;
00278 $fontSize = $this->napdf_instance->FontSizePt;
00279
00280 $column_width = (($this->napdf_instance->w - 0.25) / 2) - 0.05;
00281
00282 $top = 0.125;
00283 $left = $in_left ? 0.125 : (0.125 + $column_width + 0.1);
00284 $bottom = $this->napdf_instance->h - 0.125;
00285 $right = $left + $column_width;
00286 $this->right_offset = 0;
00287
00288 $heading_height = 9;
00289 $height = ($heading_height/72) + 0.01;
00290 $gap2 = 0.02;
00291
00292 $fSize = $fontSize / 70;
00293 $fSizeSmall = ($fontSize - 1) / 70;
00294
00295 $height_one_meeting = ($fSize * 6) + $gap2;
00296
00297 $y_offset = $bottom - $fSize;
00298
00299 $current_day = " ";
00300
00301 $extra_height = $height + 0.05;
00302
00303 if ( $in_left )
00304 {
00305 $this->napdf_instance->AddPage();
00306 }
00307
00308 $this->pos['y'] = $top;
00309 $watermark_pos = 1.0;
00310
00311 if ( $this->pos['start'] )
00312 {
00313 $this->pos['count'] = 0;
00314 }
00315
00316 while ( !$this->pos['end'] && (($this->pos['y'] + $height_one_meeting + $extra_height + ($fSizeSmall * 2)) < ($y_offset - 0.1)) )
00317 {
00318 $extra = 0;
00319 $contd = "";
00320 $meeting = $meetings[intval($this->pos['count'])];
00321 $this->napdf_instance->SetLeftMargin ( $left );
00322
00323 if ( $this->pos['start'] || ($current_day != $meeting['weekday_tinyint']) )
00324 {
00325 $this->napdf_instance->SetFillColor ( 0 );
00326 $this->napdf_instance->SetTextColor ( 255 );
00327 if ( $this->pos['start'] )
00328 {
00329 $this->pos['start'] = "";
00330 }
00331 else
00332 {
00333 if ( ($this->pos['y'] == $top) && ($this->pos['weekday'] == $meeting['weekday_tinyint']) )
00334 {
00335 $contd = _PDF_CONTD;
00336 }
00337 }
00338
00339 if ( $current_day != $meeting['weekday_tinyint'] )
00340 {
00341 $this->pos['weekday'] = $meeting['weekday_tinyint'];
00342 $current_day = $this->pos['weekday'];
00343 }
00344
00345 $header = $this->weekday_names[$current_day - 1];
00346
00347 $header .= $contd;
00348
00349 $this->napdf_instance->SetFont ( $fontFamily, 'B', $heading_height );
00350 $this->napdf_instance->Rect ( $left, $this->pos['y'], ($right - $left), $height, "F" );
00351 $stringWidth = $this->napdf_instance->GetStringWidth ( $header );
00352 $cellleft = (($right + $left) / 2) - ($stringWidth / 2);
00353 $this->napdf_instance->SetXY ( $cellleft, $this->pos['y'] + 0.005 );
00354 $this->napdf_instance->Cell ( 0, $heading_height/72, $header );
00355 $this->pos['y'] += ($height);
00356 }
00357 else
00358 {
00359 $this->napdf_instance->Line ( $left, $this->pos['y'], $right, $this->pos['y'] );
00360 }
00361
00362 $this->napdf_instance->SetFillColor ( 255 );
00363 $this->napdf_instance->SetTextColor ( 0 );
00364
00365 $this->napdf_instance->SetFont ( $fontFamily, 'B', $fontSize );
00366
00367 $cell_top = $this->pos['y'] + $gap2;
00368 $this->napdf_instance->SetXY ( $left, $cell_top );
00369
00370 $display_string = $meeting['meeting_name'];
00371
00372 $display_string .= " (".$this->RearrangeFormats ( $meeting['formats'] ).")";
00373
00374 $this->napdf_instance->SetX ( $left );
00375
00376 $this->napdf_instance->MultiCell ( $column_width, $fSize, utf8_decode ( $display_string ), 0, "L" );
00377
00378 $this->napdf_instance->SetFont ( $fontFamily, '', $fontSize );
00379
00380 $display_string = self::translate_time ( $meeting['start_time'] );
00381 if ( $meeting['duration_time'] && ('01:30:00' != $meeting['duration_time']) )
00382 {
00383 $display_string .= " (".self::translate_duration ( $meeting['duration_time'] ).")";
00384 }
00385
00386 $this->napdf_instance->SetX ( $left );
00387 $this->napdf_instance->MultiCell ( $column_width, $fSize, utf8_decode ( $display_string ), 0, "L" );
00388
00389 $display_string = '';
00390
00391 if ( trim ( $meeting['location_city_subsection'] ) )
00392 {
00393 $display_string .= trim ( $meeting['location_city_subsection'] );
00394 }
00395
00396 if ( trim ( $meeting['location_neighborhood'] ) )
00397 {
00398 $display_string .= ' ('.trim ( $meeting['location_neighborhood'] ).')';
00399 }
00400
00401 if ( $display_string )
00402 {
00403 $display_string .= ', ';
00404 }
00405
00406 $display_string .= $meeting['location_municipality'];
00407
00408 if ( $display_string )
00409 {
00410 $display_string .= ', ';
00411 }
00412
00413 $display_string .= $meeting['location_province'];
00414
00415 $this->napdf_instance->SetX ( $left );
00416 $this->napdf_instance->MultiCell ( $column_width, $fSize, utf8_decode ( $display_string ), 0, "L" );
00417
00418 $display_string = '';
00419
00420 if ( trim ( $meeting['location_text'] ) )
00421 {
00422 $display_string .= trim ( $meeting['location_text'] );
00423 }
00424
00425 if ( trim ( $meeting['location_info'] ) )
00426 {
00427 if ( $display_string )
00428 {
00429 $display_string .= ', ';
00430 }
00431
00432 $display_string .= " (".trim ( $meeting['location_info'] ).")";
00433 }
00434
00435 if ( $display_string )
00436 {
00437 $display_string .= ', ';
00438 }
00439
00440 $display_string .= $meeting['location_street'];
00441
00442 $this->napdf_instance->SetX ( $left );
00443 $this->napdf_instance->MultiCell ( $column_width, $fSize, utf8_decode ( $display_string ), 0, "L" );
00444
00445 $desc = $this->Get_Special_Format_Text ( $meeting['formats'] );
00446
00447 if ( trim ( $meeting['description_string'] ) )
00448 {
00449 if ( $desc )
00450 {
00451 $desc .= ", ";
00452 }
00453 $desc = trim ( $meeting['description_string'] );
00454 }
00455
00456 if ( trim ( $meeting['comments'] ) )
00457 {
00458 if ( $desc )
00459 {
00460 $desc .= ", ";
00461 }
00462 $desc .= trim ( $meeting['comments'] );
00463 }
00464
00465 $desc = preg_replace ( "/[\n|\r]/", ", ", $desc );
00466 $desc = preg_replace ( "/,\s*,/", ",", $desc );
00467 $desc = stripslashes ( stripslashes ( $desc ) );
00468
00469 if ( $desc )
00470 {
00471 $extra = ($fSizeSmall * 3);
00472 $this->napdf_instance->SetFont ( $fontFamily, 'I', $fontSize - 1 );
00473 $this->napdf_instance->SetX ( $left );
00474 $this->napdf_instance->MultiCell ( $column_width, $fSizeSmall, utf8_decode ( $desc ), 0, "L" );
00475 }
00476
00477 $yMax = max ( $yMax, $this->napdf_instance->GetY ( ) ) + $gap2;
00478 $this->pos['y'] = $yMax;
00479 $this->pos['count']++;
00480
00481 if ( $this->pos['count'] == $count_max )
00482 {
00483 $this->pos['end'] = 1;
00484 }
00485 else
00486 {
00487 $next_meeting = $meetings[intval($this->pos['count'])];
00488
00489 if ( $current_day != $next_meeting['weekday_tinyint'] )
00490 {
00491 $extra_height = $height + 0.05;
00492 }
00493 else
00494 {
00495 $extra_height = 0;
00496 }
00497 }
00498 }
00499
00500 if ( !$in_left || $this->pos['end'] )
00501 {
00502 $this->napdf_instance->SetFont ( $fontFamily, 'B', 7 );
00503 $this->napdf_instance->SetXY ( $right, $y_offset );
00504 $this->napdf_instance->Cell ( 0, 0, _PDF_PAGE." ".$this->napdf_instance->PageNo(), 0, 0, "R" );
00505 $this->napdf_instance->SetFont ( $fontFamily, '', $fontSize );
00506 }
00507 }
00508
00509
00510
00511 private function Get_Special_Format_Text ( $inFormats )
00512 {
00513 $ret = "";
00514
00515 $format_array = split ( ",", $inFormats );
00516
00517 foreach ( $format_array as $format )
00518 {
00519 if ( $this->special_formats[$format] )
00520 {
00521 if ( $ret )
00522 {
00523 $ret .= ", ";
00524 }
00525
00526 $ret .= $this->special_formats[$format];
00527 }
00528 }
00529
00530 return $ret;
00531 }
00532
00533
00534
00535 private function RearrangeFormats ( $inFormats )
00536 {
00537 $inFormats = split ( ",", $inFormats );
00538
00539 if ( !in_array ( "C", $inFormats ) && !in_array ( "O", $inFormats ) )
00540 {
00541 array_push ( $inFormats, "C" );
00542 }
00543
00544 if ( !$ignore_bk && !in_array ( "BK", $inFormats ) && ((in_array ( "BT", $inFormats ) || in_array ( "IW", $inFormats ) || in_array ( "JT", $inFormats ) || in_array ( "SG", $inFormats ))) )
00545 {
00546 array_push ( $inFormats, "BK" );
00547 }
00548
00549 for ( $c = 0; $c < count ( $inFormats ); $c++ )
00550 {
00551 if ( array_key_exists ( $inFormats[$c], $this->special_formats ) )
00552 {
00553 $inFormats[$c] = null;
00554 unset ( $inFormats[$c] );
00555 }
00556 }
00557
00558 uasort ( $inFormats, 'booklet_napdf::sort_cmp' );
00559
00560 $tFormats = $inFormats;
00561
00562 $inFormats = array();
00563
00564 foreach ( $tFormats as $format )
00565 {
00566 $format = trim ( $format );
00567 if ( $format )
00568 {
00569 array_push ( $inFormats, $format );
00570 }
00571 }
00572
00573 return join ( " ", $inFormats );
00574 }
00575
00576
00577
00578 private static function sort_cmp ($a, $b)
00579 {
00580 $order_array = array( 0=>"O", 1=>"C",
00581 2=>"ES", 3=>"B", 4=>"M", 5=>"W", 6=>"GL", 7=>"YP", 8=>"BK", 9=>"IP", 10=>"Pi", 11=>"RF", 12=>"Rr",
00582 13=>"So", 14=>"St", 15=>"To", 16=>"Tr", 17=>"OE", 18=>"D", 19=>"SD", 20=>"TW", 21=>"IL",
00583 22=>"BL", 23=>"IW", 24=>"BT", 25=>"SG", 26=>"JT",
00584 27=>"Ti", 28=>"Sm", 29=>"NS", 30=>"CL", 31=>"CS", 32=>"NC", 33=>"SC", 34=>"CH", 35=>"SL", 36=>"WC" );
00585
00586 if ( in_array ( $a, $order_array ) || in_array ( $b, $order_array ) )
00587 {
00588 return (array_search ( $a, $order_array ) < array_search ( $b, $order_array )) ? -1 : 1;
00589 }
00590 else
00591 {
00592 return 0;
00593 }
00594 }
00595
00596
00597
00598 private static function translate_time ( $in_time_string )
00599 {
00600 $split = split ( ":", $in_time_string );
00601 if ( $in_time_string == "12:00:00" )
00602 {
00603 return "Noon";
00604 }
00605 elseif ( ($split[0] == "23") && (intval ( $split[1] ) > 45) )
00606 {
00607 return "Midnight";
00608 }
00609 else
00610 {
00611 return date ( "g:i A", strtotime ( $in_time_string ) );
00612 }
00613 }
00614
00615
00616
00617 private static function translate_duration ( $in_time_string )
00618 {
00619 $t = split ( ":", $in_time_string );
00620 $hours = intval ( $t[0] );
00621 $minutes = intval ( $t[1] );
00622
00623 $ret = '';
00624
00625 if ( $hours )
00626 {
00627 $ret .= "$hours hour";
00628
00629 if ( $hours > 1 )
00630 {
00631 $ret .= "s";
00632 }
00633
00634 if ( $minutes )
00635 {
00636 $ret .= " and ";
00637 }
00638 }
00639
00640 if ( $minutes )
00641 {
00642 $ret .= "$minutes minutes";
00643 }
00644
00645 return $ret;
00646 }
00647
00648
00649
00650
00651
00652
00653
00654 static function sort_meeting_data_callback (&$in_a,
00655 &$in_b
00656 )
00657 {
00658 $ret = 0;
00659
00660 if ( is_array ( $in_a ) && is_array ( $in_b ) && is_array ( napdf::$sort_order_keys ) )
00661 {
00662
00663 $sort_keys = array_reverse ( napdf::$sort_order_keys, true );
00664
00665 foreach ( $sort_keys as $key => $value )
00666 {
00667 if ( isset ( $in_a[$key] ) && isset ( $in_b[$key] ) )
00668 {
00669 $val_a = trim ( $in_a[$key] );
00670 $val_b = trim ( $in_b[$key] );
00671
00672 if ( ('weekday_tinyint' == $key) && (napdf::$week_starts > 1) && (napdf::$week_starts < 8) )
00673 {
00674 $val_a -= napdf::$week_starts;
00675
00676 if ( $val_a < 0 )
00677 {
00678 $val_a += 8;
00679 }
00680 else
00681 {
00682 $val_a += 1;
00683 }
00684
00685 $val_b -= napdf::$week_starts;
00686
00687 if ( $val_b < 0 )
00688 {
00689 $val_b += 8;
00690 }
00691 else
00692 {
00693 $val_b += 1;
00694 }
00695 }
00696
00697
00698 switch ( $key )
00699 {
00700 case 'start_time':
00701 case 'duration_time':
00702 $val_a = strtotime ( $val_a );
00703 $val_b = strtotime ( $val_b );
00704 case 'weekday_tinyint':
00705 case 'id_bigint':
00706 case 'shared_group_id_bigint':
00707 case 'service_body_bigint':
00708 $val_a = intval ( $val_a );
00709 $val_b = intval ( $val_b );
00710 case 'longitude':
00711 case 'latitude':
00712 if ( $val_a > $val_b )
00713 {
00714 $ret = 1;
00715 }
00716 elseif ( $val_b > $val_a )
00717 {
00718 $ret = -1;
00719 }
00720 break;
00721
00722 default:
00723
00724 if ( strlen ( $val_a ) && strlen ( $val_b ) )
00725 {
00726 $tmp = strcmp ( strtolower ( $val_a ), strtolower ( $val_b ) );
00727
00728 if ( $tmp != 0 )
00729 {
00730 $ret = $tmp;
00731 }
00732 }
00733 break;
00734 }
00735 }
00736
00737 if ( !$value )
00738 {
00739 $ret = -$ret;
00740 }
00741 }
00742 }
00743
00744 return $ret;
00745 }
00746 };
00747 ?>