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

Source for file ci_frontend.php

Documentation is available at ci_frontend.php

  1. <?php
  2. /**
  3.  * PEAR::CompatInfo Web frontend
  4.  *
  5.  * @version   $Id: ci_frontend.php,v 1.3 2006/07/26 08:54:30 farell Exp $
  6.  * @author    Laurent Laville <pear@laurent-laville.org>
  7.  * @ignore
  8.  */
  9.  
  10. require_once 'PEAR/Registry.php';
  11. require_once 'HTML/QuickForm.php';
  12. require_once 'HTML/QuickForm/advmultiselect.php';
  13.  
  14. if (version_compare(phpversion()'5.0.0''<')) {
  15.     include_once 'PHP/Compat.php';
  16.     PHP_Compat::loadFunction('array_combine');
  17. }
  18.  
  19. $sess =$_SESSION;
  20.  
  21. $config = new PEAR_Config();
  22. $pear_install_dir $config->get('php_dir');
  23. $reg = new PEAR_Registry($pear_install_dir);
  24.  
  25. if (count($sess== 0{
  26.  
  27.     // PEAR packages installed from each channel
  28.     $allpackages $reg->listAllPackages();
  29.     foreach ($allpackages as $channel => $packages{
  30.         if ($packages{
  31.             sort($packagesSORT_ASC);
  32.             foreach ($packages as $package{
  33.                 $info &$reg->getPackage($package$channel);
  34.                 if (is_object($info)) {
  35.                     $name          $info->getPackage();
  36.                     $version       $info->getVersion();
  37.                     $release_state $info->getState();
  38.                 else {
  39.                     $name          $info['package'];
  40.                     $version       $info['version'];
  41.                     $release_state $info['state'];
  42.                 }
  43.                 $sess['packages'][$channel][= "$name $version ($release_state)";
  44.             }
  45.         else {
  46.             $sess['packages'][$channel= array();
  47.         }
  48.     }
  49.  
  50.     // channels
  51.     $channels array_keys($sess['packages']);
  52.     array_unshift($channels'');
  53.     $sess['channels'array_combine($channels$channels);
  54.  
  55.     // packages
  56.     $names[''= array();
  57.     foreach ($sess['packages'as $c => $p{
  58.         if (count($p)) {
  59.             $l = array();
  60.             foreach ($p as $k{
  61.                 list($n$v$sexplode(' '$k);
  62.                 $l[$n;
  63.             }
  64.             $names[$carray_combine($l$p);
  65.         else {
  66.             $names[$c= array();
  67.         }
  68.     }
  69.     $sess['pkgnames'$names;
  70.  
  71.     // PHP internal functions
  72.     $func get_defined_functions();
  73.     sort($func['internal']);
  74.     $sess['phpfunctions'$func['internal'];
  75. }
  76.  
  77. // ignore functions
  78. $ignore_functions array_combine($sess['phpfunctions']$sess['phpfunctions']);
  79.  
  80. // web frontend
  81. $form = new HTML_QuickForm('cife');
  82. $form->removeAttribute('name');        // XHTML compliance
  83.  
  84. // header
  85. $form->addElement('header''cife_hdr''CompatInfo :: Web frontend');
  86.  
  87. // ignore functions
  88. $ams1 =$form->addElement('advmultiselect''ignore_functions'null,
  89.     $ignore_functions,
  90.     array('size' => 5'style' => 'width:250px;''class' => 'pool')
  91.     );
  92. $ams1->setLabel(array('PHP functions:''available''ignore'));
  93.  
  94. // packages installed
  95. $pkgInstalled =$form->addElement('hierselect''package'nullarray('class' => 'flat')'&nbsp;');
  96. $pkgInstalled->setLabel('Packages installed:');
  97. $pkgInstalled->setOptions(array($sess['channels']$sess['pkgnames']));
  98. $form->addElement('submit''filelist''File List');
  99.  
  100. // ignore files
  101. $safe $form->getSubmitValues();
  102.  
  103. if (isset($safe['filelist'])) {
  104.     $package &$reg->getPackage($safe['package'][1]$safe['package'][0]);
  105.     $files   = array();
  106.  
  107.     $filelist $package->getFilelist();
  108.     foreach ($filelist as $name => $atts{
  109.         if (isset($atts['role']&& $atts['role'!= 'php'{
  110.             continue;
  111.         }
  112.         if (!preg_match('/\.php$/'$name)) {
  113.             continue;
  114.         }
  115.         $files[$atts['installed_as'];
  116.     }
  117.     $sess['phpfiles'$files;
  118.     $labels str_replace($pear_install_dir . DIRECTORY_SEPARATOR''$files);
  119.     $ignore_files array_combine($files$labels);
  120.  
  121. else {
  122.     $ignore_files = array();
  123. }
  124.  
  125. $ams2 =$form->addElement('advmultiselect''ignore_files'null,
  126.     $ignore_files,
  127.     array('size' => 5'style' => 'width:300px;''class' => 'pool')
  128.     );
  129. $ams2->setLabel(array('Package files (role=php):''available''ignore'));
  130.  
  131. // dump options
  132. $dump =$form->addElement('checkbox''dump');
  133. $dump->setLabel('Dump:');
  134. $dump->setText('PHP min version only');
  135.  
  136. $dbg =$form->addElement('checkbox''dbg');
  137. $dbg->setLabel('Debug:');
  138. $dbg->setText('Extra output');
  139.  
  140. // commands
  141. $form->addElement('submit''process''Process');
  142. $form->addElement('submit''abort''Abort');
  143.  
  144. // initial values
  145. $form->setDefaults(array(
  146.     'ignore_functions' => array(),
  147.     'ignore_files' => array(),
  148.     'dump' => true
  149.     ));
  150.  
  151. ?>
  152. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  153.     "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  154. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  155. <head>
  156. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  157. <title>PEAR::PHP_CompatInfo Web frontend </title>
  158. <style type="text/css">
  159. <!--
  160. body {
  161.   background-color: #FFF;
  162.   font-family: Verdana, Arial, helvetica;
  163.   font-size: 10pt;
  164. }
  165.  
  166. .error {
  167.   color: red;
  168.   font-weight: bold;
  169. }
  170.  
  171. .dump {
  172.   background-color: #EEE;
  173.   color: black;
  174. }
  175.  
  176. table.pool {
  177.   border: 0;
  178.   background-color: #339900;
  179.   width:450px;
  180. }
  181. table.pool th {
  182.   font-size: 80%;
  183.   font-style: italic;
  184.   text-align: left;
  185. }
  186. table.pool select {
  187.   color: white;
  188.   background-color: #006600;
  189. }
  190.  
  191. .inputCommand {
  192.     background-color: #d0d0d0;
  193.     border: 1px solid #7B7B88;
  194.     width: 7em;
  195.     margin-bottom: 2px;
  196. }
  197.  -->
  198. </style>
  199. <script type="text/javascript">
  200. //<![CDATA[
  201. <?php
  202. echo $ams1->getElementJs();
  203.  
  204. echo $ams2->getElementJs();
  205. ?>
  206. //]]>
  207. </script>
  208. </head>
  209. <body>
  210. <?php
  211. if ($form->validate()) {
  212.     $safe $form->getSubmitValues();
  213.  
  214.     if (isset($safe['ignore_files'])) {
  215.         $ignore_files $safe['ignore_files'];
  216.     else {
  217.         $ignore_files = array();
  218.     }
  219.     if (isset($safe['ignore_functions'])) {
  220.         $ignore_functions $safe['ignore_functions'];
  221.     else {
  222.         $ignore_functions = array();
  223.     }
  224.  
  225.     if (!isset($sess['phpfiles']&& !isset($safe['abort'])) {
  226.         echo '<p class="error">Please get file list before to process.</p>';
  227.     else {
  228.         if (isset($safe['process'])) {
  229.  
  230.             include_once 'PHP/CompatInfo.php';
  231.  
  232.             $info = new PHP_CompatInfo();
  233.  
  234.             $options = array(
  235.                 'debug' => (isset($safe['dbg'])),
  236.                 'ignore_files' => $ignore_files,
  237.                 'ignore_functions' => $ignore_functions
  238.                 );
  239.  
  240.             $res $info->parseArray($sess['phpfiles']$options);
  241.  
  242.             $php $res['version'];
  243.  
  244.             echo "<h1>CompatInfo for package {$safe['package'][1]}</h1>";
  245.             echo "<h2>PHP $php min is required</h2>";
  246.  
  247.             if (!isset($safe['dump'])) {
  248.                 echo '<pre class="dump">';
  249.                 var_dump($res);
  250.                 echo '</pre>';
  251.             }
  252.         }
  253.  
  254.         if (isset($safe['process']|| isset($safe['abort'])) {
  255.             // cleansweep before quit
  256.             $_SESSION = array();
  257.             session_destroy();
  258.             if (isset($safe['abort'])) {
  259.                 echo '<h1>Task was aborted !</h1>';
  260.             }
  261.             exit();
  262.         }
  263.     }
  264. }
  265. $form->display();
  266. ?>
  267. </body>
  268. </html>

Documentation generated on Mon, 11 Mar 2019 14:44:07 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.