diff options
author | Felipe Figueroa <amenadiel@gmail.com> | 2018-03-15 02:02:10 +0300 |
---|---|---|
committer | Felipe Figueroa <amenadiel@gmail.com> | 2018-03-15 02:02:10 +0300 |
commit | 49270fe791619ba2d0dbf666cfa66ca80457dd44 (patch) | |
tree | 916738a0243836b5cfba76c470b083bd4e344ed1 /src/controllers/MaterializedviewsController.php | |
parent | c2a9af3868f88a47497b88b0dbd3ac4994e01670 (diff) |
add package tag to controllers
Diffstat (limited to 'src/controllers/MaterializedviewsController.php')
-rw-r--r-- | src/controllers/MaterializedviewsController.php | 141 |
1 files changed, 71 insertions, 70 deletions
diff --git a/src/controllers/MaterializedviewsController.php b/src/controllers/MaterializedviewsController.php index 08cd6a92..43296549 100644 --- a/src/controllers/MaterializedviewsController.php +++ b/src/controllers/MaterializedviewsController.php @@ -10,20 +10,21 @@ use PHPPgAdmin\Decorators\Decorator; /** * Base controller class. + * * @package PHPPgAdmin */ class MaterializedviewsController extends BaseController { - public $script = 'materializedviews.php'; + public $script = 'materializedviews.php'; public $controller_name = 'MaterializedviewsController'; - public $table_place = 'matviews-matviews'; + public $table_place = 'matviews-matviews'; /** * Default method to render the controller according to the action parameter. */ public function render() { - $lang = $this->lang; + $lang = $this->lang; $action = $this->action; if ('tree' == $action) { @@ -33,7 +34,7 @@ class MaterializedviewsController extends BaseController return $this->doSubTree(); } - $this->printHeader('M ' . $lang['strviews']); + $this->printHeader('M '.$lang['strviews']); $this->printBody(); switch ($action) { @@ -121,12 +122,12 @@ class MaterializedviewsController extends BaseController $columns = [ 'matview' => [ - 'title' => 'M ' . $lang['strview'], + 'title' => 'M '.$lang['strview'], 'field' => Decorator::field('relname'), - 'url' => \SUBFOLDER . "/redirect/matview?{$this->misc->href}&", - 'vars' => ['matview' => 'relname'], + 'url' => \SUBFOLDER."/redirect/matview?{$this->misc->href}&", + 'vars' => ['matview' => 'relname'], ], - 'owner' => [ + 'owner' => [ 'title' => $lang['strowner'], 'field' => Decorator::field('relowner'), ], @@ -142,29 +143,29 @@ class MaterializedviewsController extends BaseController $actions = [ 'multiactions' => [ 'keycols' => ['matview' => 'relname'], - 'url' => 'materializedviews.php', + 'url' => 'materializedviews.php', ], - 'browse' => [ + 'browse' => [ 'content' => $lang['strbrowse'], - 'attr' => [ + 'attr' => [ 'href' => [ - 'url' => 'display.php', + 'url' => 'display.php', 'urlvars' => [ - 'action' => 'confselectrows', + 'action' => 'confselectrows', 'subject' => 'matview', - 'return' => 'schema', + 'return' => 'schema', 'matview' => Decorator::field('relname'), ], ], ], ], - 'select' => [ + 'select' => [ 'content' => $lang['strselect'], - 'attr' => [ + 'attr' => [ 'href' => [ - 'url' => 'materializedviews.php', + 'url' => 'materializedviews.php', 'urlvars' => [ - 'action' => 'confselectrows', + 'action' => 'confselectrows', 'matview' => Decorator::field('relname'), ], ], @@ -178,26 +179,26 @@ class MaterializedviewsController extends BaseController // 'vars' => array('view' => 'relname'), // ), - 'alter' => [ + 'alter' => [ 'content' => $lang['stralter'], - 'attr' => [ + 'attr' => [ 'href' => [ - 'url' => 'materializedviewproperties.php', + 'url' => 'materializedviewproperties.php', 'urlvars' => [ - 'action' => 'confirm_alter', + 'action' => 'confirm_alter', 'matview' => Decorator::field('relname'), ], ], ], ], - 'drop' => [ + 'drop' => [ 'multiaction' => 'confirm_drop', - 'content' => $lang['strdrop'], - 'attr' => [ + 'content' => $lang['strdrop'], + 'attr' => [ 'href' => [ - 'url' => 'materializedviews.php', + 'url' => 'materializedviews.php', 'urlvars' => [ - 'action' => 'confirm_drop', + 'action' => 'confirm_drop', 'matview' => Decorator::field('relname'), ], ], @@ -208,29 +209,29 @@ class MaterializedviewsController extends BaseController echo $this->printTable($matviews, $columns, $actions, $this->table_place, $lang['strnoviews']); $navlinks = [ - 'create' => [ - 'attr' => [ + 'create' => [ + 'attr' => [ 'href' => [ - 'url' => 'materializedviews.php', + 'url' => 'materializedviews.php', 'urlvars' => [ - 'action' => 'create', - 'server' => $_REQUEST['server'], + 'action' => 'create', + 'server' => $_REQUEST['server'], 'database' => $_REQUEST['database'], - 'schema' => $_REQUEST['schema'], + 'schema' => $_REQUEST['schema'], ], ], ], 'content' => $lang['strcreateview'], ], 'createwiz' => [ - 'attr' => [ + 'attr' => [ 'href' => [ - 'url' => 'materializedviews.php', + 'url' => 'materializedviews.php', 'urlvars' => [ - 'action' => 'wiz_create', - 'server' => $_REQUEST['server'], + 'action' => 'wiz_create', + 'server' => $_REQUEST['server'], 'database' => $_REQUEST['database'], - 'schema' => $_REQUEST['schema'], + 'schema' => $_REQUEST['schema'], ], ], ], @@ -253,12 +254,12 @@ class MaterializedviewsController extends BaseController $reqvars = $this->misc->getRequestVars('matview'); $attrs = [ - 'text' => Decorator::field('relname'), - 'icon' => 'MView', + 'text' => Decorator::field('relname'), + 'icon' => 'MView', 'iconAction' => Decorator::url('display.php', $reqvars, ['matview' => Decorator::field('relname')]), - 'toolTip' => Decorator::field('relcomment'), - 'action' => Decorator::redirecturl('redirect.php', $reqvars, ['matview' => Decorator::field('relname')]), - 'branch' => Decorator::url('materializedviews.php', $reqvars, ['action' => 'subtree', 'matview' => Decorator::field('relname')]), + 'toolTip' => Decorator::field('relcomment'), + 'action' => Decorator::redirecturl('redirect.php', $reqvars, ['matview' => Decorator::field('relname')]), + 'branch' => Decorator::url('materializedviews.php', $reqvars, ['action' => 'subtree', 'matview' => Decorator::field('relname')]), ]; return $this->printTree($matviews, $attrs, 'matviews'); @@ -269,13 +270,13 @@ class MaterializedviewsController extends BaseController $lang = $this->lang; $data = $this->misc->getDatabaseAccessor(); - $tabs = $this->misc->getNavTabs('matview'); - $items = $this->adjustTabsForTree($tabs); + $tabs = $this->misc->getNavTabs('matview'); + $items = $this->adjustTabsForTree($tabs); $reqvars = $this->misc->getRequestVars('matview'); $attrs = [ - 'text' => Decorator::field('title'), - 'icon' => Decorator::field('icon'), + 'text' => Decorator::field('title'), + 'icon' => Decorator::field('icon'), 'action' => Decorator::actionurl(Decorator::field('url'), $reqvars, Decorator::field('urlvars'), ['matview' => $_REQUEST['matview']]), 'branch' => Decorator::ifempty( Decorator::field('branch'), @@ -285,7 +286,7 @@ class MaterializedviewsController extends BaseController Decorator::field('urlvars'), $reqvars, [ - 'action' => 'tree', + 'action' => 'tree', 'matview' => $_REQUEST['matview'], ] ) @@ -313,7 +314,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) { @@ -418,7 +419,7 @@ class MaterializedviewsController extends BaseController // Generate query SQL $query = $data->getSelectSQL($_REQUEST['matview'], array_keys($_POST['show']), $_POST['values'], $_POST['ops']); - $_REQUEST['query'] = $query; + $_REQUEST['query'] = $query; $_REQUEST['return'] = 'schema'; $this->setNoOutput(true); @@ -446,7 +447,7 @@ class MaterializedviewsController extends BaseController $this->printTrail('getTrail'); $this->printTitle($lang['strdrop'], 'pg.matview.drop'); - echo '<form action="' . \SUBFOLDER . "/src/views/materializedviews.php\" method=\"post\">\n"; + echo '<form action="'.\SUBFOLDER."/src/views/materializedviews.php\" method=\"post\">\n"; //If multi drop if (isset($_REQUEST['ma'])) { @@ -469,7 +470,7 @@ class MaterializedviewsController extends BaseController echo "</form>\n"; } else { if (is_array($_POST['view'])) { - $msg = ''; + $msg = ''; $status = $data->beginTransaction(); if (0 == $status) { foreach ($_POST['view'] as $s) { @@ -540,7 +541,7 @@ class MaterializedviewsController extends BaseController //get linking keys $rsLinkKeys = $data->getLinkingKeys($arrSelTables); - $linkCount = $rsLinkKeys->recordCount() > $tblCount ? $rsLinkKeys->recordCount() : $tblCount; + $linkCount = $rsLinkKeys->recordCount() > $tblCount ? $rsLinkKeys->recordCount() : $tblCount; $arrFields = []; //array that will hold all our table/field names @@ -557,8 +558,8 @@ class MaterializedviewsController extends BaseController $arrFields["{$arrSelTables[$i]['schemaname']}.{$arrSelTables[$i]['tablename']}.{$attrs->fields['attname']}"] = serialize( [ 'schemaname' => $arrSelTables[$i]['schemaname'], - 'tablename' => $arrSelTables[$i]['tablename'], - 'fieldname' => $attrs->fields['attname']] + 'tablename' => $arrSelTables[$i]['tablename'], + 'fieldname' => $attrs->fields['attname'], ] ); $attrs->moveNext(); } @@ -567,7 +568,7 @@ class MaterializedviewsController extends BaseController } asort($arrFields); - echo '<form action="' . \SUBFOLDER . "/src/views/materializedviews.php\" method=\"post\">\n"; + echo '<form action="'.\SUBFOLDER."/src/views/materializedviews.php\" method=\"post\">\n"; echo "<table>\n"; echo "<tr><th class=\"data\">{$lang['strviewname']}</th></tr>"; echo "<tr>\n<td class=\"data1\">\n"; @@ -605,11 +606,11 @@ class MaterializedviewsController extends BaseController echo "<tr>\n<td class=\"${rowClass}\">\n"; if (!$rsLinkKeys->EOF) { - $curLeftLink = htmlspecialchars(serialize(['schemaname' => $rsLinkKeys->fields['p_schema'], 'tablename' => $rsLinkKeys->fields['p_table'], 'fieldname' => $rsLinkKeys->fields['p_field']])); + $curLeftLink = htmlspecialchars(serialize(['schemaname' => $rsLinkKeys->fields['p_schema'], 'tablename' => $rsLinkKeys->fields['p_table'], 'fieldname' => $rsLinkKeys->fields['p_field']])); $curRightLink = htmlspecialchars(serialize(['schemaname' => $rsLinkKeys->fields['f_schema'], 'tablename' => $rsLinkKeys->fields['f_table'], 'fieldname' => $rsLinkKeys->fields['f_field']])); $rsLinkKeys->moveNext(); } else { - $curLeftLink = ''; + $curLeftLink = ''; $curRightLink = ''; } @@ -646,7 +647,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; @@ -672,17 +673,17 @@ class MaterializedviewsController extends BaseController $this->printTitle($lang['strcreateviewwiz'], 'pg.matview.create'); $this->printMsg($msg); - echo '<form action="' . \SUBFOLDER . "/src/views/materializedviews.php\" method=\"post\">\n"; + echo '<form action="'.\SUBFOLDER."/src/views/materializedviews.php\" method=\"post\">\n"; echo "<table>\n"; echo "<tr><th class=\"data\">{$lang['strtables']}</th></tr>"; echo "<tr>\n<td class=\"data1\">\n"; $arrTables = []; while (!$tables->EOF) { - $arrTmp = []; - $arrTmp['schemaname'] = $tables->fields['nspname']; - $arrTmp['tablename'] = $tables->fields['relname']; - $arrTables[$tables->fields['nspname'] . '.' . $tables->fields['relname']] = serialize($arrTmp); + $arrTmp = []; + $arrTmp['schemaname'] = $tables->fields['nspname']; + $arrTmp['tablename'] = $tables->fields['relname']; + $arrTables[$tables->fields['nspname'].'.'.$tables->fields['relname']] = serialize($arrTmp); $tables->moveNext(); } echo \PHPPgAdmin\XHtml\HTMLController::printCombo($arrTables, 'formTables[]', false, '', true); @@ -725,7 +726,7 @@ class MaterializedviewsController extends BaseController $this->printTitle($lang['strcreateview'], 'pg.matview.create'); $this->printMsg($msg); - echo '<form action="' . \SUBFOLDER . "/src/views/materializedviews.php\" method=\"post\">\n"; + echo '<form action="'.\SUBFOLDER."/src/views/materializedviews.php\" method=\"post\">\n"; echo "<table style=\"width: 100%\">\n"; echo "\t<tr>\n\t\t<th class=\"data left required\">{$lang['strname']}</th>\n"; echo "\t<td class=\"data1\"><input name=\"formView\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" value=\"", @@ -824,8 +825,8 @@ class MaterializedviewsController extends BaseController } } // We must perform some magic to make sure that we have a valid join order - $count = sizeof($arrLinks); - $arrJoined = []; + $count = sizeof($arrLinks); + $arrJoined = []; $arrUsedTbls = []; // If we have at least one join condition, output it @@ -833,7 +834,7 @@ class MaterializedviewsController extends BaseController $j = 0; while ($j < $count) { foreach ($arrLinks as $curLink) { - $arrLeftLink = unserialize($curLink['leftlink']); + $arrLeftLink = unserialize($curLink['leftlink']); $arrRightLink = unserialize($curLink['rightlink']); $data->fieldArrayClean($arrLeftLink); $data->fieldArrayClean($arrRightLink); @@ -844,7 +845,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']}\") "; @@ -890,7 +891,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']); |