Home « Server software «
Documentation: behaviors/behaviors.php
class Behaviors - Programmable extensions of sections, articles, and files
Behaviors are software extensions used from within sections, articles, and files to change YACS basic behavior on key event, such as:- Content creation - to allow for controlled article creation or file attachment (tel2pay, etc.)
- Content access - to allow for controlled access (tel2pay, license agreement, etc.)
- Content change - the main goal is to implement workflows on approvals
Behaviors are described in specialized fields either in sections, articles, or files. These multi-line fields allow for the definition of several behaviors per item.
Each line describes one behavior, according to following formats:
behavior_name
or
behavior_name behavior_parameters
The behavior name references one PHP script that extends the behavior interface, defined in behaviors/behavior.php. Parameters consist of optional data provided to the behavior script at run-time.
Some examples of behavior invocations:
// agree on creative common license prior file download (at section, article, or file level)
agree_on_file_access creative_common.txt
// ask to pay for each new article posted in a section
paypal_on_article_creation email@mysite.com 5 EUR
// ask to pay for article access (at section or article level)
paypal_on_article_access email@mysite.com 0.5 EUR
// ask to pay for file download (at section, article, or file level)
paypal_on_file_access email@mysite 1 EUR
How do behaviors compare to overlays?
Overlays are aiming to store additional structured data in articles, where behaviors are stateless, and are scoping sections.
This script is a reference file of this system.
Licence: GNU Lesser General Public License
Auteurs:
- Bernard Paques bernard.paques@bigfoot.com
behaviors/behaviors.php - All registered behaviors
Behaviors() - Constructor
function Behaviors(&$item, &$anchor)
- &$item - array reference item behaviors, if any
- &$anchor - object reference anchor behaviors, if any
allow() - Allow script execution, or block it
function allow($script, $anchor)
- $script - string script name
- $anchor -
- returns boolean FALSE if execution is cancelled, TRUE otherwise
parse() - Bind behavior declarations to real code
function parse(&$text)
- &$text - string behavior declarations