Framework
The framework is currently coded in PHP but it should be easily ported to other languages.
The plugin architecture is based on an abstract class called liveInfo. This class and all plugins (services) have an associated xml file which defines configuration values. The liveInfo.xml file contains default configuration values for the system. The xml files for services can override the values in the default xml file. For instance, the liveInfoContainer node contains the html (div container) that displays the results and pagecontrols. This can be used by all services or a service can have a liveInfoContainer node in its xml file which is used instead. This is what makes liveInfo skinnable. Every service also has an associated class which is a subclass of the liveInfo class.
The best way to describe how liveInfo is to use an example. The next two sections describe how to put a liveInfo element on a page and how to write a service.
Putting liveInfo on your page
We'll use the google service as an example. The google service displays results from Google.
Inside the head section of your page or template, put the following bit of php.
-
<?php
-
include_once('<path>liveInfo.php');
-
$liveInfoMan = liveInfoManager::getLiveInfoManager();
-
$liveInfoMan->addService('google','Search');
-
//output a string of all the css link tags for all the services
-
//output a string of all the js for all the services
-
$jsCode = $liveInfoMan->getClientsCode("js");
-
?>
Replace <path> with the install path of LiveInfo in line 2. Line 3 instantiates the LiveInfoManager object. This object is responsible for managing the liveInfo elements that are on the page. Remember, its possible to have more than one. We add the service that we want via the addService method in line 4. The addService method takes two parameters; serviceName and opName. In this case the serviceName is "google" and the opName is "Search". If you have other services, you would add them here. Each service has a associated css file and line 6 outputs the css link tag for each service. Line 7 stores the javascript object creation code into the $jsCode variable.
Also in the head section we need to load the js files and create the function that is called when the document has loaded. This function creates all the liveInfo objects for each of the services on the page
-
<script type="text/javascript" src="[path]js/xmlclient.js"></script>
-
<script type="text/javascript" src="[path]js/liveinfo.js"></script>
-
<script type="text/javascript" src="[path]js/onload.js"></script>
-
<script type="text/javascript"><!--//--><![CDATA[//><!--
-
function liveInfoServices() {
-
<?php echo $jsCode; ?>
-
}
-
//--><!]]>
-
</script>
Replace [path] with the path of your liveinfo install. The $jsCode is the javascript that inits the liveInfo objects for each element on the page. It would look like this :
-
wordpressSearch= new liveInfo("http://www.nodetraveller.com/liveInfo/liveInfo.php","wordpress","Search","s");
-
wordpressSearch.init();
-
wordpressSearch.setSubmit(true);
Now within your page or template, wherever you want, you can output the form and result HTML with the following:
And that's it. The actual form and html is actually defined in the service xml, which is what we'll look at next.