Exemple #1
0
 /**
  * Displays package information for the specified package
  *
  * @param array   $package associative array containing package information.
  * @param string  $php     optional. The PHP version on which to filter.
  *                         If not specified, defaults to 'all'.
  * @param integer $count   optional. The ordinal index of the package
  *                         being displayed.
  *
  * @return null
  */
 protected function displayPackage(array $package, $php = 'all', $count = 0)
 {
     $packageClass = $count === 0 ? 'package package-first' : 'package';
     echo " <div class=\"{$packageClass}\">\n";
     echo "  <div class=\"package-info\">\n";
     // name
     $packageName = htmlspecialchars($package['name']);
     echo "   <div class=\"package-title\">\n";
     echo "    <a href=\"package/{$packageName}\">{$packageName}</a>\n";
     echo "   </div>\n";
     // summary
     $packageSummary = trim(htmlspecialchars($package['summary']));
     echo "   <div class=\"package-description\">\n";
     echo "    <p>{$packageSummary}</p>\n";
     echo "   </div>\n";
     // deprecated note
     if (!empty($package['newpk_id'])) {
         echo "   <div class=\"package-notes\">\n";
         $newPackageName = $this->dbh->getOne('SELECT name FROM packages WHERE id = ' . $this->dbh->quote($package['newpk_id'], 'text') . ' ORDER BY id DESC LIMIT 1');
         $newPackageName = htmlspecialchars($newPackageName);
         echo "    <p>This package has been deprecated in favor of " . "<a href=\"/package/{$newPackageName}\">" . $newPackageName . "</a>.</p>";
         echo "   </div>\n";
     }
     echo "  </div>\n";
     echo "  <div class=\"package-more-info\">\n";
     echo "   <table class=\"package-data\">\n";
     echo "    <tbody>\n";
     // status
     switch ($package['status']) {
         case 'stable':
             $state = '<span class="package-stable">stable</span>';
             break;
         case 'beta':
             $state = '<span class="package-beta">beta</span>';
             break;
         case 'alpha':
         default:
             $state = '<span class="package-alpha">alpha</span>';
             break;
     }
     $timestamp = strtotime($package['releasedate']);
     $packageVersion = htmlspecialchars($package['version']);
     $packageDateIso = htmlspecialchars(date('c', $timestamp));
     $packageDate = htmlspecialchars(date('Y-m-d', $timestamp));
     echo "     <tr>\n";
     echo "      <th>Status:</th>\n";
     echo "      <td>" . $packageVersion . " " . "(" . $state . ") " . "released on <abbr class=\"date\" title=\"{$packageDateIso}\">" . $packageDate . "</abbr>" . "</td>\n";
     echo "     </tr>\n";
     // license
     $packageLicense = htmlspecialchars($package['license']);
     $packageLicenseStatus = license::isGood($package['license']);
     $packageLicenseLink = license::getLink($package['license']);
     $packageLicenseClass = $packageLicenseStatus ? 'package-license-good' : 'package-license-bad';
     echo "     <tr>\n";
     echo "      <th>License:</th>\n";
     echo "      <td>";
     echo "<span class=\"{$packageLicenseClass}\">";
     if ($packageLicenseLink === null) {
         echo $packageLicense;
     } else {
         echo "<a href=\"{$packageLicenseLink}\">{$packageLicense}</a>";
     }
     echo "</span>";
     echo "</td>\n";
     echo "     </tr>\n";
     // maintained
     echo "     <tr>\n";
     echo "      <th>Maintained:</th>\n";
     echo "      <td>";
     if ($package['unmaintained'] == 0) {
         echo "Yes";
     } else {
         echo "<span class=\"package-unmaintained\">No</span>";
     }
     echo "</td>\n";
     echo "     </tr>\n";
     // bugs
     if ($package['numbugs'] == 0) {
         $packageBugs = 'none';
     } else {
         $packageBugs = $package['numbugs'];
     }
     $packageBugsLink = 'bugs/search.php?cmd=display&amp;package_name[]=' . urlencode($package['name']);
     echo "     <tr>\n";
     echo "      <th>Open Bugs:</th>\n";
     echo "      <td>";
     echo "<a href=\"{$packageBugsLink}\">{$packageBugs}</a>";
     echo "</td>\n";
     echo "     </tr>\n";
     echo "    </tbody>\n";
     echo "   </table>\n";
     echo "  </div>\n";
     echo " </div>\n";
 }