/**
  * The "PMA_Dia_Relation_Schema" constructor
  *
  * Upon instantiation This outputs the Dia XML document
  * that user can download
  *
  * @see PMA_DIA,Table_Stats_Dia,Relation_Stats_Dia
  */
 function __construct()
 {
     global $dia, $db;
     $this->setPageNumber($_POST['pdf_page_number']);
     $this->setShowGrid(isset($_POST['show_grid']));
     $this->setShowColor($_POST['show_color']);
     $this->setShowKeys(isset($_POST['show_keys']));
     $this->setOrientation(isset($_POST['orientation']));
     $this->setPaper($_POST['paper']);
     $this->setExportType($_POST['export_type']);
     $dia = new PMA_DIA();
     $dia->startDiaDoc($this->paper, $this->_topMargin, $this->_bottomMargin, $this->_leftMargin, $this->_rightMargin, $this->orientation);
     $alltables = $this->getAllTables($db, $this->pageNumber);
     foreach ($alltables as $table) {
         if (!isset($this->tables[$table])) {
             $this->_tables[$table] = new Table_Stats_Dia($table, $this->pageNumber, $this->showKeys);
         }
     }
     $seen_a_relation = false;
     foreach ($alltables as $one_table) {
         $exist_rel = PMA_getForeigners($db, $one_table, '', 'both');
         if ($exist_rel) {
             $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 (in_array($rel['foreign_table'], $alltables)) {
                     $this->_addRelation($one_table, $master_field, $rel['foreign_table'], $rel['foreign_field'], $this->showKeys);
                 }
             }
         }
     }
     $this->_drawTables($this->showColor);
     if ($seen_a_relation) {
         $this->_drawRelations($this->showColor);
     }
     $dia->endDiaDoc();
 }
 /**
  * The "PMA_Dia_Relation_Schema" constructor
  *
  * Upon instantiation This outputs the Dia XML document
  * that user can download
  *
  * @see PMA_DIA,Table_Stats_Dia,Relation_Stats_Dia
  */
 function __construct()
 {
     parent::__construct();
     global $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']);
     $dia = new PMA_DIA();
     $dia->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 Table_Stats_Dia($table, $this->pageNumber, $this->showKeys, $this->offline);
         }
     }
     $seen_a_relation = false;
     foreach ($alltables as $one_table) {
         $exist_rel = PMA_getForeigners($GLOBALS['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();
     }
     $dia->endDiaDoc();
 }