Home « Server software «
Documentation: codes/codes.php
Class Codes - Transform some text containing UBB-like code sequences.
This module uses the Skin class for the actual rendering.Basic codes, demonstrated into codes/basic.php:
- ... - wiki bold text
- [b]...[/b] - bold text
- //...// - italics
- [i]...[/i] - italics
- ... - underlined
- [u]...[/u] - underlined
...
- monospace- [code]...[/code] - a short sample of fixed-size text (e.g. a file name)
- [color]...[/color] - change font color
- [tiny]...[/tiny] - tiny size
- [small]...[/small] - small size
- [big]...[/big] - big size
- [huge]...[/huge] - huge size
- [subscript]...[/subscript] - subscript
- [superscript]...[/superscript] - superscript
- +...+ - inserted
- [inserted]...[/inserted] - inserted
- ---...--- - deleted
- [deleted]...[/deleted] - deleted
- [flag]...[/flag] - draw attention
- [style=sans-serif]...[/style] - use a sans-serif font
- [style=serif]...[/style] - use a serif font
- [style=cursive]...[/style] - mimic hand writing
- [style=comic]...[/style] - make it funny
- [style=fantasy]...[/style] - guess what will appear
- [style=my_style]...[/style] - translated to <span class="my_style">...</span>
Block codes, demonstrated in codes/blocks.php:
- [indent]...[/indent] - shift text to the right
- [center]...[/center] - some centered text
- [right]...[/right] - some right-aligned text
- [decorated]...[/decorated] - some pretty paragraphs
- [caution]...[/caution] - a warning paragraph
- [note]...[/note] - a noticeable paragraph
- [php]...
- [snippet]...
- [quote]...[/quote] - a block of quoted text
- [folder]...[/folder] - click to view its content, or to fold it away
- [folder=foo bar]...[/folder] - with title 'foo bar'
- [sidebar]...[/sidebar] - a nice box aside
- [sidebar=foo bar]...[/sidebar] - with title 'foo bar'
- [scroller]...[/scroller] - some scrolling text
List codes, demonstrated in codes/lists.php:
- [*] - for simple lists
- [list]...
- [list=1]...
- [list=a]...
- [list=A]...
- [list=i]...
- [list=I]...
Codes for links, demonstrated in codes/links.php:
- <url> - <a href="url">url</a> or <a href="url" class="external">url</a>
- [link]<url>[/link] - <a href="url">url</a> or <a href="url" class="external">url</a>
- [link=<label>]<url>[/link] - <a href="url">label</a> or <a href="url" class="external">label</a>
- [url]<url>[/url] - deprecated by /li_li_[url=<url>]<label>[/url]_-_deprecated_by_[link]_/li_li_[button=<label>]<url>[/button]_-_build_simple_buttons_with_css_/li_li_<address>_-_<a_href=_mailto:address_class=_email_address</a_/li_li_[email]<address>[/email]_-_<a_href=_mailto:address_class=_email_address</a_/li_li_[email=<name>]<address>[/email]_-_<a_href=_mailto:address_class=_email_name</a_/li_li_[go=<name>,_<label>]_-_trigger_the_selector_on_name_/li_li_[article=<id_]_-_use_article_title_as_link_label_/li_li_[article=<id_,_foo_bar]_-_with_label_foo_bar_/li_li_[next=<id_]_-_shortcut_to_next_article_/li_li_[next=<id_,_foo_bar]_-_with_label_foo_bar_/li_li_[previous=<id_]_-_shortcut_to_previous_article_/li_li_[previous=<id_,_foo_bar]_-_with_label_foo_bar_/li_li_[section=<id_]_-_use_section_title_as_link_label_/li_li_[section=<id_,_foo_bar]_-_with_label_foo_bar_/li_li_[category=<id_]_-_use_category_title_as_link_label_/li_li_[category=<id_,_foo_bar]_-_with_label_foo_bar_/li_li_[decision=<id_]_-_use_decision_id_in_link_label_/li_li_[decision=<id_,_foo_bar]_-_with_label_foo_bar_/li_li_[user=<id_]_-_use_nick_name_as_link_label_/li_li_[user=<id_,_foo_bar]_-_with_label_foo_bar_/li_li_[server=<id_]_-_use_server_title_as_link_label_/li_li_[server=<id_,_foo_bar]_-_with_label_foo_bar_/li_li_[file=<id_]_-_use_file_title_as_link_label_/li_li_[file=<id_,_foo_bar]_-_with_label_foo_bar_/li_li_[download=<id_]_-_a_link_to_download_a_file_/li_li_[download=<id_,_foo_bar]_-_with_label_foo_bar_/li_li_[comment=<id_]_-_use_comment_id_in_link_label_/li_li_[comment=<id_,_foo_bar]_-_with_label_foo_bar_/li_li_[script]<path/script.php>[/script]_-_to_the_phpDoc_page_for_script_path/script.php_/li_li_[search]_-_a_search_form_/li_li_[search=<word>]_-_hit_Enter_to_search_for_word_/li_li_[login]_-_a_login_form_to_be_used_in_menus_/li_li_[action=<id_]_-_use_action_title_as_link_label_/li_li_[action=<id_,_foo_bar]_-_with_label_foo_bar_/li_/ul_Titles_and_questions,_demonstrated_in_[link]codes/titles.php:
- [toc] - table of contents
- [title]...[/title] - a level 1 headline, put in the table of contents
- [subtitle]...[/subtitle] - a level 2 headline
- [header1]...[/header1] - a level 1 headline
- [header2]...[/header2] - a level 2 headline
- [header3]...[/header3] - a level 3 headline
- [header4]...[/header4] - a level 4 headline
- [header5]...[/header5] - a level 5 headline
- [toq] - the table of questions for this page
- [question]...[/question] - a question-title
- [question] - a simple question
- [answer] - some answer in a FAQ
Tables, demonstrated in codes/tables.php:- [table]...[/table] - one simple table
- [table=grid]...[/table] - add a grid
- [table].[body].[/table] - a table with headers
- [csv]...[/csv] - import some data from Excel
- [csv=;]...[/csv] - import some data from Excel
Miscellaneous codes, demonstrated in codes/misc.php:- [published] - most recent published pages, in a compact list
- [published=section:<id>] - articles published most recently in the given section
- [published=category:<id>] - articles published most recently in the given category
- [published=user:<id>] - articles published most recently created by given user
- [read] - most read articles, in a compact list
- [read=section:<id>] - articles of fame in the given section
- [edited] - most recent edited pages, in a compact list
- [edited=section:<id>] - articles edited most recently in the given section
- [edited=category:<id>] - articles edited most recently in the given category
- [edited=user:<id>] - articles edited most recently created by given user
- [commented] - most fresh threads, in a compact list
- [commented=section:<id>] - articles commented most recently in the given section
- [contributed] - most contributed articles, in a compact list
- [contributed=section:<id>] - most contributed articles in the given section
- [hint=<help popup]...[/hint] - <acronym tite="help popup">...</acronym>
- [nl] - new line
- [---] or [___] - horizontal rule
- [new] - something new
- [updated] - something updated
- [popular] - people love it
- [be] - country flag
- [ca] - country flag
- [ch] - country flag
- [de] - country flag
- [en] - country flag
- [es] - country flag
- [fr] - country flag
- [gb] - country flag
- [gr] - country flag
- [it] - country flag
- [pt] - country flag
- [us] - country flag
In-line elements:- [flash=<id>, width, height] - play a Flash object
- [image=<id>] - an inline image
- [image=<id>,left] - a left-aligned image
- [image=<id>,center] - a centered image
- [image=<id>,right] - a right-aligned image
- [image]src[/image]
- [image=<alt>]src[/image]
- [img]src[/img] (deprecated)
- [img=<alt>]src[/img] (deprecated)
- [table=<id>] - an inline table
- [location=<id>] - use location title as link label
- [location=<id>, foo bar] - with label 'foo bar'
- [clear] - to introduce breaks after floating elements
Other codes:- [menu=label]url[/menu] -> one of the main menu command
- [submenu=label]url[/submenu] -> one of the second-level menu commands
- [escape]...
- [anonymous]...[/anonymous] -> for non-logged people only
- [restricted]...[/restricted] -> for logged members only
- [hidden]...[/hidden] -> for associates only
This script attempts to fight bbCode code injections by filtering strings to be used assrc
or ashref
attributes (Thank you Mordread).
Tip: If you have to check for the loading of the rendering engine, use following code:if(is_callable(array('Codes', 'beautify')))
$text = Codes::beautify($text);This script is a reference file of this system.
Voir aussi:
- codes/basic.php
- codes/blocks.php
- codes/lists.php
- codes/links.php
- codes/titles.php
- codes/tables.php
- codes/misc.php
Licence: GNU Lesser General Public License
Auteurs:
- Bernard Paques bernard.paques@bigfoot.com
- Mordread Wallas
- GnapZ
Testeurs:
- Viviane Zaniroli
- Agnes
- Pat
- Guillaume Perez
Reste à faire:
- replace marquee with our own customizable scroller
- WiKi rendering
beautify() - Beautify some text for final rendering
function &beautify($text, $options='')
- $text - string the text to beautify
- $options='' - string the set of options that apply to this text
- returns the beautified text
- implicit formatting
- formatting codes
- smileys
If the keyword[formatted]
appears at the first line of text, or if options have the keywordformatted
, no implicit formatting is performed.
If the keyword[hardcoded]
appears at the first line of text, or if options have the keywordhardcoded
, the only transformation is is new lines to breaks.Voir aussi:
beautify_implied() - Render some basic formatting
function &beautify_implied($text, $variant='text')
- $text - string the text to transform
- $variant='text' - sring either 'text' or 'newlines'
- returns the modified string
- suppress multiple newlines
- render empty lines
- render simple bulleted lines
- make URL clickable (http://..., www.foo.bar, foo.bar@foo.com)
Now this function looks for the keyword [escape] in order to avoid for formatting pre-formatted areas.
For example, if you type:hello
world
how are
you doing?
- my first item
- my second item
> quoted from
> a previous message
This will be rendered visually in the browser as:hello world
how are you doing?
- my first item
- my second item
> quoted from
> a previous messageclean_href() - Clean strings to be used in src or in href attributes
function &clean_href($text)
- $text - the input string
- returns the safe string
initialize() - Reset global variables used for rendering
function initialize($main_target=NULL)
- $main_target=NULL - string the target URL for this rendering (e.g., 'articles/view.php/123')
render() - Transform codes to html
function &render($text)
- $text - string the input string
- returns string the transformed string
// build the page
$context['text'] .= ...
// transform codes
$context['text'] = Codes::render($context['text']);
// final rendering
render_skin();render_animated() - Render an animated block of text
function &render_animated($text, $variant)
- $text - string the text
- $variant - string the variant
- returns string the rendered text
render_commented() - Render a compact list of fresh threads
function &render_commented($anchor='')
- $anchor='' - string the anchor (e.g. 'section:123')
- returns string the rendered text
render_contributed() - Render a compact list of most active threads
function &render_contributed($anchor='')
- $anchor='' - string the anchor (e.g. 'section:123')
- returns string the rendered text
render_email() - Render an email address
function &render_email($address, $text)
- $address - string the address
- $text - string the label
- returns string the rendered text
render_escaped() - Escape code sequences
function &render_escaped($text)
- $text - string the text
- returns string the rendered text
render_hidden() - Render or not some text
function &render_hidden($text, $variant)
- $text - string the text
- $variant - either 'anonymous', or 'restricted' or 'hidden'
- returns string the rendered text
render_link() - Render a web link
function &render_link($url, $label=NULL)
- $url - string the url as typed by the surfer
- $label=NULL - string the related label, if any
- returns string the rendered text
- 'www.foo.bar' becomes 'http://www.foo.bar/'
- 'anything@foo.bar' becomes 'mailto:anything@foo.bar'
render_list() - Render a list
function &render_list($content, $variant='')
- $content - string the list content
- $variant='' - string the variant, if any
- returns string the rendered text
render_news() - Render some animated news
function &render_news($variant)
- $variant - string the variant - default is 'flash'
- returns string the rendered text
render_object() - Render a link to an object
function &render_object($type, $id)
- $type - string the type
- $id - string the id, with possible options or variant
- returns string the rendered text
- action - link to an action page
- article - link to an article page
- category - link to a category page
- comment - link to a comment page
- decision - link to a decision page
- download - link to a download page
- file - link to a file page
- flash - display a file as a native flash object, or play a flash video
- go
- image - display an in-line image
- location - display some location on a map
- next - link to an article page
- previous - link to an article page
- section - link to a section page
- server - link to a server page
- user - link to a user page
render_pre() - Render a block of code
function &render_pre($text, $variant='snippet')
- $text - string the text
- $variant='snippet' -
- returns string the rendered text
render_published() - Render a compact list of recent publications
function &render_published($anchor='')
- $anchor='' - string the anchor (e.g. 'section:123')
- returns string the rendered text
- a section 'section:123'
- a category 'category:456'
- a user 'user:789'
- nothing
render_read() - Render a compact list of hits
function &render_read($anchor='')
- $anchor='' - string the anchor (e.g. 'section:123')
- returns string the rendered text
render_table() - Render a table
function render_table($content, $variant='')
- $content - string the table content
- $variant='' - string the variant, if any
- returns string the rendered text
render_table_of() - Render a table of links
function &render_table_of($variant)
- $variant - string the variant
- returns string the rendered text
render_title() - Render a title, a sub-title, or a question
function &render_title($text, $variant)
- $text - string the text
- $variant - string the variant
- returns string the rendered text
render_updated() - Render a compact list of recent modifications
function &render_updated($anchor='')
- $anchor='' - string the anchor (e.g. 'section:123')
- returns string the rendered text
- a section 'section:123'
- a category 'category:456'
- a user 'user:789'
- nothing
strip() - Remove YACS codes from a string
function &strip($text)
- $text - string embedding YACS codes
- returns a purged string