source: companies/celepar/phpgwapi/doc/vfs/vfs-2.html @ 763

Revision 763, 3.8 KB checked in by niltonneto, 15 years ago (diff)

Importação inicial do Expresso da Celepar

Line 
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'
21to True in $GLOBALS['phpgw_info']['flags'].
22An example:</P>
23<P>
24<PRE>
25$GLOBALS['phpgw_info']['flags'] = array(
26     'currentapp' =&gt; 'filemanaer',
27     'noheader' =&gt; False,
28     'noappheader' =&gt; False,
29     'enable_vfs_class' =&gt; True,
30     'enable_browser_class' =&gt; 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
38can look over it, but I don't suggest trying to understand how it
39works. It isn't necessary to know its internals to use it, but you
40may find the inline comments helpful. The basic things to keep in
41mind:</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']-&gt;vfs-&gt;mv (array(
50     'from' =&gt; 'file1',
51     'to' =&gt; 'dir/file2'
52));
53
54$GLOBALS['phpgw']-&gt;vfs-&gt;mv (array(
55     'from' =&gt; 'dir1',
56     'to' =&gt; 'dir/dir1'
57));
58
59$GLOBALS['phpgw']-&gt;vfs-&gt;rm (array(
60     'string' =&gt; 'file'
61));
62
63$GLOBALS['phpgw']-&gt;vfs-&gt;rm (array(
64     'string' =&gt; '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']-&gt;vfs-&gt;touch (array(
72     'string' =&gt; 'file'
73));
74</PRE>
75</P>
76<P>vs.</P>
77<P>
78<PRE>
79$GLOBALS['phpgw']-&gt;vfs-&gt;mkdir (array(
80     'string' =&gt; '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
90the 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.
97While you certainly <EM>can</EM> operate using full paths, it is much simpler
98to use the virtual paths. For example, instead of using:</P>
99<P>
100<PRE>
101$GLOBALS['phpgw']-&gt;vfs-&gt;cp (array(
102     'from' =&gt; '/var/www/egroupware/files/home/user/file1',
103     'to' =&gt; '/var/www/egroupware/files/home/user/file2',
104     'relatives' =&gt; 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']-&gt;vfs-&gt;cp (array(
115     'from' =&gt; '/home/user/file1',
116     'to' =&gt; '/home/user/file2',
117     'relatives' =&gt; 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
126on 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
133be stressed enough. It will make your life much easier, especially
134for file system intensive applications, but it will take some getting
135used to. If something doesn't work right the first time, chances
136are great it has to do with incorrect relativity settings. We will
137deal 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>
Note: See TracBrowser for help on using the repository browser.