00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 include_once( 'lib/ezpdf/classes/class.ezpdftable.php' );
00033 include_once( 'lib/ezpdf/classes/class.pdf.php' );
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 class eZPDF
00048 {
00049
00050
00051
00052
00053 function eZPDF( $name = "pdf" )
00054 {
00055 $this->Operators = array( $name );
00056 $this->Config =& eZINI::instance( 'pdf.ini' );
00057 }
00058
00059
00060
00061
00062 function &operatorList()
00063 {
00064 return $this->Operators;
00065 }
00066
00067
00068
00069
00070 function namedParameterList()
00071 {
00072 return array( 'operation' => array( 'type' => 'string',
00073 'required' => true,
00074 'default' => '' ) );
00075 }
00076
00077
00078
00079
00080 function modify( &$tpl, &$operatorName, &$operatorParameters, &$rootNamespace, &$currentNamespace, &$operatorValue, &$namedParameters )
00081 {
00082 $config =& eZINI::instance( 'pdf.ini' );
00083
00084 switch ( $namedParameters['operation'] )
00085 {
00086 case 'toc':
00087 {
00088 $operatorValue = '<C:callTOC';
00089
00090 if ( count( $operatorParameters ) > 1 )
00091 {
00092 $params = $tpl->elementValue( $operatorParameters[1], $rootNamespace, $currentNamespace );
00093
00094 $operatorValue .= isset( $params['size'] ) ? ':size:'. implode(',', $params['size'] ) : '';
00095 $operatorValue .= isset( $params['dots'] ) ? ':dots:'. $params['dots'] : '';
00096 $operatorValue .= isset( $params['contentText'] ) ? ':contentText:'. $params['contentText'] : '';
00097 $operatorValue .= isset( $params['indent'] ) ? ':indent:'. implode(',', $params['indent'] ) : '';
00098
00099 }
00100
00101 $operatorValue .= '>';
00102 eZDebug::writeNotice( 'PDF: Generating TOC', 'eZPDF::modify' );
00103 } break;
00104
00105 case 'set_font':
00106 {
00107 $params = $tpl->elementValue( $operatorParameters[1], $rootNamespace, $currentNamespace );
00108
00109 $operatorValue = '<ezCall:callFont';
00110
00111 foreach ( $params as $key => $value )
00112 {
00113 if ( $key == 'colorCMYK' )
00114 {
00115 $operatorValue .= ':cmyk:' . implode( ',', $value );
00116 }
00117 else if ( $key == 'colorRGB' )
00118 {
00119 $operatorValue .= ':cmyk:' . implode( ',', eZMath::rgbToCMYK2( $value[0]/255,
00120 $value[1]/255,
00121 $value[2]/255 ) );
00122 }
00123 else
00124 {
00125 $operatorValue .= ':' . $key . ':' . $value;
00126 }
00127 }
00128 $operatorValue .= '>';
00129
00130 eZDebug::writeNotice( 'PDF: Changed font.' );
00131 } break;
00132
00133 case 'table':
00134 {
00135 $operatorValue = '<ezGroup:callTable';
00136
00137 if ( count( $operatorParameters > 2 ) )
00138 {
00139 $tableSettings = $tpl->elementValue( $operatorParameters[2], $rootNamespace, $currentNamespace );
00140
00141 if ( is_array( $tableSettings ) )
00142 {
00143 foreach( array_keys( $tableSettings ) as $key )
00144 {
00145 switch( $key )
00146 {
00147 case 'headerCMYK':
00148 case 'cellCMYK':
00149 case 'textCMYK':
00150 case 'titleCellCMYK':
00151 case 'titleTextCMYK':
00152 {
00153 $operatorValue .= ':' . $key . ':' . implode( ',', $tableSettings[$key] );
00154 } break;
00155
00156 default:
00157 {
00158 $operatorValue .= ':' . $key . ':' . $tableSettings[$key];
00159 } break;
00160 }
00161 }
00162 }
00163 }
00164
00165 $operatorValue .= '>';
00166
00167 $rows = $tpl->elementValue( $operatorParameters[1], $rootNamespace, $currentNamespace );
00168
00169 $rows = str_replace( array( ' ', "\t", "\r\n", "\n" ),
00170 '',
00171 $rows );
00172 include_once( 'lib/ezi18n/classes/eztextcodec.php' );
00173 $httpCharset = eZTextCodec::internalCharset();
00174 $outputCharset = $config->hasVariable( 'PDFGeneral', 'OutputCharset' )
00175 ? $config->variable( 'PDFGeneral', 'OutputCharset' )
00176 : 'iso-8859-1';
00177 $codec =& eZTextCodec::instance( $httpCharset, $outputCharset );
00178
00179 $rows =& $codec->convertString( $rows );
00180
00181 $operatorValue .= urlencode( $rows );
00182
00183 $operatorValue .= '</ezGroup:callTable><C:callNewLine>';
00184
00185 eZDebug::writeNotice( 'PDF: Added table to PDF',
00186 'eZPDF::modify' );
00187 } break;
00188
00189 case 'header':
00190 {
00191 $header = $tpl->elementValue( $operatorParameters[1], $rootNamespace, $currentNamespace );
00192
00193 $header['text'] = str_replace( array( ' ', "\t", "\r\n", "\n" ),
00194 '',
00195 $header['text'] );
00196
00197 $operatorValue = '<ezCall:callHeader:level:'. $header['level'] .':size:'. $header['size'];
00198
00199 if ( isset( $header['align'] ) )
00200 {
00201 $operatorValue .= ':justification:'. $header['align'];
00202 }
00203
00204 if ( isset( $header['font'] ) )
00205 {
00206 $operatorValue .= ':fontName:'. $header['font'];
00207 }
00208
00209 $operatorValue .= ':label:'. rawurlencode( $header['text'] );
00210
00211 $operatorValue .= '><C:callNewLine>'. $header['text'] .'</ezCall:callHeader><C:callNewLine>';
00212
00213 eZDebug::writeNotice( 'PDF: Added header: '. $header['text'] .', size: '. $header['size'] .
00214 ', align: '. $header['align'] .', level: '. $header['level'],
00215 'eZPDF::modify' );
00216 } break;
00217
00218 case 'create':
00219 {
00220 $this->createPDF();
00221 } break;
00222
00223 case 'new_line':
00224 case 'newline':
00225 {
00226 $operatorValue = '<C:callNewLine>';
00227 } break;
00228
00229 case 'new_page':
00230 case 'newpage':
00231 {
00232 $operatorValue = '<C:callNewPage><C:callNewLine>';
00233
00234 eZDebug::writeNotice( 'PDF: New page', 'eZPDF::modify' );
00235 } break;
00236
00237 case 'image':
00238 {
00239 $image = $tpl->elementValue( $operatorParameters[1], $rootNamespace, $currentNamespace );
00240
00241 $width = isset( $image['width'] ) ? $image['width']: 100;
00242 $height = isset( $image['height'] ) ? $image['height']: 100;
00243
00244 $operatorValue = '<C:callImage:src:'. rawurlencode( $image['src'] ) .':width:'. $width .':height:'. $height;
00245
00246 if ( isset( $image['static'] ) )
00247 {
00248 $operatorValue .= ':static:' . $image['static'];
00249 }
00250
00251 if ( isset ( $image['x'] ) )
00252 {
00253 $operatorValue .= ':x:' . $image['x'];
00254 }
00255
00256 if ( isset( $image['y'] ) )
00257 {
00258 $operatorValue .= ':y:' . $image['y'];
00259 }
00260
00261 if ( isset( $image['dpi'] ) )
00262 {
00263 $operatorValue .= ':dpi:' . $image['dpi'];
00264 }
00265
00266 if ( isset( $image['align'] ) )
00267 {
00268 $operatorValue .= ':align:' . $image['align'];
00269 }
00270
00271 $operatorValue .= '>';
00272
00273 eZDebug::writeNotice( 'PDF: Added Image '.$image['src'].' to PDF file', 'eZPDF::modify' );
00274 } break;
00275
00276 case 'anchor':
00277 {
00278 $name = $tpl->elementValue( $operatorParameters[1], $rootNamespace, $currentNamespace );
00279
00280 $operatorValue = '<C:callAnchor:'. $name['name'] .':FitH:>';
00281 eZDebug::writeNotice( 'PDF: Added anchor: '.$name['name'], 'eZPDF::modify' );
00282 } break;
00283
00284 case 'link':
00285 {
00286 $link = $tpl->elementValue( $operatorParameters[1], $rootNamespace, $currentNamespace );
00287
00288 $link['text'] = str_replace( '"',
00289 '"',
00290 $link['text'] );
00291
00292 $operatorValue = '<c:alink:'. rawurlencode( $link['url'] ) .'>'. $link['text'] .'</c:alink>';
00293 eZDebug::writeNotice( 'PDF: Added link: '. $link['text'] .', url: '.$link['url'], 'eZPDF::modify' );
00294 } break;
00295
00296 case 'stream':
00297 {
00298 $this->PDF->ezStream();
00299 }
00300
00301 case 'close':
00302 {
00303 include_once( 'lib/ezfile/classes/ezdir.php' );
00304 $filename = $tpl->elementValue( $operatorParameters[1], $rootNamespace, $currentNamespace );
00305
00306 eZDir::mkdir( eZDir::dirpath( $filename ), false, true );
00307
00308
00309
00310 require_once( 'kernel/classes/ezclusterfilehandler.php' );
00311 $file = eZClusterFileHandler::instance( $filename );
00312 $file->storeContents( $this->PDF->ezOutput(), 'viewcache', 'pdf' );
00313
00314 eZDebug::writeNotice( 'PDF file closed and saved to '. $filename, 'eZPDF::modify' );
00315 } break;
00316
00317 case 'strike':
00318 {
00319 $text = $tpl->elementValue( $operatorParameters[1], $rootNamespace, $currentNamespace );
00320 $operatorValue = '<c:strike>'. $text .'</c:strike>';
00321 eZDebug::writeNotice( 'Striked text added to PDF: "'. $text .'"', 'eZPDF::modify' );
00322 } break;
00323
00324
00325 case 'execute':
00326 {
00327 $text = $tpl->elementValue( $operatorParameters[1], $rootNamespace, $currentNamespace );
00328
00329 if ( count ( $operatorParameters ) > 2 )
00330 {
00331 $options = $tpl->elementValue( $operatorParameters[2], $rootNamespace, $currentNamespace );
00332
00333 $size = isset( $options['size'] ) ? $options['size'] : $config->variable( 'PDFGeneral', 'Format' );
00334 $orientation = isset( $options['orientation'] ) ? $options['orientation'] : $config->variable( 'PDFGeneral', 'Orientation' );
00335
00336 $this->createPDF( $size, $orientation );
00337 }
00338 else
00339 {
00340 $this->createPDF( $config->variable( 'PDFGeneral', 'Format' ), $config->variable( 'PDFGeneral', 'Orientation' ) );
00341 }
00342
00343 $text = str_replace( array( ' ', "\n", "\t" ), '', $text );
00344 include_once( 'lib/ezi18n/classes/eztextcodec.php' );
00345 $httpCharset = eZTextCodec::internalCharset();
00346 $outputCharset = $config->hasVariable( 'PDFGeneral', 'OutputCharset' )
00347 ? $config->variable( 'PDFGeneral', 'OutputCharset' )
00348 : 'iso-8859-1';
00349 $codec =& eZTextCodec::instance( $httpCharset, $outputCharset );
00350
00351 $text =& $codec->convertString( $text );
00352
00353 $this->PDF->ezText( $text );
00354 eZDebug::writeNotice( 'Execute text in PDF, length: "'. strlen( $text ) .'"', 'eZPDF::modify' );
00355 } break;
00356
00357 case 'page_number':
00358 case 'pageNumber':
00359 {
00360 $numberDesc = $tpl->elementValue( $operatorParameters[1], $rootNamespace, $currentNamespace );
00361
00362 if ( isset( $numberDesc['identifier'] ) )
00363 {
00364 $identifier = $numberDesc['identifier'];
00365 }
00366 else
00367 {
00368 $identifier = 'main';
00369 }
00370
00371 if ( isset( $numberDesc['start'] ) )
00372 {
00373 $operatorValue = '<C:callStartPageCounter:start:'. $numberDesc['start'] .':identifier:'. $identifier .'>';
00374 }
00375 else if ( isset( $numberDesc['stop'] ) )
00376 {
00377 $operatorValue = '<C:callStartPageCounter:stop:1:identifier:'. $identifier .'>';
00378 }
00379 } break;
00380
00381
00382 case 'line':
00383 {
00384 $lineDesc = $tpl->elementValue( $operatorParameters[1], $rootNamespace, $currentNamespace );
00385
00386 if ( isset( $lineDesc['pages']) and
00387 $lineDesc['pages'] == 'all' )
00388 {
00389 $operatorValue = '<ezGroup:callLine';
00390 }
00391 else
00392 {
00393 $operatorValue = '<C:callDrawLine';
00394 }
00395
00396 $operatorValue .= ':x1:' . $lineDesc['x1'];
00397 $operatorValue .= ':x2:' . $lineDesc['x2'];
00398 $operatorValue .= ':y1:' . $lineDesc['y1'];
00399 $operatorValue .= ':y2:' . $lineDesc['y2'];
00400
00401 $operatorValue .= ':thickness:' . ( isset( $lineDesc['thickness'] ) ? $lineDesc['thickness'] : '1' );
00402
00403 $operatorValue .= '>';
00404
00405 if ( $lineDesc['pages'] == 'all' )
00406 {
00407 $operatorValue .= '___</ezGroup:callLine>';
00408 }
00409
00410 return $operatorValue;
00411 } break;
00412
00413 case 'footer_block':
00414 case 'header_block':
00415 {
00416 $frameDesc = $tpl->elementValue( $operatorParameters[1], $rootNamespace, $currentNamespace );
00417
00418 $operatorValue = '<ezGroup:callBlockFrame';
00419 $operatorValue .= ':location:'. $namedParameters['operation'];
00420 $operatorValue .= '>';
00421
00422 if ( isset( $frameDesc['block_code'] ) )
00423 {
00424 include_once( 'lib/ezi18n/classes/eztextcodec.php' );
00425 $httpCharset = eZTextCodec::internalCharset();
00426 $outputCharset = $config->hasVariable( 'PDFGeneral', 'OutputCharset' )
00427 ? $config->variable( 'PDFGeneral', 'OutputCharset' )
00428 : 'iso-8859-1';
00429 $codec =& eZTextCodec::instance( $httpCharset, $outputCharset );
00430
00431 $frameDesc['block_code'] =& $codec->convertString( $frameDesc['block_code'] );
00432 $operatorValue .= urlencode( $frameDesc['block_code'] );
00433 }
00434
00435 $operatorValue .= '</ezGroup:callBlockFrame>';
00436
00437 eZDebug::writeNotice( 'PDF: Added Block '.$namedParameters['operation'] .': '.$operatorValue, 'eZPDF::modify' );
00438 return $operatorValue;
00439
00440 } break;
00441
00442
00443 case 'footer':
00444 case 'frame_header':
00445 {
00446 $frameDesc = $tpl->elementValue( $operatorParameters[1], $rootNamespace, $currentNamespace );
00447
00448 $operatorValue = '<ezGroup:callFrame';
00449 $operatorValue .= ':location:'. $namedParameters['operation'];
00450
00451 if ( $namedParameters['operation'] == 'footer' )
00452 {
00453 $frameType = 'Footer';
00454 }
00455 else if( $namedParameters['operation'] == 'frame_header' )
00456 {
00457 $frameType = 'Header';
00458 }
00459
00460 if ( isset( $frameDesc['align'] ) )
00461 {
00462 $operatorValue .= ':justification:'. $frameDesc['align'];
00463 }
00464
00465 if ( isset( $frameDesc['page'] ) )
00466 {
00467 $operatorValue .= ':page:'. $frameDesc['page'];
00468 }
00469 else
00470 {
00471 $operatorValue .= ':page:all';
00472 }
00473
00474 $operatorValue .= ':newline:' . ( isset( $frameDesc['newline'] ) ? $frameDesc['newline'] : 0 );
00475
00476 $operatorValue .= ':pageOffset:';
00477 if ( isset( $frameDesc['pageOffset'] ) )
00478 {
00479 $operatorValue .= $frameDesc['pageOffset'];
00480 }
00481 else
00482 {
00483 $operatorValue .= $this->Config->variable( $frameType, 'PageOffset' );
00484 }
00485
00486 if ( isset( $frameDesc['size'] ) )
00487 {
00488 $operatorValue .= ':size:'. $frameDesc['size'];
00489 }
00490
00491 if ( isset( $frameDesc['font'] ) )
00492 {
00493 $operatorValue .= ':font:'. $frameDesc['font'];
00494 }
00495
00496 $operatorValue .= '>';
00497
00498 if ( isset( $frameDesc['text'] ) )
00499 {
00500 include_once( 'lib/ezi18n/classes/eztextcodec.php' );
00501 $httpCharset = eZTextCodec::internalCharset();
00502 $outputCharset = $config->hasVariable( 'PDFGeneral', 'OutputCharset' )
00503 ? $config->variable( 'PDFGeneral', 'OutputCharset' )
00504 : 'iso-8859-1';
00505 $codec =& eZTextCodec::instance( $httpCharset, $outputCharset );
00506
00507 $frameDesc['text'] =& $codec->convertString( $frameDesc['text'] );
00508 $operatorValue .= urlencode( $frameDesc['text'] );
00509 }
00510
00511 $operatorValue .= '</ezGroup:callFrame>';
00512
00513 if ( isset( $frameDesc['margin'] ) )
00514 {
00515 $operatorValue .= '<C:callFrameMargins';
00516
00517 $operatorValue .= ':identifier:'. $namedParameters['operation'];
00518
00519 $operatorValue .= ':topMargin:';
00520 if ( isset( $frameDesc['margin']['top'] ) )
00521 {
00522 $operatorValue .= $frameDesc['margin']['top'];
00523 }
00524 else
00525 {
00526 $operatorValue .= $this->Config->variable( $frameType, 'TopMargin' );
00527 }
00528
00529 $operatorValue .= ':bottomMargin:';
00530 if ( isset( $frameDesc['margin']['bottom'] ) )
00531 {
00532 $operatorValue .= $frameDesc['margin']['bottom'];
00533 }
00534 else
00535 {
00536 $operatorValue .= $this->Config->variable( $frameType, 'BottomMargin' );
00537 }
00538
00539 $operatorValue .= ':leftMargin:';
00540 if ( isset( $frameDesc['margin']['left'] ) )
00541 {
00542 $operatorValue .= $frameDesc['margin']['left'];
00543 }
00544 else
00545 {
00546 $operatorValue .= $this->Config->variable( $frameType, 'LeftMargin' );
00547 }
00548
00549 $operatorValue .= ':rightMargin:';
00550 if ( isset( $frameDesc['margin']['right'] ) )
00551 {
00552 $operatorValue .= $frameDesc['margin']['right'];
00553 }
00554 else
00555 {
00556 $operatorValue .= $this->Config->variable( $frameType, 'RightMargin' );
00557 }
00558
00559 $operatorValue .= ':height:';
00560 if ( isset( $frameDesc['margin']['height'] ) )
00561 {
00562 $operatorValue .= $frameDesc['margin']['height'];
00563 }
00564 else
00565 {
00566 $operatorValue .= $this->Config->variable( $frameType, 'Height' );
00567 }
00568
00569 $operatorValue .= '>';
00570 }
00571
00572 if ( isset( $frameDesc['line'] ) )
00573 {
00574 $operatorValue .= '<C:callFrameLine';
00575 $operatorValue .= ':location:'. $namedParameters['operation'];
00576
00577 $operatorValue .= ':margin:';
00578 if( isset( $frameDesc['line']['margin'] ) )
00579 {
00580 $operatorValue .= $frameDesc['line']['margin'];
00581 }
00582 else
00583 {
00584 $operatorValue .= $this->Config->variable( $frameType, 'LineMargin' );
00585 }
00586
00587 if ( isset( $frameDesc['line']['leftMargin'] ) )
00588 {
00589 $operatorValue .= ':leftMargin:'. $frameDesc['line']['leftMargin'];
00590 }
00591 if ( isset( $frameDesc['line']['rightMargin'] ) )
00592 {
00593 $operatorValue .= ':rightMargin:'. $frameDesc['line']['rightMargin'];
00594 }
00595
00596 $operatorValue .= ':pageOffset:';
00597 if ( isset( $frameDesc['line']['pageOffset'] ) )
00598 {
00599 $operatorValue .= $frameDesc['line']['pageOffset'];
00600 }
00601 else
00602 {
00603 $operatorValue .= $this->Config->variable( $frameType, 'PageOffset' );
00604 }
00605
00606 $operatorValue .= ':page:';
00607 if ( isset( $frameDesc['line']['page'] ) )
00608 {
00609 $operatorValue .= $frameDesc['line']['page'];
00610 }
00611 else
00612 {
00613 $operatorValue .= $this->Config->variable( $frameType, 'Page' );
00614 }
00615
00616 $operatorValue .= ':thickness:';
00617 if ( isset( $frameDesc['line']['thickness'] ) )
00618 {
00619 $operatorValue .= $frameDesc['line']['thickness'];
00620 }
00621 else
00622 {
00623 $operatorValue .= $this->Config->variable( $frameType, 'LineThickness' );
00624 }
00625 $operatorValue .= '>';
00626 }
00627
00628 eZDebug::writeNotice( 'PDF: Added frame '.$frameType .': '.$operatorValue, 'eZPDF::modify' );
00629 } break;
00630
00631 case 'frontpage':
00632 {
00633 $pageDesc = $tpl->elementValue( $operatorParameters[1], $rootNamespace, $currentNamespace );
00634
00635 $align = isset( $pageDesc['align'] ) ? $pageDesc['align'] : 'center';
00636 $text = isset( $pageDesc['text'] ) ? $pageDesc['text'] : '';
00637 $top_margin = isset( $pageDesc['top_margin'] ) ? $pageDesc['top_margin'] : 100;
00638
00639 $operatorValue = '<ezGroup:callFrontpage:justification:'. $align .':top_margin:'. $top_margin;
00640
00641 if ( isset( $pageDesc['size'] ) )
00642 {
00643 $operatorValue .= ':size:'. $pageDesc['size'];
00644 }
00645
00646 $text = str_replace( array( ' ', "\t", "\r\n", "\n" ),
00647 '',
00648 $text );
00649 include_once( 'lib/ezi18n/classes/eztextcodec.php' );
00650 $httpCharset = eZTextCodec::internalCharset();
00651 $outputCharset = $config->hasVariable( 'PDFGeneral', 'OutputCharset' )
00652 ? $config->variable( 'PDFGeneral', 'OutputCharset' )
00653 : 'iso-8859-1';
00654 $codec =& eZTextCodec::instance( $httpCharset, $outputCharset );
00655
00656 $text =& $codec->convertString( $text );
00657
00658 $operatorValue .= '>'. urlencode( $text ) .'</ezGroup:callFrontpage>';
00659
00660 eZDebug::writeNotice( 'Added content to frontpage: '. $operatorValue, 'eZPDF::modify' );
00661 } break;
00662
00663
00664
00665
00666
00667
00668 case 'set_margin':
00669 {
00670 include_once( 'lib/ezutils/classes/ezmath.php' );
00671 $operatorValue = '<C:callSetMargin';
00672 $options = $tpl->elementValue( $operatorParameters[1], $rootNamespace, $currentNamespace );
00673
00674 foreach( array_keys( $options ) as $key )
00675 {
00676 $operatorValue .= ':' . $key . ':' . $options[$key];
00677 }
00678
00679 $operatorValue .= '>';
00680
00681 eZDebug::writeNotice( 'Added new margin/offset setup: ' . $operatorValue );
00682
00683 return $operatorValue;
00684 } break;
00685
00686
00687 case 'keyword':
00688 {
00689 $text = $tpl->elementValue( $operatorParameters[1], $rootNamespace, $currentNamespace );
00690
00691 $text = str_replace( array( ' ', "\n", "\t" ), '', $text );
00692 include_once( 'lib/ezi18n/classes/eztextcodec.php' );
00693 $httpCharset = eZTextCodec::internalCharset();
00694 $outputCharset = $config->hasVariable( 'PDFGeneral', 'OutputCharset' )
00695 ? $config->variable( 'PDFGeneral', 'OutputCharset' )
00696 : 'iso-8859-1';
00697 $codec =& eZTextCodec::instance( $httpCharset, $outputCharset );
00698
00699 $text =& $codec->convertString( $text );
00700
00701 $operatorValue = '<C:callKeyword:'. rawurlencode( $text ) .'>';
00702 } break;
00703
00704
00705 case 'createIndex':
00706 case 'create_index':
00707 {
00708 $operatorValue = '<C:callIndex>';
00709
00710 eZDebug::writeNotice( 'Adding Keyword index to PDF', 'eZPDF::modify' );
00711 } break;
00712
00713 case 'ul':
00714 {
00715 $text = $tpl->elementValue( $operatorParameters[1], $rootNamespace, $currentNamespace );
00716 if ( count( $operatorParameters ) > 2 )
00717 {
00718 $params = $tpl->elementValue( $operatorParameters[2], $rootNamespace, $currentNamespace );
00719 }
00720 else
00721 {
00722 $params = array();
00723 }
00724
00725 if ( isset( $params['rgb'] ) )
00726 {
00727 eZMath::normalizeColorArray( $params['rgb'] );
00728 $params['cmyk'] = eZMath::rgbToCMYK2( $params['rgb'][0]/255,
00729 $params['rgb'][1]/255,
00730 $params['rgb'][2]/255 );
00731 }
00732
00733 if ( !isset( $params['cmyk'] ) )
00734 {
00735 $params['cmyk'] = eZMath::rgbToCMYK2( 0, 0, 0 );
00736 }
00737 if ( !isset( $params['radius'] ) )
00738 {
00739 $params['radius'] = 2;
00740 }
00741 if ( !isset ( $params['pre_indent'] ) )
00742 {
00743 $params['pre_indent'] = 0;
00744 }
00745 if ( !isset ( $params['indent'] ) )
00746 {
00747 $params['indent'] = 2;
00748 }
00749 if ( !isset ( $params['yOffset'] ) )
00750 {
00751 $params['yOffset'] = -1;
00752 }
00753
00754 $operatorValue = '<C:callCircle' .
00755 ':pages:current' .
00756 ':x:-1' .
00757 ':yOffset:' . $params['yOffset'] .
00758 ':y:-1' .
00759 ':indent:' . $params['indent'] .
00760 ':pre_indent:' . $params['pre_indent'] .
00761 ':radius:' . $params['radius'] .
00762 ':cmyk:' . implode( ',', $params['cmyk'] ) .
00763 '>';
00764
00765 $operatorValue .= '<C:callSetMargin' .
00766 ':delta_left:' . ( $params['indent'] + $params['radius'] * 2 + $params['pre_indent'] ) .
00767 '>';
00768
00769 $operatorValue .= $text;
00770
00771 $operatorValue .= '<C:callSetMargin' .
00772 ':delta_left:' . -1 * ( $params['indent'] + $params['radius'] * 2 + $params['pre_indent'] ) .
00773 '>';
00774 } break;
00775
00776 case 'filled_circle':
00777 {
00778 include_once( 'lib/ezutils/classes/ezmath.php' );
00779 $operatorValue = '';
00780 $options = $tpl->elementValue( $operatorParameters[1], $rootNamespace, $currentNamespace );
00781
00782 if ( !isset( $options['pages'] ) )
00783 {
00784 $options['pages'] = 'current';
00785 }
00786
00787 if ( !isset( $options['x'] ) )
00788 {
00789 $options['x'] = -1;
00790 }
00791
00792 if ( !isset( $options['y'] ) )
00793 {
00794 $options['y'] = -1;
00795 }
00796
00797 if ( isset( $options['rgb'] ) )
00798 {
00799 eZMath::normalizeColorArray( $options['rgb'] );
00800 $options['cmyk'] = eZMath::rgbToCMYK2( $options['rgb'][0]/255,
00801 $options['rgb'][1]/255,
00802 $options['rgb'][2]/255 );
00803 }
00804
00805 $operatorValue = '<C:callCircle' .
00806 ':pages:' . $options['pages'] .
00807 ':x:' . $options['x'] .
00808 ':y:' . $options['y'] .
00809 ':radius:' . $options['radius'];
00810
00811 if ( isset( $options['cmyk'] ) )
00812 {
00813 $operatorValue .= ':cmyk:' . implode( ',', $options['cmyk'] );
00814 }
00815
00816 $operatorValue .= '>';
00817
00818 eZDebug::writeNotice( 'PDF Added circle: ' . $operatorValue );
00819
00820 return $operatorValue;
00821 } break;
00822
00823 case 'rectangle':
00824 {
00825 include_once( 'lib/ezutils/classes/ezmath.php' );
00826 $operatorValue = '';
00827 $options = $tpl->elementValue( $operatorParameters[1], $rootNamespace, $currentNamespace );
00828
00829 if ( !isset( $options['pages'] ) )
00830 {
00831 $options['pages'] = 'current';
00832 }
00833 if ( !isset( $options['line_width'] ) )
00834 {
00835 $options['line_width'] = 1;
00836 }
00837 if ( !isset( $options['round_corner'] ) )
00838 {
00839 $options['round_corner'] = false;
00840 }
00841
00842 $operatorValue = '<C:callRectangle';
00843 foreach ( $options as $key => $value )
00844 {
00845 if ( $key == 'rgb' )
00846 {
00847 eZMath::normalizeColorArray( $options['rgb'] );
00848 $operatorValue .= ':cmyk:' . implode( ',', eZMath::rgbToCMYK2( $options['rgb'][0]/255,
00849 $options['rgb'][1]/255,
00850 $options['rgb'][2]/255 ) );
00851 }
00852 else if ( $key == 'cmyk' )
00853 {
00854 $operatorValue .= ':cmyk:' . implode( ',', $value );
00855 }
00856 else
00857 {
00858 $operatorValue .= ':' . $key . ':' . $value;
00859 }
00860 }
00861 $operatorValue .= '>';
00862
00863 eZDebug::writeNotice( 'PDF Added rectangle: ' . $operatorValue );
00864
00865 return $operatorValue;
00866 } break;
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876 case 'filled_rectangle':
00877 {
00878 include_once( 'lib/ezutils/classes/ezmath.php' );
00879 $operatorValue = '';
00880 $options = $tpl->elementValue( $operatorParameters[1], $rootNamespace, $currentNamespace );
00881
00882 if ( !isset( $options['pages'] ) )
00883 {
00884 $options['pages'] = 'current';
00885 }
00886
00887 if ( isset( $options['rgb'] ) )
00888 {
00889 eZMath::normalizeColorArray( $options['rgb'] );
00890 $options['cmyk'] = eZMath::rgbToCMYK2( $options['rgb'][0]/255,
00891 $options['rgb'][1]/255,
00892 $options['rgb'][2]/255 );
00893 }
00894
00895 if ( isset( $options['cmyk'] ) )
00896 {
00897 $options['cmykTop'] = $options['cmyk'];
00898 $options['cmykBottom'] = $options['cmyk'];
00899 }
00900
00901 if ( !isset( $options['cmykTop'] ) )
00902 {
00903 if ( isset( $options['rgbTop'] ) )
00904 {
00905 eZMath::normalizeColorArray( $options['rgbTop'] );
00906 $options['cmykTop'] = eZMath::rgbToCMYK2( $options['rgbTop'][0]/255,
00907 $options['rgbTop'][1]/255,
00908 $options['rgbTop'][2]/255 );
00909 }
00910 else
00911 {
00912 $options['cmykTop'] = eZMath::rgbToCMYK2( 0, 0, 0 );
00913 }
00914 }
00915
00916 if ( !isset( $options['cmykBottom'] ) )
00917 {
00918 if ( isset( $options['rgbBottom'] ) )
00919 {
00920 eZMath::normalizeColorArray( $options['rgbBottom'] );
00921 $options['cmykBottom'] = eZMath::rgbToCMYK2( $options['rgbBottom'][0]/255,
00922 $options['rgbBottom'][1]/255,
00923 $options['rgbBottom'][2]/255 );
00924 }
00925 else
00926 {
00927 $options['cmykBottom'] = eZMath::rgbToCMYK2( 0, 0, 0 );
00928 }
00929 }
00930
00931 if ( !isset( $options['pages'] ) )
00932 {
00933 $options['pages'] = 'current';
00934 }
00935
00936 $operatorValue = '<C:callFilledRectangle' .
00937 ':pages:' . $options['pages'] .
00938 ':x:' . $options['x'] .
00939 ':y:' . $options['y'] .
00940 ':width:' . $options['width'] .
00941 ':height:' . $options['height'] .
00942 ':cmykTop:' . implode( ',', $options['cmykTop'] ) .
00943 ':cmykBottom:' . implode( ',', $options['cmykBottom'] ) .
00944 '>';
00945
00946 eZDebug::writeNotice( 'Added rectangle: ' . $operatorValue );
00947 } break;
00948
00949
00950 case 'text':
00951 {
00952 $text = $tpl->elementValue( $operatorParameters[1], $rootNamespace, $currentNamespace );
00953
00954 $operatorValue = '';
00955 $changeFont = false;
00956
00957 if ( count( $operatorParameters ) >= 3)
00958 {
00959 $textSettings = $tpl->elementValue( $operatorParameters[2], $rootNamespace, $currentNamespace );
00960
00961 if ( isset( $textSettings ) )
00962 {
00963 $operatorValue .= '<ezCall:callText';
00964 $changeFont = true;
00965
00966 if ( isset( $textSettings['font'] ) )
00967 {
00968 $operatorValue .= ':font:'. $textSettings['font'];
00969 }
00970
00971 if ( isset( $textSettings['size'] ) )
00972 {
00973 $operatorValue .= ':size:'. $textSettings['size'];
00974 }
00975
00976 if ( isset( $textSettings['align'] ) )
00977 {
00978 $operatorValue .= ':justification:'. $textSettings['align'];
00979 }
00980
00981 if ( isset( $textSettings['rgb'] ) )
00982 {
00983 $textSettings['cmyk'] = eZMath::rgbToCMYK2( $textSettings['rgb'][0]/255,
00984 $textSettings['rgb'][1]/255,
00985 $textSettings['rgb'][2]/255 );
00986 }
00987
00988 if ( isset( $textSettings['cmyk'] ) )
00989 {
00990 $operatorValue .= ':cmyk:' . implode( ',', $textSettings['cmyk'] );
00991 }
00992
00993 $operatorValue .= '>';
00994 }
00995 }
00996
00997 $operatorValue .= $text;
00998 if ( $changeFont )
00999 {
01000 $operatorValue .= '</ezCall:callText>';
01001 }
01002
01003 } break;
01004
01005 case 'text_box':
01006 {
01007 $parameters = $tpl->elementValue( $operatorParameters[1], $rootNamespace, $currentNamespace );
01008
01009 $operatorValue = '<ezGroup:callTextBox';
01010
01011 foreach( array_keys( $parameters ) as $key )
01012 {
01013 if ( $key != 'text' )
01014 {
01015 $operatorValue .= ':' . $key . ':' . urlencode( $parameters[$key] );
01016 }
01017 }
01018
01019 include_once( 'lib/ezi18n/classes/eztextcodec.php' );
01020 $httpCharset = eZTextCodec::internalCharset();
01021 $outputCharset = $config->hasVariable( 'PDFGeneral', 'OutputCharset' )
01022 ? $config->variable( 'PDFGeneral', 'OutputCharset' )
01023 : 'iso-8859-1';
01024 $codec =& eZTextCodec::instance( $httpCharset, $outputCharset );
01025
01026 $parameters['text'] =& $codec->convertString( $parameters['text'] );
01027
01028 $operatorValue .= '>';
01029 $operatorValue .= urlencode( $parameters['text'] );
01030 $operatorValue .= '</ezGroup:callTextBox>';
01031
01032 return $operatorValue;
01033 } break;
01034
01035 case 'text_frame':
01036 {
01037 $text = $tpl->elementValue( $operatorParameters[1], $rootNamespace, $currentNamespace );
01038
01039 $operatorValue = '';
01040 $changeFont = false;
01041
01042 if ( count( $operatorParameters ) >= 3)
01043 {
01044 $textSettings = $tpl->elementValue( $operatorParameters[2], $rootNamespace, $currentNamespace );
01045
01046 if ( isset( $textSettings ) )
01047 {
01048 $operatorValue .= '<ezGroup:callTextFrame';
01049 $changeFont = true;
01050
01051 foreach ( array_keys( $textSettings ) as $key )
01052 {
01053 if ( $key == 'frameCMYK' )
01054 {
01055 $operatorValue .= ':frameCMYK:' . implode( ',', $textSettings['frameCMYK'] );
01056 }
01057 else if ( $key == 'frameRGB' )
01058 {
01059 $operatorValue .= ':frameCMYK:' . implode( ',', eZMath::rgbToCMYK2( $textSettings['frameRGB'][0]/255,
01060 $textSettings['frameRGB'][1]/255,
01061 $textSettings['frameRGB'][2]/255 ) );
01062 }
01063 else if ( $key == 'textCMYK' )
01064 {
01065 $operatorValue .= ':textCMYK:' . implode( ',', $textSettings['textCMYK'] );
01066 }
01067 else if ( $key == 'textRGB' )
01068 {
01069 $operatorValue .= ':textCMYK:' . implode( ',', eZMath::rgbToCMYK2( $textSettings['textRGB'][0]/255,
01070 $textSettings['textRGB'][1]/255,
01071 $textSettings['textRGB'][2]/255 ) );
01072 }
01073 else
01074 {
01075 $operatorValue .= ':' . $key . ':' . $textSettings[$key];
01076 }
01077 }
01078
01079 include_once( 'lib/ezi18n/classes/eztextcodec.php' );
01080 $httpCharset = eZTextCodec::internalCharset();
01081 $outputCharset = $config->hasVariable( 'PDFGeneral', 'OutputCharset' )
01082 ? $config->variable( 'PDFGeneral', 'OutputCharset' )
01083 : 'iso-8859-1';
01084 $codec =& eZTextCodec::instance( $httpCharset, $outputCharset );
01085
01086 $text =& $codec->convertString( $text );
01087
01088 $operatorValue .= '>' . urlencode( $text ) . '</ezGroup::callTextFrame>';
01089
01090 }
01091 }
01092
01093 eZDebug::writeNotice( 'Added TextFrame: ' . $operatorValue );
01094 } break;
01095
01096 default:
01097 {
01098 eZDebug::writeError( 'PDF operation "'. $namedParameters['operation'] .'" undefined', 'eZPDF::modify' );
01099 }
01100
01101 }
01102
01103 }
01104
01105
01106
01107
01108
01109 function createPDF( $paper = 'a4', $orientation = 'portrait' )
01110 {
01111 $this->PDF = new eZPDFTable( $paper, $orientation );
01112 $this->PDF->selectFont( 'lib/ezpdf/classes/fonts/Helvetica' );
01113 eZDebug::writeNotice( 'PDF: File created' );
01114 }
01115
01116
01117 var $Operators;
01118 var $PDF;
01119 var $Config;
01120 }
01121
01122
01123 ?>