Changeset 93621 in spip-zone
- Timestamp:
- Dec 13, 2015, 11:51:42 AM (5 years ago)
- Location:
- _core_/plugins/porte_plume
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
_core_/plugins/porte_plume/action/porte_plume_previsu.php
r91618 r93621 2 2 /** 3 3 * Gestion de l'action porte_plume_previsu 4 * 4 * 5 5 * @plugin Porte Plume pour SPIP 6 6 * @license GPL … … 8 8 */ 9 9 10 if (!defined("_ECRIRE_INC_VERSION")) return; 10 if (!defined("_ECRIRE_INC_VERSION")) { 11 return; 12 } 11 13 12 14 /** … … 29 31 // mais il faut avoir le droit de previsualiser 30 32 // (par defaut le droit d'aller dans ecrire/) 31 if (!autoriser('previsualiser', 'porteplume'))33 if (!autoriser('previsualiser', 'porteplume')) { 32 34 $contexte = array(); 35 } 33 36 34 37 echo recuperer_fond('prive/porte_plume_preview', $contexte); -
_core_/plugins/porte_plume/barre_outils/edition.php
r91618 r93621 2 2 /** 3 3 * Déclaration de la barre d'outil d'édition de SPIP 4 * 4 * 5 5 * @plugin Porte Plume pour SPIP 6 6 * @license GPL 7 7 * @package SPIP\PortePlume\BarreOutils 8 8 */ 9 if (!defined("_ECRIRE_INC_VERSION")) return; 9 if (!defined("_ECRIRE_INC_VERSION")) { 10 return; 11 } 10 12 11 13 … … 15 17 * @return Barre_outils La barre d'outil 16 18 */ 17 function barre_outils_edition() {19 function barre_outils_edition() { 18 20 $set = new Barre_outils(array( 19 'nameSpace' 21 'nameSpace' => 'edition', 20 22 #'previewAutoRefresh'=> true, 21 23 #'previewParserPath' => url_absolue(generer_url_public('preview')), 22 'onShiftEnter' => array('keepDefault'=>false, 'replaceWith'=>"\n_ "),23 'onCtrlEnter' => array('keepDefault'=>false, 'replaceWith'=>"\n\n"),24 'onShiftEnter' => array('keepDefault' => false, 'replaceWith' => "\n_ "), 25 'onCtrlEnter' => array('keepDefault' => false, 'replaceWith' => "\n\n"), 24 26 // garder les listes si on appuie sur entree 25 'onEnter' => array('keepDefault'=>false, 'selectionType'=>'return', 'replaceWith'=>"\n"),27 'onEnter' => array('keepDefault' => false, 'selectionType' => 'return', 'replaceWith' => "\n"), 26 28 // Utile quand on saisi du code, mais pas accessible ! 27 29 #'onTab' => array('keepDefault'=>false, 'replaceWith'=>"\t"), 28 'markupSet' 30 'markupSet' => array( 29 31 // H1 - {{{ 30 32 array( 31 "id" => 'header1',32 "name" => _T('barreoutils:barre_intertitre'),33 "key" => "H",34 "className" => "outil_header1", 35 "openWith" => "\n{{{", 33 "id" => 'header1', 34 "name" => _T('barreoutils:barre_intertitre'), 35 "key" => "H", 36 "className" => "outil_header1", 37 "openWith" => "\n{{{", 36 38 "closeWith" => "}}}\n", 37 "display" 39 "display" => true, 38 40 "selectionType" => "line", 39 41 ), 40 42 // Bold - {{ 41 43 array( 42 "id" 43 "name" => _T('barreoutils:barre_gras'),44 "key" => "B",45 "className" => "outil_bold", 44 "id" => 'bold', 45 "name" => _T('barreoutils:barre_gras'), 46 "key" => "B", 47 "className" => "outil_bold", 46 48 "replaceWith" => "function(h){ return espace_si_accolade(h, '{{', '}}');}", 47 49 //"openWith" => "{{", 48 50 //"closeWith" => "}}", 49 "display" 51 "display" => true, 50 52 "selectionType" => "word", 51 53 ), 52 54 // Italic - { 53 55 array( 54 "id" 55 "name" => _T('barreoutils:barre_italic'),56 "key" => "I",57 "className" => "outil_italic", 56 "id" => 'italic', 57 "name" => _T('barreoutils:barre_italic'), 58 "key" => "I", 59 "className" => "outil_italic", 58 60 "replaceWith" => "function(h){ return espace_si_accolade(h, '{', '}');}", 59 61 //"openWith" => "{", 60 62 //"closeWith" => "}", 61 "display" 62 "selectionType" => "word", 63 ), 64 63 "display" => true, 64 "selectionType" => "word", 65 ), 66 65 67 // montrer une suppression 66 68 array( 67 "id" 68 "name" 69 "className" => "outil_stroke_through", 70 "openWith" => "<del>", 69 "id" => 'stroke_through', 70 "name" => _T('barreoutils:barre_barre'), // :-) 71 "className" => "outil_stroke_through", 72 "openWith" => "<del>", 71 73 "closeWith" => "</del>", 72 "display" 73 "selectionType" => "word", 74 ), 75 74 "display" => true, 75 "selectionType" => "word", 76 ), 77 76 78 // listes -* 77 79 array( 78 "id" 79 "name" => _T('barreoutils:barre_liste_ul'),80 "className" => "outil_liste_ul", 81 "replaceWith" => "function(h){ return outil_liste(h, '*');}", 82 "display" 80 "id" => 'liste_ul', 81 "name" => _T('barreoutils:barre_liste_ul'), 82 "className" => "outil_liste_ul", 83 "replaceWith" => "function(h){ return outil_liste(h, '*');}", 84 "display" => true, 83 85 "selectionType" => "line", 84 86 "forceMultiline" => true, 85 "dropMenu" 87 "dropMenu" => array( 86 88 // liste -# 87 89 array( 88 "id" 89 "name" => _T('barreoutils:barre_liste_ol'),90 "className" => "outil_liste_ol", 91 "replaceWith" => "function(h){ return outil_liste(h, '#');}", 92 "display" 90 "id" => 'liste_ol', 91 "name" => _T('barreoutils:barre_liste_ol'), 92 "className" => "outil_liste_ol", 93 "replaceWith" => "function(h){ return outil_liste(h, '#');}", 94 "display" => true, 93 95 "selectionType" => "line", 94 96 "forceMultiline" => true, … … 96 98 // desindenter 97 99 array( 98 "id" 99 "name" => _T('barreoutils:barre_desindenter'),100 "className" => "outil_desindenter", 101 "replaceWith" => "function(h){return outil_desindenter(h);}", 102 "display" 100 "id" => 'desindenter', 101 "name" => _T('barreoutils:barre_desindenter'), 102 "className" => "outil_desindenter", 103 "replaceWith" => "function(h){return outil_desindenter(h);}", 104 "display" => true, 103 105 "selectionType" => "line", 104 106 "forceMultiline" => true, … … 106 108 // indenter 107 109 array( 108 "id" 109 "name" => _T('barreoutils:barre_indenter'),110 "className" => "outil_indenter", 111 "replaceWith" => "function(h){return outil_indenter(h);}", 112 "display" 110 "id" => 'indenter', 111 "name" => _T('barreoutils:barre_indenter'), 112 "className" => "outil_indenter", 113 "replaceWith" => "function(h){return outil_indenter(h);}", 114 "display" => true, 113 115 "selectionType" => "line", 114 116 "forceMultiline" => true, … … 122 124 "id" => "sepLink", // trouver un nom correct ! 123 125 "separator" => "---------------", 124 "display" 126 "display" => true, 125 127 ), 126 128 // lien spip 127 129 array( 128 "id" 129 "name" 130 "key" => "L",131 "className" => "outil_link",132 "openWith" => "[",133 "closeWith" => "->[!["._T('barreoutils:barre_lien_input')."]!]]",134 "display" 130 "id" => 'link', 131 "name" => _T('barreoutils:barre_lien'), 132 "key" => "L", 133 "className" => "outil_link", 134 "openWith" => "[", 135 "closeWith" => "->[![" . _T('barreoutils:barre_lien_input') . "]!]]", 136 "display" => true, 135 137 ), 136 138 // note en bas de page spip 137 139 array( 138 "id" 139 "name" 140 "className" => "outil_notes",141 "openWith" => "[[",142 "closeWith" 143 "display" 144 "selectionType" => "word", 145 ), 146 147 140 "id" => 'notes', 141 "name" => _T('barreoutils:barre_note'), 142 "className" => "outil_notes", 143 "openWith" => "[[", 144 "closeWith" => "]]", 145 "display" => true, 146 "selectionType" => "word", 147 ), 148 149 148 150 // separation 149 151 array( 150 152 "id" => "sepGuillemets", 151 153 "separator" => "---------------", 152 "display" 153 ), 154 154 "display" => true, 155 ), 156 155 157 // quote spip 156 158 // (affichee dans forum) 157 159 array( 158 "id" 159 "name" 160 "key" => "Q",161 "className" => "outil_quote",162 "openWith" => "\n<quote>",163 "closeWith" 164 "display" 165 "selectionType" => "word", 166 "dropMenu" 160 "id" => 'quote', 161 "name" => _T('barreoutils:barre_quote'), 162 "key" => "Q", 163 "className" => "outil_quote", 164 "openWith" => "\n<quote>", 165 "closeWith" => "</quote>\n", 166 "display" => true, 167 "selectionType" => "word", 168 "dropMenu" => array( 167 169 // poesie spip 168 170 array( 169 "id" 170 "name" 171 "className" => "outil_poesie",172 "openWith" => "\n<poesie>",173 "closeWith" 174 "display" 171 "id" => 'barre_poesie', 172 "name" => _T('barreoutils:barre_poesie'), 173 "className" => "outil_poesie", 174 "openWith" => "\n<poesie>", 175 "closeWith" => "</poesie>\n", 176 "display" => true, 175 177 "selectionType" => "line", 176 178 ), … … 179 181 // guillemets 180 182 array( 181 "id" 182 "name" 183 "className" => "outil_guillemets",184 "openWith" => "«",185 "closeWith" 186 "display" 187 "lang" => array('fr','eo','cpf','ar','es'),188 "selectionType" => "word", 189 "dropMenu" 183 "id" => 'guillemets', 184 "name" => _T('barreoutils:barre_guillemets'), 185 "className" => "outil_guillemets", 186 "openWith" => "«", 187 "closeWith" => "»", 188 "display" => true, 189 "lang" => array('fr', 'eo', 'cpf', 'ar', 'es'), 190 "selectionType" => "word", 191 "dropMenu" => array( 190 192 // guillemets internes 191 193 array( 192 "id" 193 "name" 194 "className" => "outil_guillemets_simples",195 "openWith" => "“",196 "closeWith" 197 "display" 198 "lang" => array('fr','eo','cpf','ar','es'),194 "id" => 'guillemets_simples', 195 "name" => _T('barreoutils:barre_guillemets_simples'), 196 "className" => "outil_guillemets_simples", 197 "openWith" => "“", 198 "closeWith" => "”", 199 "display" => true, 200 "lang" => array('fr', 'eo', 'cpf', 'ar', 'es'), 199 201 "selectionType" => "word", 200 202 ), … … 204 206 // guillemets de 205 207 array( 206 "id" 207 "name" 208 "className" => "outil_guillemets_de",209 "openWith" => "„",210 "closeWith" 211 "display" 212 "lang" => array('bg','de','pl','hr','src'),213 "selectionType" => "word", 214 "dropMenu" 208 "id" => 'guillemets_de', 209 "name" => _T('barreoutils:barre_guillemets'), 210 "className" => "outil_guillemets_de", 211 "openWith" => "„", 212 "closeWith" => "“", 213 "display" => true, 214 "lang" => array('bg', 'de', 'pl', 'hr', 'src'), 215 "selectionType" => "word", 216 "dropMenu" => array( 215 217 // guillemets de, simples 216 218 array( 217 "id" 218 "name" 219 "className" => "outil_guillemets_de_simples",220 "openWith" => "‚",221 "closeWith" 222 "display" 223 "lang" => array('bg','de','pl','hr','src'),219 "id" => 'guillemets_de_simples', 220 "name" => _T('barreoutils:barre_guillemets_simples'), 221 "className" => "outil_guillemets_de_simples", 222 "openWith" => "‚", 223 "closeWith" => "‘", 224 "display" => true, 225 "lang" => array('bg', 'de', 'pl', 'hr', 'src'), 224 226 "selectionType" => "word", 225 227 ), … … 229 231 // guillemets autres langues 230 232 array( 231 "id" 232 "name" 233 "className" => "outil_guillemets_simples",234 "openWith" => "“",235 "closeWith" 236 "display" 237 "lang_not" => array('fr','eo','cpf','ar','es','bg','de','pl','hr','src'),238 "selectionType" => "word", 239 "dropMenu" 233 "id" => 'guillemets_autres', 234 "name" => _T('barreoutils:barre_guillemets'), 235 "className" => "outil_guillemets_simples", 236 "openWith" => "“", 237 "closeWith" => "”", 238 "display" => true, 239 "lang_not" => array('fr', 'eo', 'cpf', 'ar', 'es', 'bg', 'de', 'pl', 'hr', 'src'), 240 "selectionType" => "word", 241 "dropMenu" => array( 240 242 // guillemets simples, autres langues 241 243 array( 242 "id" 243 "name" 244 "className" => "outil_guillemets_uniques",245 "openWith" => "‘",246 "closeWith" 247 "display" 248 "lang_not" => array('fr','eo','cpf','ar','es','bg','de','pl','hr','src'),244 "id" => 'guillemets_autres_simples', 245 "name" => _T('barreoutils:barre_guillemets_simples'), 246 "className" => "outil_guillemets_uniques", 247 "openWith" => "‘", 248 "closeWith" => "’", 249 "display" => true, 250 "lang_not" => array('fr', 'eo', 'cpf', 'ar', 'es', 'bg', 'de', 'pl', 'hr', 'src'), 249 251 "selectionType" => "word", 250 252 ), … … 257 259 "id" => "sepCaracteres", 258 260 "separator" => "---------------", 259 "display" 261 "display" => true, 260 262 ), 261 263 // icones clavier 262 264 array( 263 "id" 264 "name" 265 "className" 266 "display" 267 268 "dropMenu" 265 "id" => 'grpCaracteres', 266 "name" => _T('barreoutils:barre_inserer_caracteres'), 267 "className" => 'outil_caracteres', 268 "display" => true, 269 270 "dropMenu" => array( 269 271 // A majuscule accent grave 270 272 array( 271 "id" 272 "name" 273 "className" => "outil_a_maj_grave",274 "replaceWith" 275 "display" 276 "lang" => array('fr','eo','cpf'),273 "id" => 'A_grave', 274 "name" => _T('barreoutils:barre_a_accent_grave'), 275 "className" => "outil_a_maj_grave", 276 "replaceWith" => "À", 277 "display" => true, 278 "lang" => array('fr', 'eo', 'cpf'), 277 279 ), 278 280 // E majuscule accent aigu 279 281 array( 280 "id" 281 "name" 282 "className" => "outil_e_maj_aigu",283 "replaceWith" 284 "display" 285 "lang" => array('fr','eo','cpf'),282 "id" => 'E_aigu', 283 "name" => _T('barreoutils:barre_e_accent_aigu'), 284 "className" => "outil_e_maj_aigu", 285 "replaceWith" => "É", 286 "display" => true, 287 "lang" => array('fr', 'eo', 'cpf'), 286 288 ), 287 289 // E majuscule accent grave 288 290 array( 289 "id" 290 "name" 291 "className" 291 "id" => 'E_grave', 292 "name" => _T('barreoutils:barre_e_accent_grave'), 293 "className" => "outil_e_maj_grave", 292 294 "replaceWith" => "È", 293 "display" 294 "lang" => array('fr','eo','cpf'),295 "display" => true, 296 "lang" => array('fr', 'eo', 'cpf'), 295 297 ), 296 298 // e dans le a 297 299 array( 298 "id" 299 "name" 300 "className" 300 "id" => 'aelig', 301 "name" => _T('barreoutils:barre_ea'), 302 "className" => "outil_aelig", 301 303 "replaceWith" => "æ", 302 "display" 303 "lang" => array('fr','eo','cpf'),304 "display" => true, 305 "lang" => array('fr', 'eo', 'cpf'), 304 306 ), 305 307 // e dans le a majuscule 306 308 array( 307 "id" 308 "name" 309 "className" 309 "id" => 'AElig', 310 "name" => _T('barreoutils:barre_ea_maj'), 311 "className" => "outil_aelig_maj", 310 312 "replaceWith" => "Æ", 311 "display" 312 "lang" => array('fr','eo','cpf'),313 "display" => true, 314 "lang" => array('fr', 'eo', 'cpf'), 313 315 ), 314 316 // oe 315 317 array( 316 "id" 317 "name" 318 "className" => "outil_oe",319 "replaceWith" 320 "display" 321 "lang" 318 "id" => 'oe', 319 "name" => _T('barreoutils:barre_eo'), 320 "className" => "outil_oe", 321 "replaceWith" => "œ", 322 "display" => true, 323 "lang" => array('fr'), 322 324 ), 323 325 // OE 324 326 array( 325 "id" 326 "name" 327 "className" => "outil_oe_maj",328 "replaceWith" 329 "display" 330 "lang" 327 "id" => 'OE', 328 "name" => _T('barreoutils:barre_eo_maj'), 329 "className" => "outil_oe_maj", 330 "replaceWith" => "Œ", 331 "display" => true, 332 "lang" => array('fr'), 331 333 ), 332 334 // c cedille majuscule 333 335 array( 334 "id" 335 "name" 336 "className" 336 "id" => 'Ccedil', 337 "name" => _T('barreoutils:barre_c_cedille_maj'), 338 "className" => "outil_ccedil_maj", 337 339 "replaceWith" => "Ç", 338 "display" 339 "lang" => array('fr','eo','cpf'),340 "display" => true, 341 "lang" => array('fr', 'eo', 'cpf'), 340 342 ), 341 343 // Transformation en majuscule 342 344 array( 343 "id" 344 "name" 345 "className" 345 "id" => 'uppercase', 346 "name" => _T('barreoutils:barre_gestion_cr_changercassemajuscules'), 347 "className" => "outil_uppercase", 346 348 "replaceWith" => 'function(markitup) { return markitup.selection.toUpperCase() }', 347 "display" 348 "lang" => array('fr','en'),349 "display" => true, 350 "lang" => array('fr', 'en'), 349 351 ), 350 352 // Transformation en minuscule 351 353 array( 352 "id" 353 "name" 354 "className" 354 "id" => 'lowercase', 355 "name" => _T('barreoutils:barre_gestion_cr_changercasseminuscules'), 356 "className" => "outil_lowercase", 355 357 "replaceWith" => 'function(markitup) { return markitup.selection.toLowerCase() }', 356 "display" 357 "lang" => array('fr','en'),358 "display" => true, 359 "lang" => array('fr', 'en'), 358 360 ), 359 361 ), … … 362 364 // Groupe de Codes informatiques. 363 365 array( 364 "id" => "sepCode", 365 "separator" => "---------------", 366 "display" => true, 367 ), 368 array( 369 // groupe code et bouton <code> 370 "id" => 'grpCode', 371 "name" => _T('barreoutils:barre_inserer_code'), 372 "className" => 'outil_code', 373 "openWith" => "<code>", 374 "closeWith" => "</code>", 375 "display" => true, 376 "dropMenu" => array( 377 // bouton <cadre> 366 "id" => "sepCode", 367 "separator" => "---------------", 368 "display" => true, 369 ), 370 array( 371 // groupe code et bouton <code> 372 "id" => 'grpCode', 373 "name" => _T('barreoutils:barre_inserer_code'), 374 "className" => 'outil_code', 375 "openWith" => "<code>", 376 "closeWith" => "</code>", 377 "display" => true, 378 "dropMenu" => array( 379 // bouton <cadre> 380 array( 381 "id" => 'cadre', 382 "name" => _T('barreoutils:barre_inserer_cadre'), 383 "className" => 'outil_cadre', 384 "openWith" => "<cadre>\n", 385 "closeWith" => "\n</cadre>", 386 "display" => true, 387 ), 388 ), 389 ), 390 391 /* inutile (origine de markitup et non de spip) 392 393 // separation 378 394 array( 379 "id" => 'cadre', 380 "name" => _T('barreoutils:barre_inserer_cadre'), 381 "className" => 'outil_cadre', 382 "openWith" => "<cadre>\n", 383 "closeWith" => "\n</cadre>", 395 "id" => "sepPreview", // trouver un nom correct ! 396 "separator" => "---------------", 397 "display" => true, 398 ), 399 // clean 400 array( 401 "id" => 'clean', 402 "name" => _T('barreoutils:barre_clean'), 403 "className" => "outil_clean", 404 "replaceWith" => 'function(markitup) { return markitup.selection.replace(/<(.*?)>/g, "") }', 384 405 "display" => true, 385 406 ), 386 ), 387 ), 388 389 /* inutile (origine de markitup et non de spip) 390 391 // separation 392 array( 393 "id" => "sepPreview", // trouver un nom correct ! 394 "separator" => "---------------", 395 "display" => true, 396 ), 397 // clean 398 array( 399 "id" => 'clean', 400 "name" => _T('barreoutils:barre_clean'), 401 "className" => "outil_clean", 402 "replaceWith" => 'function(markitup) { return markitup.selection.replace(/<(.*?)>/g, "") }', 403 "display" => true, 404 ), 405 // preview 406 array( 407 "id" => 'preview', 408 "name" => _T('barreoutils:barre_preview'), 409 "className" => "outil_preview", 410 "call" => "preview", 411 "display" => true, 412 ), 413 */ 414 407 // preview 408 array( 409 "id" => 'preview', 410 "name" => _T('barreoutils:barre_preview'), 411 "className" => "outil_preview", 412 "call" => "preview", 413 "display" => true, 414 ), 415 */ 416 415 417 ), 416 417 'functions'=> "418 419 'functions' => " 418 420 // remplace ou cree -* ou -** ou -# ou -## 419 421 function outil_liste(h, c) { … … 476 478 ", 477 479 )); 478 480 479 481 $set->cacher(array( 480 482 'stroke_through', 481 'clean', 'preview', 483 'clean', 484 'preview', 482 485 )); 483 486 484 487 return $set; 485 488 } 486 487 489 488 490 … … 493 495 * Couples identifiant de bouton => nom de l'image (ou tableau nom, position haut, position bas) 494 496 */ 495 function barre_outils_edition_icones() {497 function barre_outils_edition_icones() { 496 498 return array( 497 499 //'outil_header1' => 'text_heading_1.png', 498 'outil_header1' => array('spt-v1.png', '-10px -226px'), //'intertitre.png'499 'outil_bold' => array('spt-v1.png', '-10px -478px'), //'text_bold.png'500 'outil_italic' => array('spt-v1.png', '-10px -586px'), //'text_italic.png'501 502 'outil_stroke_through' => array('spt-v1.png', '-10px -946px'), //'text_strikethrough.png'503 504 'outil_liste_ul' => array('spt-v1.png', '-10px -622px'), //'text_list_bullets.png'505 'outil_liste_ol' => array('spt-v1.png', '-10px -658px'), //'text_list_numbers.png'506 'outil_indenter' => array('spt-v1.png', '-10px -514px'), //'text_indent.png'507 'outil_desindenter' => array('spt-v1.png', '-10px -550px'), //'text_indent_remove.png'508 500 'outil_header1' => array('spt-v1.png', '-10px -226px'), //'intertitre.png' 501 'outil_bold' => array('spt-v1.png', '-10px -478px'), //'text_bold.png' 502 'outil_italic' => array('spt-v1.png', '-10px -586px'), //'text_italic.png' 503 504 'outil_stroke_through' => array('spt-v1.png', '-10px -946px'), //'text_strikethrough.png' 505 506 'outil_liste_ul' => array('spt-v1.png', '-10px -622px'), //'text_list_bullets.png' 507 'outil_liste_ol' => array('spt-v1.png', '-10px -658px'), //'text_list_numbers.png' 508 'outil_indenter' => array('spt-v1.png', '-10px -514px'), //'text_indent.png' 509 'outil_desindenter' => array('spt-v1.png', '-10px -550px'), //'text_indent_remove.png' 510 509 511 //'outil_quote' => 'text_indent.png', 510 'outil_quote' => array('spt-v1.png', '-10px -442px'), //'quote.png'511 'outil_poesie' => array('spt-v1.png', '-10px -1050px'), //'poesie.png'512 'outil_quote' => array('spt-v1.png', '-10px -442px'), //'quote.png' 513 'outil_poesie' => array('spt-v1.png', '-10px -1050px'), //'poesie.png' 512 514 513 515 //'outil_link' => 'world_link.png', 514 'outil_link' => array('spt-v1.png', '-10px -298px'), //'lien.png'515 'outil_notes' => array('spt-v1.png', '-10px -334px'), //'notes.png'516 517 518 'outil_guillemets' => array('spt-v1.png', '-10px -910px'), //'guillemets.png'519 'outil_guillemets_simples' => array('spt-v1.png', '-10px -802px'), //'guillemets-simples.png'520 'outil_guillemets_de' => array('spt-v1.png', '-10px -766px'), //'guillemets-de.png'521 'outil_guillemets_de_simples' => array('spt-v1.png', '-10px -838px'), //'guillemets-uniques-de.png'522 'outil_guillemets_uniques' => array('spt-v1.png', '-10px -874px'), //'guillemets-uniques.png'523 524 'outil_caracteres' => array('spt-v1.png', '-10px -262px'), //'keyboard.png'525 'outil_a_maj_grave' => array('spt-v1.png','-10px -82px'), //'agrave-maj.png'526 'outil_e_maj_aigu' => array('spt-v1.png','-10px -154px'), //'eacute-maj.png'527 'outil_e_maj_grave' => array('spt-v1.png','-10px -190px'), //'eagrave-maj.png'528 'outil_aelig' => array('spt-v1.png','-10px -46px'), //'aelig.png'529 'outil_aelig_maj' => array('spt-v1.png','-10px -10px'), //'aelig-maj.png'530 'outil_oe' => array('spt-v1.png','-10px -406px'), //'oelig.png'531 'outil_oe_maj' => array('spt-v1.png','-10px -370px'), //'oelig-maj.png'532 'outil_ccedil_maj' => array('spt-v1.png','-10px -118px'), //'ccedil-maj.png'533 'outil_uppercase' => array('spt-v1.png','-10px -730px'), //'text_uppercase.png'534 'outil_lowercase' => array('spt-v1.png','-10px -694px'), //'text_lowercase.png'535 536 'outil_code' => array('spt-v1.png', '-10px -1086px'),537 'outil_cadre' => array('spt-v1.png','-10px -1122px'),538 539 'outil_clean' => array('spt-v1.png', '-10px -982px'), //'clean.png'540 'outil_preview' => array('spt-v1.png', '-10px -1018px'), //'eye.png'516 'outil_link' => array('spt-v1.png', '-10px -298px'), //'lien.png' 517 'outil_notes' => array('spt-v1.png', '-10px -334px'), //'notes.png' 518 519 520 'outil_guillemets' => array('spt-v1.png', '-10px -910px'), //'guillemets.png' 521 'outil_guillemets_simples' => array('spt-v1.png', '-10px -802px'), //'guillemets-simples.png' 522 'outil_guillemets_de' => array('spt-v1.png', '-10px -766px'), //'guillemets-de.png' 523 'outil_guillemets_de_simples' => array('spt-v1.png', '-10px -838px'), //'guillemets-uniques-de.png' 524 'outil_guillemets_uniques' => array('spt-v1.png', '-10px -874px'), //'guillemets-uniques.png' 525 526 'outil_caracteres' => array('spt-v1.png', '-10px -262px'), //'keyboard.png' 527 'outil_a_maj_grave' => array('spt-v1.png', '-10px -82px'), //'agrave-maj.png' 528 'outil_e_maj_aigu' => array('spt-v1.png', '-10px -154px'), //'eacute-maj.png' 529 'outil_e_maj_grave' => array('spt-v1.png', '-10px -190px'), //'eagrave-maj.png' 530 'outil_aelig' => array('spt-v1.png', '-10px -46px'), //'aelig.png' 531 'outil_aelig_maj' => array('spt-v1.png', '-10px -10px'), //'aelig-maj.png' 532 'outil_oe' => array('spt-v1.png', '-10px -406px'), //'oelig.png' 533 'outil_oe_maj' => array('spt-v1.png', '-10px -370px'), //'oelig-maj.png' 534 'outil_ccedil_maj' => array('spt-v1.png', '-10px -118px'), //'ccedil-maj.png' 535 'outil_uppercase' => array('spt-v1.png', '-10px -730px'), //'text_uppercase.png' 536 'outil_lowercase' => array('spt-v1.png', '-10px -694px'), //'text_lowercase.png' 537 538 'outil_code' => array('spt-v1.png', '-10px -1086px'), 539 'outil_cadre' => array('spt-v1.png', '-10px -1122px'), 540 541 'outil_clean' => array('spt-v1.png', '-10px -982px'), //'clean.png' 542 'outil_preview' => array('spt-v1.png', '-10px -1018px'), //'eye.png' 541 543 ); 542 544 } -
_core_/plugins/porte_plume/barre_outils/forum.php
r91618 r93621 2 2 /** 3 3 * Déclaration de la barre d'outil de forum de SPIP 4 * 4 * 5 5 * @plugin Porte Plume pour SPIP 6 6 * @license GPL 7 7 * @package SPIP\PortePlume\BarreOutils 8 8 */ 9 if (!defined("_ECRIRE_INC_VERSION")) return; 10 9 if (!defined("_ECRIRE_INC_VERSION")) { 10 return; 11 } 11 12 12 13 … … 16 17 * @return Barre_outils La barre d'outil 17 18 */ 18 function barre_outils_forum() {19 function barre_outils_forum() { 19 20 // on modifie simplement la barre d'edition 20 $edition = charger_fonction('edition', 'barre_outils');21 $edition = charger_fonction('edition', 'barre_outils'); 21 22 $barre = $edition(); 22 23 $barre->nameSpace = 'forum'; 23 24 $barre->cacherTout(); 24 25 $barre->afficher(array( 25 'bold','italic', 26 'sepLink','link', 27 'sepGuillemets', 'quote', 28 'sepCaracteres','guillemets', 'guillemets_simples', 29 'guillemets_de', 'guillemets_de_simples', 30 'guillemets_autres', 'guillemets_autres_simples', 31 'A_grave', 'E_aigu', 'E_grave', 'aelig', 'AElig', 'oe', 'OE', 'Ccedil', 26 'bold', 27 'italic', 28 'sepLink', 29 'link', 30 'sepGuillemets', 31 'quote', 32 'sepCaracteres', 33 'guillemets', 34 'guillemets_simples', 35 'guillemets_de', 36 'guillemets_de_simples', 37 'guillemets_autres', 38 'guillemets_autres_simples', 39 'A_grave', 40 'E_aigu', 41 'E_grave', 42 'aelig', 43 'AElig', 44 'oe', 45 'OE', 46 'Ccedil', 32 47 )); 48 33 49 return $barre; 34 50 } -
_core_/plugins/porte_plume/porte_plume_fonctions.php
r93109 r93621 8 8 */ 9 9 10 if (!defined("_ECRIRE_INC_VERSION")) return; 10 if (!defined("_ECRIRE_INC_VERSION")) { 11 return; 12 } 11 13 12 14 /** … … 19 21 * @package SPIP\PortePlume\BarreOutils 20 22 */ 21 class Barre_outils {23 class Barre_outils { 22 24 /** 23 25 * Identifiant HTML de la barre 26 * 24 27 * @todo À supprimer car non utilisé ! 25 * @var string */ 28 * @var string 29 */ 26 30 public $id = ""; 27 31 28 32 /** 29 33 * Nom de la barre d'outil 30 * @var string */ 34 * 35 * @var string 36 */ 31 37 public $nameSpace = ""; 32 38 33 39 /** 34 40 * Langue 41 * 35 42 * @todo À supprimer car non utilisé ! 36 * @var string */ 43 * @var string 44 */ 37 45 public $lang = ""; 38 46 39 47 /** 40 48 * Option de markitup : rafraîchir la prévisu ? 49 * 41 50 * @todo À supprimer car non utilisé ! 42 * @var bool */ 51 * @var bool 52 */ 43 53 public $previewAutoRefresh = false; 44 54 45 55 /** 46 56 * Option de markitup : nom de la fonction de prévisu 57 * 47 58 * @todo À supprimer car on le redéfini dans l'appel javascript ! 48 * @var bool */ 59 * @var bool 60 */ 49 61 public $previewParserPath = ""; 50 62 51 63 /** 52 64 * Option de markitup : que faire sur l'appuie de Entrée ? 53 * @var array */ 65 * 66 * @var array 67 */ 54 68 public $onEnter = array(); 55 69 56 70 /** 57 71 * Option de markitup : que faire sur l'appuie de Shift+Entrée ? 72 * 58 73 * @example array('keepDefault'=>false, 'replaceWith'=>"\n_ ") 59 * @var array */ 74 * @var array 75 */ 60 76 public $onShiftEnter = array(); 61 77 62 78 /** 63 79 * Option de markitup : que faire sur l'appuie de Control+Entrée ? 64 * @var array */ 80 * 81 * @var array 82 */ 65 83 public $onCtrlEnter = array(); 66 84 67 85 /** 68 86 * Option de markitup : que faire sur l'appuie d'une tabulation ? 69 * @var array */ 87 * 88 * @var array 89 */ 70 90 public $onTab = array(); 71 91 72 92 /** 73 93 * Option de markitup : Code JS à exécuter avant une insertion 74 * @var string */ 94 * 95 * @var string 96 */ 75 97 public $beforeInsert = ""; 76 98 77 99 /** 78 100 * Option de markitup : Code JS à exécuter après une insertion 79 * @var string */ 101 * 102 * @var string 103 */ 80 104 public $afterInsert = ""; 81 105 82 106 /** 83 107 * Description des outils/boutons et leurs sous boutons éventuels 84 * @var array */ 108 * 109 * @var array 110 */ 85 111 public $markupSet = array(); 86 112 … … 88 114 * Fonctions JS supplémentaires à écrire après la déclaration JSON 89 115 * des outils. Ces fonctions peuvent servir aux boutons. 90 * @var string */ 116 * 117 * @var string 118 */ 91 119 public $functions = ""; 92 120 93 121 /** 94 122 * Liste des paramètres valides pour une description d'outils (markupSet) 95 * @var array */ 123 * 124 * @var array 125 */ 96 126 private $_liste_params_autorises = array( 97 127 … … 99 129 'openWith', 100 130 'closeWith', 101 'openBlockWith', // sur multiline, avant les lignes selectionnees 102 'closeBlockWith', // sur multiline, apres les lignes selectionnees 103 'placeHolder', // remplace par ce texte lorsqu'il n'y a pas de selection 104 105 'beforeInsert', // avant l'insertion 106 'afterInsert', // apres l'insertion 131 'openBlockWith', 132 // sur multiline, avant les lignes selectionnees 133 'closeBlockWith', 134 // sur multiline, apres les lignes selectionnees 135 'placeHolder', 136 // remplace par ce texte lorsqu'il n'y a pas de selection 137 138 'beforeInsert', 139 // avant l'insertion 140 'afterInsert', 141 // apres l'insertion 107 142 'beforeMultiInsert', 108 143 'afterMultiInsert', 109 144 110 'dropMenu', // appelle un sous menu 111 112 'name', // nom affiche au survol 113 'key', // raccourcis clavier 114 'className', // classe css utilisee 115 'lang', // langues dont le bouton doit apparaitre - array 116 'lang_not', // langues dont le bouton ne doit pas apparaitre - array 117 'selectionType', // '','word','line' : type de selection (normale, aux mots les plus proches, a la ligne la plus proche) 118 'multiline', // open/close sur chaque ligne (mais replace est applique sur l'ensemble de la selection) 119 'forceMultiline', // pour faire comme si on faisait systematiquement un control+shift (et replace est applique sur chaque ligne de la selection) 145 'dropMenu', 146 // appelle un sous menu 147 148 'name', 149 // nom affiche au survol 150 'key', 151 // raccourcis clavier 152 'className', 153 // classe css utilisee 154 'lang', 155 // langues dont le bouton doit apparaitre - array 156 'lang_not', 157 // langues dont le bouton ne doit pas apparaitre - array 158 'selectionType', 159 // '','word','line' : type de selection (normale, aux mots les plus proches, a la ligne la plus proche) 160 'multiline', 161 // open/close sur chaque ligne (mais replace est applique sur l'ensemble de la selection) 162 'forceMultiline', 163 // pour faire comme si on faisait systematiquement un control+shift (et replace est applique sur chaque ligne de la selection) 120 164 121 165 'separator', … … 140 184 * @return void 141 185 */ 142 function __construct($params = array()) {143 foreach ($params as $p =>$v) {186 function __construct($params = array()) { 187 foreach ($params as $p => $v) { 144 188 if (isset($this->$p)) { 145 189 // si tableau, on verifie les entrees 146 190 if (is_array($v)) { 147 $v = $this->verif_params($p, $v);191 $v = $this->verif_params($p, $v); 148 192 } 149 193 $this->$p = $v; … … 166 210 function verif_params($nom, $params = array()) { 167 211 // si markupset, on boucle sur les items 168 if (stripos($nom, 'markupSet') !==false) {169 foreach ($params as $i =>$v) {212 if (stripos($nom, 'markupSet') !== false) { 213 foreach ($params as $i => $v) { 170 214 $params[$i] = $this->verif_params($i, $v); 171 215 } 172 } 173 // sinon on teste la validite 216 } // sinon on teste la validite 174 217 else { 175 foreach ($params as $p =>$v) {218 foreach ($params as $p => $v) { 176 219 if (!in_array($p, $this->_liste_params_autorises)) { 177 220 unset($params[$p]); … … 179 222 } 180 223 } 224 181 225 return $params; 182 226 } … … 212 256 * False si l'identifiant cherché n'est pas trouvé 213 257 */ 214 function affecter(&$tableau, $identifiant, $params = array(), $lieu = 'dedans', $plusieurs = false) {258 function affecter(&$tableau, $identifiant, $params = array(), $lieu = 'dedans', $plusieurs = false) { 215 259 static $cle_de_recherche = 'id'; // ou className ? 216 260 217 261 if ($tableau === null) // utile ? 262 { 218 263 $tableau = &$this->markupSet; 219 220 if (!in_array($lieu, array('dedans','avant','apres'))) 264 } 265 266 if (!in_array($lieu, array('dedans', 'avant', 'apres'))) { 221 267 $lieu = 'dedans'; 268 } 222 269 223 270 // present en premiere ligne ? 224 271 $trouve = false; 225 foreach ($tableau as $i => $v) {272 foreach ($tableau as $i => $v) { 226 273 if (isset($v[$cle_de_recherche]) and ($v[$cle_de_recherche] == $identifiant)) { 227 274 $trouve = $i; … … 234 281 // verifier que les insertions sont correctes 235 282 $les_params = ($plusieurs ? $params : array($params)); 236 foreach ($les_params as $i =>$un_params) {283 foreach ($les_params as $i => $un_params) { 237 284 $les_params[$i] = $this->verif_params($identifiant, $un_params); 238 285 } … … 241 288 if ($lieu == 'dedans' && !$plusieurs) { 242 289 return $tableau[$trouve] = array_merge($tableau[$trouve], $les_params[0]); 243 } 244 // avant ou apres, on insere ($params peut etre tableau cle/valeur ou tableau de tableaux cle/valeur) 290 } // avant ou apres, on insere ($params peut etre tableau cle/valeur ou tableau de tableaux cle/valeur) 245 291 elseif ($lieu == 'avant') { 246 292 array_splice($tableau, $trouve, 0, $les_params); 293 247 294 return $params; 248 } 249 elseif ($lieu == 'apres') { 295 } elseif ($lieu == 'apres') { 250 296 array_splice($tableau, $trouve+1, 0, $les_params); 297 251 298 return $params; 252 299 } 253 300 } 301 254 302 return $tableau[$trouve]; 255 303 } 256 304 257 305 // recursivons sinon ! 258 foreach ($tableau as $i => $v) {306 foreach ($tableau as $i => $v) { 259 307 if (is_array($v)) { 260 308 foreach ($v as $m => $n) { 261 if (is_array($n) AND ($r = $this->affecter($tableau[$i][$m], $identifiant, $params, $lieu, $plusieurs))) 309 if (is_array($n) AND ($r = $this->affecter($tableau[$i][$m], $identifiant, $params, $lieu, $plusieurs))) { 262 310 return $r; 263 } 264 } 265 } 311 } 312 } 313 } 314 } 315 266 316 return false; 267 317 } … … 282 332 * false si aucun paramètre à affecter, true sinon. 283 333 */ 284 function affecter_a_tous(&$tableau, $params = array(), $ids = array()) {285 if (!$params) 334 function affecter_a_tous(&$tableau, $params = array(), $ids = array()) { 335 if (!$params) { 286 336 return false; 287 288 if ($tableau === null) 337 } 338 339 if ($tableau === null) { 289 340 $tableau = &$this->markupSet; 341 } 290 342 291 343 $params = $this->verif_params('divers', $params); 292 344 293 345 // merge de premiere ligne 294 foreach ($tableau as $i => &$v) {346 foreach ($tableau as $i => &$v) { 295 347 if (!$ids OR in_array($v['id'], $ids)) { 296 348 $tableau[$i] = array_merge($tableau[$i], $params); … … 301 353 } 302 354 } 355 303 356 return true; 304 357 } … … 321 374 function set($identifiant, $params = array()) { 322 375 // prudence tout de meme a pas tout modifier involontairement (si array) 323 if (!$identifiant) return false; 376 if (!$identifiant) { 377 return false; 378 } 324 379 325 380 if (is_string($identifiant)) { 326 381 return $this->affecter($this->markupSet, $identifiant, $params); 327 } 328 elseif (is_array($identifiant)) { 382 } elseif (is_array($identifiant)) { 329 383 return $this->affecter_a_tous($this->markupSet, $params, $identifiant); 330 384 } 385 331 386 return false; 332 387 } … … 346 401 return $a; 347 402 } 403 348 404 return false; 349 405 } … … 361 417 * array sinon : description de l'identifiant cherché. 362 418 */ 363 function afficher($identifiant) {364 return $this->set($identifiant, array('display'=>true));419 function afficher($identifiant) { 420 return $this->set($identifiant, array('display' => true)); 365 421 } 366 422 … … 377 433 * array sinon : description de l'identifiant cherché. 378 434 */ 379 function cacher($identifiant) {380 return $this->set($identifiant, array('display' =>false));435 function cacher($identifiant) { 436 return $this->set($identifiant, array('display' => false)); 381 437 } 382 438 … … 389 445 * false si aucun paramètre à affecter, true sinon. 390 446 */ 391 function afficherTout() {392 return $this->affecter_a_tous($this->markupSet, array('display' =>true));447 function afficherTout() { 448 return $this->affecter_a_tous($this->markupSet, array('display' => true)); 393 449 } 394 450 … … 400 456 * false si aucun paramètre à affecter, true sinon. 401 457 */ 402 function cacherTout() {403 return $this->affecter_a_tous($this->markupSet, array('display' =>false));458 function cacherTout() { 459 return $this->affecter_a_tous($this->markupSet, array('display' => false)); 404 460 } 405 461 … … 418 474 * False si l'identifiant cherché n'est pas trouvé 419 475 */ 420 function ajouterAvant($identifiant, $params) {476 function ajouterAvant($identifiant, $params) { 421 477 return $this->affecter($this->markupSet, $identifiant, $params, 'avant'); 422 478 } … … 435 491 * False si l'identifiant cherché n'est pas trouvé 436 492 */ 437 function ajouterPlusieursAvant($identifiant, $tableau_params) {493 function ajouterPlusieursAvant($identifiant, $tableau_params) { 438 494 return $this->affecter($this->markupSet, $identifiant, $tableau_params, 'avant', true); 439 495 } … … 452 508 * False si l'identifiant cherché n'est pas trouvé 453 509 */ 454 function ajouterApres($identifiant, $params) {510 function ajouterApres($identifiant, $params) { 455 511 return $this->affecter($this->markupSet, $identifiant, $params, 'apres'); 456 512 } … … 469 525 * False si l'identifiant cherché n'est pas trouvé 470 526 */ 471 function ajouterPlusieursApres($identifiant, $tableau_params) {527 function ajouterPlusieursApres($identifiant, $tableau_params) { 472 528 return $this->affecter($this->markupSet, $identifiant, $tableau_params, 'apres', true); 473 529 } … … 480 536 * @return void 481 537 */ 482 function ajouterFonction($fonction) {483 if (false === strpos($this->functions, $fonction)) {538 function ajouterFonction($fonction) { 539 if (false === strpos($this->functions, $fonction)) { 484 540 $this->functions .= "\n" . $fonction . "\n"; 485 541 } … … 493 549 * @return void 494 550 */ 495 function enlever_elements_non_affiches(&$tableau) {551 function enlever_elements_non_affiches(&$tableau) { 496 552 if ($tableau === null) { // utile ? 497 553 $tableau = &$this->markupSet; … … 502 558 unset($tableau[$p]); 503 559 $tableau = array_values($tableau); // remettre les cles automatiques sinon json les affiche et ça plante. 504 } 505 // sinon, on lance une recursion sur les sous-menus 560 } // sinon, on lance une recursion sur les sous-menus 506 561 else { 507 562 if (isset($v['dropMenu']) and is_array($v['dropMenu'])) { … … 528 583 * Tableau de description des outils 529 584 * @return void 530 **/585 **/ 531 586 function enlever_separateurs(&$tableau) { 532 587 if ($tableau === null) { // utile ? … … 551 606 unset($tableau[$p]); 552 607 $tableau = array_values($tableau); // remettre les cles automatiques sinon json les affiche et ça plante. 553 } 554 // sinon, on lance une recursion sur les sous-menus 608 } // sinon, on lance une recursion sur les sous-menus 555 609 else { 556 610 if (isset($v['dropMenu']) and is_array($v['dropMenu'])) { … … 570 624 */ 571 625 function enlever_parametres_inutiles() { 572 foreach ($this as $p=>$v){626 foreach ($this as $p => $v) { 573 627 if (!$v) { 574 628 if (is_array($v) or is_string($v)) { … … 579 633 } 580 634 } 581 foreach ($this->markupSet as $p=>$v) {582 foreach ($v as $n =>$m) {635 foreach ($this->markupSet as $p => $v) { 636 foreach ($v as $n => $m) { 583 637 if (in_array($n, array('id', 'display'))) { 584 638 unset($this->markupSet[$p][$n]); … … 595 649 * @return string Déclaration json de la barre 596 650 */ 597 function creer_json() {651 function creer_json() { 598 652 $barre = $this; 599 653 $type = $barre->nameSpace; … … 611 665 include_spip('inc/charsets'); 612 666 $json = unicode2charset(html2unicode($json)); 613 return "\n\nbarre_outils_$type = ".$json . "\n\n $fonctions"; 667 668 return "\n\nbarre_outils_$type = " . $json . "\n\n $fonctions"; 614 669 } 615 670 … … 632 687 return 'null'; 633 688 case is_string($var) : 634 if (strtolower(substr(ltrim($var), 0,8))=='function')689 if (strtolower(substr(ltrim($var), 0, 8)) == 'function') { 635 690 return $var; 691 } 692 636 693 return '"' . addcslashes($var, "\"\\\n\r") . '"'; 637 694 case is_bool($var) : … … 639 696 case is_scalar($var) : 640 697 return $var; 641 case is_object( 698 case is_object($var) : 642 699 $var = get_object_vars($var); 643 700 $asso = true; … … 655 712 $sep = ','; 656 713 } 657 return $ret ."}\n"; 714 715 return $ret . "}\n"; 658 716 } else { 659 717 $ret = '['; … … 662 720 $sep = ','; 663 721 } 664 return $ret ."]\n"; 665 } 666 } 722 723 return $ret . "]\n"; 724 } 725 } 726 667 727 return false; 668 728 } … … 683 743 * @return string Déclaration CSS des icones 684 744 */ 685 function barre_outils_css_icones() {745 function barre_outils_css_icones() { 686 746 // recuperer la liste, extraire les icones 687 747 $css = ""; 688 748 689 749 // liste des barres 690 if (!$barres = barre_outils_liste()) 750 if (!$barres = barre_outils_liste()) { 691 751 return null; 752 } 692 753 693 754 // liste des classes css et leur correspondance avec une icone … … 717 778 718 779 // passage en css 719 foreach ($classe2icone as $n =>$i) {720 $pos ="";721 if (is_array($i)) {722 $pos = "background-position:" .end($i);723 724 } 725 if (file_exists($i)) 780 foreach ($classe2icone as $n => $i) { 781 $pos = ""; 782 if (is_array($i)) { 783 $pos = "background-position:" . end($i); 784 $i = reset($i); 785 } 786 if (file_exists($i)) { 726 787 $file = $i; 727 else788 } else { 728 789 $file = find_in_path("icones_barre/$i"); 729 if ($file) 730 $css .= "\n.markItUp .$n>a>em {background-image:url(".protocole_implicite(url_absolue($file)).");$pos}"; 790 } 791 if ($file) { 792 $css .= "\n.markItUp .$n>a>em {background-image:url(" . protocole_implicite(url_absolue($file)) . ");$pos}"; 793 } 731 794 } 732 795 … … 747 810 * La barre d'outil si la fonction a été trouvée, false sinon 748 811 */ 749 function barre_outils_initialiser($set) {812 function barre_outils_initialiser($set) { 750 813 if ($f = charger_fonction($set, 'barre_outils')) { 751 814 // retourne une instance de l'objet Barre_outils 752 815 return $f(); 753 816 } 817 754 818 return false; 755 819 } … … 762 826 * False si on ne trouve aucune barre. 763 827 */ 764 function barre_outils_liste() {828 function barre_outils_liste() { 765 829 static $sets = -1; 766 if ($sets !== -1) 830 if ($sets !== -1) { 767 831 return $sets; 832 } 768 833 769 834 // on recupere l'ensemble des barres d'outils connues 770 if (!$sets = find_all_in_path('barre_outils/','.*[.]php') 771 or !is_array($sets)) { 835 if (!$sets = find_all_in_path('barre_outils/', '.*[.]php') 836 or !is_array($sets) 837 ) { 772 838 spip_log("[Scandale] Porte Plume ne trouve pas de barre d'outils !"); 773 839 $sets = false; 840 774 841 return $sets; 775 842 } 776 843 777 foreach($sets as $fichier=>$adresse) { 778 $sets[$fichier] = substr($fichier,0,-4); // juste le nom 779 } 844 foreach ($sets as $fichier => $adresse) { 845 $sets[$fichier] = substr($fichier, 0, -4); // juste le nom 846 } 847 780 848 return $sets; 781 849 } … … 814 882 if (!strlen($nom_champ) || !isset($table_des_traitements[$nom_champ])) { 815 883 $texte = propre($texte, $connect); 816 } 817 else { 884 } else { 818 885 include_spip('base/abstract_sql'); 819 886 $table = table_objet($type_objet); … … 827 894 // [FIXME] Éviter une notice sur le eval suivant qui ne connait 828 895 // pas la Pile ici. C'est pas tres joli... 829 $Pile = array( 0 => array());896 $Pile = array(0 => array()); 830 897 // remplacer le placeholder %s par le texte fourni 831 898 eval('$texte=' . str_replace('%s', '$texte', $ps) . ';'); -
_core_/plugins/porte_plume/porte_plume_ieconfig.php
r91618 r93621 3 3 /** 4 4 * Déclarations des configurations qui peuvent être sauvegardées 5 * 5 * 6 6 * @plugin Porte Plume pour SPIP 7 7 * @license GPL 8 8 * @package SPIP\PortePlume\Pipelines 9 **/9 **/ 10 10 11 if (!defined("_ECRIRE_INC_VERSION")) return; 11 if (!defined("_ECRIRE_INC_VERSION")) { 12 return; 13 } 12 14 13 15 /** … … 18 20 * @param array $table 19 21 * Déclaration des sauvegardes 20 * @return array 22 * @return array 21 23 * Déclaration des sauvegardes complétées 22 **/23 function porte_plume_ieconfig_metas($table) {24 **/ 25 function porte_plume_ieconfig_metas($table) { 24 26 $table['porte_plume']['titre'] = _T('barreoutils:info_barre_outils_public'); 25 27 $table['porte_plume']['icone'] = 'porte-plume-16.png'; -
_core_/plugins/porte_plume/porte_plume_pipelines.php
r93092 r93621 2 2 /** 3 3 * Déclarations d'autorisations et utilisations de pipelines 4 * 4 * 5 5 * @plugin Porte Plume pour SPIP 6 6 * @license GPL 7 7 * @package SPIP\PortePlume\Pipelines 8 **/8 **/ 9 9 10 if (!defined("_ECRIRE_INC_VERSION")) return; 10 if (!defined("_ECRIRE_INC_VERSION")) { 11 return; 12 } 11 13 12 14 #define('PORTE_PLUME_PUBLIC', true); … … 14 16 /** 15 17 * Fonction du pipeline autoriser. N'a rien à faire 18 * 16 19 * @pipeline autoriser 17 20 */ 18 function porte_plume_autoriser() {}21 function porte_plume_autoriser() { } 19 22 20 23 /** … … 24 27 * 25 28 * @param string $faire Action demandée 26 * @param string $type 27 * @param int $idIdentifiant de l'objet28 * @param array $quiDescription de l'auteur demandant l'autorisation29 * @param array $optOptions de cette autorisation29 * @param string $type Type d'objet sur lequel appliquer l'action 30 * @param int $id Identifiant de l'objet 31 * @param array $qui Description de l'auteur demandant l'autorisation 32 * @param array $opt Options de cette autorisation 30 33 * @return bool true s'il a le droit, false sinon 31 34 */ 32 function autoriser_porteplume_previsualiser_dist($faire, $type, $id, $qui, $opt) {35 function autoriser_porteplume_previsualiser_dist($faire, $type, $id, $qui, $opt) { 33 36 return 34 37 (test_espace_prive() AND autoriser('ecrire')) 35 OR (!test_espace_prive() AND autoriser('afficher_public','porteplume'));38 OR (!test_espace_prive() AND autoriser('afficher_public', 'porteplume')); 36 39 } 37 40 … … 40 43 * 41 44 * @param string $faire Action demandée 42 * @param string $type 43 * @param int $idIdentifiant de l'objet44 * @param array $quiDescription de l'auteur demandant l'autorisation45 * @param array $optOptions de cette autorisation45 * @param string $type Type d'objet sur lequel appliquer l'action 46 * @param int $id Identifiant de l'objet 47 * @param array $qui Description de l'auteur demandant l'autorisation 48 * @param array $opt Options de cette autorisation 46 49 * @return bool true s'il a le droit, false sinon 47 50 */ … … 51 54 return PORTE_PLUME_PUBLIC; 52 55 } 56 53 57 return ($GLOBALS['meta']['barre_outils_public'] !== 'non'); 54 58 55 59 // n'autoriser qu'aux identifies : 56 60 # return $qui['id_auteur'] ? PORTE_PLUME_PUBLIC : false; … … 67 71 * @return string Contenu du head 68 72 */ 69 function porte_plume_insert_head_public($flux) {73 function porte_plume_insert_head_public($flux) { 70 74 include_spip('inc/autoriser'); 71 75 if (autoriser('afficher_public', 'porteplume')) { 72 76 $flux = porte_plume_inserer_head($flux, $GLOBALS['spip_lang']); 73 77 } 78 74 79 return $flux; 75 80 } … … 82 87 * @return string Contenu du head 83 88 */ 84 function porte_plume_insert_head_prive($flux) {89 function porte_plume_insert_head_prive($flux) { 85 90 $js = find_in_path('javascript/porte_plume_forcer_hauteur.js'); 86 $flux = porte_plume_inserer_head($flux, $GLOBALS['spip_lang'], $prive =true)91 $flux = porte_plume_inserer_head($flux, $GLOBALS['spip_lang'], $prive = true) 87 92 . "<script type='text/javascript' src='$js'></script>\n"; 88 93 89 94 return $flux; 90 95 } … … 93 98 * Ajout des scripts du porte-plume au texte (un head) transmis 94 99 * 95 * @param string $flux 96 * @param string $lang 97 * @param bool 100 * @param string $flux Contenu du head 101 * @param string $lang Langue en cours d'utilisation 102 * @param bool $prive Est-ce pour l'espace privé ? 98 103 * @return string Contenu du head complété 99 104 */ 100 function porte_plume_inserer_head($flux, $lang, $prive = false) {105 function porte_plume_inserer_head($flux, $lang, $prive = false) { 101 106 $markitup = find_in_path('javascript/jquery.markitup_pour_spip.js'); 102 107 $js_previsu = find_in_path('javascript/jquery.previsu_spip.js'); 103 108 $js_start = parametre_url(generer_url_public('porte_plume_start.js'), 'lang', $lang); 104 if (defined('_VAR_MODE') AND _VAR_MODE =="recalcul")109 if (defined('_VAR_MODE') AND _VAR_MODE == "recalcul") { 105 110 $js_start = parametre_url($js_start, 'var_mode', 'recalcul'); 111 } 106 112 107 $flux .= 108 109 . 110 . 113 $flux .= 114 "<script type='text/javascript' src='$markitup'></script>\n" 115 . "<script type='text/javascript' src='$js_previsu'></script>\n" 116 . "<script type='text/javascript' src='$js_start'></script>\n"; 111 117 112 118 return $flux; … … 117 123 * 118 124 * @pipeline header_prive_css 119 * @param string $flux 125 * @param string $flux Contenu du head 120 126 * @return string Contenu du head complété 121 127 */ 122 function porte_plume_insert_head_prive_css($flux) {128 function porte_plume_insert_head_prive_css($flux) { 123 129 return porte_plume_insert_head_css($flux, true); 124 130 } … … 128 134 * 129 135 * Appelé aussi depuis le privé avec $prive à true. 130 * 136 * 131 137 * @pipeline insert_head_css 132 * @param string $flux 133 * @param bool 138 * @param string $flux Contenu du head 139 * @param bool $prive Est-ce pour l'espace privé ? 134 140 * @return string Contenu du head complété 135 141 */ 136 function porte_plume_insert_head_css($flux = '', $prive = false) {142 function porte_plume_insert_head_css($flux = '', $prive = false) { 137 143 include_spip('inc/autoriser'); 138 144 // toujours autoriser pour le prive. … … 144 150 $css = direction_css(find_in_path('css/barre_outils.css'), lang_dir()); 145 151 $css_icones = generer_url_public('barre_outils_icones.css'); 146 if (defined('_VAR_MODE') AND _VAR_MODE =="recalcul")152 if (defined('_VAR_MODE') AND _VAR_MODE == "recalcul") { 147 153 $css_icones = parametre_url($css_icones, 'var_mode', 'recalcul'); 154 } 148 155 $flux 149 156 .= "<link rel='stylesheet' type='text/css' media='all' href='$css' />\n" 150 . 157 . "<link rel='stylesheet' type='text/css' media='all' href='$css_icones' />\n"; 151 158 } 159 152 160 return $flux; 153 161 } … … 162 170 * Tableaux des metas et valeurs par défaut 163 171 */ 164 function porte_plume_configurer_liste_metas($metas) {172 function porte_plume_configurer_liste_metas($metas) { 165 173 $metas['barre_outils_public'] = 'oui'; 174 166 175 return $metas; 167 176 } … … 175 184 * @return array Données du pipeline 176 185 */ 177 function porte_plume_affiche_milieu($flux){ 178 if ($flux['args']['exec']=='configurer_avancees') 179 $flux['data'] .= recuperer_fond('prive/squelettes/inclure/configurer',array('configurer'=>'configurer_porte_plume')); 186 function porte_plume_affiche_milieu($flux) { 187 if ($flux['args']['exec'] == 'configurer_avancees') { 188 $flux['data'] .= recuperer_fond('prive/squelettes/inclure/configurer', 189 array('configurer' => 'configurer_porte_plume')); 190 } 180 191 181 192 return $flux; -
_core_/plugins/porte_plume/porte_plume_start.js_fonctions.php
r91618 r93621 3 3 /** 4 4 * Déclarations de fonctions servant à la construction du javascript 5 * 5 * 6 6 * @plugin Porte Plume pour SPIP 7 7 * @license GPL 8 8 * @package SPIP\PortePlume\Javascript 9 **/ 10 if (!defined("_ECRIRE_INC_VERSION")) return; 9 **/ 10 if (!defined("_ECRIRE_INC_VERSION")) { 11 return; 12 } 11 13 12 14 /** 13 15 * Retourne la définition de la barre markitup désignée. 14 16 * (cette déclaration est au format json) 15 * 16 * Deux pipelines 'porte_plume_pre_charger' et 'porte_plume_charger' 17 * 18 * Deux pipelines 'porte_plume_pre_charger' et 'porte_plume_charger' 17 19 * permettent de récuperer l'objet de classe Barre_outil 18 20 * avant son export en json pour modifier des elements. … … 22 24 * @pipeline_appel porte_plume_barre_charger 23 25 * Affiche ou cache certains boutons 24 * 26 * 25 27 * @return string Déclaration json 26 28 */ 27 function porte_plume_creer_json_markitup() {29 function porte_plume_creer_json_markitup() { 28 30 // on recupere l'ensemble des barres d'outils connues 29 31 include_spip('porte_plume_fonctions'); … … 34 36 // 1) On initialise tous les jeux de barres 35 37 $barres = array(); 36 foreach ($sets as $set) {37 if (($barre = barre_outils_initialiser($set)) AND is_object($barre)) 38 foreach ($sets as $set) { 39 if (($barre = barre_outils_initialiser($set)) AND is_object($barre)) { 38 40 $barres[$set] = $barre; 41 } 39 42 } 40 43 … … 48 51 * $barre->ajouterApres('bold',array(params)); 49 52 * $barre->ajouterAvant('bold',array(params)); 50 * 53 * 51 54 * $bold = $barre->get('bold'); 52 55 * $bold['id'] = 'bold2'; … … 66 69 * $barre->afficher('bold'); 67 70 * $barre->cacher('bold'); 68 * 71 * 69 72 * $barre->cacherTout(); 70 73 * $barre->afficher(array('bold','italic','header1')); … … 76 79 // 4 On crée les jsons 77 80 $json = ""; 78 foreach ($barres as $set=>$barre) {81 foreach ($barres as $set => $barre) { 79 82 $json .= $barre->creer_json(); 80 83 } 84 81 85 return $json; 82 86 } -
_core_/plugins/porte_plume/prive/porte_plume_preview_fonctions.php
r91618 r93621 2 2 /** 3 3 * Fonctions pour la prévisualisation 4 * 4 * 5 5 * @plugin Porte Plume pour SPIP 6 6 * @license GPL 7 7 * @package SPIP\PortePlume\Fonctions 8 **/8 **/ 9 9 10 if (!defined('_ECRIRE_INC_VERSION')) return; 10 if (!defined('_ECRIRE_INC_VERSION')) { 11 return; 12 } 11 13 12 14 … … 16 18 * Retourne le charset SQL si on le connait, en priorité 17 19 * sinon, on utilise le charset de l'affichage HTML. 18 * 20 * 19 21 * Cependant, on peut forcer un charset donné avec une constante : 20 22 * define('PORTE_PLUME_PREVIEW_CHARSET','utf-8'); … … 32 34 $charset_sql = 'utf-8'; 33 35 } 36 34 37 return $charset_sql ? $charset_sql : $charset; 35 38 } -
_core_/plugins/porte_plume/tests/barre_outil_markitup.php
r91618 r93621 7 7 require_once('lanceur_spip.php'); 8 8 9 class Test_barre_outil_markitup extends SpipTest {9 class Test_barre_outil_markitup extends SpipTest { 10 10 11 11 var $baseParamsBarre = array(); … … 20 20 21 21 $this->baseParamsBarre = array( 22 'nameSpace' 23 'markupSet' 22 'nameSpace' => 'spip', 23 'markupSet' => array( 24 24 // H1 - {{{ 25 25 array( 26 "id" 27 "name" 28 "key" 26 "id" => 'header1', 27 "name" => _T('barreoutils:barre_intertitre'), 28 "key" => "H", 29 29 "className" => "outil_header1", 30 30 "openWith" => "{{{", 31 31 "closeWith" => "}}}", 32 "display" => true, 33 ))); 32 "display" => true, 33 ) 34 ) 35 ); 34 36 $p = $this->baseParamsBarre; 35 37 $p['markupSet'][1] = array( 36 "id" 37 "name" 38 "key" 38 "id" => 'couleurs', 39 "name" => _T('barreoutils:barre_couleur'), 40 "key" => "C", 39 41 "className" => "outil_couleur", 40 "openWith" 42 "openWith" => '[color=[![Color]!]]', 41 43 "closeWith" => '[/color]', 42 "display" 43 "dropMenu" 44 "display" => true, 45 "dropMenu" => array( 44 46 array( 45 "id" 46 "name" 47 "id" => "couleur_jaune", 48 "name" => 'Yellow', 47 49 "openWith" => '[color=yellow]', 48 50 "closeWith" => '[/color]', 49 51 "className" => "outil_couleur", 50 "display" 52 "display" => true, 51 53 ), 52 54 array( 53 "id" 54 "name" 55 "id" => "couleur_orange", 56 "name" => 'Orange', 55 57 "openWith" => '[color=orange]', 56 58 "closeWith" => '[/color]', 57 59 "className" => "outil_couleur", 58 "display" 60 "display" => true, 59 61 ), 60 62 array( 61 "id" 62 "name" 63 "id" => "couleur_rouge", 64 "name" => 'Red', 63 65 "openWith" => '[color=red]', 64 66 "closeWith" => '[/color]', 65 67 "className" => "outil_couleur", 66 "display" 68 "display" => true, 67 69 ), 68 ), 70 ), 69 71 ); 70 72 $this->baseParamsBarreEtendue = $p; … … 82 84 83 85 84 function testInitialisationBarre() {86 function testInitialisationBarre() { 85 87 // parametres inseres a leur bonne place 86 88 $b = new Barre_outils($this->baseParamsBarre); … … 90 92 } 91 93 92 function testInitialisationBarreEtendue() {94 function testInitialisationBarreEtendue() { 93 95 // parametres inseres a leur bonne place, 94 96 // meme quand il y a des sous-menu d'icones … … 97 99 $this->assertEqual('header1', $b->markupSet[0]['id']); 98 100 $this->assertEqual(7, count($b->markupSet[0])); 99 $this->assertEqual('couleurs', $b->markupSet[1]['id']); 100 $this->assertEqual(3, count($b->markupSet[1]['dropMenu'])); 101 } 102 103 function testOptionsIncorrectesNonIncluses() {101 $this->assertEqual('couleurs', $b->markupSet[1]['id']); 102 $this->assertEqual(3, count($b->markupSet[1]['dropMenu'])); 103 } 104 105 function testOptionsIncorrectesNonIncluses() { 104 106 $p = $this->baseParamsBarre; 105 107 $p['fausseVariable'] = "je ne dois pas m'installer"; … … 117 119 } 118 120 119 function testRecuperationDeParametreAvecGet() {121 function testRecuperationDeParametreAvecGet() { 120 122 // trouver des id de premier niveau 121 123 $p = $this->baseParamsBarre; 122 124 $b = new Barre_outils($p); 123 125 $this->assertEqual($b->get('header1'), $p['markupSet'][0]); 124 126 125 127 // trouver des id de second niveau 126 128 $p = $this->baseParamsBarreEtendue; … … 136 138 } 137 139 138 function testModificationDeParametresAvecSet() {140 function testModificationDeParametresAvecSet() { 139 141 $p = $this->baseParamsBarre; 140 142 $b = new Barre_outils($p); 141 143 $p['markupSet'][0]['name'] = 'New'; 142 144 $r = $p['markupSet'][0]; 143 $x = $b->set('header1', array("name" =>"New"));145 $x = $b->set('header1', array("name" => "New")); 144 146 145 147 $this->assertEqual($r, $x); // set retourne la chaine modifiee complete … … 147 149 148 150 // on ne peut ajouter de mauvais parametres 149 $x = $b->set('header1', array("Je Suis Pas Bon" =>"No no no"));151 $x = $b->set('header1', array("Je Suis Pas Bon" => "No no no")); 150 152 $this->assertEqual($r, $x); // set retourne la chaine modifiee complete 151 $this->assertEqual($r, $b->get('header1')); 152 } 153 154 function testAjoutDeParametresApres() {153 $this->assertEqual($r, $b->get('header1')); 154 } 155 156 function testAjoutDeParametresApres() { 155 157 $b = new Barre_outils($this->baseParamsBarre); 156 158 $p = $this->baseParamsBarreEtendue; 157 159 158 160 // ajoutons la couleur apres 159 $b->ajouterApres('header1', $p['markupSet'][1]);161 $b->ajouterApres('header1', $p['markupSet'][1]); 160 162 $this->assertEqual(2, count($b->markupSet)); // 2 boutons de premier niveau maintenant 161 163 $this->assertEqual($b->get('couleurs'), $p['markupSet'][1]); // get renvoie bien le bon ajout 162 164 $this->assertEqual($b->markupSet[1], $p['markupSet'][1]); // et l'ajout est au bon endroit 163 165 164 165 166 167 $b->ajouterApres('couleur_orange',$coul);168 169 170 166 // ajoutons une couleur dans l'ajout 167 $coul = $p['markupSet'][1]['dropMenu'][0]; 168 $coul['id'] = 'couleur_violette'; 169 $b->ajouterApres('couleur_orange', $coul); 170 $this->assertEqual(4, count($b->markupSet[1]['dropMenu'])); // sous boutons 171 $this->assertEqual($b->get('couleur_violette'), $coul); 172 $this->assertEqual($b->markupSet[1]['dropMenu'][2], $coul); // insertion au bon endroit 171 173 172 174 // ajoutons un header2 encore apres 173 175 $p['markupSet'][0]['id'] = 'header2'; 174 $b->ajouterApres('couleurs', $p['markupSet'][0]);176 $b->ajouterApres('couleurs', $p['markupSet'][0]); 175 177 $this->assertEqual(3, count($b->markupSet)); 176 178 $this->assertEqual($b->get('header2'), $p['markupSet'][0]); … … 178 180 } 179 181 180 function testAjoutDeParametresAvant() {182 function testAjoutDeParametresAvant() { 181 183 $b = new Barre_outils($this->baseParamsBarre); 182 184 $p = $this->baseParamsBarreEtendue; 183 185 184 186 // ajoutons la couleur apres 185 $b->ajouterAvant('header1', $p['markupSet'][1]);187 $b->ajouterAvant('header1', $p['markupSet'][1]); 186 188 $this->assertEqual(2, count($b->markupSet)); // 2 boutons de premier niveau maintenant 187 189 $this->assertEqual($b->get('couleurs'), $p['markupSet'][1]); // get renvoie bien le bon ajout 188 190 $this->assertEqual($b->markupSet[0], $p['markupSet'][1]); // et l'ajout est au bon endroit 189 191 190 191 192 193 $b->ajouterAvant('couleur_orange',$coul);194 195 196 192 // ajoutons une couleur dans l'ajout 193 $coul = $p['markupSet'][1]['dropMenu'][0]; 194 $coul['id'] = 'couleur_violette'; 195 $b->ajouterAvant('couleur_orange', $coul); 196 $this->assertEqual(4, count($b->markupSet[0]['dropMenu'])); // sous boutons 197 $this->assertEqual($b->get('couleur_violette'), $coul); 198 $this->assertEqual($b->markupSet[0]['dropMenu'][1], $coul); // insertion au bon endroit 197 199 198 200 // ajoutons un header2 avant le 1 199 201 $p['markupSet'][0]['id'] = 'header2'; 200 $b->ajouterAvant('header1', $p['markupSet'][0]);202 $b->ajouterAvant('header1', $p['markupSet'][0]); 201 203 $this->assertEqual(3, count($b->markupSet)); 202 204 $this->assertEqual($b->get('header2'), $p['markupSet'][0]); … … 204 206 } 205 207 206 function testAfficherEtCacher() {208 function testAfficherEtCacher() { 207 209 $b = new Barre_outils($this->baseParamsBarre); 208 210 $b->cacher('header1'); … … 212 214 } 213 215 214 function testAfficherEtCacherTout() {216 function testAfficherEtCacherTout() { 215 217 $b = new Barre_outils($this->baseParamsBarreEtendue); 216 218 $b->cacherTout(); … … 223 225 } 224 226 225 function testAfficherEtCacherPlusieursBoutons() {226 $b = new Barre_outils($this->baseParamsBarreEtendue); 227 $b->cacher(array('header1', 'couleur_jaune'));227 function testAfficherEtCacherPlusieursBoutons() { 228 $b = new Barre_outils($this->baseParamsBarreEtendue); 229 $b->cacher(array('header1', 'couleur_jaune')); 228 230 $this->assertFalse($b->markupSet[0]['display']); 229 231 $this->assertFalse($b->markupSet[1]['dropMenu'][0]['display']); … … 231 233 232 234 $b->cacherTout(); 233 $b->afficher(array('header1', 'couleur_jaune'));235 $b->afficher(array('header1', 'couleur_jaune')); 234 236 $this->assertTrue($b->markupSet[0]['display']); 235 237 $this->assertTrue($b->markupSet[1]['dropMenu'][0]['display']); … … 237 239 } 238 240 239 function testSetAvecIdVideNeDoitRienModifier() {240 $b = new Barre_outils($this->baseParamsBarreEtendue); 241 $b->set(array(), array('display'=>false));241 function testSetAvecIdVideNeDoitRienModifier() { 242 $b = new Barre_outils($this->baseParamsBarreEtendue); 243 $b->set(array(), array('display' => false)); 242 244 $this->assertTrue($b->markupSet[0]['display']); 243 245 $this->assertTrue($b->markupSet[1]['dropMenu'][0]['display']); 244 246 } 245 247 246 function testSetAvecIdArrayDoitModifTousLesIds() {247 $b = new Barre_outils($this->baseParamsBarreEtendue); 248 $b->set(array('header1', 'couleur_jaune'),array('display'=>false));248 function testSetAvecIdArrayDoitModifTousLesIds() { 249 $b = new Barre_outils($this->baseParamsBarreEtendue); 250 $b->set(array('header1', 'couleur_jaune'), array('display' => false)); 249 251 $this->assertFalse($b->markupSet[0]['display']); 250 252 $this->assertFalse($b->markupSet[1]['dropMenu'][0]['display']); … … 252 254 } 253 255 254 function testCreerJson() {256 function testCreerJson() { 255 257 $b = new Barre_outils($this->baseParamsBarre); 256 258 $b->ajouterApres('header1', array( 257 "id"=> 'Caracteres decodes',258 "name"=> "étrange",259 260 "openWith"=> "[fr]",261 "display"=> true,259 "id" => 'Caracteres decodes', 260 "name" => "étrange", 261 "className" => "outil_fr", 262 "openWith" => "[fr]", 263 "display" => true, 262 264 )); 263 265 $json = $b->creer_json(); 264 $this->assertPattern(',barre_outils_spip = {,', $json);265 $this->assertPattern(',\[{"name":",', $json);266 $this->assertNoPattern(',eacute;,', $json);267 } 268 269 function testBoutonsDUneLangue() {266 $this->assertPattern(',barre_outils_spip = {,', $json); 267 $this->assertPattern(',\[{"name":",', $json); 268 $this->assertNoPattern(',eacute;,', $json); 269 } 270 271 function testBoutonsDUneLangue() { 270 272 $b = new Barre_outils($this->baseParamsBarre); 271 273 $ico2 = $ico1 = array( 272 "id"=> 'ico_fr1',273 "name"=> "test apparaissant si langue est le francais",274 275 "openWith"=> "[fr]",276 "lang"=> array("fr"),277 "display"=> true,274 "id" => 'ico_fr1', 275 "name" => "test apparaissant si langue est le francais", 276 "className" => "outil_fr", 277 "openWith" => "[fr]", 278 "lang" => array("fr"), 279 "display" => true, 278 280 ); 279 281 $ico2['id'] = 'ico_fr2'; 280 $ico2['lang'] = array("fr", "en","es");282 $ico2['lang'] = array("fr", "en", "es"); 281 283 282 284 $b->ajouterApres('header1', $ico1); … … 292 294 $this->assertTrue($b->markupSet[1]['display']); 293 295 $b->cacherTout(); 294 $b->afficher(array('ico_fr1', 'ico_fr2'));295 $this->assertTrue($b->markupSet[1]['display']); 296 $b->afficher(array('ico_fr1', 'ico_fr2')); 297 $this->assertTrue($b->markupSet[1]['display']); 296 298 297 299 // la langue est bien transmise au json … … 301 303 302 304 303 function testFonctionsJavacriptDansParametreNeDoitPasEtreEntreguillemetsDansJson() {305 function testFonctionsJavacriptDansParametreNeDoitPasEtreEntreguillemetsDansJson() { 304 306 $b = new Barre_outils($this->baseParamsBarre); 305 307 $clean = array( 306 "id"=> 'clean',307 "name" => _T('barreoutils:barre_clean'),308 "className"=> "outil_clean",309 310 311 "display"=> true,312 308 "id" => 'clean', 309 "name" => _T('barreoutils:barre_clean'), 310 "className" => "outil_clean", 311 // function doit etre echappe 312 "replaceWith" => 'function(markitup) { return markitup.selection.replace(/<(.*?)>/g, "") }', 313 "display" => true, 314 ); 313 315 $b->ajouterApres('header1', $clean); 314 316 $json = $b->creer_json(); 315 317 // pas de :"function(... ..." 316 $this->assertPattern('/:function\(/', $json);317 } 318 319 function testParametreFunctionsDansJson() {318 $this->assertPattern('/:function\(/', $json); 319 } 320 321 function testParametreFunctionsDansJson() { 320 322 $b = new Barre_outils($this->baseParamsBarre); 321 323 $b->functions = "function dido(){}"; … … 328 330 } 329 331 330 function testAjouterFonctions() {332 function testAjouterFonctions() { 331 333 $b = new Barre_outils($this->baseParamsBarre); 332 334 $b->ajouterFonction("function dido(){}"); -
_core_/plugins/porte_plume/tests/lanceur_spip.php
r80808 r93621 5 5 */ 6 6 $remonte = "../"; 7 while (!is_dir($remonte ."ecrire"))7 while (!is_dir($remonte . "ecrire")) { 8 8 $remonte = "../$remonte"; 9 require $remonte.'tests/test.inc'; 9 } 10 require $remonte . 'tests/test.inc'; 10 11 11 12 demarrer_simpletest();
Note: See TracChangeset
for help on using the changeset viewer.