pearweb_qa
[ class tree: pearweb_qa ] [ index: pearweb_qa ] [ all elements ]

Source for file packages_status_detail.php

Documentation is available at packages_status_detail.php

  1. <?php
  2. /*
  3.    +----------------------------------------------------------------------+
  4.    | PEAR Web site version 1.0                                            |
  5.    +----------------------------------------------------------------------+
  6.    | Copyright (c) 2001-2005 The PHP Group                                |
  7.    +----------------------------------------------------------------------+
  8.    | This source file is subject to version 2.02 of the PHP license,      |
  9.    | that is bundled with this package in the file LICENSE, and is        |
  10.    | available at through the world-wide-web at                           |
  11.    | http://www.php.net/license/2_02.txt.                                 |
  12.    | If you did not receive a copy of the PHP license and are unable to   |
  13.    | obtain it through the world-wide-web, please send a note to          |
  14.    | license@php.net so we can mail you a copy immediately.               |
  15.    +----------------------------------------------------------------------+
  16.    | Authors: Arnaud Limbourg <arnaud@limbourg.com>                       |
  17.    +----------------------------------------------------------------------+
  18.    $Id$
  19. */
  20.  
  21. /**
  22.  * This page will show a list of packages with latest
  23.  * release information along with bug count and any other info
  24.  * that may be used to identify unmaintained packages
  25.  */
  26. auth_require('pear.qa');
  27.  
  28. require 'HTML/Table.php';
  29. extra_styles('/css/packages_status.css');
  30.  
  31. // Sortable tables http://www.kryogenix.org/code/browser/sorttable/
  32. $extra_header '<script type="text/javascript" src="/javascript/sorttable.js"></script>';
  33. $states = array('snapshot''devel''alpha''beta''stable');
  34.  
  35. response_header('Quality Assurance Initiative - Packages status',
  36.     false$extra_header);
  37.  
  38. $state htmlspecialchars($_GET['state']);
  39.  
  40. if (!in_array($state$states)) {
  41.     report_error('This is not a valid state');
  42.     response_footer();
  43.     exit();
  44. }
  45.  
  46. include_once 'pear-database-package.php';
  47. $pck = new package();
  48.  
  49. $packages $pck->listAll(falsefalse);
  50. if (PEAR::isError($packages)) {
  51.     report_error('Cannot list packages');
  52.     response_footer();
  53.     exit();
  54. }
  55.  
  56. $total_packages_nbr $studied_packages_nbr = 0;
  57.  
  58. $tables = array();
  59. $time_scale = 15552000; // how much time elapsed since last release, in seconds
  60.  
  61. $tables[$state]['old'= new HTML_Table(
  62.     array(
  63.         'id'          => 'old',
  64.         'cellspacing' => 0,
  65.         'class'       => 'sortable'
  66.     )
  67. );
  68. $tables[$state]['old']->setCaption(
  69.     'Packages with state <em>'
  70.     . $state '</em> which have not been released in '
  71.     . $time_scale / 86400 . ' days'
  72. );
  73. $tables[$state]['old']->setHeaderContents(00'Package');
  74. $tables[$state]['old']->setHeaderContents(01'Version');
  75. $tables[$state]['old']->setHeaderContents(02'Date');
  76. $tables[$state]['old']->setHeaderContents(03'# bugs');
  77.  
  78. $tables[$state]['new'= new HTML_Table(
  79.     array(
  80.     'id'          => 'new',
  81.     'cellspacing' => 0,
  82.     'class'       => 'sortable'
  83.     )
  84. );
  85. $tables[$state]['new']->setCaption(
  86.     'Packages with state <em>'
  87.     . $state '</em> with a release in the past '
  88.     . $time_scale / 86400 . ' days'
  89. );
  90. $tables[$state]['new']->setHeaderContents(00'Package');
  91. $tables[$state]['new']->setHeaderContents(01'Version');
  92. $tables[$state]['new']->setHeaderContents(02'Date');
  93. $tables[$state]['new']->setHeaderContents(03'# bugs');
  94.  
  95. foreach ($packages as $package => $pck_data{
  96.     $total_packages_nbr++;
  97.  
  98.     $latest_release $pck->getRecent(1$package);
  99.     if (PEAR::isError($latest_release|| count($latest_release== 0{
  100.         continue;
  101.     }
  102.  
  103.     // we just want to see the packages for a given state
  104.     if ($latest_release[0]['state'!= $state{
  105.         continue;
  106.     }
  107.  
  108.     $release_date strtotime($latest_release[0]['releasedate']);
  109.  
  110.     $status 'new';
  111.  
  112.     if (time($time_scale $release_date{
  113.         $status 'old';
  114.     }
  115.  
  116.     $tables[$state][$status]->addRow(
  117.         array(
  118.             make_link('/package/' $package,
  119.                 $package'''title="' $package '"'),
  120.             $latest_release[0]['version'],
  121.             date('Y-m-d'$release_date),
  122.             make_link("/bugs/search.php?cmd=display&package_name%5B%5D=" urlencode($package),
  123.             bugcount($package)'''title="Bugs for package ' $package '"')
  124.         )
  125.     );
  126.  
  127.     $studied_packages_nbr++;
  128. }
  129.  
  130. $html '';
  131. foreach ($tables as $state => $table{
  132.     if ($table['old']->getRowCount(> 1{
  133.         $html .= '<p class="old">' $table['old']->toHtml('</p>';
  134.     }
  135.     if ($table['new']->getRowCount(> 1{
  136.         $html .= '<p id="new">' $table['new']->toHtml('</div>' "\n";
  137.     }
  138. }
  139.  
  140. $out '
  141. <div id="container">
  142.     <p id="pageHeader">
  143.         <h1>Summary</h1>
  144.         <div id="subtitle">
  145.             <h2>Number of packages in PEAR: {{TOTAL_PACKAGES_NUMBER}}</h2>
  146.             <h2>Number of packages studied here : {{STUDIED_PACKAGES_NUMBER}}</h2>
  147.         </div>
  148.     </p>
  149.  
  150.     <div id="details">
  151.         {{TABLES}}
  152.     </div>
  153.  
  154.     <div id="footer">
  155.     Page last updated on: {{UPDATE_DATE}}
  156.     </div>
  157. </div>
  158. ';
  159.  
  160. $search = array(
  161.     '{{TOTAL_PACKAGES_NUMBER}}',
  162.     '{{STUDIED_PACKAGES_NUMBER}}',
  163.     '{{TABLES}}',
  164.     '{{UPDATE_DATE}}',
  165. );
  166.  
  167. $replace = array(
  168.     $total_packages_nbr,
  169.     $studied_packages_nbr,
  170.     $html,
  171.     date('d F Y \a\t H:i:s')
  172. );
  173.  
  174. $out str_replace($search$replace$out);
  175.  
  176. echo $out;
  177.  
  178. response_footer();
  179.  
  180. /**
  181.  * Count number of bugs for a package
  182.  *
  183.  * @string package name
  184.  * @return int number of bugs
  185.  */
  186. function bugcount($package)
  187. {
  188.     global $dbh;
  189.  
  190.     $query '
  191.         SELECT
  192.             COUNT(*)
  193.         FROM
  194.             bugdb
  195.         WHERE
  196.             package_name=' $dbh->quoteSmart($package'
  197.             AND bug_type = "Bug"
  198.             AND status IN ("Open", "Critical", "Assigned", "Analyzed")
  199.             ';
  200.  
  201.     $count $dbh->getOne($query);
  202.  
  203.     if (PEAR::isError($count)) {
  204.         return '0';
  205.     }
  206.  
  207.     if ($count > 0 && $count < 10{
  208.         $count = "0$count";
  209.     }
  210.  
  211.     return $count;
  212. }
  213. ?>

Documentation generated on Mon, 11 Mar 2019 15:46:40 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.