Пример #1
0
function show_form()
{
    echo "\n        <h2>Edit applications</h2>\n    ";
    start_table();
    table_header("ID", "Name and description<br><p class=\"text-muted\">Click for details</p>", "Created", "weight<br><a href=https://boinc.berkeley.edu/trac/wiki/BackendPrograms#feeder><p class=\"text-muted\">details</p></a>", "shmem items", "HR type<br><a href=https://boinc.berkeley.edu/trac/wiki/HomogeneousRedundancy><p class=\"text-muted\">details</p></a>", "homogeneous app version?<br><a href=https://boinc.berkeley.edu/trac/wiki/HomogeneousAppVersion><p class=\"text-muted\">details</p></a>", "deprecated?", "Non-CPU-intensive?", "Beta?", "Exact fraction done?", "");
    $total_weight = BoincApp::sum("weight", "where deprecated=0");
    $swi = parse_config(get_config(), "<shmem_work_items>");
    if (!$swi) {
        $swi = 100;
    }
    $apps = BoincApp::enum("");
    $i = 0;
    foreach ($apps as $app) {
        // grey-out deprecated versions
        $f1 = $f2 = '';
        if ($app->deprecated == 1) {
            $f1 = "<font color='GREY'>";
            $f2 = "</font>";
        }
        echo "<tr class=row{$i}><form action=manage_apps.php method=POST>";
        $i = 1 - $i;
        echo "<input type=hidden name=id value={$app->id}>";
        echo "  <TD align='center'>{$f1} {$app->id} {$f2}</TD>\n";
        echo "  <TD align='left'>{$f1}<a href=app_details.php?appid={$app->id}>{$app->name}</a><br> {$app->user_friendly_name} {$f2}</TD>\n";
        echo "  <TD align='center'>{$f1} " . date_str($app->create_time) . "{$f2}</TD>\n";
        $v = $app->weight;
        echo "  <TD align='center'>\n        <input type='text' size='4' name='weight' value='{$v}'></TD>\n";
        if ($app->deprecated || $total_weight == 0) {
            echo '<td></td>';
        } else {
            echo '<td align="right">' . round($app->weight / $total_weight * $swi) . '</td>';
        }
        $v = $app->homogeneous_redundancy;
        echo "  <TD align='center'>\n            <input name='homogeneous_redundancy' value='{$v}'></TD>\n        ";
        $v = '';
        if ($app->homogeneous_app_version) {
            $v = ' CHECKED ';
        }
        echo "  <TD align='center'>\n            <input name='homogeneous_app_version' type='checkbox' {$v}></TD>\n        ";
        $v = '';
        if ($app->deprecated) {
            $v = ' CHECKED ';
        }
        echo "  <TD align='center'>\n            <input name='deprecated' type='checkbox' {$v}></TD>\n        ";
        $v = '';
        if ($app->non_cpu_intensive) {
            $v = ' CHECKED ';
        }
        echo "  <TD align='center'>\n            <input name='non_cpu_intensive' type='checkbox' {$v}></TD>\n        ";
        $v = '';
        if ($app->beta) {
            $v = ' CHECKED ';
        }
        echo "  <TD align='center'>\n            <input name='beta' type='checkbox' {$v}></TD>\n        ";
        $v = '';
        if ($app->fraction_done_exact) {
            $v = ' CHECKED ';
        }
        echo "  <TD align='center'>\n            <input name='fraction_done_exact' type='checkbox' {$v}></TD>\n        ";
        echo "<td><input class=\"btn btn-default\" type=submit name=submit value=Update>";
        echo "</tr></form>";
    }
    end_table();
    // Entry form to create a new application
    //
    echo "<P>\n        <h2>Add an application</h2>\n        To add an application enter the short name and description\n        ('user friendly name') below.  You can then edit the\n        application when it appears in the table above.\n        <p>\n        <form action=manage_apps.php method=POST>\n    ";
    start_table("align='center' ");
    table_header("Name", "Description", "&nbsp;");
    echo "<TR>\n            <TD> <input type='text' size='12' name='add_name' value=''></TD>\n            <TD> <input type='text' size='35' name='add_user_friendly_name' value=''></TD>\n            <TD align='center' >\n                 <input type='submit' name='add_app' value='Add Application'></TD>\n            </TR>\n";
    end_table();
    echo "</form><p>\n";
}