예제 #1
0
파일: test.php 프로젝트: pv/Tableau
if ($_GET['table'] == 'staff') {
    print "<div class='linkbox'><span><b>Staff</b></span> <span><a href=\"?table=responsibilities\">Responsibilities</a></span>{$linkbox_other_links}</div>";
    // Table selector ended here. Very simple.
    // Ok, then start up the interface.
    // We want now to interface to the table named 'staff'
    $tableau = new Tableau($connection, 'staff');
    // First, we need to specify field names for the columns, and
    // what each column is. This controls how the data is displayed
    // and edited.
    $tableau->set_columns('id', new Tableau_IDColumn(), 'name', new Tableau_TextColumn(), 'birthdate', new Tableau_DateColumn(), 'phone', new Tableau_TextColumn(), 'last_updated', new Tableau_LastUpdatedColumn(), 'photo_filename', new Tableau_FileColumn("/home/pauli/public_html/Tableau/testup", "/~pauli/Tableau/testup"), 'changes', new Tableau_ChangeTrackColumn());
    // Next, set some pretty display names for the columns
    $tableau->set_name('id', "ID", 'name', "Name", 'birthdate', "Birth date", 'phone', "Phone number", 'photo_filename', "Photo", 'last_updated', "Last updated");
    // And then longer descriptions to show when editing
    $tableau->set_comment('id', "Identifier", 'name', "Name of the person", 'birthdate', "Birth date of the person", 'phone', "Work phone number extension");
    // Tell that last_updated field should not be visible.
    $tableau->set_visible('last_updated', false);
    // ...and specify some sensible year range for the date selector.
    // The date selector is quite basic and could probably be improved
    // a lot... JavaScript?
    $tableau->columns['birthdate']->set_year_range(date('Y') - 120, date('Y') - 15);
    // Now, use the validation function we defined above.
    // We specify that it should handle fields 'name' and 'birthdate'.
    $tableau->add_validator('name', value_required);
    $tableau->add_validator('birthdate', value_required);
    // Then, we specify a display filter function, that adds
    // "missing"-links to fields whose values are missing.
    function mark_missing($row, $field, &$disp, &$cell_attr)
    {
        // Note that $field == null indicates the first column,
        // which contains an 'edit row' link
        if ($field == "changes") {