Ticket #874: apps_plan_class.diff

File apps_plan_class.diff, 2.6 KB (added by Nicolas, 16 years ago)

Removes "Plan class" column from apps.php HTML output if there is no app_version with a plan class, and removes <plan_class> from XML output from each app version with no plan class.

  • html/user/apps.php

     
    3636
    3737$apps = BoincApp::enum("deprecated=0");
    3838
     39$using_plan_class = BoincDb::get()->count("app_version", "plan_class != ''");
     40
    3941foreach ($apps as $app) {
    4042    if ($xml) {
    4143        echo "<application>\n";
    4244        echo "    <name>$app->user_friendly_name</name>\n";
    4345    } else {
    44         echo "
    45             <tr><th colspan=4>$app->user_friendly_name</th></tr>
    46             <tr>
    47                 <th>".tra("Platform")."</th>
    48                 <th>".tra("Version")."</th>
    49                 <th>".tra("Plan class")."</th>
    50                 <th>".tra("Installation time")."</th>
    51             </tr>
    52         ";
     46        $span = $using_plan_class?4:3;
     47        echo "<tr><th colspan=$span>$app->user_friendly_name</th></tr>";
     48        echo "<tr>";
     49        echo "  <th>",tra("Platform"),"</th>";
     50        echo "  <th>",tra("Version"),"</th>";
     51        if ($using_plan_class) {
     52            echo "<th>",tra("Plan class"),"</th>";
     53        }
     54        echo "  <th>",tra("Installation time"),"</th>";
     55        echo "</tr>";
    5356    }
    5457    foreach ($platforms as $platform) {
    5558        $avs = BoincAppVersion::enum(
     
    7174                echo "        <platform_short>$platform->name</platform_short>\n";
    7275                echo "        <platform_long>$platform->user_friendly_name</platform_long>\n";
    7376                echo "        <version_num>$av->version_num</version_num>\n";
    74                 echo "        <plan_class>$av->plan_class</plan_class>\n";
     77                if (!empty($av->plan_class)) {
     78                    echo "        <plan_class>$av->plan_class</plan_class>\n";
     79                }
    7580                echo "        <date>$y</date>\n";
    7681                echo "        <date_unix>$av->create_time</date_unix>\n";
    7782                echo "    </version>\n";
     
    7984                $x = sprintf("%0.2f", $av->version_num/100);
    8085                echo "<tr>
    8186                    <td>$platform->user_friendly_name</td>
    82                     <td>$x</td>
    83                     <td>$av->plan_class</td>
    84                     <td>$y</td>
    85                     </tr>
    86                 ";
     87                    <td>$x</td>";
     88                if ($using_plan_class) {
     89                    echo "<td>$av->plan_class</td>";
     90                }
     91                echo "<td>$y</td>";
     92                echo "</tr>";
    8793            }
    8894        }
    8995    }
    9096    if ($xml) {
    91         echo "    </application>\n";
     97        echo "</application>\n";
    9298    }
    9399}
    94100