fixed bugs introduced by making admin components

also show a TOC on both admin pages to easily switch
This commit is contained in:
Andreas Gohr
2016-02-04 13:20:28 +01:00
parent 15929be2d8
commit dbffe06e4b
3 changed files with 20 additions and 18 deletions

View File

@ -68,8 +68,6 @@ class admin_plugin_struct_assignments extends DokuWiki_Admin_Plugin {
* Render HTML output, e.g. helpful text and a form
*/
public function html() {
global $INPUT;
echo $this->locale_xhtml('assignments_intro');
$res = $this->sqlite->query('SELECT tbl FROM schemas GROUP BY tbl');
@ -106,17 +104,17 @@ class admin_plugin_struct_assignments extends DokuWiki_Admin_Plugin {
$html .= "</div></li>";
echo $html;
echo '</ul>';
$table = Schema::cleanTableName($INPUT->str('table'));
if($table) {
echo '<h2>'.sprintf($this->getLang('edithl'), hsc($table)).'</h2>';
$editor = new SchemaEditor(new Schema($table));
echo $editor->getEditor();
} else {
$this->html_newschema();
}
/**
* Copies the TOC from the Schema Editor
*
* @return array
*/
public function getTOC() {
/** @var admin_plugin_struct_schemas $plugin */
$plugin = plugin_load('admin', 'struct_schemas');
return $plugin->getTOC();
}
}

View File

@ -71,7 +71,7 @@ class admin_plugin_struct_schemas extends DokuWiki_Admin_Plugin {
$form = new Form();
$form->addFieldsetOpen($this->getLang('create'));
$form->setHiddenField('do', 'admin');
$form->setHiddenField('page', 'struct');
$form->setHiddenField('page', 'struct_schemas');
$form->addTextInput('table', $this->getLang('schemaname'));
$form->addButton('', $this->getLang('save'));
$form->addHTML('<p>'.$this->getLang('createhint').'</p>'); // FIXME is that true? we probably could
@ -90,10 +90,9 @@ class admin_plugin_struct_schemas extends DokuWiki_Admin_Plugin {
/** @var helper_plugin_struct_db $helper */
$helper = plugin_load('helper', 'struct_db');
$db = $helper->getDB();
parent::getTOC();
if(!$db) return parent::getTOC();
$res = $db->query("SELECT DISTINCT tbl FROM schemas ORDER BY tbl");
$tables = $db->res2arr($res);
$db->res_close($res);
@ -101,14 +100,19 @@ class admin_plugin_struct_schemas extends DokuWiki_Admin_Plugin {
$toc = array();
$link = wl($ID, array(
'do' => 'admin',
'page' => 'struct'
'page' => 'struct_assignments'
));
$toc[] = html_mktocitem($link, $this->getLang('menu_assignments'), 0, '');
$link = wl($ID, array(
'do' => 'admin',
'page' => 'struct_schemas'
));
$toc[] = html_mktocitem($link, $this->getLang('menu'), 0, '');
foreach($tables as $row) {
$link = wl($ID, array(
'do' => 'admin',
'page' => 'struct',
'page' => 'struct_schemas',
'table' => $row['tbl']
));

View File

@ -36,7 +36,7 @@ class SchemaEditor {
public function getEditor() {
$form = new Form(array('method' => 'POST', 'id'=>'plugin__struct'));
$form->setHiddenField('do', 'admin');
$form->setHiddenField('page', 'struct');
$form->setHiddenField('page', 'struct_schemas');
$form->setHiddenField('table', $this->schema->getTable());
$form->setHiddenField('schema[id]', $this->schema->getId());