3 require_once 'phing/tasks/ext/PearPackage2Task.php';
5 class PhergiePackageTask extends PearPackage2Task
7 protected function setOptions()
9 $this->pkg->addMaintainer('lead', 'team', 'Phergie Development Team', 'team@phergie.org');
11 $path = str_replace('_', '/', $this->package) . '.php';
12 if (file_exists($path)) {
13 $contents = file_get_contents($path);
14 preg_match_all('#/\*\*(.*)\*/#Ums', $contents, $matches, PREG_SET_ORDER);
15 $doc = $matches[1][1];
17 $have_summary = false;
18 $have_description = false;
19 foreach ($this->options as $option) {
20 switch ($option->getName()) {
25 $have_descripion = true;
30 if (!$have_summary || !$have_description) {
31 $description = substr($doc, 0, strpos($doc, '@'));
32 $description = trim(preg_replace(array('#^[\h*]*|[\h*]*$#m', '#[\h]+#m'), array('', ' '), $description));
33 $split = preg_split('/\v\v+/', $description);
34 $summary = trim(array_shift($split));
36 $this->pkg->setSummary(htmlentities($summary, ENT_QUOTES));
38 if (!$have_description) {
39 $this->pkg->setDescription(htmlentities($description, ENT_QUOTES));
43 $doc = preg_split('/\v+/', $doc);
44 $doc = preg_grep('/@uses/', $doc);
45 $doc = preg_replace('/\s*\* @uses\s+|\s+$/', '', $doc);
46 foreach ($doc as $line) {
47 if (strpos($line, 'extension') === 0) {
48 $line = explode(' ', $line);
50 $optional = 'required';
51 if (isset($line[2])) {
54 $this->pkg->addExtensionDep(
59 $line = explode(' ', $line);
62 $optional = 'required';
63 if (isset($line[2])) {
66 $this->pkg->addPackageDepWithChannel(
76 foreach ($this->mappings as $key => $map) {
77 switch ($map->getName()) {
79 $releases = $map->getValue();
80 foreach ($releases as $release) {
81 $this->pkg->addRelease();
82 if (isset($release['installconditions'])) {
83 if (isset($release['installconditions']['os'])) {
84 $this->pkg->setOsInstallCondition($release['installconditions']['os']);
87 if (isset($release['filelist'])) {
88 if (isset($release['filelist']['install'])) {
89 foreach ($release['filelist']['install'] as $file => $as) {
90 $this->pkg->addInstallAs($file, $as);
93 if (isset($release['filelist']['ignore'])) {
94 foreach ($release['filelist']['ignore'] as $file) {
95 $this->pkg->addIgnoreToRelease($file);
106 $this->mappings = $newmap;
108 parent::setOptions();