Documentation TYPO3 par Ameos

pdf_schema.php

00001 <?php
00002 /* $Id: pdf_schema.php,v 2.2 2003/11/26 22:52:24 rabus Exp $ */
00003 // vim: expandtab sw=4 ts=4 sts=4:
00004 
00005 
00014 require_once('./libraries/grab_globals.lib.php');
00015 require_once('./libraries/common.lib.php');
00016 
00017 
00021 require_once('./libraries/relation.lib.php');
00022 require_once('./libraries/transformations.lib.php');
00023 
00024 $cfgRelation = PMA_getRelationsParam();
00025 
00026 
00035 if (!$cfgRelation['pdfwork']) {
00036     echo '<font color="red">' . $strError . '</font><br />' . "\n";
00037     $url_to_goto = '<a href="' . $cfg['PmaAbsoluteUri'] . 'chk_rel.php?' . $url_query . '">';
00038     echo sprintf($strRelationNotWorking, $url_to_goto, '</a>') . "\n";
00039 }
00040 
00041 
00045 require_once('./libraries/fpdf/fpdf.php');
00046 $FPDF_font_path = './libraries/fpdf/font/';
00047 
00048 
00056 class PMA_PDF extends FPDF
00057 {
00061     var $x_min;
00062     var $y_min;
00063     var $l_marg = 10;
00064     var $t_marg = 10;
00065     var $scale;
00066     var $title;
00067     var $PMA_links;
00068     var $Outlines=array();
00069     var $def_outlines;
00070     var $Alias ;
00071     var $widths;
00072 
00088     function PMA_PDF($orientation = 'L', $unit = 'mm', $format = 'A4')
00089     {
00090         $this->Alias = array() ;
00091         $this->FPDF($orientation, $unit, $format);
00092     } // end of the "PMA_PDF()" method
00093     function SetAlias($name, $value)
00094     {
00095         $this->Alias[$name] = $value ;
00096     }
00097     function _putpages()
00098     {
00099         if(count($this->Alias) > 0)
00100         {
00101             $nb=$this->page;
00102             foreach($this->Alias AS $alias => $value) {
00103                 for($n=1;$n<=$nb;$n++)
00104                 $this->pages[$n]=str_replace($alias,$value,$this->pages[$n]);
00105             }
00106         }
00107         parent::_putpages();
00108     }
00109 
00121     function PMA_PDF_setScale($scale = 1, $x_min = 0, $y_min = 0, $l_marg = -1, $t_marg = -1)
00122     {
00123         $this->scale      = $scale;
00124         $this->x_min      = $x_min;
00125         $this->y_min      = $y_min;
00126         if ($this->l_marg != -1) {
00127             $this->l_marg = $l_marg;
00128         }
00129         if ($this->t_marg != -1) {
00130             $this->t_marg = $t_marg;
00131         }
00132     } // end of the "PMA_PDF_setScale" function
00133 
00134 
00150     function PMA_PDF_cellScale($w, $h = 0, $txt = '', $border = 0, $ln = 0, $align = '', $fill = 0,$link ='')
00151     {
00152         $h = $h / $this->scale;
00153         $w = $w / $this->scale;
00154         $this->Cell($w, $h, $txt, $border, $ln, $align, $fill,$link);
00155     } // end of the "PMA_PDF_cellScale" function
00156 
00157 
00170     function PMA_PDF_lineScale($x1, $y1, $x2, $y2)
00171     {
00172         $x1 = ($x1 - $this->x_min) / $this->scale + $this->l_marg;
00173         $y1 = ($y1 - $this->y_min) / $this->scale + $this->t_marg;
00174         $x2 = ($x2 - $this->x_min) / $this->scale + $this->l_marg;
00175         $y2 = ($y2 - $this->y_min) / $this->scale + $this->t_marg;
00176         $this->Line($x1, $y1, $x2, $y2);
00177     } // end of the "PMA_PDF_lineScale" function
00178 
00179 
00190     function PMA_PDF_setXyScale($x, $y)
00191     {
00192         $x = ($x - $this->x_min) / $this->scale + $this->l_marg;
00193         $y = ($y - $this->y_min) / $this->scale + $this->t_marg;
00194         $this->SetXY($x, $y);
00195     } // end of the "PMA_PDF_setXyScale" function
00196 
00197 
00207     function PMA_PDF_setXScale($x)
00208     {
00209         $x = ($x - $this->x_min) / $this->scale + $this->l_marg;
00210         $this->SetX($x);
00211     } // end of the "PMA_PDF_setXScale" function
00212 
00213 
00223     function PMA_PDF_setFontSizeScale($size)
00224     {
00225         // Set font size in points
00226         $size = $size / $this->scale;
00227         $this->SetFontSize($size);
00228     } // end of the "PMA_PDF_setFontSizeScale" function
00229 
00230 
00240     function PMA_PDF_setLineWidthScale($width)
00241     {
00242         $width = $width / $this->scale;
00243         $this->SetLineWidth($width);
00244     } // end of the "PMA_PDF_setLineWidthScale" function
00245 
00246 
00264     function PMA_PDF_die($error_message = '')
00265     {
00266         global $cfg;
00267         global $server, $lang, $convcharset, $db;
00268         global $charset, $text_dir, $strRunning, $strDatabase;
00269 
00270         require_once('./header.inc.php');
00271 
00272         echo '<p><b>PDF - '. $GLOBALS['strError'] . '</b></p>' . "\n";
00273         if (!empty($error_message)) {
00274             $error_message = htmlspecialchars($error_message);
00275         }
00276         echo '<p>' . "\n";
00277         echo '    ' . $error_message . "\n";
00278         echo '</p>' . "\n";
00279 
00280         echo '<a href="db_details_structure.php?' . PMA_generate_common_url($db)
00281              . '">' . $GLOBALS['strBack'] . '</a>';
00282         echo "\n";
00283 
00284         require_once('./footer.inc.php');
00285     } // end of the "PMA_PDF_die()" function
00286 
00287 
00298     function Error($error_message = '')
00299     {
00300         $this->PMA_PDF_die($error_message);
00301     } // end of the "Error()" method
00302 
00303     function Header(){
00304         //$datefmt
00305         // We only show this if we find something in the new pdf_pages table
00306         //
00307         // This function must be named "Header" to work with the FPDF library
00308 
00309     global $cfgRelation,$db,$pdf_page_number,$with_doc;
00310     if ($with_doc){
00311         $test_query = 'SELECT * FROM ' . PMA_backquote($cfgRelation['pdf_pages'])
00312                     . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
00313                     . ' AND page_nr = \'' . $pdf_page_number . '\'';
00314         $test_rs    = PMA_query_as_cu($test_query);
00315         $pages = @PMA_mysql_fetch_array($test_rs);
00316         $this->SetFont('', 'B', 14);
00317         $this->Cell(0,6, ucfirst($pages['page_descr']),'B',1,'C');
00318         $this->SetFont('', '');
00319         $this->Ln();
00320     }
00321     }
00322     function Footer(){
00323         // This function must be named "Footer" to work with the FPDF library
00324         global $with_doc;
00325         if ($with_doc){
00326             $this->SetY(-15);
00327             $this->SetFont('', '',14);
00328             $this->Cell(0,6, $GLOBALS['strPageNumber'] .' '.$this->PageNo() .'/{nb}','T',0,'C');
00329             $this->Cell(0,6, PMA_localisedDate(),0,1,'R');
00330             $this->SetY(20);
00331         }
00332     }
00333     function Bookmark($txt,$level=0,$y=0)
00334 {
00335    //Add a bookmark
00336    $this->Outlines[0][]=$level;
00337    $this->Outlines[1][]=$txt;
00338    $this->Outlines[2][]=$this->page;
00339    if($y==-1)
00340       $y=$this->GetY();
00341    $this->Outlines[3][]=round($this->hPt-$y*$this->k,2);
00342 }
00343 
00344 function _putbookmarks()
00345 {
00346    if(count($this->Outlines)>0)
00347    {
00348       //Save object number
00349       $memo_n = $this->n;
00350       //Take the number of sub elements for an outline
00351       $nb_outlines=sizeof($this->Outlines[0]);
00352       $first_level=array();
00353       $parent=array();
00354       $parent[0]=1;
00355       for( $i=0; $i<$nb_outlines; $i++)
00356       {
00357          $level=$this->Outlines[0][$i];
00358          $kids=0;
00359          $last=-1;
00360          $prev=-1;
00361          $next=-1;
00362          if( $i>0 )
00363          {
00364             $cursor=$i-1;
00365             //Take the previous outline in the same level
00366             while( $this->Outlines[0][$cursor] > $level && $cursor > 0)
00367                $cursor--;
00368             if( $this->Outlines[0][$cursor] == $level)
00369                $prev=$cursor;
00370          }
00371          if( $i<$nb_outlines-1)
00372          {
00373             $cursor=$i+1;
00374             while( isset($this->Outlines[0][$cursor]) && $this->Outlines[0][$cursor] > $level)
00375             {
00376                //Take the immediate kid in level + 1
00377                if( $this->Outlines[0][$cursor] == $level+1)
00378                {
00379                   $kids++;
00380                   $last=$cursor;
00381                }
00382                $cursor++;
00383             }
00384             $cursor=$i+1;
00385             //Take the next outline in the same level
00386             while( $this->Outlines[0][$cursor] > $level && ($cursor+1 < sizeof($this->Outlines[0])))
00387                $cursor++;
00388             if( $this->Outlines[0][$cursor] == $level)
00389                $next=$cursor;
00390          }
00391          $this->_newobj();
00392          $parent[$level+1]=$this->n;
00393          if( $level == 0)
00394             $first_level[]=$this->n;
00395          $this->_out('<<');
00396          $this->_out('/Title ('.$this->Outlines[1][$i].')');
00397          $this->_out('/Parent '.$parent[$level].' 0 R');
00398          if( $prev != -1)
00399             $this->_out('/Prev '.($memo_n+$prev+1).' 0 R');
00400          if( $next != -1)
00401             $this->_out('/Next '.($this->n+$next-$i).' 0 R');
00402          $this->_out('/Dest ['.(1+(2*$this->Outlines[2][$i])).' 0 R /XYZ null '.$this->Outlines[3][$i].' null]');
00403          if( $kids > 0)
00404          {
00405             $this->_out('/First '.($this->n+1).' 0 R');
00406             $this->_out('/Last '.($this->n+$last-$i).' 0 R');
00407             $this->_out('/Count -'.$kids);
00408          }
00409          $this->_out('>>');
00410          $this->_out('endobj');
00411       }
00412       //First page of outlines
00413       $this->_newobj();
00414       $this->def_outlines = $this->n;
00415       $this->_out('<<');
00416       $this->_out('/Type');
00417       $this->_out('/Outlines');
00418       $this->_out('/First '.$first_level[0].' 0 R');
00419       $this->_out('/Last '.$first_level[sizeof($first_level)-1].' 0 R');
00420       $this->_out('/Count '.sizeof($first_level));
00421       $this->_out('>>');
00422       $this->_out('endobj');
00423    }
00424 }
00425 
00426 function _putresources()
00427 {
00428    parent::_putresources();
00429    $this->_putbookmarks();
00430 }
00431 
00432 function _putcatalog()
00433 {
00434    parent::_putcatalog();
00435    if(count($this->Outlines)>0)
00436    {
00437       $this->_out('/Outlines '.$this->def_outlines.' 0 R');
00438       $this->_out('/PageMode /UseOutlines');
00439    }
00440 }
00441 function SetWidths($w)
00442 {
00443    // column widths
00444    $this->widths=$w;
00445 }
00446 
00447 function Row($data,$links)
00448 {
00449    // line height
00450    $nb=0;
00451    $data_cnt = count($data);
00452    for($i=0;$i<$data_cnt;$i++)
00453       $nb=max($nb,$this->NbLines($this->widths[$i],$data[$i]));
00454    $il = $this->FontSize;
00455    $h=($il+1)*$nb;
00456    // page break if necessary
00457    $this->CheckPageBreak($h);
00458    // draw the cells
00459    $data_cnt = count($data);
00460    for($i=0;$i<$data_cnt;$i++)
00461    {
00462       $w=$this->widths[$i];
00463       // save current position
00464       $x=$this->GetX();
00465       $y=$this->GetY();
00466       // draw the border
00467       $this->Rect($x,$y,$w,$h);
00468       if (isset($links[$i]))
00469       $this->Link($x,$y,$w,$h,$links[$i]);
00470       // print text
00471       $this->MultiCell($w,$il+1,$data[$i],0,'L');
00472       // go to right side
00473       $this->SetXY($x+$w,$y);
00474    }
00475    // go to line
00476    $this->Ln($h);
00477 }
00478 
00479 function CheckPageBreak($h)
00480 {
00481    // if height h overflows, manual page break
00482    if($this->GetY()+$h>$this->PageBreakTrigger)
00483       $this->AddPage($this->CurOrientation);
00484 }
00485 
00486 function NbLines($w,$txt)
00487 {
00488    // compute number of lines used by a multicell of width w
00489    $cw=&$this->CurrentFont['cw'];
00490    if($w==0)
00491       $w=$this->w-$this->rMargin-$this->x;
00492    $wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
00493    $s=str_replace("\r",'',$txt);
00494    $nb=strlen($s);
00495    if($nb>0 and $s[$nb-1]=="\n")
00496       $nb--;
00497    $sep=-1;
00498    $i=0;
00499    $j=0;
00500    $l=0;
00501    $nl=1;
00502    while($i<$nb)
00503    {
00504       $c=$s[$i];
00505       if($c=="\n")
00506       {
00507          $i++;
00508          $sep=-1;
00509          $j=$i;
00510          $l=0;
00511          $nl++;
00512          continue;
00513       }
00514       if($c==' ')
00515          $sep=$i;
00516       $l+=$cw[$c];
00517       if($l>$wmax)
00518       {
00519          if($sep==-1)
00520          {
00521             if($i==$j)
00522                $i++;
00523          }
00524          else
00525             $i=$sep+1;
00526          $sep=-1;
00527          $j=$i;
00528          $l=0;
00529          $nl++;
00530       }
00531       else
00532          $i++;
00533    }
00534    return $nl;
00535 }
00536 
00537 } // end of the "PMA_PDF" class
00538 
00539 
00547 class PMA_RT_Table
00548 {
00552     var $nb_fiels;
00553     var $table_name;
00554     var $width = 0;
00555     var $height;
00556     var $fields      = array();
00557     var $height_cell = 6;
00558     var $x, $y;
00559     var $primary     = array();
00560 
00561 
00573     function PMA_RT_Table_setWidth($ff)
00574     {
00575         //  this looks buggy to me... does it really work if
00576         //  there are fields that require wider cells than the name of the table?
00577         global $pdf;
00578 
00579         foreach($this->fields AS $field) {
00580             $this->width = max($this->width, $pdf->GetStringWidth($field));
00581         }
00582         $this->width += $pdf->GetStringWidth('  ');
00583         $pdf->SetFont($ff, 'B');
00584         $this->width = max($this->width, $pdf->GetStringWidth('  ' . $this->table_name));
00585         $pdf->SetFont($ff, '');
00586     } // end of the "PMA_RT_Table_setWidth()" method
00587 
00588 
00594     function PMA_RT_Table_setHeight()
00595     {
00596         $this->height = (count($this->fields) + 1) * $this->height_cell;
00597     } // end of the "PMA_RT_Table_setHeight()" method
00598 
00599 
00614     function PMA_RT_Table_draw($show_info, $ff, $setcolor=0)
00615     {
00616         global $pdf, $with_doc;
00617 
00618         $pdf->PMA_PDF_setXyScale($this->x, $this->y);
00619         $pdf->SetFont($ff, 'B');
00620         if ($setcolor) {
00621             $pdf->SetTextColor(200);
00622             $pdf->SetFillColor(0, 0, 128);
00623         }
00624         if ($with_doc) $pdf->SetLink($pdf->PMA_links['RT'][$this->table_name]['-'],-1);
00625         else $pdf->PMA_links['doc'][$this->table_name]['-'] = '';
00626         if ($show_info){
00627             $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]['-']);
00628         } else {
00629             $pdf->PMA_PDF_cellScale($this->width, $this->height_cell, $this->table_name, 1, 1, 'C', $setcolor, $pdf->PMA_links['doc'][$this->table_name]['-']);
00630         }
00631         $pdf->PMA_PDF_setXScale($this->x);
00632         $pdf->SetFont($ff, '');
00633         $pdf->SetTextColor(0);
00634         $pdf->SetFillColor(255);
00635 
00636         foreach($this->fields AS $field) {
00637             // loic1 : PHP3 fix
00638             // if (in_array($field, $this->primary)) {
00639             if ($setcolor) {
00640                 if (PMA_isInto($field, $this->primary) != -1) {
00641                     $pdf->SetFillColor(215, 121, 123);
00642                 }
00643                 if ($field == $this->displayfield) {
00644                     $pdf->SetFillColor(142, 159, 224);
00645                 }
00646             }
00647             if ($with_doc) $pdf->SetLink($pdf->PMA_links['RT'][$this->table_name][$field],-1);
00648             else $pdf->PMA_links['doc'][$this->table_name][$field] = '';
00649 
00650 
00651             $pdf->PMA_PDF_cellScale($this->width, $this->height_cell, ' ' . $field, 1, 1, 'L', $setcolor,$pdf->PMA_links['doc'][$this->table_name][$field]);
00652             $pdf->PMA_PDF_setXScale($this->x);
00653             $pdf->SetFillColor(255);
00654         } // end while
00655 
00656         /*if ($pdf->PageNo() > 1) {
00657             $pdf->PMA_PDF_die($GLOBALS['strScaleFactorSmall']);
00658         } */
00659     } // end of the "PMA_RT_Table_draw()" method
00660 
00661 
00680     function PMA_RT_Table($table_name, $ff, &$same_wide_width)
00681     {
00682         global $pdf, $pdf_page_number, $cfgRelation, $db;
00683 
00684         $this->table_name = $table_name;
00685         $sql              = 'DESCRIBE ' .  PMA_backquote($table_name);
00686         $result           = PMA_mysql_query($sql);
00687         if (!$result || !mysql_num_rows($result)) {
00688             $pdf->PMA_PDF_die(sprintf($GLOBALS['strPdfInvalidTblName'], $table_name));
00689         }
00690         // load fields
00691         while ($row = PMA_mysql_fetch_array($result)) {
00692             $this->fields[] = $row[0];
00693         }
00694 
00695         //height and width
00696         $this->PMA_RT_Table_setWidth($ff);
00697         $this->PMA_RT_Table_setHeight();
00698         if ($same_wide_width < $this->width) {
00699             $same_wide_width = $this->width;
00700         }
00701 
00702         //x and y
00703         $sql    = 'SELECT x, y FROM '
00704                 . PMA_backquote($cfgRelation['table_coords'])
00705                 .   ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
00706                 .   ' AND   table_name = \'' . PMA_sqlAddslashes($table_name) . '\''
00707                 .   ' AND   pdf_page_number = ' . $pdf_page_number;
00708         $result = PMA_query_as_cu($sql);
00709 
00710         if (!$result || !mysql_num_rows($result)) {
00711             $pdf->PMA_PDF_die(sprintf($GLOBALS['strConfigureTableCoord'], $table_name));
00712         }
00713         list($this->x, $this->y) = PMA_mysql_fetch_array($result);
00714         $this->x = (double) $this->x;
00715         $this->y = (double) $this->y;
00716         // displayfield
00717         $this->displayfield = PMA_getDisplayField($db, $table_name);
00718 
00719         // index
00720         $sql    = 'SHOW index FROM ' . PMA_backquote($table_name);
00721         $result = PMA_mysql_query($sql);
00722         if ($result && mysql_num_rows($result) > 0) {
00723             while ($row = PMA_mysql_fetch_array($result)) {
00724                 if ($row['Key_name'] == 'PRIMARY') {
00725                     $this->primary[] = $row['Column_name'];
00726                 }
00727             }
00728         } // end if
00729     } // end of the "PMA_RT_Table()" method
00730 } // end class "PMA_RT_Table"
00731 
00732 
00733 
00741 class PMA_RT_Relation
00742 {
00746     var $x_src, $y_src;
00747     var $src_dir ;
00748     var $dest_dir;
00749     var $x_dest, $y_dest;
00750     var $w_tick = 5;
00751 
00752 
00763     function PMA_RT_Relation_getXy($table, $column)
00764     {
00765         $pos = array_search($column, $table->fields);
00766         // x_left, x_right, y
00767         return array($table->x, $table->x + + $table->width, $table->y + ($pos + 1.5) * $table->height_cell);
00768     } // end of the "PMA_RT_Relation_getXy()" method
00769 
00770 
00783     function PMA_RT_Relation_draw($change_color, $i)
00784     {
00785         global $pdf;
00786 
00787         if ($change_color){
00788             $d    = $i % 6;
00789             $j    = ($i - $d) / 6;
00790             $j    = $j % 4;
00791             $j++;
00792             $case = array(
00793                         array(1, 0, 0),
00794                         array(0, 1, 0),
00795                         array(0, 0, 1),
00796                         array(1, 1, 0),
00797                         array(1, 0, 1),
00798                         array(0, 1, 1)
00799                     );
00800             list ($a, $b, $c) = $case[$d];
00801             $e    = (1 - ($j - 1) / 6);
00802             $pdf->SetDrawColor($a * 255 * $e, $b * 255 * $e, $c * 255 * $e);       }
00803         else {
00804             $pdf->SetDrawColor(0);
00805         } // end if... else...
00806 
00807         $pdf->PMA_PDF_setLineWidthScale(0.2);
00808         $pdf->PMA_PDF_lineScale($this->x_src, $this->y_src, $this->x_src + $this->src_dir * $this->w_tick, $this->y_src);
00809         $pdf->PMA_PDF_lineScale($this->x_dest + $this->dest_dir * $this->w_tick, $this->y_dest, $this->x_dest, $this->y_dest);
00810         $pdf->PMA_PDF_setLineWidthScale(0.1);
00811         $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);
00812 
00813         //arrow
00814         $root2 = 2 * sqrt(2);
00815         $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);
00816         $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);
00817 
00818         $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);
00819         $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);
00820         $pdf->SetDrawColor(0);
00821     } // end of the "PMA_RT_Relation_draw()" method
00822 
00823 
00837     function PMA_RT_Relation($master_table, $master_field,  $foreign_table, $foreign_field)
00838     {
00839         $src_pos    = $this->PMA_RT_Relation_getXy($master_table , $master_field);
00840         $dest_pos   = $this->PMA_RT_Relation_getXy($foreign_table, $foreign_field);
00841         $src_left   = $src_pos[0] - $this->w_tick;
00842         $src_right  = $src_pos[1] + $this->w_tick;
00843         $dest_left  = $dest_pos[0] - $this->w_tick;
00844         $dest_right = $dest_pos[1] + $this->w_tick;
00845 
00846         $d1 = abs($src_left  - $dest_left);
00847         $d2 = abs($src_right - $dest_left);
00848         $d3 = abs($src_left  - $dest_right);
00849         $d4 = abs($src_right - $dest_right);
00850         $d  = min($d1, $d2, $d3, $d4);
00851 
00852         if ($d == $d1) {
00853             $this->x_src    = $src_pos[0];
00854             $this->src_dir  = -1;
00855             $this->x_dest   = $dest_pos[0];
00856             $this->dest_dir = -1;
00857         } else if ($d == $d2) {
00858             $this->x_src    = $src_pos[1];
00859             $this->src_dir  = 1;
00860             $this->x_dest   = $dest_pos[0];
00861             $this->dest_dir = -1;
00862         } else if ($d == $d3) {
00863             $this->x_src    = $src_pos[0];
00864             $this->src_dir  = -1;
00865             $this->x_dest   = $dest_pos[1];
00866             $this->dest_dir = 1;
00867         } else {
00868             $this->x_src    =  $src_pos[1];
00869             $this->src_dir  = 1;
00870             $this->x_dest   = $dest_pos[1];
00871             $this->dest_dir = 1;
00872         }
00873         $this->y_src        = $src_pos[2];
00874         $this->y_dest       = $dest_pos[2];
00875     } // end of the "PMA_RT_Relation()" method
00876 } // end of the "PMA_RT_Relation" class
00877 
00878 
00879 
00887 class PMA_RT
00888 {
00892     var $tables    = array();
00893     var $relations = array();
00894     var $ff        = 'Arial';
00895     var $x_max     = 0;
00896     var $y_max     = 0;
00897     var $scale;
00898     var $x_min     = 100000;
00899     var $y_min     = 100000;
00900     var $t_marg    = 10;
00901     var $b_marg    = 10;
00902     var $l_marg    = 10;
00903     var $r_marg    = 10;
00904     var $tablewidth;
00905     var $same_wide = 0;
00906 
00914     function PMA_RT_setMinMax($table)
00915     {
00916         $this->x_max = max($this->x_max, $table->x + $table->width);
00917         $this->y_max = max($this->y_max, $table->y + $table->height);
00918         $this->x_min = min($this->x_min, $table->x);
00919         $this->y_min = min($this->y_min, $table->y);
00920     } // end of the "PMA_RT_setMinMax()" method
00921 
00922 
00935     function PMA_RT_addRelation($master_table , $master_field,  $foreign_table, $foreign_field)
00936     {
00937         if (!isset($this->tables[$master_table])) {
00938             $this->tables[$master_table] = new PMA_RT_Table($master_table, $this->ff, $this->tablewidth);
00939             $this->PMA_RT_setMinMax($this->tables[$master_table]);
00940         }
00941         if (!isset($this->tables[$foreign_table])) {
00942             $this->tables[$foreign_table] = new PMA_RT_Table($foreign_table, $this->ff, $this->tablewidth);
00943             $this->PMA_RT_setMinMax($this->tables[$foreign_table]);
00944         }
00945         $this->relations[] = new PMA_RT_Relation($this->tables[$master_table], $master_field, $this->tables[$foreign_table], $foreign_field);
00946     } // end of the "PMA_RT_addRelation()" method
00947 
00948 
00958     function PMA_RT_strokeGrid()
00959     {
00960         global $pdf;
00961 
00962         $pdf->SetMargins(0, 0);
00963         $pdf->SetDrawColor(200, 200, 200);
00964 
00965         // Draws horizontal lines
00966         for ($l = 0; $l < 21; $l++) {
00967             $pdf->line(0, $l * 10, $pdf->fh, $l * 10);
00968             // Avoid duplicates
00969             if ($l > 0) {
00970                 $pdf->SetXY(0, $l * 10);
00971                 $label = (string) sprintf('%.0f', ($l * 10 - $this->t_marg) * $this->scale + $this->y_min);
00972                 $pdf->Cell(5, 5, ' ' . $label);
00973             } // end if
00974         } // end for
00975 
00976         // Draws vertical lines
00977         for ($j = 0; $j < 30 ;$j++) {
00978             $pdf->line($j * 10, 0, $j * 10, $pdf->fw);
00979             $pdf->SetXY($j * 10, 0);
00980             $label = (string) sprintf('%.0f', ($j * 10 - $this->l_marg) * $this->scale + $this->x_min);
00981             $pdf->Cell(5, 7, $label);
00982         } // end for
00983     } // end of the "PMA_RT_strokeGrid()" method
00984 
00985 
00995     function PMA_RT_drawRelations($change_color)
00996     {
00997         $i = 0;
00998         foreach($this->relations AS $relation) {
00999             $relation->PMA_RT_Relation_draw($change_color, $i);
01000             $i++;
01001         } // end while
01002     } // end of the "PMA_RT_drawRelations()" method
01003 
01004 
01014     function PMA_RT_drawTables($show_info,$draw_color=0)
01015     {
01016         foreach($this->tables AS $table) {
01017             $table->PMA_RT_Table_draw($show_info, $this->ff,$draw_color);
01018         }
01019     } // end of the "PMA_RT_drawTables()" method
01020 
01021 
01034     function PMA_RT_showRt()
01035     {
01036         global $pdf, $db, $pdf_page_number, $cfgRelation;
01037 
01038         $pdf->SetFontSize(14);
01039         $pdf->SetLineWidth(0.2);
01040         $pdf->SetDisplayMode('fullpage');
01041         //  Get the name of this pdfpage to use as filename (Mike Beck)
01042         $_name_sql  = 'SELECT page_descr FROM ' . PMA_backquote($cfgRelation['pdf_pages'])
01043                   .   ' WHERE page_nr = ' . $pdf_page_number;
01044         $_name_rs   = PMA_query_as_cu($_name_sql);
01045         if ($_name_rs) {
01046             $_name_row = PMA_mysql_fetch_row($_name_rs);
01047             $filename = $_name_row[0] . '.pdf';
01048         }
01049         // i don't know if there is a chance for this to happen, but rather be on the safe side:
01050         if (empty($filename)) {
01051             $filename = $pdf_page_number . '.pdf';
01052         }
01053         $pdf->Output($db . '_' . $filename, TRUE);
01054         //$pdf->Output('', TRUE);
01055     } // end of the "PMA_RT_showRt()" method
01056 
01057 
01079     function PMA_RT( $which_rel, $show_info = 0, $change_color = 0 , $show_grid = 0, $all_tab_same_wide = 0, $orientation = 'L', $paper = 'A4')
01080     {
01081         global $pdf, $db, $cfgRelation, $with_doc;
01082 
01083         // Font face depends on the current language
01084         $this->ff        = str_replace('"', '', substr($GLOBALS['right_font_family'], 0, strpos($GLOBALS['right_font_family'], ',')));
01085         $this->same_wide = $all_tab_same_wide;
01086 
01087         // Initializes a new document
01088         $pdf          = new PMA_PDF('L', 'mm', $paper);
01089         $pdf->title   = sprintf($GLOBALS['strPdfDbSchema'], $GLOBALS['db'], $which_rel);
01090         $pdf->cMargin = 0;
01091         $pdf->Open();
01092         $pdf->SetTitle($pdf->title);
01093         $pdf->SetAuthor('phpMyAdmin ' . PMA_VERSION);
01094         $pdf->AliasNbPages();
01095 
01096          // fonts added to phpMyAdmin and considered non-standard by fpdf
01097          // (Note: those tahoma fonts are iso-8859-2 based)
01098          if ($this->ff == 'tahoma') {
01099              $pdf->AddFont('tahoma','','tahoma.php');
01100              $pdf->AddFont('tahoma','B','tahomab.php');
01101          }
01102 
01103         $pdf->SetFont($this->ff, '', 14);
01104         $pdf->SetAutoPageBreak('auto');
01105 
01106         // Gets tables on this page
01107         $tab_sql  = 'SELECT table_name FROM ' . PMA_backquote($cfgRelation['table_coords'])
01108                   .   ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\''
01109                   .   ' AND pdf_page_number = ' . $which_rel;
01110         $tab_rs   = PMA_query_as_cu($tab_sql);
01111         if (!$tab_rs || !mysql_num_rows($tab_rs) > 0) {
01112             $pdf->PMA_PDF_die($GLOBALS['strPdfNoTables']);
01113 //            die('No tables');
01114         }
01115         while ($curr_table = @PMA_mysql_fetch_array($tab_rs)) {
01116             $alltables[] = PMA_sqlAddslashes($curr_table['table_name']);
01117             //$intable     = '\'' . implode('\', \'', $alltables) . '\'';
01118         }
01119 
01120         //              make doc                    //
01121         if ($with_doc) {
01122             $pdf->SetAutoPageBreak('auto',15);
01123             $pdf->cMargin = 1;
01124             PMA_RT_DOC($alltables);
01125             $pdf->SetAutoPageBreak('auto');
01126             $pdf->cMargin = 0;
01127         }
01128 
01129         $pdf->Addpage();
01130 
01131 
01132         if ($with_doc) {
01133             $pdf->SetLink($pdf->PMA_links['RT']['-'],-1);
01134             $pdf->Bookmark($GLOBALS['strRelationalSchema']);
01135             $pdf->SetAlias('{00}', $pdf->PageNo()) ;
01136             $this->t_marg = 18;
01137             $this->b_marg = 18;
01138         }
01139 
01140                                 /* snip */
01141 
01142         foreach($alltables AS $table) {
01143             if (!isset($this->tables[$table])) {
01144                 $this->tables[$table] = new PMA_RT_Table($table, $this->ff, $this->tablewidth);
01145             }
01146 
01147             if($this->same_wide){
01148                 $this->tables[$table]->width = $this->tablewidth;
01149             }
01150             $this->PMA_RT_setMinMax($this->tables[$table]);
01151         }
01152         // Defines the scale factor
01153         $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;
01154         $pdf->PMA_PDF_setScale($this->scale, $this->x_min, $this->y_min, $this->l_marg, $this->t_marg);
01155 
01156 
01157         // Builds and save the PDF document
01158         $pdf->PMA_PDF_setLineWidthScale(0.1);
01159 
01160         if ($show_grid) {
01161             $pdf->SetFontSize(10);
01162             $this->PMA_RT_strokeGrid();
01163         }
01164         $pdf->PMA_PDF_setFontSizeScale(14);
01165 
01166 
01167 //        $sql    = 'SELECT * FROM ' . PMA_backquote($cfgRelation['relation'])
01168 //                .   ' WHERE master_db   = \'' . PMA_sqlAddslashes($db) . '\' '
01169 //                .   ' AND foreign_db    = \'' . PMA_sqlAddslashes($db) . '\' '
01170 //                .   ' AND master_table  IN (' . $intable . ')'
01171 //                .   ' AND foreign_table IN (' . $intable . ')';
01172 //        $result =  PMA_query_as_cu($sql);
01173 //
01174 // lem9:
01175 // previous logic was checking master tables and foreign tables
01176 // but I think that looping on every table of the pdf page as a master
01177 // and finding its foreigns is OK (then we can support innodb)
01178 
01179         $seen_a_relation = FALSE;
01180         foreach($alltables AS $one_table) {
01181 
01182             $exist_rel = PMA_getForeigners($db, $one_table, '', 'both');
01183             if ($exist_rel) {
01184                 $seen_a_relation = TRUE;
01185                 foreach($exist_rel AS $master_field => $rel) {
01186                     // put the foreign table on the schema only if selected
01187                     // by the user
01188                     // (do not use array_search() because we would have to
01189                     // to do a === FALSE and this is not PHP3 compatible)
01190 
01191                     if (PMA_isInto($rel['foreign_table'], $alltables)> -1) {
01192                         $this->PMA_RT_addRelation($one_table , $master_field, $rel['foreign_table'], $rel['foreign_field']);
01193                     }
01194 
01195                 } // end while
01196             } // end if
01197         } // end while
01198 
01199         // loic1: also show tables without relations
01200 //        $norelations     = TRUE;
01201 //        if ($result && mysql_num_rows($result) > 0) {
01202 //            $norelations = FALSE;
01203 //            while ($row = PMA_mysql_fetch_array($result)) {
01204 //                $this->PMA_RT_addRelation($row['master_table'] , $row['master_field'], $row['foreign_table'], $row['foreign_field']);
01205 //            }
01206 //        }
01207 
01208 
01209 //        if ($norelations == FALSE) {
01210         if ($seen_a_relation) {
01211             $this->PMA_RT_drawRelations($change_color);
01212         }
01213 
01214         $this->PMA_RT_drawTables($show_info,$change_color);
01215 
01216         $this->PMA_RT_showRt();
01217     } // end of the "PMA_RT()" method
01218 } // end of the "PMA_RT" class
01219 
01220 function PMA_RT_DOC($alltables ){
01221     global  $db, $pdf, $orientation;
01222     //TOC
01223     $pdf->addpage("P");
01224     $pdf->Cell(0,9, $GLOBALS['strTableOfContents'],1,0,'C');
01225     $pdf->Ln(15);
01226     $i = 1;
01227     foreach($alltables AS $table) {
01228         $pdf->PMA_links['doc'][$table]['-'] = $pdf->AddLink();
01229         $pdf->SetX(10);
01230         //$pdf->Ln(1);
01231         $pdf->Cell(0,6,$GLOBALS['strPageNumber'] . ' {'.sprintf("%02d", $i).'}',0,0,'R',0,$pdf->PMA_links['doc'][$table]['-']);
01232         $pdf->SetX(10);
01233         $pdf->Cell(0,6,$i.' '. $table,0,1,'L',0,$pdf->PMA_links['doc'][$table]['-']);
01234 
01235         //$pdf->Ln(1);
01236         $local_query = 'SHOW FIELDS FROM ' . PMA_backquote($table);
01237         $result      = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
01238         while ($row = PMA_mysql_fetch_array($result)) {
01239             $pdf->SetX(20);
01240             $field_name = $row['Field'];
01241             $pdf->PMA_links['doc'][$table][$field_name] =$pdf->AddLink();
01242             //$pdf->Cell(0,6,$field_name,0,1,'L',0,$pdf->PMA_links['doc'][$table][$field_name]);
01243         }
01244         $lasttable = $table;
01245         $i++;
01246     }
01247     $pdf->PMA_links['RT']['-'] =$pdf->AddLink();
01248     $pdf->SetX(10);
01249     $pdf->Cell(0,6,$GLOBALS['strPageNumber'] . ' {00}',0,0,'R',0,$pdf->PMA_links['doc'][$lasttable]['-']);
01250     $pdf->SetX(10);
01251     $pdf->Cell(0,6,$i.' '. $GLOBALS['strRelationalSchema'],0,1,'L',0,$pdf->PMA_links['RT']['-']);
01252     $z = 0;
01253     foreach($alltables AS $table) {
01254         $z++;
01255         $pdf->addpage($GLOBALS['orientation']);
01256         $pdf->Bookmark($table);
01257         $pdf->SetAlias('{'.sprintf("%02d", $z).'}', $pdf->PageNo()) ;
01258         $pdf->PMA_links['RT'][$table]['-'] =$pdf->AddLink();
01259         $pdf->SetLink($pdf->PMA_links['doc'][$table]['-'],-1);
01260         $pdf->SetFont('', 'B',18);
01261         $pdf->Cell(0,8, $z .' '.$table,1,1,'C',0,$pdf->PMA_links['RT'][$table]['-']);
01262         $pdf->SetFont('', '',8);
01263         $pdf->ln();
01264 
01265         $cfgRelation  = PMA_getRelationsParam();
01266         if ($cfgRelation['commwork']) {
01267             $comments = PMA_getComments($db, $table);
01268         }
01269         if ($cfgRelation['mimework']) {
01270             $mime_map = PMA_getMIME($db, $table, true);
01271         }
01272 
01276         $local_query  = "SHOW TABLE STATUS LIKE '" . PMA_sqlAddslashes($table, TRUE) . "'";
01277         $result       = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
01278         $showtable    = PMA_mysql_fetch_array($result);
01279         $num_rows     = (isset($showtable['Rows']) ? $showtable['Rows'] : 0);
01280         $show_comment = (isset($showtable['Comment']) ? $showtable['Comment'] : '');
01281         $create_time  = (isset($showtable['Create_time']) ? PMA_localisedDate(strtotime($showtable['Create_time'])) : '');
01282         $update_time  = (isset($showtable['Update_time']) ? PMA_localisedDate(strtotime($showtable['Update_time'])) : '');
01283         $check_time   = (isset($showtable['Check_time']) ? PMA_localisedDate(strtotime($showtable['Check_time'])) : '');
01284 
01285         if ($result) {
01286              mysql_free_result($result);
01287         }
01288 
01289 
01293         $local_query  = 'SHOW KEYS FROM ' . PMA_backquote($table);
01294         $result       = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
01295         $primary      = '';
01296         $indexes      = array();
01297         $lastIndex    = '';
01298         $indexes_info = array();
01299         $indexes_data = array();
01300         $pk_array     = array(); // will be use to emphasis prim. keys in the table
01301                                  // view
01302         while ($row = PMA_mysql_fetch_array($result)) {
01303             // Backups the list of primary keys
01304             if ($row['Key_name'] == 'PRIMARY') {
01305                 $primary   .= $row['Column_name'] . ', ';
01306                 $pk_array[$row['Column_name']] = 1;
01307             }
01308             // Retains keys informations
01309             if ($row['Key_name'] != $lastIndex ){
01310                 $indexes[] = $row['Key_name'];
01311                 $lastIndex = $row['Key_name'];
01312             }
01313             $indexes_info[$row['Key_name']]['Sequences'][]     = $row['Seq_in_index'];
01314             $indexes_info[$row['Key_name']]['Non_unique']      = $row['Non_unique'];
01315             if (isset($row['Cardinality'])) {
01316                 $indexes_info[$row['Key_name']]['Cardinality'] = $row['Cardinality'];
01317             }
01318             // I don't know what does following column mean....
01319             // $indexes_info[$row['Key_name']]['Packed']          = $row['Packed'];
01320             $indexes_info[$row['Key_name']]['Comment']         = $row['Comment'];
01321 
01322             $indexes_data[$row['Key_name']][$row['Seq_in_index']]['Column_name']  = $row['Column_name'];
01323             if (isset($row['Sub_part'])) {
01324                 $indexes_data[$row['Key_name']][$row['Seq_in_index']]['Sub_part'] = $row['Sub_part'];
01325             }
01326 
01327         } // end while
01328         if ($result) {
01329             mysql_free_result($result);
01330         }
01331 
01332 
01336         $local_query = 'SHOW FIELDS FROM ' . PMA_backquote($table);
01337         $result      = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
01338         $fields_cnt  = mysql_num_rows($result);
01339 
01340 
01341         // Check if we can use Relations (Mike Beck)
01342         if (!empty($cfgRelation['relation'])) {
01343             // Find which tables are related with the current one and write it in
01344             // an array
01345             $res_rel = PMA_getForeigners($db, $table);
01346 
01347             if (count($res_rel) > 0) {
01348                 $have_rel = TRUE;
01349             } else {
01350                 $have_rel = FALSE;
01351             }
01352         }
01353         else {
01354             $have_rel = FALSE;
01355         } // end if
01356 
01357 
01362         $break = false;
01363         if (!empty($show_comment)) {
01364             $pdf->Cell(0,3,$GLOBALS['strTableComments'] . ' : ' . $show_comment,0,1);
01365             $break = true;
01366         }
01367 
01368         if (!empty($create_time)) {
01369             $pdf->Cell(0,3,$GLOBALS['strStatCreateTime'] . ': ' . $create_time,0,1);
01370             $break = true;
01371         }
01372 
01373         if (!empty($update_time)) {
01374             $pdf->Cell(0,3,$GLOBALS['strStatUpdateTime'] . ': ' . $update_time,0,1);
01375             $break = true;
01376         }
01377 
01378         if (!empty($check_time)) {
01379             $pdf->Cell(0,3,$GLOBALS['strStatCheckTime'] . ': ' . $check_time,0,1);
01380             $break = true;
01381         }
01382 
01383         if ($break == true) {
01384             $pdf->Cell(0,3,'',0,1);
01385             $pdf->Ln();
01386         }
01387 
01388         $i = 0;
01389         $pdf->SetFont('', 'B');
01390         if (isset($orientation) && $orientation == 'L') {
01391             $pdf->Cell(25,8,ucfirst($GLOBALS['strField']),1,0,'C');
01392             $pdf->Cell(20,8,ucfirst($GLOBALS['strType']),1,0,'C');
01393             $pdf->Cell(20,8,ucfirst($GLOBALS['strAttr']),1,0,'C');
01394             $pdf->Cell(10,8,ucfirst($GLOBALS['strNull']),1,0,'C');
01395             $pdf->Cell(20,8,ucfirst($GLOBALS['strDefault']),1,0,'C');
01396             $pdf->Cell(25,8,ucfirst($GLOBALS['strExtra']),1,0,'C');
01397             $pdf->Cell(45,8,ucfirst($GLOBALS['strLinksTo']),1,0,'C');
01398             $pdf->Cell(67,8,ucfirst($GLOBALS['strComments']),1,0,'C');
01399             $pdf->Cell(45,8,'MIME',1,1,'C');
01400             $pdf->SetWidths(array(25,20,20,10,20,25,45,67,45));
01401         } else {
01402             $pdf->Cell(20,8,ucfirst($GLOBALS['strField']),1,0,'C');
01403             $pdf->Cell(20,8,ucfirst($GLOBALS['strType']),1,0,'C');
01404             $pdf->Cell(20,8,ucfirst($GLOBALS['strAttr']),1,0,'C');
01405             $pdf->Cell(10,8,ucfirst($GLOBALS['strNull']),1,0,'C');
01406             $pdf->Cell(15,8,ucfirst($GLOBALS['strDefault']),1,0,'C');
01407             $pdf->Cell(15,8,ucfirst($GLOBALS['strExtra']),1,0,'C');
01408             $pdf->Cell(30,8,ucfirst($GLOBALS['strLinksTo']),1,0,'C');
01409             $pdf->Cell(30,8,ucfirst($GLOBALS['strComments']),1,0,'C');
01410             $pdf->Cell(30,8,'MIME',1,1,'C');
01411             $pdf->SetWidths(array(20,20,20,10,15,15,30,30,30));
01412         }
01413         $pdf->SetFont('', '');
01414 
01415         while ($row = PMA_mysql_fetch_array($result)) {
01416             $bgcolor = ($i % 2) ?$GLOBALS['cfg']['BgcolorOne'] : $GLOBALS['cfg']['BgcolorTwo'];
01417             $i++;
01418 
01419             $type             = $row['Type'];
01420             // reformat mysql query output - staybyte - 9. June 2001
01421             // loic1: set or enum types: slashes single quotes inside options
01422             if (preg_match('@^(set|enum)\((.+)\)$@i', $type, $tmp)) {
01423                 $tmp[2]       = substr(preg_replace("@([^,])''@", "\\1\\'", ',' . $tmp[2]), 1);
01424                 $type         = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
01425                 $type_nowrap  = '';
01426 
01427                 $binary       = 0;
01428                 $unsigned     = 0;
01429                 $zerofill     = 0;
01430             } else {
01431                 $type_nowrap  = ' nowrap="nowrap"';
01432                 $type         = preg_replace('@BINARY@i', '', $type);
01433                 $type         = preg_replace('@ZEROFILL@i', '', $type);
01434                 $type         = preg_replace('@UNSIGNED@i', '', $type);
01435                 if (empty($type)) {
01436                     $type     = '&nbsp;';
01437                 }
01438 
01439                 $binary       = stristr($row['Type'], 'BINARY');
01440                 $unsigned     = stristr($row['Type'], 'UNSIGNED');
01441                 $zerofill     = stristr($row['Type'], 'ZEROFILL');
01442             }
01443             $strAttribute     = ' ';
01444             if ($binary) {
01445                 $strAttribute = 'BINARY';
01446             }
01447             if ($unsigned) {
01448                 $strAttribute = 'UNSIGNED';
01449             }
01450             if ($zerofill) {
01451                 $strAttribute = 'UNSIGNED ZEROFILL';
01452             }
01453             if (!isset($row['Default'])) {
01454                 if ($row['Null'] != '') {
01455                     $row['Default'] = 'NULL';
01456                 }
01457             }
01458             $field_name = $row['Field'];
01459             //$pdf->Ln();
01460             $pdf->PMA_links['RT'][$table][$field_name] =$pdf->AddLink();
01461             $pdf->Bookmark($field_name,1,-1);
01462             $pdf->SetLink($pdf->PMA_links['doc'][$table][$field_name],-1);
01463             $pdf_row = array($field_name ,
01464                             $type ,
01465                             $strAttribute ,
01466                             ($row['Null'] == '') ? $GLOBALS['strNo'] : $GLOBALS['strYes'],
01467                             ((isset($row['Default'])) ?  $row['Default'] : ''),
01468                             $row['Extra']  ,
01469                             ((isset($res_rel[$field_name])) ? $res_rel[$field_name]['foreign_table'] . ' -> ' . $res_rel[$field_name]['foreign_field'] : ''),
01470                             ((isset($comments[$field_name])) ? $comments[$field_name]  : '' ),
01471                             ((isset($mime_map) && isset($mime_map[$field_name])) ? str_replace('_', '/', $mime_map[$field_name]['mimetype'])  : '' )
01472                             );
01473             $links[0] = $pdf->PMA_links['RT'][$table][$field_name];
01474             if (isset($res_rel[$field_name]['foreign_table']) AND
01475                 isset($res_rel[$field_name]['foreign_field']) AND
01476                 isset($pdf->PMA_links['doc'][$res_rel[$field_name]['foreign_table']][$res_rel[$field_name]['foreign_field']])
01477               ) $links[6] = $pdf->PMA_links['doc'][$res_rel[$field_name]['foreign_table']][$res_rel[$field_name]['foreign_field']];
01478               else unset($links[6]);
01479             $pdf->Row($pdf_row, $links);
01480 
01481              /*$pdf->Cell(20,8,$field_name,1,0,'L',0,$pdf->PMA_links['RT'][$table][$field_name]);
01482                 //echo '    ' . $field_name . '&nbsp;' . "\n";
01483             }
01484         $pdf->Cell(20,8,$type,1,0,'L');
01485         $pdf->Cell(20,8,$strAttribute,1,0,'L');
01486         $pdf->Cell(15,8,,1,0,'L');
01487         $pdf->Cell(15,8,((isset($row['Default'])) ?  $row['Default'] : ''),1,0,'L');
01488         $pdf->Cell(15,8,$row['Extra'],1,0,'L');
01489            if ($have_rel) {
01490                 if (isset($res_rel[$field_name])) {
01491                     $pdf->Cell(30,8,$res_rel[$field_name]['foreign_table'] . ' -> ' . $res_rel[$field_name]['foreign_field'],1,0,'L');
01492                 }
01493             }
01494             if ($cfgRelation['commwork']) {
01495                 if (isset($comments[$field_name])) {
01496                     $pdf->Cell(0,8,$comments[$field_name],1,0,'L');
01497                 }
01498             } */
01499         } // end while
01500         $pdf->SetFont('', '',14);
01501         mysql_free_result($result);
01502     }//end each
01503 
01504 
01505 } // end function PMA_RT_DOC
01506 
01507 
01511 if (!isset($pdf_page_number)) {
01512     $pdf_page_number  = 1;
01513 }
01514 $show_grid            = (isset($show_grid) && $show_grid == 'on') ? 1 : 0;
01515 $show_color           = (isset($show_color) && $show_color == 'on') ? 1 : 0;
01516 $show_table_dimension = (isset($show_table_dimension) && $show_table_dimension == 'on') ? 1 : 0;
01517 $all_tab_same_wide    = (isset($all_tab_same_wide) && $all_tab_same_wide == 'on') ? 1 : 0;
01518 $with_doc             = (isset($with_doc) && $with_doc == 'on') ? 1 : 0;
01519 $orientation          = (isset($orientation) && $orientation == 'P') ? 'P' : 'L';
01520 $paper                = isset($paper) ? $paper : 'A4';
01521 PMA_mysql_select_db($db);
01522 
01523 $rt = new PMA_RT($pdf_page_number, $show_table_dimension, $show_color, $show_grid, $all_tab_same_wide, $orientation, $paper);
01524 ?>


Généré par Les spécialistes TYPO3 avec  doxygen 1.4.6