source: trunk/phpgwapi/doc/vfs/vfs-3.html @ 2

Revision 2, 4.3 KB checked in by niltonneto, 17 years ago (diff)

Removida todas as tags usadas pelo CVS ($Id, $Source).
Primeira versão no CVS externo.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
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: Basic Functions</TITLE>
6 <LINK HREF="vfs-4.html" REL=next>
7 <LINK HREF="vfs-2.html" REL=previous>
8 <LINK HREF="vfs.html#toc3" REL=contents>
9</HEAD>
10<BODY>
11<A HREF="vfs-4.html">Next</A>
12<A HREF="vfs-2.html">Previous</A>
13<A HREF="vfs.html#toc3">Contents</A>
14<HR>
15<H2><A NAME="sec:basic_functions"></A> <A NAME="s3">3.</A> <A HREF="vfs.html#toc3">Basic Functions</A></H2>
16
17<P>These are two functions you'll need to know before we get into
18relativity.</P>
19<H2><A NAME="sec:path_parts"></A> <A NAME="ss3.1">3.1</A> <A HREF="vfs.html#toc3.1">path_parts ()</A>
20</H2>
21
22<P>The job of path_parts () is to translate any given file location
23into its many component parts for any relativity. The values passed
24to path_parts () are:</P>
25<P>
26<PRE>
27string
28relatives
29object
30</PRE>
31</P>
32<P>'string' is the path you want to translate, 'relatives' is the
33standard relativity array, and 'object' specifies how you would like
34the return value: if 'object' is True, an object will be returned;
35if 'object' is False, an array will be returned. I think you'll find
36the object easier to deal with, and we'll be using it throughout
37this document. The most important returned values (but not all) for
38path_parts () are:</P>
39<P>
40<PRE>
41fake_full_path
42fake_leading_dirs
43fake_extra_path
44fake_name
45real_full_path
46real_leading_dirs
47real_extra_path
48real_name
49</PRE>
50</P>
51<P>Just like you would think, fake_full_path contains the full virtual
52path of 'string', and real_full_path contains the full real path
53of 'string'. The fake_name and real_name variables should always
54be the same, and contain the final file or directory name. The leading_dirs
55contain everything except the name, and the extra_path is everything
56from the / before "home" to the end of the leading_dirs. To better
57illustrate, here is an example:</P>
58<P>
59<PRE>
60$p = $GLOBALS['phpgw']-&gt;vfs-&gt;path_parts (array(
61     'string' =&gt; '/home/jason/dir/file',
62     'relatives' =&gt; array(
63         RELATIVE_NONE
64     )
65));
66</PRE>
67</P>
68<P>
69<UL>
70<LI>$p-&gt;fake_full_path - /home/jason/dir/file</LI>
71<LI>$p-&gt;fake_leading_dirs - /home/jason/dir</LI>
72<LI>$p-&gt;fake_extra_path - home/jason/dir</LI>
73<LI>$p-&gt;fake_name - file</LI>
74<LI>$p-&gt;real_full_path - /var/www/egroupware/files/home/jason/dir/file</LI>
75<LI>$p-&gt;real_leading_dirs - /var/www/egroupware/files/home/jason/dir
76 </LI>
77<LI>$p-&gt;real_extra_path - home/jason/dir</LI>
78<LI>$p-&gt;real_name - file</LI>
79</UL>
80</P>
81<P>As you can see, path_parts () is a very useful function and will
82save you from doing those darn substr ()'s yourself. For those of
83you used to the prior VFS, note that <EM>getabsolutepath () is depreciated</EM>.
84getabsolutepath () still exists (albeit in a much different form),
85and is responsible for some of the path translation, but it is an
86<EM>internal</EM> function only. Applications should only use path_parts ().
87We have shown you how to use path_parts () so you can experiment
88with it using different paths and relativities as we explore relativity.</P>
89<H2><A NAME="sec:cd"></A> <A NAME="ss3.2">3.2</A> <A HREF="vfs.html#toc3.2">cd ()</A>
90</H2>
91
92<P>Part of the overall goal for the VFS in eGroupWare is to give
93the user a seamless experience during their session. For example,
94if they upload a file using a file manager to the directory /home/my_group/project1,
95and then go to download an email attachment, the default directory
96will be /home/my_group/project1. This is accomplished using the cd
97() function. Examples: </P>
98<P>
99<PRE>
100/* cd to their home directory */
101$GLOBALS['phpgw']-&gt;vfs-&gt;cd (array(
102     'string' =&gt; '/'
103));
104
105/* cd to /home/jason/dir */
106$GLOBALS['phpgw']-&gt;vfs-&gt;cd (array(
107     'string' =&gt; '/home/jason/dir',
108     'relative' =&gt; False,
109     'relatives' =&gt; array(
110          RELATIVE_NONE
111     )
112));
113
114/* When following the above, cd's to /home/jason/dir/dir2 */
115$GLOBALS['phpgw']-&gt;vfs-&gt;cd (array(
116     'string' =&gt; 'dir2',
117     'relative' =&gt; True
118));
119</PRE>
120</P>
121<P>If 'relative' is True, the 'string' is simply appended to the
122current path. If you want to know what the current path is, use $GLOBALS['phpgw']-&gt;vfs-&gt;pwd
123().</P>
124<P>Now you're ready for relativity.</P>
125<HR>
126<A HREF="vfs-4.html">Next</A>
127<A HREF="vfs-2.html">Previous</A>
128<A HREF="vfs.html#toc3">Contents</A>
129</BODY>
130</HTML>
Note: See TracBrowser for help on using the repository browser.