1: <?php
2: /**
3: * Horde_Pear_Package_Contents_InstallAs_HordeApplication:: determines install
4: * locations for Horde applications.
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_HordeApplication:: determines install
17: * locations for Horde applications.
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_HordeApplication
31: implements Horde_Pear_Package_Contents_InstallAs
32: {
33: /**
34: * The package type.
35: *
36: * @var Horde_Pear_Package_Type
37: */
38: private $_type;
39:
40: /**
41: * Constructor.
42: *
43: * @param Horde_Pear_Package_Type $type The package type.
44: */
45: public function __construct(Horde_Pear_Package_Type $type)
46: {
47: $this->_type = $type;
48: }
49:
50: /**
51: * Tell which location the specified file should be installed to.
52: *
53: * @param string $file The file name.
54: * @param string $package The package name.
55: *
56: * @return string The install location for the file.
57: */
58: public function getInstallAs($file, $package)
59: {
60: $elements = explode('/', substr($file, 1));
61: $basedir = array_shift($elements);
62: switch ($basedir) {
63: case 'bin':
64: case 'docs':
65: case 'test':
66: return join('/', $elements);
67: case 'COPYING':
68: case 'COPYING':
69: case 'README':
70: return substr($file, 1);
71: default:
72: return $this->_type->getName() . $file;
73: }
74: }
75: }