Home « Server software «
Documentation: images/images.php
Class Images - The database abstraction layer for images
Images are saved into the file system of the web server. Each image also has a related record in the database.This script is a reference file of this system.
Licence: GNU Lesser General Public License
Auteurs:
- Bernard Paques bernard.paques@bigfoot.com
- Florent
Testeurs:
- Guillaume Perez
- Anatoly
delete() - Delete one image in the database and in the file system
function delete($id)
- $id - the id of the image to delete
- returns an error message, if any
delete_for_anchor() - Delete all images for a given anchor
function delete_for_anchor($anchor)
- $anchor - the anchor to check
- returns an error message, if any
get() - Get one image by id
function &get($id)
- $id - int the id of the image
- returns the resulting $item array, with at least keys: 'id', 'title', etc.
get_by_anchor_and_name() - Get one image by anchor and name
function &get_by_anchor_and_name($anchor, $name)
- $anchor - string the anchor
- $name - string the image name
- returns the resulting $item array, with at least keys: 'id', 'title', etc.
get_icon_href() - Get the web address of an image
function get_icon_href($item)
- $item - array the image description (i.e., Images::get($id))
- returns string the target href, or FALSE if there is an error
get_thumbnail_href() - Get the web address of one thumbnail
function get_thumbnail_href($item)
- $item - array the image description (i.e., Images::get($id))
- returns string the thumbnail href, or FALSE on error
get_url() - Get the url to view an image
function get_url($id, $action='view')
- $id - int the id of the image to view
- $action='view' - string the expected action ('view', 'edit', 'delete', ...)
- returns an anchor to the viewing script
images/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. 'images/view.php/512
').Voir aussi:
list_by_date() - List newest images
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
- $count=10 - int the number of items to display
- $variant='full' - string the list variant, if any
- returns NULL on error, else an ordered array with $url => ($prefix, $label, $suffix, $icon)
// side bar with the list of most recent images
include_once 'images/images.php';
$local['title_en'] = 'Most recent Images';
$local['title_fr'] = 'Images récentes';
$title = i18n::user('title');
$items = Images::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 image separately, using
Images::get_newest()
In this case, skip the very first image in the list by using
Images::list_by_date(1, 10, '')
Voir aussi:
- [script=for $variant description]images/images.php#list_selected[/script]
list_by_date_for_anchor() - List newest images for one anchor
function &list_by_date_for_anchor($anchor, $offset=0, $count=20, $variant=NULL, $capability='?')
- $anchor - string the anchor (e.g., 'article:123')
- $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=NULL - string the list variant, if any
- $capability='?' - string actual surfer capability ('?', 'M', or 'A') -- articles/edit.php
- returns NULL on error, else an ordered array with $url => ($prefix, $label, $suffix, $icon)
Voir aussi:
- [script=for $variant description]images/images.php#list_selected[/script]
list_by_date_for_author() - List newest images 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 image
- $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='date' - string the list variant, if any
- returns NULL on error, else an ordered array with $url => ($prefix, $label, $suffix, $icon)
include_once 'images/images.php';
$items = Images::list_by_date_for_author(12, 0, 10);
$context['text'] .= Skin::build_list($items, 'compact');
Voir aussi:
- [script=for $variant description]images/images.php#list_selected[/script]
list_by_size() - List biggest images
function &list_by_size($offset=0, $count=10, $variant='full')
- $offset=0 - int the offset from the start of the list; usually, 0 or 1
- $count=10 - int the number of items to display
- $variant='full' - string the list variant, if any
- returns NULL on error, else an ordered array with $url => ($prefix, $label, $suffix, $icon)
list_selected() - List selected images
function &list_selected(&$result, $layout='compact', $capability='?')
- &$result - resource result of database query
- $layout='compact' - string 'full', etc or object, i.e., an instance of Layout_Interface
- $capability='?' - string '?' or 'A', to support editors and to impersonate associates, where applicable
- returns NULL on error, else an ordered array with $url => ($prefix, $label, $suffix, $icon)
- 'compact' - to build short lists in boxes and sidebars (this is the default)
- 'no_anchor' - to build detailed lists in an anchor page
- 'full' - include anchor information
post() - Post a new image or an updated image
function post($fields, $capability='?')
- $fields - array an array of fields
- $capability='?' - string to support editors -- see images/edit.php
- returns the id of the image, or FALSE on error
- id+image: update an existing entry in the database
- id+no image: only update the database
- no id+image: create a new entry in the database
- no id+no image: create a new entry in the database
setup() - Create or alter tables for images
function setup()
stat() - Get some statistics
function &stat()
- returns the resulting ($count, $oldest_date, $newest_date, $total_size) 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, $oldest_date, $newest_date, $total_size) array