/codes/links.php
PHP | 369 lines | 221 code | 47 blank | 101 comment | 3 complexity | 08225e1a4a3793683baf57a69393c339 MD5 | raw file
- <?php
- /**
- * examples of formatting codes for links
- *
- * Following codes are documented on this page:
- * - <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>
- * - [<label>|<url>] - <a href="url">label</a> or <a href="url" class="external">label</a>
- * - [link=<label>]<url>[/link] - <a href="url">label</a> or <a href="url" class="external">label</a>
- * - [url]<url>[/url] - deprecated by [link]
- * - [button=<label>]<url>[/button] - build simple buttons with css
- * - <address> - <a href="mailto:address" class="email">address</a>
- * - [email]<address>[/email] - <a href="mailto:address" class="email">address</a>
- * - [email=<name>]<address>[/email] - <a href="mailto:address" class="email">name</a>
- * - [go=<word>] - to trigger the selector on 'word'
- * - [article=<id>] - use article title as link label
- * - [article=<id>, foo bar] - with label 'foo bar'
- * - [article.description=<id>] - insert article description
- * - [next=<id>] - shortcut to next article
- * - [next=<id>, foo bar] - with label 'foo bar'
- * - [previous=<id>] - shortcut to previous article
- * - [previous=<id>, foo bar] - with label 'foo bar'
- * - [random=<section:id>] - pick up one page randomly
- * - [section=<id>] - use section title as link label
- * - [section=<id>, foo bar] - with label 'foo bar'
- * - [category=<id>] - use category title as link label
- * - [category=<id>, foo bar] - with label 'foo bar'
- * - [category.description=<id>] - insert category description
- * - [user=<id>] - use nick name as link label
- * - [user=<id>, foo bar] - with label 'foo bar'
- * - [server=<id>] - use server title as link label
- * - [server=<id>, foo bar] - with label 'foo bar'
- * - [file=<id>] - use file title as link label
- * - [file=<id>, foo bar] - with label 'foo bar'
- * - [download=<id>] - a link to download a file
- * - [download=<id>, foo bar] - with label 'foo bar'
- * - [action=<id>] - use action title as link label
- * - [action=<id>, foo bar] - with label 'foo bar'
- * - [comment=<id>] - use comment id in link label
- * - [comment=<id>, foo bar] - with label 'foo bar'
- * - [decision=<id>] - use decision id in link label
- * - [decision=<id>, foo bar] - with label 'foo bar'
- * - [script]<path/script.php>[/email] - to the phpDoc page for script 'path/script.php'
- * - [search] - a search form
- * - [search=<word>] - hit Enter to search for 'word'
- * - [wikipedia=<keyword] - search Wikipedia
- * - [wikipedia=<keyword, foo bar] - search Wikipedia, with label 'foo bar'
- *
- * @see codes/index.php
- *
- * @author Bernard Paques
- * @author GnapZ
- * @reference
- * @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License
- */
- // common definitions and initial processing
- include_once '../shared/global.php';
- // load localized strings
- i18n::bind('codes');
- // load the skin
- load_skin('codes');
- // default section
- $section_id = Sections::get_default();
- // newest article
- $article_id = 1;
- if($item =& Articles::get_newest_for_anchor(NULL, TRUE))
- $article_id = $item['id'];
- // newest file
- $file_id = 1;
- if($item =& Files::get_newest())
- $file_id = $item['id'];
- // the path to this page
- $context['path_bar'] = array( 'help/' => i18n::s('Help index'),
- 'codes/' => i18n::s('Formatting Codes') );
- // the title of the page
- $context['page_title'] = i18n::s('Codes to format links');
- // the date of last modification
- if(Surfer::is_associate())
- $context['page_details'] .= '<p class="details">'.sprintf(i18n::s('Edited %s'), Skin::build_date(getlastmod())).'</p>';
- // page header
- $context['text'] .= '<p>'.i18n::s('Various methods are presented to link your pages to others.').'</p>';
- // add a toc
- $context['text'] .= "\n".'[toc]'."\n";
- // url
- $context['text'] .= '[title]'.i18n::s('External link').' [escape]<url>[/escape][/title]'
- .Skin::table_prefix('wide')
- .Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header')
- .'<tr><td class="sample">[escape]'.i18n::s('You can visit www.cisco.com or http://www.nortel.com, or have a chat at irc://irc.eu.be.ofloo.net/').'[/escape]</td>'
- .'<td>'.i18n::s('You can visit www.cisco.com or http://www.nortel.com, or have a chat at irc://irc.eu.be.ofloo.net/').'</td></tr>'
- .Skin::table_suffix();
- // [link]url[/link] - external
- $context['text'] .= '[title]'.i18n::s('External link').' [escape][link]<url>[/link][/escape][/title]'
- .Skin::table_prefix('wide')
- .Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header')
- .'<tr><td class="sample">[escape]'.i18n::s('You can visit [link]www.cisco.com[/link] or [link]http://www.nortel.com[/link], or have a chat at [link]irc://irc.eu.be.ofloo.net/[/link]').'[/escape]</td>'
- .'<td>'.i18n::s('You can visit [link]www.cisco.com[/link] or [link]http://www.nortel.com[/link], or have a chat at [link]irc://irc.eu.be.ofloo.net/[/link]').'</td></tr>'
- .Skin::table_suffix();
- // YouTube link
- $context['text'] .= '[title]'.i18n::s('YouTube link').' [escape]http://www.youtube.com/watch?v=Qo7vUdKTlhk[/escape][/title]'
- .Skin::table_prefix('wide')
- .Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header')
- .'<tr><td class="sample">[escape]http://www.youtube.com/watch?v=Qo7vUdKTlhk[/escape]</td>'
- .'<td>http://www.youtube.com/watch?v=Qo7vUdKTlhk</td></tr>'
- .Skin::table_suffix();
- // [link]url[/link] - internal
- $context['text'] .= '[title]'.i18n::s('Internal link').' [escape][link]<url>[/link][/escape][/title]'
- .Skin::table_prefix('wide')
- .Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header')
- .'<tr><td class="sample">[escape]'.i18n::s('You can visit [link]codes/basic.php[/link] or [link]index.php[/link]').'[/escape]</td>'
- .'<td>'.i18n::s('You can visit [link]codes/basic.php[/link] or [link]index.php[/link]').'</td></tr>'
- .Skin::table_suffix();
- // [label|url]
- $context['text'] .= '[title]'.i18n::s('Labelled link').' [escape][<label>|<url>][/escape][/title]'
- .Skin::table_prefix('wide')
- .Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header')
- .'<tr><td class="sample">[escape]'.i18n::s('You can visit [Cisco On Line|www.cisco.com]').'[/escape]</td>'
- .'<td>'.i18n::s('You can visit [Cisco On Line|www.cisco.com]').'</td></tr>'
- .Skin::table_suffix();
- // [link=label]url[/link]
- $context['text'] .= '[title]'.i18n::s('Labelled link').' [escape][link=<label>]<url>[/link][/escape][/title]'
- .Skin::table_prefix('wide')
- .Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header')
- .'<tr><td class="sample">[escape]'.i18n::s('You can visit [link=Cisco On Line]www.cisco.com[/link]').'[/escape]</td>'
- .'<td>'.i18n::s('You can visit [link=Cisco On Line]www.cisco.com[/link]').'</td></tr>'
- .Skin::table_suffix();
- // [button=label|url]
- $context['text'] .= '[title]'.i18n::s('Labelled button').' [escape][button=<label>|<url>][/escape][/title]'
- .Skin::table_prefix('wide')
- .Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header')
- .'<tr><td class="sample">[escape]'.i18n::s('You can visit [button=Cisco On Line|www.cisco.com]').'[/escape]</td>'
- .'<td>'.i18n::s('You can visit [button=Cisco On Line|www.cisco.com]').'</td></tr>'
- .Skin::table_suffix();
- // [click=label|url] [clicks=url]
- $context['text'] .= '[title]'.i18n::s('Member clicks').' [escape][click=<label>|<url>] [clicks=<url>][/escape][/title]'
- .Skin::table_prefix('wide')
- .Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header')
- .'<tr><td class="sample">[escape]'.i18n::s('You can visit [click=Cisco On Line|http://www.cisco.com] [folded][clicks=http://www.cisco.com][/folded]').'[/escape]</td>'
- .'<td>'.i18n::s('You can visit [click=Cisco On Line|http://www.cisco.com] [folded][clicks=http://www.cisco.com][/folded]').'</td></tr>'
- .Skin::table_suffix();
- // address
- $context['text'] .= '[title]'.i18n::s('e-mail address').' [escape]<address>[/escape][/title]'
- .Skin::table_prefix('wide')
- .Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header')
- .'<tr><td class="sample">[escape]'.i18n::s('You can send a message at webmaster@acme.com').'[/escape]</td>'
- .'<td>'.i18n::s('You can send a message at webmaster@acme.com').'</td></tr>'
- .Skin::table_suffix();
- // [email]address[/email]
- $context['text'] .= '[title]'.i18n::s('e-mail address').' [escape][email]<address>[/email][/escape][/title]'
- .Skin::table_prefix('wide')
- .Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header')
- .'<tr><td class="sample">[escape]'.i18n::s('You can send a message at [email]webmaster@acme.com[/email]').'[/escape]</td>'
- .'<td>'.i18n::s('You can send a message at [email]webmaster@acme.com[/email]').'</td></tr>'
- .Skin::table_suffix();
- // [email=label]address[/email]
- $context['text'] .= '[title]'.i18n::s('Labelled e-mail address').' [escape][email=<label>]<address>[/email][/escape][/title]'
- .Skin::table_prefix('wide')
- .Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header')
- .'<tr><td class="sample">[escape]'.i18n::s('You can send a message to our [email=support team]webmaster@acme.com[/email]').'[/escape]</td>'
- .'<td>'.i18n::s('You can send a message to our [email=support team]webmaster@acme.com[/email]').'</td></tr>'
- .Skin::table_suffix();
- // [go=monthly, monthly archive]
- $context['text'] .= '[title]'.i18n::s('Selector').' [escape][go=<name>, <label>][/escape][/title]'
- .Skin::table_prefix('wide')
- .Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header')
- .'<tr><td class="sample">[escape]'.i18n::s('Please use our [go=monthly, monthly archive] for reference').'[/escape]</td>'
- .'<td>'.i18n::s('Please use our [go=monthly, monthly archive] for reference').'</td></tr>'
- .Skin::table_suffix();
- // [[monthly, monthly archive]]
- $context['text'] .= '[title]'.i18n::s('Selector').' [escape][[<name>, <label>]][/escape][/title]'
- .Skin::table_prefix('wide')
- .Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header')
- .'<tr><td class="sample">[escape]'.i18n::s('Please use our [[monthly, monthly archive]] for reference').'[/escape]</td>'
- .'<td>'.i18n::s('Please use our [[monthly, monthly archive]] for reference').'</td></tr>'
- .Skin::table_suffix();
- // [article=id]
- $context['text'] .= '[title]'.i18n::s('Page shortcut').' [escape][article=<id>][/escape][/title]'
- .Skin::table_prefix('wide')
- .Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header')
- .'<tr><td class="sample">[escape]'.sprintf(i18n::s('Have a look at %s'), '[article='.$article_id.']').'[/escape]</td>'
- .'<td>'.sprintf(i18n::s('Have a look at %s'), '[article='.$article_id.']').'</td></tr>'
- .Skin::table_suffix();
- // [article=id, label]
- $context['text'] .= '[title]'.i18n::s('Page shortcut').' [escape][article=<id>, <label>][/escape][/title]'
- .Skin::table_prefix('wide')
- .Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header')
- .'<tr><td class="sample">[escape]'.sprintf(i18n::s('Have a look at %s'), '[article='.$article_id.', bla bla bla]').'[/escape]</td>'
- .'<td>'.sprintf(i18n::s('Have a look at %s'), '[article='.$article_id.', bla bla bla]').'</td></tr>'
- .Skin::table_suffix();
- // [article.description=id]
- $context['text'] .= '[title]'.i18n::s('Page').' [escape][article.description=<id>][/escape][/title]'
- .Skin::table_prefix('wide')
- .Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header')
- .'<tr><td class="sample">[escape][article.description='.$article_id.'][/escape]</td>'
- .'<td>[article.description='.$article_id.']</td></tr>'
- .Skin::table_suffix();
- // [previous=id]
- $context['text'] .= '[title]'.i18n::s('Previous page').' [escape][previous=<id>] [previous=<id>, <label>][/escape][/title]'
- .Skin::table_prefix('wide')
- .Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header')
- .'<tr><td class="sample">[escape][previous='.$article_id.'][/escape]</td>'
- .'<td>[previous='.$article_id.']</td></tr>'
- .Skin::table_suffix();
- // [next=id]
- $context['text'] .= '[title]'.i18n::s('Next page').' [escape][next=<id>] [next=<id>, <label>][/escape][/title]'
- .Skin::table_prefix('wide')
- .Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header')
- .'<tr><td class="sample">[escape][next='.$article_id.'][/escape]</td>'
- .'<td>[next='.$article_id.']</td></tr>'
- .Skin::table_suffix();
- // [random=section:id]
- $context['text'] .= '[title]'.i18n::s('Random').' [escape][random] [random=section:<id>][/escape][/title]'
- .Skin::table_prefix('wide')
- .Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header')
- .'<tr><td class="sample">[escape][random] [random=section:'.$section_id.'][/escape]</td>'
- .'<td>[random] [random=section:'.$section_id.']</td></tr>'
- .Skin::table_suffix();
- // [section=id]
- $context['text'] .= '[title]'.i18n::s('Section shortcut').' [escape][section=<id>] [section=<id>, <label>][/escape][/title]'
- .Skin::table_prefix('wide')
- .Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header')
- .'<tr><td class="sample">[escape]'.sprintf(i18n::s('Have a look at %s'), '[section='.$section_id.']').'[/escape]</td>'
- .'<td>'.sprintf(i18n::s('Have a look at %s'), '[section='.$section_id.']').'</td></tr>'
- .Skin::table_suffix();
- // [category=id]
- $context['text'] .= '[title]'.i18n::s('Category shortcut').' [escape][category=<id>] [category=<id>, <label>][/escape][/title]'
- .Skin::table_prefix('wide')
- .Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header')
- .'<tr><td class="sample">[escape]'.sprintf(i18n::s('Have a look at %s'), '[category=featured]').'[/escape]</td>'
- .'<td>'.sprintf(i18n::s('Have a look at %s'), '[category=featured]').'</td></tr>'
- .Skin::table_suffix();
- // [category.description=id]
- $context['text'] .= '[title]'.i18n::s('Category').' [escape][category.description=<id>][/escape][/title]'
- .Skin::table_prefix('wide')
- .Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header')
- .'<tr><td class="sample">[escape][category.description=featured][/escape]</td>'
- .'<td>[category.description=featured]</td></tr>'
- .Skin::table_suffix();
- // [user=id]
- $context['text'] .= '[title]'.i18n::s('User shortcut').' [escape][user=<id>] [user=<id>, <label>][/escape][/title]'
- .Skin::table_prefix('wide')
- .Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header')
- .'<tr><td class="sample">[escape]'.sprintf(i18n::s('Have a look at %s'), '[user='.Surfer::get_id().']').'[/escape]</td>'
- .'<td>'.sprintf(i18n::s('Have a look at %s'), '[user='.Surfer::get_id().']').'</td></tr>'
- .Skin::table_suffix();
- // [server=id]
- $context['text'] .= '[title]'.i18n::s('Server shortcut').' [escape][server=<id>] [server=<id>, <label>][/escape][/title]'
- .Skin::table_prefix('wide')
- .Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header')
- .'<tr><td class="sample">[escape]'.i18n::s('Click to view the page of [server=2, this server]').'[/escape]</td>'
- .'<td>'.i18n::s('Click to view the page of [server=2, this server]').'</td></tr>'
- .Skin::table_suffix();
- // [file=id]
- $context['text'] .= '[title]'.i18n::s('File shortcut').' [escape][file=<id>] [file=<id>, <label>][/escape][/title]'
- .Skin::table_prefix('wide')
- .Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header')
- .'<tr><td class="sample">[escape]'.sprintf(i18n::s('Have a look at %s'), '[file='.$file_id.']').'[/escape]</td>'
- .'<td>'.sprintf(i18n::s('Have a look at %s'), '[file='.$file_id.']').'</td></tr>'
- .Skin::table_suffix();
- // [download=id]
- $context['text'] .= '[title]'.i18n::s('Download shortcut').' [escape][download=<id>] [download=<id>, <label>][/escape][/title]'
- .Skin::table_prefix('wide')
- .Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header')
- .'<tr><td class="sample">[escape]'.sprintf(i18n::s('Click to %s'), '[download='.$file_id.', '.i18n::s('download the file').']').'[/escape]</td>'
- .'<td>'.sprintf(i18n::s('Click to %s'), '[download='.$file_id.', '.i18n::s('download the file').']').'</td></tr>'
- .Skin::table_suffix();
- // [clicks=id]
- $context['text'] .= '[title]'.i18n::s('Member clicks').' [escape][clicks=<id>][/escape][/title]'
- .Skin::table_prefix('wide')
- .Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header')
- .'<tr><td class="sample">[escape][clicks='.$file_id.'][/escape]</td>'
- .'<td>[clicks='.$file_id.']</td></tr>'
- .Skin::table_suffix();
- // [action=id]
- $context['text'] .= '[title]'.i18n::s('Action shortcut').' [escape][action=<id>] [action=<id>, <label>][/escape][/title]'
- .Skin::table_prefix('wide')
- .Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header')
- .'<tr><td class="sample">[escape]'.i18n::s('Click to view the page of [action=2, this action]').'[/escape]</td>'
- .'<td>'.i18n::s('Click to view the page of [action=2, this action]').'</td></tr>'
- .Skin::table_suffix();
- // [comment=id]
- $context['text'] .= '[title]'.i18n::s('Comment shortcut').' [escape][comment=<id>] [comment=<id>, <label>][/escape][/title]'
- .Skin::table_prefix('wide')
- .Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header')
- .'<tr><td class="sample">[escape]'.i18n::s('Click to view the page of [comment=2, this comment]').'[/escape]</td>'
- .'<td>'.i18n::s('Click to view the page of [comment=2, this comment]').'</td></tr>'
- .Skin::table_suffix();
- // [decision=id]
- $context['text'] .= '[title]'.i18n::s('Decision shortcut').' [escape][decision=<id>] [decision=<id>, <label>][/escape][/title]'
- .Skin::table_prefix('wide')
- .Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header')
- .'<tr><td class="sample">[escape]'.i18n::s('Click to view the page of [decision=2, this decision]').'[/escape]</td>'
- .'<td>'.i18n::s('Click to view the page of [decision=2, this decision]').'</td></tr>'
- .Skin::table_suffix();
- // [script]index.php[/script]
- $context['text'] .= '[title]'.i18n::s('Script shortcut').' [escape][script]<path/script.php>[/script][/escape][/title]'
- .Skin::table_prefix('wide')
- .Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header')
- .'<tr><td class="sample">[escape]'.i18n::s('You can access the documentation for the script [script]shared/codes.php[/script]').'[/escape]</td>'
- .'<td>'.i18n::s('You can access the documentation for the script [script]shared/codes.php[/script]').'</td></tr>'
- .Skin::table_suffix();
- // [search=yacs]
- $context['text'] .= '[title]'.i18n::s('Search').' [escape][search] [search=<words>][/escape][/title]'
- .Skin::table_prefix('wide')
- .Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header')
- .'<tr><td class="sample">[escape]'.i18n::s('All you want to know on [search=yacs]').'[/escape]</td>'
- .'<td>'.i18n::s('All you want to know on [search=yacs]').'</td></tr>'
- .Skin::table_suffix();
- // [wikipedia=keyword, label]
- $context['text'] .= '[title]'.i18n::s('Wikipedia').' [escape][wikipedia=keyword] [wikipedia=keyword, label][/escape][/title]'
- .Skin::table_prefix('wide')
- .Skin::table_row(array(i18n::s('Example'), i18n::s('Rendering')), 'header')
- .'<tr><td class="sample">[escape]'.i18n::s('All you want to know on [wikipedia=Web_2, the web 2.0]').'[/escape]</td>'
- .'<td>'.i18n::s('All you want to know on [wikipedia=Web_2, the web 2.0]').'</td></tr>'
- .Skin::table_suffix();
- // transform the text
- $context['text'] = Codes::beautify($context['text']);
- // general help on this page
- $help = '<p>'.sprintf(i18n::s('Please note that actual rendering depends on the selected %s.'), Skin::build_link('skins/', i18n::s('skin'), 'shortcut')).'</p>';
- $context['components']['boxes'] = Skin::build_box(i18n::s('Help'), $help, 'boxes', 'help');
- // render the skin
- render_skin();
- ?>