1: <?php
2: /**
3: * Horde_Pear_Package_Contents_InstallAs_HordeComponent:: determines install
4: * locations for Horde components.
5: *
6: * PHP version 5
7: *
8: * @category Horde
9: * @package Pear
10: * @author Gunnar Wrobel <wrobel@pardus.de>
11: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
12: * @link http://pear.horde.org/index.php?package=Pear
13: */
14:
15: /**
16: * Horde_Pear_Package_Contents_InstallAs_HordeComponent:: determines install
17: * locations for Horde components.
18: *
19: * Copyright 2011-2012 Horde LLC (http://www.horde.org/)
20: *
21: * See the enclosed file COPYING for license information (LGPL). If you
22: * did not receive this file, see http://www.horde.org/licenses/lgpl21.
23: *
24: * @category Horde
25: * @package Pear
26: * @author Gunnar Wrobel <wrobel@pardus.de>
27: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
28: * @link http://pear.horde.org/index.php?package=Pear
29: */
30: class Horde_Pear_Package_Contents_InstallAs_HordeComponent
31: implements Horde_Pear_Package_Contents_InstallAs
32: {
33: /**
34: * Tell which location the specified file should be installed to.
35: *
36: * @param string $file The file name.
37: * @param string $package The package name.
38: *
39: * @return string The install location for the file.
40: */
41: public function getInstallAs($file, $package)
42: {
43: $elements = explode('/', substr($file, 1));
44: $basedir = array_shift($elements);
45: switch ($basedir) {
46: case 'COPYING':
47: case 'examples':
48: case 'js':
49: case 'locale':
50: return substr($file, 1);
51: case 'migration':
52: return $basedir . '/' . basename($file);
53: case 'doc':
54: foreach (explode('_', $package) as $dir) {
55: if ($elements[0] == $dir) {
56: array_shift($elements);
57: } else {
58: break;
59: }
60: }
61: // Fall through.
62: default:
63: return join('/', $elements);
64: }
65: }
66: }