| <?php |
| |
| require_once "excludes.php"; |
| require_once "XMLNode.class.php"; |
| require_once "XMLParser.class.php"; |
| require_once "XMLHandler.class.php"; |
| require_once "URLCheck.class.php"; |
| require_once "URLReader.class.php"; |
| require_once "Shipping.class.php"; |
| |
| define("XMLFILE","eclipse-project-info.xml"); |
| define("FAKEREPORTS","http://phoenix.eclipse.org/projects/temporary"); |
| |
| class ProjectInfo { |
| // Main |
| var $_name; |
| var $_shortname; |
| var $_url; |
| var $_summary; |
| var $_description; |
| var $_shipping; |
| var $_projectiplog; |
| var $_mailinglists; |
| var $_newsgroup; |
| var $_bugzilla; |
| var $_blog; |
| var $_cvs; |
| |
| // Auxiliar |
| var $_excludes; |
| var $_excount; |
| var $_projectID; |
| var $_inturl; |
| |
| |
| function ProjectInfo($projectID,$url){ |
| # Get exclude information |
| $this->_excludes = explode(",",EXCLUDED_PROJECTS); |
| $this->_excount = count($this->_excludes); |
| |
| $this->_projectID = $projectID; |
| $this->_inturl = dirname($url); |
| |
| // Variables with accessors |
| $this->_name = ""; |
| $this->_shortname = ""; |
| $this->_url = ""; |
| $this->_summary = ""; |
| $this->_description = ""; |
| $this->_shipping = New Shipping(); |
| $this->_projectiplog = ""; |
| $this->_mailinglists = array(); |
| $this->_newsgroup = ""; |
| $this->_bugzilla = ""; |
| $this->_blog = ""; |
| $this->_cvs = ""; |
| } |
| |
| function validProject($project){ |
| $project = strtolower($project); |
| |
| for($i=0;$i<$this->_excount;$i++){ |
| if ($project == $this->_excludes[$i]) |
| return 0; |
| else |
| if (strpos($project,".") && strpos($this->_excludes[$i],".")){ |
| $pos1 = strrpos($project,"."); // Check if this |
| $pos2 = strrpos($this->_excludes[$i],"."); // group is excluded |
| $str1 = substr($project,0,$pos1); // by means of a |
| $str2 = substr($this->_excludes[$i],0,$pos2); // wildcard group |
| $str3 = substr($this->_excludes[$i],$pos2+1); // (i.e., tptp.*) |
| if ($str1 == $str2 && $str3 == '*') |
| return 0; |
| } |
| } |
| |
| return 1; |
| } |
| |
| function getProjectInfo(){ |
| if ($this->validProject($this->_projectID)){ |
| $this->_inturl .= "/".XMLFILE; |
| $u = new URLCheck($this->_inturl); |
| if (!$u->urlExists()) // if real URL doesn't exist use prototype |
| $this->_inturl = $this->fakeFile($this->_projectID); |
| $p =& new XMLParser(); // Has to be done each time or it fails |
| $p->parse($this->_inturl); |
| print_r($p->getOutput()); echo "<br>\n"; |
| $h = new XMLHandler($p->getOutput()); |
| |
| // Name |
| $node = new XMLNode($h->getNodeByPath("/project/name")); |
| if ($node->getContent() != "") |
| $this->_name = $node->getContent(); |
| |
| // ShortName |
| $node = new XMLNode($h->getNodeByPath("/project/short-name")); |
| if ($node->getContent() != "") |
| $this->_shortname = $node->getContent(); |
| |
| // URL |
| $node = new XMLNode($h->getNodeByPath("/project/URL")); |
| if ($node->getContent() != "") |
| $this->_url = $node->getContent(); |
| |
| // Summary |
| $node = new XMLNode($h->getNodeByPath("/project/summary")); |
| if ($node->getContent() != "") |
| $this->_summary = $node->getContent(); |
| |
| // Description |
| $node->setNode($h->getNodeByPath("/project/description")); |
| if ($node->getContent() != "") |
| $this->_description = $node->getContent(); |
| |
| // Shipping |
| $node->setNode($h->getNodeByPath("/project/shipping")); |
| if ($node->hasAttributes() && ($node->getAttribute('URL') != "")){ |
| $parseurl = new URLReader($node->getAttribute('URL')); |
| $ship = $parseurl->getReleases($node->getAttribute('ANAME')); |
| if (count($a)) |
| echo $this->_shipping->setShipping($ship); |
| } |
| // Releases |
| |
| // Project IP Log |
| $node->setNode($h->getNodeByPath("/project/project-ip-log")); |
| if ($node->hasAttributes()) |
| $this->_projectiplog = $node->getAttribute('URL'); |
| |
| // Community |
| |
| // Mailing Lists |
| $node->setNode($h->getNodeByPath("/project/community/mailing-lists")); |
| if ($node->getContent() != ""){ |
| $this->_mailinglists = $node->getContent(); |
| } |
| |
| // Newsgroup |
| $node->setNode($h->getNodeByPath("/project/community/newsgroup")); |
| if ($node->getContent() != "") |
| $this->_newsgroup = $node->getContent(); |
| |
| // Bugzilla |
| $node->setNode($h->getNodeByPath("/project/community/bugzilla")); |
| if ($node->getContent() != "") |
| $this->_bugzilla = $node->getContent(); |
| |
| // Blog |
| $node->setNode($h->getNodeByPath("/project/community/blog")); |
| if ($node->getContent() != "") |
| $this->_blog = $node->getContent(); |
| |
| // CVS |
| $node->setNode($h->getNodeByPath("/project/community/cvs")); |
| if ($node->getContent() != "") |
| $this->_cvs = $node->getContent(); |
| } |
| } |
| |
| function fakeFile($pID){ |
| $pID = str_replace(".","/",$pID); // For directory search |
| $url = FAKEREPORTS."/".$pID."/".XMLFILE; |
| $u = new URLCheck($url); |
| if (!$u->urlExists()) |
| die("Could not find ".$url." aborting...\n"); |
| |
| return $url; |
| } |
| |
| function getName(){ |
| return $this->_name; |
| } |
| |
| function getShortName(){ |
| return $this->_shortname; |
| } |
| |
| function getURL(){ |
| return $this->_url; |
| } |
| |
| function getSummary(){ |
| return $this->_summary; |
| } |
| |
| function getDescription(){ |
| return $this->_description; |
| } |
| |
| function getShipping(){ |
| return $this->_shipping; |
| } |
| |
| function getProjectIPLog(){ |
| return $this->_projectiplog; |
| } |
| |
| function getMailingLists(){ |
| return $this->_mailinglists; |
| } |
| |
| function getNewsgroup(){ |
| return $this->_newsgroup; |
| } |
| |
| function getBugzilla(){ |
| return $this->_bugzilla; |
| } |
| |
| function getBlog(){ |
| return $this->_blog; |
| } |
| |
| function getCVS(){ |
| return $this->_cvs; |
| } |
| |
| } |
| ?> |