forked from jbroadway/sitellite
/
v2.php
executable file
·1773 lines (1666 loc) · 59.3 KB
/
v2.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* PEAR_PackageFile_v2, package.xml version 2.0
*
* PHP versions 4 and 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to license@php.net so we can mail you a copy immediately.
*
* @category pear
* @package PEAR
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2005 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version CVS: $Id: v2.php,v 1.1 2005/07/02 21:12:31 lux Exp $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a1
*/
/**
* For error handling
*/
require_once 'PEAR/ErrorStack.php';
/**
* @category pear
* @package PEAR
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2005 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version Release: 1.4.0a12
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
class PEAR_PackageFile_v2
{
/**
* Parsed package information
* @var array
* @access private
*/
var $_packageInfo = array();
/**
* path to package .tgz or false if this is a local/extracted package.xml
* @var string|false
* @access private
*/
var $_archiveFile;
/**
* path to package .xml or false if this is an abstract parsed-from-string xml
* @var string|false
* @access private
*/
var $_packageFile;
/**
* This is used by file analysis routines to log progress information
* @var PEAR_Common
* @access protected
*/
var $_logger;
/**
* This is set to the highest validation level that has been validated
*
* If the package.xml is invalid or unknown, this is set to 0. If
* normal validation has occurred, this is set to PEAR_VALIDATE_NORMAL. If
* downloading/installation validation has occurred it is set to PEAR_VALIDATE_DOWNLOADING
* or INSTALLING, and so on up to PEAR_VALIDATE_PACKAGING. This allows validation
* "caching" to occur, which is particularly important for package validation, so
* that PHP files are not validated twice
* @var int
* @access private
*/
var $_isValid = 0;
/**
* True if the filelist has been validated
* @param bool
*/
var $_filesValid = false;
/**
* @var PEAR_Registry
* @access protected
*/
var $_registry;
/**
* @var PEAR_Config
* @access protected
*/
var $_config;
/**
* Optional Dependency group requested for installation
* @var string
* @access private
*/
var $_requestedGroup = false;
/**
* @var PEAR_ErrorStack
* @access protected
*/
var $_stack;
/**
* Namespace prefix used for tasks in this package.xml - use tasks: whenever possible
*/
var $_tasksNs;
/**
* Determines whether this packagefile was initialized only with partial package info
*
* If this package file was constructed via parsing REST, it will only contain
*
* - package name
* - channel name
* - dependencies
* @var boolean
* @access private
*/
var $_incomplete = true;
/**
* The constructor merely sets up the private error stack
*/
function PEAR_PackageFile_v2()
{
$this->_stack = new PEAR_ErrorStack('PEAR_PackageFile_v2', false, null);
$this->_isValid = false;
}
/**
* To make unit-testing easier
* @param PEAR_Frontend_*
* @param array options
* @param PEAR_Config
* @return PEAR_Downloader
* @access protected
*/
function &getPEARDownloader(&$i, $o, &$c)
{
$z = &new PEAR_Downloader($i, $o, $c);
return $z;
}
/**
* To make unit-testing easier
* @param PEAR_Config
* @param array options
* @param array package name as returned from {@link PEAR_Registry::parsePackageName()}
* @param int PEAR_VALIDATE_* constant
* @return PEAR_Dependency2
* @access protected
*/
function &getPEARDependency2(&$c, $o, $p, $s = PEAR_VALIDATE_INSTALLING)
{
if (!class_exists('PEAR_Dependency2')) {
require_once 'PEAR/Dependency2.php';
}
$z = &new PEAR_Dependency2($c, $o, $p, $s);
return $z;
}
/**
* Installation of source package has failed, attempt to download and install the
* binary version of this package.
* @param PEAR_Installer
*/
function installBinary(&$installer)
{
if ($this->getPackageType() == 'extsrc') {
if (!is_array($installer->getInstallPackages())) {
return false;
}
foreach ($installer->getInstallPackages() as $p) {
if ($p->isExtension($this->_packageInfo['providesextension'])) {
if ($p->getPackageType() != 'extsrc') {
return false; // the user probably downloaded it separately
}
}
}
if (isset($this->_packageInfo['extsrcrelease']['binarypackage'])) {
$installer->log(0, 'Attempting to download binary version of extension "' .
$this->_packageInfo['providesextension'] . '"');
$params = $this->_packageInfo['extsrcrelease']['binarypackage'];
if (!is_array($params) || !isset($params[0])) {
$params = array($params);
}
if (isset($this->_packageInfo['channel'])) {
foreach ($params as $i => $param) {
$params[$i] = array('channel' => $this->_packageInfo['channel'],
'package' => $param);
}
}
$dl = &$this->getPEARDownloader($installer->ui, $installer->getOptions(),
$installer->config);
$verbose = $dl->config->get('verbose');
$dl->config->set('verbose', -1);
foreach ($params as $param) {
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
$ret = $dl->download(array($param));
PEAR::popErrorHandling();
if (is_array($ret) && count($ret)) {
break;
}
}
$dl->config->set('verbose', $verbose);
if (is_array($ret)) {
if (count($ret) == 1) {
$pf = $ret[0]->getPackageFile();
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
$ret = $installer->install($ret[0]);
PEAR::popErrorHandling();
if (is_array($ret)) {
$installer->log(0, 'Download and install of binary extension "' .
$this->_registry->parsedPackageNameToString(
array('channel' => $pf->getChannel(),
'package' => $pf->getPackage()), true) . '" successful');
return $ret;
}
$installer->log(0, 'Download and install of binary extension "' .
$this->_registry->parsedPackageNameToString(
array('channel' => $pf->getChannel(),
'package' => $pf->getPackage()), true) . '" failed');
}
}
}
}
return false;
}
/**
* @return string|false Extension name
*/
function getProvidesExtension()
{
if (in_array($this->getPackageType(), array('extsrc', 'extbin'))) {
if (isset($this->_packageInfo['providesextension'])) {
return $this->_packageInfo['providesextension'];
}
}
return false;
}
/**
* @param string Extension name
* @return bool
*/
function isExtension($extension)
{
if (in_array($this->getPackageType(), array('extsrc', 'extbin'))) {
return $this->_packageInfo['providesextension'] == $extension;
}
return false;
}
/**
* Tests whether every part of the package.xml 1.0 is represented in
* this package.xml 2.0
* @param PEAR_PackageFile_v1
* @return bool
*/
function isEquivalent($pf1)
{
if (!$pf1) {
return true;
}
if ($this->getPackageType() == 'bundle') {
return false;
}
$this->_stack->getErrors(true);
if (!$pf1->validate(PEAR_VALIDATE_NORMAL)) {
return false;
}
$pass = true;
if ($pf1->getPackage() != $this->getPackage()) {
$this->_differentPackage($pf1->getPackage());
$pass = false;
}
if ($pf1->getVersion() != $this->getVersion()) {
$this->_differentVersion($pf1->getVersion());
$pass = false;
}
if ($pf1->getState() != $this->getState()) {
$this->_differentState($pf1->getState());
$pass = false;
}
$filelist = $this->getFilelist();
foreach ($pf1->getFilelist() as $file => $atts) {
if (!isset($filelist[$file])) {
$this->_missingFile($file);
$pass = false;
}
}
return $pass;
}
function _differentPackage($package)
{
$this->_stack->push(__FUNCTION__, 'error', array('package' => $package,
'self' => $this->getPackage()),
'package.xml 1.0 package "%package%" does not match "%self%"');
}
function _differentVersion($version)
{
$this->_stack->push(__FUNCTION__, 'error', array('version' => $version,
'self' => $this->getVersion()),
'package.xml 1.0 version "%version%" does not match "%self%"');
}
function _differentState($state)
{
$this->_stack->push(__FUNCTION__, 'error', array('state' => $state,
'self' => $this->getState()),
'package.xml 1.0 state "%state%" does not match "%self%"');
}
function _missingFile($file)
{
$this->_stack->push(__FUNCTION__, 'error', array('file' => $file),
'package.xml 1.0 file "%file%" is not present in <contents>');
}
/**
* WARNING - do not use this function unless you know what you're doing
*/
function setRawState($state)
{
$this->_packageInfo['stability']['release'] = $state;
}
/**
* WARNING - do not use this function unless you know what you're doing
*/
function setRawPackage($package)
{
$this->_packageInfo['name'] = $package;
}
/**
* WARNING - do not use this function unless you know what you're doing
*/
function setRawChannel($channel)
{
$this->_packageInfo['channel'] = $channel;
}
function setRequestedGroup($group)
{
$this->_requestedGroup = $group;
}
function getRequestedGroup()
{
if (isset($this->_requestedGroup)) {
return $this->_requestedGroup;
}
return false;
}
/**
* For saving in the registry.
*
* Set the last version that was installed
* @param string
*/
function setLastInstalledVersion($version)
{
$this->_packageInfo['_lastversion'] = $version;
}
/**
* @return string|false
*/
function getLastInstalledVersion()
{
if (isset($this->_packageInfo['_lastversion'])) {
return $this->_packageInfo['_lastversion'];
}
return false;
}
/**
* Determines whether this package.xml has post-install scripts or not
* @return array|false
*/
function listPostinstallScripts()
{
$filelist = $this->getFilelist();
$contents = $this->getContents();
$contents = $contents['dir']['file'];
if (!is_array($contents) || !isset($contents[0])) {
$contents = array($contents);
}
$taskfiles = array();
foreach ($contents as $file) {
$atts = $file['attribs'];
unset($file['attribs']);
if (count($file)) {
$taskfiles[$atts['name']] = $file;
}
}
$common = new PEAR_Common;
$common->debug = $this->_config->get('verbose');
$this->_scripts = array();
$ret = array();
foreach ($taskfiles as $name => $tasks) {
if (!isset($filelist[$name])) {
// ignored files will not be in the filelist
continue;
}
$atts = $filelist[$name];
foreach ($tasks as $tag => $raw) {
$task = $this->getTask($tag);
$task = &new $task($this->_config, $common, PEAR_TASK_INSTALL);
if ($task->isScript()) {
$ret[] = $filelist[$name]['installed_as'];
}
}
}
if (count($ret)) {
return $ret;
}
return false;
}
/**
* Initialize post-install scripts for running
*
* This method can be used to detect post-install scripts, as the return value
* indicates whether any exist
* @return bool
*/
function initPostinstallScripts()
{
$filelist = $this->getFilelist();
$contents = $this->getContents();
$contents = $contents['dir']['file'];
if (!is_array($contents) || !isset($contents[0])) {
$contents = array($contents);
}
$taskfiles = array();
foreach ($contents as $file) {
$atts = $file['attribs'];
unset($file['attribs']);
if (count($file)) {
$taskfiles[$atts['name']] = $file;
}
}
$common = new PEAR_Common;
$common->debug = $this->_config->get('verbose');
$this->_scripts = array();
foreach ($taskfiles as $name => $tasks) {
$atts = $filelist[$name];
foreach ($tasks as $tag => $raw) {
$taskname = $this->getTask($tag);
$task = &new $taskname($this->_config, $common, PEAR_TASK_INSTALL);
if (!$task->isScript()) {
continue; // scripts are only handled after installation
}
$lastversion = isset($this->_packageInfo['_lastversion']) ?
$this->_packageInfo['_lastversion'] : null;
$task->init($raw, $atts, $lastversion);
$res = $task->startSession($this, $atts['installed_as']);
if (!$res) {
continue; // skip this file
}
if (PEAR::isError($res)) {
return $res;
}
$assign = &$task;
$this->_scripts[] = &$assign;
}
}
if (count($this->_scripts)) {
return true;
}
return false;
}
function runPostinstallScripts()
{
if ($this->initPostinstallScripts()) {
$ui = &PEAR_Frontend::singleton();
if ($ui) {
$ui->runPostinstallScripts($this->_scripts, $this);
}
}
}
/**
* Convert a recursive set of <dir> and <file> tags into a single <dir> tag with
* <file> tags.
*/
function flattenFilelist()
{
if (isset($this->_packageInfo['bundle'])) {
return;
}
$filelist = array();
if (isset($this->_packageInfo['contents']['dir']['dir'])) {
$this->_getFlattenedFilelist($filelist, $this->_packageInfo['contents']['dir']);
if (!isset($filelist[1])) {
$filelist = $filelist[0];
}
$this->_packageInfo['contents']['dir']['file'] = $filelist;
unset($this->_packageInfo['contents']['dir']['dir']);
} else {
// else already flattened but check for baseinstalldir propagation
if (isset($this->_packageInfo['contents']['dir']['attribs']['baseinstalldir'])) {
if (isset($this->_packageInfo['contents']['dir']['file'][0])) {
foreach ($this->_packageInfo['contents']['dir']['file'] as $i => $file) {
$this->_packageInfo['contents']['dir']['file'][$i]['attribs']['baseinstalldir']
= $this->_packageInfo['contents']['dir']['attribs']['baseinstalldir'];
}
} else {
$this->_packageInfo['contents']['dir']['file']['attribs']['baseinstalldir']
= $this->_packageInfo['contents']['dir']['attribs']['baseinstalldir'];
}
}
}
}
/**
* @param array the final flattened file list
* @param array the current directory being processed
* @param string|false any recursively inherited baeinstalldir attribute
* @param string private recursion variable
* @return array
* @access protected
*/
function _getFlattenedFilelist(&$files, $dir, $baseinstall = false, $path = '')
{
if (isset($dir['attribs']) && isset($dir['attribs']['baseinstalldir'])) {
$baseinstall = $dir['attribs']['baseinstalldir'];
}
if (isset($dir['dir'])) {
if (!isset($dir['dir'][0])) {
$dir['dir'] = array($dir['dir']);
}
foreach ($dir['dir'] as $subdir) {
if (!isset($subdir['attribs']) || !isset($subdir['attribs']['name'])) {
$name = '*unknown*';
} else {
$name = $subdir['attribs']['name'];
}
$newpath = empty($path) ? $name :
$path . '/' . $name;
$this->_getFlattenedFilelist($files, $subdir,
$baseinstall, $newpath);
}
}
if (isset($dir['file'])) {
if (!isset($dir['file'][0])) {
$dir['file'] = array($dir['file']);
}
foreach ($dir['file'] as $file) {
$attrs = $file['attribs'];
$name = $attrs['name'];
if ($baseinstall) {
$attrs['baseinstalldir'] = $baseinstall;
}
$attrs['name'] = empty($path) ? $name : $path . '/' . $name;
$attrs['name'] = preg_replace(array('!\\\\+!', '!/+!'), array('/', '/'),
$attrs['name']);
$file['attribs'] = $attrs;
$files[] = $file;
}
}
}
function setConfig(&$config)
{
$this->_config = &$config;
$this->_registry = &$config->getRegistry();
}
function setLogger(&$logger)
{
if ($logger && (!is_object($logger) || !method_exists($logger, 'log'))) {
return PEAR::raiseError('Logger must be compatible with PEAR_Common::log');
}
$this->_logger = &$logger;
}
/**
* WARNING - do not use this function directly unless you know what you're doing
*/
function setDeps($deps)
{
$this->_packageInfo['dependencies'] = $deps;
}
function setPackagefile($file, $archive = false)
{
$this->_packageFile = $file;
$this->_archiveFile = $archive ? $archive : $file;
}
/**
* Wrapper to {@link PEAR_ErrorStack::getErrors()}
* @param boolean determines whether to purge the error stack after retrieving
* @return array
*/
function getValidationWarnings($purge = true)
{
return $this->_stack->getErrors($purge);
}
function getPackageFile()
{
return $this->_packageFile;
}
function getArchiveFile()
{
return $this->_archiveFile;
}
/**
* Directly set the array that defines this packagefile
*
* WARNING: no validation. This should only be performed by internal methods
* inside PEAR or by inputting an array saved from an existing PEAR_PackageFile_v2
* @param array
*/
function fromArray($pinfo)
{
unset($pinfo['old']);
unset($pinfo['xsdversion']);
$this->_incomplete = false;
$this->_packageInfo = $pinfo;
}
function isIncomplete()
{
return $this->_incomplete;
}
/**
* @return array
*/
function toArray($forreg = false)
{
if (!$this->validate(PEAR_VALIDATE_NORMAL)) {
return false;
}
return $this->getArray($forreg);
}
function getArray($forReg = false)
{
if ($forReg) {
$arr = $this->_packageInfo;
$arr['old'] = array();
$arr['old']['version'] = $this->getVersion();
$arr['old']['release_date'] = $this->getDate();
$arr['old']['release_state'] = $this->getState();
$arr['old']['release_license'] = $this->getLicense();
$arr['old']['release_notes'] = $this->getNotes();
$arr['old']['release_deps'] = $this->getDeps();
$arr['old']['maintainers'] = $this->getMaintainers();
$arr['xsdversion'] = '2.0';
return $arr;
} else {
$info = $this->_packageInfo;
unset($info['dirtree']);
if (isset($info['_lastversion'])) {
unset($info['_lastversion']);
}
return $info;
}
}
function packageInfo($field)
{
$arr = $this->getArray(true);
if ($field == 'apiversion') {
return $arr['version']['api'];
}
if (isset($arr['old'][$field])) {
if (!is_string($arr['old'][$field])) {
return null;
}
return $arr['old'][$field];
}
if (isset($arr[$field])) {
if (!is_string($arr[$field])) {
return null;
}
return $arr[$field];
}
return null;
}
function getName()
{
return $this->getPackage();
}
function getPackage()
{
if (isset($this->_packageInfo['name'])) {
return $this->_packageInfo['name'];
}
return false;
}
function getChannel()
{
if (isset($this->_packageInfo['uri'])) {
return '__uri';
}
if (isset($this->_packageInfo['channel'])) {
return strtolower($this->_packageInfo['channel']);
}
return false;
}
function getUri()
{
if (isset($this->_packageInfo['uri'])) {
return $this->_packageInfo['uri'];
}
return false;
}
function getExtends()
{
if (isset($this->_packageInfo['extends'])) {
return $this->_packageInfo['extends'];
}
return false;
}
function getSummary()
{
if (isset($this->_packageInfo['summary'])) {
return $this->_packageInfo['summary'];
}
return false;
}
function getDescription()
{
if (isset($this->_packageInfo['description'])) {
return $this->_packageInfo['description'];
}
return false;
}
function getMaintainers($raw = false)
{
if (!$this->_isValid && !$this->validate()) {
return false;
}
if ($raw) {
$ret = array('lead' => $this->_packageInfo['lead']);
(isset($this->_packageInfo['developer'])) ?
$ret['developer'] = $this->_packageInfo['developer'] :null;
(isset($this->_packageInfo['contributor'])) ?
$ret['contributor'] = $this->_packageInfo['contributor'] :null;
(isset($this->_packageInfo['helper'])) ?
$ret['helper'] = $this->_packageInfo['helper'] :null;
return $ret;
} else {
$ret = array();
$leads = isset($this->_packageInfo['lead'][0]) ? $this->_packageInfo['lead'] :
array($this->_packageInfo['lead']);
foreach ($leads as $lead) {
$s = $lead;
$s['handle'] = $s['user'];
unset($s['user']);
$s['role'] = 'lead';
$ret[] = $s;
}
if (isset($this->_packageInfo['developer'])) {
$leads = isset($this->_packageInfo['developer'][0]) ?
$this->_packageInfo['developer'] :
array($this->_packageInfo['developer']);
foreach ($leads as $maintainer) {
$s = $maintainer;
$s['handle'] = $s['user'];
unset($s['user']);
$s['role'] = 'developer';
$ret[] = $s;
}
}
if (isset($this->_packageInfo['contributor'])) {
$leads = isset($this->_packageInfo['contributor'][0]) ?
$this->_packageInfo['contributor'] :
array($this->_packageInfo['contributor']);
foreach ($leads as $maintainer) {
$s = $maintainer;
$s['handle'] = $s['user'];
unset($s['user']);
$s['role'] = 'contributor';
$ret[] = $s;
}
}
if (isset($this->_packageInfo['helper'])) {
$leads = isset($this->_packageInfo['helper'][0]) ?
$this->_packageInfo['helper'] :
array($this->_packageInfo['helper']);
foreach ($leads as $maintainer) {
$s = $maintainer;
$s['handle'] = $s['user'];
unset($s['user']);
$s['role'] = 'helper';
$ret[] = $s;
}
}
return $ret;
}
return false;
}
function getLeads()
{
if (isset($this->_packageInfo['lead'])) {
return $this->_packageInfo['lead'];
}
return false;
}
function getDevelopers()
{
if (isset($this->_packageInfo['developer'])) {
return $this->_packageInfo['developer'];
}
return false;
}
function getContributors()
{
if (isset($this->_packageInfo['contributor'])) {
return $this->_packageInfo['contributor'];
}
return false;
}
function getHelpers()
{
if (isset($this->_packageInfo['helper'])) {
return $this->_packageInfo['helper'];
}
return false;
}
function setDate($date)
{
if (!isset($this->_packageInfo['date'])) {
// ensure that the extends tag is set up in the right location
$this->_packageInfo = $this->_insertBefore($this->_packageInfo,
array('time', 'version',
'stability', 'license', 'notes', 'contents', 'compatible',
'dependencies', 'providesextension', 'srcpackage', 'srcuri',
'phprelease', 'extsrcrelease',
'extbinrelease', 'bundle', 'changelog'), array(), 'date');
}
$this->_packageInfo['date'] = $date;
$this->_isValid = 0;
}
function setTime($time)
{
$this->_isValid = 0;
if (!isset($this->_packageInfo['time'])) {
// ensure that the time tag is set up in the right location
$this->_packageInfo = $this->_insertBefore($this->_packageInfo,
array('version',
'stability', 'license', 'notes', 'contents', 'compatible',
'dependencies', 'providesextension', 'srcpackage', 'srcuri',
'phprelease', 'extsrcrelease',
'extbinrelease', 'bundle', 'changelog'), $time, 'time');
}
$this->_packageInfo['time'] = $time;
}
function getDate()
{
if (isset($this->_packageInfo['date'])) {
return $this->_packageInfo['date'];
}
return false;
}
function getTime()
{
if (isset($this->_packageInfo['time'])) {
return $this->_packageInfo['time'];
}
return false;
}
/**
* @param package|api version category to return
*/
function getVersion($key = 'release')
{
if (isset($this->_packageInfo['version'][$key])) {
return $this->_packageInfo['version'][$key];
}
return false;
}
function getStability()
{
if (isset($this->_packageInfo['stability'])) {
return $this->_packageInfo['stability'];
}
return false;
}
function getState($key = 'release')
{
if (isset($this->_packageInfo['stability'][$key])) {
return $this->_packageInfo['stability'][$key];
}
return false;
}
function getLicense($raw = false)
{
if (isset($this->_packageInfo['license'])) {
if ($raw) {
return $this->_packageInfo['license'];
}
if (is_array($this->_packageInfo['license'])) {
return $this->_packageInfo['license']['_content'];
} else {
return $this->_packageInfo['license'];
}
}
return false;
}
function getLicenseLocation()
{
if (!isset($this->_packageInfo['license']) || !is_array($this->_packageInfo['license'])) {
return false;
}
return $this->_packageInfo['license']['attribs'];
}
function getNotes()
{
if (isset($this->_packageInfo['notes'])) {
return $this->_packageInfo['notes'];
}
return false;
}
/**
* This should only be used to retrieve filenames and install attributes
*/
function getFilelist($preserve = false)
{
if (isset($this->_packageInfo['filelist']) && !$preserve) {
return $this->_packageInfo['filelist'];
}
$this->flattenFilelist();
if ($contents = $this->getContents()) {
$ret = array();
if (!isset($contents['dir']['file'][0])) {
$contents['dir']['file'] = array($contents['dir']['file']);
}
foreach ($contents['dir']['file'] as $file) {
$name = $file['attribs']['name'];
if (!$preserve) {
$file = $file['attribs'];
}
$ret[$name] = $file;
}
if (!$preserve) {
$this->_packageInfo['filelist'] = $ret;
}
return $ret;
}
return false;
}
/**
* This is only used at install-time, after all serialization
* is over.
*/
function resetFilelist()
{
$this->_packageInfo['filelist'] = array();
}