/** * This method opens and validates the uploaded PEAR package * and assembles the content of the package file itself, the * dependencies and the release notes. * * @param Faett_Package_Model_Link $link The link with the PEAR package file * @return void */ public function generatePEARInfos(Faett_Package_Model_Link $link) { // initialize the PEAR service implementation $service = Faett_Core_Factory::get(Mage::getBaseDir()); // initialize the PEAR_PackageFile_v2 instance $pf = $service->packageFile($packageFile = Faett_Package_Model_Link::getBasePath() . $link->getLinkFile()); // initialize the archive $tar = new Archive_Tar($packageFile); // try to load the content of the package2.xml file $contents = $tar->extractInString('package2.xml'); // if not available, try to load from package.xml file if (!$contents) { $contents = $tar->extractInString('package.xml'); } // load the data to assemble the link with $link->setPackageFile($contents); $link->setPackageName($pf->getName()); $link->setPackageSize(filesize($packageFile)); $link->setDependencies(serialize($pf->getDependencies())); $link->setState($pf->getState()); $link->setVersion($pf->getVersion()); $link->setReleaseDate($pf->getDate()); $link->setLicence($pf->getLicense()); $link->setSummary($pf->getSummary()); $link->setDescription($pf->getDescription()); $link->setNotes($pf->getNotes()); // set the licence URI if (is_array($loc = $pf->getLicenseLocation())) { if (array_key_exists('uri', $loc)) { $link->setLicenceUri($loc['uri']); } elseif (array_key_exists('filesource', $loc)) { $link->setLicenceUri($loc['filesource']); } } // save the completed link $link->save(); }