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

Source for file Package.php

Documentation is available at Package.php

  1. <?php
  2. /**
  3. *   A single PEAR package with some of its data
  4. *   like name, category, installed version, latest version,
  5. *   summary and description
  6. *
  7. *   @author Christian Weiske <cweiske@php.net>
  8. */
  9. class PEAR_Frontend_Gtk2_Package
  10. {
  11.     protected $bFullyLoaded         = false;
  12.  
  13.     protected $strName              = null;
  14.     protected $strChannel           = null;
  15.     protected $strCategory          = null;
  16.     protected $strSummary           = null;
  17.     protected $strDescription       = null;
  18.     protected $strVersionLatest     = null;
  19.     protected $strVersionInstalled  = null;
  20.  
  21.     /**
  22.     *   Constructs a package object
  23.     *
  24.     *   @param string $strName  the package name
  25.     */
  26.     public function __construct($strName$strChannel)
  27.     {
  28.         $this->setName($strName);
  29.         $this->setChannel($strChannel);
  30.         $this->setFullyLoaded(false);
  31.     }//public function __construct($strName, $strChannel)
  32.  
  33.  
  34.  
  35.     /**
  36.     *   Loads the package information array from
  37.     *   PEAR_Registry::packageInfo() into the local variables
  38.     */
  39.     public function incorporateLocalInfo($arPackageInfo)
  40.     {
  41.         $this->setSummary($arPackageInfo['summary']);
  42.         $this->setDescription($arPackageInfo['description']);
  43.  
  44.         if (is_array($arPackageInfo['version'])) {
  45.             $this->setInstalledVersion($arPackageInfo['version']['release']);
  46.         else {
  47.             $this->setInstalledVersion($arPackageInfo['version']);
  48.         }
  49. //require_once 'Gtk2/VarDump.php'; new Gtk2_VarDump($arPackageInfo, '$arPackageInfo');
  50.     }//public function incorporateLocalInfo($arPackageInfo)
  51.  
  52.  
  53.  
  54.     /**
  55.     *   Reloads the local package info.
  56.     *   Useful if the package has been installed or uninstalled
  57.     */
  58.     public function refreshLocalInfo()
  59.     {
  60.         $config = PEAR_Config::singleton();
  61.         $arData $config->getRegistry()->packageInfo($this->getName()null$this->getChannel());
  62.  
  63.         if ($arData === null{
  64.             //no local package data -> uninstalled or not available
  65.             $this->setInstalledVersion(null);
  66.         else {
  67.             $this->incorporateLocalInfo($arData);
  68.         }
  69.     }//public function refreshLocalInfo()
  70.  
  71.  
  72.  
  73.     /**
  74.     *   Tries to guess the category name from the package name
  75.     *       e.g. Dev_Inspector should have "Dev" as category
  76.     *   If no category can be guessed, "" (empty string) will
  77.     *       be returned
  78.     *
  79.     *   @param  string  $strName    The package name
  80.     *   @return string  The guessed category name
  81.     */
  82.     public static function guessCategory($strName)
  83.     {
  84.         $nPos strpos($strName'_');
  85.         if ($nPos !== false{
  86.             $strCategory substr($strName0$nPos);
  87.         else {
  88.             //no underscore
  89.             $strCategory $strName;
  90.         }
  91.         return $strCategory;
  92.     }//public static function guessCategory($strName)
  93.  
  94.  
  95.  
  96.     public function getName({
  97.         return $this->strName;
  98.     }
  99.  
  100.  
  101.  
  102.     public function getChannel({
  103.         return $this->strChannel;
  104.     }
  105.  
  106.  
  107.  
  108.     public function getSummary({
  109.         return $this->strSummary;
  110.     }
  111.  
  112.  
  113.  
  114.     public function getDescription({
  115.         return $this->strDescription;
  116.     }
  117.  
  118.  
  119.  
  120.     public function getCategory()
  121.     {
  122.         return $this->strCategory;
  123.     }//public function getCategory()
  124.  
  125.  
  126.  
  127.     function getInstalledVersion()
  128.     {
  129.         return $this->strVersionInstalled;
  130.     }//function getInstalledVersion()
  131.  
  132.  
  133.  
  134.     function getLatestVersion()
  135.     {
  136.         return $this->strVersionLatest;
  137.     }//function getLatestVersion()
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.     function setName($strName)
  145.     {
  146.         $this->strName $strName;
  147.     }//function setName($strName)
  148.  
  149.  
  150.  
  151.     function setCategory($strCategory)
  152.     {
  153.         $this->strCategory $strCategory;
  154.     }//function setCategory($strCategory)
  155.  
  156.  
  157.  
  158.     function setChannel($strChannel)
  159.     {
  160.         $this->strChannel $strChannel;
  161.     }//function setChannel($strChannel)
  162.  
  163.  
  164.  
  165.     function setSummary($strSummary)
  166.     {
  167.         $this->strSummary $strSummary;
  168.     }//function setSummary($strSummary)
  169.  
  170.  
  171.  
  172.     function setDescription($strDescription)
  173.     {
  174.         $this->strDescription $strDescription;
  175.     }//function setDescription($strDescription)
  176.  
  177.  
  178.  
  179.     function setFullyLoaded($bFullyLoaded)
  180.     {
  181.         $this->bFullyLoaded $bFullyLoaded;
  182.     }//function setFullyLoaded($bFullyLoaded)
  183.  
  184.  
  185.  
  186.     function setInstalledVersion($strVersionInstalled)
  187.     {
  188.         if ($strVersionInstalled == ''{
  189.             $strVersionInstalled = null;
  190.         }
  191.         $this->strVersionInstalled $strVersionInstalled;
  192.     }//function setInstalledVersion($strVersionInstalled)
  193.  
  194.  
  195.  
  196.     function setLatestVersion($strVersionLatest)
  197.     {
  198.         if (!is_string($strVersionLatest)) {
  199.             $strVersionLatest '?';
  200.         }
  201.         if ($strVersionLatest == ''{
  202.             $strVersionLatest = null;
  203.         }
  204.         $this->strVersionLatest $strVersionLatest;
  205.     }//function setInstalledVersion($strVersionLatest)
  206.  
  207. }//class PEAR_Frontend_Gtk2_Package
  208. ?>

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