Bearsampp 2026.9.23
Loading...
Searching...
No Matches
Common.php
Go to the documentation of this file.
1<?php
31{
37
42 {
43 $this->config = $config;
44 }
45
52 function getInfo($role)
53 {
54 if (empty($GLOBALS['_PEAR_INSTALLER_ROLES'][$role])) {
55 return PEAR::raiseError('Unknown Role class: "' . $role . '"');
56 }
57 return $GLOBALS['_PEAR_INSTALLER_ROLES'][$role];
58 }
59
72 function processInstallation($pkg, $atts, $file, $tmp_path, $layer = null)
73 {
74 $roleInfo = PEAR_Installer_Role_Common::getInfo('PEAR_Installer_Role_' .
75 ucfirst(str_replace('pear_installer_role_', '', strtolower(get_class($this)))));
76 if (PEAR::isError($roleInfo)) {
77 return $roleInfo;
78 }
79 if (!$roleInfo['locationconfig']) {
80 return false;
81 }
82 if ($roleInfo['honorsbaseinstall']) {
83 $dest_dir = $save_destdir = $this->config->get($roleInfo['locationconfig'], $layer,
84 $pkg->getChannel());
85 if (!empty($atts['baseinstalldir'])) {
86 $dest_dir .= DIRECTORY_SEPARATOR . $atts['baseinstalldir'];
87 }
88 } elseif ($roleInfo['unusualbaseinstall']) {
89 $dest_dir = $save_destdir = $this->config->get($roleInfo['locationconfig'],
90 $layer, $pkg->getChannel()) . DIRECTORY_SEPARATOR . $pkg->getPackage();
91 if (!empty($atts['baseinstalldir'])) {
92 $dest_dir .= DIRECTORY_SEPARATOR . $atts['baseinstalldir'];
93 }
94 } else {
95 $dest_dir = $save_destdir = $this->config->get($roleInfo['locationconfig'],
96 $layer, $pkg->getChannel()) . DIRECTORY_SEPARATOR . $pkg->getPackage();
97 }
98 if (dirname($file) != '.' && empty($atts['install-as'])) {
99 $dest_dir .= DIRECTORY_SEPARATOR . dirname($file);
100 }
101 if (empty($atts['install-as'])) {
102 $dest_file = $dest_dir . DIRECTORY_SEPARATOR . basename($file);
103 } else {
104 $dest_file = $dest_dir . DIRECTORY_SEPARATOR . $atts['install-as'];
105 }
106 $orig_file = $tmp_path . DIRECTORY_SEPARATOR . $file;
107
108 // Clean up the DIRECTORY_SEPARATOR mess
109 $ds2 = DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR;
110
111 list($dest_dir, $dest_file, $orig_file) = preg_replace(array('!\\\\+!', '!/!', "!$ds2+!"),
112 array(DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR,
113 DIRECTORY_SEPARATOR),
114 array($dest_dir, $dest_file, $orig_file));
115 return array($save_destdir, $dest_dir, $dest_file, $orig_file);
116 }
117
123 {
124 $roleInfo = PEAR_Installer_Role_Common::getInfo('PEAR_Installer_Role_' .
125 ucfirst(str_replace('pear_installer_role_', '', strtolower(get_class($this)))));
126 if (PEAR::isError($roleInfo)) {
127 return $roleInfo;
128 }
129 return $roleInfo['locationconfig'];
130 }
131
139 function setup(&$installer, $pkg, $atts, $file)
140 {
141 }
142
143 function isExecutable()
144 {
145 $roleInfo = PEAR_Installer_Role_Common::getInfo('PEAR_Installer_Role_' .
146 ucfirst(str_replace('pear_installer_role_', '', strtolower(get_class($this)))));
147 if (PEAR::isError($roleInfo)) {
148 return $roleInfo;
149 }
150 return $roleInfo['executable'];
151 }
152
153 function isInstallable()
154 {
155 $roleInfo = PEAR_Installer_Role_Common::getInfo('PEAR_Installer_Role_' .
156 ucfirst(str_replace('pear_installer_role_', '', strtolower(get_class($this)))));
157 if (PEAR::isError($roleInfo)) {
158 return $roleInfo;
159 }
160 return $roleInfo['installable'];
161 }
162
163 function isExtension()
164 {
165 $roleInfo = PEAR_Installer_Role_Common::getInfo('PEAR_Installer_Role_' .
166 ucfirst(str_replace('pear_installer_role_', '', strtolower(get_class($this)))));
167 if (PEAR::isError($roleInfo)) {
168 return $roleInfo;
169 }
170 return $roleInfo['phpextension'];
171 }
172}
173?>
$GLOBALS['_PEAR_default_error_mode']
Definition PEAR.php:46
processInstallation($pkg, $atts, $file, $tmp_path, $layer=null)
Definition Common.php:72
setup(&$installer, $pkg, $atts, $file)
Definition Common.php:139