This creates and manages an instance of the napdf class, and creates the PDF file. More...

Public Member Functions | |
| __construct ($in_http_vars) | |
| AssemblePDF () | |
| OutputPDF () | |
Data Fields | |
| $weekday_names = array ( "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ) | |
| $pos = array ( 'start' => 1, 'end' => '', 'count' => 0, 'y' => 0, 'weekday' => 1 ) | |
| $right_offset = 0 | |
| $formats = 0 | |
Private Member Functions | |
| DrawLastPageTrailer ($left, $top, $right, $bottom) | |
| DrawListPanel ($left, $top, $right, $bottom, $meetings, $day=-1, $count=0) | |
| DrawRearPanel ($left, $top, $right, $bottom, $formats) | |
| DrawFrontPanel ($left, $top, $right, $bottom, $date) | |
| RearrangeFormats ($inFormats) | |
Static Private Member Functions | |
| static | break_meetings_by_day ($in_meetings_array) |
| static | sort_cmp ($a, $b) |
| static | translate_time ($in_time_string) |
| static | translate_duration ($in_time_string) |
| static | call_curl ($in_uri, $in_post=true, &$http_status=null) |
This creates and manages an instance of the napdf class, and creates the PDF file.
Definition at line 15 of file eli_napdf.class.php.
| __construct | ( | $ | in_http_vars | ) |
< The width, in inches, of each page
< The height, in inches, of each page.
< The measurement units (inches)
< The font we'll use
< The font size we'll use
< The orientation (portrait)
These are the sort keys, for sorting the meetings before display
< First, weekday
< Next, the town.
< Finally, the time the meeting starts
< Our week starts on Monday (2)
These are the parameters that we send over to the root server, in order to get our meetings.
< Do a search
< We'll be very specific in our request
< We will be asking for meetings in specific Service Bodies.
< SASASC
< NASC
< ELIASC
< SSASC
| in_http_vars | The HTTP parameters we'd like to send to the server. |
Definition at line 28 of file eli_napdf.class.php.
{
$this->page_x = 11; ///< The width, in inches, of each page
$this->page_y = 17; ///< The height, in inches, of each page.
$this->units = 'in'; ///< The measurement units (inches)
$this->font = 'Helvetica'; ///< The font we'll use
$this->font_size = 12; ///< The font size we'll use
$this->orientation = 'L'; ///< The orientation (portrait)
/// These are the sort keys, for sorting the meetings before display
$this->sort_keys = array ( 'weekday_tinyint' => true, ///< First, weekday
'location_municipality' => true, ///< Next, the town.
'start_time' => true, ///< Finally, the time the meeting starts
'week_starts' => 2 ///< Our week starts on Monday (2)
);
/// These are the parameters that we send over to the root server, in order to get our meetings.
$this->out_http_vars = array ('do_search' => 'yes', ///< Do a search
'bmlt_search_type' => 'advanced', ///< We'll be very specific in our request
'advanced_service_bodies' => array ( ///< We will be asking for meetings in specific Service Bodies.
1001, ///< SASASC
1002, ///< NASC
1003, ///< ELIASC
1004 ///< SSASC
)
);
parent::__construct ( $in_http_vars );
}
| AssemblePDF | ( | ) |
Implements IPrintableList.
Definition at line 62 of file eli_napdf.class.php.
References $pos, DrawFrontPanel(), DrawLastPageTrailer(), DrawListPanel(), and DrawRearPanel().
{
$ret = false;
if ( $this->napdf_instance instanceof napdf )
{
$page_margins = 0.35;
$meeting_data =& $this->napdf_instance->meeting_data;
if ( $meeting_data )
{
// Calculate the overall layout of the list
// The front and back panels are quarter page panels.
$panelpage['margin'] = $page_margins;
$panelpage['height'] = $this->napdf_instance->h - ($panelpage['margin'] * 2);
$panelpage['width'] = ($this->napdf_instance->w / 4) - ($panelpage['margin'] * 2);
// List pages are half page panels.
$listpage['margin'] = $page_margins;
$listpage['height'] = $this->napdf_instance->h - ($listpage['margin'] * 2);
$listpage[width] = ($this->napdf_instance->w / 2) - ($listpage['margin'] * 2);
// These are the actual drawing areas.
// The panel that is up front of the folded list.
$frontpanel_x_offset = $panelpage['width'] + ($panelpage['margin'] * 3);
$frontpanel_max_x_offset = $frontpanel_x_offset + $panelpage['width'];
$frontpanel_y_offset = $panelpage['margin'];
$frontpanel_max_y_offset = $frontpanel_y_offset + $panelpage['height'];
// The panel that is on the back of the folded list.
$backpanel_x_offset = $panelpage['margin'];
$backpanel_max_x_offset = $backpanel_x_offset + $panelpage['width'];
$backpanel_y_offset = $panelpage['margin'];
$backpanel_max_y_offset = $backpanel_y_offset + $panelpage['height'];
// Each page is separated by a vertical line.
$vertical_separator_x = ($this->napdf_instance->w / 2);
$vertical_separator_y = $page_margins;
$vertical_separator_y_2 = $this->napdf_instance->h - $page_margins;
// The front page has half dedicated to a single list panel.
$frontlist_x_offset = $frontpanel_max_x_offset + $panelpage['margin'] + $listpage['margin'];
$frontlist_max_x_offset = $frontlist_x_offset + $listpage['width'];
$frontlist_y_offset = $listpage['margin'];
$frontlist_max_y_offset = $frontlist_y_offset + $listpage['height'];
// The back page has two list panels.
$backlist_page_1_x_offset = $listpage['margin'];
$backlist_page_1_max_x_offset = $backlist_page_1_x_offset + $listpage['width'];
$backlist_page_1_y_offset = $listpage['margin'];
$backlist_page_1_max_y_offset = $backlist_page_1_y_offset + $listpage['height'];
$backlist_page_2_x_offset = $backlist_page_1_max_x_offset + ($listpage['margin'] * 2);
$backlist_page_2_max_x_offset = $backlist_page_2_x_offset + $listpage['width'];
$backlist_page_2_y_offset = $listpage['margin'];
$backlist_page_2_max_y_offset = $backlist_page_2_y_offset + $listpage['height'];
global $columns, $maxwidth, $fSize, $y;
$maxwidth = $listpage['width'] + 1;
$columns = "";
$fSize = $this->napdf_instance->FontSizePt;
foreach ( $meeting_data as &$meeting )
{
$meeting['location'] = $meeting['location_text'].', '.$meeting['location_street'];
}
$this->napdf_instance->AddPage ( );
$pos = $this->DrawListPanel ( $backlist_page_1_x_offset, $backlist_page_1_y_offset, $backlist_page_1_max_x_offset, $backlist_page_1_max_y_offset, $meeting_data );
$this->napdf_instance->Line ( $vertical_separator_x, $vertical_separator_y, $vertical_separator_x, $vertical_separator_y_2 );
$pos = $this->DrawListPanel ( $backlist_page_2_x_offset, $backlist_page_2_y_offset, $backlist_page_2_max_x_offset, $backlist_page_2_max_y_offset, $meeting_data, $pos['day'], $pos['count'] );
$this->napdf_instance->AddPage ( );
$this->DrawRearPanel ( $backpanel_x_offset, $backpanel_y_offset, $backpanel_max_x_offset, $backpanel_max_y_offset, $this->napdf_instance->format_data );
$inPrinter_Date = date ( '\U\p\d\a\t\e\d F jS, Y' );
$this->DrawFrontPanel ( $frontpanel_x_offset, $frontpanel_y_offset, $frontpanel_max_x_offset, $frontpanel_max_y_offset, $inPrinter_Date );
$this->napdf_instance->Line ( $vertical_separator_x, $vertical_separator_y, $vertical_separator_x, $vertical_separator_y_2 );
if ( $pos )
{
$this->DrawListPanel ( $frontlist_x_offset, $frontlist_y_offset, $frontlist_max_x_offset, $frontlist_max_y_offset, $meeting_data, $pos['day'], $pos['count'] );
}
else
{
$y = $frontlist_y_offset;
}
$this->DrawLastPageTrailer ( $frontlist_x_offset, $y, $frontlist_max_x_offset, $frontlist_max_y_offset );
}
$ret = true;
}
return $ret;
}
| static break_meetings_by_day | ( | $ | in_meetings_array | ) | [static, private] |
Definition at line 815 of file eli_napdf.class.php.
Referenced by DrawListPanel().
{
$last_day = -1;
$meetings_day = array();
foreach ( $in_meetings_array as $meeting )
{
if ( $meeting['weekday_tinyint'] != $last_day )
{
$last_day = $meeting['weekday_tinyint'] -1;
}
$meetings_day[$last_day][] = $meeting;
}
return $meetings_day;
}
| static call_curl | ( | $ | in_uri, | |
| $ | in_post = true, |
|||
| &$ | http_status = null | |||
| ) | [static, private] |
| in_uri | A string. The URI to call. | |
| in_post | If false, the transaction is a GET, not a POST. Default is true. | |
| http_status | Optional reference to a string. Returns the HTTP call status. |
Definition at line 913 of file eli_napdf.class.php.
{
$ret = null;
// If the curl extension isn't loaded, we try one backdoor thing. Maybe we can use file_get_contents.
if ( !extension_loaded ( 'curl' ) )
{
if ( ini_get ( 'allow_url_fopen' ) )
{
$ret = file_get_contents ( $in_uri );
}
}
else
{
// Create a new cURL resource.
$resource = curl_init();
// If we will be POSTing this transaction, we split up the URI.
if ( $in_post )
{
$spli = explode ( "?", $in_uri, 2 );
if ( is_array ( $spli ) && count ( $spli ) )
{
$in_uri = $spli[0];
$in_params = $spli[1];
curl_setopt ( $resource, CURLOPT_POST, true );
curl_setopt ( $resource, CURLOPT_POSTFIELDS, $in_params );
}
}
// Set url to call.
curl_setopt ( $resource, CURLOPT_URL, $in_uri );
// Make curl_exec() function (see below) return requested content as a string (unless call fails).
curl_setopt ( $resource, CURLOPT_RETURNTRANSFER, true );
// By default, cURL prepends response headers to string returned from call to curl_exec().
// You can control this with the below setting.
// Setting it to false will remove headers from beginning of string.
// If you WANT the headers, see the Yahoo documentation on how to parse with them from the string.
curl_setopt ( $resource, CURLOPT_HEADER, false );
// Allow cURL to follow any 'location:' headers (redirection) sent by server (if needed set to true, else false- defaults to false anyway).
// Disabled, because some servers disable this for security reasons.
// curl_setopt ( $resource, CURLOPT_FOLLOWLOCATION, true );
// Set maximum times to allow redirection (use only if needed as per above setting. 3 is sort of arbitrary here).
curl_setopt ( $resource, CURLOPT_MAXREDIRS, 3 );
// Set connection timeout in seconds (very good idea).
curl_setopt ( $resource, CURLOPT_CONNECTTIMEOUT, 10 );
// Direct cURL to send request header to server allowing compressed content to be returned and decompressed automatically (use only if needed).
curl_setopt ( $resource, CURLOPT_ENCODING, 'gzip,deflate' );
// Execute cURL call and return results in $content variable.
$content = curl_exec ( $resource );
// Check if curl_exec() call failed (returns false on failure) and handle failure.
if ( $content === false )
{
// Cram as much info into the exception as possible.
throw new Exception ( "curl failure calling $in_uri, ".curl_error ( $resource ).", ".curl_errno ( $resource ) );
}
else
{
// Do what you want with returned content (e.g. HTML, XML, etc) here or AFTER curl_close() call below as it is stored in the $content variable.
// You MIGHT want to get the HTTP status code returned by server (e.g. 200, 400, 500).
// If that is the case then this is how to do it.
$http_status = curl_getinfo ($resource, CURLINFO_HTTP_CODE );
}
// Close cURL and free resource.
curl_close ( $resource );
// Maybe echo $contents of $content variable here.
if ( $content !== false )
{
$ret = $content;
}
}
return $ret;
}
| DrawFrontPanel | ( | $ | left, | |
| $ | top, | |||
| $ | right, | |||
| $ | bottom, | |||
| $ | date | |||
| ) | [private] |
Definition at line 677 of file eli_napdf.class.php.
Referenced by AssemblePDF().
{
$inTitleGraphic = "../ny_printed_lists/images/ELI_Cover_Logo.png";
$y = $top + 0.125;
$fontSize = $this->font_size;
$this->napdf_instance->SetFont ( $this->font, 'B', ($fontSize - 4) );
$stringWidth = $this->napdf_instance->GetStringWidth ( $date );
$cellleft = (($right + $left) / 2) - ($stringWidth / 2);
$this->napdf_instance->SetXY ( $cellleft, $y );
$this->napdf_instance->Cell ( 0, 0, $date );
$y += 0.2;
$this->napdf_instance->SetFont ( $this->font, 'B', ($fontSize + 4) );
$stringWidth = $this->napdf_instance->GetStringWidth ( _PDF_SASNA_LIST_BANNER );
$cellleft = (($right + $left) / 2) - ($stringWidth / 2);
$this->napdf_instance->SetXY ( $cellleft, $y );
$this->napdf_instance->Cell ( 0, 0, _PDF_SASNA_LIST_BANNER );
$y += 0.21;
$this->napdf_instance->SetFont ( $this->font, 'B', ($fontSize - 4) );
$stringWidth = $this->napdf_instance->GetStringWidth ( _PDF_SASNA_LIST_BANNER_2 );
$cellleft = (($right + $left) / 2) - ($stringWidth / 2);
$this->napdf_instance->SetXY ( $cellleft, $y );
$this->napdf_instance->Cell ( 0, 0, _PDF_SASNA_LIST_BANNER_2 );
$y += 0.15;
$this->napdf_instance->SetFont ( $this->font, 'B', ($fontSize + 1) );
$stringWidth = $this->napdf_instance->GetStringWidth ( _PDF_SASNA_LIST_BANNER_3 );
$cellleft = (($right + $left) / 2) - ($stringWidth / 2);
$this->napdf_instance->SetXY ( $cellleft, $y );
$this->napdf_instance->Cell ( 0, 0, _PDF_SASNA_LIST_BANNER_3 );
$y += 0.2;
$this->napdf_instance->SetFont ( $fontFamily, 'I', $fontSize );
$stringWidth = $this->napdf_instance->GetStringWidth ( _PDF_SASNA_LIST_BANNER_4 );
$cellleft = (($right + $left) / 2) - ($stringWidth / 2);
$this->napdf_instance->SetXY ( $cellleft, $y );
$this->napdf_instance->Cell ( 0, 0, _PDF_SASNA_LIST_BANNER_4 );
$this->napdf_instance->Image ( $inTitleGraphic, ($left + .85), 1.45, (($right - $left) - 1.7), 0, 'PNG' );
$this->napdf_instance->SetFont ( $fontFamily, 'B', ($fontSize + 1) );
$y = 3.5;
$cellleft = $left + 0.6;
$this->napdf_instance->SetXY ( $cellleft, $y );
$this->napdf_instance->Cell ( 0, 0, _PDF_SASNA_LIST_HELPLINES );
$y += 0.2;
$this->napdf_instance->SetFont ( $this->font, '', ($fontSize - 2) );
$this->napdf_instance->SetXY ( $cellleft, $y );
$this->napdf_instance->Cell ( 0, 0, _PDF_SASNA_LIST_HELPLINE_ELI );
$y += 0.16;
$this->napdf_instance->SetFont ( $this->font, '', ($fontSize - 2) );
$this->napdf_instance->SetXY ( $cellleft, $y );
$this->napdf_instance->Cell ( 0, 0, _PDF_SASNA_LIST_HELPLINE_NASSAU );
$y += 0.16;
$this->napdf_instance->SetXY ( $cellleft, $y );
$this->napdf_instance->Cell ( 0, 0, _PDF_SASNA_LIST_HELPLINE_QUEENS );
$y += 0.25;
$this->napdf_instance->SetFont ( $this->font, 'B', ($fontSize + 1) );
$cellleft = $left;
$this->napdf_instance->SetXY ( $cellleft, $y );
$st_width = $this->napdf_instance->GetStringWidth ( _PDF_SASNA_LIST_WELCOME );
$this->napdf_instance->Cell ( 0, 0, _PDF_SASNA_LIST_WELCOME );
$y += 0.125;
$this->napdf_instance->SetFont ( $this->font, '', $fontSize );
$this->napdf_instance->SetLineWidth ( 0.02 );
$this->napdf_instance->Line ( ($st_width + $left) + 0.0625, $y, $right, $y );
while ( $y < ($bottom - 0.3) )
{
$y += 0.3;
$this->napdf_instance->Line ( $left + 0.0625, $y, $right, $y );
}
}
| DrawLastPageTrailer | ( | $ | left, | |
| $ | top, | |||
| $ | right, | |||
| $ | bottom | |||
| ) | [private] |
Definition at line 178 of file eli_napdf.class.php.
References $i.
Referenced by AssemblePDF().
{
$y = $top + 0.125;
$fontFamily = $this->napdf_instance->FontFamily;
$fontSize = $this->napdf_instance->FontSizePt;
$s_array = array();
$na_dom = new DOMDocument;
if ( $na_dom )
{
if ( @$na_dom->loadHTML($this->call_curl ( "http://newyorkna.org/Events_and_Meetings/eli.html" )) )
{
$div_contents = $na_dom->getElementByID ( "meeting_times" );
if ( $div_contents )
{
$p_list = $div_contents->getElementsByTagName ( "p" );
if ( $p_list && $p_list->length )
{
for ( $i = 0; $i < $p_list->length; $i++ )
{
$the_item = $p_list->item($i);
if ( $the_item )
{
if ( "first" == $the_item->getAttribute ( "class" ) )
{
$p_list2 = $the_item->getElementsByTagName ( "b" );
$a['_name'] = $p_list2->item(0)->nodeValue;
$a['_description'] = '';
while ( $p_list->item($i + 1) && ("first" != $p_list->item($i + 1)->getAttribute ( "class" )) )
{
if ( $a['_description'] )
{
$a['_description'] .= "\n";
}
$a['_description'] .= $p_list->item(++$i)->nodeValue;
}
}
array_push ( $s_array, $a );
}
}
}
}
}
}
$this->napdf_instance->Line ( $left, $y, $right, $y );
$this->napdf_instance->SetXY ( $left, $y );
$this->napdf_instance->SetFont ( $fontFamily, 'B', ($fontSize - 3) );
$this->napdf_instance->SetLeftMargin ( $left );
$y = $this->napdf_instance->GetY ( );
$y += 0.125;
$this->napdf_instance->SetFont ( $fontFamily, 'B', ($fontSize - 3) );
$stringWidth = $this->napdf_instance->GetStringWidth ( _PDF_SASNA_LIST_ELI_SUBCOMMITTEES );
$cellleft = (($right + $left) / 2) - ($stringWidth / 2);
$this->napdf_instance->SetXY ( $cellleft, $y );
$this->napdf_instance->Cell ( 0, 0, _PDF_SASNA_LIST_ELI_SUBCOMMITTEES );
$y += 0.25;
if ( is_array ( $s_array ) && count ( $s_array ) )
{
$this->napdf_instance->SetFont ( $fontFamily, 'B', ($fontSize - 4) );
$count = 0;
$offset = 0;
foreach ( $s_array as $row )
{
$offset = max ( $offset, ($this->napdf_instance->GetStringWidth ( $row['_name'] ) + 0.1) );
$sub_table[$count++] = $row;
}
for ( $c = 0; $c < $count; $c++ )
{
$this->napdf_instance->SetFont ( $fontFamily, 'B', ($fontSize - 4) );
$this->napdf_instance->SetLeftMargin ( $left );
$this->napdf_instance->SetXY ( $left, $y );
$this->napdf_instance->MultiCell ( $offset, ($fontSize - 4) / 72, $sub_table[$c]['_name'] );
$this->napdf_instance->SetFont ( $fontFamily, '', ($fontSize - 4) );
$this->napdf_instance->SetLeftMargin ( $left + $offset );
$this->napdf_instance->SetXY ( $left + $offset, $y );
$this->napdf_instance->MultiCell ( ($right - ($left + $offset)), ($fontSize - 4) / 72, $sub_table[$c]['_description'] );
$y = $this->napdf_instance->GetY ( ) + 0.1;
}
}
$y += 0.05;
$this->napdf_instance->Line ( $left, $y, $right, $y );
$y += 0.15;
$this->napdf_instance->SetFont ( $fontFamily, 'B', ($fontSize - 2) );
$this->napdf_instance->SetLeftMargin ( $left );
$this->napdf_instance->SetXY ( $left, $y );
$this->napdf_instance->MultiCell ( 0, ($fontSize - 2) / 72, _PDF_SASNA_LIST_WHATIS_HEADER );
$y = $this->napdf_instance->GetY ( ) + 0.05;
$this->napdf_instance->SetFont ( $fontFamily, 'I', ($fontSize - 2) );
$this->napdf_instance->SetXY ( $left, $y );
$this->napdf_instance->MultiCell ( 0, ($fontSize - 2) / 72, _PDF_SASNA_LIST_WHATIS_TEXT );
$y = $this->napdf_instance->GetY ( ) + 0.15;
$this->napdf_instance->SetFont ( $fontFamily, 'B', ($fontSize - 2) );
$this->napdf_instance->SetLeftMargin ( $left );
$this->napdf_instance->SetXY ( $left, $y );
$this->napdf_instance->MultiCell ( 0, ($fontSize - 2) / 72, _PDF_SASNA_LIST_WDR_HEADER );
$y = $this->napdf_instance->GetY ( ) + 0.05;
$this->napdf_instance->SetFont ( $fontFamily, 'I', ($fontSize - 2) );
$this->napdf_instance->SetXY ( $left, $y );
$this->napdf_instance->MultiCell ( 0, ($fontSize - 2) / 72, _PDF_SASNA_LIST_WDR_TEXT );
}
| DrawListPanel | ( | $ | left, | |
| $ | top, | |||
| $ | right, | |||
| $ | bottom, | |||
| $ | meetings, | |||
| $ | day = -1, |
|||
| $ | count = 0 | |||
| ) | [private] |
Definition at line 300 of file eli_napdf.class.php.
References $pos, break_meetings_by_day(), RearrangeFormats(), and translate_time().
Referenced by AssemblePDF().
{
$meetings_days = self::break_meetings_by_day ( $meetings );
global $columns, $maxwidth, $fSize, $y;
$pos['day'] = $day;
$pos['count'] = $count;
$y = $top + 0.125;
$last_line = 0;
$daygap = 0.2;
$sep = 0.05;
if ( $day == -1 )
{
$fSize = $this->font_size + 2;
$columns['day'] = 0;
$columns['town'] = 0;
$columns['name'] = 0;
$columns['location'] = 0;
$columns['time'] = 0;
$columns['duration'] = 0;
$columns['format'] = 0;
while ( ($maxwidth > ($right - $left)) && ($fSize > 0) )
{
$fSize -= 0.1;
$this->napdf_instance->SetFont ( $this->font, 'B', $fSize );
$columns['day'] = $daygap;
$columns['town'] = $this->napdf_instance->GetStringWidth ( _PDF_SASNA_LIST_HEADER_TOWN ) + $sep;
$columns['name'] = $this->napdf_instance->GetStringWidth ( _PDF_SASNA_LIST_HEADER_NAME ) + $sep;
$columns['location'] = $this->napdf_instance->GetStringWidth ( _PDF_SASNA_LIST_HEADER_LOCATION ) + $sep;
$columns['time'] = $this->napdf_instance->GetStringWidth ( _PDF_SASNA_LIST_HEADER_TIME ) + $sep;
$columns['format'] = $this->napdf_instance->GetStringWidth ( _PDF_SASNA_LIST_HEADER_FORMAT );
$this->napdf_instance->SetFont ( $this->font, '', $fSize );
foreach ( $meetings as $meeting )
{
$columns['town'] = max ( $columns['town'], ($this->napdf_instance->GetStringWidth ( $meeting['location_municipality'] ) + $sep) );
$columns['name'] = max ( $columns['name'], ($this->napdf_instance->GetStringWidth ( $meeting['meeting_name'] ) + $sep) );
$columns['location'] = max ( $columns['location'], ($this->napdf_instance->GetStringWidth ( $meeting['location'] ) + $sep) );
$columns['time'] = max ( $columns['time'], ($this->napdf_instance->GetStringWidth ( $this->translate_time ( $meeting['start_time'] ) ) + $sep) );
$columns['format'] = max ( $columns['format'], $this->napdf_instance->GetStringWidth ( $this->RearrangeFormats ( $meeting['formats'] ) ) );
}
$line_height = $fSize / 72;
$duration_width = $line_height;
$duration_gap = $duration_width / 8;
$columns['duration'] = ($duration_width * 2) + ($duration_gap * 2);
$maxwidth = ($columns['day'] + $columns['town'] + $columns['name'] + $columns['location'] + $columns['time'] + $columns['duration'] + $columns['format']);
}
}
$line_height = $fSize / 72;
$duration_width = $line_height;
$duration_gap = $duration_width / 8;
$columns['duration'] = ($duration_width * 2) + ($duration_gap * 2);
$this->napdf_instance->SetFont ( $this->font, 'B', $fSize );
$x = $left + $daygap;
$this->napdf_instance->SetXY ( $x, $y );
$this->napdf_instance->Cell ( 0, 0, _PDF_SASNA_LIST_HEADER_TOWN );
$x += ($columns['town']);
$this->napdf_instance->SetX ( $x );
$this->napdf_instance->Cell ( 0, 0, _PDF_SASNA_LIST_HEADER_NAME );
$x += ($columns['name']);
$this->napdf_instance->SetX ( $x );
$this->napdf_instance->Cell ( 0, 0, _PDF_SASNA_LIST_HEADER_LOCATION );
$x += ($columns['location']);
$this->napdf_instance->SetX ( $x );
$this->napdf_instance->Cell ( 0, 0, _PDF_SASNA_LIST_HEADER_TIME );
$x += ($columns['time']+$columns['duration']);
$this->napdf_instance->SetX ( $x );
$this->napdf_instance->Cell ( 0, 0, _PDF_SASNA_LIST_HEADER_FORMAT );
$this->napdf_instance->SetFont ( $this->font, '', $fSize );
$y += $line_height;
if ( $pos['day'] == -1 )
{
$pos['day'] = 1;
}
for ( ; $pos['day'] < 7; $pos['day']++ )
{
$grayLine = 0;
$day_name = $this->weekday_names[$pos['day']];
$slen = strlen ( $day_name );
$ya = $y + $line_height + 0.125;
if ( (max($ya, ($slen * 0.125))) >= $bottom )
{
break;
}
$this->napdf_instance->Line ( $left, $y, $right, $y );
$y += $line_height;
$x = $left + 0.1;
$this->napdf_instance->SetFont ( $this->font, '', $fSize );
$meetings_day = $meetings_days[$pos['day']];
$count = count ( $meetings_day );
for ( ; $pos['count'] < $count; $pos['count']++ )
{
$x = $left + $daygap;
if ( $grayLine == 1 )
{
$this->napdf_instance->SetFillColor ( 220 );
$this->napdf_instance->Rect ( $left + $daygap, $y - ($fSize / 144), $right - ($left + $daygap), $fSize / 72, 'F' );
$grayLine = 0;
}
else
{
$grayLine = 1;
}
$this->napdf_instance->SetXY ( $x, $y );
$this->napdf_instance->Cell ( $columns['town'], 0, $meetings_day[$pos['count']]['location_municipality'] );
$x += $columns['town'];
$this->napdf_instance->SetX ( $x );
$this->napdf_instance->Cell ( $columns['name'], 0, $meetings_day[$pos['count']]['meeting_name'] );
$x += $columns['name'];
$this->napdf_instance->SetX ( $x );
$this->napdf_instance->Cell ( $columns['location'], 0, $meetings_day[$pos['count']]['location'] );
$x += $columns['location'];
$this->napdf_instance->SetX ( $x );
$this->napdf_instance->Cell ( $columns['time'], 0, $this->translate_time ( $meetings_day[$pos['count']]['start_time'] ), 0, 0, 'R' );
$x += $columns['time'];
$this->napdf_instance->SetX ( $x );
if ( $meetings_day[$pos['count']]['duration_time'] == "00:00:00" )
{
$meetings_day[$pos['count']]['duration_time'] = "01:30:00";
}
$base_dir = "images/";
$duration = split ( ":", $meetings_day[$pos['count']]['duration_time'] );
$duration[0] = intval ( $duration[0] );
$duration[1] = intval ( $duration[1] );
$ClockGraphic1 = "";
$ClockGraphic2 = "";
if ( $duration[0] > 0 )
{
$ClockGraphic1 = "C_60";
if ( $duration[0] > 1 )
{
$ClockGraphic2 = "C_60";
}
}
if ( !$ClockGraphic2 )
{
if ( $duration[1] > 45 )
{
$ClockGraphic2 = "C_60";
}
elseif ( $duration[1] > 30 )
{
$ClockGraphic2 = "C_45";
}
elseif ( $duration[1] > 15 )
{
$ClockGraphic2 = "C_30";
}
elseif ( $duration[1] > 0 )
{
$ClockGraphic2 = "C_15";
}
}
if ( $ClockGraphic1 )
{
$this->napdf_instance->Image ( "$base_dir$ClockGraphic1.png", $x, $y-($duration_width/2), $duration_width, 0, 'PNG' );
}
$x += $duration_width + $duration_gap;
if ( $ClockGraphic2 )
{
$this->napdf_instance->Image ( "$base_dir$ClockGraphic2.png", $x, $y-($duration_width/2), $duration_width, 0, 'PNG' );
}
$x += $duration_width + $duration_gap;
$this->napdf_instance->SetXY ( $x, $y );
$this->napdf_instance->Cell ( $columns['format'], 0, $this->RearrangeFormats ( $meetings_day[$pos['count']]['formats'] ) );
$y += $line_height;
if ( ($y + $line_height) >= $bottom )
{
$pos['count']++;
break;
}
}
$this->napdf_instance->SetFont ( $this->font, 'B', 14 );
for ( $a = 0; $a < $slen; $a++ )
{
$letter = $day_name[$a];
$this->napdf_instance->SetXY ( $left, $ya );
$this->napdf_instance->Cell ( $daygap, 0, $letter, 0, 0, 'C' );
$ya += 0.2;
if ( ($ya + 0.125) >= $y )
{
break;
}
}
if ( ($pos['count'] < ($count - 1)) && (($y + $line_height) >= $bottom) )
{
break;
}
$pos['count'] = 0;
if ( $pos['day'] == 0 )
{
$pos = "";
break;
}
if ( $pos['day'] == 6 )
{
$pos['day'] = -1;
}
$next_day = $pos['day'] + 1;
$next_day_count = count ( $meetings_days[$next_day] );
$next_day_y = ($next_day_count * $line_height);
$next_day_slen = strlen ( $this->weekday_names[$next_day_count] );
$next_day_y = max ( $next_day_y, ($next_day_slen * 0.125) );
if ( ($y + $next_day_y) >= $bottom )
{
$pos['day']++;
break;
}
}
return $pos;
}
| DrawRearPanel | ( | $ | left, | |
| $ | top, | |||
| $ | right, | |||
| $ | bottom, | |||
| $ | formats | |||
| ) | [private] |
Definition at line 559 of file eli_napdf.class.php.
References $formats.
Referenced by AssemblePDF().
{
$y = $top + 0.125;
$fontSize = $this->font_size;
// $this->napdf_instance->Rect ( $left, $top, ($right - $left), ($bottom - $top) );
$this->napdf_instance->SetFont ( $this->font, 'B', ($fontSize - 3) );
$stringWidth = $this->napdf_instance->GetStringWidth ( _PDF_SASNA_LIST_FORMAT_KEY );
$cellleft = (($right + $left) / 2) - ($stringWidth / 2);
$this->napdf_instance->SetXY ( $cellleft, $y );
$this->napdf_instance->Cell ( 0, 0, _PDF_SASNA_LIST_FORMAT_KEY );
$y += 0.125;
$count = count ( $formats );
$w1 = $left + 0.25;
$fSize = $fontSize - 4;
$this->napdf_instance->SetY ( $y );
foreach ( $formats as $format )
{
$this->napdf_instance->SetFont ( $this->font, 'B', $fSize );
$this->napdf_instance->SetLeftMargin ( $left );
$str = $format['key_string'];
$this->napdf_instance->SetX ( $left );
$this->napdf_instance->Cell ( 0, 0.13, $str );
$this->napdf_instance->SetFont ( $this->font, '', $fSize );
$str = $format['description_string'];
$this->napdf_instance->SetLeftMargin ( $w1 );
$this->napdf_instance->SetX ( $w1 );
$this->napdf_instance->MultiCell ( ($right - $w1), 0.13, $str );
$this->napdf_instance->SetY ( $this->napdf_instance->GetY ( ) + 0.01 );
}
$y = $this->napdf_instance->GetY ( ) + 0.1;
$base_dir = "images/";
$ClockGraphic1 = "C_15";
$ClockGraphic2 = "C_30";
$ClockGraphic3 = "C_45";
$ClockGraphic4 = "C_60";
$duration_width = 0.12;
$duration_gap = $duration_width / 4;
$x = $left;
$this->napdf_instance->SetLeftMargin ( $x );
$this->napdf_instance->SetXY ( $x, $y );
$str = _PDF_SASNA_LIST_DUR_INTRO." ";
$l = $this->napdf_instance->GetStringWidth ( $str );
$this->napdf_instance->Cell ( $l, 0.13, $str );
$x += $l + $duration_gap;
$this->napdf_instance->Image ( "$base_dir$ClockGraphic1.png", $x, $y, $duration_width, 0, 'PNG' );
$x += $duration_width + $duration_gap;
$str = _PDF_SASNA_LIST_DUR_15.", ";
$l = $this->napdf_instance->GetStringWidth ( $str );
$this->napdf_instance->SetX ( $x );
$this->napdf_instance->Cell ( $l, 0.13, $str );
$x += $l + $duration_gap;
$this->napdf_instance->Image ( "$base_dir$ClockGraphic2.png", $x, $y, $duration_width, 0, 'PNG' );
$x += $duration_width + $duration_gap;
$str = _PDF_SASNA_LIST_DUR_30.", ";
$l = $this->napdf_instance->GetStringWidth ( $str );
$this->napdf_instance->SetX ( $x );
$this->napdf_instance->Cell ( $l, 0.13, $str );
$x += $l + $duration_gap;
$this->napdf_instance->Image ( "$base_dir$ClockGraphic3.png", $x, $y, $duration_width, 0, 'PNG' );
$x += $duration_width + $duration_gap;
$str = _PDF_SASNA_LIST_DUR_45.", ";
$l = $this->napdf_instance->GetStringWidth ( $str );
$this->napdf_instance->SetX ( $x );
$this->napdf_instance->Cell ( $l, 0.13, $str );
$x += $l + $duration_gap;
$this->napdf_instance->Image ( "$base_dir$ClockGraphic4.png", $x, $y, $duration_width, 0, 'PNG' );
$x += $duration_width + $duration_gap;
$str = _PDF_SASNA_LIST_DUR_60;
$l = $this->napdf_instance->GetStringWidth ( $str );
$this->napdf_instance->SetX ( $x );
$this->napdf_instance->Cell ( $l, 0.13, $str );
$y = $this->napdf_instance->GetY ( ) + 0.25;
$this->napdf_instance->SetFont ( $this->font, 'B', ($fontSize + 1) );
$this->napdf_instance->SetXY ( $left + 0.2, $y );
$this->napdf_instance->MultiCell ( ($right - $left), (($fontSize + 1) / 72), _PDF_SASNA_LIST_MAILING_ELI );
$y = $this->napdf_instance->GetY ( ) + 0.05;
$this->napdf_instance->SetFont ( $this->font, 'B', ($fontSize - 1) );
$this->napdf_instance->SetXY ( $left + 0.3, $y );
$this->napdf_instance->MultiCell ( ($right - $left), (($fontSize + 1) / 72), _PDF_SASNA_LIST_ELI );
$y = $this->napdf_instance->GetY ( ) + 0.03;
$this->napdf_instance->SetFont ( $this->font, '', $fontSize - 1 );
$this->napdf_instance->SetXY ( $left + 0.3, $y );
$this->napdf_instance->MultiCell ( ($right - $left), (($fontSize - 1) / 72), _PDF_SASNA_LIST_PO_ELI );
$y = $this->napdf_instance->GetY ( ) + 0.03;
$this->napdf_instance->SetFont ( $this->font, '', $fontSize - 1 );
$this->napdf_instance->SetXY ( $left + 0.3, $y );
$this->napdf_instance->MultiCell ( ($right - $left), (($fontSize - 1) / 72), _PDF_SASNA_LIST_TOWN_ELI );
$this->napdf_instance->SetFont ( $this->font, '', $fontSize );
}
| OutputPDF | ( | ) |
Implements IPrintableList.
Definition at line 168 of file eli_napdf.class.php.
{
$d = date ( "Y_m_d" );
$this->napdf_instance->Output( "ELI_PrintableList_$d.pdf", "D" );
}
| RearrangeFormats | ( | $ | inFormats | ) | [private] |
Definition at line 781 of file eli_napdf.class.php.
Referenced by DrawListPanel().
{
$inFormats = split ( ",", $inFormats );
if ( !in_array ( "C", $inFormats ) && !in_array ( "O", $inFormats ) )
{
array_push ( $inFormats, "C" );
}
if ( !$ignore_bk && !in_array ( "BK", $inFormats ) && ((in_array ( "BT", $inFormats ) || in_array ( "IW", $inFormats ) || in_array ( "JT", $inFormats ) || in_array ( "SG", $inFormats ))) )
{
array_push ( $inFormats, "BK" );
}
usort ( $inFormats, 'eli_napdf::sort_cmp' );
$tFormats = $inFormats;
$inFormats = array();
foreach ( $tFormats as $format )
{
$format = trim ( $format );
if ( $format )
{
array_push ( $inFormats, $format );
}
}
return join ( ",", $inFormats );
}
| static sort_cmp | ( | $ | a, | |
| $ | b | |||
| ) | [static, private] |
Definition at line 835 of file eli_napdf.class.php.
{
$order_array = array( 0=>"O", 1=>"C",
2=>"ES", 3=>"B", 4=>"M", 5=>"W", 6=>"GL", 7=>"YP", 8=>"BK", 9=>"IP", 10=>"Pi", 11=>"RF", 12=>"Rr",
13=>"So", 14=>"St", 15=>"To", 16=>"Tr", 17=>"OE", 18=>"D", 19=>"SD", 20=>"TW", 21=>"IL",
22=>"BL", 23=>"IW", 24=>"BT", 25=>"SG", 26=>"JT",
27=>"Ti", 28=>"Sm", 29=>"NS", 30=>"CL", 31=>"CS", 32=>"NC", 33=>"SC", 34=>"CH", 35=>"SL", 36=>"WC" );
if ( in_array ( $a, $order_array ) || in_array ( $b, $order_array ) )
{
return (array_search ( $a, $order_array ) < array_search ( $b, $order_array )) ? -1 : 1;
}
else
{
return 0;
}
}
| static translate_duration | ( | $ | in_time_string | ) | [static, private] |
Definition at line 874 of file eli_napdf.class.php.
{
$t = split ( ":", $in_time_string );
$hours = intval ( $t[0] );
$minutes = intval ( $t[1] );
$ret = '';
if ( $hours )
{
$ret .= "$hours hour";
if ( $hours > 1 )
{
$ret .= "s";
}
if ( $minutes )
{
$ret .= " and ";
}
}
if ( $minutes )
{
$ret .= "$minutes minutes";
}
return $ret;
}
| static translate_time | ( | $ | in_time_string | ) | [static, private] |
Definition at line 855 of file eli_napdf.class.php.
Referenced by DrawListPanel().
{
$split = split ( ":", $in_time_string );
if ( $in_time_string == "12:00:00" )
{
return "Noon";
}
elseif ( ($split[0] == "23") && (intval ( $split[1] ) > 45) )
{
return "Midnight";
}
else
{
return date ( "g:i A", strtotime ( $in_time_string ) );
}
}
| $formats = 0 |
Definition at line 20 of file eli_napdf.class.php.
Referenced by DrawRearPanel().
| $pos = array ( 'start' => 1, 'end' => '', 'count' => 0, 'y' => 0, 'weekday' => 1 ) |
Definition at line 18 of file eli_napdf.class.php.
Referenced by AssemblePDF(), and DrawListPanel().
| $right_offset = 0 |
Definition at line 19 of file eli_napdf.class.php.
| $weekday_names = array ( "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ) |
Definition at line 17 of file eli_napdf.class.php.
1.7.1