bkasc_napdf.class.php

Go to the documentation of this file.
00001 <?php
00002 /**
00003     \file gnyr_napdf.class.php
00004     
00005     \brief This file creates and dumps a GNYR meeting list in PDF form.
00006 */
00007 // Get the napdf class, which is used to fetch the data and construct the file.
00008 require_once ( dirname ( __FILE__ ).'/../pdf_generator/printableList.class.php' );
00009 require_once ( dirname ( __FILE__ ).'/pdf_decls.php' );
00010 define ( "_BK_MAIN_DESIGNATOR_", "B.A.S.C.N.A." );
00011 define ( "_BK_MAIN_STATEMENT_", "Brooklyn Area Meeting List" );
00012 define ( "_BK_URL_", "www.bsana.org" );
00013 define ( "_BK_BLURB_", "When at the end of the road we find that we can no longer function as a human being, either with or without drugs, we all face the same dilemma. What is there left to do? There seems to be this alternative: either go on as best we can to the bitter ends -jails, institutions or death- or find a new way to live. In years gone by, very few addicts ever had this last choice. Those who are addicted today are more fortunate. For the first time in mans entire history, a simple way has been proving itself in the lives of many addicts. It is available to us all. This is a simple spiritual -not religious- program, known as Narcotics Anonymous." );
00014 define ( "_BK_HELPLINE_", "Narcotics Anonymous Helpline (New York City): 212-929-NANA (6262)" );
00015 define ( "_BK_REVISED_", "Revised: " );
00016 define ( "_BK_GNY_", "Source: www.newyorkna.net/nameetings" );
00017 
00018 
00019 /**
00020     \brief  This creates and manages an instance of the napdf class, and creates
00021     the PDF file.
00022 */
00023 class bkasc_napdf extends printableList implements IPrintableList
00024 {
00025     var $weekday_names = array ( "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" );
00026     var $pos = array ( 'start' => 1, 'end' => '', 'count' => 0, 'y' => 0, 'weekday' => 1 );
00027     var $right_offset = 0;
00028     var $formats = 0;
00029     
00030     /********************************************************************
00031         \brief  The constructor for this class does a lot. It creates the instance of the napdf class, gets the data from the
00032         server, then sorts it. When the constructor is done, the data is ready to be assembled into a PDF.
00033         
00034         If the napdf object does not successfully get data from the server, then it is set to null.
00035     */
00036     function __construct ( $in_http_vars    ///< The HTTP parameters we'd like to send to the server.
00037                             )
00038     {
00039         $this->page_x = 7;      ///< The width, in inches, of each page
00040         $this->page_y = 8.5;        ///< The height, in inches, of each page.
00041         $this->units = 'in';        ///< The measurement units (inches)
00042         $this->font = 'Helvetica';      ///< The font we'll use
00043         $this->font_size = 7.25;    ///< The font size we'll use
00044         $this->orientation = 'P';   ///< The orientation (portrait)
00045         /// These are the sort keys, for sorting the meetings before display
00046         $this->sort_keys = array (  'weekday_tinyint' => true,          ///< First, weekday
00047                                     'start_time' => true,               ///< Finally, the time the meeting starts
00048                                     'week_starts' => 1                  ///< Our week starts on Sunday (1)
00049                                     );
00050         /// These are the parameters that we send over to the root server, in order to get our meetings.
00051         $this->out_http_vars = array ('do_search' => 'yes',                     ///< Do a search
00052                                     'meeting_key' => 'location_city_subsection',    ///< We'll be looking for a borough...
00053                                     'meeting_key_value' => 'brooklyn',      ///< named 'brooklyn'.
00054                                     'meeting_key_contains' => '1'           ///< Just as long as its contained in the borough.
00055                                     );
00056         
00057         $this->lang_search = array ( 'en', 'es' );
00058 
00059         napdf::$sort_callback = 'bkasc_napdf::sort_meeting_data_callback_ny';
00060         
00061         parent::__construct ( $in_http_vars, $this->lang_search );
00062     }
00063     /*************************** INTERFACE FUNCTIONS ***************************/
00064     /********************************************************************
00065         \brief This function actually assembles the PDF. It does not output it.
00066         
00067         \returns a boolean. true if successful.
00068     */
00069     function AssemblePDF ()
00070     {
00071         $ret = false;
00072         
00073         if ( $this->napdf_instance instanceof napdf )
00074             {
00075             $layout = $this->_Set_Page_Layout ( );
00076             
00077             $this->BK_DrawFrontCover ( $layout );
00078             
00079             $this->DrawFormatPage ( );
00080             
00081             while ( $this->BK_DrawOneListPage ( $layout ) );
00082             
00083             $this->BK_DrawChangeForm ( $layout );
00084 
00085             $ret = true;
00086             }
00087         
00088         return $ret;
00089     }
00090     
00091     /********************************************************************
00092     */
00093     function OutputPDF ()
00094     {
00095         $d = date ( "Y_m_d" );
00096         $this->napdf_instance->Output( "BKASC_PrintableList_$d.pdf", "D" );
00097     }
00098     
00099     /*************************** INTERNAL FUNCTIONS ***************************/
00100     /********************************************************************
00101     */
00102     private static function sort_cmp_formats ($a, $b) 
00103     {
00104     $order_array = array(   0=>"C", 1=>"O",
00105                             2=>"ES", 3=>"B", 4=>"M", 5=>"W", 6=>"GL", 7=>"YP", 8=>"BK", 9=>"IP", 10=>"Pi", 11=>"RF", 12=>"Rr",
00106                             13=>"So", 14=>"St", 15=>"To", 16=>"Tr", 17=>"OE", 18=>"D", 19=>"SD", 20=>"TW", 21=>"IL",
00107                             22=>"BL", 23=>"IW", 24=>"BT", 25=>"SG", 26=>"JT",
00108                             27=>"Ti", 28=>"Sm", 29=>"NS", 30=>"CL", 31=>"CS", 32=>"NC", 33=>"SC", 34=>"CH", 35=>"SL", 36=>"WC" );
00109     
00110     if ( in_array ( $a['key_string'], $order_array ) || in_array ( $b['key_string'], $order_array ) )
00111         {
00112         return (array_search ( $a['key_string'], $order_array ) < array_search ( $b['key_string'], $order_array )) ? -1 : 1;
00113         }
00114     else
00115         {
00116         return 0;
00117         }
00118     }
00119 
00120     /********************************************************************
00121         \brief Combines the two languages for a common format display.
00122         
00123         \returns a new array, with the format data sorted out. The Spanish
00124         description is appended to the description by a line feed.
00125     */
00126     private static function sort_formats( $in_format_data   ///< An array of format information
00127                                         )
00128     {
00129         $ret = array();
00130         
00131         foreach ( $in_format_data as $format )
00132             {
00133             if ( $format['lang'] == 'en' )  // We skip the Spanish, and only work on the English.
00134                 {
00135                 $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);
00136                 $r_temp = array (   'key_string' => $format['key_string'],
00137                                     'description_string' => '('.$format['name_string'].') '.$format['description_string']
00138                                     );
00139                 if ( $s_desc )
00140                     {
00141                     $r_temp['description_string'] .= "\n$s_desc";
00142                     }
00143                 
00144                 array_push ( $ret, $r_temp );
00145                 }
00146             }
00147         
00148         usort ( $ret, 'bkasc_napdf::sort_cmp_formats' );
00149         
00150         return $ret;
00151     }
00152     
00153     /********************************************************************
00154     */
00155     private function DrawFormatPage ( )
00156     {
00157     $formats = self::sort_formats ( $this->napdf_instance->format_data );
00158 
00159     $this->napdf_instance->SetFont ( $this->font, '', $this->font_size );
00160     $heading_height = 9;
00161     $height = ($heading_height/72) + 0.01;
00162     $top = 0.125;
00163     $left = 0.125;
00164     $bottom = $this->napdf_instance->h - 0.125;
00165     $right = $this->napdf_instance->w - 0.125;
00166     $fontFamily = $this->napdf_instance->FontFamily;
00167     $fontSize = $this->napdf_instance->FontSizePt;
00168     $fontSizeSmaller = $fontSize - 0.3;
00169     $fSize = $fontSizeSmaller / 72;
00170     $this->right_offset = 0.4;
00171     $space_needed = (($fontSizeSmaller / 72) * 5) + 0.02;
00172     $y_offset = $bottom - $fSize;
00173     
00174     $newpage = 2;
00175     
00176     $countmax = count ( $formats );
00177         
00178     $alt_color = 255;
00179     
00180     for ( $count = 0; $count < $countmax; $count++ )
00181         {
00182         $alt_color = ($alt_color == 255) ? 225 : 255;
00183         $format_code = $formats[$count]['key_string'];
00184         $format_desc = $formats[$count]['description_string'];
00185         
00186         if ( $format_code )
00187             {
00188             if ( $newpage )
00189                 {
00190                 $alt_color = 225;
00191                 $this->napdf_instance->AddPage();
00192                 $this->napdf_instance->SetFont ( $fontFamily, 'B', 7 );
00193                 $this->napdf_instance->Line ( $left, $y_offset - 0.1, $right, $y_offset - 0.1 );
00194                 $this->napdf_instance->SetXY ( $left, $y_offset );
00195                 global $resized;
00196                 
00197                 $this->napdf_instance->SetXY ( $right, $y_offset );
00198                 $this->napdf_instance->Cell ( 0, 0, _PDF_PAGE." ".$this->napdf_instance->PageNo(), 0, 0, "R" );
00199                 $this->napdf_instance->SetFont ( $fontFamily, '', $fontSize );
00200                 $this->napdf_instance->SetFillColor ( 0 );
00201                 $this->napdf_instance->SetTextColor ( 255 );
00202                 $header = ""._PDF_LEGEND_HEADER."";
00203                 if ( $newpage != 2 )
00204                     {
00205                     $header .= _PDF_CONTD;
00206                     }
00207                 
00208                 $this->napdf_instance->SetFont ( $fontFamily, 'B', $heading_height );
00209                 $stringWidth = $this->napdf_instance->GetStringWidth ( utf8_decode ( $header ) );
00210                 $cellleft = (($right + $left) / 2) - ($stringWidth / 2);
00211                 $this->napdf_instance->Rect ( $left, $top, ($right - $left), $height, "F" );
00212                 $this->napdf_instance->SetXY ( $cellleft, $top + 0.01 );
00213                 $this->napdf_instance->Cell ( 0, $heading_height/72, utf8_decode ( $header ) );
00214                 $this->napdf_instance->SetFillColor ( 255 );
00215                 $this->napdf_instance->SetTextColor ( 0 );
00216                 $newpage = "";
00217                 $this->napdf_instance->SetY ( $top + $height );
00218                 }
00219             
00220             $y = $this->napdf_instance->GetY();
00221             
00222             $height = ($fSize * 2) + 0.02;
00223             $this->napdf_instance->SetFillColor ( $alt_color );
00224             $this->napdf_instance->Rect ( $left, $y, ($right - $left), $height, "F" );
00225 
00226             $this->napdf_instance->SetY($this->napdf_instance->GetY()+ 0.01);
00227             $y = $this->napdf_instance->GetY();
00228             $this->napdf_instance->SetFont ( $fontFamily, 'B', $fontSizeSmaller );
00229             $this->napdf_instance->SetLeftMargin ( $left );
00230             $this->napdf_instance->SetXY ( $left, $y );
00231             $this->napdf_instance->MultiCell ( $this->right_offset - $left, $fSize, utf8_decode ( $format_code ), 0, "L" );
00232     
00233             $this->napdf_instance->SetFont ( $fontFamily, '', $fontSizeSmaller );
00234             $this->napdf_instance->SetLeftMargin ( $this->right_offset );
00235             $this->napdf_instance->SetXY ( $this->right_offset, $y );
00236             $this->napdf_instance->MultiCell ( $right - $this->right_offset, $fSize, utf8_decode ( $format_desc ), 0, "L" );
00237             
00238             if ( ($this->napdf_instance->GetY() + 0.01 + $space_needed) >= $y_offset )
00239                 {
00240                 $newpage = 1;
00241                 }
00242             else
00243                 {
00244                 $this->napdf_instance->SetY($this->napdf_instance->GetY()+ 0.01);
00245                 }
00246             }
00247         }
00248     
00249     if ( ($this->napdf_instance->GetY() + 0.3 + $fSize/72) > $y_offset )
00250         {
00251         $this->napdf_instance->AddPage();
00252         $y = $y_offset;
00253         }
00254     else
00255         {
00256         $y = $this->napdf_instance->GetY() + 0.3;
00257         }
00258     }
00259 
00260     /********************************************************************
00261     */
00262     private function RearrangeFormats ( $inFormats )
00263     {
00264     $inFormats = split ( ",", $inFormats );
00265     
00266     if ( !in_array ( "C", $inFormats ) && !in_array ( "O", $inFormats ) )
00267         {
00268         array_push ( $inFormats, "C" );
00269         }
00270     
00271     if ( !$ignore_bk && !in_array ( "BK", $inFormats ) && ((in_array ( "BT", $inFormats ) || in_array ( "IW", $inFormats ) || in_array ( "JT", $inFormats ) || in_array ( "SG", $inFormats ))) )
00272         {
00273         array_push ( $inFormats, "BK" );
00274         }
00275     
00276     uasort ( $inFormats, 'bkasc_napdf::sort_cmp' );
00277     
00278     $tFormats = $inFormats;
00279     
00280     $inFormats = array();
00281     
00282     foreach ( $tFormats as $format )
00283         {
00284         $format = trim ( $format );
00285         if ( $format )
00286             {
00287             array_push ( $inFormats, $format );
00288             }
00289         }
00290     
00291     return join ( ",", $inFormats );
00292     }
00293 
00294     /********************************************************************
00295     */
00296     private static function sort_cmp ($a, $b) 
00297     {
00298     $order_array = array(   0=>"C", 1=>"O",
00299                             2=>"ES", 3=>"B", 4=>"M", 5=>"W", 6=>"GL", 7=>"YP", 8=>"BK", 9=>"IP", 10=>"Pi", 11=>"RF", 12=>"Rr",
00300                             13=>"So", 14=>"St", 15=>"To", 16=>"Tr", 17=>"OE", 18=>"D", 19=>"SD", 20=>"TW", 21=>"IL",
00301                             22=>"BL", 23=>"IW", 24=>"BT", 25=>"SG", 26=>"JT",
00302                             27=>"Ti", 28=>"Sm", 29=>"NS", 30=>"CL", 31=>"CS", 32=>"NC", 33=>"SC", 34=>"CH", 35=>"SL", 36=>"WC" );
00303     
00304     if ( in_array ( $a, $order_array ) || in_array ( $b, $order_array ) )
00305         {
00306         return (array_search ( $a, $order_array ) < array_search ( $b, $order_array )) ? -1 : 1;
00307         }
00308     else
00309         {
00310         return 0;
00311         }
00312     }
00313 
00314     /********************************************************************
00315     */
00316     private static function FindFormatPos ( $in_key, $in_format_array )
00317     {
00318         $c = -1;
00319         
00320         foreach ( $in_format_array as $format )
00321             {
00322             $c++;
00323             
00324             if ( $in_key == $format['key_string'] )
00325                 {
00326                 break;
00327                 }
00328             }
00329         
00330         return $c;
00331     }
00332     
00333     /********************************************************************
00334     */
00335     private static function translate_time ( $in_time_string ) 
00336     {
00337         $split = split ( ":", $in_time_string );
00338         if ( $in_time_string == "12:00:00" )
00339             {
00340             return "Noon";
00341             }
00342         elseif ( ($split[0] == "23") && (intval ( $split[1] ) > 45) )
00343             {
00344             return "Midnight";
00345             }
00346         else
00347             {
00348             return date ( "g:i A", strtotime ( $in_time_string ) );
00349             }
00350     }
00351 
00352     /********************************************************************
00353     */
00354     private static function translate_duration ( $in_time_string ) 
00355     {
00356         $t = split ( ":", $in_time_string );
00357         $hours = intval ( $t[0] );
00358         $minutes = intval ( $t[1] );
00359         
00360         $ret = '';
00361         
00362         if ( $hours )
00363             {
00364             $ret .= "$hours hour";
00365             
00366             if ( $hours > 1 )
00367                 {
00368                 $ret .= "s";
00369                 }
00370                 
00371             if ( $minutes )
00372                 {
00373                 $ret .= " and ";
00374                 }
00375             }
00376         
00377         if ( $minutes )
00378             {
00379             $ret .= "$minutes minutes";
00380             }
00381         
00382         return $ret;
00383     }
00384     
00385     /**
00386         \brief  This is a static callback function to be used for sorting the multi-dimensional meeting_data
00387                 array. It uses the sort_order_keys array to determine the sort.
00388                 
00389         \returns an integer. -1 if a < b, 0 if a == b, or 1 if a > b.
00390     */
00391     static function sort_meeting_data_callback_ny ( &$in_a,     ///< The first meeting array to compare
00392                                                     &$in_b      ///< The second meeting array to compare
00393                                                     )
00394     {
00395         $ret = 0;
00396         
00397         if ( is_array ( $in_a ) && is_array ( $in_b ) && is_array ( napdf::$sort_order_keys ) )
00398             {
00399             // We reverse the array, in order to sort from least important to most important.
00400             $sort_keys = array_reverse ( napdf::$sort_order_keys, true );
00401 
00402             foreach ( $sort_keys as $key => $value )
00403                 {
00404                 if ( isset ( $in_a[$key] ) && isset ( $in_b[$key] ) )
00405                     {
00406                     $val_a = trim ( $in_a[$key] );
00407                     $val_b = trim ( $in_b[$key] );
00408 
00409                     if ( ('weekday_tinyint' == $key) && (napdf::$week_starts > 1) && (napdf::$week_starts < 8) )
00410                         {
00411                         $val_a -= napdf::$week_starts;
00412 
00413                         if ( $val_a < 0 )
00414                             {
00415                             $val_a += 8;
00416                             }
00417                         else
00418                             {
00419                             $val_a += 1;
00420                             }
00421                         
00422                         $val_b -= napdf::$week_starts;
00423                         
00424                         if ( $val_b < 0 )
00425                             {
00426                             $val_b += 8;
00427                             }
00428                         else
00429                             {
00430                             $val_b += 1;
00431                             }
00432                         }
00433 
00434                     // We know a few keys already, and we can determine how the sorting goes from there.
00435                     switch ( $key )
00436                         {
00437                         case 'start_time':
00438                         case 'duration_time':
00439                             $val_a = strtotime ( $val_a );
00440                             $val_b = strtotime ( $val_b );
00441                         case 'weekday_tinyint':
00442                         case 'id_bigint':
00443                         case 'shared_group_id_bigint':
00444                         case 'service_body_bigint':
00445                             $val_a = intval ( $val_a );
00446                             $val_b = intval ( $val_b );
00447                         case 'longitude':
00448                         case 'latitude':
00449                             if ( $val_a > $val_b )
00450                                 {
00451                                 $ret = 1;
00452                                 }
00453                             elseif ( $val_b > $val_a )
00454                                 {
00455                                 $ret = -1;
00456                                 }
00457                         break;
00458                         
00459                         default:
00460                             // We ignore blank values
00461                             if ( strlen ( $val_a ) && strlen ( $val_b ) )
00462                                 {
00463                                 $tmp = strcmp ( strtolower ( $val_a ), strtolower ( $val_b ) );
00464                                 
00465                                 if ( $tmp != 0 )
00466                                     {
00467                                     $ret = $tmp;
00468                                     }
00469                                 }
00470                         break;
00471                         }
00472                     }
00473                 
00474                 if ( !$value )
00475                     {
00476                     $ret = -$ret;
00477                     }
00478                 }
00479             
00480             $county_a = trim ( $in_a['location_city_subsection'] );
00481             if ( !$county_a )
00482                 {
00483                 $county_a = trim ( $in_a['location_sub_province'] );
00484                 }
00485             
00486             $county_b = trim ( $in_b['location_city_subsection'] );
00487             if ( !$county_b )
00488                 {
00489                 $county_b = trim ( $in_b['location_sub_province'] );
00490                 }
00491             
00492             if ( isset ( $county_a ) && isset ( $county_b ) )
00493                 {
00494                 $tmp = strcmp ( strtolower ( $county_a ), strtolower ( $county_b ) );
00495                 
00496                 if ( $tmp != 0 )
00497                     {
00498                     $ret = $tmp;
00499                     }
00500                 }
00501             }
00502         
00503         return $ret;
00504     }
00505         
00506     /***************************************************************************************************
00507     ***************************************************************************************************/
00508     function BK_DrawFrontCover ( $in_layout )
00509         {
00510         $top = $in_layout['page_metrics']['margin']['top'];
00511         $left = $in_layout['page_metrics']['margin']['left'];
00512         $bottom = $this->napdf_instance->h - $in_layout['page_metrics']['margin']['bottom'];
00513         $right = $this->napdf_instance->w - $in_layout['page_metrics']['margin']['right'];
00514         $inTitleGraphic = "../ny_printed_lists/images/ELI_Cover_Logo.png";
00515     
00516         $this->napdf_instance->AddPage();
00517     
00518         $this->napdf_instance->Image ( $inTitleGraphic, ($right + $left) / 2 - 1, $top + 0.25, 2, 2 );
00519         
00520         $y = 2.75;
00521         
00522         $str = _BK_MAIN_DESIGNATOR_;
00523         
00524         $this->napdf_instance->SetFont ( "Helvetica", "B", 16 );
00525         $stw = $this->napdf_instance->GetStringWidth ( utf8_decode ( $str ) );
00526         
00527         $this->napdf_instance->SetXY ( (($right + $left) / 2) - ($stw / 2), $y ); 
00528     
00529         $this->napdf_instance->Cell ( 0, 14/72, utf8_decode ( $str ) );
00530         
00531         $y += 0.25;
00532         
00533         $str = _BK_MAIN_STATEMENT_;
00534         
00535         $this->napdf_instance->SetFont ( "Helvetica", "B", 14 );
00536         $stw = $this->napdf_instance->GetStringWidth ( utf8_decode ( $str ) );
00537         
00538         $this->napdf_instance->SetXY ( (($right + $left) / 2) - ($stw / 2), $y ); 
00539     
00540         $this->napdf_instance->Cell ( 0, 14/72, utf8_decode ( $str ) );
00541         
00542         $y += 0.25;
00543         
00544         $str = _BK_URL_;
00545         
00546         $this->napdf_instance->SetFont ( "Helvetica", "B", 12 );
00547         $stw = $this->napdf_instance->GetStringWidth ( utf8_decode ( $str ) );
00548         
00549         $this->napdf_instance->SetXY ( (($right + $left) / 2) - ($stw / 2), $y ); 
00550     
00551         $this->napdf_instance->Cell ( 0, 12/72, utf8_decode ( $str ) );
00552         
00553         $y += 0.35;
00554         
00555         $this->napdf_instance->SetLineWidth ( 0.025 );
00556         $this->napdf_instance->Rect ( $left + 1, $y - 0.05, $right - ($left + 2), 3.25 );
00557         
00558         $str = _BK_BLURB_;
00559         
00560         $this->napdf_instance->SetFont ( "Helvetica", "", 9 );
00561         
00562         $this->napdf_instance->SetXY ( $left + 1, $y ); 
00563     
00564         $this->napdf_instance->MultiCell ( ($right - 1) - ($left + 1), 9/72, utf8_decode ( $str ), 0, "L" );
00565         
00566         $y = $this->napdf_instance->GetY() + 18/72;
00567         $this->napdf_instance->SetLineWidth ( 0.01 );
00568         
00569         $this->napdf_instance->Line ( $left + 1.25, $y - 9/72, $right - 1.25, $y - 9/72 );
00570         
00571         $str = _PDF_BROOKLYN_JFT_TEXT;
00572         
00573         $this->napdf_instance->SetFont ( "Helvetica", "", 9 );
00574         
00575         $this->napdf_instance->SetXY ( $left + 1, $y ); 
00576     
00577         $this->napdf_instance->MultiCell ( ($right - 1) - ($left + 1), 9/72, utf8_decode ( $str ), 0, "L" );
00578         
00579         $y = $this->napdf_instance->GetY() + 0.25;
00580             
00581         $str = _BK_HELPLINE_;
00582         
00583         $this->napdf_instance->SetFont ( "Helvetica", "B", 10 );
00584         $stw = $this->napdf_instance->GetStringWidth ( utf8_decode ( $str ) );
00585         
00586         $this->napdf_instance->SetXY ( (($right + $left) / 2) - ($stw / 2), $y ); 
00587     
00588         $this->napdf_instance->Cell ( 0, 10/72, utf8_decode ( $str ) );
00589         
00590         $y = $bottom - 0.25;
00591         
00592         $str = _BK_GNY_;
00593         
00594         $this->napdf_instance->SetFont ( "Helvetica", "I", 9 );
00595         $stw = $this->napdf_instance->GetStringWidth ( utf8_decode ( $str ) );
00596         
00597         $this->napdf_instance->SetXY ( $left + 0.1, $y ); 
00598     
00599         $this->napdf_instance->Cell ( 0, 9/72, utf8_decode ( $str ) );
00600         
00601         $str = _BK_REVISED_ . date ( "F, Y" );
00602         
00603         $this->napdf_instance->SetFont ( "Helvetica", "B", 10 );
00604         $stw = $this->napdf_instance->GetStringWidth ( utf8_decode ( $str ) );
00605         
00606         $this->napdf_instance->SetXY ( $right - ($stw + 0.1), $y ); 
00607     
00608         $this->napdf_instance->Cell ( 0, 10/72, utf8_decode ( $str ) );
00609         }
00610         
00611     /***************************************************************************************************
00612     ***************************************************************************************************/
00613     function BK_DrawChangeForm ( $in_layout )
00614         {
00615         $top = $in_layout['page_metrics']['margin']['top'];
00616         $left = $in_layout['page_metrics']['margin']['left'];
00617         $bottom = $this->napdf_instance->h - $in_layout['page_metrics']['margin']['bottom'];
00618         $right = $this->napdf_instance->w - $in_layout['page_metrics']['margin']['right'];
00619         $v_gap = $in_layout['data']['Meta']["V Gap"];
00620         $font_size = $in_layout[page_metrics]['font_size'];
00621         $height_row = $font_size/72 + $v_gap;
00622         $inTitleGraphic = "../ny_printed_lists/images/ELI_Cover_Logo.png";
00623     
00624         $this->napdf_instance->AddPage();
00625     
00626         // The NA Symbol. 1-Inch diameter.
00627         $this->napdf_instance->Image ( $inTitleGraphic, $left, $top, 1, 1 );
00628             
00629         $x = $left;
00630         $x_max = $left + 1;
00631         $y = $top + 1.125;
00632     
00633         // The URL, just under the NA symbol.   
00634         $this->BK_DrawString ( _PDF_BROOKLYN_VISIT, $x_max, $x, $y, "c", 7, "Helvetica" );
00635         $this->BK_DrawString ( _PDF_BROOKLYN_URL, $x_max, $x, 0, "c", 8.5, "Helvetica", "B" );
00636     
00637         $y_start = $this->napdf_instance->GetY() + ($v_gap * 2);
00638         
00639         $x = $left + 1.25;
00640         $x_max = $right;
00641         $y = $top;
00642     
00643         // The header
00644         $this->BK_DrawString ( _PDF_BROOKLYN_ASC_HEADER, $x_max, $x, $y, "c", 20, "Times", "B" );
00645         $this->BK_DrawString ( _PDF_BROOKLYN_ASC_NAME, $x_max, $x, 0, "c", 14, "Times" );
00646         $this->BK_DrawString ( _PDF_BROOKLYN_UPDATE, $x_max, $x, 0, "c", 16, "Times", "B" );
00647         
00648         // The GSR note
00649         $this->BK_DrawString ( _PDF_BROOKLYN_NOTE_GSR, $x_max, $x, $this->napdf_instance->GetY() + ($v_gap * 2), "", 9, "Helvetica", "i" );
00650         
00651         // The Submitter Info
00652     
00653         $x = $left;
00654         $x_max = $left + 2;
00655         $y = $y_start - 0.25;
00656         $this->napdf_instance->SetLineWidth ( 0.01 );
00657         
00658         $this->BK_DrawString ( _PDF_BROOKLYN_NAME, $x_max, $x, $y, "r", 10, "Times", "B" );
00659         
00660         $y = $this->napdf_instance->GetY();
00661         
00662         $this->napdf_instance->Line ( $x_max + 0.1, $y, $right, $y );
00663         
00664         $this->BK_DrawString ( _PDF_BROOKLYN_PHONE, $x_max, $x, $y + 0.15, "r", 10, "Times", "B" );
00665         
00666         $y = $this->napdf_instance->GetY();
00667         
00668         $this->napdf_instance->Line ( $x_max + 0.1, $y, $right, $y );
00669     
00670         $this->BK_DrawString ( _PDF_BROOKLYN_EMAIL, $x_max, $x, $y + 0.15, "r", 10, "Times", "B" );
00671         
00672         $y = $this->napdf_instance->GetY();
00673         
00674         $this->napdf_instance->Line ( $x_max + 0.1, $y, $right, $y );
00675     
00676         $this->BK_DrawString ( _PDF_BROOKLYN_GSP, $x_max, $x, $y + 0.15, "r", 10, "Times", "B" );
00677         
00678         $y = $this->napdf_instance->GetY();
00679         
00680         $this->napdf_instance->Line ( $x_max + 0.1, $y, $right, $y );
00681     
00682         $y += 0.05;
00683         $this->napdf_instance->SetLineWidth ( 0.025 );
00684         $this->napdf_instance->Line ( $left, $y, $right, $y );
00685         $y += 0.05;
00686         $x_max = $left + 1.125;
00687     
00688         $this->BK_DrawString ( _PDF_BROOKLYN_CHANGE_TYPE, $x_max, $x, $y, "r", 9, "Helvetica", "B" );
00689         
00690         $r_w = $r_h = 0.125;
00691         $this->napdf_instance->SetLineWidth ( 0.01 );
00692         $x_max = $right;
00693     
00694         
00695         $x = $left + 1.25;
00696         $this->napdf_instance->Rect ( $x, $y+ 0.01, $r_w, $r_h );
00697         $x += ($r_w + 0.01);
00698     
00699         $d_s = $this->BK_DrawString ( _PDF_BROOKLYN_CHANGE_TYPE_CLOSED, $x_max, $x, $y, "", 9, "Helvetica", "" );
00700         
00701         $x += $d_s['width'] + 0.25;
00702         $this->napdf_instance->Rect ( $x, $y+ 0.01, $r_w, $r_h );
00703         $x += ($r_w + 0.01);
00704     
00705         $d_s = $this->BK_DrawString ( _PDF_BROOKLYN_CHANGE_TYPE_NEW, $x_max, $x, $y, "", 9, "Helvetica", "" );
00706             
00707         $x += $d_s['width'] + 0.25;
00708         $this->napdf_instance->Rect ( $x, $y+ 0.01, $r_w, $r_h );
00709         $x += ($r_w + 0.01);
00710     
00711         $d_s = $this->BK_DrawString ( _PDF_BROOKLYN_CHANGE_TYPE_CHANGED, $x_max, $x, $y, "", 9, "Helvetica", "" );
00712         
00713         $y = ($d_s['y'] + 0.065);
00714         $this->napdf_instance->SetLineWidth ( 0.025 );
00715         $this->napdf_instance->Line ( $left, $y, $right, $y );
00716         
00717         $y += 0.065;
00718     
00719         $d_s = $this->BK_DrawString ( _PDF_BROOKLYN_HEADER_FORMAT, $right, $left, $y, "C", 12, "Helvetica", "B" );
00720         
00721         $y = $d_s['y'];
00722         
00723         $d_s = $this->BK_DrawString ( _PDF_BROOKLYN_NOTE_FORMAT, $right, $left, $y, "C", 9, "Helvetica", "I" );
00724         
00725         // Format Checkboxes
00726         
00727         $y = ($d_s['y'] + 0.065);
00728         $col = -1;
00729         $x = $left;
00730         $cell_size = 0.5;
00731         $this->napdf_instance->SetLineWidth ( 0.01 );
00732         $this->napdf_instance->SetFont ( "Helvetica", "B", 10 );
00733         
00734         $formats = self::sort_formats ( $this->napdf_instance->format_data );
00735         foreach ( $formats as $format )
00736             {
00737             if ( $format['key_string'] )
00738                 {
00739                 if ( $col++ > 11 )
00740                     {
00741                     $col = 0;
00742                     $x = $left;
00743                     $y += 0.25;
00744                     }
00745                 $this->napdf_instance->Rect ( $x, $y+ 0.01, $r_w, $r_h );
00746                 $this->napdf_instance->SetXY ( $x + $r_w, $y );
00747                 $this->napdf_instance->Cell ( 0, 10/72, utf8_decode (  $format['key_string'] ) );
00748                 $x += $cell_size;
00749                 }
00750             }
00751         
00752         $y += 0.25;
00753         $this->napdf_instance->SetLineWidth ( 0.025 );
00754         $this->napdf_instance->Line ( $left, $y, $right, $y );
00755         
00756         $y += 0.065;
00757     
00758         $d_s = $this->BK_DrawString ( _PDF_BROOKLYN_HEADER_LOCATION, $right, $left, $y, "C", 12, "Helvetica", "B" );
00759     
00760         $y = ($d_s['y'] + 0.15);
00761     
00762         $x = $left;
00763         $x_max = $left + 1.1;
00764         $this->napdf_instance->SetLineWidth ( 0.01 );
00765         
00766         $d_s = $this->BK_DrawString ( _PDF_BROOKLYN_LOCATION_MEETING_NAME, $x_max, $x, $y, "r", 10, "Times", "B" );
00767         
00768         $y = $d_s['y'];
00769         
00770         $this->napdf_instance->Line ( $x_max + 0.1, $y, $right, $y );
00771         
00772         $y += 0.15;
00773         
00774         $d_s = $this->BK_DrawString ( _PDF_BROOKLYN_LOCATION_NAME, $x_max, $x, $y, "r", 10, "Times", "B" );
00775         
00776         $y = $d_s['y'];
00777         
00778         $this->napdf_instance->Line ( $x_max + 0.1, $y, $right, $y );
00779         
00780         $y += 0.15;
00781         
00782         $d_s = $this->BK_DrawString ( _PDF_BROOKLYN_LOCATION_ADDR, $x_max, $x, $y, "r", 10, "Times", "B" );
00783         
00784         $y = $d_s['y'];
00785         
00786         $this->napdf_instance->Line ( $x_max + 0.1, $y, $right, $y );
00787         
00788         $y += 0.15;
00789         
00790         $d_s = $this->BK_DrawString ( _PDF_BROOKLYN_LOCATION_TOWN, $x_max, $x, $y, "r", 10, "Times", "B" );
00791         
00792         $yt = $d_s['y'];
00793         
00794         $this->napdf_instance->Line ( $x_max + 0.1, $yt, $x_max + 3.6, $yt );
00795         
00796         $d_s = $this->BK_DrawString ( _PDF_BROOKLYN_LOCATION_ZIP, $x_max + 4, $x_max + 3.6, $y, "r", 10, "Times", "B" );
00797         
00798         $this->napdf_instance->Line ( $x_max + 4.1, $yt, $right, $yt );
00799         
00800         $y = $d_s['y'] + 0.15;
00801         
00802         $d_s = $this->BK_DrawString ( _PDF_BROOKLYN_LOCATION_DIR, $x_max, $x, $y, "r", 10, "Times", "B" );
00803         
00804         $y = $d_s['y'];
00805         
00806         $this->napdf_instance->Line ( $x_max + 0.1, $y, $right, $y );
00807         
00808         $y += 0.3;
00809         
00810         $this->napdf_instance->Line ( $x_max + 0.1, $y, $right, $y );
00811         
00812         $y += 0.05;
00813         
00814         $this->napdf_instance->SetLineWidth ( 0.025 );
00815         $this->napdf_instance->Line ( $left, $y, $right, $y );
00816     
00817         $y += 0.065;
00818     
00819         $d_s = $this->BK_DrawString ( _PDF_BROOKLYN_HEADER_TIME, $right, $left, $y, "C", 12, "Helvetica", "B" );
00820     
00821         $y = ($d_s['y'] + 0.15);
00822         
00823         $d_s = $this->BK_DrawString ( _PDF_BROOKLYN_MEETING_DAY, $left + 0.9, $left, $y, "R", 10, "Times", "B" );
00824     
00825         $this->napdf_instance->SetFont ( "Helvetica", "", 9 );
00826     
00827         global $days;
00828         
00829         $x = $left + 1;
00830         $this->napdf_instance->SetLineWidth ( 0.01 );
00831         
00832         foreach ( $this->weekday_names as $day )
00833             {
00834             $this->napdf_instance->Rect ( $x, $y+ 0.01, $r_w, $r_h );
00835             $this->napdf_instance->SetXY ( $x + $r_w, $y );
00836             $cell_size = $this->napdf_instance->GetStringWidth ( utf8_decode ( $day ) ) + 0.2 + $r_w;
00837             $this->napdf_instance->Cell ( 0, 10/72, utf8_decode ( $day ) );
00838             $x += $cell_size;
00839             }
00840         
00841         $y += ($r_h + 0.15);
00842         
00843         $d_s = $this->BK_DrawString ( _PDF_BROOKLYN_MEETING_TIME, $left + 0.9, $left, $y, "R", 10, "Times", "B" );
00844         
00845         $yt = $d_s['y'];
00846         
00847         $this->napdf_instance->Line ( $left + 1, $yt, $left + 4, $yt );
00848         
00849         $d_s = $this->BK_DrawString ( _PDF_BROOKLYN_MEETING_DURATION, $left + 4.8, $left + 4.1, $y, "R", 10, "Times", "B" );
00850         
00851         $y = $d_s['y'];
00852         
00853         $this->napdf_instance->Line ( $left + 4.9, $yt, $right, $yt );
00854         
00855         $y = $this->napdf_instance->GetY() + 0.05;
00856         $this->napdf_instance->SetLineWidth ( 0.025 );
00857         $this->napdf_instance->Line ( $left, $y, $right, $y );
00858     
00859         $y += 0.065;
00860     
00861         $d_s = $this->BK_DrawString ( _PDF_BROOKLYN_HEADER_NOTES, $right, $left, $y, "C", 12, "Helvetica", "B" );
00862     
00863         $this->napdf_instance->SetLineWidth ( 0.01 );
00864     
00865         $y = ($d_s['y'] + 0.3);
00866         
00867         while ( $y < $bottom )
00868             {
00869             $this->napdf_instance->Line ( $left, $y, $right, $y );
00870         
00871             $y += 0.3;
00872             }
00873         }
00874         
00875     /***************************************************************************************************
00876     ***************************************************************************************************/
00877     function BK_DrawString ( $in_string, $in_x_max, $in_x='', $in_y='', $in_align='', $in_fontsize='', $in_font_family='', $in_font_style='' )
00878         {
00879         if ( !$in_x )
00880             {
00881             $in_x = $this->napdf_instance->GetX();
00882             }
00883     
00884         if ( !$in_y )
00885             {
00886             $in_y = $this->napdf_instance->GetY();
00887             }
00888         
00889         if ( !$in_fontsize )
00890             {
00891             $in_fontsize = $this->napdf_instance->FontSizePt;
00892             }
00893     
00894         if ( !$in_font_family )
00895             {
00896             $in_font_family = $this->napdf_instance->FontFamily;
00897             }
00898     
00899         $height_row = $in_fontsize/72;
00900         
00901         $this->napdf_instance->SetFont ( $in_font_family, $in_font_style, $in_fontsize );
00902         $stringWidth = $this->napdf_instance->GetStringWidth ( utf8_decode ( $in_string ) );
00903         $ret['width'] = $stringWidth;
00904         
00905         $align = "L";
00906         
00907         if ( ($in_x_max > $in_x) && preg_match ( "/^c.*/i", $in_align ) )
00908             {
00909             $cellleft = (($in_x_max + $in_x) / 2) - ($stringWidth / 2);
00910             }
00911         elseif ( ($in_x_max > $in_x) && preg_match ( "/^r.*/i", $in_align ) )
00912             {
00913             $cellleft = $in_x_max - $stringWidth;
00914             }
00915         else
00916             {
00917             $cellleft = $in_x;
00918             }
00919         
00920         $this->napdf_instance->SetXY ( $cellleft, $in_y );
00921         $this->napdf_instance->MultiCell ( $in_x_max - $in_x, $height_row, utf8_decode ( $in_string ), "", $align );
00922         $ret['y'] = $this->napdf_instance->GetY();
00923         
00924         return $ret;
00925         }
00926     
00927     /***************************************************************************************************
00928     ***************************************************************************************************/
00929     function BK_DrawOneListPage ( &$in_layout )
00930         {
00931         $ret = false;
00932     
00933         $top = $in_layout['page_metrics']['margin']['top'];
00934         $left = $in_layout['page_metrics']['margin']['left'];
00935         $bottom = $this->napdf_instance->h - $in_layout['page_metrics']['margin']['bottom'];
00936         $right = $this->napdf_instance->w - $in_layout['page_metrics']['margin']['right'];
00937         $v_gap = $in_layout['data']['Meta']["V Gap"];
00938         $font_size = $in_layout[page_metrics]['font_size'];
00939         $height_row = $font_size/72 + $v_gap;
00940         
00941         $current_meeting = $in_layout['data']['Meta']['meetings']['meetings'][$in_layout['placeholder']['meeting_index']];
00942         
00943         if ( !$in_layout['placeholder']['meeting_index'] )
00944             {
00945             $day = "";
00946             }
00947         else
00948             {
00949             $day = $in_layout['placeholder']['weekday'];
00950             }
00951     
00952         $this->napdf_instance->AddPage();
00953     
00954         $y = $this->BK_WriteDayHeader ( $in_layout, $current_meeting['weekday'], $top, $left, $right,  $day );  
00955         $day = $current_meeting['weekday'];
00956         $in_layout['placeholder']['weekday'] = $day;
00957     
00958         $alt_color = 255;
00959         
00960         do {
00961             $alt_color = ($alt_color == 255) ? 225 : 255;
00962             if ( !$current_meeting )
00963                 {
00964                 $current_meeting = $in_layout['data']['Meta']['meetings']['meetings'][$in_layout['placeholder']['meeting_index']];
00965                 }
00966             $look_ahead = $height_row;
00967     
00968             if ( $current_meeting['weekday'] != $day )
00969                 {
00970                 $look_ahead += 0.27;
00971                 
00972                 if ( $y < ($bottom - $look_ahead) )
00973                     {
00974                     $day = $current_meeting['weekday'];
00975                     $in_layout['placeholder']['weekday'] = $day;
00976                     $y = $this->BK_WriteDayHeader ( $in_layout, $day, $y, $left, $right );
00977                     $alt_color = 255;
00978                     }
00979                 else
00980                     {
00981                     break;
00982                     }
00983                 }
00984             else
00985                 {
00986                 $y = $this->BK_Write_One_Meeting ( $in_layout, $in_layout['placeholder']['meeting_index']++, $y, 0, $alt_color );
00987                 }
00988     
00989             $current_meeting = "";
00990             } while ( ($y < ($bottom - $look_ahead))
00991                 && ($in_layout['placeholder']['meeting_index'] < count ( $in_layout['data']['Meta']['meetings']['meetings'] )) );
00992     
00993         if ( $in_layout['placeholder']['meeting_index'] < count ( $in_layout['data']['Meta']['meetings']['meetings'] ) )
00994             {
00995             $ret = true;
00996             }
00997             
00998         return $ret;
00999         }
01000     
01001     
01002     /***************************************************************************************************
01003     ***************************************************************************************************/
01004     function BK_Write_One_Meeting ( $in_layout, $in_index, $in_y, $in_page_offset=0, $in_bgcolor=255, $in_textcolor=0 )
01005         {
01006         $current_meeting = $in_layout['data']['Meta']['meetings']['meetings'][$in_index];
01007         $v_gap = $in_layout['data']['Meta']["V Gap"];
01008         
01009         $left = $in_page_offset + $in_layout[page_metrics]['margin']['left'];
01010         $right = $in_page_offset + $in_layout[page_metrics]['width'] - $in_layout[page_metrics]['margin']['right'];
01011         $font_family = $in_layout[page_metrics]['font_family'];
01012         $font_size = $in_layout[page_metrics]['font_size'];
01013         $height_row = $font_size/72 + $v_gap;
01014         $rows = count ( $in_layout ) - 3;
01015         $height = $height_row * $rows;
01016         
01017         $this->napdf_instance->SetFillColor ( $in_bgcolor );
01018         $this->napdf_instance->SetTextColor ( $in_textcolor );
01019         $this->napdf_instance->Rect ( $left, $in_y, ($right - $left), $height, "F" );
01020     
01021         $this->napdf_instance->SetY ( $in_y );
01022     
01023         for ( $count = 0; $count < $rows; $count++ )
01024             {
01025             $row_array = $in_layout[$count];
01026     
01027             $last_elem = "key";
01028             
01029             $row_layout = array();
01030             
01031             $element_count = count ( $row_array );
01032     
01033             $str = "";
01034             $left_pos = 0;
01035             
01036             for ( $ecount = 0; $ecount < $element_count; $ecount++ )
01037                 {
01038                 $element = $row_array[$ecount];
01039                 $et['string'] = $current_meeting[$element['key']];
01040                 $et['left'] = $element['left'];
01041                 $et['format'] = $element['format'];
01042                 array_push ( $row_layout, $et );
01043                 }
01044             
01045             foreach ( $row_layout as $et )
01046                 {
01047                 $this->napdf_instance->SetFont ( $font_family, $et['format'], $font_size );
01048                 $this->napdf_instance->SetX ( $et['left'] );
01049                 $this->napdf_instance->Cell ( 0, $height_row, utf8_decode ( $et['string'] ) );
01050                 }
01051             
01052             $this->napdf_instance->SetY ( $in_y + $height_row );
01053             }
01054         
01055         
01056         return $this->napdf_instance->GetY();
01057         }
01058         
01059     /***************************************************************************************************
01060     ***************************************************************************************************/
01061     function BK_WriteDayHeader ( $in_layout, $in_day, $in_y, $in_left, $in_right,  $in_day_contd="" )
01062         {
01063         if ( $in_day_contd == $in_day )
01064             {
01065             $in_day .= _PDF_CONTD;
01066             }
01067         
01068         $height_total = 0.25;
01069         
01070         $this->napdf_instance->SetFillColor ( 0 );
01071         $this->napdf_instance->SetTextColor ( 255 );
01072         $this->napdf_instance->Rect ( $in_left, $in_y, ($in_right - $in_left), $height_total, "F" );
01073         
01074         $height_header = 0.15;
01075     
01076         $this->napdf_instance->SetFont ( 'Times', 'B', 9 );
01077         $stringWidth = $this->napdf_instance->GetStringWidth ( utf8_decode ( $in_day ) );
01078         $cellleft = (($in_right + $in_left) / 2) - ($stringWidth / 2);
01079         $this->napdf_instance->SetXY ( $cellleft, $in_y );
01080         $this->napdf_instance->Cell ( 0, $height_header, utf8_decode ( $in_day ) );
01081         
01082         $this->napdf_instance->SetFont ( 'Helvetica', 'B', 7 );
01083         
01084         $height_row = 0.1;
01085         
01086         $row_layout = array();
01087         
01088         $in_y += $height_header;
01089         
01090         foreach ( $in_layout[0] as $element )
01091             {
01092             $et['left'] = $element['left'];
01093             $et['string'] = $element['string'];
01094             array_push ( $row_layout, $et );
01095             }
01096         
01097         foreach ( $row_layout as $et )
01098             {
01099             $this->napdf_instance->SetXY ( $et['left'], $in_y );
01100             $this->napdf_instance->Cell ( 0, $height_row, utf8_decode ( $et['string'] ) );
01101             }
01102     
01103         $this->napdf_instance->SetFillColor ( 255 );
01104         $this->napdf_instance->SetTextColor ( 0 );
01105         $this->napdf_instance->SetY ( $in_y + $height_row + 0.02 );
01106         return $this->napdf_instance->GetY();
01107         }
01108     
01109     /***************************************************************************************************
01110     ***************************************************************************************************/
01111     function _Set_Page_Layout ( $in_font_family = "Helvetica" )
01112         {
01113         $calculated_data = $this->_CalculateListMeta ( $in_font_family );
01114         
01115         $page_metrics['font_family'] = $in_font_family;
01116         $page_metrics['width'] = 7;
01117         $page_metrics['height'] = 8.5;
01118         $page_metrics['margin']['top'] = 0.25;
01119         $page_metrics['margin']['left'] = 0.25;
01120         $page_metrics['margin']['bottom'] = 0.25;
01121         $page_metrics['margin']['right'] = 0.25;
01122         $page_metrics['footer'] = 0.5;
01123         $page_metrics['font_size'] = 0;
01124         
01125         $rows[0] = array ( "Name", "Location", "Time", "Format" );
01126         
01127         $row_layout = array();
01128         
01129         $total_width = 0;
01130         
01131         for ( $row_index = 0; $row_index < count ( $rows ); $row_index++ )
01132             {
01133             $e_count = 0;
01134             for ( $row_array_index = 0; $row_array_index < count ( $rows[$row_index] ); $row_array_index++ )
01135                 {
01136                 $element = $rows[$row_index][$row_array_index];
01137                 $elements = split ( "\+", $element );
01138                 
01139                 for ( $element_index = 0; $element_index < count ( $elements ); $element_index++ )
01140                     {
01141                     $element_string = $elements[$element_index];
01142                     
01143                     if ( array_key_exists ( $element_string, $calculated_data['Info'] ) )
01144                         {
01145                         $width = $calculated_data['Info'][$element]['width'];
01146                         $row_layout[$row_index][$e_count]['key'] = $calculated_data['Info'][$element_string]['key'];
01147                         }
01148                     
01149                     $row_layout[$row_index][$e_count]['string'] = $element_string;
01150                     $row_layout[$row_index][$e_count]['format'] = $calculated_data['Info'][$element_string]['format'];
01151                     $row_layout[$row_index][$e_count++]['width'] = $width;
01152                     }
01153                 
01154                 if ( $row_array_index != (count ( $rows[$row_index] ) - 1) )
01155                     {
01156                     $row_layout[$row_index][$e_count++]['width'] = $calculated_data['Meta']['H Gap'];
01157                     }
01158                 }
01159             
01160             $row_width = 0;
01161             for ( $counter = 0; $counter < count ( $row_layout[$row_index] ); $counter++ )
01162                 {
01163                 $row_width += $row_layout[$row_index][$counter]['width'];
01164                 }
01165             
01166             $total_width = max ( $total_width, $row_width );
01167             }
01168             
01169         $page_width = $page_metrics['width'] - ($page_metrics['margin']['left'] + $page_metrics['margin']['right']);
01170         
01171         $coefficient = $page_width / $total_width;
01172     
01173         $font_size = $calculated_data['Meta']['font_size'];
01174         $font_size *= $coefficient;
01175     
01176         for ( $row_index = 0; $row_index < count ( $row_layout ); $row_index++ )
01177             {
01178             $pos = $page_metrics['margin']['left'];
01179             for ( $row_array_index = 0; $row_array_index < count ( $row_layout[$row_index] ); $row_array_index++ )
01180                 {
01181                 $row_layout[$row_index][$row_array_index]['width'] *= $coefficient;
01182                 $row_layout[$row_index][$row_array_index]['left'] = $pos;
01183                 $pos += $row_layout[$row_index][$row_array_index]['width'];
01184                 }
01185             }
01186             
01187         $page_metrics['font_size'] = $font_size;
01188         $row_layout['page_metrics'] = $page_metrics;
01189         $row_layout['data'] = $calculated_data;
01190         $row_layout['placeholder']['weekday'] = 0;
01191         $row_layout['placeholder']['town'] = 0;
01192         $row_layout['placeholder']['county'] = 0;
01193         $row_layout['placeholder']['meeting_index'] = 0;
01194     
01195         return $row_layout;
01196         }
01197     
01198     /***************************************************************************************************
01199     ***************************************************************************************************/
01200     function _CalculateListMeta ( $in_font_family = "Helvetica" )
01201         {
01202         define ( "_BK_PLACEHOLDER_", "####" );
01203         
01204         $meetings = $this->_GetMeetings_And_Formats ( );
01205         
01206         $ret = array (  "Meta" => array (       "font_size" => 10,
01207                                                         "font_family" => $in_font_family,
01208                                                         "H Gap" => 0.125,
01209                                                         "V Gap" => 0.02,
01210                                                         "meetings" => $meetings),
01211                             
01212                             "Info" =>   array ( "Name" => array ( "key" => "name", "format" => "B", "width" => 0, "const_value" => _BK_PLACEHOLDER_, "row" => 0, "col" => 0 ),
01213                             
01214                                                         // Meeting Location Stuff
01215                                                         "Town" => array ( "key" => "town", "format" => "", "width" => 0, "const_value" => _BK_PLACEHOLDER_, "row" => 0, "col" => 0 ),
01216                                                         "Borough" => array ( "key" => "county", "format" => "", "width" => 0, "const_value" => _BK_PLACEHOLDER_, "row" => 0, "col" => 0 ),
01217                                                         "Neighborhood" => array ( "key" => "neighborhood", "format" => "", "width" => 0, "const_value" => _BK_PLACEHOLDER_, "row" => 0, "col" => 0 ),
01218                                                         "Location" => array ( "key" => "location_and_street_address", "format" => "", "width" => 0, "const_value" => _BK_PLACEHOLDER_, "row" => 0, "col" => 0 ),
01219                                                         "Location Info" => array ( "key" => "location_info", "format" => "", "width" => 0, "const_value" => _BK_PLACEHOLDER_, "row" => 0, "col" => 0 ),
01220                                                         
01221                                                         // Time and Duration Stuff
01222                                                         "Weekday" => array ( "key" => "weekday", "format" => "", "width" => 0, "const_value" => _BK_PLACEHOLDER_, "row" => 0, "col" => 0 ),
01223                                                         "Time" => array ( "key" => "start_time", "format" => "", "width" => 0, "const_value" => _BK_PLACEHOLDER_, "row" => 0, "col" => 0 ),
01224                                                         "Duration" => array ( "key" => "duration", "format" => "", "width" => 0, "const_value" => _BK_PLACEHOLDER_, "row" => 0, "col" => 0 ),
01225                                                         
01226                                                         // Meta Stuff
01227                                                         "Description" => array ( "key" => "description", "width" => 0, "const_value" => _BK_PLACEHOLDER_, "row" => 0, "col" => 0 ),
01228                                                         "Comments" => array ( "key" => "othertext", "width" => 0, "const_value" => _BK_PLACEHOLDER_, "row" => 0, "col" => 0 ),
01229                                                         "Format" => array ( "key" => "format", "format" => "", "width" => 0, "const_value" => _BK_PLACEHOLDER_, "row" => 0, "col" => 0 ) ) );
01230         
01231         reset ( $ret['Meta']['meetings'] );
01232         $font_family = $ret['Meta']['font_family'];
01233         $font_size = $ret['Meta']['font_size'];
01234         
01235         $meetings = $ret['Meta']['meetings']['meetings'];
01236     
01237         foreach ( $meetings as $meeting )
01238             {
01239             reset ( $ret['Info'] );
01240             
01241             while ( list ( $key, $value ) = each ( $ret['Info'] ) )
01242                 {
01243                 if ( ($ret['Info'][$key]['const_value'] == _BK_PLACEHOLDER_) && $meeting[$ret['Info'][$key]['key']] )
01244                     {
01245                     $ret['Info'][$key]['const_value'] = $meeting[$ret['Info'][$key]['key']];
01246                     }
01247                 elseif ( $ret['Info'][$key]['const_value']
01248                         && ($ret['Info'][$key]['const_value'] != _BK_PLACEHOLDER_)
01249                         && ($ret['Info'][$key]['const_value'] != $meeting[$ret['Info'][$key]['key']]) )
01250                     {
01251                     $ret['Info'][$key]['const_value'] = "";
01252                     }
01253                 
01254                 $meeting_key = $ret['Info'][$key]['key'];
01255                 $string = $meeting[$meeting_key];
01256                 
01257                 $this->napdf_instance->SetFont ( $font_family, $ret['Info'][$key]['format'], $font_size );
01258                 $width = $this->napdf_instance->GetStringWidth ( $meeting[$meeting_key] );
01259                 $ret['Info'][$key]['width'] = max ( $width, $ret['Info'][$key]['width'] );
01260                 }
01261             }
01262         
01263         reset ( $ret['Info'] );
01264         
01265         while ( list ( $key, $value ) = each ( $ret['Info'] ) )
01266             {
01267             if ( $ret['Info'][$key]['const_value'] == _BK_PLACEHOLDER_ )
01268                 {
01269                 $ret['Info'][$key]['const_value'] = Null;
01270                 }
01271             }
01272         
01273         return $ret;
01274         }
01275     
01276     /***************************************************************************************************
01277     ***************************************************************************************************/
01278     function _GetMeetings_And_Formats ( )
01279         {
01280         global $days, $formats, $special_formats, $special_formats_spanish;
01281         
01282         $meetings_in =& $this->napdf_instance->meeting_data;
01283 
01284         $meetings = array();
01285         $weekdayindex = 0;
01286         $meeting_day = array ();
01287         
01288         foreach ( $meetings_in as $row )
01289             {
01290             $this_meeting['weekday'] = $this->weekday_names[$row['weekday_tinyint'] - 1];
01291             $this_meeting['name'] = $row['meeting_name'];
01292             $this_meeting['town'] = $row['location_municipality'];
01293             $this_meeting['county'] = $row['location_city_subsection'];
01294             $this_meeting['neighborhood'] = $row['location_neighborhood'];
01295             $this_meeting['start_time'] = self::translate_time ( $row['start_time'] );
01296             $this_meeting['location'] = $row['location_text'];
01297             $this_meeting['location_info'] = $row['location_info'];
01298             $this_meeting['street_address'] = $row['location_street'];
01299             $this_meeting['description'] = $row['comments'];
01300             $this_meeting['othertext'] =  $row['description_string'];
01301             $this_meeting['format'] = $row['formats'];
01302             $check_f = split ( ",", $this_meeting['format'] );
01303             $spec = false;
01304             foreach ( $check_f as $f )
01305                 {
01306                 if ( ($f == "C") || ($f == "O") )
01307                     {
01308                     $spec = true;
01309                     break;
01310                     }
01311                 }
01312             
01313             if ( !$spec )
01314                 {
01315                 if ( $this_meeting['format'] )
01316                     {
01317                     $this_meeting['format'] = ",".$this_meeting['format'];
01318                     }
01319                 
01320                 $this_meeting['format'] = "C".$this_meeting['format'];
01321                 }
01322             
01323             $this_meeting['location_and_street_address'] = $this_meeting['location'].", ".$this_meeting['street_address'];
01324             $this_meeting['duration'] = self::translate_duration ( $meeting['duration_time'] );
01325             
01326             array_push ( $meetings, $this_meeting );
01327             }
01328         
01329         // This will mark when the list was printed.
01330         $date = _PDF_PRINTED_ON;
01331         
01332         $ret['date'] = $date;
01333         $ret['meetings'] = $meetings;
01334         
01335         return $ret;
01336         }
01337 
01338 };
01339 ?>
 All Data Structures Files Functions Variables Enumerations