3057ec13 |
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 | namespace Civi\Report; |
12 | |
13 | /** |
14 | * Base Report Output Handler |
15 | */ |
16 | class OutputHandlerBase implements OutputHandlerInterface { |
17 | |
18 | /** |
19 | * This is for convenience since otherwise several functions |
20 | * would take it as a parameter. |
21 | * |
22 | * @var \CRM_Report_Form |
23 | */ |
24 | protected $form; |
25 | |
26 | /** |
27 | * Getter for $form |
28 | * |
29 | * @return \CRM_Report_Form |
30 | */ |
31 | public function getForm():\CRM_Report_Form { |
32 | return $this->form; |
33 | } |
34 | |
35 | /** |
36 | * Setter for $form |
37 | * |
38 | * @param \CRM_Report_Form $form |
39 | */ |
40 | public function setForm(\CRM_Report_Form $form) { |
41 | $this->form = $form; |
42 | } |
43 | |
44 | /** |
45 | * Are we a suitable output handler based on the given form? |
46 | * |
47 | * The class member $form isn't set yet at this point since we don't |
48 | * even know if we're in play yet, so the form is a parameter. |
49 | * |
50 | * @param \CRM_Report_Form $form |
51 | * |
52 | * @return bool |
53 | */ |
54 | public function isOutputHandlerFor(\CRM_Report_Form $form):bool { |
55 | return FALSE; |
56 | } |
57 | |
58 | /** |
59 | * Return the download filename. This should be the "clean" name, not |
60 | * a munged temporary filename. |
61 | * |
62 | * @return string |
63 | */ |
64 | public function getFileName():string { |
65 | return ''; |
66 | } |
67 | |
68 | /** |
69 | * Return the html body of the email. |
70 | * |
71 | * @return string |
72 | */ |
73 | public function getMailBody():string { |
74 | return ''; |
75 | } |
76 | |
77 | /** |
78 | * Return the report contents as a string. |
79 | * |
80 | * @return string |
81 | */ |
82 | public function getOutputString():string { |
83 | return ''; |
84 | } |
85 | |
86 | /** |
87 | * Set headers as appropriate and send the output to the browser. |
88 | */ |
89 | public function download() { |
90 | } |
91 | |
92 | /** |
93 | * Mime type of the attachment. |
94 | * |
95 | * @return string |
96 | */ |
97 | public function getMimeType():string { |
98 | return 'text/html'; |
99 | } |
100 | |
101 | /** |
102 | * Charset of the attachment. |
103 | * |
104 | * The default of '' means charset is not specified in the mimepart, |
105 | * which is normal for binary attachments, but for text attachments you |
106 | * should specify something like 'utf-8'. |
107 | * |
108 | * @return string |
109 | */ |
110 | public function getCharset():string { |
111 | return ''; |
112 | } |
113 | |
114 | /** |
115 | * Hide/show various elements in the output, but generally for a handler |
116 | * this is always set to TRUE. |
117 | * |
118 | * @return bool |
119 | */ |
120 | public function isPrintOnly():bool { |
121 | return TRUE; |
122 | } |
123 | |
124 | /** |
125 | * Use a pager, but for a handler this would be FALSE since paging |
126 | * is a UI element. |
127 | * |
128 | * @return bool |
129 | */ |
130 | public function isAddPaging():bool { |
131 | return FALSE; |
132 | } |
133 | |
134 | /** |
135 | * Create absolute urls for links. Generally for a handler |
136 | * this is always set to TRUE, but for example for 'print' it's displayed |
137 | * on the site so it can be relative. |
138 | * @todo Couldn't it just always be absolute? |
139 | * |
140 | * @return bool |
141 | */ |
142 | public function isAbsoluteUrl():bool { |
143 | return TRUE; |
144 | } |
145 | |
146 | } |