[ Index ] |
PHP Cross Reference of vtigercrm-6.1.0 |
[Summary view] [Print] [Text view]
1 <?php 2 /*+********************************************************************************** 3 * The contents of this file are subject to the vtiger CRM Public License Version 1.0 4 * ("License"); You may not use this file except in compliance with the License 5 * The Original Code is: vtiger CRM Open Source 6 * The Initial Developer of the Original Code is vtiger. 7 * Portions created by vtiger are Copyright (C) vtiger. 8 * All Rights Reserved. 9 ************************************************************************************/ 10 include_once dirname(__FILE__) . '/Viewer.php'; 11 12 class Vtiger_PDF_ContentViewer extends Vtiger_PDF_Viewer { 13 14 protected $cells; 15 16 protected $contentModels = array(); 17 protected $contentSummaryModel; 18 protected $watermarkModel; 19 20 function addContentModel($m) { 21 $this->contentModels[] = $m; 22 } 23 24 function setContentModels($m) { 25 if(!is_array($m)) $m = array($m); 26 $this->contentModels = $m; 27 } 28 29 function setSummaryModel($m) { 30 $this->contentSummaryModel = $m; 31 } 32 33 function setWatermarkModel($m) { 34 $this->watermarkModel = $m; 35 } 36 37 function totalHeight($parent) { 38 return 0; // Variable height 39 } 40 41 function initDisplay($parent) { 42 $pdf = $parent->getPDF(); 43 $contentFrame = $parent->getContentFrame(); 44 45 $pdf->MultiCell($contentFrame->w, $contentFrame->h, "", 1, 'L', 0, 1, $contentFrame->x, $contentFrame->y); 46 } 47 48 function displayWatermark($parent) { 49 $pdf = $parent->getPDF(); 50 $contentFrame = $parent->getContentFrame(); 51 52 if($this->watermarkModel) { 53 $content = $this->watermarkModel->get('content'); 54 55 $currentFontSize = $pdf->getFontSize(); 56 $pdf->SetFont('','B',40); 57 $pdf->SetTextColor(240,240,240); 58 59 $contentW = $pdf->GetStringWidth($content); 60 $contentH = $pdf->GetStringHeight($content, $contentFrame->w); 61 $contentLineY = $contentFrame->y + ($contentFrame->h/2.0) - ($contentH/2.0); 62 $contentLineX = $contentFrame->x + ($contentFrame->w/2.0) - ($contentW/2.0); 63 64 $pdf->Text($contentLineX, $contentLineY, $content); 65 $pdf->SetTextColor(0,0,0); 66 $pdf->SetFont('','',$currentFontSize); 67 } 68 } 69 70 function display($parent) { 71 $models = $this->contentModels; 72 73 $totalModels = count($models); 74 $pdf = $parent->getPDF(); 75 76 $parent->createPage(); 77 $contentFrame = $parent->getContentFrame(); 78 79 $contentLineX = $contentFrame->x; $contentLineY = $contentFrame->y; 80 81 for ($index = 0; $index < $totalModels; ++$index) { 82 $model = $models[$index]; 83 84 $contentHeight = $pdf->GetStringHeight($model->get('content'), $contentFrame->w); 85 if($contentLineY + $contentHeight > ($contentFrame->h+$contentFrame->y)) { 86 $parent->createPage(); 87 88 $contentFrame = $parent->getContentFrame(); 89 $contentLineX = $contentFrame->x; $contentLineY = $contentFrame->y; 90 } 91 92 $pdf->MultiCell($contentFrame->w, $contentHeight, $model->get('content'), 1, 'L', 0, 1, $contentLineX, $contentLineY); 93 $contentLineY = $pdf->GetY(); 94 } 95 96 // Add last page to take care of footer display 97 $parent->createLastPage(); 98 } 99 100 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:08:37 2014 | Cross-referenced by PHPXref 0.7.1 |