Upgraded phpmyadmin to 4.0.4 (All Languages) - No modifications yet
[openemr.git] / phpmyadmin / libraries / plugins / export / ExportPdf.class.php
blobffabb96efa00138f80d7d0bb5b04c20c2868f6f0
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Produce a PDF report (export) from a query
6 * @package PhpMyAdmin-Export
7 * @subpackage PDF
8 */
9 if (! defined('PHPMYADMIN')) {
10 exit;
13 /* Get the export interface */
14 require_once 'libraries/plugins/ExportPlugin.class.php';
15 /* Get the PMA_ExportPdf class */
16 require_once 'libraries/plugins/export/PMA_ExportPdf.class.php';
18 /**
19 * Handles the export for the PDF class
21 * @package PhpMyAdmin-Export
22 * @subpackage PDF
24 class ExportPdf extends ExportPlugin
26 /**
27 * PMA_ExportPdf instance
29 * @var PMA_ExportPdf
31 private $_pdf;
33 /**
34 * PDF Report Title
36 * @var string
38 private $_pdfReportTitle;
40 /**
41 * Constructor
43 public function __construct()
45 // initialize the specific export PDF variables
46 $this->initSpecificVariables();
48 $this->setProperties();
51 /**
52 * Initialize the local variables that are used for export PDF
54 * @return void
56 protected function initSpecificVariables()
58 $this->_setPdfReportTitle("");
59 $this->_setPdf(new PMA_ExportPdf('L', 'pt', 'A3'));
62 /**
63 * Sets the export PDF properties
65 * @return void
67 protected function setProperties()
69 $props = 'libraries/properties/';
70 include_once "$props/plugins/ExportPluginProperties.class.php";
71 include_once "$props/options/groups/OptionsPropertyRootGroup.class.php";
72 include_once "$props/options/groups/OptionsPropertyMainGroup.class.php";
73 include_once "$props/options/items/MessageOnlyPropertyItem.class.php";
74 include_once "$props/options/items/TextPropertyItem.class.php";
75 include_once "$props/options/items/HiddenPropertyItem.class.php";
77 $exportPluginProperties = new ExportPluginProperties();
78 $exportPluginProperties->setText('PDF');
79 $exportPluginProperties->setExtension('pdf');
80 $exportPluginProperties->setMimeType('application/pdf');
81 $exportPluginProperties->setForceFile(true);
82 $exportPluginProperties->setOptionsText(__('Options'));
84 // create the root group that will be the options field for
85 // $exportPluginProperties
86 // this will be shown as "Format specific options"
87 $exportSpecificOptions = new OptionsPropertyRootGroup();
88 $exportSpecificOptions->setName("Format Specific Options");
90 // general options main group
91 $generalOptions = new OptionsPropertyMainGroup();
92 $generalOptions->setName("general_opts");
93 // create primary items and add them to the group
94 $leaf = new MessageOnlyPropertyItem();
95 $leaf->setName("explanation");
96 $leaf->setText(
97 __('(Generates a report containing the data of a single table)')
99 $generalOptions->addProperty($leaf);
100 $leaf = new TextPropertyItem();
101 $leaf->setName("report_title");
102 $leaf->setText(__('Report title:'));
103 $generalOptions->addProperty($leaf);
104 $leaf = new HiddenPropertyItem();
105 $leaf->setName("structure_or_data");
106 $generalOptions->addProperty($leaf);
107 // add the main group to the root group
108 $exportSpecificOptions->addProperty($generalOptions);
110 // set the options for the export plugin property item
111 $exportPluginProperties->setOptions($exportSpecificOptions);
112 $this->properties = $exportPluginProperties;
116 * This method is called when any PluginManager to which the observer
117 * is attached calls PluginManager::notify()
119 * @param SplSubject $subject The PluginManager notifying the observer
120 * of an update.
122 * @return void
124 public function update (SplSubject $subject)
129 * Outputs export header
131 * @return bool Whether it succeeded
133 public function exportHeader ()
135 $pdf_report_title = $this->_getPdfReportTitle();
136 $pdf = $this->_getPdf();
137 $pdf->Open();
139 $attr = array('titleFontSize' => 18, 'titleText' => $pdf_report_title);
140 $pdf->setAttributes($attr);
141 $pdf->setTopMargin(30);
143 return true;
147 * Outputs export footer
149 * @return bool Whether it succeeded
151 public function exportFooter ()
153 $pdf = $this->_getPdf();
155 // instead of $pdf->Output():
156 if (! PMA_exportOutputHandler($pdf->getPDFData())) {
157 return false;
160 return true;
164 * Outputs database header
166 * @param string $db Database name
168 * @return bool Whether it succeeded
170 public function exportDBHeader ($db)
172 return true;
176 * Outputs database footer
178 * @param string $db Database name
180 * @return bool Whether it succeeded
182 public function exportDBFooter ($db)
184 return true;
188 * Outputs CREATE DATABASE statement
190 * @param string $db Database name
192 * @return bool Whether it succeeded
194 public function exportDBCreate($db)
196 return true;
199 * Outputs the content of a table in NHibernate format
201 * @param string $db database name
202 * @param string $table table name
203 * @param string $crlf the end of line sequence
204 * @param string $error_url the url to go back in case of error
205 * @param string $sql_query SQL query for obtaining data
207 * @return bool Whether it succeeded
209 public function exportData($db, $table, $crlf, $error_url, $sql_query)
211 $pdf = $this->_getPdf();
213 $attr = array('currentDb' => $db, 'currentTable' => $table);
214 $pdf->setAttributes($attr);
215 $pdf->mysqlReport($sql_query);
217 return true;
218 } // end of the 'PMA_exportData()' function
221 /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
225 * Gets the PMA_ExportPdf instance
227 * @return PMA_ExportPdf
229 private function _getPdf()
231 return $this->_pdf;
235 * Instantiates the PMA_ExportPdf class
237 * @param string $pdf PMA_ExportPdf instance
239 * @return void
241 private function _setPdf($pdf)
243 $this->_pdf = $pdf;
247 * Gets the PDF report title
249 * @return string
251 private function _getPdfReportTitle()
253 return $this->_pdfReportTitle;
257 * Sets the PDF report title
259 * @param string $pdfReportTitle PDF report title
261 * @return void
263 private function _setPdfReportTitle($pdfReportTitle)
265 $this->_pdfReportTitle = $pdfReportTitle;