1: <?php
2: /**
3: * The Horde_Kolab_Storage_Folder_Namespace_Element_Shared:: class represents
4: * the shared namespace and hides the prefix of that shared namespace.
5: *
6: * PHP version 5
7: *
8: * @category Kolab
9: * @package Kolab_Storage
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=Kolab_Storage
13: */
14:
15: /**
16: * The Horde_Kolab_Storage_Folder_Namespace_Element_Shared:: class represents
17: * the shared namespace and hides the prefix of that shared namespace.
18: *
19: * Copyright 2010-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 Kolab
25: * @package Kolab_Storage
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=Kolab_Storage
29: */
30: class Horde_Kolab_Storage_Folder_Namespace_Element_SharedWithPrefix
31: extends Horde_Kolab_Storage_Folder_Namespace_Element_Shared
32: {
33: /**
34: * The prefix to hide when referencing this namespace.
35: *
36: * @var string
37: */
38: protected $_prefix;
39:
40: /**
41: * Constructor.
42: *
43: * @param string $name The prefix identifying this namespace.
44: * @param string $delimiter The delimiter used for this namespace.
45: * @param string $user The current user.
46: * @param string $prefix The prefix to hide.
47: */
48: public function __construct($name, $delimiter, $user, $prefix)
49: {
50: parent::__construct($name, $delimiter, $user);
51: $this->_prefix = $prefix;
52: }
53:
54: /**
55: * Return an array describing the path elements of the folder.
56: *
57: * @param string $name The name of the folder.
58: *
59: * @return array The path elements.
60: */
61: protected function _subpath($name)
62: {
63: $path = parent::_subpath($name);
64: if (!empty($path) && strpos($path[0], $this->_prefix) === 0) {
65: $path[0] = substr($path[0], strlen($this->_prefix));
66: }
67: return $path;
68: }
69:
70: /**
71: * Generate a folder path for the given path in this namespace.
72: *
73: * @param array $path The path of the folder.
74: *
75: * @return string The name of the folder.
76: */
77: public function generateName($path)
78: {
79: return $this->_prefix . parent::generateName($path);
80: }
81:
82: /**
83: * Generate a folder path for the given subpath and owner.
84: *
85: * @since Horde_Kolab_Storage 1.1.0
86: *
87: * @param string $subpath The subpath of the folder.
88: * @param string $owner The folder owner.
89: *
90: * @return string The name of the folder.
91: */
92: public function generatePath($subpath, $owner)
93: {
94: return $this->_prefix . parent::generatePath($subpath, $owner);
95: }
96:
97:
98: }