635 {
636 $reg = &$this->config->getRegistry();
637 $caption = 'About ' . $obj->getChannel() . '/' .$obj->getPackage() . '-' .
638 $obj->getVersion();
639 $data = array(
640 'caption' => $caption,
641 'border' => true);
642 switch ($obj->getPackageType()) {
643 case 'php' :
644 $release = 'PEAR-style PHP-based Package';
645 break;
646 case 'extsrc' :
647 $release = 'PECL-style PHP extension (source code)';
648 break;
649 case 'zendextsrc' :
650 $release = 'PECL-style Zend extension (source code)';
651 break;
652 case 'extbin' :
653 $release = 'PECL-style PHP extension (binary)';
654 break;
655 case 'zendextbin' :
656 $release = 'PECL-style Zend extension (binary)';
657 break;
658 case 'bundle' :
659 $release = 'Package bundle (collection of packages)';
660 break;
661 }
662 $extends = $obj->getExtends();
663 $extends = $extends ?
664 $obj->getPackage() . ' (extends ' . $extends . ')' : $obj->getPackage();
665 if ($src = $obj->getSourcePackage()) {
666 $extends .= ' (source package ' . $src['channel'] . '/' . $src['package'] . ')';
667 }
668
669 $info = array(
670 'Release Type' => $release,
671 'Name' => $extends,
672 'Channel' => $obj->getChannel(),
673 'Summary' => preg_replace('/ +/', ' ', $obj->getSummary()),
674 'Description' => preg_replace('/ +/', ' ', $obj->getDescription()),
675 );
676 $info['Maintainers'] = '';
677 foreach (array('lead', 'developer', 'contributor', 'helper') as $role) {
678 $leads = $obj->{"get{$role}s"}();
679 if (!$leads) {
680 continue;
681 }
682
683 if (isset($leads['active'])) {
684 $leads = array($leads);
685 }
686
687 foreach ($leads as $lead) {
688 if (!empty($info['Maintainers'])) {
689 $info['Maintainers'] .= "\n";
690 }
691
692 $active = $lead['active'] == 'no' ? ', inactive' : '';
693 $info['Maintainers'] .= $lead['name'] . ' <';
694 $info['Maintainers'] .= $lead['email'] . "> ($role$active)";
695 }
696 }
697
698 $info['Release Date'] = $obj->getDate();
699 if ($time = $obj->getTime()) {
700 $info['Release Date'] .= ' ' . $time;
701 }
702
703 $info['Release Version'] = $obj->getVersion() . ' (' . $obj->getState() . ')';
704 $info['API Version'] = $obj->getVersion('api') . ' (' . $obj->getState('api') . ')';
705 $info['License'] = $obj->getLicense();
706 $uri = $obj->getLicenseLocation();
707 if ($uri) {
708 if (isset($uri['uri'])) {
709 $info['License'] .= ' (' . $uri['uri'] . ')';
710 } else {
711 $extra = $obj->getInstalledLocation($info['filesource']);
712 if ($extra) {
713 $info['License'] .= ' (' . $uri['filesource'] . ')';
714 }
715 }
716 }
717
718 $info['Release Notes'] = $obj->getNotes();
719 if ($compat = $obj->getCompatible()) {
720 if (!isset($compat[0])) {
721 $compat = array($compat);
722 }
723
724 $info['Compatible with'] = '';
725 foreach ($compat as $package) {
726 $info['Compatible with'] .= $package['channel'] . '/' . $package['name'] .
727 "\nVersions >= " . $package['min'] . ', <= ' . $package['max'];
728 if (isset($package['exclude'])) {
729 if (is_array($package['exclude'])) {
730 $package['exclude'] = implode(', ', $package['exclude']);
731 }
732
733 if (!isset($info['Not Compatible with'])) {
734 $info['Not Compatible with'] = '';
735 } else {
736 $info['Not Compatible with'] .= "\n";
737 }
738 $info['Not Compatible with'] .= $package['channel'] . '/' .
739 $package['name'] . "\nVersions " . $package['exclude'];
740 }
741 }
742 }
743
744 $usesrole = $obj->getUsesrole();
745 if ($usesrole) {
746 if (!isset($usesrole[0])) {
747 $usesrole = array($usesrole);
748 }
749
750 foreach ($usesrole as $roledata) {
751 if (isset($info['Uses Custom Roles'])) {
752 $info['Uses Custom Roles'] .= "\n";
753 } else {
754 $info['Uses Custom Roles'] = '';
755 }
756
757 if (isset($roledata['package'])) {
758 $rolepackage = $reg->parsedPackageNameToString($roledata, true);
759 } else {
760 $rolepackage = $roledata['uri'];
761 }
762 $info['Uses Custom Roles'] .= $roledata['role'] . ' (' . $rolepackage . ')';
763 }
764 }
765
766 $usestask = $obj->getUsestask();
767 if ($usestask) {
768 if (!isset($usestask[0])) {
769 $usestask = array($usestask);
770 }
771
772 foreach ($usestask as $taskdata) {
773 if (isset($info['Uses Custom Tasks'])) {
774 $info['Uses Custom Tasks'] .= "\n";
775 } else {
776 $info['Uses Custom Tasks'] = '';
777 }
778
779 if (isset($taskdata['package'])) {
780 $taskpackage = $reg->parsedPackageNameToString($taskdata, true);
781 } else {
782 $taskpackage = $taskdata['uri'];
783 }
784 $info['Uses Custom Tasks'] .= $taskdata['task'] . ' (' . $taskpackage . ')';
785 }
786 }
787
788 $deps = $obj->getDependencies();
789 $info['Required Dependencies'] = 'PHP version ' . $deps['required']['php']['min'];
790 if (isset($deps['required']['php']['max'])) {
791 $info['Required Dependencies'] .= '-' . $deps['required']['php']['max'] . "\n";
792 } else {
793 $info['Required Dependencies'] .= "\n";
794 }
795
796 if (isset($deps['required']['php']['exclude'])) {
797 if (!isset($info['Not Compatible with'])) {
798 $info['Not Compatible with'] = '';
799 } else {
800 $info['Not Compatible with'] .= "\n";
801 }
802
803 if (is_array($deps['required']['php']['exclude'])) {
804 $deps['required']['php']['exclude'] =
805 implode(', ', $deps['required']['php']['exclude']);
806 }
807 $info['Not Compatible with'] .= "PHP versions\n " .
808 $deps['required']['php']['exclude'];
809 }
810
811 $info['Required Dependencies'] .= 'PEAR installer version';
812 if (isset($deps['required']['pearinstaller']['max'])) {
813 $info['Required Dependencies'] .= 's ' .
814 $deps['required']['pearinstaller']['min'] . '-' .
815 $deps['required']['pearinstaller']['max'];
816 } else {
817 $info['Required Dependencies'] .= ' ' .
818 $deps['required']['pearinstaller']['min'] . ' or newer';
819 }
820
821 if (isset($deps['required']['pearinstaller']['exclude'])) {
822 if (!isset($info['Not Compatible with'])) {
823 $info['Not Compatible with'] = '';
824 } else {
825 $info['Not Compatible with'] .= "\n";
826 }
827
828 if (is_array($deps['required']['pearinstaller']['exclude'])) {
829 $deps['required']['pearinstaller']['exclude'] =
830 implode(', ', $deps['required']['pearinstaller']['exclude']);
831 }
832 $info['Not Compatible with'] .= "PEAR installer\n Versions " .
833 $deps['required']['pearinstaller']['exclude'];
834 }
835
836 foreach (array('Package', 'Extension') as $type) {
837 $index = strtolower($type);
838 if (isset($deps['required'][$index])) {
839 if (isset($deps['required'][$index]['name'])) {
840 $deps['required'][$index] = array($deps['required'][$index]);
841 }
842
843 foreach ($deps['required'][$index] as $package) {
844 if (isset($package['conflicts'])) {
845 $infoindex = 'Not Compatible with';
846 if (!isset($info['Not Compatible with'])) {
847 $info['Not Compatible with'] = '';
848 } else {
849 $info['Not Compatible with'] .= "\n";
850 }
851 } else {
852 $infoindex = 'Required Dependencies';
853 $info[$infoindex] .= "\n";
854 }
855
856 if ($index == 'extension') {
857 $name = $package['name'];
858 } else {
859 if (isset($package['channel'])) {
860 $name = $package['channel'] . '/' . $package['name'];
861 } else {
862 $name = '__uri/' . $package['name'] . ' (static URI)';
863 }
864 }
865
866 $info[$infoindex] .= "$type $name";
867 if (isset($package['uri'])) {
868 $info[$infoindex] .= "\n Download URI: $package[uri]";
869 continue;
870 }
871
872 if (isset($package['max']) && isset($package['min'])) {
873 $info[$infoindex] .= " \n Versions " .
874 $package['min'] . '-' . $package['max'];
875 } elseif (isset($package['min'])) {
876 $info[$infoindex] .= " \n Version " .
877 $package['min'] . ' or newer';
878 } elseif (isset($package['max'])) {
879 $info[$infoindex] .= " \n Version " .
880 $package['max'] . ' or older';
881 }
882
883 if (isset($package['recommended'])) {
884 $info[$infoindex] .= "\n Recommended version: $package[recommended]";
885 }
886
887 if (isset($package['exclude'])) {
888 if (!isset($info['Not Compatible with'])) {
889 $info['Not Compatible with'] = '';
890 } else {
891 $info['Not Compatible with'] .= "\n";
892 }
893
894 if (is_array($package['exclude'])) {
895 $package['exclude'] = implode(', ', $package['exclude']);
896 }
897
898 $package['package'] = $package['name'];
899 if (isset($package['conflicts'])) {
900 $info['Not Compatible with'] .= '=> except ';
901 }
902 $info['Not Compatible with'] .= 'Package ' .
903 $reg->parsedPackageNameToString($package, true);
904 $info['Not Compatible with'] .= "\n Versions " . $package['exclude'];
905 }
906 }
907 }
908 }
909
910 if (isset($deps['required']['os'])) {
911 if (isset($deps['required']['os']['name'])) {
912 $dep['required']['os']['name'] = array($dep['required']['os']['name']);
913 }
914
915 foreach ($dep['required']['os'] as $os) {
916 if (isset($os['conflicts']) && $os['conflicts'] == 'yes') {
917 if (!isset($info['Not Compatible with'])) {
918 $info['Not Compatible with'] = '';
919 } else {
920 $info['Not Compatible with'] .= "\n";
921 }
922 $info['Not Compatible with'] .= "$os[name] Operating System";
923 } else {
924 $info['Required Dependencies'] .= "\n";
925 $info['Required Dependencies'] .= "$os[name] Operating System";
926 }
927 }
928 }
929
930 if (isset($deps['required']['arch'])) {
931 if (isset($deps['required']['arch']['pattern'])) {
932 $dep['required']['arch']['pattern'] = array($dep['required']['os']['pattern']);
933 }
934
935 foreach ($dep['required']['arch'] as $os) {
936 if (isset($os['conflicts']) && $os['conflicts'] == 'yes') {
937 if (!isset($info['Not Compatible with'])) {
938 $info['Not Compatible with'] = '';
939 } else {
940 $info['Not Compatible with'] .= "\n";
941 }
942 $info['Not Compatible with'] .= "OS/Arch matching pattern '/$os[pattern]/'";
943 } else {
944 $info['Required Dependencies'] .= "\n";
945 $info['Required Dependencies'] .= "OS/Arch matching pattern '/$os[pattern]/'";
946 }
947 }
948 }
949
950 if (isset($deps['optional'])) {
951 foreach (array('Package', 'Extension') as $type) {
952 $index = strtolower($type);
953 if (isset($deps['optional'][$index])) {
954 if (isset($deps['optional'][$index]['name'])) {
955 $deps['optional'][$index] = array($deps['optional'][$index]);
956 }
957
958 foreach ($deps['optional'][$index] as $package) {
959 if (isset($package['conflicts']) && $package['conflicts'] == 'yes') {
960 $infoindex = 'Not Compatible with';
961 if (!isset($info['Not Compatible with'])) {
962 $info['Not Compatible with'] = '';
963 } else {
964 $info['Not Compatible with'] .= "\n";
965 }
966 } else {
967 $infoindex = 'Optional Dependencies';
968 if (!isset($info['Optional Dependencies'])) {
969 $info['Optional Dependencies'] = '';
970 } else {
971 $info['Optional Dependencies'] .= "\n";
972 }
973 }
974
975 if ($index == 'extension') {
976 $name = $package['name'];
977 } else {
978 if (isset($package['channel'])) {
979 $name = $package['channel'] . '/' . $package['name'];
980 } else {
981 $name = '__uri/' . $package['name'] . ' (static URI)';
982 }
983 }
984
985 $info[$infoindex] .= "$type $name";
986 if (isset($package['uri'])) {
987 $info[$infoindex] .= "\n Download URI: $package[uri]";
988 continue;
989 }
990
991 if ($infoindex == 'Not Compatible with') {
992
993 continue;
994 }
995
996 if (isset($package['max']) && isset($package['min'])) {
997 $info[$infoindex] .= " \n Versions " .
998 $package['min'] . '-' . $package['max'];
999 } elseif (isset($package['min'])) {
1000 $info[$infoindex] .= " \n Version " .
1001 $package['min'] . ' or newer';
1002 } elseif (isset($package['max'])) {
1003 $info[$infoindex] .= " \n Version " .
1004 $package['min'] . ' or older';
1005 }
1006
1007 if (isset($package['recommended'])) {
1008 $info[$infoindex] .= "\n Recommended version: $package[recommended]";
1009 }
1010
1011 if (isset($package['exclude'])) {
1012 if (!isset($info['Not Compatible with'])) {
1013 $info['Not Compatible with'] = '';
1014 } else {
1015 $info['Not Compatible with'] .= "\n";
1016 }
1017
1018 if (is_array($package['exclude'])) {
1019 $package['exclude'] = implode(', ', $package['exclude']);
1020 }
1021
1022 $info['Not Compatible with'] .= "Package $package\n Versions " .
1023 $package['exclude'];
1024 }
1025 }
1026 }
1027 }
1028 }
1029
1030 if (isset($deps['group'])) {
1031 if (!isset($deps['group'][0])) {
1032 $deps['group'] = array($deps['group']);
1033 }
1034
1035 foreach ($deps['group'] as $group) {
1036 $info['Dependency Group ' . $group['attribs']['name']] = $group['attribs']['hint'];
1037 $groupindex = $group['attribs']['name'] . ' Contents';
1038 $info[$groupindex] = '';
1039 foreach (array('Package', 'Extension') as $type) {
1040 $index = strtolower($type);
1041 if (isset($group[$index])) {
1042 if (isset($group[$index]['name'])) {
1043 $group[$index] = array($group[$index]);
1044 }
1045
1046 foreach ($group[$index] as $package) {
1047 if (!empty($info[$groupindex])) {
1048 $info[$groupindex] .= "\n";
1049 }
1050
1051 if ($index == 'extension') {
1052 $name = $package['name'];
1053 } else {
1054 if (isset($package['channel'])) {
1055 $name = $package['channel'] . '/' . $package['name'];
1056 } else {
1057 $name = '__uri/' . $package['name'] . ' (static URI)';
1058 }
1059 }
1060
1061 if (isset($package['uri'])) {
1062 if (isset($package['conflicts']) && $package['conflicts'] == 'yes') {
1063 $info[$groupindex] .= "Not Compatible with $type $name";
1064 } else {
1065 $info[$groupindex] .= "$type $name";
1066 }
1067
1068 $info[$groupindex] .= "\n Download URI: $package[uri]";
1069 continue;
1070 }
1071
1072 if (isset($package['conflicts']) && $package['conflicts'] == 'yes') {
1073 $info[$groupindex] .= "Not Compatible with $type $name";
1074 continue;
1075 }
1076
1077 $info[$groupindex] .= "$type $name";
1078 if (isset($package['max']) && isset($package['min'])) {
1079 $info[$groupindex] .= " \n Versions " .
1080 $package['min'] . '-' . $package['max'];
1081 } elseif (isset($package['min'])) {
1082 $info[$groupindex] .= " \n Version " .
1083 $package['min'] . ' or newer';
1084 } elseif (isset($package['max'])) {
1085 $info[$groupindex] .= " \n Version " .
1086 $package['min'] . ' or older';
1087 }
1088
1089 if (isset($package['recommended'])) {
1090 $info[$groupindex] .= "\n Recommended version: $package[recommended]";
1091 }
1092
1093 if (isset($package['exclude'])) {
1094 if (!isset($info['Not Compatible with'])) {
1095 $info['Not Compatible with'] = '';
1096 } else {
1097 $info[$groupindex] .= "Not Compatible with\n";
1098 }
1099
1100 if (is_array($package['exclude'])) {
1101 $package['exclude'] = implode(', ', $package['exclude']);
1102 }
1103 $info[$groupindex] .= " Package $package\n Versions " .
1104 $package['exclude'];
1105 }
1106 }
1107 }
1108 }
1109 }
1110 }
1111
1112 if ($obj->getPackageType() == 'bundle') {
1113 $info['Bundled Packages'] = '';
1114 foreach ($obj->getBundledPackages() as $package) {
1115 if (!empty($info['Bundled Packages'])) {
1116 $info['Bundled Packages'] .= "\n";
1117 }
1118
1119 if (isset($package['uri'])) {
1120 $info['Bundled Packages'] .= '__uri/' . $package['name'];
1121 $info['Bundled Packages'] .= "\n (URI: $package[uri]";
1122 } else {
1123 $info['Bundled Packages'] .= $package['channel'] . '/' . $package['name'];
1124 }
1125 }
1126 }
1127
1128 $info['package.xml version'] = '2.0';
1129 if ($installed) {
1130 if ($obj->getLastModified()) {
1131 $info['Last Modified'] = date('Y-m-d H:i', $obj->getLastModified());
1132 }
1133
1134 $v = $obj->getLastInstalledVersion();
1135 $info['Previous Installed Version'] = $v ? $v : '- None -';
1136 }
1137
1138 foreach ($info as $key => $value) {
1139 $data['data'][] = array($key, $value);
1140 }
1141
1142 $data['raw'] = $obj->getArray();
1143 $this->ui->outputData($data, 'package-info');
1144 }