1: <?php
2: /**
3: * The core file list generator for package.xml files.
4: *
5: * PHP version 5
6: *
7: * @category Horde
8: * @package Pear
9: * @author Gunnar Wrobel <wrobel@pardus.de>
10: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
11: * @link http://pear.horde.org/index.php?package=Pear
12: */
13:
14: /**
15: * The core file list generator for package.xml files.
16: *
17: * Copyright 2011-2012 Horde LLC (http://www.horde.org/)
18: *
19: * See the enclosed file COPYING for license information (LGPL). If you
20: * did not receive this file, see http://www.horde.org/licenses/lgpl21.
21: *
22: * @category Horde
23: * @package Pear
24: * @author Gunnar Wrobel <wrobel@pardus.de>
25: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
26: * @link http://pear.horde.org/index.php?package=Pear
27: */
28: class Horde_Pear_Package_Contents_List
29: implements Horde_Pear_Package_Contents
30: {
31: /**
32: * The root path for the file listing.
33: *
34: * @var string
35: */
36: private $_root;
37:
38: /**
39: * Handles ignoring files from the file list.
40: *
41: * @var Horde_Pear_Package_Contents_Ignore
42: */
43: private $_ignore;
44:
45: /**
46: * Handles including files from the file list.
47: *
48: * @var Horde_Pear_Package_Contents_Include.
49: */
50: private $_include;
51:
52: /**
53: * Handles file roles.
54: *
55: * @var Horde_Pear_Package_Contents_Role.
56: */
57: private $_role;
58:
59: /**
60: * Handles install locations.
61: *
62: * @var Horde_Pear_Package_Contents_InstallAs.
63: */
64: private $_install_as;
65:
66: /**
67: * Constructor.
68: *
69: * @param Horde_Pear_Package_Type $type The package type.
70: *
71: * @return NULL
72: */
73: public function __construct(Horde_Pear_Package_Type $type)
74: {
75: $this->_root = $type->getRootPath();
76: $this->_include = $type->getInclude();
77: $this->_ignore = $type->getIgnore();
78: $this->_role = $type->getRole();
79: $this->_install_as = $type->getInstallAs();
80: }
81:
82: /**
83: * Return the content list.
84: *
85: * @return array The file list.
86: */
87: public function getContents()
88: {
89: $list = new RecursiveIteratorIterator(
90: new RecursiveDirectoryIterator($this->_root)
91: );
92: $elements = array();
93: foreach ($list as $element) {
94: if ($this->_include->isIncluded($element)
95: && !$this->_ignore->isIgnored($element)) {
96: $file = substr($element->getPathname(), strlen($this->_root));
97: $elements[$file] = array(
98: 'role' => $this->_role->getRole($file),
99: 'as' => $this->_install_as->getInstallAs($file, 'Horde_' . basename($this->_root))
100: );
101: }
102: }
103: return $elements;
104: }
105: }