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

Source for file PackageData.php

Documentation is available at PackageData.php

  1. <?php
  2.  
  3. /*
  4. * Experimental Package Data Class - used to manage state information 
  5. * on the installer.
  6. *
  7. */
  8.  
  9.  
  10. class PEAR_Frontend_Gtk_PackageData {
  11.     
  12.     var $ui// the User interface object
  13.     /* data from remote-list */
  14.     var $name;               // name  -- wel actually not there, but lets use it anyway
  15.     var $category "";      // eg. XML
  16.     var $license "";       //eg.  PHP License
  17.     var $summary "";       // eg. RSS parser
  18.     var $description "";   // eg. Parser for Resource Description ....
  19.     var $lead  =  "";        // alan_k
  20.     var $stable =  "";  // eg. 0.9.1 version on the main server!
  21.  
  22.     /* data from local list */
  23.     
  24.     var $filelist;       // File Objects:
  25.                             // name
  26.                             // role
  27.                             // md5sum
  28.                             // installed_as
  29.                             
  30.     var $maintainers;   // Maintainer Objects
  31.                             //handle
  32.                             //name
  33.                             //email
  34.                             //role
  35.     var $version;       // Installed version eg. 1.1
  36.     var $release_date;  // eg. 2002-05-16
  37.     var $release_licence//eg. PHP 2.0.2
  38.     var $release_state// eg. stable
  39.     var $release_notes// 
  40.     var $changelog;     // Changelog Objects
  41.                             // version
  42.                             // release_date
  43.                             // release_state
  44.                             // release_notes
  45.     var $_lastmodified//
  46.                             
  47.  
  48.     /* data from installer */
  49.     var $isInstalled;    // is it installed
  50.     var $QueueInstall = FALSE;
  51.     var $QueueRemove = FALSE; 
  52.     
  53.     /* data not available yet!!! */
  54.     var $dependancies;   // list of packages that this depends on.
  55.     var $gtknode;         // gtk node for this package
  56.     
  57.     function &staticNewFromArray($array{
  58.         
  59.         // convert package.xml 2.0 to package.xml 1.0 (sort of)
  60.         if (isset($array['xsdversion']&& $array['xsdversion'== '2.0'{
  61.             require_once 'PEAR/PackageFile/v2.php';
  62.             $v2 &new PEAR_PackageFile_v2;
  63.             $v2->setConfig($this->ui->config);
  64.             unset($array['old']);
  65.             unset($array['xsdversion']);
  66.             unset($array['filelist']);
  67.             unset($array['dirtree']);
  68.             $v2->fromArray($array);
  69.             if (!$v2->validate()) {
  70.                 foreach ($v2->getValidationWarnings(as $warning{
  71.                     var_dump($warning['message']);
  72.                 }
  73.             }
  74.             $v2g &$v2->getDefaultGenerator();
  75.             $com = new PEAR_Common;
  76.             var_dump($v2g->toXml());
  77.             $array $com->infoFromString($v2g->toXml());
  78.         }
  79.         $t = new PEAR_Frontend_Gtk_PackageData;
  80.         foreach($array as $k=>$v{
  81.              
  82.              //echo "SETTING $k to $v\n";
  83.             $t->$k $v;
  84.         }
  85.         if (isset($t->package)) {
  86.             $t->name = $t->package;
  87.         }
  88.         return $t;
  89.     }
  90.     
  91.     
  92.     function merge($object{
  93.         foreach(get_object_vars($objectas $k=>$v{
  94.             if (!$vcontinue;
  95.             //echo "SET $k -> $v\n";
  96.             $this->$k $v;
  97.         }
  98.     }
  99.     /*
  100.     * create Node
  101.     *
  102.     * creates a node  - current format is:
  103.     * Name (Tree), Trash, Installed Version, Latest Version, Add, Info Icon, Summary
  104.     *
  105.     *
  106.     * @params object GtkNode Parent in tree
  107.     */
  108.     
  109.     function createNode(&$parent{
  110.         
  111.         $this->gtknode $this->ui->_packages->widget->insert_node(
  112.             $parentNULL//parent, sibling
  113.             array($this->name'','','' ),
  114.             5,   
  115.             $this->ui->_pixmaps['package.xpm'][0],
  116.             $this->ui->_pixmaps['package.xpm'][1],  
  117.             $this->ui->_pixmaps['package.xpm'][0],
  118.             $this->ui->_pixmaps['package.xpm'][1],
  119.             false,true
  120.         );
  121.         $this->_setIcon(3,'info_icon.xpm',$this->summary);
  122.         $this->ui->_packages->widget->node_set_row_data$this->gtknode$this->name);
  123.         $this->_showDelete();
  124.         $this->_showInstall();
  125.     }
  126.     
  127.     function _setIcon($col,$name,$string=''{
  128.         $ui = PEAR_Command::getFrontendObject();
  129.         $this->ui->_packages->widget->node_set_pixtext(
  130.             $this->gtknode$col,$string,0,
  131.             $this->ui->_pixmaps[$name][0],
  132.             $this->ui->_pixmaps[$name][1]
  133.         );        
  134.     }
  135.     
  136.     function _showDelete({
  137.         if (!$this->versionreturn;
  138.         
  139.         $icon "stock_delete-outline-16.xpm";
  140.         if ($this->QueueRemove)
  141.             $icon "stock_delete-16.xpm";
  142.         $this->_setIcon(1,$icon,' '.$this->version);   
  143.     }
  144.     
  145.     function _showInstall({
  146.         if ($this->version == $this->stablereturn;
  147.      
  148.         //foreach(get_object_vars($this) as $k=>$v) echo "$k=>$v\n";
  149.         $icon "check_no.xpm";
  150.         if ($this->QueueInstall)
  151.             $icon "check_yes.xpm";
  152.         $this->_setIcon(2,$icon' '.$this->stable);   
  153.     }
  154.     function toggleRemove({
  155.         if (!$this->versionreturn;
  156.  
  157.         $this->QueueRemove !$this->QueueRemove;
  158.         if ($this->QueueRemove
  159.             $this->QueueInstall = FALSE;
  160.         
  161.         $this->_showDelete();
  162.         $this->_showInstall();
  163.         
  164.     }
  165.     function toggleInstall({
  166.         if ($this->version == $this->stablereturn;
  167.         
  168.         $this->QueueInstall !$this->QueueInstall;
  169.         if ($this->QueueInstall)
  170.             $this->QueueRemove = FALSE;
  171.         $this->_showInstall();
  172.         $this->_showDelete();
  173.     }
  174.     
  175.     function doQueue({
  176.         $cmd = PEAR_Command::factory('install',$this->ui->config);
  177.         if ($this->QueueInstall{
  178.             $cmd->run('upgrade' ,''array($this->name));
  179.             return;
  180.         }
  181.         if (!$this->QueueRemovereturn;
  182.         $cmd->run('uninstall' ,''array($this->name));
  183.         
  184.     }
  185.     
  186. }
  187. ?>

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