User->GetParameter('xcs_tree_name'); $cols = []; if(!empty($table)) { $columns = $app->DB->SelectArrCache( sprintf( 'SHOW COLUMNS FROM `%s` ', $table), 60, 'xcs_column' ); if(!empty($columns)) { foreach($columns as $key => $column) { $cols[] = reset($column); if($key > 74) { break; } } } } $firstCol = reset($cols); $heading = array_merge($cols, ['']); $findcols = array_merge($cols, [$firstCol]); $searchsql = $cols; $sql = sprintf( "SELECT `%s`, IFNULL(`%s`, '') FROM `%s`", $firstCol, implode("`,''), IFNULL(`", $cols), $table ); $fastcount = sprintf('SELECT COUNT(*) FROM `%s`', $table); break; } $erg = []; foreach($erlaubtevars as $k => $v) { if(isset($$v)) { $erg[$v] = $$v; } } return $erg; } /** * Databaseviewer constructor. * * @param Application $app * @param bool $intern */ public function __construct($app, $intern = false) { $this->app=$app; if($intern) { return; } $this->app->ActionHandlerInit($this); // ab hier alle Action Handler definieren die das Modul hat $this->app->ActionHandler("list", "DatabaseViewerList"); $this->app->ActionHandler("treeajax", "DatabaseViewerTreeAjax"); $this->app->ActionHandlerListen($app); } public function DatabaseViewerMenu() { $this->app->erp->MenuEintrag('index.php?module=databaseviewer&action=list', 'Übersicht'); } public function DatabaseViewerList() { $cmd = $this->app->Secure->GetGET('cmd'); if($cmd === 'filtertree') { $tableName = $this->app->Secure->GetPOST('name'); $this->app->User->SetParameter('xcs_tree_id',$this->app->Secure->GetPOST('id')); $this->app->User->SetParameter('xcs_tree_name', $tableName); $tableColumns = $this->app->DB->SelectArrCache( sprintf( 'SHOW COLUMNS FROM `%s` ', $tableName), 60, 'xcs_column' ); $html = ''; if((!empty($tableColumns)?count($tableColumns):0) > 75) { $html = '
Die Tabellenansicht wurde auf 75 Spalten gekürzt
'; } $this->app->YUI->TableSearch('PAGE', 'database_table_view', 'show', '', '', basename(__FILE__), __CLASS__); $html .= $this->app->Tpl->FinalParse('databaseviewer_table.tpl'); echo json_encode(array('status'=>1,'html'=>$html)); $this->app->ExitXentral(); } if($this->app->Secure->GetGET('module')==='databaseviewer'){ $this->DatabaseViewerMenu(); } $this->app->erp->Headlines('Datenbank Ansicht'); $this->app->Tpl->Set( 'TREE', '
'. $this->app->Tpl->Parse('return', 'databaseviewer_tree.tpl',true). '
' ); $this->app->Tpl->Parse('PAGE', 'databaseviewer_sqlviewer.tpl'); } /** * @param null|array $tables */ public function getTables(&$tables) { $res = $this->app->DB->SelectArrCache('SHOW TABLES',60, 'xcs_table'); if(empty($res)) { return; } foreach($res as $table) { $table = reset($table); $tables[] = $table; } } public function DatabaseViewerTreeAjax() { $disabled = false; $tables = null; $this->getTables($tables); if(!empty($tables)) { $maxlvl = 0; foreach($tables as $k => $table) { $name = 'node'.$k; $$name = new stdClass(); $$name->id = $k; $$name->label = $table; $$name->checkbox = false; $$name->inode = false; $$name->radio = false; if($disabled) { $$name->disabled = true; } $baum[] = $$name; } echo json_encode($baum); $this->app->erp->ExitWawi(); } echo '[]'; $this->app->erp->ExitWawi(); } }