Documentation TYPO3 par Ameos

pdf_schema.php

00001 <?php
00002 /* $Id: pdf_schema.php,v 2.14 2005/08/14 21:34:00 lem9 Exp $ */
00003 // vim: expandtab sw=4 ts=4 sts=4:
00004 
00013 require_once('./libraries/grab_globals.lib.php');
00014 require_once('./libraries/common.lib.php');
00015 
00016 
00020 require_once('./libraries/relation.lib.php');
00021 require_once('./libraries/transformations.lib.php');
00022 
00023 $cfgRelation = PMA_getRelationsParam();
00024 
00025 
00034 if (!$cfgRelation['pdfwork']) {
00035     echo '<font color="red">' . $strError . '</font><br />' . "\n";
00036     $url_to_goto = '<a href="' . $cfg['PmaAbsoluteUri'] . 'chk_rel.php?' . $url_query . '">';
00037     echo sprintf($strRelationNotWorking, $url_to_goto, '</a>') . "\n";
00038 }
00039 
00040 
00044 define('FPDF_FONTPATH','./libraries/fpdf/font/');
00045 if ($charset == 'utf-8') {
00046     define('PMA_PDF_FONT', 'FreeSans');
00047     require_once('./libraries/fpdf/ufpdf.php');
00048     class PMA_FPDF extends UFPDF {
00049     };
00050 } else {
00051     define('PMA_PDF_FONT', 'Arial');
00052     require_once('./libraries/fpdf/fpdf.php');
00053     class PMA_FPDF extends FPDF {
00054     };
00055 }
00056 
00057 
00065 class PMA_PDF extends PMA_FPDF
00066 {
00070     var $x_min;
00071     var $y_min;
00072     var $l_marg = 10;
00073     var $t_marg = 10;
00074     var $scale;
00075     var $title;
00076     var $PMA_links;
00077     var $Outlines=array();
00078     var $def_outlines;
00079     var $Alias ;
00080     var $widths;
00081 
00097     function PMA_PDF($orientation = 'L', $unit = 'mm', $format = 'A4')
00098     {
00099         $this->Alias = array() ;
00100         $this->FPDF($orientation, $unit, $format);
00101     } // end of the "PMA_PDF()" method
00102     function SetAlias($name, $value)
00103     {
00104         $this->Alias[$name] = $value ;
00105     }
00106     function _putpages()
00107     {
00108         if (count($this->Alias) > 0)
00109         {
00110             $nb=$this->page;
00111             foreach ($this->Alias AS $alias => $value) {
00112                 for ($n=1;$n<=$nb;$n++)
00113                 $this->pages[$n]=$this->_strreplace($alias,$value,$this->pages[$n]);
00114             }
00115         }
00116         parent::_putpages();
00117     }
00118 
00130     function PMA_PDF_setScale($scale = 1, $x_min = 0, $y_min = 0, $l_marg = -1, $t_marg = -1)
00131     {
00132         $this->scale      = $scale;
00133         $this->x_min      = $x_min;
00134         $this->y_min      = $y_min;
00135         if ($this->l_marg != -1) {
00136             $this->l_marg = $l_marg;
00137         }
00138         if ($this->t_marg != -1) {
00139             $this->t_marg = $t_marg;
00140         }
00141     } // end of the "PMA_PDF_setScale" function
00142 
00143 
00159     function PMA_PDF_cellScale($w, $h = 0, $txt = '', $border = 0, $ln = 0, $align = '', $fill = 0,$link ='')
00160     {
00161         $h = $h / $this->scale;
00162         $w = $w / $this->scale;
00163         $this->Cell($w, $h, $txt, $border, $ln, $align, $fill,$link);
00164     } // end of the "PMA_PDF_cellScale" function
00165 
00166 
00179     function PMA_PDF_lineScale($x1, $y1, $x2, $y2)
00180     {
00181         $x1 = ($x1 - $this->x_min) / $this->scale + $this->l_marg;
00182         $y1 = ($y1 - $this->y_min) / $this->scale + $this->t_marg;
00183         $x2 = ($x2 - $this->x_min) / $this->scale + $this->l_marg;
00184         $y2 = ($y2 - $this->y_min) / $this->scale + $this->t_marg;
00185         $this->Line($x1, $y1, $x2, $y2);
00186     } // end of the "PMA_PDF_lineScale" function
00187 
00188 
00199     function PMA_PDF_setXyScale($x, $y)
00200     {
00201         $x = ($x - $this->x_min) / $this->scale + $this->l_marg;
00202         $y = ($y - $this->y_min) / $this->scale + $this->t_marg;
00203         $this->SetXY($x, $y);
00204     } // end of the "PMA_PDF_setXyScale" function
00205 
00206 
00216     function PMA_PDF_setXScale($x)
00217     {
00218         $x = ($x - $this->x_min) / $this->scale + $this->l_marg;
00219         $this->SetX($x);
00220     } // end of the "PMA_PDF_setXScale" function
00221 
00222 
00232     function PMA_PDF_setFontSizeScale($size)
00233     {
00234         // Set font size in points
00235         $size = $size / $this->scale;
00236         $this->SetFontSize($size);
00237     } // end of the "PMA_PDF_setFontSizeScale" function
00238 
00239 
00249     function PMA_PDF_setLineWidthScale($width)
00250     {
00251         $width = $width / $this->scale;
00252         $this->SetLineWidth($width);
00253     } // end of the "PMA_PDF_setLineWidthScale" function
00254 
00255 
00273     function PMA_PDF_die($error_message = '')
00274     {
00275         global $cfg;
00276         global $server, $lang, $convcharset, $db;
00277         global $charset, $text_dir, $strRunning, $strDatabase;
00278 
00279         require_once('./header.inc.php');
00280 
00281         echo '<p><b>PDF - '. $GLOBALS['strError'] . '</b></p>' . "\n";
00282         if (!empty($error_message)) {
00283             $error_message = htmlspecialchars($error_message);
00284         }
00285         echo '<p>' . "\n";
00286         echo '    ' . $error_message . "\n";
00287         echo '</p>' . "\n";
00288 
00289         echo '<a href="db_details_structure.php?' . PMA_generate_common_url($db)
00290              . '">' . $GLOBALS['strBack'] . '</a>';
00291         echo "\n";
00292 
00293         require_once('./footer.inc.php');
00294     } // end of the "PMA_PDF_die()" function 
00295 
00296 
00307     function Error($error_message = '')
00308     {
00309         $this->PMA_PDF_die($error_message);
00310     } // end of the "Error()" method
00311 
00312     function Header(){
00313         //$datefmt
00314         // We only show this if we find something in the new pdf_pages table
00315         //
00316         // This function must be named "Header" to work with the FPDF library
00317 
00318     global $cfgRelation,$db,$pdf_page_number,$with_doc;
00319     if ($with_doc){
00320         $test_query = 'SELECT * FROM ' . PMA_backquote($cfgRelation['pdf_pages'])
00321                     . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
00322                     . ' AND page_nr = \'' . $pdf_page_number . '\'';
00323         $test_rs    = PMA_query_as_cu($test_query);
00324         $pages = @PMA_DBI_fetch_assoc($test_rs);
00325         $this->SetFont('', 'B', 14);
00326         $this->Cell(0,6, ucfirst($pages['page_descr']),'B',1,'C');
00327         $this->SetFont('', '');
00328         $this->Ln();
00329     }
00330     }
00331     function Footer(){
00332         // This function must be named "Footer" to work with the FPDF library
00333         global $with_doc;
00334         if ($with_doc){
00335             $this->SetY(-15);
00336             $this->SetFont('', '',14);
00337             $this->Cell(0,6, $GLOBALS['strPageNumber'] .' '.$this->PageNo() .'/{nb}','T',0,'C');
00338             $this->Cell(0,6, PMA_localisedDate(),0,1,'R');
00339             $this->SetY(20);
00340         }
00341     }
00342     function Bookmark($txt,$level=0,$y=0)
00343 {
00344    //Add a bookmark
00345    $this->Outlines[0][]=$level;
00346    $this->Outlines[1][]=$txt;
00347    $this->Outlines[2][]=$this->page;
00348    if ($y==-1)
00349       $y=$this->GetY();
00350    $this->Outlines[3][]=round($this->hPt-$y*$this->k,2);
00351 }
00352 
00353 function _putbookmarks()
00354 {
00355    if (count($this->Outlines)>0)
00356    {
00357       //Save object number
00358       $memo_n = $this->n;
00359       //Take the number of sub elements for an outline
00360       $nb_outlines=sizeof($this->Outlines[0]);
00361       $first_level=array();
00362       $parent=array();
00363       $parent[0]=1;
00364       for ($i=0; $i<$nb_outlines; $i++)
00365       {
00366          $level=$this->Outlines[0][$i];
00367          $kids=0;
00368          $last=-1;
00369          $prev=-1;
00370          $next=-1;
00371          if ($i>0 )
00372          {
00373             $cursor=$i-1;
00374             //Take the previous outline in the same level
00375             while ($this->Outlines[0][$cursor] > $level && $cursor > 0)
00376                $cursor--;
00377             if ($this->Outlines[0][$cursor] == $level)
00378                $prev=$cursor;
00379          }
00380          if ($i<$nb_outlines-1)
00381          {
00382             $cursor=$i+1;
00383             while (isset($this->Outlines[0][$cursor]) && $this->Outlines[0][$cursor] > $level)
00384             {
00385                //Take the immediate kid in level + 1
00386                if ($this->Outlines[0][$cursor] == $level+1)
00387                {
00388                   $kids++;
00389                   $last=$cursor;
00390                }
00391                $cursor++;
00392             }
00393             $cursor=$i+1;
00394             //Take the next outline in the same level
00395             while ($this->Outlines[0][$cursor] > $level && ($cursor+1 < sizeof($this->Outlines[0])))
00396                $cursor++;
00397             if ($this->Outlines[0][$cursor] == $level)
00398                $next=$cursor;
00399          }
00400          $this->_newobj();
00401          $parent[$level+1]=$this->n;
00402          if ($level == 0)
00403             $first_level[]=$this->n;
00404          $this->_out('<<');
00405          $this->_out('/Title ('.$this->Outlines[1][$i].')');
00406          $this->_out('/Parent '.$parent[$level].' 0 R');
00407          if ($prev != -1)
00408             $this->_out('/Prev '.($memo_n+$prev+1).' 0 R');
00409          if ($next != -1)
00410             $this->_out('/Next '.($this->n+$next-$i).' 0 R');
00411          $this->_out('/Dest ['.(1+(2*$this->Outlines[2][$i])).' 0 R /XYZ null '.$this->Outlines[3][$i].' null]');
00412          if ($kids > 0)
00413          {
00414             $this->_out('/First '.($this->n+1).' 0 R');
00415             $this->_out('/Last '.($this->n+$last-$i).' 0 R');
00416             $this->_out('/Count -'.$kids);
00417          }
00418          $this->_out('>>');
00419          $this->_out('endobj');
00420       }
00421       //First page of outlines
00422       $this->_newobj();
00423       $this->def_outlines = $this->n;
00424       $this->_out('<<');
00425       $this->_out('/Type');
00426       $this->_out('/Outlines');
00427       $this->_out('/First '.$first_level[0].' 0 R');
00428       $this->_out('/Last '.$first_level[sizeof($first_level)-1].' 0 R');
00429       $this->_out('/Count '.sizeof($first_level));
00430       $this->_out('>>');
00431       $this->_out('endobj');
00432    }
00433 }
00434 
00435 function _putresources()
00436 {
00437    parent::_putresources();
00438    $this->_putbookmarks();
00439 }
00440 
00441 function _putcatalog()
00442 {
00443    parent::_putcatalog();
00444    if (count($this->Outlines)>0)
00445    {
00446       $this->_out('/Outlines '.$this->def_outlines.' 0 R');
00447       $this->_out('/PageMode /UseOutlines');
00448    }
00449 }
00450 function SetWidths($w)
00451 {
00452    // column widths
00453    $this->widths=$w;
00454 }
00455 
00456 function Row($data,$links)
00457 {
00458    // line height
00459    $nb=0;
00460    $data_cnt = count($data);
00461    for ($i=0;$i<$data_cnt;$i++)
00462       $nb=max($nb,$this->NbLines($this->widths[$i],$data[$i]));
00463    $il = $this->FontSize;
00464    $h=($il+1)*$nb;
00465    // page break if necessary
00466    $this->CheckPageBreak($h);
00467    // draw the cells
00468    $data_cnt = count($data);
00469    for ($i=0;$i<$data_cnt;$i++)
00470    {
00471       $w=$this->widths[$i];
00472       // save current position
00473       $x=$this->GetX();
00474       $y=$this->GetY();
00475       // draw the border
00476       $this->Rect($x,$y,$w,$h);
00477       if (isset($links[$i]))
00478       $this->Link($x,$y,$w,$h,$links[$i]);
00479       // print text
00480       $this->MultiCell($w,$il+1,$data[$i],0,'L');
00481       // go to right side
00482       $this->SetXY($x+$w,$y);
00483    }
00484    // go to line
00485    $this->Ln($h);
00486 }
00487 
00488 function CheckPageBreak($h)
00489 {
00490    // if height h overflows, manual page break
00491    if ($this->GetY()+$h>$this->PageBreakTrigger)
00492       $this->AddPage($this->CurOrientation);
00493 }
00494 
00495 function NbLines($w,$txt)
00496 {
00497    // compute number of lines used by a multicell of width w
00498    $cw=&$this->CurrentFont['cw'];
00499    if ($w==0)
00500       $w=$this->w-$this->rMargin-$this->x;
00501    $wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
00502    $s=str_replace("\r",'',$txt);
00503    $nb=strlen($s);
00504    if ($nb>0 and $s[$nb-1]=="\n")
00505       $nb--;
00506    $sep=-1;
00507    $i=0;
00508    $j=0;
00509    $l=0;
00510    $nl=1;
00511    while ($i<$nb)
00512    {
00513       $c=$s[$i];
00514       if ($c=="\n")
00515       {
00516          $i++;
00517          $sep=-1;
00518          $j=$i;
00519          $l=0;
00520          $nl++;
00521          continue;
00522       }
00523       if ($c==' ')
00524          $sep=$i;
00525       $l+=isset($cw[ord($c)])?$cw[ord($c)]:0 ;
00526       if ($l>$wmax)
00527       {
00528          if ($sep==-1)
00529          {
00530             if ($i==$j)
00531                $i++;
00532          }
00533          else
00534             $i=$sep+1;
00535          $sep=-1;
00536          $j=$i;
00537          $l=0;
00538          $nl++;
00539       }
00540       else
00541          $i++;
00542    }
00543    return $nl;
00544 }
00545 
00546 } // end of the "PMA_PDF" class
00547 
00548 
00556 class PMA_RT_Table
00557 {
00561     var $nb_fiels;
00562     var $table_name;
00563     var $width = 0;
00564     var $height;
00565     var $fields      = array();
00566     var $height_cell = 6;
00567     var $x, $y;
00568     var $primary     = array();
00569 
00570 
00582     function PMA_RT_Table_setWidth($ff)
00583     {
00584         //  this looks buggy to me... does it really work if
00585         //  there are fields that require wider cells than the name of the table?
00586         global $pdf;
00587 
00588         foreach ($this->fields AS $field) {
00589             $this->width = max($this->width, $pdf->GetStringWidth($field));
00590         }
00591         $this->width += $pdf->GetStringWidth('  ');
00592         $pdf->SetFont($ff, 'B');
00593         $this->width = max($this->width, $pdf->GetStringWidth('  ' . $this->table_name));
00594         $pdf->SetFont($ff, '');
00595     } // end of the "PMA_RT_Table_setWidth()" method
00596 
00597 
00603     function PMA_RT_Table_setHeight()
00604     {
00605         $this->height = (count($this->fields) + 1) * $this->height_cell;
00606     } // end of the "PMA_RT_Table_setHeight()" method
00607 
00608 
00623     function PMA_RT_Table_draw($show_info, $ff, $setcolor=0)
00624     {
00625         global $pdf, $with_doc;
00626 
00627         $pdf->PMA_PDF_setXyScale($this->x, $this->y);
00628         $pdf->SetFont($ff, 'B');
00629         if ($setcolor) {
00630             $pdf->SetTextColor(200);
00631             $pdf->SetFillColor(0, 0, 128);
00632         }
00633         if ($with_doc) $pdf->SetLink($pdf->PMA_links['RT'][$this->table_name]['-'],-1);
00634         else $pdf->PMA_links['doc'][$this->table_name]['-'] = '';
00635         if ($show_info){
00636             $pdf->PMA_PDF_cellScale($this->width, $this->height_cell, sprintf('%.0f', $this->width) . 'x' . sprintf('%.0f', $this->height) . ' ' . $this->table_name, 1, 1, 'C', $setcolor, $pdf->PMA_links['doc'][$this->table_name]['-']);
00637         } else {
00638             $pdf->PMA_PDF_cellScale($this->width, $this->height_cell, $this->table_name, 1, 1, 'C', $setcolor, $pdf->PMA_links['doc'][$this->table_name]['-']);
00639         }
00640         $pdf->PMA_PDF_setXScale($this->x);
00641         $pdf->SetFont($ff, '');
00642         $pdf->SetTextColor(0);
00643         $pdf->SetFillColor(255);
00644 
00645         foreach ($this->fields AS $field) {
00646             // loic1 : PHP3 fix
00647             // if (in_array($field, $this->primary)) {
00648             if ($setcolor) {
00649                 if (PMA_isInto($field, $this->primary) != -1) {
00650                     $pdf->SetFillColor(215, 121, 123);
00651                 }
00652                 if ($field == $this->displayfield) {
00653                     $pdf->SetFillColor(142, 159, 224);
00654                 }
00655             }
00656             if ($with_doc) $pdf->SetLink($pdf->PMA_links['RT'][$this->table_name][$field],-1);
00657             else $pdf->PMA_links['doc'][$this->table_name][$field] = '';
00658 
00659 
00660             $pdf->PMA_PDF_cellScale($this->width, $this->height_cell, ' ' . $field, 1, 1, 'L', $setcolor,$pdf->PMA_links['doc'][$this->table_name][$field]);
00661             $pdf->PMA_PDF_setXScale($this->x);
00662             $pdf->SetFillColor(255);
00663         } // end while
00664 
00665         /*if ($pdf->PageNo() > 1) {
00666             $pdf->PMA_PDF_die($GLOBALS['strScaleFactorSmall']);
00667         } */
00668     } // end of the "PMA_RT_Table_draw()" method
00669 
00670 
00689     function PMA_RT_Table($table_name, $ff, &$same_wide_width)
00690     {
00691         global $pdf, $pdf_page_number, $cfgRelation, $db;
00692 
00693         $this->table_name = $table_name;
00694         $sql              = 'DESCRIBE ' .  PMA_backquote($table_name);
00695         $result           = PMA_DBI_try_query($sql, NULL, PMA_DBI_QUERY_STORE);
00696         if (!$result || !PMA_DBI_num_rows($result)) {
00697             $pdf->PMA_PDF_die(sprintf($GLOBALS['strPdfInvalidTblName'], $table_name));
00698         }
00699         // load fields
00700         while ($row = PMA_DBI_fetch_row($result)) {
00701             $this->fields[] = $row[0];
00702         }
00703 
00704         //height and width
00705         $this->PMA_RT_Table_setWidth($ff);
00706         $this->PMA_RT_Table_setHeight();
00707         if ($same_wide_width < $this->width) {
00708             $same_wide_width = $this->width;
00709         }
00710 
00711         //x and y
00712         $sql    = 'SELECT x, y FROM '
00713                 . PMA_backquote($cfgRelation['table_coords'])
00714                 .   ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
00715                 .   ' AND   table_name = \'' . PMA_sqlAddslashes($table_name) . '\''
00716                 .   ' AND   pdf_page_number = ' . $pdf_page_number;
00717         $result = PMA_query_as_cu($sql, FALSE, PMA_DBI_QUERY_STORE);
00718 
00719         if (!$result || !PMA_DBI_num_rows($result)) {
00720             $pdf->PMA_PDF_die(sprintf($GLOBALS['strConfigureTableCoord'], $table_name));
00721         }
00722         list($this->x, $this->y) = PMA_DBI_fetch_row($result);
00723         $this->x = (double) $this->x;
00724         $this->y = (double) $this->y;
00725         // displayfield
00726         $this->displayfield = PMA_getDisplayField($db, $table_name);
00727 
00728         // index
00729         $result = PMA_DBI_query('SHOW INDEX FROM ' . PMA_backquote($table_name) . ';', NULL, PMA_DBI_QUERY_STORE);
00730         if (PMA_DBI_num_rows($result) > 0) {
00731             while ($row = PMA_DBI_fetch_assoc($result)) {
00732                 if ($row['Key_name'] == 'PRIMARY') {
00733                     $this->primary[] = $row['Column_name'];
00734                 }
00735             }
00736         } // end if
00737     } // end of the "PMA_RT_Table()" method
00738 } // end class "PMA_RT_Table"
00739 
00740 
00741 
00749 class PMA_RT_Relation
00750 {
00754     var $x_src, $y_src;
00755     var $src_dir ;
00756     var $dest_dir;
00757     var $x_dest, $y_dest;
00758     var $w_tick = 5;
00759 
00760 
00771     function PMA_RT_Relation_getXy($table, $column)
00772     {
00773         $pos = array_search($column, $table->fields);
00774         // x_left, x_right, y
00775         return array($table->x, $table->x + + $table->width, $table->y + ($pos + 1.5) * $table->height_cell);
00776     } // end of the "PMA_RT_Relation_getXy()" method
00777 
00778 
00791     function PMA_RT_Relation_draw($change_color, $i)
00792     {
00793         global $pdf;
00794 
00795         if ($change_color){
00796             $d    = $i % 6;
00797             $j    = ($i - $d) / 6;
00798             $j    = $j % 4;
00799             $j++;
00800             $case = array(
00801                         array(1, 0, 0),
00802                         array(0, 1, 0),
00803                         array(0, 0, 1),
00804                         array(1, 1, 0),
00805                         array(1, 0, 1),
00806                         array(0, 1, 1)
00807                     );
00808             list ($a, $b, $c) = $case[$d];
00809             $e    = (1 - ($j - 1) / 6);
00810             $pdf->SetDrawColor($a * 255 * $e, $b * 255 * $e, $c * 255 * $e);       }
00811         else {
00812             $pdf->SetDrawColor(0);
00813         } // end if... else...
00814 
00815         $pdf->PMA_PDF_setLineWidthScale(0.2);
00816         $pdf->PMA_PDF_lineScale($this->x_src, $this->y_src, $this->x_src + $this->src_dir * $this->w_tick, $this->y_src);
00817         $pdf->PMA_PDF_lineScale($this->x_dest + $this->dest_dir * $this->w_tick, $this->y_dest, $this->x_dest, $this->y_dest);
00818         $pdf->PMA_PDF_setLineWidthScale(0.1);
00819         $pdf->PMA_PDF_lineScale($this->x_src + $this->src_dir * $this->w_tick, $this->y_src, $this->x_dest + $this->dest_dir * $this->w_tick, $this->y_dest);
00820 
00821         //arrow
00822         $root2 = 2 * sqrt(2);
00823         $pdf->PMA_PDF_lineScale($this->x_src + $this->src_dir * $this->w_tick * 0.75, $this->y_src, $this->x_src + $this->src_dir * (0.75 - 1 / $root2) * $this->w_tick, $this->y_src + $this->w_tick / $root2);
00824         $pdf->PMA_PDF_lineScale($this->x_src + $this->src_dir * $this->w_tick * 0.75, $this->y_src, $this->x_src + $this->src_dir * (0.75 - 1 / $root2) * $this->w_tick, $this->y_src - $this->w_tick / $root2);
00825 
00826         $pdf->PMA_PDF_lineScale($this->x_dest + $this->dest_dir * $this->w_tick / 2, $this->y_dest, $this->x_dest + $this->dest_dir * (0.5 + 1 / $root2) * $this->w_tick, $this->y_dest + $this->w_tick / $root2);
00827         $pdf->PMA_PDF_lineScale($this->x_dest + $this->dest_dir * $this->w_tick / 2, $this->y_dest, $this->x_dest + $this->dest_dir * (0.5 + 1 / $root2) * $this->w_tick, $this->y_dest - $this->w_tick / $root2);
00828         $pdf->SetDrawColor(0);
00829     } // end of the "PMA_RT_Relation_draw()" method
00830 
00831 
00845     function PMA_RT_Relation($master_table, $master_field,  $foreign_table, $foreign_field)
00846     {
00847         $src_pos    = $this->PMA_RT_Relation_getXy($master_table , $master_field);
00848         $dest_pos   = $this->PMA_RT_Relation_getXy($foreign_table, $foreign_field);
00849         $src_left   = $src_pos[0] - $this->w_tick;
00850         $src_right  = $src_pos[1] + $this->w_tick;
00851         $dest_left  = $dest_pos[0] - $this->w_tick;
00852         $dest_right = $dest_pos[1] + $this->w_tick;
00853 
00854         $d1 = abs($src_left  - $dest_left);
00855         $d2 = abs($src_right - $dest_left);
00856         $d3 = abs($src_left  - $dest_right);
00857         $d4 = abs($src_right - $dest_right);
00858         $d  = min($d1, $d2, $d3, $d4);
00859 
00860         if ($d == $d1) {
00861             $this->x_src    = $src_pos[0];
00862             $this->src_dir  = -1;
00863             $this->x_dest   = $dest_pos[0];
00864             $this->dest_dir = -1;
00865         } else if ($d == $d2) {
00866             $this->x_src    = $src_pos[1];
00867             $this->src_dir  = 1;
00868             $this->x_dest   = $dest_pos[0];
00869             $this->dest_dir = -1;
00870         } else if ($d == $d3) {
00871             $this->x_src    = $src_pos[0];
00872             $this->src_dir  = -1;
00873             $this->x_dest   = $dest_pos[1];
00874             $this->dest_dir = 1;
00875         } else {
00876             $this->x_src    =  $src_pos[1];
00877             $this->src_dir  = 1;
00878             $this->x_dest   = $dest_pos[1];
00879             $this->dest_dir = 1;
00880         }
00881         $this->y_src        = $src_pos[2];
00882         $this->y_dest       = $dest_pos[2];
00883     } // end of the "PMA_RT_Relation()" method
00884 } // end of the "PMA_RT_Relation" class
00885 
00886 
00887 
00895 class PMA_RT
00896 {
00900     var $tables    = array();
00901     var $relations = array();
00902     var $ff        = PMA_PDF_FONT;
00903     var $x_max     = 0;
00904     var $y_max     = 0;
00905     var $scale;
00906     var $x_min     = 100000;
00907     var $y_min     = 100000;
00908     var $t_marg    = 10;
00909     var $b_marg    = 10;
00910     var $l_marg    = 10;
00911     var $r_marg    = 10;
00912     var $tablewidth;
00913     var $same_wide = 0;
00914 
00922     function PMA_RT_setMinMax($table)
00923     {
00924         $this->x_max = max($this->x_max, $table->x + $table->width);
00925         $this->y_max = max($this->y_max, $table->y + $table->height);
00926         $this->x_min = min($this->x_min, $table->x);
00927         $this->y_min = min($this->y_min, $table->y);
00928     } // end of the "PMA_RT_setMinMax()" method
00929 
00930 
00943     function PMA_RT_addRelation($master_table , $master_field,  $foreign_table, $foreign_field)
00944     {
00945         if (!isset($this->tables[$master_table])) {
00946             $this->tables[$master_table] = new PMA_RT_Table($master_table, $this->ff, $this->tablewidth);
00947             $this->PMA_RT_setMinMax($this->tables[$master_table]);
00948         }
00949         if (!isset($this->tables[$foreign_table])) {
00950             $this->tables[$foreign_table] = new PMA_RT_Table($foreign_table, $this->ff, $this->tablewidth);
00951             $this->PMA_RT_setMinMax($this->tables[$foreign_table]);
00952         }
00953         $this->relations[] = new PMA_RT_Relation($this->tables[$master_table], $master_field, $this->tables[$foreign_table], $foreign_field);
00954     } // end of the "PMA_RT_addRelation()" method
00955 
00956 
00966     function PMA_RT_strokeGrid()
00967     {
00968         global $pdf;
00969 
00970         $pdf->SetMargins(0, 0);
00971         $pdf->SetDrawColor(200, 200, 200);
00972 
00973         // Draws horizontal lines
00974         for ($l = 0; $l < 21; $l++) {
00975             $pdf->line(0, $l * 10, $pdf->fh, $l * 10);
00976             // Avoid duplicates
00977             if ($l > 0) {
00978                 $pdf->SetXY(0, $l * 10);
00979                 $label = (string) sprintf('%.0f', ($l * 10 - $this->t_marg) * $this->scale + $this->y_min);
00980                 $pdf->Cell(5, 5, ' ' . $label);
00981             } // end if
00982         } // end for
00983 
00984         // Draws vertical lines
00985         for ($j = 0; $j < 30 ;$j++) {
00986             $pdf->line($j * 10, 0, $j * 10, $pdf->fw);
00987             $pdf->SetXY($j * 10, 0);
00988             $label = (string) sprintf('%.0f', ($j * 10 - $this->l_marg) * $this->scale + $this->x_min);
00989             $pdf->Cell(5, 7, $label);
00990         } // end for
00991     } // end of the "PMA_RT_strokeGrid()" method
00992 
00993 
01003     function PMA_RT_drawRelations($change_color)
01004     {
01005         $i = 0;
01006         foreach ($this->relations AS $relation) {
01007             $relation->PMA_RT_Relation_draw($change_color, $i);
01008             $i++;
01009         } // end while
01010     } // end of the "PMA_RT_drawRelations()" method
01011 
01012 
01022     function PMA_RT_drawTables($show_info,$draw_color=0)
01023     {
01024         foreach ($this->tables AS $table) {
01025             $table->PMA_RT_Table_draw($show_info, $this->ff,$draw_color);
01026         }
01027     } // end of the "PMA_RT_drawTables()" method
01028 
01029 
01042     function PMA_RT_showRt()
01043     {
01044         global $pdf, $db, $pdf_page_number, $cfgRelation;
01045 
01046         $pdf->SetFontSize(14);
01047         $pdf->SetLineWidth(0.2);
01048         $pdf->SetDisplayMode('fullpage');
01049         //  Get the name of this pdfpage to use as filename (Mike Beck)
01050         $_name_sql  = 'SELECT page_descr FROM ' . PMA_backquote($cfgRelation['pdf_pages'])
01051                   .   ' WHERE page_nr = ' . $pdf_page_number;
01052         $_name_rs   = PMA_query_as_cu($_name_sql);
01053         if ($_name_rs) {
01054             $_name_row = PMA_DBI_fetch_row($_name_rs);
01055             $filename = $_name_row[0] . '.pdf';
01056         }
01057         // i don't know if there is a chance for this to happen, but rather be on the safe side:
01058         if (empty($filename)) {
01059             $filename = $pdf_page_number . '.pdf';
01060         }
01061         //$pdf->Output($db . '_' . $filename, TRUE);
01062         $pdf->Output($db . '_' . $filename, 'I'); // destination: Inline
01063     } // end of the "PMA_RT_showRt()" method
01064 
01065 
01087     function PMA_RT( $which_rel, $show_info = 0, $change_color = 0 , $show_grid = 0, $all_tab_same_wide = 0, $orientation = 'L', $paper = 'A4')
01088     {
01089         global $pdf, $db, $cfgRelation, $with_doc;
01090 
01091         // Font face depends on the current language
01092         $this->ff        = str_replace('"', '', substr($GLOBALS['right_font_family'], 0, strpos($GLOBALS['right_font_family'], ',')));
01093 
01094         $this->same_wide = $all_tab_same_wide;
01095 
01096         // Initializes a new document
01097         $pdf          = new PMA_PDF('L', 'mm', $paper);
01098         $pdf->title   = sprintf($GLOBALS['strPdfDbSchema'], $GLOBALS['db'], $which_rel);
01099         $pdf->cMargin = 0;
01100         $pdf->Open();
01101         $pdf->SetTitle($pdf->title);
01102         $pdf->SetAuthor('phpMyAdmin ' . PMA_VERSION);
01103         $pdf->AliasNbPages();
01104 
01105         if ($GLOBALS['charset'] == 'utf-8') {
01106             // Force FreeSans for utf-8
01107             $this->ff = 'FreeSans';
01108             $pdf->AddFont('FreeSans','','FreeSans.php');
01109             $pdf->AddFont('FreeSans','B','FreeSansBold.php');
01110             $pdf->SetFont('FreeSans', '', 14);
01111         } else { 
01112             // fonts added to phpMyAdmin and considered non-standard by fpdf
01113             // (Note: those tahoma fonts are iso-8859-2 based)
01114             if ($this->ff == 'tahoma') {
01115                 $pdf->AddFont('tahoma','','tahoma.php');
01116                 $pdf->AddFont('tahoma','B','tahomab.php');
01117             }
01118         }
01119         $pdf->SetFont($this->ff, '', 14);
01120         $pdf->SetAutoPageBreak('auto');
01121 
01122         // Gets tables on this page
01123         $tab_sql  = 'SELECT table_name FROM ' . PMA_backquote($cfgRelation['table_coords'])
01124                   .   ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
01125                   .   ' AND pdf_page_number = ' . $which_rel;
01126         $tab_rs   = PMA_query_as_cu($tab_sql, NULL, PMA_DBI_QUERY_STORE);
01127         if (!$tab_rs || !PMA_DBI_num_rows($tab_rs) > 0) {
01128             $pdf->PMA_PDF_die($GLOBALS['strPdfNoTables']);
01129 //            die('No tables');
01130         }
01131         while ($curr_table = @PMA_DBI_fetch_assoc($tab_rs)) {
01132             $alltables[] = PMA_sqlAddslashes($curr_table['table_name']);
01133             //$intable     = '\'' . implode('\', \'', $alltables) . '\'';
01134         }
01135 
01136         //              make doc                    //
01137         if ($with_doc) {
01138             $pdf->SetAutoPageBreak('auto',15);
01139             $pdf->cMargin = 1;
01140             PMA_RT_DOC($alltables);
01141             $pdf->SetAutoPageBreak('auto');
01142             $pdf->cMargin = 0;
01143         }
01144 
01145         $pdf->Addpage();
01146 
01147 
01148         if ($with_doc) {
01149             $pdf->SetLink($pdf->PMA_links['RT']['-'],-1);
01150             $pdf->Bookmark($GLOBALS['strRelationalSchema']);
01151             $pdf->SetAlias('{00}', $pdf->PageNo()) ;
01152             $this->t_marg = 18;
01153             $this->b_marg = 18;
01154         }
01155 
01156                                 /* snip */
01157 
01158         foreach ($alltables AS $table) {
01159             if (!isset($this->tables[$table])) {
01160                 $this->tables[$table] = new PMA_RT_Table($table, $this->ff, $this->tablewidth);
01161             }
01162 
01163             if ($this->same_wide){
01164                 $this->tables[$table]->width = $this->tablewidth;
01165             }
01166             $this->PMA_RT_setMinMax($this->tables[$table]);
01167         }
01168         // Defines the scale factor
01169         $this->scale = ceil(max(($this->x_max - $this->x_min) / ($pdf->fh - $this->r_marg - $this->l_marg), ($this->y_max - $this->y_min) / ($pdf->fw - $this->t_marg - $this->b_marg)) * 100) / 100;
01170         $pdf->PMA_PDF_setScale($this->scale, $this->x_min, $this->y_min, $this->l_marg, $this->t_marg);
01171 
01172 
01173         // Builds and save the PDF document
01174         $pdf->PMA_PDF_setLineWidthScale(0.1);
01175 
01176         if ($show_grid) {
01177             $pdf->SetFontSize(10);
01178             $this->PMA_RT_strokeGrid();
01179         }
01180         $pdf->PMA_PDF_setFontSizeScale(14);
01181 
01182 
01183 //        $sql    = 'SELECT * FROM ' . PMA_backquote($cfgRelation['relation'])
01184 //                .   ' WHERE master_db   = \'' . PMA_sqlAddslashes($db) . '\' '
01185 //                .   ' AND foreign_db    = \'' . PMA_sqlAddslashes($db) . '\' '
01186 //                .   ' AND master_table  IN (' . $intable . ')'
01187 //                .   ' AND foreign_table IN (' . $intable . ')';
01188 //        $result =  PMA_query_as_cu($sql);
01189 //
01190 // lem9:
01191 // previous logic was checking master tables and foreign tables
01192 // but I think that looping on every table of the pdf page as a master
01193 // and finding its foreigns is OK (then we can support innodb)
01194 
01195         $seen_a_relation = FALSE;
01196         foreach ($alltables AS $one_table) {
01197 
01198             $exist_rel = PMA_getForeigners($db, $one_table, '', 'both');
01199             if ($exist_rel) {
01200                 $seen_a_relation = TRUE;
01201                 foreach ($exist_rel AS $master_field => $rel) {
01202                     // put the foreign table on the schema only if selected
01203                     // by the user
01204                     // (do not use array_search() because we would have to
01205                     // to do a === FALSE and this is not PHP3 compatible)
01206 
01207                     if (PMA_isInto($rel['foreign_table'], $alltables)> -1) {
01208                         $this->PMA_RT_addRelation($one_table , $master_field, $rel['foreign_table'], $rel['foreign_field']);
01209                     }
01210 
01211                 } // end while
01212             } // end if
01213         } // end while
01214 
01215         // loic1: also show tables without relations
01216 //        $norelations     = TRUE;
01217 //        if ($result && PMA_DBI_num_rows($result) > 0) {
01218 //            $norelations = FALSE;
01219 //            while ($row = PMA_DBI_fetch_assoc($result)) {
01220 //                $this->PMA_RT_addRelation($row['master_table'] , $row['master_field'], $row['foreign_table'], $row['foreign_field']);
01221 //            }
01222 //        }
01223 
01224 
01225 //        if ($norelations == FALSE) {
01226         if ($seen_a_relation) {
01227             $this->PMA_RT_drawRelations($change_color);
01228         }
01229 
01230         $this->PMA_RT_drawTables($show_info,$change_color);
01231 
01232         $this->PMA_RT_showRt();
01233     } // end of the "PMA_RT()" method
01234 } // end of the "PMA_RT" class
01235 
01236 function PMA_RT_DOC($alltables ){
01237     global  $db, $pdf, $orientation, $paper;
01238     //TOC
01239     $pdf->addpage($GLOBALS['orientation']);
01240     $pdf->Cell(0,9, $GLOBALS['strTableOfContents'],1,0,'C');
01241     $pdf->Ln(15);
01242     $i = 1;
01243     foreach ($alltables AS $table) {
01244         $pdf->PMA_links['doc'][$table]['-'] = $pdf->AddLink();
01245         $pdf->SetX(10);
01246         //$pdf->Ln(1);
01247         $pdf->Cell(0,6,$GLOBALS['strPageNumber'] . ' {'.sprintf("%02d", $i).'}',0,0,'R',0,$pdf->PMA_links['doc'][$table]['-']);
01248         $pdf->SetX(10);
01249         $pdf->Cell(0,6,$i.' '. $table,0,1,'L',0,$pdf->PMA_links['doc'][$table]['-']);
01250 
01251         //$pdf->Ln(1);
01252         $result     = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';');
01253         while ($row = PMA_DBI_fetch_assoc($result)) {
01254             $pdf->SetX(20);
01255             $field_name = $row['Field'];
01256             $pdf->PMA_links['doc'][$table][$field_name] =$pdf->AddLink();
01257             //$pdf->Cell(0,6,$field_name,0,1,'L',0,$pdf->PMA_links['doc'][$table][$field_name]);
01258         }
01259         $lasttable = $table;
01260         $i++;
01261     }
01262     $pdf->PMA_links['RT']['-'] =$pdf->AddLink();
01263     $pdf->SetX(10);
01264     $pdf->Cell(0,6,$GLOBALS['strPageNumber'] . ' {00}',0,0,'R',0,$pdf->PMA_links['doc'][$lasttable]['-']);
01265     $pdf->SetX(10);
01266     $pdf->Cell(0,6,$i.' '. $GLOBALS['strRelationalSchema'],0,1,'L',0,$pdf->PMA_links['RT']['-']);
01267     $z = 0;
01268     foreach ($alltables AS $table) {
01269         $z++;
01270         $pdf->addpage($GLOBALS['orientation']);
01271         $pdf->Bookmark($table);
01272         $pdf->SetAlias('{'.sprintf("%02d", $z).'}', $pdf->PageNo()) ;
01273         $pdf->PMA_links['RT'][$table]['-'] =$pdf->AddLink();
01274         $pdf->SetLink($pdf->PMA_links['doc'][$table]['-'],-1);
01275         $pdf->SetFont('', 'B',18);
01276         $pdf->Cell(0,8, $z .' '.$table,1,1,'C',0,$pdf->PMA_links['RT'][$table]['-']);
01277         $pdf->SetFont('', '',8);
01278         $pdf->ln();
01279 
01280         $cfgRelation  = PMA_getRelationsParam();
01281         if ($cfgRelation['commwork'] || PMA_MYSQL_INT_VERSION >= 40100) {
01282             $comments = PMA_getComments($db, $table);
01283         }
01284         if ($cfgRelation['mimework']) {
01285             $mime_map = PMA_getMIME($db, $table, true);
01286         }
01287 
01288 
01292         $result       = PMA_DBI_query('SHOW TABLE STATUS LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\';', NULL, PMA_DBI_QUERY_STORE);
01293         $showtable    = PMA_DBI_fetch_assoc($result);
01294         $num_rows     = (isset($showtable['Rows']) ? $showtable['Rows'] : 0);
01295         $show_comment = (isset($showtable['Comment']) ? $showtable['Comment'] : '');
01296         $create_time  = (isset($showtable['Create_time']) ? PMA_localisedDate(strtotime($showtable['Create_time'])) : '');
01297         $update_time  = (isset($showtable['Update_time']) ? PMA_localisedDate(strtotime($showtable['Update_time'])) : '');
01298         $check_time   = (isset($showtable['Check_time']) ? PMA_localisedDate(strtotime($showtable['Check_time'])) : '');
01299 
01300         PMA_DBI_free_result($result);
01301         unset($result);
01302 
01303 
01307         $result       = PMA_DBI_query('SHOW KEYS FROM ' . PMA_backquote($table) . ';');
01308         $primary      = '';
01309         $indexes      = array();
01310         $lastIndex    = '';
01311         $indexes_info = array();
01312         $indexes_data = array();
01313         $pk_array     = array(); // will be use to emphasis prim. keys in the table
01314                                  // view
01315         while ($row = PMA_DBI_fetch_assoc($result)) {
01316             // Backups the list of primary keys
01317             if ($row['Key_name'] == 'PRIMARY') {
01318                 $primary   .= $row['Column_name'] . ', ';
01319                 $pk_array[$row['Column_name']] = 1;
01320             }
01321             // Retains keys informations
01322             if ($row['Key_name'] != $lastIndex ){
01323                 $indexes[] = $row['Key_name'];
01324                 $lastIndex = $row['Key_name'];
01325             }
01326             $indexes_info[$row['Key_name']]['Sequences'][]     = $row['Seq_in_index'];
01327             $indexes_info[$row['Key_name']]['Non_unique']      = $row['Non_unique'];
01328             if (isset($row['Cardinality'])) {
01329                 $indexes_info[$row['Key_name']]['Cardinality'] = $row['Cardinality'];
01330             }
01331             // I don't know what does following column mean....
01332             // $indexes_info[$row['Key_name']]['Packed']          = $row['Packed'];
01333             $indexes_info[$row['Key_name']]['Comment']         = $row['Comment'];
01334 
01335             $indexes_data[$row['Key_name']][$row['Seq_in_index']]['Column_name']  = $row['Column_name'];
01336             if (isset($row['Sub_part'])) {
01337                 $indexes_data[$row['Key_name']][$row['Seq_in_index']]['Sub_part'] = $row['Sub_part'];
01338             }
01339 
01340         } // end while
01341         if ($result) {
01342             PMA_DBI_free_result($result);
01343         }
01344 
01345 
01349         $result      = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';', NULL, PMA_DBI_QUERY_STORE);
01350         $fields_cnt  = PMA_DBI_num_rows($result);
01351 
01352 
01353         // Check if we can use Relations (Mike Beck)
01354         if (!empty($cfgRelation['relation'])) {
01355             // Find which tables are related with the current one and write it in
01356             // an array
01357             $res_rel = PMA_getForeigners($db, $table);
01358 
01359             if (count($res_rel) > 0) {
01360                 $have_rel = TRUE;
01361             } else {
01362                 $have_rel = FALSE;
01363             }
01364         }
01365         else {
01366             $have_rel = FALSE;
01367         } // end if
01368 
01369 
01374         $break = false;
01375         if (!empty($show_comment)) {
01376             $pdf->Cell(0,3,$GLOBALS['strTableComments'] . ' : ' . $show_comment,0,1);
01377             $break = true;
01378         }
01379 
01380         if (!empty($create_time)) {
01381             $pdf->Cell(0,3,$GLOBALS['strStatCreateTime'] . ': ' . $create_time,0,1);
01382             $break = true;
01383         }
01384 
01385         if (!empty($update_time)) {
01386             $pdf->Cell(0,3,$GLOBALS['strStatUpdateTime'] . ': ' . $update_time,0,1);
01387             $break = true;
01388         }
01389 
01390         if (!empty($check_time)) {
01391             $pdf->Cell(0,3,$GLOBALS['strStatCheckTime'] . ': ' . $check_time,0,1);
01392             $break = true;
01393         }
01394 
01395         if ($break == true) {
01396             $pdf->Cell(0,3,'',0,1);
01397             $pdf->Ln();
01398         }
01399 
01400         $i = 0;
01401         $pdf->SetFont('', 'B');
01402         if (isset($orientation) && $orientation == 'L') {
01403             $pdf->Cell(25,8,ucfirst($GLOBALS['strField']),1,0,'C');
01404             $pdf->Cell(20,8,ucfirst($GLOBALS['strType']),1,0,'C');
01405             $pdf->Cell(20,8,ucfirst($GLOBALS['strAttr']),1,0,'C');
01406             $pdf->Cell(10,8,ucfirst($GLOBALS['strNull']),1,0,'C');
01407             $pdf->Cell(20,8,ucfirst($GLOBALS['strDefault']),1,0,'C');
01408             $pdf->Cell(25,8,ucfirst($GLOBALS['strExtra']),1,0,'C');
01409             $pdf->Cell(45,8,ucfirst($GLOBALS['strLinksTo']),1,0,'C');
01410 
01411             if ($paper == 'A4') {
01412                 $comments_width = 67;
01413             } else {
01414                 // this is really intended for 'letter'
01415                 // TODO: find optimal width for all formats
01416                 $comments_width = 50;
01417             }
01418             $pdf->Cell($comments_width,8,ucfirst($GLOBALS['strComments']),1,0,'C');
01419             $pdf->Cell(45,8,'MIME',1,1,'C');
01420             $pdf->SetWidths(array(25,20,20,10,20,25,45,$comments_width,45));
01421         } else {
01422             $pdf->Cell(20,8,ucfirst($GLOBALS['strField']),1,0,'C');
01423             $pdf->Cell(20,8,ucfirst($GLOBALS['strType']),1,0,'C');
01424             $pdf->Cell(20,8,ucfirst($GLOBALS['strAttr']),1,0,'C');
01425             $pdf->Cell(10,8,ucfirst($GLOBALS['strNull']),1,0,'C');
01426             $pdf->Cell(15,8,ucfirst($GLOBALS['strDefault']),1,0,'C');
01427             $pdf->Cell(15,8,ucfirst($GLOBALS['strExtra']),1,0,'C');
01428             $pdf->Cell(30,8,ucfirst($GLOBALS['strLinksTo']),1,0,'C');
01429             $pdf->Cell(30,8,ucfirst($GLOBALS['strComments']),1,0,'C');
01430             $pdf->Cell(30,8,'MIME',1,1,'C');
01431             $pdf->SetWidths(array(20,20,20,10,15,15,30,30,30));
01432         }
01433         $pdf->SetFont('', '');
01434 
01435         while ($row = PMA_DBI_fetch_assoc($result)) {
01436             $bgcolor = ($i % 2) ?$GLOBALS['cfg']['BgcolorOne'] : $GLOBALS['cfg']['BgcolorTwo'];
01437             $i++;
01438 
01439             $type             = $row['Type'];
01440             // reformat mysql query output - staybyte - 9. June 2001
01441             // loic1: set or enum types: slashes single quotes inside options
01442             if (preg_match('@^(set|enum)\((.+)\)$@i', $type, $tmp = array())) {
01443                 $tmp[2]       = substr(preg_replace("@([^,])''@", "\\1\\'", ',' . $tmp[2]), 1);
01444                 $type         = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
01445                 $type_nowrap  = '';
01446 
01447                 $binary       = 0;
01448                 $unsigned     = 0;
01449                 $zerofill     = 0;
01450             } else {
01451                 $type_nowrap  = ' nowrap="nowrap"';
01452                 $type         = preg_replace('@BINARY@i', '', $type);
01453                 $type         = preg_replace('@ZEROFILL@i', '', $type);
01454                 $type         = preg_replace('@UNSIGNED@i', '', $type);
01455                 if (empty($type)) {
01456                     $type     = '&nbsp;';
01457                 }
01458 
01459                 $binary       = stristr($row['Type'], 'BINARY');
01460                 $unsigned     = stristr($row['Type'], 'UNSIGNED');
01461                 $zerofill     = stristr($row['Type'], 'ZEROFILL');
01462             }
01463             $strAttribute     = ' ';
01464             if ($binary) {
01465                 $strAttribute = 'BINARY';
01466             }
01467             if ($unsigned) {
01468                 $strAttribute = 'UNSIGNED';
01469             }
01470             if ($zerofill) {
01471                 $strAttribute = 'UNSIGNED ZEROFILL';
01472             }
01473             if (!isset($row['Default'])) {
01474                 if ($row['Null'] != '') {
01475                     $row['Default'] = 'NULL';
01476                 }
01477             }
01478             $field_name = $row['Field'];
01479             //$pdf->Ln();
01480             $pdf->PMA_links['RT'][$table][$field_name] =$pdf->AddLink();
01481             $pdf->Bookmark($field_name,1,-1);
01482             $pdf->SetLink($pdf->PMA_links['doc'][$table][$field_name],-1);
01483             $pdf_row = array($field_name ,
01484                             $type ,
01485                             $strAttribute ,
01486                             ($row['Null'] == '') ? $GLOBALS['strNo'] : $GLOBALS['strYes'],
01487                             ((isset($row['Default'])) ?  $row['Default'] : ''),
01488                             $row['Extra']  ,
01489                             ((isset($res_rel[$field_name])) ? $res_rel[$field_name]['foreign_table'] . ' -> ' . $res_rel[$field_name]['foreign_field'] : ''),
01490                             ((isset($comments[$field_name])) ? $comments[$field_name]  : '' ),
01491                             ((isset($mime_map) && isset($mime_map[$field_name])) ? str_replace('_', '/', $mime_map[$field_name]['mimetype'])  : '' )
01492                             );
01493             $links[0] = $pdf->PMA_links['RT'][$table][$field_name];
01494             if (isset($res_rel[$field_name]['foreign_table']) AND
01495                 isset($res_rel[$field_name]['foreign_field']) AND
01496                 isset($pdf->PMA_links['doc'][$res_rel[$field_name]['foreign_table']][$res_rel[$field_name]['foreign_field']])
01497               ) $links[6] = $pdf->PMA_links['doc'][$res_rel[$field_name]['foreign_table']][$res_rel[$field_name]['foreign_field']];
01498               else unset($links[6]);
01499             $pdf->Row($pdf_row, $links);
01500 
01501              /*$pdf->Cell(20,8,$field_name,1,0,'L',0,$pdf->PMA_links['RT'][$table][$field_name]);
01502                 //echo '    ' . $field_name . '&nbsp;' . "\n";
01503             }
01504         $pdf->Cell(20,8,$type,1,0,'L');
01505         $pdf->Cell(20,8,$strAttribute,1,0,'L');
01506         $pdf->Cell(15,8,,1,0,'L');
01507         $pdf->Cell(15,8,((isset($row['Default'])) ?  $row['Default'] : ''),1,0,'L');
01508         $pdf->Cell(15,8,$row['Extra'],1,0,'L');
01509            if ($have_rel) {
01510                 if (isset($res_rel[$field_name])) {
01511                     $pdf->Cell(30,8,$res_rel[$field_name]['foreign_table'] . ' -> ' . $res_rel[$field_name]['foreign_field'],1,0,'L');
01512                 }
01513             }
01514             if ($cfgRelation['commwork']) {
01515                 if (isset($comments[$field_name])) {
01516                     $pdf->Cell(0,8,$comments[$field_name],1,0,'L');
01517                 }
01518             } */
01519         } // end while
01520         $pdf->SetFont('', '',14);
01521         PMA_DBI_free_result($result);
01522     }//end each
01523 
01524 
01525 } // end function PMA_RT_DOC
01526 
01527 
01531 if (!isset($pdf_page_number)) {
01532     $pdf_page_number  = 1;
01533 }
01534 $show_grid            = (isset($show_grid) && $show_grid == 'on') ? 1 : 0;
01535 $show_color           = (isset($show_color) && $show_color == 'on') ? 1 : 0;
01536 $show_table_dimension = (isset($show_table_dimension) && $show_table_dimension == 'on') ? 1 : 0;
01537 $all_tab_same_wide    = (isset($all_tab_same_wide) && $all_tab_same_wide == 'on') ? 1 : 0;
01538 $with_doc             = (isset($with_doc) && $with_doc == 'on') ? 1 : 0;
01539 $orientation          = (isset($orientation) && $orientation == 'P') ? 'P' : 'L';
01540 $paper                = isset($paper) ? $paper : 'A4';
01541 PMA_DBI_select_db($db);
01542 
01543 $rt = new PMA_RT($pdf_page_number, $show_table_dimension, $show_color, $show_grid, $all_tab_same_wide, $orientation, $paper);
01544 ?>


Généré par L'expert TYPO3 avec  doxygen 1.4.6