1 | [(#REM) |
---|
2 | /********************************************************************************** |
---|
3 | * @Subject pgn.html skeleton template to manage .pgn file attached to the SPIP article |
---|
4 | * @package pgn4spip: Embed pgn4web Chessboard plugin for SPIP 2.x or 3.x |
---|
5 | * @version 2.61.0 |
---|
6 | * @copyright copyright (c) 2012 Matt Chesstale |
---|
7 | * @license GNU General Public License version 3 |
---|
8 | * @language SPIP loop embedding PHP |
---|
9 | * |
---|
10 | * @history |
---|
11 | * 2.61.0: Initial version for SPIP 2.1 |
---|
12 | * @reference: Using models: http://www.spip.net/en_article3512.html |
---|
13 | * Utiliser les modèles : http://www.spip.net/fr_article3454.html |
---|
14 | * @Usage |
---|
15 | * If <doc1> is the document of number 1 associated to the downloaded .pgn file, |
---|
16 | * use in the article the syntax: <pgn1|option="prm1=value1 prm2=value2 ..."> |
---|
17 | * |
---|
18 | * @Example In a SPIP article: |
---|
19 | * Example 1: <pgn1> |
---|
20 | * Example 2: <pgn1|option="movesDisplay=puzzle"> |
---|
21 | * Example 3: <pgn1|option="md=p"> |
---|
22 | * with md = movesDisplay and p = puzzle |
---|
23 | * @Caution the options eo = extendedoptions and pd = pgnData are not allowed |
---|
24 | * @Return HTML code of the iframe to run board.html with the indicated .pgn document |
---|
25 | **********************************************************************************/ |
---|
26 | ] |
---|
27 | <BOUCLE_pgn(DOCUMENTS){id_document=#ENV{id}}{extension==pgn}{tout}> |
---|
28 | <?php |
---|
29 | define('PLUGIN_Name', "pgn4spip"); |
---|
30 | define('PATH_Fonctions', PLUGIN_Name . '/' . PLUGIN_Name . '_fonctions.php'); |
---|
31 | if (!function_exists('pgn4spip_prepropre')) require _DIR_PLUGINS . PATH_Fonctions; |
---|
32 | |
---|
33 | define('QUOTE_HTML', '"'); // '"' in HTML |
---|
34 | define('LenQuote', 6); |
---|
35 | |
---|
36 | $UrlRoot = '[(#URL_SITE_SPIP)]'; // Absolute URL of the SPIP web site root |
---|
37 | $UrlPgn = '[(#URL_DOCUMENT)]'; // Unique document having the id given as parameter of template from the SPIP loop |
---|
38 | while ((strlen($UrlPgn) > 1) && ($UrlPgn[0] == '.')) |
---|
39 | $UrlPgn = substr($UrlPgn, 1); // Remove relative dot |
---|
40 | |
---|
41 | if ($UrlPgn[0] != '/') $UrlPgn = '/' . $UrlPgn; |
---|
42 | $option = '[(#ENV{option})]'; // Get the options after "|" in the template <pgn1|option=...> |
---|
43 | $lenOpt = strlen($option); |
---|
44 | if ($lenOpt > LenQuote * 2) |
---|
45 | { |
---|
46 | if (substr($option, 0, LenQuote) == QUOTE_HTML) |
---|
47 | $option = substr($option, LenQuote); // Remove first double quote coded in HTML |
---|
48 | $lenOpt = $lenOpt - LenQuote; |
---|
49 | if (($lenOpt > LenQuote) && (substr($option, $lenOpt- LenQuote, LenQuote) == QUOTE_HTML)) |
---|
50 | { |
---|
51 | $lenOpt = $lenOpt - LenQuote; |
---|
52 | $option = substr($option, 0, $lenOpt); // Remove last double quote |
---|
53 | } |
---|
54 | } |
---|
55 | if ($lenOpt > 0) $option .= ' '; // Separator with the two last options |
---|
56 | $option .= 'eo=true pd=' . $UrlRoot . $UrlPgn; // eo = extendedoptions; pd = pgnData |
---|
57 | echo pgn4spip_prepropre('[pgn ' . $option . '][/pgn]'); |
---|
58 | ?> |
---|
59 | </BOUCLE_pgn> |
---|