Update of /cvsroot/fink/php-lib
In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv2372

Modified Files:
        finkinfo.inc 
Added Files:
        test.php 
Log Message:
a simple php class for representing fink packages, distributions, and releases

Index: finkinfo.inc
===================================================================
RCS file: /cvsroot/fink/php-lib/finkinfo.inc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- finkinfo.inc        15 Nov 2007 18:09:03 -0000      1.1.1.1
+++ finkinfo.inc        15 Nov 2007 19:10:04 -0000      1.2
@@ -0,0 +1,149 @@
+<?php
+
+class Package {
+       protected $name;
+       protected $version;
+       protected $revision;
+       protected $epoch;
+
+       protected $description;
+       protected $descdetail;
+       protected $descusage;
+
+       protected $homepage;
+       protected $license;
+       protected $maintainer;
+
+       protected $section;
+       protected $parent;
+
+       public function __construct($name, $version = NULL, $revision = NULL, 
$epoch = 0) {
+               $this->name     = $name;
+               $this->version  = $version;
+               $this->revision = $revision;
+               $this->epoch    = $epoch;
+       }
+
+       public function getId() {
+               $id = $this->name;
+               if (isset($this->epoch))    { $id .= '_' . $this->epoch; };
+               if (isset($this->version))  {
+                       if (isset($this->epoch)) {
+                               $id .= ':' . $this->version;
+                       } else {
+                               $id .= '_' . $this->version;
+                       }
+               }
+               if (isset($this->revision)) { $id .= '-' . $this->revision; };
+               return $id;
+       }
+
+       public function getName()                  { return $this->name; }
+       public function getVersion()               { return $this->version; }
+       public function setVersion($version)       { $this->version = $version; 
}
+       public function getRevision()              { return $this->revision; }
+       public function setRevision($rev)          { $this->revision = $rev; }
+       public function getEpoch()                 { return $this->epoch; }
+       public function setEpoch($epoch)           { $this->epoch = $epoch; }
+
+       public function getDescription()           { return $this->description; 
}
+       public function setDescription($desc)      { $this->description = 
$desc; }
+       public function getDescDetail()            { return $this->descdetail; }
+       public function setDescDetail($detail)     { $this->descdetail = 
$detail; }
+       public function getDescUsage()             { return $this->descusage; }
+       public function setDescUsage($usage)       { $this->descusage = $usage; 
}
+
+       public function getHomepage()              { return $this->homepage; }
+       public function setHomepage($homepage)     { $this->homepage = 
$homepage; }
+       public function getLicense()               { return $this->license; }
+       public function setLicense($license)       { $this->license = $license; 
}
+       public function getMaintainer()            { return $this->maintainer; }
+       public function setMaintainer($maintainer) { $this->maintainer = 
$maintainer; }
+
+       public function getSection()               { return $this->section; }
+       public function setSection($section)       { $this->section = $section; 
}
+       public function getParent()                { return $this->parent; }
+       public function setParent($parent)         { $this->parent = $parent; }
+
+       public function __toString() {
+               return $this->getId();
+       }
+}
+
+class Distribution {
+       protected $name;
+       protected $architecture;
+       protected $description;
+       protected $priority = 0;
+       protected $isActive = TRUE;
+       protected $isVisible = TRUE;
+       protected $isSupported = FALSE;
+
+       public function __construct($name, $architecture, $description = NULL, 
$priority = 0, $isActive = TRUE, $isVisible = TRUE, $isSupported = FALSE) {
+               $this->name         = $name;
+               $this->architecture = $architecture;
+               $this->description  = isset($description)? $description : $name;
+               $this->priority     = $priority;
+               $this->isActive     = $isActive;
+               $this->isVisible    = $isVisible;
+               $this->isSupported  = $isSupported;
+       }
+
+       public function getId() {
+               $id = $this->name;
+               if (isset($this->architecture)) { $id .= '-' . 
$this->architecture; };
+               return $id;
+       }
+
+       public function getName()              { return $this->name; }
+       public function setName($name)         { $this->name = $name; }
+       public function getArchitecture()      { return $this->architecture; }
+       public function setArchitecture($arch) { $this->architecture = $arch; }
+       public function getDescription()       { return $this->description; }
+       public function setDescription($desc)  { $this->description = $desc; }
+
+       public function getPriority()          { return $this->priority; }
+       public function setPriority($prio)     { $this->priority = $prio; }
+       public function isActive()             { return $this->isActive; }
+       public function setActive($boolean)    { $this->isActive = $boolean; }
+       public function isVisible()            { return $this->isVisible; }
+       public function setVisible($boolean)   { $this->isVisible = $boolean; }
+       public function isSupported()          { return $this->isSupported; }
+       public function setSupported($boolean) { $this->isSupported = $boolean; 
}
+
+       public function __toString() {
+               return $this->getId();
+       }
+}
+
+class Release {
+       protected $distribution;
+       protected $type;
+       protected $version;
+       protected $priority = 0;
+       protected $isActive = TRUE;
+
+       public function __construct($distribution, $type, $version, $priority = 
0, $isActive = TRUE) {
+               $this->distribution = $distribution;
+               $this->type         = $type;
+               $this->version      = $version;
+               $this->priority     = $priority;
+               $this->isActive     = $isActive;
+       }
+
+       public function getId() {
+               $id = $this->distribution . '-' . $this->version . '-' . 
$this->type;
+               return $id;
+       }
+
+       public function getPriority()          { return $this->priority; }
+       public function setPriority($prio)     { $this->priority = $prio; }
+       public function isActive()             { return $this->isActive; }
+       public function setActive($boolean)    { $this->isActive = $boolean; }
+
+       public function __toString() {
+               return $this->getId();
+       }
+}
+
+?>

--- NEW FILE: test.php ---
<?php

include "finkinfo.inc";

$foo = new Package("test", "1.0", "1");

$dist = new Distribution("10.5", "i386");
$release = new Release($dist, "unstable", "current");

echo "foo = " . $foo . "\n";
echo "dist = " . $dist . "\n";
echo "release = " . $release . "\n";


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Fink-commits mailing list
[email protected]
http://news.gmane.org/gmane.os.apple.fink.cvs

Reply via email to