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"; } // S'il n'y a toujours rien, c'est qu'il est publiƩ if ($pages->db[$key]['state'] === null) { $pages->db[$key]['state'] = "published"; } } return $pages->save(); } }