Cleanup globals

Signed-off-by: Bimal Yashodha <kb.yashodha@gmail.com>
This commit is contained in:
Bimal Yashodha 2014-08-09 22:49:38 +05:30
parent 16e28773d3
commit 7259665f94
11 changed files with 54 additions and 77 deletions

View File

@ -202,17 +202,12 @@ class PMA_Export_Relation_Schema
* @param string $type Schema Type
* @param string $error_message The error mesage
*
* @global array the PMA configuration array
* @global string $db the current database name
*
* @access public
*
* @return void
*/
function dieSchema($pageNumber, $type = '', $error_message = '')
{
global $db;
echo "<p><strong>" . __("SCHEMA ERROR: ") . $type . "</strong></p>" . "\n";
if (!empty($error_message)) {
$error_message = htmlspecialchars($error_message);
@ -220,7 +215,7 @@ class PMA_Export_Relation_Schema
echo '<p>' . "\n";
echo ' ' . $error_message . "\n";
echo '</p>' . "\n";
echo '<a href="schema_edit.php?' . PMA_URL_getCommon($db)
echo '<a href="schema_edit.php?' . PMA_URL_getCommon($GLOBALS['db'])
. '&do=selectpage&chpage=' . htmlspecialchars($pageNumber)
. '&action_choose=0'
. '">' . __('Back') . '</a>';

View File

@ -122,8 +122,6 @@ abstract class TableStats
*/
protected function loadCoordinates()
{
global $cfgRelation;
if ($this->offline) {
$tbl_coords = json_decode($_REQUEST['tbl_coords']);
foreach ($tbl_coords as $tbl) {
@ -136,7 +134,7 @@ abstract class TableStats
} else {
$sql = "SELECT x, y FROM "
. PMA_Util::backquote($GLOBALS['cfgRelation']['db']) . "."
. PMA_Util::backquote($cfgRelation['table_coords'])
. PMA_Util::backquote($GLOBALS['cfgRelation']['table_coords'])
. " WHERE db_name = '" . PMA_Util::sqlAddSlashes($this->db) . "'"
. " AND table_name = '" . PMA_Util::sqlAddSlashes($this->tableName) . "'"
. " AND pdf_page_number = " . $this->pageNumber;

View File

@ -222,7 +222,7 @@ class PMA_Dia_Relation_Schema extends PMA_Export_Relation_Schema
{
parent::__construct();
global $dia, $db;
global $dia;
$this->setShowColor(isset($_REQUEST['dia_show_color']));
$this->setShowKeys(isset($_REQUEST['dia_show_keys']));
@ -242,7 +242,7 @@ class PMA_Dia_Relation_Schema extends PMA_Export_Relation_Schema
$alltables[] = $tbl->table_name;
}
} else {
$alltables = $this->getAllTables($db, $this->pageNumber);
$alltables = $this->getAllTables($GLOBALS['db'], $this->pageNumber);
}
foreach ($alltables as $table) {
@ -302,8 +302,8 @@ class PMA_Dia_Relation_Schema extends PMA_Export_Relation_Schema
*/
function showOutput()
{
global $dia, $db;
$filename = $db . '-' . $this->pageNumber;
global $dia;
$filename = $GLOBALS['db'] . '-' . $this->pageNumber;
if ($this->isOffline()) {
$filename = __("Dia export page");
}

View File

@ -36,17 +36,15 @@ class Table_Stats_Dia extends TableStats
* @param boolean $offline Whether the coordinates are sent from the browser
*
* @global object $dia The current dia document
* @global array $cfgRelation The relations settings
* @global string $db The current db name
*
* @see PMA_DIA
*/
function __construct(
$tableName, $pageNumber, $showKeys = false, $offline = false
) {
global $dia, $cfgRelation, $db;
global $dia;
parent::__construct(
$dia, $db, $pageNumber, $tableName, $showKeys, false, $offline
$dia, $GLOBALS['db'], $pageNumber, $tableName, $showKeys, false, $offline
);
/**

View File

@ -330,7 +330,7 @@ class PMA_Eps_Relation_Schema extends PMA_Export_Relation_Schema
{
parent::__construct();
global $eps,$db;
global $eps;
$this->setShowColor(isset($_REQUEST['eps_show_color']));
$this->setShowKeys(isset($_REQUEST['eps_show_keys']));
@ -342,7 +342,7 @@ class PMA_Eps_Relation_Schema extends PMA_Export_Relation_Schema
$eps->setTitle(
sprintf(
__('Schema of the %s database - Page %s'),
$db,
$GLOBALS['db'],
$this->pageNumber
)
);
@ -358,7 +358,7 @@ class PMA_Eps_Relation_Schema extends PMA_Export_Relation_Schema
$alltables[] = $tbl->table_name;
}
} else {
$alltables = $this->getAllTables($db, $this->pageNumber);
$alltables = $this->getAllTables($GLOBALS['db'], $this->pageNumber);
}
foreach ($alltables as $table) {
@ -377,7 +377,7 @@ class PMA_Eps_Relation_Schema extends PMA_Export_Relation_Schema
$seen_a_relation = false;
foreach ($alltables as $one_table) {
$exist_rel = PMA_getForeigners($db, $one_table, '', 'both');
$exist_rel = PMA_getForeigners($GLOBALS['db'], $one_table, '', 'both');
if ($exist_rel) {
$seen_a_relation = true;
foreach ($exist_rel as $master_field => $rel) {
@ -430,8 +430,8 @@ class PMA_Eps_Relation_Schema extends PMA_Export_Relation_Schema
*/
function showOutput()
{
global $eps,$db;
$filename = $db . '-' . $this->pageNumber;
global $eps;
$filename = $GLOBALS['db'] . '-' . $this->pageNumber;
if ($this->isOffline()) {
$filename = __("EPS export page");
}

View File

@ -43,10 +43,6 @@ class Table_Stats_Eps extends TableStats
* from the browser
*
* @global object $eps The current eps document
* @global integer The current page number (from the
* $cfg['Servers'][$i]['table_coords'] table)
* @global array $cfgRelation The relations settings
* @global string $db The current db name
*
* @access private
* @see PMA_EPS, Table_Stats_Eps::Table_Stats_setWidth,
@ -56,9 +52,9 @@ class Table_Stats_Eps extends TableStats
$tableName, $font, $fontSize, $pageNumber, &$same_wide_width,
$showKeys = false, $tableDimension = false, $offline = false
) {
global $eps, $cfgRelation, $db;
global $eps;
parent::__construct(
$eps, $db, $pageNumber, $tableName, $showKeys, $tableDimension, $offline
$eps, $GLOBALS['db'], $pageNumber, $tableName, $showKeys, $tableDimension, $offline
);
// height and width
@ -108,8 +104,6 @@ class Table_Stats_Eps extends TableStats
* @param string $font The font name
* @param integer $fontSize The font size
*
* @global object $eps The current eps document
*
* @return void
*
* @access private

View File

@ -54,22 +54,25 @@ class PMA_Schema_PDF extends PMA_PDF
private $_ff = PMA_PDF_FONT;
private $_offline;
private $_exportingPage;
private $_withDoc;
/**
* Constructs PDF for schema export.
*
* @param string $orientation page orientation
* @param string $unit unit
* @param string $format the format used for pages
* @param int $exportingPage schema page number that is being exported
* @param string $orientation page orientation
* @param string $unit unit
* @param string $paper the format used for pages
* @param int $exportingPage schema page number that is being exported
* @param boolean $withDoc with document dictionary
*
* @access public
*/
public function __construct(
$orientation, $unit, $format, $exportingPage
$orientation, $unit, $paper, $exportingPage, $withDoc
) {
parent::__construct($orientation, $unit, $format);
parent::__construct($orientation, $unit, $paper);
$this->_exportingPage = $exportingPage;
$this->_withDoc = $withDoc;
}
/**
@ -243,15 +246,14 @@ class PMA_Schema_PDF extends PMA_PDF
// We only show this if we find something in the new pdf_pages table
// This function must be named "Header" to work with the TCPDF library
global $cfgRelation, $db, $pdf_with_doc;
if ($pdf_with_doc) {
if ($this->_withDoc) {
if ($this->_offline) {
$pg_name = __("PDF export page");
} else {
$test_query = 'SELECT * FROM '
. PMA_Util::backquote($GLOBALS['cfgRelation']['db']) . '.'
. PMA_Util::backquote($GLOBALS['cfgRelation']['pdf_pages'])
. ' WHERE db_name = \'' . PMA_Util::sqlAddSlashes($db) . '\''
. ' WHERE db_name = \'' . PMA_Util::sqlAddSlashes($GLOBALS['db']) . '\''
. ' AND page_nr = \'' . $this->_exportingPage . '\'';
$test_rs = PMA_queryAsControlUser($test_query);
$pages = @$GLOBALS['dbi']->fetchAssoc($test_rs);
@ -274,8 +276,7 @@ class PMA_Schema_PDF extends PMA_PDF
*/
function Footer()
{
global $pdf_with_doc;
if ($pdf_with_doc) {
if ($this->_withDoc) {
parent::Footer();
}
}
@ -444,7 +445,6 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
* The "PMA_Pdf_Relation_Schema" constructor
*
* @global object $pdf The current PDF Schema document
* @global string $db The current db name
* @access private
* @see PMA_Schema_PDF
*/
@ -452,7 +452,7 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
{
parent::__construct();
global $pdf, $db;
global $pdf;
$this->setShowGrid(isset($_REQUEST['pdf_show_grid']));
$this->setShowColor(isset($_REQUEST['pdf_show_color']));
@ -465,7 +465,8 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
// Initializes a new document
$pdf = new PMA_Schema_PDF(
$this->orientation, 'mm', $this->paper, intval($_REQUEST['chpage'])
$this->orientation, 'mm', $this->paper,
intval($_REQUEST['chpage']), $this->_withDoc
);
$pdf->SetTitle(
sprintf(
@ -485,7 +486,7 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
$alltables[] = $tbl->table_name;
}
} else {
$alltables = $this->getAllTables($db, $this->pageNumber);
$alltables = $this->getAllTables($GLOBALS['db'], $this->pageNumber);
}
if ($this->_withDoc) {
@ -555,7 +556,7 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
// and finding its foreigns is OK (then we can support innodb)
$seen_a_relation = false;
foreach ($alltables as $one_table) {
$exist_rel = PMA_getForeigners($db, $one_table, '', 'both');
$exist_rel = PMA_getForeigners($GLOBALS['db'], $one_table, '', 'both');
if ($exist_rel) {
$seen_a_relation = true;
foreach ($exist_rel as $master_field => $rel) {
@ -811,10 +812,7 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
*
* @param integer $pageNumber page number
*
* @global object $pdf The current PDF document
* @global string $cfgRelation The current database name
* @global integer The current page number (from the
* $cfg['Servers'][$i]['table_coords'] table)
* @global object $pdf The current PDF document
* @access private
*
* @return void
@ -858,7 +856,7 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
*/
public function dataDictionaryDoc($alltables)
{
global $db, $pdf, $pdf_orientation, $pdf_paper;
global $pdf;
// TOC
$pdf->addpage($this->orientation);
$pdf->Cell(0, 9, __('Table of contents'), 1, 0, 'C');
@ -919,15 +917,15 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
$pdf->ln();
$cfgRelation = PMA_getRelationsParam();
$comments = PMA_getComments($db, $table);
$comments = PMA_getComments($GLOBALS['db'], $table);
if ($cfgRelation['mimework']) {
$mime_map = PMA_getMIME($db, $table, true);
$mime_map = PMA_getMIME($GLOBALS['db'], $table, true);
}
/**
* Gets table informations
*/
$showtable = PMA_Table::sGetStatusInfo($db, $table);
$showtable = PMA_Table::sGetStatusInfo($GLOBALS['db'], $table);
$show_comment = isset($showtable['Comment'])
? $showtable['Comment']
: '';
@ -996,12 +994,12 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
/**
* Gets fields properties
*/
$columns = $GLOBALS['dbi']->getColumns($db, $table);
$columns = $GLOBALS['dbi']->getColumns($GLOBALS['db'], $table);
// Check if we can use Relations
if (!empty($cfgRelation['relation'])) {
// Find which tables are related with the current one and write it in
// an array
$res_rel = PMA_getForeigners($db, $table);
$res_rel = PMA_getForeigners($GLOBALS['db'], $table);
} // end if
/**
@ -1035,7 +1033,7 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
}
$pdf->SetFont($this->_ff, 'B');
if (isset($pdf_orientation) && $pdf_orientation == 'L') {
if (isset($this->orientation) && $this->orientation == 'L') {
$pdf->Cell(25, 8, __('Column'), 1, 0, 'C');
$pdf->Cell(20, 8, __('Type'), 1, 0, 'C');
$pdf->Cell(20, 8, __('Attributes'), 1, 0, 'C');
@ -1044,7 +1042,7 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
$pdf->Cell(25, 8, __('Extra'), 1, 0, 'C');
$pdf->Cell(45, 8, __('Links to'), 1, 0, 'C');
if ($pdf_paper == 'A4') {
if ($this->paper == 'A4') {
$comments_width = 67;
} else {
// this is really intended for 'letter'

View File

@ -44,8 +44,6 @@ class Table_Stats_Pdf extends TableStats
* from the browser
*
* @global object $pdf The current PDF document
* @global array $cfgRelation The relations settings
* @global string $db The current db name
*
* @see PMA_Schema_PDF, Table_Stats_Pdf::Table_Stats_setWidth,
* Table_Stats_Pdf::Table_Stats_setHeight
@ -53,9 +51,10 @@ class Table_Stats_Pdf extends TableStats
function __construct($tableName, $fontSize, $pageNumber, &$sameWideWidth,
$showKeys = false, $tableDimension = false, $offline = false
) {
global $pdf, $cfgRelation, $db;
global $pdf;
parent::__construct(
$pdf, $db, $pageNumber, $tableName, $showKeys, $tableDimension, $offline
$pdf, $GLOBALS['db'], $pageNumber, $tableName,
$showKeys, $tableDimension, $offline
);
$this->heightCell = 6;

View File

@ -303,7 +303,7 @@ class PMA_Svg_Relation_Schema extends PMA_Export_Relation_Schema
{
parent::__construct();
global $svg, $db;
global $svg;
$this->setShowColor(isset($_REQUEST['svg_show_color']));
$this->setShowKeys(isset($_REQUEST['svg_show_keys']));
@ -314,7 +314,7 @@ class PMA_Svg_Relation_Schema extends PMA_Export_Relation_Schema
$svg->setTitle(
sprintf(
__('Schema of the %s database - Page %s'),
$db,
$GLOBALS['db'],
$this->pageNumber
)
);
@ -330,7 +330,7 @@ class PMA_Svg_Relation_Schema extends PMA_Export_Relation_Schema
$alltables[] = $tbl->table_name;
}
} else {
$alltables = $this->getAllTables($db, $this->pageNumber);
$alltables = $this->getAllTables($GLOBALS['db'], $this->pageNumber);
}
foreach ($alltables as $table) {
@ -349,7 +349,7 @@ class PMA_Svg_Relation_Schema extends PMA_Export_Relation_Schema
}
$seen_a_relation = false;
foreach ($alltables as $one_table) {
$exist_rel = PMA_getForeigners($db, $one_table, '', 'both');
$exist_rel = PMA_getForeigners($GLOBALS['db'], $one_table, '', 'both');
if ($exist_rel) {
$seen_a_relation = true;
foreach ($exist_rel as $master_field => $rel) {
@ -402,8 +402,8 @@ class PMA_Svg_Relation_Schema extends PMA_Export_Relation_Schema
*/
function showOutput()
{
global $svg, $db;
$filename = $db . '-' . $this->pageNumber;
global $svg;
$filename = $GLOBALS['db'] . '-' . $this->pageNumber;
if ($this->isOffline()) {
$filename = __("SVG export page");
}

View File

@ -43,8 +43,6 @@ class Table_Stats_Svg extends TableStats
* from the browser
*
* @global object $svg The current SVG image document
* @global array $cfgRelation The relations settings
* @global string $db The current db name
*
* @access private
*
@ -55,9 +53,9 @@ class Table_Stats_Svg extends TableStats
$tableName, $font, $fontSize, $pageNumber, &$same_wide_width,
$showKeys = false, $tableDimension = false, $offline = false
) {
global $svg, $cfgRelation, $db;
global $svg;
parent::__construct(
$svg, $db, $pageNumber, $tableName, $showKeys, $tableDimension, $offline
$svg, $GLOBALS['db'], $pageNumber, $tableName, $showKeys, $tableDimension, $offline
);
// height and width

View File

@ -29,10 +29,7 @@ require_once 'libraries/plugin_interface.lib.php';
*/
$post_params = array(
'db',
'pdf_with_doc',
'pdf_orientation',
'pdf_paper'
'db'
);
foreach ($post_params as $one_post_param) {
if (isset($_REQUEST[$one_post_param])) {