2025-01-23 22:41:26 +01:00
|
|
|
|
|
|
|
<?php defined('KOBLOG') or die('Koblog CMS.');
|
|
|
|
|
|
|
|
class KoblogUpdater {
|
|
|
|
// Special function to upgrade
|
|
|
|
public static function upgradeArticlesToPageTypes()
|
|
|
|
{
|
2025-01-25 15:01:12 +01:00
|
|
|
$dataHead = "<?php defined('KOBLOG') or die('Koblog CMS.'); ?>" . PHP_EOL;
|
|
|
|
|
2025-01-23 22:41:26 +01:00
|
|
|
global $pages;
|
2025-01-25 15:01:12 +01:00
|
|
|
global $L;
|
|
|
|
|
2025-01-23 22:41:26 +01:00
|
|
|
foreach ($pages->db as $key => $fields) {
|
|
|
|
if ($fields['type'] === "published") {
|
|
|
|
$pages->db[$key]['type'] = "article";
|
2025-01-24 20:02:30 +01:00
|
|
|
$pages->db[$key]['state'] = "published";
|
|
|
|
} elseif ($fields['type'] === "draft") {
|
|
|
|
$pages->db[$key]['type'] = "article";
|
|
|
|
$pages->db[$key]['state'] = "draft";
|
|
|
|
} elseif ($fields['type'] === "autosave") {
|
|
|
|
$pages->db[$key]['type'] = "article";
|
|
|
|
$pages->db[$key]['state'] = "autosave";
|
|
|
|
} elseif ($fields['type'] === "scheduled") {
|
|
|
|
$pages->db[$key]['type'] = "article";
|
|
|
|
$pages->db[$key]['state'] = "scheduled";
|
2025-01-25 12:28:59 +01:00
|
|
|
} elseif ($fields['type'] === "sticky") {
|
|
|
|
$pages->db[$key]['type'] = "article";
|
|
|
|
$pages->db[$key]['state'] = "published";
|
|
|
|
$pages->db[$key]['sticky'] = true;
|
2025-01-24 20:02:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// S'il n'y a toujours rien, c'est qu'il est publié
|
|
|
|
if ($pages->db[$key]['state'] === null) {
|
|
|
|
$pages->db[$key]['state'] = "published";
|
2025-01-23 22:41:26 +01:00
|
|
|
}
|
2025-01-25 12:28:59 +01:00
|
|
|
|
|
|
|
// S'il n'y a toujours pas de sticky, c'est qu'il ne l'est pas
|
|
|
|
if ($pages->db[$key]['sticky'] === null) {
|
|
|
|
$pages->db[$key]['sticky'] = false;
|
|
|
|
}
|
2025-01-23 22:41:26 +01:00
|
|
|
}
|
2025-01-25 15:01:12 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
if (!file_exists(PATH_DATABASES . 'pagetypes.php')) {
|
|
|
|
$data = array(
|
2025-01-25 15:05:17 +01:00
|
|
|
'article' => array('name' => $L->g("Article"), 'plural' => $L->g("Articles"), 'icon'=>'file-text'),
|
|
|
|
'static' => array('name' => $L->g("Static page"), 'plural' => $L->g("Static pages"), 'icon'=>'file'),
|
2025-01-25 15:01:12 +01:00
|
|
|
);
|
|
|
|
file_put_contents(PATH_DATABASES . 'pagetypes.php', $dataHead . json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
|
|
|
|
}
|
|
|
|
|
2025-01-23 22:41:26 +01:00
|
|
|
return $pages->save();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|