Browse Source

Migrate content and draft

pull/255/head
Danang Probo Sayekti 10 years ago
parent
commit
8b2d616a88
3 changed files with 46 additions and 10 deletions
  1. +8
    -1
      system/admin/views/update.html.php
  2. +4
    -8
      system/admin/views/updated-to.html.php
  3. +34
    -1
      system/includes/functions.php

+ 8
- 1
system/admin/views/update.html.php View File

@ -32,4 +32,11 @@ if ($updater->able()) {
echo '<p>Read on <a target="_blank" href="' . $info['html_url'] . '">Github</a>.</p>'; echo '<p>Read on <a target="_blank" href="' . $info['html_url'] . '">Github</a>.</p>';
} }
migrate_old_content();
$files = array();
$draft = array();
$files = glob('content/*/blog/*.md', GLOB_NOSORT);
$draft = glob('content/*/draft/*.md', GLOB_NOSORT);
if (!empty($files) || !empty($draft)) {
migrate_old_content();
}

+ 4
- 8
system/admin/views/updated-to.html.php View File

@ -1,9 +1,5 @@
<h3>Updated to
<h3>
<h2>[<?php echo $info['tag_name']; ?>] <?php echo $info['name']; ?></h2>
<h3>Updated to<h3>
<h2>[<?php echo $info['tag_name']; ?>] <?php echo $info['name']; ?></h2>
<p><?php echo \Michelf\MarkdownExtra::defaultTransform($info['body']); ?></p>
<p><?php echo \Michelf\MarkdownExtra::defaultTransform($info['body']); ?></p>
<?php
require_once "system/upgrade/run.php";
?>
<?php require_once "system/upgrade/run.php"; ?>

+ 34
- 1
system/includes/functions.php View File

@ -2618,6 +2618,9 @@ function migrate_old_content()
$content = array(); $content = array();
$tmp = array(); $tmp = array();
$files = array(); $files = array();
$draft = array();
$dtmp = array();
$dfiles = array();
$tmp = glob('content/*/blog/*.md', GLOB_NOSORT); $tmp = glob('content/*/blog/*.md', GLOB_NOSORT);
if (is_array($tmp)) { if (is_array($tmp)) {
@ -2695,6 +2698,36 @@ function migrate_old_content()
unlink('content/views.json'); unlink('content/views.json');
} }
rebuilt_cache('all');
$dtmp = glob('content/*/draft/*.md', GLOB_NOSORT);
$old = array();
if (is_array($dtmp)) {
foreach ($dtmp as $dfile) {
$draft[] = $dfile;
}
}
if(!empty($draft)) {
foreach ($draft as $d => $val) {
$arr = explode('/', $val);
$old[] = 'content/' . $arr[1] . '/draft/';
$dir = 'content/' . $arr[1] . '/blog/uncategorized/draft/';
$new = 'content/' . $arr[1] . '/blog/uncategorized/draft/' . $arr[3];
if (!is_dir($dir)) {
mkdir($dir, 0775, true);
}
$dfiles[] = array($val, $new);
}
foreach ($dfiles as $fd) {
rename($fd[0], $fd[1]);
}
$tt = array();
$tt = array_unique($old, SORT_REGULAR);
foreach ($tt as $t) {
rmdir($t);
}
}
rebuilt_cache('all');
} }

Loading…
Cancel
Save