00001 <?php
00002
00003
00004
00005
00006
00007 ini_set('display_errors', 1);
00008 ini_set('error_reporting', E_ERROR);
00009
00010 require_once ( dirname ( __FILE__ ).'/../pdf_generator/printableList.class.php' );
00011 require_once ( dirname ( __FILE__ ).'/pdf_decls.php' );
00012
00013
00014
00015
00016
00017 class nyc_napdf extends printableList implements IPrintableList
00018 {
00019 var $weekday_names = array ( "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" );
00020 var $pos = array ( 'start' => 1, 'end' => '', 'count' => 0, 'y' => 0, 'weekday' => 1 );
00021 var $formats = 0;
00022
00023
00024
00025
00026
00027
00028
00029 function __construct ( $in_http_vars
00030 )
00031 {
00032 $this->page_x = 11;
00033 $this->page_y = 17;
00034 $this->units = 'in';
00035 $this->font = 'Helvetica';
00036 $this->font_size = 12;
00037 $this->orientation = 'L';
00038
00039 $this->sort_keys = array ( 'weekday_tinyint' => true,
00040 'start_time' => true,
00041 'location_neighborhood' => true,
00042 'week_starts' => 1
00043 );
00044
00045 $this->out_http_vars = array ('do_search' => 'yes',
00046 'bmlt_search_type' => 'advanced',
00047 'location_province' => 'NY',
00048 'meeting_key' => array ( 'location_city_subsection',
00049 'location_municipality',
00050 'location_sub_province'
00051 ),
00052 'meeting_key_value' => 'Manhattan'
00053 );
00054
00055 parent::__construct ( $in_http_vars );
00056 }
00057
00058
00059
00060
00061
00062
00063
00064 function AssemblePDF ()
00065 {
00066 $ret = false;
00067
00068 if ( $this->napdf_instance instanceof napdf )
00069 {
00070 $page_margins = 0.35;
00071
00072 $meeting_data =& $this->napdf_instance->meeting_data;
00073
00074 if ( $meeting_data )
00075 {
00076
00077
00078
00079 $panelpage['margin'] = $page_margins;
00080 $panelpage['height'] = $this->napdf_instance->h - ($panelpage['margin'] * 2);
00081 $panelpage['width'] = ($this->napdf_instance->w / 4) - ($panelpage['margin'] * 2);
00082
00083
00084 $listpage['margin'] = $page_margins;
00085 $listpage['height'] = $this->napdf_instance->h - ($listpage['margin'] * 2);
00086 $listpage[width] = ($this->napdf_instance->w / 2) - ($listpage['margin'] * 2);
00087
00088
00089
00090
00091 $frontpanel_x_offset = $panelpage['width'] + ($panelpage['margin'] * 3);
00092 $frontpanel_max_x_offset = $frontpanel_x_offset + $panelpage['width'];
00093 $frontpanel_y_offset = $panelpage['margin'];
00094 $frontpanel_max_y_offset = $frontpanel_y_offset + $panelpage['height'];
00095
00096
00097 $backpanel_x_offset = $panelpage['margin'];
00098 $backpanel_max_x_offset = $backpanel_x_offset + $panelpage['width'];
00099 $backpanel_y_offset = $panelpage['margin'];
00100 $backpanel_max_y_offset = $backpanel_y_offset + $panelpage['height'];
00101
00102
00103 $vertical_separator_x = ($this->napdf_instance->w / 2);
00104 $vertical_separator_y = $page_margins;
00105 $vertical_separator_y_2 = $this->napdf_instance->h - $page_margins;
00106
00107
00108 $frontlist_x_offset = $frontpanel_max_x_offset + $panelpage['margin'] + $listpage['margin'];
00109 $frontlist_max_x_offset = $frontlist_x_offset + $listpage['width'];
00110 $frontlist_y_offset = $listpage['margin'];
00111 $frontlist_max_y_offset = $frontlist_y_offset + $listpage['height'];
00112
00113
00114 $backlist_page_1_x_offset = $listpage['margin'];
00115 $backlist_page_1_max_x_offset = $backlist_page_1_x_offset + $listpage['width'];
00116 $backlist_page_1_y_offset = $listpage['margin'];
00117 $backlist_page_1_max_y_offset = $backlist_page_1_y_offset + $listpage['height'];
00118
00119 $backlist_page_2_x_offset = $backlist_page_1_max_x_offset + ($listpage['margin'] * 2);
00120 $backlist_page_2_max_x_offset = $backlist_page_2_x_offset + $listpage['width'];
00121 $backlist_page_2_y_offset = $listpage['margin'];
00122 $backlist_page_2_max_y_offset = $backlist_page_2_y_offset + $listpage['height'];
00123
00124 global $columns, $maxwidth, $fSize, $y;
00125 $maxwidth = $listpage['width'] + 1;
00126 $columns = "";
00127 $fSize = $this->napdf_instance->FontSizePt;
00128
00129 foreach ( $meeting_data as &$meeting )
00130 {
00131 $meeting['location'] = $meeting['location_text'].', '.$meeting['location_street'];
00132 }
00133
00134 $this->napdf_instance->AddPage ( );
00135 $this->DrawRearPanel ( $backpanel_x_offset, $backpanel_y_offset, $backpanel_max_x_offset, $backpanel_max_y_offset, $this->napdf_instance->format_data );
00136
00137 $inPrinter_Date = date ( '\R\e\v\i\s\e\d F, Y' );
00138
00139 $this->DrawFrontPanel ( $frontpanel_x_offset, $frontpanel_y_offset, $frontpanel_max_x_offset, $frontpanel_max_y_offset, $inPrinter_Date );
00140
00141 $this->napdf_instance->Line ( $vertical_separator_x, $vertical_separator_y, $vertical_separator_x, $vertical_separator_y_2 );
00142
00143 $this->DrawListPage ( 4 );
00144 $this->DrawListPage ( 5 );
00145 $this->DrawListPage ( 6 );
00146 $this->DrawListPage ( 7 );
00147
00148 $this->napdf_instance->AddPage ( );
00149
00150 $this->DrawListPage ( 0 );
00151 $this->DrawListPage ( 1 );
00152 $this->DrawListPage ( 2 );
00153 $this->DrawListPage ( 3 );
00154 $this->DrawListPage ( 4 );
00155 $this->DrawListPage ( 5 );
00156 $this->DrawListPage ( 6 );
00157 $this->DrawListPage ( 7 );
00158 }
00159 $ret = true;
00160 }
00161
00162 return $ret;
00163 }
00164
00165
00166
00167 function OutputPDF ()
00168 {
00169 $d = date ( "Y_m_d" );
00170 $this->napdf_instance->Output( "NYC_PrintableList_$d.pdf", "D" );
00171 }
00172
00173
00174
00175
00176
00177 private function DrawListPage ( $in_column
00178 )
00179 {
00180 include ( dirname ( __FILE__ ).'/booklet_pdf_decls.php' );
00181 $meetings =& $this->napdf_instance->meeting_data;
00182
00183 $count_max = count ( $meetings );
00184
00185 $this->napdf_instance->SetFont ( $this->font, '', $this->font_size - 5 );
00186 $fontFamily = $this->napdf_instance->FontFamily;
00187 $fontSize = $this->napdf_instance->FontSizePt;
00188
00189 $column_width = (($this->napdf_instance->w - 0.5) / 8) - 0.05;
00190
00191 $top = 0.125;
00192 $left = 0.125 + (($column_width + 0.1) * $in_column);
00193 $bottom = $this->napdf_instance->h - 0.125;
00194 $right = $left + $column_width;
00195
00196 $heading_height = 9;
00197 $height = ($heading_height/72) + 0.01;
00198 $gap2 = 0.02;
00199
00200 $fSize = $fontSize / 70;
00201 $fSizeSmall = ($fontSize - 1) / 70;
00202
00203 $height_one_meeting = ($fSize * 6) + $gap2;
00204
00205 $y_offset = $bottom - $fSize;
00206
00207 $current_day = " ";
00208
00209 $extra_height = $height + 0.05;
00210
00211 $this->pos['y'] = $top;
00212 $watermark_pos = 1.0;
00213
00214 if ( $this->pos['start'] )
00215 {
00216 $this->pos['count'] = 0;
00217 }
00218
00219 while ( !$this->pos['end'] && (($this->pos['y'] + $height_one_meeting + $extra_height + ($fSizeSmall * 2)) < ($y_offset - 0.1)) )
00220 {
00221 $extra = 0;
00222 $contd = "";
00223 $desc = '';
00224
00225 $meeting = $meetings[intval($this->pos['count'])];
00226 $this->napdf_instance->SetLeftMargin ( $left );
00227
00228 if ( $this->pos['start'] || ($current_day != $meeting['weekday_tinyint']) )
00229 {
00230 $this->napdf_instance->SetFillColor ( 0 );
00231 $this->napdf_instance->SetTextColor ( 255 );
00232 if ( $this->pos['start'] )
00233 {
00234 $this->pos['start'] = "";
00235 }
00236 else
00237 {
00238 if ( ($this->pos['y'] == $top) && ($this->pos['weekday'] == $meeting['weekday_tinyint']) )
00239 {
00240 $contd = _PDF_CONTD;
00241 }
00242 }
00243
00244 if ( $current_day != $meeting['weekday_tinyint'] )
00245 {
00246 $this->pos['weekday'] = $meeting['weekday_tinyint'];
00247 $current_day = $this->pos['weekday'];
00248 }
00249
00250 $header = $this->weekday_names[$current_day - 1];
00251
00252 $header .= $contd;
00253
00254 $this->napdf_instance->SetFont ( $fontFamily, 'B', $heading_height );
00255 $this->napdf_instance->Rect ( $left, $this->pos['y'], ($right - $left), $height, "F" );
00256 $stringWidth = $this->napdf_instance->GetStringWidth ( $header );
00257 $cellleft = (($right + $left) / 2) - ($stringWidth / 2);
00258 $this->napdf_instance->SetXY ( $cellleft, $this->pos['y'] + 0.005 );
00259 $this->napdf_instance->Cell ( 0, $heading_height/72, $header );
00260 $this->pos['y'] += ($height);
00261 }
00262 else
00263 {
00264 $this->napdf_instance->Line ( $left, $this->pos['y'], $right, $this->pos['y'] );
00265 }
00266
00267 $this->napdf_instance->SetFillColor ( 255 );
00268 $this->napdf_instance->SetTextColor ( 0 );
00269
00270 $cell_top = $this->pos['y'] + $gap2;
00271 $this->napdf_instance->SetXY ( $left, $cell_top );
00272
00273 $this->napdf_instance->SetFont ( $fontFamily, '', $fontSize );
00274
00275 $display_string = self::translate_time ( $meeting['start_time'] );
00276 if ( $meeting['duration_time'] && ('01:30:00' != $meeting['duration_time']) )
00277 {
00278 $display_string .= " (".self::translate_duration ( $meeting['duration_time'] ).")";
00279 }
00280
00281 $this->napdf_instance->MultiCell ( $column_width, $fSize, utf8_decode ( $display_string ), 0, "L" );
00282
00283 $this->napdf_instance->SetFont ( $fontFamily, 'B', $fontSize );
00284
00285 $this->napdf_instance->SetX ( $left );
00286 $display_string = $meeting['meeting_name'];
00287
00288 $display_string .= " (".$this->RearrangeFormats ( $meeting['formats'] ).")";
00289
00290 $this->napdf_instance->SetX ( $left );
00291
00292 $this->napdf_instance->MultiCell ( $column_width, $fSize, utf8_decode ( $display_string ), 0, "L" );
00293
00294 $this->napdf_instance->SetFont ( $fontFamily, '', $fontSize );
00295
00296 if ( $meeting['location_neighborhood'] )
00297 {
00298 $display_string = $meeting['location_neighborhood'];
00299 $this->napdf_instance->SetX ( $left );
00300 $this->napdf_instance->MultiCell ( $column_width, $fSize, utf8_decode ( $display_string ), 0, "L" );
00301 }
00302
00303 $display_string = '';
00304
00305 if ( $meeting['location_text'] )
00306 {
00307 $display_string .= $meeting['location_text'];
00308 }
00309
00310 if ( $meeting['location_info'] )
00311 {
00312 if ( $display_string )
00313 {
00314 $display_string .= ', ';
00315 }
00316
00317 $display_string .= " (".$meeting['location_info'].")";
00318 }
00319
00320 if ( $display_string )
00321 {
00322 $display_string .= ', ';
00323 }
00324
00325 $display_string .= $meeting['location_street'];
00326
00327 $this->napdf_instance->SetX ( $left );
00328 $this->napdf_instance->MultiCell ( $column_width, $fSize, utf8_decode ( $display_string ), 0, "L" );
00329
00330 if ( $meeting['description_string'] )
00331 {
00332 if ( $desc )
00333 {
00334 $desc .= ", ";
00335 }
00336 $desc = $meeting['description_string'];
00337 }
00338
00339 if ( $meeting['comments'] )
00340 {
00341 if ( $desc )
00342 {
00343 $desc .= ", ";
00344 }
00345 $desc .= $meeting['comments'];
00346 }
00347
00348 $desc = preg_replace ( "/[\n|\r]/", ", ", $desc );
00349 $desc = preg_replace ( "/,\s*,/", ",", $desc );
00350 $desc = stripslashes ( stripslashes ( $desc ) );
00351
00352 if ( $desc )
00353 {
00354 $extra = ($fSizeSmall * 3);
00355 $this->napdf_instance->SetFont ( $fontFamily, 'I', $fontSize - 1 );
00356 $this->napdf_instance->SetX ( $left );
00357 $this->napdf_instance->MultiCell ( $column_width, $fSizeSmall, utf8_decode ( $desc ), 0, "L" );
00358 }
00359
00360 $yMax = max ( $yMax, $this->napdf_instance->GetY ( ) ) + $gap2;
00361 $this->pos['y'] = $yMax;
00362 $this->pos['count']++;
00363
00364 if ( $this->pos['count'] == $count_max )
00365 {
00366 $this->pos['end'] = 1;
00367 }
00368 else
00369 {
00370 $next_meeting = $meetings[intval($this->pos['count'])];
00371
00372 if ( $current_day != $next_meeting['weekday_tinyint'] )
00373 {
00374 $extra_height = $height + 0.05;
00375 }
00376 else
00377 {
00378 $extra_height = 0;
00379 }
00380 }
00381 }
00382 }
00383
00384
00385
00386 private function DrawRearPanel ( $left, $top, $right, $bottom, $formats )
00387 {
00388 $y = $top + 0.125;
00389
00390 $fontSize = $this->font_size;
00391
00392 $this->napdf_instance->SetFont ( $this->font, 'B', ($fontSize - 3) );
00393 $stringWidth = $this->napdf_instance->GetStringWidth ( _PDF_SASNA_LIST_FORMAT_KEY );
00394 $cellleft = (($right + $left) / 2) - ($stringWidth / 2);
00395
00396 $this->napdf_instance->SetXY ( $cellleft, $y );
00397
00398 $this->napdf_instance->Cell ( 0, 0, _PDF_SASNA_LIST_FORMAT_KEY );
00399 $y += 0.125;
00400
00401 $count = count ( $formats );
00402 $w1 = $left + 0.25;
00403 $fSize = $fontSize - 4;
00404
00405 $this->napdf_instance->SetY ( $y );
00406
00407 foreach ( $formats as $format )
00408 {
00409 $this->napdf_instance->SetFont ( $this->font, 'B', $fSize );
00410 $this->napdf_instance->SetLeftMargin ( $left );
00411 $str = $format['key_string'];
00412 $this->napdf_instance->SetX ( $left );
00413 $this->napdf_instance->Cell ( 0, 0.13, $str );
00414 $this->napdf_instance->SetFont ( $this->font, '', $fSize );
00415 $str = $format['description_string'];
00416 $this->napdf_instance->SetLeftMargin ( $w1 );
00417 $this->napdf_instance->SetX ( $w1 );
00418 $this->napdf_instance->MultiCell ( ($right - $w1), 0.13, $str );
00419 $this->napdf_instance->SetY ( $this->napdf_instance->GetY ( ) + 0.01 );
00420 }
00421
00422 $y = $this->napdf_instance->GetY ( ) + 0.1;
00423
00424 $this->napdf_instance->SetFont ( $fontFamily, 'B', $fontSize * 0.75 );
00425
00426 $this->napdf_instance->SetXY ( $left, $y );
00427 $this->napdf_instance->Cell ( 0, 0, _PDF_NYC_LIST_CORRECTIONS1 );
00428
00429 $this->napdf_instance->SetFont ( $fontFamily, '', $fontSize * 0.75 );
00430
00431 $x = $left + 0.25;
00432 $y = $this->napdf_instance->GetY ( ) + 0.25;
00433 $this->napdf_instance->SetXY ( $x, $y );
00434
00435 $this->napdf_instance->Cell ( 0, 0, _PDF_NYC_LIST_CORRECTIONS2 );
00436 $y = $this->napdf_instance->GetY ( ) + 0.17;
00437 $this->napdf_instance->SetXY ( $x, $y );
00438 $this->napdf_instance->Cell ( 0, 0, _PDF_NYC_LIST_CORRECTIONS3 );
00439 $y = $this->napdf_instance->GetY ( ) + 0.17;
00440 $this->napdf_instance->SetXY ( $x, $y );
00441 $this->napdf_instance->Cell ( 0, 0, _PDF_NYC_LIST_CORRECTIONS4 );
00442 $y = $this->napdf_instance->GetY ( );
00443
00444 $this->DrawSubcommittees ( $left, $y );
00445 }
00446
00447
00448 private function DrawSubcommittees ( $left, $y )
00449 {
00450 $right = $left + (($this->napdf_instance->w - 0.5) / 4);
00451
00452 $fontFamily = $this->napdf_instance->FontFamily;
00453 $fontSize = $this->napdf_instance->FontSizePt;
00454
00455 $s_array = array();
00456 $na_dom = new DOMDocument;
00457 if ( $na_dom )
00458 {
00459 if ( @$na_dom->loadHTML($this->call_curl ( "http://newyorkna.org/Events_and_Meetings/nyc.html" )) )
00460 {
00461 $div_contents = $na_dom->getElementByID ( "meeting_times" );
00462
00463 if ( $div_contents )
00464 {
00465 $p_list = $div_contents->getElementsByTagName ( "p" );
00466 if ( $p_list && $p_list->length )
00467 {
00468 for ( $i = 0; $i < $p_list->length; $i++ )
00469 {
00470 $the_item = $p_list->item($i);
00471 if ( $the_item )
00472 {
00473 if ( "first" == $the_item->getAttribute ( "class" ) )
00474 {
00475 $p_list2 = $the_item->getElementsByTagName ( "b" );
00476 $a['_name'] = $p_list2->item(0)->nodeValue;
00477 $a['_description'] = '';
00478
00479 while ( $p_list->item($i + 1) && ("first" != $p_list->item($i + 1)->getAttribute ( "class" )) )
00480 {
00481 if ( $a['_description'] )
00482 {
00483 $a['_description'] .= "\n";
00484 }
00485 $a['_description'] .= $p_list->item(++$i)->nodeValue;
00486 }
00487 }
00488
00489 array_push ( $s_array, $a );
00490 }
00491 }
00492 }
00493 }
00494 }
00495 }
00496
00497 $y += 0.125;
00498
00499 $this->napdf_instance->Line ( $left, $y, $right, $y );
00500
00501 $this->napdf_instance->SetXY ( $left, $y );
00502 $this->napdf_instance->SetFont ( $fontFamily, 'B', ($fontSize - 1) );
00503 $this->napdf_instance->SetLeftMargin ( $left );
00504
00505 $y += 0.125;
00506
00507 $this->napdf_instance->SetFont ( $fontFamily, 'B', ($fontSize - 1) );
00508 $stringWidth = $this->napdf_instance->GetStringWidth ( _PDF_NYC_LIST_SUBCOMMITTEES );
00509
00510 $cellleft = (($right + $left) / 2) - ($stringWidth / 2);
00511
00512 $this->napdf_instance->SetXY ( $cellleft, $y );
00513
00514 $this->napdf_instance->Cell ( 0, 0, _PDF_NYC_LIST_SUBCOMMITTEES );
00515
00516 $y += 0.125;
00517
00518 if ( is_array ( $s_array ) && count ( $s_array ) )
00519 {
00520 $this->napdf_instance->SetFont ( $fontFamily, 'B', ($fontSize - 2) );
00521
00522 $count = 0;
00523 $offset = 0;
00524 foreach ( $s_array as $row )
00525 {
00526 $offset = max ( $offset, ($this->napdf_instance->GetStringWidth ( $row['_name'] ) + 0.1) );
00527 $sub_table[$count++] = $row;
00528 }
00529
00530 for ( $c = 0; $c < $count; $c++ )
00531 {
00532 $this->napdf_instance->SetFont ( $fontFamily, 'B', ($fontSize - 2) );
00533 $this->napdf_instance->SetLeftMargin ( $left );
00534 $this->napdf_instance->SetXY ( $left, $y );
00535 $this->napdf_instance->MultiCell ( $offset, ($fontSize - 2) / 72, $sub_table[$c]['_name'] );
00536 $this->napdf_instance->SetFont ( $fontFamily, '', ($fontSize - 2) );
00537 $this->napdf_instance->SetLeftMargin ( $left + $offset );
00538 $this->napdf_instance->SetXY ( $left + $offset, $y );
00539 $this->napdf_instance->MultiCell ( ($right - ($left + $offset)), ($fontSize - 2) / 72, $sub_table[$c]['_description'] );
00540 $y = $this->napdf_instance->GetY ( ) + 0.1;
00541 }
00542 }
00543 }
00544
00545
00546
00547 private function DrawFrontPanel ( $left, $top, $right, $bottom, $date )
00548 {
00549 $inTitleGraphic = "../ny_printed_lists/images/NYC_Cover_Logo.jpg";
00550 $y = $top + 0.125;
00551
00552 $fontSize = $this->font_size;
00553
00554 $this->napdf_instance->SetFont ( $this->font, 'B', ($fontSize - 4) );
00555
00556 $stringWidth = $this->napdf_instance->GetStringWidth ( $date );
00557
00558 $cellleft = (($right + $left) / 2) - ($stringWidth / 2);
00559
00560 $this->napdf_instance->SetXY ( $cellleft, $y );
00561
00562 $this->napdf_instance->Cell ( 0, 0, $date );
00563 $y += 0.2;
00564
00565 $this->napdf_instance->SetFont ( $this->font, 'B', ($fontSize + 4) );
00566 $stringWidth = $this->napdf_instance->GetStringWidth ( _PDF_NYC_LIST_BANNER );
00567 $cellleft = (($right + $left) / 2) - ($stringWidth / 2);
00568
00569 $this->napdf_instance->SetXY ( $cellleft, $y );
00570
00571 $this->napdf_instance->Cell ( 0, 0, _PDF_NYC_LIST_BANNER );
00572 $y += 0.21;
00573
00574 $this->napdf_instance->SetFont ( $this->font, 'B', ($fontSize - 4) );
00575 $stringWidth = $this->napdf_instance->GetStringWidth ( _PDF_NYC_LIST_BANNER_2 );
00576 $cellleft = (($right + $left) / 2) - ($stringWidth / 2);
00577
00578 $this->napdf_instance->SetXY ( $cellleft, $y );
00579
00580 $this->napdf_instance->Cell ( 0, 0, _PDF_NYC_LIST_BANNER_2 );
00581 $y += 0.15;
00582
00583 $this->napdf_instance->SetFont ( $this->font, 'B', ($fontSize + 1) );
00584 $stringWidth = $this->napdf_instance->GetStringWidth ( _PDF_NYC_LIST_BANNER_3 );
00585 $cellleft = (($right + $left) / 2) - ($stringWidth / 2);
00586
00587 $this->napdf_instance->SetXY ( $cellleft, $y );
00588 $this->napdf_instance->Cell ( 0, 0, _PDF_NYC_LIST_BANNER_3 );
00589
00590 $this->napdf_instance->Image ( $inTitleGraphic, ($left + .60), 1.2, (($right - $left) - 1.25), 0, 'JPG' );
00591 $this->napdf_instance->SetFont ( $fontFamily, 'B', ($fontSize + 1) );
00592
00593 $y = 3.5;
00594 $cellleft = $left;
00595
00596 $this->napdf_instance->SetXY ( $cellleft, $y );
00597 $this->napdf_instance->Cell ( 0, 0, _PDF_NYC_LIST_HELPLINE_REGION );
00598 $y += 0.35;
00599
00600 $this->napdf_instance->SetFont ( $fontFamily, 'B', ($fontSize + 1) );
00601
00602 $this->napdf_instance->SetFont ( $fontFamily, 'B', ($fontSize + 2) );
00603 $url_string = _PDF_NYC_LIST_URL;
00604
00605 $stringWidth = $this->napdf_instance->GetStringWidth ( $url_string );
00606 $cellleft = (($right + $left) / 2) - ($stringWidth / 2);
00607
00608 $this->napdf_instance->SetXY ( $cellleft, $y );
00609
00610 $this->napdf_instance->Cell ( 0, 0, $url_string );
00611 $y += 0.3;
00612
00613 $cellleft = $left;
00614 $this->napdf_instance->SetXY ( $cellleft, $y );
00615 $st_width = $this->napdf_instance->GetStringWidth ( _PDF_NYC_LIST_NAME );
00616 $this->napdf_instance->Cell ( 0, 0, _PDF_NYC_LIST_NAME );
00617 $stringWidth = $this->napdf_instance->GetStringWidth ( _PDF_NYC_LIST_PHONE );
00618 $this->napdf_instance->SetXY ( $right - $stringWidth, $y );
00619 $this->napdf_instance->Cell ( 0, 0, _PDF_NYC_LIST_PHONE );
00620 $y += 0.125;
00621
00622 $this->napdf_instance->SetFont ( $fontFamily, '', $fontSize );
00623
00624 $this->napdf_instance->SetLineWidth ( 0.02 );
00625 $this->napdf_instance->Line ( $left + 0.0625, $y, $right, $y );
00626
00627 while ( $y < ($bottom - 0.3) )
00628 {
00629 $y += 0.3;
00630 $this->napdf_instance->Line ( $left + 0.0625, $y, $right, $y );
00631 }
00632 }
00633
00634
00635
00636 private function RearrangeFormats ( $inFormats )
00637 {
00638 $inFormats = split ( ",", $inFormats );
00639
00640 if ( !in_array ( "C", $inFormats ) && !in_array ( "O", $inFormats ) )
00641 {
00642 array_push ( $inFormats, "C" );
00643 }
00644
00645 if ( !$ignore_bk && !in_array ( "BK", $inFormats ) && ((in_array ( "BT", $inFormats ) || in_array ( "IW", $inFormats ) || in_array ( "JT", $inFormats ) || in_array ( "SG", $inFormats ))) )
00646 {
00647 array_push ( $inFormats, "BK" );
00648 }
00649
00650 uasort ( $inFormats, 'nyc_napdf::sort_cmp' );
00651
00652 $tFormats = $inFormats;
00653
00654 $inFormats = array();
00655
00656 foreach ( $tFormats as $format )
00657 {
00658 $format = trim ( $format );
00659 if ( $format )
00660 {
00661 array_push ( $inFormats, $format );
00662 }
00663 }
00664
00665 return join ( ",", $inFormats );
00666 }
00667
00668
00669
00670 private static function break_meetings_by_day ( $in_meetings_array )
00671 {
00672 $last_day = -1;
00673 $meetings_day = array();
00674
00675 foreach ( $in_meetings_array as $meeting )
00676 {
00677 if ( $meeting['weekday_tinyint'] != $last_day )
00678 {
00679 $last_day = $meeting['weekday_tinyint'] -1;
00680 }
00681
00682 $meetings_day[$last_day][] = $meeting;
00683 }
00684
00685 return $meetings_day;
00686 }
00687
00688
00689
00690 private static function sort_cmp ($a, $b)
00691 {
00692 $order_array = array( 0=>"O", 1=>"C",
00693 2=>"ES", 3=>"B", 4=>"M", 5=>"W", 6=>"GL", 7=>"YP", 8=>"BK", 9=>"IP", 10=>"Pi", 11=>"RF", 12=>"Rr",
00694 13=>"So", 14=>"St", 15=>"To", 16=>"Tr", 17=>"OE", 18=>"D", 19=>"SD", 20=>"TW", 21=>"IL",
00695 22=>"BL", 23=>"IW", 24=>"BT", 25=>"SG", 26=>"JT",
00696 27=>"Ti", 28=>"Sm", 29=>"NS", 30=>"CL", 31=>"CS", 32=>"NC", 33=>"SC", 34=>"CH", 35=>"SL", 36=>"WC" );
00697
00698 if ( in_array ( $a, $order_array ) || in_array ( $b, $order_array ) )
00699 {
00700 return (array_search ( $a, $order_array ) < array_search ( $b, $order_array )) ? -1 : 1;
00701 }
00702 else
00703 {
00704 return 0;
00705 }
00706 }
00707
00708
00709
00710 private static function translate_time ( $in_time_string )
00711 {
00712 $split = split ( ":", $in_time_string );
00713 if ( $in_time_string == "12:00:00" )
00714 {
00715 return "Noon";
00716 }
00717 elseif ( ($split[0] == "23") && (intval ( $split[1] ) > 45) )
00718 {
00719 return "Midnight";
00720 }
00721 else
00722 {
00723 return date ( "g:i A", strtotime ( $in_time_string ) );
00724 }
00725 }
00726
00727
00728
00729 private static function translate_duration ( $in_time_string )
00730 {
00731 $t = split ( ":", $in_time_string );
00732 $hours = intval ( $t[0] );
00733 $minutes = intval ( $t[1] );
00734
00735 $ret = '';
00736
00737 if ( $hours )
00738 {
00739 $ret .= "$hours hour";
00740
00741 if ( $hours > 1 )
00742 {
00743 $ret .= "s";
00744 }
00745
00746 if ( $minutes )
00747 {
00748 $ret .= " and ";
00749 }
00750 }
00751
00752 if ( $minutes )
00753 {
00754 $ret .= "$minutes minutes";
00755 }
00756
00757 return $ret;
00758 }
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768 private static function call_curl ( $in_uri,
00769 $in_post = true,
00770 &$http_status = null
00771 )
00772 {
00773 $ret = null;
00774
00775
00776 if ( !extension_loaded ( 'curl' ) )
00777 {
00778 if ( ini_get ( 'allow_url_fopen' ) )
00779 {
00780 $ret = file_get_contents ( $in_uri );
00781 }
00782 }
00783 else
00784 {
00785
00786 $resource = curl_init();
00787
00788
00789 if ( $in_post )
00790 {
00791 $spli = explode ( "?", $in_uri, 2 );
00792
00793 if ( is_array ( $spli ) && count ( $spli ) )
00794 {
00795 $in_uri = $spli[0];
00796 $in_params = $spli[1];
00797
00798 curl_setopt ( $resource, CURLOPT_POST, true );
00799 curl_setopt ( $resource, CURLOPT_POSTFIELDS, $in_params );
00800 }
00801 }
00802
00803
00804 curl_setopt ( $resource, CURLOPT_URL, $in_uri );
00805
00806
00807 curl_setopt ( $resource, CURLOPT_RETURNTRANSFER, true );
00808
00809
00810
00811
00812
00813 curl_setopt ( $resource, CURLOPT_HEADER, false );
00814
00815
00816
00817
00818
00819
00820 curl_setopt ( $resource, CURLOPT_MAXREDIRS, 3 );
00821
00822
00823 curl_setopt ( $resource, CURLOPT_CONNECTTIMEOUT, 10 );
00824
00825
00826 curl_setopt ( $resource, CURLOPT_ENCODING, 'gzip,deflate' );
00827
00828
00829 $content = curl_exec ( $resource );
00830
00831
00832 if ( $content === false )
00833 {
00834
00835 throw new Exception ( "curl failure calling $in_uri, ".curl_error ( $resource ).", ".curl_errno ( $resource ) );
00836 }
00837 else
00838 {
00839
00840
00841
00842
00843 $http_status = curl_getinfo ($resource, CURLINFO_HTTP_CODE );
00844 }
00845
00846
00847 curl_close ( $resource );
00848
00849
00850 if ( $content !== false )
00851 {
00852 $ret = $content;
00853 }
00854 }
00855
00856 return $ret;
00857 }
00858 };
00859 ?>