The purpose of the fCMSPro backend API is to
enable the creation of custom HTML pages that can display content from your
database (the same content which is displayed inside your Flash movie). The most common
objective when creating these pages is to allow search engines to index your
site more easily. By including the
phpapi.php file from the
fCMSBackend your php code will have access to a
query mechanism similar to the one used by the
fCMSPro inside Flash. As well as querying,
there is an XLST based transformation
capability which can be used to transform specific XML based database field
values into valid HTML.
When you install the fCMSBackend code, you install both the necessary code to communicate with Flash and the backend API. The layout of the fCMSBackend installation is as follows:
index.php
index.css
swfobject.js
fcms_html.php
fcmsfull.php
fCMSBackend
fCMSBackend > config
fCMSBackend > transform
fCMSBackend > transform > default
fCMSBackend > imgRoot
fCMSBackend > admin
fCMSBackend > includes
fCMSBackend > modules
(The config directory contains the configuration
files. The transform directory contains
XSLT transformations that generate HTML based
on the XML that Flash uses. The imgRoot
directory contains the images and files uploaded using the Flash based admin
mode. The admin and
includes directories hold the code for the
fCMSPro.)
As well as the configuration, you can also edit the XSLT transformations. The
files on the site root that are needed to generate the HTML-based copy of the database information are index.php,
fcms_html.php,
index.css and
swfobject.js, they are required if you want search
engines to index the content.
The default index.php file generates the
HTML code that will insert the .swf file using javascript functions
stored in the swfobject.js file (see
SWFObject:
Javascript Flash Player detection and embed script ). The Flash file
should be named fCMSPro.swf and should be
placed inside the site root (the location can be changed by editing the template). In
the case that the Flash player is not available or javascript is disabled in
the user's browser, the user (or the search engine spider) will see the html
version displaying the database's content in place of the Flash version.
Please note the following:
There are 3 types of HTML content generated by the
fCMSPro backend:
The fcms_html.php file has some parameters at the beginning which you can change to customize the HTML output. By changing the css and php inside fcms_html.php you can completely change the appearance of the fCMSPro generated html pages.
If you require another presentation of the information in your document
database using HTML, you can define it using the PHP backend API. If you only
require the Flash site, you can delete the default templates and not use them
at all. If you disable javascript in your browser, or add
the skipflash parameter to the URL of your site
(for example:
http://www.example.com/index.php?skipflash=true)
you will be able to see the HTML that is generated instead of the Flash movie.
This way you can test your site the way that search engines will see it.
The Flash fields "rich_text" and "file" are stored in XML format, in order for
them to be displayed in the HTML they must be transformed. The fCMSPro system
uses the standard XSLT language. Inside the 'transform' folder, each subfolder
represents a specific transformation and it must contain an XSLT file for each
Flash type that is stored as XML.
Only the transformation default is normally present and you should never
change it. This transformation is used by the default 'index.php' template.
You can create your own transformations by creating a subdirectory and inside
creating XSLT files for each XML content type. If you define your own
transformations, you can change (or create your own) 'fcms_html.php' file and
use your own transformations.
In order to access the document database from PHP, you must include the '/fCMSBackend/phpapi.php' file. This will create a global object called '$FCMSInterface', which you can then access in order to query the database and use transformations.
getAllDocTypes($filter_special=True)
This function will return a list of all the document types defined in your database. By default, document types that begin with an underscore (_) are not returned. If the parameter is False, all document types with an underscore will also be returned.
transformString ($transfrom_name, $file, $xml)
This function will execute the XSLT transformation on the data passed by the
'$xml' parameter. It will use the file named in the '$file' parameter from the
'$transform_name' directory of the 'transform' directory. (For general use you
shouldn't need to make use of this function).
newQuery ()
executeQuery ($query, $transform_name)
The first function will return the new query object. You can use this object
to construct your query. You must then pass it to the second function, with
the transformation name (the subdirectory in the 'transform' folder) you want
to use for the XML transformation. The return value of the function is an
array with the following keys:
"documents": the value is an array of numeric document ids.
"results": the value is an array that maps document ids to the array of field values this array maps field names to the fieldvalue array. The field value array contains the following keys:
"id": the field id.
"transformation_name": the transformation name used.
"raw_values": an array mapping page numbers (by default, there is only page number 0) to raw Flash values.
"values": an array mapping page number to transformed values.
The query object follows the same logic as the query object in flash. You must understand how the Flash query works in order to use these methods:
addFilter ($filter_array)
The filter array must have the following keys defined:
"fields": the string array containing field names used in the filter.
"operator": the operator for the filter.
"neg": should be True if the operator should be inverted.
"values": an array of values used for comparison.
"datatype": the datatype of the filter.
setSortOn ($field, $datatype, $isDescending)
This method will set "sort on" information for the query. You must pass the field name, its datatype and a boolean indicating if you want a descending or an ascending sort.
setLimits ($begin, $count)
Sets the limits for the query.
setFieldList ($fields)
The list of field names that should be returned, or an array containing an asterisk (*) which will cause all document fields to be returned.