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(
  62.             $this->getName()null$this->getChannel()
  63.         );
  64.  
  65.         if ($arData === null{
  66.             //no local package data -> uninstalled or not available
  67.             $this->setInstalledVersion(null);
  68.         else {
  69.             $this->incorporateLocalInfo($arData);
  70.         }
  71.     }//public function refreshLocalInfo()
  72.  
  73.  
  74.  
  75.     /**
  76.     *   Tries to guess the category name from the package name
  77.     *       e.g. Dev_Inspector should have "Dev" as category
  78.     *   If no category can be guessed, "" (empty string) will
  79.     *       be returned
  80.     *
  81.     *   @param  string  $strName    The package name
  82.     *   @return string  The guessed category name
  83.     */
  84.     public static function guessCategory($strName)
  85.     {
  86.         $nPos strpos($strName'_');
  87.         if ($nPos !== false{
  88.             $strCategory substr($strName0$nPos);
  89.         else {
  90.             //no underscore
  91.             $strCategory $strName;
  92.         }
  93.         return $strCategory;
  94.     }//public static function guessCategory($strName)
  95.  
  96.  
  97.  
  98.     public function getName({
  99.         return $this->strName;
  100.     }
  101.  
  102.  
  103.  
  104.     public function getChannel({
  105.         return $this->strChannel;
  106.     }
  107.  
  108.  
  109.  
  110.     public function getSummary({
  111.         return $this->strSummary;
  112.     }
  113.  
  114.  
  115.  
  116.     public function getDescription({
  117.         return $this->strDescription;
  118.     }
  119.  
  120.  
  121.  
  122.     public function getCategory()
  123.     {
  124.         return $this->strCategory;
  125.     }//public function getCategory()
  126.  
  127.  
  128.  
  129.     function getInstalledVersion()
  130.     {
  131.         return $this->strVersionInstalled;
  132.     }//function getInstalledVersion()
  133.  
  134.  
  135.  
  136.     function getLatestVersion()
  137.     {
  138.         return $this->strVersionLatest;
  139.     }//function getLatestVersion()
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.     function setName($strName)
  147.     {
  148.         $this->strName $strName;
  149.     }//function setName($strName)
  150.  
  151.  
  152.  
  153.     function setCategory($strCategory)
  154.     {
  155.         $this->strCategory $strCategory;
  156.     }//function setCategory($strCategory)
  157.  
  158.  
  159.  
  160.     function setChannel($strChannel)
  161.     {
  162.         $this->strChannel $strChannel;
  163.     }//function setChannel($strChannel)
  164.  
  165.  
  166.  
  167.     function setSummary($strSummary)
  168.     {
  169.         $this->strSummary $strSummary;
  170.     }//function setSummary($strSummary)
  171.  
  172.  
  173.  
  174.     function setDescription($strDescription)
  175.     {
  176.         $this->strDescription $strDescription;
  177.     }//function setDescription($strDescription)
  178.  
  179.  
  180.  
  181.     function setFullyLoaded($bFullyLoaded)
  182.     {
  183.         $this->bFullyLoaded $bFullyLoaded;
  184.     }//function setFullyLoaded($bFullyLoaded)
  185.  
  186.  
  187.  
  188.     function setInstalledVersion($strVersionInstalled)
  189.     {
  190.         if ($strVersionInstalled == ''{
  191.             $strVersionInstalled = null;
  192.         }
  193.         $this->strVersionInstalled $strVersionInstalled;
  194.     }//function setInstalledVersion($strVersionInstalled)
  195.  
  196.  
  197.  
  198.     function setLatestVersion($strVersionLatest)
  199.     {
  200.         if (!is_string($strVersionLatest)) {
  201.             $strVersionLatest '?';
  202.         }
  203.         if ($strVersionLatest == ''{
  204.             $strVersionLatest = null;
  205.         }
  206.         $this->strVersionLatest $strVersionLatest;
  207.     }//function setInstalledVersion($strVersionLatest)
  208.  
  209. }//class PEAR_Frontend_Gtk2_Package
  210. ?>

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