Bearsampp 2026.9.23
Loading...
Searching...
No Matches
v2.php
Go to the documentation of this file.
1<?php
18require_once 'PEAR/XMLParser.php';
19require_once 'PEAR/PackageFile/v2.php';
32{
36
37 function setConfig(&$c)
38 {
39 $this->_config = &$c;
40 $this->_registry = &$c->getRegistry();
41 }
42
43 function setLogger(&$l)
44 {
45 $this->_logger = &$l;
46 }
47
54 function _unIndent($str)
55 {
56 // remove leading newlines
57 $str = preg_replace('/^[\r\n]+/', '', $str);
58 // find whitespace at the beginning of the first line
59 $indent_len = strspn($str, " \t");
60 $indent = substr($str, 0, $indent_len);
61 $data = '';
62 // remove the same amount of whitespace from following lines
63 foreach (explode("\n", $str) as $line) {
64 if (substr($line, 0, $indent_len) == $indent) {
65 $data .= substr($line, $indent_len) . "\n";
66 } else {
67 $data .= $line . "\n";
68 }
69 }
70 return $data;
71 }
72
79 function postProcess($data, $element)
80 {
81 if ($element == 'notes') {
82 return trim($this->_unIndent($data));
83 }
84 return trim($data);
85 }
86
95 function parse($data, $file = null, $archive = false, $class = 'PEAR_PackageFile_v2')
96 {
97 if (PEAR::isError($err = parent::parse($data))) {
98 return $err;
99 }
100
101 $ret = new $class;
102 $ret->encoding = $this->encoding;
103 $ret->setConfig($this->_config);
104 if (isset($this->_logger)) {
105 $ret->setLogger($this->_logger);
106 }
107
108 $ret->fromArray($this->_unserializedData);
109 $ret->setPackagefile($file, $archive);
110 return $ret;
111 }
112}
parse($data, $file=null, $archive=false, $class='PEAR_PackageFile_v2')
Definition v2.php:95
postProcess($data, $element)
Definition v2.php:79