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/ViewsController.php | |
parent | c2a9af3868f88a47497b88b0dbd3ac4994e01670 (diff) |
add package tag to controllers
Diffstat (limited to 'src/controllers/ViewsController.php')
-rw-r--r-- | src/controllers/ViewsController.php | 141 |
1 files changed, 71 insertions, 70 deletions
diff --git a/src/controllers/ViewsController.php b/src/controllers/ViewsController.php index d5099026..3aee6e19 100644 --- a/src/controllers/ViewsController.php +++ b/src/controllers/ViewsController.php @@ -10,20 +10,21 @@ use PHPPgAdmin\Decorators\Decorator; /** * Base controller class. + * * @package PHPPgAdmin */ class ViewsController extends BaseController { - public $script = 'views.php'; + public $script = 'views.php'; public $controller_name = 'ViewsController'; - public $table_place = 'views-views'; + public $table_place = 'views-views'; /** * 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) { @@ -119,13 +120,13 @@ class ViewsController extends BaseController $views = $data->getViews(); $columns = [ - 'view' => [ + 'view' => [ 'title' => $lang['strview'], 'field' => Decorator::field('relname'), - 'url' => \SUBFOLDER . "/redirect/view?{$this->misc->href}&", - 'vars' => ['view' => 'relname'], + 'url' => \SUBFOLDER."/redirect/view?{$this->misc->href}&", + 'vars' => ['view' => 'relname'], ], - 'owner' => [ + 'owner' => [ 'title' => $lang['strowner'], 'field' => Decorator::field('relowner'), ], @@ -141,30 +142,30 @@ class ViewsController extends BaseController $actions = [ 'multiactions' => [ 'keycols' => ['view' => 'relname'], - 'url' => 'views.php', + 'url' => 'views.php', ], - 'browse' => [ + 'browse' => [ 'content' => $lang['strbrowse'], - 'attr' => [ + 'attr' => [ 'href' => [ - 'url' => 'display.php', + 'url' => 'display.php', 'urlvars' => [ - 'action' => 'confselectrows', + 'action' => 'confselectrows', 'subject' => 'view', - 'return' => 'schema', - 'view' => Decorator::field('relname'), + 'return' => 'schema', + 'view' => Decorator::field('relname'), ], ], ], ], - 'select' => [ + 'select' => [ 'content' => $lang['strselect'], - 'attr' => [ + 'attr' => [ 'href' => [ - 'url' => 'views.php', + 'url' => 'views.php', 'urlvars' => [ 'action' => 'confselectrows', - 'view' => Decorator::field('relname'), + 'view' => Decorator::field('relname'), ], ], ], @@ -177,27 +178,27 @@ class ViewsController extends BaseController // 'vars' => array('view' => 'relname'), // ), - 'alter' => [ + 'alter' => [ 'content' => $lang['stralter'], - 'attr' => [ + 'attr' => [ 'href' => [ - 'url' => 'viewproperties.php', + 'url' => 'viewproperties.php', 'urlvars' => [ 'action' => 'confirm_alter', - 'view' => Decorator::field('relname'), + 'view' => Decorator::field('relname'), ], ], ], ], - 'drop' => [ + 'drop' => [ 'multiaction' => 'confirm_drop', - 'content' => $lang['strdrop'], - 'attr' => [ + 'content' => $lang['strdrop'], + 'attr' => [ 'href' => [ - 'url' => 'views.php', + 'url' => 'views.php', 'urlvars' => [ 'action' => 'confirm_drop', - 'view' => Decorator::field('relname'), + 'view' => Decorator::field('relname'), ], ], ], @@ -207,29 +208,29 @@ class ViewsController extends BaseController echo $this->printTable($views, $columns, $actions, $this->table_place, $lang['strnoviews']); $navlinks = [ - 'create' => [ - 'attr' => [ + 'create' => [ + 'attr' => [ 'href' => [ - 'url' => 'views.php', + 'url' => 'views.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' => 'views.php', + 'url' => 'views.php', 'urlvars' => [ - 'action' => 'wiz_create', - 'server' => $_REQUEST['server'], + 'action' => 'wiz_create', + 'server' => $_REQUEST['server'], 'database' => $_REQUEST['database'], - 'schema' => $_REQUEST['schema'], + 'schema' => $_REQUEST['schema'], ], ], ], @@ -252,12 +253,12 @@ class ViewsController extends BaseController $reqvars = $this->misc->getRequestVars('view'); $attrs = [ - 'text' => Decorator::field('relname'), - 'icon' => 'View', + 'text' => Decorator::field('relname'), + 'icon' => 'View', 'iconAction' => Decorator::url('display.php', $reqvars, ['view' => Decorator::field('relname')]), - 'toolTip' => Decorator::field('relcomment'), - 'action' => Decorator::redirecturl('redirect.php', $reqvars, ['view' => Decorator::field('relname')]), - 'branch' => Decorator::url('views.php', $reqvars, ['action' => 'subtree', 'view' => Decorator::field('relname')]), + 'toolTip' => Decorator::field('relcomment'), + 'action' => Decorator::redirecturl('redirect.php', $reqvars, ['view' => Decorator::field('relname')]), + 'branch' => Decorator::url('views.php', $reqvars, ['action' => 'subtree', 'view' => Decorator::field('relname')]), ]; return $this->printTree($views, $attrs, 'views'); @@ -268,13 +269,13 @@ class ViewsController extends BaseController $lang = $this->lang; $data = $this->misc->getDatabaseAccessor(); - $tabs = $this->misc->getNavTabs('view'); - $items = $this->adjustTabsForTree($tabs); + $tabs = $this->misc->getNavTabs('view'); + $items = $this->adjustTabsForTree($tabs); $reqvars = $this->misc->getRequestVars('view'); $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'), ['view' => $_REQUEST['view']]), 'branch' => Decorator::ifempty( Decorator::field('branch'), @@ -285,7 +286,7 @@ class ViewsController extends BaseController $reqvars, [ 'action' => 'tree', - 'view' => $_REQUEST['view'], + 'view' => $_REQUEST['view'], ] ) ), @@ -312,7 +313,7 @@ class ViewsController extends BaseController $attrs = $data->getTableAttributes($_REQUEST['view']); - 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) { @@ -417,7 +418,7 @@ class ViewsController extends BaseController // Generate query SQL $query = $data->getSelectSQL($_REQUEST['view'], array_keys($_POST['show']), $_POST['values'], $_POST['ops']); - $_REQUEST['query'] = $query; + $_REQUEST['query'] = $query; $_REQUEST['return'] = 'schema'; $this->setNoOutput(true); @@ -445,7 +446,7 @@ class ViewsController extends BaseController $this->printTrail('view'); $this->printTitle($lang['strdrop'], 'pg.view.drop'); - echo '<form action="' . \SUBFOLDER . "/src/views/views.php\" method=\"post\">\n"; + echo '<form action="'.\SUBFOLDER."/src/views/views.php\" method=\"post\">\n"; //If multi drop if (isset($_REQUEST['ma'])) { @@ -468,7 +469,7 @@ class ViewsController extends BaseController echo "</form>\n"; } else { if (is_array($_POST['view'])) { - $msg = ''; + $msg = ''; $status = $data->beginTransaction(); if (0 == $status) { foreach ($_POST['view'] as $s) { @@ -539,7 +540,7 @@ class ViewsController 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 @@ -556,8 +557,8 @@ class ViewsController 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(); } @@ -566,7 +567,7 @@ class ViewsController extends BaseController } asort($arrFields); - echo '<form action="' . \SUBFOLDER . "/src/views/views.php\" method=\"post\">\n"; + echo '<form action="'.\SUBFOLDER."/src/views/views.php\" method=\"post\">\n"; echo "<table>\n"; echo "<tr><th class=\"data\">{$lang['strviewname']}</th></tr>"; echo "<tr>\n<td class=\"data1\">\n"; @@ -604,11 +605,11 @@ class ViewsController 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 = ''; } @@ -645,7 +646,7 @@ class ViewsController 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; @@ -671,17 +672,17 @@ class ViewsController extends BaseController $this->printTitle($lang['strcreateviewwiz'], 'pg.view.create'); $this->printMsg($msg); - echo '<form action="' . \SUBFOLDER . "/src/views/views.php\" method=\"post\">\n"; + echo '<form action="'.\SUBFOLDER."/src/views/views.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); @@ -724,7 +725,7 @@ class ViewsController extends BaseController $this->printTitle($lang['strcreateview'], 'pg.view.create'); $this->printMsg($msg); - echo '<form action="' . \SUBFOLDER . "/src/views/views.php\" method=\"post\">\n"; + echo '<form action="'.\SUBFOLDER."/src/views/views.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=\"", @@ -823,8 +824,8 @@ class ViewsController 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 @@ -832,7 +833,7 @@ class ViewsController 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); @@ -843,7 +844,7 @@ class ViewsController 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']}\") "; @@ -889,7 +890,7 @@ class ViewsController 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']); |