Merge pull request #19174 from eileenmcnaughton/conttype
[civicrm-core.git] / CRM / Report / OutputHandler / Print.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
10 */
11
12 use Civi\Report\OutputHandlerInterface;
13 use Civi\Report\OutputHandlerBase;
14
15 /**
16 * CSV Report Output Handler
17 */
18 class CRM_Report_OutputHandler_Print extends OutputHandlerBase implements OutputHandlerInterface {
19
20 /**
21 * Are we a suitable output handler based on the given form?
22 *
23 * The class member $form isn't set yet at this point since we don't
24 * even know if we're in play yet, so the form is a parameter.
25 *
26 * @param CRM_Report_Form $form
27 *
28 * @return bool
29 */
30 public function isOutputHandlerFor(CRM_Report_Form $form):bool {
31 return ($form->getOutputMode() === 'print');
32 }
33
34 /**
35 * Return the download filename. This should be the "clean" name, not
36 * a munged temporary filename.
37 *
38 * For 'print' there is no attachment.
39 *
40 * @return string
41 */
42 public function getFileName():string {
43 return '';
44 }
45
46 /**
47 * Return the html body of the email.
48 *
49 * @return string
50 */
51 public function getMailBody():string {
52 return $this->getOutputString();
53 }
54
55 /**
56 * Return the report contents as a string.
57 *
58 * @return string
59 */
60 public function getOutputString():string {
61 return $this->getForm()->compileContent();
62 }
63
64 /**
65 * Set headers as appropriate and send the output to the browser.
66 * Here the headers are already text/html.
67 */
68 public function download() {
69 echo $this->getOutputString();
70 }
71
72 /**
73 * Override so links displayed in the browser are relative.
74 *
75 * @return bool
76 */
77 public function isAbsoluteUrl():bool {
78 return FALSE;
79 }
80
81 }