easyPoll and etoGraph -uses an external class (postgraph_poll.class.php) and global namespace to allow variable sharing between the class file and the etomite snippet. The only change from the original class was at the lines :
function printImage()
{
global $graphPath, $graphName;
$graphPath='assets/graph/img';
$graphName= md5(rand() * time()).'.png';
// header("Content-type: image/jpeg");
ImagePNG($this->img, $graphPath.'/'.$graphName);
}
Plaincart uses some external files and classes to build and integrate an external application with etomite, for example...Plaincart/SNIPPETS/shop_paypal.ipn:
class paypal_class {
var $last_error; // holds the last error encountered
var $ipn_log; // bool: log IPN results to text file?
var $ipn_log_file; // filename of the IPN log
var $ipn_response; // holds the IPN response from paypal
var $ipn_data = array(); // array contains the POST values for IPN
var $fields = array(); // array holds the fields to submit to paypal
Shoutbox uses JSON (Javascript Object Notation) class:
Quote
JSON (JavaScript Object Notation) is a lightweight data-interchange
* format. It is easy for humans to read and write. It is easy for machines
* to parse and generate. It is based on a subset of the JavaScript
* Programming Language, Standard ECMA-262 3rd Edition - December 1999.
* This feature can also be found in Python. JSON is a text format that is
* completely language independent but uses conventions that are familiar
* to programmers of the C-family of languages, including C, C++, C#, Java,
* JavaScript, Perl, TCL, and many others. These properties make JSON an
* ideal data-interchange language.
* format. It is easy for humans to read and write. It is easy for machines
* to parse and generate. It is based on a subset of the JavaScript
* Programming Language, Standard ECMA-262 3rd Edition - December 1999.
* This feature can also be found in Python. JSON is a text format that is
* completely language independent but uses conventions that are familiar
* to programmers of the C-family of languages, including C, C++, C#, Java,
* JavaScript, Perl, TCL, and many others. These properties make JSON an
* ideal data-interchange language.
This is used to create an AJAX shoutbox with an external class and external control script but integrated into etomite with a simple chunk.
Another method I use is to create a class in a snippet then call the snippet into the template after the header so that the class functions are available to use in subsequent snippet code. Although a slightly increased overhead for pages not requiring the code, the ease of use knowing the functions are avaliable rather than delivering them "just in time" makes writing code based on the class much easier.
Edited by Cris D., 24 October 2008 - 08:08 PM.











