Skip to content

Commit 6c55736

Browse files
committed
Fix issue with non-unique ID in markup and adjust tab location (fixes #43)
1 parent 9c8a2f2 commit 6c55736

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

VersionControl.module

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class VersionControl extends WireData implements Module, ConfigurableModule {
2929
'summary' => 'Version control features for page content.',
3030
'href' => 'https://modules.processwire.com/modules/version-control/',
3131
'author' => 'Teppo Koivula',
32-
'version' => '1.3.4',
32+
'version' => '1.3.5',
3333
'singular' => true,
3434
'autoload' => true,
3535
'installs' => array(
@@ -1054,6 +1054,7 @@ class VersionControl extends WireData implements Module, ConfigurableModule {
10541054
$wrapper->prepend($fieldset);
10551055

10561056
$field = $this->modules->get("InputfieldHidden");
1057+
$field->id = 'history_filters__id';
10571058
$field->name = 'id';
10581059
$field->value = $page->id;
10591060
$fieldset->add($field);
@@ -1077,11 +1078,15 @@ class VersionControl extends WireData implements Module, ConfigurableModule {
10771078
$this->config->scripts->add($this->config->urls->$class . "HistoryTab.min.js?v=$version");
10781079

10791080
// insert new tab to Page Edit form
1080-
$form->append($wrapper);
1081+
$submit = $form->find('name=submit_save')->first();
1082+
if ($submit) {
1083+
$form->insertBefore($wrapper, $submit);
1084+
} else {
1085+
$form->append($wrapper);
1086+
}
10811087
if (!method_exists($event->object, "getTabs")) {
10821088
// note: this works for ProcessWire < 2.4.18 and won't be reached
10831089
// after 2.5.14 at all; see addTabHistory() for more details.
1084-
$form->append($wrapper);
10851090
$siblings = $form->children('id=ProcessPageEditSettings|ProcessPageEditDelete|ProcessPageEditView');
10861091
if (count($siblings)) {
10871092
if ($siblings->first()->attr('id') == "ProcessPageEditSettings") {
@@ -1116,10 +1121,8 @@ class VersionControl extends WireData implements Module, ConfigurableModule {
11161121
$keys = array_keys($event->return);
11171122
if (($pos = array_search('ProcessPageEditSettings', $keys)) !== false) {
11181123
$pos += 1;
1119-
} else {
1120-
if (($pos = array_search('ProcessPageEditDelete', $keys)) === false) {;
1121-
$pos = array_search('ProcessPageEditView', $keys);
1122-
}
1124+
} else if (($pos = array_search('ProcessPageEditDelete', $keys)) === false) {
1125+
$pos = array_search('ProcessPageEditView', $keys);
11231126
}
11241127
if ($pos !== false) {
11251128
$event->return = array_merge(

0 commit comments

Comments
 (0)