42 lines
No EOL
1.7 KiB
PHP
42 lines
No EOL
1.7 KiB
PHP
|
|
<?php defined('KOBLOG') or die('Koblog CMS.');
|
|
|
|
class KoblogUpdater {
|
|
// Special function to upgrade
|
|
public static function upgradeArticlesToPageTypes()
|
|
{
|
|
global $pages;
|
|
foreach ($pages->db as $key => $fields) {
|
|
if ($fields['type'] === "published") {
|
|
$pages->db[$key]['type'] = "article";
|
|
$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";
|
|
} elseif ($fields['type'] === "sticky") {
|
|
$pages->db[$key]['type'] = "article";
|
|
$pages->db[$key]['state'] = "published";
|
|
$pages->db[$key]['sticky'] = true;
|
|
}
|
|
|
|
// S'il n'y a toujours rien, c'est qu'il est publié
|
|
if ($pages->db[$key]['state'] === null) {
|
|
$pages->db[$key]['state'] = "published";
|
|
}
|
|
|
|
// 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;
|
|
}
|
|
}
|
|
|
|
return $pages->save();
|
|
}
|
|
|
|
} |