More bugs fixes on resource editing 2, a=chris

Chris Pollett [2016-03-07 01:Mar:th]
More bugs fixes on resource editing 2, a=chris
Filename
src/views/elements/WikiElement.php
diff --git a/src/views/elements/WikiElement.php b/src/views/elements/WikiElement.php
index 641da08de..a4e71f0a6 100644
--- a/src/views/elements/WikiElement.php
+++ b/src/views/elements/WikiElement.php
@@ -78,6 +78,9 @@ class WikiElement extends Element implements CrawlConstants
         if ($logged_in) {
             $other_base_query .= "&". $csrf_token;
         }
+        if (!empty($data['SUB_PATH'])) {
+            $other_base_query .= "&sf=". $data['SUB_PATH'];
+        }
         if (($is_admin || $logged_in) && !C\MOBILE &&
             (!isset($data['page_type']) ||
             $data['page_type'] != 'presentation')) { ?>
@@ -306,9 +309,13 @@ class WikiElement extends Element implements CrawlConstants
             $data['CONTROLLER'], $data['GROUP']['GROUP_ID']) .
             C\CSRF_TOKEN.'='.$data[C\CSRF_TOKEN];
         $base_url = htmlentities($simple_base_url);
-        $edit_url = htmlentities(B\wikiUrl($data['PAGE_NAME'], true,
+        $simple_current_url = B\wikiUrl($data['PAGE_NAME'], true,
            $data['CONTROLLER'], $data['GROUP']['GROUP_ID']) .
-           C\CSRF_TOKEN . '=' . $data[C\CSRF_TOKEN] . "&arg=edit");
+           C\CSRF_TOKEN . '=' . $data[C\CSRF_TOKEN] . "&arg=edit";
+        if (!empty($data['SUB_PATH'])) {
+            $simple_current_url .= "&sf=".$data['SUB_PATH'];
+        }
+        $current_url = htmlentities($simple_current_url);
         if (isset($data['OTHER_BACK_URL'])) {
             $append = $data['OTHER_BACK_URL'];
         }
@@ -500,7 +507,7 @@ class WikiElement extends Element implements CrawlConstants
             <div id="save-container" class="top-margin center"><?php
             if (isset($data['RESOURCE_NAME'])) { ?>
                 <button class="button-box" type="button"
-                    onclick="window.location='<?=$edit_url; ?>'" ><?=
+                    onclick="window.location='<?=$current_url; ?>'" ><?=
                     tl('wiki_element_closebutton') ?></button><?php
             }
             ?>
@@ -555,8 +562,6 @@ class WikiElement extends Element implements CrawlConstants
         </div>
         <?php
             $this->renderResources($data, false);
-            $rename_sub_path = (empty($data['SUB_PATH'])) ? "" :
-                "&sf=".$data['SUB_PATH'];
         ?>
         <script type="text/javascript">
         function renameResource(old_name, id)
@@ -571,9 +576,8 @@ class WikiElement extends Element implements CrawlConstants
                     tl("wiki_element_rename_failed") ?></h1>');
                 return;
             }
-            var location = "<?= "$simple_base_url&arg=edit&a=wiki&page_name=".
-                $data['PAGE_NAME']. $rename_sub_path
-                ?>" + "&new_resource_name=" + new_name +
+            var location = "<?=$simple_current_url?>" +
+                "&new_resource_name=" + new_name +
                 "&old_resource_name=" + old_name.replace('&quot;','"');
             window.location = location;
         }
ViewGit