Skip to main content Help Control Panel

Aubagne HipHop

Tout le Hip Hop d'Aubagne et des alentours

Home «   Server software «  

Documentation: articles/articles.php

ContentClick to slide

Class Articles - The database abstraction layer for articles

The several versions of article content are now saved for history, and may be restored at any time.

How to lock an article?

An article can be locked to prevent modification. This feature only concerns regular members of the community, as associates and editors are always allowed to add, change of remove any page.

How to manage options for articles?

The options field is a convenient place to save attributes for any article without extending the database schema. As articles are commonly used to anchor some pages, their options can be also checked through the has_option() member function of the Anchor interface. Check shared/anchor.php for more information.

This means that some options are used within the context of one article (eg, no_links), while others can be used with related items as well.

Specific options to be processed by advanced overlays are not described hereafter. One example of this is the optional keyword 'home_with_results' for the rendering of polls. Please check documentation pages for any overlay you use, like overlays/poll.php.

You can combine any of following keywords in the field for options, with the separator (spaces, tabs, commas) of your choice:

files_by_title - When viewing articles, order attached files by alphabetical order instead of using edition time information. This option may prove useful to structure a list of files. For example, on a page describing a complex project, you would like to offer an introduction to the project ('1.introduction.doc'), then a report on initial issue ('2.the issue.ppt'), and a business case for the solution ('3.profit_and_loss.xls'). By adjusting file names and titles as shown, and by setting the option files_by_title, you would achieve a nice and logical thing.

formatted - The YACS rendering engine is disabled, since the description contains formatting tags. Use this option if you copy the source of a HTML or of a XHTML page, and paste it into an article at your server. Note that this keyword is also accepted if it is formatted as a YACS code ('[formatted]') at the very beginning of the description field.

hardcoded - The YACS rendering engine is disabled, except that new lines are changed to (X)HTML breaks. Use this option if you copy some raw text file (including a mail message) and make a page out of it. Note that this keyword is also accepted if it is formatted as a YACS code ('[hardcoded]') at the very beginning of the description field.

links_by_title - When wiewing articles, order attached links by alphabetical order instead of using edition time information. This options works like files_by_title, except that it applies to link. Use it to create nice and ordered bookmarks.

no_comments - New comments cannot be posted on this page.

no_files - New files cannot be attached to this page.

no_links - New links cannot be posted to this article.

skin_<xxxx> - Select one skin explicitly. Use this option to apply a specific skin to a page. This setting is the most straightforward way of introducing some skin to web surfers.

variant_<xxxx> - Select one skin variant explicitly. Usually only the variant 'articles' is used throughout articles. This can be changed to 'xxxx' by using the option variant_<xxxx>. Then the underlying skin may adapt to this code by looking at $context['skin_variant']. Basically, use variants to change the rendering of individual articles of your site, if the skin allows it.

Also, a specific option is available to handle the article at the front page:

none - Don't mention this published article at the site front page. Use this option to avoid that special pages add noise to the front page. For example, while building the on-line manual of YACS this option has been set to intermediate pages, that are only featuring lists of following pages.

How to order articles and to manage sticky pages?

Usually articles are ranked by edition date, with the most recent page coming first. You can change this 'natural' order by modifying the value of the rank field.

What is the result obtained, depending on the value set?

* 10000 - This is the default value. All articles created by YACS are ranked equally.

* Less than 10000 - Useful to create sticky and ordered pages. Sticky, since these pages will always come first. Ordered, since the lower rank values come before higher rank values. Pages that have the same rank value are ordered by dates, with the newest item coming first. This lets you arrange precisely the order of sticky pages.

* More than 10000 - To reject pages at the end of lists.

This script is a reference file of this system.

Voir aussi:

Licence: GNU Lesser General Public License

Auteurs:

Testeurs:

Reste à faire:

delete() - Delete one article

function delete($id)

delete_for_anchor() - Delete all articles for a given anchor

function delete_for_anchor($anchor)

delete_for_nick_name() - Delete articles by nick name

function delete_for_nick_name($nick_name)

get() - Get one article by id, nick name or by handle

function &get($id, $variant=NULL)

get_newest_for_anchor() - Get the newest article for one anchor

function &get_newest_for_anchor($anchor, $without_sticky=FALSE)

This function is to be used while listing articles for one anchor. It provides the last edited article for this anchor.

Only articles matching following criteria are returned:

Voir aussi:

get_next_url() - Get url of next article

function get_next_url(&$item, $anchor, $order='date', $capability='?')

This function is used to build navigation bars.

Voir aussi:

get_options() - Get articles as options of a <SELECT> field

function &get_options()

Only articles matching following criteria are returned:

Voir aussi:

get_previous_url() - Get url of previous article

function get_previous_url(&$item, $anchor, $order='date', $capability='?')

This function is used to build navigation bars.

Voir aussi:

get_url() - Get the url to view an article

function get_url($id, $action='view')

By default, a relative URL will be provided (e.g. 'articles/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. 'articles/view.php/512').

Voir aussi:

increment_hits() - Set the hits counter - errors are not reported, if any

function increment_hits($id)

list_by_date() - List most recent articles

function &list_by_date($offset=0, $count=10, $variant='full', $since=NULL)

Actually list articles by publishing date, then by title.

To build a simple box of the newest articles in your main index page, just use:
include_once 'articles/articles.php';
$items Articles::list_by_date(010);
$context['text'] .= Skin::build_list($items'decorated');


You can also display the newest article separately, using Articles::get_newest() In this case, skip the very first article in the list by using Articles::list_by_date(1, 10)

Only articles matching following criteria are returned: or YACS is allowed to show restricted teasers or YACS is allowed to show restricted teasers

Voir aussi:

list_by_date_for_anchor() - List most recent publications for one anchor

function &list_by_date_for_anchor($anchor, $offset=0, $count=10, $variant='no_anchor', $capability='?')

Actually list articles by rank, then by publishing date, then by title. If you select to not use the ranking system, articles will be ordered by date only. Else articles with a low ranking mark will appear first, and articles with a high ranking mark will be put at the end of the list.

Example:
include_once 'articles/articles.php';
$items Articles::list_by_date_for_anchor('section:12');
$context['text'] .= Skin::build_list($items'decorated');


Use the variant 'boxes' to fetch articles within boxes. This is the standard way of displaying navigation, gadgets and extra boxes in yacs.

// load the navigation boxes, if any
include_once $context['path_to_root'].'sections/sections.php';
$anchor Sections::lookup('navigation_boxes');
include_once 
$context['path_to_root'].'articles/articles.php';
if(
$items Articles::list_by_date_for_anchor($anchor05'boxes')) {
  foreach(
$items as $title => $content)
    echo 
"<p></p>\n".Skin::build_box($title$content'navigation')."\n";
}


Only articles matching following criteria are returned: or YACS is allowed to show restricted teasers

Voir aussi:

list_by_date_for_author() - List most recent articles for one author

function &list_by_date_for_author($author_id, $offset=0, $count=10, $variant='no_author')

Articles are sorted by edition dates, to let updated articles appear at the top of lists in user pages.

Example:
include_once 'articles/articles.php';
$items Articles::list_by_date_for_author(12010);
$context['text'] .= Skin::build_list($items'decorated');


Only articles matching following criteria are returned:

Voir aussi:

list_by_edition_date() - List most recent updates

function &list_by_edition_date($offset=0, $count=10, $variant='full', $since=NULL)

Actually list articles by edition date, then by title.

Only articles matching following criteria are returned: or YACS is allowed to show restricted teasers or YACS is allowed to show restricted teasers

Voir aussi:

list_by_edition_date_for_anchor() - List most recent updates for one anchor

function &list_by_edition_date_for_anchor($anchor, $offset=0, $count=10, $variant='no_anchor', $capability='?')

Actually list articles by rank, then by edition date, then by title. If you select to not use the ranking system, articles will be ordered by date only. Else articles with a low ranking mark will appear first, and articles with a high ranking mark will be put at the end of the list.

Using edition dates enables updated articles to appear at the top of list in sections.

Only articles matching following criteria are returned: or YACS is allowed to show restricted teasers

Voir aussi:

list_by_expiry_date() - List dead articles

function &list_by_expiry_date($offset=0, $count=10, $variant='full')

This function never lists inactive articles. It is aiming to provide a simple list of the articles for the review page.

Only articles matching following criteria are returned:

Most recent dead pages come first, which is exactly what's expected for the review page.

Voir aussi:

list_by_future_date() - List articles that have been published in the future

function &list_by_future_date($offset=0, $count=10, $variant='full')

Only articles matching following criteria are returned:

Hidden articles, and articles in hidden sections, are not listed at all.

Voir aussi:

list_by_hits() - List most read articles

function &list_by_hits($offset=0, $count=10, $variant='hits')

To build a simple box of the most read articles in your main index page, just use:
include_once 'articles/articles.php';
$items Articles::list_by_hits(0COMPACT_LIST_SIZE);
$context['text'] .= Skin::build_list($items'compact');


You can also display the most read article separately, using Articles::get_most_read() In this case, skip the very first article in the list by using Articles::list_by_hits(1, 10)

Only articles matching following criteria are returned:

Voir aussi:

list_by_hits_for_anchor() - List most read articles for one anchor

function &list_by_hits_for_anchor($anchor, $offset=0, $count=10, $variant='no_anchor', $capability='?')

Only articles matching following criteria are returned: or YACS is allowed to show restricted teasers

Voir aussi:

list_by_hits_for_author() - List most read articles for one author

function &list_by_hits_for_author($author_id, $offset=0, $count=10, $variant='no_author')

To build a simple box of the most read articles on the author page, just use:
include_once 'articles/articles.php';
$items Articles::list_by_hits_for_author(12010);
$context['text'] .= Skin::build_list($items'compact');


Only articles matching following criteria are returned:

Voir aussi:

list_by_oldest_date() - List oldest articles

function &list_by_oldest_date($offset=0, $count=10, $variant='full')

Useful to check the very first pages published.

This function never lists inactive articles. It is aiming to provide a simple list of the articles for the review page.

Only articles matching following criteria are returned:

Namely, hiddent articles, or articles attached to hidden sections, are not listed at all.

Voir aussi:

list_by_title_for_anchor() - List articles by title for one anchor

function &list_by_title_for_anchor($anchor, $offset=0, $count=10, $variant='no_anchor', $capability='?')

Actually list articles by rank, then by title, then by edition date. If you select to not use the ranking system, articles will be ordered by title only. Else articles with a low ranking mark will appear first, and articles with a high ranking mark will be put at the end of the list.

Example:
include_once 'articles/articles.php';
$items Articles::list_by_title_for_anchor('section:12');
$context['text'] .= Skin::build_list($items'decorated');


Use the variant 'boxes' to fetch articles within boxes. This is the standard way of displaying navigation and extra boxes in yacs.

// load the navigation boxes, if any
include_once $context['path_to_root'].'sections/sections.php';
$anchor Sections::lookup('navigation_boxes');
include_once 
$context['path_to_root'].'articles/articles.php';
if(
$items Articles::list_by_title_for_anchor($anchor05'boxes')) {
  foreach(
$items as $title => $content)
    echo 
"<p></p>\n".Skin::build_box($title$content'navigation')."\n";
}


Only articles matching following criteria are returned: or YACS is allowed to show restricted teasers

Voir aussi:

list_randomly() - List some articles randomly

function &list_randomly($count=10, $variant='full')

To build a simple box of random articles in your main index page, just use:
include_once 'articles/articles.php';
$items Articles::list_randomly(10);
$context['text'] .= Skin::build_list($items'decorated');


Only articles matching following criteria are returned:

Voir aussi:

list_selected() - List selected articles

function &list_selected(&$result, $variant='compact', $capability='?')

Accept following layouts:

Voir aussi:

list_unpublished() - List unpublished articles

function &list_unpublished($offset=0, $count=10, $variant='full')

An article is unpublished if its 'publish_date' is empty.

Example:
include_once 'articles/articles.php';
$items Articles::list_unpublished();
$context['text'] .= Skin::build_list($items'decorated');


Only articles matching following criteria are returned:

Articles are ordered by decreasing modification date, which is the expected behaviour for the review page.

Voir aussi:

list_unread() - List articles that are not read

function &list_unread($offset=0, $count=10, $variant='full')

Only articles matching following criteria are returned:

Hidden articles, and articles in hidden sections, are not listed at all.

lookup() - Get the id of one article knowing its nick name

function lookup($nick_name)

post() - Post a new article

function post(&$fields, $capability='?')

On error this function adds a string to $context['error'].

Voir aussi:

put() - Put an updated article in the database

function put(&$fields, $capability='?')



Voir aussi:

rate() - Rate a page

function rate($id, $rating)

Errors are not reported, if any

search() - Search for some keywords in all articles

function &search($pattern, $offset=0, $count=10, $variant='full')

Only articles matching following criteria are returned: or YACS is allowed to show restricted teasers

Voir aussi:

search_in_section() - Search for some keywords articles anchored to one precise section

function &search_in_section($section_id, $pattern, $offset=0, $count=10, $variant='full')

Only articles matching following criteria are returned: or YACS is allowed to show restricted teasers

Voir aussi:

setup() - Create tables for articles

function setup()

stamp() - Stamp an article

function stamp($id, $publication=NULL, $expiry=NULL, $publisher=NULL)

This function is used to change various dates for one article.

* If a publication date is provided, it is saved along the article. An optional expiry date will be saved as well.

* If only an expiry date is provided, it is saved along the article.

* If no date is provided, the review field is updated to the current date and time.

If a publication date is provided, it is assumed to be in the time zone of the surfer, and it is adjusted to the server time zone automatically.

The name of the surfer is registered as the official publisher. As an alternative, publisher attributes ('name', 'id' and 'address') can be provided in parameters.

If an expiration date is provided, it is assumed to be in the time zone of the surfer, and it is adjusted to the server time zone automatically.

Voir aussi:

stat() - Get some statistics

function &stat()

Only articles matching following criteria are returned: or YACS is allowed to show restricted teasers or YACS is allowed to show restricted teasers

Voir aussi:

stat_for_anchor() - Get some statistics for one anchor

function &stat_for_anchor($anchor, $capability='?')

Only articles matching following criteria are returned: or YACS is allowed to show restricted teasers

Voir aussi:

stat_for_author() - Get some statistics for one author

function &stat_for_author($author_id)

Only articles matching following criteria are returned:

Voir aussi:

unpublish() - Unpublish an article

function unpublish($id)

Clear all publihing information

Voir aussi:

Tools
Browse the source of this script
Server software