Home « Server software «
Documentation: tables/tables.php
Class Tables - The database abstraction layer for tables
Tables are mySQL queries saved into the database, used to build dynamic tables on-the-fly. A nice feature to extend yacs with little effort. Also a very powerful tool to be used in conjonction with overlays that update the database directly.This script is a reference file of this system.
Voir aussi:
Licence: GNU Lesser General Public License
Auteurs:
- Bernard Paques bernard.paques@bigfoot.com
- Florent
build() - Build one table
function build($id, $variant='simple')
- $id - the id of the table to build
- $variant='simple' - string the variant to provide - default is 'simple'
- returns a displayable string
- csv - to provide a downloadable csv page
- inline - to render tables within articles
- simple - the legacy fixed table
- sortable - click on column to sort the row
delete() - Delete one table in the database
function delete($id)
- $id - the id of the table to delete
- returns an error message, if any
delete_for_anchor() - Delete all tables for a given anchor
function delete_for_anchor($anchor)
- $anchor - the anchor to check
- returns an error message, if any
get() - Get one table by id
function &get($id)
- $id - int the id of the table
- returns the resulting $row array, with at least keys: 'id', 'title', etc.
get_url() - Get the url to view an table
function get_url($id, $action='view')
- $id - int the id of the table to view
- $action='view' - string the expected action ('view', 'edit', 'delete', ...)
- returns an anchor to the viewing script
tables/view.php?id=512
'),
which may be not processed correctly by search engines.
If the parameter 'with_friendly_urls
' has been set to 'Y
' in the configuration panel,
this function will return an URL parsable by search engines (e.g. 'tables/view.php/512
').Voir aussi:
list_by_date() - List newest tables
function &list_by_date($offset=0, $count=10, $variant='full')
- $offset=0 - int the offset from the start of the list; usually, 0 or 1 - default is 0
- $count=10 - int the number of items to display - default is 10
- $variant='full' - string the list variant, if any - default is 'full'
- returns NULL on error, else an ordered array with $url => ($prefix, $label, $suffix, $icon)
To build a simple box of the newest tables in your main index page, just use the following example:
// side bar with the list of most recent tables
include_once 'tables/tables.php';
$local['title_en'] = 'Most recent tables';
$local['title_fr'] = 'Tables récentes';
$title = i18n::user('title');
$items = Tables::list_by_date(0, 10, '');
$text = Skin::build_list($items, 'compact');
$context['text'] .= Skin::build_box($title, $text, 'navigation');
You can also display the newest table separately, using Tables::get_newest() In this case, skip the very first table in the list by using Tables::list_by_date(1, 10, '')
Voir aussi:
- [script=for $variant description]tables/tables.php#list_selected[/script]
list_by_date_for_anchor() - List newest tables for one anchor
function &list_by_date_for_anchor($anchor, $offset=0, $count=20, $variant='no_anchor', $capability='?')
- $anchor - int the id of the anchor
- $offset=0 - int the offset from the start of the list; usually, 0 or 1
- $count=20 - int the number of items to display
- $variant='no_anchor' - string the list variant, if any
- $capability='?' - string actual surfer capability ('?', 'M', or 'A') -- see articles/edit.php
- returns NULL on error, else an ordered array with $url => ($prefix, $label, $suffix, $icon)
include_once 'tables/tables.php';
$items = Tables::list_by_date_for_anchor(0, 10, '', 'section:12');
$context['text'] .= Skin::build_list($items, 'compact');
list_by_date_for_author() - List newest tables for one author
function &list_by_date_for_author($author_id, $offset=0, $count=20, $variant='date')
- $author_id - int the id of the author of the table
- $offset=0 - int the offset from the start of the list; usually, 0 or 1 - default is 0
- $count=20 - int the number of items to display - default is 20
- $variant='date' - string the list variant, if any - default is 'date'
- returns NULL on error, else an ordered array with $url => ($prefix, $label, $suffix, $icon)
Voir aussi:
- [script=for $variant description]tables/tables.php#list_selected[/script]
list_selected() - List selected tables
function &list_selected(&$result, $layout='compact', $capability='?')
- &$result - resource result of database query
- $layout='compact' - string '?' or 'A', to support editors and to impersonate associates, where applicable
- $capability='?' -
- returns NULL on error, else an ordered array with $url => ($prefix, $label, $suffix, $icon)
post() - Post a new table or an updated table
function post($fields)
- $fields - array an array of fields
- returns the id of the new article, or FALSE on error
Voir aussi:
setup() - Create or alter tables for tables
function setup()
stat() - Get some statistics
function &stat()
- returns the resulting ($count, $min_date, $max_date) array
stat_for_anchor() - Get some statistics for one anchor
function &stat_for_anchor($anchor)
- $anchor - the selected anchor (e.g., 'article:12')
- returns the resulting ($count, $min_date, $max_date) array