pluf2

pluf2 Git Source Tree


Root/src/Pluf/Text/Wiki/Configuration.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<?php
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
# ***** BEGIN LICENSE BLOCK *****
# This file is part of Plume Framework, a simple PHP Application Framework.
# Copyright (C) 2001-2007 Loic d'Anterroches and contributors.
#
# Plume Framework is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# Plume Framework is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
#
# ***** END LICENSE BLOCK ***** */
 
/*
 * Based on Wiki Renderer copyright (C) 2003-2004 Laurent Jouanneau
 */
 
/**
 * Default Wiki Renderer configuration.
 */
class Pluf_Text_Wiki_Configuration
{
    /**
     * @var array   liste des tags inline
     */
    public $inlinetags = array(
         'strong' => array('__','__',     
                           null,null),
         'em'     => array('\'\'','\'\''
                           null,null),
         'code'   => array('@@','@@',     
                           null,null),
         'q'      => array('^^','^^',     
                           array('lang','cite'), null),
         'cite'   => array('{{','}}',     
                           array('title'), null),
         'acronym'=> array('??','??',     
                           array('title'), null),
         'link'   => array('[',']',       
                           array('href','hreflang','title'),
                           'Pluf_Text_Wiki_Configuration_buildlink'),
         'image'  => array('((','))',     
                           array('src','alt','align','longdesc'),
                           'Pluf_Text_Wiki_Configuration_buildimage'),
         'anchor' => array('~~','~~',     
                           array('name'),
                           'Pluf_Text_Wiki_Configuration_buildanchor')
         );
 
    /**
     * liste des balises de type bloc autoris�es.  Attention, ordre
     * important (p en dernier, car c'est le bloc par defaut..)
     */
 
    public $bloctags = array(
        'Pluf_Text_Wiki_Block_Title' => true,
        'Pluf_Text_Wiki_Block_List' => true,
        'Pluf_Text_Wiki_Block_Pre' => true,
        'Pluf_Text_Wiki_Block_Hr' => true,
        'Pluf_Text_Wiki_Block_Blockquote' => true,
        'Pluf_Text_Wiki_Block_Definition' => true,
        'Pluf_Text_Wiki_Block_Table' => true,
        'Pluf_Text_Wiki_Block_P' => true
    );
 
 
    public $simpletags = array('%%%'=>'<br />', ':-)'=>'<img src="laugh.png" alt=":-)" />');
 
    /**
     * @var   integer   niveau minimum pour les balises titres
     */
 
    public $minHeaderLevel=3;
 
 
    /**
     * indique le sens dans lequel il faut interpreter le nombre de
     * signe de titre
     *
     * true -> ! = titre , !! = sous titre, !!! = sous-sous-titre
     * false-> !!! = titre , !! = sous titre, ! = sous-sous-titre
     */
 
    public $headerOrder=false;
    public $escapeSpecialChars=true;
    public $inlineTagSeparator='|';
    public $blocAttributeTag='��';
 
    public $checkWikiWord = false;
    public $checkWikiWordFunction = null;
 
}
 
// =====================================
// fonctions de g�n�rateur de
// code HTML sp�cifiques � certaines balises inlines
/**
 * Generate a link.
 *
 * If the configuration variable 'wiki_create_action' is set to true and
 * the URL starts with '/' and does not contains a dot '.' an action is
 * created out of it, with 'app_base' as the base url.
 */
function Pluf_Text_Wiki_Configuration_buildlink($contents, $attr)
{
    $cnt = count($contents);
    $attribut = '';
    if ($cnt == 0) return '[]';
    if ($cnt == 1) {
        $contents[1] = $contents[0];
        if (strlen($contents[0]) > 40) {
            $contents[0] = substr($contents[0], 0, 40).'(..)';
        }
        $cnt = 2;
    }
    if ($cnt > count($attr)) {
        $cnt = count($attr)+1;
    }
    if (strpos($contents[1], 'javascript:') !== false) {
        // for security reason
        $contents[1] = '#';
    }
    if ('/' == $contents[1]{0} and false === strpos($contents[1], '.')) {
        if (true === Pluf::f('wiki_create_action')) {
            $murl = new Pluf_HTTP_URL();
            $contents[1] = Pluf::f('app_base').$murl->generate($contents[1]);
        }
    }
    for ($i=1; $i<$cnt; $i++) {
        $attribut .= ' '.$attr[$i-1].'="'.$contents[$i].'"';
    }
    return '<a'.$attribut.'>'.$contents[0].'</a>';
}
 
function Pluf_Text_Wiki_Configuration_buildanchor($contents, $attr)
{
   return '<a name="'.$contents[0].'"></a>';
}
 
function Pluf_Text_Wiki_Configuration_builddummie($contents, $attr)
{
   return (isset($contents[0])?$contents[0]:'');
}
 
function Pluf_Text_Wiki_Configuration_buildimage($contents, $attr)
{
   $cnt=count($contents);
   $attribut='';
   if($cnt > 4) $cnt=4;
   switch($cnt){
      case 4:
         $attribut.=' longdesc="'.$contents[3].'"';
      case 3:
         if($contents[2]=='l' ||$contents[2]=='L' || $contents[2]=='g' || $contents[2]=='G')
            $attribut.=' style="float:left;"';
         elseif($contents[2]=='r' ||$contents[2]=='R' || $contents[2]=='d' || $contents[2]=='D')
            $attribut.=' style="float:right;"';
      case 2:
         $attribut.=' alt="'.$contents[1].'"';
      case 1:
      default:
         $attribut.=' src="'.$contents[0].'"';
         if($cnt == 1) $attribut.=' alt=""';
   }
   return '<img'.$attribut.' />';
 
}

Archive Download this file

Branches

Number of commits:
Page rendered in 0.09196s using 11 queries.