Documentation : articles/article.php
- Class Article extends Anchor - The article anchor
- Allows() - Allow or block operations
- Get_focus() - Get the focus for this anchor
- Get_icon_url() - Get the url to display the icon for this anchor
- Get_neighbours() - Get next and previous items, if any
- Get_path_bar() - Get the path bar for this anchor
- Get_reference() - Get the reference for this anchor
- Get_teaser() - Get some introductory text from an article
- Get_thumbnail_url() - Get the url to display the thumbnail for this anchor
- Get_url() - Get the url to display the main page for this anchor
- Is_editable() - Check that the surfer is an editor of an article
- Is_interactive() - Is this an interactive thread?
- Load_by_id() - Load the related item
- Parse() - Parse one article from a piece of text
- Parse_match() - Called from within a preg_replace_callback() in Article::parse()
- Restore() - Restore a previous version of this article
- Touch() - Remember the last action for this article
- Transcode() - Transcode some references
Class Article extends Anchor - The article anchor
This class implements the Anchor interface for published articles.This script is a reference file of this system.
Voir aussi :
Licence : GNU Lesser General Public License
Auteurs :
- Bernard Paques bernard.paques@bigfoot.com
- GnapZ
Testeurs :
- Guillaume Perez
- Dobliu
allows() - Allow or block operations
function allows($type, $action)
- $type - string the kind of item to handle
- $action - string the foreseen operation ('edit', 'new', ...)
- returns TRUE if the operation is accepted, FALSE otherwise
get_focus() - Get the focus for this anchor
function get_focus()
- returns array of anchor references
get_icon_url() - Get the url to display the icon for this anchor
function get_icon_url()
- returns an anchor to the icon image
Voir aussi :
get_neighbours() - Get next and previous items, if any
function get_neighbours($type, $item)
- $type - string the item type (eg, 'image', 'file', etc.)
- $item - array the anchored item asking for neighbours
- returns an array($previous_url, $previous_label, $next_url, $next_label, $option_url, $option_label), or NULL
Voir aussi :
get_path_bar() - Get the path bar for this anchor
function get_path_bar()
- returns an array of $url => $label, or NULL
Voir aussi :
get_reference() - Get the reference for this anchor
function get_reference()
- returns 'article:<id>', or NULL on error
$anchor = Anchors::get($article['anchor']);
$context['text'] .= '<input type="hidden" name="anchor"
value="'.$anchor->get_reference().'" />';
Voir aussi :
get_teaser() - Get some introductory text from an article
function &get_teaser($variant = 'basic')
- $variant = 'basic' - string an optional variant, including
- returns NULL, of some text
If there is some introductory text, it is used. Else the description text is used instead. The number of words is capped in both cases.
Also, the number of remaining words is provided.
Following variants may be selected to adapt to various situations:
- 'basic' - strip every tag, we want almost plain ASCII - maybe this will be send in a mail message
- 'hover' - some text to be displayed while hovering a link
- 'quote' - transform YACS codes, then strip most HTML tags
- 'teaser' - limit the number of words, tranform YACS codes, and link to permalink
Voir aussi :
get_thumbnail_url() - Get the url to display the thumbnail for this anchor
function get_thumbnail_url()
- returns an anchor to the thumbnail image
Voir aussi :
get_url() - Get the url to display the main page for this anchor
function get_url($action='view')
- $action='view' - string the targeted action ('view', 'print', 'edit', 'delete', ...)
- returns an anchor to the viewing script, or NULL on error
Voir aussi :
is_editable() - Check that the surfer is an editor of an article
function is_editable($user_id=NULL)
- $user_id=NULL - int optional reference to some user profile
- returns TRUE or FALSE
An anonymous surfer is considered as an editor if he has provided the secret handle.
is_interactive() - Is this an interactive thread?
function is_interactive()
- returns TRUE is this page supports interactions, FALSE otherwise
load_by_id() - Load the related item
function load_by_id($id, $mutable=FALSE)
- $id - int the id of the record to load
- $mutable=FALSE - boolean TRUE to always fetch a fresh instance, FALSE to enable cache
Voir aussi :
parse() - Parse one article from a piece of text
function parse($text, $item = NULL)
- $text - string the input text
- $item = NULL - array previous attributes for the page
- returns an array of updated attributes
- anchor - the complete anchor for this post (e.g. 'article:123')
- author - nick name, id or e-mail address of the poster (if distinct from e-mail poster)
- blogid or section - nick name or id of the target section for the post (e.g., 'my_blog')
- tags (or categories) - a list of comma-separated topics to be linked to this post
- introduction - some introductory text for this post
- source - a web reference to original material, if any
- title - to override the Subject: field of the message
Sample usage:
// parse article content
include_once $context['path_to_root'].'articles/article.php';
$article = new Article();
$fields = $article->parse($content['description'], $item);
Voir aussi :
parse_match() - Called from within a preg_replace_callback() in Article::parse()
function parse_match($matches)
- $matches -
restore() - Restore a previous version of this article
function restore($item)
- $item - array set of attributes to restore
- returns TRUE on success, FALSE otherwise
Voir aussi :
touch() - Remember the last action for this article
function touch($action, $origin, $silently = FALSE)
- $action - string one of the pre-defined action code
- $origin - string the id of the item related to this update
- $silently = FALSE - boolean TRUE to not change the edit date of the article, default is FALSE
- On image creation, the adequate code is added to the description field to let the image be displayed inline
- On icon selection, the icon field is updated
- On thumbnail image selection, the thumbnail image field is updated
- On location creation, some code is inserted in the description field to display location name inline
- On table creation, some code is inserted in the description field to display the table inline
Moreover, on any change that impact the edition date (i.e., not in silent mode), a message is sent to the article creator, if different from the current surfer and a message is sent to watchers as well.
Voir aussi :
transcode() - Transcode some references
function transcode($transcoded)
- $transcoded - array of pairs of strings to be used in preg_replace()
Voir aussi :