__construct() 공개 메소드

Constructor.
public __construct ( string $db, object $diagram )
$db string database name
$diagram object schema diagram
 /**
  * The "PMA\libraries\plugins\schema\svg\SvgRelationSchema" constructor
  *
  * Upon instantiation This starts writing the SVG XML document
  * user will be prompted for download as .svg extension
  *
  * @param string $db database name
  *
  * @see PMA_SVG
  */
 function __construct($db)
 {
     parent::__construct($db, new Svg());
     $this->setShowColor(isset($_REQUEST['svg_show_color']));
     $this->setShowKeys(isset($_REQUEST['svg_show_keys']));
     $this->setTableDimension(isset($_REQUEST['svg_show_table_dimension']));
     $this->setAllTablesSameWidth(isset($_REQUEST['svg_all_tables_same_width']));
     $this->diagram->setTitle(sprintf(__('Schema of the %s database - Page %s'), $this->db, $this->pageNumber));
     $this->diagram->SetAuthor('phpMyAdmin ' . PMA_VERSION);
     $this->diagram->setFont('Arial');
     $this->diagram->setFontSize('16px');
     $alltables = $this->getTablesFromRequest();
     foreach ($alltables as $table) {
         if (!isset($this->_tables[$table])) {
             $this->_tables[$table] = new TableStatsSvg($this->diagram, $this->db, $table, $this->diagram->getFont(), $this->diagram->getFontSize(), $this->pageNumber, $this->_tablewidth, $this->showKeys, $this->tableDimension, $this->offline);
         }
         if ($this->sameWide) {
             $this->_tables[$table]->width =& $this->_tablewidth;
         }
         $this->_setMinMax($this->_tables[$table]);
     }
     $border = 15;
     $this->diagram->startSvgDoc($this->_xMax + $border, $this->_yMax + $border, $this->_xMin - $border, $this->_yMin - $border);
     $seen_a_relation = false;
     foreach ($alltables as $one_table) {
         $exist_rel = PMA_getForeigners($this->db, $one_table, '', 'both');
         if (!$exist_rel) {
             continue;
         }
         $seen_a_relation = true;
         foreach ($exist_rel as $master_field => $rel) {
             /* put the foreign table on the schema only if selected
              * by the user
              * (do not use array_search() because we would have to
              * to do a === false and this is not PHP3 compatible)
              */
             if ($master_field != 'foreign_keys_data') {
                 if (in_array($rel['foreign_table'], $alltables)) {
                     $this->_addRelation($one_table, $this->diagram->getFont(), $this->diagram->getFontSize(), $master_field, $rel['foreign_table'], $rel['foreign_field'], $this->tableDimension);
                 }
                 continue;
             }
             foreach ($rel as $one_key) {
                 if (!in_array($one_key['ref_table_name'], $alltables)) {
                     continue;
                 }
                 foreach ($one_key['index_list'] as $index => $one_field) {
                     $this->_addRelation($one_table, $this->diagram->getFont(), $this->diagram->getFontSize(), $one_field, $one_key['ref_table_name'], $one_key['ref_index_list'][$index], $this->tableDimension);
                 }
             }
         }
     }
     if ($seen_a_relation) {
         $this->_drawRelations();
     }
     $this->_drawTables();
     $this->diagram->endSvgDoc();
 }
 /**
  * The "PMA\libraries\plugins\schema\dia\DiaRelationSchema" constructor
  *
  * Upon instantiation This outputs the Dia XML document
  * that user can download
  *
  * @param string $db database name
  *
  * @see Dia,TableStatsDia,RelationStatsDia
  */
 public function __construct($db)
 {
     parent::__construct($db, new Dia());
     $this->setShowColor(isset($_REQUEST['dia_show_color']));
     $this->setShowKeys(isset($_REQUEST['dia_show_keys']));
     $this->setOrientation($_REQUEST['dia_orientation']);
     $this->setPaper($_REQUEST['dia_paper']);
     $this->diagram->startDiaDoc($this->paper, $this->_topMargin, $this->_bottomMargin, $this->_leftMargin, $this->_rightMargin, $this->orientation);
     $alltables = $this->getTablesFromRequest();
     foreach ($alltables as $table) {
         if (!isset($this->tables[$table])) {
             $this->_tables[$table] = new TableStatsDia($this->diagram, $this->db, $table, $this->pageNumber, $this->showKeys, $this->offline);
         }
     }
     $seen_a_relation = false;
     foreach ($alltables as $one_table) {
         $exist_rel = PMA_getForeigners($this->db, $one_table, '', 'both');
         if (!$exist_rel) {
             continue;
         }
         $seen_a_relation = true;
         foreach ($exist_rel as $master_field => $rel) {
             /* put the foreign table on the schema only if selected
              * by the user
              * (do not use array_search() because we would have to
              * to do a === false and this is not PHP3 compatible)
              */
             if ($master_field != 'foreign_keys_data') {
                 if (in_array($rel['foreign_table'], $alltables)) {
                     $this->_addRelation($one_table, $master_field, $rel['foreign_table'], $rel['foreign_field'], $this->showKeys);
                 }
                 continue;
             }
             foreach ($rel as $one_key) {
                 if (!in_array($one_key['ref_table_name'], $alltables)) {
                     continue;
                 }
                 foreach ($one_key['index_list'] as $index => $one_field) {
                     $this->_addRelation($one_table, $one_field, $one_key['ref_table_name'], $one_key['ref_index_list'][$index], $this->showKeys);
                 }
             }
         }
     }
     $this->_drawTables();
     if ($seen_a_relation) {
         $this->_drawRelations();
     }
     $this->diagram->endDiaDoc();
 }
예제 #3
0
 /**
  * The "PdfRelationSchema" constructor
  *
  * @param string $db database name
  *
  * @see PMA_Schema_PDF
  */
 public function __construct($db)
 {
     $this->setShowGrid(isset($_REQUEST['pdf_show_grid']));
     $this->setShowColor(isset($_REQUEST['pdf_show_color']));
     $this->setShowKeys(isset($_REQUEST['pdf_show_keys']));
     $this->setTableDimension(isset($_REQUEST['pdf_show_table_dimension']));
     $this->setAllTablesSameWidth(isset($_REQUEST['pdf_all_tables_same_width']));
     $this->setWithDataDictionary(isset($_REQUEST['pdf_with_doc']));
     $this->setTableOrder($_REQUEST['pdf_table_order']);
     $this->setOrientation($_REQUEST['pdf_orientation']);
     $this->setPaper($_REQUEST['pdf_paper']);
     // Initializes a new document
     parent::__construct($db, new Pdf($this->orientation, 'mm', $this->paper, $this->pageNumber, $this->_withDoc, $db));
     $this->diagram->SetTitle(sprintf(__('Schema of the %s database'), $this->db));
     $this->diagram->setCMargin(0);
     $this->diagram->Open();
     $this->diagram->SetAutoPageBreak('auto');
     $this->diagram->setOffline($this->offline);
     $alltables = $this->getTablesFromRequest();
     if ($this->getTableOrder() == 'name_asc') {
         sort($alltables);
     } else {
         if ($this->getTableOrder() == 'name_desc') {
             rsort($alltables);
         }
     }
     if ($this->_withDoc) {
         $this->diagram->SetAutoPageBreak('auto', 15);
         $this->diagram->setCMargin(1);
         $this->dataDictionaryDoc($alltables);
         $this->diagram->SetAutoPageBreak('auto');
         $this->diagram->setCMargin(0);
     }
     $this->diagram->Addpage();
     if ($this->_withDoc) {
         $this->diagram->SetLink($this->diagram->PMA_links['RT']['-'], -1);
         $this->diagram->Bookmark(__('Relational schema'));
         $this->diagram->SetAlias('{00}', $this->diagram->PageNo());
         $this->_topMargin = 28;
         $this->_bottomMargin = 28;
     }
     /* snip */
     foreach ($alltables as $table) {
         if (!isset($this->_tables[$table])) {
             $this->_tables[$table] = new TableStatsPdf($this->diagram, $this->db, $table, null, $this->pageNumber, $this->_tablewidth, $this->showKeys, $this->tableDimension, $this->offline);
         }
         if ($this->sameWide) {
             $this->_tables[$table]->width = $this->_tablewidth;
         }
         $this->_setMinMax($this->_tables[$table]);
     }
     // Defines the scale factor
     $innerWidth = $this->diagram->getPageWidth() - $this->_rightMargin - $this->_leftMargin;
     $innerHeight = $this->diagram->getPageHeight() - $this->_topMargin - $this->_bottomMargin;
     $this->_scale = ceil(max(($this->_xMax - $this->_xMin) / $innerWidth, ($this->_yMax - $this->_yMin) / $innerHeight) * 100) / 100;
     $this->diagram->setScale($this->_scale, $this->_xMin, $this->_yMin, $this->_leftMargin, $this->_topMargin);
     // Builds and save the PDF document
     $this->diagram->setLineWidthScale(0.1);
     if ($this->_showGrid) {
         $this->diagram->SetFontSize(10);
         $this->_strokeGrid();
     }
     $this->diagram->setFontSizeScale(14);
     // previous logic was checking master tables and foreign tables
     // but I think that looping on every table of the pdf page as a master
     // and finding its foreigns is OK (then we can support innodb)
     $seen_a_relation = false;
     foreach ($alltables as $one_table) {
         $exist_rel = PMA_getForeigners($this->db, $one_table, '', 'both');
         if (!$exist_rel) {
             continue;
         }
         $seen_a_relation = true;
         foreach ($exist_rel as $master_field => $rel) {
             // put the foreign table on the schema only if selected
             // by the user
             // (do not use array_search() because we would have to
             // to do a === false and this is not PHP3 compatible)
             if ($master_field != 'foreign_keys_data') {
                 if (in_array($rel['foreign_table'], $alltables)) {
                     $this->_addRelation($one_table, $master_field, $rel['foreign_table'], $rel['foreign_field']);
                 }
                 continue;
             }
             foreach ($rel as $one_key) {
                 if (!in_array($one_key['ref_table_name'], $alltables)) {
                     continue;
                 }
                 foreach ($one_key['index_list'] as $index => $one_field) {
                     $this->_addRelation($one_table, $one_field, $one_key['ref_table_name'], $one_key['ref_index_list'][$index]);
                 }
             }
         }
         // end while
     }
     // end while
     if ($seen_a_relation) {
         $this->_drawRelations();
     }
     $this->_drawTables();
 }