/**
  * The "PMA_Pdf_Relation_Schema" 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 PMA_Schema_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 Table_Stats_Pdf($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();
 }
 /**
  * The "PMA_EPS_Relation_Schema" constructor
  *
  * Upon instantiation This starts writing the EPS document
  * user will be prompted for download as .eps extension
  *
  * @see PMA_EPS
  */
 function __construct()
 {
     parent::__construct();
     global $eps;
     $this->setShowColor(isset($_REQUEST['eps_show_color']));
     $this->setShowKeys(isset($_REQUEST['eps_show_keys']));
     $this->setTableDimension(isset($_REQUEST['eps_show_table_dimension']));
     $this->setAllTablesSameWidth(isset($_REQUEST['eps_all_tables_same_width']));
     $this->setOrientation($_REQUEST['eps_orientation']);
     $eps = new PMA_EPS();
     $eps->setTitle(sprintf(__('Schema of the %s database - Page %s'), $GLOBALS['db'], $this->pageNumber));
     $eps->setAuthor('phpMyAdmin ' . PMA_VERSION);
     $eps->setDate(date("j F Y, g:i a"));
     $eps->setOrientation($this->orientation);
     $eps->setFont('Verdana', '10');
     $alltables = $this->getTablesFromRequest();
     foreach ($alltables as $table) {
         if (!isset($this->_tables[$table])) {
             $this->_tables[$table] = new Table_Stats_Eps($table, $eps->getFont(), $eps->getFontSize(), $this->pageNumber, $this->_tablewidth, $this->showKeys, $this->tableDimension, $this->offline);
         }
         if ($this->sameWide) {
             $this->_tables[$table]->width = $this->_tablewidth;
         }
     }
     $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, $eps->getFont(), $eps->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, $eps->getFont(), $eps->getFontSize(), $one_field, $one_key['ref_table_name'], $one_key['ref_index_list'][$index], $this->tableDimension);
                 }
             }
         }
     }
     if ($seen_a_relation) {
         $this->_drawRelations();
     }
     $this->_drawTables();
     $eps->endEpsDoc();
 }
Exemplo n.º 3
0
 /**
  * Displays an error on missing coordinates
  *
  * @return void
  */
 protected function showMissingCoordinatesError()
 {
     PMA_Export_Relation_Schema::dieSchema($this->pageNumber, "EPS", sprintf(__('Please configure the coordinates for table %s'), $this->tableName));
 }
 /**
  * Displays an error when the table cannot be found.
  *
  * @return void
  */
 protected function showMissingTableError()
 {
     PMA_Export_Relation_Schema::dieSchema($this->pageNumber, "DIA", sprintf(__('The %s table doesn\'t exist!'), $this->tableName));
 }
 /**
  * The "PMA_Svg_Relation_Schema" 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 PMA_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 Table_Stats_Svg($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();
 }
Exemplo n.º 6
0
 /**
  * get all the export options and verify
  * call and include the appropriate Schema Class depending on $export_type
  *
  * @return void
  * @access private
  */
 private function _processExportSchema()
 {
     /**
      * Settings for relation stuff
      */
     include_once './libraries/transformations.lib.php';
     include_once './libraries/Index.class.php';
     /**
      * default is PDF, otherwise validate it's only letters a-z
      */
     global $db, $export_type;
     if (!isset($export_type) || !preg_match('/^[a-zA-Z]+$/', $export_type)) {
         $export_type = 'pdf';
     }
     $GLOBALS['dbi']->selectDb($db);
     $path = PMA_securePath(ucfirst($export_type));
     $filename = 'libraries/schema/' . $path . '_Relation_Schema.class.php';
     if (!file_exists($filename)) {
         PMA_Export_Relation_Schema::dieSchema($_POST['chpage'], $export_type, __('File doesn\'t exist'));
     }
     $GLOBALS['skip_import'] = false;
     include $filename;
     if ($GLOBALS['skip_import']) {
         PMA_Export_Relation_Schema::dieSchema($_POST['chpage'], $export_type, __('Plugin is disabled'));
     }
     $class_name = 'PMA_' . $path . '_Relation_Schema';
     $obj_schema = new $class_name();
     $obj_schema->showOutput();
 }
 /**
  * Displays an error message
  *
  * @param string error_message the error mesage
  * @access public
  * @see PMA_Export_Relation_Schema::dieSchema
  */
 function Error($error_message = '')
 {
     PMA_Export_Relation_Schema::dieSchema($error_message);
 }
/**
 * Gets some core libraries
 */
require_once './libraries/common.inc.php';
require './libraries/StorageEngine.class.php';
/**
 * Include settings for relation stuff
 * get all variables needed for exporting relational schema
 * in $cfgRelation
 */
require_once './libraries/relation.lib.php';
$cfgRelation = PMA_getRelationsParam();
require_once './libraries/transformations.lib.php';
require_once './libraries/Index.class.php';
require_once "./libraries/schema/Export_Relation_Schema.class.php";
/**
 * get all the export options and verify
 * call and include the appropriate Schema Class depending on $export_type
 * default is PDF
 */
global $db, $export_type;
if (!isset($export_type) || !preg_match('/^[a-zA-Z]+$/', $export_type)) {
    $export_type = 'pdf';
}
PMA_DBI_select_db($db);
$path = PMA_securePath(ucfirst($export_type));
if (!file_exists('./libraries/schema/' . $path . '_Relation_Schema.class.php')) {
    PMA_Export_Relation_Schema::dieSchema($_POST['chpage'], $export_type, __('File doesn\'t exist'));
}
require "./libraries/schema/" . $path . "_Relation_Schema.class.php";
$obj_schema = eval("new PMA_" . $path . "_Relation_Schema();");
 /**
  * The "PMA_Dia_Relation_Schema" constructor
  *
  * Upon instantiation This outputs the Dia XML document
  * that user can download
  *
  * @param string $db database name
  *
  * @see PMA_DIA,Table_Stats_Dia,Relation_Stats_Dia
  */
 public function __construct($db)
 {
     parent::__construct($db, new PMA_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 Table_Stats_Dia($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();
 }