1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> |
---|
2 | <HTML> |
---|
3 | <HEAD> |
---|
4 | <META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.17"> |
---|
5 | <TITLE>phpgwapi - VFS Class: Basics</TITLE> |
---|
6 | <LINK HREF="vfs-3.html" REL=next> |
---|
7 | <LINK HREF="vfs-1.html" REL=previous> |
---|
8 | <LINK HREF="vfs.html#toc2" REL=contents> |
---|
9 | </HEAD> |
---|
10 | <BODY> |
---|
11 | <A HREF="vfs-3.html">Next</A> |
---|
12 | <A HREF="vfs-1.html">Previous</A> |
---|
13 | <A HREF="vfs.html#toc2">Contents</A> |
---|
14 | <HR> |
---|
15 | <H2><A NAME="sec:basics"></A> <A NAME="s2">2.</A> <A HREF="vfs.html#toc2">Basics</A></H2> |
---|
16 | |
---|
17 | <H2><A NAME="sec:prerequisites"></A> <A NAME="ss2.1">2.1</A> <A HREF="vfs.html#toc2.1">Prerequisites</A> |
---|
18 | </H2> |
---|
19 | |
---|
20 | <P>You must explicitly enable the VFS class. To do this, set 'enable_vfs_class' |
---|
21 | to True in $GLOBALS['phpgw_info']['flags']. |
---|
22 | An example:</P> |
---|
23 | <P> |
---|
24 | <PRE> |
---|
25 | $GLOBALS['phpgw_info']['flags'] = array( |
---|
26 | 'currentapp' => 'filemanaer', |
---|
27 | 'noheader' => False, |
---|
28 | 'noappheader' => False, |
---|
29 | 'enable_vfs_class' => True, |
---|
30 | 'enable_browser_class' => True |
---|
31 | ); |
---|
32 | </PRE> |
---|
33 | </P> |
---|
34 | <H2><A NAME="sec:concepts"></A> <A NAME="ss2.2">2.2</A> <A HREF="vfs.html#toc2.2">Concepts</A> |
---|
35 | </H2> |
---|
36 | |
---|
37 | <P>The VFS in located in phpgwapi/inc/class.vfs_sql.inc.php. You |
---|
38 | can look over it, but I don't suggest trying to understand how it |
---|
39 | works. It isn't necessary to know its internals to use it, but you |
---|
40 | may find the inline comments helpful. The basic things to keep in |
---|
41 | mind:</P> |
---|
42 | <P> |
---|
43 | <UL> |
---|
44 | <LI>Files and directories are synonymous in almost all cases</LI> |
---|
45 | </UL> |
---|
46 | </P> |
---|
47 | <P> |
---|
48 | <PRE> |
---|
49 | $GLOBALS['phpgw']->vfs->mv (array( |
---|
50 | 'from' => 'file1', |
---|
51 | 'to' => 'dir/file2' |
---|
52 | )); |
---|
53 | |
---|
54 | $GLOBALS['phpgw']->vfs->mv (array( |
---|
55 | 'from' => 'dir1', |
---|
56 | 'to' => 'dir/dir1' |
---|
57 | )); |
---|
58 | |
---|
59 | $GLOBALS['phpgw']->vfs->rm (array( |
---|
60 | 'string' => 'file' |
---|
61 | )); |
---|
62 | |
---|
63 | $GLOBALS['phpgw']->vfs->rm (array( |
---|
64 | 'string' => 'dir' |
---|
65 | )); |
---|
66 | </PRE> |
---|
67 | </P> |
---|
68 | <P>All work as you would except them to. The major exception is:</P> |
---|
69 | <P> |
---|
70 | <PRE> |
---|
71 | $GLOBALS['phpgw']->vfs->touch (array( |
---|
72 | 'string' => 'file' |
---|
73 | )); |
---|
74 | </PRE> |
---|
75 | </P> |
---|
76 | <P>vs.</P> |
---|
77 | <P> |
---|
78 | <PRE> |
---|
79 | $GLOBALS['phpgw']->vfs->mkdir (array( |
---|
80 | 'string' => 'dir' |
---|
81 | )); |
---|
82 | </PRE> |
---|
83 | </P> |
---|
84 | <P> |
---|
85 | <UL> |
---|
86 | <LI>Users and groups are synonymous</LI> |
---|
87 | </UL> |
---|
88 | </P> |
---|
89 | <P>As far as the actual paths are concerned, users and groups are |
---|
90 | the same. /home/username works the same as /home/groupname.</P> |
---|
91 | <P> |
---|
92 | <UL> |
---|
93 | <LI>You should never have to know the real paths of files</LI> |
---|
94 | </UL> |
---|
95 | </P> |
---|
96 | <P>One of the VFS's responsibilities is to translate paths for you. |
---|
97 | While you certainly <EM>can</EM> operate using full paths, it is much simpler |
---|
98 | to use the virtual paths. For example, instead of using:</P> |
---|
99 | <P> |
---|
100 | <PRE> |
---|
101 | $GLOBALS['phpgw']->vfs->cp (array( |
---|
102 | 'from' => '/var/www/egroupware/files/home/user/file1', |
---|
103 | 'to' => '/var/www/egroupware/files/home/user/file2', |
---|
104 | 'relatives' => array( |
---|
105 | RELATIVE_NONE|VFS_REAL, |
---|
106 | RELATIVE_NONE|VFS_REAL |
---|
107 | ) |
---|
108 | )); |
---|
109 | </PRE> |
---|
110 | </P> |
---|
111 | <P>you might use</P> |
---|
112 | <P> |
---|
113 | <PRE> |
---|
114 | $GLOBALS['phpgw']->vfs->cp (array( |
---|
115 | 'from' => '/home/user/file1', |
---|
116 | 'to' => '/home/user/file2', |
---|
117 | 'relatives' => array( |
---|
118 | RELATIVE_NONE, |
---|
119 | RELATIVE_NONE |
---|
120 | ) |
---|
121 | )); |
---|
122 | </PRE> |
---|
123 | </P> |
---|
124 | <P>(We'll get to the RELATIVE's in a minute.)</P> |
---|
125 | <P>Site administrators should be able to move their files dir around |
---|
126 | on their system and know that everything will continue to work smoothly.</P> |
---|
127 | <P> |
---|
128 | <UL> |
---|
129 | <LI>Relativity is <EM>vital</EM></LI> |
---|
130 | </UL> |
---|
131 | </P> |
---|
132 | <P>Relativity is a new feature in the VFS, and its importance cannot |
---|
133 | be stressed enough. It will make your life much easier, especially |
---|
134 | for file system intensive applications, but it will take some getting |
---|
135 | used to. If something doesn't work right the first time, chances |
---|
136 | are great it has to do with incorrect relativity settings. We will |
---|
137 | deal with relativity in depth in the Relativity section.</P> |
---|
138 | <HR> |
---|
139 | <A HREF="vfs-3.html">Next</A> |
---|
140 | <A HREF="vfs-1.html">Previous</A> |
---|
141 | <A HREF="vfs.html#toc2">Contents</A> |
---|
142 | </BODY> |
---|
143 | </HTML> |
---|