mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-01 20:34:20 +01:00
263fdedd2a
places that were including the footer.inc.php to use the function. Re-arrange phpgw.inc.php to include optional classes after reading the DB config misc bugfixes.
154 lines
4.8 KiB
HTML
154 lines
4.8 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
|
<HTML>
|
|
<HEAD>
|
|
<META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9">
|
|
<TITLE> phpGroupWare Application Development: The API</TITLE>
|
|
<LINK HREF="phpGW_Developers-HOWTO-6.html" REL=next>
|
|
<LINK HREF="phpGW_Developers-HOWTO-4.html" REL=previous>
|
|
<LINK HREF="phpGW_Developers-HOWTO.html#toc5" REL=contents>
|
|
</HEAD>
|
|
<BODY>
|
|
<A HREF="phpGW_Developers-HOWTO-6.html">Next</A>
|
|
<A HREF="phpGW_Developers-HOWTO-4.html">Previous</A>
|
|
<A HREF="phpGW_Developers-HOWTO.html#toc5">Contents</A>
|
|
<HR>
|
|
<H2><A NAME="s5">5. The API</A></H2>
|
|
|
|
<H2><A NAME="ss5.1">5.1 Introduction</A>
|
|
</H2>
|
|
|
|
<P>phpGroupWare attempts to provide developers with a useful API to handle common tasks.<BR>
|
|
To do this we have created a multi-dimensional class $phpgw->.<BR>
|
|
This allows for terrific code organization, and help developers easily identify the file that the function is in.
|
|
All the files that are part of this class are in the inc/core directory and are named to match the sub-class.<BR>
|
|
Example:
|
|
<CODE>$phpgw->send->msg()</CODE> is in the <CODE>inc/phpgwapi/phpgw_send.inc.php</CODE> file.
|
|
<H2><A NAME="ss5.2">5.2 Basic functions</A>
|
|
</H2>
|
|
|
|
<H3>$phpgw->link</H3>
|
|
|
|
<P><CODE>$phpgw->link($url)</CODE><BR>
|
|
Add support for session management. ALL links must use this, that includes href's form actions and header location's.<BR>
|
|
If you are just doing a form action back to the same page, you can use it without any parameters.<BR>
|
|
This function is right at the core of the class because it is used so often, we wanted to save developers a few keystrokes.
|
|
Example:
|
|
<HR>
|
|
<PRE>
|
|
<form name=copy method=post action="<?php echo $phpgw->link();?>">
|
|
/* If session management is done via passing url parameters */
|
|
/* The the result would be */
|
|
/* <form name=copy method=post action="somepage.php?sessionid=87687693276?kp3=kjh98u80"> */
|
|
</PRE>
|
|
<HR>
|
|
<H2><A NAME="ss5.3">5.3 Application Functions</A>
|
|
</H2>
|
|
|
|
<P>
|
|
<H3>$phpgw->common->phpgw_header</H3>
|
|
|
|
<P><CODE>$phpgw->phpgw_header()</CODE><BR>
|
|
Print out the start of the HTML page, including the navigation bar
|
|
and includes <CODE>appname/inc/header.php</CODE>
|
|
<H3>$phpgw->common->phpgw_footer</H3>
|
|
|
|
<P><CODE>$phpgw->phpgw_footer()</CODE><BR>
|
|
Prints the system footer, and includes <CODE>appname/inc/footer.php</CODE>
|
|
<H3>$phpgw->common->appsession</H3>
|
|
|
|
<P><CODE>$phpgw->common->appsession($data)</CODE><BR>
|
|
Store important information session information that your application needs.<BR>
|
|
<CODE>$phpgw->appsession</CODE> will return the value of your session data is you leave the parameter empty [i.e. <CODE>$phpgw->appsession("")</CODE>], otherwise it will store whatever data you send to it.<BR>
|
|
You can also store a comma delimited string and use <CODE>explode()</CODE> to turn it back into an array when you receive the value back.<BR>
|
|
Example:
|
|
<HR>
|
|
<PRE>
|
|
$phpgw->common->appsession("/path/to/something");
|
|
echo "Dir: " . $phpgw->common->appsession();
|
|
</PRE>
|
|
<HR>
|
|
<H2><A NAME="ss5.4">5.4 File functions</A>
|
|
</H2>
|
|
|
|
<H3>$phpgw->vfs->read_file</H3>
|
|
|
|
<P><CODE>$phpgw->vfs->read_file($file)</CODE><BR>
|
|
Returns the data from $file.<BR>
|
|
You must send the complete path to the file.<BR>
|
|
Example:
|
|
<HR>
|
|
<PRE>
|
|
$data = $phpgw->vfs->read_file("/some/dir/to/file.txt");
|
|
</PRE>
|
|
<HR>
|
|
<P>
|
|
<H3>$phpgw->vfs->write_file</H3>
|
|
|
|
<P><CODE>$phpgw->vfs->write_file($file, $contents)</CODE><BR>
|
|
Write data to $file.<BR>
|
|
You must send the complete path to the file.<BR>
|
|
Example:
|
|
<HR>
|
|
<PRE>
|
|
$data = $phpgw->vfs->write_file("/some/dir/to/file.txt");
|
|
</PRE>
|
|
<HR>
|
|
<P>
|
|
<H3>$phpgw->vfs->read_userfile</H3>
|
|
|
|
<P><CODE>$phpgw->vfs->read_userfile($file)</CODE><BR>
|
|
Returns the data from $file, which resides in the users private dir.<BR>
|
|
Example:
|
|
<HR>
|
|
<PRE>
|
|
$data = $phpgw->vfs->read_userfile("file.txt");
|
|
</PRE>
|
|
<HR>
|
|
<P>
|
|
<H3>$phpgw->vfs->write_userfile</H3>
|
|
|
|
<P><CODE>$phpgw->write_userfile($file, $contents)</CODE><BR>
|
|
Writes data to $file, which resides in the users private dir.<BR>
|
|
Example:
|
|
<HR>
|
|
<PRE>
|
|
$data = $phpgw->vfs->write_userfile("file.txt");
|
|
</PRE>
|
|
<HR>
|
|
<P>
|
|
<H3>$phpgw->vfs->list_userfiles</H3>
|
|
|
|
<P><CODE>$phpgw->vfs->list_userfiles()</CODE><BR>
|
|
Returns an array which has the list of files in the users private dir.<BR>
|
|
Example:
|
|
<HR>
|
|
<PRE>
|
|
$filelist = array();
|
|
$filelist = $phpgw->vfs->list_userfiles();
|
|
</PRE>
|
|
<HR>
|
|
<H2><A NAME="ss5.5">5.5 Email/NNTP Functions</A>
|
|
</H2>
|
|
|
|
<P>
|
|
<P>
|
|
<H3>$phpgw->send->msg</H3>
|
|
|
|
<P><CODE>$phpgw->msg->send($service, $to, $subject, $body, $msgtype, $cc, $bcc)</CODE><BR>
|
|
Send a message via email or NNTP and returns any error codes.<BR>
|
|
Example:
|
|
<HR>
|
|
<PRE>
|
|
$to = "someuser@domain.com";
|
|
$subject = "Hello buddy";
|
|
$body = "Give me a call\n Been wondering what your up to.";
|
|
$errors = $phpgw->msg->send("email", $to, $subject, $body);
|
|
</PRE>
|
|
<HR>
|
|
<HR>
|
|
<A HREF="phpGW_Developers-HOWTO-6.html">Next</A>
|
|
<A HREF="phpGW_Developers-HOWTO-4.html">Previous</A>
|
|
<A HREF="phpGW_Developers-HOWTO.html#toc5">Contents</A>
|
|
</BODY>
|
|
</HTML>
|