Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGarvin Hicking <me@supergarv.de>2003-11-22 23:57:48 +0300
committerGarvin Hicking <me@supergarv.de>2003-11-22 23:57:48 +0300
commitc2b46ac9452b997ff61664e3f15a0f4e1367b1b2 (patch)
tree26f88dfa49345ad56261a93bf756941f99ddafe7 /pdf_schema.php
parent096094b74d73ae02aef352b8daafac0706b69078 (diff)
Final batch of PHP3-Compatibility fixes. Please test. :-)
Diffstat (limited to 'pdf_schema.php')
-rw-r--r--pdf_schema.php116
1 files changed, 38 insertions, 78 deletions
diff --git a/pdf_schema.php b/pdf_schema.php
index fc97f0f33b..05dd2e7563 100644
--- a/pdf_schema.php
+++ b/pdf_schema.php
@@ -43,32 +43,10 @@ if (!$cfgRelation['pdfwork']) {
* Gets the "fpdf" libraries and defines the pdf font path
*/
require('./libraries/fpdf/fpdf.php');
-// loic1: PHP3 compatibility
-// define('FPDF_FONTPATH', './libraries/fpdf/font/');
$FPDF_font_path = './libraries/fpdf/font/';
/**
- * Emulates the "array_search" function with PHP < 4.0.5
- */
-if (PMA_PHP_INT_VERSION < 40005) {
- function array_search($needle, $haystack) {
- $match = FALSE;
-
- reset($haystack);
- while (list($key, $value) = each($haystack)) {
- if ($value == $needle) {
- $match = $key;
- }
- } // end while
-
- return $match;
- } // end of the "array_search" function
-} // end if
-
-
-
-/**
* Extends the "FPDF" class and prepares the work
*
* @access public
@@ -121,8 +99,7 @@ class PMA_PDF extends FPDF
if(count($this->Alias) > 0)
{
$nb=$this->page;
- @reset($this->Alias);
- while(list($alias, $value) = each($this->Alias)) {
+ foreach($this->Alias AS $alias => $value) {
for($n=1;$n<=$nb;$n++)
$this->pages[$n]=str_replace($alias,$value,$this->pages[$n]);
}
@@ -472,14 +449,16 @@ function Row($data,$links)
{
// line height
$nb=0;
- for($i=0;$i<count($data);$i++)
+ $data_cnt = count($data);
+ for($i=0;$i<$data_cnt;$i++)
$nb=max($nb,$this->NbLines($this->widths[$i],$data[$i]));
$il = $this->FontSize;
$h=($il+1)*$nb;
// page break if necessary
$this->CheckPageBreak($h);
// draw the cells
- for($i=0;$i<count($data);$i++)
+ $data_cnt = count($data);
+ for($i=0;$i<$data_cnt;$i++)
{
$w=$this->widths[$i];
// save current position
@@ -598,8 +577,7 @@ class PMA_RT_Table
// there are fields that require wider cells than the name of the table?
global $pdf;
- reset($this->fields);
- while (list(, $field) = each($this->fields)) {
+ foreach($this->fields AS $field) {
$this->width = max($this->width, $pdf->GetStringWidth($field));
}
$this->width += $pdf->GetStringWidth(' ');
@@ -656,17 +634,16 @@ class PMA_RT_Table
$pdf->SetTextColor(0);
$pdf->SetFillColor(255);
- reset($this->fields);
- while (list(, $field) = each($this->fields)) {
+ foreach($this->fields AS $field) {
// loic1 : PHP3 fix
// if (in_array($field, $this->primary)) {
if ($setcolor) {
if (PMA_isInto($field, $this->primary) != -1) {
- $pdf->SetFillColor(215, 121, 123);
- }
- if ($field == $this->displayfield) {
- $pdf->SetFillColor(142, 159, 224);
- }
+ $pdf->SetFillColor(215, 121, 123);
+ }
+ if ($field == $this->displayfield) {
+ $pdf->SetFillColor(142, 159, 224);
+ }
}
if ($with_doc) $pdf->SetLink($pdf->PMA_links['RT'][$this->table_name][$field],-1);
else $pdf->PMA_links['doc'][$this->table_name][$field] = '';
@@ -1019,8 +996,7 @@ class PMA_RT
function PMA_RT_drawRelations($change_color)
{
$i = 0;
- reset($this->relations);
- while (list(, $relation) = each($this->relations)) {
+ foreach($this->relations AS $relation) {
$relation->PMA_RT_Relation_draw($change_color, $i);
$i++;
} // end while
@@ -1038,8 +1014,7 @@ class PMA_RT
*/
function PMA_RT_drawTables($show_info,$draw_color=0)
{
- reset($this->tables);
- while (list(, $table) = each($this->tables)) {
+ foreach($this->tables AS $table) {
$table->PMA_RT_Table_draw($show_info, $this->ff,$draw_color);
}
} // end of the "PMA_RT_drawTables()" method
@@ -1165,14 +1140,11 @@ class PMA_RT
/* snip */
- reset ($alltables);
- while (list(, $table) = each ($alltables)) {
+ foreach($alltables AS $table) {
if (!isset($this->tables[$table])) {
$this->tables[$table] = new PMA_RT_Table($table, $this->ff, $this->tablewidth);
}
- } // while
- reset($alltables);
- while (list(, $table) = each ($alltables)) {
+
if($this->same_wide){
$this->tables[$table]->width = $this->tablewidth;
}
@@ -1206,13 +1178,12 @@ class PMA_RT
// and finding its foreigns is OK (then we can support innodb)
$seen_a_relation = FALSE;
- reset($alltables);
- while (list(,$one_table) = each($alltables)) {
+ foreach($alltables AS $one_table) {
$exist_rel = PMA_getForeigners($db, $one_table, '', 'both');
if ($exist_rel) {
$seen_a_relation = TRUE;
- while (list($master_field,$rel) = each($exist_rel)) {
+ foreach($exist_rel AS $master_field => $rel) {
// put the foreign table on the schema only if selected
// by the user
// (do not use array_search() because we would have to
@@ -1254,8 +1225,7 @@ function PMA_RT_DOC($alltables ){
$pdf->Cell(0,9, $GLOBALS['strTableOfContents'],1,0,'C');
$pdf->Ln(15);
$i = 1;
- @reset($alltables);
- while(list(, $table) = each($alltables)) {
+ foreach($alltables AS $table) {
$pdf->PMA_links['doc'][$table]['-'] = $pdf->AddLink();
$pdf->SetX(10);
//$pdf->Ln(1);
@@ -1281,8 +1251,7 @@ function PMA_RT_DOC($alltables ){
$pdf->SetX(10);
$pdf->Cell(0,6,$i.' '. $GLOBALS['strRelationalSchema'],0,1,'L',0,$pdf->PMA_links['RT']['-']);
$z = 0;
- @reset($alltables);
- while(list(, $table) = each($alltables)) {
+ foreach($alltables AS $table) {
$z++;
$pdf->addpage($GLOBALS['orientation']);
$pdf->Bookmark($table);
@@ -1305,24 +1274,15 @@ function PMA_RT_DOC($alltables ){
/**
* Gets table informations
*/
- // The 'show table' statement works correct since 3.23.03
- if (PMA_MYSQL_INT_VERSION >= 32303) {
- $local_query = "SHOW TABLE STATUS LIKE '" . PMA_sqlAddslashes($table, TRUE) . "'";
- $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
- $showtable = PMA_mysql_fetch_array($result);
- $num_rows = (isset($showtable['Rows']) ? $showtable['Rows'] : 0);
- $show_comment = (isset($showtable['Comment']) ? $showtable['Comment'] : '');
- $create_time = (isset($showtable['Create_time']) ? PMA_localisedDate(strtotime($showtable['Create_time'])) : '');
- $update_time = (isset($showtable['Update_time']) ? PMA_localisedDate(strtotime($showtable['Update_time'])) : '');
- $check_time = (isset($showtable['Check_time']) ? PMA_localisedDate(strtotime($showtable['Check_time'])) : '');
- } else {
- $showtable = array();
- $num_rows = PMA_countRecords($db, $table, TRUE);
- $show_comment = '';
- $create_time = '';
- $update_time = '';
- $check_time = '';
- } // end display comments
+ $local_query = "SHOW TABLE STATUS LIKE '" . PMA_sqlAddslashes($table, TRUE) . "'";
+ $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
+ $showtable = PMA_mysql_fetch_array($result);
+ $num_rows = (isset($showtable['Rows']) ? $showtable['Rows'] : 0);
+ $show_comment = (isset($showtable['Comment']) ? $showtable['Comment'] : '');
+ $create_time = (isset($showtable['Create_time']) ? PMA_localisedDate(strtotime($showtable['Create_time'])) : '');
+ $update_time = (isset($showtable['Update_time']) ? PMA_localisedDate(strtotime($showtable['Update_time'])) : '');
+ $check_time = (isset($showtable['Check_time']) ? PMA_localisedDate(strtotime($showtable['Check_time'])) : '');
+
if ($result) {
mysql_free_result($result);
}
@@ -1460,8 +1420,8 @@ function PMA_RT_DOC($alltables ){
$type = $row['Type'];
// reformat mysql query output - staybyte - 9. June 2001
// loic1: set or enum types: slashes single quotes inside options
- if (eregi('^(set|enum)\((.+)\)$', $type, $tmp)) {
- $tmp[2] = substr(ereg_replace("([^,])''", "\\1\\'", ',' . $tmp[2]), 1);
+ if (preg_match('@^(set|enum)\((.+)\)$@i', $type, $tmp)) {
+ $tmp[2] = substr(preg_replace("@([^,])''@", "\\1\\'", ',' . $tmp[2]), 1);
$type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
$type_nowrap = '';
@@ -1470,16 +1430,16 @@ function PMA_RT_DOC($alltables ){
$zerofill = 0;
} else {
$type_nowrap = ' nowrap="nowrap"';
- $type = eregi_replace('BINARY', '', $type);
- $type = eregi_replace('ZEROFILL', '', $type);
- $type = eregi_replace('UNSIGNED', '', $type);
+ $type = preg_replace('@BINARY@i', '', $type);
+ $type = preg_replace('@ZEROFILL@i', '', $type);
+ $type = preg_replace('@UNSIGNED@i', '', $type);
if (empty($type)) {
$type = '&nbsp;';
}
- $binary = eregi('BINARY', $row['Type'], $test);
- $unsigned = eregi('UNSIGNED', $row['Type'], $test);
- $zerofill = eregi('ZEROFILL', $row['Type'], $test);
+ $binary = stristr($row['Type'], 'BINARY');
+ $unsigned = stristr($row['Type'], 'UNSIGNED');
+ $zerofill = stristr($row['Type'], 'ZEROFILL');
}
$strAttribute = ' ';
if ($binary) {
@@ -1562,4 +1522,4 @@ $paper = isset($paper) ? $paper : 'A4';
PMA_mysql_select_db($db);
$rt = new PMA_RT($pdf_page_number, $show_table_dimension, $show_color, $show_grid, $all_tab_same_wide, $orientation, $paper);
-?>
+?> \ No newline at end of file