better package listing
authorMichael Wallner <mike@php.net>
Wed, 20 May 2015 08:38:45 +0000 (10:38 +0200)
committerMichael Wallner <mike@php.net>
Wed, 20 May 2015 08:38:45 +0000 (10:38 +0200)
public/index.php

index f132afb1ac77265ea3203ac59a45c48ebdd0db47..9f35721218519a6fcae5402c58b39738f4c56dfd 100644 (file)
                        <table class="table table-full">
                                <thead>
                                        <tr>
-                                               <th class="text-left">Package</th>
+                                               <th class="text-left" colspan="4">Package</th>
                                                <th class="text-left">Date</th>
                                                <th class="text-right">Size</th>
                                                <th class="text-right">Pharext</th>
                                        </tr>
                                </thead>
                                <tbody>
-                                       <?php foreach (array_reverse(glob("phars/$package/*.ext.phar*")) as $phar) : ?>
+                                       
+                                       <?php
+                                       
+                                       $versions = [];
+                                       foreach (glob("phars/$package/*.ext.phar*") as $phar) {
+                                               list($name, $enc) = explode(".ext.phar", basename($phar));
+                                               $data = new Phar($phar);
+                                               $meta = $data->getMetadata();
+                                               if ($meta) {
+                                                       $release = $meta["release"];
+                                               } else {
+                                                       $release = substr($name, strlen($package)+1);
+                                               }
+                                               $versions[$release][$enc] = [$phar, $meta];
+                                               uksort($versions[$release], function($a, $b) {
+                                                       $al = strlen($a);
+                                                       $bl = strlen($b);
+                                                       if ($al < $bl) return -1;
+                                                       if ($al > $bl) return 1;
+                                                       return 0;
+                                               });
+                                       }
+                                       uksort($versions, "version_compare");
+                                       
+                                       ?>
+                                       <?php foreach (array_reverse($versions) as $version => $phars) : ?>
 
                                        <tr>
+                                               <td class="text-left">
+                                                       <?= htmlspecialchars($package) ?>
+                                                       <?= htmlspecialchars($version) ?>
+                                               </td>
+                                               
+                                               <?php foreach ($phars as $ext => list($phar, $meta)) : ?>
                                                <td class="text-left">
                                                        <a href="<?= htmlspecialchars($phar) ?>"
-                                                          ><?= htmlspecialchars(basename($phar)) ?></a>
+                                                          >ext.phar<?= htmlspecialchars($ext) ?></a>
                                                </td>
+                                               <?php endforeach; ?>
+                                               <?php for($i = 0; $i < 3-count($phars); ++$i) : ?>
+                                               
+                                               <td></td>
+                                               <?php endfor; ?>
+                                               
                                                <td class="text-left">
                                                        <?php
 
                                                </td>
                                                <td class="text-right">
                                                        <?php
-                                                       $data = new Phar($phar);
-                                                       $meta = $data->getMetadata();
                                                        if ($meta) {
                                                                printf("v%s\n", $meta["version"]);
                                                        } else {
                        
                        </ul>
                        <?php endif; ?>
-
+                       <pre><?php var_dump($versions)?></pre>
                </div>
                <div class="footer">
                        <footer>
                                &copy; 2015 m6w6, Michael Wallner &mdash; Powered by <a href="//github.com/m6w6/pharext">pharext
                                        <?php
-                                       require_once __DIR__."/../vendor/m6w6/pharext/src/pharext/Version.php";
-                                       printf("v%s\n", pharext\VERSION);
+                                       require_once "../vendor/autoload.php";
+                                       printf("v%s\n", pharext\Metadata::version());
                                        ?>
                                </a>
                        </footer>