[SPIP] v3.2.1-->v3.2.2
[lhc/web/www.git] / www / ecrire / xml / indenter.php
1 <?php
2
3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
5 * *
6 * Copyright (c) 2001-2019 *
7 * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
8 * *
9 * Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
10 * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
11 \***************************************************************************/
12
13 if (!defined('_ECRIRE_INC_VERSION')) {
14 return;
15 }
16
17 class IndenteurXML {
18
19 // http://code.spip.net/@debutElement
20 public function debutElement($phraseur, $name, $attrs) {
21 xml_debutElement($this, $name, $attrs);
22 }
23
24 // http://code.spip.net/@finElement
25 public function finElement($phraseur, $name) {
26 xml_finElement($this, $name);
27 }
28
29 // http://code.spip.net/@textElement
30 public function textElement($phraseur, $data) {
31 xml_textElement($this, $data);
32 }
33
34 public function piElement($phraseur, $target, $data) {
35 xml_PiElement($this, $target, $data);
36 }
37
38 // http://code.spip.net/@defautElement
39 public function defaultElement($phraseur, $data) {
40 xml_defaultElement($this, $data);
41 }
42
43 // http://code.spip.net/@phraserTout
44 public function phraserTout($phraseur, $data) {
45 xml_parsestring($this, $data);
46 }
47
48 public $depth = "";
49 public $res = "";
50 public $err = array();
51 public $contenu = array();
52 public $ouvrant = array();
53 public $reperes = array();
54 public $entete = '';
55 public $page = '';
56 public $dtc = null;
57 public $sax = null;
58 }
59
60 // http://code.spip.net/@xml_indenter_dist
61 function xml_indenter_dist($page, $apply = false) {
62 $sax = charger_fonction('sax', 'xml');
63 $f = new IndenteurXML();
64 $sax($page, $apply, $f);
65 if (!$f->err) {
66 return $f->entete . $f->res;
67 }
68 spip_log("indentation impossible " . count($f->err) . " erreurs de validation");
69
70 return $f->entete . $f->page;
71 }