Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'ticket/62558' of https://github.com/jasmineaura/automod

…into jasmineaura-ticket/62558
  • Loading branch information...
commit 4b9b4310daf6197fe61878887bb3587d4aa5c0d8 2 parents 42ad0ae + 2e2860e
@tumba25 tumba25 authored
Showing with 56 additions and 38 deletions.
  1. +32 −16 root/includes/editor.php
  2. +24 −22 root/includes/mod_parser.php
View
48 root/includes/editor.php
@@ -679,21 +679,14 @@ function build_uninstall($find, $inline_find, $action_type, $action)
(($this->last_action[2] == 'AFTER' && $this->curr_action[2] == 'BEFORE')
|| ($this->last_action[2] == 'BEFORE' && $this->curr_action[2] == 'AFTER')))
{
- $last_action_index = sizeof($this->mod_actions[$this->open_filename]) - 1;
- unset($this->mod_actions[$this->open_filename][$last_action_index]);
-
- // Re-index the array to start at zero and go sequentially
- $this->mod_actions[$this->open_filename] = array_merge($this->mod_actions[$this->open_filename]);
+ array_pop($this->mod_actions[$this->open_filename]);
$action_type = 'REPLACE';
// Remove the add from the find -- this is an effect of the way the
// add method works, putting the new lines in the same array element
// as the find
- if (!empty($this->last_action))
- {
- $find = str_replace(trim($this->last_action[1]), '', $find);
- }
+ $find = str_replace(trim($this->last_action[1]), '', $find);
if ($this->last_action[2] == 'AFTER')
{
@@ -718,15 +711,38 @@ function build_uninstall($find, $inline_find, $action_type, $action)
}
else
{
- $this->mod_actions[$this->open_filename][] = array(
- $find => array(
- 'in-line-edit' => array(
- $inline_find => array(
- $action_type => array($action),
+ // Do we have preceding in-line-edit(s) on the same complete find or line?
+ if (!empty($this->last_action) && $this->last_action[0] == $this->curr_action[0])
+ {
+ $prev_inline_edits = array_pop($this->mod_actions[$this->open_filename]);
+ $prev_find = key($prev_inline_edits);
+
+ // Add our current in-line-edit
+ $prev_inline_edits[$prev_find]['in-line-edit'][] = array(
+ $inline_find => array(
+ $action_type => array($action),
+ ),
+ );
+
+ // Add the new set of in-line-edit's to our MOD Actions array, w/ the updated $find
+ $this->mod_actions[$this->open_filename][] = array(
+ $find => $prev_inline_edits[$prev_find]
+ );
+ }
+ else
+ {
+ $this->mod_actions[$this->open_filename][] = array(
+ $find => array(
+ 'in-line-edit' => array(
+ array(
+ $inline_find => array(
+ $action_type => array($action),
+ ),
+ ),
),
),
- ),
- );
+ );
+ }
}
$this->last_action = $this->curr_action;
View
46 root/includes/mod_parser.php
@@ -188,33 +188,35 @@ function reverse_edits($actions)
break;
case 'IN-LINE-EDIT':
- $action_id = 0;
// build the reverse just like the normal action
- foreach ($command as $inline_find => $inline_action_ary)
+ foreach ($command as $action_id => $inline_edit)
{
- foreach ($inline_action_ary as $inline_action => $inline_command)
+ foreach ($inline_edit as $inline_find => $inline_action_ary)
{
- $inline_command = $inline_command[0];
-
- switch (strtoupper($inline_action))
+ foreach ($inline_action_ary as $inline_action => $inline_command)
{
- case 'IN-LINE-AFTER-ADD':
- case 'IN-LINE-BEFORE-ADD':
- // Replace with a blank string
- $reverse_edits['EDITS'][$file][$edit_id][$find]['in-line-edit'][$action_id][$inline_command]['in-line-replace'][] = '';
- break;
-
- case 'IN-LINE-REPLACE':
- // replace with the inline find
- $reverse_edits['EDITS'][$file][$edit_id][$find]['in-line-edit'][$action_id][$inline_command][$inline_action][] = $inline_find;
- break;
-
- default:
- // For the moment, we do nothing. What about increment?
- break;
+ $inline_command = $inline_command[0];
+
+ switch (strtoupper($inline_action))
+ {
+ case 'IN-LINE-AFTER-ADD':
+ case 'IN-LINE-BEFORE-ADD':
+ // Replace with a blank string
+ $reverse_edits['EDITS'][$file][$edit_id][$find]['in-line-edit'][$action_id][$inline_command]['in-line-replace'][] = '';
+ break;
+
+ case 'IN-LINE-REPLACE':
+ // replace with the inline find
+ $reverse_edits['EDITS'][$file][$edit_id][$find]['in-line-edit'][$action_id][$inline_command][$inline_action][] = $inline_find;
+ break;
+
+ default:
+ // For the moment, we do nothing. What about increment?
+ break;
+ }
+
+ $action_id++;
}
-
- $action_id++;
}
}
break;
Please sign in to comment.
Something went wrong with that request. Please try again.