Revision | 3e9f1ee95a3a67f919dedd02ad0acc4efcab0877 (tree) |
---|---|
Zeit | 2017-10-31 00:25:57 |
Autor | umorigu <umorigu@gmai...> |
Commiter | umorigu |
BugTrack/2445 Rename deleted page
@@ -25,7 +25,7 @@ function plugin_rename_action() | ||
25 | 25 | if ($src == '') return plugin_rename_phase1(); |
26 | 26 | |
27 | 27 | $src_pattern = '/' . preg_quote($src, '/') . '/'; |
28 | - $arr0 = preg_grep($src_pattern, get_existpages()); | |
28 | + $arr0 = preg_grep($src_pattern, plugin_rename_get_existpages()); | |
29 | 29 | if (! is_array($arr0) || empty($arr0)) |
30 | 30 | return plugin_rename_phase1('nomatch'); |
31 | 31 |
@@ -45,7 +45,7 @@ function plugin_rename_action() | ||
45 | 45 | if ($refer == '') { |
46 | 46 | return plugin_rename_phase1(); |
47 | 47 | |
48 | - } else if (! is_page($refer)) { | |
48 | + } else if (! plugin_rename_is_page($refer)) { | |
49 | 49 | return plugin_rename_phase1('notpage', $refer); |
50 | 50 | |
51 | 51 | } else if ($refer === $whatsnew) { |
@@ -405,7 +405,7 @@ function plugin_rename_proceed($pages, $files, $exists) | ||
405 | 405 | function plugin_rename_getrelated($page) |
406 | 406 | { |
407 | 407 | $related = array(); |
408 | - $pages = get_existpages(); | |
408 | + $pages = plugin_rename_get_existpages(); | |
409 | 409 | $pattern = '/(?:^|\/)' . preg_quote(strip_bracket($page), '/') . '(?:\/|$)/'; |
410 | 410 | foreach ($pages as $name) { |
411 | 411 | if ($name === $page) continue; |
@@ -419,7 +419,7 @@ function plugin_rename_getselecttag($page) | ||
419 | 419 | global $whatsnew; |
420 | 420 | |
421 | 421 | $pages = array(); |
422 | - foreach (get_existpages() as $_page) { | |
422 | + foreach (plugin_rename_get_existpages() as $_page) { | |
423 | 423 | if ($_page === $whatsnew) continue; |
424 | 424 | |
425 | 425 | $selected = ($_page === $page) ? ' selected' : ''; |
@@ -438,3 +438,40 @@ function plugin_rename_getselecttag($page) | ||
438 | 438 | EOD; |
439 | 439 | |
440 | 440 | } |
441 | + | |
442 | +/** | |
443 | + * List exist pages and deleted pages | |
444 | + */ | |
445 | +function plugin_rename_get_existpages() { | |
446 | + $list1 = array_values(get_existpages()); | |
447 | + $list2 = array_values(get_existpages(DIFF_DIR, '.txt')); | |
448 | + $list3 = array_values(get_existpages(BACKUP_DIR, '.txt')); | |
449 | + $list4 = array_values(get_existpages(BACKUP_DIR, '.gz')); | |
450 | + $list5 = array_values(get_existpages(COUNTER_DIR, '.count')); | |
451 | + $wholelist = array_merge($list1, $list2, $list3, $list4, $list5); | |
452 | + $list = array_unique($wholelist); | |
453 | + return $list; | |
454 | +} | |
455 | + | |
456 | +/** | |
457 | + * Return where the page exists or existed | |
458 | + */ | |
459 | +function plugin_rename_is_page($page) { | |
460 | + $enc = encode($page); | |
461 | + if (is_page($page)) { | |
462 | + return true; | |
463 | + } | |
464 | + if (file_exists(DIFF_DIR . $enc . '.txt')) { | |
465 | + return true; | |
466 | + } | |
467 | + if (file_exists(BACKUP_DIR . $enc . '.txt')) { | |
468 | + return true; | |
469 | + } | |
470 | + if (file_exists(BACKUP_DIR . $enc . '.gz')) { | |
471 | + return true; | |
472 | + } | |
473 | + if (file_exists(COUNTER_DIR . $enc . '.count')) { | |
474 | + return true; | |
475 | + } | |
476 | + return false; | |
477 | +} |