Personal Weezo space access   search
  • Franšais
  • English
Extensions

themeDeveloping an extension

Through its extensions architecture, Weezo can offer new types of resources.

PHP skills are required to develop plugins.
A Weezo extension is a set of PHP scripts plus a text file named "describer.ini".
To be redistributed, all this files must be placed into a 7zip archive, which name will define resource's name. This archive's extension should be renamed to .weezoResource to ease installation (as .weezoResource files are associated with Weezo).

Weezo integrated extension installer unpacks your extension files in the directory: /www/res/misc/zipfile_name.

describer.ini

    This text file, located in the root directory of your extension, defines among other things :
  • the extension name (in the different supported languages)
  • a short description (in the different supported languages)
  • session management method (see below)
  • the index script name (actually path from extension directory)
  • the configuration script name (optional - this script will be used for resource configuration in user interface)
  • the resource icons
  • a preview image
  • the author name
  • a URL to the author's web site

The describer.ini file format and a detailed set of instructions are located in the file /www/res/misc/describer.ini.readme.txt

Session management

describer.ini file defines "resourceStartsSession" parameter.
Set this parameter to true if you need to do your own session management (opening and closing sessions).
This is the recommended setting for adapting existing applications as it maximizes inependance with Weezo application: using session_destroy or unsetting $_SESSION array won't destroy weezo session and thus not disconnect the user.

If resourceStartsSession is set to false, weezo session is not closed before starting extension scripts. All weezo session data is therefore accessible.
Keep in mind that a session_write_close will disconnect user !

license.txt

You may add a "license.txt" file in the root directory of the extension. It's content will be displayed during the extension installation process.


PHP scripts

Resource configuration

If a config.php script is located into your root directory, it'll be considered as resource configuration script. If you wish to use another script for configuration, modify the describer.ini accordingly.
If no configuration script is set, Weezo interface will display a simple script allowing user to change resource name.
You may specify standaloneConfig=true and configStartsSession=true in describer.ini if you want your script to be totally independant of Weezo's architecture. Instructions below are then irrelevant

If you want to use Weezo features, set standaloneConfig=false.
You should then use an existing config.php script to understand how it works.
When called from user interface or remote administration, configuration script is included by a script which has already inserted  head> /head> and  body>.
This script may also be directly called by user (this is the "limited configuration" case). You should then rely on rcConfigRights() for access control and head/body insertion.

Configuration script structure:
rcConfigRights($limitedConfigAllowed=false); // used to check access rights. if $limitedConfigAllowed is false, user may not access configuration script. If true, user may access configuration an thus change some parameters for this session
rcInsertScriptAndForm(); // Insert required javascript and forms
rcInsertIconName($resourceData); // Insert resource's icon and resource name selection control

[rcProcessData(...)] // see below
[rcProcessData(...)]
...
[rcAdvancedConfigStart()]
[rcProcessData(...)]
[rcProcessData(...)]
...
rcButtonSaveCancel() // Insert save/cancel buttons (remote administration only) and some scripts
rcWriteResourceFile($resourceData, $fileName); // Commit changes

rcProcessData function defines and process a parameter.
Format: rcProcessData(data_name, format (dataBoolean, dataList, dataNumeric, dataText, dataPath), default value, contstraints, display, line_break(true/false), sensitive_data(Y/N)); Calling this function will:
  • create the data
  • define its format
  • define its default value
  • display the control used to modify it
  • validate and apply new value sent by user

Once again, it's highly recommended to use an existing config.php to understant how this stuff works...

rcAdvancedConfigStart() defines the begining of "advanced configuration" block (see files explorer for exemple).

All data is stored into $resourceData array.

Main resource scripts

You may do whatever you want !
Just remember those simple rules:
  • Default script called when resource is called is ./index.php. It can be changed by modifying "baseFile" in describer.ini
  • security.php is appened before every PHP script. It includes all functions located into commonFunctions.php. It's a bit messy, but feel free to use them !
  • Keep in mind your extension can be associated twice to a same user (for example 2 photo albums). You must ensure there will be no collisions between the 2 instances running in the same session. You may want to use Weezo's WEnv::res()->getVar()/WEnv::res()->setVar() functions that will store data properly (Note: WEnv::res()->getVar() also give access to configuration data set with rcProcessData() function). If you can't use this solution and can't modify your script, you may set "singleInstance=true" in describer.ini so this resource cannot be created more than once.
  • If you don't want to use those WEnv::res()->getVar/WEnv::res()->setVar functions and did set resourceStartsSession=false, is recommended to prefix your $_SESSION vars as not all Weezo session vars have not been properly prefixed...
  • For a better integration, you should use cfInsertHead() function that will instert head node, with theme's CSS, and all common javascript (for window interaction for example). You should then use frame1 for upper level frames, then frame2, then frame3, and h1, h2 and h3 as frame's titles

FAQ

Access right management

Access right management is integrated into Weezo core. You don't have to develop it in your extension scripts.
It is done by the script "security.php". This script is automatically executed before any other PHP scripts (auto-prepend).
A PHP script will only be authorized to execute if located in the directory (or sub-directory) of a resource associated with the connected/authenticated user group.

Be well aware though that any non-PHP file remains accessible, even to non authenticated users.

 

Apache / PHP Environment

Because two good examples are always better than a bad explanation (and a long one at that), you can check the php.ini and httpd.conf files used by Weezo. They are located in the directory : /data/default.


How to develop and test your extension?

The simplest to do is to directly develop in the directory /www/res/misc/extension_name

Once a minimal describer.ini is created and the index script defined, your extension will appear into the Weezo interface (restart Weezo first...).


Can I start from scripts provided with Weezo?

Of course you can! The level of excellency reached by our team of thousands of expert developers is such, we don't doubt their pedagogical potential is of the utmost value ;-)

Joke aside, all scripts provided with Weezo are open source (PHP license). You can modify them at will.


Can I adapt existing scripts to work within Weezo ?

Yes, it is possible. You just have to go by the rules defined upthere.
If you adapt existing scripts, keep in mind that mySQL is not part of the default Weezo package (you may use cfMySQLInstalled() function to know wether MySQL is installed or not).