
The File Browser Tool(plug-in)
==============================


What is it
----------
The 'fileBrowser' tool of WebApp is a WebBox which is used to 
preview the templates and WebBox-es of a WebApp application.
It allows the users to browse the folders of the application
and to display the files. The files are displayed according
to their types, e.g. a php file is displayed as code, an image
file is displayed as an image, an HTML file can be displayed
both as HTML code and as rendered HTML, etc.

It is usually used by the grafical designer of the application
to see how the templates look in the application. He cannot see 
the templates properly just by opening them in the browser, because
the templates contain {{variables}}, template tags (like <Repeat>, <if>,
<Recordset>) etc. It can also be used by the JavaScript programmer
and PHP/DB programmer to test the functionality of a WebBox separately
from the rest of the application (if the WebBox is well encapsulated).


How to enable it for a certain application
------------------------------------------
To use it for a certain application, add a php file (e.g. 
'browse.php') in the root folder of the application, which
contains these lines:
    <?php
    include "webapp.php";
    WebApp::addVar("APP_STYLE", APP_URL."templates/styles.css");
    WebApp::constructHtmlPage(BROWSER_PATH."fileBrowser.html");
    ?>

It is not a standalone application, it is like a plug-in tool
that can be added to an existing application. The constant 
BROWSE_PATH is declared by the framework itself. By including
the "webapp.php" of the application, it gets the paths,
the DB connection and the configuration of the application itself,
which are needed in order to preview the templates correctly.


How it is used
--------------
On the left-side of the page there is a box that allows the user to
browse a folder and to select a file. The selected file is displayed
on the right side of the page. On the top of the page there is a
panel that allows the user to change the way the template is displayed.

If you check the "Hide Folder Box" and then click refresh, then the
left box that is used to browse the folders is hidden (this may be
useful when the template that is being displayed is too large and
fills all the width of the browser).

The options "Code View" and "Preview" change the viewing mode of
the HTML files. When "Code View" is selected, the HTML code of the
templates will be displayed. When "Preview" is selected, the templates
are displayed in the same way that they will be displayed in the 
application.

The second box on the top allows the user to change any session variables,
and the third box allows him to change the root folder of the select box.


The configuration file
----------------------
Sometimes the templates may have variables inside it, or may be associated
with recordsets that contain variables. If these variables are given 
values somewhere else in the application (outside the template) then these
variables will be uninstantiated and the template will not be displayed
properly. In order to correct this situation, a configuration file may
be used for each template. The 'fileBrowser' looks for the file
'tplFile.cfg.php', includes it if found, and calls the function 
'tplFile_config()'. In this function the user can instantiate these 
variables so that the template is displayed correctly (similar to how
it is displayed in a real situation in the application).

