mirror of
https://github.com/cosmocode/dokuwiki-plugin-struct.git
synced 2025-08-01 15:54:34 +00:00
Add button to clear schema data
This commit is contained in:
@ -113,6 +113,23 @@ class admin_plugin_struct_schemas extends DokuWiki_Admin_Plugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// clear
|
||||||
|
if($table && $INPUT->bool('clear')) {
|
||||||
|
if($table != $INPUT->str('confirm_clear')) {
|
||||||
|
msg($this->getLang('clear_fail'), -1);
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
$schema = new Schema($table);
|
||||||
|
$schema->clear();
|
||||||
|
msg($this->getLang('clear_ok'), 1);
|
||||||
|
touch(action_plugin_struct_cache::getSchemaRefreshFile());
|
||||||
|
send_redirect(wl($ID, array('do' => 'admin', 'page' => 'struct_schemas'), true, '&'));
|
||||||
|
} catch(StructException $e) {
|
||||||
|
msg(hsc($e->getMessage()), -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -204,12 +221,18 @@ class admin_plugin_struct_schemas extends DokuWiki_Admin_Plugin {
|
|||||||
$form->setHiddenField('page', 'struct_schemas');
|
$form->setHiddenField('page', 'struct_schemas');
|
||||||
$form->setHiddenField('table', $schema->getTable());
|
$form->setHiddenField('table', $schema->getTable());
|
||||||
|
|
||||||
|
$form->addFieldsetOpen($this->getLang('btn_delete'));
|
||||||
$form->addHTML($this->locale_xhtml('delete_intro'));
|
$form->addHTML($this->locale_xhtml('delete_intro'));
|
||||||
|
|
||||||
$form->addFieldsetOpen($this->getLang('tab_delete'));
|
|
||||||
$form->addTextInput('confirm', $this->getLang('del_confirm'));
|
$form->addTextInput('confirm', $this->getLang('del_confirm'));
|
||||||
$form->addButton('delete', $this->getLang('btn_delete'));
|
$form->addButton('delete', $this->getLang('btn_delete'));
|
||||||
$form->addFieldsetClose();
|
$form->addFieldsetClose();
|
||||||
|
|
||||||
|
$form->addFieldsetOpen($this->getLang('btn_clear'));
|
||||||
|
$form->addHTML($this->locale_xhtml('clear_intro'));
|
||||||
|
$form->addTextInput('confirm_clear', $this->getLang('clear_confirm'));
|
||||||
|
$form->addButton('clear', $this->getLang('btn_clear'));
|
||||||
|
$form->addFieldsetClose();
|
||||||
|
|
||||||
return $form->toHTML();
|
return $form->toHTML();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1
lang/de/clear_intro.txt
Normal file
1
lang/de/clear_intro.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
**ACHTUNG:** Hiermit werden **alle** Daten gelöscht, die jemals für dieses Schema gespeichert waren. Es gibt kein Zurück!
|
1
lang/de/delete_intro.txt
Normal file
1
lang/de/delete_intro.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
**ACHTUNG:** Hiermit wird die Definition des Schemas gelöscht und **alle** Daten, die jemals für dieses Schema gespeichert waren. Es gibt kein Zurück!
|
@ -18,4 +18,15 @@ $lang['summary'] = 'Struct-Daten geändert';
|
|||||||
$lang['export'] = 'Schema als JSON exportieren';
|
$lang['export'] = 'Schema als JSON exportieren';
|
||||||
$lang['btn_export'] = 'Exportieren';
|
$lang['btn_export'] = 'Exportieren';
|
||||||
|
|
||||||
|
$lang['del_confirm'] = 'Namen des Schema zur Bestätigung der Löschung eingeben';
|
||||||
|
$lang['del_fail'] = 'Die Schemanamen stimmten nicht überein. Schema nicht gelöscht';
|
||||||
|
$lang['del_ok'] = 'Schema wurde gelöscht';
|
||||||
|
$lang['btn_delete'] = 'Löschen';
|
||||||
$lang['js']['confirmAssignmentsDelete'] = 'Wollen Sie wirklich die Zuweisung von Schma "{0}" zu Seite/Namensraum "{1}" löschen?';
|
$lang['js']['confirmAssignmentsDelete'] = 'Wollen Sie wirklich die Zuweisung von Schma "{0}" zu Seite/Namensraum "{1}" löschen?';
|
||||||
|
|
||||||
|
$lang['clear_confirm'] = 'Namen des Schema zur Bestätigung der Entfernung aller Daten eingeben';
|
||||||
|
$lang['clear_fail'] = 'Die Schemanamen stimmten nicht überein. Daten wurden nicht entfernt';
|
||||||
|
$lang['clear_ok'] = 'Die Daten des Schemas wurden entfernt';
|
||||||
|
$lang['btn_clear'] = 'Leeren';
|
||||||
|
|
||||||
|
$lang['tab_delete'] = 'Löschen/Leeren';
|
||||||
|
1
lang/en/clear_intro.txt
Normal file
1
lang/en/clear_intro.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
**WARNING:** This will clear **all** data that has ever been saved for this schema! There is no going back!
|
@ -36,9 +36,14 @@ $lang['del_ok'] = 'Schema has been deleted';
|
|||||||
$lang['btn_delete'] = 'Delete';
|
$lang['btn_delete'] = 'Delete';
|
||||||
$lang['js']['confirmAssignmentsDelete'] = 'Do you really want to delete the assignment of schema "{0}" to page/namespace "{1}"?';
|
$lang['js']['confirmAssignmentsDelete'] = 'Do you really want to delete the assignment of schema "{0}" to page/namespace "{1}"?';
|
||||||
|
|
||||||
|
$lang['clear_confirm'] = 'Enter schema name to confirm clearing all data';
|
||||||
|
$lang['clear_fail'] = 'Schema names did not match. Data not deleted';
|
||||||
|
$lang['clear_ok'] = 'Data of schema has been deleted';
|
||||||
|
$lang['btn_clear'] = 'Clear';
|
||||||
|
|
||||||
$lang['tab_edit'] = 'Edit Schema';
|
$lang['tab_edit'] = 'Edit Schema';
|
||||||
$lang['tab_export'] = 'Import/Export';
|
$lang['tab_export'] = 'Import/Export';
|
||||||
$lang['tab_delete'] = 'Delete';
|
$lang['tab_delete'] = 'Delete/Clear';
|
||||||
|
|
||||||
$lang['editor_sort'] = 'Sort';
|
$lang['editor_sort'] = 'Sort';
|
||||||
$lang['editor_label'] = 'Field Name';
|
$lang['editor_label'] = 'Field Name';
|
||||||
|
@ -252,6 +252,21 @@ class Schema {
|
|||||||
$this->ts = 0;
|
$this->ts = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear all data of a schema, but retain the schema itself
|
||||||
|
*/
|
||||||
|
public function clear() {
|
||||||
|
if(!$this->id) throw new StructException('can not clear data of unsaved schema');
|
||||||
|
|
||||||
|
$this->sqlite->query('BEGIN TRANSACTION');
|
||||||
|
$sql = 'DELETE FROM ?';
|
||||||
|
$this->sqlite->query($sql, 'data_' . $this->table);
|
||||||
|
$this->sqlite->query($sql, 'multi_' . $this->table);
|
||||||
|
$this->sqlite->query('COMMIT TRANSACTION');
|
||||||
|
$this->sqlite->query('VACUUM');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
@ -144,6 +144,7 @@
|
|||||||
|
|
||||||
fieldset {
|
fieldset {
|
||||||
margin-bottom: 1em;
|
margin-bottom: 1em;
|
||||||
|
width: 500px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user