コード例 #1
0
ファイル: test.php プロジェクト: pozymasika/simple_todo
<?php

include_once __DIR__ . '/../src/Todo.php';
print_r(Todo::batch_read());
コード例 #2
0
ファイル: index.php プロジェクト: pozymasika/simple_todo
<?php

/**Our _todo app's GUI client.
*What we have done is just provide an interface that talks to  our boring _Todo controller methods.
*Notice how we try very hard to decouple php from the html so that we can plug in stuff like
*templates easily.
*/
include_once __DIR__ . '/src/Todo.php';
$items = Todo::batch_read();
?>

<?php 
//refresh page to reflect new changes
function refresh()
{
    header("Location: .");
}
//submit/update an item
if (isset($_POST) && isset($_POST['title'])) {
    if ($_POST['title']) {
        $title = strip_tags(stripslashes($_POST['title']));
        if (isset($_POST['id'])) {
            Todo::update($_POST['id'], $title);
        } else {
            Todo::create($title);
        }
    }
    refresh();
}
//delete an item
if (isset($_GET['delete']) && isset($_GET['id'])) {