From 4137e993d11e926ae28343c1eeac1a46977efd47 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Tue, 14 Jul 2015 08:05:03 +0200 Subject: [PATCH] jump to correct hash after renaming a file --- src/phorkie/Repository/Post.php | 10 ++++++++++ www/edit.php | 9 ++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/phorkie/Repository/Post.php b/src/phorkie/Repository/Post.php index 7a373aa..b9489e7 100644 --- a/src/phorkie/Repository/Post.php +++ b/src/phorkie/Repository/Post.php @@ -13,6 +13,12 @@ class Repository_Post */ public $newfileName; + /** + * List of files that have been renamed. + * + * @var array + */ + public $renameMap = array(); public function __construct(Repository $repo = null) @@ -48,6 +54,9 @@ class Repository_Post $bChanged = true; } + $this->renameMap = array(); + $this->newfileName = null; + foreach ($postData['files'] as $num => $arFile) { $bUpload = false; if ($_FILES['files']['error'][$num]['upload'] == 0) { @@ -102,6 +111,7 @@ class Repository_Post ->addArgument($name) ->execute(); $bCommit = true; + $this->renameMap[$originalName] = $name; } else { $name = $originalName; } diff --git a/www/edit.php b/www/edit.php index e7e6fbc..1ced7b6 100644 --- a/www/edit.php +++ b/www/edit.php @@ -22,7 +22,14 @@ $repopo = new Repository_Post($repo); if ($repopo->process($_POST, $_SESSION)) { $anchor = ''; if ($file instanceof File) { - $anchor = '#' . $file->getAnchorName(); + if (isset($repopo->renameMap[$file->getFilename()])) { + $anchor = '#' + . $repo->getFileByName( + $repopo->renameMap[$file->getFilename()] + )->getAnchorName(); + } else { + $anchor = '#' . $file->getAnchorName(); + } } else if ($file === 'newfile' && $repopo->newfileName) { $anchor = '#' . $repo->getFileByName($repopo->newfileName)->getAnchorName(); } -- 2.30.2