action) { return $this->doTree(); } $this->printHeader(); $this->printBody(); switch ($this->action) { /*case 'save_create': if (isset($_POST['cancel'])) { $this->doDefault(); } else { $this->doSaveCreate(); } break; case 'create': $this->doCreate(); break;*/ case 'drop': if (isset($_POST['cancel'])) { $this->doDefault(); } else { $this->doDrop(false); } break; case 'confirm_drop': $this->doDrop(true); break; case 'properties': $this->doProperties(); break; default: $this->doDefault(); break; } $this->printFooter(); } /** * Generate XML for the browser tree. */ public function doTree() { $data = $this->misc->getDatabaseAccessor(); $operators = $data->getOperators(); // Operator prototype: "type operator type" $proto = Decorator::concat(Decorator::field('oprleftname'), ' ', Decorator::field('oprname'), ' ', Decorator::field('oprrightname')); $reqvars = $this->misc->getRequestVars('operator'); $attrs = [ 'text' => $proto, 'icon' => 'Operator', 'toolTip' => Decorator::field('oprcomment'), 'action' => Decorator::actionurl( 'operators', $reqvars, [ 'action' => 'properties', 'operator' => $proto, 'operator_oid' => Decorator::field('oid'), ] ), ]; return $this->printTree($operators, $attrs, 'operators'); } /** * Show default list of operators in the database. * * @param mixed $msg */ public function doDefault($msg = '') { $data = $this->misc->getDatabaseAccessor(); $this->printTrail('schema'); $this->printTabs('schema', 'operators'); $this->printMsg($msg); $operators = $data->getOperators(); $columns = [ 'operator' => [ 'title' => $this->lang['stroperator'], 'field' => Decorator::field('oprname'), 'url' => "operators?action=properties&{$this->misc->href}&", 'vars' => ['operator' => 'oprname', 'operator_oid' => 'oid'], ], 'leftarg' => [ 'title' => $this->lang['strleftarg'], 'field' => Decorator::field('oprleftname'), ], 'rightarg' => [ 'title' => $this->lang['strrightarg'], 'field' => Decorator::field('oprrightname'), ], 'returns' => [ 'title' => $this->lang['strreturns'], 'field' => Decorator::field('resultname'), ], 'actions' => [ 'title' => $this->lang['stractions'], ], 'comment' => [ 'title' => $this->lang['strcomment'], 'field' => Decorator::field('oprcomment'), ], ]; $actions = [ 'drop' => [ // 'title' => $this->lang['strdrop'], // 'url' => "operators?action=confirm_drop&{$this->misc->href}&", // 'vars' => array('operator' => 'oprname', 'operator_oid' => 'oid'), 'content' => $this->lang['strdrop'], 'attr' => [ 'href' => [ 'url' => 'operators', 'urlvars' => [ 'action' => 'confirm_drop', 'operator' => Decorator::field('oprname'), 'operator_oid' => Decorator::field('oid'), ], ], ], ], ]; echo $this->printTable($operators, $columns, $actions, 'operators-operators', $this->lang['strnooperators']); // TODO operators action=create $this->lang['strcreateoperator'] } /** * Show read only properties for an operator. * * @param mixed $msg */ public function doProperties($msg = '') { $data = $this->misc->getDatabaseAccessor(); $this->printTrail('operator'); $this->printTitle($this->lang['strproperties'], 'pg.operator'); $this->printMsg($msg); $oprdata = $data->getOperator($_REQUEST['operator_oid']); $oprdata->fields['oprcanhash'] = $data->phpBool($oprdata->fields['oprcanhash']); if ($oprdata->recordCount() > 0) { echo ''.PHP_EOL; echo "".PHP_EOL; echo ''.PHP_EOL; echo "".PHP_EOL; echo ''.PHP_EOL; echo "".PHP_EOL; echo ''.PHP_EOL; echo "".PHP_EOL; echo ''.PHP_EOL; echo "".PHP_EOL; echo ''.PHP_EOL; echo "".PHP_EOL; echo ''.PHP_EOL; echo "".PHP_EOL; echo ''.PHP_EOL; // these field only exists in 8.2 and before in pg_catalog if (isset($oprdata->fields['oprlsortop'])) { echo "".PHP_EOL; echo ''.PHP_EOL; echo "".PHP_EOL; echo ''.PHP_EOL; echo "".PHP_EOL; echo ''.PHP_EOL; echo "".PHP_EOL; echo ''.PHP_EOL; echo "".PHP_EOL; echo ''.PHP_EOL; echo "".PHP_EOL; echo ''.PHP_EOL; } else { echo "".PHP_EOL; echo ''.PHP_EOL; } echo '
{$this->lang['strname']}', $this->misc->printVal($oprdata->fields['oprname']), '
{$this->lang['strleftarg']}', $this->misc->printVal($oprdata->fields['oprleftname']), '
{$this->lang['strrightarg']}', $this->misc->printVal($oprdata->fields['oprrightname']), '
{$this->lang['strcommutator']}', $this->misc->printVal($oprdata->fields['oprcom']), '
{$this->lang['strnegator']}', $this->misc->printVal($oprdata->fields['oprnegate']), '
{$this->lang['strjoin']}', $this->misc->printVal($oprdata->fields['oprjoin']), '
{$this->lang['strhashes']}', ($oprdata->fields['oprcanhash']) ? $this->lang['stryes'] : $this->lang['strno'], '
{$this->lang['strmerges']}', ('0' !== $oprdata->fields['oprlsortop'] && '0' !== $oprdata->fields['oprrsortop']) ? $this->lang['stryes'] : $this->lang['strno'], '
{$this->lang['strrestrict']}', $this->misc->printVal($oprdata->fields['oprrest']), '
{$this->lang['strleftsort']}', $this->misc->printVal($oprdata->fields['oprlsortop']), '
{$this->lang['strrightsort']}', $this->misc->printVal($oprdata->fields['oprrsortop']), '
{$this->lang['strlessthan']}', $this->misc->printVal($oprdata->fields['oprltcmpop']), '
{$this->lang['strgreaterthan']}', $this->misc->printVal($oprdata->fields['oprgtcmpop']), '
{$this->lang['strmerges']}', $data->phpBool($oprdata->fields['oprcanmerge']) ? $this->lang['stryes'] : $this->lang['strno'], '
'.PHP_EOL; $this->printNavLinks( [ 'showall' => [ 'attr' => [ 'href' => [ 'url' => 'operators', 'urlvars' => [ 'server' => $_REQUEST['server'], 'database' => $_REQUEST['database'], 'schema' => $_REQUEST['schema'], ], ], ], 'content' => $this->lang['strshowalloperators'], ], ], 'operators-properties', get_defined_vars() ); } else { $this->doDefault($this->lang['strinvalidparam']); } } /** * Show confirmation of drop and perform actual drop. * * @param mixed $confirm */ public function doDrop($confirm) { $data = $this->misc->getDatabaseAccessor(); if ($confirm) { $this->printTrail('operator'); $this->printTitle($this->lang['strdrop'], 'pg.operator.drop'); echo '

', sprintf($this->lang['strconfdropoperator'], $this->misc->printVal($_REQUEST['operator'])), '

'.PHP_EOL; echo '
'.PHP_EOL; echo "

".PHP_EOL; echo '

'.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo $this->misc->form; echo "lang['strdrop']}\" />".PHP_EOL; echo "lang['strcancel']}\" />

".PHP_EOL; echo '
'.PHP_EOL; } else { $status = $data->dropOperator($_POST['operator_oid'], isset($_POST['cascade'])); if (0 == $status) { $this->doDefault($this->lang['stroperatordropped']); } else { $this->doDefault($this->lang['stroperatordroppedbad']); } } } }