Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/HuasoFoundries/phpPgAdmin6.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/classes/ContainerUtils.php36
-rw-r--r--src/classes/Translations.php11
-rw-r--r--src/controllers/AlldbController.php59
-rw-r--r--src/controllers/DatabaseController.php112
-rw-r--r--src/controllers/DataexportController.php12
-rw-r--r--src/controllers/DbexportController.php26
-rw-r--r--src/controllers/DisplayController.php181
-rw-r--r--src/controllers/IndexesController.php116
-rw-r--r--src/controllers/MaterializedviewsController.php30
-rw-r--r--src/controllers/RulesController.php8
-rw-r--r--src/controllers/SchemasController.php67
-rw-r--r--src/controllers/TblpropertiesController.php36
-rw-r--r--src/traits/ExportTrait.php46
-rw-r--r--src/traits/ViewsAndMaterializedViewsTrait.php2
14 files changed, 356 insertions, 386 deletions
diff --git a/src/classes/ContainerUtils.php b/src/classes/ContainerUtils.php
index 4f1283ff..ce50c4f5 100644
--- a/src/classes/ContainerUtils.php
+++ b/src/classes/ContainerUtils.php
@@ -22,25 +22,44 @@ class ContainerUtils
protected $container;
+ /**
+ * Constructor of the ContainerUtils class
+ *
+ * @param \Slim\Container $container The app container
+ */
public function __construct($container)
{
$this->container = $container;
}
- public function getRedirectUrl($subject = '')
+ /**
+ * Determines the redirection url according to query string
+ *
+ * @return string The redirect url.
+ */
+ public function getRedirectUrl()
{
$query_string = $this->container->requestobj->getUri()->getQuery();
- // but if server_id isn't set, then you will be redirected to intro
+ // if server_id isn't set, then you will be redirected to intro
if ($this->container->requestobj->getQueryParam('server') === null) {
- $destinationurl = \SUBFOLDER.'/src/views/intro';
+ $destinationurl = \SUBFOLDER . '/src/views/intro';
} else {
- $destinationurl = \SUBFOLDER.'/src/views/login'.($query_string ? '?'.$query_string : '');
+ // otherwise, you'll be redirected to the login page for that server;
+ $destinationurl = \SUBFOLDER . '/src/views/login' . ($query_string ? '?' . $query_string : '');
}
return $destinationurl;
}
+ /**
+ * Gets the destination with the last active tab selected for that controller
+ * Usually used after going through a redirect route.
+ *
+ * @param string $subject The subject, usually a view name like 'server' or 'table'
+ *
+ * @return string The destination url with last tab set in the query string
+ */
public function getDestinationWithLastTab($subject)
{
$_server_info = $this->container->misc->getServerInfo();
@@ -51,7 +70,7 @@ class ContainerUtils
$destinationurl = $this->getRedirectUrl();
} else {
$url = $this->container->misc->getLastTabURL($subject);
- $this->addFlash($url, 'getLastTabURL for '.$subject);
+ $this->addFlash($url, 'getLastTabURL for ' . $subject);
// Load query vars into superglobal arrays
if (isset($url['urlvars'])) {
$urlvars = [];
@@ -71,6 +90,13 @@ class ContainerUtils
return $destinationurl;
}
+ /**
+ * Adds an error to the errors array property of the container
+ *
+ * @param string $errormsg The error msg
+ *
+ * @return \Slim\Container The app container
+ */
public function addError($errormsg)
{
$errors = $this->container->get('errors');
diff --git a/src/classes/Translations.php b/src/classes/Translations.php
index 8ecd1fbc..ca57cf5a 100644
--- a/src/classes/Translations.php
+++ b/src/classes/Translations.php
@@ -164,11 +164,10 @@ class Translations
public function __construct($container)
{
- $availableLanguages = $this->availableLanguages;
- $appLangFiles = $this->appLangFiles;
- $appClasses = $this->appClasses;
- $_language = $this->_language;
- $conf = $container->conf;
+ $appLangFiles = $this->appLangFiles;
+ $appClasses = $this->appClasses;
+ $_language = $this->_language;
+ $conf = $container->conf;
$languages_iso_code = $this->languages_iso_code;
@@ -200,7 +199,7 @@ class Translations
$_language = 'english';
}
- $_type = '\PHPPgAdmin\Translations\\'.$appClasses[$_language];
+ $_type = '\PHPPgAdmin\Translations\\' . $appClasses[$_language];
$langClass = new $_type();
diff --git a/src/controllers/AlldbController.php b/src/controllers/AlldbController.php
index 66261fcd..aa6cb520 100644
--- a/src/controllers/AlldbController.php
+++ b/src/controllers/AlldbController.php
@@ -15,6 +15,7 @@ use PHPPgAdmin\Decorators\Decorator;
*/
class AlldbController extends BaseController
{
+ use \PHPPgAdmin\Traits\ExportTrait;
public $table_place = 'alldb-databases';
public $controller_title = 'strdatabases';
@@ -108,7 +109,7 @@ class AlldbController extends BaseController
'database' => [
'title' => $this->lang['strdatabase'],
'field' => Decorator::field('datname'),
- 'url' => \SUBFOLDER."/redirect/database?{$href}&",
+ 'url' => \SUBFOLDER . "/redirect/database?{$href}&",
'vars' => ['database' => 'datname'],
],
'owner' => [
@@ -262,7 +263,7 @@ class AlldbController extends BaseController
$this->printTrail('database');
$this->printTitle($this->lang['stralter'], 'pg.database.alter');
- echo '<form action="'.\SUBFOLDER."/src/views/alldb\" method=\"post\">\n";
+ echo '<form action="' . \SUBFOLDER . "/src/views/alldb\" method=\"post\">\n";
echo "<table>\n";
echo "<tr><th class=\"data left required\">{$this->lang['strname']}</th>\n";
echo '<td class="data1">';
@@ -333,7 +334,7 @@ class AlldbController extends BaseController
$this->printTrail('database');
$this->printTitle($this->lang['strdrop'], 'pg.database.drop');
- echo '<form action="'.\SUBFOLDER."/src/views/alldb\" method=\"post\">\n";
+ echo '<form action="' . \SUBFOLDER . "/src/views/alldb\" method=\"post\">\n";
//If multi drop
if (isset($_REQUEST['ma'])) {
foreach ($_REQUEST['ma'] as $v) {
@@ -416,7 +417,7 @@ class AlldbController extends BaseController
$tablespaces = $data->getTablespaces();
}
- echo '<form action="'.\SUBFOLDER."/src/views/alldb\" method=\"post\">\n";
+ echo '<form action="' . \SUBFOLDER . "/src/views/alldb\" method=\"post\">\n";
echo "<table>\n";
echo "\t<tr>\n\t\t<th class=\"data left required\">{$this->lang['strname']}</th>\n";
echo "\t\t<td class=\"data1\"><input name=\"formName\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" value=\"",
@@ -558,41 +559,23 @@ class AlldbController extends BaseController
$this->printTabs('server', 'export');
$this->printMsg($msg);
- echo '<form action="'.\SUBFOLDER."/src/views/dbexport\" method=\"post\">\n";
- echo "<table>\n";
- echo "<tr><th class=\"data\">{$this->lang['strformat']}</th><th class=\"data\">{$this->lang['stroptions']}</th></tr>\n";
- // Data only
- echo '<tr><th class="data left" rowspan="2">';
- echo "<input type=\"radio\" id=\"what1\" name=\"what\" value=\"dataonly\" checked=\"checked\" /><label for=\"what1\">{$this->lang['strdataonly']}</label></th>\n";
- echo "<td>{$this->lang['strformat']}\n";
- echo "<select name=\"d_format\">\n";
- echo "<option value=\"copy\">COPY</option>\n";
- echo "<option value=\"sql\">SQL</option>\n";
- echo "</select>\n</td>\n</tr>\n";
- echo "<tr><td><input type=\"checkbox\" id=\"d_oids\" name=\"d_oids\" /><label for=\"d_oids\">{$this->lang['stroids']}</label></td>\n</tr>\n";
- // Structure only
- echo "<tr><th class=\"data left\"><input type=\"radio\" id=\"what2\" name=\"what\" value=\"structureonly\" /><label for=\"what2\">{$this->lang['strstructureonly']}</label></th>\n";
- echo "<td><input type=\"checkbox\" id=\"s_clean\" name=\"s_clean\" /><label for=\"s_clean\">{$this->lang['strdrop']}</label></td>\n</tr>\n";
- // Structure and data
- echo '<tr><th class="data left" rowspan="3">';
- echo "<input type=\"radio\" id=\"what3\" name=\"what\" value=\"structureanddata\" /><label for=\"what3\">{$this->lang['strstructureanddata']}</label></th>\n";
- echo "<td>{$this->lang['strformat']}\n";
- echo "<select name=\"sd_format\">\n";
- echo "<option value=\"copy\">COPY</option>\n";
- echo "<option value=\"sql\">SQL</option>\n";
- echo "</select>\n</td>\n</tr>\n";
- echo "<tr><td><input type=\"checkbox\" id=\"sd_clean\" name=\"sd_clean\" /><label for=\"sd_clean\">{$this->lang['strdrop']}</label></td>\n</tr>\n";
- echo "<tr><td><input type=\"checkbox\" id=\"sd_oids\" name=\"sd_oids\" /><label for=\"sd_oids\">{$this->lang['stroids']}</label></td>\n</tr>\n";
- echo "</table>\n";
+ $subject = 'server';
+ $object = $_REQUEST['server'];
- echo "<h3>{$this->lang['stroptions']}</h3>\n";
- echo "<p><input type=\"radio\" id=\"output1\" name=\"output\" value=\"show\" checked=\"checked\" /><label for=\"output1\">{$this->lang['strshow']}</label>\n";
- echo "<br/><input type=\"radio\" id=\"output2\" name=\"output\" value=\"download\" /><label for=\"output2\">{$this->lang['strdownload']}</label></p>\n";
+ $this->prtrace($this->misc->getServerInfo());
+
+ echo $this->formHeader('dbexport');
+
+ echo $this->dataOnly(true, true);
+
+ echo $this->structureOnly();
+
+ echo $this->structureAndData(true);
+
+ // dumpall doesn't support gzip
+ echo $this->displayOrDownload(false);
+
+ echo $this->formFooter($subject, $object);
- echo "<p><input type=\"hidden\" name=\"action\" value=\"export\" />\n";
- echo "<input type=\"hidden\" name=\"subject\" value=\"server\" />\n";
- echo $this->misc->form;
- echo "<input type=\"submit\" value=\"{$this->lang['strexport']}\" /></p>\n";
- echo "</form>\n";
}
}
diff --git a/src/controllers/DatabaseController.php b/src/controllers/DatabaseController.php
index 2cf514f8..404d71d3 100644
--- a/src/controllers/DatabaseController.php
+++ b/src/controllers/DatabaseController.php
@@ -16,6 +16,7 @@ use PHPPgAdmin\Decorators\Decorator;
class DatabaseController extends BaseController
{
use \PHPPgAdmin\Traits\AdminTrait;
+ use \PHPPgAdmin\Traits\ExportTrait;
public $table_place = 'database-variables';
public $fields;
public $controller_title = 'strdatabase';
@@ -44,20 +45,20 @@ class DatabaseController extends BaseController
$scripts = '';
// normal flow
if ('locks' == $this->action || 'processes' == $this->action) {
- $scripts .= '<script src="'.\SUBFOLDER.'/assets/js/database.js" type="text/javascript"></script>';
+ $scripts .= '<script src="' . \SUBFOLDER . '/assets/js/database.js" type="text/javascript"></script>';
$refreshTime = $this->conf['ajax_refresh'] * 1500;
$scripts .= "<script type=\"text/javascript\">\n";
$scripts .= "var Database = {\n";
$scripts .= "ajax_time_refresh: {$refreshTime},\n";
- $scripts .= "str_start: {text:'{$this->lang['strstart']}',icon: '".$this->misc->icon('Execute')."'},\n";
- $scripts .= "str_stop: {text:'{$this->lang['strstop']}',icon: '".$this->misc->icon('Stop')."'},\n";
- $scripts .= "load_icon: '".$this->misc->icon('Loading')."',\n";
+ $scripts .= "str_start: {text:'{$this->lang['strstart']}',icon: '" . $this->misc->icon('Execute') . "'},\n";
+ $scripts .= "str_stop: {text:'{$this->lang['strstop']}',icon: '" . $this->misc->icon('Stop') . "'},\n";
+ $scripts .= "load_icon: '" . $this->misc->icon('Loading') . "',\n";
$scripts .= "server:'{$_REQUEST['server']}',\n";
$scripts .= "dbname:'{$_REQUEST['database']}',\n";
$scripts .= "action:'refresh_{$this->action}',\n";
- $scripts .= "errmsg: '".str_replace("'", "\\'", $this->lang['strconnectionfail'])."'\n";
+ $scripts .= "errmsg: '" . str_replace("'", "\\'", $this->lang['strconnectionfail']) . "'\n";
$scripts .= "};\n";
$scripts .= "</script>\n";
}
@@ -184,7 +185,7 @@ class DatabaseController extends BaseController
$this->printTabs('database', 'find');
$this->printMsg($msg);
- echo '<form action="'.\SUBFOLDER."/src/views/database\" method=\"post\">\n";
+ echo '<form action="' . \SUBFOLDER . "/src/views/database\" method=\"post\">\n";
echo '<p><input name="term" value="', htmlspecialchars($_REQUEST['term']),
"\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" />\n";
// Output list of filters. This is complex due to all the 'has' and 'conf' feature possibilities
@@ -213,8 +214,8 @@ class DatabaseController extends BaseController
echo "</select>\n";
echo "<input type=\"submit\" value=\"{$this->lang['strfind']}\" />\n";
echo $this->misc->form;
- echo '<input type="hidden" name="action" value="find" /></p>'."\n";
- echo '<input type="hidden" name="confirm" value="true" /></p>'."\n";
+ echo '<input type="hidden" name="action" value="find" /></p>' . "\n";
+ echo '<input type="hidden" name="confirm" value="true" /></p>' . "\n";
echo "</form>\n";
// Default focus
@@ -324,7 +325,7 @@ class DatabaseController extends BaseController
switch ($curr) {
case 'SCHEMA':
- echo '<li><a href="'.\SUBFOLDER."/redirect/schema?{$this->misc->href}&schema=";
+ echo '<li><a href="' . \SUBFOLDER . "/redirect/schema?{$this->misc->href}&schema=";
echo $this->misc->printVal($rs->fields['name']), '">';
echo $this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']);
echo "</a></li>\n";
@@ -333,14 +334,14 @@ class DatabaseController extends BaseController
case 'TABLE':
echo '<li>';
echo "<a href=\"tables?subject=schema&{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.';
- echo '<a href="'.\SUBFOLDER."/redirect/table?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '&amp;table=',
+ echo '<a href="' . \SUBFOLDER . "/redirect/table?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '&amp;table=',
urlencode($rs->fields['name']), '">', $this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n";
break;
case 'VIEW':
echo '<li>';
echo "<a href=\"views?subject=schema&{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.';
- echo '<a href="'.\SUBFOLDER."/redirect/view?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '&amp;view=',
+ echo '<a href="' . \SUBFOLDER . "/redirect/view?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '&amp;view=',
urlencode($rs->fields['name']), '">', $this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n";
break;
@@ -353,7 +354,7 @@ class DatabaseController extends BaseController
break;
case 'COLUMNTABLE':
echo '<li>';
- echo '<a href="'.\SUBFOLDER."/redirect/schema?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.';
+ echo '<a href="' . \SUBFOLDER . "/redirect/schema?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.';
echo "<a href=\"tblproperties?subject=table&{$this->misc->href}&table=", urlencode($rs->fields['relname']), '&amp;schema=', urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['relname']), '</a>.';
echo "<a href=\"colproperties?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '&amp;table=',
urlencode($rs->fields['relname']), '&amp;column=', urlencode($rs->fields['name']), '">',
@@ -362,7 +363,7 @@ class DatabaseController extends BaseController
break;
case 'COLUMNVIEW':
echo '<li>';
- echo '<a href="'.\SUBFOLDER."/redirect/schema?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.';
+ echo '<a href="' . \SUBFOLDER . "/redirect/schema?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.';
echo "<a href=\"viewproperties?subject=view&{$this->misc->href}&view=", urlencode($rs->fields['relname']), '&amp;schema=', urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['relname']), '</a>.';
echo "<a href=\"colproperties?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '&amp;view=',
urlencode($rs->fields['relname']), '&amp;column=', urlencode($rs->fields['name']), '">',
@@ -371,15 +372,15 @@ class DatabaseController extends BaseController
break;
case 'INDEX':
echo '<li>';
- echo '<a href="'.\SUBFOLDER."/redirect/schema?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.';
- echo '<a href="'.\SUBFOLDER."/redirect/table?{$this->misc->href}&table=", urlencode($rs->fields['relname']), '&amp;schema=', urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['relname']), '</a>.';
+ echo '<a href="' . \SUBFOLDER . "/redirect/schema?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.';
+ echo '<a href="' . \SUBFOLDER . "/redirect/table?{$this->misc->href}&table=", urlencode($rs->fields['relname']), '&amp;schema=', urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['relname']), '</a>.';
echo "<a href=\"indexes?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '&amp;table=', urlencode($rs->fields['relname']), '">', $this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n";
break;
case 'CONSTRAINTTABLE':
echo '<li>';
- echo '<a href="'.\SUBFOLDER."/redirect/schema?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.';
- echo '<a href="'.\SUBFOLDER."/redirect/table?{$this->misc->href}&table=", urlencode($rs->fields['relname']), '&amp;schema=', urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['relname']), '</a>.';
+ echo '<a href="' . \SUBFOLDER . "/redirect/schema?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.';
+ echo '<a href="' . \SUBFOLDER . "/redirect/table?{$this->misc->href}&table=", urlencode($rs->fields['relname']), '&amp;schema=', urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['relname']), '</a>.';
echo "<a href=\"constraints?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '&amp;table=',
urlencode($rs->fields['relname']), '">', $this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n";
@@ -393,24 +394,24 @@ class DatabaseController extends BaseController
break;
case 'TRIGGER':
echo '<li>';
- echo '<a href="'.\SUBFOLDER."/redirect/schema?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.';
- echo '<a href="'.\SUBFOLDER."/redirect/table?{$this->misc->href}&table=", urlencode($rs->fields['relname']), '&amp;schema=', urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['relname']), '</a>.';
+ echo '<a href="' . \SUBFOLDER . "/redirect/schema?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.';
+ echo '<a href="' . \SUBFOLDER . "/redirect/table?{$this->misc->href}&table=", urlencode($rs->fields['relname']), '&amp;schema=', urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['relname']), '</a>.';
echo "<a href=\"triggers?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '&amp;table=', urlencode($rs->fields['relname']), '">',
$this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n";
break;
case 'RULETABLE':
echo '<li>';
- echo '<a href="'.\SUBFOLDER."/redirect/schema?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.';
- echo '<a href="'.\SUBFOLDER."/redirect/table?{$this->misc->href}&table=", urlencode($rs->fields['relname']), '&amp;schema=', urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['relname']), '</a>.';
+ echo '<a href="' . \SUBFOLDER . "/redirect/schema?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.';
+ echo '<a href="' . \SUBFOLDER . "/redirect/table?{$this->misc->href}&table=", urlencode($rs->fields['relname']), '&amp;schema=', urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['relname']), '</a>.';
echo "<a href=\"rules?subject=table&{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '&amp;reltype=table&amp;table=',
urlencode($rs->fields['relname']), '">', $this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n";
break;
case 'RULEVIEW':
echo '<li>';
- echo '<a href="'.\SUBFOLDER."/redirect/schema?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.';
- echo '<a href="'.\SUBFOLDER."/redirect/view?{$this->misc->href}&view=", urlencode($rs->fields['relname']), '&amp;schema=', urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['relname']), '</a>.';
+ echo '<a href="' . \SUBFOLDER . "/redirect/schema?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.';
+ echo '<a href="' . \SUBFOLDER . "/redirect/view?{$this->misc->href}&view=", urlencode($rs->fields['relname']), '&amp;schema=', urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['relname']), '</a>.';
echo "<a href=\"rules?subject=view&{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '&amp;reltype=view&amp;view=',
urlencode($rs->fields['relname']), '">', $this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n";
@@ -464,7 +465,7 @@ class DatabaseController extends BaseController
break;
case 'OPCLASS':
echo '<li>';
- echo '<a href="'.\SUBFOLDER."/redirect/schema?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.';
+ echo '<a href="' . \SUBFOLDER . "/redirect/schema?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.';
echo "<a href=\"opclasses?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">',
$this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n";
@@ -488,52 +489,25 @@ class DatabaseController extends BaseController
*/
public function doExport($msg = '')
{
- $data = $this->misc->getDatabaseAccessor();
-
$this->printTrail('database');
$this->printTabs('database', 'export');
$this->printMsg($msg);
- echo '<form action="'.\SUBFOLDER."/src/views/dbexport\" method=\"post\">\n";
- echo "<table>\n";
- echo "<tr><th class=\"data\">{$this->lang['strformat']}</th><th class=\"data\" colspan=\"2\">{$this->lang['stroptions']}</th></tr>\n";
- // Data only
- echo '<tr><th class="data left" rowspan="2">';
- echo "<input type=\"radio\" id=\"what1\" name=\"what\" value=\"dataonly\" checked=\"checked\" /><label for=\"what1\">{$this->lang['strdataonly']}</label></th>\n";
- echo "<td>{$this->lang['strformat']}</td>\n";
- echo "<td><select name=\"d_format\">\n";
- echo "<option value=\"copy\">COPY</option>\n";
- echo "<option value=\"sql\">SQL</option>\n";
- echo "</select>\n</td>\n</tr>\n";
- echo "<tr><td><label for=\"d_oids\">{$this->lang['stroids']}</label></td><td><input type=\"checkbox\" id=\"d_oids\" name=\"d_oids\" /></td>\n</tr>\n";
- // Structure only
- echo "<tr><th class=\"data left\"><input type=\"radio\" id=\"what2\" name=\"what\" value=\"structureonly\" /><label for=\"what2\">{$this->lang['strstructureonly']}</label></th>\n";
- echo "<td><label for=\"s_clean\">{$this->lang['strdrop']}</label></td><td><input type=\"checkbox\" id=\"s_clean\" name=\"s_clean\" /></td>\n</tr>\n";
- // Structure and data
- echo '<tr><th class="data left" rowspan="3">';
- echo "<input type=\"radio\" id=\"what3\" name=\"what\" value=\"structureanddata\" /><label for=\"what3\">{$this->lang['strstructureanddata']}</label></th>\n";
- echo "<td>{$this->lang['strformat']}</td>\n";
- echo "<td><select name=\"sd_format\">\n";
- echo "<option value=\"copy\">COPY</option>\n";
- echo "<option value=\"sql\">SQL</option>\n";
- echo "</select>\n</td>\n</tr>\n";
- echo "<tr><td><label for=\"sd_clean\">{$this->lang['strdrop']}</label></td><td><input type=\"checkbox\" id=\"sd_clean\" name=\"sd_clean\" /></td>\n</tr>\n";
- echo "<tr><td><label for=\"sd_oids\">{$this->lang['stroids']}</label></td><td><input type=\"checkbox\" id=\"sd_oids\" name=\"sd_oids\" /></td>\n</tr>\n";
- echo "</table>\n";
-
- echo "<h3>{$this->lang['stroptions']}</h3>\n";
- echo "<p><input type=\"radio\" id=\"output1\" name=\"output\" value=\"show\" checked=\"checked\" /><label for=\"output1\">{$this->lang['strshow']}</label>\n";
- echo "<br/><input type=\"radio\" id=\"output2\" name=\"output\" value=\"download\" /><label for=\"output2\">{$this->lang['strdownload']}</label>\n";
- // MSIE cannot download gzip in SSL mode - it's just broken
- if (!(strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE') && isset($_SERVER['HTTPS']))) {
- echo "<br /><input type=\"radio\" id=\"output3\" name=\"output\" value=\"gzipped\" /><label for=\"output3\">{$this->lang['strdownloadgzipped']}</label>\n";
- }
- echo "</p>\n";
- echo "<p><input type=\"hidden\" name=\"action\" value=\"export\" />\n";
- echo "<input type=\"hidden\" name=\"subject\" value=\"database\" />\n";
- echo $this->misc->form;
- echo "<input type=\"submit\" value=\"{$this->lang['strexport']}\" /></p>\n";
- echo "</form>\n";
+ $subject = 'database';
+ $object = $_REQUEST['database'];
+
+ echo $this->formHeader('dbexport');
+
+ echo $this->dataOnly(true, true);
+
+ echo $this->structureOnly();
+
+ echo $this->structureAndData(true);
+
+ echo $this->displayOrDownload(!(strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE') && isset($_SERVER['HTTPS'])));
+
+ echo $this->formFooter($subject, $object);
+
}
/**
@@ -577,7 +551,7 @@ class DatabaseController extends BaseController
$this->printMsg($msg);
if (0 === strlen($msg)) {
- echo '<br /><a id="control" href=""><img src="'.$this->misc->icon('Refresh')."\" alt=\"{$this->lang['strrefresh']}\" title=\"{$this->lang['strrefresh']}\"/>&nbsp;{$this->lang['strrefresh']}</a>";
+ echo '<br /><a id="control" href=""><img src="' . $this->misc->icon('Refresh') . "\" alt=\"{$this->lang['strrefresh']}\" title=\"{$this->lang['strrefresh']}\"/>&nbsp;{$this->lang['strrefresh']}</a>";
}
echo '<div id="data_block">';
@@ -759,7 +733,7 @@ class DatabaseController extends BaseController
$this->printTrail('database');
$this->printTabs('database', 'locks');
- echo '<br /><a id="control" href=""><img src="'.$this->misc->icon('Refresh')."\" alt=\"{$this->lang['strrefresh']}\" title=\"{$this->lang['strrefresh']}\"/>&nbsp;{$this->lang['strrefresh']}</a>";
+ echo '<br /><a id="control" href=""><img src="' . $this->misc->icon('Refresh') . "\" alt=\"{$this->lang['strrefresh']}\" title=\"{$this->lang['strrefresh']}\"/>&nbsp;{$this->lang['strrefresh']}</a>";
echo '<div id="data_block">';
$this->currentLocks();
@@ -779,7 +753,7 @@ class DatabaseController extends BaseController
$this->printTrail('database');
$this->printTabs('database', 'sql');
echo "<p>{$this->lang['strentersql']}</p>\n";
- echo '<form action="'.\SUBFOLDER.'/src/views/sql" method="post" enctype="multipart/form-data" id="sqlform">'."\n";
+ echo '<form action="' . \SUBFOLDER . '/src/views/sql" method="post" enctype="multipart/form-data" id="sqlform">' . "\n";
echo "<p>{$this->lang['strsql']}<br />\n";
echo '<textarea style="width:95%;" rows="15" cols="50" name="query" id="query">',
htmlspecialchars($_SESSION['sqlquery']), "</textarea></p>\n";
diff --git a/src/controllers/DataexportController.php b/src/controllers/DataexportController.php
index c9f5f13d..0feb29c0 100644
--- a/src/controllers/DataexportController.php
+++ b/src/controllers/DataexportController.php
@@ -130,7 +130,7 @@ class DataexportController extends BaseController
$ext = 'txt';
}
$response = $response
- ->withHeader('Content-Disposition', 'attachment; filename=dump.'.$ext);
+ ->withHeader('Content-Disposition', 'attachment; filename=dump.' . $ext);
}
} else {
$response = $response
@@ -165,7 +165,7 @@ class DataexportController extends BaseController
// If the dump is not structureonly then dump the actual data
if ('structureonly' != $_REQUEST['what']) {
// Get database encoding
- $dbEncoding = $data->getDatabaseEncoding();
+ //$dbEncoding = $data->getDatabaseEncoding();
// Set fetch mode to NUM so that duplicate field names are properly returned
$data->conn->setFetchMode(ADODB_FETCH_NUM);
@@ -312,7 +312,7 @@ class DataexportController extends BaseController
$values = (is_null($v) ? 'NULL' : "'{$v}'");
$first = false;
} else {
- $values .= ', '.((is_null($v) ? 'NULL' : "'{$v}'"));
+ $values .= ', ' . ((is_null($v) ? 'NULL' : "'{$v}'"));
}
}
echo ") VALUES ({$values});\n";
@@ -398,7 +398,7 @@ class DataexportController extends BaseController
$this->printMsg($msg);
}
- echo '<form action="'.\SUBFOLDER."/src/views/dataexport\" method=\"post\">\n";
+ echo '<form action="' . \SUBFOLDER . "/src/views/dataexport\" method=\"post\">\n";
echo "<table>\n";
echo "<tr><th class=\"data\">{$this->lang['strformat']}:</th><td><select name=\"d_format\">\n";
// COPY and SQL require a table
@@ -420,10 +420,10 @@ class DataexportController extends BaseController
echo "<p><input type=\"hidden\" name=\"action\" value=\"export\" />\n";
echo "<input type=\"hidden\" name=\"what\" value=\"dataonly\" />\n";
if (isset($_REQUEST['table'])) {
- echo '<input type="hidden" name="subject" value="table" />'."\n";
+ echo '<input type="hidden" name="subject" value="table" />' . "\n";
echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['table']), "\" />\n";
} else {
- echo '<input type="hidden" name="subject" value="table" />'."\n";
+ echo '<input type="hidden" name="subject" value="table" />' . "\n";
}
$this->prtrace('$_REQUEST[query]', $_REQUEST['query'], htmlspecialchars(urlencode($_REQUEST['query'])));
$this->prtrace('$_SESSION[sqlquery]', $_SESSION['sqlquery'], htmlspecialchars(urlencode($_SESSION['sqlquery'])));
diff --git a/src/controllers/DbexportController.php b/src/controllers/DbexportController.php
index efdb88f3..958acb84 100644
--- a/src/controllers/DbexportController.php
+++ b/src/controllers/DbexportController.php
@@ -46,7 +46,7 @@ class DbexportController extends BaseController
// Obtain the pg_dump version number and check if the path is good
$version = [];
- preg_match('/(\\d+(?:\\.\\d+)?)(?:\\.\\d+)?.*$/', exec($exe.' --version'), $version);
+ preg_match('/(\\d+(?:\\.\\d+)?)(?:\\.\\d+)?.*$/', exec($exe . ' --version'), $version);
$this->prtrace('$exe', $exe, 'version', $version[1]);
@@ -96,20 +96,20 @@ class DbexportController extends BaseController
}
// Set environmental variables that pg_dump uses
- putenv('PGPASSWORD='.$server_info['password']);
- putenv('PGUSER='.$server_info['username']);
+ putenv('PGPASSWORD=' . $server_info['password']);
+ putenv('PGUSER=' . $server_info['username']);
$hostname = $server_info['host'];
if (null !== $hostname && '' != $hostname) {
- putenv('PGHOST='.$hostname);
+ putenv('PGHOST=' . $hostname);
}
$port = $server_info['port'];
if (null !== $port && '' != $port) {
- putenv('PGPORT='.$port);
+ putenv('PGPORT=' . $port);
}
// Build command for executing pg_dump. '-i' means ignore version differences.
if (((float) $version[1]) < 9.5) {
- $cmd = $exe.' -i';
+ $cmd = $exe . ' -i';
} else {
$cmd = $exe;
}
@@ -124,7 +124,7 @@ class DbexportController extends BaseController
switch ($_REQUEST['subject']) {
case 'schema':
// This currently works for 8.2+ (due to the orthoganl -t -n issue introduced then)
- $cmd .= ' -n '.$this->misc->escapeShellArg("\"{$f_schema}\"");
+ $cmd .= ' -n ' . $this->misc->escapeShellArg("\"{$f_schema}\"");
break;
case 'table':
@@ -137,13 +137,13 @@ class DbexportController extends BaseController
// Starting in 8.2, -n and -t are orthagonal, so we now schema qualify
// the table name in the -t argument and quote both identifiers
if (((float) $version[1]) >= 8.2) {
- $cmd .= ' -t '.$this->misc->escapeShellArg("\"{$f_schema}\".\"{$f_object}\"");
+ $cmd .= ' -t ' . $this->misc->escapeShellArg("\"{$f_schema}\".\"{$f_object}\"");
} else {
// If we are 7.4 or higher, assume they are using 7.4 pg_dump and
// set dump schema as well. Also, mixed case dumping has been fixed
// then..
- $cmd .= ' -t '.$this->misc->escapeShellArg($f_object)
- .' -n '.$this->misc->escapeShellArg($f_schema);
+ $cmd .= ' -t ' . $this->misc->escapeShellArg($f_object)
+ . ' -n ' . $this->misc->escapeShellArg($f_schema);
}
}
@@ -184,7 +184,11 @@ class DbexportController extends BaseController
}
if (!$dumpall) {
- putenv('PGDATABASE='.$_REQUEST['database']);
+
+ putenv('PGDATABASE=' . $_REQUEST['database']);
+ } else {
+ $cmd .= ' --no-role-password';
+ putenv('PGDATABASE');
}
/*$this->prtrace(
diff --git a/src/controllers/DisplayController.php b/src/controllers/DisplayController.php
index c6e74ba5..79d189bb 100644
--- a/src/controllers/DisplayController.php
+++ b/src/controllers/DisplayController.php
@@ -18,7 +18,6 @@ class DisplayController extends BaseController
*/
public function render()
{
- $conf = $this->conf;
$this->misc = $this->misc;
$plugin_manager = $this->plugin_manager;
@@ -28,13 +27,13 @@ class DisplayController extends BaseController
set_time_limit(0);
- $scripts = '<script src="'.\SUBFOLDER.'/assets/js/display.js" type="text/javascript"></script>';
+ $scripts = '<script src="' . \SUBFOLDER . '/assets/js/display.js" type="text/javascript"></script>';
- $scripts .= '<script type="text/javascript">'."\n";
+ $scripts .= '<script type="text/javascript">' . "\n";
$scripts .= "var Display = {\n";
- $scripts .= "errmsg: '".str_replace("'", "\\'", $this->lang['strconnectionfail'])."'\n";
+ $scripts .= "errmsg: '" . str_replace("'", "\\'", $this->lang['strconnectionfail']) . "'\n";
$scripts .= "};\n";
- $scripts .= '</script>'."\n";
+ $scripts .= '</script>' . "\n";
$footer_template = 'footer.twig';
$header_template = 'header.twig';
@@ -257,10 +256,10 @@ class DisplayController extends BaseController
//die(htmlspecialchars($query));
- echo '<form method="post" id="sqlform" action="'.$_SERVER['REQUEST_URI'].'">';
+ echo '<form method="post" id="sqlform" action="' . $_SERVER['REQUEST_URI'] . '">';
echo $this->misc->form;
if ($object) {
- echo '<input type="hidden" name="'.$subject.'" value="', htmlspecialchars($object), '" />'."\n";
+ echo '<input type="hidden" name="' . $subject . '" value="', htmlspecialchars($object), '" />' . "\n";
}
echo '<textarea width="90%" name="query" id="query" rows="5" cols="100" resizable="true">';
echo htmlspecialchars($query);
@@ -343,19 +342,19 @@ class DisplayController extends BaseController
// Display edit and delete actions if we have a key
$colspan = count($buttons);
if ($colspan > 0 and count($key) > 0) {
- echo "<th colspan=\"{$colspan}\" class=\"data\">{$this->lang['stractions']}</th>"."\n";
+ echo "<th colspan=\"{$colspan}\" class=\"data\">{$this->lang['stractions']}</th>" . "\n";
}
// we show OIDs only if we are in TABLE or SELECT type browsing
$this->printTableHeaderCells($resultset, $_gets, isset($object));
- echo '</tr>'."\n";
+ echo '</tr>' . "\n";
$i = 0;
reset($resultset->fields);
while (!$resultset->EOF) {
$id = (0 == ($i % 2) ? '1' : '2');
- echo "<tr class=\"data{$id}\">"."\n";
+ echo "<tr class=\"data{$id}\">" . "\n";
// Display edit and delete links if we have a key
if ($colspan > 0 and count($key) > 0) {
$keys_array = [];
@@ -369,7 +368,7 @@ class DisplayController extends BaseController
$keys_array["key[{$v}]"] = $resultset->fields[$v];
}
if ($has_nulls) {
- echo "<td colspan=\"{$colspan}\">&nbsp;</td>"."\n";
+ echo "<td colspan=\"{$colspan}\">&nbsp;</td>" . "\n";
} else {
if (isset($actions['actionbuttons']['edit'])) {
$actions['actionbuttons']['edit'] = $edit_params;
@@ -390,24 +389,24 @@ class DisplayController extends BaseController
foreach ($actions['actionbuttons'] as $this->action) {
echo "<td class=\"opbutton{$id}\">";
$this->printLink($this->action, true, __METHOD__);
- echo '</td>'."\n";
+ echo '</td>' . "\n";
}
}
}
$this->printTableRowCells($resultset, $fkey_information, isset($object));
- echo '</tr>'."\n";
+ echo '</tr>' . "\n";
$resultset->moveNext();
++$i;
}
- echo '</table>'."\n";
+ echo '</table>' . "\n";
- echo '<p>', $resultset->recordCount(), " {$this->lang['strrows']}</p>"."\n";
+ echo '<p>', $resultset->recordCount(), " {$this->lang['strrows']}</p>" . "\n";
// Show page navigation
echo $paginator;
} else {
- echo "<p>{$this->lang['strnodata']}</p>"."\n";
+ echo "<p>{$this->lang['strnodata']}</p>" . "\n";
}
// Navigation links
@@ -585,7 +584,7 @@ class DisplayController extends BaseController
$finfo = $resultset->fetchField($j);
if (false === $args) {
- echo '<th class="data">', $this->misc->printVal($finfo->name), '</th>'."\n";
+ echo '<th class="data">', $this->misc->printVal($finfo->name), '</th>' . "\n";
} else {
$args['page'] = $_REQUEST['page'];
$args['sortkey'] = $j + 1;
@@ -601,12 +600,12 @@ class DisplayController extends BaseController
, $this->misc->printVal($finfo->name);
if ($_REQUEST['sortkey'] == ($j + 1)) {
if ('asc' == $_REQUEST['sortdir']) {
- echo '<img src="'.$this->misc->icon('RaiseArgument').'" alt="asc">';
+ echo '<img src="' . $this->misc->icon('RaiseArgument') . '" alt="asc">';
} else {
- echo '<img src="'.$this->misc->icon('LowerArgument').'" alt="desc">';
+ echo '<img src="' . $this->misc->icon('LowerArgument') . '" alt="desc">';
}
}
- echo '</a></th>'."\n";
+ echo '</a></th>' . "\n";
}
++$j;
}
@@ -645,16 +644,16 @@ class DisplayController extends BaseController
$query_params = $fkey_information['byconstr'][$conid]['url_data'];
foreach ($fkey_information['byconstr'][$conid]['fkeys'] as $p_field => $f_field) {
- $query_params .= '&amp;'.urlencode("fkey[{$f_field}]").'='.urlencode($resultset->fields[$p_field]);
+ $query_params .= '&amp;' . urlencode("fkey[{$f_field}]") . '=' . urlencode($resultset->fields[$p_field]);
}
// $fkey_information['common_url'] is already urlencoded
- $query_params .= '&amp;'.$fkey_information['common_url'];
+ $query_params .= '&amp;' . $fkey_information['common_url'];
echo '<div style="display:inline-block;">';
- echo '<a class="fk fk_'.htmlentities($conid, ENT_QUOTES, 'UTF-8')."\" href=\"display?{$query_params}\">";
- echo '<img src="'.$this->misc->icon('ForeignKey').'" style="vertical-align:middle;" alt="[fk]" title="'
- .htmlentities($fkey_information['byconstr'][$conid]['consrc'], ENT_QUOTES, 'UTF-8')
- .'" />';
+ echo '<a class="fk fk_' . htmlentities($conid, ENT_QUOTES, 'UTF-8') . "\" href=\"display?{$query_params}\">";
+ echo '<img src="' . $this->misc->icon('ForeignKey') . '" style="vertical-align:middle;" alt="[fk]" title="'
+ . htmlentities($fkey_information['byconstr'][$conid]['consrc'], ENT_QUOTES, 'UTF-8')
+ . '" />';
echo '</a>';
echo '</div>';
}
@@ -699,16 +698,16 @@ class DisplayController extends BaseController
$fksprops = false;
}
- echo '<form action="'.\SUBFOLDER.'/src/views/display" method="post" id="ac_form">'."\n";
+ echo '<form action="' . \SUBFOLDER . '/src/views/display" method="post" id="ac_form">' . "\n";
$elements = 0;
$error = true;
if (1 == $resultset->recordCount() && $attrs->recordCount() > 0) {
- echo '<table>'."\n";
+ echo '<table>' . "\n";
// Output table header
echo "<tr><th class=\"data\">{$this->lang['strcolumn']}</th><th class=\"data\">{$this->lang['strtype']}</th>";
- echo "<th class=\"data\">{$this->lang['strformat']}</th>"."\n";
+ echo "<th class=\"data\">{$this->lang['strformat']}</th>" . "\n";
echo "<th class=\"data\">{$this->lang['strnull']}</th><th class=\"data\">{$this->lang['strvalue']}</th></tr>";
$i = 0;
@@ -721,19 +720,19 @@ class DisplayController extends BaseController
$_REQUEST['format'][$attrs->fields['attname']] = 'VALUE';
}
- echo "<tr class=\"data{$id}\">"."\n";
+ echo "<tr class=\"data{$id}\">" . "\n";
echo '<td style="white-space:nowrap;">', $this->misc->printVal($attrs->fields['attname']), '</td>';
- echo '<td style="white-space:nowrap;">'."\n";
+ echo '<td style="white-space:nowrap;">' . "\n";
echo $this->misc->printVal($data->formatType($attrs->fields['type'], $attrs->fields['atttypmod']));
echo '<input type="hidden" name="types[', htmlspecialchars($attrs->fields['attname']), ']" value="',
htmlspecialchars($attrs->fields['type']), '" /></td>';
++$elements;
- echo '<td style="white-space:nowrap;">'."\n";
- echo '<select name="format['.htmlspecialchars($attrs->fields['attname']), ']">'."\n";
- echo '<option value="VALUE"', ($_REQUEST['format'][$attrs->fields['attname']] == 'VALUE') ? ' selected="selected"' : '', ">{$this->lang['strvalue']}</option>"."\n";
+ echo '<td style="white-space:nowrap;">' . "\n";
+ echo '<select name="format[' . htmlspecialchars($attrs->fields['attname']), ']">' . "\n";
+ echo '<option value="VALUE"', ($_REQUEST['format'][$attrs->fields['attname']] == 'VALUE') ? ' selected="selected"' : '', ">{$this->lang['strvalue']}</option>" . "\n";
$selected = ($_REQUEST['format'][$attrs->fields['attname']] == 'EXPRESSION') ? ' selected="selected"' : '';
- echo '<option value="EXPRESSION"'.$selected.">{$this->lang['strexpression']}</option>"."\n";
- echo "</select>\n</td>"."\n";
+ echo '<option value="EXPRESSION"' . $selected . ">{$this->lang['strexpression']}</option>" . "\n";
+ echo "</select>\n</td>" . "\n";
++$elements;
echo '<td style="white-space:nowrap;">';
// Output null box if the column allows nulls (doesn't look at CHECKs or ASSERTIONS)
@@ -743,7 +742,7 @@ class DisplayController extends BaseController
$_REQUEST['nulls'][$attrs->fields['attname']] = 'on';
}
echo "<label><span><input type=\"checkbox\" class=\"nullcheckbox\" name=\"nulls[{$attrs->fields['attname']}]\"",
- isset($_REQUEST['nulls'][$attrs->fields['attname']]) ? ' checked="checked"' : '', ' /></span></label></td>'."\n";
+ isset($_REQUEST['nulls'][$attrs->fields['attname']]) ? ' checked="checked"' : '', ' /></span></label></td>' . "\n";
++$elements;
} else {
echo '&nbsp;</td>';
@@ -770,64 +769,64 @@ class DisplayController extends BaseController
echo '</td>';
++$elements;
- echo '</tr>'."\n";
+ echo '</tr>' . "\n";
++$i;
$attrs->moveNext();
}
- echo '</table>'."\n";
+ echo '</table>' . "\n";
$error = false;
} elseif (1 != $resultset->recordCount()) {
- echo "<p>{$this->lang['strrownotunique']}</p>"."\n";
+ echo "<p>{$this->lang['strrownotunique']}</p>" . "\n";
} else {
- echo "<p>{$this->lang['strinvalidparam']}</p>"."\n";
+ echo "<p>{$this->lang['strinvalidparam']}</p>" . "\n";
}
- echo '<input type="hidden" name="action" value="editrow" />'."\n";
+ echo '<input type="hidden" name="action" value="editrow" />' . "\n";
echo $this->misc->form;
if (isset($_REQUEST['table'])) {
- echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['table']), '" />'."\n";
+ echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['table']), '" />' . "\n";
}
if (isset($_REQUEST['subject'])) {
- echo '<input type="hidden" name="subject" value="', htmlspecialchars($_REQUEST['subject']), '" />'."\n";
+ echo '<input type="hidden" name="subject" value="', htmlspecialchars($_REQUEST['subject']), '" />' . "\n";
}
if (isset($_REQUEST['query'])) {
- echo '<input type="hidden" name="query" value="', htmlspecialchars($_REQUEST['query']), '" />'."\n";
+ echo '<input type="hidden" name="query" value="', htmlspecialchars($_REQUEST['query']), '" />' . "\n";
}
if (isset($_REQUEST['count'])) {
- echo '<input type="hidden" name="count" value="', htmlspecialchars($_REQUEST['count']), '" />'."\n";
+ echo '<input type="hidden" name="count" value="', htmlspecialchars($_REQUEST['count']), '" />' . "\n";
}
if (isset($_REQUEST['return'])) {
- echo '<input type="hidden" name="return" value="', htmlspecialchars($_REQUEST['return']), '" />'."\n";
+ echo '<input type="hidden" name="return" value="', htmlspecialchars($_REQUEST['return']), '" />' . "\n";
}
- echo '<input type="hidden" name="page" value="', htmlspecialchars($_REQUEST['page']), '" />'."\n";
- echo '<input type="hidden" name="sortkey" value="', htmlspecialchars($_REQUEST['sortkey']), '" />'."\n";
- echo '<input type="hidden" name="sortdir" value="', htmlspecialchars($_REQUEST['sortdir']), '" />'."\n";
- echo '<input type="hidden" name="strings" value="', htmlspecialchars($_REQUEST['strings']), '" />'."\n";
- echo '<input type="hidden" name="key" value="', htmlspecialchars(urlencode(serialize($key))), '" />'."\n";
+ echo '<input type="hidden" name="page" value="', htmlspecialchars($_REQUEST['page']), '" />' . "\n";
+ echo '<input type="hidden" name="sortkey" value="', htmlspecialchars($_REQUEST['sortkey']), '" />' . "\n";
+ echo '<input type="hidden" name="sortdir" value="', htmlspecialchars($_REQUEST['sortdir']), '" />' . "\n";
+ echo '<input type="hidden" name="strings" value="', htmlspecialchars($_REQUEST['strings']), '" />' . "\n";
+ echo '<input type="hidden" name="key" value="', htmlspecialchars(urlencode(serialize($key))), '" />' . "\n";
echo '<p>';
if (!$error) {
- echo "<input type=\"submit\" name=\"save\" accesskey=\"r\" value=\"{$this->lang['strsave']}\" />"."\n";
+ echo "<input type=\"submit\" name=\"save\" accesskey=\"r\" value=\"{$this->lang['strsave']}\" />" . "\n";
}
- echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" />"."\n";
+ echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" />" . "\n";
if (false !== $fksprops) {
if ('default off' != $this->conf['autocomplete']) {
- echo "<input type=\"checkbox\" id=\"no_ac\" value=\"1\" checked=\"checked\" /><label for=\"no_ac\">{$this->lang['strac']}</label>"."\n";
+ echo "<input type=\"checkbox\" id=\"no_ac\" value=\"1\" checked=\"checked\" /><label for=\"no_ac\">{$this->lang['strac']}</label>" . "\n";
} else {
- echo "<input type=\"checkbox\" id=\"no_ac\" value=\"0\" /><label for=\"no_ac\">{$this->lang['strac']}</label>"."\n";
+ echo "<input type=\"checkbox\" id=\"no_ac\" value=\"0\" /><label for=\"no_ac\">{$this->lang['strac']}</label>" . "\n";
}
}
- echo '</p>'."\n";
- echo '</form>'."\n";
- echo '<script src="'.\SUBFOLDER.'/assets/js/insert_or_edit_row.js" type="text/javascript"></script>';
+ echo '</p>' . "\n";
+ echo '</form>' . "\n";
+ echo '<script src="' . \SUBFOLDER . '/assets/js/insert_or_edit_row.js" type="text/javascript"></script>';
}
/**
@@ -880,58 +879,58 @@ class DisplayController extends BaseController
$resultset = $data->browseRow($_REQUEST['table'], $_REQUEST['key']);
- echo '<form action="'.\SUBFOLDER.'/src/views/display" method="post">'."\n";
+ echo '<form action="' . \SUBFOLDER . '/src/views/display" method="post">' . "\n";
echo $this->misc->form;
if (1 == $resultset->recordCount()) {
- echo "<p>{$this->lang['strconfdeleterow']}</p>"."\n";
+ echo "<p>{$this->lang['strconfdeleterow']}</p>" . "\n";
$fkinfo = [];
echo '<table><tr>';
$this->printTableHeaderCells($resultset, false, true);
echo '</tr>';
- echo '<tr class="data1">'."\n";
+ echo '<tr class="data1">' . "\n";
$this->printTableRowCells($resultset, $fkinfo, true);
- echo '</tr>'."\n";
- echo '</table>'."\n";
- echo '<br />'."\n";
+ echo '</tr>' . "\n";
+ echo '</table>' . "\n";
+ echo '<br />' . "\n";
- echo '<input type="hidden" name="action" value="delrow" />'."\n";
- echo "<input type=\"submit\" name=\"yes\" value=\"{$this->lang['stryes']}\" />"."\n";
- echo "<input type=\"submit\" name=\"no\" value=\"{$this->lang['strno']}\" />"."\n";
+ echo '<input type="hidden" name="action" value="delrow" />' . "\n";
+ echo "<input type=\"submit\" name=\"yes\" value=\"{$this->lang['stryes']}\" />" . "\n";
+ echo "<input type=\"submit\" name=\"no\" value=\"{$this->lang['strno']}\" />" . "\n";
} elseif (1 != $resultset->recordCount()) {
- echo "<p>{$this->lang['strrownotunique']}</p>"."\n";
- echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" />"."\n";
+ echo "<p>{$this->lang['strrownotunique']}</p>" . "\n";
+ echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" />" . "\n";
} else {
- echo "<p>{$this->lang['strinvalidparam']}</p>"."\n";
- echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" />"."\n";
+ echo "<p>{$this->lang['strinvalidparam']}</p>" . "\n";
+ echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" />" . "\n";
}
if (isset($_REQUEST['table'])) {
- echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['table']), '" />'."\n";
+ echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['table']), '" />' . "\n";
}
if (isset($_REQUEST['subject'])) {
- echo '<input type="hidden" name="subject" value="', htmlspecialchars($_REQUEST['subject']), '" />'."\n";
+ echo '<input type="hidden" name="subject" value="', htmlspecialchars($_REQUEST['subject']), '" />' . "\n";
}
if (isset($_REQUEST['query'])) {
- echo '<input type="hidden" name="query" value="', htmlspecialchars($_REQUEST['query']), '" />'."\n";
+ echo '<input type="hidden" name="query" value="', htmlspecialchars($_REQUEST['query']), '" />' . "\n";
}
if (isset($_REQUEST['count'])) {
- echo '<input type="hidden" name="count" value="', htmlspecialchars($_REQUEST['count']), '" />'."\n";
+ echo '<input type="hidden" name="count" value="', htmlspecialchars($_REQUEST['count']), '" />' . "\n";
}
if (isset($_REQUEST['return'])) {
- echo '<input type="hidden" name="return" value="', htmlspecialchars($_REQUEST['return']), '" />'."\n";
+ echo '<input type="hidden" name="return" value="', htmlspecialchars($_REQUEST['return']), '" />' . "\n";
}
- echo '<input type="hidden" name="page" value="', htmlspecialchars($_REQUEST['page']), '" />'."\n";
- echo '<input type="hidden" name="sortkey" value="', htmlspecialchars($_REQUEST['sortkey']), '" />'."\n";
- echo '<input type="hidden" name="sortdir" value="', htmlspecialchars($_REQUEST['sortdir']), '" />'."\n";
- echo '<input type="hidden" name="strings" value="', htmlspecialchars($_REQUEST['strings']), '" />'."\n";
- echo '<input type="hidden" name="key" value="', htmlspecialchars(urlencode(serialize($_REQUEST['key']))), '" />'."\n";
- echo '</form>'."\n";
+ echo '<input type="hidden" name="page" value="', htmlspecialchars($_REQUEST['page']), '" />' . "\n";
+ echo '<input type="hidden" name="sortkey" value="', htmlspecialchars($_REQUEST['sortkey']), '" />' . "\n";
+ echo '<input type="hidden" name="sortdir" value="', htmlspecialchars($_REQUEST['sortdir']), '" />' . "\n";
+ echo '<input type="hidden" name="strings" value="', htmlspecialchars($_REQUEST['strings']), '" />' . "\n";
+ echo '<input type="hidden" name="key" value="', htmlspecialchars(urlencode(serialize($_REQUEST['key']))), '" />' . "\n";
+ echo '</form>' . "\n";
} else {
$status = $data->deleteRow($_POST['table'], unserialize(urldecode($_POST['key'])));
if (0 == $status) {
@@ -960,7 +959,7 @@ class DisplayController extends BaseController
if (isset($_REQUEST['table'])) {
$constraints = $data->getConstraintsWithFields($_REQUEST['table']);
if ($constraints->recordCount() > 0) {
- $fkey_information['common_url'] = $this->misc->getHREF('schema').'&amp;subject=table';
+ $fkey_information['common_url'] = $this->misc->getHREF('schema') . '&amp;subject=table';
// build the FK constraints data structure
while (!$constraints->EOF) {
@@ -968,7 +967,7 @@ class DisplayController extends BaseController
if ('f' == $constr['contype']) {
if (!isset($fkey_information['byconstr'][$constr['conid']])) {
$fkey_information['byconstr'][$constr['conid']] = [
- 'url_data' => 'table='.urlencode($constr['f_table']).'&amp;schema='.urlencode($constr['f_schema']),
+ 'url_data' => 'table=' . urlencode($constr['f_table']) . '&amp;schema=' . urlencode($constr['f_schema']),
'fkeys' => [],
'consrc' => $constr['consrc'],
];
@@ -1017,7 +1016,7 @@ class DisplayController extends BaseController
$max_pages
);
- echo '<a href="javascript:void(0);" style="display:table-cell;" class="fk_delete"><img alt="[delete]" src="'.$this->misc->icon('Delete').'" /></a>'."\n";
+ echo '<a href="javascript:void(0);" style="display:table-cell;" class="fk_delete"><img alt="[delete]" src="' . $this->misc->icon('Delete') . '" /></a>' . "\n";
echo '<div style="display:table-cell;">';
if (is_object($resultset) && $resultset->recordCount() > 0) {
@@ -1028,10 +1027,10 @@ class DisplayController extends BaseController
echo '<table><tr>';
$this->printTableHeaderCells($resultset, false, true);
echo '</tr>';
- echo '<tr class="data1">'."\n";
+ echo '<tr class="data1">' . "\n";
$this->printTableRowCells($resultset, $fkinfo, true);
- echo '</tr>'."\n";
- echo '</table>'."\n";
+ echo '</tr>' . "\n";
+ echo '</table>' . "\n";
} else {
echo $this->lang['strnodata'];
}
@@ -1082,7 +1081,7 @@ class DisplayController extends BaseController
unset($gets['page']);
$url = http_build_query($gets);
- $result = '<p style="text-align: center">'."\n";
+ $result = '<p style="text-align: center">' . "\n";
if ($page != 1) {
$result .= sprintf('<a class="pagenav" href="?%s&page=1">%s</a>%s&nbsp;', $url, $lang['strfirst'], "\n");
$result .= sprintf('<a class="pagenav" href="?%s&page=%s">%s</a>%s', $url, $page - 1, $lang['strprev'], "\n");
@@ -1091,7 +1090,7 @@ class DisplayController extends BaseController
list($min_page, $max_page) = $this->_getMinMaxPages($page, $pages);
for ($i = $min_page; $i <= $max_page; ++$i) {
- $result .= (($i === $page) ? $i : sprintf('<a class="pagenav" href="display?%s&page=%s">%s</a>', $url, $i, $i))."\n";
+ $result .= (($i === $page) ? $i : sprintf('<a class="pagenav" href="display?%s&page=%s">%s</a>', $url, $i, $i)) . "\n";
}
if ($page != $pages) {
diff --git a/src/controllers/IndexesController.php b/src/controllers/IndexesController.php
index b235400d..8af3bd71 100644
--- a/src/controllers/IndexesController.php
+++ b/src/controllers/IndexesController.php
@@ -16,7 +16,7 @@ use PHPPgAdmin\Decorators\Decorator;
class IndexesController extends BaseController
{
public $controller_title = 'strindexes';
- public $scripts = '<script src="'.\SUBFOLDER.'/assets/js/indexes.js" type="text/javascript"></script>';
+ public $scripts = '<script src="' . \SUBFOLDER . '/assets/js/indexes.js" type="text/javascript"></script>';
/**
* Default method to render the controller according to the action parameter.
@@ -143,7 +143,7 @@ class IndexesController extends BaseController
],
];
- $url = \SUBFOLDER.'/src/views/indexes';
+ $url = \SUBFOLDER . '/src/views/indexes';
$actions = [
'cluster' => [
@@ -222,8 +222,6 @@ class IndexesController extends BaseController
$indexes = $data->getIndexes($object);
- $reqvars = $this->misc->getRequestVars($subject);
-
$getIcon = function ($f) {
if ('t' == $f['indisprimary']) {
return 'PrimaryKey';
@@ -267,18 +265,18 @@ class IndexesController extends BaseController
$this->printTabs($subject, 'indexes');
$this->printTitle($this->lang['strclusterindex'], 'pg.index.cluster');
- echo '<p>', sprintf($this->lang['strconfcluster'], $this->misc->printVal($_REQUEST['index'])), '</p>'."\n";
+ echo '<p>', sprintf($this->lang['strconfcluster'], $this->misc->printVal($_REQUEST['index'])), '</p>' . "\n";
- echo '<form action="'.\SUBFOLDER.'/src/views/indexes" method="post">'."\n";
+ echo '<form action="' . \SUBFOLDER . '/src/views/indexes" method="post">' . "\n";
echo '<p><input type="checkbox" id="analyze" name="analyze"', (isset($_REQUEST['analyze']) ? ' checked="checked"' : ''), ' />';
- echo "<label for=\"analyze\">{$this->lang['stranalyze']}</label></p>"."\n";
- echo '<input type="hidden" name="action" value="cluster_index" />'."\n";
- echo '<input type="hidden" name="table" value="', htmlspecialchars($object), '" />'."\n";
- echo '<input type="hidden" name="index" value="', htmlspecialchars($_REQUEST['index']), '" />'."\n";
+ echo "<label for=\"analyze\">{$this->lang['stranalyze']}</label></p>" . "\n";
+ echo '<input type="hidden" name="action" value="cluster_index" />' . "\n";
+ echo '<input type="hidden" name="table" value="', htmlspecialchars($object), '" />' . "\n";
+ echo '<input type="hidden" name="index" value="', htmlspecialchars($_REQUEST['index']), '" />' . "\n";
echo $this->misc->form;
- echo "<input type=\"submit\" name=\"cluster\" value=\"{$this->lang['strclusterindex']}\" />"."\n";
- echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" />"."\n";
- echo '</form>'."\n";
+ echo "<input type=\"submit\" name=\"cluster\" value=\"{$this->lang['strclusterindex']}\" />" . "\n";
+ echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" />" . "\n";
+ echo '</form>' . "\n";
} else {
set_time_limit(0);
list($status, $sql) = $data->clusterIndex($object, $_POST['index']);
@@ -286,15 +284,15 @@ class IndexesController extends BaseController
if (isset($_POST['analyze'])) {
$status = $data->analyzeDB($object);
if (0 == $status) {
- $this->doDefault($sql.'<br>'.$this->lang['strclusteredgood'].' '.$this->lang['stranalyzegood']);
+ $this->doDefault($sql . '<br>' . $this->lang['strclusteredgood'] . ' ' . $this->lang['stranalyzegood']);
} else {
- $this->doDefault($sql.'<br>'.$this->lang['stranalyzebad']);
+ $this->doDefault($sql . '<br>' . $this->lang['stranalyzebad']);
}
} else {
- $this->doDefault($sql.'<br>'.$this->lang['strclusteredgood']);
+ $this->doDefault($sql . '<br>' . $this->lang['strclusteredgood']);
}
} else {
- $this->doDefault($sql.'<br>'.$this->lang['strclusteredbad']);
+ $this->doDefault($sql . '<br>' . $this->lang['strclusteredbad']);
}
}
}
@@ -363,61 +361,61 @@ class IndexesController extends BaseController
$buttonRemove->set_attribute('onclick', 'buttonPressed(this);');
$buttonRemove->set_attribute('type', 'button');
- echo '<form onsubmit="doSelectAll();" name="formIndex" action="indexes" method="post">'."\n";
+ echo '<form onsubmit="doSelectAll();" name="formIndex" action="indexes" method="post">' . "\n";
- echo '<table>'."\n";
- echo '<tr><th class="data required" colspan="3">'.$this->lang['strindexname'].'</th></tr>';
+ echo '<table>' . "\n";
+ echo '<tr><th class="data required" colspan="3">' . $this->lang['strindexname'] . '</th></tr>';
echo '<tr>';
echo '<td class="data1" colspan="3">';
- echo 'Index name cannot exceed '.$data->_maxNameLen.' characters<br>';
- echo '<input type="text" name="formIndexName" size="32" placeholder="Index Name" maxlength="'.
- $data->_maxNameLen.'" value="'.
- htmlspecialchars($formIndexName).'" />';
+ echo 'Index name cannot exceed ' . $data->_maxNameLen . ' characters<br>';
+ echo '<input type="text" name="formIndexName" size="32" placeholder="Index Name" maxlength="' .
+ $data->_maxNameLen . '" value="' .
+ htmlspecialchars($formIndexName) . '" />';
echo '</td>';
echo '</tr>';
echo '<tr>';
- echo '<th class="data">'.$this->lang['strtablecolumnlist'].'</th><th class="data">&nbsp;</th>';
- echo '<th class="data required">'.$this->lang['strindexcolumnlist'].'</th>';
- echo '</tr>'."\n";
+ echo '<th class="data">' . $this->lang['strtablecolumnlist'] . '</th><th class="data">&nbsp;</th>';
+ echo '<th class="data required">' . $this->lang['strindexcolumnlist'] . '</th>';
+ echo '</tr>' . "\n";
- echo '<tr><td class="data1">'.$selColumns->fetch().'</td>'."\n";
- echo '<td class="data1">'.$buttonRemove->fetch().$buttonAdd->fetch().'</td>';
- echo '<td class="data1">'.$selIndex->fetch().'</td></tr>'."\n";
+ echo '<tr><td class="data1">' . $selColumns->fetch() . '</td>' . "\n";
+ echo '<td class="data1">' . $buttonRemove->fetch() . $buttonAdd->fetch() . '</td>';
+ echo '<td class="data1">' . $selIndex->fetch() . '</td></tr>' . "\n";
echo '<tr>';
- echo '<th class="data left required" scope="row">'.$this->lang['strindextype'].'</th>';
+ echo '<th class="data left required" scope="row">' . $this->lang['strindextype'] . '</th>';
echo '<td colspan="2" class="data1"><select name="formIndexType">';
foreach ($data->typIndexes as $v) {
echo '<option value="', htmlspecialchars($v), '"',
- ($v == $formIndexType) ? ' selected="selected"' : '', '>', htmlspecialchars($v), '</option>'."\n";
+ ($v == $formIndexType) ? ' selected="selected"' : '', '>', htmlspecialchars($v), '</option>' . "\n";
}
- echo '</select></td></tr>'."\n";
+ echo '</select></td></tr>' . "\n";
echo '<tr>';
echo "<th class=\"data left\" scope=\"row\"><label for=\"formUnique\">{$this->lang['strunique']}</label></th>";
echo '<td colspan="2" class="data1"><input type="checkbox" id="formUnique" name="formUnique"', ($formUnique ? 'checked="checked"' : ''), ' /></td>';
echo '</tr>';
echo '<tr>';
echo "<th class=\"data left\" scope=\"row\">{$this->lang['strwhere']}</th>";
- echo '<td colspan="2" class="data1">(<input name="formWhere" size="32" maxlength="'.$data->_maxNameLen.'" value="'.htmlspecialchars($formWhere).'" />)</td>';
+ echo '<td colspan="2" class="data1">(<input name="formWhere" size="32" maxlength="' . $data->_maxNameLen . '" value="' . htmlspecialchars($formWhere) . '" />)</td>';
echo '</tr>';
// Tablespace (if there are any)
if ($data->hasTablespaces() && $tablespaces->recordCount() > 0) {
- echo '<tr>'."\n";
- echo "<th class=\"data left\">{$this->lang['strtablespace']}</th>"."\n";
+ echo '<tr>' . "\n";
+ echo "<th class=\"data left\">{$this->lang['strtablespace']}</th>" . "\n";
echo '<td colspan="2" class="data1">';
- echo "\n\t\t\t<select name=\"formSpc\">"."\n";
+ echo "\n\t\t\t<select name=\"formSpc\">" . "\n";
// Always offer the default (empty) option
echo "\t\t\t\t<option value=\"\"",
- ('' == $formSpc) ? ' selected="selected"' : '', '></option>'."\n";
+ ('' == $formSpc) ? ' selected="selected"' : '', '></option>' . "\n";
// Display all other tablespaces
while (!$tablespaces->EOF) {
$spcname = htmlspecialchars($tablespaces->fields['spcname']);
echo "\t\t\t\t<option value=\"{$spcname}\"",
- ($spcname == $formSpc) ? ' selected="selected"' : '', ">{$spcname}</option>"."\n";
+ ($spcname == $formSpc) ? ' selected="selected"' : '', ">{$spcname}</option>" . "\n";
$tablespaces->moveNext();
}
- echo "\t\t\t</select>\n\t\t</td>\n\t</tr>"."\n";
+ echo "\t\t\t</select>\n\t\t</td>\n\t</tr>" . "\n";
}
if ($data->hasConcurrentIndexBuild()) {
@@ -429,13 +427,13 @@ class IndexesController extends BaseController
echo '</table>';
- echo '<p><input type="hidden" name="action" value="save_create_index" />'."\n";
+ echo '<p><input type="hidden" name="action" value="save_create_index" />' . "\n";
echo $this->misc->form;
- echo '<input type="hidden" name="subject" value="', htmlspecialchars($subject), '" />'."\n";
- echo '<input type="hidden" name="'.$subject.'" value="', htmlspecialchars($object), '" />'."\n";
- echo "<input type=\"submit\" value=\"{$this->lang['strcreate']}\" />"."\n";
- echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" /></p>"."\n";
- echo '</form>'."\n";
+ echo '<input type="hidden" name="subject" value="', htmlspecialchars($subject), '" />' . "\n";
+ echo '<input type="hidden" name="' . $subject . '" value="', htmlspecialchars($object), '" />' . "\n";
+ echo "<input type=\"submit\" value=\"{$this->lang['strcreate']}\" />" . "\n";
+ echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" /></p>" . "\n";
+ echo '</form>' . "\n";
}
/**
@@ -475,7 +473,7 @@ class IndexesController extends BaseController
);
if (0 == $status) {
- $this->doDefault($sql.'<br>'.$this->lang['strindexcreated']);
+ $this->doDefault($sql . '<br>' . $this->lang['strindexcreated']);
} else {
$this->doCreateIndex($this->lang['strindexcreatedbad']);
}
@@ -492,30 +490,30 @@ class IndexesController extends BaseController
$data = $this->misc->getDatabaseAccessor();
$subject = urlencode($this->getRequestParam('subject', 'table'));
- $object = urlencode($this->getRequestParam($this->getRequestParam('subject', 'table')));
+ $object = urlencode($this->getRequestParam($subject));
if ($confirm) {
$this->printTrail('index');
$this->printTitle($this->lang['strdrop'], 'pg.index.drop');
- echo '<p>', sprintf($this->lang['strconfdropindex'], $this->misc->printVal($this->getRequestParam('index'))), '</p>'."\n";
- echo '<form action="'.\SUBFOLDER.'/src/views/indexes" method="post">'."\n";
- echo '<input type="hidden" name="action" value="drop_index" />'."\n";
- echo '<input type="hidden" name="table" value="', htmlspecialchars($object), '" />'."\n";
- echo '<input type="hidden" name="index" value="', htmlspecialchars($this->getRequestParam('index')), '" />'."\n";
+ echo '<p>', sprintf($this->lang['strconfdropindex'], $this->misc->printVal($this->getRequestParam('index'))), '</p>' . "\n";
+ echo '<form action="' . \SUBFOLDER . '/src/views/indexes" method="post">' . "\n";
+ echo '<input type="hidden" name="action" value="drop_index" />' . "\n";
+ echo '<input type="hidden" name="table" value="', htmlspecialchars($object), '" />' . "\n";
+ echo '<input type="hidden" name="index" value="', htmlspecialchars($this->getRequestParam('index')), '" />' . "\n";
echo $this->misc->form;
echo '<p><input type="checkbox" id="cascade" name="cascade" value="1" />';
- echo '<label for="cascade">'.$this->lang['strcascade'].'</label></p>'."\n";
- echo "<input type=\"submit\" name=\"drop\" value=\"{$this->lang['strdrop']}\" />"."\n";
- echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" />"."\n";
- echo '</form>'."\n";
+ echo '<label for="cascade">' . $this->lang['strcascade'] . '</label></p>' . "\n";
+ echo "<input type=\"submit\" name=\"drop\" value=\"{$this->lang['strdrop']}\" />" . "\n";
+ echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" />" . "\n";
+ echo '</form>' . "\n";
} else {
try {
list($status, $sql) = $data->dropIndex($this->getPostParam('index'), $this->getPostParam('cascade'));
if (0 == $status) {
- $this->doDefault($sql."\n".$this->lang['strindexdropped']);
+ $this->doDefault($sql . "\n" . $this->lang['strindexdropped']);
} else {
- $this->doDefault($sql."\n".$this->lang['strindexdroppedbad']);
+ $this->doDefault($sql . "\n" . $this->lang['strindexdroppedbad']);
}
} catch (\PHPPgAdmin\ADOdbException $e) {
$this->doDefault($this->lang['strindexdroppedbad']);
diff --git a/src/controllers/MaterializedviewsController.php b/src/controllers/MaterializedviewsController.php
index 9e924bf0..a2c23878 100644
--- a/src/controllers/MaterializedviewsController.php
+++ b/src/controllers/MaterializedviewsController.php
@@ -29,7 +29,7 @@ class MaterializedviewsController extends BaseController
return $this->doSubTree();
}
- $this->printHeader('M '.$this->lang['strviews']);
+ $this->printHeader('M ' . $this->lang['strviews']);
$this->printBody();
switch ($this->action) {
@@ -116,9 +116,9 @@ class MaterializedviewsController extends BaseController
$columns = [
'matview' => [
- 'title' => 'M '.$this->lang['strview'],
+ 'title' => 'M ' . $this->lang['strview'],
'field' => Decorator::field('relname'),
- 'url' => \SUBFOLDER."/redirect/matview?{$this->misc->href}&amp;",
+ 'url' => \SUBFOLDER . "/redirect/matview?{$this->misc->href}&amp;",
'vars' => ['matview' => 'relname'],
],
'owner' => [
@@ -260,8 +260,6 @@ class MaterializedviewsController extends BaseController
public function doSubTree()
{
- $data = $this->misc->getDatabaseAccessor();
-
$tabs = $this->misc->getNavTabs('matview');
$items = $this->adjustTabsForTree($tabs);
$reqvars = $this->misc->getRequestVars('matview');
@@ -305,7 +303,7 @@ class MaterializedviewsController extends BaseController
$attrs = $data->getTableAttributes($_REQUEST['matview']);
- echo '<form action="'.\SUBFOLDER.'/src/views/'.$this->script.'" method="post" id="selectform">';
+ echo '<form action="' . \SUBFOLDER . '/src/views/' . $this->script . '" method="post" id="selectform">';
echo "\n";
if ($attrs->recordCount() > 0) {
@@ -431,7 +429,7 @@ class MaterializedviewsController extends BaseController
$this->printTrail('getTrail');
$this->printTitle($this->lang['strdrop'], 'pg.matview.drop');
- echo '<form action="'.\SUBFOLDER."/src/views/materializedviews\" method=\"post\">\n";
+ echo '<form action="' . \SUBFOLDER . "/src/views/materializedviews\" method=\"post\">\n";
//If multi drop
if (isset($_REQUEST['ma'])) {
@@ -516,8 +514,6 @@ class MaterializedviewsController extends BaseController
$arrSelTables[] = unserialize($_POST['formTables'][$i]);
}
- $linkCount = $tblCount;
-
//get linking keys
$rsLinkKeys = $data->getLinkingKeys($arrSelTables);
$linkCount = $rsLinkKeys->recordCount() > $tblCount ? $rsLinkKeys->recordCount() : $tblCount;
@@ -538,7 +534,7 @@ class MaterializedviewsController extends BaseController
[
'schemaname' => $arrSelTables[$i]['schemaname'],
'tablename' => $arrSelTables[$i]['tablename'],
- 'fieldname' => $attrs->fields['attname'], ]
+ 'fieldname' => $attrs->fields['attname']]
);
$attrs->moveNext();
}
@@ -547,7 +543,7 @@ class MaterializedviewsController extends BaseController
}
asort($arrFields);
- echo '<form action="'.\SUBFOLDER."/src/views/materializedviews\" method=\"post\">\n";
+ echo '<form action="' . \SUBFOLDER . "/src/views/materializedviews\" method=\"post\">\n";
echo "<table>\n";
echo "<tr><th class=\"data\">{$this->lang['strviewname']}</th></tr>";
echo "<tr>\n<td class=\"data1\">\n";
@@ -626,7 +622,7 @@ class MaterializedviewsController extends BaseController
echo "<p><input type=\"hidden\" name=\"action\" value=\"save_create_wiz\" />\n";
foreach ($arrSelTables as $curTable) {
- echo '<input type="hidden" name="formTables[]" value="'.htmlspecialchars(serialize($curTable))."\" />\n";
+ echo '<input type="hidden" name="formTables[]" value="' . htmlspecialchars(serialize($curTable)) . "\" />\n";
}
echo $this->misc->form;
@@ -651,7 +647,7 @@ class MaterializedviewsController extends BaseController
$this->printTitle($this->lang['strcreateviewwiz'], 'pg.matview.create');
$this->printMsg($msg);
- echo '<form action="'.\SUBFOLDER."/src/views/materializedviews\" method=\"post\">\n";
+ echo '<form action="' . \SUBFOLDER . "/src/views/materializedviews\" method=\"post\">\n";
echo "<table>\n";
echo "<tr><th class=\"data\">{$this->lang['strtables']}</th></tr>";
echo "<tr>\n<td class=\"data1\">\n";
@@ -661,7 +657,7 @@ class MaterializedviewsController extends BaseController
$arrTmp = [];
$arrTmp['schemaname'] = $tables->fields['nspname'];
$arrTmp['tablename'] = $tables->fields['relname'];
- $arrTables[$tables->fields['nspname'].'.'.$tables->fields['relname']] = serialize($arrTmp);
+ $arrTables[$tables->fields['nspname'] . '.' . $tables->fields['relname']] = serialize($arrTmp);
$tables->moveNext();
}
echo \PHPPgAdmin\XHtml\HTMLController::printCombo($arrTables, 'formTables[]', false, '', true);
@@ -699,7 +695,7 @@ class MaterializedviewsController extends BaseController
$this->printTitle($this->lang['strcreateview'], 'pg.matview.create');
$this->printMsg($msg);
- echo '<form action="'.\SUBFOLDER."/src/views/materializedviews\" method=\"post\">\n";
+ echo '<form action="' . \SUBFOLDER . "/src/views/materializedviews\" method=\"post\">\n";
echo "<table style=\"width: 100%\">\n";
echo "\t<tr>\n\t\t<th class=\"data left required\">{$this->lang['strname']}</th>\n";
echo "\t<td class=\"data1\"><input name=\"formView\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" value=\"",
@@ -815,7 +811,7 @@ class MaterializedviewsController extends BaseController
if ((!in_array($curLink, $arrJoined, true) && in_array($tbl1, $arrUsedTbls, true)) || !count($arrJoined)) {
// Make sure for multi-column foreign keys that we use a table alias tables joined to more than once
// This can (and should be) more optimized for multi-column foreign keys
- $adj_tbl2 = in_array($tbl2, $arrUsedTbls, true) ? "${tbl2} AS alias_ppa_".mktime() : $tbl2;
+ $adj_tbl2 = in_array($tbl2, $arrUsedTbls, true) ? "${tbl2} AS alias_ppa_" . mktime() : $tbl2;
$linkFields .= strlen($linkFields) ? "{$curLink['operator']} ${adj_tbl2} ON (\"{$arrLeftLink['schemaname']}\".\"{$arrLeftLink['tablename']}\".\"{$arrLeftLink['fieldname']}\" = \"{$arrRightLink['schemaname']}\".\"{$arrRightLink['tablename']}\".\"{$arrRightLink['fieldname']}\") "
: "${tbl1} {$curLink['operator']} ${adj_tbl2} ON (\"{$arrLeftLink['schemaname']}\".\"{$arrLeftLink['tablename']}\".\"{$arrLeftLink['fieldname']}\" = \"{$arrRightLink['schemaname']}\".\"{$arrRightLink['tablename']}\".\"{$arrRightLink['fieldname']}\") ";
@@ -861,7 +857,7 @@ class MaterializedviewsController extends BaseController
//add where from additional conditions
if (strlen($addConditions)) {
- $viewQuery .= ' WHERE '.$addConditions;
+ $viewQuery .= ' WHERE ' . $addConditions;
}
$status = $data->createView($_POST['formView'], $viewQuery, false, $_POST['formComment'], true);
diff --git a/src/controllers/RulesController.php b/src/controllers/RulesController.php
index 3ebbf9db..74a31c33 100644
--- a/src/controllers/RulesController.php
+++ b/src/controllers/RulesController.php
@@ -25,7 +25,7 @@ class RulesController extends BaseController
}
// Different header if we're view rules or table rules
- $this->printHeader($_REQUEST[$_REQUEST['subject']].' - '.$this->lang['strrules']);
+ $this->printHeader($_REQUEST[$_REQUEST['subject']] . ' - ' . $this->lang['strrules']);
$this->printBody();
switch ($this->action) {
@@ -138,8 +138,6 @@ class RulesController extends BaseController
$rules = $data->getRules($_REQUEST[$_REQUEST['subject']]);
- $reqvars = $this->misc->getRequestVars($_REQUEST['subject']);
-
$attrs = [
'text' => Decorator::field('rulename'),
'icon' => 'Rule',
@@ -173,7 +171,7 @@ class RulesController extends BaseController
$this->printTitle($this->lang['strcreaterule'], 'pg.rule.create');
$this->printMsg($msg);
- echo '<form action="'.\SUBFOLDER."/src/views/rules\" method=\"post\">\n";
+ echo '<form action="' . \SUBFOLDER . "/src/views/rules\" method=\"post\">\n";
echo "<table>\n";
echo "<tr><th class=\"data left required\">{$this->lang['strname']}</th>\n";
echo "<td class=\"data1\"><input name=\"name\" size=\"16\" maxlength=\"{$data->_maxNameLen}\" value=\"",
@@ -249,7 +247,7 @@ class RulesController extends BaseController
$this->misc->printVal($_REQUEST[$_REQUEST['reltype']])
), "</p>\n";
- echo '<form action="'.\SUBFOLDER."/src/views/rules\" method=\"post\">\n";
+ echo '<form action="' . \SUBFOLDER . "/src/views/rules\" method=\"post\">\n";
echo "<input type=\"hidden\" name=\"action\" value=\"drop\" />\n";
echo '<input type="hidden" name="subject" value="', htmlspecialchars($_REQUEST['reltype']), "\" />\n";
echo '<input type="hidden" name="', htmlspecialchars($_REQUEST['reltype']),
diff --git a/src/controllers/SchemasController.php b/src/controllers/SchemasController.php
index a38c15dd..e73744f5 100644
--- a/src/controllers/SchemasController.php
+++ b/src/controllers/SchemasController.php
@@ -15,6 +15,7 @@ use PHPPgAdmin\Decorators\Decorator;
*/
class SchemasController extends BaseController
{
+ use \PHPPgAdmin\Traits\ExportTrait;
public $controller_title = 'strschemas';
/**
@@ -34,7 +35,6 @@ class SchemasController extends BaseController
}
$header_template = 'header.twig';
- $footer_template = 'footer.twig';
ob_start();
switch ($this->action) {
@@ -103,7 +103,7 @@ class SchemasController extends BaseController
'schema' => [
'title' => $this->lang['strschema'],
'field' => Decorator::field('nspname'),
- 'url' => \SUBFOLDER."/redirect/schema?{$this->misc->href}&amp;",
+ 'url' => \SUBFOLDER . "/redirect/schema?{$this->misc->href}&amp;",
'vars' => ['schema' => 'nspname'],
],
'owner' => [
@@ -281,7 +281,7 @@ class SchemasController extends BaseController
$this->printTitle($this->lang['strcreateschema'], 'pg.schema.create');
$this->printMsg($msg);
- echo '<form action="'.\SUBFOLDER.'/src/views/schemas" method="post">'."\n";
+ echo '<form action="' . \SUBFOLDER . '/src/views/schemas" method="post">' . "\n";
echo "<table style=\"width: 100%\">\n";
echo "\t<tr>\n\t\t<th class=\"data left required\">{$this->lang['strname']}</th>\n";
echo "\t\t<td class=\"data1\"><input name=\"formName\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" value=\"",
@@ -356,7 +356,7 @@ class SchemasController extends BaseController
$this->coalesceArr($_POST, 'owner', $schema->fields['ownername']);
- echo '<form action="'.\SUBFOLDER.'/src/views/schemas" method="post">'."\n";
+ echo '<form action="' . \SUBFOLDER . '/src/views/schemas" method="post">' . "\n";
echo "<table>\n";
echo "\t<tr>\n";
@@ -433,7 +433,7 @@ class SchemasController extends BaseController
$this->printTrail('schema');
$this->printTitle($this->lang['strdrop'], 'pg.schema.drop');
- echo '<form action="'.\SUBFOLDER.'/src/views/schemas" method="post">'."\n";
+ echo '<form action="' . \SUBFOLDER . '/src/views/schemas" method="post">' . "\n";
//If multi drop
if (isset($_REQUEST['ma'])) {
foreach ($_REQUEST['ma'] as $v) {
@@ -496,54 +496,25 @@ class SchemasController extends BaseController
*/
public function doExport($msg = '')
{
- $data = $this->misc->getDatabaseAccessor();
$this->printTrail('schema');
$this->printTabs('schema', 'export');
$this->printMsg($msg);
- echo '<form action="'.\SUBFOLDER.'/src/views/dbexport" method="post">'."\n";
-
- echo "<table>\n";
- echo "<tr><th class=\"data\">{$this->lang['strformat']}</th><th class=\"data\" colspan=\"2\">{$this->lang['stroptions']}</th></tr>\n";
- // Data only
- echo '<tr><th class="data left" rowspan="2">';
- echo "<input type=\"radio\" id=\"what1\" name=\"what\" value=\"dataonly\" checked=\"checked\" /><label for=\"what1\">{$this->lang['strdataonly']}</label></th>\n";
- echo "<td>{$this->lang['strformat']}</td>\n";
- echo "<td><select name=\"d_format\">\n";
- echo "<option value=\"copy\">COPY</option>\n";
- echo "<option value=\"sql\">SQL</option>\n";
- echo "</select>\n</td>\n</tr>\n";
- echo "<tr><td><label for=\"d_oids\">{$this->lang['stroids']}</label></td><td><input type=\"checkbox\" id=\"d_oids\" name=\"d_oids\" /></td>\n</tr>\n";
- // Structure only
- echo "<tr><th class=\"data left\"><input type=\"radio\" id=\"what2\" name=\"what\" value=\"structureonly\" /><label for=\"what2\">{$this->lang['strstructureonly']}</label></th>\n";
- echo "<td><label for=\"s_clean\">{$this->lang['strdrop']}</label></td><td><input type=\"checkbox\" id=\"s_clean\" name=\"s_clean\" /></td>\n</tr>\n";
- // Structure and data
- echo '<tr><th class="data left" rowspan="3">';
- echo "<input type=\"radio\" id=\"what3\" name=\"what\" value=\"structureanddata\" /><label for=\"what3\">{$this->lang['strstructureanddata']}</label></th>\n";
- echo "<td>{$this->lang['strformat']}</td>\n";
- echo "<td><select name=\"sd_format\">\n";
- echo "<option value=\"copy\">COPY</option>\n";
- echo "<option value=\"sql\">SQL</option>\n";
- echo "</select>\n</td>\n</tr>\n";
- echo "<tr><td><label for=\"sd_clean\">{$this->lang['strdrop']}</label></td><td><input type=\"checkbox\" id=\"sd_clean\" name=\"sd_clean\" /></td>\n</tr>\n";
- echo "<tr><td><label for=\"sd_oids\">{$this->lang['stroids']}</label></td><td><input type=\"checkbox\" id=\"sd_oids\" name=\"sd_oids\" /></td>\n</tr>\n";
- echo "</table>\n";
+ $subject = 'schema';
+ $object = $_REQUEST['schema'];
+
+ echo $this->formHeader('dbexport');
+
+ echo $this->dataOnly(true, true);
+
+ echo $this->structureOnly();
+
+ echo $this->structureAndData(true);
+
+ echo $this->displayOrDownload(!(strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE') && isset($_SERVER['HTTPS'])));
+
+ echo $this->formFooter($subject, $object);
- echo "<h3>{$this->lang['stroptions']}</h3>\n";
- echo "<p><input type=\"radio\" id=\"output1\" name=\"output\" value=\"show\" checked=\"checked\" /><label for=\"output1\">{$this->lang['strshow']}</label>\n";
- echo "<br/><input type=\"radio\" id=\"output2\" name=\"output\" value=\"download\" /><label for=\"output2\">{$this->lang['strdownload']}</label>\n";
- // MSIE cannot download gzip in SSL mode - it's just broken
- if (!(strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE') && isset($_SERVER['HTTPS']))) {
- echo "<br /><input type=\"radio\" id=\"output3\" name=\"output\" value=\"gzipped\" /><label for=\"output3\">{$this->lang['strdownloadgzipped']}</label>\n";
- }
- echo "</p>\n";
- echo "<p><input type=\"hidden\" name=\"action\" value=\"export\" />\n";
- echo "<input type=\"hidden\" name=\"subject\" value=\"schema\" />\n";
- echo '<input type="hidden" name="database" value="', htmlspecialchars($_REQUEST['database']), "\" />\n";
- echo '<input type="hidden" name="schema" value="', htmlspecialchars($_REQUEST['schema']), "\" />\n";
- echo $this->misc->form;
- echo "<input type=\"submit\" value=\"{$this->lang['strexport']}\" /></p>\n";
- echo "</form>\n";
}
}
diff --git a/src/controllers/TblpropertiesController.php b/src/controllers/TblpropertiesController.php
index 2df87255..663eabca 100644
--- a/src/controllers/TblpropertiesController.php
+++ b/src/controllers/TblpropertiesController.php
@@ -128,29 +128,29 @@ class TblpropertiesController extends BaseController
foreach ($p['keys'] as $k => $c) {
if (is_null($p['keys'][$k]['consrc'])) {
$atts = $data->getAttributeNames($_REQUEST['table'], explode(' ', $p['keys'][$k]['indkey']));
- $c['consrc'] = ('u' == $c['contype'] ? 'UNIQUE (' : 'PRIMARY KEY (').join(',', $atts).')';
+ $c['consrc'] = ('u' == $c['contype'] ? 'UNIQUE (' : 'PRIMARY KEY (') . join(',', $atts) . ')';
}
if ($c['p_field'] == $s) {
switch ($c['contype']) {
case 'p':
- $str .= '<a href="constraints?'.$misc->href.'&amp;table='.urlencode($c['p_table']).'&amp;schema='.urlencode($c['p_schema']).'"><img src="'.
- $misc->icon('PrimaryKey').'" alt="[pk]" title="'.htmlentities($c['consrc'], ENT_QUOTES, 'UTF-8').'" /></a>';
+ $str .= '<a href="constraints?' . $misc->href . '&amp;table=' . urlencode($c['p_table']) . '&amp;schema=' . urlencode($c['p_schema']) . '"><img src="' .
+ $misc->icon('PrimaryKey') . '" alt="[pk]" title="' . htmlentities($c['consrc'], ENT_QUOTES, 'UTF-8') . '" /></a>';
break;
case 'f':
- $str .= '<a href="tblproperties?'.$misc->href.'&amp;table='.urlencode($c['f_table']).'&amp;schema='.urlencode($c['f_schema']).'"><img src="'.
- $misc->icon('ForeignKey').'" alt="[fk]" title="'.htmlentities($c['consrc'], ENT_QUOTES, 'UTF-8').'" /></a>';
+ $str .= '<a href="tblproperties?' . $misc->href . '&amp;table=' . urlencode($c['f_table']) . '&amp;schema=' . urlencode($c['f_schema']) . '"><img src="' .
+ $misc->icon('ForeignKey') . '" alt="[fk]" title="' . htmlentities($c['consrc'], ENT_QUOTES, 'UTF-8') . '" /></a>';
break;
case 'u':
- $str .= '<a href="constraints?'.$misc->href.'&amp;table='.urlencode($c['p_table']).'&amp;schema='.urlencode($c['p_schema']).'"><img src="'.
- $misc->icon('UniqueConstraint').'" alt="[uniq]" title="'.htmlentities($c['consrc'], ENT_QUOTES, 'UTF-8').'" /></a>';
+ $str .= '<a href="constraints?' . $misc->href . '&amp;table=' . urlencode($c['p_table']) . '&amp;schema=' . urlencode($c['p_schema']) . '"><img src="' .
+ $misc->icon('UniqueConstraint') . '" alt="[uniq]" title="' . htmlentities($c['consrc'], ENT_QUOTES, 'UTF-8') . '" /></a>';
break;
case 'c':
- $str .= '<a href="constraints?'.$misc->href.'&amp;table='.urlencode($c['p_table']).'&amp;schema='.urlencode($c['p_schema']).'"><img src="'.
- $misc->icon('CheckConstraint').'" alt="[check]" title="'.htmlentities($c['consrc'], ENT_QUOTES, 'UTF-8').'" /></a>';
+ $str .= '<a href="constraints?' . $misc->href . '&amp;table=' . urlencode($c['p_table']) . '&amp;schema=' . urlencode($c['p_schema']) . '"><img src="' .
+ $misc->icon('CheckConstraint') . '" alt="[check]" title="' . htmlentities($c['consrc'], ENT_QUOTES, 'UTF-8') . '" /></a>';
}
}
}
@@ -178,7 +178,7 @@ class TblpropertiesController extends BaseController
'column' => [
'title' => $this->lang['strcolumn'],
'field' => Decorator::field('attname'),
- 'url' => "colproperties?subject=column&amp;{$misc->href}&amp;table=".urlencode($_REQUEST['table']).'&amp;',
+ 'url' => "colproperties?subject=column&amp;{$misc->href}&amp;table=" . urlencode($_REQUEST['table']) . '&amp;',
'vars' => ['column' => 'attname'],
],
'type' => [
@@ -496,7 +496,7 @@ class TblpropertiesController extends BaseController
$_POST['tablespace'] = $table->fields['tablespace'];
}
- echo '<form action="'.\SUBFOLDER."/src/views/tblproperties\" method=\"post\">\n";
+ echo '<form action="' . \SUBFOLDER . "/src/views/tblproperties\" method=\"post\">\n";
echo "<table>\n";
echo "<tr><th class=\"data left required\">{$this->lang['strname']}</th>\n";
echo '<td class="data1">';
@@ -583,8 +583,6 @@ class TblpropertiesController extends BaseController
// Structure and data
echo $this->structureAndData($hasID);
- echo "</table>\n";
-
echo $this->displayOrDownload();
echo $this->formFooter($subject, $object);
@@ -604,7 +602,7 @@ class TblpropertiesController extends BaseController
// Don't show upload option if max size of uploads is zero
$max_size = $misc->inisizeToBytes(ini_get('upload_max_filesize'));
if (is_double($max_size) && $max_size > 0) {
- echo '<form action="'.\SUBFOLDER."/src/views/dataimport\" method=\"post\" enctype=\"multipart/form-data\">\n";
+ echo '<form action="' . \SUBFOLDER . "/src/views/dataimport\" method=\"post\" enctype=\"multipart/form-data\">\n";
echo "<table>\n";
echo "\t<tr>\n\t\t<th class=\"data left required\">{$this->lang['strformat']}</th>\n";
echo "\t\t<td><select name=\"format\">\n";
@@ -669,8 +667,8 @@ class TblpropertiesController extends BaseController
$this->printTitle($this->lang['straddcolumn'], 'pg.column.add');
$this->printMsg($msg);
- echo '<script src="'.\SUBFOLDER.'/assets/js/tables.js" type="text/javascript"></script>';
- echo '<form action="'.\SUBFOLDER."/src/views/tblproperties\" method=\"post\">\n";
+ echo '<script src="' . \SUBFOLDER . '/assets/js/tables.js" type="text/javascript"></script>';
+ echo '<form action="' . \SUBFOLDER . "/src/views/tblproperties\" method=\"post\">\n";
// Output table header
echo "<table>\n";
@@ -736,7 +734,7 @@ class TblpropertiesController extends BaseController
echo "<input type=\"submit\" value=\"{$this->lang['stradd']}\" />\n";
echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" /></p>\n";
echo "</form>\n";
- echo '<script type="text/javascript">predefined_lengths = new Array('.implode(',', $escaped_predef_types).");checkLengths(document.getElementById('type').value,'');</script>\n";
+ echo '<script type="text/javascript">predefined_lengths = new Array(' . implode(',', $escaped_predef_types) . ");checkLengths(document.getElementById('type').value,'');</script>\n";
break;
case 2:
@@ -789,9 +787,9 @@ class TblpropertiesController extends BaseController
$this->printTrail('column');
$this->printTitle($this->lang['strdrop'], 'pg.column.drop');
- echo '<p>'.sprintf($this->lang['strconfdropcolumn'], $misc->printVal($_REQUEST['column']), $misc->printVal($_REQUEST['table']))."</p>\n";
+ echo '<p>' . sprintf($this->lang['strconfdropcolumn'], $misc->printVal($_REQUEST['column']), $misc->printVal($_REQUEST['table'])) . "</p>\n";
- echo '<form action="'.\SUBFOLDER."/src/views/tblproperties\" method=\"post\">\n";
+ echo '<form action="' . \SUBFOLDER . "/src/views/tblproperties\" method=\"post\">\n";
echo "<input type=\"hidden\" name=\"action\" value=\"drop\" />\n";
echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['table']), "\" />\n";
echo '<input type="hidden" name="column" value="', htmlspecialchars($_REQUEST['column']), "\" />\n";
diff --git a/src/traits/ExportTrait.php b/src/traits/ExportTrait.php
index 5742206e..b8aefb4a 100644
--- a/src/traits/ExportTrait.php
+++ b/src/traits/ExportTrait.php
@@ -17,10 +17,11 @@ trait ExportTrait
* prints the dataOnly option when exporting a table, view or materialized view
*
* @param boolean $hasID Indicates if the object has has an object ID
+ * @param boolean $onlyCopyAndSQL when exporting schema or DB, only copy or SQL formats are offered
*
* @return string html table row
*/
- public function dataOnly($hasID)
+ public function dataOnly($hasID, $onlyCopyAndSQL = false)
{
$content = '<tr>';
$content .= '<th class="data left" rowspan="' . ($hasID ? 2 : 1) . '">';
@@ -30,10 +31,14 @@ trait ExportTrait
$content .= '<td><select name="d_format">' . "\n";
$content .= '<option value="copy">COPY</option>' . "\n";
$content .= '<option value="sql">SQL</option>' . "\n";
- $content .= '<option value="csv">CSV</option>' . "\n";
- $content .= "<option value=\"tab\">{$this->lang['strtabbed']}</option>" . "\n";
- $content .= '<option value="html">XHTML</option>' . "\n";
- $content .= '<option value="xml">XML</option>' . "\n";
+
+ if (!$onlyCopyAndSQL) {
+ $content .= '<option value="csv">CSV</option>' . "\n";
+ $content .= "<option value=\"tab\">{$this->lang['strtabbed']}</option>" . "\n";
+ $content .= '<option value="html">XHTML</option>' . "\n";
+ $content .= '<option value="xml">XML</option>' . "\n";
+ }
+
$content .= sprintf('</select>%s</td>%s</tr>%s', "\n", "\n", "\n");
if ($hasID) {
@@ -89,9 +94,16 @@ trait ExportTrait
return $content;
}
- public function formHeader()
+ /**
+ * Returns the export form header
+ *
+ * @param string $endpoint The endpoint to send the request to (dataexport or dbexport)
+ *
+ * @return string the html for the form header
+ */
+ public function formHeader($endpoint = 'dataexport')
{
- $content = sprintf('<form action="%s" method=\"post\">%s', \SUBFOLDER . '/src/views/dataexport', "\n");
+ $content = sprintf('<form action="%s/%s" method=\"post\">%s', \SUBFOLDER . '/src/views', $endpoint, "\n");
$content .= "<table>\n";
$content .= sprintf('<tr><th class="data">%s</th>', $this->lang['strformat']);
$content .= sprintf('<th class="data" colspan="2">%s</th></tr>%s', $this->lang['stroptions'], "\n");
@@ -118,13 +130,27 @@ trait ExportTrait
return $content;
}
- public function displayOrDownload()
+ /**
+ * Offers the option of display, download and conditionally download gzipped
+ *
+ * @param bool $offerGzip Offer to download gzipped
+ *
+ * @return string the html of the display or download section
+ */
+ public function displayOrDownload($offerGzip = false)
{
- $content = sprintf('<h3>%s</h3>%s', $this->lang['stroptions'], "\n");
+ $content = sprintf('</table>%s', "\n");
+ $content .= sprintf('<h3>%s</h3>%s', $this->lang['stroptions'], "\n");
$content .= '<p><input type="radio" id="output1" name="output" value="show" checked="checked" />';
$content .= sprintf('<label for="output1">%s</label>', $this->lang['strshow'], "\n");
$content .= '<br/><input type="radio" id="output2" name="output" value="download" />';
- $content .= sprintf('<label for="output2">%s</label></p>%s', $this->lang['strdownload'], "\n");
+ $content .= sprintf('<label for="output2">%s</label>', $this->lang['strdownload']);
+
+ if ($offerGzip) {
+ $content .= '<br /><input type="radio" id="output3" name="output" value="gzipped" />';
+ $content .= sprintf('<label for="output3">%s</label>%s', $this->lang['strdownloadgzipped'], "\n");
+ }
+ $content .= sprintf('</p>%s', "\n");
return $content;
}
diff --git a/src/traits/ViewsAndMaterializedViewsTrait.php b/src/traits/ViewsAndMaterializedViewsTrait.php
index 95cddda7..5be8da1b 100644
--- a/src/traits/ViewsAndMaterializedViewsTrait.php
+++ b/src/traits/ViewsAndMaterializedViewsTrait.php
@@ -240,8 +240,6 @@ trait ViewsAndMaterializedViewsTrait
// Structure and data
// echo $this->structureAndData();
- echo "</table>\n";
-
echo $this->displayOrDownload();
echo $this->formFooter($subject, $object);