{$term}", $string); } /** * Default method to render the controller according to the action parameter. */ public function render() { if ('tree' == $this->action) { return $this->doTree(); } if ('refresh_locks' == $this->action) { return $this->currentLocks(true); } if ('refresh_processes' == $this->action) { return $this->currentProcesses(true); } $scripts = ''; // normal flow if ('locks' == $this->action || 'processes' == $this->action) { $scripts .= ''; $refreshTime = $this->conf['ajax_refresh'] * 1500; $scripts .= ''.PHP_EOL; } $header_template = 'header.twig'; $footer_template = 'footer.twig'; // @todo convert all these methods to return text instead of print text ob_start(); switch ($this->action) { case 'find': if (isset($_REQUEST['term'])) { $this->printFindForm(false); } else { $this->printFindForm(true); } break; case 'sql': $this->doSQL(); $header_template = 'header_sqledit.twig'; $footer_template = 'footer_sqledit.twig'; break; case 'variables': $this->doVariables(); break; case 'processes': $this->doProcesses(); break; case 'locks': $this->doLocks(); break; case 'export': $this->doExport(); break; case 'signal': $this->doSignal(); break; default: if (false === $this->adminActions($this->action, 'database')) { $header_template = 'header_sqledit.twig'; $footer_template = 'footer_sqledit.twig'; $this->doSQL(); } break; } $output = ob_get_clean(); $this->printHeader($this->headerTitle(), $scripts, true, $header_template); $this->printBody(); echo $output; $this->printFooter(true, $footer_template); } public function doTree($print = true) { $reqvars = $this->misc->getRequestVars('database'); $tabs = $this->misc->getNavTabs('database'); $items = $this->adjustTabsForTree($tabs); $attrs = [ 'text' => Decorator::field('title'), 'icon' => Decorator::field('icon'), 'action' => Decorator::actionurl( Decorator::field('url'), $reqvars, Decorator::field('urlvars'), [ 'database' => $this->misc->getDatabase(), ] ), 'branch' => Decorator::branchurl( Decorator::field('url'), $reqvars, Decorator::field('urlvars'), [ 'action' => 'tree', 'database' => $this->misc->getDatabase(), ] ), ]; return $this->printTree($items, $attrs, 'database', $print); } /** * Sends a signal to a process. */ public function doSignal() { $data = $this->misc->getDatabaseAccessor(); $status = $data->sendSignal($_REQUEST['pid'], $_REQUEST['signal']); if (0 == $status) { $this->doProcesses($this->lang['strsignalsent']); } else { $this->doProcesses($this->lang['strsignalsentbad']); } } /** * Searches for a named database object. * * @param mixed $confirm * @param mixed $msg */ public function printFindForm($confirm = true, $msg = '') { $data = $this->misc->getDatabaseAccessor(); $this->coalesceArr($_REQUEST, 'term', ''); $this->coalesceArr($_REQUEST, 'filter', ''); $this->printTrail('database'); $this->printTabs('database', 'find'); $this->printMsg($msg); echo '
'.PHP_EOL; // Default focus $this->setFocus('forms[0].term'); // If a search term has been specified, then perform the search // and display the results, grouped by object type if (!$confirm && '' != $_REQUEST['term']) { return $this->doFind(); } } private function _printTypeOption($curr) { $filter = $_REQUEST['filter']; $optionhtml = sprintf('%s'.PHP_EOL; return $optionhtml; } private function _translatedType($curr) { $types = [ 'COLUMN' => $this->lang['strcolumns'], 'CONSTRAINT' => $this->lang['strconstraints'], 'COLUMNTABLE' => $this->lang['strcolumns'], 'COLUMNVIEW' => $this->lang['strcolumns'], 'CONSTRAINTDOMAIN' => $this->lang['strconstraints'], 'CONSTRAINTTABLE' => $this->lang['strconstraints'], 'DOMAIN' => $this->lang['strdomains'], 'FUNCTION' => $this->lang['strfunctions'], 'INDEX' => $this->lang['strindexes'], 'RULE' => $this->lang['strrules'], 'RULETABLE' => $this->lang['strrules'], 'RULEVIEW' => $this->lang['strrules'], 'SCHEMA' => $this->lang['strschemas'], 'SEQUENCE' => $this->lang['strsequences'], 'TABLE' => $this->lang['strtables'], 'TRIGGER' => $this->lang['strtriggers'], 'VIEW' => $this->lang['strviews'], 'AGGREGATE' => $this->lang['straggregates'], 'CONVERSION' => $this->lang['strconversions'], 'LANGUAGE' => $this->lang['strlanguages'], 'OPCLASS' => $this->lang['stropclasses'], 'OPERATOR' => $this->lang['stroperators'], 'TYPE' => $this->lang['strtypes'], ]; if (array_key_exists($curr, $types)) { return $types[$curr]; } return $this->lang['strallobjects']; } private function _printHtmlForType($curr, $rs) { $destination = null; switch ($curr) { case 'SCHEMA': $destination = $this->container->utils->getDestinationWithLastTab('schema'); echo '', $rs->recordCount(), ' ', $this->lang['strobjects'], '
'.PHP_EOL; } else { echo "{$this->lang['strnoobjects']}
".PHP_EOL; } } /** * Displays options for database download. * * @param mixed $msg */ public function doExport($msg = '') { $this->printTrail('database'); $this->printTabs('database', 'export'); $this->printMsg($msg); $subject = 'database'; $object = $_REQUEST['database']; echo $this->formHeader('dbexport'); echo $this->dataOnly(true, true); echo $this->structureOnly(); echo $this->structureAndData(true); // $server_info = $this->misc->getServerInfo(); // echo $this->offerNoRoleExport(isset($server_info['pgVersion']) && floatval(substr($server_info['pgVersion'], 0, 3)) >= 10); echo $this->displayOrDownload(!(strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE') && isset($_SERVER['HTTPS']))); echo $this->formFooter($subject, $object); } /** * Show the current status of all database variables. */ public function doVariables() { $data = $this->misc->getDatabaseAccessor(); // Fetch the variables from the database $variables = $data->getVariables(); $this->printTrail('database'); $this->printTabs('database', 'variables'); $columns = [ 'variable' => [ 'title' => $this->lang['strname'], 'field' => Decorator::field('name'), ], 'value' => [ 'title' => $this->lang['strsetting'], 'field' => Decorator::field('setting'), ], ]; $actions = []; echo $this->printTable($variables, $columns, $actions, $this->table_place, $this->lang['strnodata']); } /** * Show all current database connections and any queries they * are running. * * @param mixed $msg */ public function doProcesses($msg = '') { $this->printTrail('database'); $this->printTabs('database', 'processes'); $this->printMsg($msg); if (0 === strlen($msg)) { echo '{$this->lang['strentersql']}
".PHP_EOL; echo ''.PHP_EOL; // Default focus $this->setFocus('forms[0].query'); } /** * This functions does pretty much nothing. It's meant to implement * an abstract method of AdminTrait. * * @param string $msg The message * * @return string The message */ public function doDefault($msg = '') { return $msg; } }