Home « Server software «
Documentation: comments/comments.php
Class Comments - The database abstraction layer for comments
Comments are not intended to create complex threading systems. They are more or less to be used as sticky notes aside published pages.At the moment YACS supports following comment types:
- attention - it's worth the reading
- done - job has been completed
- idea - to submit a new suggestion
- information - answering a previous request
- question - please help
- thumbs down - I dislike it
- thumbs up - I enjoy this
- warning - you should take care
This script is a reference file of this system.
Licence: GNU Lesser General Public License
Auteurs:
- Bernard Paques bernard.paques@bigfoot.com
- Florent
are_allowed() - Check new comments are allowed
function are_allowed()
- returns TRUE or FALSE
- surfer has been authenticated
- or anonymous comments have been allowed
- or teasers have been enabled
delete() - Delete one comment
function delete($id)
- $id - the id of the comment to delete
- returns an error message, if any
Voir aussi:
delete_for_anchor() - Delete all comments for a given anchor
function delete_for_anchor($anchor)
- $anchor - the anchor to check
- returns an error message, if any
Voir aussi:
get() - Get one comment by id
function &get($id)
- $id - int the id of the comment
- returns the resulting $item array, with at least keys: 'id', 'type', 'description', etc.
Voir aussi:
get_img() - Get a
element
function get_img($type)
- $type - the type ('suggestion', etc.')
- returns a suitable HTML element
Voir aussi:
- comments/layout_comments_as_boxesandarrows.php
- comments/layout_comments_as_daily.php
- comments/layout_comments_as_jive.php
- comments/layout_comments_as_manual.php
- comments/layout_comments_as_yabb.php
- skins/skin_skeleton.php
get_next_url() - Get id of next comment
function get_next_url($item, $anchor, $order='date', $capability='?')
- $item - array the current item
- $anchor - string the anchor of the current item
- $order='date' - string the order, either 'date' or 'reverse'
- $capability='?' - string surfer actual capability ('?', 'M', or 'A')
- returns some text
Voir aussi:
get_options() - Get types as options of a <SELECT> field
function get_options($type)
- $type - string the current type
- returns the HTML to insert in the page
Voir aussi:
get_previous_url() - Get id of previous comment
function get_previous_url($item, $anchor, $order='date', $capability='?')
- $item - array the current item
- $anchor - string the anchor of the current item
- $order='date' - string the order, either 'date' or 'reverse'
- $capability='?' - string surfer actual capability ('?', 'M', or 'A')
- returns some text
Voir aussi:
get_radio_buttons() - Get types as radio buttons
function get_radio_buttons($name, $type)
- $name - string the current type
- $type -
- returns the HTML to insert in the page
Voir aussi:
get_title() - Get a default title from the type selected
function get_title($type)
- $type - the type ('suggestion', etc.')
- returns a suitable title
get_url() - Get the url to view a comment
function get_url($id, $action='view')
- $id - int the id of the comment to view, or an anchor reference
- $action='view' - string the expected action ('view', 'edit', 'delete', ...)
- returns an anchor to the viewing script
comments/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. 'comments/view.php/512
').Voir aussi:
- comments/check.php
- comments/layout_comments_as_boxesandarrows.php
- comments/layout_comments_as_daily.php
- comments/layout_comments_as_jive.php
- comments/layout_comments_as_manual.php
- comments/layout_comments_as_yabb.php
- comments/view.php
- control/configure.php
- skins/skin_skeleton.php
list_by_date() - List newest comments
function &list_by_date($offset=0, $count=10, $variant='date')
- $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='date' - 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 comments
include_once 'comments/comments.php';
$local['title_en'] = 'Most recent comments';
$local['title_fr'] = 'commentaires récents';
$title = i18n::user('title');
$items = Comments::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 comment separately, using Comments::get_newest() In this case, skip the very first comment in the list by using Comments::list_by_date(1, 10)
Voir aussi:
list_by_date_for_anchor() - List newest comments 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')
- returns NULL on error, else an ordered array with $url => ($prefix, $label, $suffix, $icon)
Example:
include_once 'comments/comments.php';
$items = Comments::list_by_date_for_anchor('section:12', 0, 10);
$context['text'] .= Skin::build_list($items, 'compact');
Voir aussi:
- articles/fetch_as_msword.php
- articles/fetch_as_pdf.php
- articles/fetch_for_palm.php
- articles/print.php
- articles/view.php
- categories/view.php
- comments/feed.php
- sections/view.php
list_by_date_for_author() - List newest comments 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 comment
- $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)
list_next() - List next comments in thread
function &list_next($id, $variant='date')
- $id - int the id of the main comment
- $variant='date' - string the list variant, if any
- returns NULL on error, else an ordered array with $url => ($prefix, $label, $suffix, $icon)
Voir aussi:
list_selected() - List selected comments
function &list_selected(&$result, $variant='compact', $capability='?')
- &$result - resource result of database query
- $variant='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 an array of $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
- 'search' - include anchor information
- 'feeds'
list_threads_by_count() - Thread comments by numbers
function &list_threads_by_count($offset=0, $count=10, $variant='date')
- $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='date' - string the list variant, if any
- returns NULL on error, else an ordered array with $url => ($prefix, $label, $suffix, $icon)
Voir aussi:
list_threads_by_count_for_anchor() - Thread comments by umbers for given anchor
function &list_threads_by_count_for_anchor($anchor, $offset=0, $count=10, $variant='date', $capability='?')
- $anchor - int the offset from the start of the list; usually, 0 or 1
- $offset=0 - int the number of items to display
- $count=10 - string the list variant, if any
- $variant='date' - string actual surfer capability ('?', 'M', or 'A') -- used to impersonate the actual surfer, as in services/blog.php for example
- $capability='?' -
- returns NULL on error, else an ordered array with $url => ($prefix, $label, $suffix, $icon)
Voir aussi:
list_threads_by_date() - Thread newest comments
function &list_threads_by_date($offset=0, $count=10, $variant='date')
- $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='date' - string the list variant, if any
- returns NULL on error, else an ordered array with $url => ($prefix, $label, $suffix, $icon)
Voir aussi:
list_threads_by_date_for_anchor() - Thread newest comments
function &list_threads_by_date_for_anchor($anchor, $offset=0, $count=10, $variant='date', $capability='?')
- $anchor - int the offset from the start of the list; usually, 0 or 1
- $offset=0 - int the number of items to display
- $count=10 - string the list variant, if any
- $variant='date' - string actual surfer capability ('?', 'M', or 'A') -- used to impersonate the actual surfer, as in services/blog.php for example
- $capability='?' -
- returns NULL on error, else an ordered array with $url => ($prefix, $label, $suffix, $icon)
Voir aussi:
post() - Post a new comment or an updated comment
function post($fields)
- $fields - array an array of fields
- returns the id of the new article, or FALSE on error
On error this script updates
$context['error']
.Voir aussi:
search() - Search for some keywords in all comments
function &search($pattern, $offset=0, $count=10, $variant='search')
- $pattern - the search string
- $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='search' - string the list variant, if any
- returns NULL on error, else an ordered array with $url => ($prefix, $label, $suffix, $icon)
Voir aussi:
setup() - Create tables for comments
function setup()
Voir aussi:
stat() - Get some statistics
function &stat()
- returns the resulting ($count, $min_date, $max_date) array
Voir aussi:
stat_for_anchor() - Get some statistics for one anchor
function &stat_for_anchor($anchor, $capability='?')
- $anchor - the selected anchor (e.g., 'article:12')
- $capability='?' - string actual surfer capability ('?', 'M', or 'A')
- returns the resulting ($count, $min_date, $max_date) array
Voir aussi:
- articles/delete.php
- articles/layout_articles_as_yabb.php
- articles/layout_articles_as_jive.php
- articles/view.php
- categories/delete.php
- categories/view.php
- sections/delete.php
- sections/layout_sections_as_boxesandarrows.php
- sections/sections.php
- sections/view.php
- skins/layout_home_articles_as_alistapart.php
- skins/layout_home_articles_as_daily.php
- skins/layout_home_articles_as_newspaper.php
- skins/layout_home_articles_as_slashdot.php
- skins/skin_skeleton.php
- users/delete.php
stat_threads() - Get some statistics on threads
function &stat_threads()
- returns the resulting ($count, $min_date, $max_date) array
Voir aussi: