towards PEAR coding standards

This commit is contained in:
Marc Delisle
2005-12-04 19:28:28 +00:00
parent 88ff1c4181
commit 4a89855656

View File

@@ -11,7 +11,8 @@ define('FPDF_FONTPATH','./libraries/fpdf/font/');
//if ($charset == 'utf-8') {
define('PMA_PDF_FONT', 'FreeSans');
require_once('./libraries/fpdf/ufpdf.php');
class PMA_FPDF extends UFPDF {
class PMA_FPDF extends UFPDF
{
};
//} else {
// define('PMA_PDF_FONT', 'Arial');
@@ -23,14 +24,15 @@ define('FPDF_FONTPATH','./libraries/fpdf/font/');
// Adapted from a LGPL script by Philip Clarke
class PMA_PDF extends PMA_FPDF {
class PMA_PDF extends PMA_FPDF
{
var $tablewidths;
var $headerset;
var $footerset;
// overloading of a fpdf function:
function _beginpage($orientation) {
function _beginpage($orientation)
{
$this->page++;
// solved the problem of overwriting a page, if it already exists
if (!isset($this->pages[$this->page])) {
@@ -69,7 +71,8 @@ function _beginpage($orientation) {
}
}
function Header() {
function Header()
{
global $maxY;
// Check if header for this page already exists
@@ -80,7 +83,7 @@ function Header() {
}
$this->SetY(($this->tMargin) - ($this->FontSizePt/$this->k)*2);
$this->cellFontSize = $this->FontSizePt ;
$this->SetFont(PMA_PDF_FONT,'',( ( $this->titleFontSize) ? $this->titleFontSize : $this->FontSizePt ));
$this->SetFont(PMA_PDF_FONT, '' ,($this->titleFontSize ? $this->titleFontSize : $this->FontSizePt ));
$this->Cell(0, $this->FontSizePt, $this->titleText, 0, 1, 'C');
$l = ($this->lMargin);
$this->SetFont(PMA_PDF_FONT, '', $this->cellFontSize);
@@ -108,7 +111,8 @@ function Header() {
$this->SetY($maxY);
}
function Footer() {
function Footer()
{
// Check if footer for this page already exists
if (!isset($this->footerset[$this->page])) {
$this->SetY(-15);
@@ -120,7 +124,8 @@ function Footer() {
}
}
function morepagestable($lineheight=8) {
function morepagestable($lineheight=8)
{
// some things to set and 'remember'
$l = $this->lMargin;
$startheight = $h = $this->GetY();
@@ -143,7 +148,6 @@ function morepagestable($lineheight=8) {
$this->Line($l, $h, $fullwidth+$l, $h);
// write the content and remember the height of the highest col
foreach ($data as $col => $txt) {
$this->page = $currpage;
$this->SetXY($l, $h);
$this->MultiCell($this->tablewidths[$col], $lineheight, $txt, 0, $this->colAlign[$col]);
@@ -192,8 +196,8 @@ function morepagestable($lineheight=8) {
}
function mysql_report($query,$attr=array()){
function mysql_report($query, $attr = array())
{
foreach ($attr as $key => $val){
$this->$key = $val ;
}
@@ -208,7 +212,7 @@ function mysql_report($query,$attr=array()){
if (!isset($this->tablewidths)){
// starting col width
$this->sColWidth = (($this->w-$this->lMargin-$this->rMargin))/$this->numFields;
$this->sColWidth = ($this->w - $this->lMargin - $this->rMargin) / $this->numFields;
// loop through results header and set initial col widths/ titles/ alignment
// if a col title is less than the starting col width / reduce that column size
@@ -233,12 +237,12 @@ function mysql_report($query,$attr=array()){
while ($row = PMA_DBI_fetch_row($this->results)) {
foreach ($colFits as $key => $val) {
$stringWidth = $this->getstringwidth($row[$key]) + 6 ;
if( ($stringWidth) > $this->sColWidth ){
if ($stringWidth > $this->sColWidth) {
// any col where row is bigger than the start width is now discarded
unset($colFits[$key]);
} else {
// if text is not bigger than the current column width setting enlarge the column
if( ($stringWidth) > $val ){
if ($stringWidth > $val) {
$colFits[$key] = ($stringWidth) ;
}
}
@@ -253,10 +257,10 @@ function mysql_report($query,$attr=array()){
$totAlreadyFitted += $val;
}
$surplus = (sizeof($colFits)*$this->sColWidth) - ($totAlreadyFitted);
$surplus = (sizeof($colFits) * $this->sColWidth) - $totAlreadyFitted;
for ($i=0; $i < $this->numFields; $i++) {
if (!in_array($i, array_keys($colFits))) {
$this->tablewidths[$i] = $this->sColWidth + ($surplus/(($this->numFields)-sizeof($colFits)));
$this->tablewidths[$i] = $this->sColWidth + ($surplus / ($this->numFields - sizeof($colFits)));
}
}
@@ -286,7 +290,8 @@ function mysql_report($query,$attr=array()){
*
* @return bool Whether it suceeded
*/
function PMA_exportComment($text) {
function PMA_exportComment($text)
{
return TRUE;
}
@@ -297,7 +302,8 @@ function PMA_exportComment($text) {
*
* @access public
*/
function PMA_exportFooter() {
function PMA_exportFooter()
{
return TRUE;
}
@@ -308,7 +314,8 @@ function PMA_exportFooter() {
*
* @access public
*/
function PMA_exportHeader() {
function PMA_exportHeader()
{
return TRUE;
}
@@ -321,7 +328,8 @@ function PMA_exportHeader() {
*
* @access public
*/
function PMA_exportDBHeader($db) {
function PMA_exportDBHeader($db)
{
return TRUE;
}
@@ -334,7 +342,8 @@ function PMA_exportDBHeader($db) {
*
* @access public
*/
function PMA_exportDBFooter($db) {
function PMA_exportDBFooter($db)
{
return TRUE;
}
@@ -347,7 +356,8 @@ function PMA_exportDBFooter($db) {
*
* @access public
*/
function PMA_exportDBCreate($db) {
function PMA_exportDBCreate($db)
{
return TRUE;
}
@@ -364,7 +374,8 @@ function PMA_exportDBCreate($db) {
*
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
{
global $what;
global $pdf_report_title;