Skip to main content Help Control Panel

YACS CMS : Open source !

Server software «  

Documentation: overlays/overlay.php

class Overlay - The overlay interface used by articles

Overlays are a straightforward way to extend YACS content pages. For example, articles can be transformed to recipes, or to other pages that has to include some structured data.

Overlay data is saved along standard articles as a serialized snippet. The encoding and decoding of this field requires a specialized class.

The overlay interface masks these details and offers convenient methods to create, access and save piggy-back data.

As visible in articles/edit.php, the creation of a new overlay or the update of an existing one is achieved through following sequence:
// create a new overlay
$overlay Overlay::bind($overlay_type);

// get form fields used to updated the overlay
$fields $overlay->get_fields($item);

// get a label for some ordinary field
$label $overlay->get_label('title''edit');

...

// process posted data
$overlay->parse_fields($_POST);

// save article and serialized overlay as well
$_POST['overlay'] = $overlay->save();
$_POST['overlay_id'] = $overlay->get_id();
Articles::post($_POST);

// save overlay state
$overlay->remember('insert'$item);



As visible into articles/view.php, an overlay is handled with following calls:
// extract overlay data from a record
$overlay Overlay::load($item);

// get text related to this instance
$text $overlay->get_text('view');

// get additional tabs
$text $overlay->get_tabs('view');



Also, post-processing steps can include the removal of the hosting record, as shown in articles/delete.php
// extract overlay data from a record
$overlay Overlay::load($item);

// post-processing steps specific to the overlay
$overlay->remember('delete'$item);



As a consequence, this class has two constructors:

The interface itself is made of following member functions, that have to be overloaded into child functions:

Following functions are aiming to simplify external calls:

This script is a reference file of this system.

License: GNU Lesser General Public License

Authors:

Testers:

overlays/overlay.php - Attributes specific to this overlay

allows() - Allow or block operations

function allows($type, $action)

bind() - Create a new overlay from scratch

function bind($type)

This function creates an instance of the Overlay class based on the given type. For the type 'foo', the script file 'overlays/foo.php' is loaded.

Example:
// create a new overlay
$overlay Overlay::bind('recipe');



The provided string may include parameters after the type. These parameters, if any, are saved along overlay attributes.

Example:
// this overlay will preserve past events
$overlay Overlay::bind('day without_past_dates');



See also:

export() - Export an overlay as XML

function export()

get_extra_text() - Text to be inserted aside

function &get_extra_text($host=NULL)

To be overloaded into derivated class

get_fields() - Build the list of fields for one overlay

function get_fields($host)

This function is used to create forms aiming to change overlay data. To be overloaded into derivated class.

See also:

get_id() - Identify one instance

function get_id()

This function returns a string that identify uniquely one overlay instance. When this information is saved, it can be used later on to retrieve one page and its content.

@returns a unique string, or NULL

See also:

get_label() - Get an overlaid label

function get_label($name, $action='view')

This function changes strings used to describe an overlaid item.

Accepted action codes:

To be overloaded into derivated class

See also:

get_list_text() - Display the content of one overlay in a list

function &get_list_text($host=NULL)

To be overloaded into derivated class

get_live_introduction() - Display a live introduction

function &get_live_introduction($host=NULL)

To be overloaded into derivated class

get_live_title() - Display a live title

function &get_live_title($host=NULL)

To be overloaded into derivated class

get_tabs() - Add some tabbed panels

function &get_tabs($variant='view', $host=NULL)

Display additional information in panels.

Accepted action codes:

See also:

get_text() - Display the content of one overlay

function &get_text($variant='view', $host=NULL)

Accepted variant codes:

To be overloaded into derivated class

get_trailer_text() - Text to come after page description

function &get_trailer_text($host=NULL)

To be overloaded into derivated class

get_type() - Retrieve overlay type

function get_type()

@returns string

See also:

get_view_text() - Display the content of one overlay in main view panel

function &get_view_text($host=NULL)

To be overloaded into derivated class

load() - Restore an instance

function load($host, $name='overlay')

This function unserializes piggy-back data and uses it to populate an overlay instance.

// get the record from the database
$item =& Articles::get($id);

// extract overlay data from $item['overlay']
$overlay Overlay::load($item);



See also:

parse_fields() - Capture form content

function parse_fields($fields)

This function is used to actually change some overlay data.

To be overloaded into derivated class.

See also:

render() - Render some page component

function render($type, $reference, $page=1)



See also:

remember() - Remember an action once it's done

function remember($variant, $host)

This function enables a cascaded synchronization with some external storage facility. For example, a secondary table can be created in the database to derive information from some overlay instance.

To be overloaded into derivated class

See also:

save() - Serialize overlay content

function save()



See also: