diff --git a/index.php b/index.php index a5677b9..dc3f6f0 100644 --- a/index.php +++ b/index.php @@ -285,6 +285,12 @@ else if (!empty($_POST["action"])) } $now = time(); + $created = $now; + + if (!empty($id_to_edit) && !empty($model["list"][$id_to_edit]) && !empty($model["list"][$id_to_edit]["created"])) + { + $created = $model["list"][$id_to_edit]["created"]; + } if (empty($model["list"])) { @@ -296,7 +302,7 @@ else if (!empty($_POST["action"])) "description" => $description, "deadline" => $deadline, "category" => $category, - "created" => $now, + "created" => $created, "modified" => $now, ); @@ -503,10 +509,44 @@ function todo_list(array $model = []) : string $te->set_block_template("MAIN_ITEM_SUMMARY", "MAIN_ITEM_SUMMARY_DESC"); } + unset($deadline); + $deadline = date("Y-m-d", intval($item["deadline"])); + if (empty($deadline)) + { + $deadline = "N/A"; + } + + unset($created); + $created = date("Y-m-d", intval($item["created"])); + if (empty($created)) + { + $created = "N/A"; + } + + unset($modified); + $modified = date("Y-m-d", intval($item["modified"])); + if (empty($modified)) + { + $modified = "N/A"; + } + + unset($category); + $category = $item["category"]; + $category_raw = $item["category"]; + if (empty($category)) + { + $category = "Uncategorized"; + } + $te->append_argumented_block("MAIN_CATEGORY_ITEMS", "MAIN_ITEM", [ "MAIN_ITEM_ID" => $key, - "MAIN_ITEM_TITLE" => $item["title"], - "MAIN_ITEM_DESCRIPTION" => $item["description"], + "MAIN_ITEM_TITLE" => str_replace([ "\"", "'" ], [ """, "'" ], $item["title"]), + "MAIN_ITEM_DESCRIPTION" => str_replace([ "\"", "'" ], [ """, "'" ], $item["description"]), + "MAIN_ITEM_CATEGORY" => str_replace([ "\"", "'" ], [ """, "'" ], $category), + "MAIN_ITEM_CATEGORY_RAW" => $category_raw, + "MAIN_ITEM_DEADLINE" => $deadline, + "MAIN_ITEM_CREATED" => $created, + "MAIN_ITEM_MODIFIED" => $modified, ]); } diff --git a/templates/add-form.html b/templates/add-form.html index 92ab5f5..e1754e6 100644 --- a/templates/add-form.html +++ b/templates/add-form.html @@ -1,8 +1,9 @@